Telegram: exec approvals for OpenCode/Codex (#37233)
Merged via squash. Prepared head SHA: f2433790941841ade0efe6292ff4909b2edd6f18 Co-authored-by: huntharo <5617868+huntharo@users.noreply.github.com> Co-authored-by: huntharo <5617868+huntharo@users.noreply.github.com> Reviewed-by: @huntharo
This commit is contained in:
@@ -57,6 +57,7 @@ type SystemRunExecutionContext = {
|
||||
sessionKey: string;
|
||||
runId: string;
|
||||
cmdText: string;
|
||||
suppressNotifyOnExit: boolean;
|
||||
};
|
||||
|
||||
type ResolvedExecApprovals = ReturnType<typeof resolveExecApprovals>;
|
||||
@@ -77,6 +78,7 @@ type SystemRunParsePhase = {
|
||||
timeoutMs: number | undefined;
|
||||
needsScreenRecording: boolean;
|
||||
approved: boolean;
|
||||
suppressNotifyOnExit: boolean;
|
||||
};
|
||||
|
||||
type SystemRunPolicyPhase = SystemRunParsePhase & {
|
||||
@@ -167,6 +169,7 @@ async function sendSystemRunDenied(
|
||||
host: "node",
|
||||
command: execution.cmdText,
|
||||
reason: params.reason,
|
||||
suppressNotifyOnExit: execution.suppressNotifyOnExit,
|
||||
}),
|
||||
);
|
||||
await opts.sendInvokeResult({
|
||||
@@ -216,6 +219,7 @@ async function parseSystemRunPhase(
|
||||
const agentId = opts.params.agentId?.trim() || undefined;
|
||||
const sessionKey = opts.params.sessionKey?.trim() || "node";
|
||||
const runId = opts.params.runId?.trim() || crypto.randomUUID();
|
||||
const suppressNotifyOnExit = opts.params.suppressNotifyOnExit === true;
|
||||
const envOverrides = sanitizeSystemRunEnvOverrides({
|
||||
overrides: opts.params.env ?? undefined,
|
||||
shellWrapper: shellCommand !== null,
|
||||
@@ -228,7 +232,7 @@ async function parseSystemRunPhase(
|
||||
agentId,
|
||||
sessionKey,
|
||||
runId,
|
||||
execution: { sessionKey, runId, cmdText },
|
||||
execution: { sessionKey, runId, cmdText, suppressNotifyOnExit },
|
||||
approvalDecision: resolveExecApprovalDecision(opts.params.approvalDecision),
|
||||
envOverrides,
|
||||
env: opts.sanitizeEnv(envOverrides),
|
||||
@@ -236,6 +240,7 @@ async function parseSystemRunPhase(
|
||||
timeoutMs: opts.params.timeoutMs ?? undefined,
|
||||
needsScreenRecording: opts.params.needsScreenRecording === true,
|
||||
approved: opts.params.approved === true,
|
||||
suppressNotifyOnExit,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -434,6 +439,7 @@ async function executeSystemRunPhase(
|
||||
runId: phase.runId,
|
||||
cmdText: phase.cmdText,
|
||||
result,
|
||||
suppressNotifyOnExit: phase.suppressNotifyOnExit,
|
||||
});
|
||||
await opts.sendInvokeResult({
|
||||
ok: true,
|
||||
@@ -501,6 +507,7 @@ async function executeSystemRunPhase(
|
||||
runId: phase.runId,
|
||||
cmdText: phase.cmdText,
|
||||
result,
|
||||
suppressNotifyOnExit: phase.suppressNotifyOnExit,
|
||||
});
|
||||
|
||||
await opts.sendInvokeResult({
|
||||
|
||||
@@ -13,6 +13,7 @@ export type SystemRunParams = {
|
||||
approved?: boolean | null;
|
||||
approvalDecision?: string | null;
|
||||
runId?: string | null;
|
||||
suppressNotifyOnExit?: boolean | null;
|
||||
};
|
||||
|
||||
export type RunResult = {
|
||||
@@ -35,6 +36,7 @@ export type ExecEventPayload = {
|
||||
success?: boolean;
|
||||
output?: string;
|
||||
reason?: string;
|
||||
suppressNotifyOnExit?: boolean;
|
||||
};
|
||||
|
||||
export type ExecFinishedResult = {
|
||||
@@ -51,6 +53,7 @@ export type ExecFinishedEventParams = {
|
||||
runId: string;
|
||||
cmdText: string;
|
||||
result: ExecFinishedResult;
|
||||
suppressNotifyOnExit?: boolean;
|
||||
};
|
||||
|
||||
export type SkillBinsProvider = {
|
||||
|
||||
@@ -355,6 +355,7 @@ async function sendExecFinishedEvent(
|
||||
timedOut: params.result.timedOut,
|
||||
success: params.result.success,
|
||||
output: combined,
|
||||
suppressNotifyOnExit: params.suppressNotifyOnExit,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user