skybridge 0.0.0-dev.f5a2ffe → 0.0.0-dev.fc2f516

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.
Files changed (125) hide show
  1. package/README.md +173 -0
  2. package/dist/src/server/index.d.ts +2 -0
  3. package/dist/src/server/inferUtilityTypes.d.ts +54 -0
  4. package/dist/src/server/inferUtilityTypes.js +2 -0
  5. package/dist/src/server/inferUtilityTypes.js.map +1 -0
  6. package/dist/src/server/server.d.ts +44 -9
  7. package/dist/src/server/server.js +9 -1
  8. package/dist/src/server/server.js.map +1 -1
  9. package/dist/src/test/utils.d.ts +61 -0
  10. package/dist/src/test/utils.js +122 -1
  11. package/dist/src/test/utils.js.map +1 -1
  12. package/dist/src/web/data-llm.d.ts +13 -0
  13. package/dist/src/web/data-llm.js +67 -0
  14. package/dist/src/web/data-llm.js.map +1 -0
  15. package/dist/src/web/data-llm.test.js +76 -0
  16. package/dist/src/web/data-llm.test.js.map +1 -0
  17. package/dist/src/web/generate-helpers.d.ts +115 -0
  18. package/dist/src/web/generate-helpers.js +109 -0
  19. package/dist/src/web/generate-helpers.js.map +1 -0
  20. package/dist/src/web/generate-helpers.test-d.d.ts +1 -0
  21. package/dist/src/web/generate-helpers.test-d.js +151 -0
  22. package/dist/src/web/generate-helpers.test-d.js.map +1 -0
  23. package/dist/src/web/generate-helpers.test.d.ts +1 -0
  24. package/dist/src/web/generate-helpers.test.js +17 -0
  25. package/dist/src/web/generate-helpers.test.js.map +1 -0
  26. package/dist/src/web/hooks/index.d.ts +10 -5
  27. package/dist/src/web/hooks/index.js +10 -5
  28. package/dist/src/web/hooks/index.js.map +1 -1
  29. package/dist/src/web/hooks/use-call-tool.d.ts +69 -23
  30. package/dist/src/web/hooks/use-call-tool.js +26 -10
  31. package/dist/src/web/hooks/use-call-tool.js.map +1 -1
  32. package/dist/src/web/hooks/use-call-tool.test-d.d.ts +1 -0
  33. package/dist/src/web/hooks/use-call-tool.test-d.js +104 -0
  34. package/dist/src/web/hooks/use-call-tool.test-d.js.map +1 -0
  35. package/dist/src/web/hooks/use-call-tool.test.js +108 -3
  36. package/dist/src/web/hooks/use-call-tool.test.js.map +1 -1
  37. package/dist/src/web/hooks/use-files.d.ts +10 -0
  38. package/dist/src/web/hooks/use-files.js +7 -0
  39. package/dist/src/web/hooks/use-files.js.map +1 -0
  40. package/dist/src/web/hooks/use-files.test.d.ts +1 -0
  41. package/dist/src/web/hooks/use-files.test.js +29 -0
  42. package/dist/src/web/hooks/use-files.test.js.map +1 -0
  43. package/dist/src/web/hooks/use-locale.d.ts +1 -0
  44. package/dist/src/web/hooks/use-locale.js +5 -0
  45. package/dist/src/web/hooks/use-locale.js.map +1 -0
  46. package/dist/src/web/hooks/use-locale.test.d.ts +1 -0
  47. package/dist/src/web/hooks/use-locale.test.js +21 -0
  48. package/dist/src/web/hooks/use-locale.test.js.map +1 -0
  49. package/dist/src/web/hooks/use-open-external.d.ts +1 -0
  50. package/dist/src/web/hooks/use-open-external.js +6 -0
  51. package/dist/src/web/hooks/use-open-external.js.map +1 -0
  52. package/dist/src/web/hooks/use-open-external.test.d.ts +1 -0
  53. package/dist/src/web/hooks/use-open-external.test.js +24 -0
  54. package/dist/src/web/hooks/use-open-external.test.js.map +1 -0
  55. package/dist/src/web/hooks/use-openai-global.js +3 -1
  56. package/dist/src/web/hooks/use-openai-global.js.map +1 -1
  57. package/dist/src/web/hooks/use-request-modal.d.ts +6 -0
  58. package/dist/src/web/hooks/use-request-modal.js +9 -0
  59. package/dist/src/web/hooks/use-request-modal.js.map +1 -0
  60. package/dist/src/web/hooks/use-request-modal.test.d.ts +1 -0
  61. package/dist/src/web/hooks/use-request-modal.test.js +24 -0
  62. package/dist/src/web/hooks/use-request-modal.test.js.map +1 -0
  63. package/dist/src/web/hooks/use-send-follow-up-message.d.ts +1 -0
  64. package/dist/src/web/hooks/use-send-follow-up-message.js +11 -0
  65. package/dist/src/web/hooks/use-send-follow-up-message.js.map +1 -0
  66. package/dist/src/web/hooks/use-theme.d.ts +1 -0
  67. package/dist/src/web/hooks/use-theme.js +5 -0
  68. package/dist/src/web/hooks/use-theme.js.map +1 -0
  69. package/dist/src/web/hooks/use-theme.test.d.ts +1 -0
  70. package/dist/src/web/hooks/use-theme.test.js +26 -0
  71. package/dist/src/web/hooks/use-theme.test.js.map +1 -0
  72. package/dist/src/web/hooks/use-tool-info.d.ts +24 -4
  73. package/dist/src/web/hooks/use-tool-info.js +17 -4
  74. package/dist/src/web/hooks/use-tool-info.js.map +1 -1
  75. package/dist/src/web/hooks/use-tool-info.test-d.d.ts +1 -0
  76. package/dist/src/web/hooks/use-tool-info.test-d.js +74 -0
  77. package/dist/src/web/hooks/use-tool-info.test-d.js.map +1 -0
  78. package/dist/src/web/hooks/use-tool-info.test.js +36 -15
  79. package/dist/src/web/hooks/use-tool-info.test.js.map +1 -1
  80. package/dist/src/web/hooks/use-user-agent.d.ts +1 -0
  81. package/dist/src/web/hooks/use-user-agent.js +5 -0
  82. package/dist/src/web/hooks/use-user-agent.js.map +1 -0
  83. package/dist/src/web/hooks/use-user-agent.test.d.ts +1 -0
  84. package/dist/src/web/hooks/use-user-agent.test.js +31 -0
  85. package/dist/src/web/hooks/use-user-agent.test.js.map +1 -0
  86. package/dist/src/web/hooks/use-widget-state.js +30 -6
  87. package/dist/src/web/hooks/use-widget-state.js.map +1 -1
  88. package/dist/src/web/hooks/use-widget-state.test.js +0 -1
  89. package/dist/src/web/hooks/use-widget-state.test.js.map +1 -1
  90. package/dist/src/web/index.d.ts +3 -1
  91. package/dist/src/web/index.js +3 -1
  92. package/dist/src/web/index.js.map +1 -1
  93. package/dist/src/web/mount-widget.js +5 -0
  94. package/dist/src/web/mount-widget.js.map +1 -1
  95. package/dist/src/web/plugin/data-llm.test.d.ts +1 -0
  96. package/dist/src/web/plugin/data-llm.test.js +81 -0
  97. package/dist/src/web/plugin/data-llm.test.js.map +1 -0
  98. package/dist/src/web/{plugin.js → plugin/plugin.js} +5 -0
  99. package/dist/src/web/plugin/plugin.js.map +1 -0
  100. package/dist/src/web/plugin/transform-data-llm.d.ts +12 -0
  101. package/dist/src/web/plugin/transform-data-llm.js +93 -0
  102. package/dist/src/web/plugin/transform-data-llm.js.map +1 -0
  103. package/dist/src/web/plugin/transform-data-llm.test.d.ts +1 -0
  104. package/dist/src/web/plugin/transform-data-llm.test.js +81 -0
  105. package/dist/src/web/plugin/transform-data-llm.test.js.map +1 -0
  106. package/dist/src/web/proxy.d.ts +1 -0
  107. package/dist/src/web/proxy.js +48 -0
  108. package/dist/src/web/proxy.js.map +1 -0
  109. package/dist/src/web/types.d.ts +43 -14
  110. package/dist/src/web/types.js +1 -0
  111. package/dist/src/web/types.js.map +1 -1
  112. package/dist/vitest.config.js +0 -1
  113. package/dist/vitest.config.js.map +1 -1
  114. package/package.json +6 -2
  115. package/dist/src/test/setup.js +0 -9
  116. package/dist/src/test/setup.js.map +0 -1
  117. package/dist/src/web/hooks/use-tool-output.d.ts +0 -4
  118. package/dist/src/web/hooks/use-tool-output.js +0 -9
  119. package/dist/src/web/hooks/use-tool-output.js.map +0 -1
  120. package/dist/src/web/hooks/use-tool-response-metadata.d.ts +0 -4
  121. package/dist/src/web/hooks/use-tool-response-metadata.js +0 -8
  122. package/dist/src/web/hooks/use-tool-response-metadata.js.map +0 -1
  123. package/dist/src/web/plugin.js.map +0 -1
  124. /package/dist/src/{test/setup.d.ts → web/data-llm.test.d.ts} +0 -0
  125. /package/dist/src/web/{plugin.d.ts → plugin/plugin.d.ts} +0 -0
