Skip to content

[Node] Add Commands and UI Elicitation Support to SDK#906

Merged
MRayermannMSFT merged 3 commits intomainfrom
mrayermannmsft/uiandcommands-sdk
Mar 23, 2026
Merged

[Node] Add Commands and UI Elicitation Support to SDK#906
MRayermannMSFT merged 3 commits intomainfrom
mrayermannmsft/uiandcommands-sdk

Conversation

@MRayermannMSFT
Copy link
Copy Markdown
Contributor

What

Adds commands and UI elicitation support to the Node.js SDK, enabling SDK clients to register slash commands that CLI users can invoke and to request interactive form dialogs via the CLI's elicitation component. The public API includes commands in session config for registering command handlers with automatic event routing, a session.ui object with convenience methods (confirm, select, input, and generic elicitation), and a session.capabilities getter for runtime feature detection. Includes unit tests for all new code paths, E2E tests for both features, and updated README documentation.ah

Why

The CLI recently shipped support for SDK-registered commands and UI elicitation dialogs, but the Node.js SDK had no way to use these features. Without this change, SDK consumers building extensions or agents that participate in interactive CLI sessions cannot register slash commands or prompt users with structured input dialogs — limiting the SDK to headless-only workflows.

@MRayermannMSFT MRayermannMSFT requested a review from a team as a code owner March 23, 2026 17:22
Copilot AI review requested due to automatic review settings March 23, 2026 17:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds command registration/event routing and UI elicitation (interactive dialogs) support to the Node.js SDK, enabling CLI TUI integrations via new session config and session.ui APIs.

Changes:

  • Introduces SessionConfig.commands with automatic routing for command.execute events and RPC responses.
  • Adds capability detection via session.capabilities plus session.ui convenience methods (elicitation, confirm, select, input) gated by capabilities.ui?.elicitation.
  • Updates Node + harness dependencies and adds unit/E2E tests + README docs for the new features.

Reviewed changes

Copilot reviewed 10 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/harness/package.json Bumps Copilot CLI dependency used by the E2E harness.
test/harness/package-lock.json Lockfile update for harness dependency bump.
nodejs/test/e2e/ui_elicitation.test.ts Adds E2E coverage for headless-mode behavior of session.ui.
nodejs/test/e2e/commands.test.ts Adds E2E coverage for multi-client command registration broadcast behavior.
nodejs/test/client.test.ts Adds unit tests for commands forwarding/routing and UI capabilities gating.
nodejs/src/types.ts Adds public types for commands, capabilities, and elicitation schemas/results; adds commands to session config types.
nodejs/src/session.ts Implements command handler routing + UI elicitation APIs with capability checks.
nodejs/src/index.ts Re-exports new public types.
nodejs/src/client.ts Forwards commands in create/resume RPC payloads; plumbs capabilities from responses into sessions.
nodejs/package.json Bumps Copilot CLI dependency required for new RPC/event support.
nodejs/package-lock.json Lockfile update for Node package dependency bump.
nodejs/README.md Documents new capabilities, commands, and UI elicitation APIs/events.
Files not reviewed (2)
  • nodejs/package-lock.json: Language not supported
  • test/harness/package-lock.json: Language not supported

@github-actions
Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review

This PR adds Commands and UI Elicitation support to the Node.js SDK. After reviewing all four SDK implementations, I've identified a feature parity gap that should be addressed.

✅ What's Consistent

All four SDKs have the low-level generated RPC methods:

  • session.ui.elicitation() (Python, Go, .NET) / SessionRpc.ui.elicitation() (Node)
  • session.commands.handlePendingCommand() in all SDKs
  • Event types like elicitation.requested, elicitation.completed, command.execute

⚠️ Feature Parity Gap

The Node.js SDK now provides high-level convenience APIs that are missing in Python, Go, and .NET:

1. Commands Registration API

Node.js (this PR):

const session = await client.createSession({
    commands: [{
        name: "deploy",
        description: "Deploy the app",
        handler: async ({ commandName, args }) => { /* ... */ }
    }]
});

Missing in: Python, Go, .NET

  • ❌ No commands field in SessionConfig/SessionOptions/CreateSessionRequest
  • ❌ No automatic event routing for command.execute events
  • ❌ Users must manually handle command.execute events and call RPC methods

2. UI Convenience Methods

Node.js (this PR):

if (session.capabilities.ui?.elicitation) {
    const ok = await session.ui.confirm("Deploy?");
    const env = await session.ui.select("Pick env", ["prod", "staging"]);
    const name = await session.ui.input("Name:", { minLength: 1 });
}

Missing in: Python, Go, .NET

  • ❌ No session.ui property with confirm(), select(), input() helpers
  • ❌ No session.capabilities property for feature detection
  • ❌ Users must manually construct elicitation schemas and call low-level RPC

