opencode/packages/opencode
Kit Langton da5e29b320 fix(server): read auth Config from Flag for HttpApi/Hono parity
HttpApi auth middleware was reading ServerAuth.Config via Effect's generated
defaultLayer, which resolves Config.string('OPENCODE_SERVER_PASSWORD') once
and is memoized by Layer identity. Subsequent runtime mutation of process.env
(or Flag.OPENCODE_SERVER_PASSWORD) was never observed, so the middleware kept
serving 401 even when auth was disabled at runtime.

Hono's AuthMiddleware reads Flag.OPENCODE_SERVER_PASSWORD per request, so it
picks up mutations immediately. With Hono still the production default and
HttpApi gated by OPENCODE_EXPERIMENTAL_HTTPAPI, the gap was masked by tests
that flipped the flag back to Hono for no-auth scenarios.

Override ServerAuth.Config.defaultLayer to read Flag.* via Layer.sync at
layer-build time. Each fresh listener (memoMap) picks up current Flag values.
This matches Hono behavior across listeners; per-request mutation within a
single listener is not preserved (would require reading Flag in the middleware
itself, which is a separate concern).

Tests:
- httpapi-listen: parameterize 'tickets optional when auth disabled' across
  both backends to lock in parity.
- httpapi-raw-route-auth + httpapi-ui: switch from ConfigProvider injection
  (which is now a no-op since defaultLayer is Flag-backed, not Config-backed)
  to ServerAuth.Config.layer({...}) for explicit overrides, or Flag mutation
  for tests that exercise the production read path.

46/46 auth + PTY tests pass.
2026-05-04 00:13:02 -04:00
..
bin cache platform binary in postinstall for faster startup (#14467) 2026-02-20 12:19:17 -06:00
migration chore: generate 2026-05-03 02:10:52 +00:00
script feat(server): Server.openapi() backed by HttpApi spec, parity-checked against Hono output (#25545) 2026-05-03 09:06:23 -04:00
scripts Prepare Effect HttpApi backend parity (#24853) 2026-04-29 09:34:50 -04:00
specs refactor: rename workspace adapters (#25272) 2026-05-01 07:36:52 -04:00
src fix(server): read auth Config from Flag for HttpApi/Hono parity 2026-05-04 00:13:02 -04:00
test fix(server): read auth Config from Flag for HttpApi/Hono parity 2026-05-04 00:13:02 -04:00
.gitignore refactor(httpapi): fork server startup by flag (#24799) 2026-04-28 11:02:35 -04:00
AGENTS.md Refactor HttpApi workspace routing and proxy boundaries (#25006) 2026-04-29 16:50:54 -04:00
BUN_SHELL_MIGRATION_PLAN.md sync 2026-02-25 01:48:10 -05:00
bunfig.toml tui plugins (#19347) 2026-03-27 15:00:26 +01:00
Dockerfile
drizzle.config.ts sqlite again (#10597) 2026-02-14 04:19:02 +00:00
git feat: interactive update flow for non-patch releases (#18662) 2026-03-22 23:12:40 +00:00
package.json fix(server): support desktop PTY websockets with HttpApi (#25598) 2026-05-03 18:23:29 +00:00
parsers-config.ts feat(tui): add syntax highlighting for kotlin, hcl, lua, toml (#18198) 2026-03-23 16:15:24 +01:00
README.md
sst-env.d.ts zen: update sst version 2026-02-18 13:54:23 -05:00
tsconfig.json core: remove @effect/language-service plugin and optimize hot path type performance 2026-04-30 23:21:05 -04:00

js

To install dependencies:

bun install

To run:

bun run index.ts

This project was created using bun init in bun v1.2.12. Bun is a fast all-in-one JavaScript runtime.