在原有只读抓取 (browser_fetch_page) 基础上,新增 observe→act 循环, 让 Agent 能在用户的 Chrome 中实际操作网页:点击/输入/滚动/等待/页内跳转。 后端: - 新工具 browser_act,按 session 复用标签页,返回带编号的可交互元素清单+正文 - browser_context 任务队列扩展 kind/session_id/action 与 observation 结果 - /api/browser-context 路由下发 act 任务、接收 observation - BrowserContextConfig 增加 actions_enabled 等开关,tools.py 两级门控 - 接线 app.py 路由挂载、app_config.py 配置字段、config.yaml 工具注册 前端: - ChatPage 处理「发送当前页」回跳的 browser_context query 参数并自动提交 扩展 (browser-extension/deer-web-clipper): - shared.js 自包含注入函数 deerObservePage / deerPerformAction - background.js 按 kind 分发任务,session→tab 映射存 chrome.storage.session 测试:tests/test_browser_act.py(队列往返 + 工具校验 + 模拟扩展成功路径,8 passed) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
75 lines
2.4 KiB
HTML
75 lines
2.4 KiB
HTML
<!doctype html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>zncm Web Clipper Settings</title>
|
|
<link rel="stylesheet" href="styles.css" />
|
|
</head>
|
|
<body>
|
|
<main class="options">
|
|
<h1>zncm Web Clipper Settings</h1>
|
|
<label>
|
|
API 地址
|
|
<input id="apiBaseUrl" />
|
|
</label>
|
|
<label>
|
|
前端地址
|
|
<input id="webBaseUrl" />
|
|
</label>
|
|
<label class="checkbox">
|
|
<input id="autoDiscoverServiceUrl" type="checkbox" />
|
|
自动识别已打开 zncm 页面的服务地址
|
|
</label>
|
|
<div class="actions">
|
|
<button id="discoverService" type="button">重新识别服务地址</button>
|
|
</div>
|
|
<p id="serviceStatus" class="status"></p>
|
|
<label>
|
|
Access Token
|
|
<textarea id="accessToken" rows="5" placeholder="会自动从已登录 zncm 页面或 access_token Cookie 获取。也可以手动粘贴。"></textarea>
|
|
</label>
|
|
<label class="checkbox">
|
|
<input id="tokenSyncEnabled" type="checkbox" />
|
|
自动同步已登录 zncm 的 token
|
|
</label>
|
|
<div class="actions">
|
|
<button id="syncToken" type="button">Sync token now</button>
|
|
</div>
|
|
<p id="tokenStatus" class="status"></p>
|
|
<label class="checkbox">
|
|
<input id="pageAssistantEnabled" type="checkbox" />
|
|
启用页面问答框
|
|
</label>
|
|
<label>
|
|
默认首问
|
|
<textarea id="defaultPrompt" rows="4"></textarea>
|
|
</label>
|
|
<label class="checkbox">
|
|
<input id="taskPollingEnabled" type="checkbox" />
|
|
启用 zncm 聊天触发的浏览器抓取任务
|
|
</label>
|
|
<label>
|
|
Worker ID
|
|
<input id="workerId" placeholder="自动生成" />
|
|
</label>
|
|
<label>
|
|
任务轮询间隔秒数
|
|
<input id="taskPollIntervalSeconds" type="number" min="3" step="1" />
|
|
</label>
|
|
<label>
|
|
页面加载超时秒数
|
|
<input id="taskPageLoadTimeoutSeconds" type="number" min="5" step="1" />
|
|
</label>
|
|
<label class="checkbox">
|
|
<input id="closeTaskTabs" type="checkbox" />
|
|
抓取完成后关闭任务标签页
|
|
</label>
|
|
<button id="save" type="button">保存</button>
|
|
<p id="status" class="status"></p>
|
|
</main>
|
|
<script src="config.js"></script>
|
|
<script src="shared.js"></script>
|
|
<script src="options.js"></script>
|
|
</body>
|
|
</html>
|