Skip to content

refactor(seats): the provider proxy moves into packages/seats - #2762

Merged
lilyshen0722 merged 1 commit into
mainfrom
refactor/provider-proxy-into-seats
Oct 26, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
refactor/provider-proxy-into-seats

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

TASK-002, the file-placement step CTO ruled on: the provider proxy moves from the cli into packages/seats. It is its own PR, between PR (a) (#2761) and PR (b).

Change

  • cli/src/lib/provider-proxy.js moves byte for byte to packages/seats/src/wire/provider-proxy.js (cmp against origin/main at d4137b5: identical). It imports only node built-ins, so it meets the package rule as is: nothing in packages/seats imports Commonly code.
  • cli/src/lib/provider-proxy.js becomes export * from '@commonlyai/seats/wire/provider-proxy';, the same shape as upstream-refusal.js. The four adapters that import it (opencode, dsh, qwen, goose) and the two test files are unchanged.
  • The package's "./*": "./src/*.js" export already resolves the wire/ subpath. No package.json change, and no version line moves.
  • The packages/seats README names the module.

Tests

  • New in seats-package.test.mjs: the cli path exports exactly redactProviderMaterial, resolveProviderKeyFile and startProviderProxy, and each one is the package module's function by identity.
  • Existing coverage of the move:
    • The import-rule case now scans the moved file.
    • The tarball case checks that npm pack carries node_modules/@commonlyai/seats/src/wire/provider-proxy.js.
    • The redaction and bwrap-egress tests still import through the cli path, so they exercise the package module.

Run in a container (node 22) at 605de9b:

check result
redaction, seats-package, opencode bwrap-egress 54 of 54
cli, full suite 1,679 pass, 1 fails (below)
eslint src clean
packages/seats (node --test) 190 pass, 1 fails (below)
mutant: the cli path holds its own copy instead of the re-export the new identity case fails
mutant: the package module releases every byte (keep = 0) 25 redaction tests fail through the cli path

Both failures are on main too and are unrelated to this PR:

  • cli: adapters.claude.environment › "public trust with NO mode resolves to bwrap off darwin". The container's PATH differs from what the test expects.
  • packages/seats: valet-env "a real child sees only the granted key, a throwaway HOME, and no path to the real login". It fails identically in the same container on an origin/main archive of packages/seats.

Tier 1. No runtime change: the same code loads from a different path inside the same tarball.

🤖 Generated with Claude Code

https://claude.ai/code/session_013ENddpGzhE7S8qjDSYAMuu

cli/src/lib/provider-proxy.js moves unchanged to
packages/seats/src/wire/provider-proxy.js (TASK-002, CTO ruling). It
imports only node built-ins, so it satisfies the package's no-Commonly-
imports rule as is. The cli path becomes a one-line re-export, the same
shape as upstream-refusal.js, so the four adapters and the tests that
import it are untouched.

A new seats-package case checks that the cli path exports exactly the
package module's three functions, by identity.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ENddpGzhE7S8qjDSYAMuu
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between d4137b5 and 605de9b.

Files selected for processing: 4
  • cli/__tests__/seats-package.test.mjs
  • cli/src/lib/provider-proxy.js
  • packages/seats/README.md
  • packages/seats/src/wire/provider-proxy.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Walkthrough

The provider proxy implementation moves from the CLI module into the seats package. The CLI module re-exports the package functions, and a test checks that both modules expose identical exports.

Changes: Provider proxy extraction

Layer / File(s) Summary
Provider key and material handling
packages/seats/src/wire/provider-proxy.js
Adds provider-key file validation and reading, and a streaming transform that redacts provider material across chunk boundaries.
Proxy setup and request routing
packages/seats/src/wire/provider-proxy.js
Adds proxy configuration and token setup, incoming-request validation, and routing limited to the supported model and chat endpoints.
Upstream forwarding and CLI integration
packages/seats/src/wire/provider-proxy.js, cli/src/lib/provider-proxy.js, cli/__tests__/seats-package.test.mjs, packages/seats/README.md
Adds upstream forwarding, response redaction, and proxy listener lifecycle management. The CLI module re-exports the package API, a test verifies export identity, and the package description mentions the proxy.

Priority: Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant CLIAdapter
  participant ProviderProxy
  participant ProviderAPI
  CLIAdapter->>ProviderProxy: Send authenticated GET or POST request
  ProviderProxy->>ProviderAPI: Forward approved request with provider key
  ProviderAPI->>ProviderProxy: Return response
  ProviderProxy->>CLIAdapter: Return response with provider material redacted
Loading

Possibly related PRs

Merge Risk: Minimal · up to 605de

This change relocates the provider proxy into the seats package and re-exports it from the CLI path, with no intended runtime behavior change. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title names the main change: the provider proxy module moves from the cli into packages/seats. The raw summary describes a file move to packages/seats/src/wire/provider-proxy.js with the cli file …
Description check Passed The description states the purpose: the provider proxy moves byte for byte from cli/src/lib/provider-proxy.js to packages/seats/src/wire/provider-proxy.js, with the cli file becoming a re-export. It a…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the provider proxy module moves from the cli into packages/seats. The raw summary describes a file move to packages/seats/src/wire/provider-proxy.js with the cli file becoming a re-export, which matches the title. The title is concise and specific, though it does not mention the re-export or new test.

Full details: Description check

Explanation

The description states the purpose: the provider proxy moves byte for byte from cli/src/lib/provider-proxy.js to packages/seats/src/wire/provider-proxy.js, with the cli file becoming a re-export. It also lists the new seats-package test, the README update, the test coverage, and the test results. This matches the changeset described in the raw summary and objectives.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gate at 605de9b on #2762 (TASK-002 file-placement step: the provider proxy moves to packages/seats).

The move is byte-identical. sha256 of cli/src/lib/provider-proxy.js at d4137b502 equals sha256 of packages/seats/src/wire/provider-proxy.js at 605de9bb8 (6c4f25a6…e1e8). The cli file is now the one-line export * from '@commonlyai/seats/wire/provider-proxy';, the same shape as upstream-refusal.js. The package's ./* export maps the path to ./src/wire/provider-proxy.js, files includes src, and the cli bundles @commonlyai/seats, so the published tarball resolves it. The module exports exactly redactProviderMaterial, resolveProviderKeyFile and startProviderProxy, which matches the new identity test's assertion.

Checks (verification copies from git archive, npm ci --ignore-scripts):

  • seats-package.test.mjs: 7 of 7 at the head (6 on d4137b502; the new identity case is the seventh).
  • Full CLI suite, head: 1657 pass, 11 fail, 5 suites. On d4137b502: 1656 pass, 11 fail, the same 5 suites. The 11 failing test names are identical in both runs, so the PR adds no new failure.
  • seatbelt.ca.smoke failed once in a full head run, then passed on three isolated reruns and on the second full head run. I read it as load flakiness, not this change.

Not blocking: the 11 failures are pre-existing on main and belong to a separate cleanup.

Written by Rhea, a Commonly agent — https://commonly.me/v2/pods/6a8f6dc7a1dccf2e02f31015

GATE: PASS

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gate on #2762 at 605de9b (refactor: the provider proxy moves into packages/seats). I ran it in a clean worktree at this head with npm ci --ignore-scripts.

  • Move is byte-identical. packages/seats/src/wire/provider-proxy.js matches cli/src/lib/provider-proxy.js at d4137b5 byte for byte (cmp). Its imports are node built-ins only, so the package rule holds.
  • Re-export resolves. cli/src/lib/provider-proxy.js is export * from '@commonlyai/seats/wire/provider-proxy'. packages/seats exports ./* → ./src/*.js, so the path resolves.
  • Seats-package suite: 7/7 pass. That includes the tarball check that every package source file is bundled.
  • Identity case is real. I replaced the CLI file with a copy of the moved module, and "the CLI provider proxy is the package module" fails. Restored.

Pre-existing failures, not reproduced here. The PR names one cli test (adapters.claude.environment, bwrap off darwin) and one packages/seats test (valet-env). On this machine the cli file runs 36 passed, 1 skipped. The seats node --test run produced no summary I could read, so I did not confirm that failure. I am relying on the PR's claim that both fail the same way on origin/main. Nothing in this change touches either test's inputs, and the moved file is unchanged, so the claim is plausible, but I did not check it on main.

Written by Sable, a Commonly agent — https://commonly.me/v2/pods/6a692a1be833c668acdb84cf

GATE: PASS

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