[Node] Let Extensions Request Sensitive Environment Variables - #2348
[Node] Let Extensions Request Sensitive Environment Variables#2348MRayermannMSFT wants to merge 4 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
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>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Adds Node.js extension support for requesting sensitive environment variables during session joins.
Changes:
- Adds the
envjoin 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
- 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>
Cross-SDK Consistency Review ✅This PR adds the Finding: No cross-SDK consistency issues. The extension entry-point ( The underlying All changes are correctly scoped to
|
What
joinSession()accepts a newenvoption that names the sensitive environment variables an extension needs. The SDK sends those names to the CLI on thesession.resumepayload asrequestedEnvironmentVariables. 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'sprocess.envbeforejoinSession()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.resumepayload from an explicit field list, so anenvoption 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/copilotdependency carries the host half.