Documentation
¶
Index ¶
- Constants
- type BackendDoctorCheck
- type BackendDoctorInput
- type BackendDoctorReport
- type BackendDoctorStatus
- type BackendLifecycleSnapshot
- type CommandError
- type ConfigSnapshot
- type ErrorKind
- type HookSnapshot
- type MCPServerCounts
- type MCPServerSnapshot
- type ModelSnapshot
- type ModelSnapshotOptions
- type PluginSnapshot
- type ProviderCatalogSnapshot
- type ProviderCatalogSnapshotOptions
- type ProviderSnapshot
- type SandboxBackendSnapshot
- type SandboxBlockSnapshot
- type SandboxDecisionSnapshot
- type SandboxGrantMatchSnapshot
- type SandboxGrantSnapshot
- type SandboxPlanSnapshot
- type SandboxPolicySnapshot
- type SandboxRiskSnapshot
- type SessionSnapshot
- type SessionTreeSnapshot
Constants ¶
const RuntimeGo = "go"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackendDoctorCheck ¶
type BackendDoctorInput ¶
type BackendDoctorInput struct {
MCP config.MCPConfig
Hooks hooks.LoadResult
Plugins plugins.LoadResult
}
type BackendDoctorReport ¶
type BackendDoctorReport struct {
OK bool `json:"ok"`
Status BackendDoctorStatus `json:"status"`
Checks []BackendDoctorCheck `json:"checks"`
}
func NewBackendDoctorReport ¶
func NewBackendDoctorReport(input BackendDoctorInput) BackendDoctorReport
type BackendDoctorStatus ¶
type BackendDoctorStatus string
const ( BackendDoctorStatusPass BackendDoctorStatus = "pass" BackendDoctorStatusWarn BackendDoctorStatus = "warn" BackendDoctorStatusFail BackendDoctorStatus = "fail" )
type BackendLifecycleSnapshot ¶
type BackendLifecycleSnapshot struct {
MCPServers []MCPServerSnapshot `json:"mcpServers"`
Hooks []HookSnapshot `json:"hooks"`
Plugins []PluginSnapshot `json:"plugins"`
}
BackendLifecycleSnapshot bundles the typed snapshots for the three backend surfaces that the WorkSplit PRD places in Gnanam's lane: MCP servers, hooks, and plugins. `zero doctor` and the headless `zero config` command can return one of these to give the operator a single payload describing the full extensibility surface. The three inner slices are always non-nil so JSON output is `[]` and never `null`.
func NewBackendLifecycleSnapshot ¶
func NewBackendLifecycleSnapshot(servers []mcp.Server, hookDefs []hooks.Definition, loaded []plugins.LoadedPlugin) BackendLifecycleSnapshot
NewBackendLifecycleSnapshot builds the bundled snapshot. Each argument may be nil; the snapshot slice stays non-nil for each surface so JSON output is always `[]` and never `null`. The caller is expected to have already loaded the data using the existing mcp.NormalizeConfig, hooks.Load, and plugins.Load helpers.
type CommandError ¶
type CommandError struct {
Kind ErrorKind `json:"kind"`
Message string `json:"message"`
Recoverable bool `json:"recoverable,omitempty"`
}
func ProviderError ¶
func ProviderError(message string) CommandError
func RuntimeError ¶
func RuntimeError(message string) CommandError
func UsageError ¶
func UsageError(message string) CommandError
func (CommandError) Error ¶
func (err CommandError) Error() string
type ConfigSnapshot ¶
type ConfigSnapshot struct {
Runtime string `json:"runtime"`
ActiveProvider string `json:"activeProvider,omitempty"`
MaxTurns int `json:"maxTurns"`
Providers []ProviderSnapshot `json:"providers"`
}
func ConfigSnapshotFromResolved ¶
func ConfigSnapshotFromResolved(resolved config.ResolvedConfig) ConfigSnapshot
type HookSnapshot ¶
type HookSnapshot struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Event string `json:"event"`
Matcher string `json:"matcher,omitempty"`
Command string `json:"command"`
Args []string `json:"args,omitempty"`
Enabled bool `json:"enabled"`
Source string `json:"source,omitempty"`
}
HookSnapshot is the typed view of a single configured hook as it is exposed to the TUI render path, the headless `zero hooks` command, and PR/CI automation. The command and arguments are preserved because they are the operator's primary tool for understanding which shell command will run. The matcher is preserved because it is the operator's primary tool for understanding when the hook will fire.
func HookSnapshotFromDefinition ¶
func HookSnapshotFromDefinition(def hooks.Definition, source hooks.ConfigSource) HookSnapshot
HookSnapshotFromDefinition converts a hooks.Definition into its typed snapshot. The source is the only field that is not on the definition itself; callers that have it from hooks.LoadResult should pass it through. An empty source stays empty in the snapshot.
func HookSnapshots ¶
func HookSnapshots(definitions []hooks.Definition) []HookSnapshot
HookSnapshots converts a slice of hooks.Definition into a stable, sorted slice of typed snapshots. Output is sorted alphabetically by ID, then by event, so consumers see a deterministic ordering. An empty input returns a non-nil empty slice so JSON output is always `[]` and never `null`.
func HookSnapshotsWithSource ¶
func HookSnapshotsWithSource(definitions []hooks.Definition, source hooks.ConfigSource) []HookSnapshot
HookSnapshotsWithSource converts a slice of hooks.Definition and tags every snapshot with the same source string. The helper exists so callers that have a single hooks.LoadResult can build the snapshot slice in one pass.
type MCPServerCounts ¶
MCPServerCounts is the optional runtime count bundle that the snapshot can carry. The struct is split out so callers that have a live tool registry and a live permission store can supply the values without the snapshot helper needing to know about either backend.
type MCPServerSnapshot ¶
type MCPServerSnapshot struct {
Name string `json:"name"`
Type string `json:"type"`
Identity string `json:"identity,omitempty"`
URL string `json:"url,omitempty"`
Command string `json:"command,omitempty"`
ArgCount int `json:"argCount"`
EnvKeyCount int `json:"envKeyCount"`
HeaderCount int `json:"headerCount"`
ToolCount int `json:"toolCount"`
AllowGranted int `json:"allowGranted"`
DenyGranted int `json:"denyGranted"`
}
MCPServerSnapshot is the typed view of a single configured MCP server as it is exposed to the TUI render path, the headless `zero mcp` command, and PR/CI automation. The snapshot strips every field that can carry a secret. Command arguments are preserved because the tool surface (path, flags) is the part a maintainer needs to see when triaging an MCP failure. Environment variables and HTTP headers are summarised as redacted key counts instead of being copied verbatim, so a token in MCP_AUTH_TOKEN never reaches the headless JSON output.
func MCPServerSnapshotFromServer ¶
func MCPServerSnapshotFromServer(server mcp.Server) MCPServerSnapshot
MCPServerSnapshotFromServer converts a single mcp.Server into its typed snapshot. Secret material in `Env` and `Headers` is never copied; only the key counts are recorded. The URL field is run through stripURLCredentialsFromURL so userinfo and sensitive query values are removed before the snapshot leaves the runtime. A URL that fails to parse is returned trimmed, not empty, so the operator still sees the configured endpoint when triaging a malformed MCP configuration.
func MCPServerSnapshotWithCounts ¶
func MCPServerSnapshotWithCounts(server mcp.Server, counts *MCPServerCounts) MCPServerSnapshot
MCPServerSnapshotWithCounts returns a snapshot that also records how many tools the server exposes and how many persistent approvals are currently recorded. A nil counts struct is treated as zero values so callers that do not have a live registry can still call this helper.
func MCPServerSnapshots ¶
func MCPServerSnapshots(servers []mcp.Server) []MCPServerSnapshot
MCPServerSnapshots converts a slice of mcp.Server into a stable, sorted slice of typed snapshots. Output is sorted alphabetically by Name so consumers (TUI, headless, JSON output) see a deterministic ordering. An empty input returns a non-nil empty slice so JSON output is always `[]` and never `null`.
type ModelSnapshot ¶
type ModelSnapshot struct {
ID string `json:"id"`
DisplayName string `json:"displayName"`
Provider string `json:"provider"`
APIModel string `json:"apiModel"`
Status string `json:"status"`
ContextWindow int `json:"contextWindow"`
MaxOutputTokens int `json:"maxOutputTokens"`
Capabilities []string `json:"capabilities"`
ReasoningEfforts []string `json:"reasoningEfforts,omitempty"`
Description string `json:"description,omitempty"`
}
func ModelSnapshotFromEntry ¶
func ModelSnapshotFromEntry(model modelregistry.ModelEntry) ModelSnapshot
func ModelSnapshots ¶
func ModelSnapshots(registry modelregistry.Registry, options ModelSnapshotOptions) ([]ModelSnapshot, error)
type ModelSnapshotOptions ¶
type ModelSnapshotOptions struct {
Provider modelregistry.ProviderKind
IncludeDeprecated bool
}
type PluginSnapshot ¶
type PluginSnapshot struct {
ID string `json:"id"`
Name string `json:"name"`
Version string `json:"version,omitempty"`
Description string `json:"description,omitempty"`
Enabled bool `json:"enabled"`
Source string `json:"source"`
Root string `json:"root,omitempty"`
PluginDir string `json:"pluginDir,omitempty"`
ManifestPath string `json:"manifestPath,omitempty"`
ToolCount int `json:"toolCount"`
PromptCount int `json:"promptCount"`
SkillCount int `json:"skillCount"`
HookCount int `json:"hookCount"`
}
PluginSnapshot is the typed view of a single loaded plugin as it is exposed to the TUI render path, the headless `zero plugins` command, and PR/CI automation. The path fields are preserved because the operator needs to know where the manifest came from when triaging a load failure. Counts replace the full slice of tools, hooks, prompts, and skills so the headless JSON output stays small even for plugins with many extensions.
func PluginSnapshotFromPlugin ¶
func PluginSnapshotFromPlugin(plugin plugins.LoadedPlugin) PluginSnapshot
PluginSnapshotFromPlugin converts a plugins.LoadedPlugin into its typed snapshot. The full slice of tools, hooks, prompts, and skills is collapsed to counts so the headless JSON output stays small. Operator-facing path and metadata fields are preserved after trimming and redaction because they help triage a load failure but may include copied token-like strings.
func PluginSnapshots ¶
func PluginSnapshots(loaded []plugins.LoadedPlugin) []PluginSnapshot
PluginSnapshots converts a slice of plugins.LoadedPlugin into a stable, sorted slice of typed snapshots. Output is sorted alphabetically by ID so consumers (TUI, headless, JSON output) see a deterministic ordering. An empty input returns a non-nil empty slice so JSON output is always `[]` and never `null`.
type ProviderCatalogSnapshot ¶
type ProviderCatalogSnapshot struct {
ID string `json:"id"`
Name string `json:"name"`
Transport string `json:"transport"`
DefaultBaseURL string `json:"defaultBaseUrl,omitempty"`
DefaultModel string `json:"defaultModel,omitempty"`
AuthEnvVars []string `json:"authEnvVars,omitempty"`
RequiresAuth bool `json:"requiresAuth"`
Local bool `json:"local"`
RuntimeSupported bool `json:"runtimeSupported"`
RuntimeUnsupportedReason string `json:"runtimeUnsupportedReason,omitempty"`
Recommended bool `json:"recommended,omitempty"`
}
func ProviderCatalogSnapshotFromDescriptor ¶
func ProviderCatalogSnapshotFromDescriptor(descriptor providercatalog.Descriptor) ProviderCatalogSnapshot
func ProviderCatalogSnapshots ¶
func ProviderCatalogSnapshots(options ProviderCatalogSnapshotOptions) ([]ProviderCatalogSnapshot, error)
type ProviderCatalogSnapshotOptions ¶
type ProviderCatalogSnapshotOptions struct {
Transport string
}
type ProviderSnapshot ¶
type ProviderSnapshot struct {
Name string `json:"name"`
ProviderKind string `json:"providerKind,omitempty"`
BaseURL string `json:"baseUrl,omitempty"`
Model string `json:"model,omitempty"`
APIModel string `json:"apiModel,omitempty"`
Active bool `json:"active"`
APIKeySet bool `json:"apiKeySet"`
Status string `json:"status,omitempty"`
Message string `json:"message,omitempty"`
}
func ProviderSnapshotFromProfile ¶
func ProviderSnapshotFromProfile(profile config.ProviderProfile, active bool) ProviderSnapshot
type SandboxBackendSnapshot ¶
type SandboxBackendSnapshot struct {
Name string `json:"name"`
Available bool `json:"available"`
Platform string `json:"platform,omitempty"`
Fallback bool `json:"fallback"`
CommandWrapping bool `json:"commandWrapping"`
NativeIsolation bool `json:"nativeIsolation"`
Executable string `json:"executable,omitempty"`
Message string `json:"message,omitempty"`
}
SandboxBackendSnapshot is the typed view of a sandbox.Backend as it is exposed to the TUI render path, the headless `zero sandbox policy --json` command, and PR/CI automation. The snapshot is a strict superset of the on-disk backend shape: every field of sandbox.Backend is copied verbatim, and a NativeIsolation field is preserved so the JSON shape matches what consumers already expect.
func SandboxBackendSnapshotFromBackend ¶
func SandboxBackendSnapshotFromBackend(backend sandbox.Backend) SandboxBackendSnapshot
SandboxBackendSnapshotFromBackend converts a sandbox.Backend into its typed snapshot. Every field is copied verbatim.
type SandboxBlockSnapshot ¶
type SandboxBlockSnapshot struct {
Code string `json:"code"`
ToolName string `json:"toolName,omitempty"`
Action string `json:"action"`
Path string `json:"path,omitempty"`
Reason string `json:"reason"`
Recoverable bool `json:"recoverable"`
}
SandboxBlockSnapshot is the typed view of a sandbox.Block as it is exposed to the TUI render path, the audit log, and PR/CI automation. The Path field is preserved because the operator needs it to triage an out-of-workspace or symlink traversal block.
func SandboxBlockSnapshotFromBlock ¶
func SandboxBlockSnapshotFromBlock(block *sandbox.Block) *SandboxBlockSnapshot
SandboxBlockSnapshotFromBlock converts a sandbox.Block into its typed snapshot. A nil input returns a zero snapshot so the helper is safe to call when the decision did not produce a block.
type SandboxDecisionSnapshot ¶
type SandboxDecisionSnapshot struct {
Action string `json:"action"`
Reason string `json:"reason,omitempty"`
Risk SandboxRiskSnapshot `json:"risk"`
GrantMatched bool `json:"grantMatched"`
Grant *SandboxGrantSnapshot `json:"grant,omitempty"`
Block *SandboxBlockSnapshot `json:"block,omitempty"`
}
SandboxDecisionSnapshot is the typed view of a live sandbox.Decision as it is exposed to the TUI render path, the audit log, and PR/CI automation. The snapshot includes the resolved grant (when the decision was driven by a persistent grant) and the block (when the decision was a deny) so consumers do not have to reach back into the sandbox package to render the outcome.
func SandboxDecisionSnapshotFromDecision ¶
func SandboxDecisionSnapshotFromDecision(decision sandbox.Decision) SandboxDecisionSnapshot
SandboxDecisionSnapshotFromDecision converts a sandbox.Decision into its typed snapshot. The optional Grant and Block fields are converted with their respective helpers so the snapshot always carries the same JSON shape regardless of the decision outcome.
type SandboxGrantMatchSnapshot ¶
type SandboxGrantMatchSnapshot struct {
ToolName string `json:"toolName"`
Matched bool `json:"matched"`
Grant *SandboxGrantSnapshot `json:"grant,omitempty"`
}
SandboxGrantMatchSnapshot is the typed view returned to consumers who look up a grant for a specific tool call. It pairs the underlying grant snapshot with a Matched flag so callers can tell the difference between "grant existed and matched" and "no grant recorded for this tool" without inspecting an error or a typed zero value.
func SandboxGrantMatchSnapshotFromLookup ¶
func SandboxGrantMatchSnapshotFromLookup(toolName string, lookup sandbox.GrantLookup) SandboxGrantMatchSnapshot
SandboxGrantMatchSnapshotFromLookup converts a sandbox.GrantLookup into its typed snapshot. When the lookup did not match, the returned snapshot has Matched=false and a nil Grant pointer so consumers can render the absence without consulting an error.
type SandboxGrantSnapshot ¶
type SandboxGrantSnapshot struct {
ToolName string `json:"toolName"`
Decision string `json:"decision"`
ApprovedAt string `json:"approvedAt,omitempty"`
Reason string `json:"reason,omitempty"`
}
SandboxGrantSnapshot is the typed view of a single persistent sandbox grant as it is exposed to TUI, headless, and PR/CI automation. The snapshot guarantees that no secret material from the grant's Reason field is leaked: the field is always run through the standard redaction pipeline before it is copied into the snapshot. ToolName, Decision, and ApprovedAt are non-secret metadata and are copied verbatim.
func SandboxGrantSnapshotFromGrant ¶
func SandboxGrantSnapshotFromGrant(grant sandbox.Grant) SandboxGrantSnapshot
SandboxGrantSnapshotFromGrant converts a sandbox.Grant into its typed snapshot. The Reason field is run through redaction so any secret material is masked before the snapshot leaves the runtime. An empty or whitespace-only Reason becomes an empty Reason in the snapshot, which keeps the JSON shape stable for downstream consumers.
func SandboxGrantSnapshots ¶
func SandboxGrantSnapshots(grants []sandbox.Grant) []SandboxGrantSnapshot
SandboxGrantSnapshots converts a slice of sandbox grants into a stable, sorted slice of typed snapshots. The output is sorted alphabetically by tool name so consumers (TUI, headless, JSON output) get a deterministic ordering. An empty input produces an empty (non-nil) slice so the JSON output is always `[]` and never `null`.
type SandboxPlanSnapshot ¶
type SandboxPlanSnapshot struct {
Policy SandboxPolicySnapshot `json:"policy"`
Backend SandboxBackendSnapshot `json:"backend"`
Restrictions []string `json:"restrictions"`
WorkspaceRoot string `json:"workspaceRoot,omitempty"`
WriteRoots []string `json:"writeRoots,omitempty"`
}
SandboxPlanSnapshot is the typed view of a sandbox.BackendPlan as it is exposed to the TUI render path, the headless `zero sandbox policy --json` command, and PR/CI automation. The snapshot bundles the policy, the backend, and the human-readable restriction warnings so the operator gets one payload describing the entire sandbox posture.
WriteRoots lists every directory the sandbox allows writes in (workspace root first, then user-granted extras). No current builder populates it — SandboxPlanSnapshotFromPlan leaves it unset because a BackendPlan carries no engine scope. Callers that hold the live engine can set it from engine.Scope().Roots(); omitempty keeps the JSON shape stable when unset.
func SandboxPlanSnapshotFromPlan ¶
func SandboxPlanSnapshotFromPlan(plan sandbox.BackendPlan) SandboxPlanSnapshot
SandboxPlanSnapshotFromPlan converts a sandbox.BackendPlan into its typed snapshot. Each entry of the Restrictions slice is trimmed, the slice is sorted alphabetically, and the result is copied so the snapshot does not alias the input. WriteRoots is left unset because a BackendPlan carries no engine scope; callers that hold the live engine can populate it from engine.Scope().Roots().
type SandboxPolicySnapshot ¶
type SandboxPolicySnapshot struct {
Mode string `json:"mode"`
Network string `json:"network"`
EnforceWorkspace bool `json:"enforceWorkspace"`
EffectiveMode string `json:"effectiveMode,omitempty"`
}
SandboxPolicySnapshot is the typed view of the live sandbox policy as it is exposed to the TUI render path, the headless `zero sandbox policy --json` command, and PR/CI automation. The snapshot is a strict superset of the on-disk policy shape: every field of sandbox.Policy is copied verbatim, and an EffectiveMode field is added so consumers do not have to translate the empty string into the enforced default themselves.
func SandboxPolicySnapshotFromPolicy ¶
func SandboxPolicySnapshotFromPolicy(policy sandbox.Policy) SandboxPolicySnapshot
SandboxPolicySnapshotFromPolicy converts a sandbox.Policy into its typed snapshot. The EffectiveMode field is the resolved policy mode: an empty Mode falls back to ModeEnforce, which is the runtime default. Consumers can read EffectiveMode to render the "what is actually in effect" line without re-implementing the default.
type SandboxRiskSnapshot ¶
type SandboxRiskSnapshot struct {
Level string `json:"level"`
Categories []string `json:"categories"`
Reason string `json:"reason"`
}
SandboxRiskSnapshot is the typed view of a sandbox.Risk as it is exposed to the TUI render path and PR/CI automation. The snapshot copies Level and Reason verbatim and sorts Categories alphabetically so the JSON output is deterministic.
func SandboxRiskSnapshotFromRisk ¶
func SandboxRiskSnapshotFromRisk(risk sandbox.Risk) SandboxRiskSnapshot
SandboxRiskSnapshotFromRisk converts a sandbox.Risk into its typed snapshot. The Categories slice is sorted alphabetically and copied so the snapshot does not alias the input.
type SessionSnapshot ¶
type SessionSnapshot struct {
SessionID string `json:"sessionId"`
Kind string `json:"kind,omitempty"`
Title string `json:"title,omitempty"`
Cwd string `json:"cwd,omitempty"`
ModelID string `json:"modelId,omitempty"`
Provider string `json:"provider,omitempty"`
Tag string `json:"tag,omitempty"`
Depth int `json:"depth,omitempty"`
ParentSessionID string `json:"parentSessionId,omitempty"`
RootSessionID string `json:"rootSessionId,omitempty"`
AgentName string `json:"agentName,omitempty"`
TaskID string `json:"taskId,omitempty"`
ForkedFromEventID string `json:"forkedFromEventId,omitempty"`
ForkedFromSequence int `json:"forkedFromSequence,omitempty"`
SpawnedFromEventID string `json:"spawnedFromEventId,omitempty"`
SpawnedFromSequence int `json:"spawnedFromSequence,omitempty"`
SpecID string `json:"specId,omitempty"`
SpecFilePath string `json:"specFilePath,omitempty"`
SpecStatus string `json:"specStatus,omitempty"`
SpecDraftModelID string `json:"specDraftModelId,omitempty"`
SpecDraftReasoning string `json:"specDraftReasoning,omitempty"`
SpecUserComment string `json:"specUserComment,omitempty"`
SpecRejectReason string `json:"specRejectReason,omitempty"`
SpecSourceSessionID string `json:"specSourceSessionId,omitempty"`
SpecImplSessionID string `json:"specImplSessionId,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
EventCount int `json:"eventCount"`
LastEventType string `json:"lastEventType,omitempty"`
}
func SessionSnapshotFromMetadata ¶
func SessionSnapshotFromMetadata(item sessions.Metadata) SessionSnapshot
func SessionSnapshots ¶
func SessionSnapshots(items []sessions.Metadata) []SessionSnapshot
type SessionTreeSnapshot ¶
type SessionTreeSnapshot struct {
Session SessionSnapshot `json:"session"`
Children []SessionTreeSnapshot `json:"children,omitempty"`
}
func SessionTreeSnapshotFromNode ¶
func SessionTreeSnapshotFromNode(node sessions.TreeNode) SessionTreeSnapshot