skybridge 0.0.0-dev.8c3e153 → 0.0.0-dev.8cc4309
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/bin/run.js +9 -0
- package/dist/cli/run-command.d.ts +1 -0
- package/dist/cli/run-command.js +40 -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 +35 -0
- package/dist/cli/use-execute-steps.js.map +1 -0
- package/dist/commands/build.d.ts +9 -0
- package/dist/commands/build.js +43 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/dev.d.ts +7 -0
- package/dist/commands/dev.js +19 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/{src/server → server}/index.d.ts +1 -2
- package/dist/{src/server → server}/index.js +0 -1
- package/dist/server/index.js.map +1 -0
- package/dist/server/inferUtilityTypes.js.map +1 -0
- package/dist/{src/server → server}/server.d.ts +49 -10
- package/dist/server/server.js +132 -0
- package/dist/server/server.js.map +1 -0
- package/dist/{src/server → server}/templateHelper.d.ts +3 -0
- 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 +11 -3
- package/dist/server/widgetsDevServer.js.map +1 -0
- package/dist/{src/test → test}/utils.d.ts +11 -0
- package/dist/{src/test → test}/utils.js +20 -0
- package/dist/test/utils.js.map +1 -0
- package/dist/test/widget.test.js +234 -0
- package/dist/test/widget.test.js.map +1 -0
- package/dist/web/bridges/adaptors/apps-sdk-adaptor.d.ts +14 -0
- package/dist/web/bridges/adaptors/apps-sdk-adaptor.js +36 -0
- package/dist/web/bridges/adaptors/apps-sdk-adaptor.js.map +1 -0
- package/dist/web/bridges/adaptors/mcp-app-adaptor.d.ts +19 -0
- package/dist/web/bridges/adaptors/mcp-app-adaptor.js +137 -0
- package/dist/web/bridges/adaptors/mcp-app-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/hooks/use-adaptor.d.ts +2 -0
- package/dist/web/bridges/hooks/use-adaptor.js +8 -0
- package/dist/web/bridges/hooks/use-adaptor.js.map +1 -0
- package/dist/web/bridges/hooks/use-apps-sdk-bridge.d.ts +2 -0
- package/dist/web/bridges/hooks/use-apps-sdk-bridge.js +7 -0
- package/dist/web/bridges/hooks/use-apps-sdk-bridge.js.map +1 -0
- package/dist/web/bridges/hooks/use-bridge.d.ts +2 -0
- package/dist/web/bridges/hooks/use-bridge.js +8 -0
- package/dist/web/bridges/hooks/use-bridge.js.map +1 -0
- package/dist/web/bridges/hooks/use-mcp-app-bridge.d.ts +5 -0
- package/dist/web/bridges/hooks/use-mcp-app-bridge.js +7 -0
- package/dist/web/bridges/hooks/use-mcp-app-bridge.js.map +1 -0
- package/dist/web/bridges/hooks/use-mcp-app-bridge.test.js +62 -0
- package/dist/web/bridges/hooks/use-mcp-app-bridge.test.js.map +1 -0
- package/dist/web/bridges/index.d.ts +4 -0
- package/dist/web/bridges/index.js +5 -0
- package/dist/web/bridges/index.js.map +1 -0
- package/dist/web/bridges/mcp-app-bridge.d.ts +49 -0
- package/dist/web/bridges/mcp-app-bridge.js +256 -0
- package/dist/web/bridges/mcp-app-bridge.js.map +1 -0
- package/dist/web/bridges/types.d.ts +59 -0
- package/dist/web/bridges/types.js +2 -0
- package/dist/web/bridges/types.js.map +1 -0
- package/dist/web/create-store.js.map +1 -0
- package/dist/web/create-store.test.js.map +1 -0
- package/dist/{src/web → web}/data-llm.js +4 -2
- package/dist/web/data-llm.js.map +1 -0
- package/dist/web/data-llm.test.js.map +1 -0
- package/dist/web/generate-helpers.js.map +1 -0
- package/dist/{src/web → web}/generate-helpers.test-d.js +31 -2
- package/dist/web/generate-helpers.test-d.js.map +1 -0
- package/dist/web/generate-helpers.test.js.map +1 -0
- package/dist/web/helpers/state.js.map +1 -0
- package/dist/web/helpers/state.test.js.map +1 -0
- package/dist/{src/web → web}/hooks/index.d.ts +2 -3
- package/dist/{src/web → web}/hooks/index.js +2 -3
- package/dist/web/hooks/index.js.map +1 -0
- package/dist/web/hooks/test/utils.d.ts +10 -0
- package/dist/web/hooks/test/utils.js +40 -0
- package/dist/web/hooks/test/utils.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-call-tool.d.ts +1 -1
- package/dist/{src/web → web}/hooks/use-call-tool.js +12 -4
- package/dist/web/hooks/use-call-tool.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-call-tool.test-d.js +1 -1
- package/dist/web/hooks/use-call-tool.test-d.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-call-tool.test.js +28 -3
- 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 +10 -0
- package/dist/web/hooks/use-display-mode.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-display-mode.test.js +1 -0
- package/dist/web/hooks/use-display-mode.test.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-files.d.ts +1 -1
- package/dist/web/hooks/use-files.js +7 -0
- package/dist/web/hooks/use-files.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-files.test.js +4 -4
- 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.js +95 -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.js +50 -0
- package/dist/web/hooks/use-open-external.test.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-openai-global.d.ts +2 -1
- package/dist/web/hooks/use-openai-global.js +6 -0
- package/dist/web/hooks/use-openai-global.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.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/{src/web → web}/hooks/use-tool-info.d.ts +12 -1
- package/dist/web/hooks/use-tool-info.js +26 -0
- package/dist/web/hooks/use-tool-info.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-tool-info.test-d.js +40 -4
- package/dist/web/hooks/use-tool-info.test-d.js.map +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.js +93 -0
- package/dist/web/hooks/use-user.test.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-widget-state.js +10 -9
- package/dist/web/hooks/use-widget-state.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-widget-state.test.js +1 -0
- package/dist/web/hooks/use-widget-state.test.js.map +1 -0
- package/dist/{src/web → web}/index.d.ts +1 -0
- package/dist/{src/web → web}/index.js +1 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/mount-widget.js.map +1 -0
- package/dist/web/plugin/data-llm.test.js.map +1 -0
- package/dist/{src/web → web}/plugin/plugin.js +10 -4
- package/dist/web/plugin/plugin.js.map +1 -0
- package/dist/{src/web → web}/plugin/transform-data-llm.js +6 -3
- package/dist/web/plugin/transform-data-llm.js.map +1 -0
- package/dist/web/plugin/transform-data-llm.test.js.map +1 -0
- package/dist/{src/web → web}/proxy.js +5 -0
- package/dist/web/proxy.js.map +1 -0
- package/dist/{src/web → web}/types.d.ts +26 -10
- package/dist/web/types.js.map +1 -0
- package/package.json +41 -21
- package/dist/src/server/devtoolsStaticServer.d.ts +0 -15
- package/dist/src/server/devtoolsStaticServer.js +0 -43
- package/dist/src/server/devtoolsStaticServer.js.map +0 -1
- package/dist/src/server/index.js.map +0 -1
- package/dist/src/server/inferUtilityTypes.js.map +0 -1
- package/dist/src/server/server.js +0 -62
- 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.js.map +0 -1
- package/dist/src/test/widget.test.js +0 -95
- package/dist/src/test/widget.test.js.map +0 -1
- package/dist/src/web/create-store.js.map +0 -1
- package/dist/src/web/create-store.test.js.map +0 -1
- package/dist/src/web/data-llm.js.map +0 -1
- package/dist/src/web/data-llm.test.js.map +0 -1
- package/dist/src/web/generate-helpers.js.map +0 -1
- package/dist/src/web/generate-helpers.test-d.js.map +0 -1
- package/dist/src/web/generate-helpers.test.js.map +0 -1
- package/dist/src/web/helpers/state.js.map +0 -1
- package/dist/src/web/helpers/state.test.js.map +0 -1
- package/dist/src/web/hooks/index.js.map +0 -1
- package/dist/src/web/hooks/use-call-tool.js.map +0 -1
- package/dist/src/web/hooks/use-call-tool.test-d.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-files.js +0 -7
- package/dist/src/web/hooks/use-files.js.map +0 -1
- package/dist/src/web/hooks/use-files.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.js +0 -25
- package/dist/src/web/hooks/use-openai-global.js.map +0 -1
- package/dist/src/web/hooks/use-request-modal.d.ts +0 -6
- 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.js +0 -20
- package/dist/src/web/hooks/use-tool-info.js.map +0 -1
- package/dist/src/web/hooks/use-tool-info.test-d.js.map +0 -1
- package/dist/src/web/hooks/use-tool-info.test.js +0 -59
- package/dist/src/web/hooks/use-tool-info.test.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.map +0 -1
- package/dist/src/web/hooks/use-widget-state.test.js.map +0 -1
- package/dist/src/web/index.js.map +0 -1
- package/dist/src/web/mount-widget.js.map +0 -1
- package/dist/src/web/plugin/data-llm.test.js.map +0 -1
- package/dist/src/web/plugin/plugin.js.map +0 -1
- package/dist/src/web/plugin/transform-data-llm.js.map +0 -1
- package/dist/src/web/plugin/transform-data-llm.test.js.map +0 -1
- package/dist/src/web/proxy.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}/inferUtilityTypes.d.ts +0 -0
- /package/dist/{src/server → server}/inferUtilityTypes.js +0 -0
- /package/dist/{src/server → server}/templateHelper.js +0 -0
- /package/dist/{src/test → test}/widget.test.d.ts +0 -0
- /package/dist/{src/web/create-store.test.d.ts → web/bridges/hooks/use-mcp-app-bridge.test.d.ts} +0 -0
- /package/dist/{src/web → web}/create-store.d.ts +0 -0
- /package/dist/{src/web → web}/create-store.js +0 -0
- /package/dist/{src/web/data-llm.test.d.ts → web/create-store.test.d.ts} +0 -0
- /package/dist/{src/web → web}/create-store.test.js +0 -0
- /package/dist/{src/web → web}/data-llm.d.ts +0 -0
- /package/dist/{src/web/plugin → web}/data-llm.test.d.ts +0 -0
- /package/dist/{src/web → web}/data-llm.test.js +0 -0
- /package/dist/{src/web → web}/generate-helpers.d.ts +0 -0
- /package/dist/{src/web → web}/generate-helpers.js +0 -0
- /package/dist/{src/web → web}/generate-helpers.test-d.d.ts +0 -0
- /package/dist/{src/web → web}/generate-helpers.test.d.ts +0 -0
- /package/dist/{src/web → web}/generate-helpers.test.js +0 -0
- /package/dist/{src/web → web}/helpers/state.d.ts +0 -0
- /package/dist/{src/web → web}/helpers/state.js +0 -0
- /package/dist/{src/web → web}/helpers/state.test.d.ts +0 -0
- /package/dist/{src/web → web}/helpers/state.test.js +0 -0
- /package/dist/{src/web → web}/hooks/use-call-tool.test-d.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-call-tool.test.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-display-mode.test.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-files.test.d.ts +0 -0
- /package/dist/{src/web/hooks/use-locale.test.d.ts → web/hooks/use-layout.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-open-external.test.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-request-modal.test.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-tool-info.test-d.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-tool-info.test.d.ts +0 -0
- /package/dist/{src/web/hooks/use-theme.test.d.ts → web/hooks/use-user.test.d.ts} +0 -0
- /package/dist/{src/web → web}/hooks/use-widget-state.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-widget-state.test.d.ts +0 -0
- /package/dist/{src/web → web}/mount-widget.d.ts +0 -0
- /package/dist/{src/web → web}/mount-widget.js +0 -0
- /package/dist/{src/web/hooks/use-user-agent.test.d.ts → web/plugin/data-llm.test.d.ts} +0 -0
- /package/dist/{src/web → web}/plugin/data-llm.test.js +0 -0
- /package/dist/{src/web → web}/plugin/plugin.d.ts +0 -0
- /package/dist/{src/web → web}/plugin/transform-data-llm.d.ts +0 -0
- /package/dist/{src/web → web}/plugin/transform-data-llm.test.d.ts +0 -0
- /package/dist/{src/web → web}/plugin/transform-data-llm.test.js +0 -0
- /package/dist/{src/web → web}/proxy.d.ts +0 -0
- /package/dist/{src/web → web}/types.js +0 -0
package/bin/run.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runCommand(command: string, args: string[]): Promise<void>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
export function runCommand(command, args) {
|
|
3
|
+
return new Promise((resolve, reject) => {
|
|
4
|
+
const stdoutChunks = [];
|
|
5
|
+
const stderrChunks = [];
|
|
6
|
+
const proc = spawn(command, args, {
|
|
7
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
8
|
+
});
|
|
9
|
+
if (proc.stdout) {
|
|
10
|
+
proc.stdout.on("data", (chunk) => {
|
|
11
|
+
stdoutChunks.push(chunk);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
if (proc.stderr) {
|
|
15
|
+
proc.stderr.on("data", (chunk) => {
|
|
16
|
+
stderrChunks.push(chunk);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
proc.on("close", (code) => {
|
|
20
|
+
if (code === 0) {
|
|
21
|
+
resolve();
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const stdoutOutput = Buffer.concat(stdoutChunks).toString();
|
|
25
|
+
const stderrOutput = Buffer.concat(stderrChunks).toString();
|
|
26
|
+
const allOutput = [stdoutOutput, stderrOutput]
|
|
27
|
+
.filter((output) => output.trim())
|
|
28
|
+
.join("\n");
|
|
29
|
+
const errorMessage = allOutput
|
|
30
|
+
? `Command failed with exit code ${code}\n${allOutput}`
|
|
31
|
+
: `Command failed with exit code ${code}`;
|
|
32
|
+
reject(new Error(errorMessage));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
proc.on("error", (error) => {
|
|
36
|
+
reject(error);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# 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,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,IAAc;IACxD,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,IAAI,EAAE;Y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,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,35 @@
|
|
|
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
|
+
const [command, ...args] = step.command.split(" ");
|
|
14
|
+
if (!command) {
|
|
15
|
+
throw new Error("Invalid command");
|
|
16
|
+
}
|
|
17
|
+
await runCommand(command, args);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
setStatus("success");
|
|
21
|
+
setImmediate(() => {
|
|
22
|
+
process.exit(0);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
setStatus("error");
|
|
27
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
28
|
+
setImmediate(() => {
|
|
29
|
+
process.exit(1);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}, [steps]);
|
|
33
|
+
return { currentStep, status, error, execute };
|
|
34
|
+
};
|
|
35
|
+
//# 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,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBACnD,IAAI,CAAC,OAAO,EAAE,CAAC;wBACb,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;oBACrC,CAAC;oBACD,MAAM,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAClC,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,43 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Command } from "@oclif/core";
|
|
3
|
+
import { Box, render, Text } from "ink";
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
import { useExecuteSteps } from "../cli/use-execute-steps.js";
|
|
6
|
+
export const commandSteps = [
|
|
7
|
+
{
|
|
8
|
+
label: "Building widgets",
|
|
9
|
+
command: "vite build -c web/vite.config.ts",
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
label: "Compiling server",
|
|
13
|
+
command: "shx rm -rf server/dist && tsc -p tsconfig.server.json",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
label: "Copying static assets",
|
|
17
|
+
command: "shx cp -r web/dist dist/assets",
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
export default class Build extends Command {
|
|
21
|
+
static description = "Build the widgets and MCP server";
|
|
22
|
+
static examples = ["skybridge build"];
|
|
23
|
+
static flags = {};
|
|
24
|
+
async run() {
|
|
25
|
+
const App = () => {
|
|
26
|
+
const { currentStep, status, error, execute } = useExecuteSteps(commandSteps);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
execute();
|
|
29
|
+
}, [execute]);
|
|
30
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { color: "cyan", bold: true, children: ["\u26F0", " ", "Skybridge"] }), _jsxs(Text, { color: "cyan", children: [" v", this.config.version] }), _jsx(Text, { color: "green", children: " \u2192 building for production\u2026" })] }), commandSteps.map((step, index) => {
|
|
31
|
+
const isCurrent = index === currentStep && status === "running";
|
|
32
|
+
const isCompleted = index < currentStep || status === "success";
|
|
33
|
+
const isError = status === "error" && index === currentStep;
|
|
34
|
+
return (_jsx(Box, { marginBottom: 0, children: _jsxs(Text, { color: isError ? "red" : isCompleted ? "green" : "grey", children: [isError ? "✗" : isCompleted ? "✓" : isCurrent ? "⟳" : "○", " ", step.label] }) }, step.label));
|
|
35
|
+
}), 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))) })] }))] }));
|
|
36
|
+
};
|
|
37
|
+
render(_jsx(App, {}), {
|
|
38
|
+
exitOnCtrlC: true,
|
|
39
|
+
patchConsole: false,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
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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,19 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { Command } from "@oclif/core";
|
|
4
|
+
import { Box, render, Text } from "ink";
|
|
5
|
+
export default class Dev extends Command {
|
|
6
|
+
static description = "Start development server";
|
|
7
|
+
static examples = ["skybridge"];
|
|
8
|
+
static flags = {};
|
|
9
|
+
async run() {
|
|
10
|
+
spawn("nodemon", ["--quiet"], {
|
|
11
|
+
stdio: ["ignore", "ignore", "inherit"],
|
|
12
|
+
});
|
|
13
|
+
const App = () => {
|
|
14
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, marginLeft: 1, children: [_jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { color: "cyan", bold: true, children: ["\u26F0", " ", "Welcome to Skybridge"] }), _jsxs(Text, { color: "cyan", children: [" v", 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://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" })] }) })] }));
|
|
15
|
+
};
|
|
16
|
+
render(_jsx(App, {}), { exitOnCtrlC: true, patchConsole: false });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAExC,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ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AAC,KAAK,EAAC,MAAM,wDAA+C,EACjE,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,sCAEjB,IACH,EACN,KAAC,GAAG,IAAC,YAAY,EAAE,CAAC,YAClB,MAAC,IAAI,eACH,MAAC,IAAI,IAAC,KAAK,EAAC,SAAS,uBAAG,IAAI,IAAQ,EACpC,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,6CAAoC,EACtD,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,wDAEjB,IACF,GACH,EACN,KAAC,GAAG,cACF,MAAC,IAAI,eACH,MAAC,IAAI,IAAC,KAAK,EAAC,SAAS,uBAAG,IAAI,IAAQ,EACpC,KAAC,IAAI,kCAAuB,EAC5B,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,8CAEjB,IACF,GACH,EACN,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,YACf,MAAC,IAAI,eACH,MAAC,IAAI,IAAC,KAAK,EAAC,SAAS,uBAAG,IAAI,IAAQ,EACpC,KAAC,IAAI,iDAAsC,EAC3C,MAAC,IAAI,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,qCACP,GAAG,IACb,EACP,KAAC,IAAI,8BAAmB,EACxB,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,EAAC,SAAS,4DAEtB,EACP,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,8BAAW,IACxB,GACH,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"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export { devtoolsStaticServer } from "./devtoolsStaticServer.js";
|
|
2
1
|
export type { AnyToolRegistry, InferTools, ToolInput, ToolNames, ToolOutput, ToolResponseMetadata, } from "./inferUtilityTypes.js";
|
|
3
|
-
export type { McpServerTypes, ToolDef } from "./server.js";
|
|
2
|
+
export type { McpServerTypes, ToolDef, WidgetHostType } from "./server.js";
|
|
4
3
|
export { McpServer } from "./server.js";
|
|
5
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 @@
|
|
|
1
|
+
{"version":3,"file":"inferUtilityTypes.js","sourceRoot":"","sources":["../../src/server/inferUtilityTypes.ts"],"names":[],"mappings":""}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { McpUiResourceMeta } from "@modelcontextprotocol/ext-apps";
|
|
1
2
|
import { McpServer as McpServerBase, type RegisteredTool } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
3
|
import type { AnySchema, SchemaOutput, ZodRawShapeCompat } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
3
4
|
import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
@@ -7,16 +8,48 @@ export type ToolDef<TInput = unknown, TOutput = unknown, TResponseMetadata = unk
|
|
|
7
8
|
output: TOutput;
|
|
8
9
|
responseMetadata: TResponseMetadata;
|
|
9
10
|
};
|
|
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
|
+
/** Origins allowed for nested iframe embeds */
|
|
18
|
+
frameDomains?: string[];
|
|
19
|
+
/** Origins permitted for the <base> tag URI directive */
|
|
20
|
+
baseUriDomains?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Origins that can receive openExternal redirects without safe-link modal (OpenAI-specific)
|
|
23
|
+
* @see https://developers.openai.com/apps-sdk/reference#component-resource-_meta-fields
|
|
24
|
+
*/
|
|
25
|
+
redirectDomains?: string[];
|
|
26
|
+
};
|
|
27
|
+
/** Extended MCP Apps resource metadata with upcoming CSP fields */
|
|
28
|
+
type ExtendedMcpUiResourceMeta = Omit<McpUiResourceMeta, "csp"> & {
|
|
29
|
+
csp?: ExtendedMcpUiResourceCsp;
|
|
30
|
+
};
|
|
31
|
+
/** User-provided resource configuration with optional CSP override */
|
|
32
|
+
export type WidgetResourceMeta = {
|
|
33
|
+
ui?: ExtendedMcpUiResourceMeta;
|
|
34
|
+
} & Resource["_meta"];
|
|
35
|
+
export type WidgetHostType = "apps-sdk" | "mcp-app";
|
|
36
|
+
type McpServerOriginalResourceConfig = Omit<Resource, "uri" | "name" | "mimeType" | "_meta"> & {
|
|
37
|
+
_meta?: WidgetResourceMeta;
|
|
38
|
+
};
|
|
11
39
|
type McpServerOriginalToolConfig = Omit<Parameters<typeof McpServerBase.prototype.registerTool<ZodRawShapeCompat, ZodRawShapeCompat>>[1], "inputSchema" | "outputSchema">;
|
|
40
|
+
type Simplify<T> = {
|
|
41
|
+
[K in keyof T]: T[K];
|
|
42
|
+
};
|
|
12
43
|
type ExtractStructuredContent<T> = T extends {
|
|
13
44
|
structuredContent: infer SC;
|
|
14
|
-
} ? SC : never;
|
|
15
|
-
type ExtractMeta<T> = Extract<T, {
|
|
45
|
+
} ? Simplify<SC> : never;
|
|
46
|
+
type ExtractMeta<T> = [Extract<T, {
|
|
47
|
+
_meta: unknown;
|
|
48
|
+
}>] extends [never] ? unknown : Extract<T, {
|
|
16
49
|
_meta: unknown;
|
|
17
50
|
}> extends {
|
|
18
51
|
_meta: infer M;
|
|
19
|
-
} ? M : unknown;
|
|
52
|
+
} ? Simplify<M> : unknown;
|
|
20
53
|
/**
|
|
21
54
|
* Type-level marker interface for cross-package type inference.
|
|
22
55
|
* This enables TypeScript to infer tool types across package boundaries
|
|
@@ -29,9 +62,6 @@ type ExtractMeta<T> = Extract<T, {
|
|
|
29
62
|
export interface McpServerTypes<TTools extends Record<string, ToolDef>> {
|
|
30
63
|
readonly tools: TTools;
|
|
31
64
|
}
|
|
32
|
-
type Simplify<T> = {
|
|
33
|
-
[K in keyof T]: T[K];
|
|
34
|
-
};
|
|
35
65
|
type ShapeOutput<Shape extends ZodRawShapeCompat> = Simplify<{
|
|
36
66
|
[K in keyof Shape as undefined extends SchemaOutput<Shape[K]> ? never : K]: SchemaOutput<Shape[K]>;
|
|
37
67
|
} & {
|
|
@@ -48,15 +78,24 @@ type ToolConfig<TInput extends ZodRawShapeCompat | AnySchema> = {
|
|
|
48
78
|
annotations?: ToolAnnotations;
|
|
49
79
|
_meta?: Record<string, unknown>;
|
|
50
80
|
};
|
|
51
|
-
type ToolHandler<TInput extends ZodRawShapeCompat, TReturn extends
|
|
81
|
+
type ToolHandler<TInput extends ZodRawShapeCompat, TReturn extends {
|
|
82
|
+
content: CallToolResult["content"];
|
|
83
|
+
} = CallToolResult> = (args: ShapeOutput<TInput>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => TReturn | Promise<TReturn>;
|
|
52
84
|
export declare class McpServer<TTools extends Record<string, ToolDef> = Record<never, ToolDef>> extends McpServerBase {
|
|
53
85
|
readonly $types: McpServerTypes<TTools>;
|
|
54
|
-
registerWidget<TName extends string, TInput extends ZodRawShapeCompat, TReturn extends
|
|
86
|
+
registerWidget<TName extends string, TInput extends ZodRawShapeCompat, TReturn extends {
|
|
87
|
+
content: CallToolResult["content"];
|
|
88
|
+
}>(name: TName, resourceConfig: McpServerOriginalResourceConfig, toolConfig: McpServerOriginalToolConfig & {
|
|
55
89
|
inputSchema?: TInput;
|
|
56
90
|
outputSchema?: ZodRawShapeCompat | AnySchema;
|
|
57
91
|
}, toolCallback: ToolHandler<TInput, TReturn>): AddTool<TTools, TName, TInput, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
|
|
58
|
-
registerTool<TName extends string, InputArgs extends ZodRawShapeCompat, TReturn extends
|
|
92
|
+
registerTool<TName extends string, InputArgs extends ZodRawShapeCompat, TReturn extends {
|
|
93
|
+
content: CallToolResult["content"];
|
|
94
|
+
}>(name: TName, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs, TReturn>): AddTool<TTools, TName, InputArgs, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
|
|
59
95
|
registerTool<InputArgs extends ZodRawShapeCompat>(name: string, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs>): RegisteredTool;
|
|
96
|
+
private registerWidgetResource;
|
|
60
97
|
private lookupDistFile;
|
|
98
|
+
private lookupDistFileWithIndexFallback;
|
|
99
|
+
private readManifest;
|
|
61
100
|
}
|
|
62
101
|
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
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 appsSdkResourceConfig = {
|
|
17
|
+
hostType: "apps-sdk",
|
|
18
|
+
uri: `ui://widgets/apps-sdk/${name}.html`,
|
|
19
|
+
mimeType: "text/html+skybridge",
|
|
20
|
+
buildContentMeta: ({ resourceDomains, connectDomains, domain }) => {
|
|
21
|
+
const userUi = userMeta?.ui;
|
|
22
|
+
const userCsp = userUi?.csp;
|
|
23
|
+
const defaults = {
|
|
24
|
+
"openai/widgetCSP": {
|
|
25
|
+
resource_domains: resourceDomains,
|
|
26
|
+
connect_domains: connectDomains,
|
|
27
|
+
},
|
|
28
|
+
"openai/widgetDomain": domain,
|
|
29
|
+
"openai/widgetDescription": toolConfig.description,
|
|
30
|
+
};
|
|
31
|
+
const fromUi = {
|
|
32
|
+
"openai/widgetCSP": {
|
|
33
|
+
resource_domains: userCsp?.resourceDomains,
|
|
34
|
+
connect_domains: userCsp?.connectDomains,
|
|
35
|
+
frame_domains: userCsp?.frameDomains,
|
|
36
|
+
redirect_domains: userCsp?.redirectDomains,
|
|
37
|
+
},
|
|
38
|
+
"openai/widgetDomain": userUi?.domain,
|
|
39
|
+
"openai/widgetPrefersBorder": userUi?.prefersBorder,
|
|
40
|
+
};
|
|
41
|
+
const directOpenaiKeys = Object.fromEntries(Object.entries(userMeta ?? {}).filter(([key]) => key.startsWith("openai/")));
|
|
42
|
+
return mergeWithUnion(mergeWithUnion(defaults, fromUi), directOpenaiKeys);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
const extAppsResourceConfig = {
|
|
46
|
+
hostType: "mcp-app",
|
|
47
|
+
uri: `ui://widgets/ext-apps/${name}.html`,
|
|
48
|
+
mimeType: "text/html;profile=mcp-app",
|
|
49
|
+
buildContentMeta: ({ resourceDomains, connectDomains, domain }) => {
|
|
50
|
+
const defaults = {
|
|
51
|
+
ui: {
|
|
52
|
+
csp: {
|
|
53
|
+
resourceDomains,
|
|
54
|
+
connectDomains,
|
|
55
|
+
},
|
|
56
|
+
domain,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
return mergeWithUnion(defaults, { ui: userMeta?.ui });
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
[appsSdkResourceConfig, extAppsResourceConfig].forEach((widgetConfig) => {
|
|
63
|
+
this.registerWidgetResource({
|
|
64
|
+
name,
|
|
65
|
+
widgetConfig,
|
|
66
|
+
resourceConfig,
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
const toolMeta = {
|
|
70
|
+
...toolConfig._meta,
|
|
71
|
+
"openai/outputTemplate": appsSdkResourceConfig.uri,
|
|
72
|
+
ui: {
|
|
73
|
+
resourceUri: extAppsResourceConfig.uri,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
this.registerTool(name, {
|
|
77
|
+
...toolConfig,
|
|
78
|
+
_meta: toolMeta,
|
|
79
|
+
}, toolCallback);
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
registerTool(name, config, cb) {
|
|
83
|
+
super.registerTool(name, config, cb);
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
registerWidgetResource({ name, widgetConfig, resourceConfig, }) {
|
|
87
|
+
const { hostType, uri: widgetUri, mimeType, buildContentMeta, } = widgetConfig;
|
|
88
|
+
this.registerResource(name, widgetUri, { ...resourceConfig, _meta: resourceConfig._meta }, async (uri, extra) => {
|
|
89
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
90
|
+
const serverUrl = isProduction
|
|
91
|
+
? `https://${extra?.requestInfo?.headers?.["x-forwarded-host"] ?? extra?.requestInfo?.headers?.host}`
|
|
92
|
+
: "http://localhost:3000";
|
|
93
|
+
const html = isProduction
|
|
94
|
+
? templateHelper.renderProduction({
|
|
95
|
+
hostType,
|
|
96
|
+
serverUrl,
|
|
97
|
+
widgetFile: this.lookupDistFileWithIndexFallback(`src/widgets/${name}`),
|
|
98
|
+
styleFile: this.lookupDistFile("style.css"),
|
|
99
|
+
})
|
|
100
|
+
: templateHelper.renderDevelopment({
|
|
101
|
+
hostType,
|
|
102
|
+
serverUrl,
|
|
103
|
+
widgetName: name,
|
|
104
|
+
});
|
|
105
|
+
const VITE_HMR_WEBSOCKET_DEFAULT_URL = "ws://localhost:24678";
|
|
106
|
+
const contentMeta = buildContentMeta({
|
|
107
|
+
resourceDomains: [serverUrl],
|
|
108
|
+
connectDomains: !isProduction ? [VITE_HMR_WEBSOCKET_DEFAULT_URL] : [],
|
|
109
|
+
domain: serverUrl,
|
|
110
|
+
});
|
|
111
|
+
return {
|
|
112
|
+
contents: [
|
|
113
|
+
{ uri: uri.href, mimeType, text: html, _meta: contentMeta },
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
lookupDistFile(key) {
|
|
119
|
+
const manifest = this.readManifest();
|
|
120
|
+
return manifest[key]?.file;
|
|
121
|
+
}
|
|
122
|
+
lookupDistFileWithIndexFallback(basePath) {
|
|
123
|
+
const manifest = this.readManifest();
|
|
124
|
+
const flatFileKey = `${basePath}.tsx`;
|
|
125
|
+
const indexFileKey = `${basePath}/index.tsx`;
|
|
126
|
+
return manifest[flatFileKey]?.file ?? manifest[indexFileKey]?.file;
|
|
127
|
+
}
|
|
128
|
+
readManifest() {
|
|
129
|
+
return JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAK7B,OAAO,EACL,SAAS,IAAI,aAAa,GAG3B,MAAM,yCAAyC,CAAC;AAcjD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,cAAc,GAAG,CACrB,MAAS,EACT,MAAS,EACF,EAAE;IACT,OAAO,SAAS,CAAC,MAAM,EAAE,MAAM,EAA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AE,CAAC,SAAS,CAAC;gBAC5B,cAAc,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC,EAAE;gBACrE,MAAM,EAAE,SAAS;aAClB,CAAC,CAAC;YAEH,OAAO;gBACL,QAAQ,EAAE;oBACR,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE;iBAC5D;aACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;IAEO,cAAc,CAAC,GAAW;QAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACrC,OAAO,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IAC7B,CAAC;IAEO,+BAA+B,CAAC,QAAgB;QACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAErC,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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateHelper.js","sourceRoot":"","sources":["../../src/server/templateHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,UAAU,MAAM,YAAY,CAAC;AAGpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,MAAM,cAAc;IACV,aAAa,GAAG,IAAI,GAAG,EAAsC,CAAC;IAE9D,YAAY,CAAC,YAAoB;QACvC,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QACpD,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,YAAY,MAAM,CAAC,CAAC;QACzE,MAAM,cAAc,GAAG,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAC3D,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAEpD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QAC/C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,gBAAgB,CAAC,IAKhB;QACC,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACjD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,iBAAiB,CAAC,IAIjB;QACC,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QAClD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<base href="{{serverUrl}}" />
|
|
2
|
+
<script type="module">window.skybridge = { hostType: "{{hostType}}" };</script>
|
|
3
|
+
<script type="module">
|
|
4
|
+
import { injectIntoGlobalHook } from "{{serverUrl}}/assets/@react-refresh";
|
|
5
|
+
injectIntoGlobalHook(window); window.$RefreshReg$ = () => {};
|
|
6
|
+
window.$RefreshSig$ = () => (type) => type;
|
|
7
|
+
window.__vite_plugin_react_preamble_installed__ = true;
|
|
8
|
+
</script>
|
|
9
|
+
<script type="module" src="{{serverUrl}}/@vite/client"></script>
|
|
10
|
+
<script type="module">
|
|
11
|
+
// Checks for browser support and shows error if local network access is denied
|
|
12
|
+
(async () => {
|
|
13
|
+
if (!navigator.permissions?.query) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Skip for non-http(s) protocols (file://, custom protocols in Electron, etc.)
|
|
18
|
+
const protocol = window.location.protocol;
|
|
19
|
+
const isNonHttpProtocol = protocol !== 'http:' && protocol !== 'https:'
|
|
20
|
+
if (isNonHttpProtocol) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const host = window.location.hostname;
|
|
25
|
+
const isLoopback = host === 'localhost'
|
|
26
|
+
|| /^127\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.test(host)
|
|
27
|
+
|| host === '::1';
|
|
28
|
+
if (isLoopback) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const status = await navigator.permissions.query({ name: "local-network-access" });
|
|
34
|
+
if (status.state === "denied") {
|
|
35
|
+
const errorDiv = document.createElement("div");
|
|
36
|
+
errorDiv.style.cssText = "background: #fef2f2; border: 2px solid #ef4444; border-radius: 8px; padding: 16px; text-align: center; z-index: 10000; font-family: system-ui, sans-serif;";
|
|
37
|
+
|
|
38
|
+
const errorTitle = document.createElement("div");
|
|
39
|
+
errorTitle.style.cssText = "color: #ef4444; font-size: 18px; font-weight: 600; margin-bottom: 8px;";
|
|
40
|
+
errorTitle.textContent = "Error: Local network access permission is denied.";
|
|
41
|
+
|
|
42
|
+
const errorMessage = document.createElement("div");
|
|
43
|
+
errorMessage.style.cssText = "color: #ef4444; font-size: 14px;";
|
|
44
|
+
errorMessage.textContent = "Local network access is required for your widget to connect to the local dev server. Please enable it in your browser settings. ";
|
|
45
|
+
|
|
46
|
+
const link = document.createElement("a");
|
|
47
|
+
link.href = "https://developer.chrome.com/blog/local-network-access";
|
|
48
|
+
link.target = "_blank";
|
|
49
|
+
link.rel = "noopener noreferrer";
|
|
50
|
+
link.style.cssText = "color: #ef4444; text-decoration: underline;";
|
|
51
|
+
link.textContent = "Learn more";
|
|
52
|
+
errorMessage.appendChild(link);
|
|
53
|
+
|
|
54
|
+
errorDiv.appendChild(errorTitle);
|
|
55
|
+
errorDiv.appendChild(errorMessage);
|
|
56
|
+
document.body.appendChild(errorDiv);
|
|
57
|
+
}
|
|
58
|
+
} catch (e) {
|
|
59
|
+
// Permission API doesn't support local-network-access, ignore silently
|
|
60
|
+
}
|
|
61
|
+
})();
|
|
62
|
+
</script>
|
|
63
|
+
<div id="root"></div>
|
|
64
|
+
<script type="module" id="dev-widget-entry">
|
|
65
|
+
import('{{serverUrl}}/src/widgets/{{widgetName}}');
|
|
66
|
+
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Router } from "express";
|
|
2
2
|
/**
|
|
3
3
|
* Install Vite dev server
|
|
4
4
|
* This router MUST be installed at the application root, like so:
|
|
@@ -9,4 +9,4 @@ import { type RequestHandler } from "express";
|
|
|
9
9
|
* app.use(await widgetsRouter());
|
|
10
10
|
* }
|
|
11
11
|
*/
|
|
12
|
-
export declare const widgetsDevServer: () => Promise<
|
|
12
|
+
export declare const widgetsDevServer: () => Promise<Router>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
import cors from "cors";
|
|
3
4
|
import express, {} from "express";
|
|
@@ -14,10 +15,17 @@ import express, {} from "express";
|
|
|
14
15
|
export const widgetsDevServer = async () => {
|
|
15
16
|
const router = express.Router();
|
|
16
17
|
const { createServer, searchForWorkspaceRoot, loadConfigFromFile } = await import("vite");
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
// Since 0.16.0, the template is a single package that does not rely on workspace.
|
|
19
|
+
// It means that, when starting the server, the working dir is the template root
|
|
20
|
+
// hence we don't need to walk up the tree to find the workspace, which does not exist anymore.
|
|
21
|
+
let webAppRoot = path.join(process.cwd(), "web");
|
|
22
|
+
// fallback to the old behavior for backward compatibility
|
|
23
|
+
const hasWebAppRoot = existsSync(webAppRoot);
|
|
24
|
+
if (!hasWebAppRoot) {
|
|
25
|
+
const workspaceRoot = searchForWorkspaceRoot(process.cwd());
|
|
26
|
+
webAppRoot = path.join(workspaceRoot, "web");
|
|
27
|
+
}
|
|
19
28
|
const configResult = await loadConfigFromFile({ command: "serve", mode: "development" }, path.join(webAppRoot, "vite.config.ts"), webAppRoot);
|
|
20
|
-
// biome-ignore lint/correctness/noUnusedVariables: Remove build-specific options that don't apply to dev server
|
|
21
29
|
const { build, preview, ...devConfig } = configResult?.config || {};
|
|
22
30
|
const vite = await createServer({
|
|
23
31
|
...devConfig,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widgetsDevServer.js","sourceRoot":"","sources":["../../src/server/widgetsDevServer.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,QAAQ;QACjB,MAAM,EAAE;YACN,YAAY,EAAE,IAAI;YAClB,cAAc,EAAE,IAAI;SACrB;QACD,IAAI,EAAE,UAAU;QAChB,YAAY,EAAE;YACZ,OAAO,EAAE,CAAC,OAAO,EAAE,kBAAkB,CAAC;SACvC;KACF,CAAC,CAAC;IAEH,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IACnB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAElC,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -104,6 +104,17 @@ export declare function createMinimalTestServer(): McpServer<Record<never, impor
|
|
|
104
104
|
}[];
|
|
105
105
|
}, unknown>;
|
|
106
106
|
}>;
|
|
107
|
+
export declare function createInterfaceTestServer(): McpServer<Record<never, import("../server/server.js").ToolDef<unknown, unknown, unknown>> & {
|
|
108
|
+
"interface-widget": import("../server/server.js").ToolDef<{
|
|
109
|
+
id: string;
|
|
110
|
+
}, {
|
|
111
|
+
itemName: string;
|
|
112
|
+
quantity: number;
|
|
113
|
+
}, {
|
|
114
|
+
processedBy: string;
|
|
115
|
+
version: number;
|
|
116
|
+
}>;
|
|
117
|
+
}>;
|
|
107
118
|
/**
|
|
108
119
|
* Mock extra parameter for resource callback
|
|
109
120
|
*/
|