feat: show search

This commit is contained in:
2026-06-19 20:13:26 -04:00
parent 4e654ebb82
commit 072701a649

View File

@@ -2,6 +2,7 @@
// a shared headless Firefox session. Provider config lives in // a shared headless Firefox session. Provider config lives in
// ~/.pi/pi-web/config.json (env overrides supported). // ~/.pi/pi-web/config.json (env overrides supported).
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent"; import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
import { Text } from "@mariozechner/pi-tui";
import { Type } from "typebox"; import { Type } from "typebox";
import { ConfigError, loadConfig, resolveSettings } from "./src/config.ts"; import { ConfigError, loadConfig, resolveSettings } from "./src/config.ts";
import { fetchPage, type FetchResult } from "./src/fetch.ts"; import { fetchPage, type FetchResult } from "./src/fetch.ts";
@@ -45,6 +46,15 @@ export default function (pi: ExtensionAPI) {
parameters: Type.Object({ parameters: Type.Object({
query: Type.String({ description: "Search query text" }), query: Type.String({ description: "Search query text" }),
}), }),
renderCall(args, theme, context) {
const query = args?.query;
const display = query && query.length > 0
? query
: theme.fg("toolOutput", "...");
const text = new Text("", 0, 0);
text.setText(theme.fg("toolTitle", theme.bold(`web_search "${display}"`)));
return text;
},
async execute(_toolCallId, params) { async execute(_toolCallId, params) {
try { try {
const results = await runSearch(params.query); const results = await runSearch(params.query);
@@ -74,6 +84,15 @@ export default function (pi: ExtensionAPI) {
parameters: Type.Object({ parameters: Type.Object({
url: Type.String({ description: "Absolute URL to fetch" }), url: Type.String({ description: "Absolute URL to fetch" }),
}), }),
renderCall(args, theme, context) {
const url = args?.url;
const display = url && url.length > 0
? url
: theme.fg("toolOutput", "...");
const text = new Text("", 0, 0);
text.setText(theme.fg("toolTitle", theme.bold(`web_fetch ${display}`)));
return text;
},
async execute(_toolCallId, params) { async execute(_toolCallId, params) {
try { try {
const result = await fetchPage({ url: params.url }); const result = await fetchPage({ url: params.url });