skybridge 0.0.0-dev.f76ccdc → 0.0.0-dev.fa642c4

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 (136) hide show
  1. package/dist/src/server/devtoolsStaticServer.d.ts +15 -0
  2. package/dist/src/server/devtoolsStaticServer.js +43 -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 +58 -9
  11. package/dist/src/server/server.js +13 -5
  12. package/dist/src/server/server.js.map +1 -1
  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 +1 -1
  16. package/dist/src/server/widgetsDevServer.js +3 -3
  17. package/dist/src/server/widgetsDevServer.js.map +1 -1
  18. package/dist/src/test/utils.d.ts +97 -1
  19. package/dist/src/test/utils.js +182 -3
  20. package/dist/src/test/utils.js.map +1 -1
  21. package/dist/src/test/widget.test.js +26 -21
  22. package/dist/src/test/widget.test.js.map +1 -1
  23. package/dist/src/web/create-store.d.ts +3 -0
  24. package/dist/src/web/create-store.js +25 -0
  25. package/dist/src/web/create-store.js.map +1 -0
  26. package/dist/src/web/create-store.test.js +70 -0
  27. package/dist/src/web/create-store.test.js.map +1 -0
  28. package/dist/src/web/data-llm.d.ts +14 -0
  29. package/dist/src/web/data-llm.js +68 -0
  30. package/dist/src/web/data-llm.js.map +1 -0
  31. package/dist/src/web/data-llm.test.d.ts +1 -0
  32. package/dist/src/web/data-llm.test.js +76 -0
  33. package/dist/src/web/data-llm.test.js.map +1 -0
  34. package/dist/src/web/generate-helpers.d.ts +115 -0
  35. package/dist/src/web/generate-helpers.js +111 -0
  36. package/dist/src/web/generate-helpers.js.map +1 -0
  37. package/dist/src/web/generate-helpers.test-d.d.ts +1 -0
  38. package/dist/src/web/generate-helpers.test-d.js +180 -0
  39. package/dist/src/web/generate-helpers.test-d.js.map +1 -0
  40. package/dist/src/web/generate-helpers.test.d.ts +1 -0
  41. package/dist/src/web/generate-helpers.test.js +17 -0
  42. package/dist/src/web/generate-helpers.test.js.map +1 -0
  43. package/dist/src/web/helpers/state.d.ts +7 -0
  44. package/dist/src/web/helpers/state.js +40 -0
  45. package/dist/src/web/helpers/state.js.map +1 -0
  46. package/dist/src/web/helpers/state.test.d.ts +1 -0
  47. package/dist/src/web/helpers/state.test.js +53 -0
  48. package/dist/src/web/helpers/state.test.js.map +1 -0
  49. package/dist/src/web/hooks/index.d.ts +2 -3
  50. package/dist/src/web/hooks/index.js +2 -3
  51. package/dist/src/web/hooks/index.js.map +1 -1
  52. package/dist/src/web/hooks/use-call-tool.d.ts +69 -23
  53. package/dist/src/web/hooks/use-call-tool.js +26 -10
  54. package/dist/src/web/hooks/use-call-tool.js.map +1 -1
  55. package/dist/src/web/hooks/use-call-tool.test-d.d.ts +1 -0
  56. package/dist/src/web/hooks/use-call-tool.test-d.js +104 -0
  57. package/dist/src/web/hooks/use-call-tool.test-d.js.map +1 -0
  58. package/dist/src/web/hooks/use-call-tool.test.js +102 -3
  59. package/dist/src/web/hooks/use-call-tool.test.js.map +1 -1
  60. package/dist/src/web/hooks/use-display-mode.js.map +1 -1
  61. package/dist/src/web/hooks/use-display-mode.test.js +2 -2
  62. package/dist/src/web/hooks/use-display-mode.test.js.map +1 -1
  63. package/dist/src/web/hooks/use-files.d.ts +10 -0
  64. package/dist/src/web/hooks/use-files.js +7 -0
  65. package/dist/src/web/hooks/use-files.js.map +1 -0
  66. package/dist/src/web/hooks/use-files.test.d.ts +1 -0
  67. package/dist/src/web/hooks/use-files.test.js +29 -0
  68. package/dist/src/web/hooks/use-files.test.js.map +1 -0
  69. package/dist/src/web/hooks/use-locale.js.map +1 -1
  70. package/dist/src/web/hooks/use-locale.test.js +2 -2
  71. package/dist/src/web/hooks/use-locale.test.js.map +1 -1
  72. package/dist/src/web/hooks/use-open-external.test.js +2 -2
  73. package/dist/src/web/hooks/use-open-external.test.js.map +1 -1
  74. package/dist/src/web/hooks/use-openai-global.d.ts +2 -2
  75. package/dist/src/web/hooks/use-openai-global.js +7 -3
  76. package/dist/src/web/hooks/use-openai-global.js.map +1 -1
  77. package/dist/src/web/hooks/use-request-modal.d.ts +3 -2
  78. package/dist/src/web/hooks/use-request-modal.js.map +1 -1
  79. package/dist/src/web/hooks/use-request-modal.test.js +2 -2
  80. package/dist/src/web/hooks/use-request-modal.test.js.map +1 -1
  81. package/dist/src/web/hooks/use-theme.js.map +1 -1
  82. package/dist/src/web/hooks/use-theme.test.js +2 -2
  83. package/dist/src/web/hooks/use-theme.test.js.map +1 -1
  84. package/dist/src/web/hooks/use-tool-info.d.ts +24 -4
  85. package/dist/src/web/hooks/use-tool-info.js +15 -4
  86. package/dist/src/web/hooks/use-tool-info.js.map +1 -1
  87. package/dist/src/web/hooks/use-tool-info.test-d.d.ts +1 -0
  88. package/dist/src/web/hooks/use-tool-info.test-d.js +73 -0
  89. package/dist/src/web/hooks/use-tool-info.test-d.js.map +1 -0
  90. package/dist/src/web/hooks/use-tool-info.test.js +36 -15
  91. package/dist/src/web/hooks/use-tool-info.test.js.map +1 -1
  92. package/dist/src/web/hooks/use-user-agent.js.map +1 -1
  93. package/dist/src/web/hooks/use-user-agent.test.js +2 -2
  94. package/dist/src/web/hooks/use-user-agent.test.js.map +1 -1
  95. package/dist/src/web/hooks/use-widget-state.js +9 -7
  96. package/dist/src/web/hooks/use-widget-state.js.map +1 -1
  97. package/dist/src/web/hooks/use-widget-state.test.js +2 -3
  98. package/dist/src/web/hooks/use-widget-state.test.js.map +1 -1
  99. package/dist/src/web/index.d.ts +6 -3
  100. package/dist/src/web/index.js +6 -3
  101. package/dist/src/web/index.js.map +1 -1
  102. package/dist/src/web/mount-widget.js +5 -0
  103. package/dist/src/web/mount-widget.js.map +1 -1
  104. package/dist/src/web/plugin/data-llm.test.d.ts +1 -0
  105. package/dist/src/web/plugin/data-llm.test.js +81 -0
  106. package/dist/src/web/plugin/data-llm.test.js.map +1 -0
  107. package/dist/src/web/{plugin.js → plugin/plugin.js} +5 -0
  108. package/dist/src/web/plugin/plugin.js.map +1 -0
  109. package/dist/src/web/plugin/transform-data-llm.d.ts +12 -0
  110. package/dist/src/web/plugin/transform-data-llm.js +93 -0
  111. package/dist/src/web/plugin/transform-data-llm.js.map +1 -0
  112. package/dist/src/web/plugin/transform-data-llm.test.d.ts +1 -0
  113. package/dist/src/web/plugin/transform-data-llm.test.js +81 -0
  114. package/dist/src/web/plugin/transform-data-llm.test.js.map +1 -0
  115. package/dist/src/web/proxy.d.ts +1 -0
  116. package/dist/src/web/proxy.js +48 -0
  117. package/dist/src/web/proxy.js.map +1 -0
  118. package/dist/src/web/types.d.ts +45 -21
  119. package/dist/src/web/types.js +1 -0
  120. package/dist/src/web/types.js.map +1 -1
  121. package/dist/vitest.config.js +0 -1
  122. package/dist/vitest.config.js.map +1 -1
  123. package/package.json +15 -8
  124. package/LICENSE +0 -674
  125. package/README.md +0 -198
  126. package/dist/src/test/setup.js +0 -9
  127. package/dist/src/test/setup.js.map +0 -1
  128. package/dist/src/web/hooks/use-tool-output.d.ts +0 -4
  129. package/dist/src/web/hooks/use-tool-output.js +0 -9
  130. package/dist/src/web/hooks/use-tool-output.js.map +0 -1
  131. package/dist/src/web/hooks/use-tool-response-metadata.d.ts +0 -4
  132. package/dist/src/web/hooks/use-tool-response-metadata.js +0 -8
  133. package/dist/src/web/hooks/use-tool-response-metadata.js.map +0 -1
  134. package/dist/src/web/plugin.js.map +0 -1
  135. /package/dist/src/{test/setup.d.ts → web/create-store.test.d.ts} +0 -0
  136. /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,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iEAAiE,EAAE,KAAK,IAAI,EAAE;QAC/E,MAAM,IAAI,GAAG;;;;;KAKZ,CAAC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,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"}
