Skip to content

fix(plugin-net): support bounded binary responses - #2485

Merged
vastsa merged 4 commits into
vastsa:mainfrom
taokoplay:fix/comfyui-binary-response
Nov 21, 2026
Merged

vastsa merged 4 commits into
vastsa:mainfrom
taokoplay:fix/comfyui-binary-response

Conversation

@taokoplay

Copy link
Copy Markdown

Summary

Add an opt-in bounded binary response mode to the plugin host network API so approved plugins can download media through the existing permission, allowlist, redirect, timeout, and audit controls.

Changes

  • Add responseType: "base64" and maxResponseBytes to pi.net.fetch.
  • Return Base64 bytes with content type and byte length while preserving the existing text response contract.
  • Enforce a 16 MiB default and maximum host-side limit with no partial response.
  • Advertise binary response capability for older-host feature detection.
  • Document the SDK and plugin API contract and record the architecture decision.

Verification

  • pnpm check:pr-base
  • pnpm --filter @pi-desktop/plugin-sdk build
  • node --test apps/desktop/test/plugin-fetch-redirect.test.mjs with Node 22.22.1
  • 12/12 tests passed

This is the Host prerequisite for the ComfyUI media workflow plugin change. No real provider or ComfyUI service was contacted.

Add an opt-in base64 response mode for plugin net.fetch so media plugins can download bounded binary results through the existing host permission and redirect controls. Preserve text responses and advertise the capability for older-host checks.

Cover the IPC path, size enforcement, byte metadata, SDK types, API documentation, and the accepted architecture decision with a focused regression suite.
Make the optional binary response limit type-safe under the Desktop strict TypeScript configuration. Preserve the existing runtime validation and error behavior while allowing the CI typecheck to complete.
@vastsa

vastsa commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution. I reviewed this as a fix, but it is a new capability rather than a bug fix. It adds a public Plugin SDK/host API surface (responseType: "base64", maxResponseBytes, new result fields, new getCapabilities flags, and a new ADR), and the PR describes it as a prerequisite for a new ComfyUI media workflow.

Under the current temporary contribution policy (AGENTS.md §15), outside contributions are limited to fix and perf changes, so I'm closing this as a feat. Please reopen or resubmit after the restriction is lifted.

If you resubmit, please also keep the existing pi.net.fetch spec text this diff removes: older hosts silently ignoring unknown options (why redirect alone is not capability detection), and the audit of status >= 400 with retryAfter. Both still describe current behavior. The failed Trusted extensions Electron E2E run timed out on a browser screenshot and looks unrelated.

@vastsa vastsa closed this Nov 21, 2026
@vastsa vastsa reopened this Nov 21, 2026
…tract docs

The SDK still typed net.getCapabilities with the old redirect-only shape, so
plugins could not read the new binaryResponseBody flag without a cast. The
host now advertises the shared size constant instead of a duplicated literal.

The spec rewrite also dropped still-valid guidance: older hosts ignore unknown
fetch options, so passing an option is not capability detection, and failed
calls are audited with their advertised retryAfter. Restore both alongside the
binary-mode text.
@vastsa
vastsa merged commit eaa3d60 into vastsa:main Nov 21, 2026
6 checks passed
@vastsa

vastsa commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Reopened after review: merged on its merits. I pushed one small landing commit (5264171): typed pi.net.getCapabilities with the new PluginNetCapabilities, reused the shared 16 MiB constant, and restored the still-valid spec text about capability detection and retryAfter auditing. Thanks!

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.

3 participants