Phase 1: API Key Config & i2i Variations — Worker#44
Open
mcarlson wants to merge 7 commits into
Open
Conversation
Handles text-to-image (JSON POST to /images/generations) and image-to-image (multipart/form-data POST to /images/edits). Downloads source images as buffers, uploads results to R2, supports b64_json responses. Installs form-data package. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Handles both sync (images returned directly) and async (request_id polling via queue.fal.run) FAL API responses. Parses size as WxH object, maps queue position to job progress, uploads results to R2. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Routes jobs to OpenAI or FAL adapter based on userEndpointProvider. Validates required fields, calls adapter, then updates the dream via videoServiceClient.uploadGeneratedImage. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds WorkerFactory.createWorker for user-endpoint, creates the Queue instance, and adds it to Bull Board adapters. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…FAL shape/size fallback, SSRF guard
… re-validate poll URLs to close rebinding TOCTOU
…ion, allow IPv6 literals, fix FAL comments, add url-safety tests Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 1: API Key Config & i2i Variations — Worker
Adds the GPU/worker side for user-supplied image-generation endpoints: a dedicated
user-endpointqueue that dispatches jobs to OpenAI- or FAL-compatible providers using the user's decrypted key, then attaches the result to the dream.What's in this PR
/images/generations) and i2i (/images/edits) against a user's OpenAI-compatible endpoint.queue.fal.run) flow for Flux Schnell / Flux Pro etc.user-endpointqueue + job router — registered alongside existing workers (Bull Board included); routes by provider type, validates required job-data fields, uploads the generated image to R2 and attaches it to the dream.Correctness / hardening
uploadGeneratedImagereturns a boolean; the handler now throws onfalseso the dream is marked failed instead of silently "completed" with no image.images ?? output.images) andparseFalSizepassthrough for named sizes.url-safety.ts): https-only, rejects loopback / RFC1918 / link-local+metadata / IPv6 ULA / NAT64 / IPv4-mapped-IPv6 (dotted + hex via a proper IPv6 expander); IPv6 literals validated directly. OpenAI calls pin the validated IP (maxRedirects: 0); the FAL submit is pinned, and the fixed-hostqueue.fal.runpolls are re-validated. The R2 presigned source-image download (our own storage) is intentionally not pinned.Cross-repo dependency
This is 1 of 3 PRs and is not functional alone:
user-endpointjobs to this queueJob-data contract (
dream_uuid,userEndpointDecryptedKey,userEndpointUrl,userEndpointProvider,userEndpointModelId,prompt,image,size,n) is verified key-by-key against the backend producer. Merge the three together.Verification
npm run build(tsc) ✓ · url-safety checks ✓Plan & design:
docs/superpowers/plans/2026-06-12-api-key-config-i2i-variations.md(metarepo).🤖 Generated with Claude Code