mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
fix: use --add-dir flag for granting Claude read access to uploads
This commit is contained in:
@@ -7,6 +7,7 @@ import { appendMcpConfigArg } from "./utils/mcpConfig";
|
||||
import { systemPrompt } from "./utils/systemPrompt";
|
||||
import { withBunRuntimeEnv } from "@/utils/bunRuntime";
|
||||
import { spawnWithAbort } from "@/utils/spawnWithAbort";
|
||||
import { getHapiBlobsDir } from "@/constants/uploadPaths";
|
||||
|
||||
export async function claudeLocal(opts: {
|
||||
abort: AbortSignal,
|
||||
@@ -68,6 +69,10 @@ export async function claudeLocal(opts: {
|
||||
args.push('--settings', opts.hookSettingsPath);
|
||||
logger.debug(`[ClaudeLocal] Using hook settings: ${opts.hookSettingsPath}`);
|
||||
|
||||
// Add blobs directory for file upload access
|
||||
args.push('--add-dir', getHapiBlobsDir());
|
||||
logger.debug(`[ClaudeLocal] Adding blobs directory: ${getHapiBlobsDir()}`);
|
||||
|
||||
// Prepare environment variables
|
||||
// Note: Local mode uses global Claude installation
|
||||
const env = {
|
||||
|
||||
@@ -9,6 +9,7 @@ import { getProjectPath } from "./utils/path";
|
||||
import { awaitFileExist } from "@/modules/watcher/awaitFileExist";
|
||||
import { systemPrompt } from "./utils/systemPrompt";
|
||||
import { PermissionResult } from "./sdk/types";
|
||||
import { getHapiBlobsDir } from "@/constants/uploadPaths";
|
||||
|
||||
export async function claudeRemote(opts: {
|
||||
|
||||
@@ -123,6 +124,7 @@ export async function claudeRemote(opts: {
|
||||
abort: opts.signal,
|
||||
pathToClaudeCodeExecutable: 'claude',
|
||||
settingsPath: opts.hookSettingsPath,
|
||||
additionalDirectories: [getHapiBlobsDir()],
|
||||
}
|
||||
|
||||
// Track thinking state
|
||||
|
||||
@@ -260,6 +260,7 @@ export function query(config: {
|
||||
const {
|
||||
prompt,
|
||||
options: {
|
||||
additionalDirectories = [],
|
||||
allowedTools = [],
|
||||
appendSystemPrompt,
|
||||
customSystemPrompt,
|
||||
@@ -303,6 +304,7 @@ export function query(config: {
|
||||
if (settingsPath) args.push('--settings', settingsPath)
|
||||
if (allowedTools.length > 0) args.push('--allowedTools', allowedTools.join(','))
|
||||
if (disallowedTools.length > 0) args.push('--disallowedTools', disallowedTools.join(','))
|
||||
if (additionalDirectories.length > 0) args.push('--add-dir', ...additionalDirectories)
|
||||
if (strictMcpConfig) args.push('--strict-mcp-config')
|
||||
if (permissionMode) args.push('--permission-mode', permissionMode)
|
||||
|
||||
|
||||
@@ -157,6 +157,7 @@ export interface CanCallToolCallback {
|
||||
*/
|
||||
export interface QueryOptions {
|
||||
abort?: AbortSignal
|
||||
additionalDirectories?: string[]
|
||||
allowedTools?: string[]
|
||||
appendSystemPrompt?: string
|
||||
customSystemPrompt?: string
|
||||
|
||||
Reference in New Issue
Block a user