@apollo/client-ai-apps 0.3.2 → 0.3.3
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.
- package/.github/workflows/pr.yaml +52 -3
- package/.github/workflows/prep-release.yml +38 -0
- package/.github/workflows/release.yaml +8 -4
- package/.github/workflows/verify-changeset.yml +58 -0
- package/CHANGELOG.md +25 -0
- package/dist/core/ApolloClient.d.ts +3 -2
- package/dist/core/ApolloClient.d.ts.map +1 -0
- package/dist/core/ApolloClient.js +65 -0
- package/dist/core/ApolloClient.js.map +1 -0
- package/dist/index.d.ts +18 -17
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -278
- package/dist/index.js.map +1 -0
- package/dist/link/ToolCallLink.d.ts +1 -0
- package/dist/link/ToolCallLink.d.ts.map +1 -0
- package/dist/link/ToolCallLink.js +39 -0
- package/dist/link/ToolCallLink.js.map +1 -0
- package/dist/react/ApolloProvider.d.ts +4 -3
- package/dist/react/ApolloProvider.d.ts.map +1 -0
- package/dist/react/ApolloProvider.js +30 -0
- package/dist/react/ApolloProvider.js.map +1 -0
- package/dist/react/context/ToolUseContext.d.ts +4 -3
- package/dist/react/context/ToolUseContext.d.ts.map +1 -0
- package/dist/react/context/ToolUseContext.js +11 -0
- package/dist/react/context/ToolUseContext.js.map +1 -0
- package/dist/react/hooks/useCallTool.d.ts +4 -0
- package/dist/react/hooks/useCallTool.d.ts.map +1 -0
- package/dist/react/hooks/useCallTool.js +5 -0
- package/dist/react/hooks/useCallTool.js.map +1 -0
- package/dist/react/hooks/useOpenAiGlobal.d.ts +2 -1
- package/dist/react/hooks/useOpenAiGlobal.d.ts.map +1 -0
- package/dist/react/hooks/useOpenAiGlobal.js +20 -0
- package/dist/react/hooks/useOpenAiGlobal.js.map +1 -0
- package/dist/react/hooks/useOpenExternal.d.ts +1 -0
- package/dist/react/hooks/useOpenExternal.d.ts.map +1 -0
- package/dist/react/hooks/useOpenExternal.js +5 -0
- package/dist/react/hooks/useOpenExternal.js.map +1 -0
- package/dist/react/hooks/useRequestDisplayMode.d.ts +2 -1
- package/dist/react/hooks/useRequestDisplayMode.d.ts.map +1 -0
- package/dist/react/hooks/useRequestDisplayMode.js +6 -0
- package/dist/react/hooks/useRequestDisplayMode.js.map +1 -0
- package/dist/react/hooks/useSendFollowUpMessage.d.ts +1 -0
- package/dist/react/hooks/useSendFollowUpMessage.d.ts.map +1 -0
- package/dist/react/hooks/useSendFollowUpMessage.js +8 -0
- package/dist/react/hooks/useSendFollowUpMessage.js.map +1 -0
- package/dist/react/hooks/useToolEffect.d.ts +1 -0
- package/dist/react/hooks/useToolEffect.d.ts.map +1 -0
- package/dist/react/hooks/useToolEffect.js +28 -0
- package/dist/react/hooks/useToolEffect.js.map +1 -0
- package/dist/react/hooks/useToolInput.d.ts +1 -0
- package/dist/react/hooks/useToolInput.d.ts.map +1 -0
- package/dist/react/hooks/useToolInput.js +6 -0
- package/dist/react/hooks/useToolInput.js.map +1 -0
- package/dist/react/hooks/useToolName.d.ts +1 -0
- package/dist/react/hooks/useToolName.d.ts.map +1 -0
- package/dist/react/hooks/useToolName.js +6 -0
- package/dist/react/hooks/useToolName.js.map +1 -0
- package/dist/react/hooks/useToolOutput.d.ts +2 -1
- package/dist/react/hooks/useToolOutput.d.ts.map +1 -0
- package/dist/react/hooks/useToolOutput.js +5 -0
- package/dist/react/hooks/useToolOutput.js.map +1 -0
- package/dist/react/hooks/useToolResponseMetadata.d.ts +2 -1
- package/dist/react/hooks/useToolResponseMetadata.d.ts.map +1 -0
- package/dist/react/hooks/useToolResponseMetadata.js +5 -0
- package/dist/react/hooks/useToolResponseMetadata.js.map +1 -0
- package/dist/react/hooks/useWidgetState.d.ts +3 -2
- package/dist/react/hooks/useWidgetState.d.ts.map +1 -0
- package/dist/react/hooks/useWidgetState.js +27 -0
- package/dist/react/hooks/useWidgetState.js.map +1 -0
- package/dist/types/application-manifest.d.ts +7 -0
- package/dist/types/application-manifest.d.ts.map +1 -0
- package/dist/types/application-manifest.js +2 -0
- package/dist/types/application-manifest.js.map +1 -0
- package/dist/types/openai.d.ts +1 -0
- package/dist/types/openai.d.ts.map +1 -0
- package/dist/types/openai.js +6 -0
- package/dist/types/openai.js.map +1 -0
- package/dist/vite/absolute_asset_imports_plugin.d.ts +1 -0
- package/dist/vite/absolute_asset_imports_plugin.d.ts.map +1 -0
- package/dist/vite/absolute_asset_imports_plugin.js +17 -0
- package/dist/vite/absolute_asset_imports_plugin.js.map +1 -0
- package/dist/vite/application_manifest_plugin.d.ts +2 -1
- package/dist/vite/application_manifest_plugin.d.ts.map +1 -0
- package/dist/vite/application_manifest_plugin.js +274 -0
- package/dist/vite/application_manifest_plugin.js.map +1 -0
- package/dist/vite/index.d.ts +3 -2
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +3 -307
- package/dist/vite/index.js.map +1 -0
- package/knope.toml +63 -0
- package/package.json +15 -8
- package/src/core/ApolloClient.ts +10 -5
- package/src/core/__tests__/ApolloClient.test.ts +12 -9
- package/src/index.ts +17 -17
- package/src/react/ApolloProvider.tsx +4 -3
- package/src/react/__tests__/ApolloProvider.test.tsx +3 -3
- package/src/react/context/ToolUseContext.tsx +2 -1
- package/src/react/hooks/__tests__/useCallTool.test.ts +1 -1
- package/src/react/hooks/__tests__/useOpenAiGlobal.test.ts +6 -6
- package/src/react/hooks/__tests__/useOpenExternal.test.tsx +2 -2
- package/src/react/hooks/__tests__/useRequestDisplayMode.test.ts +2 -2
- package/src/react/hooks/__tests__/useSendFollowUpMessage.test.ts +1 -1
- package/src/react/hooks/__tests__/useToolEffect.test.tsx +2 -2
- package/src/react/hooks/__tests__/useToolInput.test.ts +1 -1
- package/src/react/hooks/__tests__/useToolName.test.ts +1 -1
- package/src/react/hooks/__tests__/useToolOutput.test.tsx +2 -2
- package/src/react/hooks/__tests__/useToolResponseMetadata.test.tsx +2 -2
- package/src/react/hooks/__tests__/useWidgetState.test.tsx +2 -2
- package/src/react/hooks/useOpenAiGlobal.ts +2 -5
- package/src/react/hooks/useOpenExternal.ts +1 -1
- package/src/react/hooks/useRequestDisplayMode.ts +1 -1
- package/src/react/hooks/useToolEffect.tsx +3 -3
- package/src/react/hooks/useToolInput.ts +1 -1
- package/src/react/hooks/useToolName.ts +1 -1
- package/src/react/hooks/useToolOutput.ts +1 -1
- package/src/react/hooks/useToolResponseMetadata.ts +1 -1
- package/src/react/hooks/useWidgetState.ts +4 -3
- package/src/testing/internal/index.ts +2 -2
- package/src/testing/internal/matchers/index.ts +1 -1
- package/src/testing/internal/matchers/toRerender.ts +2 -2
- package/src/testing/internal/matchers/{index.d.ts → types.ts} +1 -1
- package/src/testing/internal/openai/dispatchStateChange.ts +1 -1
- package/src/testing/internal/openai/stubOpenAiGlobals.ts +6 -2
- package/src/types/application-manifest.ts +7 -0
- package/src/vite/__tests__/absolute_asset_imports_plugin.test.ts +2 -2
- package/src/vite/__tests__/application_manifest_plugin.test.ts +299 -240
- package/src/vite/application_manifest_plugin.ts +160 -96
- package/src/vite/index.ts +2 -2
- package/tsconfig.base.build.json +13 -0
- package/tsconfig.base.json +21 -0
- package/tsconfig.config.json +9 -0
- package/tsconfig.json +10 -0
- package/tsconfig.src.build.json +14 -0
- package/tsconfig.src.json +17 -0
- package/tsconfig.test.json +20 -0
- package/tsconfig.vite.build.json +6 -0
- package/tsconfig.vite.json +16 -0
- package/scripts/build-vite.mjs +0 -18
- package/scripts/build.mjs +0 -7
- package/scripts/shared.mjs +0 -9
package/knope.toml
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
versioned_files = ["package.json", "package-lock.json"]
|
|
3
|
+
changelog = "CHANGELOG.md"
|
|
4
|
+
|
|
5
|
+
[[workflows]]
|
|
6
|
+
name = "prepare-release"
|
|
7
|
+
|
|
8
|
+
[[workflows.steps]]
|
|
9
|
+
type = "Command"
|
|
10
|
+
command = "git switch -c release/$BASE_BRANCH"
|
|
11
|
+
shell = true
|
|
12
|
+
|
|
13
|
+
[[workflows.steps]]
|
|
14
|
+
type = "PrepareRelease"
|
|
15
|
+
ignore_conventional_commits = true
|
|
16
|
+
|
|
17
|
+
[[workflows.steps]]
|
|
18
|
+
type = "Command"
|
|
19
|
+
command = "npm run format && git add package.json package-lock.json"
|
|
20
|
+
shell = true
|
|
21
|
+
|
|
22
|
+
[[workflows.steps]]
|
|
23
|
+
type = "Command"
|
|
24
|
+
command = "git commit -m \"chore: prepare release $version\""
|
|
25
|
+
|
|
26
|
+
[[workflows.steps]]
|
|
27
|
+
type = "Command"
|
|
28
|
+
command = "git push --force --set-upstream origin release/$BASE_BRANCH"
|
|
29
|
+
shell = true
|
|
30
|
+
|
|
31
|
+
[[workflows.steps]]
|
|
32
|
+
type = "CreatePullRequest"
|
|
33
|
+
base = "main"
|
|
34
|
+
|
|
35
|
+
[workflows.steps.title]
|
|
36
|
+
template = "chore: prepare release $version"
|
|
37
|
+
|
|
38
|
+
[workflows.steps.body]
|
|
39
|
+
template = "This PR was created by Knope. Merging it will create a new release\n\n$changelog"
|
|
40
|
+
|
|
41
|
+
[[workflows]]
|
|
42
|
+
name = "release"
|
|
43
|
+
|
|
44
|
+
[[workflows.steps]]
|
|
45
|
+
type = "Release"
|
|
46
|
+
|
|
47
|
+
[[workflows]]
|
|
48
|
+
name = "document-change"
|
|
49
|
+
|
|
50
|
+
[[workflows.steps]]
|
|
51
|
+
type = "CreateChangeFile"
|
|
52
|
+
|
|
53
|
+
[[workflows]]
|
|
54
|
+
name = "get-version"
|
|
55
|
+
help_text = "Get the current version of the project"
|
|
56
|
+
|
|
57
|
+
[[workflows.steps]]
|
|
58
|
+
type = "Command"
|
|
59
|
+
command = 'echo "$version"'
|
|
60
|
+
|
|
61
|
+
[github]
|
|
62
|
+
owner = "apollographql"
|
|
63
|
+
repo = "apollo-ai-apps-client"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollo/client-ai-apps",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -15,18 +15,24 @@
|
|
|
15
15
|
".": "./dist/index.js",
|
|
16
16
|
"./vite": "./dist/vite/index.js"
|
|
17
17
|
},
|
|
18
|
+
"devEngines": {
|
|
19
|
+
"packageManager": {
|
|
20
|
+
"name": "npm"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
18
23
|
"scripts": {
|
|
19
24
|
"dev": "node ./scripts/dev.mjs",
|
|
20
25
|
"prebuild": "npm run clean",
|
|
21
|
-
"build": "npm run build:
|
|
22
|
-
"build:
|
|
23
|
-
"build:vite": "
|
|
26
|
+
"build": "npm run build:src && npm run build:vite",
|
|
27
|
+
"build:src": "tsc --project tsconfig.src.build.json",
|
|
28
|
+
"build:vite": "tsc --project tsconfig.vite.build.json",
|
|
24
29
|
"clean": "rimraf dist",
|
|
25
30
|
"test": "vitest run --coverage",
|
|
26
31
|
"test:watch": "vitest --coverage",
|
|
27
32
|
"changeset": "knope document-change",
|
|
28
33
|
"format": "prettier --write .",
|
|
29
|
-
"format:check": "prettier --check ."
|
|
34
|
+
"format:check": "prettier --check .",
|
|
35
|
+
"typecheck": "tsc -b --emitDeclarationOnly"
|
|
30
36
|
},
|
|
31
37
|
"keywords": [],
|
|
32
38
|
"author": "",
|
|
@@ -36,7 +42,7 @@
|
|
|
36
42
|
"@testing-library/jest-dom": "^6.9.1",
|
|
37
43
|
"@testing-library/react": "^16.3.0",
|
|
38
44
|
"@testing-library/react-render-stream": "^2.0.2",
|
|
39
|
-
"@types/node": "^24.10.
|
|
45
|
+
"@types/node": "^24.10.4",
|
|
40
46
|
"@types/react": "^19.2.2",
|
|
41
47
|
"@vitejs/plugin-react": "^5.1.1",
|
|
42
48
|
"@vitest/coverage-v8": "^4.0.13",
|
|
@@ -57,6 +63,7 @@
|
|
|
57
63
|
"@apollo/client": "^4.0.9",
|
|
58
64
|
"@graphql-tools/graphql-tag-pluck": "^8.3.23",
|
|
59
65
|
"crypto-hash": "^4.0.0",
|
|
60
|
-
"glob": "^11.0.3"
|
|
66
|
+
"glob": "^11.0.3",
|
|
67
|
+
"tslib": "^2.8.1"
|
|
61
68
|
}
|
|
62
|
-
}
|
|
69
|
+
}
|
package/src/core/ApolloClient.ts
CHANGED
|
@@ -4,9 +4,10 @@ import { DocumentTransform } from "@apollo/client";
|
|
|
4
4
|
import { removeDirectivesFromDocument } from "@apollo/client/utilities/internal";
|
|
5
5
|
import { parse } from "graphql";
|
|
6
6
|
import { __DEV__ } from "@apollo/client/utilities/environment";
|
|
7
|
-
import "../types/openai";
|
|
8
|
-
import { ApplicationManifest } from "../types/application-manifest";
|
|
9
|
-
import { ToolCallLink } from "../link/ToolCallLink";
|
|
7
|
+
import "../types/openai.js";
|
|
8
|
+
import type { ApplicationManifest } from "../types/application-manifest.js";
|
|
9
|
+
import { ToolCallLink } from "../link/ToolCallLink.js";
|
|
10
|
+
import type { FetchResult } from "@apollo/client";
|
|
10
11
|
|
|
11
12
|
// TODO: In the future if/when we support PQs again, do pqLink.concat(toolCallLink)
|
|
12
13
|
// Commenting this out for now.
|
|
@@ -50,16 +51,20 @@ export class ApolloClient extends BaseApolloClient {
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
async prefetchData() {
|
|
54
|
+
const toolOutput = window.openai.toolOutput as {
|
|
55
|
+
prefetch?: Record<string, FetchResult<any>>;
|
|
56
|
+
} | null;
|
|
57
|
+
|
|
53
58
|
// Write prefetched data to the cache
|
|
54
59
|
this.manifest.operations.forEach((operation) => {
|
|
55
60
|
if (
|
|
56
61
|
operation.prefetch &&
|
|
57
62
|
operation.prefetchID &&
|
|
58
|
-
|
|
63
|
+
toolOutput?.prefetch?.[operation.prefetchID]
|
|
59
64
|
) {
|
|
60
65
|
this.writeQuery({
|
|
61
66
|
query: parse(operation.body),
|
|
62
|
-
data:
|
|
67
|
+
data: toolOutput.prefetch[operation.prefetchID].data,
|
|
63
68
|
});
|
|
64
69
|
}
|
|
65
70
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { expect, test, describe, vi } from "vitest";
|
|
2
|
-
import { ApolloClient } from "../ApolloClient";
|
|
3
|
-
import { ApplicationManifest } from "../../types/application-manifest";
|
|
2
|
+
import { ApolloClient } from "../ApolloClient.js";
|
|
3
|
+
import type { ApplicationManifest } from "../../types/application-manifest.js";
|
|
4
4
|
import { parse } from "graphql";
|
|
5
5
|
import { ApolloLink, HttpLink, InMemoryCache } from "@apollo/client";
|
|
6
|
-
import { ToolCallLink } from "../../link/ToolCallLink";
|
|
6
|
+
import { ToolCallLink } from "../../link/ToolCallLink.js";
|
|
7
7
|
|
|
8
8
|
describe("Client Basics", () => {
|
|
9
9
|
test("Should execute tool call when client.query is called", async () => {
|
|
@@ -56,11 +56,12 @@ describe("Client Basics", () => {
|
|
|
56
56
|
},
|
|
57
57
|
],
|
|
58
58
|
resource: "index.html",
|
|
59
|
-
|
|
59
|
+
csp: { connectDomains: [], resourceDomains: [] },
|
|
60
|
+
} satisfies ApplicationManifest;
|
|
60
61
|
|
|
61
62
|
const client = new ApolloClient({
|
|
62
63
|
cache: new InMemoryCache(),
|
|
63
|
-
manifest
|
|
64
|
+
manifest,
|
|
64
65
|
});
|
|
65
66
|
|
|
66
67
|
const variables = { id: "1" };
|
|
@@ -145,11 +146,12 @@ describe("prefetchData", () => {
|
|
|
145
146
|
},
|
|
146
147
|
],
|
|
147
148
|
resource: "index.html",
|
|
148
|
-
|
|
149
|
+
csp: { connectDomains: [], resourceDomains: [] },
|
|
150
|
+
} satisfies ApplicationManifest;
|
|
149
151
|
|
|
150
152
|
const client = new ApolloClient({
|
|
151
153
|
cache: new InMemoryCache(),
|
|
152
|
-
manifest
|
|
154
|
+
manifest,
|
|
153
155
|
});
|
|
154
156
|
await client.prefetchData();
|
|
155
157
|
|
|
@@ -428,11 +430,12 @@ describe("prefetchData", () => {
|
|
|
428
430
|
},
|
|
429
431
|
],
|
|
430
432
|
resource: "index.html",
|
|
431
|
-
|
|
433
|
+
csp: { connectDomains: [], resourceDomains: [] },
|
|
434
|
+
} satisfies ApplicationManifest;
|
|
432
435
|
|
|
433
436
|
const client = new ApolloClient({
|
|
434
437
|
cache: new InMemoryCache(),
|
|
435
|
-
manifest
|
|
438
|
+
manifest,
|
|
436
439
|
});
|
|
437
440
|
await client.prefetchData();
|
|
438
441
|
|
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,21 @@ export type {
|
|
|
18
18
|
ManifestTool,
|
|
19
19
|
ManifestExtraInput,
|
|
20
20
|
ManifestCsp,
|
|
21
|
-
} from "./types/application-manifest";
|
|
21
|
+
} from "./types/application-manifest.js";
|
|
22
22
|
|
|
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";
|
|
23
|
+
export { ToolUseProvider } from "./react/context/ToolUseContext.js";
|
|
24
|
+
export { useOpenAiGlobal } from "./react/hooks/useOpenAiGlobal.js";
|
|
25
|
+
export { useToolName } from "./react/hooks/useToolName.js";
|
|
26
|
+
export { useToolInput } from "./react/hooks/useToolInput.js";
|
|
27
|
+
export { useSendFollowUpMessage } from "./react/hooks/useSendFollowUpMessage.js";
|
|
28
|
+
export { useRequestDisplayMode } from "./react/hooks/useRequestDisplayMode.js";
|
|
29
|
+
export { useToolEffect } from "./react/hooks/useToolEffect.js";
|
|
30
|
+
export { useOpenExternal } from "./react/hooks/useOpenExternal.js";
|
|
31
|
+
export { useToolOutput } from "./react/hooks/useToolOutput.js";
|
|
32
|
+
export { useToolResponseMetadata } from "./react/hooks/useToolResponseMetadata.js";
|
|
33
|
+
export { useWidgetState } from "./react/hooks/useWidgetState.js";
|
|
34
34
|
|
|
35
35
|
export * from "@apollo/client";
|
|
36
|
-
export { ApolloClient } from "./core/ApolloClient";
|
|
37
|
-
export { ApolloProvider } from "./react/ApolloProvider";
|
|
38
|
-
export { ToolCallLink } from "./link/ToolCallLink";
|
|
36
|
+
export { ApolloClient } from "./core/ApolloClient.js";
|
|
37
|
+
export { ApolloProvider } from "./react/ApolloProvider.js";
|
|
38
|
+
export { ToolCallLink } from "./link/ToolCallLink.js";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
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,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
|
|
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
|
|
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
|
|
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
|
|
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", {
|
|
@@ -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
|
-
|
|
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,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,6 +1,7 @@
|
|
|
1
|
-
import { SetStateAction
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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,6 +1,10 @@
|
|
|
1
1
|
import { vi } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
|
|
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,7 @@ export type ApplicationManifest = {
|
|
|
7
7
|
resource: string;
|
|
8
8
|
operations: ManifestOperation[];
|
|
9
9
|
csp: ManifestCsp;
|
|
10
|
+
widgetSettings?: ManifestWidgetSettings;
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export type ManifestOperation = {
|
|
@@ -26,6 +27,12 @@ export type ManifestTool = {
|
|
|
26
27
|
extraInputs?: ManifestExtraInput[];
|
|
27
28
|
};
|
|
28
29
|
|
|
30
|
+
export type ManifestWidgetSettings = {
|
|
31
|
+
description?: string;
|
|
32
|
+
domain?: string;
|
|
33
|
+
prefersBorder?: boolean;
|
|
34
|
+
};
|
|
35
|
+
|
|
29
36
|
export type ManifestExtraInput = {
|
|
30
37
|
name: string;
|
|
31
38
|
description: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { expect, test
|
|
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 = {
|