Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

Commit 0f0d798

Browse files
sugyanclaude
andauthored
feat: add backend permission mode support (#227)
- Add permissionMode parameter to executeClaudeCommand function - Pass permissionMode to Claude Code SDK query options - Update handleChatRequest to accept permissionMode from ChatRequest - Import PermissionMode type from Claude Code SDK for type safety - Maintains backward compatibility for requests without permissionMode Closes #133 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 49da10d commit 0f0d798

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

backend/handlers/chat.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { Context } from "hono";
2-
import { AbortError, query } from "@anthropic-ai/claude-code";
2+
import {
3+
AbortError,
4+
query,
5+
type PermissionMode,
6+
} from "@anthropic-ai/claude-code";
37
import type { ChatRequest, StreamResponse } from "../../shared/types.ts";
48
import { logger } from "../utils/logger.ts";
59

@@ -12,6 +16,7 @@ import { logger } from "../utils/logger.ts";
1216
* @param sessionId - Optional session ID for conversation continuity
1317
* @param allowedTools - Optional array of allowed tool names
1418
* @param workingDirectory - Optional working directory for Claude execution
19+
* @param permissionMode - Optional permission mode for Claude execution
1520
* @returns AsyncGenerator yielding StreamResponse objects
1621
*/
1722
async function* executeClaudeCommand(
@@ -22,6 +27,7 @@ async function* executeClaudeCommand(
2227
sessionId?: string,
2328
allowedTools?: string[],
2429
workingDirectory?: string,
30+
permissionMode?: PermissionMode,
2531
): AsyncGenerator<StreamResponse> {
2632
let abortController: AbortController;
2733

@@ -47,6 +53,7 @@ async function* executeClaudeCommand(
4753
...(sessionId ? { resume: sessionId } : {}),
4854
...(allowedTools ? { allowedTools } : {}),
4955
...(workingDirectory ? { cwd: workingDirectory } : {}),
56+
...(permissionMode ? { permissionMode } : {}),
5057
},
5158
})) {
5259
// Debug logging of raw SDK messages
@@ -110,6 +117,7 @@ export async function handleChatRequest(
110117
chatRequest.sessionId,
111118
chatRequest.allowedTools,
112119
chatRequest.workingDirectory,
120+
chatRequest.permissionMode,
113121
)) {
114122
const data = JSON.stringify(chunk) + "\n";
115123
controller.enqueue(new TextEncoder().encode(data));

0 commit comments

Comments
 (0)