( settings: SettingsJson, )
| 643 | * @returns Sorted array of key paths |
| 644 | */ |
| 645 | export function getManagedSettingsKeysForLogging( |
| 646 | settings: SettingsJson, |
| 647 | ): string[] { |
| 648 | // Use .strip() to get only valid schema keys |
| 649 | const validSettings = SettingsSchema().strip().parse(settings) as Record< |
| 650 | string, |
| 651 | unknown |
| 652 | > |
| 653 | const keysToExpand = ['permissions', 'sandbox', 'hooks'] |
| 654 | const allKeys: string[] = [] |
| 655 | |
| 656 | // Define valid nested keys for each nested setting we expand |
| 657 | const validNestedKeys: Record<string, Set<string>> = { |
| 658 | permissions: new Set([ |
| 659 | 'allow', |
| 660 | 'deny', |
| 661 | 'ask', |
| 662 | 'defaultMode', |
| 663 | 'disableBypassPermissionsMode', |
| 664 | ...(feature('TRANSCRIPT_CLASSIFIER') ? ['disableAutoMode'] : []), |
| 665 | 'additionalDirectories', |
| 666 | ]), |
| 667 | sandbox: new Set([ |
| 668 | 'enabled', |
| 669 | 'failIfUnavailable', |
| 670 | 'allowUnsandboxedCommands', |
| 671 | 'network', |
| 672 | 'filesystem', |
| 673 | 'ignoreViolations', |
| 674 | 'excludedCommands', |
| 675 | 'autoAllowBashIfSandboxed', |
| 676 | 'enableWeakerNestedSandbox', |
| 677 | 'enableWeakerNetworkIsolation', |
| 678 | 'ripgrep', |
| 679 | ]), |
| 680 | // For hooks, we use z.record with enum keys, so we validate separately |
| 681 | hooks: new Set([ |
| 682 | 'PreToolUse', |
| 683 | 'PostToolUse', |
| 684 | 'Notification', |
| 685 | 'UserPromptSubmit', |
| 686 | 'SessionStart', |
| 687 | 'SessionEnd', |
| 688 | 'Stop', |
| 689 | 'SubagentStop', |
| 690 | 'PreCompact', |
| 691 | 'PostCompact', |
| 692 | 'TeammateIdle', |
| 693 | 'TaskCreated', |
| 694 | 'TaskCompleted', |
| 695 | ]), |
| 696 | } |
| 697 | |
| 698 | for (const key of Object.keys(validSettings)) { |
| 699 | if ( |
| 700 | keysToExpand.includes(key) && |
| 701 | validSettings[key] && |
| 702 | typeof validSettings[key] === 'object' |
no test coverage detected