fix(caserun): 收敛现有类型诊断
This commit is contained in:
@@ -54,7 +54,7 @@ export function agentTraceLookup(input: { baseUrl: string; traceId: string; sess
|
||||
export function agentTraceIdentityArtifact(run: PreparedCaseRun, agent: AgentRunStage) {
|
||||
const traceId = text(agent.traceId);
|
||||
const lookup = agent.traceLookup ?? agentTraceLookup({ baseUrl: agent.baseUrl, traceId, sessionId: agent.sessionId, conversationId: agent.conversationId, threadId: agent.threadId });
|
||||
const resultBody = agent.result?.body && typeof agent.result.body === "object" ? agent.result.body : agent.result;
|
||||
const resultBody = (agent.result?.body && typeof agent.result.body === "object" ? agent.result.body : agent.result) as Record<string, any>;
|
||||
return clean({
|
||||
contractVersion: "hwpod-case-run-agent-trace-identity-v1",
|
||||
source: "caserun-identity",
|
||||
|
||||
@@ -37,7 +37,7 @@ export async function refreshCaseRegistryArtifacts(context: CaseContext, caseRep
|
||||
const sync = context.parsed.noCaseRepoGitSync === true
|
||||
? null
|
||||
: await syncCaseRegistryRel(context, caseRepo, `runs/${caseId}/${runId}`, `data: refresh caserun artifacts ${runId}`);
|
||||
const trace = final.manifest.trace ?? first.manifest.trace ?? {};
|
||||
const trace = (final.manifest.trace ?? first.manifest.trace ?? {}) as Record<string, any>;
|
||||
return ok("case.refresh", {
|
||||
caseId,
|
||||
runId,
|
||||
@@ -252,4 +252,4 @@ async function readText(file: string) { try { return await readFile(file, "utf8"
|
||||
async function isDirectory(file: string) { try { return (await stat(file)).isDirectory(); } catch { return false; } }
|
||||
function escapeRegExp(value: string) { return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"); }
|
||||
function cliError(code: string, message: string, details: Record<string, unknown> = {}) { return Object.assign(new Error(message), { code, details }); }
|
||||
function ok(action: string, extra: Record<string, unknown> = {}) { return { ok: true, action, status: "completed", ...extra }; }
|
||||
function ok<T extends Record<string, unknown>>(action: string, extra: T) { return { ok: true, action, status: "completed", ...extra }; }
|
||||
|
||||
@@ -250,7 +250,7 @@ async function runCaseRunWorker(context: CaseContext) {
|
||||
const caseId = requiredText(context.parsed.caseId ?? context.rest[2], "caseId");
|
||||
const runId = requiredText(context.parsed.runId, "runId");
|
||||
const runDir = path.resolve(context.cwd, requiredText(context.parsed.runDir, "runDir"));
|
||||
const workerContext = { ...context, parsed: { ...context.parsed, runId, runDir }, rest: ["run", caseId] };
|
||||
const workerContext: CaseContext = { ...context, parsed: { ...context.parsed, runId, runDir }, rest: ["run", caseId] };
|
||||
await writeRunControl(workerContext, await loadControlRunSkeleton(workerContext, caseId, runId, runDir), { status: "running", stage: "worker-running", startedAt: context.now() });
|
||||
try {
|
||||
let payload = await runCaseRun(workerContext);
|
||||
@@ -505,7 +505,7 @@ export async function buildCaseRun(context: CaseContext, prepared?: PreparedCase
|
||||
keilJob: job ? job.summary : null,
|
||||
validation: clean({ plan: validationPlan, results: validationResults, blocker: validationBlocker, archivePath: "validation-observations.json" }),
|
||||
replay: validationReplay,
|
||||
artifacts: job?.summary?.artifacts ?? [],
|
||||
artifacts: job?.summary && "artifacts" in job.summary ? job.summary.artifacts : [],
|
||||
decisions: {
|
||||
autoEvaluation: false,
|
||||
runnerPostAgentCompileCheck: "recorded",
|
||||
@@ -723,8 +723,8 @@ async function runAgentTaskStage(context: CaseContext, run: PreparedCaseRun) {
|
||||
const nextRun = await updateRun(context, run, { agent });
|
||||
return { run: nextRun, agent };
|
||||
}
|
||||
const sessionId = session.sessionId;
|
||||
const threadId = session.threadId;
|
||||
const sessionId = "sessionId" in session ? session.sessionId : "";
|
||||
const threadId = "threadId" in session ? session.threadId : "";
|
||||
const traceId = text(context.parsed.traceId) || `trc_case_${slug(run.caseId)}_${randomUUID().replace(/-/gu, "")}`;
|
||||
run = await updateRun(context, run, { stage: "agent-submitting", agent: agentFailureStage({ stageStatus: "session_created", baseUrl, projectId, providerProfile, conversationId, sessionId, threadId, traceId, promptPath, promptSha256, sessionResponse: compactObject(session.body) }) });
|
||||
const accepted = await submitAgentTask(context, { baseUrl, projectId, providerProfile, conversationId, sessionId, threadId, traceId, prompt });
|
||||
@@ -1422,5 +1422,5 @@ function extractPrepareBlocker(summary: ReturnType<typeof errorSummary>) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function ok(action: string, extra: Record<string, unknown> = {}, status = "succeeded") { return { ok: status !== "failed", action, status, ...extra }; }
|
||||
function ok<T extends Record<string, unknown>>(action: string, extra: T, status = "succeeded") { return { ok: status !== "failed", action, status, ...extra }; }
|
||||
function requiredText(value: unknown, field: string) { const result = text(value); if (!result) throw cliError("missing_required_value", `${field} is required`, { field }); return result; }
|
||||
|
||||
@@ -337,7 +337,7 @@ export async function requestKeilJobStatus(context: CaseContext, run: PreparedCa
|
||||
const document = await readHwpodSpec(run.specPath);
|
||||
const keilCliPath = text(document.spec.workspace.keilCliPath) || text(document.spec.debugProbe.keilCliPath) || "keil-cli.py";
|
||||
const pythonCommand = text(document.spec.workspace.pythonCommand) || text(document.spec.debugProbe.pythonCommand) || "py -3";
|
||||
const jobStatusCommand = jobStatusCommandForTest(pythonCommand, keilCliPath, jobId, document.spec.workspace.path);
|
||||
const jobStatusCommand = jobStatusCommandForTest(pythonCommand, keilCliPath, jobId);
|
||||
const hwpodId = text(document.metadata.name) || text(document.metadata.uid) || run.caseId;
|
||||
const plan = {
|
||||
contractVersion: "hwpod-node-ops-v1",
|
||||
|
||||
Reference in New Issue
Block a user