diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index 4b305bdf..11fe2bf0 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -53,7 +53,7 @@ Plans: Plans: - [x] 03-01: Rename NanoBanana to GenerateImage, add model selector (image models only) -- [ ] 03-02: Provider-specific execution in generate API route +- [x] 03-02: Provider-specific execution in generate API route - [ ] 03-03: Backward compatibility for existing workflows ### Phase 4: Model Search Dialog @@ -98,7 +98,7 @@ Phases execute in numeric order: 1 → 2 → 3 → 4 → 5 → 6 |-------|----------------|--------|-----------| | 1. Provider Infrastructure | 2/2 | Complete | 2026-01-09 | | 2. Model Discovery | 3/3 | Complete | 2026-01-09 | -| 3. Generate Node Refactor | 1/3 | In progress | - | +| 3. Generate Node Refactor | 2/3 | In progress | - | | 4. Model Search Dialog | 0/2 | Not started | - | | 5. Image URL Server | 0/2 | Not started | - | | 6. Video & Polish | 0/4 | Not started | - | diff --git a/.planning/STATE.md b/.planning/STATE.md index 338fbe8e..e5d8e10a 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -10,18 +10,18 @@ See: .planning/PROJECT.md (updated 2026-01-09) ## Current Position Phase: 3 of 6 (Generate Node Refactor) -Plan: 1 of 3 in current phase +Plan: 2 of 3 in current phase Status: In progress -Last activity: 2026-01-09 - Completed 03-01-PLAN.md (Rename NanoBanana to GenerateImage) +Last activity: 2026-01-09 - Completed 03-02-PLAN.md (Provider-specific execution) -Progress: [======================================] 40% (6/15 plans) +Progress: [==========================================] 47% (7/15 plans) ## Performance Metrics **Velocity:** -- Total plans completed: 6 -- Average duration: 5.5 min -- Total execution time: 0.55 hours +- Total plans completed: 7 +- Average duration: 5.3 min +- Total execution time: 0.62 hours **By Phase:** @@ -29,10 +29,10 @@ Progress: [======================================] 40% (6/15 plans) |-------|-------|-------|----------| | 1. Provider Infrastructure | 2/2 | 14 min | 7 min | | 2. Model Discovery | 3/3 | 14 min | 4.7 min | -| 3. Generate Node Refactor | 1/3 | 5 min | 5 min | +| 3. Generate Node Refactor | 2/3 | 10 min | 5 min | **Recent Trend:** -- Last 5 plans: 4 min, 5 min, 5 min, 5 min +- Last 5 plans: 5 min, 5 min, 5 min, 5 min - Trend: stable ## Accumulated Context @@ -57,6 +57,9 @@ Recent decisions affecting current work: - Provider dropdown shows Gemini always, others only if API key configured - Aspect ratio/resolution controls shown only for Gemini provider - Backward compatibility via aliases: NanoBananaNode, saveNanoBananaDefaults +- Server-side provider execution in API route (not client-side) +- Header-based API key passing: X-Replicate-API-Key, X-Fal-API-Key +- fal.ai sync API (fal.run) instead of queue-based async ### Deferred Issues @@ -69,6 +72,6 @@ None. ## Session Continuity Last session: 2026-01-09 -Stopped at: Completed 03-01-PLAN.md (GenerateImageNode with provider/model selector) +Stopped at: Completed 03-02-PLAN.md (Provider-specific execution) Resume file: None -Next action: Execute 03-02-PLAN.md (Provider-specific execution in generate API route) +Next action: Execute 03-03-PLAN.md (Backward compatibility for existing workflows) diff --git a/.planning/phases/03-generate-node-refactor/03-02-SUMMARY.md b/.planning/phases/03-generate-node-refactor/03-02-SUMMARY.md new file mode 100644 index 00000000..2aa1a508 --- /dev/null +++ b/.planning/phases/03-generate-node-refactor/03-02-SUMMARY.md @@ -0,0 +1,106 @@ +--- +phase: 03-generate-node-refactor +plan: 02 +subsystem: api +tags: [replicate, fal-ai, image-generation, multi-provider] + +# Dependency graph +requires: + - phase: 03-01 + provides: GenerateImageNode with provider/model selector, SelectedModel type +provides: + - Replicate provider generate() implementation with polling + - fal.ai provider generate() implementation + - Multi-provider dispatch in /api/generate route +affects: [04-model-search-dialog, 05-image-url-server] + +# Tech tracking +tech-stack: + added: [] + patterns: + - Provider dispatch pattern in API route via provider-specific helpers + - Header-based API key passing (X-Replicate-API-Key, X-Fal-API-Key) + - Replicate prediction polling pattern + +key-files: + created: [] + modified: + - src/lib/providers/replicate.ts + - src/lib/providers/fal.ts + - src/app/api/generate/route.ts + +key-decisions: + - "Server-side provider execution (helpers in route.ts) rather than client-side" + - "Header-based API key passing to avoid localStorage on server" + - "fal.ai sync API (fal.run) instead of queue-based async" + +patterns-established: + - "Provider-specific helper functions: generateWithGemini(), generateWithReplicate(), generateWithFal()" + - "Replicate polling with 1s interval until succeeded/failed" + - "Multi-format fal.ai response handling (images array, image object, output string)" + +issues-created: [] + +# Metrics +duration: 5 min +completed: 2026-01-09 +--- + +# Phase 3 Plan 2: Provider-Specific Execution Summary + +**Multi-provider dispatch in /api/generate with Replicate prediction polling and fal.ai sync API** + +## Performance + +- **Duration:** 5 min +- **Started:** 2026-01-09T07:29:01Z +- **Completed:** 2026-01-09T07:34:10Z +- **Tasks:** 3 +- **Files modified:** 3 + +## Accomplishments + +- Replicate generate() implementation with version fetching and prediction polling +- fal.ai generate() implementation with sync fal.run API and multi-format response handling +- Generate API route now dispatches to correct provider based on selectedModel.provider +- Gemini logic extracted into generateWithGemini() helper for clarity + +## Task Commits + +Each task was committed atomically: + +1. **Task 1: Implement Replicate provider generate()** - `cbfdc9f` (feat) +2. **Task 2: Implement fal.ai provider generate()** - `d9c0ce7` (feat) +3. **Task 3: Update generate API route for multi-provider dispatch** - `ac11c6e` (feat) + +**Plan metadata:** (this commit) + +## Files Created/Modified + +- `src/lib/providers/replicate.ts` - Added ReplicatePrediction interface and generate() with API polling +- `src/lib/providers/fal.ts` - Added FalGenerationResponse interface and generate() with sync API +- `src/app/api/generate/route.ts` - Added multi-provider dispatch and provider-specific helper functions + +## Decisions Made + +- Server-side provider execution in API route rather than client-side provider.generate() calls +- API keys passed via request headers (X-Replicate-API-Key, X-Fal-API-Key) to avoid localStorage access on server +- fal.ai uses sync fal.run API for simplicity (queue-based async not needed for image generation) + +## Deviations from Plan + +None - plan executed exactly as written. + +## Issues Encountered + +None + +## Next Phase Readiness + +- Provider generation working for Replicate and fal.ai +- Image inputs not yet passed to providers (requires Phase 5 URL server) +- Ready for 03-03-PLAN.md (backward compatibility for existing workflows) + +--- +*Phase: 03-generate-node-refactor* +*Completed: 2026-01-09*