(
argv: readonly string[],
overrides: Partial<MakaRunEnvironmentDeps> = {},
commandOverrides: Partial<RuntimeHostRunCommandDeps> = {},
options: RuntimeHostTextCliOptions = {
cliCommand: 'maka',
clientDataRoot: resolveMakaClientDataRoot(),
},
)
| 68 | } |
| 69 | |
| 70 | export async function runRuntimeHostTextCli( |
| 71 | argv: readonly string[], |
| 72 | overrides: Partial<MakaRunEnvironmentDeps> = {}, |
| 73 | commandOverrides: Partial<RuntimeHostRunCommandDeps> = {}, |
| 74 | options: RuntimeHostTextCliOptions = { |
| 75 | cliCommand: 'maka', |
| 76 | clientDataRoot: resolveMakaClientDataRoot(), |
| 77 | }, |
| 78 | ): Promise<number> { |
| 79 | const commandDeps = { ...defaultRuntimeHostRunCommandDeps(), ...commandOverrides }; |
| 80 | let connected: RuntimeHostCliConnectionContext | undefined; |
| 81 | const connect = async ( |
| 82 | rootPath: string, |
| 83 | hostProfileId?: string, |
| 84 | ): Promise<RuntimeHostCliConnectionContext> => { |
| 85 | connected ??= await commandDeps.connect(rootPath, hostProfileId, options.clientDataRoot); |
| 86 | return connected; |
| 87 | }; |
| 88 | try { |
| 89 | return await commandDeps.run( |
| 90 | argv, |
| 91 | { |
| 92 | listSessions: async (rootPath, hostProfileId) => |
| 93 | runtimeHostSessionSummaries( |
| 94 | await readRuntimeHostSessions((await connect(rootPath, hostProfileId)).connection), |
| 95 | ), |
| 96 | createContext: async (input) => { |
| 97 | const context = await connect(input.workspaceRoot, input.hostProfileId); |
| 98 | const preparedInput = await prepareRuntimeHostRunInput( |
| 99 | context.connection, |
| 100 | context.catalog, |
| 101 | context.profile, |
| 102 | input, |
| 103 | options.cliCommand, |
| 104 | ); |
| 105 | return commandDeps.createContext( |
| 106 | context.connection, |
| 107 | context.catalog, |
| 108 | preparedInput, |
| 109 | context.profile, |
| 110 | ); |
| 111 | }, |
| 112 | }, |
| 113 | { ...overrides, cliCommand: () => options.cliCommand }, |
| 114 | ); |
| 115 | } finally { |
| 116 | await connected?.close().catch(() => undefined); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | function defaultRuntimeHostRunCommandDeps(): RuntimeHostRunCommandDeps { |
| 121 | return { |
no test coverage detected