skybridge 0.0.0-dev.6e31b21 → 0.0.0-dev.6f1dfd8
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/bin/run.js +9 -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/use-execute-steps.d.ts +10 -0
- package/dist/cli/use-execute-steps.js +31 -0
- package/dist/cli/use-execute-steps.js.map +1 -0
- package/dist/commands/build.d.ts +9 -0
- package/dist/commands/build.js +44 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/dev.d.ts +7 -0
- package/dist/commands/dev.js +20 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/start.d.ts +7 -0
- package/dist/commands/start.js +33 -0
- package/dist/commands/start.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 +99 -0
- package/dist/server/server.js +138 -0
- package/dist/server/server.js.map +1 -0
- package/dist/{src/server → server}/templateHelper.d.ts +3 -0
- package/dist/{src/server → server}/templateHelper.js +5 -4
- package/dist/server/templateHelper.js.map +1 -0
- package/dist/server/templates/development.hbs +66 -0
- package/dist/{src/server → server}/templates/production.hbs +1 -0
- package/dist/{src/server → server}/widgetsDevServer.d.ts +2 -2
- package/dist/{src/server → server}/widgetsDevServer.js +13 -5
- package/dist/server/widgetsDevServer.js.map +1 -0
- package/dist/test/utils.d.ts +135 -0
- package/dist/test/utils.js +242 -0
- package/dist/test/utils.js.map +1 -0
- package/dist/test/widget.test.js +255 -0
- package/dist/test/widget.test.js.map +1 -0
- package/dist/web/bridges/apps-sdk/adaptor.d.ts +14 -0
- package/dist/web/bridges/apps-sdk/adaptor.js +39 -0
- package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -0
- package/dist/web/bridges/apps-sdk/bridge.d.ts +10 -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/{src/web → web/bridges/apps-sdk}/types.d.ts +50 -45
- 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 +19 -0
- package/dist/web/bridges/mcp-app/adaptor.js +145 -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.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 +74 -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/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.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.js +139 -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.js +209 -0
- package/dist/web/generate-helpers.test-d.js.map +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.js +53 -0
- package/dist/web/helpers/state.test.js.map +1 -0
- package/dist/web/hooks/index.d.ts +10 -0
- package/dist/web/hooks/index.js +11 -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.js +104 -0
- package/dist/web/hooks/use-call-tool.test-d.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-call-tool.test.js +41 -15
- package/dist/web/hooks/use-call-tool.test.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-display-mode.d.ts +1 -1
- package/dist/web/hooks/use-display-mode.js +9 -0
- package/dist/web/hooks/use-display-mode.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-display-mode.test.js +3 -2
- package/dist/web/hooks/use-display-mode.test.js.map +1 -0
- package/dist/web/hooks/use-files.d.ts +10 -0
- package/dist/web/hooks/use-files.js +7 -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 +29 -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.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 +14 -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.js +8 -0
- package/dist/web/hooks/use-send-follow-up-message.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.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/{src/web → web}/hooks/use-widget-state.test.js +3 -2
- 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/{src/web → web}/mount-widget.js +5 -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.js +39 -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 +53 -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 +54 -31
- package/README.md +0 -198
- 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 -13
- package/dist/src/server/server.js +0 -57
- package/dist/src/server/server.js.map +0 -1
- package/dist/src/server/templateHelper.js.map +0 -1
- package/dist/src/server/templates/development.hbs +0 -12
- package/dist/src/server/widgetsDevServer.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 -90
- package/dist/src/test/widget.test.js.map +0 -1
- package/dist/src/web/hooks/index.d.ts +0 -13
- package/dist/src/web/hooks/index.js +0 -14
- package/dist/src/web/hooks/index.js.map +0 -1
- package/dist/src/web/hooks/use-call-tool.d.ts +0 -61
- package/dist/src/web/hooks/use-call-tool.js +0 -66
- package/dist/src/web/hooks/use-call-tool.js.map +0 -1
- package/dist/src/web/hooks/use-call-tool.test.js.map +0 -1
- package/dist/src/web/hooks/use-display-mode.js +0 -7
- package/dist/src/web/hooks/use-display-mode.js.map +0 -1
- package/dist/src/web/hooks/use-display-mode.test.js.map +0 -1
- package/dist/src/web/hooks/use-locale.d.ts +0 -1
- package/dist/src/web/hooks/use-locale.js +0 -5
- package/dist/src/web/hooks/use-locale.js.map +0 -1
- package/dist/src/web/hooks/use-locale.test.js +0 -21
- package/dist/src/web/hooks/use-locale.test.js.map +0 -1
- package/dist/src/web/hooks/use-open-external.js +0 -6
- package/dist/src/web/hooks/use-open-external.js.map +0 -1
- package/dist/src/web/hooks/use-open-external.test.js +0 -24
- package/dist/src/web/hooks/use-open-external.test.js.map +0 -1
- package/dist/src/web/hooks/use-openai-global.d.ts +0 -2
- package/dist/src/web/hooks/use-openai-global.js +0 -23
- package/dist/src/web/hooks/use-openai-global.js.map +0 -1
- package/dist/src/web/hooks/use-request-modal.d.ts +0 -5
- package/dist/src/web/hooks/use-request-modal.js +0 -9
- package/dist/src/web/hooks/use-request-modal.js.map +0 -1
- package/dist/src/web/hooks/use-request-modal.test.js +0 -24
- package/dist/src/web/hooks/use-request-modal.test.js.map +0 -1
- package/dist/src/web/hooks/use-send-follow-up-message.js +0 -11
- package/dist/src/web/hooks/use-send-follow-up-message.js.map +0 -1
- package/dist/src/web/hooks/use-theme.d.ts +0 -1
- package/dist/src/web/hooks/use-theme.js +0 -5
- package/dist/src/web/hooks/use-theme.js.map +0 -1
- package/dist/src/web/hooks/use-theme.test.js +0 -26
- package/dist/src/web/hooks/use-theme.test.js.map +0 -1
- package/dist/src/web/hooks/use-tool-info.d.ts +0 -23
- package/dist/src/web/hooks/use-tool-info.js +0 -22
- package/dist/src/web/hooks/use-tool-info.js.map +0 -1
- package/dist/src/web/hooks/use-tool-info.test.js +0 -134
- package/dist/src/web/hooks/use-tool-info.test.js.map +0 -1
- package/dist/src/web/hooks/use-tool-output.d.ts +0 -4
- package/dist/src/web/hooks/use-tool-output.js +0 -9
- package/dist/src/web/hooks/use-tool-output.js.map +0 -1
- package/dist/src/web/hooks/use-tool-response-metadata.d.ts +0 -4
- package/dist/src/web/hooks/use-tool-response-metadata.js +0 -8
- package/dist/src/web/hooks/use-tool-response-metadata.js.map +0 -1
- package/dist/src/web/hooks/use-user-agent.d.ts +0 -1
- package/dist/src/web/hooks/use-user-agent.js +0 -5
- package/dist/src/web/hooks/use-user-agent.js.map +0 -1
- package/dist/src/web/hooks/use-user-agent.test.js +0 -31
- package/dist/src/web/hooks/use-user-agent.test.js.map +0 -1
- package/dist/src/web/hooks/use-widget-state.js +0 -30
- package/dist/src/web/hooks/use-widget-state.js.map +0 -1
- package/dist/src/web/hooks/use-widget-state.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.map +0 -1
- package/dist/src/web/plugin.js +0 -28
- package/dist/src/web/plugin.js.map +0 -1
- package/dist/src/web/types.js.map +0 -1
- package/dist/vitest.config.d.ts +0 -2
- package/dist/vitest.config.js +0 -8
- package/dist/vitest.config.js.map +0 -1
- /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/hooks/use-call-tool.test.d.ts → web/bridges/mcp-app/use-mcp-app-context.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-display-mode.test.d.ts → web/create-store.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-locale.test.d.ts → web/data-llm.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-open-external.test.d.ts → web/generate-helpers.test-d.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-request-modal.test.d.ts → web/generate-helpers.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-theme.test.d.ts → web/helpers/state.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-tool-info.test.d.ts → web/hooks/use-call-tool.test-d.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-user-agent.test.d.ts → web/hooks/use-call-tool.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-widget-state.test.d.ts → web/hooks/use-display-mode.test.d.ts} +0 -0
- /package/dist/{src/web → web}/hooks/use-open-external.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-send-follow-up-message.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-widget-state.d.ts +0 -0
- /package/dist/{src/web → web}/mount-widget.d.ts +0 -0
- /package/dist/{src/web → web/plugin}/plugin.d.ts +0 -0
package/bin/run.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from "ink";
|
|
3
|
+
export const Header = ({ version, children, }) => {
|
|
4
|
+
return (_jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { color: "cyan", bold: true, children: ["\u26F0", " ", "Welcome to Skybridge"] }), _jsxs(Text, { color: "cyan", children: [" v", version] }), children] }));
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.js","sourceRoot":"","sources":["../../src/cli/header.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAEhC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EACrB,OAAO,EACP,QAAQ,GAIT,EAAE,EAAE;IACH,OAAO,CACL,MAAC,GAAG,IAAC,YAAY,EAAE,CAAC,aAClB,MAAC,IAAI,IAAC,KAAK,EAAC,MAAM,EAAC,IAAI,6BACnB,IAAI,4BACD,EACP,MAAC,IAAI,IAAC,KAAK,EAAC,MAAM,mBAAI,OAAO,IAAQ,EACpC,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
export function runCommand(command, options = {
|
|
3
|
+
stdio: ["ignore", "inherit", "inherit"],
|
|
4
|
+
}) {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
const stdoutChunks = [];
|
|
7
|
+
const stderrChunks = [];
|
|
8
|
+
const proc = spawn(command, {
|
|
9
|
+
...options,
|
|
10
|
+
shell: true,
|
|
11
|
+
});
|
|
12
|
+
if (proc.stdout) {
|
|
13
|
+
proc.stdout.on("data", (chunk) => {
|
|
14
|
+
stdoutChunks.push(chunk);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (proc.stderr) {
|
|
18
|
+
proc.stderr.on("data", (chunk) => {
|
|
19
|
+
stderrChunks.push(chunk);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
proc.on("close", (code) => {
|
|
23
|
+
if (code === 0) {
|
|
24
|
+
resolve();
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const stdoutOutput = Buffer.concat(stdoutChunks).toString();
|
|
28
|
+
const stderrOutput = Buffer.concat(stderrChunks).toString();
|
|
29
|
+
const allOutput = [stdoutOutput, stderrOutput]
|
|
30
|
+
.filter((output) => output.trim())
|
|
31
|
+
.join("\n");
|
|
32
|
+
const errorMessage = allOutput
|
|
33
|
+
? `Command failed with exit code ${code}\n${allOutput}`
|
|
34
|
+
: `Command failed with exit code ${code}`;
|
|
35
|
+
reject(new Error(errorMessage));
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
proc.on("error", (error) => {
|
|
39
|
+
reject(error);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=run-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-command.js","sourceRoot":"","sources":["../../src/cli/run-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE9D,MAAM,UAAU,UAAU,CACxB,OAAe,EACf,UAAwB;IACtB,KAAK,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;CACxC;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,YAAY,GAAa,EAAE,CAAC;QAClC,MAAM,YAAY,GAAa,EAAE,CAAC;QAElC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,EAAE;YAC1B,GAAG,OAAO;YACV,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBAC/B,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBAC/B,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACxB,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,OAAO,EAAE,CAAC;YACZ,CAAC;iBAAM,CAAC;gBACN,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;gBAC5D,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;gBAC5D,MAAM,SAAS,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC;qBAC3C,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;qBACjC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACd,MAAM,YAAY,GAAG,SAAS;oBAC5B,CAAC,CAAC,iCAAiC,IAAI,KAAK,SAAS,EAAE;oBACvD,CAAC,CAAC,iCAAiC,IAAI,EAAE,CAAC;gBAC5C,MAAM,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;YAClC,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACzB,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface CommandStep {
|
|
2
|
+
label: string;
|
|
3
|
+
command: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const useExecuteSteps: (steps: CommandStep[]) => {
|
|
6
|
+
currentStep: number;
|
|
7
|
+
status: "error" | "running" | "success";
|
|
8
|
+
error: string | null;
|
|
9
|
+
execute: () => Promise<void>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
import { runCommand } from "./run-command.js";
|
|
3
|
+
export const useExecuteSteps = (steps) => {
|
|
4
|
+
const [currentStep, setCurrentStep] = useState(0);
|
|
5
|
+
const [status, setStatus] = useState("running");
|
|
6
|
+
const [error, setError] = useState(null);
|
|
7
|
+
const execute = useCallback(async () => {
|
|
8
|
+
try {
|
|
9
|
+
for (let i = 0; i < steps.length; i++) {
|
|
10
|
+
const step = steps[i];
|
|
11
|
+
if (step) {
|
|
12
|
+
setCurrentStep(i);
|
|
13
|
+
await runCommand(step.command);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
setStatus("success");
|
|
17
|
+
setImmediate(() => {
|
|
18
|
+
process.exit(0);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
setStatus("error");
|
|
23
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
24
|
+
setImmediate(() => {
|
|
25
|
+
process.exit(1);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}, [steps]);
|
|
29
|
+
return { currentStep, status, error, execute };
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=use-execute-steps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-execute-steps.js","sourceRoot":"","sources":["../../src/cli/use-execute-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAO9C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAoB,EAAE,EAAE;IACtD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAS,CAAC,CAAC,CAAC;IAC1D,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAClC,SAAS,CACV,CAAC;IACF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAExD,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACrC,IAAI,CAAC;YACH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBACtB,IAAI,IAAI,EAAE,CAAC;oBACT,cAAc,CAAC,CAAC,CAAC,CAAC;oBAClB,MAAM,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACjC,CAAC;YACH,CAAC;YACD,SAAS,CAAC,SAAS,CAAC,CAAC;YACrB,YAAY,CAAC,GAAG,EAAE;gBAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,SAAS,CAAC,OAAO,CAAC,CAAC;YACnB,QAAQ,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3D,YAAY,CAAC,GAAG,EAAE;gBAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACjD,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import { type CommandStep } from "../cli/use-execute-steps.js";
|
|
3
|
+
export declare const commandSteps: CommandStep[];
|
|
4
|
+
export default class Build extends Command {
|
|
5
|
+
static description: string;
|
|
6
|
+
static examples: string[];
|
|
7
|
+
static flags: {};
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 { useEffect } from "react";
|
|
5
|
+
import { Header } from "../cli/header.js";
|
|
6
|
+
import { useExecuteSteps } from "../cli/use-execute-steps.js";
|
|
7
|
+
export const commandSteps = [
|
|
8
|
+
{
|
|
9
|
+
label: "Building widgets",
|
|
10
|
+
command: "vite build -c web/vite.config.ts",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
label: "Compiling server",
|
|
14
|
+
command: "shx rm -rf dist && tsc -p tsconfig.server.json",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
label: "Copying static assets",
|
|
18
|
+
command: "shx cp -r web/dist dist/assets",
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
export default class Build extends Command {
|
|
22
|
+
static description = "Build the widgets and MCP server";
|
|
23
|
+
static examples = ["skybridge build"];
|
|
24
|
+
static flags = {};
|
|
25
|
+
async run() {
|
|
26
|
+
const App = () => {
|
|
27
|
+
const { currentStep, status, error, execute } = useExecuteSteps(commandSteps);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
execute();
|
|
30
|
+
}, [execute]);
|
|
31
|
+
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) => {
|
|
32
|
+
const isCurrent = index === currentStep && status === "running";
|
|
33
|
+
const isCompleted = index < currentStep || status === "success";
|
|
34
|
+
const isError = status === "error" && index === currentStep;
|
|
35
|
+
return (_jsx(Box, { marginBottom: 0, children: _jsxs(Text, { color: isError ? "red" : isCompleted ? "green" : "grey", children: [isError ? "✗" : isCompleted ? "✓" : isCurrent ? "⟳" : "○", " ", step.label] }) }, step.label));
|
|
36
|
+
}), 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))) })] }))] }));
|
|
37
|
+
};
|
|
38
|
+
render(_jsx(App, {}), {
|
|
39
|
+
exitOnCtrlC: true,
|
|
40
|
+
patchConsole: false,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.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,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,OAAO,EAAE,gDAAgD;KAC1D;IACD;QACE,KAAK,EAAE,uBAAuB;QAC9B,OAAO,EAAE,gCAAgC;KAC1C;CACF,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,OAAO;IACxC,MAAM,CAAU,WAAW,GAAG,kCAAkC,CAAC;IACjE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,KAAK,IACN,IAJC,IAAI,CAAC,KAAK,CAKd,CACP,CAAC;oBACJ,CAAC,CAAC,EAED,MAAM,KAAK,SAAS,IAAI,CACvB,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,YACf,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,2DAEjB,GACH,CACP,EAEA,MAAM,KAAK,OAAO,IAAI,KAAK,IAAI,CAC9B,MAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ,aACvC,KAAC,IAAI,IAAC,KAAK,EAAC,KAAK,EAAC,IAAI,0CAEf,EACP,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ,YACtC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAC/B,KAAC,IAAI,IAAY,KAAK,EAAC,KAAK,YACzB,IAAI,IADI,IAAI,CAER,CACR,CAAC,GACE,IACF,CACP,IACG,CACP,CAAC;QACJ,CAAC,CAAC;QAEF,MAAM,CAAC,KAAC,GAAG,KAAG,EAAE;YACd,WAAW,EAAE,IAAI;YACjB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;IACL,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 { Header } from "../cli/header.js";
|
|
5
|
+
import { runCommand } from "../cli/run-command.js";
|
|
6
|
+
export default class Dev extends Command {
|
|
7
|
+
static description = "Start development server";
|
|
8
|
+
static examples = ["skybridge"];
|
|
9
|
+
static flags = {};
|
|
10
|
+
async run() {
|
|
11
|
+
runCommand("nodemon --quiet", {
|
|
12
|
+
stdio: ["ignore", "ignore", "inherit"],
|
|
13
|
+
});
|
|
14
|
+
const App = () => {
|
|
15
|
+
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" })] }) })] }));
|
|
16
|
+
};
|
|
17
|
+
render(_jsx(App, {}), { exitOnCtrlC: true, patchConsole: false });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//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EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9D,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { Command } from "@oclif/core";
|
|
5
|
+
import { Box, render, Text } from "ink";
|
|
6
|
+
import { Header } from "../cli/header.js";
|
|
7
|
+
import { runCommand } from "../cli/run-command.js";
|
|
8
|
+
export default class Start extends Command {
|
|
9
|
+
static description = "Start production server";
|
|
10
|
+
static examples = ["skybridge start"];
|
|
11
|
+
static flags = {};
|
|
12
|
+
async run() {
|
|
13
|
+
console.clear();
|
|
14
|
+
const distPath = resolve(process.cwd(), "dist/index.js");
|
|
15
|
+
if (!existsSync(distPath)) {
|
|
16
|
+
console.error("❌ Error: dist/index.js not found");
|
|
17
|
+
console.error("");
|
|
18
|
+
console.error("Please build your project first:");
|
|
19
|
+
console.error(" skybridge build");
|
|
20
|
+
console.error("");
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
runCommand("node dist/index.js", {
|
|
24
|
+
stdio: ["ignore", "ignore", "inherit"],
|
|
25
|
+
env: { ...process.env, NODE_ENV: "production" },
|
|
26
|
+
});
|
|
27
|
+
const App = () => {
|
|
28
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, marginLeft: 1, children: [_jsx(Header, { version: this.config.version }), _jsxs(Box, { children: [_jsx(Text, { children: "Server running at: " }), _jsx(Text, { color: "green", bold: true, children: "http://localhost:3000/mcp" })] })] }));
|
|
29
|
+
};
|
|
30
|
+
render(_jsx(App, {}), { exitOnCtrlC: true, patchConsole: false });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.tsx"],"names":[],"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AAM,GAAG,GAAG,GAAG,EAAE;YACf,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,aACnD,KAAC,MAAM,IAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,GAAI,EACxC,MAAC,GAAG,eACF,KAAC,IAAI,sCAA2B,EAChC,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,gDAEjB,IACH,IACF,CACP,CAAC;QACJ,CAAC,CAAC;QAEF,MAAM,CAAC,KAAC,GAAG,KAAG,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9D,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,99 @@
|
|
|
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
|
+
export type ToolDef<TInput = unknown, TOutput = unknown, TResponseMetadata = unknown> = {
|
|
7
|
+
input: TInput;
|
|
8
|
+
output: TOutput;
|
|
9
|
+
responseMetadata: TResponseMetadata;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Extended MCP Apps CSP with upcoming fields from ext-apps PR #158
|
|
13
|
+
* and Skybridge-specific fields for OpenAI compatibility
|
|
14
|
+
* @see https://github.com/modelcontextprotocol/ext-apps/pull/158
|
|
15
|
+
*/
|
|
16
|
+
type ExtendedMcpUiResourceCsp = McpUiResourceMeta["csp"] & {
|
|
17
|
+
/**
|
|
18
|
+
* Origins that can receive openExternal redirects without safe-link modal (OpenAI-specific)
|
|
19
|
+
* @see https://developers.openai.com/apps-sdk/reference#component-resource-_meta-fields
|
|
20
|
+
*/
|
|
21
|
+
redirectDomains?: string[];
|
|
22
|
+
};
|
|
23
|
+
/** Extended MCP Apps resource metadata with upcoming CSP fields */
|
|
24
|
+
type ExtendedMcpUiResourceMeta = Omit<McpUiResourceMeta, "csp"> & {
|
|
25
|
+
csp?: ExtendedMcpUiResourceCsp;
|
|
26
|
+
};
|
|
27
|
+
/** User-provided resource configuration with optional CSP override */
|
|
28
|
+
export type WidgetResourceMeta = {
|
|
29
|
+
ui?: ExtendedMcpUiResourceMeta;
|
|
30
|
+
} & Resource["_meta"];
|
|
31
|
+
export type WidgetHostType = "apps-sdk" | "mcp-app";
|
|
32
|
+
type McpServerOriginalResourceConfig = Omit<Resource, "uri" | "name" | "mimeType" | "_meta"> & {
|
|
33
|
+
_meta?: WidgetResourceMeta;
|
|
34
|
+
/** Restrict host types to a specific subset */
|
|
35
|
+
hosts?: WidgetHostType[];
|
|
36
|
+
};
|
|
37
|
+
type McpServerOriginalToolConfig = Omit<Parameters<typeof McpServerBase.prototype.registerTool<ZodRawShapeCompat, ZodRawShapeCompat>>[1], "inputSchema" | "outputSchema">;
|
|
38
|
+
type Simplify<T> = {
|
|
39
|
+
[K in keyof T]: T[K];
|
|
40
|
+
};
|
|
41
|
+
type ExtractStructuredContent<T> = T extends {
|
|
42
|
+
structuredContent: infer SC;
|
|
43
|
+
} ? Simplify<SC> : never;
|
|
44
|
+
type ExtractMeta<T> = [Extract<T, {
|
|
45
|
+
_meta: unknown;
|
|
46
|
+
}>] extends [never] ? unknown : Extract<T, {
|
|
47
|
+
_meta: unknown;
|
|
48
|
+
}> extends {
|
|
49
|
+
_meta: infer M;
|
|
50
|
+
} ? Simplify<M> : unknown;
|
|
51
|
+
/**
|
|
52
|
+
* Type-level marker interface for cross-package type inference.
|
|
53
|
+
* This enables TypeScript to infer tool types across package boundaries
|
|
54
|
+
* using structural typing on the $types property, rather than relying on
|
|
55
|
+
* class generic inference which fails when McpServer comes from different
|
|
56
|
+
* package installations.
|
|
57
|
+
*
|
|
58
|
+
* Inspired by tRPC's _def pattern and Hono's type markers.
|
|
59
|
+
*/
|
|
60
|
+
export interface McpServerTypes<TTools extends Record<string, ToolDef>> {
|
|
61
|
+
readonly tools: TTools;
|
|
62
|
+
}
|
|
63
|
+
type ShapeOutput<Shape extends ZodRawShapeCompat> = Simplify<{
|
|
64
|
+
[K in keyof Shape as undefined extends SchemaOutput<Shape[K]> ? never : K]: SchemaOutput<Shape[K]>;
|
|
65
|
+
} & {
|
|
66
|
+
[K in keyof Shape as undefined extends SchemaOutput<Shape[K]> ? K : never]?: SchemaOutput<Shape[K]>;
|
|
67
|
+
}>;
|
|
68
|
+
type AddTool<TTools, TName extends string, TInput extends ZodRawShapeCompat, TOutput, TResponseMetadata = unknown> = McpServer<TTools & {
|
|
69
|
+
[K in TName]: ToolDef<ShapeOutput<TInput>, TOutput, TResponseMetadata>;
|
|
70
|
+
}>;
|
|
71
|
+
type ToolConfig<TInput extends ZodRawShapeCompat | AnySchema> = {
|
|
72
|
+
title?: string;
|
|
73
|
+
description?: string;
|
|
74
|
+
inputSchema?: TInput;
|
|
75
|
+
outputSchema?: ZodRawShapeCompat | AnySchema;
|
|
76
|
+
annotations?: ToolAnnotations;
|
|
77
|
+
_meta?: Record<string, unknown>;
|
|
78
|
+
};
|
|
79
|
+
type ToolHandler<TInput extends ZodRawShapeCompat, TReturn extends {
|
|
80
|
+
content: CallToolResult["content"];
|
|
81
|
+
} = CallToolResult> = (args: ShapeOutput<TInput>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => TReturn | Promise<TReturn>;
|
|
82
|
+
export declare class McpServer<TTools extends Record<string, ToolDef> = Record<never, ToolDef>> extends McpServerBase {
|
|
83
|
+
readonly $types: McpServerTypes<TTools>;
|
|
84
|
+
registerWidget<TName extends string, TInput extends ZodRawShapeCompat, TReturn extends {
|
|
85
|
+
content: CallToolResult["content"];
|
|
86
|
+
}>(name: TName, resourceConfig: McpServerOriginalResourceConfig, toolConfig: McpServerOriginalToolConfig & {
|
|
87
|
+
inputSchema?: TInput;
|
|
88
|
+
outputSchema?: ZodRawShapeCompat | AnySchema;
|
|
89
|
+
}, toolCallback: ToolHandler<TInput, TReturn>): AddTool<TTools, TName, TInput, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
|
|
90
|
+
registerTool<TName extends string, InputArgs extends ZodRawShapeCompat, TReturn extends {
|
|
91
|
+
content: CallToolResult["content"];
|
|
92
|
+
}>(name: TName, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs, TReturn>): AddTool<TTools, TName, InputArgs, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
|
|
93
|
+
registerTool<InputArgs extends ZodRawShapeCompat>(name: string, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs>): RegisteredTool;
|
|
94
|
+
private registerWidgetResource;
|
|
95
|
+
private lookupDistFile;
|
|
96
|
+
private lookupDistFileWithIndexFallback;
|
|
97
|
+
private readManifest;
|
|
98
|
+
}
|
|
99
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { McpServer as McpServerBase, } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
import { mergeWith, union } from "es-toolkit";
|
|
5
|
+
import { templateHelper } from "./templateHelper.js";
|
|
6
|
+
const mergeWithUnion = (target, source) => {
|
|
7
|
+
return mergeWith(target, source, (targetVal, sourceVal) => {
|
|
8
|
+
if (Array.isArray(targetVal) && Array.isArray(sourceVal)) {
|
|
9
|
+
return union(targetVal, sourceVal);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
export class McpServer extends McpServerBase {
|
|
14
|
+
registerWidget(name, resourceConfig, toolConfig, toolCallback) {
|
|
15
|
+
const userMeta = resourceConfig._meta;
|
|
16
|
+
const toolMeta = {
|
|
17
|
+
...toolConfig._meta,
|
|
18
|
+
};
|
|
19
|
+
if (!resourceConfig.hosts || resourceConfig.hosts.includes("apps-sdk")) {
|
|
20
|
+
const widgetConfig = {
|
|
21
|
+
hostType: "apps-sdk",
|
|
22
|
+
uri: `ui://widgets/apps-sdk/${name}.html`,
|
|
23
|
+
mimeType: "text/html+skybridge",
|
|
24
|
+
buildContentMeta: ({ resourceDomains, connectDomains, domain }) => {
|
|
25
|
+
const userUi = userMeta?.ui;
|
|
26
|
+
const userCsp = userUi?.csp;
|
|
27
|
+
const defaults = {
|
|
28
|
+
"openai/widgetCSP": {
|
|
29
|
+
resource_domains: resourceDomains,
|
|
30
|
+
connect_domains: connectDomains,
|
|
31
|
+
},
|
|
32
|
+
"openai/widgetDomain": domain,
|
|
33
|
+
"openai/widgetDescription": toolConfig.description,
|
|
34
|
+
};
|
|
35
|
+
const fromUi = {
|
|
36
|
+
"openai/widgetCSP": {
|
|
37
|
+
resource_domains: userCsp?.resourceDomains,
|
|
38
|
+
connect_domains: userCsp?.connectDomains,
|
|
39
|
+
frame_domains: userCsp?.frameDomains,
|
|
40
|
+
redirect_domains: userCsp?.redirectDomains,
|
|
41
|
+
},
|
|
42
|
+
"openai/widgetDomain": userUi?.domain,
|
|
43
|
+
"openai/widgetPrefersBorder": userUi?.prefersBorder,
|
|
44
|
+
};
|
|
45
|
+
const directOpenaiKeys = Object.fromEntries(Object.entries(userMeta ?? {}).filter(([key]) => key.startsWith("openai/")));
|
|
46
|
+
return mergeWithUnion(mergeWithUnion(defaults, fromUi), directOpenaiKeys);
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
this.registerWidgetResource({
|
|
50
|
+
name,
|
|
51
|
+
widgetConfig,
|
|
52
|
+
resourceConfig,
|
|
53
|
+
});
|
|
54
|
+
toolMeta["openai/outputTemplate"] = widgetConfig.uri;
|
|
55
|
+
}
|
|
56
|
+
if (!resourceConfig.hosts || resourceConfig.hosts.includes("mcp-app")) {
|
|
57
|
+
const widgetConfig = {
|
|
58
|
+
hostType: "mcp-app",
|
|
59
|
+
uri: `ui://widgets/ext-apps/${name}.html`,
|
|
60
|
+
mimeType: "text/html;profile=mcp-app",
|
|
61
|
+
buildContentMeta: ({ resourceDomains, connectDomains, domain }) => {
|
|
62
|
+
const defaults = {
|
|
63
|
+
ui: {
|
|
64
|
+
csp: {
|
|
65
|
+
resourceDomains,
|
|
66
|
+
connectDomains,
|
|
67
|
+
},
|
|
68
|
+
domain,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
return mergeWithUnion(defaults, { ui: userMeta?.ui });
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
this.registerWidgetResource({
|
|
75
|
+
name,
|
|
76
|
+
widgetConfig,
|
|
77
|
+
resourceConfig,
|
|
78
|
+
});
|
|
79
|
+
toolMeta.ui = { resourceUri: widgetConfig.uri };
|
|
80
|
+
}
|
|
81
|
+
this.registerTool(name, {
|
|
82
|
+
...toolConfig,
|
|
83
|
+
_meta: toolMeta,
|
|
84
|
+
}, toolCallback);
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
registerTool(name, config, cb) {
|
|
88
|
+
super.registerTool(name, config, cb);
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
registerWidgetResource({ name, widgetConfig, resourceConfig, }) {
|
|
92
|
+
const { hostType, uri: widgetUri, mimeType, buildContentMeta, } = widgetConfig;
|
|
93
|
+
this.registerResource(name, widgetUri, { ...resourceConfig, _meta: resourceConfig._meta }, async (uri, extra) => {
|
|
94
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
95
|
+
const serverUrl = isProduction
|
|
96
|
+
? `https://${extra?.requestInfo?.headers?.["x-forwarded-host"] ?? extra?.requestInfo?.headers?.host}`
|
|
97
|
+
: "http://localhost:3000";
|
|
98
|
+
const html = isProduction
|
|
99
|
+
? templateHelper.renderProduction({
|
|
100
|
+
hostType,
|
|
101
|
+
serverUrl,
|
|
102
|
+
widgetFile: this.lookupDistFileWithIndexFallback(`src/widgets/${name}`),
|
|
103
|
+
styleFile: this.lookupDistFile("style.css"),
|
|
104
|
+
})
|
|
105
|
+
: templateHelper.renderDevelopment({
|
|
106
|
+
hostType,
|
|
107
|
+
serverUrl,
|
|
108
|
+
widgetName: name,
|
|
109
|
+
});
|
|
110
|
+
const VITE_HMR_WEBSOCKET_DEFAULT_URL = "ws://localhost:24678";
|
|
111
|
+
const contentMeta = buildContentMeta({
|
|
112
|
+
resourceDomains: [serverUrl],
|
|
113
|
+
connectDomains: !isProduction ? [VITE_HMR_WEBSOCKET_DEFAULT_URL] : [],
|
|
114
|
+
domain: serverUrl,
|
|
115
|
+
baseUriDomains: [serverUrl],
|
|
116
|
+
});
|
|
117
|
+
return {
|
|
118
|
+
contents: [
|
|
119
|
+
{ uri: uri.href, mimeType, text: html, _meta: contentMeta },
|
|
120
|
+
],
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
lookupDistFile(key) {
|
|
125
|
+
const manifest = this.readManifest();
|
|
126
|
+
return manifest[key]?.file;
|
|
127
|
+
}
|
|
128
|
+
lookupDistFileWithIndexFallback(basePath) {
|
|
129
|
+
const manifest = this.readManifest();
|
|
130
|
+
const flatFileKey = `${basePath}.tsx`;
|
|
131
|
+
const indexFileKey = `${basePath}/index.tsx`;
|
|
132
|
+
return manifest[flatFileKey]?.file ?? manifest[indexFileKey]?.file;
|
|
133
|
+
}
|
|
134
|
+
readManifest() {
|
|
135
|
+
return JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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ErC,MAAM,WAAW,GAAG,GAAG,QAAQ,MAAM,CAAC;QACtC,MAAM,YAAY,GAAG,GAAG,QAAQ,YAAY,CAAC;QAC7C,OAAO,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,IAAI,QAAQ,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC;IACrE,CAAC;IAEO,YAAY;QAClB,OAAO,IAAI,CAAC,KAAK,CACf,YAAY,CACV,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,CAAC,EACpE,OAAO,CACR,CACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import type { WidgetHostType } from "./server.js";
|
|
1
2
|
declare class TemplateHelper {
|
|
2
3
|
private templateCache;
|
|
3
4
|
private loadTemplate;
|
|
4
5
|
renderProduction(data: {
|
|
6
|
+
hostType: WidgetHostType;
|
|
5
7
|
serverUrl: string;
|
|
6
8
|
widgetFile: string;
|
|
7
9
|
styleFile: string;
|
|
8
10
|
}): string;
|
|
9
11
|
renderDevelopment(data: {
|
|
12
|
+
hostType: WidgetHostType;
|
|
10
13
|
serverUrl: string;
|
|
11
14
|
widgetName: string;
|
|
12
15
|
}): string;
|