forked from ultraworkers/claw-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPermissionRule.ts
More file actions
40 lines (37 loc) · 1.15 KB
/
Copy pathPermissionRule.ts
File metadata and controls
40 lines (37 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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(),
}),
)