@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.
Files changed (54) hide show
  1. package/README.md +11 -47
  2. package/dist/DevToolsFrame.d.ts +9 -6
  3. package/dist/DevToolsFrame.d.ts.map +1 -1
  4. package/dist/DevToolsFrame.js +33 -24
  5. package/dist/DevToolsFrame.js.map +1 -1
  6. package/dist/DevToolsHost.d.ts +31 -29
  7. package/dist/DevToolsHost.d.ts.map +1 -1
  8. package/dist/DevToolsHost.js +81 -99
  9. package/dist/DevToolsHost.js.map +1 -1
  10. package/dist/DevToolsModal.d.ts +4 -1
  11. package/dist/DevToolsModal.d.ts.map +1 -1
  12. package/dist/DevToolsModal.js +132 -77
  13. package/dist/DevToolsModal.js.map +1 -1
  14. package/dist/ExtensionHost.d.ts +8 -5
  15. package/dist/ExtensionHost.d.ts.map +1 -1
  16. package/dist/ExtensionHost.js +40 -44
  17. package/dist/ExtensionHost.js.map +1 -1
  18. package/dist/FrameClient.d.ts +29 -27
  19. package/dist/FrameClient.d.ts.map +1 -1
  20. package/dist/FrameClient.js +52 -55
  21. package/dist/FrameClient.js.map +1 -1
  22. package/dist/FrameHost.d.ts +9 -6
  23. package/dist/FrameHost.d.ts.map +1 -1
  24. package/dist/FrameHost.js +24 -25
  25. package/dist/FrameHost.js.map +1 -1
  26. package/dist/constants.d.ts +5 -2
  27. package/dist/constants.d.ts.map +1 -1
  28. package/dist/constants.js +6 -2
  29. package/dist/constants.js.map +1 -1
  30. package/dist/index.d.ts +11 -11
  31. package/dist/index.js +10 -10
  32. package/dist/styles/DevToolsModal.styles.d.ts +16 -12
  33. package/dist/styles/DevToolsModal.styles.d.ts.map +1 -1
  34. package/dist/styles/DevToolsModal.styles.js +101 -103
  35. package/dist/styles/DevToolsModal.styles.js.map +1 -1
  36. package/dist/types.d.ts +12 -8
  37. package/dist/types.d.ts.map +1 -1
  38. package/dist/types.js +0 -2
  39. package/dist/utils/serialization.d.ts +7 -3
  40. package/dist/utils/serialization.d.ts.map +1 -1
  41. package/dist/utils/serialization.js +48 -76
  42. package/dist/utils/serialization.js.map +1 -1
  43. package/dist/utils/toolNormalization.d.ts +10 -7
  44. package/dist/utils/toolNormalization.d.ts.map +1 -1
  45. package/dist/utils/toolNormalization.js +38 -48
  46. package/dist/utils/toolNormalization.js.map +1 -1
  47. package/package.json +11 -11
  48. package/src/DevToolsModal.tsx +7 -1
  49. package/src/FrameClient.ts +2 -0
  50. package/src/utils/serialization.ts +7 -7
  51. package/src/utils/toolNormalization.ts +10 -10
  52. package/dist/index.d.ts.map +0 -1
  53. package/dist/index.js.map +0 -1
  54. package/dist/types.js.map +0 -1
@@ -1,80 +1,52 @@
1
1
  import { normalizeToolList } from "./toolNormalization.js";
