mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7941] [MERGED] feat: support ToAPIs through existing media connections #8016
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#8016
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7941
Author: @SpicyMarinara
Created: 10/21/2026
Status: ✅ Merged
Merged: 10/21/2026
Merged by: @SpicyMarinara
Base:
staging← Head:codex/7922-toapis-media📝 Commits (10+)
8f12e3echore: start ToAPIs media compatibility worke0b96f9feat: support ToAPIs through existing media connectionsd47b478fix: honor ToAPIs paid-task boundaries and verified video preset3dcbf73test: name inferred custom connection deadline proof preciselybc6f88dfix: honor configured response limits for ToAPIs output2b83395Merge branch 'staging' into codex/7922-toapis-mediad6921e3fix: scope ToAPIs deadlines and sanitize rejection details59f0aa6fix: redact decoded ToAPIs errors before display truncationf5d14b4fix: redact normalized ToAPIs credentials in errors686039bfix: arm ToAPIs deadline guard at task submission📊 Changes
5 files changed (+1300 additions, -4 deletions)
View changed files
📝
packages/server/src/lib/logger.ts(+34 -0)📝
packages/server/src/services/image/image-generation.ts(+27 -4)➕
packages/server/src/services/media/toapis-media.ts(+397 -0)📝
packages/server/src/services/video/video-generation.ts(+3 -0)➕
scripts/regressions/toapis-media.regression.ts(+839 -0)📄 Description
Linked issue
Closes #7922
Why this change
ToAPIs text already works through Custom (OAI-Compatible), but changing the media base URL alone fails: its image API returns an asynchronous task, and its video API uses a different request and polling contract. This adds the compatibility requested by @SpicyMarinara without another branded provider or service choice.
What changed
https://toapis.com/v1orhttps://toapis.cn/v1, the user's API key, and a manually entered model ID. Provider and service catalogs are unchanged; text remains on Custom (OAI-Compatible).gpt-image-2andseedance-2-mini. Image scope is one 1k image, Auto quality, at most one reference, and the common 1:1, 16:9, 9:16, 3:2 and 2:3 ratios. Video scope is text or one first frame, exactly 4 seconds, 480p, 16:9 and audio off. Unsupported settings fail before buying a task.err/errorand formatted-Error log calls at info and above, including cause wrappers and Gallery; unmarked errors retain the existing Pino behavior. The useful HTTP reason remains on the thrown/UI error and one capped, sanitized debug diagnostic. Non-HTTP polling transport faults retain their original diagnostic at debug, with cancellation excluded. Known local receipt UUIDs remain in marked wrapper metadata without reintroducing provider text above debug. This covers standard logging arguments and cycle-safe finite cause chains, not arbitrary nested containers or provider text already interpolated into a raw string. Definite submission rejections retain their HTTP status and a capped, sanitized reason with keys, current task IDs and URLs redacted; transient polling GET errors have bounded retries.not_submittedand permits the same unpaid fallback, and ordinary Gemini chat-image fallback on the same base URL is preserved. They also expose a stableretryable: falsecontract for package retry loops; the related Marinara-Agents safety follow-up covers Noodle 1.5.9 and Slurp 0.3.53, including delayed automatic post/artwork retries. This companion PR has merged and published to Marinara-Agents staging as Noodle 1.5.9 and Slurp 0.3.53; installed consumers must update before using ToAPIs automation. Publication verification matched all 14 raw files, every ZIP payload and all three catalog lanes to the reviewed source, without claiming a main release or upgrades of existing installations. Pre-submission validation/rejection can still use an existing fallback. Receipts support manual reconciliation, without adding a resume UI.The adapter and integration proof were adapted from the linked AGPL-3.0 community reference and independently reviewed and validated. Existing OpenAI and Seedance contracts retain their original paths.
Validation
Human checklist, intentionally unchecked:
pnpm checkpasses locallyCONTRIBUTING.mdCompleted local evidence:
pnpm installandpnpm check: passed. The existingHomeProfessorMariChat.tsxhook dependency warning remains.node scripts/run-regressions.mjs --filter scripts/regressions/toapis-media.regression.ts: 45 integration checks passed, including real connection save/masking, Test Image/Test Video, Gallery image/file and first-frame video routes. Only provider HTTP/DNS is mocked. Negative controls cover legacy services, invalid inputs, private output URLs, cancellation, deadline races, transient/permanent polling failure, receipt permissions, configured image/video download ceilings, nonretryable markers including explicit OpenAI and inferred custom-connection deadline paths, and no paid POST replay or fallback. New controls cover reference-upload deadline fallback with no task/receipt, Gemini chat-image deadline fallback, HTTP reasons, HTML stripping, escaped, nested JSON and whitespace-normalized credentials, partial-key truncation and encoded task-ID redaction, unknown JSON metadata omission, and oversized error-body rejection. The stalled transport control also verifies the real deadline abort reason and that its emergency guard never fired. Four additional checks retain all prior 39 cases while covering the held receipt-save deadline, actual shared-Pino JSON serialization for marked direct/wrapped/field/formatted/child errors and unmarked cause/cycle controls and 40 ordinary wrappers around a marked error, rate-limited polling and both media fallback warnings, and the real Gallery rejection route with its useful UI reason preserved.pnpm smoke:ui: 7/7 desktop Chromium checks passed.retryable: false, and submit only one task each. After the shared included-review quota reset, a fresh local CodeRabbit review of implementation headbc6f88da70063afc654d16a8f26b20248f12b939completed across all four changed files with zero new findings. No billing changes were made. The storage-format suggestion was traced and rejected: optional task-receipt sidecars do not change the canonicalstorage/manifest.jsonor table layout.Manual verification notes
No fresh live API task, billing settlement or physical-device behavior is claimed. The earlier full hosted CodeRabbit review covered implementation
bc6f88da70063afc654d16a8f26b20248f12b939; source identity was preserved by GitHub update-branch head2b8339566ad218802e4a4b700d4e2a97e6aae83c. A genuine Dottore examination of2b833956then found two valid issues: URL-only deadline classification and missing HTTP rejection details. The current follow-up fixes both with the focused before/after proof above. Receipts remain intentionally durable for manual reconciliation: automatic pruning could discard the identity of an uncertain paid task. Splitting the small upload/task response type is a readability suggestion, with existing runtime validation retained; neither suggestion changes this compatibility fix.Current follow-up head:
8fabd679eec6b11df662a03c04c96a7105b5943e. Fullpnpm check, all 45 offline integration checks, formatting/diff checks and independent source/security audits pass. The independent combined staging candidate also passed all 39 checks, fullpnpm checkand URL-security regression; this is local integration proof, not a claim that pending hosted checks have passed.Local review found a deadline-proof weakness and a nested-JSON privacy edge; both are fixed. Its later claim that the padded-key control bypassed ToAPIs was rejected:
generateOpenAIdispatches this exact origin directly to the adapter, nativeHeadersnormalizes the trailing space, and both the real-entry regression and direct-adapter negative control observe that behavior. The final redactor compares the stored and normalized key. The final local CodeRabbit review of59f0aa6b41ad029397db66d71c2ba6d7ab63cfb2through686039b327e205973ef11c4b8d47ba28d68950c5covered all three follow-up files and completed with zero new findings. The only subsequent change moves the byte-identical OpenAI/default dispatch block to the switch end, preserving the existing static backend-coverage regression; source identity was proved and the unchanged reference, timeout and 39-check regressions, fullpnpm check, format and diff checks passed after the move. This does not claim that local review covered the later relocation commit.Genuine hosted Dottore review of
59f0aa6breturned one LOW finding: a deadline during reference upload was marked nonretryable before generation submission. The final private callback arms the deadline guard only after the initial receipt save and an abort check, immediately before the generation API call. The new upload control reproduces the old failure and now proves one ordinary fallback, zero ToAPIs generation POSTs and no new receipt; existing explicit/default post-submission and Gemini controls remain. The post-save abort race is independently code-traced: an already-aborted worker cannot arm the guard or submit late after fallback.The sanitizer nit is intentionally declined: the response is already capped at 2 MiB; decoding must finish before complete-value redaction and the final 300-character display limit, as the nested/partial-key controls prove. Dottore's test UNKNOWN was an evidence-bundle limitation; the retained regression source and actual 39-check runs cover HTTP reasons, oversized errors and upload deadlines. This does not claim that Dottore ran those tests or returned a Viable verdict.
Genuine hosted Dottore review of
9b48cc12completed with two LOW findings, one comment nit and two proof warnings; its success status means examination completed, not a Viable verdict. Both LOWs are fixed here: a known unpaid abort best-effort persistsnot_submittedbefore rethrowing the original error, and the native Pino hook protects marked ToAPIs errors before Pino can copy a bare error message or flatten its cause into non-debug output. The standard serializer-only approach was rejected after installed-Pino proof showed that implicitmsgwould still leak. Independent review also reproduced a 40-wrapper leak in an initial depth-limited prototype; the arbitrary cap was removed, and the existing cycle set safely walks finite cause chains. The expanded original check now fails on that prototype and passes on the final code. The error reason remains useful in Gallery's HTTP 502 response and at debug. Repeated poll warnings use the existing rate limiter with operational metadata only; media download failure remains status-only without adding an error-body read. The abort comment now describes the full guarded boundary.Both findings have negative proof: untouched
9b48left asubmittingreceipt with no task ID and zero paid POSTs while allowing one fallback, and its warning contained provider text; a native-Pino no-hook control also fails the serialized-private-text assertion. The repaired owning suite passes 43/43, including actual shared-Pino JSON and real Gallery route controls. Fullpnpm checkand independent peer source/proof review pass. The final local integration candidate also passed fullpnpm check, all 43 media checks plus the existing logging-failure-lines and logging-request-trail regressions; this is local combined-source proof, not hosted or staging-green proof. Fresh local CodeRabbit review of9b48cc1213c4179046c01f54272d2628b2c87bb8through exact final head65c87c80d425b24f6ce983d83e91aa960814d038completed across the three follow-up files with zero new findings. The superseded depth-limited review was stopped without a completion claim; the final review covers the corrected finite-chain implementation.The proof warnings are answered by the retained executable source and observed runs, not by claiming Dottore executed tests. Post-submission no-replay controls remain intact. A deadline can surface without a provider task ID or the existing local receipt identifier in its message; the receipt remains durable and must be found manually. This reconciliation usability limit is disclosed, not classified as a retry/safety failure or claimed fixed. The video race hypothesis is not reproduced or asserted fixed: the adapter still wraps its actual paid video submission and existing video cancellation/no-replay controls pass.
Genuine hosted Dottore review of
65c87c80completed with two LOWs, two nits and one WARN/one UNKNOWN; the success status means examination completed, not a Viable verdict. The two LOWs are fixed in this final follow-up: the three existingrunTaskwrapper sites supply their known local UUID as metadata, and non-HTTP/non-aborted polling errors retain a debug diagnostic before the terminal retry check. UI messages and retry behavior are unchanged; the shared logger and output/outer-deadline interfaces are unchanged. The diagnostic naming nit and pre-existing untyped receipt vocabulary are declined as style/typing scope, with HTTP status and metadata type already available.Both regressions have independent before controls: untouched
65fails the real serialized-log transport-debug assertion; after only that fix, the real Gallery uncertain-task control independently fails because its warning lacks the UUID already in the UI message and saved receipt. The final suite passes 45/45 with all previous 43 assertions retained. It verifies both uncertain/missing-ID Gallery warnings resolve to their actual saved receipts, distinct task pointers, and one paid POST with bounded 30 poll GETs, one metadata warning and available debug diagnostics for a network failure. Peer source/proof review passes. The final combined candidate with latest staging also passes fullpnpm checkand all 45 offline checks. Fresh local CodeRabbit review of exact8fabd679eec6b11df662a03c04c96a7105b5943eagainst65c87c80d425b24f6ce983d83e91aa960814d038completed across both changed files with zero new findings.The final WARN/UNKNOWN are review-bundle limits: the retained held-save test proves fallback succeeds with no paid POST and a
not_submittedreceipt.runTaskis awaited before the download-only wrapping catch, so that catch does not relabel the unpaid abort. This is observed local proof, not a claim that Dottore executed the tests. The disclosed outer-deadline/download receipt-pointer usability limit remains; no new state plumbing or public receipt API was added.Original-code controls reproduced the blocked Gemini fallback and failed the missing-reason assertion; the initial stalled-fixture lifecycle was corrected before recording the valid control. Current-head required CI and substantive hosted Dottore review remain merge gates; companion Agents staging publication has been verified. Hosted container checks supply container proof. No live task, billing settlement or physical-device proof is claimed.
Docs and release impact
Setup is documented above. For video, save 4 seconds, 480p and 16:9 in the existing connection Video Generation Defaults before using Test Video or Gallery. No user-guide, release metadata or changelog changes.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.