( store: CommandAllowRulesStore<TState>, additionalAllowedTools: string[], )
| 16 | } |
| 17 | |
| 18 | export function syncAllowedToolsForTurn<TState extends CommandAllowRulesState>( |
| 19 | store: CommandAllowRulesStore<TState>, |
| 20 | additionalAllowedTools: string[], |
| 21 | ): void { |
| 22 | store.setState(prev => { |
| 23 | const current = prev.toolPermissionContext.alwaysAllowRules.command |
| 24 | if ( |
| 25 | current === additionalAllowedTools || |
| 26 | (current?.length === additionalAllowedTools.length && |
| 27 | current.every((value, index) => value === additionalAllowedTools[index])) |
| 28 | ) { |
| 29 | return prev |
| 30 | } |
| 31 | |
| 32 | return { |
| 33 | ...prev, |
| 34 | toolPermissionContext: { |
| 35 | ...prev.toolPermissionContext, |
| 36 | alwaysAllowRules: { |
| 37 | ...prev.toolPermissionContext.alwaysAllowRules, |
| 38 | command: additionalAllowedTools, |
| 39 | }, |
| 40 | }, |
| 41 | } |
| 42 | }) |
| 43 | } |
| 44 | |
| 45 | function isCompactBoundaryMessage(message: CompactBoundaryLike): boolean { |
| 46 | return message.type === 'system' && message.subtype === 'compact_boundary' |
no outgoing calls
no test coverage detected