feat(agent): 增强 Agent 配置,新增结构化字段与聊天功能支持

This commit is contained in:
hugo committed 2026-07-07 11:10:32 +08:00
1 parent ac4262cd75
commit c8ce77199e
183 files changed
+11690 -2300

No files matched your search

+7 -5
View File
@@ -15,7 +15,7 @@ Required env (same as backend):
FREIGHT_UPLOAD_QUEUE_DIR
FREIGHT_RPA_UPLOAD_TRIGGER_DIR
Optional:
FREIGHT_RPA_MOCK=true
FREIGHT_RPA_MOCK=false
FREIGHT_RPA_POLL_SECONDS=3
FREIGHT_RPA_SAMPLE_INVENTORY=path/to/sample.xlsx
FREIGHT_RPA_BROWSER_PROFILE_DIR=data/shipping_notice/freight_rpa/browser_profile
@@ -3837,23 +3837,25 @@ def _handle_inventory_trigger(trigger_path: Path, drop_dir: Path, processed_dir:
trigger_path.unlink(missing_ok=True)
return
mock = _env("FREIGHT_RPA_MOCK", "true").lower() == "true"
mock = _env("FREIGHT_RPA_MOCK", "false").lower() == "true"
mode = "mock" if mock else "browser"
try:
out_file = _write_sample_inventory(drop_dir, task_no) if mock else _download_inventory_with_browser(body, drop_dir)
_post_callback("/api/shipping-notice/rpa/inventory-ready", {
"task_no": task_no,
"success": True,
"file_path": str(out_file),
"rpa_mode": mode,
"source_code": ((body.get("rpa_inventory_source") or {}).get("source_code") if isinstance(body.get("rpa_inventory_source"), dict) else None),
})
_move_trigger(trigger_path, processed_dir, "processed")
mode = "mock" if mock else "browser"
print(f"[inventory] {mode} export done for {task_no} -> {out_file.name}")
except Exception as exc:
try:
_post_callback("/api/shipping-notice/rpa/inventory-ready", {
"task_no": task_no,
"success": False,
"rpa_mode": mode,
"error_message": str(exc),
})
if trigger_path.exists():
@@ -3871,7 +3873,7 @@ def _handle_upload_trigger(trigger_path: Path, processed_dir: Path) -> None:
trigger_path.unlink(missing_ok=True)
return
mock = _env("FREIGHT_RPA_MOCK", "true").lower() == "true"
mock = _env("FREIGHT_RPA_MOCK", "false").lower() == "true"
if not mock:
print(f"[upload] real RPA not implemented; trigger kept: {trigger_path.name}")
return
@@ -3924,7 +3926,7 @@ def main() -> None:
upload_processed = upload_trigger_dir / "processed"
print("[freight_rpa_worker] started")
print(f" mock={_env('FREIGHT_RPA_MOCK', 'true')}")
print(f" mock={_env('FREIGHT_RPA_MOCK', 'false')}")
print(f" inventory_triggers={inv_trigger_dir}")
print(f" upload_triggers={upload_trigger_dir}")
print(f" drop={drop_dir}")