skybridge 0.0.0-dev.eb4d79a → 0.0.0-dev.eb5abb2
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/LICENSE +21 -674
- package/README.md +116 -23
- package/bin/run.js +5 -0
- package/dist/cli/header.d.ts +4 -0
- package/dist/cli/header.js +6 -0
- package/dist/cli/header.js.map +1 -0
- package/dist/cli/run-command.d.ts +2 -0
- package/dist/cli/run-command.js +43 -0
- package/dist/cli/run-command.js.map +1 -0
- package/dist/cli/telemetry.d.ts +7 -0
- package/dist/cli/telemetry.js +123 -0
- package/dist/cli/telemetry.js.map +1 -0
- package/dist/cli/use-execute-steps.d.ts +11 -0
- package/dist/cli/use-execute-steps.js +36 -0
- package/dist/cli/use-execute-steps.js.map +1 -0
- package/dist/cli/use-nodemon.d.ts +6 -0
- package/dist/cli/use-nodemon.js +61 -0
- package/dist/cli/use-nodemon.js.map +1 -0
- package/dist/cli/use-typescript-check.d.ts +8 -0
- package/dist/cli/use-typescript-check.js +59 -0
- package/dist/cli/use-typescript-check.js.map +1 -0
- package/dist/commands/build.d.ts +9 -0
- package/dist/commands/build.js +46 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/dev.d.ts +9 -0
- package/dist/commands/dev.js +31 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/start.d.ts +7 -0
- package/dist/commands/start.js +28 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/telemetry/disable.d.ts +5 -0
- package/dist/commands/telemetry/disable.js +14 -0
- package/dist/commands/telemetry/disable.js.map +1 -0
- package/dist/commands/telemetry/enable.d.ts +5 -0
- package/dist/commands/telemetry/enable.js +14 -0
- package/dist/commands/telemetry/enable.js.map +1 -0
- package/dist/commands/telemetry/status.d.ts +5 -0
- package/dist/commands/telemetry/status.js +14 -0
- package/dist/commands/telemetry/status.js.map +1 -0
- package/dist/server/asset-base-url-transform-plugin.d.ts +11 -0
- package/dist/server/asset-base-url-transform-plugin.js +34 -0
- package/dist/server/asset-base-url-transform-plugin.js.map +1 -0
- package/dist/server/asset-base-url-transform-plugin.test.js +56 -0
- package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -0
- package/dist/server/express.d.ts +5 -0
- package/dist/server/express.js +63 -0
- package/dist/server/express.js.map +1 -0
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/inferUtilityTypes.d.ts +64 -0
- package/dist/server/inferUtilityTypes.js +2 -0
- package/dist/server/inferUtilityTypes.js.map +1 -0
- package/dist/server/server.d.ts +109 -0
- package/dist/server/server.js +201 -0
- package/dist/server/server.js.map +1 -0
- package/dist/server/templateHelper.d.ts +19 -0
- package/dist/{src/server → server}/templateHelper.js +5 -12
- package/dist/server/templateHelper.js.map +1 -0
- package/dist/server/templates/development.hbs +67 -0
- package/dist/server/templates/production.hbs +6 -0
- package/dist/{src/server → server}/widgetsDevServer.d.ts +2 -2
- package/dist/server/widgetsDevServer.js +57 -0
- package/dist/server/widgetsDevServer.js.map +1 -0
- package/dist/test/utils.d.ts +355 -0
- package/dist/test/utils.js +242 -0
- package/dist/test/utils.js.map +1 -0
- package/dist/test/widget.test.js +261 -0
- package/dist/test/widget.test.js.map +1 -0
- package/dist/web/bridges/apps-sdk/adaptor.d.ts +22 -0
- package/dist/web/bridges/apps-sdk/adaptor.js +70 -0
- package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -0
- package/dist/web/bridges/apps-sdk/bridge.d.ts +14 -0
- package/dist/web/bridges/apps-sdk/bridge.js +46 -0
- package/dist/web/bridges/apps-sdk/bridge.js.map +1 -0
- package/dist/web/bridges/apps-sdk/index.d.ts +5 -0
- package/dist/web/bridges/apps-sdk/index.js +5 -0
- package/dist/web/bridges/apps-sdk/index.js.map +1 -0
- package/dist/web/bridges/apps-sdk/types.d.ts +117 -0
- package/dist/web/bridges/apps-sdk/types.js.map +1 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +2 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +7 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -0
- package/dist/web/bridges/get-adaptor.d.ts +2 -0
- package/dist/web/bridges/get-adaptor.js +8 -0
- package/dist/web/bridges/get-adaptor.js.map +1 -0
- package/dist/web/bridges/index.d.ts +5 -0
- package/dist/web/bridges/index.js +6 -0
- package/dist/web/bridges/index.js.map +1 -0
- package/dist/web/bridges/mcp-app/adaptor.d.ts +36 -0
- package/dist/web/bridges/mcp-app/adaptor.js +188 -0
- package/dist/web/bridges/mcp-app/adaptor.js.map +1 -0
- package/dist/web/bridges/mcp-app/bridge.d.ts +43 -0
- package/dist/web/bridges/mcp-app/bridge.js +255 -0
- package/dist/web/bridges/mcp-app/bridge.js.map +1 -0
- package/dist/web/bridges/mcp-app/index.d.ts +4 -0
- package/dist/web/bridges/mcp-app/index.js +4 -0
- package/dist/web/bridges/mcp-app/index.js.map +1 -0
- package/dist/web/bridges/mcp-app/types.d.ts +8 -0
- package/dist/web/bridges/mcp-app/types.js +2 -0
- package/dist/web/bridges/mcp-app/types.js.map +1 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +5 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js +7 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.d.ts +1 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +66 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -0
- package/dist/web/bridges/types.d.ts +98 -0
- package/dist/web/bridges/types.js +2 -0
- package/dist/web/bridges/types.js.map +1 -0
- package/dist/web/bridges/use-host-context.d.ts +2 -0
- package/dist/web/bridges/use-host-context.js +8 -0
- package/dist/web/bridges/use-host-context.js.map +1 -0
- package/dist/web/components/modal-provider.d.ts +4 -0
- package/dist/web/components/modal-provider.js +47 -0
- package/dist/web/components/modal-provider.js.map +1 -0
- package/dist/web/create-store.d.ts +3 -0
- package/dist/web/create-store.js +24 -0
- package/dist/web/create-store.js.map +1 -0
- package/dist/web/create-store.test.d.ts +1 -0
- package/dist/web/create-store.test.js +126 -0
- package/dist/web/create-store.test.js.map +1 -0
- package/dist/web/data-llm.d.ts +14 -0
- package/dist/web/data-llm.js +72 -0
- package/dist/web/data-llm.js.map +1 -0
- package/dist/web/data-llm.test.d.ts +1 -0
- package/dist/web/data-llm.test.js +141 -0
- package/dist/web/data-llm.test.js.map +1 -0
- package/dist/web/generate-helpers.d.ts +116 -0
- package/dist/web/generate-helpers.js +111 -0
- package/dist/web/generate-helpers.js.map +1 -0
- package/dist/web/generate-helpers.test-d.d.ts +1 -0
- package/dist/web/generate-helpers.test-d.js +209 -0
- package/dist/web/generate-helpers.test-d.js.map +1 -0
- package/dist/web/generate-helpers.test.d.ts +1 -0
- package/dist/web/generate-helpers.test.js +17 -0
- package/dist/web/generate-helpers.test.js.map +1 -0
- package/dist/web/helpers/state.d.ts +7 -0
- package/dist/web/helpers/state.js +45 -0
- package/dist/web/helpers/state.js.map +1 -0
- package/dist/web/helpers/state.test.d.ts +1 -0
- package/dist/web/helpers/state.test.js +53 -0
- package/dist/web/helpers/state.test.js.map +1 -0
- package/dist/web/hooks/index.d.ts +11 -0
- package/dist/web/hooks/index.js +12 -0
- package/dist/web/hooks/index.js.map +1 -0
- package/dist/web/hooks/test/utils.d.ts +16 -0
- package/dist/web/hooks/test/utils.js +60 -0
- package/dist/web/hooks/test/utils.js.map +1 -0
- package/dist/web/hooks/use-call-tool.d.ts +101 -0
- package/dist/web/hooks/use-call-tool.js +68 -0
- package/dist/web/hooks/use-call-tool.js.map +1 -0
- package/dist/web/hooks/use-call-tool.test-d.d.ts +1 -0
- package/dist/web/hooks/use-call-tool.test-d.js +104 -0
- package/dist/web/hooks/use-call-tool.test-d.js.map +1 -0
- package/dist/web/hooks/use-call-tool.test.d.ts +1 -0
- package/dist/web/hooks/use-call-tool.test.js +190 -0
- package/dist/web/hooks/use-call-tool.test.js.map +1 -0
- package/dist/web/hooks/use-display-mode.d.ts +4 -0
- package/dist/web/hooks/use-display-mode.js +9 -0
- package/dist/web/hooks/use-display-mode.js.map +1 -0
- package/dist/web/hooks/use-display-mode.test.d.ts +1 -0
- package/dist/web/hooks/use-display-mode.test.js +41 -0
- package/dist/web/hooks/use-display-mode.test.js.map +1 -0
- package/dist/web/hooks/use-files.d.ts +6 -0
- package/dist/web/hooks/use-files.js +9 -0
- package/dist/web/hooks/use-files.js.map +1 -0
- package/dist/web/hooks/use-files.test.d.ts +1 -0
- package/dist/web/hooks/use-files.test.js +30 -0
- package/dist/web/hooks/use-files.test.js.map +1 -0
- package/dist/web/hooks/use-layout.d.ts +22 -0
- package/dist/web/hooks/use-layout.js +23 -0
- package/dist/web/hooks/use-layout.js.map +1 -0
- package/dist/web/hooks/use-layout.test.d.ts +1 -0
- package/dist/web/hooks/use-layout.test.js +96 -0
- package/dist/web/hooks/use-layout.test.js.map +1 -0
- package/dist/web/hooks/use-open-external.d.ts +1 -0
- package/dist/web/hooks/use-open-external.js +8 -0
- package/dist/web/hooks/use-open-external.js.map +1 -0
- package/dist/web/hooks/use-open-external.test.d.ts +1 -0
- package/dist/web/hooks/use-open-external.test.js +50 -0
- package/dist/web/hooks/use-open-external.test.js.map +1 -0
- package/dist/web/hooks/use-request-modal.d.ts +9 -0
- package/dist/web/hooks/use-request-modal.js +16 -0
- package/dist/web/hooks/use-request-modal.js.map +1 -0
- package/dist/web/hooks/use-request-modal.test.d.ts +1 -0
- package/dist/web/hooks/use-request-modal.test.js +57 -0
- package/dist/web/hooks/use-request-modal.test.js.map +1 -0
- package/dist/web/hooks/use-send-follow-up-message.d.ts +1 -0
- package/dist/web/hooks/use-send-follow-up-message.js +8 -0
- package/dist/web/hooks/use-send-follow-up-message.js.map +1 -0
- package/dist/web/hooks/use-set-open-in-app-url.d.ts +1 -0
- package/dist/web/hooks/use-set-open-in-app-url.js +8 -0
- package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -0
- package/dist/web/hooks/use-set-open-in-app-url.test.d.ts +1 -0
- package/dist/web/hooks/use-set-open-in-app-url.test.js +49 -0
- package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -0
- package/dist/web/hooks/use-tool-info.d.ts +36 -0
- package/dist/web/hooks/use-tool-info.js +26 -0
- package/dist/web/hooks/use-tool-info.js.map +1 -0
- package/dist/web/hooks/use-tool-info.test-d.d.ts +1 -0
- package/dist/web/hooks/use-tool-info.test-d.js +109 -0
- package/dist/web/hooks/use-tool-info.test-d.js.map +1 -0
- package/dist/web/hooks/use-tool-info.test.d.ts +1 -0
- package/dist/web/hooks/use-tool-info.test.js +130 -0
- package/dist/web/hooks/use-tool-info.test.js.map +1 -0
- package/dist/web/hooks/use-user.d.ts +18 -0
- package/dist/web/hooks/use-user.js +19 -0
- package/dist/web/hooks/use-user.js.map +1 -0
- package/dist/web/hooks/use-user.test.d.ts +1 -0
- package/dist/web/hooks/use-user.test.js +94 -0
- package/dist/web/hooks/use-user.test.js.map +1 -0
- package/dist/web/hooks/use-widget-state.d.ts +4 -0
- package/dist/web/hooks/use-widget-state.js +32 -0
- package/dist/web/hooks/use-widget-state.js.map +1 -0
- package/dist/web/hooks/use-widget-state.test.d.ts +1 -0
- package/dist/web/hooks/use-widget-state.test.js +62 -0
- package/dist/web/hooks/use-widget-state.test.js.map +1 -0
- package/dist/web/index.d.ts +8 -0
- package/dist/web/index.js +9 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/mount-widget.js +27 -0
- package/dist/web/mount-widget.js.map +1 -0
- package/dist/web/plugin/data-llm.test.d.ts +1 -0
- package/dist/web/plugin/data-llm.test.js +81 -0
- package/dist/web/plugin/data-llm.test.js.map +1 -0
- package/dist/web/plugin/plugin.d.ts +2 -0
- package/dist/web/plugin/plugin.js +46 -0
- package/dist/web/plugin/plugin.js.map +1 -0
- package/dist/web/plugin/transform-data-llm.d.ts +12 -0
- package/dist/web/plugin/transform-data-llm.js +96 -0
- package/dist/web/plugin/transform-data-llm.js.map +1 -0
- package/dist/web/plugin/transform-data-llm.test.d.ts +1 -0
- package/dist/web/plugin/transform-data-llm.test.js +81 -0
- package/dist/web/plugin/transform-data-llm.test.js.map +1 -0
- package/dist/web/proxy.d.ts +1 -0
- package/dist/web/proxy.js +52 -0
- package/dist/web/proxy.js.map +1 -0
- package/dist/web/types.d.ts +16 -0
- package/dist/web/types.js +2 -0
- package/dist/web/types.js.map +1 -0
- package/package.json +66 -26
- package/dist/src/server/index.d.ts +0 -2
- package/dist/src/server/index.js.map +0 -1
- package/dist/src/server/server.d.ts +0 -12
- package/dist/src/server/server.js +0 -45
- package/dist/src/server/server.js.map +0 -1
- package/dist/src/server/templateHelper.d.ts +0 -14
- package/dist/src/server/templateHelper.js.map +0 -1
- package/dist/src/server/widgetsDevServer.js +0 -39
- package/dist/src/server/widgetsDevServer.js.map +0 -1
- package/dist/src/test/setup.js +0 -9
- package/dist/src/test/setup.js.map +0 -1
- package/dist/src/test/utils.d.ts +0 -28
- package/dist/src/test/utils.js +0 -43
- package/dist/src/test/utils.js.map +0 -1
- package/dist/src/test/widget.test.js +0 -69
- package/dist/src/test/widget.test.js.map +0 -1
- package/dist/src/web/index.d.ts +0 -4
- package/dist/src/web/index.js +0 -5
- package/dist/src/web/index.js.map +0 -1
- package/dist/src/web/mount-widget.js +0 -14
- package/dist/src/web/mount-widget.js.map +0 -1
- package/dist/src/web/types.d.ts +0 -95
- package/dist/src/web/types.js.map +0 -1
- package/dist/src/web/use-openai-global.d.ts +0 -2
- package/dist/src/web/use-openai-global.js +0 -21
- package/dist/src/web/use-openai-global.js.map +0 -1
- package/dist/src/web/use-tool-output.d.ts +0 -3
- package/dist/src/web/use-tool-output.js +0 -5
- package/dist/src/web/use-tool-output.js.map +0 -1
- package/dist/vitest.config.d.ts +0 -2
- package/dist/vitest.config.js +0 -9
- package/dist/vitest.config.js.map +0 -1
- /package/dist/{src/test/setup.d.ts → server/asset-base-url-transform-plugin.test.d.ts} +0 -0
- /package/dist/{src/server → server}/index.js +0 -0
- /package/dist/{src/test → test}/widget.test.d.ts +0 -0
- /package/dist/{src/web → web/bridges/apps-sdk}/types.js +0 -0
- /package/dist/{src/web → web}/mount-widget.d.ts +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cpSync, rmSync } from "node:fs";
|
|
3
|
+
import { Command } from "@oclif/core";
|
|
4
|
+
import { Box, render, Text } from "ink";
|
|
5
|
+
import { useEffect } from "react";
|
|
6
|
+
import { Header } from "../cli/header.js";
|
|
7
|
+
import { useExecuteSteps } from "../cli/use-execute-steps.js";
|
|
8
|
+
export const commandSteps = [
|
|
9
|
+
{
|
|
10
|
+
label: "Building widgets",
|
|
11
|
+
command: "vite build -c web/vite.config.ts",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
label: "Compiling server",
|
|
15
|
+
run: () => rmSync("dist", { recursive: true, force: true }),
|
|
16
|
+
command: "tsc -p tsconfig.server.json",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label: "Copying static assets",
|
|
20
|
+
run: () => cpSync("web/dist", "dist/assets", { recursive: true }),
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
export default class Build extends Command {
|
|
24
|
+
static description = "Build the widgets and MCP server";
|
|
25
|
+
static examples = ["skybridge build"];
|
|
26
|
+
static flags = {};
|
|
27
|
+
async run() {
|
|
28
|
+
const App = () => {
|
|
29
|
+
const { currentStep, status, error, execute } = useExecuteSteps(commandSteps);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
execute();
|
|
32
|
+
}, [execute]);
|
|
33
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsx(Header, { version: this.config.version, children: _jsx(Text, { color: "green", children: " \u2192 building for production\u2026" }) }), commandSteps.map((step, index) => {
|
|
34
|
+
const isCurrent = index === currentStep && status === "running";
|
|
35
|
+
const isCompleted = index < currentStep || status === "success";
|
|
36
|
+
const isError = status === "error" && index === currentStep;
|
|
37
|
+
return (_jsx(Box, { marginBottom: 0, children: _jsxs(Text, { color: isError ? "red" : isCompleted ? "green" : "grey", children: [isError ? "✗" : isCompleted ? "✓" : isCurrent ? "⟳" : "○", " ", step.label] }) }, step.label));
|
|
38
|
+
}), status === "success" && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "green", bold: true, children: "\u2713 Build completed successfully!" }) })), status === "error" && error && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "red", bold: true, children: "\u2717 Build failed" }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: error.split("\n").map((line) => (_jsx(Text, { color: "red", children: line }, line))) })] }))] }));
|
|
39
|
+
};
|
|
40
|
+
render(_jsx(App, {}), {
|
|
41
|
+
exitOnCtrlC: true,
|
|
42
|
+
patchConsole: false,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAoB,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEhF,MAAM,CAAC,MAAM,YAAY,GAAkB;IACzC;QACE,KAAK,EAAE,kBAAkB;QACzB,OAAO,EAAE,kCAAkC;KAC5C;IACD;QACE,KAAK,EAAE,kBAAkB;QACzB,GAAG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Command } from "@oclif/core";
|
|
2
|
+
export default class Dev extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
"use-forwarded-host": import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Command, Flags } from "@oclif/core";
|
|
3
|
+
import { Box, render, Text } from "ink";
|
|
4
|
+
import { Header } from "../cli/header.js";
|
|
5
|
+
import { useNodemon } from "../cli/use-nodemon.js";
|
|
6
|
+
import { useTypeScriptCheck } from "../cli/use-typescript-check.js";
|
|
7
|
+
export default class Dev extends Command {
|
|
8
|
+
static description = "Start development server";
|
|
9
|
+
static examples = ["skybridge"];
|
|
10
|
+
static flags = {
|
|
11
|
+
"use-forwarded-host": Flags.boolean({
|
|
12
|
+
description: "Uses the forwarded host header to construct widget URLs instead of localhost, useful when accessing the dev server through a tunnel (e.g., ngrok)",
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
async run() {
|
|
16
|
+
const { flags } = await this.parse(Dev);
|
|
17
|
+
const env = {
|
|
18
|
+
...process.env,
|
|
19
|
+
...(flags["use-forwarded-host"]
|
|
20
|
+
? { SKYBRIDGE_USE_FORWARDED_HOST: "true" }
|
|
21
|
+
: {}),
|
|
22
|
+
};
|
|
23
|
+
const App = () => {
|
|
24
|
+
const tsErrors = useTypeScriptCheck();
|
|
25
|
+
const messages = useNodemon(env);
|
|
26
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, marginLeft: 1, children: [_jsx(Header, { version: this.config.version }), _jsxs(Box, { children: [_jsxs(Text, { color: "green", children: ["\u2192", " "] }), _jsxs(Text, { color: "white", bold: true, children: ["Open DevTools to test your app locally:", " "] }), _jsx(Text, { color: "green", children: "http://localhost:3000/" })] }), _jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsxs(Text, { children: ["MCP server running at:", " "] }), _jsx(Text, { color: "white", bold: true, children: "http://localhost:3000/mcp" })] }), _jsx(Text, { color: "white", underline: true, children: "To test on ChatGPT:" }), _jsxs(Box, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsx(Text, { color: "grey", children: "Make your local server accessible with " }), _jsx(Text, { color: "white", bold: true, children: "ngrok http 3000" })] }), _jsx(Box, { marginBottom: 1, children: _jsxs(Text, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsx(Text, { color: "grey", children: "Connect to ChatGPT with URL " }), _jsx(Text, { color: "white", bold: true, children: "https://xxxxxx.ngrok-free.app/mcp" })] }) }), _jsx(Box, { children: _jsxs(Text, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsx(Text, { children: "Documentation: " }), _jsx(Text, { color: "white", bold: true, children: "https://docs.skybridge.tech/" })] }) }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsx(Text, { children: "If you like Skybridge, please " }), _jsxs(Text, { color: "white", bold: true, children: ["give it a star", " "] }), _jsx(Text, { children: "on GitHub: " }), _jsx(Text, { color: "white", underline: true, children: "https://github.com/alpic-ai/skybridge" }), _jsx(Text, { color: "grey", children: " \uD83D\uDE4F" })] }) }), tsErrors.length > 0 && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "red", bold: true, children: "\u26A0\uFE0F TypeScript errors found:" }), tsErrors.map((error) => (_jsxs(Box, { marginLeft: 2, flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: "white", children: error.file }), _jsxs(Text, { color: "grey", children: ["(", error.line, ",", error.col, "):", " "] })] }), _jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: "red", children: error.message }) })] }, `${error.file}:${error.line}:${error.col}`)))] })), messages.length > 0 && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "white", bold: true, children: "Logs:" }), messages.map((message, index) => (_jsx(Box, { marginLeft: 2, children: message.type === "restart" ? (_jsxs(_Fragment, { children: [_jsxs(Text, { color: "green", children: ["\u2713", " "] }), _jsx(Text, { color: "white", children: message.text })] })) : message.type === "error" ? (_jsx(Text, { color: "red", children: message.text })) : (_jsx(Text, { children: message.text })) }, `${message.type}-${index}-${message.text.slice(0, 20)}`)))] }))] }));
|
|
27
|
+
};
|
|
28
|
+
render(_jsx(App, {}), { exitOnCtrlC: true, patchConsole: true });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,OAAO;IACtC,MAAM,CAAU,WAAW,GAAG,0BAA0B,CAAC;IACzD,MAAM,CAAU,QAAQ,GAAG,CAAC,WAAW,CAAC,CAAC;IACzC,MAAM,CAAU,KAAK,GAAG;QACtB,oBAAoB,EAAE,KAAK,CAAC,OAAO,CAAC;YAClC,WAAW,EACT,mJAAmJ;SACtJ,CAAC;KACH,CAAC;IAEK,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC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,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { Command } from "@oclif/core";
|
|
4
|
+
import { runCommand } from "../cli/run-command.js";
|
|
5
|
+
export default class Start extends Command {
|
|
6
|
+
static description = "Start production server";
|
|
7
|
+
static examples = ["skybridge start"];
|
|
8
|
+
static flags = {};
|
|
9
|
+
async run() {
|
|
10
|
+
console.clear();
|
|
11
|
+
const distPath = resolve(process.cwd(), "dist/index.js");
|
|
12
|
+
if (!existsSync(distPath)) {
|
|
13
|
+
console.error("❌ Error: dist/index.js not found");
|
|
14
|
+
console.error("");
|
|
15
|
+
console.error("Please build your project first:");
|
|
16
|
+
console.error(" skybridge build");
|
|
17
|
+
console.error("");
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
console.log(`\x1b[36m\x1b[1m⛰ Welcome to Skybridge\x1b[0m \x1b[36mv${this.config.version}\x1b[0m`);
|
|
21
|
+
console.log(`Server running at: \x1b[32m\x1b[1mhttp://localhost:3000/mcp\x1b[0m`);
|
|
22
|
+
await runCommand("node dist/index.js", {
|
|
23
|
+
stdio: ["ignore", "inherit", "inherit"],
|
|
24
|
+
env: { ...process.env, NODE_ENV: "production" },
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,OAAO;IACxC,MAAM,CAAU,WAAW,GAAG,yBAAyB,CAAC;IACxD,MAAM,CAAU,QAAQ,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC/C,MAAM,CAAU,KAAK,GAAG,EAAE,CAAC;IAEpB,KAAK,CAAC,GAAG;QACd,OAAO,CAAC,KAAK,EAAE,CAAC;QAEhB,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,eAAe,CAAC,CAAC;QACzD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;YAClD,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;YAClD,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACnC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,CAAC,GAAG,CACT,0DAA0D,IAAI,CAAC,MAAM,CAAC,OAAO,SAAS,CACvF,CAAC;QACF,OAAO,CAAC,GAAG,CACT,oEAAoE,CACrE,CAAC;QAEF,MAAM,UAAU,CAAC,oBAAoB,EAAE;YACrC,KAAK,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;YACvC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE;SAChD,CAAC,CAAC;IACL,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Command } from "@oclif/core";
|
|
3
|
+
import { Box, render, Text } from "ink";
|
|
4
|
+
import { setEnabled } from "../../cli/telemetry.js";
|
|
5
|
+
export default class TelemetryDisable extends Command {
|
|
6
|
+
static description = "Disable Skybridge telemetry on this machine";
|
|
7
|
+
async run() {
|
|
8
|
+
await this.parse(TelemetryDisable);
|
|
9
|
+
setEnabled(false);
|
|
10
|
+
const App = () => (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsxs(Box, { children: [_jsx(Text, { color: "yellow", children: "\u2713" }), _jsx(Text, { children: " Telemetry has been " }), _jsx(Text, { color: "yellow", bold: true, children: "disabled" })] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "gray", children: "Config saved to ~/.skybridge/config.json" }) }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "gray", children: "Skybridge never collects Personally Identifiable Information (PII). If you'd like to help us improve Skybridge by allowing anonymous CLI usage data, please reenable telemetry with: skybridge telemetry enable" }) })] }));
|
|
11
|
+
render(_jsx(App, {}));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=disable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disable.js","sourceRoot":"","sources":["../../../src/commands/telemetry/disable.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,OAAO;IACnD,MAAM,CAAU,WAAW,GAAG,6CAA6C,CAAC;IAErE,KAAK,CAAC,GAAG;QACd,MAAM,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACnC,UAAU,CAAC,KAAK,CAAC,CAAC;QAElB,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,CAChB,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,OAAO,EAAE,CAAC,aACpC,MAAC,GAAG,eACF,KAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,uBAAS,EAC7B,KAAC,IAAI,uCAA4B,EACjC,KAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,EAAC,IAAI,+BAElB,IACH,EACN,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,YACf,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,yDAAgD,GAC9D,EACN,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,YACf,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,gOAKX,GACH,IACF,CACP,CAAC;QAEF,MAAM,CAAC,KAAC,GAAG,KAAG,CAAC,CAAC;IAClB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Command } from "@oclif/core";
|
|
3
|
+
import { Box, render, Text } from "ink";
|
|
4
|
+
import { setEnabled } from "../../cli/telemetry.js";
|
|
5
|
+
export default class TelemetryEnable extends Command {
|
|
6
|
+
static description = "Enable Skybridge telemetry on this machine";
|
|
7
|
+
async run() {
|
|
8
|
+
await this.parse(TelemetryEnable);
|
|
9
|
+
setEnabled(true);
|
|
10
|
+
const App = () => (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsxs(Box, { children: [_jsx(Text, { color: "green", children: "\u2713" }), _jsx(Text, { children: " Telemetry has been " }), _jsx(Text, { color: "green", bold: true, children: "enabled" })] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "gray", children: "Config saved to ~/.skybridge/config.json" }) })] }));
|
|
11
|
+
render(_jsx(App, {}));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=enable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enable.js","sourceRoot":"","sources":["../../../src/commands/telemetry/enable.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IAClD,MAAM,CAAU,WAAW,GAAG,4CAA4C,CAAC;IAEpE,KAAK,CAAC,GAAG;QACd,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAClC,UAAU,CAAC,IAAI,CAAC,CAAC;QAEjB,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,CAChB,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,OAAO,EAAE,CAAC,aACpC,MAAC,GAAG,eACF,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,uBAAS,EAC5B,KAAC,IAAI,uCAA4B,EACjC,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,8BAEjB,IACH,EACN,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,YACf,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,yDAAgD,GAC9D,IACF,CACP,CAAC;QAEF,MAAM,CAAC,KAAC,GAAG,KAAG,CAAC,CAAC;IAClB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Command } from "@oclif/core";
|
|
3
|
+
import { Box, render, Text } from "ink";
|
|
4
|
+
import { getMachineId, isEnabled } from "../../cli/telemetry.js";
|
|
5
|
+
export default class TelemetryStatus extends Command {
|
|
6
|
+
static description = "Get Skybridge current telemetry settings for this machine";
|
|
7
|
+
async run() {
|
|
8
|
+
await this.parse(TelemetryStatus);
|
|
9
|
+
const enabled = isEnabled();
|
|
10
|
+
const App = () => (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsx(Text, { bold: true, underline: true, children: "Skybridge Telemetry" }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { children: "Status: " }), enabled ? (_jsx(Text, { color: "green", bold: true, children: "Enabled" })) : (_jsx(Text, { color: "yellow", bold: true, children: "Disabled" }))] }), _jsxs(Box, { marginTop: 1, children: [_jsx(Text, { color: "gray", children: "Machine ID: " }), _jsx(Text, { children: getMachineId() })] })] }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "gray", children: "To opt out, run: skybridge telemetry disable" }), _jsx(Text, { color: "gray", children: "Or set: SKYBRIDGE_TELEMETRY_DISABLED=1" }), _jsx(Text, { color: "gray", children: "Debug mode: SKYBRIDGE_TELEMETRY_DEBUG=1" })] })] }));
|
|
11
|
+
render(_jsx(App, {}));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/telemetry/status.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IAClD,MAAM,CAAU,WAAW,GACzB,2DAA2D,CAAC;IAEvD,KAAK,CAAC,GAAG;QACd,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAClC,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC;QAE5B,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,CAChB,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,OAAO,EAAE,CAAC,aACpC,KAAC,IAAI,IAAC,IAAI,QAAC,SAAS,0CAEb,EAEP,MAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ,aACvC,MAAC,GAAG,eACF,KAAC,IAAI,2BAAgB,EACpB,OAAO,CAAC,CAAC,CAAC,CACT,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,8BAEjB,CACR,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,EAAC,IAAI,+BAElB,CACR,IACG,EAEN,MAAC,GAAG,IAAC,SAAS,EAAE,CAAC,aACf,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,6BAAoB,EACtC,KAAC,IAAI,cAAE,YAAY,EAAE,GAAQ,IACzB,IACF,EAEN,MAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ,aACvC,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,6DAAoD,EACtE,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,uDAA8C,EAChE,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,wDAA+C,IAC7D,IACF,CACP,CAAC;QAEF,MAAM,CAAC,KAAC,GAAG,KAAG,CAAC,CAAC;IAClB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
/**
|
|
3
|
+
* Transforms asset import paths to use the development server base URL.
|
|
4
|
+
*/
|
|
5
|
+
export declare function assetBaseUrlTransform(code: string, devServerOrigin: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Vite plugin that transforms asset import paths to use the development server base URL.
|
|
8
|
+
*/
|
|
9
|
+
export declare function assetBaseUrlTransformPlugin(options: {
|
|
10
|
+
devServerOrigin: string;
|
|
11
|
+
}): Plugin;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transforms asset import paths to use the development server base URL.
|
|
3
|
+
*/
|
|
4
|
+
export function assetBaseUrlTransform(code, devServerOrigin) {
|
|
5
|
+
const assetStringPattern = /(?<!https?:\/\/)(["'`])(\/[^"'`]+\.(svg|png|jpeg|jpg|gif|webp|mp3|mp4|woff|woff2|ttf|eot))\1/g;
|
|
6
|
+
code = code.replace(assetStringPattern, (_match, quote, assetPath) => {
|
|
7
|
+
return `${quote}${devServerOrigin}${assetPath}${quote}`;
|
|
8
|
+
});
|
|
9
|
+
return code;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Vite plugin that transforms asset import paths to use the development server base URL.
|
|
13
|
+
*/
|
|
14
|
+
export function assetBaseUrlTransformPlugin(options) {
|
|
15
|
+
const { devServerOrigin } = options;
|
|
16
|
+
return {
|
|
17
|
+
name: "asset-base-url-transform",
|
|
18
|
+
enforce: "pre",
|
|
19
|
+
transform(code) {
|
|
20
|
+
if (!code) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const transformedCode = assetBaseUrlTransform(code, devServerOrigin);
|
|
24
|
+
if (transformedCode === code) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
code: transformedCode,
|
|
29
|
+
map: null,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=asset-base-url-transform-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-base-url-transform-plugin.js","sourceRoot":"","sources":["../../src/server/asset-base-url-transform-plugin.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,IAAY,EACZ,eAAuB;IAEvB,MAAM,kBAAkB,GACtB,+FAA+F,CAAC;IAElG,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;QACnE,OAAO,GAAG,KAAK,GAAG,eAAe,GAAG,SAAS,GAAG,KAAK,EAAE,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B,CAAC,OAE3C;IACC,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAEpC,OAAO;QACL,IAAI,EAAE,0BAA0B;QAChC,OAAO,EAAE,KAAK;QACd,SAAS,CAAC,IAAI;YACZ,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAM,eAAe,GAAG,qBAAqB,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;YAErE,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;gBAC7B,OAAO,IAAI,CAAC;YACd,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,eAAe;gBACrB,GAAG,EAAE,IAAI;aACV,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { assetBaseUrlTransform } from "./asset-base-url-transform-plugin.js";
|
|
3
|
+
describe("assetBaseUrlTransform", () => {
|
|
4
|
+
const devServerOrigin = "http://localhost:3000";
|
|
5
|
+
it("should transform asset paths in single, double, and backtick quotes", () => {
|
|
6
|
+
const cases = [
|
|
7
|
+
{
|
|
8
|
+
desc: "single-quoted",
|
|
9
|
+
code: `const image = '/assets/logo.png';`,
|
|
10
|
+
expected: `const image = '${devServerOrigin}/assets/logo.png';`,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
desc: "double-quoted",
|
|
14
|
+
code: `const image = "/assets/logo.png";`,
|
|
15
|
+
expected: `const image = "${devServerOrigin}/assets/logo.png";`,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
desc: "backtick-quoted",
|
|
19
|
+
code: "const image = `/assets/logo.png`;",
|
|
20
|
+
expected: `const image = \`${devServerOrigin}/assets/logo.png\`;`,
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
for (const { code, expected } of cases) {
|
|
24
|
+
const result = assetBaseUrlTransform(code, devServerOrigin);
|
|
25
|
+
expect(result).toBe(expected);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
it("should transform multiple asset paths", () => {
|
|
29
|
+
const code = `
|
|
30
|
+
const logo = '/assets/logo.png';
|
|
31
|
+
const icon = '/assets/icon.svg';
|
|
32
|
+
const font = '/assets/font.woff2';
|
|
33
|
+
`;
|
|
34
|
+
const result = assetBaseUrlTransform(code, devServerOrigin);
|
|
35
|
+
expect(result).toContain(`${devServerOrigin}/assets/logo.png`);
|
|
36
|
+
expect(result).toContain(`${devServerOrigin}/assets/icon.svg`);
|
|
37
|
+
expect(result).toContain(`${devServerOrigin}/assets/font.woff2`);
|
|
38
|
+
});
|
|
39
|
+
it("should not transform already absolute URLs", () => {
|
|
40
|
+
const code = `
|
|
41
|
+
const local = '/assets/logo.png';
|
|
42
|
+
const http = 'http://example.com/image.png';
|
|
43
|
+
const https = 'https://example.com/image.png';
|
|
44
|
+
`;
|
|
45
|
+
const result = assetBaseUrlTransform(code, devServerOrigin);
|
|
46
|
+
expect(result).toContain(`${devServerOrigin}/assets/logo.png`);
|
|
47
|
+
expect(result).toContain("http://example.com/image.png");
|
|
48
|
+
expect(result).toContain("https://example.com/image.png");
|
|
49
|
+
});
|
|
50
|
+
it("should not transform code without asset paths", () => {
|
|
51
|
+
const code = `const text = "Hello World";`;
|
|
52
|
+
const result = assetBaseUrlTransform(code, devServerOrigin);
|
|
53
|
+
expect(result).toBe(code);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=asset-base-url-transform-plugin.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-base-url-transform-plugin.test.js","sourceRoot":"","sources":["../../src/server/asset-base-url-transform-plugin.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,QAAQ,CAAC,uBAAuB,EAA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,qBAAqB,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;QAE5D,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,GAAG,eAAe,kBAAkB,CAAC,CAAC;QAC/D,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,8BAA8B,CAAC,CAAC;QACzD,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,+BAA+B,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,IAAI,GAAG,6BAA6B,CAAC;QAC3C,MAAM,MAAM,GAAG,qBAAqB,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;QAE5D,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
4
|
+
import cors from "cors";
|
|
5
|
+
import express from "express";
|
|
6
|
+
export async function createServer({ server, }) {
|
|
7
|
+
const app = express();
|
|
8
|
+
app.use(express.json());
|
|
9
|
+
const env = process.env.NODE_ENV || "development";
|
|
10
|
+
if (env !== "production") {
|
|
11
|
+
const { devtoolsStaticServer } = await import("@skybridge/devtools");
|
|
12
|
+
app.use(await devtoolsStaticServer());
|
|
13
|
+
const { widgetsDevServer } = await import("./widgetsDevServer.js");
|
|
14
|
+
app.use(await widgetsDevServer());
|
|
15
|
+
}
|
|
16
|
+
if (env === "production") {
|
|
17
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
+
const __dirname = path.dirname(__filename);
|
|
19
|
+
app.use("/assets", cors());
|
|
20
|
+
app.use("/assets", express.static(path.join(__dirname, "assets")));
|
|
21
|
+
}
|
|
22
|
+
app.use("/mcp", mcpMiddleware(server));
|
|
23
|
+
return app;
|
|
24
|
+
}
|
|
25
|
+
const mcpMiddleware = (server) => {
|
|
26
|
+
return async (req, res, _next) => {
|
|
27
|
+
if (req.method !== "POST") {
|
|
28
|
+
res.writeHead(405).end(JSON.stringify({
|
|
29
|
+
jsonrpc: "2.0",
|
|
30
|
+
error: {
|
|
31
|
+
code: -32000,
|
|
32
|
+
message: "Method not allowed.",
|
|
33
|
+
},
|
|
34
|
+
id: null,
|
|
35
|
+
}));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const transport = new StreamableHTTPServerTransport({
|
|
40
|
+
sessionIdGenerator: undefined,
|
|
41
|
+
});
|
|
42
|
+
res.on("close", () => {
|
|
43
|
+
transport.close();
|
|
44
|
+
});
|
|
45
|
+
await server.connect(transport);
|
|
46
|
+
await transport.handleRequest(req, res, req.body);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error("Error handling MCP request:", error);
|
|
50
|
+
if (!res.headersSent) {
|
|
51
|
+
res.status(500).json({
|
|
52
|
+
jsonrpc: "2.0",
|
|
53
|
+
error: {
|
|
54
|
+
code: -32603,
|
|
55
|
+
message: "Internal server error",
|
|
56
|
+
},
|
|
57
|
+
id: null,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=express.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../src/server/express.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,MAA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AAM,EAAE,CAAC;YAC1B,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,CACpB,IAAI,CAAC,SAAS,CAAC;gBACb,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE;oBACL,IAAI,EAAE,CAAC,KAAK;oBACZ,OAAO,EAAE,qBAAqB;iBAC/B;gBACD,EAAE,EAAE,IAAI;aACT,CAAC,CACH,CAAC;YACF,OAAO;QACT,CAAC;QAED,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,IAAI,6BAA6B,CAAC;gBAClD,kBAAkB,EAAE,SAAS;aAC9B,CAAC,CAAC;YAEH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;gBACnB,SAAS,CAAC,KAAK,EAAE,CAAC;YACpB,CAAC,CAAC,CAAC;YAEH,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAChC,MAAM,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;YACpD,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;gBACrB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;oBACnB,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE;wBACL,IAAI,EAAE,CAAC,KAAK;wBACZ,OAAO,EAAE,uBAAuB;qBACjC;oBACD,EAAE,EAAE,IAAI;iBACT,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { AnyToolRegistry, InferTools, ToolInput, ToolNames, ToolOutput, ToolResponseMetadata, } from "./inferUtilityTypes.js";
|
|
2
|
+
export type { McpServerTypes, ToolDef, WidgetHostType } from "./server.js";
|
|
3
|
+
export { McpServer } from "./server.js";
|
|
4
|
+
export { widgetsDevServer } from "./widgetsDevServer.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { McpServerTypes, ToolDef } from "./server.js";
|
|
2
|
+
/**
|
|
3
|
+
* Any tool registry shape (includes both widgets and regular tools).
|
|
4
|
+
* Used as a constraint for type parameters that accept tool registries.
|
|
5
|
+
*/
|
|
6
|
+
export type AnyToolRegistry = Record<string, ToolDef>;
|
|
7
|
+
/**
|
|
8
|
+
* Extract the tool registry type from an McpServer instance.
|
|
9
|
+
* This includes both widgets (registered via widget()) and regular tools (registered via registerTool()).
|
|
10
|
+
*
|
|
11
|
+
* Uses the `$types` property pattern for cross-package type inference.
|
|
12
|
+
* This works across package boundaries because TypeScript uses structural typing
|
|
13
|
+
* on the shape of `$types`, rather than nominal typing on the McpServer class itself.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* type MyTools = InferTools<MyServer>;
|
|
18
|
+
* // { "search": ToolDef<...>, "calculate": ToolDef<...> }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export type InferTools<ServerType> = ServerType extends {
|
|
22
|
+
$types: McpServerTypes<infer W>;
|
|
23
|
+
} ? W : never;
|
|
24
|
+
type ExtractTool<ServerType, K extends ToolNames<ServerType>> = InferTools<ServerType>[K];
|
|
25
|
+
/**
|
|
26
|
+
* Get a union of all tool names from an McpServer instance.
|
|
27
|
+
* This includes both widgets and regular tools.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* type Names = ToolNames<MyServer>;
|
|
32
|
+
* // "search" | "calculate" | "details"
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export type ToolNames<ServerType> = keyof InferTools<ServerType> & string;
|
|
36
|
+
/**
|
|
37
|
+
* Get the input type for a specific tool (widget or regular tool).
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* type SearchInput = ToolInput<MyServer, "search">;
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export type ToolInput<ServerType, ToolName extends ToolNames<ServerType>> = ExtractTool<ServerType, ToolName>["input"];
|
|
45
|
+
/**
|
|
46
|
+
* Get the output type for a specific tool (widget or regular tool).
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* type SearchOutput = ToolOutput<MyServer, "search">;
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export type ToolOutput<ServerType, ToolName extends ToolNames<ServerType>> = ExtractTool<ServerType, ToolName>["output"];
|
|
54
|
+
/**
|
|
55
|
+
* Get the responseMetadata type for a specific tool (widget or regular tool).
|
|
56
|
+
* This is inferred from the `_meta` property of the tool callback's return value.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* type SearchMeta = ToolResponseMetadata<MyServer, "search">;
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export type ToolResponseMetadata<ServerType, ToolName extends ToolNames<ServerType>> = ExtractTool<ServerType, ToolName>["responseMetadata"];
|
|
64
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inferUtilityTypes.js","sourceRoot":"","sources":["../../src/server/inferUtilityTypes.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { McpUiResourceMeta } from "@modelcontextprotocol/ext-apps";
|
|
2
|
+
import { McpServer as McpServerBase, type RegisteredTool } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import type { AnySchema, SchemaOutput, ZodRawShapeCompat } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
4
|
+
import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
5
|
+
import type { CallToolResult, Resource, ServerNotification, ServerRequest, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
6
|
+
import type { RequestHandler } from "express";
|
|
7
|
+
export type ToolDef<TInput = unknown, TOutput = unknown, TResponseMetadata = unknown> = {
|
|
8
|
+
input: TInput;
|
|
9
|
+
output: TOutput;
|
|
10
|
+
responseMetadata: TResponseMetadata;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Extended MCP Apps CSP with upcoming fields from ext-apps PR #158
|
|
14
|
+
* and Skybridge-specific fields for OpenAI compatibility
|
|
15
|
+
* @see https://github.com/modelcontextprotocol/ext-apps/pull/158
|
|
16
|
+
*/
|
|
17
|
+
type ExtendedMcpUiResourceCsp = McpUiResourceMeta["csp"] & {
|
|
18
|
+
/**
|
|
19
|
+
* Origins that can receive openExternal redirects without safe-link modal (OpenAI-specific)
|
|
20
|
+
* @see https://developers.openai.com/apps-sdk/reference#component-resource-_meta-fields
|
|
21
|
+
*/
|
|
22
|
+
redirectDomains?: string[];
|
|
23
|
+
};
|
|
24
|
+
/** Extended MCP Apps resource metadata with upcoming CSP fields */
|
|
25
|
+
type ExtendedMcpUiResourceMeta = Omit<McpUiResourceMeta, "csp"> & {
|
|
26
|
+
csp?: ExtendedMcpUiResourceCsp;
|
|
27
|
+
};
|
|
28
|
+
/** User-provided resource configuration with optional CSP override */
|
|
29
|
+
export type WidgetResourceMeta = {
|
|
30
|
+
ui?: ExtendedMcpUiResourceMeta;
|
|
31
|
+
} & Resource["_meta"];
|
|
32
|
+
export type WidgetHostType = "apps-sdk" | "mcp-app";
|
|
33
|
+
type McpServerOriginalResourceConfig = Omit<Resource, "uri" | "name" | "mimeType" | "_meta"> & {
|
|
34
|
+
_meta?: WidgetResourceMeta;
|
|
35
|
+
/** Restrict host types to a specific subset */
|
|
36
|
+
hosts?: WidgetHostType[];
|
|
37
|
+
};
|
|
38
|
+
type McpServerOriginalToolConfig = Omit<Parameters<typeof McpServerBase.prototype.registerTool<ZodRawShapeCompat, ZodRawShapeCompat>>[1], "inputSchema" | "outputSchema">;
|
|
39
|
+
type Simplify<T> = {
|
|
40
|
+
[K in keyof T]: T[K];
|
|
41
|
+
};
|
|
42
|
+
type ExtractStructuredContent<T> = T extends {
|
|
43
|
+
structuredContent: infer SC;
|
|
44
|
+
} ? Simplify<SC> : never;
|
|
45
|
+
type ExtractMeta<T> = [Extract<T, {
|
|
46
|
+
_meta: unknown;
|
|
47
|
+
}>] extends [never] ? unknown : Extract<T, {
|
|
48
|
+
_meta: unknown;
|
|
49
|
+
}> extends {
|
|
50
|
+
_meta: infer M;
|
|
51
|
+
} ? Simplify<M> : unknown;
|
|
52
|
+
/**
|
|
53
|
+
* Type-level marker interface for cross-package type inference.
|
|
54
|
+
* This enables TypeScript to infer tool types across package boundaries
|
|
55
|
+
* using structural typing on the $types property, rather than relying on
|
|
56
|
+
* class generic inference which fails when McpServer comes from different
|
|
57
|
+
* package installations.
|
|
58
|
+
*
|
|
59
|
+
* Inspired by tRPC's _def pattern and Hono's type markers.
|
|
60
|
+
*/
|
|
61
|
+
export interface McpServerTypes<TTools extends Record<string, ToolDef>> {
|
|
62
|
+
readonly tools: TTools;
|
|
63
|
+
}
|
|
64
|
+
type ShapeOutput<Shape extends ZodRawShapeCompat> = Simplify<{
|
|
65
|
+
[K in keyof Shape as undefined extends SchemaOutput<Shape[K]> ? never : K]: SchemaOutput<Shape[K]>;
|
|
66
|
+
} & {
|
|
67
|
+
[K in keyof Shape as undefined extends SchemaOutput<Shape[K]> ? K : never]?: SchemaOutput<Shape[K]>;
|
|
68
|
+
}>;
|
|
69
|
+
type AddTool<TTools, TName extends string, TInput extends ZodRawShapeCompat, TOutput, TResponseMetadata = unknown> = McpServer<TTools & {
|
|
70
|
+
[K in TName]: ToolDef<ShapeOutput<TInput>, TOutput, TResponseMetadata>;
|
|
71
|
+
}> & {
|
|
72
|
+
use(...handlers: RequestHandler[]): AddTool<TTools, TName, TInput, TOutput, TResponseMetadata>;
|
|
73
|
+
use(path: string, ...handlers: RequestHandler[]): AddTool<TTools, TName, TInput, TOutput, TResponseMetadata>;
|
|
74
|
+
run(): Promise<void>;
|
|
75
|
+
};
|
|
76
|
+
type ToolConfig<TInput extends ZodRawShapeCompat | AnySchema> = {
|
|
77
|
+
title?: string;
|
|
78
|
+
description?: string;
|
|
79
|
+
inputSchema?: TInput;
|
|
80
|
+
outputSchema?: ZodRawShapeCompat | AnySchema;
|
|
81
|
+
annotations?: ToolAnnotations;
|
|
82
|
+
_meta?: Record<string, unknown>;
|
|
83
|
+
};
|
|
84
|
+
type ToolHandler<TInput extends ZodRawShapeCompat, TReturn extends {
|
|
85
|
+
content: CallToolResult["content"];
|
|
86
|
+
} = CallToolResult> = (args: ShapeOutput<TInput>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => TReturn | Promise<TReturn>;
|
|
87
|
+
export declare class McpServer<TTools extends Record<string, ToolDef> = Record<never, ToolDef>> extends McpServerBase {
|
|
88
|
+
readonly $types: McpServerTypes<TTools>;
|
|
89
|
+
private express?;
|
|
90
|
+
private customMiddleware;
|
|
91
|
+
use(...handlers: RequestHandler[]): this;
|
|
92
|
+
use(path: string, ...handlers: RequestHandler[]): this;
|
|
93
|
+
run(): Promise<void>;
|
|
94
|
+
registerWidget<TName extends string, TInput extends ZodRawShapeCompat, TReturn extends {
|
|
95
|
+
content: CallToolResult["content"];
|
|
96
|
+
}>(name: TName, resourceConfig: McpServerOriginalResourceConfig, toolConfig: McpServerOriginalToolConfig & {
|
|
97
|
+
inputSchema?: TInput;
|
|
98
|
+
outputSchema?: ZodRawShapeCompat | AnySchema;
|
|
99
|
+
}, toolCallback: ToolHandler<TInput, TReturn>): AddTool<TTools, TName, TInput, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
|
|
100
|
+
registerTool<TName extends string, InputArgs extends ZodRawShapeCompat, TReturn extends {
|
|
101
|
+
content: CallToolResult["content"];
|
|
102
|
+
}>(name: TName, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs, TReturn>): AddTool<TTools, TName, InputArgs, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
|
|
103
|
+
registerTool<InputArgs extends ZodRawShapeCompat>(name: string, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs>): RegisteredTool;
|
|
104
|
+
private registerWidgetResource;
|
|
105
|
+
private lookupDistFile;
|
|
106
|
+
private lookupDistFileWithIndexFallback;
|
|
107
|
+
private readManifest;
|
|
108
|
+
}
|
|
109
|
+
export {};
|