fix(coding-agent): complete Agent Hub inspector metadata
This commit is contained in:
@@ -3314,7 +3314,7 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
|
||||
const done = await runSubagent();
|
||||
monitor.finish();
|
||||
|
||||
return finalizeRunResult({
|
||||
const result = await finalizeRunResult({
|
||||
monitor,
|
||||
done,
|
||||
index,
|
||||
@@ -3335,4 +3335,6 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
|
||||
sessionFile: subtaskSessionFile,
|
||||
startTime,
|
||||
});
|
||||
AgentRegistry.global().setHistory(id, { outputPath: result.outputPath });
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
import * as path from "node:path";
|
||||
import type * as natives from "@oh-my-pi/pi-natives";
|
||||
import { AgentRegistry } from "../registry/agent-registry";
|
||||
import type { ToolSession } from "../tools";
|
||||
import { generateCommitMessage } from "../utils/commit-message-generator";
|
||||
import * as git from "../utils/git";
|
||||
@@ -43,6 +44,15 @@ import {
|
||||
|
||||
type IsoBackendKind = natives.IsoBackendKind;
|
||||
|
||||
function rememberAgentArtifacts(result: SingleResult): SingleResult {
|
||||
AgentRegistry.global().setHistory(result.id, {
|
||||
outputPath: result.outputPath,
|
||||
patchPath: result.patchPath,
|
||||
branchName: result.branchName,
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Resolved repo + baseline used by every isolated spawn in a single call. */
|
||||
export interface IsolationContext {
|
||||
repoRoot: string;
|
||||
@@ -165,14 +175,14 @@ export async function runIsolatedSubprocess(opts: IsolatedRunOptions): Promise<S
|
||||
opts.description,
|
||||
opts.buildCommitMessage?.(),
|
||||
);
|
||||
return {
|
||||
return rememberAgentArtifacts({
|
||||
...result,
|
||||
branchName: commitResult?.branchName,
|
||||
branchBaseSha: commitResult?.baseSha,
|
||||
nestedPatches: commitResult?.nestedPatches,
|
||||
};
|
||||
});
|
||||
} catch (mergeErr) {
|
||||
// Agent succeeded but branch commit failed — clean up stale branch
|
||||
// Agent succeeded but branch commit failed — clean up stale branch.
|
||||
const branchName = `omp/task/${opts.agentId}`;
|
||||
await git.branch.tryDelete(opts.context.repoRoot, branchName);
|
||||
const msg = mergeErr instanceof Error ? mergeErr.message : String(mergeErr);
|
||||
@@ -183,34 +193,37 @@ export async function runIsolatedSubprocess(opts: IsolatedRunOptions): Promise<S
|
||||
opts.artifactsDir,
|
||||
opts.agentId,
|
||||
);
|
||||
return {
|
||||
return rememberAgentArtifacts({
|
||||
...result,
|
||||
patchPath: patchResult.patchPath,
|
||||
nestedPatches: patchResult.nestedPatches,
|
||||
error: `Merge failed: ${msg}`,
|
||||
};
|
||||
});
|
||||
} catch (patchErr) {
|
||||
const patchMsg = patchErr instanceof Error ? patchErr.message : String(patchErr);
|
||||
return { ...result, error: `Merge failed: ${msg}; patch capture failed: ${patchMsg}` };
|
||||
return rememberAgentArtifacts({
|
||||
...result,
|
||||
error: `Merge failed: ${msg}; patch capture failed: ${patchMsg}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result.exitCode === 0) {
|
||||
try {
|
||||
const patchResult = await writeIsolationPatch(isolationDir, taskBaseline, opts.artifactsDir, opts.agentId);
|
||||
return {
|
||||
return rememberAgentArtifacts({
|
||||
...result,
|
||||
patchPath: patchResult.patchPath,
|
||||
nestedPatches: patchResult.nestedPatches,
|
||||
};
|
||||
});
|
||||
} catch (patchErr) {
|
||||
const msg = patchErr instanceof Error ? patchErr.message : String(patchErr);
|
||||
return { ...result, error: `Patch capture failed: ${msg}` };
|
||||
return rememberAgentArtifacts({ ...result, error: `Patch capture failed: ${msg}` });
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return rememberAgentArtifacts(result);
|
||||
} catch (err) {
|
||||
return opts.buildFailureResult(err);
|
||||
return rememberAgentArtifacts(opts.buildFailureResult(err));
|
||||
} finally {
|
||||
if (handle) {
|
||||
await cleanupIsolation(handle);
|
||||
|
||||
Reference in New Issue
Block a user