You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
907 B
31 lines
907 B
import { dbGlobal } from "drizzle-pkg/lib/db";
|
|
import { agentToolLogs } from "drizzle-pkg/lib/schema/agent-tool";
|
|
import type { AgentToolLogStatus } from "drizzle-pkg/lib/schema/agent-tool";
|
|
|
|
export interface WriteToolLogParams {
|
|
toolId: string;
|
|
toolSlug: string;
|
|
userId: number | null;
|
|
input: string;
|
|
output: string | null;
|
|
status: AgentToolLogStatus;
|
|
errorMessage: string | null;
|
|
durationMs: number;
|
|
}
|
|
|
|
export async function writeToolLog(params: WriteToolLogParams): Promise<void> {
|
|
try {
|
|
await dbGlobal.insert(agentToolLogs).values({
|
|
toolId: params.toolId,
|
|
toolSlug: params.toolSlug,
|
|
userId: params.userId,
|
|
input: params.input,
|
|
output: params.output,
|
|
status: params.status,
|
|
errorMessage: params.errorMessage,
|
|
durationMs: params.durationMs,
|
|
});
|
|
} catch (e) {
|
|
console.error("[agent-tool] 写入执行日志失败:", e);
|
|
}
|
|
}
|
|
|