Merge branch 'feature/moshui20260330-schedule-job' into bot_manager

This commit is contained in:
朱潮 2026-03-31 14:37:28 +08:00
commit 41b4329b5e
4 changed files with 11 additions and 5 deletions

View File

@ -166,12 +166,18 @@ async def _execute_command(skill_path: str, command: str, hook_type: str, config
try:
# 设置环境变量,传递给子进程
env = os.environ.copy()
env['BOT_ID'] = getattr(config, 'bot_id', '')
env['ASSISTANT_ID'] = getattr(config, 'bot_id', '')
env['USER_IDENTIFIER'] = getattr(config, 'user_identifier', '')
env['TRACE_ID'] = getattr(config, 'trace_id', '')
env['SESSION_ID'] = getattr(config, 'session_id', '')
env['LANGUAGE'] = getattr(config, 'language', '')
env['HOOK_TYPE'] = hook_type
# 合并 config 中的自定义 shell 环境变量
shell_env = getattr(config, 'shell_env', None)
if shell_env:
env.update(shell_env)
# 对于 PreSave传递 content
if hook_type == 'PreSave':
env['CONTENT'] = kwargs.get('content', '')

View File

@ -4,7 +4,7 @@
用于增删改查用户的定时任务数据存储在 tasks.yaml 文件中
环境变量:
BOT_ID: 当前 bot ID
ASSISTANT_ID: 当前 bot ID
USER_IDENTIFIER: 当前用户标识
"""

View File

@ -80,7 +80,7 @@ Hook 脚本通过子进程执行,通过环境变量接收参数,通过 stdou
| 环境变量 | 说明 | 适用于 |
|---------|------|--------|
| `BOT_ID` | Bot ID | 所有 hook |
| `ASSISTANT_ID` | Bot ID | 所有 hook |
| `USER_IDENTIFIER` | 用户标识 | 所有 hook |
| `SESSION_ID` | 会话 ID | 所有 hook |
| `LANGUAGE` | 语言代码 | 所有 hook |
@ -99,7 +99,7 @@ import sys
def main():
user_identifier = os.environ.get('USER_IDENTIFIER', '')
bot_id = os.environ.get('BOT_ID', '')
bot_id = os.environ.get('ASSISTANT_ID', '')
# 输出要注入到 prompt 中的内容
print(f"## User Context\n\n用户: {user_identifier}")

View File

@ -11,7 +11,7 @@ import sys
def main():
"""从环境变量读取参数并输出注入内容"""
user_identifier = os.environ.get('USER_IDENTIFIER', '')
bot_id = os.environ.get('BOT_ID', '')
bot_id = os.environ.get('ASSISTANT_ID', '')
# 示例:根据 user_identifier 查询用户上下文
# 这里只是演示,实际应该从数据库或其他服务获取