skybridge 0.0.0-dev.ff4b4a2 → 0.0.0-dev.fff2bae
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -15
- package/dist/cli/detect-port.d.ts +18 -0
- package/dist/cli/detect-port.js +61 -0
- package/dist/cli/detect-port.js.map +1 -0
- package/dist/cli/header.js +1 -1
- package/dist/cli/header.js.map +1 -1
- package/dist/cli/run-command.js.map +1 -1
- package/dist/cli/telemetry.js.map +1 -1
- package/dist/cli/tunnel-control-server.d.ts +9 -0
- package/dist/cli/tunnel-control-server.js +31 -0
- package/dist/cli/tunnel-control-server.js.map +1 -0
- package/dist/cli/tunnel-control-server.test.js +39 -0
- package/dist/cli/tunnel-control-server.test.js.map +1 -0
- package/dist/cli/tunnel-handler.d.ts +3 -0
- package/dist/cli/tunnel-handler.js +48 -0
- package/dist/cli/tunnel-handler.js.map +1 -0
- package/dist/cli/tunnel-handler.test.js +105 -0
- package/dist/cli/tunnel-handler.test.js.map +1 -0
- package/dist/cli/tunnel.d.ts +57 -0
- package/dist/cli/tunnel.js +154 -0
- package/dist/cli/tunnel.js.map +1 -0
- package/dist/cli/tunnel.test.d.ts +1 -0
- package/dist/cli/tunnel.test.js +190 -0
- package/dist/cli/tunnel.test.js.map +1 -0
- package/dist/cli/types.d.ts +5 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/use-execute-steps.js.map +1 -1
- package/dist/cli/use-messages.d.ts +3 -0
- package/dist/cli/use-messages.js +11 -0
- package/dist/cli/use-messages.js.map +1 -0
- package/dist/cli/use-nodemon.d.ts +2 -6
- package/dist/cli/use-nodemon.js +30 -18
- package/dist/cli/use-nodemon.js.map +1 -1
- package/dist/cli/use-open-browser.d.ts +1 -0
- package/dist/cli/use-open-browser.js +44 -0
- package/dist/cli/use-open-browser.js.map +1 -0
- package/dist/cli/use-tunnel.d.ts +14 -0
- package/dist/cli/use-tunnel.js +131 -0
- package/dist/cli/use-tunnel.js.map +1 -0
- package/dist/cli/use-typescript-check.d.ts +1 -0
- package/dist/cli/use-typescript-check.js +41 -6
- package/dist/cli/use-typescript-check.js.map +1 -1
- package/dist/commands/build.js +63 -7
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/dev.d.ts +4 -1
- package/dist/commands/dev.js +57 -8
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/start.d.ts +3 -1
- package/dist/commands/start.js +31 -15
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/telemetry/disable.js.map +1 -1
- package/dist/commands/telemetry/enable.js.map +1 -1
- package/dist/commands/telemetry/status.js.map +1 -1
- package/dist/server/asset-base-url-transform-plugin.d.ts +5 -6
- package/dist/server/asset-base-url-transform-plugin.js +9 -10
- package/dist/server/asset-base-url-transform-plugin.js.map +1 -1
- package/dist/server/asset-base-url-transform-plugin.test.js +41 -13
- package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -1
- package/dist/server/content-helpers.d.ts +27 -0
- package/dist/server/content-helpers.js +46 -0
- package/dist/server/content-helpers.js.map +1 -0
- package/dist/server/content-helpers.test.d.ts +1 -0
- package/dist/server/content-helpers.test.js +70 -0
- package/dist/server/content-helpers.test.js.map +1 -0
- package/dist/server/express.d.ts +11 -0
- package/dist/server/express.js +101 -0
- package/dist/server/express.js.map +1 -0
- package/dist/server/express.test.d.ts +1 -0
- package/dist/server/express.test.js +430 -0
- package/dist/server/express.test.js.map +1 -0
- package/dist/server/index.d.ts +5 -3
- package/dist/server/index.js +3 -2
- package/dist/server/index.js.map +1 -1
- package/dist/server/inferUtilityTypes.d.ts +6 -6
- package/dist/server/inferUtilityTypes.js.map +1 -1
- package/dist/server/metric.d.ts +14 -0
- package/dist/server/metric.js +62 -0
- package/dist/server/metric.js.map +1 -0
- package/dist/server/middleware.d.ts +124 -0
- package/dist/server/middleware.js +93 -0
- package/dist/server/middleware.js.map +1 -0
- package/dist/server/middleware.test-d.d.ts +1 -0
- package/dist/server/middleware.test-d.js +75 -0
- package/dist/server/middleware.test-d.js.map +1 -0
- package/dist/server/middleware.test.d.ts +1 -0
- package/dist/server/middleware.test.js +493 -0
- package/dist/server/middleware.test.js.map +1 -0
- package/dist/server/server.d.ts +160 -63
- package/dist/server/server.js +391 -76
- package/dist/server/server.js.map +1 -1
- package/dist/server/templateHelper.d.ts +5 -8
- package/dist/server/templateHelper.js +3 -22
- package/dist/server/templateHelper.js.map +1 -1
- package/dist/server/templates.generated.d.ts +4 -0
- package/dist/server/templates.generated.js +47 -0
- package/dist/server/templates.generated.js.map +1 -0
- package/dist/server/tunnel-proxy-router.d.ts +7 -0
- package/dist/server/tunnel-proxy-router.js +110 -0
- package/dist/server/tunnel-proxy-router.js.map +1 -0
- package/dist/server/tunnel-proxy-router.test.d.ts +1 -0
- package/dist/server/tunnel-proxy-router.test.js +229 -0
- package/dist/server/tunnel-proxy-router.test.js.map +1 -0
- package/dist/server/viewsDevServer.d.ts +14 -0
- package/dist/server/viewsDevServer.js +45 -0
- package/dist/server/viewsDevServer.js.map +1 -0
- package/dist/test/utils.d.ts +13 -21
- package/dist/test/utils.js +42 -37
- package/dist/test/utils.js.map +1 -1
- package/dist/test/view.test.d.ts +1 -0
- package/dist/test/view.test.js +523 -0
- package/dist/test/view.test.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/dist/web/bridges/apps-sdk/adaptor.d.ts +9 -7
- package/dist/web/bridges/apps-sdk/adaptor.js +51 -19
- package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -1
- package/dist/web/bridges/apps-sdk/bridge.d.ts +1 -1
- package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
- package/dist/web/bridges/apps-sdk/index.d.ts +1 -1
- package/dist/web/bridges/apps-sdk/index.js.map +1 -1
- package/dist/web/bridges/apps-sdk/types.d.ts +30 -14
- package/dist/web/bridges/apps-sdk/types.js.map +1 -1
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
- package/dist/web/bridges/get-adaptor.js.map +1 -1
- package/dist/web/bridges/index.js.map +1 -1
- package/dist/web/bridges/mcp-app/adaptor.d.ts +21 -9
- package/dist/web/bridges/mcp-app/adaptor.js +142 -64
- package/dist/web/bridges/mcp-app/adaptor.js.map +1 -1
- package/dist/web/bridges/mcp-app/bridge.d.ts +13 -30
- package/dist/web/bridges/mcp-app/bridge.js +43 -196
- package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
- package/dist/web/bridges/mcp-app/index.js.map +1 -1
- package/dist/web/bridges/mcp-app/types.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +5 -3
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js +2 -2
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -41
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
- package/dist/web/bridges/types.d.ts +26 -13
- package/dist/web/bridges/types.js.map +1 -1
- package/dist/web/bridges/use-host-context.js.map +1 -1
- package/dist/web/components/modal-provider.js +3 -5
- package/dist/web/components/modal-provider.js.map +1 -1
- package/dist/web/create-store.js +17 -3
- package/dist/web/create-store.js.map +1 -1
- package/dist/web/create-store.test.js +23 -20
- package/dist/web/create-store.test.js.map +1 -1
- package/dist/web/data-llm.d.ts +1 -1
- package/dist/web/data-llm.js +3 -3
- package/dist/web/data-llm.js.map +1 -1
- package/dist/web/data-llm.test.js +33 -30
- package/dist/web/data-llm.test.js.map +1 -1
- package/dist/web/generate-helpers.d.ts +20 -18
- package/dist/web/generate-helpers.js +20 -18
- package/dist/web/generate-helpers.js.map +1 -1
- package/dist/web/generate-helpers.test-d.js +26 -26
- package/dist/web/generate-helpers.test-d.js.map +1 -1
- package/dist/web/generate-helpers.test.js.map +1 -1
- package/dist/web/helpers/state.d.ts +2 -2
- package/dist/web/helpers/state.js +11 -11
- package/dist/web/helpers/state.js.map +1 -1
- package/dist/web/helpers/state.test.js +9 -9
- package/dist/web/helpers/state.test.js.map +1 -1
- package/dist/web/hooks/index.d.ts +2 -2
- package/dist/web/hooks/index.js +1 -1
- package/dist/web/hooks/index.js.map +1 -1
- package/dist/web/hooks/test/utils.js +4 -0
- package/dist/web/hooks/test/utils.js.map +1 -1
- package/dist/web/hooks/use-call-tool.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test-d.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test.js +0 -4
- package/dist/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/web/hooks/use-display-mode.d.ts +3 -3
- package/dist/web/hooks/use-display-mode.js.map +1 -1
- package/dist/web/hooks/use-display-mode.test-d.d.ts +1 -0
- package/dist/web/hooks/use-display-mode.test-d.js +8 -0
- package/dist/web/hooks/use-display-mode.test-d.js.map +1 -0
- package/dist/web/hooks/use-display-mode.test.js.map +1 -1
- package/dist/web/hooks/use-files.d.ts +2 -1
- package/dist/web/hooks/use-files.js +1 -0
- package/dist/web/hooks/use-files.js.map +1 -1
- package/dist/web/hooks/use-files.test.js +27 -3
- package/dist/web/hooks/use-files.test.js.map +1 -1
- package/dist/web/hooks/use-layout.js.map +1 -1
- package/dist/web/hooks/use-layout.test.js +3 -3
- package/dist/web/hooks/use-layout.test.js.map +1 -1
- package/dist/web/hooks/use-open-external.d.ts +3 -1
- package/dist/web/hooks/use-open-external.js +1 -1
- package/dist/web/hooks/use-open-external.js.map +1 -1
- package/dist/web/hooks/use-open-external.test.js +26 -11
- package/dist/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/web/hooks/use-request-modal.d.ts +1 -1
- package/dist/web/hooks/use-request-modal.js +4 -4
- package/dist/web/hooks/use-request-modal.js.map +1 -1
- package/dist/web/hooks/use-request-modal.test.js +5 -1
- package/dist/web/hooks/use-request-modal.test.js.map +1 -1
- package/dist/web/hooks/use-send-follow-up-message.d.ts +2 -1
- package/dist/web/hooks/use-send-follow-up-message.js +2 -2
- package/dist/web/hooks/use-send-follow-up-message.js.map +1 -1
- package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -1
- package/dist/web/hooks/use-set-open-in-app-url.test.js +5 -11
- package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
- package/dist/web/hooks/use-tool-info.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test.js +1 -1
- package/dist/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/web/hooks/use-user.js +18 -2
- package/dist/web/hooks/use-user.js.map +1 -1
- package/dist/web/hooks/use-user.test.js +29 -1
- package/dist/web/hooks/use-user.test.js.map +1 -1
- package/dist/web/hooks/use-view-state.d.ts +4 -0
- package/dist/web/hooks/use-view-state.js +32 -0
- package/dist/web/hooks/use-view-state.js.map +1 -0
- package/dist/web/hooks/use-view-state.test.d.ts +1 -0
- package/dist/web/hooks/use-view-state.test.js +177 -0
- package/dist/web/hooks/use-view-state.test.js.map +1 -0
- package/dist/web/index.d.ts +1 -2
- package/dist/web/index.js +1 -2
- package/dist/web/index.js.map +1 -1
- package/dist/web/mount-view.d.ts +1 -0
- package/dist/web/{mount-widget.js → mount-view.js} +2 -2
- package/dist/web/mount-view.js.map +1 -0
- package/dist/web/plugin/data-llm.test.js.map +1 -1
- package/dist/web/plugin/plugin.d.ts +4 -1
- package/dist/web/plugin/plugin.js +128 -18
- package/dist/web/plugin/plugin.js.map +1 -1
- package/dist/web/plugin/scan-views.d.ts +16 -0
- package/dist/web/plugin/scan-views.js +88 -0
- package/dist/web/plugin/scan-views.js.map +1 -0
- package/dist/web/plugin/scan-views.test.d.ts +1 -0
- package/dist/web/plugin/scan-views.test.js +99 -0
- package/dist/web/plugin/scan-views.test.js.map +1 -0
- package/dist/web/plugin/transform-data-llm.js +1 -1
- package/dist/web/plugin/transform-data-llm.js.map +1 -1
- package/dist/web/plugin/transform-data-llm.test.js.map +1 -1
- package/dist/web/plugin/validate-view.d.ts +1 -0
- package/dist/web/plugin/validate-view.js +9 -0
- package/dist/web/plugin/validate-view.js.map +1 -0
- package/dist/web/plugin/validate-view.test.d.ts +1 -0
- package/dist/web/plugin/validate-view.test.js +24 -0
- package/dist/web/plugin/validate-view.test.js.map +1 -0
- package/dist/web/proxy.js.map +1 -1
- package/dist/web/types.js.map +1 -1
- package/package.json +44 -30
- package/tsconfig.base.json +33 -0
- package/dist/server/templates/development.hbs +0 -67
- package/dist/server/templates/production.hbs +0 -6
- package/dist/server/widgetsDevServer.d.ts +0 -12
- package/dist/server/widgetsDevServer.js +0 -57
- package/dist/server/widgetsDevServer.js.map +0 -1
- package/dist/test/widget.test.js +0 -255
- package/dist/test/widget.test.js.map +0 -1
- package/dist/web/hooks/use-widget-state.d.ts +0 -4
- package/dist/web/hooks/use-widget-state.js +0 -32
- package/dist/web/hooks/use-widget-state.js.map +0 -1
- package/dist/web/hooks/use-widget-state.test.js +0 -61
- package/dist/web/hooks/use-widget-state.test.js.map +0 -1
- package/dist/web/mount-widget.d.ts +0 -1
- package/dist/web/mount-widget.js.map +0 -1
- /package/dist/{test/widget.test.d.ts → cli/tunnel-control-server.test.d.ts} +0 -0
- /package/dist/{web/hooks/use-widget-state.test.d.ts → cli/tunnel-handler.test.d.ts} +0 -0
package/dist/test/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/test/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD;;GAEG;AACH,MAAM,UAAU,mBAAmB;IAKjC,mCAAmC;IACnC,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;QACE,IAAI,EAAE,kBAAkB;QACxB,OAAO,EAAE,OAAO;KACjB,EACD,EAAE,YAAY,EAAE,EAAE,EA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AAM,UAAU,UAAU,CAAC,GAA2B;IACpD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AAC9B,CAAC","sourcesContent":["import { McpServer as McpServerBase } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { type MockInstance, vi } from \"vitest\";\nimport * as z from \"zod\";\nimport { McpServer, type ViewName } from \"../server/server.js\";\n\nexport function createMockMcpServer(): {\n server: McpServer;\n mockRegisterResource: MockInstance<McpServer[\"registerResource\"]>;\n mockRegisterTool: MockInstance;\n} {\n const server = new McpServer(\n {\n name: \"alpic-openai-app\",\n version: \"0.0.1\",\n },\n { capabilities: {} },\n );\n\n const mockRegisterResource = vi.spyOn(server, \"registerResource\");\n const mockRegisterTool = vi.spyOn(McpServerBase.prototype, \"registerTool\");\n\n return {\n server,\n mockRegisterResource,\n mockRegisterTool,\n };\n}\n\nexport function createTestServer() {\n return new McpServer({ name: \"test-app\", version: \"1.0.0\" }, {})\n .registerTool(\n {\n name: \"search-trip\",\n description: \"Search for trips\",\n inputSchema: {\n destination: z.string(),\n departureDate: z.string().optional(),\n maxPrice: z.number().optional(),\n },\n outputSchema: {\n results: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n price: z.number(),\n }),\n ),\n totalCount: z.number(),\n },\n view: { component: \"search-trip\" as ViewName },\n },\n async ({ destination }) => {\n return {\n content: [{ type: \"text\", text: `Found trips to ${destination}` }],\n structuredContent: {\n results: [{ id: \"1\", name: \"Trip\", price: 1000 }],\n totalCount: 1,\n },\n };\n },\n )\n .registerTool(\n {\n name: \"get-trip-details\",\n description: \"Get trip details\",\n inputSchema: {\n tripId: z.string(),\n },\n outputSchema: {\n name: z.string(),\n description: z.string(),\n images: z.array(z.string()),\n },\n view: { component: \"get-trip-details\" as ViewName },\n },\n async ({ tripId }) => {\n return {\n content: [{ type: \"text\", text: `Details for ${tripId}` }],\n structuredContent: {\n name: \"Trip\",\n description: \"A great trip\",\n images: [\"image1.jpg\"],\n },\n };\n },\n )\n .registerTool(\n {\n name: \"no-input-view\",\n description: \"View with no input\",\n inputSchema: {},\n outputSchema: {},\n view: { component: \"no-input-view\" as ViewName },\n },\n async () => {\n return {\n content: [{ type: \"text\", text: \"No input needed\" }],\n structuredContent: {},\n };\n },\n )\n .registerTool(\n {\n name: \"inferred-output-view\",\n description: \"View with output inferred from callback\",\n inputSchema: {\n query: z.string(),\n },\n view: { component: \"inferred-output-view\" as ViewName },\n },\n async ({ query }) => {\n return {\n content: [{ type: \"text\", text: `Query: ${query}` }],\n structuredContent: {\n inferredResults: [{ id: \"inferred-1\", score: 0.95 }],\n inferredCount: 1,\n },\n };\n },\n )\n .registerTool(\n {\n name: \"calculate-price\",\n description: \"Calculate trip price\",\n inputSchema: {\n tripId: z.string(),\n passengers: z.number(),\n },\n outputSchema: {\n totalPrice: z.number(),\n currency: z.string(),\n },\n },\n async ({ tripId, passengers }) => {\n return {\n content: [{ type: \"text\", text: `Price for ${tripId}` }],\n structuredContent: {\n totalPrice: 1000 * passengers,\n currency: \"USD\",\n },\n };\n },\n )\n .registerTool(\n {\n name: \"inferred-tool\",\n description: \"Tool with output inferred from callback\",\n inputSchema: {\n itemId: z.string(),\n },\n },\n async ({ itemId }) => {\n return {\n content: [{ type: \"text\", text: `Item: ${itemId}` }],\n structuredContent: {\n itemDetails: { name: \"Inferred Item\", available: true },\n fetchedAt: \"2024-01-01\",\n },\n };\n },\n )\n .registerTool(\n {\n name: \"view-with-metadata\",\n description: \"View that returns response metadata\",\n inputSchema: {\n resourceId: z.string(),\n },\n view: { component: \"view-with-metadata\" as ViewName },\n },\n async ({ resourceId }) => {\n return {\n content: [{ type: \"text\", text: `Resource: ${resourceId}` }],\n structuredContent: {\n data: { id: resourceId, loaded: true },\n },\n _meta: {\n requestId: \"req-123\",\n timestamp: 1704067200000,\n cached: false,\n },\n };\n },\n )\n .registerTool(\n {\n name: \"tool-with-metadata\",\n description: \"Tool that returns response metadata\",\n inputSchema: {\n query: z.string(),\n },\n },\n async ({ query }) => {\n return {\n content: [{ type: \"text\", text: `Query: ${query}` }],\n structuredContent: {\n results: [query],\n },\n _meta: {\n executionTime: 150,\n source: \"cache\",\n },\n };\n },\n )\n .registerTool(\n {\n name: \"view-with-mixed-returns\",\n description:\n \"View with mixed return paths (some with _meta, some without)\",\n inputSchema: {\n shouldSucceed: z.boolean(),\n },\n view: { component: \"view-with-mixed-returns\" as ViewName },\n },\n async ({ shouldSucceed }) => {\n if (!shouldSucceed) {\n return {\n content: [{ type: \"text\", text: \"Error occurred\" }],\n structuredContent: { error: \"Something went wrong\" },\n };\n }\n return {\n content: [{ type: \"text\", text: \"Success\" }],\n structuredContent: { data: \"result\" },\n _meta: {\n processedAt: 1704067200000,\n region: \"eu-west-1\",\n },\n };\n },\n );\n}\n\nexport function createMinimalTestServer() {\n return new McpServer({ name: \"test-app\", version: \"1.0.0\" }, {}).registerTool(\n {\n name: \"search-trip\",\n description: \"Search for trips\",\n inputSchema: {\n destination: z.string(),\n },\n outputSchema: {\n results: z.array(z.object({ id: z.string() })),\n },\n view: { component: \"search-trip\" as ViewName },\n },\n async ({ destination }) => {\n return {\n content: [{ type: \"text\", text: `Found trips to ${destination}` }],\n structuredContent: { results: [{ id: \"1\" }] },\n };\n },\n );\n}\n\ninterface InterfaceOutput {\n itemName: string;\n quantity: number;\n}\n\ninterface InterfaceMeta {\n processedBy: string;\n version: number;\n}\n\ninterface InterfaceReturnType {\n content: [{ type: \"text\"; text: string }];\n structuredContent: InterfaceOutput;\n _meta: InterfaceMeta;\n}\n\nexport function createInterfaceTestServer() {\n return new McpServer(\n { name: \"interface-test-app\", version: \"1.0.0\" },\n {},\n ).registerTool(\n {\n name: \"interface-view\" as const,\n description: \"View with interface-typed output\",\n inputSchema: {\n id: z.string(),\n },\n view: { component: \"interface-view\" as ViewName },\n },\n async ({ id }): Promise<InterfaceReturnType> => {\n return {\n content: [{ type: \"text\", text: `Item ${id}` }],\n structuredContent: {\n itemName: \"Test Item\",\n quantity: 42,\n },\n _meta: {\n processedBy: \"test\",\n version: 1,\n },\n };\n },\n );\n}\n\nexport function createMockExtra(\n host: string,\n options?: {\n headers?: Record<string, string | string[]>;\n url?: URL | string;\n },\n) {\n return {\n requestInfo: {\n headers: { host, ...(options?.headers ?? {}) },\n ...(options?.url ? { url: options.url } : {}),\n },\n };\n}\n\nexport function setTestEnv(env: Record<string, string>) {\n Object.assign(process.env, env);\n}\n\nexport function resetTestEnv() {\n delete process.env.NODE_ENV;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi, } from "vitest";
|
|
3
|
+
import { createMockExtra, createMockMcpServer, resetTestEnv, setTestEnv, } from "./utils.js";
|
|
4
|
+
const mockManifest = {
|
|
5
|
+
"skybridge:view:my-view": {
|
|
6
|
+
file: "assets/my-view-abc123.js",
|
|
7
|
+
name: "my-view",
|
|
8
|
+
isEntry: true,
|
|
9
|
+
},
|
|
10
|
+
"skybridge:view:folder-view": {
|
|
11
|
+
file: "assets/folder-view-def456.js",
|
|
12
|
+
name: "folder-view",
|
|
13
|
+
isEntry: true,
|
|
14
|
+
},
|
|
15
|
+
"style.css": { file: "style.css" },
|
|
16
|
+
};
|
|
17
|
+
// Mirrors `McpServer.computeViewVersionParam`. Tests recompute the expected
|
|
18
|
+
// hash from the mocked manifest so they don't hardcode digest output.
|
|
19
|
+
function expectedVersionParam(viewFile, styleFile) {
|
|
20
|
+
const hash = crypto
|
|
21
|
+
.createHash("sha256")
|
|
22
|
+
.update(viewFile)
|
|
23
|
+
.update("\0")
|
|
24
|
+
.update(styleFile)
|
|
25
|
+
.digest("hex")
|
|
26
|
+
.slice(0, 8);
|
|
27
|
+
return `?v=${hash}`;
|
|
28
|
+
}
|
|
29
|
+
const actual = vi.hoisted(() => require("node:fs"));
|
|
30
|
+
vi.mock("node:fs", () => {
|
|
31
|
+
const readFileSyncImpl = (path, ...args) => {
|
|
32
|
+
if (typeof path === "string" && path.includes("manifest.json")) {
|
|
33
|
+
return JSON.stringify(mockManifest);
|
|
34
|
+
}
|
|
35
|
+
return actual.readFileSync(path, ...args);
|
|
36
|
+
};
|
|
37
|
+
const readFileSync = vi.fn(readFileSyncImpl);
|
|
38
|
+
return {
|
|
39
|
+
readFileSync,
|
|
40
|
+
default: {
|
|
41
|
+
readFileSync,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
describe("McpServer.registerTool (unified API)", () => {
|
|
46
|
+
let server;
|
|
47
|
+
let mockRegisterResource;
|
|
48
|
+
let mockRegisterTool;
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
({ server, mockRegisterResource, mockRegisterTool } =
|
|
51
|
+
createMockMcpServer());
|
|
52
|
+
});
|
|
53
|
+
afterEach(() => {
|
|
54
|
+
vi.clearAllMocks();
|
|
55
|
+
resetTestEnv();
|
|
56
|
+
});
|
|
57
|
+
it("should generate correct HTML for development mode", async () => {
|
|
58
|
+
setTestEnv({ NODE_ENV: "development" });
|
|
59
|
+
server.registerTool({
|
|
60
|
+
name: "my-view",
|
|
61
|
+
description: "Test tool",
|
|
62
|
+
view: {
|
|
63
|
+
component: "my-view",
|
|
64
|
+
description: "Test view",
|
|
65
|
+
},
|
|
66
|
+
}, vi.fn());
|
|
67
|
+
const appsSdkResourceCallback = mockRegisterResource.mock
|
|
68
|
+
.calls[0]?.[3];
|
|
69
|
+
expect(appsSdkResourceCallback).toBeDefined();
|
|
70
|
+
const host = "localhost:3000";
|
|
71
|
+
const serverUrl = `http://${host}`;
|
|
72
|
+
const hmrUrl = `ws://${host}`;
|
|
73
|
+
const mockExtra = createMockExtra(host);
|
|
74
|
+
const result = await appsSdkResourceCallback(new URL("ui://views/apps-sdk/my-view.html"), mockExtra);
|
|
75
|
+
expect(mockRegisterTool).toHaveBeenCalled();
|
|
76
|
+
expect(result).toEqual({
|
|
77
|
+
contents: [
|
|
78
|
+
{
|
|
79
|
+
uri: "ui://views/apps-sdk/my-view.html",
|
|
80
|
+
mimeType: "text/html+skybridge",
|
|
81
|
+
text: expect.stringContaining('<div id="root"></div>'),
|
|
82
|
+
_meta: {
|
|
83
|
+
"openai/widgetCSP": {
|
|
84
|
+
resource_domains: [serverUrl],
|
|
85
|
+
connect_domains: [serverUrl, hmrUrl],
|
|
86
|
+
},
|
|
87
|
+
"openai/widgetDomain": serverUrl,
|
|
88
|
+
"openai/widgetDescription": "Test view",
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
});
|
|
93
|
+
expect(result.contents[0]?.text).toContain(`${serverUrl}/assets/@react-refresh`);
|
|
94
|
+
expect(result.contents[0]?.text).toContain(`${serverUrl}/@vite/client`);
|
|
95
|
+
expect(result.contents[0]?.text).toContain(`${serverUrl}/_skybridge/view/my-view`);
|
|
96
|
+
});
|
|
97
|
+
it("should generate correct HTML for production mode", async () => {
|
|
98
|
+
setTestEnv({ NODE_ENV: "production" });
|
|
99
|
+
server.registerTool({
|
|
100
|
+
name: "my-view",
|
|
101
|
+
description: "Test tool",
|
|
102
|
+
view: {
|
|
103
|
+
component: "my-view",
|
|
104
|
+
description: "Test view",
|
|
105
|
+
},
|
|
106
|
+
}, vi.fn());
|
|
107
|
+
const appsSdkResourceCallback = mockRegisterResource.mock
|
|
108
|
+
.calls[0]?.[3];
|
|
109
|
+
expect(appsSdkResourceCallback).toBeDefined();
|
|
110
|
+
const host = "myapp.com";
|
|
111
|
+
const serverUrl = `https://${host}`;
|
|
112
|
+
const mockExtra = createMockExtra(host);
|
|
113
|
+
const versionedUri = `ui://views/apps-sdk/my-view.html${expectedVersionParam("assets/my-view-abc123.js", "style.css")}`;
|
|
114
|
+
const result = await appsSdkResourceCallback(new URL(versionedUri), mockExtra);
|
|
115
|
+
expect(result).toEqual({
|
|
116
|
+
contents: [
|
|
117
|
+
{
|
|
118
|
+
uri: versionedUri,
|
|
119
|
+
mimeType: "text/html+skybridge",
|
|
120
|
+
text: expect.stringContaining('<div id="root"></div>'),
|
|
121
|
+
_meta: {
|
|
122
|
+
"openai/widgetCSP": {
|
|
123
|
+
resource_domains: [serverUrl],
|
|
124
|
+
connect_domains: [serverUrl],
|
|
125
|
+
},
|
|
126
|
+
"openai/widgetDomain": serverUrl,
|
|
127
|
+
"openai/widgetDescription": "Test view",
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
});
|
|
132
|
+
expect(result.contents[0]?.text).not.toContain(`${serverUrl}/assets/@react-refresh`);
|
|
133
|
+
expect(result.contents[0]?.text).not.toContain(`${serverUrl}@vite/client`);
|
|
134
|
+
expect(result.contents[0]?.text).toContain(`${serverUrl}/assets/assets/my-view-abc123.js`);
|
|
135
|
+
expect(result.contents[0]?.text).toContain(`${serverUrl}/assets/style.css`);
|
|
136
|
+
});
|
|
137
|
+
it("should prefer x-alpic-forwarded-url when hashing Claude view domains", async () => {
|
|
138
|
+
setTestEnv({ NODE_ENV: "production" });
|
|
139
|
+
server.registerTool({
|
|
140
|
+
name: "my-view",
|
|
141
|
+
description: "Test tool",
|
|
142
|
+
view: { component: "my-view", description: "Test view" },
|
|
143
|
+
}, vi.fn());
|
|
144
|
+
const extAppsResourceCallback = mockRegisterResource.mock
|
|
145
|
+
.calls[1]?.[3];
|
|
146
|
+
expect(extAppsResourceCallback).toBeDefined();
|
|
147
|
+
const forwardedUrl = "https://everything-3a2c1264.staging.alpic.live/mcp?foo=bar";
|
|
148
|
+
const expectedDomain = `${crypto
|
|
149
|
+
.createHash("sha256")
|
|
150
|
+
.update(forwardedUrl)
|
|
151
|
+
.digest("hex")
|
|
152
|
+
.slice(0, 32)}.claudemcpcontent.com`;
|
|
153
|
+
const result = await extAppsResourceCallback(new URL(`ui://views/ext-apps/my-view.html${expectedVersionParam("assets/my-view-abc123.js", "style.css")}`), createMockExtra("localhost:3000", {
|
|
154
|
+
headers: {
|
|
155
|
+
"user-agent": "Claude-User",
|
|
156
|
+
"x-alpic-forwarded-url": forwardedUrl,
|
|
157
|
+
},
|
|
158
|
+
url: "http://localhost:3000/mcp",
|
|
159
|
+
}));
|
|
160
|
+
expect(result.contents[0]?._meta).toEqual({
|
|
161
|
+
ui: {
|
|
162
|
+
csp: {
|
|
163
|
+
resourceDomains: ["http://localhost:3000"],
|
|
164
|
+
connectDomains: ["http://localhost:3000"],
|
|
165
|
+
baseUriDomains: ["http://localhost:3000"],
|
|
166
|
+
},
|
|
167
|
+
description: "Test view",
|
|
168
|
+
domain: expectedDomain,
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
it("should register resources with correct hostType for both apps-sdk and ext-apps", async () => {
|
|
173
|
+
server.registerTool({
|
|
174
|
+
name: "my-view",
|
|
175
|
+
description: "Test tool",
|
|
176
|
+
view: {
|
|
177
|
+
component: "my-view",
|
|
178
|
+
description: "Test view",
|
|
179
|
+
prefersBorder: true,
|
|
180
|
+
},
|
|
181
|
+
}, vi.fn());
|
|
182
|
+
expect(mockRegisterResource).toHaveBeenCalledTimes(2);
|
|
183
|
+
const appsSdkCallback = mockRegisterResource.mock
|
|
184
|
+
.calls[0]?.[3];
|
|
185
|
+
const host = "localhost:3000";
|
|
186
|
+
const serverUrl = `http://${host}`;
|
|
187
|
+
const hmrUrl = `ws://${host}`;
|
|
188
|
+
const appsSdkResult = await appsSdkCallback(new URL("ui://views/apps-sdk/my-view.html"), createMockExtra(host));
|
|
189
|
+
expect(appsSdkResult).toEqual({
|
|
190
|
+
contents: [
|
|
191
|
+
{
|
|
192
|
+
uri: "ui://views/apps-sdk/my-view.html",
|
|
193
|
+
mimeType: "text/html+skybridge",
|
|
194
|
+
text: expect.stringContaining('<div id="root"></div>'),
|
|
195
|
+
_meta: {
|
|
196
|
+
"openai/widgetCSP": {
|
|
197
|
+
resource_domains: [serverUrl],
|
|
198
|
+
connect_domains: [serverUrl, hmrUrl],
|
|
199
|
+
},
|
|
200
|
+
"openai/widgetDomain": serverUrl,
|
|
201
|
+
"openai/widgetDescription": "Test view",
|
|
202
|
+
"openai/widgetPrefersBorder": true,
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
});
|
|
207
|
+
expect(appsSdkResult.contents[0]?.text).toContain('window.skybridge = { hostType: "apps-sdk", serverUrl: "http://localhost:3000" };');
|
|
208
|
+
const extAppsResourceCallback = mockRegisterResource.mock
|
|
209
|
+
.calls[1]?.[3];
|
|
210
|
+
expect(extAppsResourceCallback).toBeDefined();
|
|
211
|
+
const extAppsResult = await extAppsResourceCallback(new URL("ui://views/ext-apps/my-view.html"), createMockExtra(host));
|
|
212
|
+
expect(extAppsResult).toEqual({
|
|
213
|
+
contents: [
|
|
214
|
+
{
|
|
215
|
+
uri: "ui://views/ext-apps/my-view.html",
|
|
216
|
+
mimeType: "text/html;profile=mcp-app",
|
|
217
|
+
text: expect.stringContaining('<div id="root"></div>'),
|
|
218
|
+
_meta: {
|
|
219
|
+
ui: {
|
|
220
|
+
csp: {
|
|
221
|
+
resourceDomains: [serverUrl],
|
|
222
|
+
connectDomains: [serverUrl, hmrUrl],
|
|
223
|
+
baseUriDomains: [serverUrl],
|
|
224
|
+
},
|
|
225
|
+
domain: serverUrl,
|
|
226
|
+
description: "Test view",
|
|
227
|
+
prefersBorder: true,
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
});
|
|
233
|
+
expect(extAppsResult.contents[0]?.text).toContain('window.skybridge = { hostType: "mcp-app", serverUrl: "http://localhost:3000" };');
|
|
234
|
+
});
|
|
235
|
+
it("should register tool with ui.resourceUri metadata", async () => {
|
|
236
|
+
server.registerTool({
|
|
237
|
+
name: "my-view",
|
|
238
|
+
description: "Test tool",
|
|
239
|
+
view: { component: "my-view", description: "Test view" },
|
|
240
|
+
}, vi.fn());
|
|
241
|
+
expect(mockRegisterTool).toHaveBeenCalledTimes(1);
|
|
242
|
+
const toolCallArgs = mockRegisterTool.mock.calls[0];
|
|
243
|
+
const toolConfig = toolCallArgs?.[1];
|
|
244
|
+
expect(toolConfig._meta).toHaveProperty("ui");
|
|
245
|
+
expect(toolConfig._meta?.ui).toEqual({
|
|
246
|
+
resourceUri: "ui://views/ext-apps/my-view.html",
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
it("should register tool with openai/outputTemplate when apps-sdk only", async () => {
|
|
250
|
+
server.registerTool({
|
|
251
|
+
name: "my-view",
|
|
252
|
+
description: "Test tool",
|
|
253
|
+
view: {
|
|
254
|
+
component: "my-view",
|
|
255
|
+
description: "Test view",
|
|
256
|
+
hosts: ["apps-sdk"],
|
|
257
|
+
},
|
|
258
|
+
}, vi.fn());
|
|
259
|
+
expect(mockRegisterTool).toHaveBeenCalledTimes(1);
|
|
260
|
+
const toolCallArgs = mockRegisterTool.mock.calls[0];
|
|
261
|
+
const toolConfig = toolCallArgs?.[1];
|
|
262
|
+
expect(toolConfig._meta).not.toHaveProperty("ui");
|
|
263
|
+
expect(toolConfig._meta?.["openai/outputTemplate"]).toBe("ui://views/apps-sdk/my-view.html");
|
|
264
|
+
});
|
|
265
|
+
it("should not version view URIs in development", () => {
|
|
266
|
+
server.registerTool({
|
|
267
|
+
name: "my-view",
|
|
268
|
+
description: "Test tool",
|
|
269
|
+
view: { component: "my-view", description: "Test view" },
|
|
270
|
+
}, vi.fn());
|
|
271
|
+
const toolConfig = mockRegisterTool.mock.calls[0]?.[1];
|
|
272
|
+
expect(toolConfig._meta?.["openai/outputTemplate"]).toBe("ui://views/apps-sdk/my-view.html");
|
|
273
|
+
expect(toolConfig._meta?.ui?.resourceUri).toBe("ui://views/ext-apps/my-view.html");
|
|
274
|
+
// The URI registered with the resource handler must match the URI in
|
|
275
|
+
// outputTemplate exactly so the SDK can resolve `resources/read` requests.
|
|
276
|
+
expect(mockRegisterResource.mock.calls[0]?.[1]).toBe("ui://views/apps-sdk/my-view.html");
|
|
277
|
+
expect(mockRegisterResource.mock.calls[1]?.[1]).toBe("ui://views/ext-apps/my-view.html");
|
|
278
|
+
});
|
|
279
|
+
it("should append a stable content hash to view URIs in production", () => {
|
|
280
|
+
setTestEnv({ NODE_ENV: "production" });
|
|
281
|
+
server.registerTool({
|
|
282
|
+
name: "my-view",
|
|
283
|
+
description: "Test tool",
|
|
284
|
+
view: { component: "my-view", description: "Test view" },
|
|
285
|
+
}, vi.fn());
|
|
286
|
+
const expected = expectedVersionParam("assets/my-view-abc123.js", "style.css");
|
|
287
|
+
const toolConfig = mockRegisterTool.mock.calls[0]?.[1];
|
|
288
|
+
expect(toolConfig._meta?.["openai/outputTemplate"]).toBe(`ui://views/apps-sdk/my-view.html${expected}`);
|
|
289
|
+
expect(toolConfig._meta?.ui?.resourceUri).toBe(`ui://views/ext-apps/my-view.html${expected}`);
|
|
290
|
+
expect(mockRegisterResource.mock.calls[0]?.[1]).toBe(`ui://views/apps-sdk/my-view.html${expected}`);
|
|
291
|
+
expect(mockRegisterResource.mock.calls[1]?.[1]).toBe(`ui://views/ext-apps/my-view.html${expected}`);
|
|
292
|
+
});
|
|
293
|
+
it("should produce different version params for views with different bundles", () => {
|
|
294
|
+
setTestEnv({ NODE_ENV: "production" });
|
|
295
|
+
server.registerTool({
|
|
296
|
+
name: "my-view",
|
|
297
|
+
description: "First tool",
|
|
298
|
+
view: { component: "my-view" },
|
|
299
|
+
}, vi.fn());
|
|
300
|
+
server.registerTool({
|
|
301
|
+
name: "folder-view",
|
|
302
|
+
description: "Second tool",
|
|
303
|
+
view: { component: "folder-view" },
|
|
304
|
+
}, vi.fn());
|
|
305
|
+
const myviewTemplate = (mockRegisterTool.mock.calls[0]?.[1])._meta?.["openai/outputTemplate"];
|
|
306
|
+
const folderviewTemplate = (mockRegisterTool.mock.calls[1]?.[1])._meta?.["openai/outputTemplate"];
|
|
307
|
+
expect(myviewTemplate).not.toEqual(folderviewTemplate);
|
|
308
|
+
expect(myviewTemplate).toMatch(/\?v=[0-9a-f]{8}$/);
|
|
309
|
+
expect(folderviewTemplate).toMatch(/\?v=[0-9a-f]{8}$/);
|
|
310
|
+
});
|
|
311
|
+
it("should fall back to bare URI in production when manifest is missing", () => {
|
|
312
|
+
setTestEnv({ NODE_ENV: "production" });
|
|
313
|
+
server.registerTool({
|
|
314
|
+
name: "unknown-view",
|
|
315
|
+
description: "Test tool",
|
|
316
|
+
view: { component: "unknown-view" },
|
|
317
|
+
}, vi.fn());
|
|
318
|
+
const toolConfig = mockRegisterTool.mock.calls[0]?.[1];
|
|
319
|
+
expect(toolConfig._meta?.["openai/outputTemplate"]).toBe("ui://views/apps-sdk/unknown-view.html");
|
|
320
|
+
});
|
|
321
|
+
it("should register tool with ui.resourceUri only when mcp-app only", async () => {
|
|
322
|
+
server.registerTool({
|
|
323
|
+
name: "my-view",
|
|
324
|
+
description: "Test tool",
|
|
325
|
+
view: {
|
|
326
|
+
component: "my-view",
|
|
327
|
+
description: "Test view",
|
|
328
|
+
hosts: ["mcp-app"],
|
|
329
|
+
},
|
|
330
|
+
}, vi.fn());
|
|
331
|
+
expect(mockRegisterTool).toHaveBeenCalledTimes(1);
|
|
332
|
+
const toolCallArgs = mockRegisterTool.mock.calls[0];
|
|
333
|
+
const toolConfig = toolCallArgs?.[1];
|
|
334
|
+
expect(toolConfig._meta).toHaveProperty("ui");
|
|
335
|
+
expect(toolConfig._meta?.ui).toEqual({
|
|
336
|
+
resourceUri: "ui://views/ext-apps/my-view.html",
|
|
337
|
+
});
|
|
338
|
+
expect(toolConfig._meta?.["openai/outputTemplate"]).toBeUndefined();
|
|
339
|
+
});
|
|
340
|
+
it("should inject viewUUID into _meta of tool callback results", async () => {
|
|
341
|
+
const mockToolCallback = vi.fn().mockResolvedValue({
|
|
342
|
+
content: [{ type: "text", text: "result" }],
|
|
343
|
+
structuredContent: { data: "test" },
|
|
344
|
+
});
|
|
345
|
+
server.registerTool({
|
|
346
|
+
name: "my-view",
|
|
347
|
+
description: "Test tool",
|
|
348
|
+
view: { component: "my-view", description: "Test view" },
|
|
349
|
+
}, mockToolCallback);
|
|
350
|
+
const wrappedCallback = mockRegisterTool.mock.calls[0]?.[2];
|
|
351
|
+
expect(wrappedCallback).toBeDefined();
|
|
352
|
+
const result = await wrappedCallback({}, {});
|
|
353
|
+
expect(result._meta).toBeDefined();
|
|
354
|
+
expect(result._meta?.viewUUID).toBeDefined();
|
|
355
|
+
expect(typeof result._meta?.viewUUID).toBe("string");
|
|
356
|
+
expect(result._meta?.viewUUID).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/);
|
|
357
|
+
});
|
|
358
|
+
it("should preserve existing _meta when injecting viewUUID", async () => {
|
|
359
|
+
const mockToolCallback = vi.fn().mockResolvedValue({
|
|
360
|
+
content: [{ type: "text", text: "result" }],
|
|
361
|
+
structuredContent: { data: "test" },
|
|
362
|
+
_meta: { requestId: "req-123", cached: true },
|
|
363
|
+
});
|
|
364
|
+
server.registerTool({
|
|
365
|
+
name: "my-view",
|
|
366
|
+
description: "Test tool",
|
|
367
|
+
view: { component: "my-view", description: "Test view" },
|
|
368
|
+
}, mockToolCallback);
|
|
369
|
+
const wrappedCallback = mockRegisterTool.mock.calls[0]?.[2];
|
|
370
|
+
const result = await wrappedCallback({}, {});
|
|
371
|
+
expect(result._meta?.requestId).toBe("req-123");
|
|
372
|
+
expect(result._meta?.cached).toBe(true);
|
|
373
|
+
expect(result._meta?.viewUUID).toBeDefined();
|
|
374
|
+
});
|
|
375
|
+
it("should generate unique viewUUIDs across calls", async () => {
|
|
376
|
+
const mockToolCallback = vi.fn().mockResolvedValue({
|
|
377
|
+
content: [{ type: "text", text: "result" }],
|
|
378
|
+
structuredContent: {},
|
|
379
|
+
});
|
|
380
|
+
server.registerTool({
|
|
381
|
+
name: "my-view",
|
|
382
|
+
description: "Test tool",
|
|
383
|
+
view: { component: "my-view", description: "Test view" },
|
|
384
|
+
}, mockToolCallback);
|
|
385
|
+
const wrappedCallback = mockRegisterTool.mock.calls[0]?.[2];
|
|
386
|
+
const result1 = await wrappedCallback({}, {});
|
|
387
|
+
const result2 = await wrappedCallback({}, {});
|
|
388
|
+
expect(result1._meta?.viewUUID).not.toBe(result2._meta?.viewUUID);
|
|
389
|
+
});
|
|
390
|
+
it("should enforce one-tool-per-view constraint", () => {
|
|
391
|
+
server.registerTool({
|
|
392
|
+
name: "shake",
|
|
393
|
+
description: "First tool",
|
|
394
|
+
view: { component: "magic-8-ball" },
|
|
395
|
+
}, vi.fn());
|
|
396
|
+
expect(() => {
|
|
397
|
+
server.registerTool({
|
|
398
|
+
name: "shake-v2",
|
|
399
|
+
description: "Second tool",
|
|
400
|
+
view: { component: "magic-8-ball" },
|
|
401
|
+
}, vi.fn());
|
|
402
|
+
}).toThrow('skybridge: view "magic-8-ball" is already used by tool "shake"');
|
|
403
|
+
});
|
|
404
|
+
it("should normalize string content to ContentBlock array", async () => {
|
|
405
|
+
const mockToolCallback = vi.fn().mockResolvedValue({
|
|
406
|
+
content: "Hello world",
|
|
407
|
+
structuredContent: {},
|
|
408
|
+
});
|
|
409
|
+
server.registerTool({
|
|
410
|
+
name: "string-content",
|
|
411
|
+
description: "Test tool",
|
|
412
|
+
view: { component: "string-content" },
|
|
413
|
+
}, mockToolCallback);
|
|
414
|
+
const wrappedCallback = mockRegisterTool.mock.calls[0]?.[2];
|
|
415
|
+
const result = await wrappedCallback({}, {});
|
|
416
|
+
expect(result.content).toEqual([{ type: "text", text: "Hello world" }]);
|
|
417
|
+
});
|
|
418
|
+
it("should normalize single ContentBlock to array", async () => {
|
|
419
|
+
const mockToolCallback = vi.fn().mockResolvedValue({
|
|
420
|
+
content: { type: "text", text: "Single block" },
|
|
421
|
+
structuredContent: {},
|
|
422
|
+
});
|
|
423
|
+
server.registerTool({
|
|
424
|
+
name: "single-block",
|
|
425
|
+
description: "Test tool",
|
|
426
|
+
view: { component: "single-block" },
|
|
427
|
+
}, mockToolCallback);
|
|
428
|
+
const wrappedCallback = mockRegisterTool.mock.calls[0]?.[2];
|
|
429
|
+
const result = await wrappedCallback({}, {});
|
|
430
|
+
expect(result.content).toEqual([{ type: "text", text: "Single block" }]);
|
|
431
|
+
});
|
|
432
|
+
it("should pass through ContentBlock array unchanged", async () => {
|
|
433
|
+
const blocks = [
|
|
434
|
+
{ type: "text", text: "A" },
|
|
435
|
+
{ type: "text", text: "B" },
|
|
436
|
+
];
|
|
437
|
+
const mockToolCallback = vi.fn().mockResolvedValue({
|
|
438
|
+
content: blocks,
|
|
439
|
+
structuredContent: {},
|
|
440
|
+
});
|
|
441
|
+
server.registerTool({
|
|
442
|
+
name: "array-content",
|
|
443
|
+
description: "Test tool",
|
|
444
|
+
view: { component: "array-content" },
|
|
445
|
+
}, mockToolCallback);
|
|
446
|
+
const wrappedCallback = mockRegisterTool.mock.calls[0]?.[2];
|
|
447
|
+
const result = await wrappedCallback({}, {});
|
|
448
|
+
expect(result.content).toEqual(blocks);
|
|
449
|
+
});
|
|
450
|
+
it("should register tool without view (no resource registration)", () => {
|
|
451
|
+
server.registerTool({
|
|
452
|
+
name: "plain-tool",
|
|
453
|
+
description: "No view",
|
|
454
|
+
}, vi.fn());
|
|
455
|
+
expect(mockRegisterResource).not.toHaveBeenCalled();
|
|
456
|
+
expect(mockRegisterTool).toHaveBeenCalledTimes(1);
|
|
457
|
+
});
|
|
458
|
+
it("should apply view.csp fields to resource _meta", async () => {
|
|
459
|
+
server.registerTool({
|
|
460
|
+
name: "csp-tool",
|
|
461
|
+
description: "Test tool",
|
|
462
|
+
view: {
|
|
463
|
+
component: "csp-tool",
|
|
464
|
+
description: "Test view",
|
|
465
|
+
csp: {
|
|
466
|
+
connectDomains: ["https://api.example.com"],
|
|
467
|
+
resourceDomains: ["https://cdn.example.com"],
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
}, vi.fn());
|
|
471
|
+
const appsSdkCallback = mockRegisterResource.mock
|
|
472
|
+
.calls[0]?.[3];
|
|
473
|
+
const host = "localhost:3000";
|
|
474
|
+
const serverUrl = `http://${host}`;
|
|
475
|
+
const hmrUrl = `ws://${host}`;
|
|
476
|
+
const result = await appsSdkCallback(new URL("ui://views/apps-sdk/csp-tool.html"), createMockExtra(host));
|
|
477
|
+
const meta = result.contents[0]?._meta;
|
|
478
|
+
expect(meta["openai/widgetCSP"]).toEqual({
|
|
479
|
+
resource_domains: [serverUrl, "https://cdn.example.com"],
|
|
480
|
+
connect_domains: [serverUrl, hmrUrl, "https://api.example.com"],
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
it("should let view._meta override framework-computed keys", async () => {
|
|
484
|
+
server.registerTool({
|
|
485
|
+
name: "override-tool",
|
|
486
|
+
description: "Test tool",
|
|
487
|
+
view: {
|
|
488
|
+
component: "override-tool",
|
|
489
|
+
description: "Test view",
|
|
490
|
+
csp: { connectDomains: ["https://api.x.com"] },
|
|
491
|
+
_meta: {
|
|
492
|
+
"openai/widgetCSP": {
|
|
493
|
+
connect_domains: ["https://api.y.com"],
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
},
|
|
497
|
+
}, vi.fn());
|
|
498
|
+
const appsSdkCallback = mockRegisterResource.mock
|
|
499
|
+
.calls[0]?.[3];
|
|
500
|
+
const result = await appsSdkCallback(new URL("ui://views/apps-sdk/override-tool.html"), createMockExtra("localhost:3000"));
|
|
501
|
+
const meta = result.contents[0]?._meta;
|
|
502
|
+
expect(meta["openai/widgetCSP"]).toEqual({
|
|
503
|
+
connect_domains: ["https://api.y.com"],
|
|
504
|
+
});
|
|
505
|
+
});
|
|
506
|
+
it("should pass user _meta keys through to tool config", () => {
|
|
507
|
+
server.registerTool({
|
|
508
|
+
name: "meta-tool",
|
|
509
|
+
description: "Test tool",
|
|
510
|
+
_meta: {
|
|
511
|
+
"openai/widgetAccessible": true,
|
|
512
|
+
"openai/toolInvocation/invoking": "Loading...",
|
|
513
|
+
"acme.com/category": "utility",
|
|
514
|
+
},
|
|
515
|
+
}, vi.fn());
|
|
516
|
+
const toolCallArgs = mockRegisterTool.mock.calls[0];
|
|
517
|
+
const toolConfig = toolCallArgs?.[1];
|
|
518
|
+
expect(toolConfig._meta?.["openai/widgetAccessible"]).toBe(true);
|
|
519
|
+
expect(toolConfig._meta?.["openai/toolInvocation/invoking"]).toBe("Loading...");
|
|
520
|
+
expect(toolConfig._meta?.["acme.com/category"]).toBe("utility");
|
|
521
|
+
});
|
|
522
|
+
});
|
|
523
|
+
//# sourceMappingURL=view.test.js.map
|