feat: 添加飞书用户模块和订阅功能支持

- 新增feishu_users模块用于处理飞书用户身份验证和权限管理
- 新增subscriptions模块用于处理订阅相关功能
- 新增personalization模块用于个性化服务
- 在alembic迁移配置中注册新的模型模块
- 在API路由器中添加feishu_users和subscriptions路由
- 实现事件调度服务的改进,包括错误处理和状态更新优化
- 添加飞书命令处理的权限检查机制
- 实现飞书应用票据事件处理
- 改进审计日志记录功能
```
This commit is contained in:
2026-07-27 08:02:17 +08:00
parent db751f03b4
commit d7db84571d
148 changed files with 17110 additions and 765 deletions

View File

@@ -60,6 +60,14 @@ class AIContextKey(StrEnum):
REQUEST_CONTEXT = "request_context"
ASSISTANT_ANSWER = "assistant_answer"
USER_RULES = "user_rules"
COMPANY_RULES = "company_rules"
PERSONAL_RULES = "personal_rules"
PREFERENCES = "preferences"
INTERESTS = "interests"
CONVERSATION_HISTORY = "conversation_history"
PROVIDER_SESSION_ID = "provider_session_id"
ALLOW_PROVIDER_MEMORY = "allow_provider_memory"
EXECUTION_MODE = "execution_mode"
class AIMemoryMode(StrEnum):
@@ -67,6 +75,14 @@ class AIMemoryMode(StrEnum):
WRITE = "memory_write"
class AIExecutionMode(StrEnum):
INTERNAL = "internal"
PERSONALIZED = "personalized"
PREFERENCE_EXTRACTION = "preference_extraction"
SCHEDULED_PRIVATE = "scheduled_private"
SCHEDULED_GROUP = "scheduled_group"
class AIHttpPath(StrEnum):
CHAT_COMPLETIONS = "/chat/completions"
HEALTH = "/health"
@@ -95,13 +111,6 @@ class AIHttpPayloadKey(StrEnum):
MESSAGE = "message"
class AIToolAuditKey(StrEnum):
TOOL = "tool"
ACTION = "action"
ARGS = "args"
SESSION_KEY = "session_key"
class AIChatRole(StrEnum):
SYSTEM = "system"
USER = "user"
@@ -133,16 +142,25 @@ CHAT_USER_CONTENT_TEMPLATE = "Context:\n{context}\n\nTask:\n{task}"
AUTHORIZATION_BEARER_TEMPLATE = "Bearer {token}"
NOOP_PROVIDER_ANSWER = (
"AI provider is not configured yet. This is a deterministic placeholder. "
"Set MODEL_PROVIDER to openclaw_hermes, openclaw, hermes, or direct_llm "
"after credentials are ready."
"Set MODEL_PROVIDER to openclaw_hermes, hermes, or direct_llm after "
"credentials are ready."
)
AI_UNAVAILABLE_ANSWER = "AI 当前不可用,请稍后重试。"
PREFERENCE_EXTRACTION_INSTRUCTIONS = (
"Extract only durable user communication preferences from the supplied user text. "
"Allowed categories are language, tone, detail, topic, and interest. "
"Return strict JSON only in this shape: "
'{"preferences":[{"category":"language","value":"中文"}]}. '
"Return an empty preferences list when there is no durable preference. "
"Never return secrets, credentials, health, religion, politics, sexual orientation, "
"performance, compensation, or confidential financial information."
)
OPENCLAW_TOOL_COMPLETED_ANSWER = "OpenClaw tool invocation completed."
DIRECT_LLM_API_KEY_MISSING = "DIRECT_LLM_API_KEY is not configured"
UNEXPECTED_HERMES_RESPONSE = "Unexpected chat completion response"
OPENCLAW_CHAT_PROVIDER_REQUIRED = (
"OpenClaw Gateway is not configured as a chat provider. "
"Provide context.openclaw_tool for /tools/invoke, or use "
"MODEL_PROVIDER=hermes/openclaw_hermes for AI answers."
"OpenClaw Gateway is not exposed as a tool-execution provider. "
"Use MODEL_PROVIDER=hermes, openclaw_hermes, or direct_llm for AI answers."
)
OPENCLAW_TOOL_NOT_ALLOWED = "OpenClaw tool is not allowed"
OPENCLAW_ACTION_NOT_ALLOWED = "OpenClaw action is not allowed"