skybridge 0.0.0-dev.f232042 → 0.0.0-dev.f3e11a3

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 (168) hide show
  1. package/dist/src/server/devtoolsStaticServer.d.ts +15 -0
  2. package/dist/src/server/devtoolsStaticServer.js +38 -0
  3. package/dist/src/server/devtoolsStaticServer.js.map +1 -0
  4. package/dist/src/server/index.d.ts +3 -0
  5. package/dist/src/server/index.js +1 -0
  6. package/dist/src/server/index.js.map +1 -1
  7. package/dist/src/server/inferUtilityTypes.d.ts +64 -0
  8. package/dist/src/server/inferUtilityTypes.js +2 -0
  9. package/dist/src/server/inferUtilityTypes.js.map +1 -0
  10. package/dist/src/server/server.d.ts +70 -9
  11. package/dist/src/server/server.js +55 -30
  12. package/dist/src/server/server.js.map +1 -1
  13. package/dist/src/server/templateHelper.d.ts +3 -0
  14. package/dist/src/server/templateHelper.js +5 -4
  15. package/dist/src/server/templateHelper.js.map +1 -1
  16. package/dist/src/server/templates/development.hbs +3 -2
  17. package/dist/src/server/templates/production.hbs +1 -0
  18. package/dist/src/server/widgetsDevServer.js +3 -3
  19. package/dist/src/server/widgetsDevServer.js.map +1 -1
  20. package/dist/src/test/utils.d.ts +108 -1
  21. package/dist/src/test/utils.js +202 -3
  22. package/dist/src/test/utils.js.map +1 -1
  23. package/dist/src/test/widget.test.js +83 -27
  24. package/dist/src/test/widget.test.js.map +1 -1
  25. package/dist/src/web/bridges/apps-sdk-bridge.d.ts +8 -0
  26. package/dist/src/web/bridges/apps-sdk-bridge.js +41 -0
  27. package/dist/src/web/bridges/apps-sdk-bridge.js.map +1 -0
  28. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.d.ts +2 -0
  29. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.js +7 -0
  30. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.js.map +1 -0
  31. package/dist/src/web/bridges/hooks/use-bridge.d.ts +3 -0
  32. package/dist/src/web/bridges/hooks/use-bridge.js +27 -0
  33. package/dist/src/web/bridges/hooks/use-bridge.js.map +1 -0
  34. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.d.ts +4 -0
  35. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js +7 -0
  36. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js.map +1 -0
  37. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js +58 -0
  38. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js.map +1 -0
  39. package/dist/src/web/bridges/index.d.ts +3 -0
  40. package/dist/src/web/bridges/index.js +4 -0
  41. package/dist/src/web/bridges/index.js.map +1 -0
  42. package/dist/src/web/bridges/mcp-app-bridge.d.ts +26 -0
  43. package/dist/src/web/bridges/mcp-app-bridge.js +130 -0
  44. package/dist/src/web/bridges/mcp-app-bridge.js.map +1 -0
  45. package/dist/src/web/create-store.d.ts +3 -0
  46. package/dist/src/web/create-store.js +25 -0
  47. package/dist/src/web/create-store.js.map +1 -0
  48. package/dist/src/web/create-store.test.js +70 -0
  49. package/dist/src/web/create-store.test.js.map +1 -0
  50. package/dist/src/web/data-llm.d.ts +14 -0
  51. package/dist/src/web/data-llm.js +68 -0
  52. package/dist/src/web/data-llm.js.map +1 -0
  53. package/dist/src/web/data-llm.test.js +76 -0
  54. package/dist/src/web/data-llm.test.js.map +1 -0
  55. package/dist/src/web/generate-helpers.d.ts +115 -0
  56. package/dist/src/web/generate-helpers.js +111 -0
  57. package/dist/src/web/generate-helpers.js.map +1 -0
  58. package/dist/src/web/generate-helpers.test-d.d.ts +1 -0
  59. package/dist/src/web/generate-helpers.test-d.js +206 -0
  60. package/dist/src/web/generate-helpers.test-d.js.map +1 -0
  61. package/dist/src/web/generate-helpers.test.d.ts +1 -0
  62. package/dist/src/web/generate-helpers.test.js +17 -0
  63. package/dist/src/web/generate-helpers.test.js.map +1 -0
  64. package/dist/src/web/helpers/state.d.ts +7 -0
  65. package/dist/src/web/helpers/state.js +40 -0
  66. package/dist/src/web/helpers/state.js.map +1 -0
  67. package/dist/src/web/helpers/state.test.d.ts +1 -0
  68. package/dist/src/web/helpers/state.test.js +53 -0
  69. package/dist/src/web/helpers/state.test.js.map +1 -0
  70. package/dist/src/web/hooks/index.d.ts +4 -7
  71. package/dist/src/web/hooks/index.js +4 -7
  72. package/dist/src/web/hooks/index.js.map +1 -1
  73. package/dist/src/web/hooks/use-call-tool.d.ts +58 -20
  74. package/dist/src/web/hooks/use-call-tool.js +7 -15
  75. package/dist/src/web/hooks/use-call-tool.js.map +1 -1
  76. package/dist/src/web/hooks/use-call-tool.test-d.d.ts +1 -0
  77. package/dist/src/web/hooks/use-call-tool.test-d.js +104 -0
  78. package/dist/src/web/hooks/use-call-tool.test-d.js.map +1 -0
  79. package/dist/src/web/hooks/use-call-tool.test.js +14 -12
  80. package/dist/src/web/hooks/use-call-tool.test.js.map +1 -1
  81. package/dist/src/web/hooks/use-display-mode.js +2 -2
  82. package/dist/src/web/hooks/use-display-mode.js.map +1 -1
  83. package/dist/src/web/hooks/use-display-mode.test.js +3 -2
  84. package/dist/src/web/hooks/use-display-mode.test.js.map +1 -1
  85. package/dist/src/web/hooks/use-files.test.js +1 -1
  86. package/dist/src/web/hooks/use-files.test.js.map +1 -1
  87. package/dist/src/web/hooks/use-layout.d.ts +22 -0
  88. package/dist/src/web/hooks/use-layout.js +23 -0
  89. package/dist/src/web/hooks/use-layout.js.map +1 -0
  90. package/dist/src/web/hooks/use-layout.test.d.ts +1 -0
  91. package/dist/src/web/hooks/use-layout.test.js +46 -0
  92. package/dist/src/web/hooks/use-layout.test.js.map +1 -0
  93. package/dist/src/web/hooks/use-open-external.test.js +2 -2
  94. package/dist/src/web/hooks/use-open-external.test.js.map +1 -1
  95. package/dist/src/web/hooks/use-openai-global.d.ts +3 -2
  96. package/dist/src/web/hooks/use-openai-global.js +3 -20
  97. package/dist/src/web/hooks/use-openai-global.js.map +1 -1
  98. package/dist/src/web/hooks/use-request-modal.d.ts +6 -3
  99. package/dist/src/web/hooks/use-request-modal.js +6 -1
  100. package/dist/src/web/hooks/use-request-modal.js.map +1 -1
  101. package/dist/src/web/hooks/use-request-modal.test.js +37 -4
  102. package/dist/src/web/hooks/use-request-modal.test.js.map +1 -1
  103. package/dist/src/web/hooks/use-tool-info.d.ts +4 -4
  104. package/dist/src/web/hooks/use-tool-info.js +5 -7
  105. package/dist/src/web/hooks/use-tool-info.js.map +1 -1
  106. package/dist/src/web/hooks/use-tool-info.test-d.js +0 -1
  107. package/dist/src/web/hooks/use-tool-info.test-d.js.map +1 -1
  108. package/dist/src/web/hooks/use-tool-info.test.js +3 -2
  109. package/dist/src/web/hooks/use-tool-info.test.js.map +1 -1
  110. package/dist/src/web/hooks/use-user.d.ts +18 -0
  111. package/dist/src/web/hooks/use-user.js +19 -0
  112. package/dist/src/web/hooks/use-user.js.map +1 -0
  113. package/dist/src/web/hooks/use-user.test.d.ts +1 -0
  114. package/dist/src/web/hooks/use-user.test.js +44 -0
  115. package/dist/src/web/hooks/use-user.test.js.map +1 -0
  116. package/dist/src/web/hooks/use-widget-state.js +11 -9
  117. package/dist/src/web/hooks/use-widget-state.js.map +1 -1
  118. package/dist/src/web/hooks/use-widget-state.test.js +3 -2
  119. package/dist/src/web/hooks/use-widget-state.test.js.map +1 -1
  120. package/dist/src/web/index.d.ts +7 -3
  121. package/dist/src/web/index.js +7 -3
  122. package/dist/src/web/index.js.map +1 -1
  123. package/dist/src/web/plugin/data-llm.test.d.ts +1 -0
  124. package/dist/src/web/plugin/data-llm.test.js +81 -0
  125. package/dist/src/web/plugin/data-llm.test.js.map +1 -0
  126. package/dist/src/web/plugin/plugin.js +39 -0
  127. package/dist/src/web/plugin/plugin.js.map +1 -0
  128. package/dist/src/web/plugin/transform-data-llm.d.ts +12 -0
  129. package/dist/src/web/plugin/transform-data-llm.js +93 -0
  130. package/dist/src/web/plugin/transform-data-llm.js.map +1 -0
  131. package/dist/src/web/plugin/transform-data-llm.test.d.ts +1 -0
  132. package/dist/src/web/plugin/transform-data-llm.test.js +81 -0
  133. package/dist/src/web/plugin/transform-data-llm.test.js.map +1 -0
  134. package/dist/src/web/proxy.js +35 -27
  135. package/dist/src/web/proxy.js.map +1 -1
  136. package/dist/src/web/types.d.ts +40 -8
  137. package/dist/src/web/types.js +1 -0
  138. package/dist/src/web/types.js.map +1 -1
  139. package/package.json +15 -9
  140. package/LICENSE +0 -674
  141. package/README.md +0 -198
  142. package/dist/src/web/hooks/use-locale.d.ts +0 -1
  143. package/dist/src/web/hooks/use-locale.js +0 -5
  144. package/dist/src/web/hooks/use-locale.js.map +0 -1
  145. package/dist/src/web/hooks/use-locale.test.js +0 -21
  146. package/dist/src/web/hooks/use-locale.test.js.map +0 -1
  147. package/dist/src/web/hooks/use-theme.d.ts +0 -1
  148. package/dist/src/web/hooks/use-theme.js +0 -5
  149. package/dist/src/web/hooks/use-theme.js.map +0 -1
  150. package/dist/src/web/hooks/use-theme.test.js +0 -26
  151. package/dist/src/web/hooks/use-theme.test.js.map +0 -1
  152. package/dist/src/web/hooks/use-tool-output.d.ts +0 -4
  153. package/dist/src/web/hooks/use-tool-output.js +0 -9
  154. package/dist/src/web/hooks/use-tool-output.js.map +0 -1
  155. package/dist/src/web/hooks/use-tool-response-metadata.d.ts +0 -4
  156. package/dist/src/web/hooks/use-tool-response-metadata.js +0 -8
  157. package/dist/src/web/hooks/use-tool-response-metadata.js.map +0 -1
  158. package/dist/src/web/hooks/use-user-agent.d.ts +0 -1
  159. package/dist/src/web/hooks/use-user-agent.js +0 -5
  160. package/dist/src/web/hooks/use-user-agent.js.map +0 -1
  161. package/dist/src/web/hooks/use-user-agent.test.js +0 -31
  162. package/dist/src/web/hooks/use-user-agent.test.js.map +0 -1
  163. package/dist/src/web/plugin.js +0 -28
  164. package/dist/src/web/plugin.js.map +0 -1
  165. /package/dist/src/web/{hooks/use-locale.test.d.ts → bridges/hooks/use-mcp-app-bridge.test.d.ts} +0 -0
  166. /package/dist/src/web/{hooks/use-theme.test.d.ts → create-store.test.d.ts} +0 -0
  167. /package/dist/src/web/{hooks/use-user-agent.test.d.ts → data-llm.test.d.ts} +0 -0
  168. /package/dist/src/web/{plugin.d.ts → plugin/plugin.d.ts} +0 -0