@@ -0,0 +1 @@
1
+ export declare function installOpenAILoggingProxy(): void;
@@ -0,0 +1,48 @@
1
+ const colors = {
2
+ brand: "#6366f1",
3
+ info: "#22223b",
4
+ success: "#22c55e",
5
+ error: "#ef4444",
6
+ };
7
+ export function installOpenAILoggingProxy() {
8
+ if (typeof window === "undefined" || !window.openai) {
9
+ console.warn("[openai-proxy] window.openai not found, skipping proxy installation");
10
+ return;
11
+ }
12
+ const originalOpenAI = window.openai;
13
+ const handler = {
14
+ get(target, prop, receiver) {
15
+ const value = Reflect.get(target, prop, receiver);
16
+ if (typeof value !== "function") {
17
+ return value;
18
+ }
19
+ return (...args) => {
20
+ const methodName = String(prop);
21
+ console.group(`%c[openai] %cmethod %c${methodName}`, `color: ${colors.brand}; font-weight: normal`, `color: ${colors.info}; font-weight: normal`, `color: ${colors.success}`);
22
+ console.log("%c← args:", `color: ${colors.info}`, args);
23
+ const result = value.apply(target, args);
24
+ if (result && typeof result.then === "function") {
25
+ return result.then((resolved) => {
26
+ console.log("%c→ resolved:", `color: ${colors.success}`, resolved);
27
+ console.groupEnd();
28
+ return resolved;
29
+ }, (error) => {
30
+ console.error("%c→ rejected:", `color: ${colors.error}`, error);
31
+ console.groupEnd();
32
+ throw error;
33
+ });
34
+ }
35
+ console.log("%c→ returned:", `color: ${colors.success}`, result);
36
+ console.groupEnd();
37
+ return result;
38
+ };
39
+ },
40
+ set(target, prop, value, receiver) {
41
+ console.log(`%c[openai] %cupdate %c${String(prop)}`, `color: ${colors.brand}`, `color: ${colors.info}`, `color: ${colors.success}; font-weight: bold`, "←", value);
42
+ return Reflect.set(target, prop, value, receiver);
43
+ },
44
+ };
45
+ window.openai = new Proxy(originalOpenAI, handler);
46
+ console.log("%c[openai-proxy] %cInstalled logging proxy for window.openai", `color: ${colors.brand}`, `color: ${colors.info}`);
47
+ }
48
+ //# sourceMappingURL=proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../../src/web/proxy.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,SAAS;CACR,CAAC;AAEX,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,KAAK,CAAC;YACf,CAAC;YAED,OAAO,CAAC,GAAG,IAAe,EAAE,EAAE;gBAC5B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;gBAEhC,OAAO,CAAC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xB,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,17 +1,21 @@
1
+ import "react";
2
+ declare module "react" {
3
+ interface HTMLAttributes<T> {
4
+ "data-llm"?: string;
5
+ }
6
+ }
1
7
  export type UnknownObject = Record<string, unknown>;
2
- export type WidgetState = UnknownObject;
3
- export type SetWidgetState = (state: WidgetState) => Promise<void>;
4
- export type SendFollowUpMessage = (args: {
5
- prompt: string;
6
- }) => Promise<void>;
7
- export type RequestDisplayMode = (args: {
8
- mode: DisplayMode;
9
- }) => Promise<{
10
- mode: DisplayMode;
11
- }>;
12
- export type RequestModal = (options: RequestModalOptions) => Promise<void>;
13
- export type RequestModalOptions = {
14
- title: string;
8
+ export type Prettify<T> = {
9
+ [K in keyof T]: T[K];
10
+ } & {};
11
+ export type Objectify<T> = T & UnknownObject;
12
+ type RequiredKeys<T> = {
13
+ [K in keyof T]-?: Record<string, never> extends Pick<T, K> ? never : K;
14
+ }[keyof T];
15
+ export type HasRequiredKeys<T> = RequiredKeys<T> extends never ? false : true;
16
+ type WidgetState = UnknownObject;
17
+ type FileMetadata = {
18
+ fileId: string;
15
19
  };
16
20
  export declare const TOOL_RESPONSE_EVENT_TYPE = "openai:tool_response";
17
21
  export declare class ToolResponseEvent extends CustomEvent<{
@@ -24,13 +28,13 @@ export declare class ToolResponseEvent extends CustomEvent<{
24
28
  }
25
29
  declare global {
26
30
  interface Window {
27
- openai: API<WidgetState> & OpenAiGlobals;
31
+ openai: OpenAiMethods<WidgetState> & OpenAiProperties;
28
32
  }
29
33
  interface WindowEventMap {
30
34
  [SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
31
35
  }
32
36
  }
33
- export type OpenAiGlobals<ToolInput extends UnknownObject = UnknownObject, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
37
+ export type OpenAiProperties<ToolInput extends UnknownObject = Record<never, unknown>, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
34
38
  theme: Theme;
35
39
  userAgent: UserAgent;
36
40
  locale: string;
@@ -38,11 +42,11 @@ export type OpenAiGlobals<ToolInput extends UnknownObject = UnknownObject, ToolO
38
42
  displayMode: DisplayMode;
39
43
  safeArea: SafeArea;
40
44
  toolInput: ToolInput;
41
- toolOutput: ToolOutput | null;
45
+ toolOutput: ToolOutput | {
46
+ text: string;
47
+ } | null;
42
48
  toolResponseMetadata: ToolResponseMetadata | null;
43
49
  widgetState: WidgetState | null;
44
- requestDisplayMode: RequestDisplayMode;
45
- requestModal: RequestModal;
46
50
  };
47
51
  export type CallToolArgs = Record<string, unknown> | null;
48
52
  export type CallToolResponse = {
@@ -55,7 +59,7 @@ export type CallToolResponse = {
55
59
  result: string;
56
60
  meta: Record<string, unknown>;
57
61
  };
58
- type API<WidgetState extends UnknownObject> = {
62
+ export type OpenAiMethods<WidgetState extends UnknownObject = UnknownObject> = {
59
63
  /** Calls a tool on your MCP. Returns the full response. */
60
64
  callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
61
65
  /** Triggers a followup turn in the ChatGPT conversation */
@@ -63,7 +67,7 @@ type API<WidgetState extends UnknownObject> = {
63
67
  prompt: string;
64
68
  }) => Promise<void>;
65
69
  /** Opens an external link, redirects web page or mobile app */
66
- openExternal(payload: {
70
+ openExternal(args: {
67
71
  href: string;
68
72
  }): void;
69
73
  /** For transitioning an app from inline to fullscreen or pip */
@@ -76,11 +80,31 @@ type API<WidgetState extends UnknownObject> = {
76
80
  */
77
81
  mode: DisplayMode;
78
82
  }>;
83
+ /**
84
+ * Sets the widget state.
85
+ * This state is persisted across widget renders.
86
+ */
79
87
  setWidgetState: (state: WidgetState) => Promise<void>;
88
+ /**
89
+ * Opens a modal portaled outside of the widget iFrame.
90
+ * This ensures the modal is correctly displayed and not limited to the widget's area.
91
+ */
92
+ requestModal: (args: {
93
+ title: string;
94
+ }) => Promise<void>;
95
+ /** Uploads a new file to the host */
96
+ uploadFile: (file: File) => Promise<FileMetadata>;
97
+ /**
98
+ * Downloads a file from the host that was previously uploaded.
99
+ * Only files uploaded by the same connector instance can be downloaded.
100
+ */
101
+ downloadFile: (file: FileMetadata) => Promise<{
102
+ downloadUrl: string;
103
+ }>;
80
104
  };
81
105
  export declare const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
82
106
  export declare class SetGlobalsEvent extends CustomEvent<{
83
- globals: Partial<OpenAiGlobals>;
107
+ globals: Partial<OpenAiProperties>;
84
108
  }> {
85
109
  readonly type = "openai:set_globals";
86
110
  }
@@ -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":"AAkBA,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAC/D,MAAM,OAAO,iBAAkB,SAAQ,WAErC;IACkB,IAAI,GAAG,wBAAwB,CAAC;CACnD;AA6ED,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;AAuBf,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"}
@@ -3,7 +3,6 @@ export default defineConfig({
3
3
  test: {
4
4
  environment: "jsdom",
5
5
  globals: true,
6
- setupFiles: ["./src/test/setup.ts"],
7
6
  },
8
7
  });
9
8
  //# sourceMappingURL=vitest.config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vitest.config.js","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE;QACJ,WAAW,EAAE,OAAO;QACpB,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,CAAC,qBAAqB,CAAC;KACpC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"vitest.config.js","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE;QACJ,WAAW,EAAE,OAAO;QACpB,OAAO,EAAE,IAAI;KACd;CACF,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skybridge",
3
- "version": "0.0.0-dev.f76ccdc",
3
+ "version": "0.0.0-dev.fa642c4",
4
4
  "description": "Skybridge is a framework for building ChatGPT apps",
5
5
  "type": "module",
6
6
  "files": [
@@ -19,10 +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": "vitest run --silent",
23
- "docs:dev": "pnpm --filter @skybridge/docs start",
24
- "docs:build": "pnpm --filter @skybridge/docs build",
25
- "docs:serve": "pnpm --filter @skybridge/docs serve"
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",
25
+ "test:type": "tsc --noEmit",
26
+ "test:format": "biome ci"
26
27
  },
27
28
  "keywords": [
28
29
  "chatgpt",
@@ -33,21 +34,26 @@
33
34
  "author": "Frédéric Barthelet",
34
35
  "license": "ISC",
35
36
  "peerDependencies": {
37
+ "@modelcontextprotocol/sdk": ">=1.0.0",
36
38
  "react": ">=18.0.0",
37
39
  "react-dom": ">=18.0.0"
38
40
  },
39
41
  "dependencies": {
40
- "@modelcontextprotocol/sdk": "^1.20.0",
42
+ "@babel/core": "^7.28.5",
41
43
  "cors": "^2.8.5",
42
44
  "express": "^5.1.0",
43
45
  "handlebars": "^4.7.8",
46
+ "superjson": "^2.2.6",
44
47
  "vite": "^7.1.11",
45
- "zod": "^3.25.51"
48
+ "zustand": "^5.0.9"
46
49
  },
47
50
  "devDependencies": {
51
+ "@biomejs/biome": "2.3.8",
52
+ "@modelcontextprotocol/sdk": "^1.24.3",
48
53
  "@testing-library/dom": "^10.4.1",
49
54
  "@testing-library/react": "^16.3.0",
50
55
  "@total-typescript/tsconfig": "^1.0.4",
56
+ "@types/babel__core": "^7.20.5",
51
57
  "@types/cors": "^2.8.19",
52
58
  "@types/express": "^5.0.3",
53
59
  "@types/jsdom": "^21.1.6",
@@ -57,7 +63,8 @@
57
63
  "@vitest/ui": "^2.1.8",
58
64
  "jsdom": "^25.0.1",
59
65
  "typescript": "^5.9.3",
60
- "vitest": "^2.1.8"
66
+ "vitest": "^2.1.8",
67
+ "zod": "^4.1.13"
61
68
  },
62
69
  "packageManager": "pnpm@10.17.1"
63
70
  }