Pulse/internal/agentcapabilities/control_level.go
rcourtman ee8a24e14a backend and governance: MCP contract, agent capabilities, API, and release-control
Manifest-backed MCP tools, prompts, and resources with surface affordance contracts; agent capability manifest and governance projection; API contract tests and capability route projection; operations-loop and intelligence-funnel telemetry; release-control subsystem documentation, registry, and tooling; licensing and configuration.
2026-06-23 17:26:15 +01:00

48 lines
1.7 KiB
Go

package agentcapabilities
// ControlLevel is the shared Pulse Intelligence permission level for governed
// tool/action surfaces. Assistant settings, Assistant tool availability, and
// external-agent adapters must use this vocabulary rather than local strings.
type ControlLevel string
const (
// ControlLevelReadOnly allows read/query tools only.
ControlLevelReadOnly ControlLevel = "read_only"
// ControlLevelControlled allows control tools through approval-backed paths.
ControlLevelControlled ControlLevel = "controlled"
// ControlLevelAutonomous allows eligible control tools without per-command approval.
ControlLevelAutonomous ControlLevel = "autonomous"
)
// NormalizeControlLevel fails closed to read_only for unset or unknown values.
func NormalizeControlLevel(level string) ControlLevel {
switch ControlLevel(level) {
case ControlLevelReadOnly, ControlLevelControlled, ControlLevelAutonomous:
return ControlLevel(level)
default:
return ControlLevelReadOnly
}
}
// IsValidControlLevel reports whether a value is in the stable shared
// vocabulary. Empty and legacy values are invalid and should be normalized by
// callers that need a runtime setting.
func IsValidControlLevel(level string) bool {
switch ControlLevel(level) {
case ControlLevelReadOnly, ControlLevelControlled, ControlLevelAutonomous:
return true
default:
return false
}
}
// ControlLevelAllowsControlTools reports whether the normalized level may expose
// tools that can change Pulse or target-side state. Unknown levels fail closed.
func ControlLevelAllowsControlTools(level ControlLevel) bool {
switch NormalizeControlLevel(string(level)) {
case ControlLevelControlled, ControlLevelAutonomous:
return true
default:
return false
}
}