Skip to content

feat(codex): pull an authenticated remote catalog into local Codex state #3729

Description

@rrmlima

Area

Catalog / models

What are you trying to accomplish?

I need to keep a Codex CLI or Desktop client synchronized with the complete model catalog generated by a remotely hosted OpenCodex instance.

OpenCodex already exposes the persisted catalog through the authenticated GET|HEAD /v1/catalog data-plane endpoint. The missing workflow is safely materializing that snapshot into the remote client's local CODEX_HOME, rebuilding models_cache.json, and reporting when a running Codex app-server or Desktop process still holds the previous catalog in memory.

This would make centrally hosted OpenCodex deployments usable without maintaining deployment-specific web roots, cron jobs, PowerShell downloaders, or ad hoc cache-rebuild scripts.

What prevents this today?

model_catalog_json accepts a local filesystem path, not a URL. ocx sync builds a catalog from locally configured providers, while ocx export --client generates client-specific configuration; neither consumes a complete catalog from another OpenCodex server.

Operators currently need to implement the entire client-side lifecycle themselves:

  1. authenticate to /v1/catalog;
  2. download into a same-directory temporary file;
  3. validate JSON structure and model slug uniqueness;
  4. preserve the last-known-good catalog on network, HTTP, or validation failure;
  5. atomically replace the local catalog;
  6. rebuild $CODEX_HOME/models_cache.json;
  7. detect stale Codex app-server/Desktop processes;
  8. schedule the workflow separately on Windows, macOS, and Linux.

This duplicates security-sensitive filesystem and credential handling that OpenCodex already implements elsewhere and makes reliable Desktop synchronization unnecessarily difficult for non-technical client users.

What should OpenCodex do?

Provide an explicit remote-catalog pull workflow that consumes the existing /v1/catalog contract and installs the result as a local Codex catalog.

Observable requirements:

  • accept an HTTPS OpenCodex catalog URL;
  • read authentication from an environment reference or existing secure credential mechanism, never a plaintext CLI argument;
  • support conditional requests through ETag / If-None-Match, treating 304 as a no-op;
  • reject URL-embedded credentials and avoid forwarding authorization across origins;
  • enforce response-size and timeout bounds;
  • validate the complete catalog before the first filesystem mutation, including a non-empty models array and unique, valid slugs;
  • write through the existing catalog serialization and atomic replacement primitives;
  • preserve the last-known-good catalog and cache on every download or validation failure;
  • update models_cache.json in the same coordinated operation;
  • preserve mtimes and avoid process handling when the pulled catalog is unchanged;
  • report stale Codex processes after a real update;
  • keep --restart-codex and Windows --restart-desktop-app explicit and opt-in, because either can interrupt active work;
  • never mutate server configuration, provider credentials, or the source catalog.

The first implementation can stay intentionally narrow: one-shot pull plus cache update. A managed cross-platform scheduled integration can be discussed separately after the command contract is stable.

Example usage or interface

export OPENCODEX_CATALOG_AUTH_TOKEN='...'

ocx catalog pull \
  https://proxy.example.com/v1/catalog \
  --auth-env OPENCODEX_CATALOG_AUTH_TOKEN \
  --restart-codex

Machine-readable automation:

ocx catalog pull \
  https://proxy.example.com/v1/catalog \
  --auth-env OPENCODEX_CATALOG_AUTH_TOKEN \
  --json

Expected no-op result after an unchanged conditional request:

{
  "status": "unchanged",
  "catalogWritten": false,
  "cacheSynced": false,
  "codexRestarted": false
}

The exact command and environment-variable names are proposed for discussion; the important contract is authenticated remote-to-local materialization with coordinated catalog/cache writes and opt-in process restart.

Alternatives or workarounds

  • Serve a deployment-specific /dl directory: works, but duplicates the existing authenticated /v1/catalog endpoint and makes nginx/web-root permissions part of catalog correctness.
  • Cron plus shell/PowerShell scripts: currently workable, but each operator must reimplement validation, locking, atomic replacement, cache generation, error handling, and secret hygiene.
  • Point model_catalog_json at an HTTPS URL: incompatible with Codex's local-path contract and startup behavior.
  • Extend ocx export --client: misleading because that command exports client-specific configuration rather than the complete Codex catalog.
  • Server-side watcher or publisher daemon: does not solve client-side models_cache.json or in-memory Desktop staleness and adds another service lifecycle.
  • Automatically restart Codex Desktop: rejected as a default because it can terminate active conversations; restart must remain explicit.

Additional context

Related existing work solves adjacent, but different, layers:

A production deployment currently uses a validated atomic catalog publisher plus a Windows downloader/cache rebuilder. That proves the workflow is useful, but the proposal deliberately avoids upstreaming deployment-specific paths, nginx configuration, cron syntax, or public unauthenticated /dl behavior.

Security boundaries for implementation review:

  • no token in argv, output, errors, redirects, or persisted catalog metadata;
  • HTTPS by default;
  • no cross-origin credential forwarding;
  • bounded body acquisition;
  • validation before mutation;
  • catalog/cache writes only under the existing per-CODEX_HOME serialization permit;
  • no implicit process termination.

Checks

  • I searched existing issues and documentation.
  • This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
  • I removed secrets and personal data.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    catalogModel catalog, slugs, visibility, routed entriesenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions