agent

package
v0.260801.2 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AgentTypeClaudeCode represents Claude Code agent
	AgentTypeClaudeCode = aiagent.AgentTypeClaudeCode

	// AgentTypeOpenCode represents OpenCode IDE extension
	AgentTypeOpenCode = aiagent.AgentTypeOpenCode

	// AgentTypeCodex represents the OpenAI Codex CLI
	AgentTypeCodex = aiagent.AgentTypeCodex
)

Re-export constants for backward compatibility

View Source
const DefaultClaudeCodeDefaultMode = "acceptEdits"

Variables

View Source
var (
	// ParseAgentType parses an agent type string, supporting aliases
	ParseAgentType = aiagent.ParseAgentType

	// ListAgentInfo returns information about all supported agent types
	ListAgentInfo = aiagent.ListAgentInfo

	// GetAgentInfo returns information about a specific agent type
	GetAgentInfo = aiagent.GetAgentInfo
)

Re-export functions for backward compatibility

View Source
var ClaudeCodeRequestModels = []string{
	"tingly/cc",
	"tingly/cc-haiku",
	"tingly/cc-sonnet",
	"tingly/cc-opus",
	"tingly/cc-default",
	"tingly/cc-subagent",
}

ClaudeCodeRequestModels defines all request models for Claude Code scenario When applying claude-code agent, all these rules should be updated for convenience

View Source
var CodexRequestModels = []string{
	"tingly-codex",
}

CodexRequestModels defines the default request models for the Codex scenario. Users typically add additional rules with their own request_model names; this list only seeds the default rule when none exists yet.

View Source
var OpenCodeRequestModels = []string{
	"tingly-opencode",
}

OpenCodeRequestModels defines all request models for OpenCode scenario

Functions

func BuildCCProfileSettings added in v0.260625.1

func BuildCCProfileSettings(profileID, scenarioPath, profileName string, env map[string]string, opts ...serverconfig.ApplyOption) (string, error)

BuildCCProfileSettings materializes one derived Claude Code profile under ~/.tingly-box/claude/. The local/default profile lives at default/, while a named profile lives at <profileID>--<profileName>/ so both its stable identity and human name are visible without aliases or platform-specific links.

Config remains the source of truth. The directory contains only rebuildable runtime artifacts: settings.json and its statusline.sh wrapper.

func BuildClaudeCodeModelConfig added in v0.260514.1

func BuildClaudeCodeModelConfig(unified bool) aiagent.ClaudeCodeModelConfig

BuildClaudeCodeModelConfig constructs the model configuration for Claude Code. This contains the business logic for unified vs separate mode. Exported for use by HTTP handlers.

func BuildOpenCodeConfig added in v0.260514.1

func BuildOpenCodeConfig(configBaseURL, apiKey string, models map[string]interface{}) map[string]interface{}

BuildOpenCodeConfig constructs the OpenCode configuration object. This function contains the business logic for OpenCode config structure.

func CCProfileSettingsPath added in v0.260723.1

func CCProfileSettingsPath(profileID, profileName string) (string, error)

CCProfileSettingsPath derives the canonical generated settings path from current profile metadata. The path is never persisted; callers recompute it so profile renames and legacy-name fallbacks cannot leave stale locations.

func CollectCodexModels added in v0.260514.1

func CollectCodexModels(rules []string) []string

CollectCodexModels deduplicates and preserves order of model names. This helper processes routing rules to extract unique model names.

func DiffCCProfileConfig added in v0.260723.1

func DiffCCProfileConfig(base ClaudeCodePrefs, inheritedDefaultMode string, desired ClaudeCodePrefs, desiredDefaultMode string) (*typ.ClaudeCodeProfileConfig, error)

DiffCCProfileConfig stores a minimal, stable delta between the profile base and the full desired typed configuration submitted by the editor.

func GenerateCCEnv added in v0.260625.1

func GenerateCCEnv(cfg *serverconfig.Config, baseURL, apiKey, scenarioPath string, unified, isProfile bool) map[string]string

GenerateCCEnv builds the env map for Claude Code settings.json.

scenarioPath is "claude_code" for the main scenario or "claude_code:p1" for a profile. isProfile=true → tier models resolved from profile-scoped built-in UUIDs; isProfile=false → resolved from main-scenario built-in UUIDs (with legacy-UUID fallback for pre-migration configs).

Reading the rule's request_model (instead of assuming the seeded name) keeps the env aligned when a user renames a rule's model; the seeded name is the fallback when the rule is missing or inactive.

func InspectCCProfileSettings added in v0.260723.1

func InspectCCProfileSettings(profileID, profileName string) (string, bool, error)

InspectCCProfileSettings derives the canonical path and reports whether the generated settings file currently exists as a regular file.

func MaterializeCCProfileSettings added in v0.260723.1

func MaterializeCCProfileSettings(cfg *serverconfig.Config, baseURL, apiKey, scenarioPath string, profile typ.ProfileMeta) (string, error)

MaterializeCCProfileSettings resolves and writes one named profile using its persisted override delta. It is the shared path for HTTP mutations and CLI launch, preventing either surface from generating a different artifact.

func NormalizeClaudeCodeDefaultMode added in v0.260723.1

func NormalizeClaudeCodeDefaultMode(mode string) (string, bool)

NormalizeClaudeCodeDefaultMode applies the Tingly default for an empty value and rejects values Claude Code does not recognize.

func RemoveCCProfileArtifacts added in v0.260716.1

func RemoveCCProfileArtifacts(profileID, profileName string) error

RemoveCCProfileArtifacts removes only files generated by Tingly-Box for the selected profile. If users added anything else to the directory, it is left in place rather than recursively deleted.

func RemoveRenamedCCProfileArtifacts added in v0.260716.1

func RemoveRenamedCCProfileArtifacts(profileID, oldName, newName string) error

RemoveRenamedCCProfileArtifacts removes the old derived directory after the new one has been materialized. os.SameFile protects case-only renames on case-insensitive filesystems, where both spellings identify the same path.

Types

type AgentApply

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

AgentApply handles agent configuration with routing rules (Tingly-Box specific)

func NewAgentApply

func NewAgentApply(cfg *serverconfig.Config, host string) *AgentApply

NewAgentApply creates a new AgentApply instance

func (*AgentApply) ApplyAgent

func (aa *AgentApply) ApplyAgent(req *ApplyAgentRequest) (*ApplyAgentResult, error)

ApplyAgent applies configuration including routing rules This is the main entry point for Tingly-Box agent configuration

func (*AgentApply) RestoreAgent added in v0.260507.1

func (aa *AgentApply) RestoreAgent(req *RestoreAgentRequest) (*RestoreAgentResult, error)

RestoreAgent restores configuration files from backup

type AgentInfo

type AgentInfo = aiagent.AgentInfo

AgentInfo provides information about an agent type

type AgentType

type AgentType = aiagent.AgentType

AgentType represents the type of AI agent to configure

type ApplyAgentRequest

type ApplyAgentRequest = aiagent.ApplyAgentRequest

ApplyAgentRequest represents a request to apply agent configuration

type ApplyAgentResult

type ApplyAgentResult = aiagent.ApplyAgentResult

ApplyAgentResult represents the result of applying agent configuration

type CCProfileSettingsResolution added in v0.260723.1

type CCProfileSettingsResolution struct {
	BasePreferences      ClaudeCodePrefs
	EffectivePreferences ClaudeCodePrefs
	InheritedDefaultMode string
	EffectiveDefaultMode string
	Env                  map[string]string
	HasOverrides         bool
}

CCProfileSettingsResolution contains both the inherited profile base and the effective result after persistent overrides. Env includes server-owned keys and is ready to materialize; the preference fields are safe for API output.

func ResolveCCProfileSettings added in v0.260723.1

func ResolveCCProfileSettings(cfg *serverconfig.Config, baseURL, apiKey, scenarioPath string, profile typ.ProfileMeta) (CCProfileSettingsResolution, error)

ResolveCCProfileSettings composes main settings, rule-derived profile model slots, stored overrides, and protected connection values in that order.

type ClaudeCodePrefs added in v0.260531.1

type ClaudeCodePrefs struct {
	// Model routing
	AnthropicModel              string `json:"ANTHROPIC_MODEL,omitempty"`
	AnthropicDefaultHaikuModel  string `json:"ANTHROPIC_DEFAULT_HAIKU_MODEL,omitempty"`
	AnthropicDefaultSonnetModel string `json:"ANTHROPIC_DEFAULT_SONNET_MODEL,omitempty"`
	AnthropicDefaultOpusModel   string `json:"ANTHROPIC_DEFAULT_OPUS_MODEL,omitempty"`
	ClaudeCodeSubagentModel     string `json:"CLAUDE_CODE_SUBAGENT_MODEL,omitempty"`

	// Limits — kept as strings so empty = omit (avoids the "0 means unset"
	// ambiguity that a *int would force callers to deal with).
	APITimeoutMs              string `json:"API_TIMEOUT_MS,omitempty"`
	ClaudeCodeMaxOutputTokens string `json:"CLAUDE_CODE_MAX_OUTPUT_TOKENS,omitempty"`
	MaxThinkingTokens         string `json:"MAX_THINKING_TOKENS,omitempty"`
	BashDefaultTimeoutMs      string `json:"BASH_DEFAULT_TIMEOUT_MS,omitempty"`
	BashMaxTimeoutMs          string `json:"BASH_MAX_TIMEOUT_MS,omitempty"`
	McpTimeout                string `json:"MCP_TIMEOUT,omitempty"`
	McpToolTimeout            string `json:"MCP_TOOL_TIMEOUT,omitempty"`
	MaxMcpOutputTokens        string `json:"MAX_MCP_OUTPUT_TOKENS,omitempty"`

	// Auto-compact settings — control context window compaction
	ClaudeCodeAutoCompactWindow  string `json:"CLAUDE_CODE_AUTO_COMPACT_WINDOW,omitempty"`
	ClaudeAutocompactPctOverride string `json:"CLAUDE_AUTOCOMPACT_PCT_OVERRIDE,omitempty"`

	// Privacy / behavior switches — "1" to enable, "" to omit.
	DisableTelemetry                     string `json:"DISABLE_TELEMETRY,omitempty"`
	DisableErrorReporting                string `json:"DISABLE_ERROR_REPORTING,omitempty"`
	ClaudeCodeDisableNonessentialTraffic string `json:"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC,omitempty"`
	DisableAutoupdater                   string `json:"DISABLE_AUTOUPDATER,omitempty"`
	UseBuiltinRipgrep                    string `json:"USE_BUILTIN_RIPGREP,omitempty"`

	// Network proxy. Backend accepts these; the current UI does not surface
	// them (too niche for the form, and they overlap with system-level proxy
	// settings managed elsewhere). Wire them up if/when a user asks.
	HTTPProxy  string `json:"HTTP_PROXY,omitempty"`
	HTTPSProxy string `json:"HTTPS_PROXY,omitempty"`
	NoProxy    string `json:"NO_PROXY,omitempty"`

	// Extra is an escape hatch for env vars not modeled above. Merged in
	// after marshaling; values here override the typed fields if keys collide.
	Extra map[string]string `json:"-"`
}

ClaudeCodePrefs is the user-tunable surface of Claude Code's env config. JSON tags map 1:1 to the env var names Claude Code reads, so marshaling produces exactly what should go under "env" in ~/.claude/settings.json. Empty fields are omitted — meaning "don't write this env, let Claude Code fall back to its own default".

func ClaudeCodePrefsFromEnv added in v0.260723.1

func ClaudeCodePrefsFromEnv(env map[string]string) (ClaudeCodePrefs, error)

ClaudeCodePrefsFromEnv selects the typed preference keys from an env map. Unknown and server-owned keys are ignored.

func DefaultClaudeCodePrefs added in v0.260531.1

func DefaultClaudeCodePrefs(unified bool) ClaudeCodePrefs

DefaultClaudeCodePrefs returns tb's canonical defaults for the given mode. Used by the CLI harness directly and as the seed value for the GUI quick-config form when no user customization exists yet.

func (ClaudeCodePrefs) ToEnv added in v0.260531.1

func (p ClaudeCodePrefs) ToEnv(baseURL, apiKey string) (map[string]string, error)

ToEnv materializes prefs into an env map ready to be written under "env" in settings.json. baseURL and apiKey are sourced from the server context (not from prefs) and are always injected.

func (ClaudeCodePrefs) Values added in v0.260723.1

func (p ClaudeCodePrefs) Values() (map[string]string, error)

Values returns only the typed, user-tunable env values. Unlike ToEnv it does not inject server-owned connection values.

type ClaudeCodeSettingsSnapshot added in v0.260723.1

type ClaudeCodeSettingsSnapshot struct {
	Exists      bool
	Env         map[string]string
	DefaultMode string
	StatusLine  bool
}

ClaudeCodeSettingsSnapshot is the relevant subset of a Claude Code settings file. Env may contain keys outside the typed preference surface; callers that expose data through the API must convert it with ClaudeCodePrefsFromEnv.

func ReadMainClaudeCodeSettings added in v0.260723.1

func ReadMainClaudeCodeSettings() (ClaudeCodeSettingsSnapshot, error)

ReadMainClaudeCodeSettings reads the user's source-of-truth settings file.

type RestoreAgentRequest added in v0.260507.1

type RestoreAgentRequest = aiagent.RestoreAgentRequest

RestoreAgentRequest represents a request to restore agent configuration

type RestoreAgentResult added in v0.260507.1

type RestoreAgentResult = aiagent.RestoreAgentResult

RestoreAgentResult represents the result of restoring agent configuration

Jump to

Keyboard shortcuts

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