skybridge 0.0.0-dev.e4c9359 → 0.0.0-dev.e55cd21

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 (190) hide show
  1. package/LICENSE +21 -674
  2. package/dist/src/server/devtoolsStaticServer.d.ts +19 -0
  3. package/dist/src/server/devtoolsStaticServer.js +48 -0
  4. package/dist/src/server/devtoolsStaticServer.js.map +1 -0
  5. package/dist/src/server/index.d.ts +3 -2
  6. package/dist/src/server/index.js +1 -0
  7. package/dist/src/server/index.js.map +1 -1
  8. package/dist/src/server/inferUtilityTypes.d.ts +22 -6
  9. package/dist/src/server/server.d.ts +55 -16
  10. package/dist/src/server/server.js +54 -34
  11. package/dist/src/server/server.js.map +1 -1
  12. package/dist/src/server/templateHelper.d.ts +3 -0
  13. package/dist/src/server/templateHelper.js +5 -4
  14. package/dist/src/server/templateHelper.js.map +1 -1
  15. package/dist/src/server/templates/development.hbs +42 -3
  16. package/dist/src/server/templates/production.hbs +1 -0
  17. package/dist/src/server/widgetsDevServer.js +2 -3
  18. package/dist/src/server/widgetsDevServer.js.map +1 -1
  19. package/dist/src/test/utils.d.ts +54 -8
  20. package/dist/src/test/utils.js +86 -8
  21. package/dist/src/test/utils.js.map +1 -1
  22. package/dist/src/test/widget.test.js +83 -27
  23. package/dist/src/test/widget.test.js.map +1 -1
  24. package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.d.ts +13 -0
  25. package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.js +33 -0
  26. package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.js.map +1 -0
  27. package/dist/src/web/bridges/adaptors/mcp-app-adaptor.d.ts +16 -0
  28. package/dist/src/web/bridges/adaptors/mcp-app-adaptor.js +115 -0
  29. package/dist/src/web/bridges/adaptors/mcp-app-adaptor.js.map +1 -0
  30. package/dist/src/web/bridges/apps-sdk-bridge.d.ts +10 -0
  31. package/dist/src/web/bridges/apps-sdk-bridge.js +46 -0
  32. package/dist/src/web/bridges/apps-sdk-bridge.js.map +1 -0
  33. package/dist/src/web/bridges/hooks/use-adaptor.d.ts +2 -0
  34. package/dist/src/web/bridges/hooks/use-adaptor.js +8 -0
  35. package/dist/src/web/bridges/hooks/use-adaptor.js.map +1 -0
  36. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.d.ts +2 -0
  37. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.js +7 -0
  38. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.js.map +1 -0
  39. package/dist/src/web/bridges/hooks/use-bridge.d.ts +2 -0
  40. package/dist/src/web/bridges/hooks/use-bridge.js +8 -0
  41. package/dist/src/web/bridges/hooks/use-bridge.js.map +1 -0
  42. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.d.ts +5 -0
  43. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js +7 -0
  44. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js.map +1 -0
  45. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js +41 -0
  46. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js.map +1 -0
  47. package/dist/src/web/bridges/index.d.ts +4 -0
  48. package/dist/src/web/bridges/index.js +5 -0
  49. package/dist/src/web/bridges/index.js.map +1 -0
  50. package/dist/src/web/bridges/mcp-app-bridge.d.ts +38 -0
  51. package/dist/src/web/bridges/mcp-app-bridge.js +162 -0
  52. package/dist/src/web/bridges/mcp-app-bridge.js.map +1 -0
  53. package/dist/src/web/bridges/types.d.ts +57 -0
  54. package/dist/src/web/bridges/types.js +2 -0
  55. package/dist/src/web/bridges/types.js.map +1 -0
  56. package/dist/src/web/create-store.d.ts +3 -0
  57. package/dist/src/web/create-store.js +25 -0
  58. package/dist/src/web/create-store.js.map +1 -0
  59. package/dist/src/web/create-store.test.js +70 -0
  60. package/dist/src/web/create-store.test.js.map +1 -0
  61. package/dist/src/web/data-llm.d.ts +14 -0
  62. package/dist/src/web/data-llm.js +70 -0
  63. package/dist/src/web/data-llm.js.map +1 -0
  64. package/dist/src/web/data-llm.test.js +76 -0
  65. package/dist/src/web/data-llm.test.js.map +1 -0
  66. package/dist/src/web/{typed-hooks.d.ts → generate-helpers.d.ts} +23 -20
  67. package/dist/src/web/{typed-hooks.js → generate-helpers.js} +14 -10
  68. package/dist/src/web/generate-helpers.js.map +1 -0
  69. package/dist/src/web/generate-helpers.test-d.js +209 -0
  70. package/dist/src/web/generate-helpers.test-d.js.map +1 -0
  71. package/dist/src/web/{typed-hooks.test.js → generate-helpers.test.js} +5 -5
  72. package/dist/src/web/generate-helpers.test.js.map +1 -0
  73. package/dist/src/web/helpers/state.d.ts +7 -0
  74. package/dist/src/web/helpers/state.js +40 -0
  75. package/dist/src/web/helpers/state.js.map +1 -0
  76. package/dist/src/web/helpers/state.test.d.ts +1 -0
  77. package/dist/src/web/helpers/state.test.js +53 -0
  78. package/dist/src/web/helpers/state.test.js.map +1 -0
  79. package/dist/src/web/hooks/index.d.ts +4 -7
  80. package/dist/src/web/hooks/index.js +4 -7
  81. package/dist/src/web/hooks/index.js.map +1 -1
  82. package/dist/src/web/hooks/test/utils.d.ts +10 -0
  83. package/dist/src/web/hooks/test/utils.js +40 -0
  84. package/dist/src/web/hooks/test/utils.js.map +1 -0
  85. package/dist/src/web/hooks/use-call-tool.d.ts +21 -20
  86. package/dist/src/web/hooks/use-call-tool.js +19 -19
  87. package/dist/src/web/hooks/use-call-tool.js.map +1 -1
  88. package/dist/src/web/hooks/use-call-tool.test-d.d.ts +1 -0
  89. package/dist/src/web/hooks/use-call-tool.test-d.js +104 -0
  90. package/dist/src/web/hooks/use-call-tool.test-d.js.map +1 -0
  91. package/dist/src/web/hooks/use-call-tool.test.js +40 -12
  92. package/dist/src/web/hooks/use-call-tool.test.js.map +1 -1
  93. package/dist/src/web/hooks/use-display-mode.d.ts +1 -1
  94. package/dist/src/web/hooks/use-display-mode.js +6 -3
  95. package/dist/src/web/hooks/use-display-mode.js.map +1 -1
  96. package/dist/src/web/hooks/use-display-mode.test.js +3 -2
  97. package/dist/src/web/hooks/use-display-mode.test.js.map +1 -1
  98. package/dist/src/web/hooks/use-files.test.js +1 -1
  99. package/dist/src/web/hooks/use-files.test.js.map +1 -1
  100. package/dist/src/web/hooks/use-layout.d.ts +22 -0
  101. package/dist/src/web/hooks/use-layout.js +23 -0
  102. package/dist/src/web/hooks/use-layout.js.map +1 -0
  103. package/dist/src/web/hooks/use-layout.test.d.ts +1 -0
  104. package/dist/src/web/hooks/use-layout.test.js +95 -0
  105. package/dist/src/web/hooks/use-layout.test.js.map +1 -0
  106. package/dist/src/web/hooks/use-open-external.js +5 -3
  107. package/dist/src/web/hooks/use-open-external.js.map +1 -1
  108. package/dist/src/web/hooks/use-open-external.test.js +43 -17
  109. package/dist/src/web/hooks/use-open-external.test.js.map +1 -1
  110. package/dist/src/web/hooks/use-openai-global.d.ts +3 -2
  111. package/dist/src/web/hooks/use-openai-global.js +3 -20
  112. package/dist/src/web/hooks/use-openai-global.js.map +1 -1
  113. package/dist/src/web/hooks/use-request-modal.d.ts +6 -3
  114. package/dist/src/web/hooks/use-request-modal.js +6 -1
  115. package/dist/src/web/hooks/use-request-modal.js.map +1 -1
  116. package/dist/src/web/hooks/use-request-modal.test.js +37 -4
  117. package/dist/src/web/hooks/use-request-modal.test.js.map +1 -1
  118. package/dist/src/web/hooks/use-send-follow-up-message.js +3 -6
  119. package/dist/src/web/hooks/use-send-follow-up-message.js.map +1 -1
  120. package/dist/src/web/hooks/use-tool-info.d.ts +13 -2
  121. package/dist/src/web/hooks/use-tool-info.js +15 -11
  122. package/dist/src/web/hooks/use-tool-info.js.map +1 -1
  123. package/dist/src/web/hooks/use-tool-info.test-d.js +40 -5
  124. package/dist/src/web/hooks/use-tool-info.test-d.js.map +1 -1
  125. package/dist/src/web/hooks/use-tool-info.test.js +119 -48
  126. package/dist/src/web/hooks/use-tool-info.test.js.map +1 -1
  127. package/dist/src/web/hooks/use-user.d.ts +18 -0
  128. package/dist/src/web/hooks/use-user.js +19 -0
  129. package/dist/src/web/hooks/use-user.js.map +1 -0
  130. package/dist/src/web/hooks/use-user.test.d.ts +1 -0
  131. package/dist/src/web/hooks/use-user.test.js +93 -0
  132. package/dist/src/web/hooks/use-user.test.js.map +1 -0
  133. package/dist/src/web/hooks/use-widget-state.js +11 -9
  134. package/dist/src/web/hooks/use-widget-state.js.map +1 -1
  135. package/dist/src/web/hooks/use-widget-state.test.js +3 -2
  136. package/dist/src/web/hooks/use-widget-state.test.js.map +1 -1
  137. package/dist/src/web/index.d.ts +7 -4
  138. package/dist/src/web/index.js +7 -4
  139. package/dist/src/web/index.js.map +1 -1
  140. package/dist/src/web/plugin/data-llm.test.d.ts +1 -0
  141. package/dist/src/web/plugin/data-llm.test.js +81 -0
  142. package/dist/src/web/plugin/data-llm.test.js.map +1 -0
  143. package/dist/src/web/plugin/plugin.js +39 -0
  144. package/dist/src/web/plugin/plugin.js.map +1 -0
  145. package/dist/src/web/plugin/transform-data-llm.d.ts +12 -0
  146. package/dist/src/web/plugin/transform-data-llm.js +96 -0
  147. package/dist/src/web/plugin/transform-data-llm.js.map +1 -0
  148. package/dist/src/web/plugin/transform-data-llm.test.d.ts +1 -0
  149. package/dist/src/web/plugin/transform-data-llm.test.js +81 -0
  150. package/dist/src/web/plugin/transform-data-llm.test.js.map +1 -0
  151. package/dist/src/web/proxy.js +6 -1
  152. package/dist/src/web/proxy.js.map +1 -1
  153. package/dist/src/web/types.d.ts +38 -12
  154. package/dist/src/web/types.js +1 -0
  155. package/dist/src/web/types.js.map +1 -1
  156. package/package.json +28 -19
  157. package/README.md +0 -323
  158. package/dist/src/web/hooks/use-locale.d.ts +0 -1
  159. package/dist/src/web/hooks/use-locale.js +0 -5
  160. package/dist/src/web/hooks/use-locale.js.map +0 -1
  161. package/dist/src/web/hooks/use-locale.test.js +0 -21
  162. package/dist/src/web/hooks/use-locale.test.js.map +0 -1
  163. package/dist/src/web/hooks/use-theme.d.ts +0 -1
  164. package/dist/src/web/hooks/use-theme.js +0 -5
  165. package/dist/src/web/hooks/use-theme.js.map +0 -1
  166. package/dist/src/web/hooks/use-theme.test.js +0 -26
  167. package/dist/src/web/hooks/use-theme.test.js.map +0 -1
  168. package/dist/src/web/hooks/use-tool-output.d.ts +0 -4
  169. package/dist/src/web/hooks/use-tool-output.js +0 -9
  170. package/dist/src/web/hooks/use-tool-output.js.map +0 -1
  171. package/dist/src/web/hooks/use-tool-response-metadata.d.ts +0 -4
  172. package/dist/src/web/hooks/use-tool-response-metadata.js +0 -8
  173. package/dist/src/web/hooks/use-tool-response-metadata.js.map +0 -1
  174. package/dist/src/web/hooks/use-user-agent.d.ts +0 -1
  175. package/dist/src/web/hooks/use-user-agent.js +0 -5
  176. package/dist/src/web/hooks/use-user-agent.js.map +0 -1
  177. package/dist/src/web/hooks/use-user-agent.test.js +0 -31
  178. package/dist/src/web/hooks/use-user-agent.test.js.map +0 -1
  179. package/dist/src/web/plugin.js +0 -28
  180. package/dist/src/web/plugin.js.map +0 -1
  181. package/dist/src/web/typed-hooks.js.map +0 -1
  182. package/dist/src/web/typed-hooks.test-d.js +0 -90
  183. package/dist/src/web/typed-hooks.test-d.js.map +0 -1
  184. package/dist/src/web/typed-hooks.test.js.map +0 -1
  185. /package/dist/src/web/{hooks/use-locale.test.d.ts → bridges/hooks/use-mcp-app-bridge.test.d.ts} +0 -0
  186. /package/dist/src/web/{hooks/use-theme.test.d.ts → create-store.test.d.ts} +0 -0
  187. /package/dist/src/web/{hooks/use-user-agent.test.d.ts → data-llm.test.d.ts} +0 -0
  188. /package/dist/src/web/{typed-hooks.test-d.d.ts → generate-helpers.test-d.d.ts} +0 -0
  189. /package/dist/src/web/{typed-hooks.test.d.ts → generate-helpers.test.d.ts} +0 -0
  190. /package/dist/src/web/{plugin.d.ts → plugin/plugin.d.ts} +0 -0
