feat: 支持运行中 steer command

This commit is contained in:
Codex
2026-06-02 10:04:36 +08:00
parent 1d45d272f1
commit d90e01a91c
15 changed files with 206 additions and 13 deletions
+3 -1
View File
@@ -113,8 +113,10 @@ export interface RunRecord extends CreateRunInput {
leaseExpiresAt: string | null;
}
export type CommandType = "turn" | "steer" | "interrupt";
export interface CreateCommandInput extends JsonRecord {
type: "turn" | "interrupt";
type: CommandType;
payload: JsonRecord;
idempotencyKey?: string;
}
+10 -1
View File
@@ -215,12 +215,21 @@ function validateBackendSecretScope(backendProfile: BackendProfile, executionPol
export function validateCreateCommand(input: unknown): CreateCommandInput {
const record = asRecord(input, "command");
const type = requiredString(record, "type");
if (type !== "turn" && type !== "interrupt") throw new AgentRunError("schema-invalid", `command type ${type} is not supported`, { httpStatus: 400 });
if (type !== "turn" && type !== "steer" && type !== "interrupt") throw new AgentRunError("schema-invalid", `command type ${type} is not supported`, { httpStatus: 400 });
const payload = asRecord(record.payload ?? {}, "payload");
if (type === "steer" && !steerPrompt(payload)) throw new AgentRunError("schema-invalid", "steer command payload requires a non-empty prompt, message, or text", { httpStatus: 400 });
const idempotencyKey = typeof record.idempotencyKey === "string" && record.idempotencyKey.trim().length > 0 ? record.idempotencyKey.trim() : undefined;
return { type, payload, ...(idempotencyKey ? { idempotencyKey } : {}) };
}
function steerPrompt(payload: JsonRecord): string | null {
for (const key of ["prompt", "message", "text"]) {
const value = payload[key];
if (typeof value === "string" && value.trim().length > 0) return value.trim();
}
return null;
}
export function validateCreateQueueTask(input: unknown): CreateQueueTaskInput {
const record = asRecord(input, "queueTask");
const tenantId = requiredString(record, "tenantId");