@@ -0,0 +1,76 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { render } from "@testing-library/react";
3
+ import { afterEach, beforeEach, describe, expect, it, vi, } from "vitest";
4
+ import { DataLLM } from "./data-llm.js";
5
+ describe("DataLLM", () => {
6
+ let OpenaiMock;
7
+ beforeEach(() => {
8
+ OpenaiMock = {
9
+ widgetState: {},
10
+ setWidgetState: vi.fn(),
11
+ };
12
+ // Use Object.defineProperty to ensure it persists
13
+ Object.defineProperty(globalThis, "openai", {
14
+ value: OpenaiMock,
15
+ writable: true,
16
+ configurable: true,
17
+ });
18
+ // Also set on window for browser-like environment
19
+ if (typeof window !== "undefined") {
20
+ Object.defineProperty(window, "openai", {
21
+ value: OpenaiMock,
22
+ writable: true,
23
+ configurable: true,
24
+ });
25
+ }
26
+ vi.stubGlobal("openai", OpenaiMock);
27
+ });
28
+ afterEach(() => {
29
+ vi.resetAllMocks();
30
+ // Keep the mock available for React cleanup, but reset it
31
+ if (typeof window !== "undefined" && window.openai) {
32
+ window.openai.setWidgetState = vi.fn();
33
+ window.openai.widgetState = {};
34
+ }
35
+ });
36
+ it("should register a node with content and call setWidgetState", () => {
37
+ render(_jsx(DataLLM, { content: "Test content", children: _jsx("div", { children: "Child" }) }));
38
+ expect(OpenaiMock.setWidgetState).toHaveBeenCalled();
39
+ const callArgs = OpenaiMock.setWidgetState.mock.calls[0]?.[0];
40
+ expect(callArgs).toHaveProperty("__widget_context");
41
+ expect(callArgs?.__widget_context).toContain("- Test content");
42
+ });
43
+ it("should preserve existing widgetState when updating context", () => {
44
+ OpenaiMock.widgetState = { existingKey: "existingValue" };
45
+ render(_jsx(DataLLM, { content: "Test content", children: _jsx("div", { children: "Child" }) }));
46
+ const callArgs = OpenaiMock.setWidgetState.mock.calls[0]?.[0];
47
+ expect(callArgs).toHaveProperty("existingKey", "existingValue");
48
+ expect(callArgs).toHaveProperty("__widget_context");
49
+ });
50
+ it("should handle deeply nested DataLLM components", () => {
51
+ 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" }) }) })] }));
52
+ const callArgs = OpenaiMock.setWidgetState.mock.calls[OpenaiMock.setWidgetState.mock.calls.length - 1]?.[0];
53
+ const context = callArgs?.__widget_context;
54
+ expect(context).toContain("- Level 1");
55
+ expect(context).toContain(" - Level 2A");
56
+ expect(context).toContain(" - Level 2B");
57
+ expect(context).toContain(" - Level 3");
58
+ });
59
+ it("should update context when content changes", () => {
60
+ const { rerender } = render(_jsx(DataLLM, { content: "Initial content", children: _jsx("div", { children: "Child" }) }));
61
+ const initialCalls = OpenaiMock.setWidgetState.mock.calls.length;
62
+ rerender(_jsx(DataLLM, { content: "Updated content", children: _jsx("div", { children: "Child" }) }));
63
+ expect(OpenaiMock.setWidgetState.mock.calls.length).toBeGreaterThan(initialCalls);
64
+ const lastCallArgs = OpenaiMock.setWidgetState.mock.calls[OpenaiMock.setWidgetState.mock.calls.length - 1]?.[0];
65
+ expect(lastCallArgs?.__widget_context).toContain("- Updated content");
66
+ });
67
+ it("should remove node and update context when component unmounts", () => {
68
+ const { unmount } = render(_jsx(DataLLM, { content: "Content to remove", children: _jsx("div", { children: "Child" }) }));
69
+ const callsBeforeUnmount = OpenaiMock.setWidgetState.mock.calls.length;
70
+ unmount();
71
+ expect(OpenaiMock.setWidgetState.mock.calls.length).toBeGreaterThan(callsBeforeUnmount);
72
+ const lastCallArgs = OpenaiMock.setWidgetState.mock.calls[OpenaiMock.setWidgetState.mock.calls.length - 1]?.[0];
73
+ expect(lastCallArgs?.__widget_context).not.toContain("Content to remove");
74
+ });
75
+ });
76
+ //# sourceMappingURL=data-llm.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-llm.test.js","sourceRoot":"","sources":["../../../src/web/data-llm.test.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,MAAM,EACN,EAAE,EACF,EAAE,GAEH,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,IAAI,UAA0D,CAAC;IAE/D,UAAU,CAAC,GAAG,EAAE;QACd,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AAK,CAAC,MAAM,CAAC,CAAC,eAAe,CACjE,kBAAkB,CACnB,CAAC;QACF,MAAM,YAAY,GAChB,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAClC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAChD,EAAE,CAAC,CAAC,CAAC,CAAC;QACT,MAAM,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,115 @@
1
+ import { type CallToolState, type CallToolFn, type CallToolAsyncFn } from "./hooks/use-call-tool.js";
2
+ import { type ToolState } from "./hooks/use-tool-info.js";
3
+ import type { InferTools, ToolInput, ToolOutput } from "../server/index.js";
4
+ import type { CallToolResponse, Prettify, Objectify } from "./types.js";
5
+ type TypedCallToolResponse<TOutput> = CallToolResponse & {
6
+ structuredContent: TOutput;
7
+ };
8
+ type TypedCallToolReturn<TInput, TOutput> = Prettify<CallToolState<TypedCallToolResponse<TOutput>> & {
9
+ callTool: CallToolFn<TInput, TypedCallToolResponse<TOutput>>;
10
+ callToolAsync: CallToolAsyncFn<TInput, TypedCallToolResponse<TOutput>>;
11
+ }>;
12
+ type TypedToolInfoReturn<TInput, TOutput> = ToolState<Objectify<TInput>, {
13
+ structuredContent: TOutput;
14
+ }, Objectify<{}>>;
15
+ /**
16
+ * Creates typed versions of skybridge hooks with full type inference
17
+ * for tool names, inputs, and outputs.
18
+ *
19
+ * This is the recommended way to use skybridge hooks in your widgets.
20
+ * Set this up once in a dedicated file and export the typed hooks for use across your app.
21
+ *
22
+ * @typeParam ServerType - The type of your McpServer instance (use `typeof server`).
23
+ * Must be a server instance created with method chaining.
24
+ * TypeScript will validate that tools can be inferred from this type.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * // server/src/index.ts
29
+ * const server = new McpServer({ name: "my-app", version: "1.0" }, {})
30
+ * .widget("search-voyage", {}, {
31
+ * inputSchema: { destination: z.string() },
32
+ * outputSchema: { results: z.array(z.string()) },
33
+ * }, async ({ destination }) => {
34
+ * return { content: [{ type: "text", text: `Found trips to ${destination}` }] };
35
+ * });
36
+ *
37
+ * export type AppType = typeof server;
38
+ * ```
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * // web/src/skybridge.ts (one-time setup)
43
+ * import type { AppType } from "../server";
44
+ * import { generateHelpers } from "skybridge/web";
45
+ *
46
+ * export const { useCallTool, useToolInfo } = generateHelpers<AppType>();
47
+ * ```
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * // web/src/widgets/search.tsx (usage)
52
+ * import { useCallTool, useToolInfo } from "../skybridge";
53
+ *
54
+ * export function SearchWidget() {
55
+ * const { callTool, data } = useCallTool("search-voyage");
56
+ * // ^ autocomplete for tool names
57
+ * callTool({ destination: "Spain" });
58
+ * // ^ autocomplete for input fields
59
+ *
60
+ * const toolInfo = useToolInfo<"search-voyage">();
61
+ * // ^ autocomplete for widget names
62
+ * // toolInfo.input is typed based on widget input schema
63
+ * // toolInfo.output.structuredContent is typed based on widget output schema
64
+ * }
65
+ * ```
66
+ */
67
+ export declare function generateHelpers<ServerType = never>(): {
68
+ /**
69
+ * Typed version of `useCallTool` that provides autocomplete for tool names
70
+ * and type inference for inputs and outputs.
71
+ *
72
+ * @param name - The name of the widget to call. Autocompletes based on your server's widget registry.
73
+ * @returns A hook with typed `callTool` function and `data` property.
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const { callTool, data, isPending } = useCallTool("search-voyage");
78
+ * // TypeScript knows callTool expects { destination: string }
79
+ * callTool({ destination: "Spain" });
80
+ *
81
+ * // data.structuredContent is typed based on your outputSchema
82
+ * if (data) {
83
+ * console.log(data.structuredContent.results);
84
+ * }
85
+ * ```
86
+ */
87
+ useCallTool: <ToolName extends keyof InferTools<ServerType> & string>(name: ToolName) => TypedCallToolReturn<ToolInput<ServerType, ToolName>, ToolOutput<ServerType, ToolName>>;
88
+ /**
89
+ * Typed version of `useToolInfo` that provides autocomplete for widget names
90
+ * and type inference for inputs, outputs, and responseMetadata.
91
+ *
92
+ * @typeParam K - The name of the widget. Autocompletes based on your server's widget registry.
93
+ * @returns A discriminated union with `status: "pending" | "success"` that narrows correctly.
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * const toolInfo = useToolInfo<"search-voyage">();
98
+ * // toolInfo.input is typed as { destination: string; ... }
99
+ * // toolInfo.output.structuredContent is typed as { results: Array<...>; ... }
100
+ * // toolInfo.status narrows correctly: "pending" | "success"
101
+ *
102
+ * if (toolInfo.isPending) {
103
+ * // TypeScript knows output is undefined here
104
+ * console.log(toolInfo.input.destination);
105
+ * }
106
+ *
107
+ * if (toolInfo.isSuccess) {
108
+ * // TypeScript knows output is defined here
109
+ * console.log(toolInfo.output.structuredContent.results);
110
+ * }
111
+ * ```
112
+ */
113
+ useToolInfo: <ToolName extends keyof InferTools<ServerType> & string>() => TypedToolInfoReturn<ToolInput<ServerType, ToolName>, ToolOutput<ServerType, ToolName>>;
114
+ };
115
+ export {};
@@ -0,0 +1,109 @@
1
+ import { useCallTool, } from "./hooks/use-call-tool.js";
2
+ import { useToolInfo } from "./hooks/use-tool-info.js";
3
+ /**
4
+ * Creates typed versions of skybridge hooks with full type inference
5
+ * for tool names, inputs, and outputs.
6
+ *
7
+ * This is the recommended way to use skybridge hooks in your widgets.
8
+ * Set this up once in a dedicated file and export the typed hooks for use across your app.
9
+ *
10
+ * @typeParam ServerType - The type of your McpServer instance (use `typeof server`).
11
+ * Must be a server instance created with method chaining.
12
+ * TypeScript will validate that tools can be inferred from this type.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * // server/src/index.ts
17
+ * const server = new McpServer({ name: "my-app", version: "1.0" }, {})
18
+ * .widget("search-voyage", {}, {
19
+ * inputSchema: { destination: z.string() },
20
+ * outputSchema: { results: z.array(z.string()) },
21
+ * }, async ({ destination }) => {
22
+ * return { content: [{ type: "text", text: `Found trips to ${destination}` }] };
23
+ * });
24
+ *
25
+ * export type AppType = typeof server;
26
+ * ```
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * // web/src/skybridge.ts (one-time setup)
31
+ * import type { AppType } from "../server";
32
+ * import { generateHelpers } from "skybridge/web";
33
+ *
34
+ * export const { useCallTool, useToolInfo } = generateHelpers<AppType>();
35
+ * ```
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * // web/src/widgets/search.tsx (usage)
40
+ * import { useCallTool, useToolInfo } from "../skybridge";
41
+ *
42
+ * export function SearchWidget() {
43
+ * const { callTool, data } = useCallTool("search-voyage");
44
+ * // ^ autocomplete for tool names
45
+ * callTool({ destination: "Spain" });
46
+ * // ^ autocomplete for input fields
47
+ *
48
+ * const toolInfo = useToolInfo<"search-voyage">();
49
+ * // ^ autocomplete for widget names
50
+ * // toolInfo.input is typed based on widget input schema
51
+ * // toolInfo.output.structuredContent is typed based on widget output schema
52
+ * }
53
+ * ```
54
+ */
55
+ export function generateHelpers() {
56
+ return {
57
+ /**
58
+ * Typed version of `useCallTool` that provides autocomplete for tool names
59
+ * and type inference for inputs and outputs.
60
+ *
61
+ * @param name - The name of the widget to call. Autocompletes based on your server's widget registry.
62
+ * @returns A hook with typed `callTool` function and `data` property.
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * const { callTool, data, isPending } = useCallTool("search-voyage");
67
+ * // TypeScript knows callTool expects { destination: string }
68
+ * callTool({ destination: "Spain" });
69
+ *
70
+ * // data.structuredContent is typed based on your outputSchema
71
+ * if (data) {
72
+ * console.log(data.structuredContent.results);
73
+ * }
74
+ * ```
75
+ */
76
+ useCallTool: (name) => {
77
+ return useCallTool(name);
78
+ },
79
+ /**
80
+ * Typed version of `useToolInfo` that provides autocomplete for widget names
81
+ * and type inference for inputs, outputs, and responseMetadata.
82
+ *
83
+ * @typeParam K - The name of the widget. Autocompletes based on your server's widget registry.
84
+ * @returns A discriminated union with `status: "pending" | "success"` that narrows correctly.
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * const toolInfo = useToolInfo<"search-voyage">();
89
+ * // toolInfo.input is typed as { destination: string; ... }
90
+ * // toolInfo.output.structuredContent is typed as { results: Array<...>; ... }
91
+ * // toolInfo.status narrows correctly: "pending" | "success"
92
+ *
93
+ * if (toolInfo.isPending) {
94
+ * // TypeScript knows output is undefined here
95
+ * console.log(toolInfo.input.destination);
96
+ * }
97
+ *
98
+ * if (toolInfo.isSuccess) {
99
+ * // TypeScript knows output is defined here
100
+ * console.log(toolInfo.output.structuredContent.results);
101
+ * }
102
+ * ```
103
+ */
104
+ useToolInfo: () => {
105
+ return useToolInfo();
106
+ },
107
+ };
108
+ }
109
+ //# sourceMappingURL=generate-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-helpers.js","sourceRoot":"","sources":["../../../src/web/generate-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAIZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAAkB,MAAM,0BAA0B,CAAC;AAmBvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,UAAU,eAAe;IAI7B,OAAO;QACL;;;;;;;;;;;;;;;;;;WAkBG;QACH,WAAW,EAAE,CACX,IAAc,EAC0E,EAAE;YAC1F,OAAO,WAAW,CAAC,IAAI,CAGtB,CAAC;QACJ,CAAC;QAED;;;;;;;;;;;;;;;;;;;;;;;;WAwBG;QACH,WAAW,EAAE,GAGX,EAAE;YACF,OAAO,WAAW,EAGjB,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,151 @@
1
+ import { expectTypeOf, test } from "vitest";
2
+ import { generateHelpers } from "./generate-helpers.js";
3
+ import { createTestServer } from "../test/utils.js";
4
+ const server = createTestServer();
5
+ test("InferTools extracts the tool registry type (widgets + registerTool)", () => {
6
+ expectTypeOf().toHaveProperty("search-voyage");
7
+ expectTypeOf().toHaveProperty("get-trip-details");
8
+ expectTypeOf().toHaveProperty("no-input-widget");
9
+ expectTypeOf().toHaveProperty("calculate-price");
10
+ expectTypeOf().toHaveProperty("inferred-output-widget");
11
+ expectTypeOf().toHaveProperty("inferred-tool");
12
+ });
13
+ test("ToolNames returns a union of tool name literals (widgets + registerTool)", () => {
14
+ expectTypeOf().toEqualTypeOf();
15
+ });
16
+ test("ToolInput extracts the correct input type from Zod schema", () => {
17
+ expectTypeOf().toEqualTypeOf();
18
+ expectTypeOf().toEqualTypeOf();
19
+ expectTypeOf().toEqualTypeOf();
20
+ });
21
+ test("ToolOutput extracts the correct output type from callback's structuredContent", () => {
22
+ expectTypeOf().toEqualTypeOf();
23
+ expectTypeOf().toEqualTypeOf();
24
+ expectTypeOf().toEqualTypeOf();
25
+ expectTypeOf().toEqualTypeOf();
26
+ });
27
+ test("ToolOutput extracts the correct output type from callback (inferred)", () => {
28
+ expectTypeOf().toEqualTypeOf();
29
+ expectTypeOf().toEqualTypeOf();
30
+ });
31
+ test("generateHelpers provides autocomplete for tool names (widgets + registerTool)", () => {
32
+ const { useCallTool } = generateHelpers();
33
+ useCallTool("search-voyage");
34
+ useCallTool("get-trip-details");
35
+ useCallTool("no-input-widget");
36
+ useCallTool("calculate-price");
37
+ useCallTool("inferred-output-widget");
38
+ useCallTool("inferred-tool");
39
+ // @ts-expect-error - "invalid-name" is not a valid tool name
40
+ useCallTool("invalid-name");
41
+ });
42
+ test("useCallTool returns correctly typed callTool function", () => {
43
+ const { useCallTool } = generateHelpers();
44
+ const { callTool } = useCallTool("search-voyage");
45
+ callTool({ destination: "Spain" });
46
+ callTool({ destination: "France", departureDate: "2024-06-01" });
47
+ callTool({ destination: "Italy", maxPrice: 1000 });
48
+ const { callTool: calculateTool } = useCallTool("calculate-price");
49
+ calculateTool({ tripId: "123", passengers: 2 });
50
+ });
51
+ test("callTool can be called without args for tools with no required inputs", () => {
52
+ const { useCallTool } = generateHelpers();
53
+ const { callTool, callToolAsync } = useCallTool("no-input-widget");
54
+ callTool();
55
+ callTool({});
56
+ callToolAsync();
57
+ callToolAsync({});
58
+ });
59
+ test("callTool requires args for tools with required inputs", () => {
60
+ const { useCallTool } = generateHelpers();
61
+ const { callTool } = useCallTool("search-voyage");
62
+ // @ts-expect-error - "destination" is required
63
+ callTool();
64
+ // @ts-expect-error - "destination" is required
65
+ callTool({});
66
+ // This should work
67
+ callTool({ destination: "Spain" });
68
+ });
69
+ test("callTool supports sideEffects for tools with required inputs", () => {
70
+ const { useCallTool } = generateHelpers();
71
+ const { callTool, data } = useCallTool("search-voyage");
72
+ callTool({ destination: "Spain" }, {
73
+ onSuccess: (response, args) => {
74
+ expectTypeOf(response.structuredContent.results).toBeArray();
75
+ expectTypeOf(args.destination).toBeString();
76
+ },
77
+ onError: (error, args) => {
78
+ expectTypeOf(error).toBeUnknown();
79
+ expectTypeOf(args.destination).toBeString();
80
+ },
81
+ onSettled: (response, error, args) => {
82
+ if (response) {
83
+ expectTypeOf(response.structuredContent.totalCount).toBeNumber();
84
+ }
85
+ expectTypeOf(args.destination).toBeString();
86
+ },
87
+ });
88
+ });
89
+ test("callTool supports sideEffects for tools with no required inputs", () => {
90
+ const { useCallTool } = generateHelpers();
91
+ const { callTool } = useCallTool("no-input-widget");
92
+ callTool({
93
+ onSuccess: (response) => {
94
+ expectTypeOf(response).toHaveProperty("structuredContent");
95
+ },
96
+ });
97
+ callTool({}, {
98
+ onSuccess: (response) => {
99
+ expectTypeOf(response).toHaveProperty("structuredContent");
100
+ },
101
+ });
102
+ });
103
+ test("callToolAsync returns correctly typed promise", () => {
104
+ const { useCallTool } = generateHelpers();
105
+ const { callToolAsync: searchAsync } = useCallTool("search-voyage");
106
+ const searchPromise = searchAsync({ destination: "Spain" });
107
+ expectTypeOf(searchPromise).resolves.toHaveProperty("structuredContent");
108
+ const { callToolAsync: noInputAsync } = useCallTool("no-input-widget");
109
+ const noInputPromise = noInputAsync();
110
+ expectTypeOf(noInputPromise).resolves.toHaveProperty("structuredContent");
111
+ });
112
+ test("useCallTool returns correctly typed data", () => {
113
+ const { useCallTool } = generateHelpers();
114
+ const { data } = useCallTool("search-voyage");
115
+ if (data) {
116
+ expectTypeOf(data.structuredContent).toExtend();
117
+ expectTypeOf(data.structuredContent.results).toBeArray();
118
+ expectTypeOf(data.structuredContent.totalCount).toBeNumber();
119
+ }
120
+ });
121
+ test("useCallTool returns correctly typed data for callback-inferred outputs", () => {
122
+ const { useCallTool } = generateHelpers();
123
+ const { data: widgetData } = useCallTool("inferred-output-widget");
124
+ if (widgetData) {
125
+ expectTypeOf(widgetData.structuredContent).toExtend();
126
+ }
127
+ const { data: toolData } = useCallTool("inferred-tool");
128
+ if (toolData) {
129
+ expectTypeOf(toolData.structuredContent).toExtend();
130
+ }
131
+ });
132
+ test("generateHelpers provides autocomplete for tool names in useToolInfo (widgets + registerTool)", () => {
133
+ const { useToolInfo } = generateHelpers();
134
+ useToolInfo();
135
+ useToolInfo();
136
+ useToolInfo();
137
+ useToolInfo();
138
+ useToolInfo();
139
+ useToolInfo();
140
+ // @ts-expect-error - "invalid-name" is not a valid tool name
141
+ useToolInfo();
142
+ });
143
+ test("useToolInfo infers input and output types", () => {
144
+ const { useToolInfo } = generateHelpers();
145
+ const toolInfo = useToolInfo();
146
+ expectTypeOf(toolInfo.input).toExtend();
147
+ if (toolInfo.status === "success") {
148
+ expectTypeOf(toolInfo.output.structuredContent).toExtend();
149
+ }
150
+ });
151
+ //# sourceMappingURL=generate-helpers.test-d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-helpers.test-d.js","sourceRoot":"","sources":["../../../src/web/generate-helpers.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,MAAM,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,WAAW,EAAkB,CAAC;AAChC,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,2CAA2C,EAAE,GAAG,EAAE;IACrD,MAAM,EAAE,WAAW,EAAE,GAAG,eAAe,EAAc,CAAC;IACtD,MAAM,QAAQ,GAAG,WAAW,EAAmB,CAAC;IAEhD,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,QAAQ,EAA0C,CAAC;IAEhF,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAClC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAA2C,CAAC;IACtG,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { generateHelpers } from "./generate-helpers.js";
3
+ import { createMinimalTestServer } from "../test/utils.js";
4
+ const server = createMinimalTestServer();
5
+ describe("generateHelpers", () => {
6
+ it("should return an object with useCallTool hook", () => {
7
+ const hooks = generateHelpers();
8
+ expect(hooks).toHaveProperty("useCallTool");
9
+ expect(typeof hooks.useCallTool).toBe("function");
10
+ });
11
+ it("should return an object with useToolInfo hook", () => {
12
+ const hooks = generateHelpers();
13
+ expect(hooks).toHaveProperty("useToolInfo");
14
+ expect(typeof hooks.useToolInfo).toBe("function");
15
+ });
16
+ });
17
+ //# sourceMappingURL=generate-helpers.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-helpers.test.js","sourceRoot":"","sources":["../../../src/web/generate-helpers.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,MAAM,MAAM,GAAG,uBAAuB,EAAE,CAAC;AAGzC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,KAAK,GAAG,eAAe,EAAc,CAAC;QAC5C,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,KAAK,GAAG,eAAe,EAAc,CAAC;QAC5C,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,7 +1,12 @@
1
+ export { useCallTool, type CallToolState, type SideEffects, type CallToolFn, type CallToolAsyncFn, } from "./use-call-tool.js";
2
+ export { useDisplayMode } from "./use-display-mode.js";
3
+ export { useFiles } from "./use-files.js";
4
+ export { useLocale } from "./use-locale.js";
1
5
  export { useOpenAiGlobal } from "./use-openai-global.js";
2
- export { useToolOutput } from "./use-tool-output.js";
3
- export { useToolResponseMetadata } from "./use-tool-response-metadata.js";
4
- export { useCallTool } from "./use-call-tool.js";
5
- export { useWidgetState } from "./use-widget-state.js";
6
+ export { useOpenExternal } from "./use-open-external.js";
7
+ export { useRequestModal } from "./use-request-modal.js";
8
+ export { useSendFollowUpMessage } from "./use-send-follow-up-message.js";
9
+ export { useTheme } from "./use-theme.js";
6
10
  export { useToolInfo } from "./use-tool-info.js";
7
- export { useDisplayMode } from "./use-display-mode.js";
11
+ export { useUserAgent } from "./use-user-agent.js";
12
+ export { useWidgetState } from "./use-widget-state.js";
@@ -1,8 +1,13 @@
1
+ export { useCallTool, } from "./use-call-tool.js";
2
+ export { useDisplayMode } from "./use-display-mode.js";
3
+ export { useFiles } from "./use-files.js";
4
+ export { useLocale } from "./use-locale.js";
1
5
  export { useOpenAiGlobal } from "./use-openai-global.js";
2
- export { useToolOutput } from "./use-tool-output.js";
3
- export { useToolResponseMetadata } from "./use-tool-response-metadata.js";
4
- export { useCallTool } from "./use-call-tool.js";
5
- export { useWidgetState } from "./use-widget-state.js";
6
+ export { useOpenExternal } from "./use-open-external.js";
7
+ export { useRequestModal } from "./use-request-modal.js";
8
+ export { useSendFollowUpMessage } from "./use-send-follow-up-message.js";
9
+ export { useTheme } from "./use-theme.js";
6
10
  export { useToolInfo } from "./use-tool-info.js";
7
- export { useDisplayMode } from "./use-display-mode.js";
11
+ export { useUserAgent } from "./use-user-agent.js";
12
+ export { useWidgetState } from "./use-widget-state.js";
8
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/web/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/web/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAKZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}