Add fallback guidance to wrapper MVP

This commit is contained in:
Eve
2026-04-22 22:45:22 +08:00
parent e04e1fd561
commit 5c80bf243c

View File

@@ -12,9 +12,7 @@ function parseArgs(argv) {
} }
function readInput(path) { function readInput(path) {
if (!path || path === '-') { if (!path || path === '-') return fs.readFileSync(0, 'utf8');
return fs.readFileSync(0, 'utf8');
}
return fs.readFileSync(path, 'utf8'); return fs.readFileSync(path, 'utf8');
} }
@@ -72,27 +70,42 @@ function bootstrapTaskState(input, classificationResult) {
function validateSilentLaunch(input, classificationResult) { function validateSilentLaunch(input, classificationResult) {
if (!classificationResult.silentCandidate) { if (!classificationResult.silentCandidate) {
return { ok: true, reason: 'not a silent long-task' }; return {
ok: true,
reason: 'not a silent long-task',
recommendedFallback: 'none',
requiredNextAction: 'proceed_with_normal_long_task_flow',
};
} }
if (!input.checkpointTrigger) { if (!input.checkpointTrigger) {
return { ok: false, reason: 'missing first forced checkpoint trigger' }; return {
ok: false,
reason: 'missing first forced checkpoint trigger',
recommendedFallback: 'non_silent_follow_up',
requiredNextAction: 'define_first_checkpoint_trigger_before_silent_launch',
};
} }
if (!input.externalizedTrigger) { if (!input.externalizedTrigger) {
return { ok: false, reason: 'missing externalized checkpoint path' }; return {
ok: false,
reason: 'missing externalized checkpoint path',
recommendedFallback: 'non_silent_follow_up',
requiredNextAction: 'bind_externalized_checkpoint_path_or_abort_silent_launch',
};
} }
return { return {
ok: true, ok: true,
reason: `${input.triggerKind || 'externalized'} trigger is defined`, reason: `${input.triggerKind || 'externalized'} trigger is defined`,
recommendedFallback: 'none',
requiredNextAction: 'proceed_with_silent_launch',
}; };
} }
function planHandoff(classificationResult) { function planHandoff(classificationResult) {
if (classificationResult.needsOwnerDecision) { if (classificationResult.needsOwnerDecision) return { mode: 'button_path' };
return { mode: 'button_path' };
}
return { mode: 'direct_reply' }; return { mode: 'direct_reply' };
} }
@@ -114,6 +127,8 @@ function main() {
taskRecord, taskRecord,
silentLaunchOk: silentLaunch.ok, silentLaunchOk: silentLaunch.ok,
silentLaunchReason: silentLaunch.reason, silentLaunchReason: silentLaunch.reason,
recommendedFallback: silentLaunch.recommendedFallback,
requiredNextAction: silentLaunch.requiredNextAction,
handoff, handoff,
}; };