65 lines
2.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""pipeline-bidding 模块装载入口。
宿主应用pipeline-app在 init() 中调用 load_pipeline_bidding() 即挂载投标产线:
能力包注册bid_ability+ 角色工具 schema 注册role_tool_schemas+ 对账器启动bid_flow
未装本模块的宿主完全零接触(不 import 本包则以上全部不发生)。
表结构不在此处建(铁律:运行期不做 schema 变更),建表走部署期:
json2ddl 生成 → build.sh 应用 / 人工执行(见 build.sh
"""
import logging
logger = logging.getLogger("pipeline.bidding")
_loaded = False
def load_pipeline_bidding():
"""挂载投标产线(幂等)。"""
global _loaded
if _loaded:
return True
ok = True
# 1. 角色工具 schema → 引擎分发字典(全路径模块,引擎裸名约定不变)
try:
from .role_tool_schemas import register_role_tools
n = register_role_tools()
logger.info("[pipeline_bidding] role tool schemas: %d", n)
except Exception as e:
logger.warning("[pipeline_bidding] role tool schema 注册失败: %s", str(e)[:200])
ok = False
# 2. 主 agent 能力包 + slash 命令import 即注册,与开发产线同机制)
try:
from . import bid_ability # noqa: F401
logger.info("[pipeline_bidding] ability registered: bidding_general")
except Exception as e:
logger.warning("[pipeline_bidding] ability 注册失败: %s", str(e)[:200])
ok = False
# 3. 状态对账器(角色任务唯一创建者 + 阻塞门禁守门)。
# PIPELINE_MODE=web 时不注册(与引擎 poller 同款模式开关)。
import os
mode = (os.environ.get("PIPELINE_MODE", "all") or "all").strip().lower()
if mode in ("all", "worker"):
try:
from .bid_flow import start_poller
r = start_poller()
try:
from appPublic.log import debug as _dbg
_dbg("[pipeline_bidding] poller register result: %s (PIPELINE_MODE=%s)" % (r, mode))
except Exception:
pass
logger.info("[pipeline_bidding] poller register: %s (mode=%s)", r, mode)
except Exception as e:
logger.warning("[pipeline_bidding] poller 启动失败: %s", str(e)[:200])
ok = False
else:
logger.info("[pipeline_bidding] PIPELINE_MODE=webpoller 不启动")
_loaded = ok or _loaded
logger.info("[pipeline_bidding] v0.1.0 loaded")
return True