feat: add interactive permission prompt UI to Inspector

Add permission request handling to the Inspector UI so users can
Allow, Always Allow, or Reject tool calls that require permissions
instead of having them auto-cancelled. Wires up SDK
onPermissionRequest/respondPermission through App → ChatPanel →
ChatMessages with proper toolCallId-to-pendingId mapping.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Nathan Flurry 2026-03-10 16:47:52 -07:00
parent 1720b6d0ba
commit e8ffd78ac0
27 changed files with 812 additions and 563 deletions

View file

@ -96,14 +96,6 @@ const session = await sdk.createSession({
});
```
```ts
// Claude permission modes are exposed as a first-class helper.
const claude = await sdk.createSession({
agent: "claude",
permissionMode: "default",
});
```
```ts
// After creation
await session.setModel("gpt-5.2-codex");
@ -111,10 +103,6 @@ await session.setMode("full-access");
await session.setThoughtLevel("medium");
```
```ts
await claude.setPermissionMode("acceptEdits");
```
Query available modes:
```ts
@ -139,26 +127,41 @@ await session.setConfigOption("some-agent-option", "value");
## Handle permission requests
For agents that use ACP `session/request_permission` (for example Claude in `default` mode), register a permission listener and reply with `once`, `always`, or `reject`:
For agents that request tool-use permissions, register a permission listener and reply with `once`, `always`, or `reject`:
```ts
const claude = await sdk.createSession({
const session = await sdk.createSession({
agent: "claude",
permissionMode: "default",
mode: "default",
});
claude.onPermissionRequest((request) => {
session.onPermissionRequest((request) => {
console.log(request.toolCall.title, request.availableReplies);
void claude.replyPermission(request.id, "once");
void session.respondPermission(request.id, "once");
});
await claude.prompt([
await session.prompt([
{ type: "text", text: "Create ./permission-example.txt with the text hello." },
]);
```
### Auto-approving permissions
To auto-approve all permission requests, respond with `"once"` or `"always"` in your listener:
```ts
session.onPermissionRequest((request) => {
void session.respondPermission(request.id, "always");
});
```
See `examples/permissions/src/index.ts` for a complete permissions example that works with Claude and Codex.
<Info>
Some agents like Claude allow configuring permission behavior through modes (e.g. `bypassPermissions`, `acceptEdits`). We recommend leaving the mode as `default` and handling permission decisions explicitly in `onPermissionRequest` instead.
</Info>
## Destroy a session
```ts