MCPcopy
hub / github.com/superagent-ai/grok-cli / prepareVerifyRun

Function prepareVerifyRun

src/verify/orchestrator.ts:45–110  ·  view source on GitHub ↗
(
  agent: VerifyAgentLike,
  options: VerifyOrchestratorOptions = {},
)

Source from the content-addressed store, hash-verified

43}
44
45export async function prepareVerifyRun(
46 agent: VerifyAgentLike,
47 options: VerifyOrchestratorOptions = {},
48): Promise<PreparedVerifyRun> {
49 const cwd = agent.getCwd();
50 const baseSettings = agent.getSandboxSettings();
51 const manifest = loadVerifyEnvironment(cwd, baseSettings);
52
53 if (manifest) {
54 options.onProgress?.(`Loaded verify environment manifest: ${manifest.path}`);
55 } else {
56 options.onProgress?.("No verify environment manifest found; running verify-detect to generate one");
57 }
58
59 let profile = inferVerifyProjectProfile(cwd, manifest?.sandboxSettings ?? baseSettings, manifest?.recipe ?? null);
60 let usedVerifyDetect = false;
61 let manifestPath = manifest?.path;
62
63 if (!manifest) {
64 const detectedRecipe = await agent.detectVerifyRecipe(baseSettings, options.abortSignal);
65 if (detectedRecipe) {
66 usedVerifyDetect = true;
67 profile = inferVerifyProjectProfile(cwd, baseSettings, detectedRecipe);
68 options.onProgress?.(`verify-detect selected recipe for ${profile.appLabel}`);
69 manifestPath = saveVerifyEnvironment(cwd, profile.recipe, profile.sandboxSettings);
70 options.onProgress?.(`Created verify environment manifest: ${manifestPath}`);
71 } else {
72 options.onProgress?.(
73 "verify-detect did not return a usable recipe; keeping deterministic fallback without writing a manifest",
74 );
75 }
76 }
77
78 const sandboxSettings = buildRuntimeSandboxSettings(profile);
79 options.onProgress?.("Preparing verify checkpoint");
80 const checkpoint = await ensureVerifyCheckpoint(cwd, profile, sandboxSettings);
81 if (checkpoint.checkpointName) {
82 sandboxSettings.from = checkpoint.checkpointName;
83 if (checkpoint.guestWorkdir) {
84 sandboxSettings.guestWorkdir = checkpoint.guestWorkdir;
85 sandboxSettings.syncHostWorkspace = true;
86 }
87 options.onProgress?.(
88 checkpoint.created
89 ? `Created verify checkpoint: ${checkpoint.checkpointName}`
90 : `Using verify checkpoint: ${checkpoint.checkpointName}`,
91 );
92 } else {
93 options.onProgress?.("No verify checkpoint needed for this recipe");
94 }
95
96 const taskRequest: TaskRequest = {
97 agent: "verify",
98 description: "Run local verification",
99 prompt: buildVerifyTaskPrompt(cwd, sandboxSettings, profile.recipe),
100 };
101
102 return {

Callers 2

runVerifyOrchestrationFunction · 0.85

Calls 9

loadVerifyEnvironmentFunction · 0.90
saveVerifyEnvironmentFunction · 0.90
ensureVerifyCheckpointFunction · 0.90
buildVerifyTaskPromptFunction · 0.90
getCwdMethod · 0.65
getSandboxSettingsMethod · 0.65
detectVerifyRecipeMethod · 0.65

Tested by

no test coverage detected