@@ -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,MAAM,EAAE,IAAI,CA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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"}
@@ -1,45 +1,53 @@
1
+ const colors = {
2
+ brand: "#6366f1",
3
+ info: "#22223b",
4
+ success: "#22c55e",
5
+ error: "#ef4444",
6
+ };
1
7
  export function installOpenAILoggingProxy() {
2
8
  if (typeof window === "undefined" || !window.openai) {
3
9
  console.warn("[openai-proxy] window.openai not found, skipping proxy installation");
4
10
  return;
5
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
+ }
6
17
  const originalOpenAI = window.openai;
7
18
  const handler = {
8
19
  get(target, prop, receiver) {
9
20
  const value = Reflect.get(target, prop, receiver);
10
- if (typeof value === "function") {
11
- return function (...args) {
12
- const methodName = String(prop);
13
- console.groupCollapsed(`%c[openai] %c${methodName}`, "color: #6366f1; font-weight: bold", "color: #22c55e; font-weight: bold");
14
- console.log("%cArguments:", "color: #f59e0b; font-weight: bold", args);
15
- console.trace("Call stack");
16
- console.groupEnd();
17
- const result = value.apply(target, args);
18
- if (result instanceof Promise) {
19
- return result.then((resolved) => {
20
- console.groupCollapsed(`%c[openai] %c${methodName} %c✓ resolved`, "color: #6366f1; font-weight: bold", "color: #22c55e; font-weight: bold", "color: #10b981");
21
- console.log("%cResult:", "color: #06b6d4; font-weight: bold", resolved);
22
- console.groupEnd();
23
- return resolved;
24
- }, (error) => {
25
- console.groupCollapsed(`%c[openai] %c${methodName} %c✗ rejected`, "color: #6366f1; font-weight: bold", "color: #22c55e; font-weight: bold", "color: #ef4444");
26
- console.error("%cError:", "color: #ef4444; font-weight: bold", error);
27
- console.groupEnd();
28
- throw error;
29
- });
30
- }
31
- return result;
32
- };
21
+ if (typeof value !== "function") {
22
+ return value;
33
23
  }
34
- console.log(`%c[openai] %cget %c${String(prop)}`, "color: #6366f1; font-weight: bold", "color: #a855f7", "color: #22c55e", "→", value);
35
- return value;
24
+ return (...args) => {
25
+ const methodName = String(prop);
26
+ console.group(`%c[openai] %cmethod %c${methodName}`, `color: ${colors.brand}; font-weight: normal`, `color: ${colors.info}; font-weight: normal`, `color: ${colors.success}`);
27
+ console.log("%c← args:", `color: ${colors.info}`, args);
28
+ const result = value.apply(target, args);
29
+ if (result && typeof result.then === "function") {
30
+ return result.then((resolved) => {
31
+ console.log("%c→ resolved:", `color: ${colors.success}`, resolved);
32
+ console.groupEnd();
33
+ return resolved;
34
+ }, (error) => {
35
+ console.error("%c→ rejected:", `color: ${colors.error}`, error);
36
+ console.groupEnd();
37
+ throw error;
38
+ });
39
+ }
40
+ console.log("%c→ returned:", `color: ${colors.success}`, result);
41
+ console.groupEnd();
42
+ return result;
43
+ };
36
44
  },
37
45
  set(target, prop, value, receiver) {
38
- console.log(`%c[openai] %cset %c${String(prop)}`, "color: #6366f1; font-weight: bold", "color: #f97316", "color: #22c55e", "←", value);
46
+ console.log(`%c[openai] %cupdate %c${String(prop)}`, `color: ${colors.brand}`, `color: ${colors.info}`, `color: ${colors.success}; font-weight: bold`, "←", value);
39
47
  return Reflect.set(target, prop, value, receiver);
40
48
  },
41
49
  };
42
50
  window.openai = new Proxy(originalOpenAI, handler);
43
- console.log("%c[openai-proxy] %cInstalled logging proxy for window.openai", "color: #6366f1; font-weight: bold", "color: #94a3b8");
51
+ console.log("%c[openai-proxy] %cInstalled logging proxy for window.openai", `color: ${colors.brand}`, `color: ${colors.info}`);
44
52
  }
45
53
  //# sourceMappingURL=proxy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../../src/web/proxy.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,yBAAyB;IACvC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACpD,OAAO,CAAC,IAAI,CACV,qEAAqE,CACtE,CAAC;QACF,OAAO;IACT,CAAC;IAED,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IAErC,MAAM,OAAO,GAAwC;QACnD,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ;YACxB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;YAElD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;gBAChC,OAAO,UAAU,GAAG,IAAe;oBACjC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;oBAEhC,OAAO,CAAC,cAAc,CACpB,gBAAgB,UAAU,EAAE,EAC5B,mCAAmC,EACnC,mCAAmC,CACpC,CAAC;oBACF,OAAO,CAAC,GAAG,CACT,cAAc,EACd,mCAAmC,EACnC,IAAI,CACL,CAAC;oBACF,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;oBAC5B,OAAO,CAAC,QAAQ,EAAE,CAAC;oBAEnB,MAAM,MAAM,GAA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CAAC,KAAK,EAAE,EACxB,UAAU,MAAM,CAAC,IAAI,EAAE,EACvB,UAAU,MAAM,CAAC,OAAO,qBAAqB,EAC7C,GAAG,EACH,KAAK,CACN,CAAC;YAEF,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,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,4 +1,19 @@
1
+ import "react";
2
+ import type { WidgetHostType } from "../server/index.js";
3
+ declare module "react" {
4
+ interface HTMLAttributes<T> {
5
+ "data-llm"?: string;
6
+ }
7
+ }
1
8
  export type UnknownObject = Record<string, unknown>;
9
+ export type Prettify<T> = {
10
+ [K in keyof T]: T[K];
11
+ } & {};
12
+ export type Objectify<T> = T & UnknownObject;
13
+ type RequiredKeys<T> = {
14
+ [K in keyof T]-?: Record<string, never> extends Pick<T, K> ? never : K;
15
+ }[keyof T];
16
+ export type HasRequiredKeys<T> = RequiredKeys<T> extends never ? false : true;
2
17
  type WidgetState = UnknownObject;
3
18
  type FileMetadata = {
4
19
  fileId: string;
@@ -14,19 +29,24 @@ export declare class ToolResponseEvent extends CustomEvent<{
14
29
  }
15
30
  declare global {
16
31
  interface Window {
17
- openai: API<WidgetState> & OpenAiGlobals;
32
+ skybridge: SkybridgeProperties;
33
+ openai: OpenAiMethods<WidgetState> & OpenAiProperties;
18
34
  }
19
35
  interface WindowEventMap {
20
36
  [SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
21
37
  }
22
38
  }
23
- export type OpenAiGlobals<ToolInput extends UnknownObject = {}, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
39
+ export type SkybridgeProperties = {
40
+ hostType: WidgetHostType;
41
+ };
42
+ export type OpenAiProperties<ToolInput extends UnknownObject = Record<never, unknown>, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
24
43
  theme: Theme;
25
44
  userAgent: UserAgent;
26
45
  locale: string;
27
46
  maxHeight: number;
28
47
  displayMode: DisplayMode;
29
48
  safeArea: SafeArea;
49
+ view: View;
30
50
  toolInput: ToolInput;
31
51
  toolOutput: ToolOutput | {
32
52
  text: string;
@@ -45,7 +65,17 @@ export type CallToolResponse = {
45
65
  result: string;
46
66
  meta: Record<string, unknown>;
47
67
  };
48
- type API<WidgetState extends UnknownObject> = {
68
+ export type RequestModalOptions = {
69
+ title?: string;
70
+ params?: Record<string, unknown>;
71
+ anchor?: {
72
+ top?: number;
73
+ left?: number;
74
+ width?: number;
75
+ height?: number;
76
+ };
77
+ };
78
+ export type OpenAiMethods<WidgetState extends UnknownObject = UnknownObject> = {
49
79
  /** Calls a tool on your MCP. Returns the full response. */
50
80
  callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
51
81
  /** Triggers a followup turn in the ChatGPT conversation */
@@ -75,9 +105,7 @@ type API<WidgetState extends UnknownObject> = {
75
105
  * Opens a modal portaled outside of the widget iFrame.
76
106
  * This ensures the modal is correctly displayed and not limited to the widget's area.
77
107
  */
78
- requestModal: (args: {
79
- title: string;
80
- }) => Promise<void>;
108
+ requestModal: (args: RequestModalOptions) => Promise<void>;
81
109
  /** Uploads a new file to the host */
82
110
  uploadFile: (file: File) => Promise<FileMetadata>;
83
111
  /**
@@ -90,12 +118,16 @@ type API<WidgetState extends UnknownObject> = {
90
118
  };
91
119
  export declare const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
92
120
  export declare class SetGlobalsEvent extends CustomEvent<{
93
- globals: Partial<OpenAiGlobals>;
121
+ globals: Partial<OpenAiProperties>;
94
122
  }> {
95
123
  readonly type = "openai:set_globals";
96
124
  }
97
125
  export type CallTool = (name: string, args: Record<string, unknown>) => Promise<CallToolResponse>;
98
- export type DisplayMode = "pip" | "inline" | "fullscreen";
126
+ export type DisplayMode = "pip" | "inline" | "fullscreen" | "modal";
127
+ export type View = {
128
+ mode: DisplayMode;
129
+ params?: Record<string, unknown>;
130
+ };
99
131
  export type Theme = "light" | "dark";
100
132
  export type SafeAreaInsets = {
101
133
  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":"AAMA,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;AAwBf,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAC/D,MAAM,OAAO,iBAAkB,SAAQ,WAErC;IACkB,IAAI,GAAG,wBAAwB,CAAC;CACnD;AA0GD,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,6 +1,6 @@
1
1
  {
2
2
  "name": "skybridge",
3
- "version": "0.0.0-dev.f232042",
3
+ "version": "0.0.0-dev.f3e11a3",
4
4
  "description": "Skybridge is a framework for building ChatGPT apps",
5
5
  "type": "module",
6
6
  "files": [
@@ -19,12 +19,11 @@
19
19
  "scripts": {
20
20
  "build": "tsc && pnpm run build:templates",
21
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",
22
+ "format": "biome check --write --error-on-warnings",
23
+ "test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
24
+ "test:unit": "vitest run",
24
25
  "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"
26
+ "test:format": "biome ci"
28
27
  },
29
28
  "keywords": [
30
29
  "chatgpt",
@@ -35,21 +34,27 @@
35
34
  "author": "Frédéric Barthelet",
36
35
  "license": "ISC",
37
36
  "peerDependencies": {
37
+ "@modelcontextprotocol/sdk": ">=1.0.0",
38
38
  "react": ">=18.0.0",
39
39
  "react-dom": ">=18.0.0"
40
40
  },
41
41
  "dependencies": {
42
- "@modelcontextprotocol/sdk": "^1.20.0",
42
+ "@babel/core": "^7.28.5",
43
43
  "cors": "^2.8.5",
44
44
  "express": "^5.1.0",
45
45
  "handlebars": "^4.7.8",
46
+ "superjson": "^2.2.6",
46
47
  "vite": "^7.1.11",
47
- "zod": "^3.25.51"
48
+ "zustand": "^5.0.9"
48
49
  },
49
50
  "devDependencies": {
51
+ "@biomejs/biome": "2.3.8",
52
+ "@modelcontextprotocol/ext-apps": "^0.2.2",
53
+ "@modelcontextprotocol/sdk": "^1.24.3",
50
54
  "@testing-library/dom": "^10.4.1",
51
55
  "@testing-library/react": "^16.3.0",
52
56
  "@total-typescript/tsconfig": "^1.0.4",
57
+ "@types/babel__core": "^7.20.5",
53
58
  "@types/cors": "^2.8.19",
54
59
  "@types/express": "^5.0.3",
55
60
  "@types/jsdom": "^21.1.6",
@@ -59,7 +64,8 @@
59
64
  "@vitest/ui": "^2.1.8",
60
65
  "jsdom": "^25.0.1",
61
66
  "typescript": "^5.9.3",
62
- "vitest": "^2.1.8"
67
+ "vitest": "^2.1.8",
68
+ "zod": "^4.1.13"
63
69
  },
64
70
  "packageManager": "pnpm@10.17.1"
65
71
  }