Documentation
¶
Index ¶
Constants ¶
const ( // Default authentication tokens DefaultUserToken = "tingly-box-user-token" DefaultModelToken = "tingly-box-model-token" // Default mode name DefaultModeName = "tingly" )
const ( LogDirName = "log" // DefaultRequestTimeout is the default timeout for HTTP requests in seconds DefaultRequestTimeout = 1800 // DefaultMaxTimeout in seconds DefaultMaxTimeout = 30 * 60 // ModelFetchTimeout is the timeout for fetching models from provider API in seconds ModelFetchTimeout = 30 // DefaultMaxTokens is the default max_tokens value for API requests DefaultMaxTokens = 8192 )
const ( DefaultMinSpeedSamples = 5 // Minimum samples required before making speed-based decisions DefaultSpeedThresholdTps = 50.0 // Minimum acceptable tokens per second DefaultSpeedSampleWindow = 100 // Default number of speed samples to keep )
Token speed-based routing defaults
const ( DefaultTTFTThresholdMs = int64(500) // Default TTFT threshold in milliseconds DefaultTTFTSampleWindow = 100 // Default number of TTFT samples to keep DefaultTTFTPercentile = 0.95 // Default percentile for TTFT comparison (0.95 = p95) DefaultTTFTComparisonMode = "p95" // Default comparison mode: "avg", "p50", "p95", "p99" )
TTFT (Time To First Token) based routing defaults
const ( DefaultMinCacheHitRate = 0.3 // Minimum acceptable cache hit rate (30%) DefaultMinCacheSamples = 10 // Minimum samples before using cache data )
Cache-aware routing defaults
const ( DefaultMaxCostTokens = int64(50000) // Default max token cost per window DefaultCostWindowSize = 3600 // Default cost window in seconds (1 hour) )
Cost-optimized routing defaults
const ( FlagUnified = "unified" FlagSeparate = "separate" FlagSmart = "smart" FlagSkipUsage = "skip_usage" )
ScenarioFlags bool field keys. These are the canonical string keys used when reading or writing typed ScenarioFlags fields through the GetScenarioFlag / SetScenarioFlag string-keyed API (e.g. the HTTP endpoint).
const ( FlagThinkingEffort = "thinking_effort" FlagRecordingV2 = "recording_v2" FlagCustomUserAgent = "custom_user_agent" )
ScenarioFlags string field keys. Same contract as above but for GetScenarioStringFlag / SetScenarioStringFlag.
const ( ExtensionVisionProxyService = "vision_proxy_service" ExtensionGuardrails = "guardrails" ExtensionMCP = "mcp" ExtensionSkillIDE = "skill_ide" ExtensionBench = "bench" ExtensionProjects = "projects" )
ScenarioConfig.Extensions keys. These are the canonical string keys used when reading or writing feature toggles stored in the Extensions map (as opposed to typed ScenarioFlags fields).
const ( // Authentication metadata. CtxKeyAuthKind = "auth_kind" // string (see AuthKind* constants) CtxKeyUserID = "user_id" // string CtxKeyTeamID = "team_id" // string (authorized team identity) CtxKeyEnterpriseUserID = "enterprise_user_id" // string CtxKeyEnterpriseDepartmentID = "enterprise_department_id" // string CtxKeyEnterpriseKeyPrefix = "enterprise_key_prefix" // string CtxKeyEnterpriseUserTier = "enterprise_user_tier" // string CtxKeyEnterpriseContextJTI = "enterprise_context_jti" // string CtxKeyEnterpriseContextVerified = "enterprise_context_verified" // bool CtxKeyRemoteClientID = "client_id" // string CtxKeyRemoteClaims = "claims" // *auth.Claims CtxKeyRequestID = "request_id" // string CtxKeyRecoveredErrorCount = "recovered_error_count" // int: errors from attempts superseded by a successful failover // Request tracking metadata. CtxKeyRule = "tracking_rule" // *typ.Rule CtxKeyProvider = "tracking_provider" // *typ.Provider CtxKeyModel = "tracking_model" // string (actual model used) CtxKeyRequestModel = "tracking_request_model" // string (model requested by user) CtxKeyScenario = "tracking_scenario" // string (extracted from request path) CtxKeyStreamed = "tracking_streamed" // bool CtxKeyStartTime = "tracking_start_time" // time.Time CtxKeyFirstTokenTime = "tracking_first_token_time" // time.Time (for TTFT calculation) CtxKeyCacheHit = "tracking_cache_hit" // bool (cache hit status) CtxKeySessionID = "tracking_session_id" // string (resolved session ID for affinity) CtxKeyAffinityKey = "tracking_affinity_key" // string (scoped affinity store key: session + matched smart partition) CtxKeyLBServiceID = "tracking_lb_service_id" // string (selected upstream, e.g. "provider-uuid:model") CtxKeyLBTactic = "tracking_lb_tactic" // string (tactic name, e.g. "random") CtxKeyTraceID = "tracking_trace_id" // string (OTel trace id, set only when the request span is sampled) // CtxKeyOperation is the gen_ai.operation.name for the endpoint, declared // once where the route is registered so the metrics and trace pipelines // report the same operation instead of each deriving its own. Unset means // the default, "chat". CtxKeyOperation = "tracking_operation" // string // Protocol recording metadata. CtxKeyProtocolRecorder = "protocol_recorder" // *recording.ProtocolRecorder // Guardrail runtime metadata. CtxKeyCredentialMaskState = "guardrails_credential_mask_state" // *guardrails/core.CredentialMaskState )
Gin context key constants for per-request metadata. Defined here so that server/, routing/, middleware/, and protocol/ sub-packages can share the writer/reader contract without import cycles or duplicated string literals.
const ( AuthKindGlobalModelToken = "global_model_token" AuthKindSharingKey = "sharing_key" )
Authentication principal kinds recorded in CtxKeyAuthKind. Keep these separate from user_id: user_id identifies who generated usage, while the principal kind determines which model surfaces that identity may access.
const ConfigDirName = ".tingly-box"
const DBDirName = "db"
const DBFileName = "tingly.db" // Unified SQLite database file
const DefaultServerPort = 12580
DefaultServerPort is the port the server listens on unless --port says otherwise. It is not persisted in config.json, so a CLI process can know the default without loading the configuration (see app.AppManager).
const ImageDirName = "image"
const MemoryDirName = "memory"
Variables ¶
var KnownExtensionBoolFlags = map[string]bool{ ExtensionGuardrails: true, ExtensionMCP: true, ExtensionSkillIDE: true, ExtensionBench: true, ExtensionProjects: true, }
KnownExtensionBoolFlags is the single source of truth for which Extensions-map keys are a settable/readable bool toggle through Config.GetScenarioFlag / Config.SetScenarioFlag's generic fallback (the default case for anything that isn't one of the typed ScenarioFlags fields above). Adding a new global on/off feature toggle (e.g. a new row in frontend/src/components/GlobalExperimentalFeatures.tsx) means adding one key here — the getter and setter both pick it up automatically, with no switch/case to remember to touch on the backend.
This existed as an asymmetry before: GetScenarioFlag already fell back to reading any key out of Extensions (defaulting to false when absent), but SetScenarioFlag required an explicit `case constant.ExtensionXxx:` for every key or it rejected the write with "unknown flag name" — so a flag could be read (silently false) but never turned on until someone remembered to add its case. That's what broke the bench flag on launch and had bitten skill_ide/guardrails/mcp before it (see TestProfileScenarioFlagWriteInheritsBaseConfig's history). This map closes that gap by making both directions read the same registry.
vision_proxy_service is deliberately excluded: it stores a structured object (provider/model selection), not a bool, and is read directly off ScenarioConfig.Extensions rather than through Get/SetScenarioFlag.
Functions ¶
func GetImageDir ¶ added in v0.260531.1
GetImageDir returns the generated-image persistence directory path
func GetMemoryDir ¶
GetMemoryDir returns the memory directory path
func GetTinglyConfDir ¶
func GetTinglyConfDir() string
GetTinglyConfDir returns the config directory path (default: ~/.tingly-box)
Types ¶
This section is empty.