Skip to content

fix(acp): forward hosted credentials - #118

Merged
cursor[bot] merged 2 commits into
mainfrom
Travis-Gilbert/acp-hosted-railway-bridge
Jul 25, 2026
Merged

fix(acp): forward hosted credentials#118
cursor[bot] merged 2 commits into
mainfrom
Travis-Gilbert/acp-hosted-railway-bridge

Conversation

@Travis-Gilbert

@Travis-Gilbert Travis-Gilbert commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Routes CommonPlace server-side hosted ACP connections through the configured Theorem credential when an incoming Authorization header is unavailable. Includes a focused transport contract test.

Summary by CodeRabbit

  • Bug Fixes

    • Hosted ACP connections now fall back to the configured Theorem API key when no request authorization token is provided.
    • Authentication query parameters are handled consistently for hosted WebSocket connections.
  • Tests

    • Added coverage for API-key-based hosted connection authentication.
    • ACP unit tests now run as part of the continuous integration checks.

Copilot AI review requested due to automatic review settings July 25, 2026 22:50
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 40a9a4b4-94a1-47f5-8cad-6208203e5c6f

📥 Commits

Reviewing files that changed from the base of the PR and between 245a0b9 and 8a43698.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • .github/workflows/console-ci.yml
  • packages/theorem-acp/package.json
  • packages/theorem-acp/src/hosted-client.test.ts
  • packages/theorem-acp/src/hosted-client.ts
  • packages/theorem-acp/vitest.config.ts

📝 Walkthrough

Walkthrough

The ACP hosted WebSocket resolver now uses THEOREM_API_KEY when no request token is available. Vitest configuration, package scripts, regression tests, and a CI gate were added for ACP unit test execution.

Changes

ACP hosted authentication tests

Layer / File(s) Summary
Hosted token fallback and regression coverage
packages/theorem-acp/src/hosted-client.ts, packages/theorem-acp/src/hosted-client.test.ts
Hosted WebSocket URLs fall back to the trimmed THEOREM_API_KEY; tests clear credential environment variables and verify the resulting tokenized URL.

ACP test runner and CI execution

Layer / File(s) Summary
ACP Vitest and CI execution
packages/theorem-acp/vitest.config.ts, packages/theorem-acp/package.json, .github/workflows/console-ci.yml
The ACP package adds Vitest configuration and a test script, and console CI runs the ACP tests after typechecking.

Estimated code review effort: 2 (Simple) | ~10 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch Travis-Gilbert/acp-hosted-railway-bridge

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Theorem ACP hosted WebSocket URL resolution so server-side environments can still authenticate when there is no incoming Authorization header by falling back to a configured Theorem credential, and adds a targeted transport contract test for that behavior.

Changes:

  • Extend appendToken() to fall back to process.env.THEOREM_API_KEY when no request-derived bearer token is available.
  • Add a focused test asserting THEOREM_API_KEY is used to append ?token=... when no request token is present.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/theorem-acp/src/hosted-client.ts Adds server-credential fallback for hosted ACP WS tokenization.
packages/theorem-acp/src/hosted-client.test.ts Adds a contract test for server credential fallback behavior.
Comments suppressed due to low confidence (2)

packages/theorem-acp/src/hosted-client.test.ts:37

  • These tests can become environment-dependent: resolveHostedAcpWsUrl() derives a token via forwardAuthHeaders() from several env vars (THEOREM_API_TOKEN / THEOREM_AGENT_* / RUSTYRED_AGENT_BEARER). If any of those are set in the runner, the resolved URL will include ?token=..., making this assertion flaky. Clear the full set of token env vars in this test setup in addition to THEOREM_API_KEY.

This issue also appears on line 44 of the same file.
packages/theorem-acp/src/hosted-client.test.ts:46

  • This test assumes THEOREM_API_KEY is the only available credential. If any of THEOREM_API_TOKEN / THEOREM_AGENT_* / RUSTYRED_AGENT_BEARER are set in the environment, forwardAuthHeaders() will supply an Authorization header and appendToken() will prefer that over THEOREM_API_KEY, causing a nondeterministic failure. Clear the other token env vars in this test before setting THEOREM_API_KEY.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5937562bf4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

);
});

it('uses the server Theorem credential when no request token is present', () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the relocated tests in a runnable suite

After moving this file out of apps/web/src, none of the configured test jobs execute it: the web and console Vitest configurations only include their respective src/** trees, while @commonplace/theorem-acp exposes only a TypeScript check script and CI invokes only that check. Consequently, this new credential contract test and the four existing routing tests moved with it can regress while every unit-test job remains green; add a package test configuration/script and CI invocation, or retain the tests in a consuming application's suite.

Useful? React with 👍 / 👎.

delete process.env.THEOREM_AGENT_API_TOKEN;
delete process.env.THEOREM_AGENT_API_BEARER;
delete process.env.RUSTYRED_AGENT_BEARER;
delete process.env.THEOREM_API_KEY;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Clear all fallback credentials in the unauthenticated URL test

When the test process has any supported hosted credential such as THEOREM_API_TOKEN, THEOREM_AGENT_API_TOKEN, THEOREM_AGENT_API_BEARER, or RUSTYRED_AGENT_BEARER, forwardAuthHeaders still supplies it and resolveHostedAcpWsUrl() appends it as ?token=..., contradicting the bare-URL expectation below. The test previously deleted all four variables, but this replacement deletes only THEOREM_API_KEY, making the result depend on the runner's environment once the relocated suite is wired back into Vitest.

Useful? React with 👍 / 👎.

Clear all auth credential env vars so the transport contract stays
deterministic, and wire theorem-acp vitest into console CI.

Co-authored-by: Travis Gilbert <Travis-Gilbert@users.noreply.github.com>
@ecc-tools

ecc-tools Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

@cursor
cursor Bot merged commit 615b6d9 into main Jul 25, 2026
2 of 7 checks passed
@cursor
cursor Bot deleted the Travis-Gilbert/acp-hosted-railway-bridge branch July 25, 2026 23:36
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.

3 participants