(
runtime: AgentDeviceRuntime,
options:
| AdminInstallCommandOptions
| AdminReinstallCommandOptions
| AdminInstallFromSourceCommandOptions,
mode: 'install' | 'reinstall' | 'installFromSource',
)
| 145 | await runInstallCommand(runtime, options, 'installFromSource'); |
| 146 | |
| 147 | async function runInstallCommand( |
| 148 | runtime: AgentDeviceRuntime, |
| 149 | options: |
| 150 | | AdminInstallCommandOptions |
| 151 | | AdminReinstallCommandOptions |
| 152 | | AdminInstallFromSourceCommandOptions, |
| 153 | mode: 'install' | 'reinstall' | 'installFromSource', |
| 154 | ): Promise<AdminInstallCommandResult> { |
| 155 | const methodName = mode === 'reinstall' ? 'reinstallApp' : 'installApp'; |
| 156 | const method = runtime.backend[methodName]; |
| 157 | if (!method) { |
| 158 | throw new AppError('UNSUPPORTED_OPERATION', `admin.${mode} is not supported by this backend`); |
| 159 | } |
| 160 | |
| 161 | const app = |
| 162 | 'app' in options && options.app !== undefined ? requireText(options.app, 'app') : undefined; |
| 163 | if (mode !== 'installFromSource' && !app) { |
| 164 | throw new AppError('INVALID_ARGS', `admin.${mode} requires app`); |
| 165 | } |
| 166 | |
| 167 | const context = toBackendContext(runtime, options); |
| 168 | const resolved = await resolveInstallSource(runtime, context, options.source); |
| 169 | try { |
| 170 | const result = await method.call(runtime.backend, context, { |
| 171 | ...(app ? { app } : {}), |
| 172 | source: resolved.source, |
| 173 | }); |
| 174 | return formatInstallResult(mode, app, resolved.source, result); |
| 175 | } finally { |
| 176 | await resolved.cleanup?.(); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | async function resolveInstallSource( |
| 181 | runtime: AgentDeviceRuntime, |
no test coverage detected