Auto-reply: add /verbose directives and tool result replies

This commit is contained in:
Peter Steinberger
2025-12-03 09:04:37 +00:00
parent 8ba35a2dc3
commit 086dd284d6
10 changed files with 242 additions and 8 deletions

View File

@@ -34,6 +34,7 @@ type CommandReplyParams = {
commandRunner: typeof runCommandWithTimeout;
enqueue?: EnqueueRunner;
thinkLevel?: ThinkLevel;
verboseLevel?: "off" | "on";
};
export type CommandReplyMeta = {
@@ -141,6 +142,7 @@ export async function runCommandReply(
commandRunner,
enqueue = enqueueCommand,
thinkLevel,
verboseLevel,
} = params;
if (!reply.command?.length) {
@@ -301,6 +303,8 @@ export async function runCommandReply(
// Collect one message per assistant text from parseOutput (tau RPC can emit many).
const parsedTexts =
parsed?.texts?.map((t) => t.trim()).filter(Boolean) ?? [];
const parsedToolResults =
parsed?.toolResults?.map((t) => t.trim()).filter(Boolean) ?? [];
type ReplyItem = { text: string; media?: string[] };
const replyItems: ReplyItem[] = [];
@@ -314,6 +318,18 @@ export async function runCommandReply(
});
}
if (verboseLevel === "on") {
for (const tr of parsedToolResults) {
const prefixed = `🛠️ ${tr}`;
const { text: cleanedText, mediaUrls: mediaFound } =
splitMediaFromOutput(prefixed);
replyItems.push({
text: cleanedText,
media: mediaFound?.length ? mediaFound : undefined,
});
}
}
// If parser gave nothing, fall back to raw stdout as a single message.
if (replyItems.length === 0 && trimmed && !parserProvided) {
const { text: cleanedText, mediaUrls: mediaFound } =