π File detail
utils/permissions/PermissionRule.ts
π§© .tsπ 41 linesπΎ 1,176 bytesπ text
β Back to All Filesπ― Use case
This file lives under βutils/β, which covers cross-cutting helpers (shell, tempfiles, settings, messages, process input, β¦). On the API surface it exposes permissionBehaviorSchema and permissionRuleValueSchema β mainly functions, hooks, or classes. Dependencies touch schema validation. It composes internal code from types and lazySchema (relative imports).
Generated from folder role, exports, dependency roots, and inline comments β not hand-reviewed for every path.
π§ Inline summary
import z from 'zod/v4' // Types extracted to src/types/permissions.ts to break import cycles import type { PermissionBehavior, PermissionRule,
π€ Exports (heuristic)
permissionBehaviorSchemapermissionRuleValueSchema
π External import roots
Package roots from from "β¦" (relative paths omitted).
zod
π₯οΈ Source preview
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(),
}),
)