- agent_run_event gains plan_updated, options_proposed/resolved, approval_requested/resolved (migration 0040)
- AgentRunStartInput.proposeFirst; mode deprecated (plan_only maps to proposeFirst); mode dropped from AgentRun API
- POST /agent/runs/{id}/choice; agent.optionsTimeoutSec/optionsTimeoutAction/approvalTimeoutSec settings
Co-Authored-By: Claude Opus 5.5 <[email protected]>
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import type { Kysely } from "kysely";
|
|
import { execDdl, oneOf } from "../src/migration-helpers.ts";
|
|
|
|
// AG-2 Agent 交互改为自动化优先:取消 plan_only / execute 运行模式(agent_run.mode 列保留为内部能力上限),
|
|
// agent_run_event 增加会话交互事件:
|
|
// plan_updated(agent.plan 步骤清单)、options_proposed / options_resolved(agent.propose_options 方案选择)、
|
|
// approval_requested / approval_resolved(需审批的能力在步骤处的审批卡)。
|
|
|
|
const OLD_TYPES = [
|
|
"run_started",
|
|
"text_delta",
|
|
"thinking_delta",
|
|
"tool_call_start",
|
|
"tool_call_end",
|
|
"tool_call_rejected",
|
|
"compaction",
|
|
"run_completed",
|
|
"run_failed",
|
|
"subagent_spawned",
|
|
"subagent_event",
|
|
"subagent_completed",
|
|
];
|
|
const ADDED = ["plan_updated", "options_proposed", "options_resolved", "approval_requested", "approval_resolved"];
|
|
|
|
const swap = (values: readonly string[]) => `
|
|
alter table agent_run_event drop constraint agent_run_event_type_check;
|
|
alter table agent_run_event add constraint agent_run_event_type_check ${oneOf("type", values)};
|
|
`;
|
|
|
|
// biome-ignore lint/suspicious/noExplicitAny: 迁移不依赖应用表类型
|
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
await execDdl(db, swap([...OLD_TYPES, ...ADDED]));
|
|
}
|
|
|
|
// biome-ignore lint/suspicious/noExplicitAny: 同上
|
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
await execDdl(
|
|
db,
|
|
`
|
|
delete from agent_run_event where type in (${ADDED.map((t) => `'${t}'`).join(", ")});
|
|
${swap(OLD_TYPES)}`,
|
|
);
|
|
}
|