# 查价中台环境变量模板（本地开发）
# 生产部署请使用：cp deploy/.env.production.example .env && bash deploy/install.sh
# 详见 deploy/README.md

MYSQL_HOST_PORT=3307
MYSQL_ROOT_PASSWORD=changeme
JWT_SECRET=your-256-bit-secret-change-in-production

# 宿主 Service Token 映射（JSON）：token → { customerId, permissions[] }
HOST_SERVICE_TOKENS={"demo-host-token":{"customerId":"CUST_001","permissions":["pricing:markup:write"]}}
# 本地 development 默认跳过宿主 Token 鉴权（npm run dev）；生产环境无效
# 若要在本地也校验 Token，设为 false
# HOST_SERVICE_AUTH_DISABLED=false

# 管理端可见客户列表（逗号分隔，与 HOST_SERVICE_TOKENS 合并）
CUSTOMER_REGISTRY=CUST_001,CUST_002,CUST_003

# 宿主两步公开接口（美美与共等）：true=免 Token；后期改 false 并走 Service Token
HOST_PUBLIC_API_ENABLED=false
HOST_PUBLIC_DEFAULT_CUSTOMER_ID=CUST_001

# ── RPA（PRD v0.6 GD-15，headed 录制后填入）────────────────────────
# 逗号分隔、按序探测；禁止 dashboard.mothership.com / www.mothership.com/quote
# 英文 locale 避免中文精简 widget（无 cargo editor）；首页 + en-US 为推荐组合
MOTHERSHIP_QUOTE_URLS=https://www.mothership.com/
# 留空则 Playwright 默认；en-US headless 仅显示 zip 精简条，与地址 RPA 不兼容
# RPA_BROWSER_LOCALE=en-US
RPA_STORAGE_STATE_PATH=.rpa/mothership-storage.json
# 缺会话文件时 headless 自动访问 MOTHERSHIP_QUOTE_URLS 获取 cookies（默认 true；设 false 则须手动 record:mothership）
# RPA_AUTO_BOOTSTRAP_STORAGE=true
RPA_MOCK_MODE=false
# 地址 commit 隔离：real=真实 MotherShip；mock=仅替代 commit（prove-rpa-chain 下游验证用）
RPA_ADDRESS_MODE=real
# 报价模式：direct=直连 axel API（默认，embed-demo 推荐）| widget=Playwright 页面交互
RPA_QUOTE_MODE=direct
# 方案 A：widget 双地址 vault 注入（widget 模式默认 true；显式 false 可关闭）
# RPA_DUAL_ADDRESS_PATCH=true
# place commit 修复模式：event=Google事件触发(默认) | state=React注入 | legacy=原逻辑
RPA_PLACE_FIX_MODE=event
# true 时注入 P0 实例拓扑/监听器指纹 + P2 fetch 劫持，fix-place 各阶段落盘 .rpa/place-diagnostic/
RPA_PLACE_DIAG=false
# 有头调试：RPA_HEADED=true 等价 RPA_HEADLESS=false
RPA_HEADLESS=true
# RPA_HEADED=true
# 货物 drawer 填写完成后 page.pause()（仅人工验收时开启）
# RPA_CARGO_DRAWER_PAUSE=true
RPA_BROWSER_LOCALE=en-US
RPA_USE_PATCHRIGHT=false
# 反爬：playwright-extra stealth（与 patchright 二选一；部分页面会破坏 widget，默认 false）
RPA_USE_STEALTH=false
# 使用本机 Chrome/Edge，降低 HeadlessChrome 指纹（推荐 chrome）
# RPA_BROWSER_CHANNEL=chrome
# 真人入口流：先打开首页再点 Get Quote（携带 Referer/Cookie）
# RPA_HUMAN_ENTRY_FLOW=true
# RPA_QUOTE_WARMUP_URL=https://www.mothership.com/
# headed 调试：慢动作毫秒；RPA_NETWORK_DEBUG=true 输出全部请求
# RPA_SLOW_MO_MS=100
# RPA_NETWORK_DEBUG=false
RPA_WORKER_ID=
RPA_QUEUE_ENABLED=true
# 驻留页单次会话加速（实验性，默认关；true 时需 worker + confirm 全链路）
RPA_PARKED_SESSION=false