@@ -0,0 +1,96 @@
1
+ const LLM_IMPORT_SOURCE = "skybridge/web";
2
+ function createBabelPlugin(t) {
3
+ return {
4
+ name: "data-llm-babel",
5
+ visitor: {
6
+ Program: {
7
+ enter(path, state) {
8
+ state.hasDataLLMImport = false;
9
+ state.needsDataLLMImport = false;
10
+ for (const node of path.node.body) {
11
+ if (!t.isImportDeclaration(node)) {
12
+ continue;
13
+ }
14
+ if (node.source.value !== LLM_IMPORT_SOURCE) {
15
+ continue;
16
+ }
17
+ const hasSpecifier = node.specifiers.some((s) => t.isImportSpecifier(s) &&
18
+ t.isIdentifier(s.imported, { name: "DataLLM" }));
19
+ if (hasSpecifier) {
20
+ state.hasDataLLMImport = true;
21
+ break;
22
+ }
23
+ }
24
+ },
25
+ exit(path, state) {
26
+ if (state.needsDataLLMImport && !state.hasDataLLMImport) {
27
+ const importDecl = t.importDeclaration([
28
+ t.importSpecifier(t.identifier("DataLLM"), t.identifier("DataLLM")),
29
+ ], t.stringLiteral(LLM_IMPORT_SOURCE));
30
+ path.node.body.unshift(importDecl);
31
+ }
32
+ },
33
+ },
34
+ JSXElement(path, state) {
35
+ const opening = path.node.openingElement;
36
+ const attributes = opening.attributes;
37
+ const llmAttributeIndex = attributes.findIndex((attribute) => t.isJSXAttribute(attribute) &&
38
+ t.isJSXIdentifier(attribute.name, { name: "data-llm" }));
39
+ if (llmAttributeIndex === -1) {
40
+ return;
41
+ }
42
+ const llmAttribute = attributes[llmAttributeIndex];
43
+ let contentExpression;
44
+ if (t.isStringLiteral(llmAttribute.value)) {
45
+ contentExpression = llmAttribute.value;
46
+ }
47
+ else if (t.isJSXExpressionContainer(llmAttribute.value)) {
48
+ contentExpression = llmAttribute.value.expression;
49
+ }
50
+ else {
51
+ return;
52
+ }
53
+ const contentAttr = t.jsxAttribute(t.jsxIdentifier("content"), t.isStringLiteral(contentExpression)
54
+ ? contentExpression
55
+ : t.jsxExpressionContainer(contentExpression));
56
+ const filteredAttributes = attributes.filter((_, index) => index !== llmAttributeIndex);
57
+ const newOpening = t.jsxOpeningElement(opening.name, filteredAttributes, opening.selfClosing);
58
+ const elementWithoutLlm = t.jsxElement(newOpening, path.node.closingElement, path.node.children, path.node.selfClosing);
59
+ const llmOpening = t.jsxOpeningElement(t.jsxIdentifier("DataLLM"), [
60
+ contentAttr,
61
+ ]);
62
+ const llmClosing = t.jsxClosingElement(t.jsxIdentifier("DataLLM"));
63
+ const wrapped = t.jsxElement(llmOpening, llmClosing, [elementWithoutLlm], false);
64
+ state.needsDataLLMImport = true;
65
+ path.replaceWith(wrapped);
66
+ },
67
+ },
68
+ };
69
+ }
70
+ export const transform = async (code, id) => {
71
+ if (!/\.(jsx|tsx)$/.test(id)) {
72
+ return null;
73
+ }
74
+ if (id.includes("node_modules")) {
75
+ return null;
76
+ }
77
+ // Dynamic import to ensure @babel/core is only loaded in Node.js context
78
+ const { types: t, transformSync } = await import("@babel/core");
79
+ const babelOptions = {
80
+ plugins: [createBabelPlugin(t)],
81
+ parserOpts: {
82
+ plugins: ["jsx", "typescript"],
83
+ },
84
+ filename: id,
85
+ sourceFileName: id,
86
+ };
87
+ const result = transformSync(code, babelOptions);
88
+ if (!result || !result.code) {
89
+ return null;
90
+ }
91
+ return {
92
+ code: result.code,
93
+ map: result.map || null,
94
+ };
95
+ };
96
+ //# sourceMappingURL=transform-data-llm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-data-llm.js","sourceRoot":"","sources":["../../../../src/web/plugin/transform-data-llm.ts"],"names":[],"mappings":"AAEA,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAO1C,SAAS,iBAAiB,CAAC,CAAe;IACxC,OAAO;QACL,IAAI,EAAE,gBAAgB;QAEtB,OAAO,EAAE;YACP,OAAO,EAAE;gBACP,KAAK,CAAC,IAAI,EAAE,KAAK;oBACf,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC;oBAC/B,KAAK,CAAC,kBAAkB,GAAG,KAAK,CAAC;oBAEjC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;wBAClC,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,IA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d,CAAC;IAED,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,IAAI;KACxB,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,81 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { transform } from "./transform-data-llm.js";
3
+ describe("data-llm plugin", () => {
4
+ it("should transform JSX element with data-llm string attribute", async () => {
5
+ const code = `
6
+ function Component() {
7
+ return <div data-llm="Test description">Content</div>;
8
+ }
9
+ `;
10
+ const result = await transform(code, "test.tsx");
11
+ expect(result).not.toBeNull();
12
+ expect(result?.code).toContain("DataLLM");
13
+ expect(result?.code).toContain('content="Test description"');
14
+ expect(result?.code).not.toContain("data-llm");
15
+ });
16
+ it("should transform JSX element with data-llm expression attribute", async () => {
17
+ const code = `
18
+ function Component() {
19
+ const desc = "Dynamic description";
20
+ return <div data-llm={desc}>Content</div>;
21
+ }
22
+ `;
23
+ const result = await transform(code, "test.tsx");
24
+ expect(result).not.toBeNull();
25
+ expect(result?.code).toContain("DataLLM");
26
+ expect(result?.code).toContain("content={desc}");
27
+ expect(result?.code).not.toContain("data-llm");
28
+ });
29
+ it("should add import for DataLLM when not present", async () => {
30
+ const code = `
31
+ function Component() {
32
+ return <div data-llm="Test">Content</div>;
33
+ }
34
+ `;
35
+ const result = await transform(code, "test.tsx");
36
+ expect(result).not.toBeNull();
37
+ expect(result?.code).toContain('import { DataLLM } from "skybridge/web"');
38
+ });
39
+ it("should handle DataLLM imports correctly", async () => {
40
+ // No duplicate import
41
+ const codeWithImport = `
42
+ import { DataLLM } from "skybridge/web";
43
+ function Component() {
44
+ return <div data-llm="Test">Content</div>;
45
+ }
46
+ `;
47
+ const result1 = await transform(codeWithImport, "test.tsx");
48
+ expect(result1?.code.match(/import.*DataLLM.*from.*skybridge\/web/g)).toHaveLength(1);
49
+ // Preserve other imports and add missing DataLLM
50
+ const codeWithOthers = `
51
+ import React from "react";
52
+ import { useState } from "react";
53
+ function Component() {
54
+ return <div data-llm="Test">Content</div>;
55
+ }
56
+ `;
57
+ const result2 = await transform(codeWithOthers, "test.tsx");
58
+ expect(result2?.code).toContain('import React from "react"');
59
+ expect(result2?.code).toContain('import { useState } from "react"');
60
+ expect(result2?.code).toContain('import { DataLLM } from "skybridge/web"');
61
+ });
62
+ it("should handle complex JSX with multiple data-llm attributes", async () => {
63
+ const code = `
64
+ function Component() {
65
+ return (
66
+ <div>
67
+ <section data-llm="Section 1">
68
+ <p>Content 1</p>
69
+ </section>
70
+ <section data-llm="Section 2">
71
+ <p>Content 2</p>
72
+ </section>
73
+ </div>
74
+ );
75
+ }
76
+ `;
77
+ const result = await transform(code, "test.tsx");
78
+ expect(result).toMatchSnapshot();
79
+ });
80
+ });
81
+ //# sourceMappingURL=transform-data-llm.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-data-llm.test.js","sourceRoot":"","sources":["../../../../src/web/plugin/transform-data-llm.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC3E,MAAM,IAAI,GAAG;;;;KAIZ,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAEjD,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC9B,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC1C,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;QAC7D,MAAM,CAAC,MA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AC;QAElB,iDAAiD;QACjD,MAAM,cAAc,GAAG;;;;;;KAMtB,CAAC;QACF,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;QAC5D,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;QAC7D,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,kCAAkC,CAAC,CAAC;QACpE,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,yCAAyC,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC3E,MAAM,IAAI,GAAG;;;;;;;;;;;;;KAaZ,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAEjD,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -9,6 +9,11 @@ export function installOpenAILoggingProxy() {
9
9
  console.warn("[openai-proxy] window.openai not found, skipping proxy installation");
