@whyshu/argent-engine 0.8.0-rc.3 → 0.8.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MANIFEST.json +20 -12
- package/engine/VERSION +1 -1
- package/engine/scripts/build-engine-package.mjs +1 -1
- package/engine/scripts/capability-packs.lock.json +12 -12
- package/engine/scripts/check-argent-desktop.mjs +91 -0
- package/engine/scripts/erp_invoice_shadow.py +62 -0
- package/engine/scripts/erp_invoice_writeback.py +93 -0
- package/engine/scripts/flow-requirements.json +3 -3
- package/engine/scripts/flow_source.py +10 -1
- package/engine/scripts/flow_sources/__init__.py +1 -0
- package/engine/scripts/flow_sources/erp.py +54 -0
- package/engine/scripts/invoice_lip_runner.py +43 -0
- package/engine/scripts/lib/plugin-packages.mjs +3 -0
- package/engine/scripts/orchestrator.py +173 -5
- package/engine/scripts/orchestrator_br.py +89 -1
- package/engine/scripts/query_runner.py +2 -3
- package/engine/scripts/release-gate-0.8.mjs +1 -0
- package/engine/scripts/skuflow_invoice_runner.py +145 -0
- package/engine/tools/agentic/README.md +95 -0
- package/engine/tools/agentic/mcp_server.py +212 -0
- package/engine/tools/agentic/ml_agent_tools.py +602 -0
- package/engine/version.mjs +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Argent Agentic ML Tools(M1)
|
|
2
|
+
|
|
3
|
+
只读探针,供本地 shadow 与后续 MCP server 复用。
|
|
4
|
+
|
|
5
|
+
## 用法
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
export ARGENT_DATA_DIR="$HOME/.dsh/argent" # 店铺映射/store list 兜底
|
|
9
|
+
export ARGENT_EVIDENCE_DIR="$HOME/.dsh/argent-local/evidence"
|
|
10
|
+
|
|
11
|
+
python3 tools/agentic/ml_agent_tools.py probe-hub \
|
|
12
|
+
--shipment 80555414 --store "墨西哥-2店-子账号" --json
|
|
13
|
+
|
|
14
|
+
python3 tools/agentic/ml_agent_tools.py probe-appointment \
|
|
15
|
+
--shipment 80555414 --store "墨西哥-2店-子账号" --json
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- 也可传 `--store-id 27494792824433`;
|
|
19
|
+
- 店铺窗口需已打开(本机可用 `ziniao-cli store open --name ...`);
|
|
20
|
+
- 只调用 `ziniao-cli page visit/exec/screenshot`,不点写按钮、不提交预约。
|
|
21
|
+
|
|
22
|
+
## 输出
|
|
23
|
+
|
|
24
|
+
符合 `docs/agentic-tools-contract-v1.md` 的信封;证据截图落
|
|
25
|
+
`$ARGENT_EVIDENCE_DIR/<日期>/`。
|
|
26
|
+
|
|
27
|
+
- `probe-hub`:五项 checklist + `operationallyComplete` + 卡片证据;
|
|
28
|
+
- `probe-appointment`:运输方式选项、日历可见性、平台错误页/已有预约标记。
|
|
29
|
+
|
|
30
|
+
## M1 状态
|
|
31
|
+
|
|
32
|
+
- [x] probe-hub 本地真实店铺只读跑通:80555414 `operationallyComplete=true`;74009400 `false`(仅 appointment 未完成,labels/boxLabels 已完成);
|
|
33
|
+
- [x] probe-appointment 页面/选项/错误页抽取实现;74009400 正确识别 `existingAppointment=true`(已有预约时不展示运输方式下拉);
|
|
34
|
+
- [x] MCP stdio server(`mcp_server.py`,tools/list + tools/call 已用 80555414 实测);本地 3081 profile 已挂载(`mcp-argent-ml`);
|
|
35
|
+
- [ ] ERP AgentTask 派发/信号联调。
|
|
36
|
+
|
|
37
|
+
## M1 端到端 shadow(2026-10-27 15:10)
|
|
38
|
+
|
|
39
|
+
本地 dsh 3081 + task-board + MCP 已跑通**真实 agent 会话**:
|
|
40
|
+
|
|
41
|
+
- 任务 prompt:让 agent 调 `mcp__argent_ml__ml_probe_hub` 探测 80555414;
|
|
42
|
+
- 结果:agent 正确调用 MCP 工具,返回 `operationallyComplete=true`、五项全绿,
|
|
43
|
+
并引用证据截图 `/Users/chester/.dsh/argent-local/evidence/20261027/hub-80555414-151020.png`;
|
|
44
|
+
- session:`session-50610720-0477-43d9-9e61-6ffb7934a1c1`;
|
|
45
|
+
- 前置修复:隔离 DSH_HOME 需要 `DEEPSEEK_API_KEY`(从本机 credentials 注入启动环境,未写入仓库)。
|
|
46
|
+
|
|
47
|
+
## M2 ERP AgentTask 闭环(2026-10-27)
|
|
48
|
+
|
|
49
|
+
本地 ERP `ly-agentic-local` 创建 AgentTask → `scripts/agentic-local-bridge.mjs`(ERP 侧)
|
|
50
|
+
→ 本地 dsh task-board → agent 调 MCP `ml_probe_hub` → AgentTask `completed`。
|
|
51
|
+
实测 session `session-b438c456-87f2-4d7d-b584-d9f88d09fd19`,agent 实际完成 MCP 调用。
|
|
52
|
+
|
|
53
|
+
## 实战 canary(2026-10-27 15:28)
|
|
54
|
+
|
|
55
|
+
- 使用 lip 新 SKU 记录 `reczz28SLNgEOAjV`(HW-MX-YU-080,160 件/10 箱,墨西哥-2店-子账号);
|
|
56
|
+
- 步骤 1-3 成功,创建货件 **80664493**;
|
|
57
|
+
- 步骤 4 受阻:预约页实际返回「No contamos con citas en este momento…」,即**平台暂无可预约日期**,
|
|
58
|
+
不是脚本缺陷;旧脚本将其误报为「页面形态异常」;
|
|
59
|
+
- 已给 `ml_probe_appointment` 增加 `noSlots` 识别与 `--current-page` 只读模式(页面限流时可直接读当前页);
|
|
60
|
+
- 该货件尚未预约,因此无需取消;等待平台放号后继续。
|
|
61
|
+
|
|
62
|
+
## 受控写工具(M2)
|
|
63
|
+
|
|
64
|
+
`ml_run_full_step`:通过现有 FULL 编排器执行单步(确定性工具)。
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# 只读步骤(1/2/6)可直接跑
|
|
68
|
+
python3 tools/agentic/ml_agent_tools.py run-full-step --record-id reczz... --step 1 --json
|
|
69
|
+
# 写步骤必须带 approvalToken(环境变量 ARGENT_WRITE_APPROVAL 校验)
|
|
70
|
+
ARGENT_WRITE_APPROVAL=local-canary python3 tools/agentic/ml_agent_tools.py run-full-step \
|
|
71
|
+
--record-id reczz... --step 4 --allow-write --approval-token local-canary --json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
生产由 ERP 签发 approval token;本地仅用于受控 canary。
|
|
75
|
+
|
|
76
|
+
## 受控写工具实测(M2)
|
|
77
|
+
|
|
78
|
+
- `ml_run_full_step` 已挂到本地 MCP(`mcp__argent_ml__ml_run_full_step`);
|
|
79
|
+
- 只读 step1 实测 success;
|
|
80
|
+
- 写 step4 带本地审批 token 实测:工具正确返回 `ok:false`,引擎失败原因为平台暂无可预约日期;
|
|
81
|
+
- 本地审批 token 仅存于隔离 profile env(`ARGENT_WRITE_APPROVAL`),不进入仓库。
|
|
82
|
+
|
|
83
|
+
## 预约放号 watcher(M3.5)
|
|
84
|
+
|
|
85
|
+
`ml_watch_appointment`:停留预约页低频刷新等待放号(只读)。
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
python3 tools/agentic/ml_agent_tools.py watch-appointment \
|
|
89
|
+
--shipment 80664493 --store 墨西哥-2店-子账号 --interval-sec 60 --max-seconds 600 --json
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
- 只刷新同一标签页,不重开店铺窗口;
|
|
93
|
+
- 返回 `slots_available` / `existing_appointment` 即停止;
|
|
94
|
+
- 平台错误页/无号继续等待,超时返回 observations;
|
|
95
|
+
- 自动预约(写)仍由 `ml_run_full_step` + approvalToken 执行。
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Argent ML Tools MCP server(M1,stdio,只读)。
|
|
3
|
+
|
|
4
|
+
协议:MCP JSON-RPC 2.0 over stdio;工具复用 ml_agent_tools.py。
|
|
5
|
+
不依赖第三方 MCP SDK,便于客户机/本地直接运行。
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
import sys
|
|
11
|
+
import traceback
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
HERE = Path(__file__).resolve().parent
|
|
15
|
+
sys.path.insert(0, str(HERE))
|
|
16
|
+
import ml_agent_tools as tools # noqa: E402
|
|
17
|
+
|
|
18
|
+
SERVER_INFO = {"name": "argent-ml-tools", "version": "0.1.0"}
|
|
19
|
+
PROTOCOL = "2024-11-05"
|
|
20
|
+
|
|
21
|
+
TOOLS = [
|
|
22
|
+
{
|
|
23
|
+
"name": "ml_probe_hub",
|
|
24
|
+
"description": "只读读取美客多 FULL hub-v2 五项状态,判断整票是否已完成。",
|
|
25
|
+
"inputSchema": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"properties": {
|
|
28
|
+
"shipmentNo": {"type": "string", "description": "货件号,如 80555414"},
|
|
29
|
+
"store": {"type": "string", "description": "店铺名,如 墨西哥-2店-子账号"},
|
|
30
|
+
"storeId": {"type": "string", "description": "店铺 ID(可选,优先于 store)"},
|
|
31
|
+
"recordId": {"type": "string", "description": "ERP sourceRecordId(可选,用于匹配 AgentTask)"},
|
|
32
|
+
},
|
|
33
|
+
"required": ["shipmentNo"],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "ml_finalize_ticket",
|
|
38
|
+
"description": "步骤1-8 完成后用 hub-v2 五项验证并写 ERP AgentTask 完成态(需 approvalToken;0.8 不再写 lip)。",
|
|
39
|
+
"inputSchema": {
|
|
40
|
+
"type": "object",
|
|
41
|
+
"properties": {
|
|
42
|
+
"recordId": {"type": "string"},
|
|
43
|
+
"shipmentNo": {"type": "string"},
|
|
44
|
+
"store": {"type": "string"},
|
|
45
|
+
"approvalToken": {"type": "string"},
|
|
46
|
+
},
|
|
47
|
+
"required": ["shipmentNo", "store"],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "ml_run_full_step",
|
|
52
|
+
"description": "受控调用现有 FULL 编排器执行单步(step 1-8);写步骤需要 approvalToken,仅本地/受信环境。",
|
|
53
|
+
"inputSchema": {
|
|
54
|
+
"type": "object",
|
|
55
|
+
"properties": {
|
|
56
|
+
"recordId": {"type": "string", "description": "ERP sourceRecordId"},
|
|
57
|
+
"step": {"type": "integer", "minimum": 1, "maximum": 8, "description": "FULL 步骤号"},
|
|
58
|
+
"allowWrite": {"type": "boolean", "description": "是否允许写步骤(3/4/5/7/8)"},
|
|
59
|
+
"approvalToken": {"type": "string", "description": "写步骤审批 token"},
|
|
60
|
+
"timeoutS": {"type": "integer", "minimum": 30, "maximum": 1200},
|
|
61
|
+
"record": {"type": "object", "description": "ERP-only 合成记录:record_id/sourceRecordId、store_name、sku、qty/quantity、box/boxCount、shipment_id/shipmentNo"},
|
|
62
|
+
},
|
|
63
|
+
"required": ["recordId", "step"],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"name": "ml_open_appointment_slots",
|
|
68
|
+
"description": "只读打开预约页、选择 Vehículo particular 并展开日期选择,返回可用日期/时段(不提交预约)。",
|
|
69
|
+
"inputSchema": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"properties": {
|
|
72
|
+
"shipmentNo": {"type": "string"},
|
|
73
|
+
"store": {"type": "string"},
|
|
74
|
+
"storeId": {"type": "string"},
|
|
75
|
+
},
|
|
76
|
+
"required": ["shipmentNo"],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "ml_watch_appointment",
|
|
81
|
+
"description": "停留预约页低频刷新等待放号(只读;发现可用时段/已有预约即返回)。",
|
|
82
|
+
"inputSchema": {
|
|
83
|
+
"type": "object",
|
|
84
|
+
"properties": {
|
|
85
|
+
"shipmentNo": {"type": "string"},
|
|
86
|
+
"store": {"type": "string"},
|
|
87
|
+
"storeId": {"type": "string"},
|
|
88
|
+
"intervalSec": {"type": "integer", "minimum": 15, "maximum": 900},
|
|
89
|
+
"maxSeconds": {"type": "integer", "minimum": 30, "maximum": 7200},
|
|
90
|
+
},
|
|
91
|
+
"required": ["shipmentNo"],
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "ml_probe_appointment",
|
|
96
|
+
"description": "只读读取预约页运输方式/日历/错误页,不提交预约。",
|
|
97
|
+
"inputSchema": {
|
|
98
|
+
"type": "object",
|
|
99
|
+
"properties": {
|
|
100
|
+
"shipmentNo": {"type": "string", "description": "货件号"},
|
|
101
|
+
"store": {"type": "string", "description": "店铺名"},
|
|
102
|
+
"storeId": {"type": "string", "description": "店铺 ID(可选)"},
|
|
103
|
+
},
|
|
104
|
+
"required": ["shipmentNo"],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def write(msg: dict) -> None:
|
|
111
|
+
sys.stdout.write(json.dumps(msg, ensure_ascii=False) + "\n")
|
|
112
|
+
sys.stdout.flush()
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def result(req_id, payload):
|
|
116
|
+
write({"jsonrpc": "2.0", "id": req_id, "result": payload})
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def error(req_id, code, message):
|
|
120
|
+
write({"jsonrpc": "2.0", "id": req_id, "error": {"code": code, "message": message}})
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def call_tool(name: str, args: dict) -> dict:
|
|
124
|
+
if name == "ml_probe_hub":
|
|
125
|
+
out = tools.probe_hub(
|
|
126
|
+
store=str(args.get("store") or ""),
|
|
127
|
+
shipment_no=str(args.get("shipmentNo") or ""),
|
|
128
|
+
store_id=str(args.get("storeId") or ""),
|
|
129
|
+
record_id=str(args.get("recordId") or ""),
|
|
130
|
+
open_store=False,
|
|
131
|
+
)
|
|
132
|
+
elif name == "ml_open_appointment_slots":
|
|
133
|
+
out = tools.open_appointment_slots(
|
|
134
|
+
str(args.get("store") or ""),
|
|
135
|
+
str(args.get("shipmentNo") or ""),
|
|
136
|
+
str(args.get("storeId") or ""),
|
|
137
|
+
False,
|
|
138
|
+
)
|
|
139
|
+
elif name == "ml_watch_appointment":
|
|
140
|
+
out = tools.watch_appointment(
|
|
141
|
+
str(args.get("store") or ""),
|
|
142
|
+
str(args.get("shipmentNo") or ""),
|
|
143
|
+
str(args.get("storeId") or ""),
|
|
144
|
+
False,
|
|
145
|
+
int(args.get("intervalSec") or 60),
|
|
146
|
+
int(args.get("maxSeconds") or 300),
|
|
147
|
+
)
|
|
148
|
+
elif name == "ml_finalize_ticket":
|
|
149
|
+
out = tools.finalize_ticket(
|
|
150
|
+
str(args.get("recordId") or ""),
|
|
151
|
+
str(args.get("store") or ""),
|
|
152
|
+
str(args.get("approvalToken") or ""),
|
|
153
|
+
str(args.get("shipmentNo") or ""),
|
|
154
|
+
)
|
|
155
|
+
elif name == "ml_run_full_step":
|
|
156
|
+
out = tools.run_full_step(
|
|
157
|
+
record_id=str(args.get("recordId") or ""),
|
|
158
|
+
step=int(args.get("step") or 0),
|
|
159
|
+
allow_write=bool(args.get("allowWrite")),
|
|
160
|
+
approval_token=str(args.get("approvalToken") or ""),
|
|
161
|
+
timeout_s=int(args.get("timeoutS") or 600),
|
|
162
|
+
record=args.get("record") or None,
|
|
163
|
+
)
|
|
164
|
+
elif name == "ml_probe_appointment":
|
|
165
|
+
out = tools.probe_appointment(
|
|
166
|
+
store=str(args.get("store") or ""),
|
|
167
|
+
shipment_no=str(args.get("shipmentNo") or ""),
|
|
168
|
+
store_id=str(args.get("storeId") or ""),
|
|
169
|
+
open_store=False,
|
|
170
|
+
)
|
|
171
|
+
else:
|
|
172
|
+
raise ValueError(f"unknown tool: {name}")
|
|
173
|
+
text = json.dumps(out, ensure_ascii=False)
|
|
174
|
+
return {"content": [{"type": "text", "text": text}], "isError": not bool(out.get("ok"))}
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def main() -> int:
|
|
178
|
+
for line in sys.stdin:
|
|
179
|
+
line = line.strip()
|
|
180
|
+
if not line:
|
|
181
|
+
continue
|
|
182
|
+
try:
|
|
183
|
+
msg = json.loads(line)
|
|
184
|
+
except json.JSONDecodeError:
|
|
185
|
+
continue
|
|
186
|
+
method = msg.get("method")
|
|
187
|
+
req_id = msg.get("id")
|
|
188
|
+
if method == "initialize":
|
|
189
|
+
result(req_id, {"protocolVersion": PROTOCOL, "capabilities": {"tools": {}}, "serverInfo": SERVER_INFO})
|
|
190
|
+
elif method == "notifications/initialized":
|
|
191
|
+
continue
|
|
192
|
+
elif method == "ping":
|
|
193
|
+
result(req_id, {})
|
|
194
|
+
elif method == "tools/list":
|
|
195
|
+
result(req_id, {"tools": TOOLS})
|
|
196
|
+
elif method == "tools/call":
|
|
197
|
+
params = msg.get("params") or {}
|
|
198
|
+
try:
|
|
199
|
+
result(req_id, call_tool(str(params.get("name") or ""), params.get("arguments") or {}))
|
|
200
|
+
except Exception as exc: # noqa: BLE001
|
|
201
|
+
error(req_id, -32603, f"{type(exc).__name__}: {exc}")
|
|
202
|
+
elif req_id is not None:
|
|
203
|
+
error(req_id, -32601, f"method not found: {method}")
|
|
204
|
+
return 0
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
if __name__ == "__main__":
|
|
208
|
+
try:
|
|
209
|
+
sys.exit(main())
|
|
210
|
+
except Exception: # noqa: BLE001
|
|
211
|
+
traceback.print_exc(file=sys.stderr)
|
|
212
|
+
sys.exit(1)
|