📋 Recommendation

To maintain feature parity across SDKs, consider:

  1. Short-term: Document in this PR that Commands and UI Elicitation convenience APIs are Node.js-only (temporarily)
  2. Follow-up PRs: Add equivalent APIs to Python, Go, and .NET:
    • Python: session.capabilities, session.ui.confirm(), session_config.commands
    • Go: session.Capabilities, session.UI.Confirm(), SessionOptions.Commands
    • .NET: session.Capabilities, session.UI.Confirm(), CreateSessionRequest.Commands

📚 Implementation Guidance

For reference, the Node.js implementation in this PR shows the pattern:

  • Capabilities: Stored during create/resume from RPC response (see client.ts lines with setCapabilities)
  • Commands: Registered via session.commands.register() RPC, with automatic event routing
  • UI helpers: Thin wrappers around session.ui.elicitation() that construct JSON schemas

This approach should translate well to other languages following their naming conventions.


Verdict: This PR is well-implemented for Node.js, but creates a temporary feature gap. The underlying CLI support is language-agnostic, so other SDKs can adopt these patterns in follow-up work.

Generated by SDK Consistency Review Agent for issue #906 ·

@github-actions
Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review

This PR adds Commands and UI Elicitation support to the Node.js SDK. I've reviewed the other SDK implementations (Python, Go, .NET) to assess consistency.

⚠️ Consistency Concerns

1. Commands Registration API - Major Inconsistency

Status: This PR creates a significant API gap across SDKs.

  • Node.js (this PR): Full command registration via SessionConfig.commands: CommandDefinition[] with automatic event routing
  • Python: Only has low-level session.rpc.commands.handle_pending_command() - no command registration API
  • Go: Only has session.RPC.Commands.HandlePendingCommand() - no command registration API
  • .NET: Only has session.Rpc.Commands.HandlePendingCommandAsync() - no command registration API

Impact: SDK consumers using Python/Go/.NET cannot register custom slash commands, while Node.js users can. This is a significant feature parity gap that limits the usefulness of the CLI's command system for multi-language teams.

Recommendation: Consider adding equivalent command registration APIs to Python, Go, and .NET SDKs to maintain feature parity. The pattern should be similar:

  • Python: commands parameter in create_session() accepting List[CommandDefinition]
  • Go: Commands []CommandDefinition field in SessionConfig
  • .NET: Commands property in SessionOptions

2. UI Elicitation - Minor Inconsistency

Status: All SDKs support UI elicitation, but with different ergonomics.

  • Node.js (this PR): session.ui.elicitation() + convenience methods (confirm, select, input)
  • Python: _register_user_input_handler() with ask_user tool invocation pattern
  • Go: session.RPC.Ui.Elicitation()
  • .NET: session.Rpc.Ui.ElicitationAsync()

Impact: Minor. All SDKs can perform UI elicitation, though Node.js now has nicer convenience wrappers. The generic elicitation() method handles all cases in other SDKs.

Recommendation: Optional - consider adding Confirm(), Select(), and Input() convenience methods to Go/.NET for API consistency (Python's pattern is different due to the ask_user tool architecture).


3. Capabilities API - New Feature

Status: Node.js adds session.capabilities for runtime feature detection.

  • Node.js (this PR): session.capabilities: SessionCapabilities
  • Python/Go/.NET: No capabilities getter

Impact: Medium. Without capabilities checking, SDK consumers in other languages cannot determine at runtime what features the CLI host supports (e.g., whether UI elicitation is available).

Recommendation: Add session.capabilities or equivalent to Python, Go, and .NET SDKs for runtime feature detection.


✅ What's Good

  • The Node.js implementation is well-designed and follows existing SDK patterns
  • Documentation is thorough
  • E2E tests cover both features

📋 Suggested Follow-up

To maintain feature parity, I recommend creating issues to track:

  1. [High Priority] Add command registration APIs to Python, Go, and .NET SDKs
  2. [Medium Priority] Add capabilities getter to Python, Go, and .NET SDKs
  3. [Low Priority] Consider UI convenience methods for Go/.NET (confirm/select/input)

This is excellent work on the Node.js SDK! The inconsistencies noted above are not blockers for this PR, but should be addressed in follow-up work to ensure all SDK users have access to the same capabilities.

Generated by SDK Consistency Review Agent for issue #906 ·

Copy link
Copy Markdown
Contributor

@SteveSandersonMS SteveSandersonMS left a comment

Choose a reason for hiding this comment

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

Nice, thanks!

@MRayermannMSFT MRayermannMSFT added this pull request to the merge queue Mar 23, 2026
Merged via the queue into main with commit 4088739 Mar 23, 2026
35 checks passed
@MRayermannMSFT MRayermannMSFT deleted the mrayermannmsft/uiandcommands-sdk branch March 23, 2026 18:12
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