Documentation
¶
Index ¶
- Constants
- Variables
- func AnswerOf(row *runtimetypes.HITLApproval) string
- func IsAttentionAsk(row *runtimetypes.HITLApproval) bool
- func PolicyNameFromContext(ctx context.Context) string
- func SetAdjudicator(svc Service, adjudicator Adjudicator)
- func SetApprovalCeiling(svc Service, ceiling time.Duration)
- func WithPolicyName(ctx context.Context, policyName string) context.Context
- type Action
- type Adjudication
- type Adjudicator
- type ApprovalRequest
- type AskKind
- type AttentionBounds
- type AttentionRequest
- type ComputeBounds
- type ComputeBoundsReader
- type Condition
- type ConditionOp
- type EvaluationResult
- type KVReader
- type OnExhausted
- type Policy
- type PolicyEvaluator
- type PolicySource
- type PolicyValidator
- type Rule
- type Service
Constants ¶
View Source
const ( AttentionToolsName = "mission" AttentionToolName = "mission_ask_attention" )
View Source
const ( ReasonMatchedRule = "matched_rule" ReasonDefaultAction = "default_action" )
View Source
const DefaultApprovalCeiling = time.Hour
View Source
const DefaultMaxAgentAnswers = 3
View Source
const DefaultMaxAgentApprovals = 10
Variables ¶
View Source
var ( ErrApprovalNotFound = errors.New("hitlservice: approval not found") ErrApprovalAlreadyResolved = errors.New("hitlservice: approval already answered") ErrApprovalExpired = errors.New("hitlservice: approval expired before it was answered") )
View Source
var ErrAgentAnswerBoundSpent = errors.New("hitlservice: mission agent-answer bound spent")
View Source
var ErrAgentApprovalBoundSpent = errors.New("hitlservice: mission agent-approval bound spent")
View Source
var ErrAttentionUnanswered = errors.New("hitlservice: attention ask went unanswered")
Functions ¶
func AnswerOf ¶
func AnswerOf(row *runtimetypes.HITLApproval) string
func IsAttentionAsk ¶
func IsAttentionAsk(row *runtimetypes.HITLApproval) bool
func PolicyNameFromContext ¶
func SetAdjudicator ¶
func SetAdjudicator(svc Service, adjudicator Adjudicator)
func SetApprovalCeiling ¶
Types ¶
type Adjudication ¶
type Adjudicator ¶
type Adjudicator interface {
Adjudicate(ctx context.Context, ask Adjudication)
}
type ApprovalRequest ¶
type AttentionBounds ¶
type AttentionBounds struct {
AllowAgentAnswers bool `json:"allowAgentAnswers,omitempty"`
MaxAgentAnswers int `json:"maxAgentAnswers,omitempty"`
AllowAgentApprovals bool `json:"allowAgentApprovals,omitempty"`
MaxAgentApprovals int `json:"maxAgentApprovals,omitempty"`
}
func (AttentionBounds) EffectiveMaxAgentAnswers ¶
func (b AttentionBounds) EffectiveMaxAgentAnswers() int
func (AttentionBounds) EffectiveMaxAgentApprovals ¶
func (b AttentionBounds) EffectiveMaxAgentApprovals() int
type AttentionRequest ¶
type ComputeBounds ¶
type ComputeBounds struct {
MaxTurns int `json:"maxTurns,omitempty"`
MaxToolCalls int `json:"maxToolCalls,omitempty"`
MaxTokens int `json:"maxTokens,omitempty"`
ModelAllowlist []string `json:"modelAllowlist,omitempty"`
BackendAllowlist []string `json:"backendAllowlist,omitempty"`
OnExhausted OnExhausted `json:"onExhausted,omitempty"`
}
type ComputeBoundsReader ¶
type ComputeBoundsReader interface {
ComputeBoundsFor(ctx context.Context, policyName string) (ComputeBounds, error)
}
type Condition ¶
type Condition struct {
Key string `json:"key"`
Op ConditionOp `json:"op"`
Value string `json:"value"`
}
type ConditionOp ¶
type ConditionOp string
const ( OpEq ConditionOp = "eq" OpGlob ConditionOp = "glob" OpHost ConditionOp = "host" OpCommandBlacklist ConditionOp = "command_blacklist" OpCommandAskAlways ConditionOp = "command_ask_always" OpNoCommandSubstitution ConditionOp = "no_command_substitution" )
type EvaluationResult ¶
type OnExhausted ¶
type OnExhausted string
const ( OnExhaustedFinishStuck OnExhausted = "finish_stuck" OnExhaustedPauseAsk OnExhausted = "pause_ask" )
type Policy ¶
type Policy struct {
DefaultAction Action `json:"default_action,omitempty"`
Rules []Rule `json:"rules"`
Compute *ComputeBounds `json:"compute,omitempty"`
Attention *AttentionBounds `json:"attention,omitempty"`
}
type PolicyEvaluator ¶
type PolicySource ¶
type PolicySource interface {
ReadPolicy(ctx context.Context, tenantID, name string) ([]byte, error)
}
func NewFSPolicySource ¶
func NewFSPolicySource(dirs ...string) PolicySource
type PolicyValidator ¶
func NewPolicyValidator ¶
func NewPolicyValidator(src PolicySource, tenantID, fallbackPolicy string) PolicyValidator
type Service ¶
type Service interface {
PolicyEvaluator
RequestApproval(ctx context.Context, req ApprovalRequest, sink taskengine.TaskEventSink) (bool, error)
Respond(ctx context.Context, approvalID string, approved bool) error
RequestAttention(ctx context.Context, req AttentionRequest, sink taskengine.TaskEventSink) (string, error)
Answer(ctx context.Context, askID, text string) error
AnswerAsAgent(ctx context.Context, askID, text string) error
PendingAttentionAsks(ctx context.Context, missionID string) ([]*runtimetypes.HITLApproval, error)
AttentionBoundsFor(ctx context.Context, policyName string) (AttentionBounds, error)
AgentAnswerCount(ctx context.Context, missionID string) (int, error)
SweepExpired(ctx context.Context) (int, error)
ListPending(ctx context.Context, limit int) ([]*runtimetypes.HITLApproval, error)
}
func New ¶
func New(src PolicySource, tenantID string, store KVReader, tracker libtracker.ActivityTracker) Service
func NewWithDefaultPolicy ¶
func NewWithDefaultPolicy(src PolicySource, tenantID string, store KVReader, tracker libtracker.ActivityTracker, fallbackPolicy string) Service
Click to show internal directories.
Click to hide internal directories.