10
10
  return;
11
11
  }
12
+ const descriptor = Object.getOwnPropertyDescriptor(window, "openai");
13
+ if (descriptor?.configurable === false || descriptor?.writable === false) {
14
+ console.warn("[openai-proxy] window.openai is not configurable or writable, skipping proxy installation");
15
+ return;
16
+ }
12
17
  const originalOpenAI = window.openai;
13
18
  const handler = {
14
19
  get(target, prop, receiver) {
@@ -16,7 +21,7 @@ export function installOpenAILoggingProxy() {
16
21
  if (typeof value !== "function") {
17
22
  return value;
18
23
  }
19
- return function (...args) {
24
+ return (...args) => {
20
25
  const methodName = String(prop);
21
26
  console.group(`%c[openai] %cmethod %c${methodName}`, `color: ${colors.brand}; font-weight: normal`, `color: ${colors.info}; font-weight: normal`, `color: ${colors.success}`);
22
27
  console.log("%c← args:", `color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AAC,CAAC;QACpD,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,MAAM,GAAG,IAAI,KAAK,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEnD,OAAO,CAAC,GAAG,CACT,8DAA8D,EAC9D,UAAU,MAAM,CAAC,KAAK,EAAE,EACxB,UAAU,MAAM,CAAC,IAAI,EAAE,CACxB,CAAC;AACJ,CAAC"}
@@ -1,8 +1,20 @@
1
+ import "react";
2
+ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
+ import type { WidgetHostType } from "../server/index.js";
4
+ declare module "react" {
5
+ interface HTMLAttributes<T> {
6
+ "data-llm"?: string;
7
+ }
8
+ }
1
9
  export type UnknownObject = Record<string, unknown>;
2
10
  export type Prettify<T> = {
3
11
  [K in keyof T]: T[K];
4
12
  } & {};
5
13
  export type Objectify<T> = T & UnknownObject;
14
+ type RequiredKeys<T> = {
15
+ [K in keyof T]-?: Record<string, never> extends Pick<T, K> ? never : K;
16
+ }[keyof T];
17
+ export type HasRequiredKeys<T> = RequiredKeys<T> extends never ? false : true;
6
18
  type WidgetState = UnknownObject;
7
19
  type FileMetadata = {
8
20
  fileId: string;
@@ -18,19 +30,24 @@ export declare class ToolResponseEvent extends CustomEvent<{
18
30
  }
19
31
  declare global {
20
32
  interface Window {
21
- openai: API<WidgetState> & OpenAiGlobals;
33
+ skybridge: SkybridgeProperties;
34
+ openai: OpenAiMethods<WidgetState> & OpenAiProperties;
22
35
  }
23
36
  interface WindowEventMap {
24
37
  [SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
25
38
  }
26
39
  }
27
- export type OpenAiGlobals<ToolInput extends UnknownObject = {}, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
40
+ export type SkybridgeProperties = {
41
+ hostType: WidgetHostType;
42
+ };
43
+ export type OpenAiProperties<ToolInput extends UnknownObject = Record<never, unknown>, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
28
44
  theme: Theme;
29
45
  userAgent: UserAgent;
30
46
  locale: string;
31
47
  maxHeight: number;
32
48
  displayMode: DisplayMode;
33
49
  safeArea: SafeArea;
50
+ view: View;
34
51
  toolInput: ToolInput;
35
52
  toolOutput: ToolOutput | {
36
53
  text: string;
@@ -40,16 +57,23 @@ export type OpenAiGlobals<ToolInput extends UnknownObject = {}, ToolOutput exten
40
57
  };
41
58
  export type CallToolArgs = Record<string, unknown> | null;
42
59
  export type CallToolResponse = {
43
- content: {
44
- type: "text";
45
- text: string;
46
- }[];
60
+ content: CallToolResult["content"];
47
61
  structuredContent: Record<string, unknown>;
48
62
  isError: boolean;
49
63
  result: string;
50
64
  meta: Record<string, unknown>;
51
65
  };
52
- type API<WidgetState extends UnknownObject> = {
66
+ export type RequestModalOptions = {
67
+ title?: string;
68
+ params?: Record<string, unknown>;
69
+ anchor?: {
70
+ top?: number;
71
+ left?: number;
72
+ width?: number;
73
+ height?: number;
74
+ };
75
+ };
76
+ export type OpenAiMethods<WidgetState extends UnknownObject = UnknownObject> = {
53
77
  /** Calls a tool on your MCP. Returns the full response. */
54
78
  callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
55
79
  /** Triggers a followup turn in the ChatGPT conversation */
@@ -79,9 +103,7 @@ type API<WidgetState extends UnknownObject> = {
79
103
  * Opens a modal portaled outside of the widget iFrame.
80
104
  * This ensures the modal is correctly displayed and not limited to the widget's area.
81
105
  */
82
- requestModal: (args: {
83
- title: string;
84
- }) => Promise<void>;
106
+ requestModal: (args: RequestModalOptions) => Promise<void>;
85
107
  /** Uploads a new file to the host */
86
108
  uploadFile: (file: File) => Promise<FileMetadata>;
87
109
  /**
@@ -94,12 +116,16 @@ type API<WidgetState extends UnknownObject> = {
94
116
  };
95
117
  export declare const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
96
118
  export declare class SetGlobalsEvent extends CustomEvent<{
97
- globals: Partial<OpenAiGlobals>;
119
+ globals: Partial<OpenAiProperties>;
98
120
  }> {
99
121
  readonly type = "openai:set_globals";
100
122
  }
101
123
  export type CallTool = (name: string, args: Record<string, unknown>) => Promise<CallToolResponse>;
102
- export type DisplayMode = "pip" | "inline" | "fullscreen";
124
+ export type DisplayMode = "pip" | "inline" | "fullscreen" | "modal";
125
+ export type View = {
126
+ mode: DisplayMode;
127
+ params?: Record<string, unknown>;
128
+ };
103
129
  export type Theme = "light" | "dark";
104
130
  export type SafeAreaInsets = {
105
131
  top: number;
@@ -1,3 +1,4 @@
1
+ import "react";
1
2
  export const TOOL_RESPONSE_EVENT_TYPE = "openai:tool_response";
2
3
  export class ToolResponseEvent extends CustomEvent {
3
4
  type = TOOL_RESPONSE_EVENT_TYPE;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/web/types.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAC/D,MAAM,OAAO,iBAAkB,SAAQ,WAErC;IACkB,IAAI,GAAG,wBAAwB,CAAC;CACnD;AA8FD,sDAAsD;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D,MAAM,OAAO,eAAgB,SAAQ,WAEnC;IACkB,IAAI,GAAG,sBAAsB,CAAC;CACjD"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/web/types.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,CAAC;AAyBf,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAC/D,MAAM,OAAO,iBAAkB,SAAQ,WAErC;IACkB,IAAI,GAAG,wBAAwB,CAAC;CACnD;AAuGD,sDAAsD;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D,MAAM,OAAO,eAAgB,SAAQ,WAEnC;IACkB,IAAI,GAAG,sBAAsB,CAAC;CACjD"}
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "skybridge",
3
- "version": "0.0.0-dev.e4c9359",
3
+ "version": "0.0.0-dev.e55cd21",
4
4
  "description": "Skybridge is a framework for building ChatGPT apps",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/alpic-ai/skybridge.git"
8
+ },
5
9
  "type": "module",
6
10
  "files": [
7
11
  "dist"
@@ -16,16 +20,6 @@
16
20
  "default": "./dist/src/web/index.js"
17
21
  }
18
22
  },
19
- "scripts": {
20
- "build": "tsc && pnpm run build:templates",
21
- "build:templates": "cp -r src/server/templates dist/src/server/",
22
- "test": "pnpm run test:unit && pnpm run test:type",
23
- "test:unit": "vitest run --silent",
24
- "test:type": "tsc --noEmit",
25
- "docs:dev": "pnpm --filter @skybridge/docs start",
26
- "docs:build": "pnpm --filter @skybridge/docs build",
27
- "docs:serve": "pnpm --filter @skybridge/docs serve"
28
- },
29
23
  "keywords": [
30
24
  "chatgpt",
31
25
  "app",
@@ -35,31 +29,46 @@
35
29
  "author": "Frédéric Barthelet",
36
30
  "license": "ISC",
37
31
  "peerDependencies": {
32
+ "@modelcontextprotocol/sdk": ">=1.0.0",
38
33
  "react": ">=18.0.0",
39
34
  "react-dom": ">=18.0.0"
40
35
  },
41
36
  "dependencies": {
42
- "@modelcontextprotocol/sdk": "^1.20.0",
37
+ "@babel/core": "^7.28.5",
43
38
  "cors": "^2.8.5",
39
+ "dequal": "^2.0.3",
44
40
  "express": "^5.1.0",
45
41
  "handlebars": "^4.7.8",
42
+ "superjson": "^2.2.6",
46
43
  "vite": "^7.1.11",
47
- "zod": "^3.25.51"
44
+ "zustand": "^5.0.9"
48
45
  },
49
46
  "devDependencies": {
47
+ "@modelcontextprotocol/ext-apps": "^0.2.2",
48
+ "@modelcontextprotocol/sdk": "^1.24.3",
50
49
  "@testing-library/dom": "^10.4.1",
51
- "@testing-library/react": "^16.3.0",
50
+ "@testing-library/react": "^16.3.1",
52
51
  "@total-typescript/tsconfig": "^1.0.4",
52
+ "@types/babel__core": "^7.20.5",
53
53
  "@types/cors": "^2.8.19",
54
54
  "@types/express": "^5.0.3",
55
- "@types/jsdom": "^21.1.6",
55
+ "@types/jsdom": "^27.0.0",
56
56
  "@types/node": "^22.15.30",
57
57
  "@types/react": "^19.2.2",
58
58
  "@types/react-dom": "^19.2.2",
59
59
  "@vitest/ui": "^2.1.8",
60
- "jsdom": "^25.0.1",
60
+ "jsdom": "^27.4.0",
61
61
  "typescript": "^5.9.3",
62
- "vitest": "^2.1.8"
62
+ "vitest": "^2.1.8",
63
+ "zod": "^4.1.13"
63
64
  },
64
- "packageManager": "pnpm@10.17.1"
65
- }
65
+ "scripts": {
66
+ "build": "tsc && pnpm run build:templates",
67
+ "build:templates": "cp -r src/server/templates dist/src/server/",
68
+ "format": "biome check --write --error-on-warnings",
69
+ "test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
70
+ "test:unit": "vitest run",
71
+ "test:type": "tsc --noEmit",
72
+ "test:format": "biome ci"
73
+ }
74
+ }