mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 22:05:50 +00:00
feat: 问就是封包
This commit is contained in:
@@ -1325,14 +1325,15 @@ export function checkWritePermissionForTool<Input extends AnyObject>(
|
||||
},
|
||||
]
|
||||
: generateSuggestions(path, 'write', toolPermissionContext, pathsToCheck)
|
||||
const failedCheck = safetyCheck as { safe: false; message: string; classifierApprovable: boolean }
|
||||
return {
|
||||
behavior: 'ask',
|
||||
message: safetyCheck.message,
|
||||
message: failedCheck.message,
|
||||
suggestions: safetySuggestions,
|
||||
decisionReason: {
|
||||
type: 'safetyCheck',
|
||||
reason: safetyCheck.message,
|
||||
classifierApprovable: safetyCheck.classifierApprovable,
|
||||
reason: failedCheck.message,
|
||||
classifierApprovable: failedCheck.classifierApprovable,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,8 +112,8 @@ export function isPathInSandboxWriteAllowlist(resolvedPath: string): boolean {
|
||||
// their resolution to avoid N × config.length redundant syscalls per
|
||||
// command with N write targets (matching getResolvedWorkingDirPaths).
|
||||
const pathsToCheck = getPathsForPermissionCheck(resolvedPath)
|
||||
const resolvedAllow = allowOnly.flatMap(getResolvedSandboxConfigPath)
|
||||
const resolvedDeny = denyWithinAllow.flatMap(getResolvedSandboxConfigPath)
|
||||
const resolvedAllow = allowOnly.flatMap(getResolvedSandboxConfigPath) as string[]
|
||||
const resolvedDeny = denyWithinAllow.flatMap(getResolvedSandboxConfigPath) as string[]
|
||||
return pathsToCheck.every(p => {
|
||||
for (const denyPath of resolvedDeny) {
|
||||
if (pathInWorkingPath(p, denyPath)) return false
|
||||
@@ -184,12 +184,13 @@ export function isPathAllowed(
|
||||
precomputedPathsToCheck,
|
||||
)
|
||||
if (!safetyCheck.safe) {
|
||||
const failedCheck = safetyCheck as { safe: false; message: string; classifierApprovable: boolean }
|
||||
return {
|
||||
allowed: false,
|
||||
decisionReason: {
|
||||
type: 'safetyCheck',
|
||||
reason: safetyCheck.message,
|
||||
classifierApprovable: safetyCheck.classifierApprovable,
|
||||
reason: failedCheck.message,
|
||||
classifierApprovable: failedCheck.classifierApprovable,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ async function runPermissionRequestHooksForHeadlessAgent(
|
||||
input,
|
||||
context,
|
||||
permissionMode,
|
||||
suggestions,
|
||||
suggestions as any,
|
||||
context.abortController.signal,
|
||||
)) {
|
||||
if (!hookResult.permissionRequestResult) {
|
||||
@@ -423,12 +423,12 @@ async function runPermissionRequestHooksForHeadlessAgent(
|
||||
const finalInput = decision.updatedInput ?? input
|
||||
// Persist permission updates if provided
|
||||
if (decision.updatedPermissions?.length) {
|
||||
persistPermissionUpdates(decision.updatedPermissions)
|
||||
persistPermissionUpdates(decision.updatedPermissions as any)
|
||||
context.setAppState(prev => ({
|
||||
...prev,
|
||||
toolPermissionContext: applyPermissionUpdates(
|
||||
prev.toolPermissionContext,
|
||||
decision.updatedPermissions!,
|
||||
decision.updatedPermissions as any,
|
||||
),
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user