skybridge 0.0.0-dev.e4c9359 → 0.0.0-dev.e62daf3
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/LICENSE +21 -674
- package/README.md +70 -270
- package/dist/src/server/devtoolsStaticServer.d.ts +15 -0
- package/dist/src/server/devtoolsStaticServer.js +38 -0
- package/dist/src/server/devtoolsStaticServer.js.map +1 -0
- package/dist/src/server/index.d.ts +3 -2
- package/dist/src/server/index.js +1 -0
- package/dist/src/server/index.js.map +1 -1
- package/dist/src/server/inferUtilityTypes.d.ts +22 -6
- package/dist/src/server/server.d.ts +45 -16
- package/dist/src/server/server.js +15 -6
- package/dist/src/server/server.js.map +1 -1
- package/dist/src/server/templateHelper.js +5 -4
- package/dist/src/server/templateHelper.js.map +1 -1
- package/dist/src/server/templates/development.hbs +2 -2
- package/dist/src/server/widgetsDevServer.js +3 -3
- package/dist/src/server/widgetsDevServer.js.map +1 -1
- package/dist/src/test/utils.d.ts +44 -9
- package/dist/src/test/utils.js +66 -8
- package/dist/src/test/utils.js.map +1 -1
- package/dist/src/test/widget.test.js +43 -21
- package/dist/src/test/widget.test.js.map +1 -1
- package/dist/src/web/create-store.d.ts +3 -0
- package/dist/src/web/create-store.js +25 -0
- package/dist/src/web/create-store.js.map +1 -0
- package/dist/src/web/create-store.test.js +70 -0
- package/dist/src/web/create-store.test.js.map +1 -0
- package/dist/src/web/data-llm.d.ts +14 -0
- package/dist/src/web/data-llm.js +68 -0
- package/dist/src/web/data-llm.js.map +1 -0
- package/dist/src/web/data-llm.test.js +76 -0
- package/dist/src/web/data-llm.test.js.map +1 -0
- package/dist/src/web/{typed-hooks.d.ts → generate-helpers.d.ts} +23 -20
- package/dist/src/web/{typed-hooks.js → generate-helpers.js} +14 -10
- package/dist/src/web/generate-helpers.js.map +1 -0
- package/dist/src/web/generate-helpers.test-d.d.ts +1 -0
- package/dist/src/web/generate-helpers.test-d.js +180 -0
- package/dist/src/web/generate-helpers.test-d.js.map +1 -0
- package/dist/src/web/generate-helpers.test.d.ts +1 -0
- package/dist/src/web/{typed-hooks.test.js → generate-helpers.test.js} +5 -5
- package/dist/src/web/generate-helpers.test.js.map +1 -0
- package/dist/src/web/helpers/state.d.ts +7 -0
- package/dist/src/web/helpers/state.js +40 -0
- package/dist/src/web/helpers/state.js.map +1 -0
- package/dist/src/web/helpers/state.test.d.ts +1 -0
- package/dist/src/web/helpers/state.test.js +53 -0
- package/dist/src/web/helpers/state.test.js.map +1 -0
- package/dist/src/web/hooks/index.d.ts +2 -4
- package/dist/src/web/hooks/index.js +2 -4
- package/dist/src/web/hooks/index.js.map +1 -1
- package/dist/src/web/hooks/use-call-tool.d.ts +21 -20
- package/dist/src/web/hooks/use-call-tool.js +7 -15
- package/dist/src/web/hooks/use-call-tool.js.map +1 -1
- package/dist/src/web/hooks/use-call-tool.test-d.d.ts +1 -0
- package/dist/src/web/hooks/use-call-tool.test-d.js +104 -0
- package/dist/src/web/hooks/use-call-tool.test-d.js.map +1 -0
- package/dist/src/web/hooks/use-call-tool.test.js +14 -12
- package/dist/src/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/src/web/hooks/use-display-mode.js.map +1 -1
- package/dist/src/web/hooks/use-display-mode.test.js +2 -2
- package/dist/src/web/hooks/use-display-mode.test.js.map +1 -1
- package/dist/src/web/hooks/use-files.test.js +1 -1
- package/dist/src/web/hooks/use-files.test.js.map +1 -1
- package/dist/src/web/hooks/use-locale.js.map +1 -1
- package/dist/src/web/hooks/use-locale.test.js +2 -2
- package/dist/src/web/hooks/use-locale.test.js.map +1 -1
- package/dist/src/web/hooks/use-open-external.test.js +2 -2
- package/dist/src/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/src/web/hooks/use-openai-global.d.ts +2 -2
- package/dist/src/web/hooks/use-openai-global.js +7 -5
- package/dist/src/web/hooks/use-openai-global.js.map +1 -1
- package/dist/src/web/hooks/use-request-modal.test.js +2 -2
- package/dist/src/web/hooks/use-request-modal.test.js.map +1 -1
- package/dist/src/web/hooks/use-theme.js.map +1 -1
- package/dist/src/web/hooks/use-theme.test.js +2 -2
- package/dist/src/web/hooks/use-theme.test.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.d.ts +1 -1
- package/dist/src/web/hooks/use-tool-info.js +4 -6
- package/dist/src/web/hooks/use-tool-info.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.test-d.js +0 -1
- package/dist/src/web/hooks/use-tool-info.test-d.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.test.js +2 -2
- package/dist/src/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/src/web/hooks/use-user-agent.js.map +1 -1
- package/dist/src/web/hooks/use-user-agent.test.js +2 -2
- package/dist/src/web/hooks/use-user-agent.test.js.map +1 -1
- package/dist/src/web/hooks/use-widget-state.js +9 -7
- package/dist/src/web/hooks/use-widget-state.js.map +1 -1
- package/dist/src/web/hooks/use-widget-state.test.js +2 -2
- package/dist/src/web/hooks/use-widget-state.test.js.map +1 -1
- package/dist/src/web/index.d.ts +6 -4
- package/dist/src/web/index.js +6 -4
- package/dist/src/web/index.js.map +1 -1
- package/dist/src/web/plugin/data-llm.test.d.ts +1 -0
- package/dist/src/web/plugin/data-llm.test.js +81 -0
- package/dist/src/web/plugin/data-llm.test.js.map +1 -0
- package/dist/src/web/plugin/plugin.js +39 -0
- package/dist/src/web/plugin/plugin.js.map +1 -0
- package/dist/src/web/plugin/transform-data-llm.d.ts +12 -0
- package/dist/src/web/plugin/transform-data-llm.js +93 -0
- package/dist/src/web/plugin/transform-data-llm.js.map +1 -0
- package/dist/src/web/plugin/transform-data-llm.test.d.ts +1 -0
- package/dist/src/web/plugin/transform-data-llm.test.js +81 -0
- package/dist/src/web/plugin/transform-data-llm.test.js.map +1 -0
- package/dist/src/web/proxy.js +1 -1
- package/dist/src/web/proxy.js.map +1 -1
- package/dist/src/web/types.d.ts +14 -4
- package/dist/src/web/types.js +1 -0
- package/dist/src/web/types.js.map +1 -1
- package/package.json +14 -6
- package/dist/src/web/hooks/use-tool-output.d.ts +0 -4
- package/dist/src/web/hooks/use-tool-output.js +0 -9
- package/dist/src/web/hooks/use-tool-output.js.map +0 -1
- package/dist/src/web/hooks/use-tool-response-metadata.d.ts +0 -4
- package/dist/src/web/hooks/use-tool-response-metadata.js +0 -8
- package/dist/src/web/hooks/use-tool-response-metadata.js.map +0 -1
- package/dist/src/web/plugin.js +0 -28
- package/dist/src/web/plugin.js.map +0 -1
- package/dist/src/web/typed-hooks.js.map +0 -1
- package/dist/src/web/typed-hooks.test-d.js +0 -90
- package/dist/src/web/typed-hooks.test-d.js.map +0 -1
- package/dist/src/web/typed-hooks.test.js.map +0 -1
- /package/dist/src/web/{typed-hooks.test-d.d.ts → create-store.test.d.ts} +0 -0
- /package/dist/src/web/{typed-hooks.test.d.ts → data-llm.test.d.ts} +0 -0
- /package/dist/src/web/{plugin.d.ts → plugin/plugin.d.ts} +0 -0
package/dist/src/web/types.d.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
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
8
|
export type Prettify<T> = {
|
|
3
9
|
[K in keyof T]: T[K];
|
|
4
10
|
} & {};
|
|
5
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;
|
|
6
16
|
type WidgetState = UnknownObject;
|
|
7
17
|
type FileMetadata = {
|
|
8
18
|
fileId: string;
|
|
@@ -18,13 +28,13 @@ export declare class ToolResponseEvent extends CustomEvent<{
|
|
|
18
28
|
}
|
|
19
29
|
declare global {
|
|
20
30
|
interface Window {
|
|
21
|
-
openai:
|
|
31
|
+
openai: OpenAiMethods<WidgetState> & OpenAiProperties;
|
|
22
32
|
}
|
|
23
33
|
interface WindowEventMap {
|
|
24
34
|
[SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
|
|
25
35
|
}
|
|
26
36
|
}
|
|
27
|
-
export type
|
|
37
|
+
export type OpenAiProperties<ToolInput extends UnknownObject = Record<never, unknown>, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
|
|
28
38
|
theme: Theme;
|
|
29
39
|
userAgent: UserAgent;
|
|
30
40
|
locale: string;
|
|
@@ -49,7 +59,7 @@ export type CallToolResponse = {
|
|
|
49
59
|
result: string;
|
|
50
60
|
meta: Record<string, unknown>;
|
|
51
61
|
};
|
|
52
|
-
type
|
|
62
|
+
export type OpenAiMethods<WidgetState extends UnknownObject = UnknownObject> = {
|
|
53
63
|
/** Calls a tool on your MCP. Returns the full response. */
|
|
54
64
|
callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
|
|
55
65
|
/** Triggers a followup turn in the ChatGPT conversation */
|
|
@@ -94,7 +104,7 @@ type API<WidgetState extends UnknownObject> = {
|
|
|
94
104
|
};
|
|
95
105
|
export declare const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
|
|
96
106
|
export declare class SetGlobalsEvent extends CustomEvent<{
|
|
97
|
-
globals: Partial<
|
|
107
|
+
globals: Partial<OpenAiProperties>;
|
|
98
108
|
}> {
|
|
99
109
|
readonly type = "openai:set_globals";
|
|
100
110
|
}
|
package/dist/src/web/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/web/types.ts"],"names":[],"mappings":"
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skybridge",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.e62daf3",
|
|
4
4
|
"description": "Skybridge is a framework for building ChatGPT apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -19,9 +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
|
-
"
|
|
23
|
-
"test
|
|
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",
|
|
26
|
+
"test:format": "biome ci",
|
|
25
27
|
"docs:dev": "pnpm --filter @skybridge/docs start",
|
|
26
28
|
"docs:build": "pnpm --filter @skybridge/docs build",
|
|
27
29
|
"docs:serve": "pnpm --filter @skybridge/docs serve"
|
|
@@ -35,21 +37,26 @@
|
|
|
35
37
|
"author": "Frédéric Barthelet",
|
|
36
38
|
"license": "ISC",
|
|
37
39
|
"peerDependencies": {
|
|
40
|
+
"@modelcontextprotocol/sdk": ">=1.0.0",
|
|
38
41
|
"react": ">=18.0.0",
|
|
39
42
|
"react-dom": ">=18.0.0"
|
|
40
43
|
},
|
|
41
44
|
"dependencies": {
|
|
42
|
-
"@
|
|
45
|
+
"@babel/core": "^7.28.5",
|
|
43
46
|
"cors": "^2.8.5",
|
|
44
47
|
"express": "^5.1.0",
|
|
45
48
|
"handlebars": "^4.7.8",
|
|
49
|
+
"superjson": "^2.2.6",
|
|
46
50
|
"vite": "^7.1.11",
|
|
47
|
-
"
|
|
51
|
+
"zustand": "^5.0.9"
|
|
48
52
|
},
|
|
49
53
|
"devDependencies": {
|
|
54
|
+
"@biomejs/biome": "2.3.8",
|
|
55
|
+
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
50
56
|
"@testing-library/dom": "^10.4.1",
|
|
51
57
|
"@testing-library/react": "^16.3.0",
|
|
52
58
|
"@total-typescript/tsconfig": "^1.0.4",
|
|
59
|
+
"@types/babel__core": "^7.20.5",
|
|
53
60
|
"@types/cors": "^2.8.19",
|
|
54
61
|
"@types/express": "^5.0.3",
|
|
55
62
|
"@types/jsdom": "^21.1.6",
|
|
@@ -59,7 +66,8 @@
|
|
|
59
66
|
"@vitest/ui": "^2.1.8",
|
|
60
67
|
"jsdom": "^25.0.1",
|
|
61
68
|
"typescript": "^5.9.3",
|
|
62
|
-
"vitest": "^2.1.8"
|
|
69
|
+
"vitest": "^2.1.8",
|
|
70
|
+
"zod": "^4.1.13"
|
|
63
71
|
},
|
|
64
72
|
"packageManager": "pnpm@10.17.1"
|
|
65
73
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { useToolInfo } from "./use-tool-info.js";
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated This hook is deprecated. Use `useToolInfo()` instead and access the `output` property.
|
|
4
|
-
*/
|
|
5
|
-
export function useToolOutput() {
|
|
6
|
-
const { output } = useToolInfo();
|
|
7
|
-
return output;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=use-tool-output.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-tool-output.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-tool-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,CAAC;IAEjC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { useOpenAiGlobal } from "./use-openai-global.js";
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated This hook is deprecated. Use `useToolInfo()` instead and access the `responseMetadata` property.
|
|
4
|
-
*/
|
|
5
|
-
export function useToolResponseMetadata() {
|
|
6
|
-
return useOpenAiGlobal("toolResponseMetadata");
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=use-tool-response-metadata.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-tool-response-metadata.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-tool-response-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,eAAe,CAAC,sBAAsB,CAAC,CAAC;AACjD,CAAC"}
|
package/dist/src/web/plugin.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export function skybridge() {
|
|
2
|
-
return {
|
|
3
|
-
name: "skybridge",
|
|
4
|
-
async config(config) {
|
|
5
|
-
// Dynamic imports to ensure Node modules are only loaded in Node.js context
|
|
6
|
-
const { globSync } = await import("node:fs");
|
|
7
|
-
const { resolve } = await import("node:path");
|
|
8
|
-
const projectRoot = config.root || process.cwd();
|
|
9
|
-
const widgetsPattern = resolve(projectRoot, "src/widgets/*.{js,ts,jsx,tsx,html}");
|
|
10
|
-
const input = Object.fromEntries(globSync(widgetsPattern).map((file) => [
|
|
11
|
-
file.match(/src\/widgets\/(.+)\.tsx$/)?.[1],
|
|
12
|
-
file,
|
|
13
|
-
]));
|
|
14
|
-
return {
|
|
15
|
-
base: "/assets",
|
|
16
|
-
build: {
|
|
17
|
-
manifest: true,
|
|
18
|
-
minify: true,
|
|
19
|
-
cssCodeSplit: false,
|
|
20
|
-
rollupOptions: {
|
|
21
|
-
input,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/web/plugin.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,SAAS;IACvB,OAAO;QACL,IAAI,EAAE,WAAW;QAEjB,KAAK,CAAC,MAAM,CAAC,MAAM;YACjB,4EAA4E;YAC5E,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;YAC7C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;YAE9C,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YACjD,MAAM,cAAc,GAAG,OAAO,CAC5B,WAAW,EACX,oCAAoC,CACrC,CAAC;YAEF,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAC9B,QAAQ,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;gBACrC,IAAI,CAAC,KAAK,CAAC,0BAA0B,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC3C,IAAI;aACL,CAAC,CACH,CAAC;YAEF,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE;oBACL,QAAQ,EAAE,IAAI;oBACd,MAAM,EAAE,IAAI;oBACZ,YAAY,EAAE,KAAK;oBACnB,aAAa,EAAE;wBACb,KAAK;qBACN;iBACF;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typed-hooks.js","sourceRoot":"","sources":["../../../src/web/typed-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAsB,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAkB,MAAM,0BAA0B,CAAC;AAuBvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,UAAU,gBAAgB;IAI9B,OAAO;QACL;;;;;;;;;;;;;;;;;;WAkBG;QACH,WAAW,EAAE,CACX,IAAO,EACqD,EAAE;YAC9D,OAAO,WAAW,CAAC,IAAI,CAGtB,CAAC;QACJ,CAAC;QAED;;;;;;;;;;;;;;;;;;;;;;;;WAwBG;QACH,WAAW,EAAE,GAGX,EAAE;YACF,OAAO,WAAW,EAGjB,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { expectTypeOf, test } from "vitest";
|
|
2
|
-
import { createTypedHooks } from "./typed-hooks.js";
|
|
3
|
-
import { createTestServer } from "../test/utils.js";
|
|
4
|
-
const server = createTestServer();
|
|
5
|
-
test("InferTools extracts the tool registry type (widgets + registerTool)", () => {
|
|
6
|
-
expectTypeOf().toHaveProperty("search-voyage");
|
|
7
|
-
expectTypeOf().toHaveProperty("get-trip-details");
|
|
8
|
-
expectTypeOf().toHaveProperty("no-input-widget");
|
|
9
|
-
expectTypeOf().toHaveProperty("calculate-price");
|
|
10
|
-
expectTypeOf().toHaveProperty("inferred-output-widget");
|
|
11
|
-
expectTypeOf().toHaveProperty("inferred-tool");
|
|
12
|
-
});
|
|
13
|
-
test("ToolNames returns a union of tool name literals (widgets + registerTool)", () => {
|
|
14
|
-
expectTypeOf().toEqualTypeOf();
|
|
15
|
-
});
|
|
16
|
-
test("ToolInput extracts the correct input type from Zod schema", () => {
|
|
17
|
-
expectTypeOf().toEqualTypeOf();
|
|
18
|
-
expectTypeOf().toEqualTypeOf();
|
|
19
|
-
expectTypeOf().toEqualTypeOf();
|
|
20
|
-
});
|
|
21
|
-
test("ToolOutput extracts the correct output type from callback's structuredContent", () => {
|
|
22
|
-
expectTypeOf().toEqualTypeOf();
|
|
23
|
-
expectTypeOf().toEqualTypeOf();
|
|
24
|
-
expectTypeOf().toEqualTypeOf();
|
|
25
|
-
expectTypeOf().toEqualTypeOf();
|
|
26
|
-
});
|
|
27
|
-
test("ToolOutput extracts the correct output type from callback (inferred)", () => {
|
|
28
|
-
expectTypeOf().toEqualTypeOf();
|
|
29
|
-
expectTypeOf().toEqualTypeOf();
|
|
30
|
-
});
|
|
31
|
-
test("createTypedHooks provides autocomplete for tool names (widgets + registerTool)", () => {
|
|
32
|
-
const { useCallTool } = createTypedHooks();
|
|
33
|
-
useCallTool("search-voyage");
|
|
34
|
-
useCallTool("get-trip-details");
|
|
35
|
-
useCallTool("no-input-widget");
|
|
36
|
-
useCallTool("calculate-price");
|
|
37
|
-
useCallTool("inferred-output-widget");
|
|
38
|
-
useCallTool("inferred-tool");
|
|
39
|
-
// @ts-expect-error - "invalid-name" is not a valid tool name
|
|
40
|
-
useCallTool("invalid-name");
|
|
41
|
-
});
|
|
42
|
-
test("useCallTool returns correctly typed callTool function", () => {
|
|
43
|
-
const { useCallTool } = createTypedHooks();
|
|
44
|
-
const { callTool } = useCallTool("search-voyage");
|
|
45
|
-
callTool({ destination: "Spain" });
|
|
46
|
-
callTool({ destination: "France", departureDate: "2024-06-01" });
|
|
47
|
-
callTool({ destination: "Italy", maxPrice: 1000 });
|
|
48
|
-
const { callTool: calculateTool } = useCallTool("calculate-price");
|
|
49
|
-
calculateTool({ tripId: "123", passengers: 2 });
|
|
50
|
-
});
|
|
51
|
-
test("useCallTool returns correctly typed data", () => {
|
|
52
|
-
const { useCallTool } = createTypedHooks();
|
|
53
|
-
const { data } = useCallTool("search-voyage");
|
|
54
|
-
if (data) {
|
|
55
|
-
expectTypeOf(data.structuredContent).toExtend();
|
|
56
|
-
expectTypeOf(data.structuredContent.results).toBeArray();
|
|
57
|
-
expectTypeOf(data.structuredContent.totalCount).toBeNumber();
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
test("useCallTool returns correctly typed data for callback-inferred outputs", () => {
|
|
61
|
-
const { useCallTool } = createTypedHooks();
|
|
62
|
-
const { data: widgetData } = useCallTool("inferred-output-widget");
|
|
63
|
-
if (widgetData) {
|
|
64
|
-
expectTypeOf(widgetData.structuredContent).toExtend();
|
|
65
|
-
}
|
|
66
|
-
const { data: toolData } = useCallTool("inferred-tool");
|
|
67
|
-
if (toolData) {
|
|
68
|
-
expectTypeOf(toolData.structuredContent).toExtend();
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
test("createTypedHooks provides autocomplete for tool names in useToolInfo (widgets + registerTool)", () => {
|
|
72
|
-
const { useToolInfo } = createTypedHooks();
|
|
73
|
-
useToolInfo();
|
|
74
|
-
useToolInfo();
|
|
75
|
-
useToolInfo();
|
|
76
|
-
useToolInfo();
|
|
77
|
-
useToolInfo();
|
|
78
|
-
useToolInfo();
|
|
79
|
-
// @ts-expect-error - "invalid-name" is not a valid tool name
|
|
80
|
-
useToolInfo();
|
|
81
|
-
});
|
|
82
|
-
test("useToolInfo infers input and output types", () => {
|
|
83
|
-
const { useToolInfo } = createTypedHooks();
|
|
84
|
-
const toolInfo = useToolInfo();
|
|
85
|
-
expectTypeOf(toolInfo.input).toExtend();
|
|
86
|
-
if (toolInfo.status === "success") {
|
|
87
|
-
expectTypeOf(toolInfo.output).toExtend();
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
//# sourceMappingURL=typed-hooks.test-d.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typed-hooks.test-d.js","sourceRoot":"","sources":["../../../src/web/typed-hooks.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IA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"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|