feat: add official Codex skill and harden task execution
Install and update artemis-use with task diagnostics and plugin guidance. Preserve cross-device file receipts, review canonical reports, guard stage transitions and reduce small history summaries. Improve exploration lifecycle, request recovery and browser live connections.
This commit is contained in:
1 parent
2328a4df0c
commit
e1ea099592
128 files changed
+4944
-700
No files matched your search
@@ -0,0 +1,60 @@
|
||||
"""Durable admission receipts in the existing automation store; never replay a write."""
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import time
|
||||
from uuid import uuid4
|
||||
|
||||
from apps.admin_console.services.automation_store import identifier, store
|
||||
|
||||
|
||||
def lookup(request_id: str) -> dict:
|
||||
record = store.get("mcp_task_request", identifier(request_id))
|
||||
if record is None:
|
||||
return {"request_id": request_id, "status": "not_found"}
|
||||
job = store.job(record["trace_id"])
|
||||
return {
|
||||
**record.get("response", {}),
|
||||
**({"status": job["status"]} if job else {}),
|
||||
"status_scope": "task_queue" if job else "submission_receipt",
|
||||
"request_id": request_id,
|
||||
"trace_id": record["trace_id"],
|
||||
"submission_state": record["state"],
|
||||
"message": "请求已登记;请按 trace_id 查询详细状态,不要用新 request_id 自动重提。",
|
||||
}
|
||||
|
||||
|
||||
def run_once(request_id: str, parameters: dict, execute) -> dict:
|
||||
identifier(request_id)
|
||||
fingerprint = hashlib.sha256(
|
||||
json.dumps(parameters, sort_keys=True, ensure_ascii=False).encode("utf-8")
|
||||
).hexdigest()
|
||||
with store.connection() as connection:
|
||||
connection.execute("BEGIN IMMEDIATE")
|
||||
row = connection.execute(
|
||||
"SELECT payload FROM automation_records WHERE kind='mcp_task_request' AND id=?",
|
||||
(request_id,),
|
||||
).fetchone()
|
||||
if row:
|
||||
if json.loads(row[0])["fingerprint"] != fingerprint:
|
||||
raise ValueError("request_id 已用于不同任务内容,请使用新的编号")
|
||||
connection.commit()
|
||||
return {**lookup(request_id), "deduplicated": True}
|
||||
record = {
|
||||
"trace_id": str(uuid4()),
|
||||
"fingerprint": fingerprint,
|
||||
"state": "submitting",
|
||||
}
|
||||
connection.execute(
|
||||
"INSERT INTO automation_records VALUES ('mcp_task_request',?,?,?)",
|
||||
(request_id, json.dumps(record), time.time()),
|
||||
)
|
||||
connection.commit()
|
||||
try:
|
||||
response = execute(record["trace_id"])
|
||||
except Exception:
|
||||
# A lost reply says nothing about whether the queue accepted the task.
|
||||
store.put("mcp_task_request", request_id, {**record, "state": "unknown"})
|
||||
raise
|
||||
store.put("mcp_task_request", request_id, {**record, "state": "returned", "response": response})
|
||||
return {**response, "request_id": request_id}
|
||||
Reference in new issue
Block a user