feat: 支持运行中 steer command
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user