( pendingCheck: PendingClassifierCheck, signal: AbortSignal, isNonInteractiveSession: boolean, )
| 1553 | * if the classifier doesn't auto-approve. |
| 1554 | */ |
| 1555 | export async function awaitClassifierAutoApproval( |
| 1556 | pendingCheck: PendingClassifierCheck, |
| 1557 | signal: AbortSignal, |
| 1558 | isNonInteractiveSession: boolean, |
| 1559 | ): Promise<PermissionDecisionReason | undefined> { |
| 1560 | const { command, cwd, descriptions } = pendingCheck |
| 1561 | const speculativeResult = consumeSpeculativeClassifierCheck(command) |
| 1562 | const classifierResult = speculativeResult |
| 1563 | ? await speculativeResult |
| 1564 | : await classifyBashCommand( |
| 1565 | command, |
| 1566 | cwd, |
| 1567 | descriptions, |
| 1568 | 'allow', |
| 1569 | signal, |
| 1570 | isNonInteractiveSession, |
| 1571 | ) |
| 1572 | |
| 1573 | logClassifierResultForAnts(command, 'allow', descriptions, classifierResult) |
| 1574 | |
| 1575 | if ( |
| 1576 | feature('BASH_CLASSIFIER') && |
| 1577 | classifierResult.matches && |
| 1578 | classifierResult.confidence === 'high' |
| 1579 | ) { |
| 1580 | return { |
| 1581 | type: 'classifier', |
| 1582 | classifier: 'bash_allow', |
| 1583 | reason: `Allowed by prompt rule: "${classifierResult.matchedDescription}"`, |
| 1584 | } |
| 1585 | } |
| 1586 | return undefined |
| 1587 | } |
| 1588 | |
| 1589 | type AsyncClassifierCheckCallbacks = { |
| 1590 | shouldContinue: () => boolean |
no test coverage detected