Documentation
¶
Index ¶
- Constants
- Variables
- func AgentsDir(home string) string
- func Bootstrap(ctx context.Context, home string, cfg Config) (PreseedResult, []SyncResult, error)
- func BootstrapFor(ctx context.Context, home, project string, cfg Config) (PreseedResult, []SyncResult, error)
- func ChainFileFor(chainID string) string
- func CompileLock(home string) (release func(), err error)
- func CompileShippedAgent(cfg Config, name string) (*taskengine.TaskChainDefinition, error)
- func CompileShippedTree(cfg Config) (*taskengine.TaskChainDefinition, error)
- func ConfigProblems(texts ...string) []string
- func ConfigSectionNames() []string
- func DeleteLayerItem(raw, section, name string) (string, bool, error)
- func DeleteLayerSection(raw, section string) (string, bool, error)
- func EffectiveSection(cfg Config, section string) (any, error)
- func EmitChain(ir *AgentIR, cfg Config) (*taskengine.TaskChainDefinition, error)
- func EmitPolicy(ir *AgentIR, cfg Config) (*hitlservice.Policy, error)
- func EmitTree(root *AgentTree, cfg Config) (*taskengine.TaskChainDefinition, error)
- func EnvelopeName(s string) (string, bool)
- func EnvelopePolicyFile(name string) string
- func LayerItem(raw, section, name string) (any, bool, error)
- func LayerRevision(raw string) string
- func LayerSection(raw, section string) (any, bool, error)
- func LockLayerWrites() func()
- func MergePatch(target, patch any) any
- func NewConfigProblems(before, after []string) []string
- func ParseConfigLayer(raw string) (map[string]any, error)
- func PatchLayerItem(raw, section, name string, patch any) (string, error)
- func PatchLayerSection(raw, section string, patch any) (string, error)
- func PolicyFileFor(stem string) string
- func PolicyForAgent(ctx context.Context, generatedDir Root, agentName string) (string, bool)
- func PolicyForChain(ctx context.Context, generatedDir Root, chainFile string) (string, bool)
- func RenderEnvelopePolicy(cfg Config, name, source string) ([]byte, error)
- func RenderSkillInventory(skills []Skill) string
- func RenderWorkspaceEnvelopes(ctx context.Context, home, workspaceRoot string) ([]string, error)
- func RetireStaleEnvelopePolicies(generatedDir string, keep []string) ([]string, error)
- func SetLayerItem(raw, section, name string, value any) (string, error)
- func SetLayerSection(raw, section string, value any) (string, error)
- func SyncEnvelopePolicy(ctx context.Context, cfg Config, name string, generatedDir Root, source string) (string, bool, error)
- func ToolPatternRef(pattern string) (tools, tool string, err error)
- func ToolSets(connected []string) []string
- func TreeSignature(home string) string
- func WorkspacePolicyDir(home, workspaceID string) string
- func WriteConfigLayer(path, raw string) error
- type AgentFileStatus
- type AgentIR
- func Parse(path string, data []byte, cfg Config) (*AgentIR, error)
- func ParseAntigravity(path string, data []byte, cfg Config) (*AgentIR, error)
- func ParseAs(dialect Dialect, path string, data []byte, cfg Config) (*AgentIR, error)
- func ParseClaudeCode(path string, data []byte, cfg Config) (*AgentIR, error)
- type AgentTree
- type AttentionDefaults
- type AxisGrant
- type Budgets
- type ChainDefaults
- type ComputeDefaults
- type Config
- func (cfg Config) EnvelopeNames() []string
- func (cfg Config) For(agent string) (Config, error)
- func (c Config) MapModel(name string) (provider, id string, ok bool)
- func (c Config) MapTools(names []string) ([]string, []Unmapped, error)
- func (cfg Config) ParseEnvelope(name string) (Envelope, error)
- func (cfg Config) PostureEnvelope(p Posture) (Envelope, error)
- func (cfg Config) ResolveEnvelope(name string) (Envelope, error)
- func (cfg Config) UnknownAgents(known map[string]bool) []string
- func (cfg Config) Validate() error
- type ConfigLayer
- type DeclaredMCPServer
- type DeclaredRemoteTool
- type Dialect
- type Envelope
- type ErrAmbiguousDialect
- type ErrMissingField
- type ErrNoFrontmatter
- type ErrUnknownTool
- type ErrUnsafePosture
- type Model
- type NamingDefaults
- type PolicyDefaults
- type Posture
- type PostureGrants
- type PreseedResult
- type PreseedSource
- type Problem
- type Role
- type Root
- type RoutingDefaults
- type SectionKind
- type Skill
- type Source
- type SourceDir
- type StandingRule
- type SyncOption
- type SyncResult
- type Tools
- type TranspiledEnvelope
- type Unmapped
- type WriteAction
Constants ¶
const ( MacroRoundsUsed = "{{rounds_used}}" MacroRecoveryRoundsUsed = "{{recovery_rounds_used}}" MacroMainRounds = "{{main_rounds}}" MacroRecoveryRounds = "{{recovery_rounds}}" )
const ( AxisFilesRead = "files.read" AxisFilesWrite = "files.write" AxisShell = "shell" AxisNetworkRead = "network.read" AxisNetworkWrite = "network.write" AxisEventsFire = "events.fire" AxisEventsSubscribe = "events.subscribe" AxisMissionsFire = "missions.fire" AxisMissionsAnswer = "missions.answer" )
const AgentFilename = "agent.md"
const ChainSchemaURL = "https://contenox.com/schema/task-chain.schema.json"
const CompiledChainPrefix = "agent-"
const ConfigFilename = "agents.toml"
const EnvelopeSection = "envelopes"
const FailureFilename = "failure.md"
const FieldMCPServers = "mcpServers"
const FieldRemoteTools = "remoteTools"
const GeneratedDirName = hitlservice.GeneratedPolicyDir
const NativeSourceDir = "agents"
const PolicySchemaURL = "https://contenox.com/schema/hitl-policy-v1.schema.json"
const PreseedStateFilename = ".preseed-state.json"
const RecoveryFilename = "recovery.md"
const RoleSubagent = RoleMission
const SkillDirName = "skills"
const SkillsMacro = "{{skills}}"
const SyncStateFilename = ".sync-state.json"
const ToolsInheritAll = "*"
const TreeDialect = DialectClaudeCode
Variables ¶
var ErrNoEnvelope = errors.New("agentdecl: no such envelope")
var ForeignSourceDirs = []string{ path.Join(".claude", "agents"), path.Join(".agents", "agents"), }
var Preseeded = []struct { RelPath string Source string Content func() string }{ {ConfigFilename, "agents.toml", func() string { return string(shippedConfig) }}, {path.Join(NativeSourceDir, "README.md"), "preseed/README.md", func() string { return preseedReadme }}, {path.Join(NativeSourceDir, "reviewer.md"), "preseed/reviewer.md", func() string { return preseedReviewer }}, {path.Join(NativeSourceDir, "researcher.md"), "preseed/researcher.md", func() string { return preseedResearcher }}, {path.Join(NativeSourceDir, "run.md"), "preseed/run.md", func() string { return preseedRun }}, {path.Join(NativeSourceDir, "chat.md"), "preseed/chat.md", func() string { return preseedChat }}, {path.Join(NativeSourceDir, "planner.md"), "preseed/planner.md", func() string { return preseedPlanner }}, }
var ReservedNames = map[string]bool{}
Functions ¶
func Bootstrap ¶
func Bootstrap(ctx context.Context, home string, cfg Config) (PreseedResult, []SyncResult, error)
func BootstrapFor ¶
func BootstrapFor(ctx context.Context, home, project string, cfg Config) (PreseedResult, []SyncResult, error)
BootstrapFor is Bootstrap with a project root: its `.contenox/agents/` and other tools' agent folders are compiled beside the home's, and a project agents.toml layers over the home one. An empty project means home only.
func ChainFileFor ¶
func CompileLock ¶
func CompileShippedAgent ¶
func CompileShippedAgent(cfg Config, name string) (*taskengine.TaskChainDefinition, error)
func CompileShippedTree ¶
func CompileShippedTree(cfg Config) (*taskengine.TaskChainDefinition, error)
func ConfigProblems ¶
func ConfigSectionNames ¶
func ConfigSectionNames() []string
func EmitChain ¶
func EmitChain(ir *AgentIR, cfg Config) (*taskengine.TaskChainDefinition, error)
func EmitPolicy ¶
func EmitPolicy(ir *AgentIR, cfg Config) (*hitlservice.Policy, error)
func EmitTree ¶
func EmitTree(root *AgentTree, cfg Config) (*taskengine.TaskChainDefinition, error)
func EnvelopeName ¶
func EnvelopePolicyFile ¶
func LayerRevision ¶
func LockLayerWrites ¶
func LockLayerWrites() func()
func MergePatch ¶
func NewConfigProblems ¶
func PolicyFileFor ¶
func PolicyForAgent ¶
PolicyForAgent reports the generated policy of the declaration whose scoped name ends in agentName — a declaration read from another product's directory carries that product's prefix, so an exact match is not enough.
func PolicyForChain ¶
PolicyForChain reports the generated policy file an agent's compiled chain was emitted with, so a caller that knows the chain (a mission naming a declared agent, say) can bound itself by that agent's own posture instead of a global default. The name is the file under the generated root.
func RenderEnvelopePolicy ¶
func RenderSkillInventory ¶
func SyncEnvelopePolicy ¶
func ToolPatternRef ¶
func TreeSignature ¶
TreeSignature changes whenever a declaration or agents.toml changes, so a watcher can tell "something moved" without parsing anything.
func WorkspacePolicyDir ¶
func WriteConfigLayer ¶
Types ¶
type AgentFileStatus ¶
type AgentFileStatus struct {
Path string `json:"path"`
State string `json:"state"`
Problems []Problem `json:"problems,omitempty"`
}
AgentFileStatus is one declaration source as the app sees it: where it is, whether it is still the shipped copy, and what the last compile said about it.
func AgentFiles ¶
func AgentFiles(home string) ([]AgentFileStatus, error)
AgentFiles lists every declaration under <home>/agents with its state and the problems the last compile reported for it. States: shipped (byte-identical to the file this build ships), edited (a shipped file the user changed), user (everything else).
type AgentIR ¶
type AgentIR struct {
Source Source `json:"source"`
Name string `json:"name"`
Description string `json:"description"`
SystemPrompt string `json:"system_prompt"`
Model Model `json:"model"`
Tools Tools `json:"tools"`
MCPServers []string `json:"mcp_servers,omitempty"`
DeclaredMCP []DeclaredMCPServer `json:"declared_mcp,omitempty"`
DeclaredRemote []DeclaredRemoteTool `json:"declared_remote,omitempty"`
Role Role `json:"role"`
Posture Posture `json:"posture"`
Category string `json:"category,omitempty"`
Icon string `json:"icon,omitempty"`
Think string `json:"think,omitempty"`
DefaultBranch string `json:"default_branch,omitempty"`
Temperature *float32 `json:"temperature,omitempty"`
Budgets Budgets `json:"budgets"`
Unmapped []Unmapped `json:"unmapped,omitempty"`
}
func ParseAntigravity ¶
func (*AgentIR) AddUnmapped ¶
func (*AgentIR) DeclaredToolsetNames ¶
func (*AgentIR) RunsAsSubagent ¶
func (*AgentIR) ScopedName ¶
type AgentTree ¶
type AttentionDefaults ¶
type ChainDefaults ¶
type ChainDefaults struct {
TokenLimit int64 `toml:"token_limit"`
MaxTokens string `toml:"max_tokens"`
Think string `toml:"think"`
MainRounds int `toml:"main_rounds"`
RecoveryRounds int `toml:"recovery_rounds"`
RetryOnFailure int `toml:"retry_on_failure"`
Shift bool `toml:"shift"`
RetryPolicy *llmretry.RetryPolicy `toml:"retry_policy"`
}
type ComputeDefaults ¶
type Config ¶
type Config struct {
Version int `toml:"version"`
Chain ChainDefaults `toml:"chain"`
Routing RoutingDefaults `toml:"routing"`
ToolsPolicies map[string]map[string]string `toml:"tools_policies"`
Policy PolicyDefaults `toml:"policy"`
Naming NamingDefaults `toml:"naming"`
Tools map[string]string `toml:"tools"`
Models map[string]string `toml:"models"`
Envelopes map[string]map[string]any `toml:"envelopes"`
Agents map[string]map[string]any `toml:"agents"`
}
func ConfigFromTexts ¶
func (Config) EnvelopeNames ¶
type ConfigLayer ¶
func ReadConfigLayer ¶
func ReadConfigLayer(path string) (ConfigLayer, error)
type DeclaredMCPServer ¶
type DeclaredMCPServer struct {
Declared string `json:"declared"`
Transport string `json:"transport"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
URL string `json:"url,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
AuthEnvKey string `json:"auth_env_key,omitempty"`
AuthType string `json:"auth_type,omitempty"`
}
type DeclaredRemoteTool ¶
type ErrAmbiguousDialect ¶
type ErrAmbiguousDialect struct{ Path string }
func (*ErrAmbiguousDialect) Error ¶
func (e *ErrAmbiguousDialect) Error() string
type ErrMissingField ¶
func (*ErrMissingField) Error ¶
func (e *ErrMissingField) Error() string
type ErrNoFrontmatter ¶
type ErrNoFrontmatter struct{ Path string }
func (*ErrNoFrontmatter) Error ¶
func (e *ErrNoFrontmatter) Error() string
type ErrUnknownTool ¶
type ErrUnknownTool struct {
Tools []string
}
func (*ErrUnknownTool) Error ¶
func (e *ErrUnknownTool) Error() string
type ErrUnsafePosture ¶
func (*ErrUnsafePosture) Error ¶
func (e *ErrUnsafePosture) Error() string
type NamingDefaults ¶
type NamingDefaults struct {
ScopeWithDialect bool `toml:"scope_with_dialect"`
}
type PolicyDefaults ¶
type PolicyDefaults struct {
DefaultAction string `toml:"default_action"`
Compute ComputeDefaults `toml:"compute"`
Attention AttentionDefaults `toml:"attention"`
AlwaysDeny []StandingRule `toml:"always_deny"`
AlwaysAllow []StandingRule `toml:"always_allow"`
Postures map[string]PostureGrants `toml:"postures"`
}
type PostureGrants ¶
type PreseedResult ¶
type PreseedSource ¶
func PreseedSources ¶
func PreseedSources() ([]PreseedSource, error)
type Problem ¶
type Problem struct {
Source string `json:"source"`
Name string `json:"name,omitempty"`
Action string `json:"action"`
Reason string `json:"reason,omitempty"`
Field string `json:"field,omitempty"`
}
Problem is one thing a sync or render pass could not do. The boot keeps the latest list so the app can show a broken declaration instead of only logging it: refused, ignored, or a field the declaration named and this build does not carry.
func LastProblems ¶
func LastProblems() []Problem
LastProblems reports what the most recent bootstrap could not act on.
type RoutingDefaults ¶
type SectionKind ¶
type SectionKind string
const ( SectionNamed SectionKind = "named" SectionFlat SectionKind = "flat" SectionSingleton SectionKind = "singleton" )
func SectionKindOf ¶
func SectionKindOf(section string) (SectionKind, bool)
type StandingRule ¶
type SyncOption ¶
type SyncOption func(*syncOptions)
func WithSkills ¶
func WithSkills(skills []Skill) SyncOption
type SyncResult ¶
type SyncResult struct {
Source string
Name string
Dialect Dialect
Action WriteAction
Reason string
Unmapped []Unmapped
MCP []DeclaredMCPServer
Remote []DeclaredRemoteTool
}
func Sync ¶
func Sync(ctx context.Context, sourceDirs []SourceDir, generated Root, cfg Config, opts ...SyncOption) ([]SyncResult, error)
type TranspiledEnvelope ¶
type TranspiledEnvelope struct {
Policy *hitlservice.Policy
Notes []string
}
func TranspileEnvelope ¶
func TranspileEnvelope(env Envelope) (TranspiledEnvelope, error)
type WriteAction ¶
type WriteAction string
const ( ActionCreated WriteAction = "created" ActionUpdated WriteAction = "updated" ActionUnchanged WriteAction = "unchanged" ActionRefused WriteAction = "refused" ActionIgnored WriteAction = "ignored" )