@optima-chat/optima-agent 0.8.93 → 0.8.95
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/.claude/skills/ads/SKILL.md +220 -261
- package/.claude/skills/ads/template/campaign/CREATIVES.md +18 -0
- package/.claude/skills/ads/template/campaign/NOTES.md +10 -0
- package/.claude/skills/ads/template/campaign/STRATEGY.md +29 -0
- package/.claude/skills/ads/template/user/ADS.md +29 -0
- package/.claude/skills/ads/template/user/LEARNINGS.md +15 -0
- package/.claude/skills/ads/template/user/PROGRESS.md +20 -0
- package/.claude/skills/ads/template/user/README.md +25 -0
- package/.claude/skills/ads/template/user/REPORTS/.gitkeep +0 -0
- package/.claude/skills/ads/template/user/assets/.gitignore +2 -0
- package/.claude/skills/ads/template/user/campaigns/.gitkeep +0 -0
- package/.claude/skills/browser/SKILL.md +72 -307
- package/.claude/skills/homepage/SKILL.md +6 -0
- package/.claude/skills/i18n/SKILL.md +31 -1
- package/.claude/skills/merchant/SKILL.md +5 -0
- package/.claude/skills/shop-content/SKILL.md +101 -0
- package/package.json +1 -1
|
@@ -23,60 +23,75 @@ description: "Browser automation for web interactions. Use when user needs to op
|
|
|
23
23
|
|
|
24
24
|
1. `browser-cli scripts` — 查看已有脚本(显示名称、描述、步骤)
|
|
25
25
|
2. 如果有匹配的脚本 → 直接用 `browser-cli runscript <name> --param ...`
|
|
26
|
-
3. 如果没有 →
|
|
26
|
+
3. 如果没有 → 手动用 browser-cli 命令完成任务
|
|
27
27
|
|
|
28
28
|
脚本执行零 token 消耗,比手动操作快 10 倍以上。
|
|
29
29
|
|
|
30
30
|
## 命令
|
|
31
31
|
|
|
32
|
-
###
|
|
32
|
+
### 会话管理
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
# 会话管理
|
|
36
35
|
browser-cli launch [--url <url>] [--force] # 启动浏览器(--force 先关闭已有会话)
|
|
37
36
|
browser-cli close # 关闭浏览器并释放资源
|
|
38
37
|
browser-cli status # 查看当前会话状态
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 导航
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
```bash
|
|
41
43
|
browser-cli navigate <url> # 跳转到 URL
|
|
42
44
|
browser-cli back # 后退
|
|
43
45
|
browser-cli refresh # 刷新页面
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 交互
|
|
44
49
|
|
|
45
|
-
|
|
50
|
+
```bash
|
|
46
51
|
browser-cli click <index> # 按索引点击元素
|
|
47
52
|
browser-cli input <index> <text> [--no-clear] # 输入文本(--no-clear 追加而非替换)
|
|
48
53
|
browser-cli select <index> <option> # 选择下拉选项
|
|
49
54
|
browser-cli scroll <up|down> [--pages <n>] # 滚动页面(默认 1 页)
|
|
50
55
|
browser-cli keys <key> # 键盘操作(Enter、Tab 等)
|
|
51
|
-
browser-cli upload <index> <file...>
|
|
56
|
+
browser-cli upload <index> <file...> # 上传文件到 file input(路径自动转换)
|
|
57
|
+
```
|
|
52
58
|
|
|
53
|
-
|
|
59
|
+
### 页面检查
|
|
60
|
+
|
|
61
|
+
```bash
|
|
54
62
|
browser-cli dom # 获取当前 DOM 状态
|
|
55
63
|
browser-cli screenshot [file] # 截图(默认:/tmp/screenshot.png)
|
|
56
64
|
browser-cli search <pattern> # 搜索页面文本
|
|
57
65
|
browser-cli find <css_selector> # 通过 CSS 选择器查询
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 标签页管理
|
|
58
69
|
|
|
59
|
-
|
|
70
|
+
```bash
|
|
60
71
|
browser-cli tabs # 列出所有标签页
|
|
61
72
|
browser-cli switch <tab_id> # 切换标签页
|
|
62
73
|
browser-cli close-tab <tab_id> # 关闭标签页
|
|
63
74
|
```
|
|
64
75
|
|
|
65
|
-
###
|
|
76
|
+
### 脚本
|
|
66
77
|
|
|
67
78
|
```bash
|
|
68
|
-
# 查看与管理
|
|
69
79
|
browser-cli scripts # 列出所有脚本(含描述和步骤)
|
|
70
80
|
browser-cli script-code <name> # 查看脚本源码
|
|
71
|
-
browser-cli delete-script <name> # 删除脚本
|
|
72
|
-
|
|
73
|
-
# 提交
|
|
74
|
-
browser-cli submit-script --name <name> --code-file <path> # 提交脚本(新建或覆盖)
|
|
75
|
-
|
|
76
|
-
# 执行
|
|
77
81
|
browser-cli runscript <name> --param key=value [...] # 执行脚本(自动轮询到完成)
|
|
78
82
|
browser-cli runscript <name> --param key=value --no-poll # 执行但不等待
|
|
79
83
|
browser-cli script-task <task-id> # 查询执行状态
|
|
84
|
+
browser-cli submit-script --name <name> --code-file <path> # 提交新脚本(新建或覆盖)
|
|
85
|
+
browser-cli delete-script <name> # 删除脚本
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Profile 管理
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
browser-cli profiles # 列出浏览器 profile
|
|
92
|
+
browser-cli delete-profile <id> # 删除 profile
|
|
93
|
+
browser-cli launch --profile <id> # 用指定 profile 启动
|
|
94
|
+
browser-cli runscript <name> --profile <id> --param ... # 用指定 profile 执行脚本
|
|
80
95
|
```
|
|
81
96
|
|
|
82
97
|
## DOM 索引格式
|
|
@@ -92,38 +107,6 @@ browser-cli script-task <task-id> # 查询执行状态
|
|
|
92
107
|
- 每次操作后索引会**重新分配** — 务必使用最新的索引
|
|
93
108
|
- 使用这些索引来执行 `click`、`input` 和 `select` 命令
|
|
94
109
|
|
|
95
|
-
## 登录与 Profile
|
|
96
|
-
|
|
97
|
-
浏览器支持命名 Profile,用于隔离不同账号的登录态(cookies、session)。
|
|
98
|
-
|
|
99
|
-
**当有明确的账号身份时(如多账号运营),必须使用 `--profile`。** 省略 `--profile` 会使用默认 Profile,导致不同账号登录态互相覆盖。
|
|
100
|
-
|
|
101
|
-
- **命名 Profile**:`--profile <id>` 隔离不同账号的登录态,`launch` 和 `runscript` 都支持
|
|
102
|
-
- **登录态自动持久化**:Profile 数据在浏览器运行时实时保存到磁盘,不依赖 close
|
|
103
|
-
- **首次登录**:需要用户提供账号和验证码
|
|
104
|
-
- **后续使用**:自动恢复登录态,无需重新登录
|
|
105
|
-
- **login_required 处理**:如果 `runscript` 报此错误,用 `browser-cli launch --profile <id> --url <平台URL>` 引导用户重新登录
|
|
106
|
-
|
|
107
|
-
```bash
|
|
108
|
-
# 登录到指定 Profile
|
|
109
|
-
browser-cli launch --profile xhs-tech --url https://creator.xiaohongshu.com
|
|
110
|
-
|
|
111
|
-
# 用指定 Profile 执行脚本
|
|
112
|
-
browser-cli runscript xiaohongshu-image-note --profile xhs-tech --param title="..."
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
## 文件路径
|
|
116
|
-
|
|
117
|
-
浏览器后端可以直接读取用户工作空间的文件(通过共享 EFS)。传文件路径时直接使用你看到的路径即可,后端会自动转换:
|
|
118
|
-
|
|
119
|
-
```
|
|
120
|
-
~/images/photo.jpg → 自动转换 ✓
|
|
121
|
-
/home/aiuser/images/photo.jpg → 自动转换 ✓
|
|
122
|
-
/mnt/efs/{userId}/images/... → 自动转换 ✓
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
不需要上传文件,不需要手动转换路径。
|
|
126
|
-
|
|
127
110
|
## 操作流程
|
|
128
111
|
|
|
129
112
|
### 流程一:有脚本(常见)
|
|
@@ -131,12 +114,6 @@ browser-cli runscript xiaohongshu-image-note --profile xhs-tech --param title=".
|
|
|
131
114
|
```bash
|
|
132
115
|
# 1. 检查脚本
|
|
133
116
|
browser-cli scripts
|
|
134
|
-
# 输出:
|
|
135
|
-
# xiaohongshu-image-note — 在小红书创作者平台发布图文笔记
|
|
136
|
-
# [1] navigate — 打开小红书发布页
|
|
137
|
-
# [2] switch_tab — 切换到上传图文模式
|
|
138
|
-
# [3] upload — 上传图片 {images}
|
|
139
|
-
# ...
|
|
140
117
|
|
|
141
118
|
# 2. 直接执行
|
|
142
119
|
browser-cli runscript xiaohongshu-image-note \
|
|
@@ -145,52 +122,35 @@ browser-cli runscript xiaohongshu-image-note \
|
|
|
145
122
|
--param 'images=["~/images/photo1.jpg", "~/images/photo2.jpg"]'
|
|
146
123
|
# 输出: ✓ Script completed
|
|
147
124
|
|
|
148
|
-
#
|
|
125
|
+
# 小红书评论
|
|
149
126
|
browser-cli runscript xiaohongshu-comment \
|
|
150
127
|
--param search_keyword="辞职做跨境电商" \
|
|
151
128
|
--param comment="写得好!"
|
|
152
|
-
|
|
153
|
-
#
|
|
129
|
+
|
|
130
|
+
# 小红书数据采集
|
|
131
|
+
browser-cli runscript xiaohongshu-data-collect
|
|
132
|
+
|
|
133
|
+
# Instagram 发帖
|
|
134
|
+
browser-cli runscript instagram-image-post \
|
|
135
|
+
--param 'images=["~/images/photo.jpg"]' \
|
|
136
|
+
--param body="Morning vibes ☕"
|
|
154
137
|
```
|
|
155
138
|
|
|
156
|
-
###
|
|
139
|
+
### 流程二:无脚本(手动操作)
|
|
157
140
|
|
|
158
141
|
```bash
|
|
159
|
-
# 1.
|
|
160
|
-
browser-cli
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
#
|
|
166
|
-
browser-cli
|
|
167
|
-
browser-cli
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
# → 登录成功,继续操作...
|
|
172
|
-
browser-cli dom # 分析页面
|
|
173
|
-
browser-cli click 1880 # 点击"上传图文"
|
|
174
|
-
browser-cli dom # 找到 file input
|
|
175
|
-
browser-cli upload 1092 ~/images/photo.jpg # 上传图片
|
|
176
|
-
browser-cli input 2905 "标题" # 填写标题
|
|
177
|
-
browser-cli input 3432 "正文内容" # 填写正文
|
|
178
|
-
browser-cli click 2814 # 点击发布
|
|
179
|
-
# → 任务完成
|
|
180
|
-
|
|
181
|
-
# 3. 生成 Python 脚本
|
|
182
|
-
# 根据上面的探索轨迹,生成脚本文件,必须包含:
|
|
183
|
-
# - DESCRIPTION: 脚本描述
|
|
184
|
-
# - STEPS: 语义步骤列表(StepDef)
|
|
185
|
-
# - run(ctx): 异步执行函数
|
|
186
|
-
# 写到本地文件
|
|
187
|
-
|
|
188
|
-
# 4. 提交脚本
|
|
189
|
-
browser-cli submit-script \
|
|
190
|
-
--name xiaohongshu-image-note \
|
|
191
|
-
--code-file /tmp/xiaohongshu_image_note.py
|
|
192
|
-
|
|
193
|
-
# 5. 关闭浏览器
|
|
142
|
+
# 1. 启动浏览器
|
|
143
|
+
browser-cli launch --url https://example.com
|
|
144
|
+
|
|
145
|
+
# 2. 查看 DOM,找到要操作的元素
|
|
146
|
+
browser-cli dom
|
|
147
|
+
|
|
148
|
+
# 3. 操作元素(用 DOM 返回的索引)
|
|
149
|
+
browser-cli click 15
|
|
150
|
+
browser-cli input 22 "内容"
|
|
151
|
+
browser-cli keys Enter
|
|
152
|
+
|
|
153
|
+
# 4. 完成后关闭
|
|
194
154
|
browser-cli close
|
|
195
155
|
```
|
|
196
156
|
|
|
@@ -199,228 +159,35 @@ browser-cli close
|
|
|
199
159
|
```bash
|
|
200
160
|
# 1. 执行脚本
|
|
201
161
|
browser-cli runscript xiaohongshu-image-note --param ...
|
|
202
|
-
# 输出:
|
|
203
|
-
#
|
|
204
|
-
#
|
|
205
|
-
# ✓ Completed:
|
|
206
|
-
# [1] navigate — 打开小红书发布页
|
|
207
|
-
# [2] switch_tab — 切换到上传图文模式
|
|
208
|
-
#
|
|
209
|
-
# ✗ Failed at step [3] upload: file input not found
|
|
210
|
-
#
|
|
211
|
-
# → Remaining steps:
|
|
212
|
-
# [3] upload — 上传图片 ["~/photo.jpg"]
|
|
213
|
-
# [4] fill_title — 填写标题'测试'
|
|
214
|
-
# [5] fill_body — 填写正文'内容'
|
|
215
|
-
# [6] publish — 点击发布按钮
|
|
216
|
-
# [7] verify — 确认发布成功
|
|
217
|
-
#
|
|
218
|
-
# Session is still open — use browser-cli dom/click/input to continue
|
|
219
|
-
|
|
220
|
-
# 2. 接管完成剩余步骤(Session 仍然打开,不需要重新 launch)
|
|
221
|
-
browser-cli dom # 查看当前页面
|
|
222
|
-
browser-cli click 15 # 继续操作
|
|
223
|
-
browser-cli input 22 "测试"
|
|
224
|
-
browser-cli click 30
|
|
225
|
-
# → 任务完成
|
|
226
|
-
|
|
227
|
-
# 3. (可选) 更新脚本以修复问题
|
|
228
|
-
# 重新生成脚本,覆盖旧版本
|
|
229
|
-
browser-cli submit-script \
|
|
230
|
-
--name xiaohongshu-image-note \
|
|
231
|
-
--code-file /tmp/xiaohongshu_image_note_v2.py
|
|
232
|
-
|
|
233
|
-
# 4. 关闭浏览器
|
|
234
|
-
browser-cli close
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
## 脚本代码规范
|
|
238
|
-
|
|
239
|
-
### 基本结构
|
|
240
|
-
|
|
241
|
-
每个脚本必须包含 `DESCRIPTION`、`STEPS` 和 `async def run(ctx)`:
|
|
242
|
-
|
|
243
|
-
```python
|
|
244
|
-
"""脚本描述。"""
|
|
245
|
-
from __future__ import annotations
|
|
246
|
-
import asyncio
|
|
247
|
-
import json
|
|
248
|
-
from app.scripts.base import ScriptContext, ScriptResult, StepDef, render_steps
|
|
249
|
-
|
|
250
|
-
DESCRIPTION = "一句话描述脚本功能"
|
|
251
|
-
|
|
252
|
-
STEPS = [
|
|
253
|
-
StepDef(id="step_id", description="步骤描述,支持 {param} 占位符"),
|
|
254
|
-
]
|
|
255
|
-
|
|
256
|
-
PAGE_SETTLE = 2 # 页面操作后等待秒数
|
|
257
|
-
|
|
258
|
-
async def run(ctx: ScriptContext) -> ScriptResult:
|
|
259
|
-
bs = ctx.browser_session
|
|
260
|
-
steps = render_steps(STEPS, ctx.params)
|
|
261
|
-
completed: list[StepDef] = []
|
|
262
|
-
|
|
263
|
-
try:
|
|
264
|
-
# 逐步执行,每完成一步 append
|
|
265
|
-
# ...
|
|
266
|
-
return ScriptResult(status="completed", output={...}, completed_steps=completed)
|
|
267
|
-
except Exception as e:
|
|
268
|
-
remaining = [s for s in steps if s not in completed]
|
|
269
|
-
snapshot = await _capture_snapshot(bs)
|
|
270
|
-
return ScriptResult(
|
|
271
|
-
status="needs_fallback",
|
|
272
|
-
completed_steps=completed,
|
|
273
|
-
remaining_steps=remaining,
|
|
274
|
-
error=str(e),
|
|
275
|
-
snapshot=snapshot,
|
|
276
|
-
)
|
|
277
|
-
|
|
278
|
-
async def _capture_snapshot(bs) -> dict:
|
|
279
|
-
try:
|
|
280
|
-
state = await bs.get_browser_state_summary(include_screenshot=False)
|
|
281
|
-
dom = state.dom_state.llm_representation() if state and state.dom_state else ""
|
|
282
|
-
except Exception:
|
|
283
|
-
dom = ""
|
|
284
|
-
return {"dom": dom}
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
### 浏览器操作 API
|
|
288
|
-
|
|
289
|
-
```python
|
|
290
|
-
# 导航
|
|
291
|
-
action = ctx.action_model(navigate={"url": "https://example.com"})
|
|
292
|
-
await ctx.controller.act(action, bs)
|
|
293
|
-
await asyncio.sleep(PAGE_SETTLE)
|
|
162
|
+
# 输出: ⚠ Script needs fallback
|
|
163
|
+
# → 显示已完成和剩余步骤
|
|
294
164
|
|
|
295
|
-
#
|
|
296
|
-
|
|
297
|
-
|
|
165
|
+
# 2. Session 仍然打开 — 用手动命令继续完成剩余步骤
|
|
166
|
+
browser-cli dom
|
|
167
|
+
browser-cli click 15
|
|
168
|
+
browser-cli input 22 "内容"
|
|
298
169
|
|
|
299
|
-
#
|
|
300
|
-
|
|
301
|
-
await ctx.controller.act(action, bs)
|
|
302
|
-
|
|
303
|
-
# 获取当前 DOM(每步操作前刷新)
|
|
304
|
-
state = await bs.get_browser_state_summary(include_screenshot=False, cached=False)
|
|
305
|
-
sm = state.dom_state.selector_map or {}
|
|
306
|
-
|
|
307
|
-
# 获取当前 URL
|
|
308
|
-
page = await bs.get_current_page()
|
|
309
|
-
url = await page.get_url()
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
### 元素查找(语义匹配,不要硬编码 index)
|
|
313
|
-
|
|
314
|
-
DOM index 每次页面变化后会重新分配,脚本中**不能硬编码 index**。
|
|
315
|
-
必须通过语义属性动态查找:
|
|
316
|
-
|
|
317
|
-
```python
|
|
318
|
-
# 按文字内容查找(如按钮、标签页)
|
|
319
|
-
def _find_by_text(sm, text, tag=None):
|
|
320
|
-
for idx, node in sm.items():
|
|
321
|
-
node_tag = (getattr(node, "tag_name", "") or "").lower()
|
|
322
|
-
if tag and node_tag != tag:
|
|
323
|
-
continue
|
|
324
|
-
try:
|
|
325
|
-
node_text = node.get_all_children_text().strip() if hasattr(node, "get_all_children_text") else ""
|
|
326
|
-
except Exception:
|
|
327
|
-
node_text = ""
|
|
328
|
-
if text in node_text:
|
|
329
|
-
return idx
|
|
330
|
-
return None
|
|
331
|
-
|
|
332
|
-
# 按 placeholder 查找(如输入框,支持 shadow DOM)
|
|
333
|
-
def _find_by_placeholder(sm, placeholder_contains):
|
|
334
|
-
for idx, node in sm.items():
|
|
335
|
-
attrs = getattr(node, "attributes", {}) or {}
|
|
336
|
-
if placeholder_contains in attrs.get("placeholder", ""):
|
|
337
|
-
return idx
|
|
338
|
-
# Shadow DOM fallback
|
|
339
|
-
if not attrs:
|
|
340
|
-
try:
|
|
341
|
-
llm = node.llm_representation() if hasattr(node, "llm_representation") else ""
|
|
342
|
-
if placeholder_contains in llm:
|
|
343
|
-
return idx
|
|
344
|
-
except Exception:
|
|
345
|
-
pass
|
|
346
|
-
return None
|
|
347
|
-
|
|
348
|
-
# 按 role 查找(如 contenteditable 编辑器)
|
|
349
|
-
def _find_by_role(sm, role, tag=None):
|
|
350
|
-
for idx, node in sm.items():
|
|
351
|
-
node_tag = (getattr(node, "tag_name", "") or "").lower()
|
|
352
|
-
if tag and node_tag != tag:
|
|
353
|
-
continue
|
|
354
|
-
attrs = getattr(node, "attributes", {}) or {}
|
|
355
|
-
if attrs.get("role") == role:
|
|
356
|
-
return idx
|
|
357
|
-
if attrs.get("contenteditable") and role == "textbox":
|
|
358
|
-
return idx
|
|
359
|
-
return None
|
|
360
|
-
|
|
361
|
-
# 按文件类型查找 file input(如图片上传)
|
|
362
|
-
def _find_image_file_input(bs, sm):
|
|
363
|
-
for idx, node in sm.items():
|
|
364
|
-
if not bs.is_file_input(node):
|
|
365
|
-
continue
|
|
366
|
-
attrs = getattr(node, "attributes", {}) or {}
|
|
367
|
-
accept = attrs.get("accept", "")
|
|
368
|
-
if any(ext in accept for ext in [".jpg", ".jpeg", ".png", ".webp"]):
|
|
369
|
-
return idx
|
|
370
|
-
for idx, node in sm.items():
|
|
371
|
-
if bs.is_file_input(node):
|
|
372
|
-
return idx
|
|
373
|
-
return None
|
|
170
|
+
# 3. 完成后关闭
|
|
171
|
+
browser-cli close
|
|
374
172
|
```
|
|
375
173
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
上传文件需要 `FileSystem` 和 `available_file_paths`:
|
|
379
|
-
|
|
380
|
-
```python
|
|
381
|
-
from browser_use.filesystem.file_system import FileSystem
|
|
382
|
-
from app.services.file_upload import UPLOAD_TEMP_BASE
|
|
383
|
-
import secrets as _secrets
|
|
174
|
+
## 文件路径
|
|
384
175
|
|
|
385
|
-
|
|
386
|
-
fs_dir = UPLOAD_TEMP_BASE / f"script_{_secrets.token_hex(4)}"
|
|
387
|
-
fs_dir.mkdir(parents=True, exist_ok=True)
|
|
388
|
-
file_system = FileSystem(base_dir=str(fs_dir), create_default_files=False)
|
|
176
|
+
浏览器后端可以直接读取用户工作空间的文件。传文件路径时直接使用你看到的路径即可,后端会自动转换:
|
|
389
177
|
|
|
390
|
-
|
|
391
|
-
images
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
action = ctx.action_model(upload_file={"index": file_idx, "path": img_path})
|
|
395
|
-
await ctx.controller.act(action, bs, available_file_paths=images, file_system=file_system)
|
|
178
|
+
```
|
|
179
|
+
~/images/photo.jpg → 自动转换 ✓
|
|
180
|
+
/home/aiuser/images/photo.jpg → 自动转换 ✓
|
|
181
|
+
/mnt/efs/{userId}/images/... → 自动转换 ✓
|
|
396
182
|
```
|
|
397
183
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
### 等待页面变化
|
|
401
|
-
|
|
402
|
-
页面操作后(导航、上传、点击)需要等待,用轮询模式:
|
|
403
|
-
|
|
404
|
-
```python
|
|
405
|
-
# 简单等待
|
|
406
|
-
await asyncio.sleep(PAGE_SETTLE)
|
|
184
|
+
## 需要用户登录态的任务
|
|
407
185
|
|
|
408
|
-
|
|
409
|
-
target_idx = None
|
|
410
|
-
for attempt in range(10):
|
|
411
|
-
await asyncio.sleep(PAGE_SETTLE)
|
|
412
|
-
state = await bs.get_browser_state_summary(include_screenshot=False, cached=False)
|
|
413
|
-
sm = state.dom_state.selector_map or {}
|
|
414
|
-
target_idx = _find_by_placeholder(sm, "填写标题")
|
|
415
|
-
if target_idx is not None:
|
|
416
|
-
break
|
|
417
|
-
if target_idx is None:
|
|
418
|
-
raise RuntimeError("等待超时:目标元素未出现")
|
|
419
|
-
```
|
|
186
|
+
当用户要求操作需要登录的平台(小红书、Instagram、微博、淘宝等社交/电商平台),在开始执行前先引导用户安装扩展:
|
|
420
187
|
|
|
421
|
-
|
|
188
|
+
"这个任务需要用到你在 [平台名] 的登录态。请安装 Optima Browser Operator Chrome 扩展,这样我可以直接用你已登录的浏览器来操作,不需要你提供密码。"
|
|
422
189
|
|
|
423
|
-
|
|
190
|
+
安装后用户回到聊天页面,扩展自动连接,直接执行任务。如果用户在该平台未登录,提示用户先在自己的 Chrome 里登录。
|
|
424
191
|
|
|
425
192
|
## 注意事项
|
|
426
193
|
|
|
@@ -428,9 +195,7 @@ if target_idx is None:
|
|
|
428
195
|
- **DOM 自动返回**:每个操作会自动返回 DOM 状态 — 无需单独调用 `browser-cli dom`
|
|
429
196
|
- **避免不必要的截图**:截图消耗 token,日常导航用 DOM 输出即可
|
|
430
197
|
- **5 分钟超时**:无操作 5 分钟后会话自动关闭
|
|
431
|
-
- **登录自动保持**:登录一次后自动持久化,无需重复登录
|
|
432
|
-
- **文件路径自动转换**:直接传你看到的路径(~/xxx),后端自动处理
|
|
433
198
|
- **务必关闭**:操作完成后运行 `browser-cli close` 释放资源
|
|
434
|
-
- **login_required 处理**:如果 runscript 返回 `login_required`
|
|
199
|
+
- **login_required 处理**:如果 runscript 返回 `login_required` 错误,说明该平台未登录。如果用户已安装 Extension 且 Extension 已连接,用户的 Chrome 通常已经登录了——让用户在自己的 Chrome 里手动登录该平台,然后重新 `runscript`。如果没有 Extension(走 Chromium),用 `browser-cli launch --url <平台URL>` 引导用户登录
|
|
435
200
|
- **Fallback 后更新脚本**:如果脚本频繁失败,重新生成并 submit-script 覆盖
|
|
436
201
|
- **Extension 模式**:标记了 `REQUIRES_USER_SESSION=True` 的脚本会自动使用用户的真实 Chrome(通过 Optima Browser Operator 扩展),未标记的脚本走 Chromium。这由后端自动判断,无需手动指定
|
|
@@ -58,6 +58,12 @@ description: 店铺首页配置。管理首页区块(Banner、集合列表、
|
|
|
58
58
|
| 调整背景叠加颜色 | `commerce homepage update-page-settings --overlay-color "#f5f5f5"` |
|
|
59
59
|
| 移除背景图 | `commerce homepage update-page-settings --remove-background` |
|
|
60
60
|
|
|
61
|
+
### 品牌色
|
|
62
|
+
|
|
63
|
+
| 用户说 | 命令 |
|
|
64
|
+
|-------|------|
|
|
65
|
+
| "修改品牌色" / "设置主题色" | **merchant skill**:`commerce merchant update --primary-color "#xxx"` |
|
|
66
|
+
|
|
61
67
|
### 通用操作
|
|
62
68
|
|
|
63
69
|
| 用户说 | 命令 |
|
|
@@ -177,6 +177,26 @@ commerce i18n homepage set \
|
|
|
177
177
|
commerce i18n homepage list --section-id section_123
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
+
### 场景7: 店铺政策翻译
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# 翻译退货政策
|
|
184
|
+
commerce i18n shop-policy set --policy-type returns --lang zh-CN --title "退货政策" --content "# 退货政策\n\n..."
|
|
185
|
+
|
|
186
|
+
# 翻译隐私政策
|
|
187
|
+
commerce i18n shop-policy set --policy-type privacy --lang ja-JP --title "プライバシーポリシー" --content "# ..."
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### 场景8: 店铺关于页面翻译
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# 翻译关于页面
|
|
194
|
+
commerce i18n shop-about set --lang zh-CN --about-content "# 我们的故事\n\n..."
|
|
195
|
+
|
|
196
|
+
# 翻译联系页面补充内容
|
|
197
|
+
commerce i18n shop-about set --lang ja-JP --contact-content "# お問い合わせ\n\n..."
|
|
198
|
+
```
|
|
199
|
+
|
|
180
200
|
## 卓越标准 (Excellence Standards)
|
|
181
201
|
|
|
182
202
|
### 翻译质量维度
|
|
@@ -354,6 +374,8 @@ commerce i18n variant create --variant-id var_2 --lang ja-JP \
|
|
|
354
374
|
- "翻译集合信息" → `commerce i18n collection create --collection-id XX --lang YY`
|
|
355
375
|
- "设置商户多语言信息" → `commerce i18n merchant create --lang XX`
|
|
356
376
|
- "翻译首页区块" → `commerce i18n homepage set --section-id XX --lang YY`
|
|
377
|
+
- "翻译店铺政策" → `commerce i18n shop-policy set --policy-type XX --lang YY`
|
|
378
|
+
- "翻译关于页面" → `commerce i18n shop-about set --lang XX`
|
|
357
379
|
|
|
358
380
|
### 商品翻译
|
|
359
381
|
|
|
@@ -390,6 +412,14 @@ commerce i18n variant create --variant-id var_2 --lang ja-JP \
|
|
|
390
412
|
- `commerce i18n homepage list` - 查看首页翻译
|
|
391
413
|
- `commerce i18n homepage delete` - 删除首页翻译
|
|
392
414
|
|
|
415
|
+
### 店铺政策翻译
|
|
416
|
+
|
|
417
|
+
- `commerce i18n shop-policy set` - 设置店铺政策翻译
|
|
418
|
+
|
|
419
|
+
### 店铺关于页面翻译
|
|
420
|
+
|
|
421
|
+
- `commerce i18n shop-about set` - 设置店铺关于页面翻译
|
|
422
|
+
|
|
393
423
|
## 详细示例 (Detailed Examples)
|
|
394
424
|
|
|
395
425
|
### 商品翻译示例
|
|
@@ -477,7 +507,7 @@ commerce i18n product create --product-id prod_2 --lang ja-JP --name "..."
|
|
|
477
507
|
|
|
478
508
|
## 重要提示 (Important Notes)
|
|
479
509
|
|
|
480
|
-
- **支持的语言**:en-US, es-ES, ja-JP, vi-VN, zh-CN
|
|
510
|
+
- **支持的语言**:en-US, es-ES, ja-JP, vi-VN, zh-CN, zh-HK, zh-TW
|
|
481
511
|
- **语言代码格式**:必须使用BCP 47格式(如 en-US),不能使用短代码(如 en)
|
|
482
512
|
- **变体翻译参数**:使用 `--variant-id`(不是 `--product-id`)
|
|
483
513
|
- **变体规格翻译**:`variant-attributes-translations` 格式需要同时翻译规格键和值
|
|
@@ -13,6 +13,7 @@ description: "店铺基础信息管理。使用场景:查看店铺信息、更
|
|
|
13
13
|
| "修改店铺名称" / "更新店铺描述" | `commerce merchant update --name/--description` |
|
|
14
14
|
| "设置联系方式" | `commerce merchant update --contact-*` |
|
|
15
15
|
| "更新发货地址" | `commerce merchant update --origin-*` |
|
|
16
|
+
| "设置品牌色" / "修改主题色" / "换个颜色" | `commerce merchant update --primary-color "#1a3a5c"` |
|
|
16
17
|
|
|
17
18
|
## 不在此模块(重要)
|
|
18
19
|
|
|
@@ -51,6 +52,7 @@ commerce merchant update [选项]
|
|
|
51
52
|
| `--description` | 店铺描述 |
|
|
52
53
|
| `--default-currency` | 默认货币(USD, CNY 等) |
|
|
53
54
|
| `--google-ads-customer-id` | Google Ads 客户 ID(10位数字) |
|
|
55
|
+
| `--primary-color` | 品牌主色(hex 格式,如 #FF5A5F) |
|
|
54
56
|
|
|
55
57
|
### 联系方式
|
|
56
58
|
| 选项 | 说明 |
|
|
@@ -91,6 +93,9 @@ commerce merchant update \
|
|
|
91
93
|
--origin-postal-code 518000 \
|
|
92
94
|
--origin-line-1 "科技园路1号" \
|
|
93
95
|
--origin-state 广东
|
|
96
|
+
|
|
97
|
+
# 设置品牌色
|
|
98
|
+
commerce merchant update --primary-color "#1a3a5c"
|
|
94
99
|
```
|
|
95
100
|
|
|
96
101
|
---
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: shop-content
|
|
3
|
+
description: "店铺内容管理。使用场景:更新关于我们、设置联系信息、管理退货/隐私/条款/配送政策、设置社交链接。注意:翻译用 i18n skill。"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 店铺内容管理
|
|
7
|
+
|
|
8
|
+
## 典型场景
|
|
9
|
+
|
|
10
|
+
| 用户说 | 命令 |
|
|
11
|
+
|--------|------|
|
|
12
|
+
| "更新关于我们" / "写关于页面" | `commerce shop-about update --about-content "# Our Story..."` |
|
|
13
|
+
| "设置联系方式" | `commerce shop-about update --contact-email "..." --contact-phone "..."` |
|
|
14
|
+
| "添加联系页面内容" | `commerce shop-about update --contact-content "# Contact..."` |
|
|
15
|
+
| "查看关于信息" | `commerce shop-about get` |
|
|
16
|
+
| "设置 Instagram" / "添加社交链接" | `commerce shop-about update --social-instagram "https://..."` |
|
|
17
|
+
| "设置退货政策" / "更新退货政策" | `commerce shop-policy set --type returns --title "退货政策" --content "# ..."` |
|
|
18
|
+
| "设置隐私政策" | `commerce shop-policy set --type privacy --title "隐私政策" --content "# ..."` |
|
|
19
|
+
| "设置服务条款" | `commerce shop-policy set --type terms --title "服务条款" --content "# ..."` |
|
|
20
|
+
| "设置配送政策" | `commerce shop-policy set --type shipping --title "配送政策" --content "# ..."` |
|
|
21
|
+
| "查看所有政策" | `commerce shop-policy list` |
|
|
22
|
+
| "查看退货政策" | `commerce shop-policy get --type returns` |
|
|
23
|
+
|
|
24
|
+
## 不在此模块(重要)
|
|
25
|
+
|
|
26
|
+
| 用户说 | 正确位置 |
|
|
27
|
+
|--------|----------|
|
|
28
|
+
| "翻译退货政策" / "政策日语版" | **i18n skill**:`commerce i18n shop-policy set` |
|
|
29
|
+
| "翻译关于我们" | **i18n skill**:`commerce i18n shop-about set` |
|
|
30
|
+
| "首页设置" / "首页区块" | **homepage skill** |
|
|
31
|
+
| "修改品牌色" / "主题色" | **merchant skill**:`commerce merchant update --primary-color` |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 关于页面内容
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# 查看当前内容
|
|
39
|
+
commerce shop-about get
|
|
40
|
+
|
|
41
|
+
# 更新关于页面(Markdown 格式)
|
|
42
|
+
commerce shop-about update --about-content "# Our Story\n\nWe started in 2020..."
|
|
43
|
+
|
|
44
|
+
# 更新联系页面补充内容
|
|
45
|
+
commerce shop-about update --contact-content "## 批发合作\n\n请联系..."
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 联系信息
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
commerce shop-about update \
|
|
52
|
+
--contact-email "hello@store.com" \
|
|
53
|
+
--contact-phone "+86 138xxxx" \
|
|
54
|
+
--business-address "深圳市南山区..." \
|
|
55
|
+
--business-hours "Mon-Fri 9:00-18:00"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 社交链接
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# 设置单个
|
|
62
|
+
commerce shop-about update --social-instagram "https://instagram.com/mystore"
|
|
63
|
+
|
|
64
|
+
# 设置多个
|
|
65
|
+
commerce shop-about update \
|
|
66
|
+
--social-instagram "https://instagram.com/mystore" \
|
|
67
|
+
--social-tiktok "https://tiktok.com/@mystore" \
|
|
68
|
+
--social-youtube "https://youtube.com/@mystore"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
支持:`--social-instagram`, `--social-facebook`, `--social-twitter`, `--social-tiktok`, `--social-youtube`
|
|
72
|
+
|
|
73
|
+
## 店铺政策
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# 查看所有政策
|
|
77
|
+
commerce shop-policy list
|
|
78
|
+
|
|
79
|
+
# 查看特定政策
|
|
80
|
+
commerce shop-policy get --type returns
|
|
81
|
+
|
|
82
|
+
# 设置/更新政策(Markdown 格式)
|
|
83
|
+
commerce shop-policy set --type returns --title "退货政策" --content "# 退货政策\n\n..."
|
|
84
|
+
commerce shop-policy set --type privacy --title "隐私政策" --content "# 隐私政策\n\n..."
|
|
85
|
+
commerce shop-policy set --type terms --title "服务条款" --content "# 服务条款\n\n..."
|
|
86
|
+
commerce shop-policy set --type shipping --title "配送政策" --content "# 配送政策\n\n..."
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**注意**:政策类型只能是 `terms`、`privacy`、`returns`、`shipping`。
|
|
90
|
+
|
|
91
|
+
## 内容格式
|
|
92
|
+
|
|
93
|
+
所有内容字段(about_content、contact_content、policy content)使用 **Markdown 格式**,支持标题、列表、粗体、链接等。
|
|
94
|
+
|
|
95
|
+
## 命令参考
|
|
96
|
+
|
|
97
|
+
- `commerce shop-about get` - 查看关于/联系信息
|
|
98
|
+
- `commerce shop-about update` - 更新关于/联系/社交链接
|
|
99
|
+
- `commerce shop-policy list` - 查看所有政策
|
|
100
|
+
- `commerce shop-policy get --type <type>` - 查看特定政策
|
|
101
|
+
- `commerce shop-policy set --type <type> --title <title> --content <content>` - 设置政策
|