plan.mjs 804 B

123456789101112131415161718
  1. import { errorResult, okResult } from '../core/result-envelope.mjs';
  2. import { safeError } from '../core/redaction.mjs';
  3. import { buildImageSetPlan, toPublicPlan } from '../features/planning/planner.mjs';
  4. export async function runPlan(input = {}) {
  5. try {
  6. const plan = buildImageSetPlan(input);
  7. const publicPlan = toPublicPlan(plan);
  8. return okResult({
  9. assistantMessage: publicPlan.confirmationMessage,
  10. summary: { planId: plan.planId, preset: plan.preset, outputs: plan.items.length, requiresConfirmation: true },
  11. data: { plan: publicPlan },
  12. nextActions: ['逐项审核目标、模型、尺寸和提示词。', '确认后以 confirmed=true 调用 fmode_image_set_generate。']
  13. });
  14. } catch (error) {
  15. return errorResult('needs_input', safeError(error));
  16. }
  17. }