66 lines
3.6 KiB
JavaScript
66 lines
3.6 KiB
JavaScript
import { defineToolCallRenderer } from "../types/defineToolCallRenderer.mjs";
|
|
import { useState } from "react";
|
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
|
//#region src/components/WildcardToolCallRender.tsx
|
|
const WildcardToolCallRender = defineToolCallRenderer({
|
|
name: "*",
|
|
render: ({ args, result, name, status }) => {
|
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
const statusString = String(status);
|
|
return /* @__PURE__ */ jsx("div", {
|
|
className: "cpk:mt-2 cpk:pb-2",
|
|
children: /* @__PURE__ */ jsxs("div", {
|
|
className: "cpk:rounded-xl cpk:border cpk:border-zinc-200/60 cpk:dark:border-zinc-800/60 cpk:bg-white/70 cpk:dark:bg-zinc-900/50 cpk:shadow-sm cpk:backdrop-blur cpk:p-4",
|
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
className: "cpk:flex cpk:items-center cpk:justify-between cpk:gap-3 cpk:cursor-pointer",
|
|
onClick: () => setIsExpanded(!isExpanded),
|
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
className: "cpk:flex cpk:items-center cpk:gap-2 cpk:min-w-0",
|
|
children: [
|
|
/* @__PURE__ */ jsx("svg", {
|
|
className: `cpk:h-4 cpk:w-4 cpk:text-zinc-500 cpk:dark:text-zinc-400 cpk:transition-transform ${isExpanded ? "cpk:rotate-90" : ""}`,
|
|
fill: "none",
|
|
viewBox: "0 0 24 24",
|
|
strokeWidth: 2,
|
|
stroke: "currentColor",
|
|
children: /* @__PURE__ */ jsx("path", {
|
|
strokeLinecap: "round",
|
|
strokeLinejoin: "round",
|
|
d: "M8.25 4.5l7.5 7.5-7.5 7.5"
|
|
})
|
|
}),
|
|
/* @__PURE__ */ jsx("span", { className: "cpk:inline-block cpk:h-2 cpk:w-2 cpk:rounded-full cpk:bg-blue-500" }),
|
|
/* @__PURE__ */ jsx("span", {
|
|
className: "cpk:truncate cpk:text-sm cpk:font-medium cpk:text-zinc-900 cpk:dark:text-zinc-100",
|
|
children: name
|
|
})
|
|
]
|
|
}), /* @__PURE__ */ jsx("span", {
|
|
className: `cpk:inline-flex cpk:items-center cpk:rounded-full cpk:px-2 cpk:py-1 cpk:text-xs cpk:font-medium ${statusString === "inProgress" || statusString === "executing" ? "cpk:bg-amber-100 cpk:text-amber-800 cpk:dark:bg-amber-500/15 cpk:dark:text-amber-400" : statusString === "complete" ? "cpk:bg-emerald-100 cpk:text-emerald-800 cpk:dark:bg-emerald-500/15 cpk:dark:text-emerald-400" : "cpk:bg-zinc-100 cpk:text-zinc-800 cpk:dark:bg-zinc-700/40 cpk:dark:text-zinc-300"}`,
|
|
children: String(status)
|
|
})]
|
|
}), isExpanded && /* @__PURE__ */ jsxs("div", {
|
|
className: "cpk:mt-3 cpk:grid cpk:gap-4",
|
|
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
|
|
className: "cpk:text-xs cpk:uppercase cpk:tracking-wide cpk:text-zinc-500 cpk:dark:text-zinc-400",
|
|
children: "Arguments"
|
|
}), /* @__PURE__ */ jsx("pre", {
|
|
className: "cpk:mt-2 cpk:max-h-64 cpk:overflow-auto cpk:rounded-md cpk:bg-zinc-50 cpk:dark:bg-zinc-800/60 cpk:p-3 cpk:text-xs cpk:leading-relaxed cpk:text-zinc-800 cpk:dark:text-zinc-200 cpk:whitespace-pre-wrap cpk:break-words",
|
|
children: JSON.stringify(args ?? {}, null, 2)
|
|
})] }), result !== void 0 && /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
|
|
className: "cpk:text-xs cpk:uppercase cpk:tracking-wide cpk:text-zinc-500 cpk:dark:text-zinc-400",
|
|
children: "Result"
|
|
}), /* @__PURE__ */ jsx("pre", {
|
|
className: "cpk:mt-2 cpk:max-h-64 cpk:overflow-auto cpk:rounded-md cpk:bg-zinc-50 cpk:dark:bg-zinc-800/60 cpk:p-3 cpk:text-xs cpk:leading-relaxed cpk:text-zinc-800 cpk:dark:text-zinc-200 cpk:whitespace-pre-wrap cpk:break-words",
|
|
children: typeof result === "string" ? result : JSON.stringify(result, null, 2)
|
|
})] })]
|
|
})]
|
|
})
|
|
});
|
|
}
|
|
});
|
|
|
|
//#endregion
|
|
export { WildcardToolCallRender };
|
|
//# sourceMappingURL=WildcardToolCallRender.mjs.map
|