Skip to content

Read the Redrob Launcher shared account as the last console-key fallback - #87

Closed
its-janghoon wants to merge 1 commit into
developfrom
feat/shared-account
Closed

its-janghoon wants to merge 1 commit into
developfrom
feat/shared-account

Conversation

@its-janghoon

Copy link
Copy Markdown
Member

Summary

Redrob Launcher signs a computer in once and writes the workspace key to a shared account.json (contract: redrob-launcher docs/shared-account.md; REDROB_SHARED_DIR overrides the directory). Redrob Code now reads it as the LAST fallback for the console key, read-only and fresh on every use.

  • packages/core/src/shared-account.ts: the one reader (platform path, parse, read() with no cache). Never writes or deletes the file.
  • ConsoleKey.resolve keeps its signature; new ConsoleKey.resolveWithSource returns { key, source } with source: "env" | "credential" | "api" | "launcher".
  • ModelsDev.resolveApiKey reads the shared file fourth (env, Credential store, auth.json, then launcher), so a launcher-only sign-in gets the live catalogue instead of the six-id fallback.
  • V1 provider list (GET /provider): when nothing of the app's own is present (no REDROB_API_KEY, no auth.json entry, no config apiKey) the redrob entry is reported with source: "launcher" and the resolved key, and the loader no longer sets the options.apiKey: "public" placeholder. Provider.Info.source and the generated SDK/plugin types gain the launcher literal. Existing env / api / config / custom semantics and the public sentinel are unchanged.
  • DELETE /auth/redrob still removes only the engine's auth.json entry; the next read falls back to the shared file, which is left untouched.

Tests

  • packages/core/test/console-key.test.ts (new, 13): no key anywhere; shared only -> key + source launcher; env wins; auth.json wins over shared; auth.json removed -> falls back, shared file untouched; malformed/empty file; file removed between two resolves is seen (no cache). All against REDROB_SHARED_DIR in a scratch dir.
  • packages/redrob/test/provider/provider.test.ts (+4): provider report source: launcher + key with no public placeholder; absent/empty shared file keeps custom + public; env wins; auth.json wins and removing it falls back to launcher.
  • Both test preloads point REDROB_SHARED_DIR at a scratch dir. Without that, the core "no key" ModelsDev tests fail on a machine whose launcher is signed in (reproduced here), the same leak the preload already isolates XDG_DATA_HOME for.
  • Ran: core suite 1056 pass / 0 fail; redrob shard 4/4 (contains provider.test.ts) 827 pass / 0 fail; bun turbo typecheck 18/18; oxlint 0 errors on touched files.

Redrob Launcher signs a computer in once and writes the workspace key to a
shared account.json (Linux $XDG_CONFIG_HOME/redrob-shared, macOS
~/Library/Application Support/ai.redrob.shared, Windows %APPDATA%\Redrob\Shared;
REDROB_SHARED_DIR replaces the directory). The contract is redrob-launcher
docs/shared-account.md: read-only, read fresh on every use, the app's own key
wins, empty/missing/malformed means not signed in, never log the key.

core/shared-account.ts is the one reader: path resolution, parsing, and a
read() that hits the disk every call. It never writes or deletes the file.

Every console-key consumer now ends its chain at that file:

- ConsoleKey.resolve keeps its signature and gains resolveWithSource, which
  reports where the key came from: env | credential | api | launcher.
- ModelsDev.resolveApiKey reads it fourth, after REDROB_API_KEY, the
  Credential store and auth.json, so the dynamic catalogue is served to a
  launcher-only sign-in instead of the six-id fallback.
- The V1 provider list merges the redrob provider with source "launcher" and
  the key when nothing of the app's own is present (no env, no auth.json
  entry, no config apiKey), and the redrob loader counts it as a credential
  so the "public" placeholder is not set. GET /provider therefore reports
  the redrob entry with source: "launcher" and a resolved key, which is what
  a host app reads to show "Signed in with Redrob Launcher". The Info schema
  and the generated SDK/plugin types gain the literal.

DELETE /auth/redrob still removes only the engine's auth.json entry; the
next read falls back to the shared file, which stays untouched.

Both test preloads point REDROB_SHARED_DIR at a scratch directory: the
core "no key" ModelsDev tests failed on this machine for the same reason the
preload already isolates XDG_DATA_HOME, a real launcher sign-in in
~/.config. New tests cover no key anywhere, shared only, env wins, auth.json
wins, malformed/empty files, and a file removed between two resolves.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant