mirror of https://github.com/openclaw/openclaw.git
refactor: share system run success delivery
This commit is contained in:
parent
a2fcaf9774
commit
8f852ef82f
|
|
@ -182,6 +182,25 @@ async function sendSystemRunDenied(
|
|||
});
|
||||
}
|
||||
|
||||
async function sendSystemRunCompleted(
|
||||
opts: Pick<HandleSystemRunInvokeOptions, "sendExecFinishedEvent" | "sendInvokeResult">,
|
||||
execution: SystemRunExecutionContext,
|
||||
result: ExecFinishedResult,
|
||||
payloadJSON: string,
|
||||
) {
|
||||
await opts.sendExecFinishedEvent({
|
||||
sessionKey: execution.sessionKey,
|
||||
runId: execution.runId,
|
||||
commandText: execution.commandText,
|
||||
result,
|
||||
suppressNotifyOnExit: execution.suppressNotifyOnExit,
|
||||
});
|
||||
await opts.sendInvokeResult({
|
||||
ok: true,
|
||||
payloadJSON,
|
||||
});
|
||||
}
|
||||
|
||||
export { formatSystemRunAllowlistMissMessage } from "./exec-policy.js";
|
||||
export { buildSystemRunApprovalPlan } from "./invoke-system-run-plan.js";
|
||||
|
||||
|
|
@ -462,17 +481,7 @@ async function executeSystemRunPhase(
|
|||
return;
|
||||
} else {
|
||||
const result: ExecHostRunResult = response.payload;
|
||||
await opts.sendExecFinishedEvent({
|
||||
sessionKey: phase.sessionKey,
|
||||
runId: phase.runId,
|
||||
commandText: phase.commandText,
|
||||
result,
|
||||
suppressNotifyOnExit: phase.suppressNotifyOnExit,
|
||||
});
|
||||
await opts.sendInvokeResult({
|
||||
ok: true,
|
||||
payloadJSON: JSON.stringify(result),
|
||||
});
|
||||
await sendSystemRunCompleted(opts, phase.execution, result, JSON.stringify(result));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -530,17 +539,11 @@ async function executeSystemRunPhase(
|
|||
|
||||
const result = await opts.runCommand(execArgv, phase.cwd, phase.env, phase.timeoutMs);
|
||||
applyOutputTruncation(result);
|
||||
await opts.sendExecFinishedEvent({
|
||||
sessionKey: phase.sessionKey,
|
||||
runId: phase.runId,
|
||||
commandText: phase.commandText,
|
||||
await sendSystemRunCompleted(
|
||||
opts,
|
||||
phase.execution,
|
||||
result,
|
||||
suppressNotifyOnExit: phase.suppressNotifyOnExit,
|
||||
});
|
||||
|
||||
await opts.sendInvokeResult({
|
||||
ok: true,
|
||||
payloadJSON: JSON.stringify({
|
||||
JSON.stringify({
|
||||
exitCode: result.exitCode,
|
||||
timedOut: result.timedOut,
|
||||
success: result.success,
|
||||
|
|
@ -548,7 +551,7 @@ async function executeSystemRunPhase(
|
|||
stderr: result.stderr,
|
||||
error: result.error ?? null,
|
||||
}),
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
export async function handleSystemRunInvoke(opts: HandleSystemRunInvokeOptions): Promise<void> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue