Skip to content

feat: route models inside Freya and ship the studio worker - #11

Merged
surrealwolf merged 43 commits into
mainfrom
feat/freya-operator-openrouter
Nov 23, 2026
Merged

surrealwolf merged 43 commits into
mainfrom
feat/freya-operator-openrouter

Conversation

@surrealwolf

@surrealwolf surrealwolf commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Operator: FreyaStudio, diffusion worker, and model-asset CRDs with OpenRouter, Civitai, and Hugging Face secret refs, generated admin/API tokens, and Ingress/RBAC for the studio path.
  • API / router: Freya keeps Auto on an internal privacy, alignment, and cost matrix (not OpenRouter’s upstream openrouter/auto), and adds the Civitai install queue, gallery, and settings/auth APIs.
  • Worker: local GPU worker (Dockerfile.worker, setup scripts, Compose under deploy/compose) plus external and in-cluster worker samples.
  • Web: studio UI for chat, gallery, Civitai, and worker controls, including empty-state art and the local-worker setup scripts.
  • MCP: freya-mcp Streamable HTTP server that proxies the Freya API for agents, with a standalone sample and operator wiring.

Test plan

  • cargo check the API, operator, worker, and MCP crates
  • make mock-ui and walk chat, gallery empty states, Civitai, and the Worker tab
  • Confirm Auto stays on the internal matrix (privacy / alignment / cost) and does not send openrouter/auto
  • Run the local worker setup script and confirm it writes the machine token and reaches the API
  • make compose-up (and make compose-up-gpu if a GPU is available)
  • Apply the studio sample and hit the MCP endpoint with the API bearer

Made with Cursor


Note

Medium Risk
Touches authentication, Ingress-exposed MCP, operator Secret generation, and a large new API/worker surface; misconfiguration could leave routes open locally or break cluster token/MCP alignment.

Reviewed by Cursor Bugbot for commit a840e50. Bugbot is set up for automated code reviews on this repo. Configure here.

surrealwolf and others added 21 commits May 29, 2026 07:22
The UI update button pulls source but Freya skips the native rebuild step.
Wire git pull + dotnet build into make targets and document the workflow.

Co-authored-by: Cursor <cursoragent@cursor.com>
Stop only ComfyUI to preserve git state, use fetch+reset with retries,
and skip rebuild/restart when SwarmUI is already current.

Co-authored-by: Cursor <cursoragent@cursor.com>
Clear root for OpenRouter operator rebuild while keeping prior UI tooling reachable.

Co-authored-by: Cursor <cursoragent@cursor.com>
Replace Compose/GPU UI default path with kube-rs studio, cloud+local
generation router, and Civitai key install flow.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep Freya operator Makefile/README; Compose SwarmUI updates already live under legacy/.

Co-authored-by: Cursor <cursoragent@cursor.com>
Interactive mock/dev:mock path, lacquer mist theme, portrait icons,
and suggest/session instruction packs with API assist enrichment for #9.

Co-authored-by: Cursor <cursoragent@cursor.com>
Root compose moved with the operator cutover; Lint and Validate was
failing with "no configuration file provided".

Co-authored-by: Cursor <cursoragent@cursor.com>
Contain asset dest paths, allowlist Civitai download hosts, optional
FREYA_API_TOKEN + tighter CORS, drop shell eval on asset Jobs, and
fix external worker URL / Job phase / LoRA local backend wiring.

Co-authored-by: Cursor <cursoragent@cursor.com>
Require bearer on protected GETs, wire apiTokenSecretRef and
worker authSecretRef through the operator, and allowlist worker
install hosts so cluster/Ingress deployments are not fail-open.

Co-authored-by: Cursor <cursoragent@cursor.com>
Stop nginx from injecting the API bearer, allowlist FreyaModelAsset
download hosts before attaching secretRef, and sanitize assist mode
paths. Reword sample secret comments so Security Checks CI passes.

Co-authored-by: Cursor <cursoragent@cursor.com>
Pass download credentials as authToken Bearer instead of a URL
query param, and return sanitized worker install errors so reqwest
URL Display cannot echo the secret.

Co-authored-by: Cursor <cursoragent@cursor.com>
Refresh .env.example and local docs for operator/API keys;
feature freya.png NL brand prompt in packs and builtins.

Co-authored-by: Cursor <cursoragent@cursor.com>
Planner chat models were treated as image endpoints and /images
errors were masked by a chat-modalities fallback. Sanitize model
ids, surface ZDR/credits clearly, and return a visible local stub PNG.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Surface installable Civitai weights (LoRA/LoCon/DoRA/Checkpoint/TI/VAE) with
thumbnails and a detail view that shows base-model family + related checkpoints.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep the list/suggest card in the modal when GET /v1/civitai/models/{id}
fails (common in mock vs live ids) instead of blocking Favorite/Pin.

Co-authored-by: Cursor <cursoragent@cursor.com>
Prompt submit chats with Freya; generate/search/install become
mode-gated tool actions via POST /v1/chat instead of a Generate CTA.

Co-authored-by: Cursor <cursoragent@cursor.com>
Wire Studio sample to nginx Ingress host and point the external worker
sample at an in-cluster Service/Endpoints reachable from kind.

Co-authored-by: Cursor <cursoragent@cursor.com>
Settings shows VRAM/util from worker or host nvidia-smi; API
adds /v1/worker/stats plus docker/systemd start|stop and
enable|disable so local gens can be paused without breaking
OpenRouter.

Co-authored-by: Cursor <cursoragent@cursor.com>
Local GPU control and OpenRouter chat discovery need first-class
Worker/API surfaces; rotate tokens in-UI and sync LE wildcard into
kind so freya.dataknife.net matches fleet TLS.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep Auto on an internal privacy/alignment/cost matrix, and add the Civitai queue, local worker setup, and studio UI on that path.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread config/crd/freya.dataknife.ai_crds.yaml Resolved
Comment thread crates/freya-api/src/main.rs Resolved
Comment thread crates/freya-crd/src/lib.rs Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Not approved. Cursor Bugbot reported three unresolved findings, including a high-severity invalid CRD manifest, so this needs human review. Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Agentic security review found 2 issues on the current head: unauthenticated public MCP that proxies the studio API bearer (high), and unauthenticated worker /health returning the full stats inventory (medium).

Open in Web View Automation 

Sent by Cursor Security Agent: Security Reviewer

Comment thread crates/freya-mcp/src/main.rs Resolved
Comment thread crates/freya-worker/src/main.rs Resolved
surrealwolf and others added 2 commits November 22, 2026 14:09
Keep alignment and cost fallbacks in packs/auto-models.json so the router, agent, image, and video defaults can change without another hardcoded table.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
Keep the continued studio work, leave the new host scripts in scripts/, and take the rules file that landed on main.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/freya-api/src/routes.rs Resolved
Comment thread crates/freya-mcp/src/main.rs Resolved
Comment thread crates/freya-api/src/state.rs Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Not approved. Cursor Bugbot reported four new issues (seven unresolved, including high-severity auth and credential-overwrite findings), so this needs human review. Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Comment thread crates/freya-mcp/src/main.rs Resolved
Comment thread crates/freya-worker/src/main.rs Resolved
Keep the CRD manifest as YAML, require the API bearer on /mcp, and stop empty persisted keys or a failed Secret read from replacing live credentials.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Not approved. Cursor Bugbot reviewed this head and reported 2 new issues with 13 unresolved findings (including high-severity routing, MCP allowlist, and worker TLS items), so this needs human review. Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

Cloud enhance and a Llama agent suggestion were rewriting
local scenes when alignment is uncensored or Show NSFW is
on. The worker already forwarded the prompt unchanged.
Cloud image providers still apply their own refusals.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/freya-api/src/routes.rs Resolved
Comment thread crates/freya-api/src/routes.rs Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Not approved. Cursor Bugbot skipped on this head, but unresolved Bugbot findings remain on this PR (including high-severity routing, MCP allowlist, and worker TLS items), so this needs human review. Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

