Skip to content
This repository was archived by the owner on Oct 16, 2026. It is now read-only.

fix(local): implement kody.gatewayFetchStream for --local runtime - #66

Merged
kody-bot merged 2 commits into
mainfrom
cursor/local-gateway-fetch-stream-3beb
Oct 15, 2026
Merged

kody-bot merged 2 commits into
mainfrom
cursor/local-gateway-fetch-stream-3beb

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Problem

npx @kodycodes/cli execute --local fails right after bundling with:

Error: Unknown runtime function kody.gatewayFetchStream.

Hosted runtime (kentcdodds/kody) added gatewayFetchStream and package-graph shims call it for streamed / multipart / large secret-aware bodies. The CLI --local host only Proxy-forwarded that name through JSON POST /v1/capability-proxy/call, which does not implement it (streaming uses a separate Open API route).

This blocks Cloudflare publish-static and other packages that need the streaming hop (CLI 1.20.2 / 1.24.1).

Fix

  • Implement kody.gatewayFetchStream on the workerd kody:runtime host (real method on the Proxy, not a JSON /call hop)
  • Loopback bridge POST /gateway-fetch streams to POST /v1/capability-proxy/gateway-fetch with allowlisted metadata headers, duplex body, and upstream Response reconstruction (per cli-streaming-gateway-fetch contract)
  • Bridge failures return Open API JSON + Cache-Control: no-store so workerd throws
  • Mock path buffers through MSW; null-body statuses (204/205/304/…) stay null
  • Shared bridge used by execute --local, package module runs, and kody dev

Audit / drift guard

  • Document hosted CapabilityProxy specials vs --local host surface in local-host-runtime-surface.ts
  • Only missing special host method was gatewayFetchStream
  • Tests fail when hosted specials / CLI implementation markers drift

Tests

  • Unit: streaming CapabilityProxy client, bridge + mock MSW, drift guard, bridge error envelopes, null-body mock
  • Integration: runLocalExecute calls kody.gatewayFetchStream and hits /v1/capability-proxy/gateway-fetch (not /call)
  • npm run validate green
Open in Web Open in Cursor 

Note

Medium Risk
Introduces a new secret-aware outbound streaming path through CapabilityProxy; behavior is contract-tested but affects local execute/dev networking and credential header forwarding.

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

Hosted packages now stream secret-aware bodies via gatewayFetchStream after
bundling; the CLI Proxy forwarded that name through JSON CapabilityProxy /call
and origin replied Unknown runtime function. Implement the streaming host method
and bridge hop to POST /v1/capability-proxy/gateway-fetch (contract parity),
audit hosted vs --local specials, and fail tests when the lists drift.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@kody-bot
kody-bot marked this pull request as ready for review October 15, 2026 08:07
@kentcdodds

Copy link
Copy Markdown
Owner Author

bugbot run

@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 default effort and found 2 potential issues.

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 1b0bd5c. Configure here.

Comment thread src/local-runtime-bridge.ts Outdated
Comment thread src/local-gateway-fetch-forward.ts
Bridge failures on /gateway-fetch now return Open API JSON with
Cache-Control: no-store so workerd gatewayFetchStream throws instead of
treating a bare 200 as success. Mock stream hops use a null body for
101/103/204/205/304 so the Response constructor does not throw.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@kody-bot
kody-bot merged commit a2baeb6 into main Oct 15, 2026
7 checks passed
@kody-bot
kody-bot deleted the cursor/local-gateway-fetch-stream-3beb branch October 15, 2026 08:19
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.25.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

cursor Bot pushed a commit that referenced this pull request Oct 15, 2026
Resolve package-app-dev import conflict: keep client-asset helpers from
ports and the gatewayFetchStream local runtime bridge from main.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants