+
+
+
+
+
- }
- >
- props.fileOpen?.(`${patchKeys().get(tool())}:${path}`))
- }
- onFileOpenChange={
- props.onFileOpenChange &&
- ((path, open) =>
- props.onFileOpenChange?.(`${patchKeys().get(tool())}:${path}`, open))
- }
- onSizeChange={props.onSizeChange}
- />
-
- }
- >
- item.id)
- .join(",")}
- aria-label={i18n.plural("ui.tool.loadedSkills", skills().length, {
- name: skills().join(", "),
- })}
- >
-
- {loaded().split(marker)[0]?.trim()}
-
-
-
- {(name, index) => (
- <>
- 0}>,
-
- >
- )}
+
+
+ {(subtitle) => {subtitle()}}
+
+
+ {(arg) => {arg}}
-
-
- {(suffix) => (
-
- {suffix()}
-
+
+
+ {(matches) => (
+ <>
+
+ {matches()}
+ >
)}
-
- }
- >
-
-
-
-
-
-
-
-
-
- {(subtitle) => {subtitle()}}
-
-
- {(arg) => {arg}}
-
-
-
- {(matches) => (
- <>
-
- {matches()}
- >
- )}
-
-
-
-
+
@@ -870,10 +843,6 @@ export function CurrentContextToolGroup(props: {
)
}
-function isExecute(part: ContextGroupPart | undefined) {
- return part?.type === "tool" && part.name === "execute"
-}
-
export function CurrentReadToolGroup(props: {
tools: SessionMessageAssistantTool[]
open?: boolean
@@ -1947,120 +1916,54 @@ ToolRegistry.register({
name: "execute",
render(props) {
const i18n = useI18n()
+ const pending = () => props.status === "streaming" || props.status === "running"
+ const calls = createMemo(() => executeToolCalls(props.metadata))
+ const subtitle = createMemo(() => executeToolSubtitle(calls()))
- return
+ // Like the TUI, only a runtime failure shows its output; a failed nested call is marked on its row.
+ const error = createMemo(() => {
+ if (props.status !== "error" && props.metadata.error !== true) return undefined
+ const fallback = i18n.t("ui.toolErrorCard.failed")
+ const text = stripAnsi((props.status === "error" ? props.error : undefined) || props.output || fallback)
+
+ return text.replace(/^Error:\s*/, "").trim() || fallback
+ })
+
+ // A runtime failure belongs to the call that raised it; scripts can also fail outside any call.
+ const owner = createMemo(() => calls().findLastIndex((call) => call.status === "error"))
+
+ const sawPending = pending()
+
+ return (
+
0 || !!error()}
+ compact
+ allowOpenWhilePending
+ trigger={(open) => (
+
+
+
+
+
+ {(text) => }
+
+
+ )}
+ >
+
+
+ {(call, index) => }
+
+ {(text) => }
+
+
+ )
},
})
-// Consecutive Code Mode executions read as one list of the tools their scripts called.
-export function CurrentExecuteToolGroup(props: {
- tools: SessionMessageAssistantTool[]
- defaultOpen?: boolean
- open?: boolean
- onOpenChange?: (open: boolean) => void
- onSizeChange?: () => void
-}) {
- const i18n = useI18n()
-
- const status = createMemo(
- () =>
- props.tools.find((tool) => tool.state.status === "streaming" || tool.state.status === "running")?.state.status ??
- "completed",
- )
-
- return (
-
1 ? props.tools.map((tool) => tool.id).join(",") : undefined}
- >
-
- executeRun(
- {
- status: tool.state.status,
- metadata: currentToolMetadata(tool),
- output: currentToolOutput(tool),
- error: currentToolError(tool),
- },
- i18n.t("ui.toolErrorCard.failed"),
- ),
- )}
- status={status()}
- defaultOpen={props.defaultOpen}
- open={props.open}
- onOpenChange={(open) => {
- props.onOpenChange?.(open)
- props.onSizeChange?.()
- }}
- />
-
- )
-}
-
-type ExecuteRun = { calls: ExecuteToolCall[]; error?: string }
-
-// Like the TUI, only a runtime failure shows its output; a failed nested call is marked on its row.
-function executeRun(
- props: { status?: string; metadata: Record
; output?: string; error?: string },
- fallback: string,
-): ExecuteRun {
- const calls = executeToolCalls(props.metadata)
-
- if (props.status !== "error" && props.metadata.error !== true) return { calls }
- const error = stripAnsi((props.status === "error" ? props.error : undefined) || props.output || fallback)
-
- return { calls, error: error.replace(/^Error:\s*/, "").trim() || fallback }
-}
-
-function ExecuteTool(props: Omit & { runs: ExecuteRun[] }) {
- const i18n = useI18n()
- const pending = () => props.status === "streaming" || props.status === "running"
- const calls = createMemo(() => props.runs.flatMap((run) => run.calls))
- const subtitle = createMemo(() => executeToolSubtitle(calls()))
-
- const sawPending = pending()
-
- return (
- run.calls.length > 0 || run.error)}
- compact
- allowOpenWhilePending
- trigger={(open) => (
-
-
-
-
-
- {(text) => }
-
-
- )}
- >
-
-
- {(run) => {
- // A runtime failure belongs to the call that raised it; scripts can also fail outside any call.
- const owner = createMemo(() => run().calls.findLastIndex((call) => call.status === "error"))
-
- return (
- <>
-
- {(call, index) => }
-
- {(error) => }
- >
- )
- }}
-
-
-
- )
-}
-
function ExecuteCallRow(props: { call?: ExecuteToolCall; error?: string }) {
const [open, setOpen] = createSignal(false)
const args = createMemo(() => (props.call ? executeToolCallArgs(props.call) : []))