@apollo/client-ai-apps 0.3.2 → 0.4.0

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 (140) hide show
  1. package/.github/workflows/pr.yaml +52 -3
  2. package/.github/workflows/prep-release.yml +38 -0
  3. package/.github/workflows/release.yaml +8 -4
  4. package/.github/workflows/verify-changeset.yml +58 -0
  5. package/CHANGELOG.md +88 -0
  6. package/dist/core/ApolloClient.d.ts +3 -2
  7. package/dist/core/ApolloClient.d.ts.map +1 -0
  8. package/dist/core/ApolloClient.js +65 -0
  9. package/dist/core/ApolloClient.js.map +1 -0
  10. package/dist/index.d.ts +18 -18
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +16 -279
  13. package/dist/index.js.map +1 -0
  14. package/dist/link/ToolCallLink.d.ts +1 -0
  15. package/dist/link/ToolCallLink.d.ts.map +1 -0
  16. package/dist/link/ToolCallLink.js +39 -0
  17. package/dist/link/ToolCallLink.js.map +1 -0
  18. package/dist/react/ApolloProvider.d.ts +4 -3
  19. package/dist/react/ApolloProvider.d.ts.map +1 -0
  20. package/dist/react/ApolloProvider.js +30 -0
  21. package/dist/react/ApolloProvider.js.map +1 -0
  22. package/dist/react/context/ToolUseContext.d.ts +4 -3
  23. package/dist/react/context/ToolUseContext.d.ts.map +1 -0
  24. package/dist/react/context/ToolUseContext.js +11 -0
  25. package/dist/react/context/ToolUseContext.js.map +1 -0
  26. package/dist/react/hooks/useCallTool.d.ts +4 -0
  27. package/dist/react/hooks/useCallTool.d.ts.map +1 -0
  28. package/dist/react/hooks/useCallTool.js +5 -0
  29. package/dist/react/hooks/useCallTool.js.map +1 -0
  30. package/dist/react/hooks/useOpenAiGlobal.d.ts +2 -1
  31. package/dist/react/hooks/useOpenAiGlobal.d.ts.map +1 -0
  32. package/dist/react/hooks/useOpenAiGlobal.js +20 -0
  33. package/dist/react/hooks/useOpenAiGlobal.js.map +1 -0
  34. package/dist/react/hooks/useOpenExternal.d.ts +1 -0
  35. package/dist/react/hooks/useOpenExternal.d.ts.map +1 -0
  36. package/dist/react/hooks/useOpenExternal.js +5 -0
  37. package/dist/react/hooks/useOpenExternal.js.map +1 -0
  38. package/dist/react/hooks/useRequestDisplayMode.d.ts +2 -1
  39. package/dist/react/hooks/useRequestDisplayMode.d.ts.map +1 -0
  40. package/dist/react/hooks/useRequestDisplayMode.js +6 -0
  41. package/dist/react/hooks/useRequestDisplayMode.js.map +1 -0
  42. package/dist/react/hooks/useSendFollowUpMessage.d.ts +1 -0
  43. package/dist/react/hooks/useSendFollowUpMessage.d.ts.map +1 -0
  44. package/dist/react/hooks/useSendFollowUpMessage.js +8 -0
  45. package/dist/react/hooks/useSendFollowUpMessage.js.map +1 -0
  46. package/dist/react/hooks/useToolEffect.d.ts +1 -0
  47. package/dist/react/hooks/useToolEffect.d.ts.map +1 -0
  48. package/dist/react/hooks/useToolEffect.js +28 -0
  49. package/dist/react/hooks/useToolEffect.js.map +1 -0
  50. package/dist/react/hooks/useToolInput.d.ts +1 -0
  51. package/dist/react/hooks/useToolInput.d.ts.map +1 -0
  52. package/dist/react/hooks/useToolInput.js +6 -0
  53. package/dist/react/hooks/useToolInput.js.map +1 -0
  54. package/dist/react/hooks/useToolName.d.ts +1 -0
  55. package/dist/react/hooks/useToolName.d.ts.map +1 -0
  56. package/dist/react/hooks/useToolName.js +6 -0
  57. package/dist/react/hooks/useToolName.js.map +1 -0
  58. package/dist/react/hooks/useToolOutput.d.ts +2 -1
  59. package/dist/react/hooks/useToolOutput.d.ts.map +1 -0
  60. package/dist/react/hooks/useToolOutput.js +5 -0
  61. package/dist/react/hooks/useToolOutput.js.map +1 -0
  62. package/dist/react/hooks/useToolResponseMetadata.d.ts +2 -1
  63. package/dist/react/hooks/useToolResponseMetadata.d.ts.map +1 -0
  64. package/dist/react/hooks/useToolResponseMetadata.js +5 -0
  65. package/dist/react/hooks/useToolResponseMetadata.js.map +1 -0
  66. package/dist/react/hooks/useWidgetState.d.ts +3 -2
  67. package/dist/react/hooks/useWidgetState.d.ts.map +1 -0
  68. package/dist/react/hooks/useWidgetState.js +27 -0
  69. package/dist/react/hooks/useWidgetState.js.map +1 -0
  70. package/dist/types/application-manifest.d.ts +15 -0
  71. package/dist/types/application-manifest.d.ts.map +1 -0
  72. package/dist/types/application-manifest.js +2 -0
  73. package/dist/types/application-manifest.js.map +1 -0
  74. package/dist/types/openai.d.ts +1 -0
  75. package/dist/types/openai.d.ts.map +1 -0
  76. package/dist/types/openai.js +6 -0
  77. package/dist/types/openai.js.map +1 -0
  78. package/dist/vite/absolute_asset_imports_plugin.d.ts +1 -0
  79. package/dist/vite/absolute_asset_imports_plugin.d.ts.map +1 -0
  80. package/dist/vite/absolute_asset_imports_plugin.js +17 -0
  81. package/dist/vite/absolute_asset_imports_plugin.js.map +1 -0
  82. package/dist/vite/application_manifest_plugin.d.ts +2 -1
  83. package/dist/vite/application_manifest_plugin.d.ts.map +1 -0
  84. package/dist/vite/application_manifest_plugin.js +317 -0
  85. package/dist/vite/application_manifest_plugin.js.map +1 -0
  86. package/dist/vite/index.d.ts +3 -2
  87. package/dist/vite/index.d.ts.map +1 -0
  88. package/dist/vite/index.js +3 -307
  89. package/dist/vite/index.js.map +1 -0
  90. package/knope.toml +63 -0
  91. package/package.json +19 -11
  92. package/src/core/ApolloClient.ts +10 -5
  93. package/src/core/__tests__/ApolloClient.test.ts +33 -10
  94. package/src/index.ts +19 -18
  95. package/src/react/ApolloProvider.tsx +4 -3
  96. package/src/react/__tests__/ApolloProvider.test.tsx +3 -3
  97. package/src/react/context/ToolUseContext.tsx +2 -1
  98. package/src/react/hooks/__tests__/useCallTool.test.ts +1 -1
  99. package/src/react/hooks/__tests__/useOpenAiGlobal.test.ts +6 -6
  100. package/src/react/hooks/__tests__/useOpenExternal.test.tsx +2 -2
  101. package/src/react/hooks/__tests__/useRequestDisplayMode.test.ts +2 -2
  102. package/src/react/hooks/__tests__/useSendFollowUpMessage.test.ts +1 -1
  103. package/src/react/hooks/__tests__/useToolEffect.test.tsx +2 -2
  104. package/src/react/hooks/__tests__/useToolInput.test.ts +1 -1
  105. package/src/react/hooks/__tests__/useToolName.test.ts +1 -1
  106. package/src/react/hooks/__tests__/useToolOutput.test.tsx +2 -2
  107. package/src/react/hooks/__tests__/useToolResponseMetadata.test.tsx +2 -2
  108. package/src/react/hooks/__tests__/useWidgetState.test.tsx +2 -2
  109. package/src/react/hooks/useOpenAiGlobal.ts +2 -5
  110. package/src/react/hooks/useOpenExternal.ts +1 -1
  111. package/src/react/hooks/useRequestDisplayMode.ts +1 -1
  112. package/src/react/hooks/useToolEffect.tsx +3 -3
  113. package/src/react/hooks/useToolInput.ts +1 -1
  114. package/src/react/hooks/useToolName.ts +1 -1
  115. package/src/react/hooks/useToolOutput.ts +1 -1
  116. package/src/react/hooks/useToolResponseMetadata.ts +1 -1
  117. package/src/react/hooks/useWidgetState.ts +4 -3
  118. package/src/testing/internal/index.ts +2 -2
  119. package/src/testing/internal/matchers/index.ts +1 -1
  120. package/src/testing/internal/matchers/toRerender.ts +2 -2
  121. package/src/testing/internal/matchers/{index.d.ts → types.ts} +1 -1
  122. package/src/testing/internal/openai/dispatchStateChange.ts +1 -1
  123. package/src/testing/internal/openai/stubOpenAiGlobals.ts +6 -2
  124. package/src/types/application-manifest.ts +16 -0
  125. package/src/vite/__tests__/absolute_asset_imports_plugin.test.ts +2 -2
  126. package/src/vite/__tests__/application_manifest_plugin.test.ts +460 -240
  127. package/src/vite/application_manifest_plugin.ts +253 -93
  128. package/src/vite/index.ts +2 -2
  129. package/tsconfig.base.build.json +13 -0
  130. package/tsconfig.base.json +21 -0
  131. package/tsconfig.config.json +9 -0
  132. package/tsconfig.json +10 -0
  133. package/tsconfig.src.build.json +14 -0
  134. package/tsconfig.src.json +17 -0
  135. package/tsconfig.test.json +20 -0
  136. package/tsconfig.vite.build.json +6 -0
  137. package/tsconfig.vite.json +16 -0
  138. package/scripts/build-vite.mjs +0 -18
  139. package/scripts/build.mjs +0 -7
  140. package/scripts/shared.mjs +0 -9
package/src/index.ts CHANGED
@@ -9,8 +9,8 @@ export type {
9
9
  Theme,
10
10
  UserAgent,
11
11
  UnknownObject,
12
- } from "./types/openai";
13
- export { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent } from "./types/openai";
12
+ } from "./types/openai.js";
13
+ export { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent } from "./types/openai.js";
14
14
 
15
15
  export type {
16
16
  ApplicationManifest,
@@ -18,21 +18,22 @@ export type {
18
18
  ManifestTool,
19
19
  ManifestExtraInput,
20
20
  ManifestCsp,
21
- } from "./types/application-manifest";
21
+ ManifestLabels,
22
+ ManifestWidgetSettings,
23
+ } from "./types/application-manifest.js";
22
24
 
23
- export { ToolUseProvider } from "./react/context/ToolUseContext";
24
- export { useOpenAiGlobal } from "./react/hooks/useOpenAiGlobal";
25
- export { useToolName } from "./react/hooks/useToolName";
26
- export { useToolInput } from "./react/hooks/useToolInput";
27
- export { useSendFollowUpMessage } from "./react/hooks/useSendFollowUpMessage";
28
- export { useRequestDisplayMode } from "./react/hooks/useRequestDisplayMode";
29
- export { useToolEffect } from "./react/hooks/useToolEffect";
30
- export { useOpenExternal } from "./react/hooks/useOpenExternal";
31
- export { useToolOutput } from "./react/hooks/useToolOutput";
32
- export { useToolResponseMetadata } from "./react/hooks/useToolResponseMetadata";
33
- export { useWidgetState } from "./react/hooks/useWidgetState";
25
+ export { ToolUseProvider } from "./react/context/ToolUseContext.js";
26
+ export { useOpenAiGlobal } from "./react/hooks/useOpenAiGlobal.js";
27
+ export { useToolName } from "./react/hooks/useToolName.js";
28
+ export { useToolInput } from "./react/hooks/useToolInput.js";
29
+ export { useSendFollowUpMessage } from "./react/hooks/useSendFollowUpMessage.js";
30
+ export { useRequestDisplayMode } from "./react/hooks/useRequestDisplayMode.js";
31
+ export { useToolEffect } from "./react/hooks/useToolEffect.js";
32
+ export { useOpenExternal } from "./react/hooks/useOpenExternal.js";
33
+ export { useToolOutput } from "./react/hooks/useToolOutput.js";
34
+ export { useToolResponseMetadata } from "./react/hooks/useToolResponseMetadata.js";
35
+ export { useWidgetState } from "./react/hooks/useWidgetState.js";
34
36
 
