mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
feat: add allowedTools for SDK use and re-organize test setup
This commit is contained in:
@@ -296,32 +296,17 @@ export class Query implements AsyncIterable<SDKMessage> {
|
||||
timeoutPromise,
|
||||
]);
|
||||
|
||||
// Handle boolean return (backward compatibility)
|
||||
if (typeof result === 'boolean') {
|
||||
return result
|
||||
? { behavior: 'allow', updatedInput: toolInput }
|
||||
: { behavior: 'deny', message: 'Denied' };
|
||||
}
|
||||
|
||||
// Handle PermissionResult format
|
||||
const permissionResult = result as {
|
||||
behavior: 'allow' | 'deny';
|
||||
updatedInput?: Record<string, unknown>;
|
||||
message?: string;
|
||||
interrupt?: boolean;
|
||||
};
|
||||
|
||||
if (permissionResult.behavior === 'allow') {
|
||||
if (result.behavior === 'allow') {
|
||||
return {
|
||||
behavior: 'allow',
|
||||
updatedInput: permissionResult.updatedInput ?? toolInput,
|
||||
updatedInput: result.updatedInput ?? toolInput,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
behavior: 'deny',
|
||||
message: permissionResult.message ?? 'Denied',
|
||||
...(permissionResult.interrupt !== undefined
|
||||
? { interrupt: permissionResult.interrupt }
|
||||
message: result.message ?? 'Denied',
|
||||
...(result.interrupt !== undefined
|
||||
? { interrupt: result.interrupt }
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ export function query({
|
||||
maxSessionTurns: options.maxSessionTurns,
|
||||
coreTools: options.coreTools,
|
||||
excludeTools: options.excludeTools,
|
||||
allowedTools: options.allowedTools,
|
||||
authType: options.authType,
|
||||
includePartialMessages: options.includePartialMessages,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user