Documentation
¶
Overview ¶
Package config loads WeKnora runtime configuration.
Index ¶
- Constants
- func ConfigDir() string
- func DocumentProcessTimeout(cfg *Config) time.Duration
- func ValidateConfig(cfg *Config) error
- type AgentConfig
- type AuditConfig
- type AuthConfig
- type Config
- type ConversationConfig
- type DocReaderConfig
- type ExtractManagerConfig
- type FebriText
- type IMConfig
- type ImageProcessingConfig
- type KnowledgeBaseConfig
- type ModelConfig
- type OIDCAuthConfig
- type OIDCUserInfoMapping
- type PromptTemplate
- func DefaultTemplate(templates []PromptTemplate) *PromptTemplate
- func DefaultTemplateByMode(templates []PromptTemplate, mode string) *PromptTemplate
- func FindTemplateByID(pt *PromptTemplatesConfig, id string) *PromptTemplate
- func LocalizeTemplates(templates []PromptTemplate, locale string) []PromptTemplate
- type PromptTemplateI18n
- type PromptTemplatesConfig
- type RedisConfig
- type ServerConfig
- type StreamManagerConfig
- type SummaryConfig
- type TenantConfig
- type VectorDatabaseConfig
- type WebSearchConfig
Constants ¶
const ( DefaultPromptHotWait = 120 * time.Second DefaultPromptExpire = 7 * 24 * time.Hour )
Defaults for suspendable agent prompts.
const ( AuthRegistrationModeSelfServe = "self_serve" AuthRegistrationModeInviteOnly = "invite_only" AuthRegistrationModeInviteRegister = "invite_register" AuthDefaultTenantModeCreatePersonal = "create_personal" AuthDefaultTenantModeTenantless = "tenantless" )
AuthRegistrationMode constants used by handlers and middleware.
const DefaultDocumentProcessTimeout = 2 * time.Hour
DefaultDocumentProcessTimeout is the ceiling for a single document:process Asynq task when document_process_timeout is unset or non-positive.
Variables ¶
This section is empty.
Functions ¶
func ConfigDir ¶
func ConfigDir() string
ConfigDir returns the directory containing the loaded config.yaml. Other startup code (e.g. builtin model loader) uses this to locate sibling config files like builtin_models.yaml without re-implementing viper search rules. Falls back to "./config" when LoadConfig has not been called yet.
func DocumentProcessTimeout ¶
DocumentProcessTimeout returns the effective document-process task timeout. Partial configs (e.g. unit tests) receive the default when unset.
func ValidateConfig ¶
ValidateConfig performs basic validation of the loaded configuration. It checks for obviously invalid or missing values that would cause runtime failures.
Types ¶
type AgentConfig ¶
type AgentConfig struct {
// LLMCallTimeout is the default timeout for a single LLM call in seconds.
// Default: 120 (standard agents) or 300 (can be overridden by Env).
LLMCallTimeout int `yaml:"llm_call_timeout" json:"llm_call_timeout"`
// ToolApprovalTimeoutSeconds is how long the agent waits for human approval on a flagged MCP tool.
// 0 means default 600 (10 minutes).
ToolApprovalTimeoutSeconds int `yaml:"tool_approval_timeout_seconds" json:"tool_approval_timeout_seconds"`
// PromptSuspendEnabled lets a run that waits on a suspendable prompt (tool
// approval) end after PromptHotWaitSeconds and persist its state instead of
// blocking up to ToolApprovalTimeoutSeconds. Unset means enabled.
PromptSuspendEnabled *bool `yaml:"prompt_suspend_enabled" json:"prompt_suspend_enabled"`
// PromptHotWaitSeconds is how long a suspendable prompt waits in memory
// before the run is suspended. 0 means default 120.
PromptHotWaitSeconds int `yaml:"prompt_hot_wait_seconds" json:"prompt_hot_wait_seconds"`
// PromptExpireSeconds is how long a suspended prompt stays answerable.
// 0 means default 604800 (7 days); a negative value never expires.
PromptExpireSeconds int `yaml:"prompt_expire_seconds" json:"prompt_expire_seconds"`
}
AgentConfig represents the global agent settings.
func (*AgentConfig) PromptExpiry ¶ added in v0.9.0
func (c *AgentConfig) PromptExpiry() time.Duration
PromptExpiry returns how long a suspended prompt stays answerable; zero means it never expires.
func (*AgentConfig) PromptHotWait ¶ added in v0.9.0
func (c *AgentConfig) PromptHotWait() time.Duration
PromptHotWait returns the in-memory wait before a run is suspended.
func (*AgentConfig) PromptSuspend ¶ added in v0.9.0
func (c *AgentConfig) PromptSuspend() bool
PromptSuspend reports whether suspendable prompts may suspend their run.
type AuditConfig ¶
type AuditConfig struct {
// RetentionDays is how many days of audit history to keep. Older
// rows are deleted by a daily background sweep.
// > 0 — purge rows whose created_at < NOW() - retention_days.
// = 0 — disable purge entirely (the pre-rollout default).
// < 0 — invalid; ValidateConfig rejects it.
// Default: 90 (set by applyAuditDefaults when the section is omitted).
RetentionDays int `yaml:"retention_days" json:"retention_days"`
}
AuditConfig governs durable audit log behaviour. Writes happen on every member-management mutation and on RBAC denials (when EnableRBAC is true); the table grows monotonically unless this section turns on retention.
type AuthConfig ¶
type AuthConfig struct {
// RegistrationMode controls public and invitation password registration.
// "self_serve" (default) — anyone may register; a new tenant is
// auto-created and the registrant becomes
// its Owner. Preserves existing behaviour.
// "invite_register" — new users need a valid invitation link.
// "invite_only" — no password registration; invitations can
// only be accepted by existing accounts.
// Kept as the legacy disabled mode.
RegistrationMode string `yaml:"registration_mode" json:"registration_mode"`
// DefaultTenantMode controls public password-registration provisioning.
// create_personal preserves the historical one-user-one-workspace default;
// tenantless creates only the identity and waits for an invitation or an
// explicit self-service tenant creation.
DefaultTenantMode string `yaml:"default_tenant_mode" json:"default_tenant_mode"`
ComplexPasswordEnabled bool `yaml:"complex_password_enabled" json:"complex_password_enabled"`
}
AuthConfig governs the user authentication entry points.
func (*AuthConfig) IsInviteOnly ¶
func (c *AuthConfig) IsInviteOnly() bool
IsInviteOnly identifies the legacy disabled-registration mode. It does not identify the invite_register mode, which permits new accounts.
type Config ¶
type Config struct {
Conversation *ConversationConfig `yaml:"conversation" json:"conversation"`
Server *ServerConfig `yaml:"server" json:"server"`
KnowledgeBase *KnowledgeBaseConfig `yaml:"knowledge_base" json:"knowledge_base"`
Tenant *TenantConfig `yaml:"tenant" json:"tenant"`
Auth *AuthConfig `yaml:"auth" json:"auth"`
Audit *AuditConfig `yaml:"audit" json:"audit"`
OIDCAuth *OIDCAuthConfig `yaml:"oidc_auth" json:"oidc_auth"`
Models []ModelConfig `yaml:"models" json:"models"`
VectorDatabase *VectorDatabaseConfig `yaml:"vector_database" json:"vector_database"`
DocReader *DocReaderConfig `yaml:"docreader" json:"docreader"`
StreamManager *StreamManagerConfig `yaml:"stream_manager" json:"stream_manager"`
ExtractManager *ExtractManagerConfig `yaml:"extract" json:"extract"`
WebSearch *WebSearchConfig `yaml:"web_search" json:"web_search"`
PromptTemplates *PromptTemplatesConfig `yaml:"prompt_templates" json:"prompt_templates"`
IM *IMConfig `yaml:"im" json:"im"`
Agent *AgentConfig `yaml:"agent" json:"agent"`
// FrontendBaseURL is the externally-visible origin of the SPA, used
// to compose absolute share-link URLs. Empty falls back to a host-
// relative URL ("/register?token=…") which the SPA then resolves
// against window.location.origin — fine for typical single-origin
// deployments. Sourced from FRONTEND_BASE_URL env at startup.
FrontendBaseURL string `yaml:"frontend_base_url" json:"frontend_base_url"`
}
Config 应用程序总配置
func (*Config) ResolveCustomAgentPrompts ¶
func (c *Config) ResolveCustomAgentPrompts(agent *types.CustomAgent) (system, context string)
ResolveCustomAgentPrompts resolves inherited references at request time. Explicit text always wins, including legacy saved prompts; never rewrite user content. References are scoped to their field/mode so a context template cannot become system instructions just because it has a matching ID.
type ConversationConfig ¶
type ConversationConfig struct {
MaxRounds int `yaml:"max_rounds" json:"max_rounds"`
KeywordThreshold float64 `yaml:"keyword_threshold" json:"keyword_threshold"`
EmbeddingTopK int `yaml:"embedding_top_k" json:"embedding_top_k"`
VectorThreshold float64 `yaml:"vector_threshold" json:"vector_threshold"`
RerankTopK int `yaml:"rerank_top_k" json:"rerank_top_k"`
RerankThreshold float64 `yaml:"rerank_threshold" json:"rerank_threshold"`
FallbackStrategy string `yaml:"fallback_strategy" json:"fallback_strategy"`
FallbackResponse string `yaml:"fallback_response" json:"fallback_response"`
EnableRewrite bool `yaml:"enable_rewrite" json:"enable_rewrite"`
EnableQueryExpansion bool `yaml:"enable_query_expansion" json:"enable_query_expansion"`
EnableRerank bool `yaml:"enable_rerank" json:"enable_rerank"`
Summary *SummaryConfig `yaml:"summary" json:"summary"`
// Prompt template ID fields — resolved to text by backfillConversationDefaults
FallbackPromptID string `yaml:"fallback_prompt_id" json:"fallback_prompt_id"`
RewritePromptID string `yaml:"rewrite_prompt_id" json:"rewrite_prompt_id"`
GenerateSessionTitlePromptID string `yaml:"generate_session_title_prompt_id" json:"generate_session_title_prompt_id"`
GenerateSummaryPromptID string `yaml:"generate_summary_prompt_id" json:"generate_summary_prompt_id"`
ExtractEntitiesPromptID string `yaml:"extract_entities_prompt_id" json:"extract_entities_prompt_id"`
ExtractRelationshipsPromptID string `yaml:"extract_relationships_prompt_id" json:"extract_relationships_prompt_id"`
GenerateQuestionsPromptID string `yaml:"generate_questions_prompt_id" json:"generate_questions_prompt_id"`
// GenerateKBDescriptionPromptID selects the knowledge-base description template.
GenerateKBDescriptionPromptID string `yaml:"generate_kb_description_prompt_id" json:"generate_kb_description_prompt_id"` //nolint:lll // one-line struct tag
// Resolved prompt text fields (populated by backfill, not from YAML)
FallbackPrompt string `yaml:"-" json:"fallback_prompt"`
RewritePromptSystem string `yaml:"-" json:"rewrite_prompt_system"`
RewritePromptUser string `yaml:"-" json:"rewrite_prompt_user"`
GenerateSessionTitlePrompt string `yaml:"-" json:"generate_session_title_prompt"`
GenerateSummaryPrompt string `yaml:"-" json:"generate_summary_prompt"`
ExtractEntitiesPrompt string `yaml:"-" json:"extract_entities_prompt"`
ExtractRelationshipsPrompt string `yaml:"-" json:"extract_relationships_prompt"`
GenerateQuestionsPrompt string `yaml:"-" json:"generate_questions_prompt"`
// GenerateKBDescriptionPrompt is the resolved knowledge-base description template text.
GenerateKBDescriptionPrompt string `yaml:"-" json:"generate_kb_description_prompt"`
// IntentSystemPrompts maps intent values (e.g. "greeting", "chitchat") to
// system prompt text. Populated by backfill from IntentPrompts templates.
IntentSystemPrompts map[string]string `yaml:"-" json:"-"`
}
ConversationConfig 对话服务配置
type DocReaderConfig ¶
type DocReaderConfig struct {
// Addr: for gRPC it is the server address (e.g. "localhost:50051"); for HTTP it is the base URL (e.g. "http://localhost:8080").
Addr string `yaml:"addr" json:"addr"`
// Transport: "grpc" (default) or "http"
Transport string `yaml:"transport" json:"transport"`
}
DocReaderConfig configures the document parser client (gRPC or HTTP).
type ExtractManagerConfig ¶
type ExtractManagerConfig struct {
ExtractGraph *types.PromptTemplateStructured `yaml:"extract_graph" json:"extract_graph"`
ExtractEntity *types.PromptTemplateStructured `yaml:"extract_entity" json:"extract_entity"`
FabriText *FebriText `yaml:"fabri_text" json:"fabri_text"`
}
ExtractManagerConfig 抽取管理器配置
type IMConfig ¶
type IMConfig struct {
// Workers is the number of concurrent QA worker goroutines per instance.
// Default: 5.
Workers int `yaml:"workers" json:"workers"`
// GlobalMaxWorkers is the maximum number of QA requests that can execute
// concurrently across ALL instances. Enforced via a Redis counter; when the
// global limit is reached, local workers wait until a slot opens.
// Requires Redis — ignored in single-instance mode.
// 0 (default) means no global limit.
GlobalMaxWorkers int `yaml:"global_max_workers" json:"global_max_workers"`
// MaxQueueSize is the maximum number of pending QA requests per instance.
// Default: 50.
MaxQueueSize int `yaml:"max_queue_size" json:"max_queue_size"`
// MaxPerUser limits how many requests a single user can have queued globally.
// Default: 3.
MaxPerUser int `yaml:"max_per_user" json:"max_per_user"`
// RateLimitWindow is the sliding window duration for per-user rate limiting.
// Default: 60s.
RateLimitWindow time.Duration `yaml:"rate_limit_window" json:"rate_limit_window"`
// RateLimitMax is the maximum number of requests allowed per window per user.
// Default: 10.
RateLimitMax int `yaml:"rate_limit_max" json:"rate_limit_max"`
}
IMConfig configures the IM integration service. All fields are optional — zero values fall back to built-in defaults so existing deployments need no config changes.
type ImageProcessingConfig ¶
type ImageProcessingConfig struct {
EnableMultimodal bool `yaml:"enable_multimodal" json:"enable_multimodal"`
}
ImageProcessingConfig 图像处理配置
type KnowledgeBaseConfig ¶
type KnowledgeBaseConfig struct {
ChunkSize int `yaml:"chunk_size" json:"chunk_size"`
ChunkOverlap int `yaml:"chunk_overlap" json:"chunk_overlap"`
SplitMarkers []string `yaml:"split_markers" json:"split_markers"`
KeepSeparator bool `yaml:"keep_separator" json:"keep_separator"`
ImageProcessing *ImageProcessingConfig `yaml:"image_processing" json:"image_processing"`
DocumentProcessTimeout time.Duration `yaml:"document_process_timeout" json:"document_process_timeout"`
// DocReaderCallTimeout caps a single DocReader RPC. Without this the
// gRPC call inherits the asynq task context (whole DocumentProcessTimeout,
// default 2h+), so a hung docreader would block a worker for hours and
// leave knowledge in "processing". Default 30 minutes is generous enough
// for OCR-heavy large PDFs while ensuring forward progress.
DocReaderCallTimeout time.Duration `yaml:"docreader_call_timeout" json:"docreader_call_timeout"`
}
KnowledgeBaseConfig 知识库配置
type ModelConfig ¶
type ModelConfig struct {
Type string `yaml:"type" json:"type"`
Source string `yaml:"source" json:"source"`
ModelName string `yaml:"model_name" json:"model_name"`
Parameters map[string]interface{} `yaml:"parameters" json:"parameters"`
}
ModelConfig 模型配置
type OIDCAuthConfig ¶
type OIDCAuthConfig struct {
Enable bool `yaml:"enable" json:"enable"`
IssuerURL string `yaml:"issuer_url" json:"issuer_url"`
DiscoveryURL string `yaml:"discovery_url" json:"discovery_url"`
ProviderDisplayName string `yaml:"provider_display_name" json:"provider_display_name"`
ClientID string `yaml:"client_id" json:"client_id"`
ClientSecret string `yaml:"client_secret" json:"-"`
AuthorizationEndpoint string `yaml:"authorization_endpoint" json:"authorization_endpoint"`
TokenEndpoint string `yaml:"token_endpoint" json:"token_endpoint"`
UserInfoEndpoint string `yaml:"user_info_endpoint" json:"user_info_endpoint"`
JwksURI string `yaml:"jwks_uri" json:"jwks_uri"`
Scopes []string `yaml:"scopes" json:"scopes"`
UserInfoMapping *OIDCUserInfoMapping `yaml:"user_info_mapping" json:"user_info_mapping"`
}
type OIDCUserInfoMapping ¶
type PromptTemplate ¶
type PromptTemplate struct {
ID string `yaml:"id" json:"id"`
Name string `yaml:"name" json:"name"`
Description string `yaml:"description" json:"description"`
Content string `yaml:"content" json:"content"`
User string `yaml:"user" json:"user,omitempty"`
HasKnowledgeBase bool `yaml:"has_knowledge_base" json:"has_knowledge_base,omitempty"`
HasWebSearch bool `yaml:"has_web_search" json:"has_web_search,omitempty"`
Default bool `yaml:"default" json:"default,omitempty"`
Mode string `yaml:"mode" json:"mode,omitempty"`
I18n map[string]PromptTemplateI18n `yaml:"i18n" json:"-"`
}
PromptTemplate 提示词模板
字段设计:每个模板最多由两部分组成 —— 系统侧 (content) 和用户侧 (user)。
- content: 主要内容 / 系统 Prompt(所有模板都使用此字段)
- user: 用户侧 Prompt(仅在需要 system+user 配对的模板中使用,如 rewrite、keywords_extraction)
- i18n: 多语言 name/description,键为 locale(如 "zh-CN"、"en-US"、"ko-KR"),后端根据请求语言替换 Name/Description 再返回
func DefaultTemplate ¶
func DefaultTemplate(templates []PromptTemplate) *PromptTemplate
DefaultTemplate returns the first template marked as default in the list, or the first template if none is marked, or nil if the list is empty.
func DefaultTemplateByMode ¶
func DefaultTemplateByMode(templates []PromptTemplate, mode string) *PromptTemplate
DefaultTemplateByMode returns the default template filtered by mode.
func FindTemplateByID ¶
func FindTemplateByID(pt *PromptTemplatesConfig, id string) *PromptTemplate
FindTemplateByID searches across all template lists for a template with the given ID. It returns the template if found, or nil otherwise.
func LocalizeTemplates ¶
func LocalizeTemplates(templates []PromptTemplate, locale string) []PromptTemplate
LocalizeTemplates returns a deep copy of the template list with Name and Description replaced according to the given locale. Fallback chain:
locale → primary language (e.g. "zh" from "zh-CN") → original Name/Description.
The returned slice is safe to serialise directly; it never mutates the original.
type PromptTemplateI18n ¶
type PromptTemplateI18n struct {
Name string `yaml:"name" json:"name"`
Description string `yaml:"description" json:"description"`
}
PromptTemplateI18n holds localized name and description for a prompt template.
type PromptTemplatesConfig ¶
type PromptTemplatesConfig struct {
SystemPrompt []PromptTemplate `yaml:"system_prompt" json:"system_prompt"`
ContextTemplate []PromptTemplate `yaml:"context_template" json:"context_template"`
// Rewrite 合并了前端可选模板和运行时默认模板,每个模板同时包含 content + user
Rewrite []PromptTemplate `yaml:"rewrite" json:"rewrite"`
// Fallback 合并了固定回复模板和模型兜底 prompt(通过 mode:"model" 区分)
Fallback []PromptTemplate `yaml:"fallback" json:"fallback"`
GenerateSessionTitle []PromptTemplate `yaml:"generate_session_title" json:"generate_session_title,omitempty"`
GenerateSummary []PromptTemplate `yaml:"generate_summary" json:"generate_summary,omitempty"`
// GenerateKBDescription writes the knowledge-base gist from the document profile aggregate.
GenerateKBDescription []PromptTemplate `yaml:"generate_kb_description" json:"generate_kb_description,omitempty"` //nolint:lll // one-line struct tag
KeywordsExtraction []PromptTemplate `yaml:"keywords_extraction" json:"keywords_extraction,omitempty"`
AgentSystemPrompt []PromptTemplate `yaml:"agent_system_prompt" json:"agent_system_prompt,omitempty"`
GraphExtraction []PromptTemplate `yaml:"graph_extraction" json:"graph_extraction,omitempty"`
GenerateQuestions []PromptTemplate `yaml:"generate_questions" json:"generate_questions,omitempty"`
// IntentPrompts holds per-intent system prompt overrides (template ID = intent value).
IntentPrompts []PromptTemplate `yaml:"intent_prompts" json:"intent_prompts,omitempty"`
}
PromptTemplatesConfig 提示词模板配置
每种 Prompt 类型对应一个 YAML 文件,所有模板都在同一个字段(文件)中管理。 每个模板使用 content (system prompt) + user (user prompt) 两个字段。
type RedisConfig ¶
type RedisConfig struct {
Address string `yaml:"address" json:"address"` // Redis地址
Username string `yaml:"username" json:"username"` // Redis用户名
Password string `yaml:"password" json:"password"` // Redis密码
DB int `yaml:"db" json:"db"` // Redis数据库
Prefix string `yaml:"prefix" json:"prefix"` // 键前缀
TTL time.Duration `yaml:"ttl" json:"ttl"` // 过期时间(小时)
}
RedisConfig Redis配置
type ServerConfig ¶
type ServerConfig struct {
Port int `yaml:"port" json:"port"`
Host string `yaml:"host" json:"host"`
LogPath string `yaml:"log_path" json:"log_path"`
ShutdownTimeout time.Duration `yaml:"shutdown_timeout" json:"shutdown_timeout" default:"30s"`
}
ServerConfig 服务器配置
type StreamManagerConfig ¶
type StreamManagerConfig struct {
Type string `yaml:"type" json:"type"` // 类型: "memory" 或 "redis"
Redis RedisConfig `yaml:"redis" json:"redis"` // Redis配置
CleanupTimeout time.Duration `yaml:"cleanup_timeout" json:"cleanup_timeout"` // 清理超时,单位秒
}
StreamManagerConfig 流管理器配置
type SummaryConfig ¶
type SummaryConfig struct {
MaxInputChars int `yaml:"max_input_chars" json:"max_input_chars"` // Max input characters for summary generation (default: 16384)
MaxTokens int `yaml:"max_tokens" json:"max_tokens"`
RepeatPenalty float64 `yaml:"repeat_penalty" json:"repeat_penalty"`
TopK int `yaml:"top_k" json:"top_k"`
TopP float64 `yaml:"top_p" json:"top_p"`
FrequencyPenalty float64 `yaml:"frequency_penalty" json:"frequency_penalty"`
PresencePenalty float64 `yaml:"presence_penalty" json:"presence_penalty"`
Temperature float64 `yaml:"temperature" json:"temperature"`
Seed int `yaml:"seed" json:"seed"`
MaxCompletionTokens int `yaml:"max_completion_tokens" json:"max_completion_tokens"`
NoMatchPrefix string `yaml:"no_match_prefix" json:"no_match_prefix"`
Thinking *bool `yaml:"thinking" json:"thinking"`
// Prompt template ID fields — resolved to text by backfillConversationDefaults
PromptID string `yaml:"prompt_id" json:"prompt_id"`
ContextTemplateID string `yaml:"context_template_id" json:"context_template_id"`
// Resolved prompt text fields (populated by backfill, not from YAML)
Prompt string `yaml:"-" json:"prompt"`
ContextTemplate string `yaml:"-" json:"context_template"`
}
SummaryConfig 摘要配置
type TenantConfig ¶
type TenantConfig struct {
DefaultSessionName string `yaml:"default_session_name" json:"default_session_name"`
DefaultSessionTitle string `yaml:"default_session_title" json:"default_session_title"`
DefaultSessionDescription string `yaml:"default_session_description" json:"default_session_description"`
// EnableCrossTenantAccess enables cross-tenant access for users with permission
EnableCrossTenantAccess bool `yaml:"enable_cross_tenant_access" json:"enable_cross_tenant_access"`
// EnableRBAC turns on tenant-level role enforcement (issue #1303).
// Pointer so we can distinguish "unset" from "explicit false":
// nil — fall back to the built-in default (true) applied
// by applyAuthAndTenantDefaults.
// pointer false — operators opted into the logging-only rollout
// window (set via config.yaml `enable_rbac: false`
// or env `WEKNORA_TENANT_ENABLE_RBAC=false`).
// pointer true — enforcement on (the new default).
// Read through IsRBACEnforced so callers stay nil-safe.
EnableRBAC *bool `yaml:"enable_rbac" json:"enable_rbac"`
// MaxOwnedPerUser caps how many tenants a single non-superuser can
// create (and Own) via self-service POST /tenants. Counts only Owner
// memberships so being invited as Admin/Editor/Viewer in another
// tenant doesn't burn quota. Cross-tenant superusers
// (CanAccessAllTenants) are exempt.
// > 0 — enforce the cap (handler returns 429 when reached).
// = 0 — fall back to defaultMaxOwnedTenantsPerUser in the handler.
// < 0 — disable the cap entirely (not recommended in shared deployments).
//
// Env override: WEKNORA_TENANT_MAX_OWNED_PER_USER (integer). When set
// and parseable it always wins over config.yaml so operators can
// loosen / tighten the quota without a redeploy. See
// applyAuthAndTenantDefaults for the semantics of <0 / 0 / >0.
MaxOwnedPerUser int `yaml:"max_owned_per_user" json:"max_owned_per_user" mapstructure:"max_owned_per_user"`
// SelfServiceCreationEnabled controls whether ordinary authenticated
// users may create a workspace for themselves. Nil preserves the
// historical default (enabled); cross-tenant superusers are exempt.
SelfServiceCreationEnabled *bool `yaml:"self_service_creation_enabled" json:"self_service_creation_enabled" mapstructure:"self_service_creation_enabled"`
}
TenantConfig 空间配置
func (*TenantConfig) IsRBACEnforced ¶
func (t *TenantConfig) IsRBACEnforced() bool
IsRBACEnforced reports whether tenant-level role enforcement is active. Nil receiver or nil EnableRBAC pointer means "operator did not opt out", which after applyAuthAndTenantDefaults is the new default (true). Callers that need to treat a nil *Config as fail-open (legacy behaviour) should keep their own `cfg != nil` short-circuit before invoking this helper.
func (*TenantConfig) IsSelfServiceCreationEnabled ¶
func (t *TenantConfig) IsSelfServiceCreationEnabled() bool
IsSelfServiceCreationEnabled reports whether ordinary users may create tenants. Nil keeps the historical behaviour enabled.
type VectorDatabaseConfig ¶
type VectorDatabaseConfig struct {
Driver string `yaml:"driver" json:"driver"`
}
type WebSearchConfig ¶
type WebSearchConfig struct {
Timeout int `yaml:"timeout" json:"timeout"` // 超时时间(秒)
}
WebSearchConfig represents the web search configuration