utils

package
v0.98.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRateLimiter added in v0.96.0

func NewRateLimiter(cfg config.RateLimitConfig) domain.RateLimiter

NewRateLimiter creates a new rate limiter

func NewShellTracker added in v0.81.0

func NewShellTracker(maxConcurrent int) domain.ShellTracker

NewShellTracker creates a new shell tracker with the specified maximum concurrent shells.

func NewTaskTracker added in v0.53.0

func NewTaskTracker() domain.TaskTracker

NewTaskTracker creates a new TaskTrackerImpl

func WriteViperConfigWithIndent

func WriteViperConfigWithIndent(v *viper.Viper, indent int) error

WriteViperConfigWithIndent writes the current Viper config with specified indentation This uses the same approach as config init to ensure consistent YAML structure

Types

type Agent added in v0.53.0

type Agent struct {
	AgentURL string
	Contexts []*AgentContext
}

Agent represents an A2A agent with its contexts

type AgentContext added in v0.53.0

type AgentContext struct {
	ContextID string
	Tasks     []*domain.TaskPollingState
}

AgentContext represents a context within an agent with its tasks

type OutputRingBuffer added in v0.81.0

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 added in v0.81.0

func NewOutputRingBuffer(maxSize int) *OutputRingBuffer

NewOutputRingBuffer creates a new ring buffer with the specified maximum size in bytes.

func (*OutputRingBuffer) Clear added in v0.81.0

func (rb *OutputRingBuffer) Clear()

Clear resets the buffer to empty state.

func (*OutputRingBuffer) MaxSize added in v0.81.0

func (rb *OutputRingBuffer) MaxSize() int

MaxSize returns the maximum size of the buffer in bytes.

func (*OutputRingBuffer) ReadFrom added in v0.81.0

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 added in v0.81.0

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 added in v0.81.0

func (rb *OutputRingBuffer) Size() int

Size returns the current size of the buffer in bytes.

func (*OutputRingBuffer) Stats added in v0.81.0

func (rb *OutputRingBuffer) Stats() string

Stats returns statistics about the buffer.

func (*OutputRingBuffer) String added in v0.81.0

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 added in v0.81.0

func (rb *OutputRingBuffer) TotalWritten() int64

TotalWritten returns the total number of bytes written to the buffer.

func (*OutputRingBuffer) Write added in v0.81.0

func (rb *OutputRingBuffer) Write(p []byte) (n int, err error)

Write implements io.Writer interface. Writes data to the buffer, wrapping around when full.

type TaskTrackerImpl added in v0.53.0

type TaskTrackerImpl struct {
	// contains filtered or unexported fields
}

TaskTrackerImpl provides a hierarchical implementation of TaskTracker

func (*TaskTrackerImpl) AddTask added in v0.53.0

func (t *TaskTrackerImpl) AddTask(contextID, taskID string)

AddTask adds a server-generated task ID to a context

func (*TaskTrackerImpl) ClearAllAgents added in v0.53.0

func (t *TaskTrackerImpl) ClearAllAgents()

ClearAllAgents clears all tracked agents, contexts, tasks, and polling states

func (*TaskTrackerImpl) GetAgentForContext added in v0.53.0

func (t *TaskTrackerImpl) GetAgentForContext(contextID string) string

GetAgentForContext returns the agent URL for a given context ID

func (*TaskTrackerImpl) GetAllAgents added in v0.53.0

func (t *TaskTrackerImpl) GetAllAgents() []string

GetAllAgents returns all agent URLs being tracked

func (*TaskTrackerImpl) GetAllContexts added in v0.53.0

func (t *TaskTrackerImpl) GetAllContexts() []string

GetAllContexts returns all context IDs being tracked

func (*TaskTrackerImpl) GetAllPollingTasks added in v0.53.0

func (t *TaskTrackerImpl) GetAllPollingTasks() []string

GetAllPollingTasks returns all task IDs that are currently being polled

func (*TaskTrackerImpl) GetContextForTask added in v0.53.0

func (t *TaskTrackerImpl) GetContextForTask(taskID string) string

GetContextForTask returns the context ID for a given task

func (*TaskTrackerImpl) GetContextsForAgent added in v0.53.0

func (t *TaskTrackerImpl) GetContextsForAgent(agentURL string) []string

GetContextsForAgent returns all context IDs for a specific agent

func (*TaskTrackerImpl) GetLatestContextForAgent added in v0.53.0

func (t *TaskTrackerImpl) GetLatestContextForAgent(agentURL string) string

GetLatestContextForAgent returns the most recently registered context for an agent

func (*TaskTrackerImpl) GetLatestTaskForContext added in v0.53.0

func (t *TaskTrackerImpl) GetLatestTaskForContext(contextID string) string

GetLatestTaskForContext returns the most recently added task for a context

func (*TaskTrackerImpl) GetPollingState added in v0.53.0

func (t *TaskTrackerImpl) GetPollingState(taskID string) *domain.TaskPollingState

GetPollingState returns the current polling state for a task

func (*TaskTrackerImpl) GetPollingTasksForContext added in v0.53.0

func (t *TaskTrackerImpl) GetPollingTasksForContext(contextID string) []string

GetPollingTasksForContext returns all task IDs that are currently being polled for a context

func (*TaskTrackerImpl) GetTasksForContext added in v0.53.0

func (t *TaskTrackerImpl) GetTasksForContext(contextID string) []string

GetTasksForContext returns all task IDs for a specific context

func (*TaskTrackerImpl) HasContext added in v0.53.0

func (t *TaskTrackerImpl) HasContext(contextID string) bool

HasContext checks if a context ID is registered

func (*TaskTrackerImpl) HasTask added in v0.53.0

func (t *TaskTrackerImpl) HasTask(taskID string) bool

HasTask checks if a task ID exists

func (*TaskTrackerImpl) IsPolling added in v0.53.0

func (t *TaskTrackerImpl) IsPolling(taskID string) bool

IsPolling returns whether a task currently has an active polling operation

func (*TaskTrackerImpl) RegisterContext added in v0.53.0

func (t *TaskTrackerImpl) RegisterContext(agentURL, contextID string)

RegisterContext registers a server-generated context ID for an agent

func (*TaskTrackerImpl) RemoveContext added in v0.53.0

func (t *TaskTrackerImpl) RemoveContext(contextID string)

RemoveContext removes a context and all its tasks

func (*TaskTrackerImpl) RemoveTask added in v0.53.0

func (t *TaskTrackerImpl) RemoveTask(taskID string)

RemoveTask removes a task from its context

func (*TaskTrackerImpl) StartPolling added in v0.53.0

func (t *TaskTrackerImpl) StartPolling(taskID string, state *domain.TaskPollingState)

StartPolling starts tracking a background polling operation for a task

func (*TaskTrackerImpl) StopPolling added in v0.53.0

func (t *TaskTrackerImpl) StopPolling(taskID string)

StopPolling stops and clears the polling state for a task

type TokenBucketRateLimiter added in v0.96.0

type TokenBucketRateLimiter struct {
	// contains filtered or unexported fields
}

TokenBucketRateLimiter implements token bucket rate limiting for computer use actions

func (*TokenBucketRateLimiter) CheckAndRecord added in v0.96.0

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 added in v0.96.0

func (rl *TokenBucketRateLimiter) GetCurrentCount() int

GetCurrentCount returns the number of actions in the current window

func (*TokenBucketRateLimiter) Reset added in v0.96.0

func (rl *TokenBucketRateLimiter) Reset()

Reset clears all recorded actions

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL