修复审批请求在聊天中无提示且无法响应 (#467)
* fix: support run approval prompts in chat * fix(chat): render approval prompts * fix(chat): dedupe approval pattern labels * chore: sync approval flow with current main - update Hermes Agent approval support guidance to PR #21899 - initialize Hermes table schemas in session-sync tests
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
export type ApprovalChoice = 'once' | 'session' | 'always' | 'deny'
|
||||
|
||||
export interface ApprovalCommand {
|
||||
choice: ApprovalChoice
|
||||
all: boolean
|
||||
}
|
||||
|
||||
const APPROVAL_COMMAND_RE = /^\/(approve|deny)(?:\s+(session|always|all))?\s*$/i
|
||||
|
||||
export function parseApprovalCommand(input: string): ApprovalCommand | null {
|
||||
const match = input.trim().match(APPROVAL_COMMAND_RE)
|
||||
if (!match) return null
|
||||
|
||||
const verb = match[1].toLowerCase()
|
||||
const modifier = match[2]?.toLowerCase()
|
||||
|
||||
if (verb === 'deny') {
|
||||
if (modifier && modifier !== 'all') return null
|
||||
return { choice: 'deny', all: modifier === 'all' }
|
||||
}
|
||||
|
||||
if (modifier === 'session') return { choice: 'session', all: false }
|
||||
if (modifier === 'always') return { choice: 'always', all: false }
|
||||
return { choice: 'once', all: modifier === 'all' }
|
||||
}
|
||||
|
||||
export function isApprovalCommand(input: string): boolean {
|
||||
return parseApprovalCommand(input) != null
|
||||
}
|
||||
Reference in New Issue
Block a user