mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-29 04:00:36 +00:00
feat test tool permissions
This commit is contained in:
parent
eeb4d85785
commit
db0e373ad7
74 changed files with 4065 additions and 938 deletions
|
|
@ -389,6 +389,20 @@ export interface ConfigParameters {
|
|||
modelProvidersConfig?: ModelProvidersConfig;
|
||||
/** Warnings generated during configuration resolution */
|
||||
warnings?: string[];
|
||||
/**
|
||||
* Callback for persisting a permission rule to settings.
|
||||
* Injected by the CLI layer; core uses this to write allow/ask/deny rules
|
||||
* to project or user settings when the user clicks "Always Allow".
|
||||
*
|
||||
* @param scope - 'project' for workspace settings, 'user' for user settings.
|
||||
* @param ruleType - 'allow' | 'ask' | 'deny'.
|
||||
* @param rule - The raw rule string, e.g. "Bash(git *)" or "Edit".
|
||||
*/
|
||||
onPersistPermissionRule?: (
|
||||
scope: 'project' | 'user',
|
||||
ruleType: 'allow' | 'ask' | 'deny',
|
||||
rule: string,
|
||||
) => Promise<void>;
|
||||
}
|
||||
|
||||
function normalizeConfigOutputFormat(
|
||||
|
|
@ -524,6 +538,11 @@ export class Config {
|
|||
private readonly skipLoopDetection: boolean;
|
||||
private readonly skipStartupContext: boolean;
|
||||
private readonly warnings: string[];
|
||||
private readonly onPersistPermissionRuleCallback?: (
|
||||
scope: 'project' | 'user',
|
||||
ruleType: 'allow' | 'ask' | 'deny',
|
||||
rule: string,
|
||||
) => Promise<void>;
|
||||
private initialized: boolean = false;
|
||||
readonly storage: Storage;
|
||||
private readonly fileExclusions: FileExclusions;
|
||||
|
|
@ -629,6 +648,7 @@ export class Config {
|
|||
this.skipLoopDetection = params.skipLoopDetection ?? false;
|
||||
this.skipStartupContext = params.skipStartupContext ?? false;
|
||||
this.warnings = params.warnings ?? [];
|
||||
this.onPersistPermissionRuleCallback = params.onPersistPermissionRule;
|
||||
|
||||
// Web search
|
||||
this.webSearch = params.webSearch;
|
||||
|
|
@ -1722,6 +1742,20 @@ export class Config {
|
|||
return this.permissionManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the callback for persisting permission rules to settings files.
|
||||
* Returns undefined if no callback was provided (e.g. SDK mode).
|
||||
*/
|
||||
getOnPersistPermissionRule():
|
||||
| ((
|
||||
scope: 'project' | 'user',
|
||||
ruleType: 'allow' | 'ask' | 'deny',
|
||||
rule: string,
|
||||
) => Promise<void>)
|
||||
| undefined {
|
||||
return this.onPersistPermissionRuleCallback;
|
||||
}
|
||||
|
||||
async createToolRegistry(
|
||||
sendSdkMcpMessage?: SendSdkMcpMessage,
|
||||
): Promise<ToolRegistry> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue