skybridge 0.0.0-dev.ff4b4a2 → 0.0.0-dev.fff2bae
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -15
- package/dist/cli/detect-port.d.ts +18 -0
- package/dist/cli/detect-port.js +61 -0
- package/dist/cli/detect-port.js.map +1 -0
- package/dist/cli/header.js +1 -1
- package/dist/cli/header.js.map +1 -1
- package/dist/cli/run-command.js.map +1 -1
- package/dist/cli/telemetry.js.map +1 -1
- package/dist/cli/tunnel-control-server.d.ts +9 -0
- package/dist/cli/tunnel-control-server.js +31 -0
- package/dist/cli/tunnel-control-server.js.map +1 -0
- package/dist/cli/tunnel-control-server.test.js +39 -0
- package/dist/cli/tunnel-control-server.test.js.map +1 -0
- package/dist/cli/tunnel-handler.d.ts +3 -0
- package/dist/cli/tunnel-handler.js +48 -0
- package/dist/cli/tunnel-handler.js.map +1 -0
- package/dist/cli/tunnel-handler.test.js +105 -0
- package/dist/cli/tunnel-handler.test.js.map +1 -0
- package/dist/cli/tunnel.d.ts +57 -0
- package/dist/cli/tunnel.js +154 -0
- package/dist/cli/tunnel.js.map +1 -0
- package/dist/cli/tunnel.test.d.ts +1 -0
- package/dist/cli/tunnel.test.js +190 -0
- package/dist/cli/tunnel.test.js.map +1 -0
- package/dist/cli/types.d.ts +5 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/use-execute-steps.js.map +1 -1
- package/dist/cli/use-messages.d.ts +3 -0
- package/dist/cli/use-messages.js +11 -0
- package/dist/cli/use-messages.js.map +1 -0
- package/dist/cli/use-nodemon.d.ts +2 -6
- package/dist/cli/use-nodemon.js +30 -18
- package/dist/cli/use-nodemon.js.map +1 -1
- package/dist/cli/use-open-browser.d.ts +1 -0
- package/dist/cli/use-open-browser.js +44 -0
- package/dist/cli/use-open-browser.js.map +1 -0
- package/dist/cli/use-tunnel.d.ts +14 -0
- package/dist/cli/use-tunnel.js +131 -0
- package/dist/cli/use-tunnel.js.map +1 -0
- package/dist/cli/use-typescript-check.d.ts +1 -0
- package/dist/cli/use-typescript-check.js +41 -6
- package/dist/cli/use-typescript-check.js.map +1 -1
- package/dist/commands/build.js +63 -7
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/dev.d.ts +4 -1
- package/dist/commands/dev.js +57 -8
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/start.d.ts +3 -1
- package/dist/commands/start.js +31 -15
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/telemetry/disable.js.map +1 -1
- package/dist/commands/telemetry/enable.js.map +1 -1
- package/dist/commands/telemetry/status.js.map +1 -1
- package/dist/server/asset-base-url-transform-plugin.d.ts +5 -6
- package/dist/server/asset-base-url-transform-plugin.js +9 -10
- package/dist/server/asset-base-url-transform-plugin.js.map +1 -1
- package/dist/server/asset-base-url-transform-plugin.test.js +41 -13
- package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -1
- package/dist/server/content-helpers.d.ts +27 -0
- package/dist/server/content-helpers.js +46 -0
- package/dist/server/content-helpers.js.map +1 -0
- package/dist/server/content-helpers.test.d.ts +1 -0
- package/dist/server/content-helpers.test.js +70 -0
- package/dist/server/content-helpers.test.js.map +1 -0
- package/dist/server/express.d.ts +11 -0
- package/dist/server/express.js +101 -0
- package/dist/server/express.js.map +1 -0
- package/dist/server/express.test.d.ts +1 -0
- package/dist/server/express.test.js +430 -0
- package/dist/server/express.test.js.map +1 -0
- package/dist/server/index.d.ts +5 -3
- package/dist/server/index.js +3 -2
- package/dist/server/index.js.map +1 -1
- package/dist/server/inferUtilityTypes.d.ts +6 -6
- package/dist/server/inferUtilityTypes.js.map +1 -1
- package/dist/server/metric.d.ts +14 -0
- package/dist/server/metric.js +62 -0
- package/dist/server/metric.js.map +1 -0
- package/dist/server/middleware.d.ts +124 -0
- package/dist/server/middleware.js +93 -0
- package/dist/server/middleware.js.map +1 -0
- package/dist/server/middleware.test-d.d.ts +1 -0
- package/dist/server/middleware.test-d.js +75 -0
- package/dist/server/middleware.test-d.js.map +1 -0
- package/dist/server/middleware.test.d.ts +1 -0
- package/dist/server/middleware.test.js +493 -0
- package/dist/server/middleware.test.js.map +1 -0
- package/dist/server/server.d.ts +160 -63
- package/dist/server/server.js +391 -76
- package/dist/server/server.js.map +1 -1
- package/dist/server/templateHelper.d.ts +5 -8
- package/dist/server/templateHelper.js +3 -22
- package/dist/server/templateHelper.js.map +1 -1
- package/dist/server/templates.generated.d.ts +4 -0
- package/dist/server/templates.generated.js +47 -0
- package/dist/server/templates.generated.js.map +1 -0
- package/dist/server/tunnel-proxy-router.d.ts +7 -0
- package/dist/server/tunnel-proxy-router.js +110 -0
- package/dist/server/tunnel-proxy-router.js.map +1 -0
- package/dist/server/tunnel-proxy-router.test.d.ts +1 -0
- package/dist/server/tunnel-proxy-router.test.js +229 -0
- package/dist/server/tunnel-proxy-router.test.js.map +1 -0
- package/dist/server/viewsDevServer.d.ts +14 -0
- package/dist/server/viewsDevServer.js +45 -0
- package/dist/server/viewsDevServer.js.map +1 -0
- package/dist/test/utils.d.ts +13 -21
- package/dist/test/utils.js +42 -37
- package/dist/test/utils.js.map +1 -1
- package/dist/test/view.test.d.ts +1 -0
- package/dist/test/view.test.js +523 -0
- package/dist/test/view.test.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/dist/web/bridges/apps-sdk/adaptor.d.ts +9 -7
- package/dist/web/bridges/apps-sdk/adaptor.js +51 -19
- package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -1
- package/dist/web/bridges/apps-sdk/bridge.d.ts +1 -1
- package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
- package/dist/web/bridges/apps-sdk/index.d.ts +1 -1
- package/dist/web/bridges/apps-sdk/index.js.map +1 -1
- package/dist/web/bridges/apps-sdk/types.d.ts +30 -14
- package/dist/web/bridges/apps-sdk/types.js.map +1 -1
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
- package/dist/web/bridges/get-adaptor.js.map +1 -1
- package/dist/web/bridges/index.js.map +1 -1
- package/dist/web/bridges/mcp-app/adaptor.d.ts +21 -9
- package/dist/web/bridges/mcp-app/adaptor.js +142 -64
- package/dist/web/bridges/mcp-app/adaptor.js.map +1 -1
- package/dist/web/bridges/mcp-app/bridge.d.ts +13 -30
- package/dist/web/bridges/mcp-app/bridge.js +43 -196
- package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
- package/dist/web/bridges/mcp-app/index.js.map +1 -1
- package/dist/web/bridges/mcp-app/types.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +5 -3
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js +2 -2
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -41
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
- package/dist/web/bridges/types.d.ts +26 -13
- package/dist/web/bridges/types.js.map +1 -1
- package/dist/web/bridges/use-host-context.js.map +1 -1
- package/dist/web/components/modal-provider.js +3 -5
- package/dist/web/components/modal-provider.js.map +1 -1
- package/dist/web/create-store.js +17 -3
- package/dist/web/create-store.js.map +1 -1
- package/dist/web/create-store.test.js +23 -20
- package/dist/web/create-store.test.js.map +1 -1
- package/dist/web/data-llm.d.ts +1 -1
- package/dist/web/data-llm.js +3 -3
- package/dist/web/data-llm.js.map +1 -1
- package/dist/web/data-llm.test.js +33 -30
- package/dist/web/data-llm.test.js.map +1 -1
- package/dist/web/generate-helpers.d.ts +20 -18
- package/dist/web/generate-helpers.js +20 -18
- package/dist/web/generate-helpers.js.map +1 -1
- package/dist/web/generate-helpers.test-d.js +26 -26
- package/dist/web/generate-helpers.test-d.js.map +1 -1
- package/dist/web/generate-helpers.test.js.map +1 -1
- package/dist/web/helpers/state.d.ts +2 -2
- package/dist/web/helpers/state.js +11 -11
- package/dist/web/helpers/state.js.map +1 -1
- package/dist/web/helpers/state.test.js +9 -9
- package/dist/web/helpers/state.test.js.map +1 -1
- package/dist/web/hooks/index.d.ts +2 -2
- package/dist/web/hooks/index.js +1 -1
- package/dist/web/hooks/index.js.map +1 -1
- package/dist/web/hooks/test/utils.js +4 -0
- package/dist/web/hooks/test/utils.js.map +1 -1
- package/dist/web/hooks/use-call-tool.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test-d.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test.js +0 -4
- package/dist/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/web/hooks/use-display-mode.d.ts +3 -3
- package/dist/web/hooks/use-display-mode.js.map +1 -1
- package/dist/web/hooks/use-display-mode.test-d.d.ts +1 -0
- package/dist/web/hooks/use-display-mode.test-d.js +8 -0
- package/dist/web/hooks/use-display-mode.test-d.js.map +1 -0
- package/dist/web/hooks/use-display-mode.test.js.map +1 -1
- package/dist/web/hooks/use-files.d.ts +2 -1
- package/dist/web/hooks/use-files.js +1 -0
- package/dist/web/hooks/use-files.js.map +1 -1
- package/dist/web/hooks/use-files.test.js +27 -3
- package/dist/web/hooks/use-files.test.js.map +1 -1
- package/dist/web/hooks/use-layout.js.map +1 -1
- package/dist/web/hooks/use-layout.test.js +3 -3
- package/dist/web/hooks/use-layout.test.js.map +1 -1
- package/dist/web/hooks/use-open-external.d.ts +3 -1
- package/dist/web/hooks/use-open-external.js +1 -1
- package/dist/web/hooks/use-open-external.js.map +1 -1
- package/dist/web/hooks/use-open-external.test.js +26 -11
- package/dist/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/web/hooks/use-request-modal.d.ts +1 -1
- package/dist/web/hooks/use-request-modal.js +4 -4
- package/dist/web/hooks/use-request-modal.js.map +1 -1
- package/dist/web/hooks/use-request-modal.test.js +5 -1
- package/dist/web/hooks/use-request-modal.test.js.map +1 -1
- package/dist/web/hooks/use-send-follow-up-message.d.ts +2 -1
- package/dist/web/hooks/use-send-follow-up-message.js +2 -2
- package/dist/web/hooks/use-send-follow-up-message.js.map +1 -1
- package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -1
- package/dist/web/hooks/use-set-open-in-app-url.test.js +5 -11
- package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
- package/dist/web/hooks/use-tool-info.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test.js +1 -1
- package/dist/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/web/hooks/use-user.js +18 -2
- package/dist/web/hooks/use-user.js.map +1 -1
- package/dist/web/hooks/use-user.test.js +29 -1
- package/dist/web/hooks/use-user.test.js.map +1 -1
- package/dist/web/hooks/use-view-state.d.ts +4 -0
- package/dist/web/hooks/use-view-state.js +32 -0
- package/dist/web/hooks/use-view-state.js.map +1 -0
- package/dist/web/hooks/use-view-state.test.d.ts +1 -0
- package/dist/web/hooks/use-view-state.test.js +177 -0
- package/dist/web/hooks/use-view-state.test.js.map +1 -0
- package/dist/web/index.d.ts +1 -2
- package/dist/web/index.js +1 -2
- package/dist/web/index.js.map +1 -1
- package/dist/web/mount-view.d.ts +1 -0
- package/dist/web/{mount-widget.js → mount-view.js} +2 -2
- package/dist/web/mount-view.js.map +1 -0
- package/dist/web/plugin/data-llm.test.js.map +1 -1
- package/dist/web/plugin/plugin.d.ts +4 -1
- package/dist/web/plugin/plugin.js +128 -18
- package/dist/web/plugin/plugin.js.map +1 -1
- package/dist/web/plugin/scan-views.d.ts +16 -0
- package/dist/web/plugin/scan-views.js +88 -0
- package/dist/web/plugin/scan-views.js.map +1 -0
- package/dist/web/plugin/scan-views.test.d.ts +1 -0
- package/dist/web/plugin/scan-views.test.js +99 -0
- package/dist/web/plugin/scan-views.test.js.map +1 -0
- package/dist/web/plugin/transform-data-llm.js +1 -1
- package/dist/web/plugin/transform-data-llm.js.map +1 -1
- package/dist/web/plugin/transform-data-llm.test.js.map +1 -1
- package/dist/web/plugin/validate-view.d.ts +1 -0
- package/dist/web/plugin/validate-view.js +9 -0
- package/dist/web/plugin/validate-view.js.map +1 -0
- package/dist/web/plugin/validate-view.test.d.ts +1 -0
- package/dist/web/plugin/validate-view.test.js +24 -0
- package/dist/web/plugin/validate-view.test.js.map +1 -0
- package/dist/web/proxy.js.map +1 -1
- package/dist/web/types.js.map +1 -1
- package/package.json +44 -30
- package/tsconfig.base.json +33 -0
- package/dist/server/templates/development.hbs +0 -67
- package/dist/server/templates/production.hbs +0 -6
- package/dist/server/widgetsDevServer.d.ts +0 -12
- package/dist/server/widgetsDevServer.js +0 -57
- package/dist/server/widgetsDevServer.js.map +0 -1
- package/dist/test/widget.test.js +0 -255
- package/dist/test/widget.test.js.map +0 -1
- package/dist/web/hooks/use-widget-state.d.ts +0 -4
- package/dist/web/hooks/use-widget-state.js +0 -32
- package/dist/web/hooks/use-widget-state.js.map +0 -1
- package/dist/web/hooks/use-widget-state.test.js +0 -61
- package/dist/web/hooks/use-widget-state.test.js.map +0 -1
- package/dist/web/mount-widget.d.ts +0 -1
- package/dist/web/mount-widget.js.map +0 -1
- /package/dist/{test/widget.test.d.ts → cli/tunnel-control-server.test.d.ts} +0 -0
- /package/dist/{web/hooks/use-widget-state.test.d.ts → cli/tunnel-handler.test.d.ts} +0 -0
|
@@ -15,7 +15,7 @@ describe("DataLLM", () => {
|
|
|
15
15
|
let OpenaiMock;
|
|
16
16
|
beforeEach(() => {
|
|
17
17
|
OpenaiMock = {
|
|
18
|
-
widgetState: {},
|
|
18
|
+
widgetState: { modelContent: {} },
|
|
19
19
|
setWidgetState: vi.fn(),
|
|
20
20
|
};
|
|
21
21
|
// Use Object.defineProperty to ensure it persists
|
|
@@ -39,27 +39,29 @@ describe("DataLLM", () => {
|
|
|
39
39
|
// Keep the mock available for React cleanup, but reset it
|
|
40
40
|
if (typeof window !== "undefined" && window.openai) {
|
|
41
41
|
window.openai.setWidgetState = vi.fn();
|
|
42
|
-
window.openai.widgetState = {};
|
|
42
|
+
window.openai.widgetState = { modelContent: {}, privateContent: {} };
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
|
-
it("should register a node with content and call
|
|
45
|
+
it("should register a node with content and call setViewState", () => {
|
|
46
46
|
render(_jsx(DataLLM, { content: "Test content", children: _jsx("div", { children: "Child" }) }));
|
|
47
47
|
expect(OpenaiMock.setWidgetState).toHaveBeenCalled();
|
|
48
|
-
const callArgs = OpenaiMock.setWidgetState.mock.calls[0]?.[0];
|
|
49
|
-
expect(callArgs).toHaveProperty("
|
|
50
|
-
expect(callArgs?.
|
|
48
|
+
const callArgs = OpenaiMock.setWidgetState.mock.calls[0]?.[0]?.modelContent;
|
|
49
|
+
expect(callArgs).toHaveProperty("__view_context");
|
|
50
|
+
expect(callArgs?.__view_context).toContain("- Test content");
|
|
51
51
|
});
|
|
52
|
-
it("should preserve existing
|
|
53
|
-
OpenaiMock.widgetState = {
|
|
52
|
+
it("should preserve existing viewState when updating context", () => {
|
|
53
|
+
OpenaiMock.widgetState = {
|
|
54
|
+
modelContent: { existingKey: "existingValue" },
|
|
55
|
+
};
|
|
54
56
|
render(_jsx(DataLLM, { content: "Test content", children: _jsx("div", { children: "Child" }) }));
|
|
55
|
-
const callArgs = OpenaiMock.setWidgetState.mock.calls[0]?.[0];
|
|
57
|
+
const callArgs = OpenaiMock.setWidgetState.mock.calls[0]?.[0]?.modelContent;
|
|
56
58
|
expect(callArgs).toHaveProperty("existingKey", "existingValue");
|
|
57
|
-
expect(callArgs).toHaveProperty("
|
|
59
|
+
expect(callArgs).toHaveProperty("__view_context");
|
|
58
60
|
});
|
|
59
61
|
it("should handle deeply nested DataLLM components", () => {
|
|
60
62
|
render(_jsxs(DataLLM, { content: "Level 1", children: [_jsx(DataLLM, { content: "Level 2A" }), _jsx(DataLLM, { content: "Level 2B", children: _jsx(DataLLM, { content: "Level 3", children: _jsx("div", { children: "Content" }) }) })] }));
|
|
61
|
-
const callArgs = OpenaiMock.setWidgetState.mock.calls[OpenaiMock.setWidgetState.mock.calls.length - 1]?.[0];
|
|
62
|
-
const context = callArgs?.
|
|
63
|
+
const callArgs = OpenaiMock.setWidgetState.mock.calls[OpenaiMock.setWidgetState.mock.calls.length - 1]?.[0]?.modelContent;
|
|
64
|
+
const context = callArgs?.__view_context;
|
|
63
65
|
expect(context).toContain("- Level 1");
|
|
64
66
|
expect(context).toContain(" - Level 2A");
|
|
65
67
|
expect(context).toContain(" - Level 2B");
|
|
@@ -70,16 +72,16 @@ describe("DataLLM", () => {
|
|
|
70
72
|
const initialCalls = OpenaiMock.setWidgetState.mock.calls.length;
|
|
71
73
|
rerender(_jsx(DataLLM, { content: "Updated content", children: _jsx("div", { children: "Child" }) }));
|
|
72
74
|
expect(OpenaiMock.setWidgetState.mock.calls.length).toBeGreaterThan(initialCalls);
|
|
73
|
-
const lastCallArgs = OpenaiMock.setWidgetState.mock.calls[OpenaiMock.setWidgetState.mock.calls.length - 1]?.[0];
|
|
74
|
-
expect(lastCallArgs?.
|
|
75
|
+
const lastCallArgs = OpenaiMock.setWidgetState.mock.calls[OpenaiMock.setWidgetState.mock.calls.length - 1]?.[0]?.modelContent;
|
|
76
|
+
expect(lastCallArgs?.__view_context).toContain("- Updated content");
|
|
75
77
|
});
|
|
76
78
|
it("should remove node and update context when component unmounts", () => {
|
|
77
79
|
const { unmount } = render(_jsx(DataLLM, { content: "Content to remove", children: _jsx("div", { children: "Child" }) }));
|
|
78
80
|
const callsBeforeUnmount = OpenaiMock.setWidgetState.mock.calls.length;
|
|
79
81
|
unmount();
|
|
80
82
|
expect(OpenaiMock.setWidgetState.mock.calls.length).toBeGreaterThan(callsBeforeUnmount);
|
|
81
|
-
const lastCallArgs = OpenaiMock.setWidgetState.mock.calls[OpenaiMock.setWidgetState.mock.calls.length - 1]?.[0];
|
|
82
|
-
expect(lastCallArgs?.
|
|
83
|
+
const lastCallArgs = OpenaiMock.setWidgetState.mock.calls[OpenaiMock.setWidgetState.mock.calls.length - 1]?.[0]?.modelContent;
|
|
84
|
+
expect(lastCallArgs?.__view_context).not.toContain("Content to remove");
|
|
83
85
|
});
|
|
84
86
|
});
|
|
85
87
|
describe("mcp-app mode", () => {
|
|
@@ -91,44 +93,45 @@ describe("DataLLM", () => {
|
|
|
91
93
|
vi.stubGlobal("parent", { postMessage: postMessageMock });
|
|
92
94
|
});
|
|
93
95
|
afterEach(() => {
|
|
96
|
+
cleanup();
|
|
94
97
|
McpAppBridge.resetInstance();
|
|
95
98
|
McpAppAdaptor.resetInstance();
|
|
96
99
|
});
|
|
97
|
-
it("should register a node and update
|
|
100
|
+
it("should register a node and update view state via adaptor", async () => {
|
|
98
101
|
const adaptor = McpAppAdaptor.getInstance();
|
|
99
102
|
render(_jsx(DataLLM, { content: "Test content", children: _jsx("div", { children: "Child" }) }));
|
|
100
103
|
await vi.waitFor(() => {
|
|
101
|
-
const
|
|
102
|
-
.getHostContextStore("
|
|
104
|
+
const viewState = adaptor
|
|
105
|
+
.getHostContextStore("viewState")
|
|
103
106
|
.getSnapshot();
|
|
104
|
-
expect(
|
|
107
|
+
expect(viewState?.__view_context).toContain("- Test content");
|
|
105
108
|
});
|
|
106
109
|
});
|
|
107
|
-
it("should preserve existing
|
|
110
|
+
it("should preserve existing view state when updating context", async () => {
|
|
108
111
|
const adaptor = McpAppAdaptor.getInstance();
|
|
109
|
-
await adaptor.
|
|
112
|
+
await adaptor.setViewState({ existingKey: "existingValue" });
|
|
110
113
|
render(_jsx(DataLLM, { content: "Test content", children: _jsx("div", { children: "Child" }) }));
|
|
111
114
|
await vi.waitFor(() => {
|
|
112
|
-
const
|
|
113
|
-
.getHostContextStore("
|
|
115
|
+
const viewState = adaptor
|
|
116
|
+
.getHostContextStore("viewState")
|
|
114
117
|
.getSnapshot();
|
|
115
|
-
expect(
|
|
116
|
-
expect(
|
|
118
|
+
expect(viewState?.existingKey).toBe("existingValue");
|
|
119
|
+
expect(viewState?.__view_context).toContain("- Test content");
|
|
117
120
|
});
|
|
118
121
|
});
|
|
119
122
|
it("should handle multiple DataLLM components sharing state through adaptor", async () => {
|
|
120
123
|
const adaptor = McpAppAdaptor.getInstance();
|
|
121
124
|
render(_jsxs(_Fragment, { children: [_jsx(DataLLM, { content: "First component", children: _jsx("div", { children: "First" }) }), _jsx(DataLLM, { content: "Second component", children: _jsx("div", { children: "Second" }) })] }));
|
|
122
125
|
await vi.waitFor(() => {
|
|
123
|
-
const
|
|
124
|
-
.getHostContextStore("
|
|
126
|
+
const viewState = adaptor
|
|
127
|
+
.getHostContextStore("viewState")
|
|
125
128
|
.getSnapshot();
|
|
126
|
-
const context =
|
|
129
|
+
const context = viewState?.__view_context;
|
|
127
130
|
expect(context).toContain("- First component");
|
|
128
131
|
expect(context).toContain("- Second component");
|
|
129
132
|
});
|
|
130
133
|
});
|
|
131
|
-
it("should call ui/update-model-context when
|
|
134
|
+
it("should call ui/update-model-context when view state changes", async () => {
|
|
132
135
|
render(_jsx(DataLLM, { content: "Test content", children: _jsx("div", { children: "Child" }) }));
|
|
133
136
|
await vi.waitFor(() => {
|
|
134
137
|
expect(postMessageMock).toHaveBeenCalledWith(expect.objectContaining({ method: "ui/update-model-context" }), "*");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-llm.test.js","sourceRoot":"","sources":["../../src/web/data-llm.test.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,MAAM,EACN,EAAE,EAEF,EAAE,GACH,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAE/B,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,SAAS,CAAC,GAAG,EAAE;QACb,sDAAsD;QACtD,OAA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terEach,\n beforeEach,\n describe,\n expect,\n it,\n type Mock,\n vi,\n} from \"vitest\";\nimport { McpAppAdaptor, McpAppBridge } from \"./bridges/mcp-app/index.js\";\nimport { DataLLM } from \"./data-llm.js\";\nimport {\n getMcpAppHostPostMessageMock,\n MockResizeObserver,\n} from \"./hooks/test/utils.js\";\n\ndescribe(\"DataLLM\", () => {\n afterEach(() => {\n // Clean up React components BEFORE unstubbing globals\n cleanup();\n vi.unstubAllGlobals();\n vi.resetAllMocks();\n });\n\n describe(\"apps-sdk mode\", () => {\n let OpenaiMock: { widgetState: unknown; setWidgetState: Mock };\n\n beforeEach(() => {\n OpenaiMock = {\n widgetState: { modelContent: {} },\n setWidgetState: vi.fn(),\n };\n // Use Object.defineProperty to ensure it persists\n Object.defineProperty(globalThis, \"openai\", {\n value: OpenaiMock,\n writable: true,\n configurable: true,\n });\n // Also set on window for browser-like environment\n if (typeof window !== \"undefined\") {\n Object.defineProperty(window, \"openai\", {\n value: OpenaiMock,\n writable: true,\n configurable: true,\n });\n }\n vi.stubGlobal(\"openai\", OpenaiMock);\n vi.stubGlobal(\"skybridge\", { hostType: \"apps-sdk\" });\n });\n\n afterEach(() => {\n // Keep the mock available for React cleanup, but reset it\n if (typeof window !== \"undefined\" && window.openai) {\n window.openai.setWidgetState = vi.fn();\n window.openai.widgetState = { modelContent: {}, privateContent: {} };\n }\n });\n\n it(\"should register a node with content and call setViewState\", () => {\n render(\n <DataLLM content=\"Test content\">\n <div>Child</div>\n </DataLLM>,\n );\n\n expect(OpenaiMock.setWidgetState).toHaveBeenCalled();\n const callArgs =\n OpenaiMock.setWidgetState.mock.calls[0]?.[0]?.modelContent;\n expect(callArgs).toHaveProperty(\"__view_context\");\n expect(callArgs?.__view_context).toContain(\"- Test content\");\n });\n it(\"should preserve existing viewState when updating context\", () => {\n OpenaiMock.widgetState = {\n modelContent: { existingKey: \"existingValue\" },\n };\n\n render(\n <DataLLM content=\"Test content\">\n <div>Child</div>\n </DataLLM>,\n );\n\n const callArgs =\n OpenaiMock.setWidgetState.mock.calls[0]?.[0]?.modelContent;\n expect(callArgs).toHaveProperty(\"existingKey\", \"existingValue\");\n expect(callArgs).toHaveProperty(\"__view_context\");\n });\n\n it(\"should handle deeply nested DataLLM components\", () => {\n render(\n <DataLLM content=\"Level 1\">\n <DataLLM content=\"Level 2A\" />\n <DataLLM content=\"Level 2B\">\n <DataLLM content=\"Level 3\">\n <div>Content</div>\n </DataLLM>\n </DataLLM>\n </DataLLM>,\n );\n\n const callArgs =\n OpenaiMock.setWidgetState.mock.calls[\n OpenaiMock.setWidgetState.mock.calls.length - 1\n ]?.[0]?.modelContent;\n const context = callArgs?.__view_context as string;\n expect(context).toContain(\"- Level 1\");\n expect(context).toContain(\" - Level 2A\");\n expect(context).toContain(\" - Level 2B\");\n expect(context).toContain(\" - Level 3\");\n });\n\n it(\"should update context when content changes\", () => {\n const { rerender } = render(\n <DataLLM content=\"Initial content\">\n <div>Child</div>\n </DataLLM>,\n );\n\n const initialCalls = OpenaiMock.setWidgetState.mock.calls.length;\n\n rerender(\n <DataLLM content=\"Updated content\">\n <div>Child</div>\n </DataLLM>,\n );\n\n expect(OpenaiMock.setWidgetState.mock.calls.length).toBeGreaterThan(\n initialCalls,\n );\n const lastCallArgs =\n OpenaiMock.setWidgetState.mock.calls[\n OpenaiMock.setWidgetState.mock.calls.length - 1\n ]?.[0]?.modelContent;\n expect(lastCallArgs?.__view_context).toContain(\"- Updated content\");\n });\n\n it(\"should remove node and update context when component unmounts\", () => {\n const { unmount } = render(\n <DataLLM content=\"Content to remove\">\n <div>Child</div>\n </DataLLM>,\n );\n\n const callsBeforeUnmount = OpenaiMock.setWidgetState.mock.calls.length;\n\n unmount();\n\n expect(OpenaiMock.setWidgetState.mock.calls.length).toBeGreaterThan(\n callsBeforeUnmount,\n );\n const lastCallArgs =\n OpenaiMock.setWidgetState.mock.calls[\n OpenaiMock.setWidgetState.mock.calls.length - 1\n ]?.[0]?.modelContent;\n expect(lastCallArgs?.__view_context).not.toContain(\"Content to remove\");\n });\n });\n\n describe(\"mcp-app mode\", () => {\n let postMessageMock: ReturnType<typeof getMcpAppHostPostMessageMock>;\n\n beforeEach(() => {\n vi.stubGlobal(\"skybridge\", { hostType: \"mcp-app\" });\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n postMessageMock = getMcpAppHostPostMessageMock();\n vi.stubGlobal(\"parent\", { postMessage: postMessageMock });\n });\n\n afterEach(() => {\n cleanup();\n McpAppBridge.resetInstance();\n McpAppAdaptor.resetInstance();\n });\n\n it(\"should register a node and update view state via adaptor\", async () => {\n const adaptor = McpAppAdaptor.getInstance();\n\n render(\n <DataLLM content=\"Test content\">\n <div>Child</div>\n </DataLLM>,\n );\n\n await vi.waitFor(() => {\n const viewState = adaptor\n .getHostContextStore(\"viewState\")\n .getSnapshot();\n expect(viewState?.__view_context).toContain(\"- Test content\");\n });\n });\n\n it(\"should preserve existing view state when updating context\", async () => {\n const adaptor = McpAppAdaptor.getInstance();\n await adaptor.setViewState({ existingKey: \"existingValue\" });\n\n render(\n <DataLLM content=\"Test content\">\n <div>Child</div>\n </DataLLM>,\n );\n\n await vi.waitFor(() => {\n const viewState = adaptor\n .getHostContextStore(\"viewState\")\n .getSnapshot();\n expect(viewState?.existingKey).toBe(\"existingValue\");\n expect(viewState?.__view_context).toContain(\"- Test content\");\n });\n });\n\n it(\"should handle multiple DataLLM components sharing state through adaptor\", async () => {\n const adaptor = McpAppAdaptor.getInstance();\n\n render(\n <>\n <DataLLM content=\"First component\">\n <div>First</div>\n </DataLLM>\n <DataLLM content=\"Second component\">\n <div>Second</div>\n </DataLLM>\n </>,\n );\n\n await vi.waitFor(() => {\n const viewState = adaptor\n .getHostContextStore(\"viewState\")\n .getSnapshot();\n const context = viewState?.__view_context as string;\n expect(context).toContain(\"- First component\");\n expect(context).toContain(\"- Second component\");\n });\n });\n\n it(\"should call ui/update-model-context when view state changes\", async () => {\n render(\n <DataLLM content=\"Test content\">\n <div>Child</div>\n </DataLLM>,\n );\n\n await vi.waitFor(() => {\n expect(postMessageMock).toHaveBeenCalledWith(\n expect.objectContaining({ method: \"ui/update-model-context\" }),\n \"*\",\n );\n });\n });\n });\n});\n"]}
|
|
@@ -15,7 +15,7 @@ type TypedToolInfoReturn<TInput, TOutput, TResponseMetadata> = ToolState<Objecti
|
|
|
15
15
|
* Creates typed versions of skybridge hooks with full type inference
|
|
16
16
|
* for tool names, inputs, and outputs.
|
|
17
17
|
*
|
|
18
|
-
* This is the recommended way to use skybridge hooks in your
|
|
18
|
+
* This is the recommended way to use skybridge hooks in your views.
|
|
19
19
|
* Set this up once in a dedicated file and export the typed hooks for use across your app.
|
|
20
20
|
*
|
|
21
21
|
* @typeParam ServerType - The type of your McpServer instance (use `typeof server`).
|
|
@@ -24,11 +24,13 @@ type TypedToolInfoReturn<TInput, TOutput, TResponseMetadata> = ToolState<Objecti
|
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
26
|
* ```typescript
|
|
27
|
-
* //
|
|
27
|
+
* // src/server.ts
|
|
28
28
|
* const server = new McpServer({ name: "my-app", version: "1.0" }, {})
|
|
29
|
-
* .
|
|
29
|
+
* .registerTool({
|
|
30
|
+
* name: "search-trip",
|
|
30
31
|
* inputSchema: { destination: z.string() },
|
|
31
32
|
* outputSchema: { results: z.array(z.string()) },
|
|
33
|
+
* view: { component: "search-trip", description: "Search trips" },
|
|
32
34
|
* }, async ({ destination }) => {
|
|
33
35
|
* return { content: [{ type: "text", text: `Found trips to ${destination}` }] };
|
|
34
36
|
* });
|
|
@@ -38,8 +40,8 @@ type TypedToolInfoReturn<TInput, TOutput, TResponseMetadata> = ToolState<Objecti
|
|
|
38
40
|
*
|
|
39
41
|
* @example
|
|
40
42
|
* ```typescript
|
|
41
|
-
* //
|
|
42
|
-
* import type { AppType } from "
|
|
43
|
+
* // src/helpers.ts (one-time setup)
|
|
44
|
+
* import type { AppType } from "./server";
|
|
43
45
|
* import { generateHelpers } from "skybridge/web";
|
|
44
46
|
*
|
|
45
47
|
* export const { useCallTool, useToolInfo } = generateHelpers<AppType>();
|
|
@@ -47,19 +49,19 @@ type TypedToolInfoReturn<TInput, TOutput, TResponseMetadata> = ToolState<Objecti
|
|
|
47
49
|
*
|
|
48
50
|
* @example
|
|
49
51
|
* ```typescript
|
|
50
|
-
* //
|
|
51
|
-
* import { useCallTool, useToolInfo } from "../
|
|
52
|
+
* // src/views/search.tsx (usage)
|
|
53
|
+
* import { useCallTool, useToolInfo } from "../helpers";
|
|
52
54
|
*
|
|
53
|
-
* export function
|
|
54
|
-
* const { callTool, data } = useCallTool("search-
|
|
55
|
+
* export function SearchView() {
|
|
56
|
+
* const { callTool, data } = useCallTool("search-trip");
|
|
55
57
|
* // ^ autocomplete for tool names
|
|
56
58
|
* callTool({ destination: "Spain" });
|
|
57
59
|
* // ^ autocomplete for input fields
|
|
58
60
|
*
|
|
59
|
-
* const toolInfo = useToolInfo<"search-
|
|
60
|
-
* // ^ autocomplete for
|
|
61
|
-
* // toolInfo.input is typed based on
|
|
62
|
-
* // toolInfo.output.structuredContent is typed based on
|
|
61
|
+
* const toolInfo = useToolInfo<"search-trip">();
|
|
62
|
+
* // ^ autocomplete for view names
|
|
63
|
+
* // toolInfo.input is typed based on view input schema
|
|
64
|
+
* // toolInfo.output.structuredContent is typed based on view output schema
|
|
63
65
|
* }
|
|
64
66
|
* ```
|
|
65
67
|
*/
|
|
@@ -68,12 +70,12 @@ export declare function generateHelpers<ServerType = never>(): {
|
|
|
68
70
|
* Typed version of `useCallTool` that provides autocomplete for tool names
|
|
69
71
|
* and type inference for inputs and outputs.
|
|
70
72
|
*
|
|
71
|
-
* @param name - The name of the
|
|
73
|
+
* @param name - The name of the tool to call. Autocompletes based on your server's tool registry.
|
|
72
74
|
* @returns A hook with typed `callTool` function and `data` property.
|
|
73
75
|
*
|
|
74
76
|
* @example
|
|
75
77
|
* ```typescript
|
|
76
|
-
* const { callTool, data, isPending } = useCallTool("search-
|
|
78
|
+
* const { callTool, data, isPending } = useCallTool("search-trip");
|
|
77
79
|
* // TypeScript knows callTool expects { destination: string }
|
|
78
80
|
* callTool({ destination: "Spain" });
|
|
79
81
|
*
|
|
@@ -85,15 +87,15 @@ export declare function generateHelpers<ServerType = never>(): {
|
|
|
85
87
|
*/
|
|
86
88
|
useCallTool: <ToolName extends keyof InferTools<ServerType> & string>(name: ToolName) => TypedCallToolReturn<ToolInput<ServerType, ToolName>, ToolOutput<ServerType, ToolName>>;
|
|
87
89
|
/**
|
|
88
|
-
* Typed version of `useToolInfo` that provides autocomplete for
|
|
90
|
+
* Typed version of `useToolInfo` that provides autocomplete for tool names
|
|
89
91
|
* and type inference for inputs, outputs, and responseMetadata.
|
|
90
92
|
*
|
|
91
|
-
* @typeParam K - The name of the
|
|
93
|
+
* @typeParam K - The name of the tool. Autocompletes based on your server's tool registry.
|
|
92
94
|
* @returns A discriminated union with `status: "pending" | "success"` that narrows correctly.
|
|
93
95
|
*
|
|
94
96
|
* @example
|
|
95
97
|
* ```typescript
|
|
96
|
-
* const toolInfo = useToolInfo<"search-
|
|
98
|
+
* const toolInfo = useToolInfo<"search-trip">();
|
|
97
99
|
* // toolInfo.input is typed as { destination: string; ... }
|
|
98
100
|
* // toolInfo.output is typed as { results: Array<...>; ... }
|
|
99
101
|
* // toolInfo.responseMetadata is typed based on _meta in callback return
|
|
@@ -4,7 +4,7 @@ import { useToolInfo } from "./hooks/use-tool-info.js";
|
|
|
4
4
|
* Creates typed versions of skybridge hooks with full type inference
|
|
5
5
|
* for tool names, inputs, and outputs.
|
|
6
6
|
*
|
|
7
|
-
* This is the recommended way to use skybridge hooks in your
|
|
7
|
+
* This is the recommended way to use skybridge hooks in your views.
|
|
8
8
|
* Set this up once in a dedicated file and export the typed hooks for use across your app.
|
|
9
9
|
*
|
|
10
10
|
* @typeParam ServerType - The type of your McpServer instance (use `typeof server`).
|
|
@@ -13,11 +13,13 @@ import { useToolInfo } from "./hooks/use-tool-info.js";
|
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* ```typescript
|
|
16
|
-
* //
|
|
16
|
+
* // src/server.ts
|
|
17
17
|
* const server = new McpServer({ name: "my-app", version: "1.0" }, {})
|
|
18
|
-
* .
|
|
18
|
+
* .registerTool({
|
|
19
|
+
* name: "search-trip",
|
|
19
20
|
* inputSchema: { destination: z.string() },
|
|
20
21
|
* outputSchema: { results: z.array(z.string()) },
|
|
22
|
+
* view: { component: "search-trip", description: "Search trips" },
|
|
21
23
|
* }, async ({ destination }) => {
|
|
22
24
|
* return { content: [{ type: "text", text: `Found trips to ${destination}` }] };
|
|
23
25
|
* });
|
|
@@ -27,8 +29,8 @@ import { useToolInfo } from "./hooks/use-tool-info.js";
|
|
|
27
29
|
*
|
|
28
30
|
* @example
|
|
29
31
|
* ```typescript
|
|
30
|
-
* //
|
|
31
|
-
* import type { AppType } from "
|
|
32
|
+
* // src/helpers.ts (one-time setup)
|
|
33
|
+
* import type { AppType } from "./server";
|
|
32
34
|
* import { generateHelpers } from "skybridge/web";
|
|
33
35
|
*
|
|
34
36
|
* export const { useCallTool, useToolInfo } = generateHelpers<AppType>();
|
|
@@ -36,19 +38,19 @@ import { useToolInfo } from "./hooks/use-tool-info.js";
|
|
|
36
38
|
*
|
|
37
39
|
* @example
|
|
38
40
|
* ```typescript
|
|
39
|
-
* //
|
|
40
|
-
* import { useCallTool, useToolInfo } from "../
|
|
41
|
+
* // src/views/search.tsx (usage)
|
|
42
|
+
* import { useCallTool, useToolInfo } from "../helpers";
|
|
41
43
|
*
|
|
42
|
-
* export function
|
|
43
|
-
* const { callTool, data } = useCallTool("search-
|
|
44
|
+
* export function SearchView() {
|
|
45
|
+
* const { callTool, data } = useCallTool("search-trip");
|
|
44
46
|
* // ^ autocomplete for tool names
|
|
45
47
|
* callTool({ destination: "Spain" });
|
|
46
48
|
* // ^ autocomplete for input fields
|
|
47
49
|
*
|
|
48
|
-
* const toolInfo = useToolInfo<"search-
|
|
49
|
-
* // ^ autocomplete for
|
|
50
|
-
* // toolInfo.input is typed based on
|
|
51
|
-
* // toolInfo.output.structuredContent is typed based on
|
|
50
|
+
* const toolInfo = useToolInfo<"search-trip">();
|
|
51
|
+
* // ^ autocomplete for view names
|
|
52
|
+
* // toolInfo.input is typed based on view input schema
|
|
53
|
+
* // toolInfo.output.structuredContent is typed based on view output schema
|
|
52
54
|
* }
|
|
53
55
|
* ```
|
|
54
56
|
*/
|
|
@@ -58,12 +60,12 @@ export function generateHelpers() {
|
|
|
58
60
|
* Typed version of `useCallTool` that provides autocomplete for tool names
|
|
59
61
|
* and type inference for inputs and outputs.
|
|
60
62
|
*
|
|
61
|
-
* @param name - The name of the
|
|
63
|
+
* @param name - The name of the tool to call. Autocompletes based on your server's tool registry.
|
|
62
64
|
* @returns A hook with typed `callTool` function and `data` property.
|
|
63
65
|
*
|
|
64
66
|
* @example
|
|
65
67
|
* ```typescript
|
|
66
|
-
* const { callTool, data, isPending } = useCallTool("search-
|
|
68
|
+
* const { callTool, data, isPending } = useCallTool("search-trip");
|
|
67
69
|
* // TypeScript knows callTool expects { destination: string }
|
|
68
70
|
* callTool({ destination: "Spain" });
|
|
69
71
|
*
|
|
@@ -77,15 +79,15 @@ export function generateHelpers() {
|
|
|
77
79
|
return useCallTool(name);
|
|
78
80
|
},
|
|
79
81
|
/**
|
|
80
|
-
* Typed version of `useToolInfo` that provides autocomplete for
|
|
82
|
+
* Typed version of `useToolInfo` that provides autocomplete for tool names
|
|
81
83
|
* and type inference for inputs, outputs, and responseMetadata.
|
|
82
84
|
*
|
|
83
|
-
* @typeParam K - The name of the
|
|
85
|
+
* @typeParam K - The name of the tool. Autocompletes based on your server's tool registry.
|
|
84
86
|
* @returns A discriminated union with `status: "pending" | "success"` that narrows correctly.
|
|
85
87
|
*
|
|
86
88
|
* @example
|
|
87
89
|
* ```typescript
|
|
88
|
-
* const toolInfo = useToolInfo<"search-
|
|
90
|
+
* const toolInfo = useToolInfo<"search-trip">();
|
|
89
91
|
* // toolInfo.input is typed as { destination: string; ... }
|
|
90
92
|
* // toolInfo.output is typed as { results: Array<...>; ... }
|
|
91
93
|
* // toolInfo.responseMetadata is typed based on _meta in callback return
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-helpers.js","sourceRoot":"","sources":["../../src/web/generate-helpers.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAkB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAoBvE
|
|
1
|
+
{"version":3,"file":"generate-helpers.js","sourceRoot":"","sources":["../../src/web/generate-helpers.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAkB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAoBvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,UAAU,eAAe;IAI7B,OAAO;QACL;;;;;;;;;;;;;;;;;;WAkBG;QACH,WAAW,EAAE,CACX,IAAc,EAId,EAAE;YACF,OAAO,WAAW,CAAC,IAAI,CAGtB,CAAC;QACJ,CAAC;QAED;;;;;;;;;;;;;;;;;;;;;;;;;;WA0BG;QACH,WAAW,EAAE,GAIX,EAAE;YACF,OAAO,WAAW,EAIjB,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n InferTools,\n ToolInput,\n ToolOutput,\n ToolResponseMetadata,\n} from \"../server/index.js\";\nimport type { CallToolResponse } from \"./bridges/types.js\";\nimport {\n type CallToolAsyncFn,\n type CallToolFn,\n type CallToolState,\n useCallTool,\n} from \"./hooks/use-call-tool.js\";\nimport { type ToolState, useToolInfo } from \"./hooks/use-tool-info.js\";\nimport type { Objectify, Prettify } from \"./types.js\";\n\ntype TypedCallToolResponse<TOutput> = CallToolResponse & {\n structuredContent: TOutput;\n};\n\ntype TypedCallToolReturn<TInput, TOutput> = Prettify<\n CallToolState<TypedCallToolResponse<TOutput>> & {\n callTool: CallToolFn<TInput, TypedCallToolResponse<TOutput>>;\n callToolAsync: CallToolAsyncFn<TInput, TypedCallToolResponse<TOutput>>;\n }\n>;\n\ntype TypedToolInfoReturn<TInput, TOutput, TResponseMetadata> = ToolState<\n Objectify<TInput>,\n Objectify<TOutput>,\n Objectify<TResponseMetadata>\n>;\n\n/**\n * Creates typed versions of skybridge hooks with full type inference\n * for tool names, inputs, and outputs.\n *\n * This is the recommended way to use skybridge hooks in your views.\n * Set this up once in a dedicated file and export the typed hooks for use across your app.\n *\n * @typeParam ServerType - The type of your McpServer instance (use `typeof server`).\n * Must be a server instance created with method chaining.\n * TypeScript will validate that tools can be inferred from this type.\n *\n * @example\n * ```typescript\n * // src/server.ts\n * const server = new McpServer({ name: \"my-app\", version: \"1.0\" }, {})\n * .registerTool({\n * name: \"search-trip\",\n * inputSchema: { destination: z.string() },\n * outputSchema: { results: z.array(z.string()) },\n * view: { component: \"search-trip\", description: \"Search trips\" },\n * }, async ({ destination }) => {\n * return { content: [{ type: \"text\", text: `Found trips to ${destination}` }] };\n * });\n *\n * export type AppType = typeof server;\n * ```\n *\n * @example\n * ```typescript\n * // src/helpers.ts (one-time setup)\n * import type { AppType } from \"./server\";\n * import { generateHelpers } from \"skybridge/web\";\n *\n * export const { useCallTool, useToolInfo } = generateHelpers<AppType>();\n * ```\n *\n * @example\n * ```typescript\n * // src/views/search.tsx (usage)\n * import { useCallTool, useToolInfo } from \"../helpers\";\n *\n * export function SearchView() {\n * const { callTool, data } = useCallTool(\"search-trip\");\n * // ^ autocomplete for tool names\n * callTool({ destination: \"Spain\" });\n * // ^ autocomplete for input fields\n *\n * const toolInfo = useToolInfo<\"search-trip\">();\n * // ^ autocomplete for view names\n * // toolInfo.input is typed based on view input schema\n * // toolInfo.output.structuredContent is typed based on view output schema\n * }\n * ```\n */\nexport function generateHelpers<ServerType = never>() {\n type Tools = InferTools<ServerType>;\n type ToolNames = keyof Tools & string;\n\n return {\n /**\n * Typed version of `useCallTool` that provides autocomplete for tool names\n * and type inference for inputs and outputs.\n *\n * @param name - The name of the tool to call. Autocompletes based on your server's tool registry.\n * @returns A hook with typed `callTool` function and `data` property.\n *\n * @example\n * ```typescript\n * const { callTool, data, isPending } = useCallTool(\"search-trip\");\n * // TypeScript knows callTool expects { destination: string }\n * callTool({ destination: \"Spain\" });\n *\n * // data.structuredContent is typed based on your outputSchema\n * if (data) {\n * console.log(data.structuredContent.results);\n * }\n * ```\n */\n useCallTool: <ToolName extends ToolNames>(\n name: ToolName,\n ): TypedCallToolReturn<\n ToolInput<ServerType, ToolName>,\n ToolOutput<ServerType, ToolName>\n > => {\n return useCallTool(name) as TypedCallToolReturn<\n ToolInput<ServerType, ToolName>,\n ToolOutput<ServerType, ToolName>\n >;\n },\n\n /**\n * Typed version of `useToolInfo` that provides autocomplete for tool names\n * and type inference for inputs, outputs, and responseMetadata.\n *\n * @typeParam K - The name of the tool. Autocompletes based on your server's tool registry.\n * @returns A discriminated union with `status: \"pending\" | \"success\"` that narrows correctly.\n *\n * @example\n * ```typescript\n * const toolInfo = useToolInfo<\"search-trip\">();\n * // toolInfo.input is typed as { destination: string; ... }\n * // toolInfo.output is typed as { results: Array<...>; ... }\n * // toolInfo.responseMetadata is typed based on _meta in callback return\n * // toolInfo.status narrows correctly: \"pending\" | \"success\"\n *\n * if (toolInfo.isPending) {\n * // TypeScript knows output and responseMetadata are undefined here\n * console.log(toolInfo.input.destination);\n * }\n *\n * if (toolInfo.isSuccess) {\n * // TypeScript knows output and responseMetadata are defined here\n * console.log(toolInfo.output.results);\n * console.log(toolInfo.responseMetadata);\n * }\n * ```\n */\n useToolInfo: <ToolName extends ToolNames>(): TypedToolInfoReturn<\n ToolInput<ServerType, ToolName>,\n ToolOutput<ServerType, ToolName>,\n ToolResponseMetadata<ServerType, ToolName>\n > => {\n return useToolInfo() as TypedToolInfoReturn<\n ToolInput<ServerType, ToolName>,\n ToolOutput<ServerType, ToolName>,\n ToolResponseMetadata<ServerType, ToolName>\n >;\n },\n };\n}\n"]}
|
|
@@ -3,18 +3,18 @@ import { createInterfaceTestServer, createTestServer } from "../test/utils.js";
|
|
|
3
3
|
import { generateHelpers } from "./generate-helpers.js";
|
|
4
4
|
const server = createTestServer();
|
|
5
5
|
const interfaceServer = createInterfaceTestServer();
|
|
6
|
-
test("InferTools extracts the tool registry type (
|
|
7
|
-
expectTypeOf().toHaveProperty("search-
|
|
6
|
+
test("InferTools extracts the tool registry type (views + registerTool)", () => {
|
|
7
|
+
expectTypeOf().toHaveProperty("search-trip");
|
|
8
8
|
expectTypeOf().toHaveProperty("get-trip-details");
|
|
9
|
-
expectTypeOf().toHaveProperty("no-input-
|
|
9
|
+
expectTypeOf().toHaveProperty("no-input-view");
|
|
10
10
|
expectTypeOf().toHaveProperty("calculate-price");
|
|
11
|
-
expectTypeOf().toHaveProperty("inferred-output-
|
|
11
|
+
expectTypeOf().toHaveProperty("inferred-output-view");
|
|
12
12
|
expectTypeOf().toHaveProperty("inferred-tool");
|
|
13
|
-
expectTypeOf().toHaveProperty("
|
|
13
|
+
expectTypeOf().toHaveProperty("view-with-metadata");
|
|
14
14
|
expectTypeOf().toHaveProperty("tool-with-metadata");
|
|
15
|
-
expectTypeOf().toHaveProperty("
|
|
15
|
+
expectTypeOf().toHaveProperty("view-with-mixed-returns");
|
|
16
16
|
});
|
|
17
|
-
test("ToolNames returns a union of tool name literals (
|
|
17
|
+
test("ToolNames returns a union of tool name literals (views + registerTool)", () => {
|
|
18
18
|
expectTypeOf().toEqualTypeOf();
|
|
19
19
|
});
|
|
20
20
|
test("ToolInput extracts the correct input type from Zod schema", () => {
|
|
@@ -32,23 +32,23 @@ test("ToolOutput extracts the correct output type from callback (inferred)", ()
|
|
|
32
32
|
expectTypeOf().toEqualTypeOf();
|
|
33
33
|
expectTypeOf().toEqualTypeOf();
|
|
34
34
|
});
|
|
35
|
-
test("generateHelpers provides autocomplete for tool names (
|
|
35
|
+
test("generateHelpers provides autocomplete for tool names (views + registerTool)", () => {
|
|
36
36
|
const { useCallTool } = generateHelpers();
|
|
37
|
-
useCallTool("search-
|
|
37
|
+
useCallTool("search-trip");
|
|
38
38
|
useCallTool("get-trip-details");
|
|
39
|
-
useCallTool("no-input-
|
|
39
|
+
useCallTool("no-input-view");
|
|
40
40
|
useCallTool("calculate-price");
|
|
41
|
-
useCallTool("inferred-output-
|
|
41
|
+
useCallTool("inferred-output-view");
|
|
42
42
|
useCallTool("inferred-tool");
|
|
43
|
-
useCallTool("
|
|
43
|
+
useCallTool("view-with-metadata");
|
|
44
44
|
useCallTool("tool-with-metadata");
|
|
45
|
-
useCallTool("
|
|
45
|
+
useCallTool("view-with-mixed-returns");
|
|
46
46
|
// @ts-expect-error - "invalid-name" is not a valid tool name
|
|
47
47
|
useCallTool("invalid-name");
|
|
48
48
|
});
|
|
49
49
|
test("useCallTool returns correctly typed callTool function", () => {
|
|
50
50
|
const { useCallTool } = generateHelpers();
|
|
51
|
-
const { callTool } = useCallTool("search-
|
|
51
|
+
const { callTool } = useCallTool("search-trip");
|
|
52
52
|
callTool({ destination: "Spain" });
|
|
53
53
|
callTool({ destination: "France", departureDate: "2024-06-01" });
|
|
54
54
|
callTool({ destination: "Italy", maxPrice: 1000 });
|
|
@@ -57,7 +57,7 @@ test("useCallTool returns correctly typed callTool function", () => {
|
|
|
57
57
|
});
|
|
58
58
|
test("callTool can be called without args for tools with no required inputs", () => {
|
|
59
59
|
const { useCallTool } = generateHelpers();
|
|
60
|
-
const { callTool, callToolAsync } = useCallTool("no-input-
|
|
60
|
+
const { callTool, callToolAsync } = useCallTool("no-input-view");
|
|
61
61
|
callTool();
|
|
62
62
|
callTool({});
|
|
63
63
|
callToolAsync();
|
|
@@ -65,7 +65,7 @@ test("callTool can be called without args for tools with no required inputs", ()
|
|
|
65
65
|
});
|
|
66
66
|
test("callTool requires args for tools with required inputs", () => {
|
|
67
67
|
const { useCallTool } = generateHelpers();
|
|
68
|
-
const { callTool } = useCallTool("search-
|
|
68
|
+
const { callTool } = useCallTool("search-trip");
|
|
69
69
|
// @ts-expect-error - "destination" is required
|
|
70
70
|
callTool();
|
|
71
71
|
// @ts-expect-error - "destination" is required
|
|
@@ -75,7 +75,7 @@ test("callTool requires args for tools with required inputs", () => {
|
|
|
75
75
|
});
|
|
76
76
|
test("callTool supports sideEffects for tools with required inputs", () => {
|
|
77
77
|
const { useCallTool } = generateHelpers();
|
|
78
|
-
const { callTool } = useCallTool("search-
|
|
78
|
+
const { callTool } = useCallTool("search-trip");
|
|
79
79
|
callTool({ destination: "Spain" }, {
|
|
80
80
|
onSuccess: (response, args) => {
|
|
81
81
|
expectTypeOf(response.structuredContent.results).toBeArray();
|
|
@@ -96,7 +96,7 @@ test("callTool supports sideEffects for tools with required inputs", () => {
|
|
|
96
96
|
});
|
|
97
97
|
test("callTool supports sideEffects for tools with no required inputs", () => {
|
|
98
98
|
const { useCallTool } = generateHelpers();
|
|
99
|
-
const { callTool } = useCallTool("no-input-
|
|
99
|
+
const { callTool } = useCallTool("no-input-view");
|
|
100
100
|
callTool({
|
|
101
101
|
onSuccess: (response) => {
|
|
102
102
|
expectTypeOf(response).toHaveProperty("structuredContent");
|
|
@@ -110,16 +110,16 @@ test("callTool supports sideEffects for tools with no required inputs", () => {
|
|
|
110
110
|
});
|
|
111
111
|
test("callToolAsync returns correctly typed promise", () => {
|
|
112
112
|
const { useCallTool } = generateHelpers();
|
|
113
|
-
const { callToolAsync: searchAsync } = useCallTool("search-
|
|
113
|
+
const { callToolAsync: searchAsync } = useCallTool("search-trip");
|
|
114
114
|
const searchPromise = searchAsync({ destination: "Spain" });
|
|
115
115
|
expectTypeOf(searchPromise).resolves.toHaveProperty("structuredContent");
|
|
116
|
-
const { callToolAsync: noInputAsync } = useCallTool("no-input-
|
|
116
|
+
const { callToolAsync: noInputAsync } = useCallTool("no-input-view");
|
|
117
117
|
const noInputPromise = noInputAsync();
|
|
118
118
|
expectTypeOf(noInputPromise).resolves.toHaveProperty("structuredContent");
|
|
119
119
|
});
|
|
120
120
|
test("useCallTool returns correctly typed data", () => {
|
|
121
121
|
const { useCallTool } = generateHelpers();
|
|
122
|
-
const { data } = useCallTool("search-
|
|
122
|
+
const { data } = useCallTool("search-trip");
|
|
123
123
|
if (data) {
|
|
124
124
|
expectTypeOf(data.structuredContent).toExtend();
|
|
125
125
|
expectTypeOf(data.structuredContent.results).toBeArray();
|
|
@@ -128,16 +128,16 @@ test("useCallTool returns correctly typed data", () => {
|
|
|
128
128
|
});
|
|
129
129
|
test("useCallTool returns correctly typed data for callback-inferred outputs", () => {
|
|
130
130
|
const { useCallTool } = generateHelpers();
|
|
131
|
-
const { data:
|
|
132
|
-
if (
|
|
133
|
-
expectTypeOf(
|
|
131
|
+
const { data: viewData } = useCallTool("inferred-output-view");
|
|
132
|
+
if (viewData) {
|
|
133
|
+
expectTypeOf(viewData.structuredContent).toExtend();
|
|
134
134
|
}
|
|
135
135
|
const { data: toolData } = useCallTool("inferred-tool");
|
|
136
136
|
if (toolData) {
|
|
137
137
|
expectTypeOf(toolData.structuredContent).toExtend();
|
|
138
138
|
}
|
|
139
139
|
});
|
|
140
|
-
test("generateHelpers provides autocomplete for tool names in useToolInfo (
|
|
140
|
+
test("generateHelpers provides autocomplete for tool names in useToolInfo (views + registerTool)", () => {
|
|
141
141
|
const { useToolInfo } = generateHelpers();
|
|
142
142
|
useToolInfo();
|
|
143
143
|
useToolInfo();
|
|
@@ -193,7 +193,7 @@ test("ToolResponseMetadata extracts correct type when using interface declaratio
|
|
|
193
193
|
});
|
|
194
194
|
test("generateHelpers works with interface-typed server", () => {
|
|
195
195
|
const { useCallTool, useToolInfo } = generateHelpers();
|
|
196
|
-
const { data } = useCallTool("interface-
|
|
196
|
+
const { data } = useCallTool("interface-view");
|
|
197
197
|
if (data) {
|
|
198
198
|
expectTypeOf(data.structuredContent.itemName).toBeString();
|
|
199
199
|
expectTypeOf(data.structuredContent.quantity).toBeNumber();
|
|
@@ -1 +1 @@
|
|
|
1
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,GAAG,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAC/C,IAAI,IAAI,EAAE,CAAC;QACT,YAAY,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,CAAC;QAC3D,YAAY,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,CAAC;IAC7D,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,EAAoB,CAAC;IACjD,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;QACvB,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,CAAC;QACpD,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,CAAC;QACpD,YAAY,CAAC,QAAQ,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,UAAU,EAAE,CAAC;QACjE,YAAY,CAAC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { expectTypeOf, test } from \"vitest\";\nimport type {\n InferTools,\n ToolInput,\n ToolNames,\n ToolOutput,\n ToolResponseMetadata,\n} from \"../server/index.js\";\nimport { createInterfaceTestServer, createTestServer } from \"../test/utils.js\";\nimport { generateHelpers } from \"./generate-helpers.js\";\n\nconst server = createTestServer();\ntype TestServer = typeof server;\n\nconst interfaceServer = createInterfaceTestServer();\ntype InterfaceTestServer = typeof interfaceServer;\n\ntest(\"InferTools extracts the tool registry type (views + registerTool)\", () => {\n type Tools = InferTools<TestServer>;\n\n expectTypeOf<Tools>().toHaveProperty(\"search-trip\");\n expectTypeOf<Tools>().toHaveProperty(\"get-trip-details\");\n expectTypeOf<Tools>().toHaveProperty(\"no-input-view\");\n expectTypeOf<Tools>().toHaveProperty(\"calculate-price\");\n expectTypeOf<Tools>().toHaveProperty(\"inferred-output-view\");\n expectTypeOf<Tools>().toHaveProperty(\"inferred-tool\");\n expectTypeOf<Tools>().toHaveProperty(\"view-with-metadata\");\n expectTypeOf<Tools>().toHaveProperty(\"tool-with-metadata\");\n expectTypeOf<Tools>().toHaveProperty(\"view-with-mixed-returns\");\n});\n\ntest(\"ToolNames returns a union of tool name literals (views + registerTool)\", () => {\n type Names = ToolNames<TestServer>;\n\n expectTypeOf<Names>().toEqualTypeOf<\n | \"search-trip\"\n | \"get-trip-details\"\n | \"no-input-view\"\n | \"calculate-price\"\n | \"inferred-output-view\"\n | \"inferred-tool\"\n | \"view-with-metadata\"\n | \"tool-with-metadata\"\n | \"view-with-mixed-returns\"\n >();\n});\n\ntest(\"ToolInput extracts the correct input type from Zod schema\", () => {\n type SearchInput = ToolInput<TestServer, \"search-trip\">;\n\n expectTypeOf<SearchInput>().toEqualTypeOf<{\n destination: string;\n departureDate?: string | undefined;\n maxPrice?: number | undefined;\n }>();\n\n type DetailsInput = ToolInput<TestServer, \"get-trip-details\">;\n\n expectTypeOf<DetailsInput>().toEqualTypeOf<{\n tripId: string;\n }>();\n\n type CalculateInput = ToolInput<TestServer, \"calculate-price\">;\n\n expectTypeOf<CalculateInput>().toEqualTypeOf<{\n tripId: string;\n passengers: number;\n }>();\n});\n\ntest(\"ToolOutput extracts the correct output type from callback's structuredContent\", () => {\n type SearchOutput = ToolOutput<TestServer, \"search-trip\">;\n\n expectTypeOf<SearchOutput>().toEqualTypeOf<{\n results: Array<{\n id: string;\n name: string;\n price: number;\n }>;\n totalCount: number;\n }>();\n\n type DetailsOutput = ToolOutput<TestServer, \"get-trip-details\">;\n\n expectTypeOf<DetailsOutput>().toEqualTypeOf<{\n name: string;\n description: string;\n images: string[];\n }>();\n\n // Note: outputSchema has totalPrice: z.string(), but callback returns number\n // Type is inferred from callback, so totalPrice is number\n type CalculateOutput = ToolOutput<TestServer, \"calculate-price\">;\n\n expectTypeOf<CalculateOutput>().toEqualTypeOf<{\n totalPrice: number;\n currency: string;\n }>();\n\n type NoInputOutput = ToolOutput<TestServer, \"no-input-view\">;\n expectTypeOf<NoInputOutput>().toEqualTypeOf<Record<never, unknown>>();\n});\n\ntest(\"ToolOutput extracts the correct output type from callback (inferred)\", () => {\n type InferredViewOutput = ToolOutput<TestServer, \"inferred-output-view\">;\n\n expectTypeOf<InferredViewOutput>().toEqualTypeOf<{\n inferredResults: { id: string; score: number }[];\n inferredCount: number;\n }>();\n\n type InferredToolOutput = ToolOutput<TestServer, \"inferred-tool\">;\n\n expectTypeOf<InferredToolOutput>().toEqualTypeOf<{\n itemDetails: { name: string; available: boolean };\n fetchedAt: string;\n }>();\n});\n\ntest(\"generateHelpers provides autocomplete for tool names (views + registerTool)\", () => {\n const { useCallTool } = generateHelpers<TestServer>();\n\n useCallTool(\"search-trip\");\n useCallTool(\"get-trip-details\");\n useCallTool(\"no-input-view\");\n useCallTool(\"calculate-price\");\n useCallTool(\"inferred-output-view\");\n useCallTool(\"inferred-tool\");\n useCallTool(\"view-with-metadata\");\n useCallTool(\"tool-with-metadata\");\n useCallTool(\"view-with-mixed-returns\");\n\n // @ts-expect-error - \"invalid-name\" is not a valid tool name\n useCallTool(\"invalid-name\");\n});\n\ntest(\"useCallTool returns correctly typed callTool function\", () => {\n const { useCallTool } = generateHelpers<TestServer>();\n const { callTool } = useCallTool(\"search-trip\");\n\n callTool({ destination: \"Spain\" });\n callTool({ destination: \"France\", departureDate: \"2024-06-01\" });\n callTool({ destination: \"Italy\", maxPrice: 1000 });\n\n const { callTool: calculateTool } = useCallTool(\"calculate-price\");\n calculateTool({ tripId: \"123\", passengers: 2 });\n});\n\ntest(\"callTool can be called without args for tools with no required inputs\", () => {\n const { useCallTool } = generateHelpers<TestServer>();\n const { callTool, callToolAsync } = useCallTool(\"no-input-view\");\n\n callTool();\n\n callTool({});\n\n callToolAsync();\n callToolAsync({});\n});\n\ntest(\"callTool requires args for tools with required inputs\", () => {\n const { useCallTool } = generateHelpers<TestServer>();\n const { callTool } = useCallTool(\"search-trip\");\n\n // @ts-expect-error - \"destination\" is required\n callTool();\n\n // @ts-expect-error - \"destination\" is required\n callTool({});\n\n // This should work\n callTool({ destination: \"Spain\" });\n});\n\ntest(\"callTool supports sideEffects for tools with required inputs\", () => {\n const { useCallTool } = generateHelpers<TestServer>();\n const { callTool } = useCallTool(\"search-trip\");\n\n callTool(\n { destination: \"Spain\" },\n {\n onSuccess: (response, args) => {\n expectTypeOf(response.structuredContent.results).toBeArray();\n expectTypeOf(args.destination).toBeString();\n },\n onError: (error, args) => {\n expectTypeOf(error).toBeUnknown();\n expectTypeOf(args.destination).toBeString();\n },\n onSettled: (response, error, args) => {\n if (response) {\n expectTypeOf(response.structuredContent.totalCount).toBeNumber();\n }\n expectTypeOf(error).toBeUnknown();\n expectTypeOf(args.destination).toBeString();\n },\n },\n );\n});\n\ntest(\"callTool supports sideEffects for tools with no required inputs\", () => {\n const { useCallTool } = generateHelpers<TestServer>();\n const { callTool } = useCallTool(\"no-input-view\");\n\n callTool({\n onSuccess: (response) => {\n expectTypeOf(response).toHaveProperty(\"structuredContent\");\n },\n });\n\n callTool(\n {},\n {\n onSuccess: (response) => {\n expectTypeOf(response).toHaveProperty(\"structuredContent\");\n },\n },\n );\n});\n\ntest(\"callToolAsync returns correctly typed promise\", () => {\n const { useCallTool } = generateHelpers<TestServer>();\n\n const { callToolAsync: searchAsync } = useCallTool(\"search-trip\");\n const searchPromise = searchAsync({ destination: \"Spain\" });\n expectTypeOf(searchPromise).resolves.toHaveProperty(\"structuredContent\");\n\n const { callToolAsync: noInputAsync } = useCallTool(\"no-input-view\");\n const noInputPromise = noInputAsync();\n expectTypeOf(noInputPromise).resolves.toHaveProperty(\"structuredContent\");\n});\n\ntest(\"useCallTool returns correctly typed data\", () => {\n const { useCallTool } = generateHelpers<TestServer>();\n const { data } = useCallTool(\"search-trip\");\n\n if (data) {\n expectTypeOf(data.structuredContent).toExtend<{\n results: Array<{\n id: string;\n name: string;\n price: number;\n }>;\n totalCount: number;\n }>();\n\n expectTypeOf(data.structuredContent.results).toBeArray();\n expectTypeOf(data.structuredContent.totalCount).toBeNumber();\n }\n});\n\ntest(\"useCallTool returns correctly typed data for callback-inferred outputs\", () => {\n const { useCallTool } = generateHelpers<TestServer>();\n\n const { data: viewData } = useCallTool(\"inferred-output-view\");\n if (viewData) {\n expectTypeOf(viewData.structuredContent).toExtend<{\n inferredResults: { id: string; score: number }[];\n inferredCount: number;\n }>();\n }\n\n const { data: toolData } = useCallTool(\"inferred-tool\");\n if (toolData) {\n expectTypeOf(toolData.structuredContent).toExtend<{\n itemDetails: { name: string; available: boolean };\n fetchedAt: string;\n }>();\n }\n});\n\ntest(\"generateHelpers provides autocomplete for tool names in useToolInfo (views + registerTool)\", () => {\n const { useToolInfo } = generateHelpers<TestServer>();\n\n useToolInfo<\"search-trip\">();\n useToolInfo<\"get-trip-details\">();\n useToolInfo<\"no-input-view\">();\n useToolInfo<\"calculate-price\">();\n useToolInfo<\"inferred-output-view\">();\n useToolInfo<\"inferred-tool\">();\n useToolInfo<\"view-with-metadata\">();\n useToolInfo<\"tool-with-metadata\">();\n useToolInfo<\"view-with-mixed-returns\">();\n\n // @ts-expect-error - \"invalid-name\" is not a valid tool name\n useToolInfo<\"invalid-name\">();\n});\n\ntest(\"useToolInfo infers input and output types\", () => {\n const { useToolInfo } = generateHelpers<TestServer>();\n const toolInfo = useToolInfo<\"search-trip\">();\n\n // Input is only available when not in idle state\n if (!(toolInfo.status === \"idle\")) {\n expectTypeOf(toolInfo.input).toExtend<\n ToolInput<TestServer, \"search-trip\">\n >();\n }\n\n if (toolInfo.status === \"success\") {\n expectTypeOf(toolInfo.output).toExtend<\n ToolOutput<TestServer, \"search-trip\">\n >();\n expectTypeOf(toolInfo.output.results).toBeArray();\n expectTypeOf(toolInfo.output.totalCount).toBeNumber();\n }\n});\n\ntest(\"ToolResponseMetadata extracts _meta type from callback\", () => {\n type ViewMeta = ToolResponseMetadata<TestServer, \"view-with-metadata\">;\n expectTypeOf<ViewMeta>().toEqualTypeOf<{\n requestId: string;\n timestamp: number;\n cached: boolean;\n }>();\n\n type ToolMeta = ToolResponseMetadata<TestServer, \"tool-with-metadata\">;\n expectTypeOf<ToolMeta>().toEqualTypeOf<{\n executionTime: number;\n source: string;\n }>();\n\n type SearchMeta = ToolResponseMetadata<TestServer, \"search-trip\">;\n expectTypeOf<SearchMeta>().toBeUnknown();\n});\n\ntest(\"useToolInfo infers responseMetadata type from generateHelpers\", () => {\n const { useToolInfo } = generateHelpers<TestServer>();\n const toolInfo = useToolInfo<\"view-with-metadata\">();\n\n if (toolInfo.isSuccess) {\n expectTypeOf(toolInfo.responseMetadata.requestId).toBeString();\n expectTypeOf(toolInfo.responseMetadata.timestamp).toBeNumber();\n expectTypeOf(toolInfo.responseMetadata.cached).toBeBoolean();\n }\n});\n\ntest(\"ToolResponseMetadata extracts _meta from mixed return paths\", () => {\n // View has multiple return paths: some with _meta, some without\n // ExtractMeta should still infer the _meta type from branches that have it\n type MixedMeta = ToolResponseMetadata<TestServer, \"view-with-mixed-returns\">;\n expectTypeOf<MixedMeta>().toEqualTypeOf<{\n processedAt: number;\n region: string;\n }>();\n});\n\ntest(\"ToolOutput extracts correct type when using interface declaration\", () => {\n type InterfaceViewOutput = ToolOutput<InterfaceTestServer, \"interface-view\">;\n\n expectTypeOf<InterfaceViewOutput>().toHaveProperty(\"itemName\");\n expectTypeOf<InterfaceViewOutput[\"itemName\"]>().toBeString();\n expectTypeOf<InterfaceViewOutput[\"quantity\"]>().toBeNumber();\n});\n\ntest(\"ToolResponseMetadata extracts correct type when using interface declaration\", () => {\n type InterfaceViewMeta = ToolResponseMetadata<\n InterfaceTestServer,\n \"interface-view\"\n >;\n\n expectTypeOf<InterfaceViewMeta>().toHaveProperty(\"processedBy\");\n expectTypeOf<InterfaceViewMeta[\"processedBy\"]>().toBeString();\n expectTypeOf<InterfaceViewMeta[\"version\"]>().toBeNumber();\n});\n\ntest(\"generateHelpers works with interface-typed server\", () => {\n const { useCallTool, useToolInfo } = generateHelpers<InterfaceTestServer>();\n\n const { data } = useCallTool(\"interface-view\");\n if (data) {\n expectTypeOf(data.structuredContent.itemName).toBeString();\n expectTypeOf(data.structuredContent.quantity).toBeNumber();\n }\n\n const toolInfo = useToolInfo<\"interface-view\">();\n if (toolInfo.isSuccess) {\n expectTypeOf(toolInfo.output.itemName).toBeString();\n expectTypeOf(toolInfo.output.quantity).toBeNumber();\n expectTypeOf(toolInfo.responseMetadata.processedBy).toBeString();\n expectTypeOf(toolInfo.responseMetadata.version).toBeNumber();\n }\n});\n"]}
|