# Selector（Playwright codegen / record-mothership 产出，填表 + submit）
# 录制 115541 / 115059 — 中英双语，逗号分隔按序尝试
RPA_SELECTOR_PICKUP_SECTION=#react-quoter-landing-plugin >> text=Pick up from,#react-quoter-landing-plugin >> text=Where to pick up,#react-quoter-landing-plugin >> text=从何处取货
RPA_SELECTOR_DELIVERY_SECTION=#react-quoter-landing-plugin >> text=Deliver to,#react-quoter-landing-plugin >> text=Delivery to,#react-quoter-landing-plugin >> text=送货至
RPA_SELECTOR_QUOTE_WIDGET=#react-quoter-landing-plugin
RPA_SELECTOR_PICKUP_STREET=#react-quoter-landing-plugin >> placeholder=Search by address,#react-quoter-landing-plugin >> role=textbox[name="Search by address"],#react-quoter-landing-plugin >> role=textbox[name="Search address"],#react-quoter-landing-plugin >> role=textbox[name="搜索地址"]
RPA_SELECTOR_DELIVERY_STREET=#react-quoter-landing-plugin >> placeholder=Search by address,#react-quoter-landing-plugin >> role=textbox[name="Search by address"],#react-quoter-landing-plugin >> role=textbox[name="Search address"],#react-quoter-landing-plugin >> role=textbox[name="搜索地址"]
RPA_SELECTOR_ADDRESS_SUGGESTION=#react-quoter-landing-plugin >> [role="listbox"] [role="option"],#react-quoter-landing-plugin >> li,.pac-item,[role="option"]
RPA_SELECTOR_CARGO_SECTION=#react-quoter-landing-plugin >> filter:text=Shipment details>>nth=4,#react-quoter-landing-plugin >> filter:text=Freight details>>nth=4,#react-quoter-landing-plugin >> filter:text=货运详情>>nth=4
RPA_SELECTOR_SUBMIT=role=button[name="GET QUOTE"],role=button[name="Get freight quote"],role=button[name="Get a freight quote"],role=button[name="获取货运报价"]
# 报价 tab/price selector 已废弃（Network-First）；可留空
# RPA_SELECTOR_STANDARD_TAB=
# RPA_SELECTOR_GUARANTEED_TAB=
# RPA_SELECTOR_LOWEST_OPTION=
# RPA_SELECTOR_FASTEST_OPTION=
# RPA_SELECTOR_PRICE=

# 报价 API endpoint（HAR 校准辅助，仅 telemetry；不参与 runtime 匹配）
# 阶段0 录证白名单：services.mothership.com/axel/quote
MOTHERSHIP_QUOTE_API_URL_PATTERNS=services.mothership.com/axel/quote
# 设为 true 时输出全部 REQ/RESP（定位 json=0）
RPA_QUOTE_NETWORK_VISIBILITY=false
# 设为 true 时契约失败日志输出 raw JSON body
RPA_QUOTE_DEBUG_RAW=false
# 设为 true 时日志输出 JSON 候选 URL（校准 HAR pinned 用）
RPA_QUOTE_NETWORK_SNIFF=false

# Priority1 worker 填表提速（生产建议）
# RPA_DWELL_MS=0
# RPA_SLOW_MO_MS=0
# RPA_QUOTE_POLL_MS=600
# RPA_QUOTE_WAIT_MS=90000
# RPA_PRIORITY1_WORKER_FAST=true
RPA_SELECTOR_TRANSIT=text=business days
# 货物字段已改为 fillCargoInDrawer 动态 placeholder 定位，下列 env 仅兼容旧脚本，runtime 不再读取
# RPA_SELECTOR_PALLET_QTY=...
# RPA_SELECTOR_WEIGHT=...
# RPA_SELECTOR_LENGTH=...
# RPA_SELECTOR_WIDTH=...
# RPA_SELECTOR_HEIGHT=...

# 可选：仅当入口跳转 login 时使用
MOTHERSHIP_EMAIL=
MOTHERSHIP_PASSWORD=

# 已废弃：请改用 MOTHERSHIP_QUOTE_URLS
# MOTHERSHIP_QUOTE_URL=

# 开发基础设施模式: auto | docker | native
DEV_INFRA_MODE=native

# 本地 prisma migrate/seed 使用宿主机端口；容器内仍用 mysql:3306
DATABASE_URL=mysql://root:changeme@localhost:3307/chajia
REDIS_URL=redis://localhost:6379
