Skip to content

refactor(proxy): export the Node adapter from the main entry point - #3262

Merged
thymikee merged 5 commits into
mainfrom
fix/proxy-single-entry
Oct 7, 2026
Merged

thymikee merged 5 commits into
mainfrom
fix/proxy-single-entry

Conversation

@thymikee

@thymikee thymikee commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow-up to #3256. @agent-device/proxy now has one entry point. The Node adapter moves from @agent-device/proxy/node into the main entry. The subpath was never published, so nothing outside this repo depends on it.

import { createDaemonProxy, createDaemonProxyServer } from '@agent-device/proxy';

Importing the package still evaluates the same 8 modules as before. createDaemonProxyServer and createDaemonProxyRequestListener live in daemon-proxy.ts, and the Node request adapter in node-http.ts loads on the first request, as the health helpers already do.

The Node adapter now answers TRACE with 404, as the proxy did before the Fetch rewrite. Before this change it dropped the socket, because Fetch refuses to construct a Request with that method. Review of #3256 found this. TRACK and CONNECT never reach the listener: node:http answers TRACK with 400 and routes CONNECT to its 'connect' event, which drops the socket, as it did before the rewrite. A URL with credentials, which Fetch also refuses, now gets 400.

15 files: the package exports and build entry, the README, the CLI and test imports, and a gates commit for the exports map and fallow entries.

Validation

Tested commit 5ed888a3f:

  • vitest run scripts/__tests__/eager-closure-budgets.test.ts passed. This is the check that failed on the Coverage job.
  • pnpm check:affected --run passed, including lint, typecheck, layering, fallow and build.
  • vitest run packages/proxy src/__tests__/daemon-proxy.test.ts: 25 passed. A new test sends TRACE to a real http.createServer and gets 404. Another checks that a Host with credentials gets 400.
  • Packed install: exports lists only . and ./package.json. dist/index.mjs exports createDaemonProxy, createDaemonProxyServer and createDaemonProxyRequestListener.

No device-facing change.

Review in cubic Turn on auto-fix

createDaemonProxyServer and createDaemonProxyRequestListener move from
@agent-device/proxy/node into @agent-device/proxy, so the package has one entry
point. The subpath has not been released yet.

The Node adapter now answers CONNECT, TRACE and TRACK with 404, as the proxy
did before the Fetch rewrite. Before this change it dropped the socket,
because Fetch refuses to construct a Request with those methods.
The package has one entry point now, so the exports map and the fallow entry
list name only src/index.ts.
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
Installed (including dependencies) 5.12 MB 5.12 MB +192 B
Package (unpacked) 5.12 MB 5.12 MB +192 B
Package (download) 1.54 MB 1.54 MB +207 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 20.4 ms 18.6 ms -1.8 ms
CLI --help 60.5 ms 55.0 ms -5.4 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 15 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread packages/proxy/src/node-http.ts Outdated
Comment thread packages/proxy/src/node-http.ts Outdated
thymikee and others added 2 commits October 6, 2026 21:28
…ith 400

Node never hands CONNECT or TRACK to the request listener, so the catch-all
404 only reached TRACE, and it misreported credentialed URLs, which Fetch
also refuses, as 404.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Exporting the adapter from the main entry made it evaluate one more module
on import, which the eager-closure gate refuses. The server and listener
now live beside createDaemonProxy and import node-http.ts on the first
request, as health helpers already do.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 4 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread packages/proxy/src/node-http.test.ts
Comment thread packages/proxy/src/daemon-proxy.ts
Loading node-http.ts on the first request lets the response close before
the disconnect listeners attach, so the signal also checks res.closed.
Adapter tests assert the response ends again.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@thymikee

thymikee commented Oct 6, 2026

Copy link
Copy Markdown
Member Author

This PR is ready at b8c0ef3. The Node adapter export looks right, and the checks show 19 passing and 0 failing. There are no conflicts. It only needs a maintainer approval to merge.

Not blocking: the TRACE, credential, and client-gone tests in packages/proxy/src/node-http.test.ts call serveProxyRequest directly, so no package-local test covers the lazy-import wrapper in createDaemonProxyRequestListener or its destroy-on-error catch (a small step would be to send the TRACE test through that listener), and daemon-proxy.ts, described as the transport-neutral core, now imports node:http eagerly and owns the Node server factory (the factory could live in index.ts or a small node-server.ts instead). Take or leave both.

All four cubic-dev-ai threads (P2/P3) are fixed at this commit, so please resolve them: the 404 and credentialed-URL handling (#3262 (comment)), the TRACE-only 404 branch (#3262 (comment)), the ended:true assertions in the 400 tests (#3262 (comment)), and the res.closed check for client disconnects (#3262 (comment)).

I did not re-run the eager-closure budget test or a packed install, so the module count and exports-map claims rest on reading the code and on green CI. I checked res.closed on Node v26 only. engines allows >=22.12, and I did not confirm OutgoingMessage.closed on Node 22, but if it is missing there, behavior falls back to the earlier listeners and does not regress. I also did not test TRACE and CONNECT routing in node:http here.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Oct 6, 2026
@thymikee
thymikee merged commit 8328f97 into main Oct 7, 2026
19 checks passed
@thymikee
thymikee deleted the fix/proxy-single-entry branch October 7, 2026 04:46
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-07 04:47 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant