Documentation
¶
Index ¶
- func ColorsDisabled() bool
- func IsRunningInContainer() bool
- func NewPublicOnlyHTTPClient(timeout time.Duration) *http.Client
- func OnShutdownSignal(fn func())
- func PersistSandboxDirectory(dir string, current []string) error
- func ProcessAlive(pid int) bool
- func PruneClipboardImages(dir string)
- func PruneFilesByModTime(dir string, keep int, maxAge time.Duration, match func(os.DirEntry) bool)
- func RunGit(ctx context.Context, workdir string, args ...string) ([]byte, error)
- func RunGitStdin(ctx context.Context, workdir, stdin string, args ...string) ([]byte, error)
- func SetColorsDisabled(disabled bool)
- func StripANSI(s string) string
- func WriteViperConfigSparse(v *viper.Viper, indent int) error
- func WriteViperConfigWithIndent(v *viper.Viper, indent int) error
- type OutputRingBuffer
- func (rb *OutputRingBuffer) Clear()
- func (rb *OutputRingBuffer) MaxSize() int
- func (rb *OutputRingBuffer) ReadFrom(offset int64) (string, int64)
- func (rb *OutputRingBuffer) Recent(maxBytes int) string
- func (rb *OutputRingBuffer) Size() int
- func (rb *OutputRingBuffer) Stats() string
- func (rb *OutputRingBuffer) String() string
- func (rb *OutputRingBuffer) TotalWritten() int64
- func (rb *OutputRingBuffer) Write(p []byte) (n int, err error)
- type TokenBucketRateLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColorsDisabled ¶
func ColorsDisabled() bool
ColorsDisabled reports whether CLI output colors are disabled.
func IsRunningInContainer ¶
func IsRunningInContainer() bool
IsRunningInContainer detects if the CLI is running inside a container Checks multiple indicators to reliably detect containerized environments
func NewPublicOnlyHTTPClient ¶ added in v0.182.1
NewPublicOnlyHTTPClient returns an *http.Client that refuses to connect to loopback, private, link-local (including the 169.254.169.254 cloud metadata endpoint), multicast, or unspecified addresses. Use it whenever the URL comes from an untrusted source (an LLM tool argument) and no explicit host allow-list applies. The check runs at dial time on the resolved IP, so DNS rebinding cannot bypass it, and it applies to every redirect hop too.
func OnShutdownSignal ¶ added in v0.178.1
func OnShutdownSignal(fn func())
OnShutdownSignal runs fn on SIGINT, SIGTERM or SIGHUP and then exits. SIGHUP matters as much as the other two: it is what a closing terminal sends, and it is the path on which cleanup was previously skipped entirely.
Pair it with sync.OnceFunc and defer the same fn on the normal exit path, so whichever route wins runs the cleanup exactly once.
func PersistSandboxDirectory ¶ added in v0.180.0
PersistSandboxDirectory appends dir to tools.sandbox.directories in the userspace ~/.infer/config.yaml. current seeds the key when the file does not declare it, so persisting never shrinks the effective allow-list.
func ProcessAlive ¶ added in v0.178.1
ProcessAlive reports whether a process with the given PID exists, using the portable signal-0 probe.
func PruneClipboardImages ¶ added in v0.178.1
func PruneClipboardImages(dir string)
PruneClipboardImages removes stale clipboard-image files from dir, keeping the newest 20 and anything younger than 24 hours. Recently pasted images must outlive the message that referenced them - the model may read the file via ImageDecode after the send.
func PruneFilesByModTime ¶ added in v0.178.1
PruneFilesByModTime removes files in dir that fall outside the retention window: when keep > 0 only the newest keep files matching match survive, and when maxAge > 0 files older than maxAge are removed regardless of count. Zero values disable the respective limit. Only files accepted by match are ever touched, so a producer's unrelated files stay safe.
func RunGit ¶ added in v0.178.1
RunGit runs a git command in workdir (process cwd when empty) and returns its stdout. The context bounds the command's lifetime; stderr is folded into the returned error.
func RunGitStdin ¶ added in v0.178.1
RunGitStdin is RunGit with stdin piped to the command, for plumbing that reads a patch from standard input (git apply, git am).
func SetColorsDisabled ¶
func SetColorsDisabled(disabled bool)
SetColorsDisabled records whether CLI output colors are disabled.
func WriteViperConfigSparse ¶
WriteViperConfigSparse writes only the keys actually present in v (its AllSettings), without seeding from DefaultConfig. This is what makes a project ./.infer/config.yaml a true sparse override: it carries only the keys it sets, so initConfig's key-by-key merge leaves every unset key inherited from the userspace ~/.infer/ baseline. (WriteViperConfigWithIndent, by contrast, writes the full default-seeded config and is used for the home baseline file.)
Types ¶
type OutputRingBuffer ¶
type OutputRingBuffer struct {
// contains filtered or unexported fields
}
OutputRingBuffer is a thread-safe circular buffer that implements io.Writer. It provides bounded memory usage by overwriting oldest data when the buffer fills.
func NewOutputRingBuffer ¶
func NewOutputRingBuffer(maxSize int) *OutputRingBuffer
NewOutputRingBuffer creates a new ring buffer with the specified maximum size in bytes.
func (*OutputRingBuffer) Clear ¶
func (rb *OutputRingBuffer) Clear()
Clear resets the buffer to empty state.
func (*OutputRingBuffer) MaxSize ¶
func (rb *OutputRingBuffer) MaxSize() int
MaxSize returns the maximum size of the buffer in bytes.
func (*OutputRingBuffer) ReadFrom ¶
func (rb *OutputRingBuffer) ReadFrom(offset int64) (string, int64)
ReadFrom returns all data from the specified offset onwards. The offset is absolute (based on totalWritten), not relative to buffer position. Returns the data as a string and the new offset to use for the next read.
func (*OutputRingBuffer) Recent ¶
func (rb *OutputRingBuffer) Recent(maxBytes int) string
Recent returns the most recent N bytes from the buffer. If maxBytes is larger than the buffer or total written, returns all available data.
func (*OutputRingBuffer) Size ¶
func (rb *OutputRingBuffer) Size() int
Size returns the current size of the buffer in bytes.
func (*OutputRingBuffer) Stats ¶
func (rb *OutputRingBuffer) Stats() string
Stats returns statistics about the buffer.
func (*OutputRingBuffer) String ¶
func (rb *OutputRingBuffer) String() string
String returns the entire current buffer contents as a string. This respects the circular nature and returns data in the correct order.
func (*OutputRingBuffer) TotalWritten ¶
func (rb *OutputRingBuffer) TotalWritten() int64
TotalWritten returns the total number of bytes written to the buffer.
type TokenBucketRateLimiter ¶
type TokenBucketRateLimiter struct {
// contains filtered or unexported fields
}
TokenBucketRateLimiter implements token bucket rate limiting for computer use actions
func NewRateLimiter ¶
func NewRateLimiter(cfg config.RateLimitConfig) *TokenBucketRateLimiter
NewRateLimiter creates a new rate limiter
func (*TokenBucketRateLimiter) CheckAndRecord ¶
func (rl *TokenBucketRateLimiter) CheckAndRecord(toolName string) error
CheckAndRecord checks if the action is within rate limits and records it Returns an error if the rate limit is exceeded
func (*TokenBucketRateLimiter) GetCurrentCount ¶
func (rl *TokenBucketRateLimiter) GetCurrentCount() int
GetCurrentCount returns the number of actions in the current window
func (*TokenBucketRateLimiter) Reset ¶
func (rl *TokenBucketRateLimiter) Reset()
Reset clears all recorded actions