anthropics / anthropics/claude-agent-sdk-typescript

Expose Remote Control to SDK hosts

Open
#460 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Shell
Stars
1.8k
Forks
226
PR merge metrics
No merged PRs in 30d

Description

Update after reading the Remote Control docs more carefully. This is narrower than what I first wrote, and it is a documentation and typing request rather than a "please build it" one.

Two things the docs already settle:

- auto-connect is scoped to interactive sessions. "Remote Control only activates when you explicitly run `claude remote-control`, `claude --remote-control`, or `/remote-control`, unless auto-connect is turned on", and auto-connect covers "every interactive session". So `remoteControlAtStartup` was never going to cover an SDK-hosted session, which explains what I saw. That part is working as documented.
- SDK hosts are nonetheless a recognised case. From the same page: "when you turned Remote Control off from the CLI's status panel, the VS Code extension, or a host built on the Agent SDK". So a host built on this SDK toggling Remote Control is an expected scenario.

What is missing is the API to do it. `enableRemoteControl` appears zero times in the TypeScript reference, yet it exists and works. It is a method on the object `query()` returns, in the same class as `setModel`, `setPermissionMode`, `interrupt`, `updateSettings` and `supportedCommands`, all of which are declared on the public `Query` type. `Reconstructed signature:`

```
enableRemoteControl(
enabled: boolean,
name?: string,
opts?: { reattachSessionId?, keepSessionOnExit?, workSecret?, refreshWorkSecret? }
): Promise<{ session_url, connect_url, environment_id, bridge_epoch, bridge_session_id }>
```

Called from a bare SDK session, no CLI involved:

```js
const session = query({ prompt: input(), options: { pathToClaudeCodeExecutable: CLAUDE, cwd } })
const res = await session.enableRemoteControl(true, 'DEMO-IPHONE')
// { session_url: "https://claude.ai/code/session_...", bridge_session_id: "cse_..." }
```

The session appeared in the Claude iOS app immediately, listed as connected and labelled "remote control". I sent a prompt from the phone, it ran on the desktop, and the reply came back. The remote turn arrived through the same async iterator the host already consumes for local messages, so a host needs no separate plumbing to receive it. The reply generated before I enabled Remote Control was also present in the phone transcript, so the bridge backfills rather than only streaming what follows.

The ask:

- declare `enableRemoteControl` on the `Query` type, with its option bag
- document what a host is expected to render around it: the pairing step, `session_url`, and the connection state
- if the intent is that SDK hosts use it, the docs page could say so where it already names them

For context, this is the same shape as several open issues about CLI capabilities being unreachable from SDK sessions: #456, #415, #216, and #3 on session management not being clearly exposed.

Tested with `@anthropic-ai/claude-agent-sdk` 0.3.267 and runtime 2.1.267, Linux x64, claude.ai Max subscription.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.