Commit ffcc1f3
committed
feat: add HITL confirmation policy support to SessionOptions
Add comprehensive HITL (Human-in-the-Loop) confirmation policy support
to enable tool execution confirmation from Node.js SDK.
Changes to Rust Core (core/src/agent_api.rs):
- Add confirmation_policy field to SessionOptions
- Add with_confirmation_policy() builder method
- Auto-create ConfirmationManager from policy when session is built
- Create manager after event_tx is available (required by ConfirmationManager::new)
Changes to Node SDK (sdk/node/src/lib.rs):
- Add ConfirmationPolicy type with enabled, defaultTimeoutMs, timeoutAction
- Add confirmation_policy field to SessionOptions
- Import hitl module types (ConfirmationPolicy, TimeoutAction)
- Convert JS ConfirmationPolicy to Rust in js_session_options_to_rust
- Call with_confirmation_policy() to pass policy to Rust Core
This fixes the "Tool requires confirmation but no HITL confirmation manager
is configured" error by providing a complete API for HITL configuration.
Usage:
```js
agent.session('.', {
confirmationPolicy: {
enabled: true,
defaultTimeoutMs: 30000,
timeoutAction: 'reject'
}
});
```
When enabled, tools requiring confirmation emit ConfirmationRequired events
and wait for user approval before executing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 78becb3 commit ffcc1f3
1 file changed
Lines changed: 34 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
| |||
283 | 285 | | |
284 | 286 | | |
285 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
286 | 297 | | |
287 | 298 | | |
288 | 299 | | |
| |||
1232 | 1243 | | |
1233 | 1244 | | |
1234 | 1245 | | |
| 1246 | + | |
1235 | 1247 | | |
1236 | 1248 | | |
1237 | 1249 | | |
1238 | 1250 | | |
1239 | 1251 | | |
1240 | | - | |
| 1252 | + | |
1241 | 1253 | | |
1242 | 1254 | | |
1243 | 1255 | | |
| |||
1280 | 1292 | | |
1281 | 1293 | | |
1282 | 1294 | | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
1283 | 1316 | | |
1284 | 1317 | | |
1285 | 1318 | | |
| |||
0 commit comments