落地并存测服全端:智能体 Graph/路由、后台切 8180、主账与部署脚本齐备,便于线上重发与验收。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
"""
|
||||
Worker 结构化唤醒载荷。
|
||||
|
||||
本文件职责:定义「识别/PDF 完成」唤醒图的数据结构;禁止用用户聊天文字冒充文件完成。
|
||||
调用方:jobs 槽完成后 → GraphRuntime.wake_from_worker。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Optional
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class WorkerWakePayload:
|
||||
"""
|
||||
结构化 wake(对齐 prompt/14)。
|
||||
|
||||
inquiry_no + quote_version + wait_version 三者用于对齐停点;缺任一则 runtime 拒绝。
|
||||
kind:识别完成 / PDF 完成等枚举字符串,骨架只做透传校验。
|
||||
"""
|
||||
|
||||
thread_id: str
|
||||
inquiry_no: str
|
||||
quote_version: int
|
||||
wait_version: int
|
||||
kind: str
|
||||
detail: Optional[dict[str, Any]] = None
|
||||
|
||||
def validate(self) -> None:
|
||||
"""
|
||||
校验必填字段。
|
||||
|
||||
副作用:无效时抛 ValueError;不写库。
|
||||
"""
|
||||
if not (self.thread_id or "").strip():
|
||||
raise ValueError("wake 缺少 thread_id")
|
||||
if not (self.inquiry_no or "").strip():
|
||||
raise ValueError("wake 缺少 inquiry_no")
|
||||
if self.quote_version is None or int(self.quote_version) < 0:
|
||||
raise ValueError("wake quote_version 无效")
|
||||
if self.wait_version is None or int(self.wait_version) < 0:
|
||||
raise ValueError("wake wait_version 无效")
|
||||
if not (self.kind or "").strip():
|
||||
raise ValueError("wake 缺少 kind")
|
||||
|
||||
def as_state_patch(self) -> dict[str, Any]:
|
||||
"""转为写入图状态的增量(骨架:只记录 last_wake,不推进六态)。"""
|
||||
self.validate()
|
||||
return {
|
||||
"inquiry_no": self.inquiry_no,
|
||||
"quote_version": int(self.quote_version),
|
||||
"wait_version": int(self.wait_version),
|
||||
"last_wake": {
|
||||
"kind": self.kind,
|
||||
"inquiry_no": self.inquiry_no,
|
||||
"quote_version": int(self.quote_version),
|
||||
"wait_version": int(self.wait_version),
|
||||
"detail": self.detail or {},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user