Refine WebUI commands and data skills
This commit is contained in:
@@ -143,6 +143,7 @@ function writeToolTrace(
|
||||
|
||||
for (const entry of transcript) {
|
||||
if (!entry.tool_calls?.length) continue;
|
||||
const stageNote = entry.role === "assistant" ? entry.content?.trim() : "";
|
||||
for (const call of entry.tool_calls) {
|
||||
const toolCallId = call.id;
|
||||
const toolName = call.function?.name ?? call.name;
|
||||
@@ -152,7 +153,10 @@ function writeToolTrace(
|
||||
type: "tool-input-available",
|
||||
toolCallId,
|
||||
toolName,
|
||||
input: parseToolInput(call.function?.arguments ?? call.arguments),
|
||||
input: attachStageNote(
|
||||
parseToolInput(call.function?.arguments ?? call.arguments),
|
||||
stageNote,
|
||||
),
|
||||
});
|
||||
|
||||
if (toolResults.has(toolCallId)) {
|
||||
@@ -166,6 +170,15 @@ function writeToolTrace(
|
||||
}
|
||||
}
|
||||
|
||||
function attachStageNote(input: unknown, stageNote?: string) {
|
||||
const note = stageNote?.trim();
|
||||
if (!note) return input;
|
||||
if (input && typeof input === "object" && !Array.isArray(input)) {
|
||||
return { ...input, __claw_stage_note: note };
|
||||
}
|
||||
return { value: input, __claw_stage_note: note };
|
||||
}
|
||||
|
||||
function parseToolInput(value: unknown) {
|
||||
if (typeof value !== "string") return value ?? {};
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { getCurrentAccount } from "@/lib/claw-auth";
|
||||
|
||||
const CLAW_API_URL = process.env.CLAW_API_URL ?? "http://127.0.0.1:8765";
|
||||
|
||||
export async function GET() {
|
||||
const account = await getCurrentAccount();
|
||||
if (!account) return Response.json([], { status: 401 });
|
||||
|
||||
const response = await fetch(`${CLAW_API_URL}/api/slash-commands`, {
|
||||
cache: "no-store",
|
||||
});
|
||||
const payload = await response.text();
|
||||
return new Response(payload, {
|
||||
status: response.status,
|
||||
headers: {
|
||||
"content-type":
|
||||
response.headers.get("content-type") ?? "application/json",
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user