amw-memory-operator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAMW Memory Operator
AMW 记忆操作器
Use this skill when the user wants to run, debug, or evolve browser automation in .
agent-memory-workbench当用户想要在中运行、调试或演进浏览器自动化时,使用此技能。
agent-memory-workbenchScope
适用范围
- Replay-first execution from stored trajectories
- Fallback exploration and trajectory persistence
- Artifact extraction (markdown, screenshot, image copy, QR capture)
- Run-log based debugging with minimal JSON edits
- 基于存储轨迹的重放优先执行
- 回退探索与轨迹持久化
- 工件提取(markdown、截图、图片复制、二维码捕获)
- 基于运行日志的调试,仅需最小化JSON编辑
Trajectory Governance (Required)
轨迹管理规则(强制要求)
Directory policy (do not mix):
- (optional local) Local-only scratch examples; not distributed from Git by default.
examples/ - User-verified reusable trajectories. This is the primary grep/search target.
trajectories/ready/ - AI-generated or in-test trajectories. Temporary only. Do not treat as stable memory.
trajectories/tmp/ - Deprecated but kept versions for rollback/reference.
trajectories/archive/
Lifecycle policy:
- New trajectory starts in .
trajectories/tmp/ - Run and execute with
validate.--disable-replay true - After repeated success, promote to .
trajectories/ready/ - If replaced, move old version to .
trajectories/archive/
Hard constraints:
- Do not create new user-generated JSON directly under for distribution.
examples/ - Do not commit temporary trajectories from .
trajectories/tmp/ - If a JSON is created in the wrong place, move it and explain the move.
- Keep Baidu download experiments local-only in (do not distribute under
trajectories/tmp/).examples/
ACK protocol before generating/modifying trajectory files:
Governance ACK: new JSON -> trajectories/tmp, reusable JSON -> trajectories/ready, grep default -> trajectories/ready.目录规则(请勿混用):
- (可选本地目录) 仅本地可用的临时示例;默认不会通过Git分发。
examples/ - 经过用户验证的可复用轨迹。这是grep/搜索的主要目标目录。
trajectories/ready/ - AI生成或测试中的轨迹。仅作临时使用,请勿视为稳定记忆。
trajectories/tmp/ - 已弃用但保留的版本,用于回滚或参考。
trajectories/archive/
生命周期规则:
- 新轨迹初始存储在目录。
trajectories/tmp/ - 运行命令并添加
validate参数执行。--disable-replay true - 经过多次成功执行后,升级至目录。
trajectories/ready/ - 若被替代,将旧版本移至目录。
trajectories/archive/
硬性约束:
- 请勿在目录下创建新的用户生成JSON文件用于分发。
examples/ - 请勿提交目录下的临时轨迹。
trajectories/tmp/ - 若JSON文件创建在错误位置,需将其移动并说明移动原因。
- 百度下载相关实验需仅保留在目录(请勿在
trajectories/tmp/目录下分发)。examples/
生成/修改轨迹文件前需确认ACK协议:
Governance ACK: new JSON -> trajectories/tmp, reusable JSON -> trajectories/ready, grep default -> trajectories/ready.Hard Rule: Max Two Branches
硬性规则:最多双分支
Only allow:
- Normal branch
- Human-verification branch (captcha/QR/real-person check)
Do not introduce multi-level branch trees unless the user explicitly asks.
仅允许以下两个分支:
- 常规分支
- 人工验证分支(验证码/二维码/真人核验)
除非用户明确要求,否则请勿引入多级分支树。
Resource Map
资源映射
- Contract and reserved branch schema:
references/json-two-branch-contract.md - Replay/debug checklist:
references/replay-debug-checklist.md - JSON demos:
assets/json-demos/*.json - Skill UI metadata:
agents/openai.yaml - Reusable trajectories:
trajectories/ready/**/*.json - Temporary trajectories:
trajectories/tmp/*.json
Always copy the nearest demo JSON from and minimally adapt selectors/vars.
assets/json-demos/- 合约与预留分支 schema:
references/json-two-branch-contract.md - 重放/调试检查清单:
references/replay-debug-checklist.md - JSON 示例:
assets/json-demos/*.json - 技能UI元数据:
agents/openai.yaml - 可复用轨迹:
trajectories/ready/**/*.json - 临时轨迹:
trajectories/tmp/*.json
请始终从复制最接近的示例JSON,仅对选择器/变量进行最小化调整。
assets/json-demos/Install / Run
安装 / 运行
Runtime Bootstrap (Required Before First Use)
运行时初始化(首次使用前必须执行)
If is missing in current workspace, bootstrap runtime first.
agent-memory-workbenchPowerShell:
if (!(Test-Path ./agent-memory-workbench/package.json)) { git clone https://github.com/insogao/amw.git agent-memory-workbench }Install dependencies:
npm --prefix ./agent-memory-workbench install若当前工作区中缺少,请先初始化运行时环境。
agent-memory-workbenchPowerShell命令:
if (!(Test-Path ./agent-memory-workbench/package.json)) { git clone https://github.com/insogao/amw.git agent-memory-workbench }安装依赖:
npm --prefix ./agent-memory-workbench installLocal
本地运行
cd <your-workspace>/agent-memory-workbenchnpm install- Use:
npm run amw -- list --store-dir ./datanpm run amw -- run ...npm run amw -- validate --steps-file ./trajectories/tmp/<file>.json
If running outside project root:
npm --prefix <path-to-agent-memory-workbench> run amw -- <command>Example from parent workspace:
npm --prefix ./agent-memory-workbench run amw -- <command>Profile defaults to (persistent login identity). Use to switch identities.
Browser mode defaults to (visible browser window). Use only when the user explicitly asks for headless.
Use when validating new fallback steps and you need to bypass memory hits.
main--profile <name>headed=true--headed false--disable-replay truecd <your-workspace>/agent-memory-workbenchnpm install- 使用以下命令:
npm run amw -- list --store-dir ./datanpm run amw -- run ...npm run amw -- validate --steps-file ./trajectories/tmp/<file>.json
若在项目根目录外运行:
npm --prefix <path-to-agent-memory-workbench> run amw -- <command>父工作区示例:
npm --prefix ./agent-memory-workbench run amw -- <command>默认配置文件为(持久化登录身份)。使用参数切换身份。
浏览器模式默认为(可见浏览器窗口)。仅当用户明确要求时,才使用启用无头模式。
验证新回退步骤时,使用参数以绕过记忆匹配。
main--profile <name>headed=true--headed false--disable-replay trueHeaded debug mode
带界面调试模式
Use:
--headed true --hold-open-ms 30000使用命令:
--headed true --hold-open-ms 30000Optional npx distribution (future)
可选npx分发(未来计划)
Current mode is local-first. For distribution later:
- Publish package with pointing to
binsrc-node/cli.js - Keep runtime dependency on
agent-browser - Run via
npx <your-package> run ...
当前为本地优先模式。未来分发方式:
- 发布包时将指向
binsrc-node/cli.js - 保留对的运行时依赖
agent-browser - 通过运行
npx <your-package> run ...
Core Paths
核心路径
- CLI:
src-node/cli.js - Adapter/actions: ,
src-node/agentBrowserAdapter.jssrc-node/actionRegistry.js - Reusable trajectories:
trajectories/ready/ - Temporary trajectories:
trajectories/tmp/ - Archived trajectories:
trajectories/archive/ - Artifacts:
artifacts/ - Runs: and
data/<store>/runs/<run_id>/events.jsonlsummary.json - Memory DB:
data/<store>/memory.db
- CLI:
src-node/cli.js - 适配器/动作:,
src-node/agentBrowserAdapter.jssrc-node/actionRegistry.js - 可复用轨迹:
trajectories/ready/ - 临时轨迹:
trajectories/tmp/ - 归档轨迹:
trajectories/archive/ - 工件:
artifacts/ - 运行记录:和
data/<store>/runs/<run_id>/events.jsonlsummary.json - 记忆数据库:
data/<store>/memory.db
Meta Capabilities (JSON Actions)
元能力(JSON动作)
- Navigation/input: ,
open,click,click_text,fill,type,presswait - Extraction: ,
eval_js,get_urlsnapshot - Image/text ops:
- ,
copy_textpaste_text - (element/clip screenshot)
copy_image - (prefer original image bytes)
copy_image_original paste_image
- Output/validation:
- ,
write_markdownappend_markdown_section - ,
assert_markdownassert_file
- Human takeover:
human_handoff
Screenshot granularity:
- Full page ()
full_page: true - Selector crop ()
selector - Coordinate crop ()
clip: {x,y,width,height}
Prefer whenever the user asks to "save original image" rather than screenshot.
copy_image_original- 导航/输入:,
open,click,click_text,fill,type,presswait - 提取:,
eval_js,get_urlsnapshot - 图片/文本操作:
- ,
copy_textpaste_text - (元素/剪贴板截图)
copy_image - (优先获取原始图片字节)
copy_image_original paste_image
- 输出/验证:
- ,
write_markdownappend_markdown_section - ,
assert_markdownassert_file
- 人工接管:
human_handoff
截图粒度:
- 全页截图()
full_page: true - 选择器裁剪()
selector - 坐标裁剪()
clip: {x,y,width,height}
当用户要求“保存原始图片”时,优先使用而非截图。
copy_image_originalRetrieval and Replay Workflow
检索与重放工作流
- Normalize intent into
{site, task_type, intent, vars} - Run replay-first
- If replay misses/fails, run fallback steps
- On success, persist trajectory
- Compare
summary.jsonand latency (modevsreplay)explore - For grep-first manual selection, search first.
trajectories/ready/
- 将意图标准化为
{site, task_type, intent, vars} - 执行重放优先流程
- 若重放失败/未命中,执行回退步骤
- 成功后持久化轨迹
- 对比中的
summary.json和延迟(modevsreplay)explore - 对于grep优先的手动选择,优先搜索目录。
trajectories/ready/
JSON Editing Policy
JSON编辑规则
- Edit the smallest possible segment
- Keep selectors stable and robust
- Keep variable input externalized ()
{{vars.xxx}} - Keep branch count <= 2
- Keep checks at the tail
assert_*
- 仅编辑最小必要片段
- 保持选择器稳定且健壮
- 将变量输入外部化()
{{vars.xxx}} - 分支数量不超过2个
- 将检查放在末尾
assert_*
Single-Line Match Field (Required)
单行匹配字段(强制要求)
For grep-first low-token retrieval, each JSON should include one reserved single-line field:
json
"amw_match_line": "amw site:example.com task:example_task flow:example_v1 key:foo key:bar key:<zh_keyword>"Strict rules:
- must stay on one physical line (no
amw_match_lineor wrapped multi-line values).\n - Use ASCII tags only: ,
site:,task:,flow:.key: - Chinese is allowed in values when files are UTF-8 encoded.
key: - Do not remove anchor token.
amw - Prefer adding new tokens instead of changing
key:unless behavior truly changes.flow:
For human verification:
- Detect blocker (or error symptoms)
eval_js - Save required artifact (preferred)
copy_image_original - Pause with
human_handoff - Resume normal flow
For reserved branch fields, follow .
references/json-two-branch-contract.md为了支持grep优先的低token检索,每个JSON需包含一个预留的单行字段:
json
"amw_match_line": "amw site:example.com task:example_task flow:example_v1 key:foo key:bar key:<zh_keyword>"严格规则:
- 必须保持在同一物理行(不能有
amw_match_line或换行)。\n - 仅使用ASCII标签:,
site:,task:,flow:。key: - 若文件为UTF-8编码,值中可包含中文。
key: - 请勿移除锚点标记。
amw - 除非行为确实发生变化,否则优先添加新的标记而非修改
key:。flow:
人工验证流程:
- 检测阻塞项(或错误症状)
eval_js - 保存所需工件(优先使用)
copy_image_original - 通过暂停
human_handoff - 恢复常规流程
预留分支字段请遵循。
references/json-two-branch-contract.mdDebug Protocol
调试协议
On failure, inspect in order:
- (
summary.json,failed_step_id,reason)mode - (
events.jsonl, timeout, guard failure)step_error - Artifact correctness in
artifacts/
Patch only the failed segment, then re-run once in headed mode.
For fallback verification, add so replay memory does not mask issues.
--disable-replay true失败时,按以下顺序检查:
- (
summary.json,failed_step_id,reason)mode - (
events.jsonl, 超时,守卫失败)step_error - 目录中工件的正确性
artifacts/
仅修复失败片段,然后在带界面模式下重新运行一次。
验证回退流程时,添加参数,避免重放记忆掩盖问题。
--disable-replay trueCommand Templates
命令模板
Run:
npm run amw -- run --site <site> --task-type <task_type> --intent "<intent>" --fallback-steps-file ./trajectories/ready/<file>.json --store-dir ./data/<store> --session <session> --headed true --hold-open-ms 30000Run (force fallback):
npm run amw -- run --site <site> --task-type <task_type> --intent "<intent>" --fallback-steps-file ./trajectories/tmp/<file>.json --store-dir ./data/<store> --disable-replay trueValidate JSON:
npm run amw -- validate --steps-file ./trajectories/tmp/<file>.jsonInspect:
npm run amw -- list --store-dir ./data/<store>npm run amw -- search --site <site> --task-type <task_type> --intent "<intent>" --store-dir ./data/<store>
Grep-first retrieval (AND by chain):
rg -n --glob "*.json" "\"amw_match_line\"\\s*:\\s*\".*\"" trajectories/ready | rg -i "amw" | rg -i "site:<domain>" | rg -i "task:<task_type>" | rg -i "<keyword_or_zh_keyword>"运行:
npm run amw -- run --site <site> --task-type <task_type> --intent "<intent>" --fallback-steps-file ./trajectories/ready/<file>.json --store-dir ./data/<store> --session <session> --headed true --hold-open-ms 30000强制回退运行:
npm run amw -- run --site <site> --task-type <task_type> --intent "<intent>" --fallback-steps-file ./trajectories/tmp/<file>.json --store-dir ./data/<store> --disable-replay true验证JSON:
npm run amw -- validate --steps-file ./trajectories/tmp/<file>.json检查:
npm run amw -- list --store-dir ./data/<store>npm run amw -- search --site <site> --task-type <task_type> --intent "<intent>" --store-dir ./data/<store>
Grep优先检索(链式AND匹配):
rg -n --glob "*.json" "\"amw_match_line\"\\s*:\\s*\".*\"" trajectories/ready | rg -i "amw" | rg -i "site:<domain>" | rg -i "task:<task_type>" | rg -i "<keyword_or_zh_keyword>"