Чтение зеркала Supabase агентами (khb-sql, роли khb_agent / khb_agent_ceo, KHB_SQL_URL); отчёты для агента руководителя; промты; тесты; docs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,8 @@ export interface ClaudeCall {
|
||||
/** true - продолжить существующую сессию (--resume), false - создать новую с этим id (--session-id). */
|
||||
resume: boolean;
|
||||
tools: ToolSet;
|
||||
/** Дополнительные переменные окружения агента (например KHB_SQL_URL для команды khb-sql). */
|
||||
env?: Record<string, string>;
|
||||
}
|
||||
|
||||
/** Тайминг одного хода агента (для диагностики медленных ответов). */
|
||||
@@ -72,7 +74,7 @@ export function createCliRunner(opts: CliRunnerOptions): ClaudeRunner {
|
||||
const args = ["-p", "--output-format", "json", call.resume ? "--resume" : "--session-id", call.sessionId];
|
||||
if (opts.model) args.push("--model", opts.model);
|
||||
args.push(...(call.tools === "chat" ? CHAT_TOOLS : ["--tools", ""]));
|
||||
const child = spawn(opts.bin, args, { cwd: call.cwd, stdio: ["pipe", "pipe", "pipe"], env: { ...process.env, ANTHROPIC_API_KEY: "" } });
|
||||
const child = spawn(opts.bin, args, { cwd: call.cwd, stdio: ["pipe", "pipe", "pipe"], env: { ...process.env, ANTHROPIC_API_KEY: "", ...call.env } });
|
||||
const tStart = Date.now();
|
||||
let out = "";
|
||||
let err = "";
|
||||
|
||||
@@ -122,7 +122,7 @@ export function createLiveRunner(opts: LiveRunnerOptions): LiveRunner {
|
||||
];
|
||||
if (opts.model) args.push("--model", opts.model);
|
||||
args.push(...CHAT_TOOLS);
|
||||
const child = spawn(opts.bin, args, { cwd: call.cwd, stdio: ["pipe", "pipe", "pipe"], env: { ...process.env, ANTHROPIC_API_KEY: "" } });
|
||||
const child = spawn(opts.bin, args, { cwd: call.cwd, stdio: ["pipe", "pipe", "pipe"], env: { ...process.env, ANTHROPIC_API_KEY: "", ...call.env } });
|
||||
const p: Proc = { cwd: call.cwd, sessionId: call.sessionId, child, buf: "", stderr: "", turn: null, idle: null, exited: false, lastCost: call.resume ? null : 0, lastApiMs: call.resume ? null : 0, ready: Promise.resolve() };
|
||||
child.stdout.on("data", (d) => {
|
||||
p.buf += d;
|
||||
|
||||
@@ -100,7 +100,7 @@ export async function closeOrphanRuns(ctx: AgentContext): Promise<number> {
|
||||
*/
|
||||
export function runManagerAgent(
|
||||
ctx: AgentContext,
|
||||
opts: { managerId: string; step: "step2" | "step4"; tools: ToolSet; prompt: string; /** Полный промт для повтора в новой сессии, если prompt - короткий. */ fullPrompt?: string; required: string[] },
|
||||
opts: { managerId: string; step: "step2" | "step4"; tools: ToolSet; prompt: string; /** Полный промт для повтора в новой сессии, если prompt - короткий. */ fullPrompt?: string; /** Переменные окружения агента (KHB_SQL_URL и т.п.). */ env?: Record<string, string>; required: string[] },
|
||||
): Promise<AgentOutcome> {
|
||||
const tEnter = Date.now();
|
||||
return ctx.locks.run(opts.managerId, () =>
|
||||
@@ -113,7 +113,7 @@ export function runManagerAgent(
|
||||
const run: ClaudeRunner = async (c) => {
|
||||
const t = Date.now();
|
||||
try {
|
||||
const r = await base(c);
|
||||
const r = await base(opts.env ? { ...c, env: opts.env } : c);
|
||||
timing.runs.push({ wallMs: Date.now() - t, timing: r.timing, costUsd: r.costUsd });
|
||||
return r;
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user