( baseGetAppState: ToolUseContext['getAppState'], allowedTools: string[], )
| 145 | * This is used by forked skill/command execution to grant tool permissions. |
| 146 | */ |
| 147 | export function createGetAppStateWithAllowedTools( |
| 148 | baseGetAppState: ToolUseContext['getAppState'], |
| 149 | allowedTools: string[], |
| 150 | ): ToolUseContext['getAppState'] { |
| 151 | if (allowedTools.length === 0) return baseGetAppState |
| 152 | return () => { |
| 153 | const appState = baseGetAppState() |
| 154 | return { |
| 155 | ...appState, |
| 156 | toolPermissionContext: { |
| 157 | ...appState.toolPermissionContext, |
| 158 | alwaysAllowRules: { |
| 159 | ...appState.toolPermissionContext.alwaysAllowRules, |
| 160 | command: [ |
| 161 | ...new Set([ |
| 162 | ...(appState.toolPermissionContext.alwaysAllowRules.command || |
| 163 | []), |
| 164 | ...allowedTools, |
| 165 | ]), |
| 166 | ], |
| 167 | }, |
| 168 | }, |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * Result from preparing a forked command context. |
no outgoing calls
no test coverage detected