Repository navigation
Description
Area
Multiple areas: remote connections, proxy and routing, dashboard, authentication, and service lifecycle.
What are you trying to accomplish?
Use one remote connection setup for model access and server management, while choosing these two functions independently.
A concrete example is OpenCodex on a remote Linux server and OpenCodex.app on a Mac:
- Codex and Claude Code on the Mac use models from the Linux server through a local OpenCodex gateway.
- The local OpenCodex.app manages that server through a local management relay.
- OpenCodex starts and maintains the SSH connection. The user does not need to keep a manual tunnel running.
- Model access and management have separate credentials and permissions.
- Other applications can keep using a separately published, model-only API on the server.
The same design should allow model-only connections, management-only connections, and connections with both functions. Selecting server B in the dashboard must not change the model source already selected for Codex on server A.
This is an architectural proposal. The new combinations described below are not implemented or validated by this report.
What prevents this today?
The current configuration combines several independent choices: runtime role, remote protocol, client routing, and dashboard target.
The source references in this issue use the fixed snapshot 93cdffd6ac7f125d4b932a6d45af5c3ab1de5156, from the 2.78.0 main lineage. They are not claims about later changes.
| Current behavior | Source at that snapshot |
|---|---|
Runtime roles are standalone, hub, and client; client transport is hub or link. |
config types |
| Home and Child are Link status labels, not two additional runtime roles. | Link status |
| Hub Client configures Codex with a direct remote URL and an environment key. Link Child uses a local gateway. | client connection |
| Link rejects a separate management URL and management relay. | config validation, machine listener |
The GUI has machine and shared targets. shared carries both remote dashboard routing and model-source metadata. |
GUI targets, page bindings |
Here, shared is an internal GUI target name. In Hub Client it points to the remote server, directly or through a relay. In standalone it is the same server as machine. In Link Child it also resolves to the local machine, because the current Link listener does not provide management APIs (machine status projection).
As a result, model catalog/client usage and provider administration share one target concept. Adding remote management to Link alone would improve that workflow, but would leave this wider coupling in place.
What should OpenCodex do?
1. Use one connection model
Use three records, with channels stored inside a connection:
| Record | Responsibility |
|---|---|
| Node | Local identity, providers, state, and explicitly enabled listening endpoints with their access policies. |
| Connection | A relationship with one verified remote node, its transport lifecycle, and optional model and management channels. |
| Bindings | The active model source for local applications, their gateway/direct route, and the independently selected management target in the GUI. |
Here, a node's providers are the providers and account pools configured on that node, including external provider APIs. They do not have to run on that machine.
A channel describes its purpose, endpoint, protocol profile, required capabilities, and credential reference. It does not need a separate store or supervisor. New connection descriptors use credential references and the existing protected credential storage.
Hub, Home, Client, and Child can remain familiar setup profiles and status labels. A role name should not decide all routing and permissions at once. Replace role checks only after their existing security and lifecycle responsibilities have explicit replacements.
Keep one active model source in the first version and preserve support for multiple clients served by a node. Model source A and management target B may use separate running transports. Switching the model source is explicit and uses the existing integration ownership and restoration checks. A saved configuration does not activate a connection. A new saved-connection manager or universal node identity format is not required: reuse existing connection IDs and authenticated SSH/TLS identities, and do not treat a temporary forward port as the peer identity.
2. Separate delivery, protocol, and application routing
These are different choices:
- Delivery: OpenCodex-managed SSH or a supplied endpoint. Supplied endpoints may use verified HTTPS or an explicitly configured loopback HTTP address. An externally managed SSH tunnel is a supplied endpoint; OpenCodex must not claim ownership of that process.
- Protocol profile: ordinary authenticated model HTTP/WebSocket APIs, or the existing connection-bound Link protocol. Management has its own API/session profile.
- Application route: local gateway or direct remote access.
Validate supported combinations using the existing protocol/version checks. This does not require a new general protocol framework.
For new connections, recommend the local gateway only when it supports the protocols required by the application. The gateway uses the enrolled remote model credential instead of forwarding the application's admission credentials. Compatibility checks must cover authentication semantics as well as protocols; do not silently replace a route that relies on caller-authenticated passthrough. Codex then does not need OPENCODEX_API_AUTH_TOKEN in its environment.
Keep existing direct Hub routing. Do not replace it until the gateway supports the same required SSE streaming, tool calls and continuation, supported endpoints, and WebSocket flows. Do not silently downgrade a client that requires WebSocket.
Choosing managed SSH does not choose Link. Ordinary Hub APIs over managed SSH, with direct access or a compatible gateway, are also target combinations. For a new direct route, the adapter and application must preserve protocol/authentication semantics and verify the enrolled recipient on each connection before sending credentials or bodies. SSH process/forward ownership alone does not prove this. Enable the combination after its concrete mechanism passes a separate delivery slice's checks; otherwise offer supplied verified HTTPS direct access, or Link gateway access for compatible applications. This does not impose a new TLS model listener on existing profiles or delay Link management.
Keep Link's existing socket-bound HMAC checks and HTTP fallback/426 behavior. Direct routing is unsupported for the connection-bound Link profile. An application that requires WebSocket cannot select this profile unless a compatible protocol profile is available. SSH provides delivery and host authentication; it does not remove the Link protocol checks. See Link transport authentication and Link route limits.
3. Separate the model source from the management target
The GUI needs three request contexts:
- Machine: local service, launcher/shim, and application bindings.
- Inference: catalog, readiness, and client usage for the active model source.
- Management: providers, settings, and administrative statistics for the selected node.
These are logical contexts, not a requirement for three ports. They may point to the same node.
Opening another management target must not rewrite the model catalog, Codex configuration, or active model source. A “Configure this model source” action should select the management target of that connection. If management is disabled or unsupported, offer its explicit setup or show that it is unavailable; do not enable it automatically.
Catalog, readiness, and model-source status follow the selected model source. Preserve existing /v1/catalog, /v1/models, and supported /v1/hub-state reads. Preserve /v1/usage where the peer supports it: the existing Hub endpoint authenticates a configured model key and returns usage scoped to that key, without management access. Link already allows these read routes; it does not make a non-Hub peer support Hub-only endpoints. Show unsupported or unavailable reads honestly. Model requests must keep working without usage or management access. Do not substitute statistics from another management target or broaden permissions. Additional telemetry endpoints, broader usage scopes, and local accounting are separate features. See Hub usage admission and existing Hub client behavior.
Preserve the current validated catalog/cache behavior: permitted transient failures may use the matching last good snapshot, while authentication, schema, size, or protocol failures keep their existing fail-closed behavior. This is not permission to fall back to local providers or another peer.
Management routing is a separate choice from model gateway/direct routing. Keep existing direct and relay GUI management. New SSH management uses the verified fixed-target relay. Supplied HTTPS management may use direct browser access when the peer supports the browser Origin/session contract, or the fixed-target relay when compatible; do not assume a model endpoint can also serve management. Native application and local integration actions still use the machine context. Remote provider OAuth keeps its existing server-side flow and headless URL/code handoff when the browser callback cannot reach that server; provider credentials remain on their owning node.
Keep sessions and cached data associated with the intended peer and request context. A changed forward port must not redirect credentials or reuse another peer's data. Reuse existing target checks and SSH lifecycle state; a new global generation or cache framework is not required. An authenticated reconnect to the same peer can retain its session under the existing session-expiry rules.
Track transport, model access, and management status separately. Management session expiry must leave model access working. A model-channel failure must not invalidate the management session. A shared SSH failure can affect both remote channels, while local machine controls remain available.
Disabling management stops its requests, marks that target unavailable, and retires its active GUI session under existing session rules; it leaves the model binding working. Disabling model access restores only affected application bindings through the existing ownership checks and leaves management working. An explicit disable may restore prior local bindings; an outage must not cause automatic local-account fallback. Keep shared SSH running while another enabled channel needs it. Whole-connection disconnect detaches both channels. Local detach/logout and remote key revocation remain distinct operations: preserve Hub's offline local disconnect and Link's existing owner-specific remote cleanup and recovery. Never silently select another management node.
4. Keep authorization separate
Model API keys do not grant management, pairing, or remote workspace access. Management keeps its own pairing, session, Origin, CSRF, and operation-specific write-intent checks. Preserve supported legacy management API authentication; a raw administration token still does not become a browser GUI session or consent for privileged GUI operations.
Capabilities describe what a peer supports. They do not grant permission to use it. New management access requires an explicit action and a compatible peer. An older peer keeps its known legacy behavior; missing capability metadata must not be treated as full access.
Do not add /api/* to the existing Link data allowlist. Reuse the fixed-target management relay pattern, not an arbitrary HTTP proxy. The current Hub relay is a useful starting point, but the new transport needs its own recipient verification.
5. Verify the new SSH management recipient before sending secrets
For Child-initiated SSH, checking the local SSH process and forward owner is necessary for lifecycle control, but is not sufficient to authenticate the recipient. Each adapter keeps its existing binding and ownership checks; Home-initiated reverse SSH has no local Child SSH PID to check. Another listener could take the port between an ownership check and a TCP connection.
For the new management channel over SSH, the proposed recipient check uses a separate HTTPS control endpoint on the remote node. It can listen on loopback. SSH forwards TLS without terminating it. Verify the pinned server certificate/public key on the same TLS connection that will carry pairing credentials, sessions, and request bodies, before sending those values.
Obtain the trust pin through an authenticated SSH bootstrap with a verified host key, or through separately approved trust provisioning. Do not bootstrap trust through the forwarded HTTP port being checked. Public trust metadata does not grant administrative access. The new control endpoint still requires pairing and authorization even when it listens on loopback.
Preserve both SSH directions:
- When Child initiates SSH, preserve ownership checks for its local forward.
- When Home initiates reverse SSH, preserve the reverse adapter's binding checks. No local SSH PID is expected on Child. Provision control trust on Child separately before enabling management.
In both cases, require TLS peer verification before management credentials or bodies are sent. Missing required trust, proof, or capability leaves the new management channel off; existing Link model access remains available.
Keep the relay target and canonical server origin fixed to the enrolled channel. Verify the pin on every new connection. Do not follow redirects or fall back to plaintext. Reconnecting must not reuse another peer's session. Changing the control trust pin requires approval through the existing trusted channel or a new trusted bootstrap.
The first SSH delivery slice can keep the existing Link model channel and add management separately. Preserve the existing authentication of each model protocol. This proposal does not require adding a new TLS listener for model traffic or redesigning supplied-loopback routes. Any future model transport must verify its recipient before forwarding secrets; its concrete mechanism belongs to that transport's implementation.
Preserve already configured legacy Hub management under its existing contract. The new SSH control profile requires server-side support; it is not a configuration-only change for an old Home instance.
For a supplied HTTPS management endpoint, keep normal TLS server verification and the existing fixed-origin/session authorization checks. This confirms the recipient; pairing still controls administrative access. New-channel compatibility failure affects that channel, not supported model access or already configured legacy management.
6. Keep a published model API separate from a client gateway
A node may both serve other applications and use a remote model source for its own local clients. These are separate incoming request surfaces:
- An explicitly published serving endpoint uses providers configured on that node.
- A local client gateway uses the active inference binding, which may be remote.
Select the dispatcher from the listener and its policy, not caller headers. Keep credential scopes separate. Connecting the node to an upstream must not automatically turn its published API into an upstream relay or expose management to downstream clients.
Preserve existing local API behavior, explicitly configured downstream admission policies, and the Hub's local companion listener. Enrolling a connection does not change those policies. Update application configurations only for selected integrations; preserve unselected configurations, existing provider/account state, service repair, and restoration checks. Callers of the client gateway use its active inference binding. Existing model endpoints and their streaming, cancellation, timeout, and safe-retry behavior must survive adapter extraction, beyond the Codex/Claude examples above.
The first version does not add forwarding between connection bindings, multiple active inference upstreams, or automatic fallback to local accounts. This does not restrict existing custom-provider URLs.
Preserve the existing experimental, opt-in Remote Workspace capability independently of role labels, including its separately authorized devices, roots, sessions, and lifecycle. It is not enabled by either connection channel. Its executor WSS transport and execution grants remain separate; management relay support does not imply that the relay carries executor WebSocket traffic. Existing platform and sandbox limits remain in force. No new workspace feature is required. See Remote Workspace contract.
Example usage or interface
One “Connect server” flow could ask for an SSH alias or HTTPS endpoint, then offer model access and management access separately. Gateway routing is recommended after a protocol compatibility check; direct routing remains an explicit advanced option where supported.
Expected Mac/Linux topology:
flowchart LR
C[Codex / Claude Code on Mac] --> G[Local OpenCodex gateway]
U[OpenCodex.app on Mac] --> R[Local management relay]
G --> D[Model channel]
R --> M[Management channel]
D --> P[Providers on Linux server]
M --> A[Settings on Linux server]
S[Other server-side applications] --> E[Separate model-only API]
E --> P
The two remote channels can share one managed SSH session, with separate forwards and authorization.
| Scenario | Model source / route | Management |
|---|---|---|
| Existing standalone | Local providers; existing local route | Local, unchanged |
| Existing Hub Client | Remote; existing direct route | Existing direct/relay behavior |
| Existing Link Child | Remote; local gateway with Link protocol | Off, unchanged |
| New SSH + Link connection | Remote; existing Link gateway, no direct/WS route | Off until separate control trust setup and pairing; fixed-target relay |
| New SSH + ordinary Hub API | Direct or compatible gateway, including supported WS; only after profile recipient/authentication checks pass | Independently off or paired control relay; not gated on the Hub gateway |
| New HTTPS connection | Remote; compatible gateway or explicit direct | Off or separately authorized; direct browser access or fixed-target relay when compatible |
| Management-only connection | Current local or remote model binding, unchanged | Selected remote node |
| Models from A, management of B | A remains the active source and client usage scope | B selected independently, with its own authorization |
| Home-initiated Link | Existing reverse SSH and Link gateway | Optional, after separate control trust, capability check, and pairing |
| Supplied loopback endpoint / external tunnel | Existing supported route; external process remains operator-owned | Existing behavior; new access only under its supported authorization profile |
| Disable one channel / disconnect both | Restore affected model bindings only on explicit model detach | Disable only the requested target/channel; retain transport needed by the other channel |
| Other applications using a published API | Providers configured on the node; separate model credential | No management access from that credential |
| Existing Remote Workspace | Existing independently authorized execution; distinct from local-app model routing | Preserve supported workspace administration and separate executor transport; opt-in unchanged |
Alternatives or workarounds
- Use Hub Client and an external SSH tunnel: useful today, but tunnel ownership remains outside OpenCodex and the current Hub client route remains direct.
- Add management to Link only: a useful first delivery slice, but it does not separate GUI model-source selection from administration or provide a common configuration model.
- Replace all profiles with independent flags immediately: this risks invalid combinations and loses safety checks currently attached to roles.
- Force every client through a gateway immediately: this can lose existing direct-route protocol support, especially WebSocket.
The proposal keeps the existing protocol implementations and migrates their configuration and safety checks in stages.
Additional context
Suggested delivery slices
Prepare compatibility and state handling first. Each later slice has its own activation and verification; management can ship before the optional Hub gateway.
- Add a pure internal adapter from existing configuration to Node/Connection/Bindings. Preserve URLs, credentials, client selection, listeners, and management behavior. Do not enable new access during normalization. Settle pending rotation/disconnect operations through existing recovery before migration. If recovery cannot complete safely, do not migrate the affected binding or credential state; keep the pending operation recoverable.
- Plan the minimum configuration changes and rollback before changing persistent state. Reuse the existing configuration mutation path, credential storage, and rotation/disconnect journals, including
service-api-tokenand.prev. Keep model and management credentials separate. Add fields or credential references only where needed; do not introduce a second writer or recovery engine. - Extract endpoint resolution and protocol adapters. Reuse the existing SSH supervisor and ownership state machine. Test both SSH directions and control recipient verification before activating new paths.
- Separate inference bindings and management targets. Add the optional management channel with fixed-target relay, trust setup, and pairing.
- Add and verify ordinary Hub API combinations separately: managed SSH delivery where the adapter/application meets recipient and authentication requirements, and a gateway with required protocol parity. Neither is a prerequisite for Link management. Preserve client configuration snapshots, catalog restoration, journals, and checks against overwriting later edits, and validation of the local runtime before changing Codex/Claude bindings. Keep published serving endpoints on their node-provider dispatcher.
- Migrate and activate each completed slice explicitly, preserving legacy CLI/status behavior. Test recovery and rollback for the state that slice changes. If a schema change is needed, document older-binary compatibility before writing it. Management improvements do not need to wait for the optional Hub gateway or its WebSocket support.
- Update GUI profiles, CLI status, structure documentation, and user documentation. Remove old role-dependent branches only after their security and lifecycle contracts have replacements.
Likely code areas include src/types/config.ts, src/config/schema/leaf-validators.ts, src/client/state.ts, src/remote/protocol.ts, src/link/*, src/client/hub-client.ts, src/client/machine-api.ts, src/client/machine-listener.ts, src/client/connect.ts, gui/src/api-targets.ts, and the Codex/Claude integration code.
Acceptance criteria
- Legacy configuration normalization and migration preserve model URLs, routes, credentials, selected and unselected client integrations, listeners, local/downstream admission policies, and existing management access. A missing legacy transport still means Hub. Existing opt-in workspace authorization and executor lifecycle remain intact.
- The new Hub gateway completes real SSE streaming, tool-call and continuation round trips without
OPENCODEX_API_AUTH_TOKENin Codex's environment, and does not forward caller credentials upstream. - Existing direct Hub flows, including supported WebSocket flows, keep working. Link keeps its socket proof, supported endpoint allowlist, streaming/cancellation behavior, and HTTP fallback. Test new ordinary-Hub-over-managed-SSH combinations only when their concrete recipient/protocol/authentication mechanism is ready; never substitute Link for a WS-required route.
- Management session expiry blocks management while model requests still work. Model keys never authorize management, pairing, or workspace access. An unpaired request to the new control endpoint is rejected even after successful TLS verification and on a loopback bind.
- Switching management from A to B leaves the active model source, catalog, client configuration, and client usage identity unchanged. Preserve existing authorized model-source reads, including key-scoped
/v1/usageon compatible peers, and their error/cache semantics. Unsupported reads are clearly unavailable; model requests do not depend on usage. Test compatible direct/relay GUI management and the existing remote headless OAuth handoff. - Both SSH directions preserve their ownership, configured retry policy, and recovery behavior across sleep, network loss, and restart. Home-initiated forwarding does not require a Child SSH PID. A substituted new management forward listener or a different socket after recipient verification receives no management secrets or request bodies. Link retains its same-socket authentication protections.
- New SSH management verifies the pinned recipient before credentials or request bodies are sent. New model transports satisfy their own verified recipient/authentication contract before activation; existing model profiles retain their current contracts. An incompatible capability blocks only the affected new channel; missing management support does not break models or legacy management. New verified profiles refuse redirects and plaintext downgrade. No automatic local-account fallback occurs.
- Management-only disable, model-only disable, and whole-connection disconnect preserve the surviving channel, shared transport when needed, affected GUI session rules, and binding ownership/restoration checks. Local detach and remote revocation stay distinct. Credential rotation and migration retain existing recovery rules and never overwrite later edits or grant access to another channel. Interruption tests cover affected pending operations through the existing mutation/recovery path.
- Repeated starts do not create duplicate tunnels or listeners. Cleanup stops only owned processes. A failure to bind an explicitly configured port is reported clearly without changing the configured target.
- With a remote model binding, the client gateway reaches the remote peer while the published serving endpoint reaches providers configured on that node. Their credential scopes are not interchangeable; a model-only key cannot manage the server.
- Old clients and peers keep their existing supported behavior, including already configured Hub management. New management access remains off without explicit setup and compatible server support.
- Each delivered slice has focused behavior tests, regression checks for the legacy behavior it touches, and temporary-instance integration checks, followed by applicable typecheck, privacy/structure checks, and GUI build. Cover the complete scenario matrix across delivery slices; unfinished optional Hub gateway/WS or managed-SSH Hub combinations do not block the independently verified Link management slice. Real Mac/Linux installation and request tests remain a separate acceptance step; unit tests alone do not prove deployment readiness.
The main risks are broader permissions when replacing role checks, accidental coupling between channel states, loss of direct-route protocol support, reuse of sessions after peer changes, and unsafe configuration rollback. The staged delivery and negative tests above are intended to address these risks.
Checks
- I searched existing issues and the remote connection source/structure documentation.
- This request describes a concrete OpenCodex workflow.
- Secrets, personal hostnames, local paths, and private deployment details have been removed.
Activity
Ingwannu commentedon Oct 6, 2026
This is a substantial connection/configuration architecture proposal, not a small bug-fix patch. Keeping it open for an owner scope/prioritization decision; intake does not approve the proposed permission or migration model.
@lidge-jun: please confirm whether to pursue the independently scoped Link-management slice first, or the wider connection/binding normalization. Before implementation, the first slice should state the exact legacy behavior it preserves, activation boundary, compatibility/rollback rules and measurable acceptance criteria. A pure normalization adapter must not persist migration or activate new access merely by loading existing configuration. Later model/management combinations need their own review and validation; a unified label is not authority to widen either channel.
No roadmap commitment, new connection, configuration migration, trust setup, runtime change or security scan was performed during this triage.
lidge-jun commentedon Oct 22, 2026
Thank you for the detailed proposal. We're closing this as not planned: it is outside the current priorities, and keeping it open would suggest work that isn't scheduled. The discussion stays here for reference. If you'd like to pursue it, please reopen this or open a new issue with a narrow, opt-in first slice.