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

Function prepareRuntimeHostRunInput

packages/cli/src/runtime-host-run-command.ts:184–219  ·  view source on GitHub ↗
(
  connection: RuntimeHostConnection,
  catalog: RuntimeHostCliConnectionContext['catalog'],
  profile: RuntimeHostProfile,
  input: Parameters<MakaRunDeps['createContext']>[0],
  cliCommand: string,
)

Source from the content-addressed store, hash-verified

182}
183
184async function prepareRuntimeHostRunInput(
185 connection: RuntimeHostConnection,
186 catalog: RuntimeHostCliConnectionContext['catalog'],
187 profile: RuntimeHostProfile,
188 input: Parameters<MakaRunDeps['createContext']>[0],
189 cliCommand: string,
190): Promise<Parameters<MakaRunDeps['createContext']>[0]> {
191 let projectId = input.projectId;
192 if (profile.kind === 'remote' && !input.resumeSessionId) {
193 if (!projectId) {
194 throw new Error(`Runtime Host profile ${profile.id} requires --project for a new Session`);
195 }
196 const project = findProjectByIdentity(await readRuntimeHostProjects(connection), projectId);
197 if (!project || project.archivedAt !== null || !project.available) {
198 throw new Error(`Runtime Host Project is unavailable: ${projectId}`);
199 }
200 projectId = project.id;
201 }
202 const preparedInput = projectId === input.projectId ? input : { ...input, projectId };
203 const snapshot = await readRuntimeHostCliTaskReadiness({
204 connection,
205 catalog,
206 cwd: preparedInput.cwd,
207 ...(profile.kind === 'remote' ? { workspaceState: 'ready' as const } : {}),
208 ...(preparedInput.requestedConnectionSlug
209 ? { connectionSlug: preparedInput.requestedConnectionSlug }
210 : {}),
211 ...(preparedInput.requestedModel ? { model: preparedInput.requestedModel } : {}),
212 });
213 if (isRuntimeHostCliTaskBlocked(snapshot)) {
214 throw new Error(
215 `Task is not ready:\n${formatRuntimeHostCliTaskBlockers(snapshot, cliCommand)}`,
216 );
217 }
218 return preparedInput;
219}
220
221class RuntimeHostRunRuntime implements MakaRunRuntime {
222 readonly #connection: RuntimeHostConnection;

Callers 1

runRuntimeHostTextCliFunction · 0.85

Tested by

no test coverage detected