2
- export const sanitizeForMessage = (value, seen = new WeakSet()) => {
3
- // Early return for primitives
4
- if (value === null || value === undefined)
5
- return value;
6
- if (typeof value === "string" ||
7
- typeof value === "number" ||
8
- typeof value === "boolean") {
9
- return value;
10
- }
11
- if (typeof value === "function") {
12
- return "[Function]";
13
- }
14
- if (value instanceof Date) {
15
- return value.toISOString();
16
- }
17
- if (value instanceof Map) {
18
- const result = {};
19
- for (const [key, entry] of value.entries()) {
20
- result[String(key)] = sanitizeForMessage(entry, seen);
21
- }
22
- return result;
23
- }
24
- if (value instanceof Set) {
25
- return Array.from(value).map((entry) => sanitizeForMessage(entry, seen));
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
- export const serializeModelContext = (context) => {
48
- if (!context || typeof context !== "object") {
49
- return undefined;
50
- }
51
- const modelContext = context;
52
- const result = {};
53
- const systemValue = modelContext["system"];
54
- if (typeof systemValue === "string" && systemValue.length > 0) {
55
- result.system = systemValue;
56
- }
57
- const tools = normalizeToolList(modelContext["tools"]);
58
- if (tools.length > 0) {
59
- result.tools = tools.map((tool) => ({
60
- ...tool,
61
- parameters: sanitizeForMessage(tool.parameters),
62
- }));
63
- }
64
- if (modelContext["callSettings"] !== undefined) {
65
- const callSettings = sanitizeForMessage(modelContext["callSettings"]);
66
- if (callSettings &&
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","sourceRoot":"","sources":["../../src/utils/serialization.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,+BAA4B;AAExD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,KAAc,EACd,OAAO,IAAI,OAAO,EAAU,EACnB,EAAE;IACX,8BAA8B;IAC9B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACxD,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS,EAC1B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC;IACD,IAAI,KAA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,QAAQ,CAAC,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,kBAAkB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC1D,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACnE,MAAM,CAAC,MAAM,GAAG,MAAiC,CAAC;QACpD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7D,CAAC,CAAC"}
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,G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4
- description?: string;
5
- disabled?: boolean;
6
- parameters?: unknown;
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
- export declare const normalizeToolList: (value: unknown) => NormalizedTool[];
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","sourceRoot":"","sources":["../../src/utils/toolNormalization.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AA0CF,eAAO,MAAM,iBAAiB,GAAI,OAAO,OAAO,KAAG,cAAc,EAgChE,CAAC"}
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
- if (value instanceof z.ZodType) {
5
- try {
6
- return z.toJSONSchema(value);
7
- }
8
- catch {
9
- return value;
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
- const tool = { name };
16
- if (typeof raw["type"] === "string") {
17
- tool.type = raw["type"];
18
- }
19
- if (typeof raw["description"] === "string") {
20
- tool.description = raw["description"];
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
- export const normalizeToolList = (value) => {
31
- if (!value || typeof value !== "object") {
32
- return [];
33
- }
34
- if (Array.isArray(value)) {
35
- const tools = [];
36
- for (const entry of value) {
37
- if (!isRecord(entry) || typeof entry["name"] !== "string")
38
- continue;
39
- tools.push(mapToNormalizedTool(entry["name"], entry));
40
- }
41
- return tools;
42
- }
43
- if (isRecord(value)) {
44
- const tools = [];
45
- for (const [name, entry] of Object.entries(value)) {
46
- if (!isRecord(entry)) {
47
- tools.push({ name });
48
- continue;
49
- }
50
- tools.push(mapToNormalizedTool(name, entry));
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","sourceRoot":"","sources":["../../src/utils/toolNormalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CACpE,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAE9C,MAAM,YAAY,GAAG,CAAC,KAAc,EAAW,EAAE;IAC/C,IAAI,KAAK,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC;YACH,OAAO,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAC1B,IAAY,EACZ,GAA4B,EACZ,EAAE;IAClB,MAAM,IAAI,GAAmB,EAAE,IAAI,EAAE,CAAC;IAEtC,IAAI,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,QAAQ,EAAE,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAW,CAAC;IACpC,CAAC;IAED,IAAI,OAAO,GAAG,CAAC,aAAa,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC3C,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC,aAAa,CAAW,CAAC;IAClD,CAAC;IAED,IAAI,OAAO,GAAG,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAY,CAAC;IAC7C,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,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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.0.6",
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.6"
30
+ "zod": "^4.4.3"
31
31
  },
32
32
  "peerDependencies": {
33
- "@assistant-ui/react": "^0.12.25",
34
- "@assistant-ui/tap": "^0.5.8",
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.6.0",
50
- "@types/react": "^19.2.14",
49
+ "@types/node": "^25.9.1",
50
+ "@types/react": "^19.2.15",
51
51
  "@types/react-dom": "^19.2.3",
52
- "react": "^19.2.5",
53
- "react-dom": "^19.2.5",
54
- "@assistant-ui/react": "0.12.25",
55
- "@assistant-ui/tap": "0.5.8",
56
- "@assistant-ui/x-buildutils": "0.0.5"
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",
@@ -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?.["NODE_ENV"] === "production"
185
+ process.env?.NODE_ENV === "production"
180
186
  ) {
181
187
  return null;
182
188
  }
@@ -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["system"];
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["tools"]);
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["callSettings"] !== undefined) {
79
- const callSettings = sanitizeForMessage(modelContext["callSettings"]);
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["config"] !== undefined) {
90
- const config = sanitizeForMessage(modelContext["config"]);
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["type"] === "string") {
33
- tool.type = raw["type"] as string;
32
+ if (typeof raw.type === "string") {
33
+ tool.type = raw.type as string;
34
34
  }
35
35
 
36
- if (typeof raw["description"] === "string") {
37
- tool.description = raw["description"] as string;
36
+ if (typeof raw.description === "string") {
37
+ tool.description = raw.description as string;
38
38
  }
39
39
 
40
- if (typeof raw["disabled"] === "boolean") {
41
- tool.disabled = raw["disabled"] as boolean;
40
+ if (typeof raw.disabled === "boolean") {
41
+ tool.disabled = raw.disabled as boolean;
42
42
  }
43
43
 
44
- if (Object.prototype.hasOwnProperty.call(raw, "parameters")) {
45
- tool.parameters = toJsonSchema(raw["parameters"]);
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["name"] !== "string") continue;
61
- tools.push(mapToNormalizedTool(entry["name"] as string, 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;
@@ -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":""}