Documentation
¶
Index ¶
- func ColorsDisabled() bool
- func IsRunningInContainer() bool
- func NewShellTracker(maxConcurrent int) *shellTracker
- func NewSubagentTracker() scheddomain.SubagentTracker
- 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 A2ATaskTrackerImpl
- func (t *A2ATaskTrackerImpl) AddTask(contextID, taskID string)
- func (t *A2ATaskTrackerImpl) ClearAllAgents()
- func (t *A2ATaskTrackerImpl) GetAgentForContext(contextID string) string
- func (t *A2ATaskTrackerImpl) GetAllAgents() []string
- func (t *A2ATaskTrackerImpl) GetAllContexts() []string
- func (t *A2ATaskTrackerImpl) GetAllPollingTasks() []string
- func (t *A2ATaskTrackerImpl) GetContextForTask(taskID string) string
- func (t *A2ATaskTrackerImpl) GetContextsForAgent(agentURL string) []string
- func (t *A2ATaskTrackerImpl) GetLatestContextForAgent(agentURL string) string
- func (t *A2ATaskTrackerImpl) GetLatestTaskForContext(contextID string) string
- func (t *A2ATaskTrackerImpl) GetPollingState(taskID string) *agentdomain.TaskPollingState
- func (t *A2ATaskTrackerImpl) GetPollingTasksForContext(contextID string) []string
- func (t *A2ATaskTrackerImpl) GetTasksForContext(contextID string) []string
- func (t *A2ATaskTrackerImpl) HasContext(contextID string) bool
- func (t *A2ATaskTrackerImpl) HasTask(taskID string) bool
- func (t *A2ATaskTrackerImpl) RegisterContext(agentURL, contextID string)
- func (t *A2ATaskTrackerImpl) RemoveContext(contextID string)
- func (t *A2ATaskTrackerImpl) RemoveTask(taskID string)
- func (t *A2ATaskTrackerImpl) StartPolling(taskID string, state *agentdomain.TaskPollingState)
- func (t *A2ATaskTrackerImpl) StopPolling(taskID string)
- type Agent
- type AgentContext
- 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 NewShellTracker ¶
func NewShellTracker(maxConcurrent int) *shellTracker
NewShellTracker creates a new shell tracker with the specified maximum concurrent shells. It returns the concrete type: callers that only need the tracked-shell surface assign it to a scheddomain.ShellTracker, while the shell housekeeping helpers (Cleanup/Count) stay reachable on the concrete for the background-shell service and this package's own tests.
func NewSubagentTracker ¶
func NewSubagentTracker() scheddomain.SubagentTracker
NewSubagentTracker creates an empty subagent tracker.
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 A2ATaskTrackerImpl ¶
type A2ATaskTrackerImpl struct {
// contains filtered or unexported fields
}
A2ATaskTrackerImpl provides a hierarchical implementation of A2ATaskTracker
func NewA2ATaskTracker ¶
func NewA2ATaskTracker() *A2ATaskTrackerImpl
NewA2ATaskTracker creates a new A2ATaskTrackerImpl. Returns the concrete type so callers that need to embed it (e.g. the unified services.BackgroundTaskRegistry) don't need to type-assert. The result still satisfies agentdomain.A2ATaskTracker via interface conversion.
func (*A2ATaskTrackerImpl) AddTask ¶
func (t *A2ATaskTrackerImpl) AddTask(contextID, taskID string)
AddTask adds a server-generated task ID to a context
func (*A2ATaskTrackerImpl) ClearAllAgents ¶
func (t *A2ATaskTrackerImpl) ClearAllAgents()
ClearAllAgents clears all tracked agents, contexts, tasks, and polling states
func (*A2ATaskTrackerImpl) GetAgentForContext ¶
func (t *A2ATaskTrackerImpl) GetAgentForContext(contextID string) string
GetAgentForContext returns the agent URL for a given context ID
func (*A2ATaskTrackerImpl) GetAllAgents ¶
func (t *A2ATaskTrackerImpl) GetAllAgents() []string
GetAllAgents returns all agent URLs being tracked
func (*A2ATaskTrackerImpl) GetAllContexts ¶
func (t *A2ATaskTrackerImpl) GetAllContexts() []string
GetAllContexts returns all context IDs being tracked
func (*A2ATaskTrackerImpl) GetAllPollingTasks ¶
func (t *A2ATaskTrackerImpl) GetAllPollingTasks() []string
GetAllPollingTasks returns all task IDs that are currently being polled
func (*A2ATaskTrackerImpl) GetContextForTask ¶
func (t *A2ATaskTrackerImpl) GetContextForTask(taskID string) string
GetContextForTask returns the context ID for a given task
func (*A2ATaskTrackerImpl) GetContextsForAgent ¶
func (t *A2ATaskTrackerImpl) GetContextsForAgent(agentURL string) []string
GetContextsForAgent returns all context IDs for a specific agent
func (*A2ATaskTrackerImpl) GetLatestContextForAgent ¶
func (t *A2ATaskTrackerImpl) GetLatestContextForAgent(agentURL string) string
GetLatestContextForAgent returns the most recently registered context for an agent
func (*A2ATaskTrackerImpl) GetLatestTaskForContext ¶
func (t *A2ATaskTrackerImpl) GetLatestTaskForContext(contextID string) string
GetLatestTaskForContext returns the most recently added task for a context
func (*A2ATaskTrackerImpl) GetPollingState ¶
func (t *A2ATaskTrackerImpl) GetPollingState(taskID string) *agentdomain.TaskPollingState
GetPollingState returns the current polling state for a task
func (*A2ATaskTrackerImpl) GetPollingTasksForContext ¶
func (t *A2ATaskTrackerImpl) GetPollingTasksForContext(contextID string) []string
GetPollingTasksForContext returns all task IDs that are currently being polled for a context
func (*A2ATaskTrackerImpl) GetTasksForContext ¶
func (t *A2ATaskTrackerImpl) GetTasksForContext(contextID string) []string
GetTasksForContext returns all task IDs for a specific context
func (*A2ATaskTrackerImpl) HasContext ¶
func (t *A2ATaskTrackerImpl) HasContext(contextID string) bool
HasContext checks if a context ID is registered
func (*A2ATaskTrackerImpl) HasTask ¶
func (t *A2ATaskTrackerImpl) HasTask(taskID string) bool
HasTask checks if a task ID exists
func (*A2ATaskTrackerImpl) RegisterContext ¶
func (t *A2ATaskTrackerImpl) RegisterContext(agentURL, contextID string)
RegisterContext registers a server-generated context ID for an agent
func (*A2ATaskTrackerImpl) RemoveContext ¶
func (t *A2ATaskTrackerImpl) RemoveContext(contextID string)
RemoveContext removes a context and all its tasks
func (*A2ATaskTrackerImpl) RemoveTask ¶
func (t *A2ATaskTrackerImpl) RemoveTask(taskID string)
RemoveTask removes a task from its context
func (*A2ATaskTrackerImpl) StartPolling ¶
func (t *A2ATaskTrackerImpl) StartPolling(taskID string, state *agentdomain.TaskPollingState)
StartPolling starts tracking a background polling operation for a task
func (*A2ATaskTrackerImpl) StopPolling ¶
func (t *A2ATaskTrackerImpl) StopPolling(taskID string)
StopPolling stops and clears the polling state for a task
type Agent ¶
type Agent struct {
AgentURL string
Contexts []*AgentContext
}
Agent represents an A2A agent with its contexts
type AgentContext ¶
type AgentContext struct {
ContextID string
Tasks []*agentdomain.TaskPollingState
}
AgentContext represents a context within an agent with its tasks
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