@assistant-ui/react-devtools 1.2.3 → 1.2.5
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/dist/DevToolsFrame.js +49 -21
- package/dist/DevToolsFrame.js.map +1 -1
- package/dist/DevToolsHost.js.map +1 -1
- package/dist/DevToolsModal.js +200 -99
- package/dist/DevToolsModal.js.map +1 -1
- package/dist/ExtensionHost.js.map +1 -1
- package/dist/FrameClient.js.map +1 -1
- package/dist/FrameHost.js.map +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/styles/DevToolsModal.styles.js.map +1 -1
- package/dist/utils/serialization.js.map +1 -1
- package/dist/utils/toolNormalization.js.map +1 -1
- package/package.json +5 -5
package/dist/DevToolsFrame.js
CHANGED
|
@@ -1,36 +1,64 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { FrameHost } from "./FrameHost.js";
|
|
3
3
|
import { DEFAULT_FRAME_URL } from "./constants.js";
|
|
4
|
-
import {
|
|
4
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
|
+
import { useEffect, useRef } from "@assistant-ui/tap/react-shim";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
6
7
|
//#region src/DevToolsFrame.tsx
|
|
7
|
-
const DevToolsFrame = (
|
|
8
|
+
const DevToolsFrame = (t0) => {
|
|
9
|
+
const $ = c(8);
|
|
10
|
+
const { frameUrl: t1, className, style, title: t2 } = t0;
|
|
11
|
+
const frameUrl = t1 === void 0 ? DEFAULT_FRAME_URL : t1;
|
|
12
|
+
const title = t2 === void 0 ? "assistant-ui DevTools" : t2;
|
|
8
13
|
const iframeRef = useRef(null);
|
|
9
14
|
const frameHostRef = useRef(null);
|
|
10
|
-
const resolvedFrameUrl =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
frameHostRef.current = null;
|
|
15
|
-
}
|
|
16
|
-
if (iframeRef.current) frameHostRef.current = new FrameHost(iframeRef.current);
|
|
17
|
-
}, []);
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
return () => {
|
|
15
|
+
const resolvedFrameUrl = frameUrl;
|
|
16
|
+
let t3;
|
|
17
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
18
|
+
t3 = () => {
|
|
20
19
|
if (frameHostRef.current) {
|
|
21
20
|
frameHostRef.current.destroy();
|
|
22
21
|
frameHostRef.current = null;
|
|
23
22
|
}
|
|
23
|
+
if (iframeRef.current) frameHostRef.current = new FrameHost(iframeRef.current);
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
$[0] = t3;
|
|
26
|
+
} else t3 = $[0];
|
|
27
|
+
const handleFrameLoad = t3;
|
|
28
|
+
let t4;
|
|
29
|
+
let t5;
|
|
30
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
31
|
+
t4 = () => () => {
|
|
32
|
+
if (frameHostRef.current) {
|
|
33
|
+
frameHostRef.current.destroy();
|
|
34
|
+
frameHostRef.current = null;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
t5 = [];
|
|
38
|
+
$[1] = t4;
|
|
39
|
+
$[2] = t5;
|
|
40
|
+
} else {
|
|
41
|
+
t4 = $[1];
|
|
42
|
+
t5 = $[2];
|
|
43
|
+
}
|
|
44
|
+
useEffect(t4, t5);
|
|
45
|
+
let t6;
|
|
46
|
+
if ($[3] !== className || $[4] !== resolvedFrameUrl || $[5] !== style || $[6] !== title) {
|
|
47
|
+
t6 = /* @__PURE__ */ jsx("iframe", {
|
|
48
|
+
ref: iframeRef,
|
|
49
|
+
src: resolvedFrameUrl,
|
|
50
|
+
onLoad: handleFrameLoad,
|
|
51
|
+
className,
|
|
52
|
+
style,
|
|
53
|
+
title
|
|
54
|
+
});
|
|
55
|
+
$[3] = className;
|
|
56
|
+
$[4] = resolvedFrameUrl;
|
|
57
|
+
$[5] = style;
|
|
58
|
+
$[6] = title;
|
|
59
|
+
$[7] = t6;
|
|
60
|
+
} else t6 = $[7];
|
|
61
|
+
return t6;
|
|
34
62
|
};
|
|
35
63
|
//#endregion
|
|
36
64
|
export { DevToolsFrame };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DevToolsFrame.js","names":[],"sources":["../src/DevToolsFrame.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { FrameHost } from \"./FrameHost\";\nimport { DEFAULT_FRAME_URL } from \"./constants\";\n\nexport interface DevToolsFrameProps {\n frameUrl?: string;\n className?: string;\n style?: React.CSSProperties;\n title?: string;\n}\n\nexport const DevToolsFrame: React.FC<DevToolsFrameProps> = ({\n frameUrl = DEFAULT_FRAME_URL,\n className,\n style,\n title = \"assistant-ui DevTools\",\n}) => {\n const iframeRef = useRef<HTMLIFrameElement | null>(null);\n const frameHostRef = useRef<FrameHost | null>(null);\n\n const resolvedFrameUrl = useMemo(() => frameUrl, [frameUrl]);\n\n const handleFrameLoad = useCallback(() => {\n if (frameHostRef.current) {\n frameHostRef.current.destroy();\n frameHostRef.current = null;\n }\n\n if (iframeRef.current) {\n frameHostRef.current = new FrameHost(iframeRef.current);\n }\n }, []);\n\n useEffect(() => {\n return () => {\n if (frameHostRef.current) {\n frameHostRef.current.destroy();\n frameHostRef.current = null;\n }\n };\n }, []);\n\n return (\n <iframe\n ref={iframeRef}\n src={resolvedFrameUrl}\n onLoad={handleFrameLoad}\n className={className}\n style={style}\n title={title}\n />\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DevToolsFrame.js","names":["c","_c","useCallback","useEffect","useMemo","useRef","FrameHost","DEFAULT_FRAME_URL","DevToolsFrameProps","frameUrl","className","style","React","CSSProperties","title","DevToolsFrame","FC","t0","$","t1","t2","undefined","iframeRef","frameHostRef","resolvedFrameUrl","t3","Symbol","for","current","destroy","handleFrameLoad","t4","t5","t6"],"sources":["../src/DevToolsFrame.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { FrameHost } from \"./FrameHost\";\nimport { DEFAULT_FRAME_URL } from \"./constants\";\n\nexport interface DevToolsFrameProps {\n frameUrl?: string;\n className?: string;\n style?: React.CSSProperties;\n title?: string;\n}\n\nexport const DevToolsFrame: React.FC<DevToolsFrameProps> = ({\n frameUrl = DEFAULT_FRAME_URL,\n className,\n style,\n title = \"assistant-ui DevTools\",\n}) => {\n const iframeRef = useRef<HTMLIFrameElement | null>(null);\n const frameHostRef = useRef<FrameHost | null>(null);\n\n const resolvedFrameUrl = useMemo(() => frameUrl, [frameUrl]);\n\n const handleFrameLoad = useCallback(() => {\n if (frameHostRef.current) {\n frameHostRef.current.destroy();\n frameHostRef.current = null;\n }\n\n if (iframeRef.current) {\n frameHostRef.current = new FrameHost(iframeRef.current);\n }\n }, []);\n\n useEffect(() => {\n return () => {\n if (frameHostRef.current) {\n frameHostRef.current.destroy();\n frameHostRef.current = null;\n }\n };\n }, []);\n\n return (\n <iframe\n ref={iframeRef}\n src={resolvedFrameUrl}\n onLoad={handleFrameLoad}\n className={className}\n style={style}\n title={title}\n />\n );\n};\n"],"mappings":";;;;;;;AAaA,MAAae,iBAA8CE,OAAA;CAAA,MAAAC,IAAAjB,EAAA,CAAA;CAAC,MAAA,EAAAQ,UAAAU,IAAAT,WAAAC,OAAAG,OAAAM,OAAAH;CAC1D,MAAAR,WAAAU,OAAAE,KAAAA,IAAAd,oBAAAY;CAGA,MAAAL,QAAAM,OAAAC,KAAAA,IAAA,0BAAAD;CAEA,MAAAE,YAAkBjB,OAAiC,IAAI;CACvD,MAAAkB,eAAqBlB,OAAyB,IAAI;CAElD,MAAAmB,mBAAuCf;CAAsB,IAAAgB;CAAA,IAAAP,EAAA,OAAAQ,OAAAC,IAAA,2BAAA,GAAA;EAEzBF,WAAA;GAClC,IAAIF,aAAYK,SAAQ;IACtBL,aAAYK,QAAQC,QAAS;IAC7BN,aAAYK,UAAW;GAAH;GAGtB,IAAIN,UAASM,SACXL,aAAYK,UAAW,IAAItB,UAAUgB,UAASM,OAAQ;EACvD;EACFV,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CATD,MAAAY,kBAAwBL;CASjB,IAAAM;CAAA,IAAAC;CAAA,IAAAd,EAAA,OAAAQ,OAAAC,IAAA,2BAAA,GAAA;EAEGI,iBACD;GACL,IAAIR,aAAYK,SAAQ;IACtBL,aAAYK,QAAQC,QAAS;IAC7BN,aAAYK,UAAW;GAAH;EACrB;EAEFI,KAAA,CAAA;EAAEd,EAAA,KAAAa;EAAAb,EAAA,KAAAc;CAAA,OAAA;EAAAD,KAAAb,EAAA;EAAAc,KAAAd,EAAA;CAAA;CAPLf,UAAU4B,IAOPC,EAAE;CAAC,IAAAC;CAAA,IAAAf,EAAA,OAAAR,aAAAQ,EAAA,OAAAM,oBAAAN,EAAA,OAAAP,SAAAO,EAAA,OAAAJ,OAAA;EAGJmB,KAAA,oBAAA,UAAA;GACOX,KAAAA;GACAE,KAAAA;GACGM,QAAAA;GACGpB;GACJC;GACAG;EAAK,CAAA;EACZI,EAAA,KAAAR;EAAAQ,EAAA,KAAAM;EAAAN,EAAA,KAAAP;EAAAO,EAAA,KAAAJ;EAAAI,EAAA,KAAAe;CAAA,OAAAA,KAAAf,EAAA;CAAA,OAPFe;AAOE"}
|
package/dist/DevToolsHost.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DevToolsHost.js","names":[],"sources":["../src/DevToolsHost.ts"],"sourcesContent":["import { DevToolsHooks } from \"@assistant-ui/react\";\nimport {\n sanitizeAndRedact,\n sanitizeForMessage,\n serializeModelContext,\n} from \"./utils/serialization\";\n\ninterface FrameToHostMessage {\n type: \"subscription\" | \"clearEvents\";\n data: {\n apiList?: boolean;\n apis?: number[];\n apiId?: number;\n };\n}\n\ninterface HostToFrameMessage {\n type: \"update\";\n data: {\n apiList?: Array<{ apiId: number }>;\n apis?: Array<{\n apiId: number;\n state: any;\n events: any[];\n modelContext?: any;\n scopes?: any;\n }>;\n };\n}\n\nexport class DevToolsHost {\n private subscription: {\n apiList: boolean;\n apis: Set<number>;\n } = {\n apiList: false,\n apis: new Set(),\n };\n private unsubscribe?: () => void;\n private onSendMessage: (message: HostToFrameMessage) => void;\n\n constructor(onSendMessage: (message: HostToFrameMessage) => void) {\n this.onSendMessage = onSendMessage;\n this.subscribeToDevTools();\n }\n\n onReceiveMessage(message: FrameToHostMessage) {\n switch (message.type) {\n case \"subscription\":\n this.handleSubscription(message.data);\n break;\n case \"clearEvents\":\n if (typeof message.data.apiId === \"number\") {\n DevToolsHooks.clearEventLogs(message.data.apiId);\n // The subscription will automatically trigger an update\n }\n break;\n }\n }\n\n private handleSubscription(data: FrameToHostMessage[\"data\"]) {\n const prevApiList = this.subscription.apiList;\n const prevApis = new Set(this.subscription.apis);\n\n this.subscription.apiList = data.apiList || false;\n this.subscription.apis = new Set(data.apis);\n\n // Only send update if subscription actually changed\n const apisChanged =\n prevApis.size !== this.subscription.apis.size ||\n [...this.subscription.apis].some((id) => !prevApis.has(id));\n\n if (prevApiList !== this.subscription.apiList || apisChanged) {\n this.sendUpdate();\n }\n }\n\n private subscribeToDevTools() {\n this.unsubscribe = DevToolsHooks.subscribe(() => {\n this.sendUpdate();\n });\n }\n\n private sendUpdate() {\n const update: HostToFrameMessage = {\n type: \"update\",\n data: {},\n };\n\n const allApis = DevToolsHooks.getApis();\n for (const subscriptionApiId of this.subscription.apis) {\n if (!allApis.has(subscriptionApiId)) {\n this.subscription.apis.delete(subscriptionApiId);\n }\n }\n\n if (this.subscription.apiList) {\n update.data.apiList = [...allApis.keys()].map((apiId) => ({ apiId }));\n\n if (this.subscription.apis.size === 0 && allApis.size > 0) {\n this.subscription.apis = new Set([allApis.keys().next().value!]);\n }\n }\n\n if (this.subscription.apis.size > 0) {\n update.data.apis = [];\n\n for (const apiId of this.subscription.apis) {\n const apiEntry = allApis.get(apiId);\n if (apiEntry) {\n // Collect root-scope state plus the identity and method catalog of\n // every accessor (root and derived) for the scope graph.\n const state: Record<string, unknown> = {};\n const scopes: Array<{\n name: string;\n source: string | null;\n query: Record<string, unknown> | null;\n methods: string[];\n }> = [];\n if (apiEntry.api) {\n for (const [name, scope] of Object.entries(apiEntry.api)) {\n if (typeof scope === \"function\" && \"source\" in scope) {\n let methods: string[] = [];\n try {\n const scopeValue = scope();\n if (scopeValue && typeof scopeValue === \"object\") {\n methods = Object.keys(scopeValue).filter(\n (key) =>\n typeof (scopeValue as Record<string, unknown>)[key] ===\n \"function\",\n );\n }\n if (scope.source === \"root\") {\n state[name] = scopeValue?.getState?.() ?? scopeValue;\n }\n } catch {\n // scope() may throw (derived scopes before the client is\n // mounted, or a broken root scope implementation).\n }\n scopes.push({\n name,\n source: scope.source,\n query: scope.query,\n methods,\n });\n }\n }\n }\n\n // Extract model context from thread runtime\n const modelContext = serializeModelContext(\n apiEntry.api?.thread?.().getModelContext(),\n );\n\n update.data.apis.push({\n apiId,\n state: sanitizeForMessage(state),\n events: sanitizeForMessage(apiEntry.logs) as unknown[],\n modelContext: modelContext,\n scopes: sanitizeAndRedact(scopes),\n });\n }\n }\n }\n\n if (Object.keys(update.data).length === 0) {\n return;\n }\n\n this.onSendMessage(update);\n }\n\n destroy() {\n if (this.unsubscribe) {\n this.unsubscribe();\n }\n }\n}\n"],"mappings":";;;AA8BA,
|
|
1
|
+
{"version":3,"file":"DevToolsHost.js","names":["DevToolsHooks","sanitizeAndRedact","sanitizeForMessage","serializeModelContext","FrameToHostMessage","type","data","apiList","apis","apiId","HostToFrameMessage","Array","state","events","modelContext","scopes","DevToolsHost","subscription","Set","unsubscribe","onSendMessage","message","constructor","subscribeToDevTools","onReceiveMessage","handleSubscription","clearEventLogs","prevApiList","prevApis","apisChanged","size","some","id","has","sendUpdate","subscribe","update","allApis","getApis","subscriptionApiId","delete","keys","map","next","value","apiEntry","get","Record","name","source","query","methods","api","scope","Object","entries","scopeValue","filter","key","getState","push","thread","getModelContext","logs","length","destroy"],"sources":["../src/DevToolsHost.ts"],"sourcesContent":["import { DevToolsHooks } from \"@assistant-ui/react\";\nimport {\n sanitizeAndRedact,\n sanitizeForMessage,\n serializeModelContext,\n} from \"./utils/serialization\";\n\ninterface FrameToHostMessage {\n type: \"subscription\" | \"clearEvents\";\n data: {\n apiList?: boolean;\n apis?: number[];\n apiId?: number;\n };\n}\n\ninterface HostToFrameMessage {\n type: \"update\";\n data: {\n apiList?: Array<{ apiId: number }>;\n apis?: Array<{\n apiId: number;\n state: any;\n events: any[];\n modelContext?: any;\n scopes?: any;\n }>;\n };\n}\n\nexport class DevToolsHost {\n private subscription: {\n apiList: boolean;\n apis: Set<number>;\n } = {\n apiList: false,\n apis: new Set(),\n };\n private unsubscribe?: () => void;\n private onSendMessage: (message: HostToFrameMessage) => void;\n\n constructor(onSendMessage: (message: HostToFrameMessage) => void) {\n this.onSendMessage = onSendMessage;\n this.subscribeToDevTools();\n }\n\n onReceiveMessage(message: FrameToHostMessage) {\n switch (message.type) {\n case \"subscription\":\n this.handleSubscription(message.data);\n break;\n case \"clearEvents\":\n if (typeof message.data.apiId === \"number\") {\n DevToolsHooks.clearEventLogs(message.data.apiId);\n // The subscription will automatically trigger an update\n }\n break;\n }\n }\n\n private handleSubscription(data: FrameToHostMessage[\"data\"]) {\n const prevApiList = this.subscription.apiList;\n const prevApis = new Set(this.subscription.apis);\n\n this.subscription.apiList = data.apiList || false;\n this.subscription.apis = new Set(data.apis);\n\n // Only send update if subscription actually changed\n const apisChanged =\n prevApis.size !== this.subscription.apis.size ||\n [...this.subscription.apis].some((id) => !prevApis.has(id));\n\n if (prevApiList !== this.subscription.apiList || apisChanged) {\n this.sendUpdate();\n }\n }\n\n private subscribeToDevTools() {\n this.unsubscribe = DevToolsHooks.subscribe(() => {\n this.sendUpdate();\n });\n }\n\n private sendUpdate() {\n const update: HostToFrameMessage = {\n type: \"update\",\n data: {},\n };\n\n const allApis = DevToolsHooks.getApis();\n for (const subscriptionApiId of this.subscription.apis) {\n if (!allApis.has(subscriptionApiId)) {\n this.subscription.apis.delete(subscriptionApiId);\n }\n }\n\n if (this.subscription.apiList) {\n update.data.apiList = [...allApis.keys()].map((apiId) => ({ apiId }));\n\n if (this.subscription.apis.size === 0 && allApis.size > 0) {\n this.subscription.apis = new Set([allApis.keys().next().value!]);\n }\n }\n\n if (this.subscription.apis.size > 0) {\n update.data.apis = [];\n\n for (const apiId of this.subscription.apis) {\n const apiEntry = allApis.get(apiId);\n if (apiEntry) {\n // Collect root-scope state plus the identity and method catalog of\n // every accessor (root and derived) for the scope graph.\n const state: Record<string, unknown> = {};\n const scopes: Array<{\n name: string;\n source: string | null;\n query: Record<string, unknown> | null;\n methods: string[];\n }> = [];\n if (apiEntry.api) {\n for (const [name, scope] of Object.entries(apiEntry.api)) {\n if (typeof scope === \"function\" && \"source\" in scope) {\n let methods: string[] = [];\n try {\n const scopeValue = scope();\n if (scopeValue && typeof scopeValue === \"object\") {\n methods = Object.keys(scopeValue).filter(\n (key) =>\n typeof (scopeValue as Record<string, unknown>)[key] ===\n \"function\",\n );\n }\n if (scope.source === \"root\") {\n state[name] = scopeValue?.getState?.() ?? scopeValue;\n }\n } catch {\n // scope() may throw (derived scopes before the client is\n // mounted, or a broken root scope implementation).\n }\n scopes.push({\n name,\n source: scope.source,\n query: scope.query,\n methods,\n });\n }\n }\n }\n\n // Extract model context from thread runtime\n const modelContext = serializeModelContext(\n apiEntry.api?.thread?.().getModelContext(),\n );\n\n update.data.apis.push({\n apiId,\n state: sanitizeForMessage(state),\n events: sanitizeForMessage(apiEntry.logs) as unknown[],\n modelContext: modelContext,\n scopes: sanitizeAndRedact(scopes),\n });\n }\n }\n }\n\n if (Object.keys(update.data).length === 0) {\n return;\n }\n\n this.onSendMessage(update);\n }\n\n destroy() {\n if (this.unsubscribe) {\n this.unsubscribe();\n }\n }\n}\n"],"mappings":";;;A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C;IACH;GACF;EACF;EAEA,IAAIuC,OAAOb,KAAKL,OAAO9B,IAAI,CAAC,CAAC0D,WAAW,GACtC;EAGF,KAAK5C,cAAcgB,MAAM;CAC3B;CAEA6B,UAAU;EACR,IAAI,KAAK9C,aACP,KAAKA,YAAY;CAErB;AACF"}
|
package/dist/DevToolsModal.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { DevToolsFrame } from "./DevToolsFrame.js";
|
|
3
3
|
import { ANIMATION_STYLES, getStyles } from "./styles/DevToolsModal.styles.js";
|
|
4
|
-
import {
|
|
4
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
|
+
import { useEffect, useState, useSyncExternalStore } from "@assistant-ui/tap/react-shim";
|
|
5
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
//#region src/DevToolsModal.tsx
|
|
7
8
|
const isDarkMode = () => {
|
|
@@ -22,120 +23,220 @@ const subscribeToThemeChanges = (callback) => {
|
|
|
22
23
|
return () => observer.disconnect();
|
|
23
24
|
};
|
|
24
25
|
const DevToolsModalImpl = () => {
|
|
26
|
+
const $ = c(32);
|
|
25
27
|
const [isOpen, setIsOpen] = useState(false);
|
|
26
28
|
const [buttonHover, setButtonHover] = useState(false);
|
|
27
29
|
const [closeHover, setCloseHover] = useState(false);
|
|
28
|
-
const darkMode = useSyncExternalStore(subscribeToThemeChanges, isDarkMode,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
const darkMode = useSyncExternalStore(subscribeToThemeChanges, isDarkMode, _temp);
|
|
31
|
+
let t0;
|
|
32
|
+
if ($[0] !== darkMode) {
|
|
33
|
+
t0 = getStyles(darkMode);
|
|
34
|
+
$[0] = darkMode;
|
|
35
|
+
$[1] = t0;
|
|
36
|
+
} else t0 = $[1];
|
|
37
|
+
const styles = t0;
|
|
38
|
+
let t1;
|
|
39
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
40
|
+
t1 = [];
|
|
41
|
+
$[2] = t1;
|
|
42
|
+
} else t1 = $[2];
|
|
43
|
+
useEffect(_temp3, t1);
|
|
44
|
+
let t2;
|
|
45
|
+
let t3;
|
|
46
|
+
if ($[3] !== isOpen) {
|
|
47
|
+
t2 = () => {
|
|
48
|
+
if (!isOpen) return;
|
|
49
|
+
const handleEscape = (event) => {
|
|
50
|
+
if (event.key === "Escape") setIsOpen(false);
|
|
51
|
+
};
|
|
52
|
+
document.addEventListener("keydown", handleEscape);
|
|
53
|
+
return () => document.removeEventListener("keydown", handleEscape);
|
|
42
54
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
55
|
+
t3 = [isOpen];
|
|
56
|
+
$[3] = isOpen;
|
|
57
|
+
$[4] = t2;
|
|
58
|
+
$[5] = t3;
|
|
59
|
+
} else {
|
|
60
|
+
t2 = $[4];
|
|
61
|
+
t3 = $[5];
|
|
62
|
+
}
|
|
63
|
+
useEffect(t2, t3);
|
|
64
|
+
let t4;
|
|
65
|
+
let t5;
|
|
66
|
+
let t6;
|
|
67
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
68
|
+
t4 = () => setIsOpen(true);
|
|
69
|
+
t5 = () => setButtonHover(true);
|
|
70
|
+
t6 = () => setButtonHover(false);
|
|
71
|
+
$[6] = t4;
|
|
72
|
+
$[7] = t5;
|
|
73
|
+
$[8] = t6;
|
|
74
|
+
} else {
|
|
75
|
+
t4 = $[6];
|
|
76
|
+
t5 = $[7];
|
|
77
|
+
t6 = $[8];
|
|
78
|
+
}
|
|
79
|
+
let t7;
|
|
80
|
+
if ($[9] !== buttonHover || $[10] !== styles.floatingButtonHover) {
|
|
81
|
+
t7 = buttonHover ? styles.floatingButtonHover : {};
|
|
82
|
+
$[9] = buttonHover;
|
|
83
|
+
$[10] = styles.floatingButtonHover;
|
|
84
|
+
$[11] = t7;
|
|
85
|
+
} else t7 = $[11];
|
|
86
|
+
let t8;
|
|
87
|
+
if ($[12] !== styles.floatingButton || $[13] !== t7) {
|
|
88
|
+
t8 = {
|
|
89
|
+
...styles.floatingButton,
|
|
90
|
+
...t7
|
|
48
91
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
92
|
+
$[12] = styles.floatingButton;
|
|
93
|
+
$[13] = t7;
|
|
94
|
+
$[14] = t8;
|
|
95
|
+
} else t8 = $[14];
|
|
96
|
+
let t9;
|
|
97
|
+
if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
|
|
98
|
+
t9 = /* @__PURE__ */ jsx("svg", {
|
|
99
|
+
"aria-hidden": "true",
|
|
100
|
+
width: "20",
|
|
101
|
+
height: "20",
|
|
102
|
+
viewBox: "0 0 24 24",
|
|
103
|
+
fill: "none",
|
|
104
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
59
105
|
style: {
|
|
60
|
-
|
|
61
|
-
|
|
106
|
+
width: "20px",
|
|
107
|
+
height: "20px"
|
|
62
108
|
},
|
|
109
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
110
|
+
d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",
|
|
111
|
+
stroke: "currentColor",
|
|
112
|
+
strokeWidth: "1.8",
|
|
113
|
+
strokeLinecap: "round",
|
|
114
|
+
strokeLinejoin: "round",
|
|
115
|
+
fill: "none"
|
|
116
|
+
})
|
|
117
|
+
});
|
|
118
|
+
$[15] = t9;
|
|
119
|
+
} else t9 = $[15];
|
|
120
|
+
let t10;
|
|
121
|
+
if ($[16] !== t8) {
|
|
122
|
+
t10 = /* @__PURE__ */ jsx("button", {
|
|
123
|
+
type: "button",
|
|
124
|
+
onClick: t4,
|
|
125
|
+
onMouseEnter: t5,
|
|
126
|
+
onMouseLeave: t6,
|
|
127
|
+
style: t8,
|
|
63
128
|
"aria-label": "Open assistant-ui DevTools",
|
|
64
129
|
title: "Open assistant-ui DevTools",
|
|
65
|
-
children:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
130
|
+
children: t9
|
|
131
|
+
});
|
|
132
|
+
$[16] = t8;
|
|
133
|
+
$[17] = t10;
|
|
134
|
+
} else t10 = $[17];
|
|
135
|
+
let t11;
|
|
136
|
+
if ($[18] !== styles.floatingContainer || $[19] !== t10) {
|
|
137
|
+
t11 = /* @__PURE__ */ jsx("div", {
|
|
138
|
+
style: styles.floatingContainer,
|
|
139
|
+
children: t10
|
|
140
|
+
});
|
|
141
|
+
$[18] = styles.floatingContainer;
|
|
142
|
+
$[19] = t10;
|
|
143
|
+
$[20] = t11;
|
|
144
|
+
} else t11 = $[20];
|
|
145
|
+
let t12;
|
|
146
|
+
if ($[21] !== closeHover || $[22] !== isOpen || $[23] !== styles.backdrop || $[24] !== styles.dismissButton || $[25] !== styles.dismissButtonHover || $[26] !== styles.modal || $[27] !== styles.modalContent) {
|
|
147
|
+
t12 = isOpen && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
148
|
+
style: styles.backdrop,
|
|
149
|
+
onClick: () => setIsOpen(false)
|
|
150
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
151
|
+
style: styles.modal,
|
|
152
|
+
"data-devtools-modal": true,
|
|
153
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
154
|
+
type: "button",
|
|
155
|
+
onClick: () => setIsOpen(false),
|
|
156
|
+
onMouseEnter: () => setCloseHover(true),
|
|
157
|
+
onMouseLeave: () => setCloseHover(false),
|
|
72
158
|
style: {
|
|
73
|
-
|
|
74
|
-
|
|
159
|
+
...styles.dismissButton,
|
|
160
|
+
...closeHover ? styles.dismissButtonHover : {}
|
|
75
161
|
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
fill: "none"
|
|
162
|
+
"aria-label": "Close DevTools",
|
|
163
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
164
|
+
"aria-hidden": "true",
|
|
165
|
+
width: "14",
|
|
166
|
+
height: "14",
|
|
167
|
+
viewBox: "0 0 24 24",
|
|
168
|
+
fill: "none",
|
|
169
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
170
|
+
children: [/* @__PURE__ */ jsx("path", {
|
|
171
|
+
d: "M18 6L6 18",
|
|
172
|
+
stroke: "currentColor",
|
|
173
|
+
strokeWidth: "1.6",
|
|
174
|
+
strokeLinecap: "round",
|
|
175
|
+
strokeLinejoin: "round"
|
|
176
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
177
|
+
d: "M6 6L18 18",
|
|
178
|
+
stroke: "currentColor",
|
|
179
|
+
strokeWidth: "1.6",
|
|
180
|
+
strokeLinecap: "round",
|
|
181
|
+
strokeLinejoin: "round"
|
|
182
|
+
})]
|
|
83
183
|
})
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
strokeWidth: "1.6",
|
|
113
|
-
strokeLinecap: "round",
|
|
114
|
-
strokeLinejoin: "round"
|
|
115
|
-
}), /* @__PURE__ */ jsx("path", {
|
|
116
|
-
d: "M6 6L18 18",
|
|
117
|
-
stroke: "currentColor",
|
|
118
|
-
strokeWidth: "1.6",
|
|
119
|
-
strokeLinecap: "round",
|
|
120
|
-
strokeLinejoin: "round"
|
|
121
|
-
})]
|
|
122
|
-
})
|
|
123
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
124
|
-
style: styles.modalContent,
|
|
125
|
-
children: /* @__PURE__ */ jsx(DevToolsFrame, { style: {
|
|
126
|
-
width: "100%",
|
|
127
|
-
height: "100%",
|
|
128
|
-
border: "none",
|
|
129
|
-
borderRadius: "12px",
|
|
130
|
-
backgroundColor: "transparent"
|
|
131
|
-
} })
|
|
132
|
-
})]
|
|
133
|
-
})] })] });
|
|
184
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
185
|
+
style: styles.modalContent,
|
|
186
|
+
children: /* @__PURE__ */ jsx(DevToolsFrame, { style: {
|
|
187
|
+
width: "100%",
|
|
188
|
+
height: "100%",
|
|
189
|
+
border: "none",
|
|
190
|
+
borderRadius: "12px",
|
|
191
|
+
backgroundColor: "transparent"
|
|
192
|
+
} })
|
|
193
|
+
})]
|
|
194
|
+
})] });
|
|
195
|
+
$[21] = closeHover;
|
|
196
|
+
$[22] = isOpen;
|
|
197
|
+
$[23] = styles.backdrop;
|
|
198
|
+
$[24] = styles.dismissButton;
|
|
199
|
+
$[25] = styles.dismissButtonHover;
|
|
200
|
+
$[26] = styles.modal;
|
|
201
|
+
$[27] = styles.modalContent;
|
|
202
|
+
$[28] = t12;
|
|
203
|
+
} else t12 = $[28];
|
|
204
|
+
let t13;
|
|
205
|
+
if ($[29] !== t11 || $[30] !== t12) {
|
|
206
|
+
t13 = /* @__PURE__ */ jsxs(Fragment, { children: [t11, t12] });
|
|
207
|
+
$[29] = t11;
|
|
208
|
+
$[30] = t12;
|
|
209
|
+
$[31] = t13;
|
|
210
|
+
} else t13 = $[31];
|
|
211
|
+
return t13;
|
|
134
212
|
};
|
|
135
213
|
const DevToolsModal = () => {
|
|
214
|
+
const $ = c(1);
|
|
136
215
|
if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") return null;
|
|
137
|
-
|
|
216
|
+
let t0;
|
|
217
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
218
|
+
t0 = /* @__PURE__ */ jsx(DevToolsModalImpl, {});
|
|
219
|
+
$[0] = t0;
|
|
220
|
+
} else t0 = $[0];
|
|
221
|
+
return t0;
|
|
138
222
|
};
|
|
223
|
+
function _temp() {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
function _temp2() {
|
|
227
|
+
const style_0 = document.getElementById("devtools-modal-animations");
|
|
228
|
+
if (style_0 && !document.querySelector("[data-devtools-modal]")) style_0.remove();
|
|
229
|
+
}
|
|
230
|
+
function _temp3() {
|
|
231
|
+
if (typeof document === "undefined") return;
|
|
232
|
+
if (!document.getElementById("devtools-modal-animations")) {
|
|
233
|
+
const style = document.createElement("style");
|
|
234
|
+
style.id = "devtools-modal-animations";
|
|
235
|
+
style.textContent = ANIMATION_STYLES;
|
|
236
|
+
document.head.appendChild(style);
|
|
237
|
+
}
|
|
238
|
+
return _temp2;
|
|
239
|
+
}
|
|
139
240
|
//#endregion
|
|
140
241
|
export { DevToolsModal };
|
|
141
242
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DevToolsModal.js","names":[],"sources":["../src/DevToolsModal.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState, useSyncExternalStore } from \"react\";\nimport { DevToolsFrame } from \"./DevToolsFrame\";\nimport { getStyles, ANIMATION_STYLES } from \"./styles/DevToolsModal.styles\";\n\nconst isDarkMode = (): boolean => {\n if (typeof document === \"undefined\") return false;\n return (\n document.documentElement.classList.contains(\"dark\") ||\n document.body.classList.contains(\"dark\")\n );\n};\n\nconst subscribeToThemeChanges = (callback: () => void) => {\n if (typeof MutationObserver === \"undefined\") {\n return () => {};\n }\n\n const observer = new MutationObserver(callback);\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n });\n\n if (document.body !== document.documentElement) {\n observer.observe(document.body, {\n attributes: true,\n attributeFilter: [\"class\"],\n });\n }\n\n return () => observer.disconnect();\n};\n\nconst DevToolsModalImpl = () => {\n const [isOpen, setIsOpen] = useState(false);\n const [buttonHover, setButtonHover] = useState(false);\n const [closeHover, setCloseHover] = useState(false);\n\n const darkMode = useSyncExternalStore(\n subscribeToThemeChanges,\n isDarkMode,\n () => false, // Server-side always returns false\n );\n\n const styles = useMemo(() => getStyles(darkMode), [darkMode]);\n\n useEffect(() => {\n if (typeof document === \"undefined\") return;\n\n const styleId = \"devtools-modal-animations\";\n if (!document.getElementById(styleId)) {\n const style = document.createElement(\"style\");\n style.id = styleId;\n style.textContent = ANIMATION_STYLES;\n document.head.appendChild(style);\n }\n\n return () => {\n const style = document.getElementById(styleId);\n if (style && !document.querySelector(\"[data-devtools-modal]\")) {\n style.remove();\n }\n };\n }, []);\n\n useEffect(() => {\n if (!isOpen) return;\n\n const handleEscape = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n setIsOpen(false);\n }\n };\n\n document.addEventListener(\"keydown\", handleEscape);\n return () => document.removeEventListener(\"keydown\", handleEscape);\n }, [isOpen]);\n\n return (\n <>\n <div style={styles.floatingContainer}>\n <button\n type=\"button\"\n onClick={() => setIsOpen(true)}\n onMouseEnter={() => setButtonHover(true)}\n onMouseLeave={() => setButtonHover(false)}\n style={{\n ...styles.floatingButton,\n ...(buttonHover ? styles.floatingButtonHover : {}),\n }}\n aria-label=\"Open assistant-ui DevTools\"\n title=\"Open assistant-ui DevTools\"\n >\n <svg\n aria-hidden=\"true\"\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n style={{ width: \"20px\", height: \"20px\" }}\n >\n <path\n d=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n fill=\"none\"\n />\n </svg>\n </button>\n </div>\n\n {isOpen && (\n <>\n <div style={styles.backdrop} onClick={() => setIsOpen(false)} />\n\n <div style={styles.modal} data-devtools-modal>\n <button\n type=\"button\"\n onClick={() => setIsOpen(false)}\n onMouseEnter={() => setCloseHover(true)}\n onMouseLeave={() => setCloseHover(false)}\n style={{\n ...styles.dismissButton,\n ...(closeHover ? styles.dismissButtonHover : {}),\n }}\n aria-label=\"Close DevTools\"\n >\n <svg\n aria-hidden=\"true\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M18 6L6 18\"\n stroke=\"currentColor\"\n strokeWidth=\"1.6\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M6 6L18 18\"\n stroke=\"currentColor\"\n strokeWidth=\"1.6\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </button>\n\n <div style={styles.modalContent}>\n <DevToolsFrame\n style={{\n width: \"100%\",\n height: \"100%\",\n border: \"none\",\n borderRadius: \"12px\",\n backgroundColor: \"transparent\",\n }}\n />\n </div>\n </div>\n </>\n )}\n </>\n );\n};\n\n// Export a component that only renders in development\nexport const DevToolsModal = () => {\n // Check if we're in production - most bundlers will replace process.env.NODE_ENV\n // This allows the entire component to be eliminated via dead code elimination\n if (\n typeof process !== \"undefined\" &&\n process.env?.NODE_ENV === \"production\"\n ) {\n return null;\n }\n\n return <DevToolsModalImpl />;\n};\n"],"mappings":";;;;;;AAMA,MAAM,mBAA4B;CAChC,IAAI,OAAO,aAAa,aAAa,OAAO;CAC5C,OACE,SAAS,gBAAgB,UAAU,SAAS,MAAM,KAClD,SAAS,KAAK,UAAU,SAAS,MAAM;AAE3C;AAEA,MAAM,2BAA2B,aAAyB;CAC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AA;EACE,CAAA,CACF;GACL,EAAA,CAAA,CAEJ,EAAA,CAAA;AAEN;AAGA,MAAa,sBAAsB;CAGjC,IACE,OAAO,YAAY,eACnB,QAAQ,KAAK,aAAa,cAE1B,OAAO;CAGT,OAAO,oBAAC,mBAAD,CAAoB,CAAA;AAC7B"}
|
|
1
|
+
{"version":3,"file":"DevToolsModal.js","names":["c","_c","useEffect","useMemo","useState","useSyncExternalStore","DevToolsFrame","getStyles","ANIMATION_STYLES","isDarkMode","document","documentElement","classList","contains","body","subscribeToThemeChanges","callback","MutationObserver","observer","observe","attributes","attributeFilter","disconnect","DevToolsModalImpl","$","isOpen","setIsOpen","buttonHover","setButtonHover","closeHover","setCloseHover","darkMode","_temp","t0","styles","t1","Symbol","for","_temp3","t2","t3","handleEscape","event","key","addEventListener","removeEventListener","t4","t5","t6","t7","floatingButtonHover","t8","floatingButton","t9","width","height","t10","t11","floatingContainer","t12","backdrop","dismissButton","dismissButtonHover","modal","modalContent","border","borderRadius","backgroundColor","t13","DevToolsModal","process","env","NODE_ENV","_temp2","style_0","getElementById","querySelector","style","remove","createElement","id","textContent","head","appendChild"],"sources":["../src/DevToolsModal.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useState, useSyncExternalStore } from \"react\";\nimport { DevToolsFrame } from \"./DevToolsFrame\";\nimport { getStyles, ANIMATION_STYLES } from \"./styles/DevToolsModal.styles\";\n\nconst isDarkMode = (): boolean => {\n if (typeof document === \"undefined\") return false;\n return (\n document.documentElement.classList.contains(\"dark\") ||\n document.body.classList.contains(\"dark\")\n );\n};\n\nconst subscribeToThemeChanges = (callback: () => void) => {\n if (typeof MutationObserver === \"undefined\") {\n return () => {};\n }\n\n const observer = new MutationObserver(callback);\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n });\n\n if (document.body !== document.documentElement) {\n observer.observe(document.body, {\n attributes: true,\n attributeFilter: [\"class\"],\n });\n }\n\n return () => observer.disconnect();\n};\n\nconst DevToolsModalImpl = () => {\n const [isOpen, setIsOpen] = useState(false);\n const [buttonHover, setButtonHover] = useState(false);\n const [closeHover, setCloseHover] = useState(false);\n\n const darkMode = useSyncExternalStore(\n subscribeToThemeChanges,\n isDarkMode,\n () => false, // Server-side always returns false\n );\n\n const styles = useMemo(() => getStyles(darkMode), [darkMode]);\n\n useEffect(() => {\n if (typeof document === \"undefined\") return;\n\n const styleId = \"devtools-modal-animations\";\n if (!document.getElementById(styleId)) {\n const style = document.createElement(\"style\");\n style.id = styleId;\n style.textContent = ANIMATION_STYLES;\n document.head.appendChild(style);\n }\n\n return () => {\n const style = document.getElementById(styleId);\n if (style && !document.querySelector(\"[data-devtools-modal]\")) {\n style.remove();\n }\n };\n }, []);\n\n useEffect(() => {\n if (!isOpen) return;\n\n const handleEscape = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n setIsOpen(false);\n }\n };\n\n document.addEventListener(\"keydown\", handleEscape);\n return () => document.removeEventListener(\"keydown\", handleEscape);\n }, [isOpen]);\n\n return (\n <>\n <div style={styles.floatingContainer}>\n <button\n type=\"button\"\n onClick={() => setIsOpen(true)}\n onMouseEnter={() => setButtonHover(true)}\n onMouseLeave={() => setButtonHover(false)}\n style={{\n ...styles.floatingButton,\n ...(buttonHover ? styles.floatingButtonHover : {}),\n }}\n aria-label=\"Open assistant-ui DevTools\"\n title=\"Open assistant-ui DevTools\"\n >\n <svg\n aria-hidden=\"true\"\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n style={{ width: \"20px\", height: \"20px\" }}\n >\n <path\n d=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\"\n stroke=\"currentColor\"\n strokeWidth=\"1.8\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n fill=\"none\"\n />\n </svg>\n </button>\n </div>\n\n {isOpen && (\n <>\n <div style={styles.backdrop} onClick={() => setIsOpen(false)} />\n\n <div style={styles.modal} data-devtools-modal>\n <button\n type=\"button\"\n onClick={() => setIsOpen(false)}\n onMouseEnter={() => setCloseHover(true)}\n onMouseLeave={() => setCloseHover(false)}\n style={{\n ...styles.dismissButton,\n ...(closeHover ? styles.dismissButtonHover : {}),\n }}\n aria-label=\"Close DevTools\"\n >\n <svg\n aria-hidden=\"true\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M18 6L6 18\"\n stroke=\"currentColor\"\n strokeWidth=\"1.6\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M6 6L18 18\"\n stroke=\"currentColor\"\n strokeWidth=\"1.6\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </button>\n\n <div style={styles.modalContent}>\n <DevToolsFrame\n style={{\n width: \"100%\",\n height: \"100%\",\n border: \"none\",\n borderRadius: \"12px\",\n backgroundColor: \"transparent\",\n }}\n />\n </div>\n </div>\n </>\n )}\n </>\n );\n};\n\n// Export a component that only renders in development\nexport const DevToolsModal = () => {\n // Check if we're in production - most bundlers will replace process.env.NODE_ENV\n // This allows the entire component to be eliminated via dead code elimination\n if (\n typeof process !== \"undefined\" &&\n process.env?.NODE_ENV === \"production\"\n ) {\n return null;\n }\n\n return <DevToolsModalImpl />;\n};\n"],"mappings":";;;;;;;AAMA,MAAMS,mBAA4B;CAChC,IAAI,OAAOC,aAAa,aAAa,OAAO;CAC5C,OACEA,SAASC,gBAAgBC,UAAUC,SAAS,MAAM,KAClDH,SAASI,KAAKF,UAAUC,SAAS,MAAM;AAE3C;AAEA,MAAME,2BAA2BC,aAAyB;CACxD,IAAI,OAAOC,qBAAqB,aAC9B,aAAa,CAAC;CAGhB,MAAMC,WAAW,IAAID,iBAAiBD,QAAQ;CAE9CE,SAASC,QAAQT,SAASC,iBAAiB;EACzCS,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uBAAuB,GAC1DC,QAAKC,OAAQ;AACd;AA5BmB,SAAAxC,SAAA;CActB,IAAI,OAAO5B,aAAa,aAAW;CAGnC,IAAI,CAACA,SAAQiE,eADG,2BACoB,GAAC;EACnC,MAAAE,QAAcnE,SAAQqE,cAAe,OAAO;EAC5CF,MAAKG,KAHS;EAIdH,MAAKI,cAAezE;EACpBE,SAAQwE,KAAKC,YAAaN,KAAK;CAAC;CACjC,OAEMJ;AAKN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionHost.js","names":[],"sources":["../src/ExtensionHost.ts"],"sourcesContent":["import { DevToolsHost } from \"./DevToolsHost\";\n\nexport class ExtensionHost {\n private devToolsHost: DevToolsHost;\n private messageListener: (event: MessageEvent) => void;\n\n constructor() {\n // Create DevToolsHost with callback to send messages through extension\n this.devToolsHost = new DevToolsHost((message) => {\n console.log(\"[ExtensionHost] Sending message to iframe:\", message);\n window.postMessage(\n {\n source: \"assistant-ui-devtools-page\",\n payload: message,\n },\n \"*\",\n );\n });\n\n // Setup listener to forward messages from extension to DevToolsHost\n this.messageListener = (event: MessageEvent) => {\n if (event.source !== window) return;\n\n // Log ALL messages to see what's coming through\n if (event.data.source === \"assistant-ui-devtools-iframe\") {\n console.log(\"[ExtensionHost] Received message from iframe:\", {\n source: event.data.source,\n payload: event.data.payload,\n fullData: event.data,\n });\n this.devToolsHost.onReceiveMessage(event.data.payload);\n }\n };\n\n window.addEventListener(\"message\", this.messageListener);\n\n // Announce that a new host has connected\n // This tells the iframe to re-send its subscription\n setTimeout(() => {\n console.log(\"[ExtensionHost] Announcing connection to iframe\");\n window.postMessage(\n {\n source: \"assistant-ui-devtools-page\",\n payload: {\n type: \"host-connected\",\n },\n },\n \"*\",\n );\n }, 100);\n }\n\n destroy() {\n window.removeEventListener(\"message\", this.messageListener);\n this.devToolsHost.destroy();\n }\n}\n"],"mappings":";;AAEA,
|
|
1
|
+
{"version":3,"file":"ExtensionHost.js","names":["DevToolsHost","ExtensionHost","devToolsHost","messageListener","event","MessageEvent","constructor","message","console","log","window","postMessage","source","payload","data","fullData","onReceiveMessage","addEventListener","setTimeout","type","destroy","removeEventListener"],"sources":["../src/ExtensionHost.ts"],"sourcesContent":["import { DevToolsHost } from \"./DevToolsHost\";\n\nexport class ExtensionHost {\n private devToolsHost: DevToolsHost;\n private messageListener: (event: MessageEvent) => void;\n\n constructor() {\n // Create DevToolsHost with callback to send messages through extension\n this.devToolsHost = new DevToolsHost((message) => {\n console.log(\"[ExtensionHost] Sending message to iframe:\", message);\n window.postMessage(\n {\n source: \"assistant-ui-devtools-page\",\n payload: message,\n },\n \"*\",\n );\n });\n\n // Setup listener to forward messages from extension to DevToolsHost\n this.messageListener = (event: MessageEvent) => {\n if (event.source !== window) return;\n\n // Log ALL messages to see what's coming through\n if (event.data.source === \"assistant-ui-devtools-iframe\") {\n console.log(\"[ExtensionHost] Received message from iframe:\", {\n source: event.data.source,\n payload: event.data.payload,\n fullData: event.data,\n });\n this.devToolsHost.onReceiveMessage(event.data.payload);\n }\n };\n\n window.addEventListener(\"message\", this.messageListener);\n\n // Announce that a new host has connected\n // This tells the iframe to re-send its subscription\n setTimeout(() => {\n console.log(\"[ExtensionHost] Announcing connection to iframe\");\n window.postMessage(\n {\n source: \"assistant-ui-devtools-page\",\n payload: {\n type: \"host-connected\",\n },\n },\n \"*\",\n );\n }, 100);\n }\n\n destroy() {\n window.removeEventListener(\"message\", this.messageListener);\n this.devToolsHost.destroy();\n }\n}\n"],"mappings":";;AAEA,IAAaC,gBAAb,MAA2B;CACzB;CACA;CAEAK,cAAc;EAEZ,KAAKJ,eAAe,IAAIF,cAAcO,YAAY;GAChDC,QAAQC,IAAI,8CAA8CF,OAAO;GACjEG,OAAOC,YACL;IACEC,QAAQ;IACRC,SAASN;GACX,GACA,GACF;EACF,CAAC;EAGD,KAAKJ,mBAAmBC,UAAwB;GAC9C,IAAIA,MAAMQ,WAAWF,QAAQ;GAG7B,IAAIN,MAAMU,KAAKF,WAAW,gCAAgC;IACxDJ,QAAQC,IAAI,iDAAiD;KAC3DG,QAAQR,MAAMU,KAAKF;KACnBC,SAAST,MAAMU,KAAKD;KACpBE,UAAUX,MAAMU;IAClB,CAAC;IACD,KAAKZ,aAAac,iBAAiBZ,MAAMU,KAAKD,OAAO;GACvD;EACF;EAEAH,OAAOO,iBAAiB,WAAW,KAAKd,eAAe;EAIvDe,iBAAiB;GACfV,QAAQC,IAAI,iDAAiD;GAC7DC,OAAOC,YACL;IACEC,QAAQ;IACRC,SAAS,EACPM,MAAM,iBACR;GACF,GACA,GACF;EACF,GAAG,GAAG;CACR;CAEAC,UAAU;EACRV,OAAOW,oBAAoB,WAAW,KAAKlB,eAAe;EAC1D,KAAKD,aAAakB,QAAQ;CAC5B;AACF"}
|
package/dist/FrameClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrameClient.js","names":[],"sources":["../src/FrameClient.ts"],"sourcesContent":["interface ApiData {\n apiId: number;\n state: any;\n events: any[];\n modelContext?: any;\n scopes?: any;\n}\n\ninterface UpdateMessage {\n type: \"update\";\n data: {\n apiList?: Array<{ apiId: number }>;\n apis?: ApiData[];\n };\n}\n\ninterface HostConnectedMessage {\n type: \"host-connected\";\n}\n\ntype UpdateListener = (data: {\n apiList?: Array<{ apiId: number }>;\n apis?: ApiData[];\n}) => void;\n\nexport class FrameClient {\n private listeners = new Set<UpdateListener>();\n private connectionListeners = new Set<() => void>();\n private lastUpdate: {\n apiList?: Array<{ apiId: number }>;\n apis?: ApiData[];\n } = {};\n\n constructor() {\n this.setupMessageListener();\n }\n\n private setupMessageListener() {\n window.addEventListener(\"message\", (event) => {\n const message = event.data as UpdateMessage | HostConnectedMessage;\n\n if (message.type === \"update\") {\n this.lastUpdate = message.data;\n this.notifyListeners(message.data);\n } else if (message.type === \"host-connected\") {\n // Host has reconnected (page refresh), notify listeners to re-subscribe\n this.connectionListeners.forEach((listener) => listener());\n }\n });\n }\n\n onHostConnected(listener: () => void): () => void {\n this.connectionListeners.add(listener);\n return () => {\n this.connectionListeners.delete(listener);\n };\n }\n\n subscribe(listener: UpdateListener): () => void {\n this.listeners.add(listener);\n\n // Send the last update to the new listener\n if (this.lastUpdate.apiList || this.lastUpdate.apis) {\n listener(this.lastUpdate);\n }\n\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n setSubscription(options: { apiList?: boolean; apis?: number[] }) {\n window.parent.postMessage(\n {\n type: \"subscription\",\n data: options,\n },\n \"*\",\n );\n }\n\n clearEvents(apiId: number) {\n window.parent.postMessage(\n {\n type: \"clearEvents\",\n data: { apiId },\n },\n \"*\",\n );\n }\n\n private notifyListeners(data: UpdateMessage[\"data\"]) {\n this.listeners.forEach((listener) => listener(data));\n }\n\n getLastUpdate() {\n return this.lastUpdate;\n }\n}\n"],"mappings":";AAyBA,
|
|
1
|
+
{"version":3,"file":"FrameClient.js","names":["ApiData","apiId","state","events","modelContext","scopes","UpdateMessage","type","data","apiList","Array","apis","HostConnectedMessage","UpdateListener","FrameClient","listeners","Set","connectionListeners","lastUpdate","constructor","setupMessageListener","window","addEventListener","event","message","notifyListeners","forEach","listener","onHostConnected","add","delete","subscribe","setSubscription","options","parent","postMessage","clearEvents","getLastUpdate"],"sources":["../src/FrameClient.ts"],"sourcesContent":["interface ApiData {\n apiId: number;\n state: any;\n events: any[];\n modelContext?: any;\n scopes?: any;\n}\n\ninterface UpdateMessage {\n type: \"update\";\n data: {\n apiList?: Array<{ apiId: number }>;\n apis?: ApiData[];\n };\n}\n\ninterface HostConnectedMessage {\n type: \"host-connected\";\n}\n\ntype UpdateListener = (data: {\n apiList?: Array<{ apiId: number }>;\n apis?: ApiData[];\n}) => void;\n\nexport class FrameClient {\n private listeners = new Set<UpdateListener>();\n private connectionListeners = new Set<() => void>();\n private lastUpdate: {\n apiList?: Array<{ apiId: number }>;\n apis?: ApiData[];\n } = {};\n\n constructor() {\n this.setupMessageListener();\n }\n\n private setupMessageListener() {\n window.addEventListener(\"message\", (event) => {\n const message = event.data as UpdateMessage | HostConnectedMessage;\n\n if (message.type === \"update\") {\n this.lastUpdate = message.data;\n this.notifyListeners(message.data);\n } else if (message.type === \"host-connected\") {\n // Host has reconnected (page refresh), notify listeners to re-subscribe\n this.connectionListeners.forEach((listener) => listener());\n }\n });\n }\n\n onHostConnected(listener: () => void): () => void {\n this.connectionListeners.add(listener);\n return () => {\n this.connectionListeners.delete(listener);\n };\n }\n\n subscribe(listener: UpdateListener): () => void {\n this.listeners.add(listener);\n\n // Send the last update to the new listener\n if (this.lastUpdate.apiList || this.lastUpdate.apis) {\n listener(this.lastUpdate);\n }\n\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n setSubscription(options: { apiList?: boolean; apis?: number[] }) {\n window.parent.postMessage(\n {\n type: \"subscription\",\n data: options,\n },\n \"*\",\n );\n }\n\n clearEvents(apiId: number) {\n window.parent.postMessage(\n {\n type: \"clearEvents\",\n data: { apiId },\n },\n \"*\",\n );\n }\n\n private notifyListeners(data: UpdateMessage[\"data\"]) {\n this.listeners.forEach((listener) => listener(data));\n }\n\n getLastUpdate() {\n return this.lastUpdate;\n }\n}\n"],"mappings":";AAyBA,IAAac,cAAb,MAAyB;CACvB,4BAAoB,IAAIE,IAAoB;CAC5C,sCAA8B,IAAIA,IAAgB;CAClD,aAGI,CAAC;CAELG,cAAc;EACZ,KAAKC,qBAAqB;CAC5B;CAEA,uBAA+B;EAC7BC,OAAOC,iBAAiB,YAAYC,UAAU;GAC5C,MAAMC,UAAUD,MAAMf;GAEtB,IAAIgB,QAAQjB,SAAS,UAAU;IAC7B,KAAKW,aAAaM,QAAQhB;IAC1B,KAAKiB,gBAAgBD,QAAQhB,IAAI;GACnC,OAAO,IAAIgB,QAAQjB,SAAS,kBAE1B,KAAKU,oBAAoBS,SAASC,aAAaA,SAAS,CAAC;EAE7D,CAAC;CACH;CAEAC,gBAAgBD,UAAkC;EAChD,KAAKV,oBAAoBY,IAAIF,QAAQ;EACrC,aAAa;GACX,KAAKV,oBAAoBa,OAAOH,QAAQ;EAC1C;CACF;CAEAI,UAAUJ,UAAsC;EAC9C,KAAKZ,UAAUc,IAAIF,QAAQ;EAG3B,IAAI,KAAKT,WAAWT,WAAW,KAAKS,WAAWP,MAC7CgB,SAAS,KAAKT,UAAU;EAG1B,aAAa;GACX,KAAKH,UAAUe,OAAOH,QAAQ;EAChC;CACF;CAEAK,gBAAgBC,SAAiD;EAC/DZ,OAAOa,OAAOC,YACZ;GACE5B,MAAM;GACNC,MAAMyB;EACR,GACA,GACF;CACF;CAEAG,YAAYnC,OAAe;EACzBoB,OAAOa,OAAOC,YACZ;GACE5B,MAAM;GACNC,MAAM,EAAEP,MAAM;EAChB,GACA,GACF;CACF;CAEA,gBAAwBO,MAA6B;EACnD,KAAKO,UAAUW,SAASC,aAAaA,SAASnB,IAAI,CAAC;CACrD;CAEA6B,gBAAgB;EACd,OAAO,KAAKnB;CACd;AACF"}
|
package/dist/FrameHost.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrameHost.js","names":[],"sources":["../src/FrameHost.ts"],"sourcesContent":["import { DevToolsHost } from \"./DevToolsHost\";\n\nexport class FrameHost {\n private frame: HTMLIFrameElement;\n private devToolsHost: DevToolsHost;\n private messageListener: (event: MessageEvent) => void;\n\n constructor(frame: HTMLIFrameElement) {\n this.frame = frame;\n\n // Create DevToolsHost with callback to send messages to iframe\n this.devToolsHost = new DevToolsHost((message) => {\n if (this.frame.contentWindow) {\n this.frame.contentWindow.postMessage(message, \"*\");\n }\n });\n\n // Setup listener to forward messages from iframe to DevToolsHost\n this.messageListener = (event: MessageEvent) => {\n if (event.source !== this.frame.contentWindow) return;\n this.devToolsHost.onReceiveMessage(event.data);\n };\n\n window.addEventListener(\"message\", this.messageListener);\n }\n\n destroy() {\n window.removeEventListener(\"message\", this.messageListener);\n this.devToolsHost.destroy();\n }\n}\n"],"mappings":";;AAEA,
|
|
1
|
+
{"version":3,"file":"FrameHost.js","names":["DevToolsHost","FrameHost","frame","HTMLIFrameElement","devToolsHost","messageListener","event","MessageEvent","constructor","message","contentWindow","postMessage","source","onReceiveMessage","data","window","addEventListener","destroy","removeEventListener"],"sources":["../src/FrameHost.ts"],"sourcesContent":["import { DevToolsHost } from \"./DevToolsHost\";\n\nexport class FrameHost {\n private frame: HTMLIFrameElement;\n private devToolsHost: DevToolsHost;\n private messageListener: (event: MessageEvent) => void;\n\n constructor(frame: HTMLIFrameElement) {\n this.frame = frame;\n\n // Create DevToolsHost with callback to send messages to iframe\n this.devToolsHost = new DevToolsHost((message) => {\n if (this.frame.contentWindow) {\n this.frame.contentWindow.postMessage(message, \"*\");\n }\n });\n\n // Setup listener to forward messages from iframe to DevToolsHost\n this.messageListener = (event: MessageEvent) => {\n if (event.source !== this.frame.contentWindow) return;\n this.devToolsHost.onReceiveMessage(event.data);\n };\n\n window.addEventListener(\"message\", this.messageListener);\n }\n\n destroy() {\n window.removeEventListener(\"message\", this.messageListener);\n this.devToolsHost.destroy();\n }\n}\n"],"mappings":";;AAEA,IAAaC,YAAb,MAAuB;CACrB;CACA;CACA;CAEAO,YAAYN,OAA0B;EACpC,KAAKA,QAAQA;EAGb,KAAKE,eAAe,IAAIJ,cAAcS,YAAY;GAChD,IAAI,KAAKP,MAAMQ,eACb,KAAKR,MAAMQ,cAAcC,YAAYF,SAAS,GAAG;EAErD,CAAC;EAGD,KAAKJ,mBAAmBC,UAAwB;GAC9C,IAAIA,MAAMM,WAAW,KAAKV,MAAMQ,eAAe;GAC/C,KAAKN,aAAaS,iBAAiBP,MAAMQ,IAAI;EAC/C;EAEAC,OAAOC,iBAAiB,WAAW,KAAKX,eAAe;CACzD;CAEAY,UAAU;EACRF,OAAOG,oBAAoB,WAAW,KAAKb,eAAe;EAC1D,KAAKD,aAAaa,QAAQ;CAC5B;AACF"}
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const DEFAULT_FRAME_URL = \"https://devtools-frame.assistant-ui.com\";\nexport const LOCAL_FRAME_URL = \"http://localhost:3010\";\n"],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","names":["DEFAULT_FRAME_URL","LOCAL_FRAME_URL"],"sources":["../src/constants.ts"],"sourcesContent":["export const DEFAULT_FRAME_URL = \"https://devtools-frame.assistant-ui.com\";\nexport const LOCAL_FRAME_URL = \"http://localhost:3010\";\n"],"mappings":";AAAA,MAAaA,oBAAoB;AACjC,MAAaC,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DevToolsModal.styles.js","names":[],"sources":["../../src/styles/DevToolsModal.styles.ts"],"sourcesContent":["import type { CSSProperties } from \"react\";\n\nexport interface DevToolsModalStyles {\n floatingContainer: CSSProperties;\n floatingButton: CSSProperties;\n floatingButtonHover: CSSProperties;\n backdrop: CSSProperties;\n modal: CSSProperties;\n dismissButton: CSSProperties;\n dismissButtonHover: CSSProperties;\n modalContent: CSSProperties;\n}\n\nconst COLORS = {\n light: {\n primary: \"#2563EB\",\n background: \"#f8fafc\",\n surface: \"#ffffff\",\n text: \"#111827\",\n textLight: \"#6b7280\",\n border: \"rgba(148, 163, 184, 0.35)\",\n shadow: \"rgba(37, 99, 235, 0.35)\",\n buttonText: \"#f9fafb\",\n hoverBg: \"rgba(148, 163, 184, 0.18)\",\n },\n dark: {\n primary: \"#111827\",\n background: \"#09090b\",\n surface: \"#09090b\",\n text: \"#e5e7eb\",\n textLight: \"#9ca3af\",\n border: \"rgba(63, 63, 70, 0.6)\",\n shadow: \"rgba(0, 0, 0, 0.55)\",\n buttonText: \"#e5e7eb\",\n hoverBg: \"rgba(148, 163, 184, 0.12)\",\n },\n} as const;\n\nexport const getStyles = (darkMode: boolean): DevToolsModalStyles => {\n const theme = darkMode ? COLORS.dark : COLORS.light;\n\n return {\n floatingContainer: {\n position: \"fixed\",\n bottom: \"24px\",\n right: \"24px\",\n zIndex: 2147483647,\n },\n floatingButton: {\n width: \"42px\",\n height: \"42px\",\n borderRadius: \"9999px\",\n border: \"none\",\n background: theme.primary,\n color: theme.buttonText,\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n boxShadow: darkMode\n ? `0 10px 40px ${COLORS.dark.shadow}`\n : `0 10px 40px ${COLORS.light.shadow}`,\n transition: \"transform 0.2s ease, box-shadow 0.2s ease\",\n },\n floatingButtonHover: {\n transform: \"translateY(-2px)\",\n boxShadow: darkMode\n ? \"0 16px 50px rgba(17, 24, 39, 0.55)\"\n : \"0 16px 50px rgba(37, 99, 235, 0.45)\",\n },\n backdrop: {\n position: \"fixed\",\n inset: 0,\n background: \"rgba(15, 23, 42, 0.45)\",\n backdropFilter: \"blur(6px)\",\n animation: \"fadeIn 0.12s ease\",\n zIndex: 2147483646,\n },\n modal: {\n position: \"fixed\",\n top: \"50%\",\n left: \"50%\",\n transform: \"translate(-50%, -50%)\",\n width: \"min(960px, 90vw)\",\n height: \"min(720px, 85vh)\",\n background: theme.background,\n borderRadius: \"16px\",\n border: `1px solid ${theme.border}`,\n boxShadow: darkMode\n ? \"0 32px 120px rgba(0, 0, 0, 0.55)\"\n : \"0 32px 120px rgba(15, 23, 42, 0.35)\",\n display: \"flex\",\n flexDirection: \"column\",\n overflow: \"hidden\",\n animation: \"slideIn 0.16s ease\",\n zIndex: 2147483647,\n },\n dismissButton: {\n alignSelf: \"flex-end\",\n margin: \"10px 12px 0 0\",\n background: \"transparent\",\n border: \"none\",\n color: theme.textLight,\n cursor: \"pointer\",\n padding: \"6px\",\n borderRadius: \"6px\",\n transition: \"background 0.2s ease, color 0.2s ease\",\n },\n dismissButtonHover: {\n background: theme.hoverBg,\n color: theme.text,\n },\n modalContent: {\n flex: 1,\n overflow: \"hidden\",\n position: \"relative\",\n background: theme.background,\n },\n };\n};\n\nexport const ANIMATION_STYLES = `\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes slideIn {\n from {\n opacity: 0;\n transform: translate(-50%, -48%) scale(0.95);\n }\n to {\n opacity: 1;\n transform: translate(-50%, -50%) scale(1);\n }\n }\n`;\n"],"mappings":";AAaA,
|
|
1
|
+
{"version":3,"file":"DevToolsModal.styles.js","names":["CSSProperties","DevToolsModalStyles","floatingContainer","floatingButton","floatingButtonHover","backdrop","modal","dismissButton","dismissButtonHover","modalContent","COLORS","light","primary","background","surface","text","textLight","border","shadow","buttonText","hoverBg","dark","const","getStyles","darkMode","theme","position","bottom","right","zIndex","width","height","borderRadius","color","cursor","display","alignItems","justifyContent","boxShadow","transition","transform","inset","backdropFilter","animation","top","left","flexDirection","overflow","alignSelf","margin","padding","flex","ANIMATION_STYLES"],"sources":["../../src/styles/DevToolsModal.styles.ts"],"sourcesContent":["import type { CSSProperties } from \"react\";\n\nexport interface DevToolsModalStyles {\n floatingContainer: CSSProperties;\n floatingButton: CSSProperties;\n floatingButtonHover: CSSProperties;\n backdrop: CSSProperties;\n modal: CSSProperties;\n dismissButton: CSSProperties;\n dismissButtonHover: CSSProperties;\n modalContent: CSSProperties;\n}\n\nconst COLORS = {\n light: {\n primary: \"#2563EB\",\n background: \"#f8fafc\",\n surface: \"#ffffff\",\n text: \"#111827\",\n textLight: \"#6b7280\",\n border: \"rgba(148, 163, 184, 0.35)\",\n shadow: \"rgba(37, 99, 235, 0.35)\",\n buttonText: \"#f9fafb\",\n hoverBg: \"rgba(148, 163, 184, 0.18)\",\n },\n dark: {\n primary: \"#111827\",\n background: \"#09090b\",\n surface: \"#09090b\",\n text: \"#e5e7eb\",\n textLight: \"#9ca3af\",\n border: \"rgba(63, 63, 70, 0.6)\",\n shadow: \"rgba(0, 0, 0, 0.55)\",\n buttonText: \"#e5e7eb\",\n hoverBg: \"rgba(148, 163, 184, 0.12)\",\n },\n} as const;\n\nexport const getStyles = (darkMode: boolean): DevToolsModalStyles => {\n const theme = darkMode ? COLORS.dark : COLORS.light;\n\n return {\n floatingContainer: {\n position: \"fixed\",\n bottom: \"24px\",\n right: \"24px\",\n zIndex: 2147483647,\n },\n floatingButton: {\n width: \"42px\",\n height: \"42px\",\n borderRadius: \"9999px\",\n border: \"none\",\n background: theme.primary,\n color: theme.buttonText,\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n boxShadow: darkMode\n ? `0 10px 40px ${COLORS.dark.shadow}`\n : `0 10px 40px ${COLORS.light.shadow}`,\n transition: \"transform 0.2s ease, box-shadow 0.2s ease\",\n },\n floatingButtonHover: {\n transform: \"translateY(-2px)\",\n boxShadow: darkMode\n ? \"0 16px 50px rgba(17, 24, 39, 0.55)\"\n : \"0 16px 50px rgba(37, 99, 235, 0.45)\",\n },\n backdrop: {\n position: \"fixed\",\n inset: 0,\n background: \"rgba(15, 23, 42, 0.45)\",\n backdropFilter: \"blur(6px)\",\n animation: \"fadeIn 0.12s ease\",\n zIndex: 2147483646,\n },\n modal: {\n position: \"fixed\",\n top: \"50%\",\n left: \"50%\",\n transform: \"translate(-50%, -50%)\",\n width: \"min(960px, 90vw)\",\n height: \"min(720px, 85vh)\",\n background: theme.background,\n borderRadius: \"16px\",\n border: `1px solid ${theme.border}`,\n boxShadow: darkMode\n ? \"0 32px 120px rgba(0, 0, 0, 0.55)\"\n : \"0 32px 120px rgba(15, 23, 42, 0.35)\",\n display: \"flex\",\n flexDirection: \"column\",\n overflow: \"hidden\",\n animation: \"slideIn 0.16s ease\",\n zIndex: 2147483647,\n },\n dismissButton: {\n alignSelf: \"flex-end\",\n margin: \"10px 12px 0 0\",\n background: \"transparent\",\n border: \"none\",\n color: theme.textLight,\n cursor: \"pointer\",\n padding: \"6px\",\n borderRadius: \"6px\",\n transition: \"background 0.2s ease, color 0.2s ease\",\n },\n dismissButtonHover: {\n background: theme.hoverBg,\n color: theme.text,\n },\n modalContent: {\n flex: 1,\n overflow: \"hidden\",\n position: \"relative\",\n background: theme.background,\n },\n };\n};\n\nexport const ANIMATION_STYLES = `\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes slideIn {\n from {\n opacity: 0;\n transform: translate(-50%, -48%) scale(0.95);\n }\n to {\n opacity: 1;\n transform: translate(-50%, -50%) scale(1);\n }\n }\n`;\n"],"mappings":";AAaA,MAAMU,SAAS;CACbC,OAAO;EACLC,SAAS;EACTC,YAAY;EACZC,SAAS;EACTC,MAAM;EACNC,WAAW;EACXC,QAAQ;EACRC,QAAQ;EACRC,YAAY;EACZC,SAAS;CACX;CACAC,MAAM;EACJT,SAAS;EACTC,YAAY;EACZC,SAAS;EACTC,MAAM;EACNC,WAAW;EACXC,QAAQ;EACRC,QAAQ;EACRC,YAAY;EACZC,SAAS;CACX;AACF;AAEA,MAAaG,aAAaC,aAA2C;CACnE,MAAMC,QAAQD,WAAWd,OAAOW,OAAOX,OAAOC;CAE9C,OAAO;EACLT,mBAAmB;GACjBwB,UAAU;GACVC,QAAQ;GACRC,OAAO;GACPC,QAAQ;EACV;EACA1B,gBAAgB;GACd2B,OAAO;GACPC,QAAQ;GACRC,cAAc;GACdf,QAAQ;GACRJ,YAAYY,MAAMb;GAClBqB,OAAOR,MAAMN;GACbe,QAAQ;GACRC,SAAS;GACTC,YAAY;GACZC,gBAAgB;GAChBC,WAAWd,WACP,eAAed,OAAOW,KAAKH,WAC3B,eAAeR,OAAOC,MAAMO;GAChCqB,YAAY;EACd;EACAnC,qBAAqB;GACnBoC,WAAW;GACXF,WAAWd,WACP,uCACA;EACN;EACAnB,UAAU;GACRqB,UAAU;GACVe,OAAO;GACP5B,YAAY;GACZ6B,gBAAgB;GAChBC,WAAW;GACXd,QAAQ;EACV;EACAvB,OAAO;GACLoB,UAAU;GACVkB,KAAK;GACLC,MAAM;GACNL,WAAW;GACXV,OAAO;GACPC,QAAQ;GACRlB,YAAYY,MAAMZ;GAClBmB,cAAc;GACdf,QAAQ,aAAaQ,MAAMR;GAC3BqB,WAAWd,WACP,qCACA;GACJW,SAAS;GACTW,eAAe;GACfC,UAAU;GACVJ,WAAW;GACXd,QAAQ;EACV;EACAtB,eAAe;GACbyC,WAAW;GACXC,QAAQ;GACRpC,YAAY;GACZI,QAAQ;GACRgB,OAAOR,MAAMT;GACbkB,QAAQ;GACRgB,SAAS;GACTlB,cAAc;GACdO,YAAY;EACd;EACA/B,oBAAoB;GAClBK,YAAYY,MAAML;GAClBa,OAAOR,MAAMV;EACf;EACAN,cAAc;GACZ0C,MAAM;GACNJ,UAAU;GACVrB,UAAU;GACVb,YAAYY,MAAMZ;EACpB;CACF;AACF;AAEA,MAAauC,mBAAmB"}
|
|
@@ -1 +1 @@
|
|
|
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, type NormalizedTool } 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 REDACTED = \"[redacted]\";\n\nconst SENSITIVE_KEYS = new Set([\n \"apikey\",\n \"xapikey\",\n \"accesskey\",\n \"authorization\",\n \"password\",\n \"passwd\",\n \"secret\",\n \"clientsecret\",\n \"token\",\n \"accesstoken\",\n \"refreshtoken\",\n \"cookie\",\n \"setcookie\",\n \"credential\",\n \"credentials\",\n \"privatekey\",\n \"bearer\",\n \"sessionid\",\n]);\n\nconst normalizeKey = (key: string) => key.toLowerCase().replace(/[-_]/g, \"\");\n\n/**\n * Subtrees that are credential maps with arbitrary, user-defined key names\n * (MCP stdio `env`, HTTP `headers`). Per-key name matching cannot catch\n * `OPENAI_API_KEY` or a custom auth header, so every leaf inside one of these\n * is masked wholesale.\n */\nconst MASK_ALL_KEYS = new Set([\"env\", \"headers\"]);\n\n/**\n * Mask values whose key names a known credential, and mask every value inside\n * an `env`/`headers` subtree wholesale. Operates on already sanitized plain\n * data (primitives, arrays, plain objects). Applied only to config-bearing\n * subtrees, never to a tool's parameters schema, so a schema property literally\n * named `token` is not corrupted.\n */\nexport const redactSensitive = (value: unknown, maskAll = false): unknown => {\n if (Array.isArray(value)) {\n return value.map((entry) => redactSensitive(entry, maskAll));\n }\n if (value && typeof value === \"object\") {\n const result: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(\n value as Record<string, unknown>,\n )) {\n const normalized = normalizeKey(key);\n result[key] =\n maskAll || SENSITIVE_KEYS.has(normalized)\n ? REDACTED\n : redactSensitive(entry, MASK_ALL_KEYS.has(normalized));\n }\n return result;\n }\n return maskAll ? REDACTED : value;\n};\n\nexport const sanitizeAndRedact = (value: unknown): unknown =>\n redactSensitive(sanitizeForMessage(value));\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): NormalizedTool => {\n return {\n ...tool,\n parameters: sanitizeForMessage(tool.parameters),\n ...(tool.providerOptions !== undefined\n ? { providerOptions: sanitizeAndRedact(tool.providerOptions) }\n : {}),\n ...(tool.providerArgs !== undefined\n ? { providerArgs: sanitizeAndRedact(tool.providerArgs) }\n : {}),\n ...(tool.server !== undefined\n ? { server: sanitizeAndRedact(tool.server) }\n : {}),\n ...(tool.backendDefault !== undefined\n ? { backendDefault: sanitizeForMessage(tool.backendDefault) }\n : {}),\n };\n });\n }\n\n if (modelContext.callSettings !== undefined) {\n const callSettings = sanitizeAndRedact(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 = sanitizeAndRedact(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,
|
|
1
|
+
{"version":3,"file":"serialization.js","names":["ModelContext","SerializedModelContext","normalizeToolList","NormalizedTool","sanitizeForMessage","value","seen","WeakSet","undefined","Date","toISOString","Map","result","Record","key","entry","entries","String","Set","Array","from","map","isArray","has","add","filter","item","Object","REDACTED","SENSITIVE_KEYS","normalizeKey","toLowerCase","replace","MASK_ALL_KEYS","redactSensitive","maskAll","normalized","sanitizeAndRedact","serializeModelContext","context","modelContext","systemValue","system","length","tools","tool","parameters","providerOptions","providerArgs","server","backendDefault","callSettings","config","keys"],"sources":["../../src/utils/serialization.ts"],"sourcesContent":["import type { ModelContext } from \"@assistant-ui/react\";\nimport type { SerializedModelContext } from \"../types\";\nimport { normalizeToolList, type NormalizedTool } 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 REDACTED = \"[redacted]\";\n\nconst SENSITIVE_KEYS = new Set([\n \"apikey\",\n \"xapikey\",\n \"accesskey\",\n \"authorization\",\n \"password\",\n \"passwd\",\n \"secret\",\n \"clientsecret\",\n \"token\",\n \"accesstoken\",\n \"refreshtoken\",\n \"cookie\",\n \"setcookie\",\n \"credential\",\n \"credentials\",\n \"privatekey\",\n \"bearer\",\n \"sessionid\",\n]);\n\nconst normalizeKey = (key: string) => key.toLowerCase().replace(/[-_]/g, \"\");\n\n/**\n * Subtrees that are credential maps with arbitrary, user-defined key names\n * (MCP stdio `env`, HTTP `headers`). Per-key name matching cannot catch\n * `OPENAI_API_KEY` or a custom auth header, so every leaf inside one of these\n * is masked wholesale.\n */\nconst MASK_ALL_KEYS = new Set([\"env\", \"headers\"]);\n\n/**\n * Mask values whose key names a known credential, and mask every value inside\n * an `env`/`headers` subtree wholesale. Operates on already sanitized plain\n * data (primitives, arrays, plain objects). Applied only to config-bearing\n * subtrees, never to a tool's parameters schema, so a schema property literally\n * named `token` is not corrupted.\n */\nexport const redactSensitive = (value: unknown, maskAll = false): unknown => {\n if (Array.isArray(value)) {\n return value.map((entry) => redactSensitive(entry, maskAll));\n }\n if (value && typeof value === \"object\") {\n const result: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(\n value as Record<string, unknown>,\n )) {\n const normalized = normalizeKey(key);\n result[key] =\n maskAll || SENSITIVE_KEYS.has(normalized)\n ? REDACTED\n : redactSensitive(entry, MASK_ALL_KEYS.has(normalized));\n }\n return result;\n }\n return maskAll ? REDACTED : value;\n};\n\nexport const sanitizeAndRedact = (value: unknown): unknown =>\n redactSensitive(sanitizeForMessage(value));\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): NormalizedTool => {\n return {\n ...tool,\n parameters: sanitizeForMessage(tool.parameters),\n ...(tool.providerOptions !== undefined\n ? { providerOptions: sanitizeAndRedact(tool.providerOptions) }\n : {}),\n ...(tool.providerArgs !== undefined\n ? { providerArgs: sanitizeAndRedact(tool.providerArgs) }\n : {}),\n ...(tool.server !== undefined\n ? { server: sanitizeAndRedact(tool.server) }\n : {}),\n ...(tool.backendDefault !== undefined\n ? { backendDefault: sanitizeForMessage(tool.backendDefault) }\n : {}),\n };\n });\n }\n\n if (modelContext.callSettings !== undefined) {\n const callSettings = sanitizeAndRedact(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 = sanitizeAndRedact(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,MAAaI,sBACXC,OACAC,uBAAO,IAAIC,QAAgB,MACf;CAEZ,IAAIF,UAAU,QAAQA,UAAUG,KAAAA,GAAW,OAAOH;CAClD,IACE,OAAOA,UAAU,YACjB,OAAOA,UAAU,YACjB,OAAOA,UAAU,WAEjB,OAAOA;CAET,IAAI,OAAOA,UAAU,YACnB,OAAO;CAET,IAAIA,iBAAiBI,MACnB,OAAOJ,MAAMK,YAAY;CAE3B,IAAIL,iBAAiBM,KAAK;EACxB,MAAMC,SAAkC,CAAC;EACzC,KAAK,MAAM,CAACE,KAAKC,UAAUV,MAAMW,QAAQ,GACvCJ,OAAOK,OAAOH,GAAG,KAAKV,mBAAmBW,OAAOT,IAAI;EAEtD,OAAOM;CACT;CACA,IAAIP,iBAAiBa,KACnB,OAAOC,MAAMC,KAAKf,KAAK,CAAC,CAACgB,KAAKN,UAAUX,mBAAmBW,OAAOT,IAAI,CAAC;CAEzE,IAAIa,MAAMG,QAAQjB,KAAK,GAAG;EACxB,IAAIC,KAAKiB,IAAIlB,KAA0B,GAAG,OAAO;EACjDC,KAAKkB,IAAInB,KAA0B;EACnC,OAAOA,MACJgB,KAAKN,UAAUX,mBAAmBW,OAAOT,IAAI,CAAC,CAAC,CAC/CmB,QAAQC,SAASA,SAASlB,KAAAA,CAAS;CACxC;CACA,IAAI,OAAOH,UAAU,UAAU;EAC7B,IAAIC,KAAKiB,IAAIlB,KAAe,GAAG,OAAO;EACtCC,KAAKkB,IAAInB,KAAe;EACxB,MAAMO,SAAkC,CAAC;EACzC,KAAK,MAAM,CAACE,KAAKC,UAAUY,OAAOX,QAChCX,KACF,GACEO,OAAOE,OAAOV,mBAAmBW,OAAOT,IAAI;EAE9C,OAAOM;CACT;CACA,OAAOP;AACT;AAEA,MAAauB,WA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AmByC,KAAKC,UAAU;GAC9C,GAAID,KAAKE,oBAAoBvC,KAAAA,IACzB,EAAEuC,iBAAiBV,kBAAkBQ,KAAKE,eAAe,EAAE,IAC3D,CAAC;GACL,GAAIF,KAAKG,iBAAiBxC,KAAAA,IACtB,EAAEwC,cAAcX,kBAAkBQ,KAAKG,YAAY,EAAE,IACrD,CAAC;GACL,GAAIH,KAAKI,WAAWzC,KAAAA,IAChB,EAAEyC,QAAQZ,kBAAkBQ,KAAKI,MAAM,EAAE,IACzC,CAAC;GACL,GAAIJ,KAAKK,mBAAmB1C,KAAAA,IACxB,EAAE0C,gBAAgB9C,mBAAmByC,KAAKK,cAAc,EAAE,IAC1D,CAAC;EACP;CACF,CAAC;CAGH,IAAIV,aAAaW,iBAAiB3C,KAAAA,GAAW;EAC3C,MAAM2C,eAAed,kBAAkBG,aAAaW,YAAY;EAChE,IACEA,gBACA,OAAOA,iBAAiB,YACxB,CAAChC,MAAMG,QAAQ6B,YAAY,GAE3BvC,OAAOuC,eAAeA;CAE1B;CAEA,IAAIX,aAAaY,WAAW5C,KAAAA,GAAW;EACrC,MAAM4C,SAASf,kBAAkBG,aAAaY,MAAM;EACpD,IAAIA,UAAU,OAAOA,WAAW,YAAY,CAACjC,MAAMG,QAAQ8B,MAAM,GAC/DxC,OAAOwC,SAASA;CAEpB;CAEA,OAAOzB,OAAO0B,KAAKzC,MAAM,CAAC,CAAC+B,SAAS,IAAI/B,SAASJ,KAAAA;AACnD"}
|
|
@@ -1 +1 @@
|
|
|
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 display?: string;\n providerId?: string;\n supportsDeferredResults?: boolean;\n backendDefault?: unknown;\n providerOptions?: unknown;\n providerArgs?: unknown;\n server?: unknown;\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 (typeof raw.display === \"string\") {\n tool.display = raw.display as string;\n }\n\n if (typeof raw.providerId === \"string\") {\n tool.providerId = raw.providerId as string;\n }\n\n if (typeof raw.supportsDeferredResults === \"boolean\") {\n tool.supportsDeferredResults = raw.supportsDeferredResults as boolean;\n }\n\n if (raw.unstable_backendDefault !== undefined) {\n tool.backendDefault = raw.unstable_backendDefault;\n }\n\n if (raw.providerOptions !== undefined) {\n tool.providerOptions = raw.providerOptions;\n }\n\n if (raw.args !== undefined) {\n tool.providerArgs = raw.args;\n }\n\n if (raw.server !== undefined) {\n tool.server = raw.server;\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":";;AAiBA,
|
|
1
|
+
{"version":3,"file":"toolNormalization.js","names":["z","NormalizedTool","name","type","description","disabled","display","providerId","supportsDeferredResults","backendDefault","providerOptions","providerArgs","server","parameters","isRecord","value","Record","toJsonSchema","ZodType","toJSONSchema","mapToNormalizedTool","raw","tool","unstable_backendDefault","undefined","args","Object","hasOwn","normalizeToolList","Array","isArray","tools","entry","push","entries"],"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 display?: string;\n providerId?: string;\n supportsDeferredResults?: boolean;\n backendDefault?: unknown;\n providerOptions?: unknown;\n providerArgs?: unknown;\n server?: unknown;\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 (typeof raw.display === \"string\") {\n tool.display = raw.display as string;\n }\n\n if (typeof raw.providerId === \"string\") {\n tool.providerId = raw.providerId as string;\n }\n\n if (typeof raw.supportsDeferredResults === \"boolean\") {\n tool.supportsDeferredResults = raw.supportsDeferredResults as boolean;\n }\n\n if (raw.unstable_backendDefault !== undefined) {\n tool.backendDefault = raw.unstable_backendDefault;\n }\n\n if (raw.providerOptions !== undefined) {\n tool.providerOptions = raw.providerOptions;\n }\n\n if (raw.args !== undefined) {\n tool.providerArgs = raw.args;\n }\n\n if (raw.server !== undefined) {\n tool.server = raw.server;\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":";;AAiBA,MAAMc,YAAYC,UAChBA,UAAU,QAAQ,OAAOA,UAAU;AAErC,MAAME,gBAAgBF,UAA4B;CAChD,IAAIA,iBAAiBf,EAAEkB,SACrB,IAAI;EACF,OAAOlB,EAAEmB,aAAaJ,KAAK;CAC7B,QAAQ;EACN,OAAOA;CACT;CAGF,OAAOA;AACT;AAEA,MAAMK,uBACJlB,MACAmB,QACmB;CACnB,MAAMC,OAAuB,EAAEpB,KAAK;CAEpC,IAAI,OAAOmB,IAAIlB,SAAS,UACtBmB,KAAKnB,OAAOkB,IAAIlB;CAGlB,IAAI,OAAOkB,IAAIjB,gBAAgB,UAC7BkB,KAAKlB,cAAciB,IAAIjB;CAGzB,IAAI,OAAOiB,IAAIhB,aAAa,WAC1BiB,KAAKjB,WAAWgB,IAAIhB;CAGtB,IAAI,OAAOgB,IAAIf,YAAY,UACzBgB,KAAKhB,UAAUe,IAAIf;CAGrB,IAAI,OAAOe,IAAId,eAAe,UAC5Be,KAAKf,aAAac,IAAId;CAGxB,IAAI,OAAOc,IAAIb,4BAA4B,WACzCc,KAAKd,0BAA0Ba,IAAIb;CAGrC,IAAIa,IAAIE,4BAA4BC,KAAAA,GAClCF,KAAKb,iBAAiBY,IAAIE;CAG5B,IAAIF,IAAIX,oBAAoBc,KAAAA,GAC1BF,KAAKZ,kBAAkBW,IAAIX;CAG7B,IAAIW,IAAII,SAASD,KAAAA,GACfF,KAAKX,eAAeU,IAAII;CAG1B,IAAIJ,IAAIT,WAAWY,KAAAA,GACjBF,KAAKV,SAASS,IAAIT;CAGpB,IAAIc,OAAOC,OAAON,KAAK,YAAY,GACjCC,KAAKT,aAAaI,aAAaI,IAAIR,UAAU;CAG/C,OAAOS;AACT;AAEA,MAAaM,qBAAqBb,UAAqC;CACrE,IAAI,CAACA,SAAS,OAAOA,UAAU,UAC7B,OAAO,CAAA;CAGT,IAAIc,MAAMC,QAAQf,KAAK,GAAG;EACxB,MAAMgB,QAA0B,CAAA;EAEhC,KAAK,MAAMC,SAASjB,OAAO;GACzB,IAAI,CAACD,SAASkB,KAAK,KAAK,OAAOA,MAAM9B,SAAS,UAAU;GACxD6B,MAAME,KAAKb,oBAAoBY,MAAM9B,MAAgB8B,KAAK,CAAC;EAC7D;EAEA,OAAOD;CACT;CAEA,IAAIjB,SAASC,KAAK,GAAG;EACnB,MAAMgB,QAA0B,CAAA;EAEhC,KAAK,MAAM,CAAC7B,MAAM8B,UAAUN,OAAOQ,QAAQnB,KAAK,GAAG;GACjD,IAAI,CAACD,SAASkB,KAAK,GAAG;IACpBD,MAAME,KAAK,EAAE/B,KAAK,CAAC;IACnB;GACF;GAEA6B,MAAME,KAAKb,oBAAoBlB,MAAM8B,KAAK,CAAC;EAC7C;EAEA,OAAOD;CACT;CAEA,OAAO,CAAA;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/react-devtools",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "React development tools for assistant-ui components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"assistant-ui",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@assistant-ui/react": "^0.14.14",
|
|
34
|
-
"@assistant-ui/tap": "^0.
|
|
34
|
+
"@assistant-ui/tap": "^0.8.0",
|
|
35
35
|
"@types/react": "*",
|
|
36
36
|
"@types/react-dom": "*",
|
|
37
37
|
"react": "^18 || ^19",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"react": "^19.2.7",
|
|
53
53
|
"react-dom": "^19.2.7",
|
|
54
54
|
"vitest": "^4.1.8",
|
|
55
|
-
"@assistant-ui/react": "0.14.
|
|
56
|
-
"@assistant-ui/tap": "0.
|
|
57
|
-
"@assistant-ui/x-buildutils": "0.0.
|
|
55
|
+
"@assistant-ui/react": "0.14.19",
|
|
56
|
+
"@assistant-ui/tap": "0.8.1",
|
|
57
|
+
"@assistant-ui/x-buildutils": "0.0.13"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public",
|