@@ -158,13 +158,19 @@ export async function registerExecApprovalRequest(
|
158 | 158 | return { id, expiresAtMs }; |
159 | 159 | } |
160 | 160 | |
161 | | -/** Waits for a registered approval decision, returning null when it expires. */ |
162 | | -export async function waitForExecApprovalDecision(id: string): Promise<string | null> { |
| 161 | +/** Uses a pre-resolved decision or waits for the registered approval id. */ |
| 162 | +export async function resolveRegisteredExecApprovalDecision(params: { |
| 163 | +approvalId: string; |
| 164 | +preResolvedDecision: string | null | undefined; |
| 165 | +}): Promise<string | null> { |
| 166 | +if (params.preResolvedDecision !== undefined) { |
| 167 | +return params.preResolvedDecision ?? null; |
| 168 | +} |
163 | 169 | try { |
164 | 170 | const decisionResult = await callGatewayTool<{ decision: string }>( |
165 | 171 | "exec.approval.waitDecision", |
166 | 172 | { timeoutMs: DEFAULT_APPROVAL_REQUEST_TIMEOUT_MS }, |
167 | | -{ id }, |
| 173 | +{ id: params.approvalId }, |
168 | 174 | ); |
169 | 175 | return parseDecision(decisionResult).value; |
170 | 176 | } catch (err) { |
@@ -177,17 +183,6 @@ export async function waitForExecApprovalDecision(id: string): Promise<string |
|
177 | 183 | } |
178 | 184 | } |
179 | 185 | |
180 | | -/** Uses a pre-resolved decision or waits for the registered approval id. */ |
181 | | -export async function resolveRegisteredExecApprovalDecision(params: { |
182 | | -approvalId: string; |
183 | | -preResolvedDecision: string | null | undefined; |
184 | | -}): Promise<string | null> { |
185 | | -if (params.preResolvedDecision !== undefined) { |
186 | | -return params.preResolvedDecision ?? null; |
187 | | -} |
188 | | -return await waitForExecApprovalDecision(params.approvalId); |
189 | | -} |
190 | | - |
191 | 186 | type HostExecApprovalParams = { |
192 | 187 | approvalId: string; |
193 | 188 | command?: string; |
|