Skip to content

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

Merged
MRayermannMSFT merged 5 commits into
mainfrom
mrayermannmsft-extension-env-sdk-half
Aug 18, 2026
Merged

[Node] Let Extensions Request Sensitive Environment Variables#2348
MRayermannMSFT merged 5 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

This comment has been minimized.

@MackinnonBuck MackinnonBuck left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great! Just some small thoughts that came to mind I was reviewing this. Nothing blocking, feel free to address these however you feel is appropriate!

Comment thread nodejs/src/client.ts
Comment thread nodejs/docs/extensions.md Outdated
`env` means a map of values to supply to a process everywhere else in
this SDK, so a list of names the extension asks for needs its own name.
The new name also matches the wire field exactly.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@MRayermannMSFT
MRayermannMSFT force-pushed the mrayermannmsft-extension-env-sdk-half branch from 93f5611 to 823aad4 Compare August 18, 2026 18:15
@github-actions

Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR adds requestedEnvironmentVariables support to the Node.js joinSession() / resumeSessionForExtension() API.

Scope is appropriate: Extensions run as Node.js subprocesses, and the extension entry-point API (joinSession, resumeSessionForExtension) exists only in the Node.js SDK. No other SDK (Python, Go, .NET, Java, Rust) has an equivalent extension join mechanism, so there are no peer implementations to bring into alignment.

Wire-level consistency: The new requestedEnvironmentVariables field is sent on the session.resume JSON-RPC payload. If another SDK ever gains an extension-join path, it would need the same field — but that's a forward concern, not a gap today.

No cross-SDK consistency issues found.

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

@MRayermannMSFT
MRayermannMSFT added this pull request to the merge queue Aug 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 18, 2026
@MRayermannMSFT
MRayermannMSFT added this pull request to the merge queue Aug 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 18, 2026
@MRayermannMSFT
MRayermannMSFT added this pull request to the merge queue Aug 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 18, 2026
@MRayermannMSFT
MRayermannMSFT added this pull request to the merge queue Aug 18, 2026
Merged via the queue into main with commit 525866c Aug 18, 2026
39 checks passed
@MRayermannMSFT
MRayermannMSFT deleted the mrayermannmsft-extension-env-sdk-half branch August 18, 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