35
- export * from "@apollo/client";
36
- export { ApolloClient } from "./core/ApolloClient";
37
- export { ApolloProvider } from "./react/ApolloProvider";
38
- export { ToolCallLink } from "./link/ToolCallLink";
37
+ export { ApolloClient } from "./core/ApolloClient.js";
38
+ export { ApolloProvider } from "./react/ApolloProvider.js";
39
+ export { ToolCallLink } from "./link/ToolCallLink.js";
@@ -1,7 +1,8 @@
1
- import React, { ReactNode, useEffect, useState } from "react";
1
+ import type { ReactNode } from "react";
2
+ import { useEffect, useState } from "react";
2
3
  import { ApolloProvider as BaseApolloProvider } from "@apollo/client/react";
3
- import { ApolloClient } from "../core/ApolloClient";
4
- import { SET_GLOBALS_EVENT_TYPE } from "../types/openai";
4
+ import type { ApolloClient } from "../core/ApolloClient.js";
5
+ import { SET_GLOBALS_EVENT_TYPE } from "../types/openai.js";
5
6
 
6
7
  export declare namespace ApolloProvider {
7
8
  export interface Props {
@@ -1,8 +1,8 @@
1
1
  import { expect, test, vi } from "vitest";
2
- import { ApolloProvider } from "../ApolloProvider";
2
+ import { ApolloProvider } from "../ApolloProvider.js";
3
3
  import { render } from "@testing-library/react";
4
- import { ApolloClient } from "../../core/ApolloClient";
5
- import { SET_GLOBALS_EVENT_TYPE } from "../../types/openai";
4
+ import { ApolloClient } from "../../core/ApolloClient.js";
5
+ import { SET_GLOBALS_EVENT_TYPE } from "../../types/openai.js";
6
6
 
7
7
  test("Should call prefetch data when window.open is immediately available", () => {
8
8
  vi.stubGlobal("openai", {
@@ -1,4 +1,5 @@
1
- import React, { createContext, ReactNode, useContext, useState } from "react";
1
+ import type { ReactNode } from "react";
2
+ import { createContext, useContext, useState } from "react";
2
3
 
3
4
  interface ToolUseState {
4
5
  appName: string;
@@ -1,5 +1,5 @@
1
1
  import { expect, test, vi } from "vitest";
2
- import { useCallTool } from "../useCallTool";
2
+ import { useCallTool } from "../useCallTool.js";
3
3
 
4
4
  test("Should execute tool when returned function is called", async () => {
5
5
  vi.stubGlobal("openai", {
@@ -1,7 +1,7 @@
1
1
  import { expect, test, vi } from "vitest";
2
- import { useOpenAiGlobal } from "../useOpenAiGlobal";
2
+ import { useOpenAiGlobal } from "../useOpenAiGlobal.js";
3
3
  import { renderHook, act } from "@testing-library/react";
4
- import { SET_GLOBALS_EVENT_TYPE } from "../../../types/openai";
4
+ import { SET_GLOBALS_EVENT_TYPE } from "../../../types/openai.js";
5
5
 
6
6
  test("Should update value when globals are updated and event it triggered", async () => {
7
7
  vi.stubGlobal("openai", {
@@ -9,7 +9,7 @@ test("Should update value when globals are updated and event it triggered", asyn
9
9
  });
10
10
 
11
11
  const { result } = renderHook(() => useOpenAiGlobal("toolResponseMetadata"));
12
- const beforeValue = result.current.toolName;
12
+ const beforeValue = result.current?.toolName;
13
13
 
14
14
  act(() => {
15
15
  vi.stubGlobal("openai", {
@@ -24,7 +24,7 @@ test("Should update value when globals are updated and event it triggered", asyn
24
24
  );
25
25
  });
26
26
 
27
- const afterValue = result.current.toolName;
27
+ const afterValue = result.current?.toolName;
28
28
 
29
29
  expect(beforeValue).toBe("my-tool");
30
30
  expect(afterValue).toBe("my-other-tool");
@@ -36,7 +36,7 @@ test("Should not update value when event key does not match the provided key", a
36
36
  });
37
37
 
38
38
  const { result } = renderHook(() => useOpenAiGlobal("toolResponseMetadata"));
39
- const beforeValue = result.current.toolName;
39
+ const beforeValue = result.current?.toolName;
40
40
 
41
41
  act(() => {
42
42
  vi.stubGlobal("openai", {
@@ -49,7 +49,7 @@ test("Should not update value when event key does not match the provided key", a
49
49
  );
50
50
  });
51
51
 
52
- const afterValue = result.current.toolName;
52
+ const afterValue = result.current?.toolName;
53
53
 
54
54
  expect(beforeValue).toBe("my-tool");
55
55
  expect(afterValue).toBe("my-tool");
@@ -1,7 +1,7 @@
1
1
  import { expect, test, vi } from "vitest";
2
2
  import { renderHookToSnapshotStream } from "@testing-library/react-render-stream";
3
- import { useOpenExternal } from "../useOpenExternal";
4
- import { stubOpenAiGlobals } from "../../../testing/internal";
3
+ import { useOpenExternal } from "../useOpenExternal.js";
4
+ import { stubOpenAiGlobals } from "../../../testing/internal/index.js";
5
5
 
6
6
  test("calls the global openExternal function", async () => {
7
7
  const openExternalMock = vi.fn();
@@ -1,6 +1,6 @@
1
1
  import { expect, test, vi } from "vitest";
2
- import { useRequestDisplayMode } from "../useRequestDisplayMode";
3
- import { DisplayMode } from "../../../types/openai";
2
+ import { useRequestDisplayMode } from "../useRequestDisplayMode.js";
3
+ import type { DisplayMode } from "../../../types/openai.js";
4
4
 
5
5
  test("Should set display mode when returned function is called", async () => {
6
6
  vi.stubGlobal("openai", {
@@ -1,5 +1,5 @@
1
1
  import { expect, test, vi } from "vitest";
2
- import { useSendFollowUpMessage } from "../useSendFollowUpMessage";
2
+ import { useSendFollowUpMessage } from "../useSendFollowUpMessage.js";
3
3
 
4
4
  test("Should set display mode when returned function is called", async () => {
5
5
  vi.stubGlobal("openai", {
@@ -1,7 +1,7 @@
1
1
  import { expect, test, vi } from "vitest";
2
- import { useToolEffect } from "../useToolEffect";
2
+ import { useToolEffect } from "../useToolEffect.js";
3
3
  import { renderHook } from "@testing-library/react";
4
- import { ToolUseProvider } from "../../context/ToolUseContext";
4
+ import { ToolUseProvider } from "../../context/ToolUseContext.js";
5
5
 
6
6
  test("Should trigger effect when tool name matches toolResponseMetadata", async () => {
7
7
  vi.stubGlobal("openai", {
@@ -1,5 +1,5 @@
1
1
  import { expect, test, vi } from "vitest";
2
- import { useToolInput } from "../useToolInput";
2
+ import { useToolInput } from "../useToolInput.js";
3
3
  import { renderHook } from "@testing-library/react";
4
4
 
5
5
  test("Should return tool input when called", async () => {
@@ -1,5 +1,5 @@
1
1
  import { expect, test, vi } from "vitest";
2
- import { useToolName } from "../useToolName";
2
+ import { useToolName } from "../useToolName.js";
3
3
  import { renderHook } from "@testing-library/react";
4
4
 
5
5
  test("Should return tool input when called", async () => {
@@ -2,9 +2,9 @@ import { afterEach, expect, test, vi } from "vitest";
2
2
  import {
3
3
  dispatchStateChange,
4
4
  stubOpenAiGlobals,
5
- } from "../../../testing/internal";
5
+ } from "../../../testing/internal/index.js";
6
6
  import { renderHookToSnapshotStream } from "@testing-library/react-render-stream";
7
- import { useToolOutput } from "../useToolOutput";
7
+ import { useToolOutput } from "../useToolOutput.js";
8
8
 
9
9
  afterEach(() => {
10
10
  vi.unstubAllGlobals();
@@ -2,9 +2,9 @@ import { afterEach, expect, test, vi } from "vitest";
2
2
  import {
3
3
  dispatchStateChange,
4
4
  stubOpenAiGlobals,
5
- } from "../../../testing/internal";
5
+ } from "../../../testing/internal/index.js";
6
6
  import { renderHookToSnapshotStream } from "@testing-library/react-render-stream";
7
- import { useToolResponseMetadata } from "../useToolResponseMetadata";
7
+ import { useToolResponseMetadata } from "../useToolResponseMetadata.js";
8
8
 
9
9
  afterEach(() => {
10
10
  vi.unstubAllGlobals();
@@ -3,8 +3,8 @@ import {
3
3
  disableActEnvironment,
4
4
  renderHookToSnapshotStream,
5
5
  } from "@testing-library/react-render-stream";
6
- import { useWidgetState } from "../useWidgetState";
7
- import { stubOpenAiGlobals } from "../../../testing/internal";
6
+ import { useWidgetState } from "../useWidgetState.js";
7
+ import { stubOpenAiGlobals } from "../../../testing/internal/index.js";
8
8
 
9
9
  afterEach(() => {
10
10
  vi.unstubAllGlobals();
@@ -1,9 +1,6 @@
1
1
  import { useSyncExternalStore, useCallback } from "react";
2
- import {
3
- SET_GLOBALS_EVENT_TYPE,
4
- SetGlobalsEvent,
5
- OpenAiGlobals,
6
- } from "../../types/openai";
2
+ import type { SetGlobalsEvent, OpenAiGlobals } from "../../types/openai.js";
3
+ import { SET_GLOBALS_EVENT_TYPE } from "../../types/openai.js";
7
4
 
8
5
  export function useOpenAiGlobal<K extends keyof OpenAiGlobals>(
9
6
  key: K
@@ -1,5 +1,5 @@
1
1
  import { useCallback } from "react";
2
- import { API } from "../../types/openai";
2
+ import type { API } from "../../types/openai.js";
3
3
 
4
4
  type OpenExternalFn = API<any>["openExternal"];
5
5
 
@@ -1,4 +1,4 @@
1
- import { DisplayMode } from "../../types/openai";
1
+ import type { DisplayMode } from "../../types/openai.js";
2
2
 
3
3
  export const useRequestDisplayMode = () => {
4
4
  return async (args: { mode: DisplayMode }) => {
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect } from "react";
2
- import { useToolName } from "./useToolName";
3
- import { useToolInput } from "./useToolInput";
4
- import { useToolUseState } from "../context/ToolUseContext";
2
+ import { useToolName } from "./useToolName.js";
3
+ import { useToolInput } from "./useToolInput.js";
4
+ import { useToolUseState } from "../context/ToolUseContext.js";
5
5
 
6
6
  export const useToolEffect = (
7
7
  toolName: string | string[],
@@ -1,4 +1,4 @@
1
- import { useOpenAiGlobal } from "./useOpenAiGlobal";
1
+ import { useOpenAiGlobal } from "./useOpenAiGlobal.js";
2
2
 
3
3
  export const useToolInput = (): any => {
4
4
  const toolInput = useOpenAiGlobal("toolInput");
@@ -1,4 +1,4 @@
1
- import { useOpenAiGlobal } from "./useOpenAiGlobal";
1
+ import { useOpenAiGlobal } from "./useOpenAiGlobal.js";
2
2
 
3
3
  export const useToolName = (): string | undefined => {
4
4
  const toolResponseMetadata = useOpenAiGlobal("toolResponseMetadata");
@@ -1,4 +1,4 @@
1
- import { useOpenAiGlobal } from "./useOpenAiGlobal";
1
+ import { useOpenAiGlobal } from "./useOpenAiGlobal.js";
2
2
 
3
3
  export function useToolOutput() {
4
4
  return useOpenAiGlobal("toolOutput") ?? null;
@@ -1,4 +1,4 @@
1
- import { useOpenAiGlobal } from "./useOpenAiGlobal";
1
+ import { useOpenAiGlobal } from "./useOpenAiGlobal.js";
2
2
 
3
3
  export function useToolResponseMetadata() {
4
4
  return useOpenAiGlobal("toolResponseMetadata") ?? null;
@@ -1,6 +1,7 @@
1
- import { SetStateAction, useCallback, useState } from "react";
2
- import { UnknownObject } from "../../types/openai";
3
- import { useOpenAiGlobal } from "./useOpenAiGlobal";
1
+ import type { SetStateAction } from "react";
2
+ import { useCallback, useState } from "react";
3
+ import type { UnknownObject } from "../../types/openai.js";
4
+ import { useOpenAiGlobal } from "./useOpenAiGlobal.js";
4
5
 
5
6
  export function useWidgetState<T extends UnknownObject>(
6
7
  defaultState: T | (() => T)
@@ -1,2 +1,2 @@
1
- export { dispatchStateChange } from "./openai/dispatchStateChange";
2
- export { stubOpenAiGlobals } from "./openai/stubOpenAiGlobals";
1
+ export { dispatchStateChange } from "./openai/dispatchStateChange.js";
2
+ export { stubOpenAiGlobals } from "./openai/stubOpenAiGlobals.js";
@@ -1 +1 @@
1
- import "./toRerender";
1
+ import "./toRerender.js";
@@ -1,11 +1,11 @@
1
1
  // Vitest port of toRerender from
2
2
  // https://github.com/testing-library/react-render-stream-testing-library/blob/main/src/expect/renderStreamMatchers.ts
3
- import {
3
+ import type {
4
4
  Assertable,
5
5
  NextRenderOptions,
6
6
  RenderStream,
7
- WaitForRenderTimeoutError,
8
7
  } from "@testing-library/react-render-stream";
8
+ import { WaitForRenderTimeoutError } from "@testing-library/react-render-stream";
9
9
 
10
10
  import { expect } from "vitest";
11
11
 
@@ -1,4 +1,4 @@
1
- import { NextRenderOptions } from "@testing-library/react-render-stream";
1
+ import type { NextRenderOptions } from "@testing-library/react-render-stream";
2
2
 
3
3
  interface CustomMatchers<R = unknown> {
4
4
  toRerender: (options?: NextRenderOptions) => Promise<R>;
@@ -1,4 +1,4 @@
1
- import { SET_GLOBALS_EVENT_TYPE } from "../../../types/openai";
1
+ import { SET_GLOBALS_EVENT_TYPE } from "../../../types/openai.js";
2
2
 
3
3
  export function dispatchStateChange() {
4
4
  window.dispatchEvent(
@@ -1,6 +1,10 @@
1
1
  import { vi } from "vitest";
2
- import { API, OpenAiGlobals, UnknownObject } from "../../../types/openai";
3
- import { dispatchStateChange } from "./dispatchStateChange";
2
+ import type {
3
+ API,
4
+ OpenAiGlobals,
5
+ UnknownObject,
6
+ } from "../../../types/openai.js";
7
+ import { dispatchStateChange } from "./dispatchStateChange.js";
4
8
 
5
9
  export function stubOpenAiGlobals(globals?: Partial<API<any> & OpenAiGlobals>) {
6
10
  vi.stubGlobal("openai", {
@@ -7,6 +7,8 @@ export type ApplicationManifest = {
7
7
  resource: string;
8
8
  operations: ManifestOperation[];
9
9
  csp: ManifestCsp;
10
+ widgetSettings?: ManifestWidgetSettings;
11
+ labels?: ManifestLabels;
10
12
  };
11
13
 
12
14
  export type ManifestOperation = {
@@ -24,6 +26,13 @@ export type ManifestTool = {
24
26
  name: string;
25
27
  description: string;
26
28
  extraInputs?: ManifestExtraInput[];
29
+ labels?: ManifestLabels;
30
+ };
31
+
32
+ export type ManifestWidgetSettings = {
33
+ description?: string;
34
+ domain?: string;
35
+ prefersBorder?: boolean;
27
36
  };
28
37
 
29
38
  export type ManifestExtraInput = {
@@ -34,5 +43,12 @@ export type ManifestExtraInput = {
34
43
 
35
44
  export type ManifestCsp = {
36
45
  connectDomains: string[];
46
+ frameDomains: string[];
47
+ redirectDomains: string[];
37
48
  resourceDomains: string[];
38
49
  };
50
+
51
+ export type ManifestLabels = {
52
+ "toolInvocation/invoking"?: string;
53
+ "toolInvocation/invoked"?: string;
54
+ };
@@ -1,5 +1,5 @@
1
- import { expect, test, vi, describe, beforeEach, Mock } from "vitest";
2
- import { AbsoluteAssetImportsPlugin } from "../absolute_asset_imports_plugin";
1
+ import { expect, test } from "vitest";
2
+ import { AbsoluteAssetImportsPlugin } from "../absolute_asset_imports_plugin.js";
3
3
 
4
4
  test("Should replace root relative scripts with full url when origin is provided", () => {
5
5
  const ctx = {