PermissionRule.ts
utils/permissions/PermissionRule.ts
41
Lines
1176
Bytes
2
Exports
3
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with shell-safety, permissions. It contains 41 lines, 3 detected imports, and 2 detected exports.
Important relationships
- utils/permissions/PermissionMode.ts
- utils/permissions/PermissionPromptToolResultSchema.ts
- utils/permissions/PermissionResult.ts
- utils/permissions/PermissionUpdate.ts
- utils/permissions/PermissionUpdateSchema.ts
- utils/permissions/autoModeState.ts
- utils/permissions/bashClassifier.ts
- utils/permissions/bypassPermissionsKillswitch.ts
Detected exports
permissionBehaviorSchemapermissionRuleValueSchema
Keywords
rulelazyschematooltypespermissionrulevaluemeanspermissionspermissionbehaviorpermissionrulepermissionrulesource
Detected imports
zod/v4../../types/permissions.js../lazySchema.js
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
import z from 'zod/v4'
// Types extracted to src/types/permissions.ts to break import cycles
import type {
PermissionBehavior,
PermissionRule,
PermissionRuleSource,
PermissionRuleValue,
} from '../../types/permissions.js'
import { lazySchema } from '../lazySchema.js'
// Re-export for backwards compatibility
export type {
PermissionBehavior,
PermissionRule,
PermissionRuleSource,
PermissionRuleValue,
}
/**
* ToolPermissionBehavior is the behavior associated with a permission rule.
* 'allow' means the rule allows the tool to run.
* 'deny' means the rule denies the tool from running.
* 'ask' means the rule forces a prompt to be shown to the user.
*/
export const permissionBehaviorSchema = lazySchema(() =>
z.enum(['allow', 'deny', 'ask']),
)
/**
* PermissionRuleValue is the content of a permission rule.
* @param toolName - The name of the tool this rule applies to
* @param ruleContent - The optional content of the rule.
* Each tool may implement custom handling in `checkPermissions()`
*/
export const permissionRuleValueSchema = lazySchema(() =>
z.object({
toolName: z.string(),
ruleContent: z.string().optional(),
}),
)