@assistant-ui/react-devtools 1.0.6 → 1.2.1
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/README.md +11 -47
- package/dist/DevToolsFrame.d.ts +9 -6
- package/dist/DevToolsFrame.d.ts.map +1 -1
- package/dist/DevToolsFrame.js +33 -24
- package/dist/DevToolsFrame.js.map +1 -1
- package/dist/DevToolsHost.d.ts +31 -29
- package/dist/DevToolsHost.d.ts.map +1 -1
- package/dist/DevToolsHost.js +81 -99
- package/dist/DevToolsHost.js.map +1 -1
- package/dist/DevToolsModal.d.ts +4 -1
- package/dist/DevToolsModal.d.ts.map +1 -1
- package/dist/DevToolsModal.js +132 -77
- package/dist/DevToolsModal.js.map +1 -1
- package/dist/ExtensionHost.d.ts +8 -5
- package/dist/ExtensionHost.d.ts.map +1 -1
- package/dist/ExtensionHost.js +40 -44
- package/dist/ExtensionHost.js.map +1 -1
- package/dist/FrameClient.d.ts +29 -27
- package/dist/FrameClient.d.ts.map +1 -1
- package/dist/FrameClient.js +52 -55
- package/dist/FrameClient.js.map +1 -1
- package/dist/FrameHost.d.ts +9 -6
- package/dist/FrameHost.d.ts.map +1 -1
- package/dist/FrameHost.js +24 -25
- package/dist/FrameHost.js.map +1 -1
- package/dist/constants.d.ts +5 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -2
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.js +10 -10
- package/dist/styles/DevToolsModal.styles.d.ts +16 -12
- package/dist/styles/DevToolsModal.styles.d.ts.map +1 -1
- package/dist/styles/DevToolsModal.styles.js +101 -103
- package/dist/styles/DevToolsModal.styles.js.map +1 -1
- package/dist/types.d.ts +12 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -2
- package/dist/utils/serialization.d.ts +7 -3
- package/dist/utils/serialization.d.ts.map +1 -1
- package/dist/utils/serialization.js +48 -76
- package/dist/utils/serialization.js.map +1 -1
- package/dist/utils/toolNormalization.d.ts +10 -7
- package/dist/utils/toolNormalization.d.ts.map +1 -1
- package/dist/utils/toolNormalization.js +38 -48
- package/dist/utils/toolNormalization.js.map +1 -1
- package/package.json +11 -11
- package/src/DevToolsModal.tsx +7 -1
- package/src/FrameClient.ts +2 -0
- package/src/utils/serialization.ts +7 -7
- package/src/utils/toolNormalization.ts +10 -10
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types.js.map +0 -1
|
@@ -1,80 +1,52 @@
|
|
|
1
1
|
import { normalizeToolList } from "./toolNormalization.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (Array.isArray(value)) {
|
|
28
|
-
if (seen.has(value))
|
|
29
|
-
return "[Circular]";
|
|
30
|
-
seen.add(value);
|
|
31
|
-
return value
|
|
32
|
-
.map((entry) => sanitizeForMessage(entry, seen))
|
|
33
|
-
.filter((item) => item !== undefined);
|
|
34
|
-
}
|
|
35
|
-
if (typeof value === "object") {
|
|
36
|
-
if (seen.has(value))
|
|
37
|
-
return "[Circular]";
|
|
38
|
-
seen.add(value);
|
|
39
|
-
const result = {};
|
|
40
|
-
for (const [key, entry] of Object.entries(value)) {
|
|
41
|
-
result[key] = sanitizeForMessage(entry, seen);
|
|
42
|
-
}
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
return value;
|
|
2
|
+
//#region src/utils/serialization.ts
|
|
3
|
+
const sanitizeForMessage = (value, seen = /* @__PURE__ */ new WeakSet()) => {
|
|
4
|
+
if (value === null || value === void 0) return value;
|
|
5
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
|
|
6
|
+
if (typeof value === "function") return "[Function]";
|
|
7
|
+
if (value instanceof Date) return value.toISOString();
|
|
8
|
+
if (value instanceof Map) {
|
|
9
|
+
const result = {};
|
|
10
|
+
for (const [key, entry] of value.entries()) result[String(key)] = sanitizeForMessage(entry, seen);
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
if (value instanceof Set) return Array.from(value).map((entry) => sanitizeForMessage(entry, seen));
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
if (seen.has(value)) return "[Circular]";
|
|
16
|
+
seen.add(value);
|
|
17
|
+
return value.map((entry) => sanitizeForMessage(entry, seen)).filter((item) => item !== void 0);
|
|
18
|
+
}
|
|
19
|
+
if (typeof value === "object") {
|
|
20
|
+
if (seen.has(value)) return "[Circular]";
|
|
21
|
+
seen.add(value);
|
|
22
|
+
const result = {};
|
|
23
|
+
for (const [key, entry] of Object.entries(value)) result[key] = sanitizeForMessage(entry, seen);
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
46
27
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
typeof callSettings === "object" &&
|
|
68
|
-
!Array.isArray(callSettings)) {
|
|
69
|
-
result.callSettings = callSettings;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (modelContext["config"] !== undefined) {
|
|
73
|
-
const config = sanitizeForMessage(modelContext["config"]);
|
|
74
|
-
if (config && typeof config === "object" && !Array.isArray(config)) {
|
|
75
|
-
result.config = config;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return Object.keys(result).length > 0 ? result : undefined;
|
|
28
|
+
const serializeModelContext = (context) => {
|
|
29
|
+
if (!context || typeof context !== "object") return;
|
|
30
|
+
const modelContext = context;
|
|
31
|
+
const result = {};
|
|
32
|
+
const systemValue = modelContext.system;
|
|
33
|
+
if (typeof systemValue === "string" && systemValue.length > 0) result.system = systemValue;
|
|
34
|
+
const tools = normalizeToolList(modelContext.tools);
|
|
35
|
+
if (tools.length > 0) result.tools = tools.map((tool) => ({
|
|
36
|
+
...tool,
|
|
37
|
+
parameters: sanitizeForMessage(tool.parameters)
|
|
38
|
+
}));
|
|
39
|
+
if (modelContext.callSettings !== void 0) {
|
|
40
|
+
const callSettings = sanitizeForMessage(modelContext.callSettings);
|
|
41
|
+
if (callSettings && typeof callSettings === "object" && !Array.isArray(callSettings)) result.callSettings = callSettings;
|
|
42
|
+
}
|
|
43
|
+
if (modelContext.config !== void 0) {
|
|
44
|
+
const config = sanitizeForMessage(modelContext.config);
|
|
45
|
+
if (config && typeof config === "object" && !Array.isArray(config)) result.config = config;
|
|
46
|
+
}
|
|
47
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
79
48
|
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { sanitizeForMessage, serializeModelContext };
|
|
51
|
+
|
|
80
52
|
//# sourceMappingURL=serialization.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","
|
|
1
|
+
{"version":3,"file":"serialization.js","names":[],"sources":["../../src/utils/serialization.ts"],"sourcesContent":["import type { ModelContext } from \"@assistant-ui/react\";\nimport type { SerializedModelContext } from \"../types\";\nimport { normalizeToolList } from \"./toolNormalization\";\n\nexport const sanitizeForMessage = (\n value: unknown,\n seen = new WeakSet<object>(),\n): unknown => {\n // Early return for primitives\n if (value === null || value === undefined) return value;\n if (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\"\n ) {\n return value;\n }\n if (typeof value === \"function\") {\n return \"[Function]\";\n }\n if (value instanceof Date) {\n return value.toISOString();\n }\n if (value instanceof Map) {\n const result: Record<string, unknown> = {};\n for (const [key, entry] of value.entries()) {\n result[String(key)] = sanitizeForMessage(entry, seen);\n }\n return result;\n }\n if (value instanceof Set) {\n return Array.from(value).map((entry) => sanitizeForMessage(entry, seen));\n }\n if (Array.isArray(value)) {\n if (seen.has(value as unknown as object)) return \"[Circular]\";\n seen.add(value as unknown as object);\n return value\n .map((entry) => sanitizeForMessage(entry, seen))\n .filter((item) => item !== undefined);\n }\n if (typeof value === \"object\") {\n if (seen.has(value as object)) return \"[Circular]\";\n seen.add(value as object);\n const result: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(\n value as Record<string, unknown>,\n )) {\n result[key] = sanitizeForMessage(entry, seen);\n }\n return result;\n }\n return value;\n};\n\nexport const serializeModelContext = (\n context: ModelContext | undefined,\n): SerializedModelContext | undefined => {\n if (!context || typeof context !== \"object\") {\n return undefined;\n }\n\n const modelContext = context as Record<string, unknown>;\n const result: SerializedModelContext = {};\n\n const systemValue = modelContext.system;\n if (typeof systemValue === \"string\" && systemValue.length > 0) {\n result.system = systemValue;\n }\n\n const tools = normalizeToolList(modelContext.tools);\n if (tools.length > 0) {\n result.tools = tools.map((tool) => ({\n ...tool,\n parameters: sanitizeForMessage(tool.parameters),\n }));\n }\n\n if (modelContext.callSettings !== undefined) {\n const callSettings = sanitizeForMessage(modelContext.callSettings);\n if (\n callSettings &&\n typeof callSettings === \"object\" &&\n !Array.isArray(callSettings)\n ) {\n result.callSettings = callSettings as Record<string, unknown>;\n }\n }\n\n if (modelContext.config !== undefined) {\n const config = sanitizeForMessage(modelContext.config);\n if (config && typeof config === \"object\" && !Array.isArray(config)) {\n result.config = config as Record<string, unknown>;\n }\n }\n\n return Object.keys(result).length > 0 ? result : undefined;\n};\n"],"mappings":";;AAIA,MAAa,sBACX,OACA,uBAAO,IAAI,QAAgB,MACf;CAEZ,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,OAAO;CAClD,IACE,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,WAEjB,OAAO;CAET,IAAI,OAAO,UAAU,YACnB,OAAO;CAET,IAAI,iBAAiB,MACnB,OAAO,MAAM,YAAY;CAE3B,IAAI,iBAAiB,KAAK;EACxB,MAAM,SAAkC,CAAC;EACzC,KAAK,MAAM,CAAC,KAAK,UAAU,MAAM,QAAQ,GACvC,OAAO,OAAO,GAAG,KAAK,mBAAmB,OAAO,IAAI;EAEtD,OAAO;CACT;CACA,IAAI,iBAAiB,KACnB,OAAO,MAAM,KAAK,KAAK,EAAE,KAAK,UAAU,mBAAmB,OAAO,IAAI,CAAC;CAEzE,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxB,IAAI,KAAK,IAAI,KAA0B,GAAG,OAAO;EACjD,KAAK,IAAI,KAA0B;EACnC,OAAO,MACJ,KAAK,UAAU,mBAAmB,OAAO,IAAI,CAAC,EAC9C,QAAQ,SAAS,SAAS,KAAA,CAAS;CACxC;CACA,IAAI,OAAO,UAAU,UAAU;EAC7B,IAAI,KAAK,IAAI,KAAe,GAAG,OAAO;EACtC,KAAK,IAAI,KAAe;EACxB,MAAM,SAAkC,CAAC;EACzC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAChC,KACF,GACE,OAAO,OAAO,mBAAmB,OAAO,IAAI;EAE9C,OAAO;CACT;CACA,OAAO;AACT;AAEA,MAAa,yBACX,YACuC;CACvC,IAAI,CAAC,WAAW,OAAO,YAAY,UACjC;CAGF,MAAM,eAAe;CACrB,MAAM,SAAiC,CAAC;CAExC,MAAM,cAAc,aAAa;CACjC,IAAI,OAAO,gBAAgB,YAAY,YAAY,SAAS,GAC1D,OAAO,SAAS;CAGlB,MAAM,QAAQ,kBAAkB,aAAa,KAAK;CAClD,IAAI,MAAM,SAAS,GACjB,OAAO,QAAQ,MAAM,KAAK,UAAU;EAClC,GAAG;EACH,YAAY,mBAAmB,KAAK,UAAU;CAChD,EAAE;CAGJ,IAAI,aAAa,iBAAiB,KAAA,GAAW;EAC3C,MAAM,eAAe,mBAAmB,aAAa,YAAY;EACjE,IACE,gBACA,OAAO,iBAAiB,YACxB,CAAC,MAAM,QAAQ,YAAY,GAE3B,OAAO,eAAe;CAE1B;CAEA,IAAI,aAAa,WAAW,KAAA,GAAW;EACrC,MAAM,SAAS,mBAAmB,aAAa,MAAM;EACrD,IAAI,UAAU,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,MAAM,GAC/D,OAAO,SAAS;CAEpB;CAEA,OAAO,OAAO,KAAK,MAAM,EAAE,SAAS,IAAI,SAAS,KAAA;AACnD"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
//#region src/utils/toolNormalization.d.ts
|
|
2
|
+
type NormalizedTool = {
|
|
3
|
+
name: string;
|
|
4
|
+
type?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
parameters?: unknown;
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
+
declare const normalizeToolList: (value: unknown) => NormalizedTool[];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { NormalizedTool, normalizeToolList };
|
|
9
12
|
//# sourceMappingURL=toolNormalization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolNormalization.d.ts","
|
|
1
|
+
{"version":3,"file":"toolNormalization.d.ts","names":[],"sources":["../../src/utils/toolNormalization.ts"],"mappings":";KAEY,cAAA;EACV,IAAA;EACA,IAAA;EACA,WAAA;EACA,QAAA;EACA,UAAA;AAAA;AAAA,cA2CW,iBAAA,GAAqB,KAAA,cAAiB,cAAc"}
|
|
@@ -1,56 +1,46 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
//#region src/utils/toolNormalization.ts
|
|
2
3
|
const isRecord = (value) => value !== null && typeof value === "object";
|
|
3
4
|
const toJsonSchema = (value) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return value;
|
|
5
|
+
if (value instanceof z.ZodType) try {
|
|
6
|
+
return z.toJSONSchema(value);
|
|
7
|
+
} catch {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
13
11
|
};
|
|
14
12
|
const mapToNormalizedTool = (name, raw) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
if (typeof raw["disabled"] === "boolean") {
|
|
23
|
-
tool.disabled = raw["disabled"];
|
|
24
|
-
}
|
|
25
|
-
if (Object.prototype.hasOwnProperty.call(raw, "parameters")) {
|
|
26
|
-
tool.parameters = toJsonSchema(raw["parameters"]);
|
|
27
|
-
}
|
|
28
|
-
return tool;
|
|
13
|
+
const tool = { name };
|
|
14
|
+
if (typeof raw.type === "string") tool.type = raw.type;
|
|
15
|
+
if (typeof raw.description === "string") tool.description = raw.description;
|
|
16
|
+
if (typeof raw.disabled === "boolean") tool.disabled = raw.disabled;
|
|
17
|
+
if (Object.hasOwn(raw, "parameters")) tool.parameters = toJsonSchema(raw.parameters);
|
|
18
|
+
return tool;
|
|
29
19
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return tools;
|
|
53
|
-
}
|
|
54
|
-
return [];
|
|
20
|
+
const normalizeToolList = (value) => {
|
|
21
|
+
if (!value || typeof value !== "object") return [];
|
|
22
|
+
if (Array.isArray(value)) {
|
|
23
|
+
const tools = [];
|
|
24
|
+
for (const entry of value) {
|
|
25
|
+
if (!isRecord(entry) || typeof entry.name !== "string") continue;
|
|
26
|
+
tools.push(mapToNormalizedTool(entry.name, entry));
|
|
27
|
+
}
|
|
28
|
+
return tools;
|
|
29
|
+
}
|
|
30
|
+
if (isRecord(value)) {
|
|
31
|
+
const tools = [];
|
|
32
|
+
for (const [name, entry] of Object.entries(value)) {
|
|
33
|
+
if (!isRecord(entry)) {
|
|
34
|
+
tools.push({ name });
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
tools.push(mapToNormalizedTool(name, entry));
|
|
38
|
+
}
|
|
39
|
+
return tools;
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
55
42
|
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { normalizeToolList };
|
|
45
|
+
|
|
56
46
|
//# sourceMappingURL=toolNormalization.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolNormalization.js","
|
|
1
|
+
{"version":3,"file":"toolNormalization.js","names":[],"sources":["../../src/utils/toolNormalization.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport type NormalizedTool = {\n name: string;\n type?: string;\n description?: string;\n disabled?: boolean;\n parameters?: unknown;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === \"object\";\n\nconst toJsonSchema = (value: unknown): unknown => {\n if (value instanceof z.ZodType) {\n try {\n return z.toJSONSchema(value);\n } catch {\n return value;\n }\n }\n\n return value;\n};\n\nconst mapToNormalizedTool = (\n name: string,\n raw: Record<string, unknown>,\n): NormalizedTool => {\n const tool: NormalizedTool = { name };\n\n if (typeof raw.type === \"string\") {\n tool.type = raw.type as string;\n }\n\n if (typeof raw.description === \"string\") {\n tool.description = raw.description as string;\n }\n\n if (typeof raw.disabled === \"boolean\") {\n tool.disabled = raw.disabled as boolean;\n }\n\n if (Object.hasOwn(raw, \"parameters\")) {\n tool.parameters = toJsonSchema(raw.parameters);\n }\n\n return tool;\n};\n\nexport const normalizeToolList = (value: unknown): NormalizedTool[] => {\n if (!value || typeof value !== \"object\") {\n return [];\n }\n\n if (Array.isArray(value)) {\n const tools: NormalizedTool[] = [];\n\n for (const entry of value) {\n if (!isRecord(entry) || typeof entry.name !== \"string\") continue;\n tools.push(mapToNormalizedTool(entry.name as string, entry));\n }\n\n return tools;\n }\n\n if (isRecord(value)) {\n const tools: NormalizedTool[] = [];\n\n for (const [name, entry] of Object.entries(value)) {\n if (!isRecord(entry)) {\n tools.push({ name });\n continue;\n }\n\n tools.push(mapToNormalizedTool(name, entry));\n }\n\n return tools;\n }\n\n return [];\n};\n"],"mappings":";;AAUA,MAAM,YAAY,UAChB,UAAU,QAAQ,OAAO,UAAU;AAErC,MAAM,gBAAgB,UAA4B;CAChD,IAAI,iBAAiB,EAAE,SACrB,IAAI;EACF,OAAO,EAAE,aAAa,KAAK;CAC7B,QAAQ;EACN,OAAO;CACT;CAGF,OAAO;AACT;AAEA,MAAM,uBACJ,MACA,QACmB;CACnB,MAAM,OAAuB,EAAE,KAAK;CAEpC,IAAI,OAAO,IAAI,SAAS,UACtB,KAAK,OAAO,IAAI;CAGlB,IAAI,OAAO,IAAI,gBAAgB,UAC7B,KAAK,cAAc,IAAI;CAGzB,IAAI,OAAO,IAAI,aAAa,WAC1B,KAAK,WAAW,IAAI;CAGtB,IAAI,OAAO,OAAO,KAAK,YAAY,GACjC,KAAK,aAAa,aAAa,IAAI,UAAU;CAG/C,OAAO;AACT;AAEA,MAAa,qBAAqB,UAAqC;CACrE,IAAI,CAAC,SAAS,OAAO,UAAU,UAC7B,OAAO,CAAC;CAGV,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxB,MAAM,QAA0B,CAAC;EAEjC,KAAK,MAAM,SAAS,OAAO;GACzB,IAAI,CAAC,SAAS,KAAK,KAAK,OAAO,MAAM,SAAS,UAAU;GACxD,MAAM,KAAK,oBAAoB,MAAM,MAAgB,KAAK,CAAC;EAC7D;EAEA,OAAO;CACT;CAEA,IAAI,SAAS,KAAK,GAAG;EACnB,MAAM,QAA0B,CAAC;EAEjC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,KAAK,GAAG;GACjD,IAAI,CAAC,SAAS,KAAK,GAAG;IACpB,MAAM,KAAK,EAAE,KAAK,CAAC;IACnB;GACF;GAEA,MAAM,KAAK,oBAAoB,MAAM,KAAK,CAAC;EAC7C;EAEA,OAAO;CACT;CAEA,OAAO,CAAC;AACV"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/react-devtools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "React development tools for assistant-ui components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"assistant-ui",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
],
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"zod": "^4.3
|
|
30
|
+
"zod": "^4.4.3"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@assistant-ui/react": "^0.
|
|
34
|
-
"@assistant-ui/tap": "^0.5.
|
|
33
|
+
"@assistant-ui/react": "^0.14.8",
|
|
34
|
+
"@assistant-ui/tap": "^0.5.12",
|
|
35
35
|
"@types/react": "*",
|
|
36
36
|
"@types/react-dom": "*",
|
|
37
37
|
"react": "^18 || ^19",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@types/node": "^25.
|
|
50
|
-
"@types/react": "^19.2.
|
|
49
|
+
"@types/node": "^25.9.1",
|
|
50
|
+
"@types/react": "^19.2.15",
|
|
51
51
|
"@types/react-dom": "^19.2.3",
|
|
52
|
-
"react": "^19.2.
|
|
53
|
-
"react-dom": "^19.2.
|
|
54
|
-
"@assistant-ui/react": "0.
|
|
55
|
-
"@assistant-ui/tap": "0.5.
|
|
56
|
-
"@assistant-ui/x-buildutils": "0.0.
|
|
52
|
+
"react": "^19.2.6",
|
|
53
|
+
"react-dom": "^19.2.6",
|
|
54
|
+
"@assistant-ui/react": "0.14.8",
|
|
55
|
+
"@assistant-ui/tap": "0.5.12",
|
|
56
|
+
"@assistant-ui/x-buildutils": "0.0.9"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public",
|
package/src/DevToolsModal.tsx
CHANGED
|
@@ -83,6 +83,7 @@ const DevToolsModalImpl = () => {
|
|
|
83
83
|
<>
|
|
84
84
|
<div style={styles.floatingContainer}>
|
|
85
85
|
<button
|
|
86
|
+
type="button"
|
|
86
87
|
onClick={() => setIsOpen(true)}
|
|
87
88
|
onMouseEnter={() => setButtonHover(true)}
|
|
88
89
|
onMouseLeave={() => setButtonHover(false)}
|
|
@@ -94,6 +95,7 @@ const DevToolsModalImpl = () => {
|
|
|
94
95
|
title="Open assistant-ui DevTools"
|
|
95
96
|
>
|
|
96
97
|
<svg
|
|
98
|
+
aria-hidden="true"
|
|
97
99
|
width="20"
|
|
98
100
|
height="20"
|
|
99
101
|
viewBox="0 0 24 24"
|
|
@@ -115,10 +117,13 @@ const DevToolsModalImpl = () => {
|
|
|
115
117
|
|
|
116
118
|
{isOpen && (
|
|
117
119
|
<>
|
|
120
|
+
{/* biome-ignore lint/a11y/useKeyWithClickEvents: backdrop click is a convenience; keyboard users use the close button */}
|
|
121
|
+
{/* biome-ignore lint/a11y/noStaticElementInteractions: backdrop overlay */}
|
|
118
122
|
<div style={styles.backdrop} onClick={() => setIsOpen(false)} />
|
|
119
123
|
|
|
120
124
|
<div style={styles.modal} data-devtools-modal>
|
|
121
125
|
<button
|
|
126
|
+
type="button"
|
|
122
127
|
onClick={() => setIsOpen(false)}
|
|
123
128
|
onMouseEnter={() => setCloseHover(true)}
|
|
124
129
|
onMouseLeave={() => setCloseHover(false)}
|
|
@@ -129,6 +134,7 @@ const DevToolsModalImpl = () => {
|
|
|
129
134
|
aria-label="Close DevTools"
|
|
130
135
|
>
|
|
131
136
|
<svg
|
|
137
|
+
aria-hidden="true"
|
|
132
138
|
width="14"
|
|
133
139
|
height="14"
|
|
134
140
|
viewBox="0 0 24 24"
|
|
@@ -176,7 +182,7 @@ export const DevToolsModal = () => {
|
|
|
176
182
|
// This allows the entire component to be eliminated via dead code elimination
|
|
177
183
|
if (
|
|
178
184
|
typeof process !== "undefined" &&
|
|
179
|
-
process.env?.
|
|
185
|
+
process.env?.NODE_ENV === "production"
|
|
180
186
|
) {
|
|
181
187
|
return null;
|
|
182
188
|
}
|
package/src/FrameClient.ts
CHANGED
|
@@ -43,6 +43,7 @@ export class FrameClient {
|
|
|
43
43
|
this.notifyListeners(message.data);
|
|
44
44
|
} else if (message.type === "host-connected") {
|
|
45
45
|
// Host has reconnected (page refresh), notify listeners to re-subscribe
|
|
46
|
+
// biome-ignore lint/suspicious/useIterableCallbackReturn: forEach callback intentionally has no return
|
|
46
47
|
this.connectionListeners.forEach((listener) => listener());
|
|
47
48
|
}
|
|
48
49
|
});
|
|
@@ -89,6 +90,7 @@ export class FrameClient {
|
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
private notifyListeners(data: UpdateMessage["data"]) {
|
|
93
|
+
// biome-ignore lint/suspicious/useIterableCallbackReturn: forEach callback intentionally has no return
|
|
92
94
|
this.listeners.forEach((listener) => listener(data));
|
|
93
95
|
}
|
|
94
96
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModelContext } from "@assistant-ui/react";
|
|
1
|
+
import type { ModelContext } from "@assistant-ui/react";
|
|
2
2
|
import type { SerializedModelContext } from "../types";
|
|
3
3
|
import { normalizeToolList } from "./toolNormalization";
|
|
4
4
|
|
|
@@ -62,12 +62,12 @@ export const serializeModelContext = (
|
|
|
62
62
|
const modelContext = context as Record<string, unknown>;
|
|
63
63
|
const result: SerializedModelContext = {};
|
|
64
64
|
|
|
65
|
-
const systemValue = modelContext
|
|
65
|
+
const systemValue = modelContext.system;
|
|
66
66
|
if (typeof systemValue === "string" && systemValue.length > 0) {
|
|
67
67
|
result.system = systemValue;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
const tools = normalizeToolList(modelContext
|
|
70
|
+
const tools = normalizeToolList(modelContext.tools);
|
|
71
71
|
if (tools.length > 0) {
|
|
72
72
|
result.tools = tools.map((tool) => ({
|
|
73
73
|
...tool,
|
|
@@ -75,8 +75,8 @@ export const serializeModelContext = (
|
|
|
75
75
|
}));
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
if (modelContext
|
|
79
|
-
const callSettings = sanitizeForMessage(modelContext
|
|
78
|
+
if (modelContext.callSettings !== undefined) {
|
|
79
|
+
const callSettings = sanitizeForMessage(modelContext.callSettings);
|
|
80
80
|
if (
|
|
81
81
|
callSettings &&
|
|
82
82
|
typeof callSettings === "object" &&
|
|
@@ -86,8 +86,8 @@ export const serializeModelContext = (
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
if (modelContext
|
|
90
|
-
const config = sanitizeForMessage(modelContext
|
|
89
|
+
if (modelContext.config !== undefined) {
|
|
90
|
+
const config = sanitizeForMessage(modelContext.config);
|
|
91
91
|
if (config && typeof config === "object" && !Array.isArray(config)) {
|
|
92
92
|
result.config = config as Record<string, unknown>;
|
|
93
93
|
}
|
|
@@ -29,20 +29,20 @@ const mapToNormalizedTool = (
|
|
|
29
29
|
): NormalizedTool => {
|
|
30
30
|
const tool: NormalizedTool = { name };
|
|
31
31
|
|
|
32
|
-
if (typeof raw
|
|
33
|
-
tool.type = raw
|
|
32
|
+
if (typeof raw.type === "string") {
|
|
33
|
+
tool.type = raw.type as string;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
if (typeof raw
|
|
37
|
-
tool.description = raw
|
|
36
|
+
if (typeof raw.description === "string") {
|
|
37
|
+
tool.description = raw.description as string;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
if (typeof raw
|
|
41
|
-
tool.disabled = raw
|
|
40
|
+
if (typeof raw.disabled === "boolean") {
|
|
41
|
+
tool.disabled = raw.disabled as boolean;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
if (Object.
|
|
45
|
-
tool.parameters = toJsonSchema(raw
|
|
44
|
+
if (Object.hasOwn(raw, "parameters")) {
|
|
45
|
+
tool.parameters = toJsonSchema(raw.parameters);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
return tool;
|
|
@@ -57,8 +57,8 @@ export const normalizeToolList = (value: unknown): NormalizedTool[] => {
|
|
|
57
57
|
const tools: NormalizedTool[] = [];
|
|
58
58
|
|
|
59
59
|
for (const entry of value) {
|
|
60
|
-
if (!isRecord(entry) || typeof entry
|
|
61
|
-
tools.push(mapToNormalizedTool(entry
|
|
60
|
+
if (!isRecord(entry) || typeof entry.name !== "string") continue;
|
|
61
|
+
tools.push(mapToNormalizedTool(entry.name as string, entry));
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
return tools;
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,2BAAwB;AAChD,OAAO,EAAE,aAAa,EAAE,2BAAwB;AAChD,OAAO,EAAE,SAAS,EAAE,uBAAoB;AACxC,OAAO,EAAE,YAAY,EAAE,0BAAuB;AAC9C,OAAO,EAAE,aAAa,EAAE,2BAAwB;AAChD,OAAO,EAAE,WAAW,EAAE,yBAAsB;AAC5C,OAAO,EACL,iBAAiB,EACjB,KAAK,cAAc,GACpB,qCAAkC;AACnC,OAAO,EACL,kBAAkB,EAClB,qBAAqB,GACtB,iCAA8B;AAE/B,YAAY,EAAE,sBAAsB,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAgB;AACzE,+BAA4B"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,2BAAwB;AAChD,OAAO,EAAE,aAAa,EAAE,2BAAwB;AAChD,OAAO,EAAE,SAAS,EAAE,uBAAoB;AACxC,OAAO,EAAE,YAAY,EAAE,0BAAuB;AAC9C,OAAO,EAAE,aAAa,EAAE,2BAAwB;AAChD,OAAO,EAAE,WAAW,EAAE,yBAAsB;AAC5C,OAAO,EACL,iBAAiB,GAElB,qCAAkC;AACnC,OAAO,EACL,kBAAkB,EAClB,qBAAqB,GACtB,iCAA8B;AAG/B,+BAA4B"}
|
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|