feat(cli): refine start loader — skip app-login step when following, annotate preflight label

This commit is contained in:
ezl-keygraph committed 2026-10-05 02:35:48 +05:30
1 parent 3283b4ac1d
commit ab092e0731
1 file changed
+12 -13
+12 -13
View File
@@ -500,9 +500,12 @@ export async function start(args: StartArgs): Promise<void> {
spinner.message(PREFLIGHT_LABEL); spinner.message(PREFLIGHT_LABEL);
const spec = resolveModelSpec(); const spec = resolveModelSpec();
const providerId = typeof spec === 'string' ? '' : spec.providerId; const providerId = typeof spec === 'string' ? '' : spec.providerId;
// The cyber-access probe only runs for OpenAI/Anthropic, so only name it there. // Cyber-access probe only runs for OpenAI/Anthropic; when following, the tailed log shows the login.
const showCyberAccess = providerId === 'anthropic' || providerId === 'openai'; const showCyberAccess = providerId === 'anthropic' || providerId === 'openai';
const outcome = await awaitStartupOutcome(workflowId, (label) => spinner.message(label), showCyberAccess); const outcome = await awaitStartupOutcome(workflowId, (label) => spinner.message(label), {
showCyberAccess,
showAppLogin: !args.follow,
});
if (outcome.kind === 'failed') { if (outcome.kind === 'failed') {
spinner.error(couldNotStartLabel); spinner.error(couldNotStartLabel);
printScanStartFailure(outcome.message); printScanStartFailure(outcome.message);
@@ -581,7 +584,7 @@ function readStartupError(startupErrorPath: string): StartupError | undefined {
/** Outcome of waiting for in-workflow startup (preflight + auth validation) to clear. */ /** Outcome of waiting for in-workflow startup (preflight + auth validation) to clear. */
type PreflightOutcome = { kind: 'passed' } | { kind: 'failed'; message: string } | { kind: 'unconfirmed' }; type PreflightOutcome = { kind: 'passed' } | { kind: 'failed'; message: string } | { kind: 'unconfirmed' };
const PREFLIGHT_LABEL = 'Running preflight checks'; const PREFLIGHT_LABEL = 'Running preflight checks (LLM credentials, target URL)';
const CYBER_ACCESS_LABEL = 'Checking cyber access'; const CYBER_ACCESS_LABEL = 'Checking cyber access';
const APP_LOGIN_LABEL = 'Verifying app login with provided credentials'; const APP_LOGIN_LABEL = 'Verifying app login with provided credentials';
@@ -594,8 +597,10 @@ const APP_LOGIN_LABEL = 'Verifying app login with provided credentials';
async function awaitStartupOutcome( async function awaitStartupOutcome(
workflowId: string, workflowId: string,
onLabel: (label: string) => void, onLabel: (label: string) => void,
showCyberAccess: boolean, opts: { showCyberAccess: boolean; showAppLogin: boolean },
): Promise<PreflightOutcome> { ): Promise<PreflightOutcome> {
// Wait through auth-validation only when naming the login step; otherwise stop once it begins.
const startupPhases = opts.showAppLogin ? new Set(['preflight', 'auth-validation']) : new Set(['preflight']);
let rank = 0; let rank = 0;
let label = PREFLIGHT_LABEL; let label = PREFLIGHT_LABEL;
for (let attempts = 0; attempts < 80; attempts++) { for (let attempts = 0; attempts < 80; attempts++) {
@@ -607,24 +612,18 @@ async function awaitStartupOutcome(
} }
const running = await runningActivityTypes(workflowId); const running = await runningActivityTypes(workflowId);
if (showCyberAccess && rank < 1 && running.includes('runExploitReadinessProbe')) { if (opts.showCyberAccess && rank < 1 && running.includes('runExploitReadinessProbe')) {
rank = 1; rank = 1;
label = CYBER_ACCESS_LABEL; label = CYBER_ACCESS_LABEL;
} }
if (rank < 2 && running.includes('runAuthenticationValidation')) { if (opts.showAppLogin && rank < 2 && running.includes('runAuthenticationValidation')) {
rank = 2; rank = 2;
label = APP_LOGIN_LABEL; label = APP_LOGIN_LABEL;
} }
onLabel(label); onLabel(label);
// Any phase past preflight/auth-validation means the pentest has begun.
const progress = await queryProgress(workflowId); const progress = await queryProgress(workflowId);
if ( if (progress && progress.currentPhase !== null && !startupPhases.has(progress.currentPhase)) {
progress &&
progress.currentPhase !== null &&
progress.currentPhase !== 'preflight' &&
progress.currentPhase !== 'auth-validation'
) {
return { kind: 'passed' }; return { kind: 'passed' };
} }
} catch { } catch {