approval

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 45 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package approval obtains human confirmation for write tools, either via MCP elicitation inside the client or via a browser approval page.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RestartURL

func RestartURL(base, cluster, kind, namespace, name string) string

RestartURL returns the link that requests approval to restart a workload. It holds no secret and changes nothing until a signed-in person approves. Invalid or masked values produce no link.

Types

type BrowserAuth

type BrowserAuth interface {
	RequireUser(next func(w http.ResponseWriter, r *http.Request, subject string)) http.Handler
}

BrowserAuth signs a person in for the approval page. Implemented by oauth.Server.

type Manager

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

Manager implements tool.Confirmer.

func New

func New(cfg config.Approval, publicURL string, browser BrowserAuth, logger *audit.Logger) *Manager

New returns a Manager. browser may be nil, which disables web approval. publicURL is the origin used to build approval links.

func (*Manager) Close added in v0.4.0

func (m *Manager) Close()

Close stops push delivery, including any in-flight HTTP request.

func (*Manager) Confirm

func (m *Manager) Confirm(ctx context.Context, req *mcp.CallToolRequest, r tool.ConfirmRequest) (method string, err error)

Confirm implements tool.Confirmer.

func (*Manager) Counts added in v0.8.0

func (m *Manager) Counts() (waiting, notices int)

Counts reports the approvals waiting for a decision and the inbox notices held, for metrics.

func (*Manager) EnableInboxNotify added in v0.4.0

func (m *Manager) EnableInboxNotify(cfg config.InboxNotify) error

EnableInboxNotify loads the shared key before serving. Notices never create approvals; the usual authenticated live choices flow remains the only gate.

func (*Manager) EnablePush added in v0.4.0

func (m *Manager) EnablePush(cfg config.ApprovalPush) error

EnablePush loads durable subscriptions before HTTP serving starts. A storage error fails startup rather than silently replacing the devices' VAPID key.

func (*Manager) EnableState added in v0.8.0

func (m *Manager) EnableState(path string) ([]byte, error)

EnableState loads path, if set, and returns the link-signing key to use. Call it after EnableInboxNotify and before serving. A missing file starts empty and a file this process cannot read leaves the state in memory. A readable file in another format is an error rather than silently replaced. Without a path the key is random and nothing is stored.

func (*Manager) RegisterStatus added in v0.4.0

func (m *Manager) RegisterStatus(s *mcp.Server, env *tool.Env)

RegisterStatus exposes only the requester's approval records. Add supplies scope, per-caller tool policy, timeout, audit and output bounds.

func (*Manager) ResolveApproval added in v0.4.0

func (m *Manager) ResolveApproval(ctx context.Context, r tool.ConfirmRequest) error

ResolveApproval retrieves the original invocation, even if applying it changed the current plan. Its hash binds all original arguments (including the target); only the stored runner can apply, after checking the approved summary/target.

func (*Manager) Routes

func (m *Manager) Routes(mux *http.ServeMux)

Routes registers the /approve/ pages when web approval is enabled.

func (*Manager) SetDirect

func (m *Manager) SetDirect(lookup func(name string) *tool.Direct)

SetDirect supplies the writes that can run from an approval page.

func (*Manager) SetHostOptions added in v0.4.0

func (m *Manager) SetHostOptions(evaluate func(context.Context, tool.Caller, string, string) (action.Options, error))

SetHostOptions connects the browser to the host provider's rule engine.

func (*Manager) SetOptions added in v0.4.0

func (m *Manager) SetOptions(evaluate func(context.Context, tool.Caller, string, string, string, string) (action.Options, error))

SetOptions connects the browser to the same read-only rule engine as MCP.

Jump to

Keyboard shortcuts

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