Files
archie/internal/domain/messaging/approval.go
T
sam c5f24ec914 chore: delete code no binary reaches
Removes the Kit task-tool result shim (and with it the MCP go-sdk
dependency), the messaging enable/disable/restart helpers and channel
rebuild closures nothing calls since channels became extensions, the
unused messaging capability, ephemeral and text-fallback types, and
single stragglers in telemetry, releaseupdate, skill, storepkg and
webui. The egress sandbox relay stays for #1867.
2026-11-13 03:33:32 +11:00

51 lines
1.5 KiB
Go

package messaging
import (
"context"
"errors"
"time"
)
// ApprovalRequester asks an operator to approve or deny a named action.
type ApprovalRequester interface {
RequestApproval(ctx context.Context, action, description string) (ApprovalDecision, error)
}
// ApprovalDecision is the outcome of an operator consent request.
type ApprovalDecision int
const (
// ApprovalApproved means the operator approved this one execution.
ApprovalApproved ApprovalDecision = iota
// ApprovalPermanentlyApproved means the operator approved this action
// for the lifetime of the session.
ApprovalPermanentlyApproved
// ApprovalDenied means the operator explicitly refused.
ApprovalDenied
)
// ErrApprovalDenied is returned when the operator refuses the action.
var ErrApprovalDenied = errors.New("approval denied")
// ErrApprovalNotConfigured is returned when a tool requires approval but no
// ApprovalRequester is wired.
var ErrApprovalNotConfigured = errors.New("approval is not configured")
// ToolApprovalTimeout bounds how long dispatch waits for an operator to act.
const ToolApprovalTimeout = 2 * time.Minute
type approvalCtxKey struct{}
// WithApprovalRequester stores an ApprovalRequester on ctx.
func WithApprovalRequester(ctx context.Context, a ApprovalRequester) context.Context {
return context.WithValue(ctx, approvalCtxKey{}, a)
}
// ApprovalFromContext returns the ApprovalRequester stored on ctx.
func ApprovalFromContext(ctx context.Context) ApprovalRequester {
a, _ := ctx.Value(approvalCtxKey{}).(ApprovalRequester)
return a
}