(argv: string[])
| 243 | } |
| 244 | |
| 245 | function parseCapabilityProviderCommand(argv: string[]): RuntimeHostCliCommand { |
| 246 | if (argv[0] !== 'serve') { |
| 247 | return error( |
| 248 | argv[0] |
| 249 | ? `Unexpected runtime-host capability-provider command: ${argv[0]}` |
| 250 | : 'runtime-host capability-provider requires the serve command', |
| 251 | ); |
| 252 | } |
| 253 | let url: string | undefined; |
| 254 | let mcpConfigPath: string | undefined; |
| 255 | let expectedRootId: string | undefined; |
| 256 | let credentialEnv: string | undefined; |
| 257 | let clientIdentityPath: string | undefined; |
| 258 | for (let index = 1; index < argv.length; index += 1) { |
| 259 | const argument = argv[index]; |
| 260 | if ( |
| 261 | argument === '--url' || |
| 262 | argument === '--mcp-config' || |
| 263 | argument === '--expected-root' || |
| 264 | argument === '--credential-env' || |
| 265 | argument === '--client-identity' |
| 266 | ) { |
| 267 | const parsed = optionValue(argv, index, argument); |
| 268 | if (typeof parsed !== 'string') return parsed; |
| 269 | if (argument === '--url') url = parsed; |
| 270 | if (argument === '--mcp-config') mcpConfigPath = parsed; |
| 271 | if (argument === '--expected-root') expectedRootId = parsed; |
| 272 | if (argument === '--credential-env') credentialEnv = parsed; |
| 273 | if (argument === '--client-identity') clientIdentityPath = parsed; |
| 274 | index += 1; |
| 275 | continue; |
| 276 | } |
| 277 | return error(`Unexpected argument: ${argument ?? ''}`); |
| 278 | } |
| 279 | if (!url) return error('--url is required'); |
| 280 | if (!mcpConfigPath) return error('--mcp-config is required'); |
| 281 | if (!expectedRootId) return error('--expected-root is required'); |
| 282 | return { |
| 283 | kind: 'runtime-host-capability-provider-serve', |
| 284 | url, |
| 285 | mcpConfigPath, |
| 286 | expectedRootId, |
| 287 | ...(credentialEnv ? { credentialEnv } : {}), |
| 288 | ...(clientIdentityPath ? { clientIdentityPath } : {}), |
| 289 | }; |
| 290 | } |
| 291 | |
| 292 | function parseServeCommand(argv: string[]): RuntimeHostCliCommand { |
| 293 | let rootPath: string | undefined; |
no test coverage detected