Initial TrueGrowth source import

This commit is contained in:
2026-07-07 09:36:36 +08:00
commit 3b6781d695
2283 changed files with 691996 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
## Context
The existing local image provider can register models and route to OpenAI-compatible `/images/generations`, but it cannot execute ComfyUI workflows or inspect ComfyUI model/node availability.
## Goals / Non-Goals
- Goals: connect to local `127.0.0.1:8188`, inspect ComfyUI status and nodes, run built-in text-to-image workflows, and return generated images to TrueGrowth tasks/assets.
- Non-Goals: bundling ComfyUI, silently installing models/custom nodes, replacing TrueGrowth business workflows, or exposing remote LAN ComfyUI by default.
## Decisions
- Treat ComfyUI as a local image engine behind TrueGrowth APIs.
- Keep online text/script providers and existing avatar/voice/video runtimes unchanged.
- Start with polling `/history/{prompt_id}` after `POST /prompt`; websocket can be added later without changing the public TrueGrowth API.
- Use API-format workflow JSON templates for SDXL and Flux Schnell.
## Risks / Trade-offs
- Workflow templates depend on node availability and model filenames in ComfyUI.
- Some Flux installs require custom nodes or newer ComfyUI versions; missing nodes are reported instead of hidden.
- Model downloads and licenses remain user-confirmed.

View File

@@ -0,0 +1,14 @@
# Change: Add ComfyUI local image engine
## Why
TrueGrowth needs local image generation that can actually execute downloaded models while keeping business workflows, canvas generation, task center, and media library under TrueGrowth control.
## What Changes
- Add ComfyUI as a local image engine, not as the full business workflow engine.
- Add local API endpoints for ComfyUI status, model inspection, templates, and image generation.
- Route ComfyUI generation results into the existing local task and media asset flow.
- Surface ComfyUI status and templates in Model Center so users can understand missing models or nodes.
## Impact
- Affected specs: image-generation, runtime-model-discovery
- Affected code: local runtime API bridge, workbench runtime client, Model Center, image engine entry points

View File

@@ -0,0 +1,20 @@
## ADDED Requirements
### Requirement: Generate Images Through ComfyUI Local Engine
The system SHALL allow image generation tasks to run through a local ComfyUI engine while preserving the existing task and media result flow.
#### Scenario: ComfyUI image generation succeeds
- **GIVEN** ComfyUI is reachable on the configured local base URL
- **AND** a supported workflow template is selected
- **WHEN** the user submits a prompt
- **THEN** the system SHALL submit a ComfyUI prompt
- **AND** collect output images
- **AND** expose the completed task and generated image assets through the existing task center and media library.
### Requirement: Keep Business Workflow Outside ComfyUI
The system SHALL use ComfyUI only as a local image engine, not as the full TrueGrowth business workflow engine.
#### Scenario: Business workflow uses multiple capabilities
- **WHEN** a workflow includes text/script generation, image generation, and avatar/video creation
- **THEN** text/script generation SHALL continue using configured text providers
- **AND** image generation MAY use ComfyUI
- **AND** avatar/video/voice steps SHALL continue using their existing providers.

View File

@@ -0,0 +1,9 @@
## ADDED Requirements
### Requirement: Inspect ComfyUI Runtime Availability
The system SHALL inspect local ComfyUI availability, node metadata, and model choices for image workflows.
#### Scenario: User opens local image engine settings
- **WHEN** the system checks ComfyUI
- **THEN** it SHALL probe the local ComfyUI status endpoint
- **AND** read node/model metadata where available
- **AND** report missing nodes or missing model choices for built-in templates.

View File

@@ -0,0 +1,12 @@
## 1. Implementation
- [x] 1.1 Add OpenSpec proposal and spec deltas for ComfyUI local image engine.
- [x] 1.2 Add local ComfyUI status, models, templates, and generate-image APIs.
- [x] 1.3 Add ComfyUI task runner that submits workflow JSON and collects output images.
- [x] 1.4 Add frontend runtime client types/functions.
- [x] 1.5 Add Model Center ComfyUI engine status and template controls.
- [x] 1.6 Add a workbench entry for ComfyUI image generation that writes to task center and media library.
## 2. Validation
- [x] 2.1 Run `node --check scripts/truegrowth-local-api.mjs`.
- [x] 2.2 Run `pnpm nx run web:typecheck`.
- [x] 2.3 Record build status or known blockers.