mirror of
https://github.com/dtzp555-max/ocp.git
synced 2026-07-19 09:44:07 +00:00
Closes the structural side of the port-drift cascade addressed by
v3.16.2/v3.16.3. Those releases reverted the literal line-by-line; this
one removes the invitation to drift.
Changes:
* NEW lib/constants.mjs — exports DEFAULT_PORT=3456, LOCAL_HOST,
OPENAI_API_BASE, LOCAL_PROXY_URL.
* server.mjs / setup.mjs / scripts/upgrade.mjs / scripts/doctor.mjs
(x2) / scripts/sync-openclaw.mjs all import DEFAULT_PORT from
lib/constants.mjs instead of hardcoding "3456".
* .github/workflows/alignment.yml:
- path filter extended to setup.mjs, scripts/**, lib/**,
ocp, ocp-connect.
- NEW job port-spot hard-fails any PR that introduces a hardcoded
"3478" or "3456" literal outside EXEMPT_REGEX (lib/constants.mjs,
test-features.mjs, ocp/ocp-connect bash CLIs, docs, the workflow
itself).
* Doc-comment rewording so CI grep finds zero hits.
No behavior change for any user. CLAUDE_PROXY_PORT env var still wins
at runtime; only the unset-env fallback now flows through one constant.
ALIGNMENT.md note: server.mjs change is one import + one literal swap,
mechanical. No cli.js operation changed; the citation requirement does
not apply.
cli.js: not applicable — mechanical refactor, no behavior change.
Co-authored-by: dtzp555 <dtzp555@gmail.com>
34 lines
1.6 KiB
JavaScript
34 lines
1.6 KiB
JavaScript
/**
|
|
* OCP shared constants — single source of truth.
|
|
*
|
|
* Any literal that appears in more than one place across server.mjs, setup.mjs,
|
|
* scripts/* belongs here so port-drift / URL-drift cascades cannot recur.
|
|
*
|
|
* Background: from 2026-05-08 (PR #71 dogfood accident) through 2026-05-13
|
|
* (v3.16.3) a single hardcoded "3478" in scripts/upgrade.mjs + scripts/doctor.mjs
|
|
* cascaded into every downstream config write, ultimately taking out the
|
|
* OpenClaw "大内总管" Telegram agent. See CHANGELOG v3.16.2 and v3.16.3.
|
|
*
|
|
* Adding a new constant: prefer ALL_CAPS_SNAKE_CASE. Document the consumers.
|
|
* If a literal is referenced from a shell script (ocp, ocp-connect, setup.sh)
|
|
* that can't import .mjs, add a `// keep in sync with lib/constants.mjs` note
|
|
* at the shell-script reference; CI grep prevents drift.
|
|
*/
|
|
|
|
// Default TCP port the OCP HTTP proxy listens on. Set by env CLAUDE_PROXY_PORT
|
|
// at runtime; this is the fallback when env is unset.
|
|
// Consumers: server.mjs, setup.mjs, scripts/upgrade.mjs, scripts/doctor.mjs,
|
|
// scripts/sync-openclaw.mjs. Shell scripts ocp / ocp-connect keep the literal
|
|
// "3456" in sync with this value (see CI gate in .github/workflows/alignment.yml).
|
|
export const DEFAULT_PORT = 3456;
|
|
|
|
// Localhost bind for client-side fetches (curl, health checks).
|
|
export const LOCAL_HOST = "127.0.0.1";
|
|
|
|
// OpenAI-compatible API base path appended to the proxy URL.
|
|
export const OPENAI_API_BASE = "/v1";
|
|
|
|
// Convenience: full local URL the OCP proxy listens on by default.
|
|
// scripts that want to probe locally can use this directly.
|
|
export const LOCAL_PROXY_URL = `http://${LOCAL_HOST}:${DEFAULT_PORT}`;
|