@whyshu/argent-engine 0.8.0-rc.2 → 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.
Files changed (33) hide show
  1. package/MANIFEST.json +30 -21
  2. package/engine/VERSION +1 -1
  3. package/engine/core/contracts/argent.contracts.json +1 -1
  4. package/engine/scripts/appointment-create.mjs +2 -2
  5. package/engine/scripts/argent-machine-setup.mjs +3 -1
  6. package/engine/scripts/argent-runner.mjs +4 -2
  7. package/engine/scripts/build-engine-package.mjs +1 -1
  8. package/engine/scripts/capability-packs.lock.json +19 -19
  9. package/engine/scripts/check-argent-desktop.mjs +91 -0
  10. package/engine/scripts/erp_invoice_shadow.py +62 -0
  11. package/engine/scripts/erp_invoice_writeback.py +93 -0
  12. package/engine/scripts/flow-requirements.json +3 -3
  13. package/engine/scripts/flow-session-retention.mjs +2 -1
  14. package/engine/scripts/flow_source.py +10 -1
  15. package/engine/scripts/flow_sources/__init__.py +1 -0
  16. package/engine/scripts/flow_sources/erp.py +54 -0
  17. package/engine/scripts/gen-agent-bundles.mjs +1 -1
  18. package/engine/scripts/invoice_lip_runner.py +43 -0
  19. package/engine/scripts/lib/plugin-packages.mjs +3 -0
  20. package/engine/scripts/orchestrator.py +173 -5
  21. package/engine/scripts/orchestrator_br.py +89 -1
  22. package/engine/scripts/query_runner.py +2 -3
  23. package/engine/scripts/release-gate-0.8.mjs +81 -0
  24. package/engine/scripts/session-handoff.mjs +2 -1
  25. package/engine/scripts/skuflow_invoice_runner.py +145 -0
  26. package/engine/scripts/xzh-browser.sh +2 -1
  27. package/engine/scripts/xzh_browser.py +1 -1
  28. package/engine/skills/ml-fulfillment-sop/references/agentic-runtime-v3.md +1 -1
  29. package/engine/tools/agentic/README.md +95 -0
  30. package/engine/tools/agentic/mcp_server.py +212 -0
  31. package/engine/tools/agentic/ml_agent_tools.py +602 -0
  32. package/engine/version.mjs +1 -1
  33. package/package.json +1 -1
@@ -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)