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

Method runTaskRequest

src/agent/agent.ts:1169–1392  ·  view source on GitHub ↗
(
    request: TaskRequest,
    onActivity?: (detail: string) => void,
    abortSignal?: AbortSignal,
  )

Source from the content-addressed store, hash-verified

1167 }
1168
1169 async runTaskRequest(
1170 request: TaskRequest,
1171 onActivity?: (detail: string) => void,
1172 abortSignal?: AbortSignal,
1173 ): Promise<ToolResult> {
1174 const provider = this.requireProvider();
1175 const signal = abortSignal;
1176 const agentKey = String(request.agent);
1177 const isExplore = agentKey === "explore";
1178 const isGeneral = agentKey === "general";
1179 const isVision = agentKey === "vision";
1180 const isVerify = agentKey === "verify";
1181 const isVerifyDetect = agentKey === "verify-detect";
1182 const isVerifyManifest = agentKey === "verify-manifest";
1183 const isComputer = agentKey === "computer";
1184 const subagents = loadValidSubAgents();
1185 const custom =
1186 !isExplore && !isGeneral && !isVision && !isVerify && !isVerifyDetect && !isVerifyManifest && !isComputer
1187 ? findCustomSubagent(agentKey, subagents)
1188 : undefined;
1189
1190 if (
1191 !isExplore &&
1192 !isGeneral &&
1193 !isVision &&
1194 !isVerify &&
1195 !isVerifyDetect &&
1196 !isVerifyManifest &&
1197 !isComputer &&
1198 !custom
1199 ) {
1200 const message = `Unknown sub-agent "${agentKey}". Use general, explore, vision, verify, verify-detect, verify-manifest, computer, or a configured name from ~/.grok/user-settings.json.`;
1201 return {
1202 success: false,
1203 output: message,
1204 task: {
1205 agent: agentKey,
1206 description: request.description,
1207 summary: message,
1208 },
1209 };
1210 }
1211
1212 const childMode: AgentMode = isExplore || isVerifyDetect ? "ask" : "agent";
1213 const verifySandboxOverrides: SandboxSettings = isVerify
1214 ? { allowNet: true, allowedHosts: undefined, allowEphemeralInstall: true, hostBrowserCommandsOnHost: true }
1215 : {};
1216 let verifyPreparedSettings: SandboxSettings | null = null;
1217 let verifyPreparedRecipe: VerifyRecipe | null = null;
1218 if (isVerify) {
1219 const prepared = await prepareVerifySandbox(
1220 this.bash.getCwd(),
1221 { ...this.bash.getSandboxSettings(), ...verifySandboxOverrides },
1222 undefined,
1223 onActivity,
1224 );
1225 verifyPreparedSettings = prepared.sandboxSettings;
1226 verifyPreparedRecipe = prepared.profile.recipe;

Callers 2

runTaskMethod · 0.95
detectVerifyRecipeMethod · 0.95

Calls 15

requireProviderMethod · 0.95
getCwdMethod · 0.95
getSandboxModeMethod · 0.95
getSandboxSettingsMethod · 0.95
runTaskRequestBatchMethod · 0.95
recordUsageMethod · 0.95
loadValidSubAgentsFunction · 0.90
prepareVerifySandboxFunction · 0.90
createToolsFunction · 0.90
normalizeModelIdFunction · 0.90
resolveModelRuntimeFunction · 0.90
buildMcpToolSetFunction · 0.90

Tested by

no test coverage detected