( runtime: AgentDeviceRuntime, context: BackendCommandContext, source: BackendInstallSource | undefined, )
| 178 | } |
| 179 | |
| 180 | async function resolveInstallSource( |
| 181 | runtime: AgentDeviceRuntime, |
| 182 | context: BackendCommandContext, |
| 183 | source: BackendInstallSource | undefined, |
| 184 | ): Promise<{ source: BackendInstallSource; cleanup?: () => Promise<void> }> { |
| 185 | const normalized = normalizeInstallSource(source); |
| 186 | const localResolved = await resolveLocalInstallSource(runtime, normalized); |
| 187 | try { |
| 188 | const backendResolved = runtime.backend.resolveInstallSource |
| 189 | ? await runtime.backend.resolveInstallSource(context, localResolved.source) |
| 190 | : localResolved.source; |
| 191 | return { |
| 192 | source: normalizeInstallSource(backendResolved), |
| 193 | ...(localResolved.cleanup ? { cleanup: localResolved.cleanup } : {}), |
| 194 | }; |
| 195 | } catch (error) { |
| 196 | if (localResolved.cleanup) { |
| 197 | try { |
| 198 | await localResolved.cleanup(); |
| 199 | } catch { |
| 200 | // Best-effort cleanup; preserve the original install source resolution failure. |
| 201 | } |
| 202 | } |
| 203 | throw error; |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | async function resolveLocalInstallSource( |
| 208 | runtime: AgentDeviceRuntime, |
no test coverage detected
searching dependent graphs…