f15101f skipped the rewriter when alignment was uncensored
or Show NSFW was on, so the worker got the raw line.
Local generate always rewrites. Ordinary text uses the
balanced Auto agent. Adult scenes use Cydonia or Dolphin
Venice instead of Llama, Claude, GPT, or Gemini.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/freya-api/src/routes.rs Resolved
Comment thread crates/freya-api/src/router.rs Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Not approved. Cursor Bugbot skipped on this head, but unresolved Bugbot findings remain (including high-severity routing, MCP allowlist, and worker TLS items), so this needs human review. Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Comment thread crates/freya-api/src/worker.rs Resolved
Comment thread deploy/compose/compose.yaml Resolved
surrealwolf and others added 2 commits November 22, 2026 17:46
MCP rejects an empty token and keeps a loopback host list.
In-cluster clients are on that list. Public worker HTTPS
keeps certificate checks. Compose does not publish the
worker. The operator does not adopt a Secret it does not own.

Series failures return an error. A chat pin no longer
replaces the resolved image model. Stats no longer treat
/health as inventory. Explicit generate phrasing renders.
Gif and video questions do not. Adult rewrite retries the
other uncensored model and still does not skip the rewriter.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
A missing or refused rewrite was aborting local generate
instead of sending the original scene. First-party
openrouter ids stay as agent suggestions. Auto with pinned
LoRAs restores a refused tool prompt. Food wording like
chicken breasts stays off the adult writer.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/freya-api/src/router.rs Resolved
Comment thread crates/freya-mcp/src/main.rs Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Not approved. Cursor Bugbot skipped on this head, but unresolved Bugbot findings remain (including a high-severity Unicode panic in the adult-scene scan), so this needs human review. Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

previous_word added one byte after a non-ASCII
separator and panicked mid-character. Standalone MCP
lists Service DNS hosts. Empty or * stays loopback.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Not approved. Cursor Bugbot skipped on this head, and unresolved Bugbot findings remain (worker disable, health-stats fallback, and standalone MCP Host allowlist), so this needs human review. Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

Disable drops the worker client and a URL save does not
turn it back on. A {ok:true} health body is not stats.
Standalone MCP allows the public Ingress host. Empty or
* stays loopback.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b05f640. Configure here.

Comment thread web/src/App.jsx Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not approved. Cursor Bugbot reviewed this head and left unresolved findings, including a high-severity worker Enable control issue, so this needs human review. Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Agentic security review of this head found one high-severity issue: MCP tool path parameters are concatenated into HTTP URLs without segment encoding, so a crafted jobId/id can reach other authenticated /v1 POSTs (including token rotation) through the MCP wrapper.

Open in Web View Automation 

Sent by Cursor Security Agent: Security Reviewer

Comment thread crates/freya-mcp/src/tools.rs Resolved
Enable stayed disabled unless settings.workerEnabled was
strictly false. Disable's enabled:false was ignored, so a
stale or missing flag left Enable grey while local
generation stayed off.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
cursor[bot]
cursor Bot previously approved these changes Nov 23, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Cursor Bugbot completed successfully on this head with no corresponding findings that need human review (prior Bugbot threads are resolved). This automation did not previously approve this PR.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

BREAKING CHANGE: POST /v1/worker/enable and /disable are gone.
A saved worker URL attaches the client. Local vs Cloud still
picks whether generation uses the worker.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>
cursor[bot]
cursor Bot previously approved these changes Nov 23, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Cursor Bugbot completed successfully on this head with no corresponding findings that need human review (prior Bugbot threads are resolved). This automation does not currently have an active approval on this PR.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Agentic security review of this head found one new HIGH issue: worker download errors still log raw reqwest Display text, which can include Civitai/Hugging Face download URLs and query tokens. The earlier MCP path-interpolation finding on civitai_cancel_job is unchanged on this head.

Open in Web View Automation 

Sent by Cursor Security Agent: Security Reviewer

Comment thread crates/freya-worker/src/main.rs Resolved
MCP gallery and job ids must be one [A-Za-z0-9_-]+ segment
before they are placed on an API URL. `../` and `?` are
rejected, so reqwest cannot retarget /v1/auth/token or
worker start/stop.

Worker download logs keep the sanitized status or transport
error. reqwest Display includes the request URL and query
token, so it is not logged.

Co-authored-by: Lee Chapman <surrealwolf@users.noreply.github.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Cursor Bugbot completed successfully on this head with no corresponding findings that need human review (prior Bugbot threads are resolved). This automation does not currently have an active approval on this PR.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@surrealwolf
surrealwolf merged commit 9ca89e3 into main Nov 23, 2026
11 of 13 checks passed
@surrealwolf
surrealwolf deleted the feat/freya-operator-openrouter branch November 23, 2026 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant