Documentation
¶
Index ¶
- Constants
- Variables
- func BuildCCProfileSettings(profileID, scenarioPath string, env map[string]string) (string, error)
- func BuildClaudeCodeModelConfig(unified bool) aiagent.ClaudeCodeModelConfig
- func BuildOpenCodeConfig(configBaseURL, apiKey string, models map[string]interface{}) map[string]interface{}
- func CollectCodexModels(rules []string) []string
- func GenerateCCEnv(cfg *serverconfig.Config, baseURL, apiKey, scenarioPath string, ...) map[string]string
- type AgentApply
- type AgentInfo
- type AgentType
- type ApplyAgentRequest
- type ApplyAgentResult
- type ClaudeCodePrefs
- type RestoreAgentRequest
- type RestoreAgentResult
Constants ¶
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
Variables ¶
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
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
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.
var OpenCodeRequestModels = []string{
"tingly-opencode",
}
OpenCodeRequestModels defines all request models for OpenCode scenario
Functions ¶
func BuildCCProfileSettings ¶ added in v0.260625.1
BuildCCProfileSettings creates or updates the Claude Code profile settings file at ~/.tingly-box/claude/<profileID>.json. It copies ~/.claude/settings.json as a base (if it exists), installs the shared status line script, generates a per-profile wrapper script, and merges the tingly env vars. Returns the path to the written file.
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 CollectCodexModels ¶ added in v0.260514.1
CollectCodexModels deduplicates and preserves order of model names. This helper processes routing rules to extract unique model names.
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.
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 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 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 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.
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