Skip to content

[Node] Let Extensions Request Sensitive Environment Variables - #2348

Open
MRayermannMSFT wants to merge 4 commits into
mainfrom
mrayermannmsft-extension-env-sdk-half
Open

[Node] Let Extensions Request Sensitive Environment Variables#2348
MRayermannMSFT wants to merge 4 commits into
mainfrom
mrayermannmsft-extension-env-sdk-half

Conversation

@MRayermannMSFT

@MRayermannMSFT MRayermannMSFT commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

What

joinSession() accepts a new env option that names the sensitive environment variables an extension needs. The SDK sends those names to the CLI on the session.resume payload as requestedEnvironmentVariables. The CLI prompts the user with the extension name and the exact list. If the user approves, the SDK writes the granted values into the extension process's process.env before joinSession() resolves. If the user denies, joinSession() rejects and the extension does not load.

Why

The CLI strips sensitive variables from every extension process before it starts, so an extension can never read one. The host half of the gate shipped in github/copilot-agent-runtime#15144, but the SDK builds its session.resume payload from an explicit field list, so an env option could not reach the wire. Without this change no extension can trigger the prompt, and the feature is unusable. The runtime PR left the changelog entry for this side, because the feature becomes usable here.

A note on the E2E coverage

The released CLI predates the host half, so it ignores the request and grants nothing. The E2E therefore runs the real built SDK in a real forked extension process against a stub host that speaks the extension side of the wire, which is what the CLI itself sees. It proves the requested names reach the wire, that an approved grant lands in the extension's process.env, and that a denied request grants nothing. A second case drives the real CLI and proves that asking for variables does not break the join today. That case can assert the grant once the @github/copilot dependency carries the host half.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

- Fix the factory join-path assertion broken by the new argument
- Pass extension join options only when an extension asks for variables

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

@MRayermannMSFT
MRayermannMSFT marked this pull request as ready for review August 18, 2026 01:03
@MRayermannMSFT
MRayermannMSFT requested a review from a team as a code owner August 18, 2026 01:03
Copilot AI balanced review requested due to automatic review settings August 18, 2026 01:03

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

Adds Node.js extension support for requesting sensitive environment variables during session joins.

Changes:

  • Adds the env join option and resume wire fields.
  • Applies granted values to process.env.
  • Adds unit, E2E, documentation, and changelog coverage.
Show a summary per file
File Description
CHANGELOG.md Announces the extension environment-access feature.
nodejs/docs/extensions.md Documents requesting sensitive variables.
nodejs/src/client.ts Sends requests and applies grants.
nodejs/src/extension.ts Exposes and forwards the env option.
nodejs/src/types.ts Defines internal extension join options.
nodejs/test/client.test.ts Tests resume payloads and grants.
nodejs/test/extension.test.ts Tests joinSession() forwarding.
nodejs/test/factory.test.ts Updates the extension resume expectation.
nodejs/test/e2e/extension_env_access.e2e.test.ts Adds stub-host and real-CLI coverage.
nodejs/test/e2e/fixtures/env-access-extension.mjs Provides the E2E extension fixture.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 10/10 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread nodejs/src/extension.ts Outdated
Comment thread nodejs/src/client.ts
MRayermannMSFT and others added 2 commits August 17, 2026 18:18
- Apply only approved names from a grant
- Match the docs heading style in the extensions guide

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR adds the env option to joinSession() in nodejs/src/extension.ts, allowing extensions to request sensitive environment variables (e.g. GITHUB_TOKEN) from the Copilot CLI.

Finding: No cross-SDK consistency issues.

The extension entry-point (joinSession() / @github/copilot-sdk/extension) is a Node.js-only concept — extensions today are exclusively Node.js processes forked by the CLI. No other SDK (Python, Go, .NET, Java, Rust) exposes a joinSession() or equivalent extension-mode API, so there is no parallel surface to keep in sync.

The underlying requestedEnvironmentVariables wire field is part of the shared session.resume payload. Should any other SDK eventually gain an extension mode, it would need to add the equivalent env / requested_environment_variables option at that time. That is a future concern, not a gap introduced by this PR.

All changes are correctly scoped to nodejs/.

Generated by SDK Consistency Review Agent for #2348 · sonnet46 38 AIC · ⌖ 5.44 AIC · ⊞ 6.6K ·

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.

2 participants