Documentation
¶
Overview ¶
Package intercept preserves the historical regex-interceptor API as a thin compatibility facade over the backend-neutral adapters package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSensitiveText ¶
IsSensitiveText reports whether text looks like a credential or secret prompt. It complements static Pattern.Sensitive metadata by classifying the actual matched output at runtime.
Types ¶
type Hooks ¶
type Hooks struct {
OnOutput func()
OnPrompt func(Detection)
}
Hooks receives lightweight output notifications and prompt detections. Hooks run synchronously after the Interceptor releases its lock, so they may safely call Output, Acknowledge, or Reblock.
type Interceptor ¶
type Interceptor struct {
// contains filtered or unexported fields
}
Interceptor owns the bounded output history and rolling ANSI-free detection window for one terminal stream. Consume is safe to call concurrently with Acknowledge, IsBlocked, Output, and Reblock.
func New ¶
func New(patterns []Pattern, capacity int, hooks Hooks) (*Interceptor, error)
New validates patterns and creates an Interceptor with bounded output.
func (*Interceptor) Acknowledge ¶
func (i *Interceptor) Acknowledge()
Acknowledge clears the blocked state and old detection tail so a later prompt can be detected without retriggering the prompt just answered.
func (*Interceptor) Consume ¶
func (i *Interceptor) Consume(chunk []byte)
Consume sanitizes and retains a terminal-output chunk, then searches the rolling clean-text window for the first configured prompt. A partial ANSI sequence at the end of a chunk is carried into the next call.
func (*Interceptor) IsBlocked ¶
func (i *Interceptor) IsBlocked() bool
IsBlocked reports whether a prompt is currently awaiting acknowledgement.
func (*Interceptor) Output ¶
func (i *Interceptor) Output() string
Output returns an ordered copy of the bounded, sanitized terminal history.
func (*Interceptor) Reblock ¶
func (i *Interceptor) Reblock()
Reblock restores the blocked state when delivering an answer fails.
type Pattern ¶
Pattern remains an alias so existing intercept_patterns callers keep their source compatibility while GenericRegexAdapter owns regex interpretation.
func DefaultPatterns ¶
func DefaultPatterns() []Pattern
DefaultPatterns returns an independent copy of the built-in prompt list.