skybridge 0.0.0-dev.ff50fdb → 0.0.0-dev.ffe77e9
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 +26 -16
- 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.d.ts +2 -1
- package/dist/cli/use-execute-steps.js +6 -1
- 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 -0
- package/dist/cli/use-nodemon.js +73 -0
- package/dist/cli/use-nodemon.js.map +1 -0
- 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 +9 -0
- package/dist/cli/use-typescript-check.js +94 -0
- package/dist/cli/use-typescript-check.js.map +1 -0
- package/dist/commands/build.js +64 -6
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/dev.d.ts +4 -1
- package/dist/commands/dev.js +61 -13
- 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 +10 -0
- package/dist/server/asset-base-url-transform-plugin.js +33 -0
- package/dist/server/asset-base-url-transform-plugin.js.map +1 -0
- package/dist/server/asset-base-url-transform-plugin.test.d.ts +1 -0
- package/dist/server/asset-base-url-transform-plugin.test.js +84 -0
- package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -0
- 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 +393 -64
- package/dist/server/server.js.map +1 -1
- package/dist/server/templateHelper.d.ts +5 -7
- 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 +135 -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 +0 -1
- package/dist/web/proxy.js.map +1 -1
- package/dist/web/types.js.map +1 -1
- package/package.json +44 -29
- package/tsconfig.base.json +33 -0
- package/dist/server/templates/development.hbs +0 -66
- package/dist/server/templates/production.hbs +0 -7
- package/dist/server/widgetsDevServer.d.ts +0 -12
- package/dist/server/widgetsDevServer.js +0 -47
- 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
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import cors from "cors";
|
|
3
|
+
import express, {} from "express";
|
|
4
|
+
import { assetBaseUrlTransformPlugin } from "./asset-base-url-transform-plugin.js";
|
|
5
|
+
/**
|
|
6
|
+
* Vite dev-server middleware for view assets.
|
|
7
|
+
*
|
|
8
|
+
* MUST be mounted at the Express app root so Vite can intercept
|
|
9
|
+
* `/@vite/client`, `/@react-refresh`, and `/_skybridge/view/...` imports:
|
|
10
|
+
*
|
|
11
|
+
* const app = express();
|
|
12
|
+
* if (env.NODE_ENV !== "production") {
|
|
13
|
+
* app.use(await viewsDevServer(httpServer));
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
export const viewsDevServer = async (httpServer) => {
|
|
17
|
+
const router = express.Router();
|
|
18
|
+
const { createServer, loadConfigFromFile } = await import("vite");
|
|
19
|
+
const root = process.cwd();
|
|
20
|
+
const configFile = path.join(root, "vite.config.ts");
|
|
21
|
+
const configResult = await loadConfigFromFile({ command: "serve", mode: "development" }, configFile, root);
|
|
22
|
+
const { build, preview, plugins: userPlugins = [], ...devConfig } = configResult?.config || {};
|
|
23
|
+
const vite = await createServer({
|
|
24
|
+
...devConfig,
|
|
25
|
+
// Pass `false` so Vite skips re-resolving a config file — we already
|
|
26
|
+
// loaded and spread the user's config above.
|
|
27
|
+
configFile: false,
|
|
28
|
+
appType: "custom",
|
|
29
|
+
server: {
|
|
30
|
+
allowedHosts: true,
|
|
31
|
+
middlewareMode: true,
|
|
32
|
+
hmr: {
|
|
33
|
+
server: httpServer,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
root,
|
|
37
|
+
// optimizeDeps is set by the skybridge Vite plugin (entries + include)
|
|
38
|
+
// so it can derive the view glob from `viewsDir`.
|
|
39
|
+
plugins: [...userPlugins, assetBaseUrlTransformPlugin()],
|
|
40
|
+
});
|
|
41
|
+
router.use(cors());
|
|
42
|
+
router.use("/", vite.middlewares);
|
|
43
|
+
return router;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=viewsDevServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewsDevServer.js","sourceRoot":"","sources":["../../src/server/viewsDevServer.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,EAAE,EAAe,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,2BAA2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http\";\nimport path from \"node:path\";\nimport cors from \"cors\";\nimport express, { type Router } from \"express\";\nimport { assetBaseUrlTransformPlugin } from \"./asset-base-url-transform-plugin.js\";\n\n/**\n * Vite dev-server middleware for view assets.\n *\n * MUST be mounted at the Express app root so Vite can intercept\n * `/@vite/client`, `/@react-refresh`, and `/_skybridge/view/...` imports:\n *\n * const app = express();\n * if (env.NODE_ENV !== \"production\") {\n * app.use(await viewsDevServer(httpServer));\n * }\n */\nexport const viewsDevServer = async (\n httpServer: http.Server,\n): Promise<Router> => {\n const router = express.Router();\n\n const { createServer, loadConfigFromFile } = await import(\"vite\");\n\n const root = process.cwd();\n const configFile = path.join(root, \"vite.config.ts\");\n\n const configResult = await loadConfigFromFile(\n { command: \"serve\", mode: \"development\" },\n configFile,\n root,\n );\n\n const {\n build,\n preview,\n plugins: userPlugins = [],\n ...devConfig\n } = configResult?.config || {};\n\n const vite = await createServer({\n ...devConfig,\n // Pass `false` so Vite skips re-resolving a config file — we already\n // loaded and spread the user's config above.\n configFile: false,\n appType: \"custom\",\n server: {\n allowedHosts: true,\n middlewareMode: true,\n hmr: {\n server: httpServer,\n },\n },\n root,\n // optimizeDeps is set by the skybridge Vite plugin (entries + include)\n // so it can derive the view glob from `viewsDir`.\n plugins: [...userPlugins, assetBaseUrlTransformPlugin()],\n });\n\n router.use(cors());\n router.use(\"/\", vite.middlewares);\n\n return router;\n};\n"]}
|
package/dist/test/utils.d.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { type MockInstance } from "vitest";
|
|
2
2
|
import { McpServer } from "../server/server.js";
|
|
3
|
-
/**
|
|
4
|
-
* Creates a real McpServer instance for testing
|
|
5
|
-
*/
|
|
6
3
|
export declare function createMockMcpServer(): {
|
|
7
4
|
server: McpServer;
|
|
8
5
|
mockRegisterResource: MockInstance<McpServer["registerResource"]>;
|
|
9
|
-
mockRegisterTool: MockInstance
|
|
6
|
+
mockRegisterTool: MockInstance;
|
|
10
7
|
};
|
|
11
8
|
export declare function createTestServer(): McpServer<Record<never, import("../server/server.js").ToolDef<unknown, unknown, unknown>> & {
|
|
12
|
-
"search-
|
|
9
|
+
"search-trip": import("../server/server.js").ToolDef<{
|
|
13
10
|
destination: string;
|
|
14
11
|
departureDate?: string | undefined;
|
|
15
12
|
maxPrice?: number | undefined;
|
|
@@ -30,9 +27,9 @@ export declare function createTestServer(): McpServer<Record<never, import("../s
|
|
|
30
27
|
images: string[];
|
|
31
28
|
}, unknown>;
|
|
32
29
|
} & {
|
|
33
|
-
"no-input-
|
|
30
|
+
"no-input-view": import("../server/server.js").ToolDef<{}, {}, unknown>;
|
|
34
31
|
} & {
|
|
35
|
-
"inferred-output-
|
|
32
|
+
"inferred-output-view": import("../server/server.js").ToolDef<{
|
|
36
33
|
query: string;
|
|
37
34
|
}, {
|
|
38
35
|
inferredResults: {
|
|
@@ -60,7 +57,7 @@ export declare function createTestServer(): McpServer<Record<never, import("../s
|
|
|
60
57
|
fetchedAt: string;
|
|
61
58
|
}, unknown>;
|
|
62
59
|
} & {
|
|
63
|
-
"
|
|
60
|
+
"view-with-metadata": import("../server/server.js").ToolDef<{
|
|
64
61
|
resourceId: string;
|
|
65
62
|
}, {
|
|
66
63
|
data: {
|
|
@@ -82,7 +79,7 @@ export declare function createTestServer(): McpServer<Record<never, import("../s
|
|
|
82
79
|
source: string;
|
|
83
80
|
}>;
|
|
84
81
|
} & {
|
|
85
|
-
"
|
|
82
|
+
"view-with-mixed-returns": import("../server/server.js").ToolDef<{
|
|
86
83
|
shouldSucceed: boolean;
|
|
87
84
|
}, {
|
|
88
85
|
error: string;
|
|
@@ -96,7 +93,7 @@ export declare function createTestServer(): McpServer<Record<never, import("../s
|
|
|
96
93
|
}>;
|
|
97
94
|
}>;
|
|
98
95
|
export declare function createMinimalTestServer(): McpServer<Record<never, import("../server/server.js").ToolDef<unknown, unknown, unknown>> & {
|
|
99
|
-
"search-
|
|
96
|
+
"search-trip": import("../server/server.js").ToolDef<{
|
|
100
97
|
destination: string;
|
|
101
98
|
}, {
|
|
102
99
|
results: {
|
|
@@ -105,7 +102,7 @@ export declare function createMinimalTestServer(): McpServer<Record<never, impor
|
|
|
105
102
|
}, unknown>;
|
|
106
103
|
}>;
|
|
107
104
|
export declare function createInterfaceTestServer(): McpServer<Record<never, import("../server/server.js").ToolDef<unknown, unknown, unknown>> & {
|
|
108
|
-
"interface-
|
|
105
|
+
"interface-view": import("../server/server.js").ToolDef<{
|
|
109
106
|
id: string;
|
|
110
107
|
}, {
|
|
111
108
|
itemName: string;
|
|
@@ -115,21 +112,16 @@ export declare function createInterfaceTestServer(): McpServer<Record<never, imp
|
|
|
115
112
|
version: number;
|
|
116
113
|
}>;
|
|
117
114
|
}>;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
115
|
+
export declare function createMockExtra(host: string, options?: {
|
|
116
|
+
headers?: Record<string, string | string[]>;
|
|
117
|
+
url?: URL | string;
|
|
118
|
+
}): {
|
|
122
119
|
requestInfo: {
|
|
120
|
+
url?: string | URL | undefined;
|
|
123
121
|
headers: {
|
|
124
122
|
host: string;
|
|
125
123
|
};
|
|
126
124
|
};
|
|
127
125
|
};
|
|
128
|
-
/**
|
|
129
|
-
* Sets up environment variables for testing
|
|
130
|
-
*/
|
|
131
126
|
export declare function setTestEnv(env: Record<string, string>): void;
|
|
132
|
-
/**
|
|
133
|
-
* Resets environment variables
|
|
134
|
-
*/
|
|
135
127
|
export declare function resetTestEnv(): void;
|
package/dist/test/utils.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
+
import { McpServer as McpServerBase } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
1
2
|
import { vi } from "vitest";
|
|
2
3
|
import * as z from "zod";
|
|
3
4
|
import { McpServer } from "../server/server.js";
|
|
4
|
-
/**
|
|
5
|
-
* Creates a real McpServer instance for testing
|
|
6
|
-
*/
|
|
7
5
|
export function createMockMcpServer() {
|
|
8
|
-
// Create a real McpServer instance
|
|
9
6
|
const server = new McpServer({
|
|
10
7
|
name: "alpic-openai-app",
|
|
11
8
|
version: "0.0.1",
|
|
12
9
|
}, { capabilities: {} });
|
|
13
|
-
// Mock the underlying methods to track calls
|
|
14
10
|
const mockRegisterResource = vi.spyOn(server, "registerResource");
|
|
15
|
-
const mockRegisterTool = vi.spyOn(
|
|
11
|
+
const mockRegisterTool = vi.spyOn(McpServerBase.prototype, "registerTool");
|
|
16
12
|
return {
|
|
17
13
|
server,
|
|
18
14
|
mockRegisterResource,
|
|
@@ -21,8 +17,9 @@ export function createMockMcpServer() {
|
|
|
21
17
|
}
|
|
22
18
|
export function createTestServer() {
|
|
23
19
|
return new McpServer({ name: "test-app", version: "1.0.0" }, {})
|
|
24
|
-
.
|
|
25
|
-
|
|
20
|
+
.registerTool({
|
|
21
|
+
name: "search-trip",
|
|
22
|
+
description: "Search for trips",
|
|
26
23
|
inputSchema: {
|
|
27
24
|
destination: z.string(),
|
|
28
25
|
departureDate: z.string().optional(),
|
|
@@ -36,6 +33,7 @@ export function createTestServer() {
|
|
|
36
33
|
})),
|
|
37
34
|
totalCount: z.number(),
|
|
38
35
|
},
|
|
36
|
+
view: { component: "search-trip" },
|
|
39
37
|
}, async ({ destination }) => {
|
|
40
38
|
return {
|
|
41
39
|
content: [{ type: "text", text: `Found trips to ${destination}` }],
|
|
@@ -45,7 +43,8 @@ export function createTestServer() {
|
|
|
45
43
|
},
|
|
46
44
|
};
|
|
47
45
|
})
|
|
48
|
-
.
|
|
46
|
+
.registerTool({
|
|
47
|
+
name: "get-trip-details",
|
|
49
48
|
description: "Get trip details",
|
|
50
49
|
inputSchema: {
|
|
51
50
|
tripId: z.string(),
|
|
@@ -55,6 +54,7 @@ export function createTestServer() {
|
|
|
55
54
|
description: z.string(),
|
|
56
55
|
images: z.array(z.string()),
|
|
57
56
|
},
|
|
57
|
+
view: { component: "get-trip-details" },
|
|
58
58
|
}, async ({ tripId }) => {
|
|
59
59
|
return {
|
|
60
60
|
content: [{ type: "text", text: `Details for ${tripId}` }],
|
|
@@ -65,21 +65,25 @@ export function createTestServer() {
|
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
67
|
})
|
|
68
|
-
.
|
|
69
|
-
|
|
68
|
+
.registerTool({
|
|
69
|
+
name: "no-input-view",
|
|
70
|
+
description: "View with no input",
|
|
70
71
|
inputSchema: {},
|
|
71
72
|
outputSchema: {},
|
|
73
|
+
view: { component: "no-input-view" },
|
|
72
74
|
}, async () => {
|
|
73
75
|
return {
|
|
74
76
|
content: [{ type: "text", text: "No input needed" }],
|
|
75
77
|
structuredContent: {},
|
|
76
78
|
};
|
|
77
79
|
})
|
|
78
|
-
.
|
|
79
|
-
|
|
80
|
+
.registerTool({
|
|
81
|
+
name: "inferred-output-view",
|
|
82
|
+
description: "View with output inferred from callback",
|
|
80
83
|
inputSchema: {
|
|
81
84
|
query: z.string(),
|
|
82
85
|
},
|
|
86
|
+
view: { component: "inferred-output-view" },
|
|
83
87
|
}, async ({ query }) => {
|
|
84
88
|
return {
|
|
85
89
|
content: [{ type: "text", text: `Query: ${query}` }],
|
|
@@ -89,7 +93,8 @@ export function createTestServer() {
|
|
|
89
93
|
},
|
|
90
94
|
};
|
|
91
95
|
})
|
|
92
|
-
.registerTool(
|
|
96
|
+
.registerTool({
|
|
97
|
+
name: "calculate-price",
|
|
93
98
|
description: "Calculate trip price",
|
|
94
99
|
inputSchema: {
|
|
95
100
|
tripId: z.string(),
|
|
@@ -108,7 +113,8 @@ export function createTestServer() {
|
|
|
108
113
|
},
|
|
109
114
|
};
|
|
110
115
|
})
|
|
111
|
-
.registerTool(
|
|
116
|
+
.registerTool({
|
|
117
|
+
name: "inferred-tool",
|
|
112
118
|
description: "Tool with output inferred from callback",
|
|
113
119
|
inputSchema: {
|
|
114
120
|
itemId: z.string(),
|
|
@@ -122,11 +128,13 @@ export function createTestServer() {
|
|
|
122
128
|
},
|
|
123
129
|
};
|
|
124
130
|
})
|
|
125
|
-
.
|
|
126
|
-
|
|
131
|
+
.registerTool({
|
|
132
|
+
name: "view-with-metadata",
|
|
133
|
+
description: "View that returns response metadata",
|
|
127
134
|
inputSchema: {
|
|
128
135
|
resourceId: z.string(),
|
|
129
136
|
},
|
|
137
|
+
view: { component: "view-with-metadata" },
|
|
130
138
|
}, async ({ resourceId }) => {
|
|
131
139
|
return {
|
|
132
140
|
content: [{ type: "text", text: `Resource: ${resourceId}` }],
|
|
@@ -140,7 +148,8 @@ export function createTestServer() {
|
|
|
140
148
|
},
|
|
141
149
|
};
|
|
142
150
|
})
|
|
143
|
-
.registerTool(
|
|
151
|
+
.registerTool({
|
|
152
|
+
name: "tool-with-metadata",
|
|
144
153
|
description: "Tool that returns response metadata",
|
|
145
154
|
inputSchema: {
|
|
146
155
|
query: z.string(),
|
|
@@ -157,20 +166,20 @@ export function createTestServer() {
|
|
|
157
166
|
},
|
|
158
167
|
};
|
|
159
168
|
})
|
|
160
|
-
.
|
|
161
|
-
|
|
169
|
+
.registerTool({
|
|
170
|
+
name: "view-with-mixed-returns",
|
|
171
|
+
description: "View with mixed return paths (some with _meta, some without)",
|
|
162
172
|
inputSchema: {
|
|
163
173
|
shouldSucceed: z.boolean(),
|
|
164
174
|
},
|
|
175
|
+
view: { component: "view-with-mixed-returns" },
|
|
165
176
|
}, async ({ shouldSucceed }) => {
|
|
166
177
|
if (!shouldSucceed) {
|
|
167
|
-
// Error path - no _meta
|
|
168
178
|
return {
|
|
169
179
|
content: [{ type: "text", text: "Error occurred" }],
|
|
170
180
|
structuredContent: { error: "Something went wrong" },
|
|
171
181
|
};
|
|
172
182
|
}
|
|
173
|
-
// Success path - has _meta
|
|
174
183
|
return {
|
|
175
184
|
content: [{ type: "text", text: "Success" }],
|
|
176
185
|
structuredContent: { data: "result" },
|
|
@@ -182,14 +191,16 @@ export function createTestServer() {
|
|
|
182
191
|
});
|
|
183
192
|
}
|
|
184
193
|
export function createMinimalTestServer() {
|
|
185
|
-
return new McpServer({ name: "test-app", version: "1.0.0" }, {}).
|
|
186
|
-
|
|
194
|
+
return new McpServer({ name: "test-app", version: "1.0.0" }, {}).registerTool({
|
|
195
|
+
name: "search-trip",
|
|
196
|
+
description: "Search for trips",
|
|
187
197
|
inputSchema: {
|
|
188
198
|
destination: z.string(),
|
|
189
199
|
},
|
|
190
200
|
outputSchema: {
|
|
191
201
|
results: z.array(z.object({ id: z.string() })),
|
|
192
202
|
},
|
|
203
|
+
view: { component: "search-trip" },
|
|
193
204
|
}, async ({ destination }) => {
|
|
194
205
|
return {
|
|
195
206
|
content: [{ type: "text", text: `Found trips to ${destination}` }],
|
|
@@ -198,11 +209,13 @@ export function createMinimalTestServer() {
|
|
|
198
209
|
});
|
|
199
210
|
}
|
|
200
211
|
export function createInterfaceTestServer() {
|
|
201
|
-
return new McpServer({ name: "interface-test-app", version: "1.0.0" }, {}).
|
|
202
|
-
|
|
212
|
+
return new McpServer({ name: "interface-test-app", version: "1.0.0" }, {}).registerTool({
|
|
213
|
+
name: "interface-view",
|
|
214
|
+
description: "View with interface-typed output",
|
|
203
215
|
inputSchema: {
|
|
204
216
|
id: z.string(),
|
|
205
217
|
},
|
|
218
|
+
view: { component: "interface-view" },
|
|
206
219
|
}, async ({ id }) => {
|
|
207
220
|
return {
|
|
208
221
|
content: [{ type: "text", text: `Item ${id}` }],
|
|
@@ -217,25 +230,17 @@ export function createInterfaceTestServer() {
|
|
|
217
230
|
};
|
|
218
231
|
});
|
|
219
232
|
}
|
|
220
|
-
|
|
221
|
-
* Mock extra parameter for resource callback
|
|
222
|
-
*/
|
|
223
|
-
export function createMockExtra(host) {
|
|
233
|
+
export function createMockExtra(host, options) {
|
|
224
234
|
return {
|
|
225
235
|
requestInfo: {
|
|
226
|
-
headers: { host },
|
|
236
|
+
headers: { host, ...(options?.headers ?? {}) },
|
|
237
|
+
...(options?.url ? { url: options.url } : {}),
|
|
227
238
|
},
|
|
228
239
|
};
|
|
229
240
|
}
|
|
230
|
-
/**
|
|
231
|
-
* Sets up environment variables for testing
|
|
232
|
-
*/
|
|
233
241
|
export function setTestEnv(env) {
|
|
234
242
|
Object.assign(process.env, env);
|
|
235
243
|
}
|
|
236
|
-
/**
|
|
237
|
-
* Resets environment variables
|
|
238
|
-
*/
|
|
239
244
|
export function resetTestEnv() {
|
|
240
245
|
delete process.env.NODE_ENV;
|
|
241
246
|
}
|
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,EAAE,CACrB,CAAC;IAEF,6CAA6C;IAC7C,MAAM,oBAAoB,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAClE,MAAM,gBAAgB,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAE1D,OAAO;QACL,MAAM;QACN,oBAAoB;QACpB,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;SAC7D,cAAc,CACb,eAAe,EACf,EAAE,EACF;QACE,WAAW,EAAE,oBAAoB;QACjC,WAAW,EAAE;YACX,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;YACvB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YACpC,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,EAAE;QAC7C,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;YAC/C,iBAAiB,EAAE;gBACjB,QAAQ,EAAE,WAAW;gBACrB,QAAQ,EAAE,EAAE;aACb;YACD,KAAK,EAAE;gBACL,WAAW,EAAE,MAAM;gBACnB,OAAO,EAAE,CAAC;aACX;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,OAGC;IAED,OAAO;QACL,WAAW,EAAE;YACX,OAAO,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC,EAAE;YAC9C,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9C;KACF,CAAC;AACJ,CAAC;AAED,MAAM,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 {};
|