snow-flow 10.0.194 → 10.0.196
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/package.json
CHANGED
|
@@ -1470,6 +1470,12 @@ function ToolPart(props: { last: boolean; part: ToolPart; message: AssistantMess
|
|
|
1470
1470
|
<Match when={props.part.tool === "question"}>
|
|
1471
1471
|
<Question {...toolprops} />
|
|
1472
1472
|
</Match>
|
|
1473
|
+
<Match when={props.part.tool.endsWith("tool_execute")}>
|
|
1474
|
+
<ToolExecute {...toolprops} />
|
|
1475
|
+
</Match>
|
|
1476
|
+
<Match when={props.part.tool.endsWith("tool_search")}>
|
|
1477
|
+
<ToolSearchResult {...toolprops} />
|
|
1478
|
+
</Match>
|
|
1473
1479
|
<Match when={true}>
|
|
1474
1480
|
<GenericTool {...toolprops} />
|
|
1475
1481
|
</Match>
|
|
@@ -1486,6 +1492,96 @@ type ToolProps<T extends Tool.Info> = {
|
|
|
1486
1492
|
output?: string
|
|
1487
1493
|
part: ToolPart
|
|
1488
1494
|
}
|
|
1495
|
+
function ToolExecute(props: ToolProps<any>) {
|
|
1496
|
+
const { theme } = useTheme()
|
|
1497
|
+
const [expanded, setExpanded] = createSignal(false)
|
|
1498
|
+
|
|
1499
|
+
const toolName = createMemo(() => (props.input as any).tool ?? "unknown")
|
|
1500
|
+
const toolArgs = createMemo(() => {
|
|
1501
|
+
const args = (props.input as any).args
|
|
1502
|
+
if (!args || typeof args !== "object") return ""
|
|
1503
|
+
return input(args as Record<string, any>)
|
|
1504
|
+
})
|
|
1505
|
+
const argEntries = createMemo(() => {
|
|
1506
|
+
const args = (props.input as any).args
|
|
1507
|
+
if (!args || typeof args !== "object") return []
|
|
1508
|
+
return Object.entries(args)
|
|
1509
|
+
.filter(([, v]) => typeof v === "string" || typeof v === "number" || typeof v === "boolean")
|
|
1510
|
+
.slice(0, 4)
|
|
1511
|
+
})
|
|
1512
|
+
|
|
1513
|
+
const parsed = createMemo(() => {
|
|
1514
|
+
if (!props.output) return null
|
|
1515
|
+
try {
|
|
1516
|
+
return JSON.parse(props.output)
|
|
1517
|
+
} catch {
|
|
1518
|
+
return null
|
|
1519
|
+
}
|
|
1520
|
+
})
|
|
1521
|
+
const success = createMemo(() => parsed()?.success === true)
|
|
1522
|
+
const summary = createMemo(() => {
|
|
1523
|
+
const p = parsed()
|
|
1524
|
+
if (!p) return ""
|
|
1525
|
+
if (p.result?.summary) return p.result.summary
|
|
1526
|
+
if (p.error) return p.error
|
|
1527
|
+
return success() ? "Completed" : "Failed"
|
|
1528
|
+
})
|
|
1529
|
+
|
|
1530
|
+
return (
|
|
1531
|
+
<Show
|
|
1532
|
+
when={props.output}
|
|
1533
|
+
fallback={
|
|
1534
|
+
<InlineTool icon="⚙" pending={`Executing ${toolName()}...`} complete={false} part={props.part}>
|
|
1535
|
+
{toolName()} {toolArgs()}
|
|
1536
|
+
</InlineTool>
|
|
1537
|
+
}
|
|
1538
|
+
>
|
|
1539
|
+
<BlockTool
|
|
1540
|
+
title={`# ${toolName()} ${toolArgs()}`}
|
|
1541
|
+
part={props.part}
|
|
1542
|
+
onClick={() => setExpanded((prev) => !prev)}
|
|
1543
|
+
>
|
|
1544
|
+
<box gap={0}>
|
|
1545
|
+
<For each={argEntries()}>
|
|
1546
|
+
{([key, val]) => (
|
|
1547
|
+
<text fg={theme.textMuted}>
|
|
1548
|
+
{" "}
|
|
1549
|
+
{key as string}: {String(val).slice(0, 80)}
|
|
1550
|
+
</text>
|
|
1551
|
+
)}
|
|
1552
|
+
</For>
|
|
1553
|
+
<text fg={success() ? theme.success : theme.error}>
|
|
1554
|
+
{" "}
|
|
1555
|
+
{success() ? "✓" : "✗"} {summary().slice(0, 120)}
|
|
1556
|
+
</text>
|
|
1557
|
+
<Show when={expanded()}>
|
|
1558
|
+
<text fg={theme.textMuted}>{props.output}</text>
|
|
1559
|
+
</Show>
|
|
1560
|
+
</box>
|
|
1561
|
+
</BlockTool>
|
|
1562
|
+
</Show>
|
|
1563
|
+
)
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
function ToolSearchResult(props: ToolProps<any>) {
|
|
1567
|
+
const parsed = createMemo(() => {
|
|
1568
|
+
if (!props.output) return null
|
|
1569
|
+
try {
|
|
1570
|
+
return JSON.parse(props.output)
|
|
1571
|
+
} catch {
|
|
1572
|
+
return null
|
|
1573
|
+
}
|
|
1574
|
+
})
|
|
1575
|
+
const count = createMemo(() => parsed()?.count ?? 0)
|
|
1576
|
+
const query = createMemo(() => (props.input as any).query ?? "")
|
|
1577
|
+
|
|
1578
|
+
return (
|
|
1579
|
+
<InlineTool icon="🔍" pending={`Searching tools: ${query()}...`} complete={props.output} part={props.part}>
|
|
1580
|
+
tool_search [{query()}] → {count()} tools found
|
|
1581
|
+
</InlineTool>
|
|
1582
|
+
)
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1489
1585
|
function GenericTool(props: ToolProps<any>) {
|
|
1490
1586
|
const { theme } = useTheme()
|
|
1491
1587
|
const ctx = use()
|