feat: 补齐 HWLAB 手动调度能力
This commit is contained in:
+23
-1
@@ -36,6 +36,11 @@ async function dispatch(args: ParsedArgs): Promise<JsonValue> {
|
||||
if (group === "runs" && command === "create") return client(args).post("/api/v1/runs", await jsonFile(args));
|
||||
if (group === "runs" && command === "show" && id) return client(args).get(`/api/v1/runs/${encodeURIComponent(id)}`);
|
||||
if (group === "runs" && command === "events" && id) return client(args).get(`/api/v1/runs/${encodeURIComponent(id)}/events?afterSeq=${flag(args, "after-seq", "0")}&limit=${flag(args, "limit", "100")}`);
|
||||
if (group === "runs" && command === "result" && id) {
|
||||
const commandId = optionalFlag(args, "command-id");
|
||||
return client(args).get(`/api/v1/runs/${encodeURIComponent(id)}/result${commandId ? `?commandId=${encodeURIComponent(commandId)}` : ""}`);
|
||||
}
|
||||
if (group === "runs" && command === "cancel" && id) return client(args).post(`/api/v1/runs/${encodeURIComponent(id)}/cancel`, cancelBody(args));
|
||||
if (group === "commands" && command === "create" && id) {
|
||||
const body = await jsonFile(args);
|
||||
if (!body.type) body.type = flag(args, "type", "turn");
|
||||
@@ -48,6 +53,12 @@ async function dispatch(args: ParsedArgs): Promise<JsonValue> {
|
||||
if (!runId) throw new AgentRunError("schema-invalid", "commands show requires --run-id", { httpStatus: 2 });
|
||||
return client(args).get(`/api/v1/runs/${encodeURIComponent(runId)}/commands/${encodeURIComponent(id)}`);
|
||||
}
|
||||
if (group === "commands" && command === "result" && id) {
|
||||
const runId = flag(args, "run-id", "");
|
||||
if (!runId) throw new AgentRunError("schema-invalid", "commands result requires --run-id", { httpStatus: 2 });
|
||||
return client(args).get(`/api/v1/runs/${encodeURIComponent(runId)}/commands/${encodeURIComponent(id)}/result`);
|
||||
}
|
||||
if (group === "commands" && command === "cancel" && id) return client(args).post(`/api/v1/commands/${encodeURIComponent(id)}/cancel`, cancelBody(args));
|
||||
if (group === "runner" && command === "start") {
|
||||
const runId = flag(args, "run-id", "");
|
||||
if (!runId) throw new AgentRunError("schema-invalid", "runner start requires --run-id", { httpStatus: 2 });
|
||||
@@ -86,11 +97,13 @@ async function renderRunnerJob(args: ParsedArgs): Promise<JsonRecord> {
|
||||
const runnerId = optionalFlag(args, "runner-id");
|
||||
const sourceCommit = optionalFlag(args, "source-commit");
|
||||
const runnerManagerUrl = optionalFlag(args, "runner-manager-url");
|
||||
const idempotencyKey = optionalFlag(args, "idempotency-key");
|
||||
if (namespace) body.namespace = namespace;
|
||||
if (attemptId) body.attemptId = attemptId;
|
||||
if (runnerId) body.runnerId = runnerId;
|
||||
if (sourceCommit) body.sourceCommit = sourceCommit;
|
||||
if (runnerManagerUrl) body.managerUrl = runnerManagerUrl;
|
||||
if (idempotencyKey) body.idempotencyKey = idempotencyKey;
|
||||
return await client(args).post(`/api/v1/runs/${encodeURIComponent(runId)}/runner-jobs`, body) as JsonRecord;
|
||||
}
|
||||
if (!image) throw new AgentRunError("schema-invalid", "runner job --dry-run requires --image", { httpStatus: 2 });
|
||||
@@ -188,16 +201,25 @@ function optionalFlag(args: ParsedArgs, name: string): string | null {
|
||||
return typeof value === "string" && value.length > 0 ? value : null;
|
||||
}
|
||||
|
||||
function cancelBody(args: ParsedArgs): JsonRecord {
|
||||
const reason = optionalFlag(args, "reason");
|
||||
return reason ? { reason } : {};
|
||||
}
|
||||
|
||||
function help(): JsonRecord {
|
||||
return {
|
||||
commands: [
|
||||
"runs create --json-file <run.json>",
|
||||
"runs show <runId>",
|
||||
"runs events <runId> --after-seq <n> --limit <n>",
|
||||
"runs result <runId> [--command-id <commandId>]",
|
||||
"runs cancel <runId> [--reason <text>]",
|
||||
"commands create <runId> --type turn --json-file <payload.json>",
|
||||
"commands show <commandId> --run-id <runId>",
|
||||
"commands result <commandId> --run-id <runId>",
|
||||
"commands cancel <commandId> [--reason <text>]",
|
||||
"runner start --run-id <runId> [--backend codex|deepseek]",
|
||||
"runner job --run-id <runId> --command-id <commandId> [--image <image>] [--runner-manager-url <url>]",
|
||||
"runner job --run-id <runId> --command-id <commandId> [--image <image>] [--runner-manager-url <url>] [--idempotency-key <key>]",
|
||||
"runner job --dry-run --run-id <runId> --command-id <commandId> --image <image>",
|
||||
"secrets codex render --dry-run [--profile codex|deepseek] [--codex-home <dir>] [--namespace agentrun-v01] [--secret-name <name>]",
|
||||
"backends list",
|
||||
|
||||
Reference in New Issue
Block a user