fix(agentrun): 简化 Artificer Target 派单

This commit is contained in:
Codex
2026-07-13 09:30:48 +02:00
parent 1fb29561fc
commit 43124d01e8
16 changed files with 1190 additions and 26 deletions
+71
View File
@@ -496,12 +496,83 @@ export function renderMutationSummary(command: string, raw: Record<string, unkno
if (decision !== null) lines.push(`Decision: ${decision}`);
if (internalCommandType !== null) lines.push(`InternalCommandType: ${internalCommandType}`);
lines.push(...renderCancelLifecycleMutationLines(record(data.cancelLifecycle ?? raw.cancelLifecycle)));
lines.push(...renderTargetTaskMutationLines(record(data.targetTask ?? raw.targetTask)));
lines.push(...renderAipodBindingMutationLines(record(data.aipodBinding ?? raw.aipodBinding)));
lines.push(...renderAutoDispatchMutationLines(record(data.autoDispatch ?? raw.autoDispatch)));
lines.push(...renderDispatchPlanMutationLines(record(data.dispatchPlan ?? raw.dispatchPlan)));
const next = record(raw.next ?? data.next);
const nextLines = (overrideNextLines ?? Object.values(next).map(String)).filter((line) => line.length > 0).slice(0, 5);
if (nextLines.length > 0) lines.push("", "Next:", ...nextLines.map((line) => ` ${line}`));
return renderedCliResult(raw.ok !== false, command, lines.join("\n"));
}
export function renderTargetTaskMutationLines(targetTask: Record<string, unknown>): string[] {
if (Object.keys(targetTask).length === 0) return [];
const workspace = record(targetTask.workspace);
return [
"",
"TargetTaskPreflight:",
` MDTODO: ${displayValue(targetTask.mdtodoId)} project=${displayValue(targetTask.projectId)}`,
` Target: ${displayValue(targetTask.targetRoute)}`,
` Source: ${displayValue(targetTask.repository)} ref=${displayValue(targetTask.ref)}`,
` Commit: HEAD=${displayValue(workspace.headCommit)} remote=${displayValue(targetTask.verifiedCommit)}`,
` Worktree: branch=${displayValue(workspace.branch)} clean=${displayValue(workspace.clean)} relation=${displayValue(targetTask.refRelation)}`,
];
}
export function renderAipodBindingMutationLines(binding: Record<string, unknown>): string[] {
if (Object.keys(binding).length === 0) return [];
const workspaceRef = record(binding.workspaceRef);
const resourceBundleRef = record(binding.resourceBundleRef);
const session = record(binding.session);
const providerCredentials = arrayRecords(binding.providerCredentials);
const toolCredentials = arrayRecords(binding.toolCredentials);
const lines = [
"",
"AipodBinding:",
` Aipod: ${displayValue(binding.aipod)} target=${displayValue(binding.node)}/${displayValue(binding.lane)} namespace=${displayValue(binding.namespace)}`,
` WorkspaceRef: kind=${displayValue(workspaceRef.kind)} path=${displayValue(workspaceRef.path)} valid=${displayValue(workspaceRef.valid)}`,
` ResourceBundle: ${displayValue(resourceBundleRef.repoUrl)} ref=${displayValue(resourceBundleRef.ref)} inherited=${displayValue(resourceBundleRef.inheritedFromAipod)}`,
` Session: ${displayValue(session.sessionId)} source=${displayValue(session.identitySource)}`,
];
for (const credential of providerCredentials.slice(0, 4)) {
const secretRef = record(credential.secretRef);
lines.push(` ProviderSecretRef: ${displayValue(secretRef.namespace)}/${displayValue(secretRef.name)} keys=${displayValue(secretRef.keys)} present=${displayValue(credential.bindingPresent)}`);
}
for (const credential of toolCredentials.slice(0, 6)) {
const secretRef = record(credential.secretRef);
lines.push(` ToolSecretRef: ${displayValue(credential.tool)} ${displayValue(secretRef.namespace)}/${displayValue(secretRef.name)} keys=${displayValue(secretRef.keys)} present=${displayValue(credential.bindingPresent)}`);
}
return lines;
}
export function renderAutoDispatchMutationLines(autoDispatch: Record<string, unknown>): string[] {
if (Object.keys(autoDispatch).length === 0) return [];
const identity = record(autoDispatch.identity);
return [
"",
"AutoDispatch:",
` Decision: ${displayValue(autoDispatch.decision)} mutation=${displayValue(autoDispatch.mutation)} duplicatePrevented=${displayValue(autoDispatch.duplicateDispatchPrevented)}`,
` Task: ${displayValue(identity.taskId)} state=${displayValue(identity.taskState)} attempt=${displayValue(identity.attemptId)}`,
` Run: ${displayValue(identity.runId)} command=${displayValue(identity.commandId)} runner=${displayValue(identity.runnerJobId)}`,
` Session: ${displayValue(identity.sessionId)}`,
];
}
export function renderDispatchPlanMutationLines(plan: Record<string, unknown>): string[] {
if (Object.keys(plan).length === 0) return [];
const request = record(plan.request);
const sequence = Array.isArray(plan.sequence) ? plan.sequence.map(String).join(" -> ") : "-";
return [
"",
"AutoDispatchPlan:",
` Sequence: ${sequence}`,
` Request: ${displayValue(request.method)} ${displayValue(request.pathTemplate)}`,
` Condition: ${displayValue(plan.condition)}`,
` Replay: ${displayValue(plan.replay)}`,
];
}
export function renderCancelLifecycleMutationLines(lifecycle: Record<string, unknown>): string[] {
if (Object.keys(lifecycle).length === 0) return [];
const authority = record(lifecycle.authority);