Files
openclaw/docs/start
Peter Steinberger df2cc8f259 fix(onboard): honor secret-input-mode ref for the generated gateway token (#126877)
* fix(onboard): honor secret-input-mode ref for the generated gateway token

`openclaw onboard --secret-input-mode ref` was silently ignored for
`gateway.auth.token`: onboarding generated the token and wrote it into
`openclaw.json` as a plaintext string, so `openclaw doctor` warned about
`gateway.auth.token` on the install it had just created. The flag was
honored for provider credentials, so an operator who explicitly opted into
references still ended up with a plaintext secret and a remediation
(`openclaw secrets configure`) that cannot migrate a self-generated value,
because it validates a ref by resolving one that already exists.

Setup mints this token itself, so reference mode now provisions it:

- an ambient OPENCLAW_GATEWAY_TOKEN keeps an `env` ref to that variable, so a
  later rotation stays authoritative instead of being pinned by a stale copy
- anything else (freshly generated, or an existing plaintext token being
  migrated) goes into the shared SQLite secret store as a write-only `secret`
  entry, with config holding only `{source:"store",...}`

An existing store entry wins over a freshly generated one, so reruns never
rotate a token already paired with clients. The store write precedes the
config write: a ref persisted without its value would leave the gateway
unauthenticatable, while an orphaned entry is reused by the next run.

The interactive wizard had the same dead end and is fixed the same way.
Default (plaintext) onboarding is unchanged.

User impact: `--secret-input-mode ref` now keeps the gateway token out of
openclaw.json, and a fresh install no longer self-reports a plaintext-secret
warning.

* test(onboard): split gateway onboarding suite under the max-lines gate

The added gateway auth-token tests pushed
onboard-non-interactive.gateway.test.ts to 1014 lines, over the max-lines
limit (check-lint-core-3). Repo policy is to split, never suppress.

Extract the shared vi.mock/harness preamble into
onboard-non-interactive.gateway.test-mocks.ts, following the existing
agent-command.test-mocks.ts pattern, and move the four gateway auth-token
storage tests into their own suite. The reachability mock becomes a holder
object so both suites can swap it across the module boundary, and hoisted
mocks are re-exported in a separate export clause because Vitest rejects
exporting a vi.hoisted binding at its declaration.

Test set is unchanged: the it-declaration multiset matches the pre-split
file exactly, with no duplication across the two suites.

* test(onboard): give the shared gateway onboarding mocks unique export names

check-export-name-collisions flagged `runtime` and `readConfigFileSnapshotMock`
as colliding with program.test-mocks.ts and plugins-cli-test-helpers.ts once the
gateway onboarding preamble became a shared module. Rename the exports to
gatewayOnboardRuntime / gatewayOnboardConfigSnapshotMock per the repo's
unique-export-name rule; suites alias them locally so the assertions read the
same as before.

* test(tooling): route the new gateway auth-token suite from its test helper

test-projects asserts which suites a change to
onboard-non-interactive.test-helpers.ts should run. The new
onboard-non-interactive.gateway-auth-token.test.ts imports that helper, so it
belongs in the expected routing plan.
2026-08-20 17:46:59 -07:00
..