(host: SlashCommandHost, args: string)
| 135 | } |
| 136 | |
| 137 | export async function handleAutoCommand(host: SlashCommandHost, args: string): Promise<void> { |
| 138 | const session = host.session; |
| 139 | if (session === undefined) { |
| 140 | host.showError(NO_ACTIVE_SESSION_MESSAGE); |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | const subcmd = args.trim().toLowerCase(); |
| 145 | const currentMode = host.state.appState.permissionMode; |
| 146 | |
| 147 | if (subcmd === 'on') { |
| 148 | if (currentMode === 'auto') { |
| 149 | host.showNotice('Auto mode is already on'); |
| 150 | return; |
| 151 | } |
| 152 | await session.setPermission('auto'); |
| 153 | host.setAppState({ permissionMode: 'auto' }); |
| 154 | host.showNotice('Auto mode: ON', 'Tools auto-approved. Agent will not ask questions.'); |
| 155 | return; |
| 156 | } |
| 157 | |
| 158 | if (subcmd === 'off') { |
| 159 | if (currentMode !== 'auto') { |
| 160 | host.showNotice('Auto mode is already off'); |
| 161 | return; |
| 162 | } |
| 163 | await session.setPermission('manual'); |
| 164 | host.setAppState({ permissionMode: 'manual' }); |
| 165 | host.showNotice('Auto mode: OFF'); |
| 166 | return; |
| 167 | } |
| 168 | |
| 169 | // toggle |
| 170 | if (currentMode === 'auto') { |
| 171 | await session.setPermission('manual'); |
| 172 | host.setAppState({ permissionMode: 'manual' }); |
| 173 | host.showNotice('Auto mode: OFF'); |
| 174 | } else { |
| 175 | await session.setPermission('auto'); |
| 176 | host.setAppState({ permissionMode: 'auto' }); |
| 177 | host.showNotice('Auto mode: ON', 'Tools auto-approved. Agent will not ask questions.'); |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | export async function handleCompactCommand(host: SlashCommandHost, args: string): Promise<void> { |
| 182 | const session = host.session; |
no test coverage detected