MCPcopy Create free account
hub / github.com/apache/maka / runRuntimeHostTextCli

Function runRuntimeHostTextCli

packages/cli/src/runtime-host-run-command.ts:70–118  ·  view source on GitHub ↗
(
  argv: readonly string[],
  overrides: Partial<MakaRunEnvironmentDeps> = {},
  commandOverrides: Partial<RuntimeHostRunCommandDeps> = {},
  options: RuntimeHostTextCliOptions = {
    cliCommand: 'maka',
    clientDataRoot: resolveMakaClientDataRoot(),
  },
)

Source from the content-addressed store, hash-verified

68}
69
70export 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
120function defaultRuntimeHostRunCommandDeps(): RuntimeHostRunCommandDeps {
121 return {

Callers 2

runMakaCliFunction · 0.85

Calls 9

readRuntimeHostSessionsFunction · 0.90
connectFunction · 0.70
runMethod · 0.65
createContextMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected