Skip to content

feat(daemon): HTTP and WebSocket gateway#3100

Open
kriskowal wants to merge 3 commits intomasterfrom
kriskowal-gateway
Open

feat(daemon): HTTP and WebSocket gateway#3100
kriskowal wants to merge 3 commits intomasterfrom
kriskowal-gateway

Conversation

@kriskowal
Copy link
Member

Description

This sets the stage for Endo Familiar, an Electron app that manages the daemon and serves local HTTP web applications through a custom localhttp:// protocol handler. The unified gateway eliminates the need for each weblet to claim a dedicated port, allowing Electron to route requests to weblets by hostname instead.

Adds a unified HTTP/WebSocket gateway server to the Endo daemon, listening on ENDO_ADDR (default 127.0.0.1:8920). Weblets can register on the shared server using hostname-based isolation or opt into a dedicated port with path-based isolation. Gateway clients connect over WebSocket and call fetch(token) to retrieve formula values via CapTP.

Extracts trackConnection, openCapTPSession, and makeWebletFar helpers to deduplicate the gateway and weblet connection paths. Installs @types/ws to replace @ts-ignore directives.

Security Considerations

Only loopback connections (127.0.0.1, ::1, ::ffff:127.0.0.1) are accepted. Non-local connections are rejected with a 1008 close code. This restriction will be revisited when CapTP is replaced with OCapN over Noise Protocol.

Scaling Considerations

None. One HTTP server replaces per-weblet servers when no dedicated port is requested.

Documentation Considerations

The daemon README now documents the ENDO_ADDR environment variable and its usage with endo start.

Testing Considerations

New gateway.test.js covers: gateway info page, WebSocket fetch(token), weblet on the unified server, and weblet on a dedicated port.

Compatibility Considerations

getPort() is renamed to getAddress() and now returns a URL string instead of a port number. Callers must be updated.

Upgrade Considerations

None.

@changeset-bot
Copy link

changeset-bot bot commented Feb 21, 2026

⚠️ No Changeset found

Latest commit: 9a772d2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@kriskowal
Copy link
Member Author

First reviewer to find this, please feel free to relieve the other reviewers. I’m casting a wider net than necessary: any review, not all reviews.

@kriskowal kriskowal force-pushed the kriskowal-gateway branch 2 times, most recently from b47eb0d to a75c587 Compare February 21, 2026 15:23
@kriskowal kriskowal marked this pull request as ready for review February 21, 2026 15:34
@jcorbin jcorbin force-pushed the kriskowal-gateway branch from a75c587 to 03b3ce7 Compare March 10, 2026 21:24
@jcorbin
Copy link

jcorbin commented Mar 10, 2026

Code looks reasonable, and even moreso now after my improvements while reviewing.

I'm as yet unable to run the gateway using ENDO_ADDR=127.0.0.1:9000 endo start locally, and I'm not sure where that disconnect is yet, it's as likely to be me missing something on the user side of things.

@jcorbin jcorbin force-pushed the kriskowal-gateway branch 2 times, most recently from d3deccc to 7d73ee7 Compare March 11, 2026 20:58
Comment on lines +507 to +509
// NOTE this was prior behavior, but we may want to consider passing `actual.address` out, since config might be `0.0.0.0`?
const actual = `http://${addr.config.address}:${addr.actual.port}`;
return actual;
Copy link

Choose a reason for hiding this comment

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

@kriskowal you attention here please, as this is a new thing I introduced in my review update ; also rhymes with the usage site where we log-listening above

- add missing ts-check comment, fix lsp-auto-format churn
- explicate web socket 1008 status code
- improve some console log entry formats
- avoid double-sending weblet response in error branch
- further explicate OS-resolved listen addr vs config wanted
@jcorbin jcorbin force-pushed the kriskowal-gateway branch from 7d73ee7 to 9a772d2 Compare March 11, 2026 21:09
@jcorbin
Copy link

jcorbin commented Mar 11, 2026

Well:

  • got tests to pass, that was actually a problem introduced by my first push to this PR
  • got the lint passing locally, but it still fails in CI and doesn't tell me what the problem is specifically?
  • still cannot curl the gateway locally off this branch, even after an endo purge && ENDO_ADDR=127.0.0.1:9000 endo start locally

So I'm not sure yet what the difference is between this one and the gateway in the llm ranch...

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.

2 participants