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:
chenmingxuan committed 2026-10-18 14:18:37 +08:00
1 parent 2328a4df0c
commit e1ea099592
128 files changed
+4944 -700

No files matched your search

+31 -8
View File
@@ -57,6 +57,8 @@ async def mobile_inspect_trace(
query: str | None = None,
step_range: list[int] | None = None,
max_results: int = 5,
offset: int = 0,
limit: int = 20,
) -> Any:
"""Retrieves execution details of a mobile automation task (running or finished).
@@ -64,8 +66,12 @@ async def mobile_inspect_trace(
both Flash and Pro tasks. Every result includes the assigned `device_serial`.
### Actions
- view_report / view_usage / view_requests / view_logs / view_evidence:
bounded read-only report, measured token/cache totals, request phases and IDs,
redacted log tails, or source-specific evidence index. offset/limit paginate;
start with view_report, then inspect only relevant evidence. No export is generated.
- **'view_summary'**: High-level execution summary across all steps.
Pro: hierarchical task plan with per-step status; Flash: full execution
Pro: hierarchical task plan with per-step status; Flash: paginated execution
chain with each step's reasoning and action.
- **'search'**: Deterministic keyword / step-range lookup over the full
stored history (screen descriptions, exact actions and results,
@@ -74,15 +80,15 @@ async def mobile_inspect_trace(
its step number; a `step_range` also returns that range's per-step
action ledger. Requires `query` and/or `step_range`.
- **'view_step_screenshots'**: Local file paths of one step's screenshots:
`before_screenshot` (what the agent saw), `after_screenshot` (only set
when the action failed/was intercepted, else null), and
`before_screenshot` (what the agent saw), `after_screenshot` (when actually captured, otherwise null), and
`action_overlay_screenshot` (the action visually marked — e.g. red circle
for taps — key for verifying the agent tapped the right element).
- **'view_step_details'**: Stored details of one step exactly as the agent's
own context showed it: what the screen showed, its reasoning, every tool
call it made (name, arguments, result — e.g. what the explorer or OCR
reported), the planned action, any safety-net interception and the
execution result. Coordinates are normalized [x, y]. Works for Flash and
execution result. Coordinate units depend on the tool: Cua uses screenshot
pixels; consult the recorded source geometry, never reuse another window. Works for Flash and
Pro tasks.
Args:
@@ -97,6 +103,17 @@ async def mobile_inspect_trace(
`"search"`.
max_results: Maximum `"search"` hits to return (server-side cap applies).
"""
from mcp_server.tools.automation import _id, _request
_id(trace_id)
if offset < 0 or not 1 <= limit <= 100:
raise ValueError("offset 必须非负,limit 必须在 1–100 之间")
if action in {"view_report", "view_usage", "view_requests", "view_logs", "view_evidence"}:
return await _request(
"GET",
f"/api/sessions/{trace_id}/inspection",
params={"view": action.removeprefix("view_"), "offset": offset, "limit": limit},
)
project_root = env_utils.get_project_root()
db_path = os.path.join(trace_store.TRACES_DIR, "data_engine.db")
if not os.path.exists(db_path):
@@ -135,8 +152,8 @@ async def mobile_inspect_trace(
session_start_time = session_row["start_time"] if session_row else None
cursor.execute(
"SELECT * FROM steps WHERE session_id = ? ORDER BY step_number ASC",
(trace_id,),
"SELECT * FROM steps WHERE session_id = ? ORDER BY step_number ASC LIMIT ? OFFSET ?",
(trace_id, limit, offset),
)
rows = cursor.fetchall()
@@ -252,7 +269,10 @@ async def mobile_inspect_trace(
summary_lines.append(f"### Step {s_num} (at {rel_t}, duration {dur_str})")
summary_lines.append(f"- **Thinking / Motivation:** {thought}")
summary_lines.append(f"- **Action Taken:** `{act_str}` -> `{res}`\n")
return "\n".join(summary_lines)
return (
"\n".join(summary_lines)[:40000]
+ f"\n\nPage offset={offset}, limit={limit}; use offset={offset + limit} for more steps."
)
try:
summary_markdown = build_plan_and_history(
@@ -268,7 +288,10 @@ async def mobile_inspect_trace(
f"**Session ID:** `{trace_id}` | **Model:** Pro{device_info_str}\n\n"
+ summary_markdown
)
return summary_markdown
return (
summary_markdown[:40000]
+ f"\n\nPage offset={offset}, limit={limit}; use offset={offset + limit} for more steps."
)
except Exception as e:
return {
"error": "Formatting error",