41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
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(),
|
|
}),
|
|
)
|