Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
9cc9262
✅ 修复 e2e 测试 service worker 超时并优化等待策略
CodFrm Mar 13, 2026
c4b26ed
✨ feat: 添加 Agent 聊天功能
CodFrm Mar 11, 2026
e735d8f
✨ feat: Agent API 通过 GM API 权限系统鉴权
CodFrm Mar 11, 2026
69c8973
✨ feat: 添加 OPFS 文件浏览器和优化 Agent 工具注册
CodFrm Mar 11, 2026
3e17c2c
🐛 fix: 修复 Agent tool calling 多个问题
CodFrm Mar 11, 2026
3cb6baa
🎨 style: 统一代码格式化
CodFrm Mar 11, 2026
e836c33
✨ feat: 添加 Agent 消息元数据展示和操作工具条
CodFrm Mar 11, 2026
8cd1a89
✨ feat: 添加 CATTool 系统和修复沙箱上下文注入
CodFrm Mar 12, 2026
f6f17cd
♻️ refactor: 拆分 Install Page 为 hooks + 独立视图组件
CodFrm Mar 12, 2026
e471187
📝 docs: 添加 CATTool 示例和使用文档
CodFrm Mar 12, 2026
3070ea1
🐛 fix: 修复 Agent 对话上下文丢失和流式错误处理
CodFrm Mar 12, 2026
c2c277c
♻️ refactor: 统一 UI/脚本聊天通道,规范字段命名,补充测试
CodFrm Mar 12, 2026
6e72ccc
✨ feat: 添加对话命令系统、修复删除弹框消失和会话 URL 同步
CodFrm Mar 12, 2026
359717e
✨ feat: CATTool 安装流程改进、模型配置存储迁移
CodFrm Mar 12, 2026
af95bbf
🔧 fix: 修复 lint 错误和 JSX 字面字符串警告
CodFrm Mar 12, 2026
d9bff8c
🔧 style: prettier 格式化
CodFrm Mar 12, 2026
d802120
✨ feat: 实现 CAT.agent.dom 页面 DOM 操作能力
CodFrm Mar 12, 2026
5e544ee
✨ feat: 添加 Skill 系统 — 提示词 + CATTool + 参考资料的组合能力
CodFrm Mar 12, 2026
4ff3dd7
✅ 添加 Agent 核心逻辑 E2E 测试
CodFrm Mar 12, 2026
7437f9e
♻️ refactor: Skill 系统三层渐进加载 — system prompt 只注入摘要,按需加载完整提示词和工具
CodFrm Mar 12, 2026
c3cad66
✨ feat: 实现临时会话(ephemeral conversation)支持
CodFrm Mar 12, 2026
a6c2e26
✨ feat: 实现 MCP Client — Streamable HTTP transport + Tools/Resources/P…
CodFrm Mar 12, 2026
027cdc6
🐛 fix: listModels 过滤 __default__ key 避免 ModelCard 崩溃
CodFrm Mar 12, 2026
eb7baa4
🐛 fix: OpenAI provider 支持 reasoning_content 思考过程展示并修复 usage/choices 处理顺序
CodFrm Mar 12, 2026
3bca9d8
✨ feat: Skill 管理页面 — 列表/安装/编辑/卸载 + 消息通道 + 单元测试
CodFrm Mar 12, 2026
1639aa6
🧹 chore: 移除未使用的 ComingSoon 组件
CodFrm Mar 12, 2026
fa7953d
✨ feat: Skill ZIP 包一键安装支持
CodFrm Mar 12, 2026
a24bf82
🐛 fix: trusted 模式 debugger 权限通过 confirm 页面请求
CodFrm Mar 12, 2026
6bdaf28
♻️ refactor: 移除 execute_skill_tool,load_skill 时按需注册 CATTool 为独立 LLM tool
CodFrm Mar 12, 2026
3a429a1
✨ feat: MCP 服务器详情面板 + 测试连接 loading 优化
CodFrm Mar 12, 2026
aee5000
✨ feat: Skill 安装优化 — 仅 ZIP 包 + 拖拽 + 独立安装页面
CodFrm Mar 12, 2026
cb0244a
✨ feat: 流式事件增强 + 淘宝 Skill 示例 + 输入法修复
CodFrm Mar 12, 2026
814d7a1
🧹 chore: 修复 prettier lint 错误 + eslint 忽略 .claude 目录
CodFrm Mar 12, 2026
48d5b94
🐛 fix: 修复测试和类型检查问题
CodFrm Mar 12, 2026
e6c8e06
feat: 会话附件支持 — 工具产出图片/文件展示
CodFrm Mar 12, 2026
ab05e05
fix: skill CATTool 权限验证失败 — UUID map 直接携带 grants
CodFrm Mar 12, 2026
9109fd3
feat: 移除 MCP 脚本 API + Tools/Skills 写操作权限强化
CodFrm Mar 12, 2026
bb67f45
fix: 修复代码块高亮渲染显示 [object Object] + 暗色模式适配
CodFrm Mar 12, 2026
d83136e
fix: debugger 权限改为安装时授予,移除动态请求流程
CodFrm Mar 13, 2026
42e2c89
feat: 用户消息编辑重新发送 + 修复工具调用展开内容截断
CodFrm Mar 13, 2026
ecb0c43
fix: MessageToolbar 移除 hasMetadata 提前返回,确保操作按钮始终可用
CodFrm Mar 13, 2026
78a80d0
feat: agent DOM monitor + CDP 重构 + browser_automation skill 示例
CodFrm Mar 13, 2026
2c9b452
feat: Anthropic/OpenAI prompt caching 支持 + 缓存用量展示
CodFrm Mar 13, 2026
18f8863
feat: 系统提示词模块化 + 聊天逻辑重构 + DOM 监控优化
CodFrm Mar 13, 2026
ec2fc50
fix: 修复 isolate:false 下 UUID mock 冲突导致的测试失败
CodFrm Mar 13, 2026
6cef826
🐛 修复和优化 ScriptEditor 问题 (#1258)
cyfung1031 Mar 11, 2026
abf61e7
chore: bump version to 1.4.0-beta
CodFrm Mar 13, 2026
4e0790c
fix: 构建时将 prerelease 版本号转换为 Chrome 兼容格式
CodFrm Mar 13, 2026
3ab199c
refactor: 提取 toChromeVersion 为公共函数
CodFrm Mar 13, 2026
db118d6
feat: 新增 CATTool 管理页面
CodFrm Mar 13, 2026
f4e3709
fix: 修复重新生成用户消息时内容重复的 bug
CodFrm Mar 13, 2026
8127753
feat: 错误处理三件套(超时、重试、错误分类)及单元测试
CodFrm Mar 13, 2026
6162dd5
refactor: 删除内置 DOM Tools,转为 browser-automation Skill 中的 CATTool
CodFrm Mar 13, 2026
a84b6a9
refactor: 优化 Agent 系统提示词,解耦工具实现细节
CodFrm Mar 13, 2026
2d6e7f3
refactor: 优化 browser-automation Skill 工具命名和提示词
CodFrm Mar 13, 2026
4f9d498
feat: ChatMessage.content 升级为 string | ContentBlock[] 支持多模态内容
CodFrm Mar 13, 2026
971f2bc
test: 补充 Agent 核心路径单元测试和 E2E 测试
CodFrm Mar 13, 2026
960a091
feat: CATTool 支持 @require 外部库加载
CodFrm Mar 13, 2026
016dcb8
fix: 修复 screenshot CATTool 截图失败的问题
CodFrm Mar 13, 2026
15ffbac
feat: Skill 管理支持查看工具代码和刷新缓存
CodFrm Mar 13, 2026
38767a1
fix: Skill 更新时清理旧的 scripts/references 文件
CodFrm Mar 13, 2026
779b0a3
feat: Agent 定时任务系统(internal/event 双模式)
CodFrm Mar 14, 2026
1c81c1c
fix: cdpClick 增加元素遮挡检测,避免点击到覆盖层
CodFrm Mar 14, 2026
db8e6a6
fix: 补全 Agent GM API 注册和 ESLint grant 白名单
CodFrm Mar 14, 2026
fb236d3
refactor: 迁移 Agent 示例到独立 skills 仓库
CodFrm Mar 14, 2026
5cb0e6a
feat: Skill Config 系统 — 支持 SKILL.md 声明配置字段并在沙箱中注入 CAT_CONFIG
CodFrm Mar 14, 2026
e98bdc9
docs: 同步 scriptcat.d.ts 类型声明并添加中文版
CodFrm Mar 14, 2026
aa8c203
refactor: 明确 Agent GM API 返回值类型,消除 unknown/any
CodFrm Mar 14, 2026
32e612b
fix: 修正 scriptcat.d.ts 类型声明与源码实现的差异
CodFrm Mar 14, 2026
7efcd37
fix: 修复 E2E 测试 flaky 问题
CodFrm Mar 14, 2026
d49afaf
feat: 允许 CATTool 通过 @timeout 元数据自定义超时时间
CodFrm Mar 14, 2026
8f2a01a
fix: 修复 ESLint 警告并优化 E2E service worker 就绪逻辑
CodFrm Mar 15, 2026
29cf81c
fix: 修复亮色模式下用户消息气泡字体颜色问题
CodFrm Mar 15, 2026
388b6d6
feat: 将 prompt cache 控制权交给调用方,默认启用缓存
CodFrm Mar 15, 2026
0aaef32
Merge remote-tracking branch 'origin/main' into feature/agent
CodFrm Mar 16, 2026
cf63761
Merge remote-tracking branch 'origin/release/v1.4' into feature/agent
CodFrm Mar 16, 2026
e00df98
⚡️ CI 支持 feature/* 分支构建、Agent 错误持久化及 UI 优化
CodFrm Mar 16, 2026
e4385ee
⚡️ Anthropic max_tokens 必填修复及模型配置 UI 支持自定义 max tokens
CodFrm Mar 16, 2026
b366a7a
⚡️ CAT.agent.model 只读 API 及多 tool_call 并行修复
CodFrm Mar 16, 2026
381cd70
🎨 Prettier 格式化修正
CodFrm Mar 16, 2026
fe6fc52
♻️ 统一 Model/MCP 数据加载方式,UI 页面通过 SW 消息通道获取数据
CodFrm Mar 17, 2026
59e761a
✨ 支持图片输入与模型图片生成
CodFrm Mar 17, 2026
78e422f
✨ Provider 图标识别、模型能力检测及模型服务卡片布局修复
CodFrm Mar 17, 2026
247c368
🐛 修复 Gemini 图片输出检测:仅 Gemini 2.0 Flash 支持
CodFrm Mar 17, 2026
89249a1
✨ 支持用户手动标记模型视觉输入和图片输出能力
CodFrm Mar 17, 2026
6405fed
🐛 修复 --isolate=false 下 vi.mock 不稳定导致的测试偶发失败
CodFrm Mar 17, 2026
520e338
✨ 支持禁用 tools 及 Markdown 图片预览增强
CodFrm Mar 17, 2026
8b44394
处理e2e问题加上缓存
CodFrm Mar 17, 2026
3ae34cb
♻️ 合并 CATTool 到 Skill 系统,统一为 execute_skill_script
CodFrm Mar 17, 2026
222d2f1
🐛 修复 CI 测试失败:navigator mock 污染和 e2e fixture 两阶段启动不可靠
CodFrm Mar 17, 2026
ddd0dfb
🐛 修复 CI 测试失败:navigator mock 污染和 e2e fixture 两阶段启动不可靠
CodFrm Mar 17, 2026
5f61397
♻️ 重命名 ==CATTool== 为 ==SkillScript==,清除所有 CATTool 残留
CodFrm Mar 17, 2026
b00c148
♻️ 重构 Agent E2E 测试:两阶段启动 + 共享 fixture + 修复 Repo 缓存 bug
CodFrm Mar 17, 2026
adadc5c
✨ 实现 Agent 内置工具:web_fetch、web_search、ask_user、agent、task 管理
CodFrm Mar 17, 2026
3b2cf33
🐛 修复 Agent 工具测试:替换失效的 vi.mock 别名路径为 mockSender 方案
CodFrm Mar 17, 2026
426f742
Merge branch 'feature/agent' into worktree-opfs-tools
CodFrm Mar 18, 2026
41bbe50
✨ 实现 OPFS 工作区文件系统工具及 CAT.agent.opfs 用户脚本 API
CodFrm Mar 18, 2026
1dfbe84
✨ 实现 /compact 命令和自动 compact 机制
CodFrm Mar 18, 2026
08866d2
✨ 新增 execute_script 内置工具:支持 page/sandbox 双模式执行 JS
CodFrm Mar 18, 2026
cfcdfca
✨ 实现 Tab 操作工具:get_tab_content、list_tabs、open_tab、close_tab、activate_tab
CodFrm Mar 18, 2026
641c0e3
Merge branch 'worktree-tab-tools' into feature/agent
CodFrm Mar 18, 2026
2a1314e
✨ 增强截图和 OPFS 能力:区域截图、saveTo 持久化、bloburl 读取
CodFrm Mar 18, 2026
cf6d0da
✨ CAT.agent.opfs.write 支持 Blob 和 data URL 二进制写入
CodFrm Mar 18, 2026
fa47c20
✨ web_fetch 增加 prompt 摘要功能 & 模型配置支持复制
CodFrm Mar 18, 2026
1bffca0
✨ ask_user 工具支持结构化选项(单选/多选)
CodFrm Mar 18, 2026
6050d3c
✨ 新增 Bing/百度搜索引擎 & Agent 设置页面
CodFrm Mar 18, 2026
8178141
🐛 修复 Agent 设置与类型定义问题
CodFrm Mar 19, 2026
3564676
✨ 附件扩展名、readAttachment API、缓存用量追踪与 UI 优化
CodFrm Mar 19, 2026
f9f0c14
🐛 修复 readAttachment 返回类型断言
CodFrm Mar 19, 2026
7e2b16e
✨ 支持 Agent 会话后台运行模式
CodFrm Mar 20, 2026
5c1b1d2
✨ 任务工具持久化 & OPFS Blob 跨上下文传输修复
CodFrm Mar 20, 2026
1b811c8
🐛 修复 agent.test.ts mockRepo 缺少 getAttachment 方法
CodFrm Mar 20, 2026
2ccbbaa
🐛 Offscreen→SW 消息通道改用 postMessage 支持 Blob 传输
CodFrm Mar 20, 2026
738f406
♻️ 移除 Offscreen 对 ExtensionMessage 的依赖
CodFrm Mar 20, 2026
2e60aa6
🐛 修复 offscreen 页面 navigator.serviceWorker.controller 为 null 的问题
CodFrm Mar 20, 2026
f14c43b
Merge remote-tracking branch 'origin/fix/offscreen-sw-postmessage-blo…
CodFrm Mar 20, 2026
250db4f
✨ OPFS API 适配 postMessage 通道 & 修复 Blob 传输
CodFrm Mar 20, 2026
19a231b
fix: executeScript 改用 MAIN world,DOM 操作改用 ISOLATED world
CodFrm Mar 20, 2026
fecb9db
✨ Agent 多项改进:附件路径迁移、LLM 重试机制、系统提示词优化
CodFrm Mar 20, 2026
f90ba1d
📝 完善 Agent 系统提示词和工具描述
CodFrm Mar 20, 2026
2f57342
✨ 新增 get_task/delete_task 工具,优化 Agent 工具提示词分层
CodFrm Mar 21, 2026
debfc57
✨ 子代理类型系统、Compact 提示词优化与 UI 改进
CodFrm Mar 21, 2026
34ce3cc
✨ 工具调用防护、斜杠命令菜单与子代理详情持久化
CodFrm Mar 21, 2026
584fabb
✨ 工具调用防护 startIndex 避免重复警告、Task/SubAgent UI 优化与连接测试改进
CodFrm Mar 21, 2026
009b948
✨ 新增会话导出为 Markdown 功能
CodFrm Mar 21, 2026
cb0ebff
Merge branch 'release/v1.4' into feature/agent
CodFrm Mar 21, 2026
34df70d
🔧 prettier 自动格式化
CodFrm Mar 21, 2026
ae295c6
🐛 修复 20 个单元测试失败和 e2e 问题
CodFrm Mar 21, 2026
9666d0e
✨ opfs_read 支持文本内容读取、搜索提取失败提示、正则校验
CodFrm Mar 22, 2026
14fa7ab
✨ 新增智谱(Zhipu)AI Provider 支持
CodFrm Mar 26, 2026
705c8b3
⏪ 还原 md/example 文件的 prettier 格式化,添加 prettierignore 规则
CodFrm Apr 1, 2026
fc11419
⏪ 还原 tsconfig.json/.prettierrc/bug_report 模板的 prettier 格式化
CodFrm Apr 1, 2026
2764981
Merge branch 'release/v1.4' into feature/agent
CodFrm Apr 1, 2026
1aabb34
💄 格式化合并后的代码(prettier 自动调整)
CodFrm Apr 1, 2026
0293a5b
🔀 解决 release/v1.4 合并冲突,修复 MainLayout 测试
CodFrm Apr 2, 2026
9e65a3a
🔀 合并 release/v1.4,使用 v1.4.0-beta.1 版本号
CodFrm Apr 2, 2026
7e1b529
🐛 修复 CI 测试失败:移除 vi.resetModules() 避免模块缓存污染
CodFrm Apr 2, 2026
e724989
🐛 E2E: 设置菜单项点击前先滚动到可视区域
CodFrm Apr 2, 2026
6621eb6
🐛 E2E: 用 .menu-setting 精确定位设置菜单项
CodFrm Apr 2, 2026
aad7c45
🐛 修复测试全局变量污染导致 CI 随机失败
CodFrm Apr 2, 2026
f387285
🔧 修复测试文件 prettier 格式错误
CodFrm Apr 3, 2026
354154e
🐛 移除 isolate=false,启用测试隔离避免全局状态污染
CodFrm Apr 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
- release/*
- feature/*
- dev
paths-ignore:
- ".github/**"
Expand All @@ -25,7 +26,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
cache: "pnpm"

- name: Package with Node
env:
Expand All @@ -51,4 +52,3 @@ jobs:
name: scriptcat-chrome-extension
path: |
dist/ext/*

2 changes: 1 addition & 1 deletion .github/workflows/packageRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
cache: "pnpm"

- name: Package with Node
env:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
- release/*
- feature/*
- dev
- develop/*
pull_request:
Expand All @@ -21,7 +22,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
cache: "pnpm"

- name: Setup pnpm
run: corepack enable
Expand Down Expand Up @@ -61,7 +62,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
cache: "pnpm"

- name: Setup pnpm
run: corepack enable
Expand Down
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ yarn.lock

# Claude Code
.claude

# Docs & examples
*.md
example/
204 changes: 204 additions & 0 deletions e2e/agent-conversation.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
import { expect } from "@playwright/test";
import { test, makeTextSSE, makeToolCallSSE } from "./agent-fixtures";
import { runInlineTestScript } from "./utils";

const TARGET_URL = "https://content-security-policy.com/";

test.describe("Agent Conversation API", () => {
test.setTimeout(300_000);

test("basic chat — send message and receive text reply", async ({ context, extensionId, mockLLMResponse }) => {
mockLLMResponse(() => makeTextSSE("1+1等于2。"));

const code = `// ==UserScript==
// @name Agent Basic Chat Test
// @namespace https://e2e.test
// @version 1.0.0
// @description Test basic CAT.agent.conversation.chat()
// @author E2E
// @match ${TARGET_URL}*
// @grant CAT.agent.conversation
// ==/UserScript==

(async () => {
let passed = 0;
let failed = 0;
function assert(name, condition) {
if (condition) { passed++; console.log("PASS: " + name); }
else { failed++; console.log("FAIL: " + name); }
}

try {
const conv = await CAT.agent.conversation.create({
system: "你是一个助手。",
});
assert("conversation created", !!conv && !!conv.id);

const reply = await conv.chat("1+1等于几?");
assert("reply has content", !!reply.content);
assert("reply content correct", reply.content.includes("2"));
assert("reply has usage", !!reply.usage);
} catch (e) {
failed++;
console.log("ERROR: " + e.message);
}

console.log("通过: " + passed + ", 失败: " + failed);
})();
`;

const { passed, failed, logs } = await runInlineTestScript(context, extensionId, code, TARGET_URL, 60_000);

console.log(`[agent-basic-chat] passed=${passed}, failed=${failed}`);
if (failed !== 0) console.log("[agent-basic-chat] logs:", logs.join("\n"));
expect(failed, "Some basic chat tests failed").toBe(0);
expect(passed, "No test results found").toBeGreaterThan(0);
});

test("tool calling — script-defined tools are invoked", async ({ context, extensionId, mockLLMResponse }) => {
let callCount = 0;
mockLLMResponse(() => {
callCount++;
// First call: LLM decides to call the tool
if (callCount === 1) {
return makeToolCallSSE([
{
id: "call_1",
name: "get_weather",
arguments: JSON.stringify({ city: "北京" }),
},
]);
}
// Second call: after tool result, LLM gives final answer
return makeTextSSE("北京今天22度,多云。");
});

const code = `// ==UserScript==
// @name Agent Tool Calling Test
// @namespace https://e2e.test
// @version 1.0.0
// @description Test tool calling via CAT.agent.conversation
// @author E2E
// @match ${TARGET_URL}*
// @grant CAT.agent.conversation
// ==/UserScript==

(async () => {
let passed = 0;
let failed = 0;
let toolCalled = false;
let toolArgs = null;

function assert(name, condition) {
if (condition) { passed++; console.log("PASS: " + name); }
else { failed++; console.log("FAIL: " + name); }
}

try {
const conv = await CAT.agent.conversation.create({
system: "你是天气助手。",
tools: [
{
name: "get_weather",
description: "获取天气",
parameters: {
type: "object",
properties: {
city: { type: "string", description: "城市" },
},
required: ["city"],
},
handler: async (args) => {
toolCalled = true;
toolArgs = args;
return { city: args.city, temperature: 22, condition: "多云" };
},
},
],
});

const reply = await conv.chat("北京天气怎么样?");
assert("tool was called", toolCalled);
assert("tool received city arg", toolArgs && toolArgs.city === "北京");
assert("final reply has content", !!reply.content);
assert("final reply mentions weather", reply.content.includes("22") || reply.content.includes("多云"));
} catch (e) {
failed++;
console.log("ERROR: " + e.message);
}

console.log("通过: " + passed + ", 失败: " + failed);
})();
`;

const { passed, failed, logs } = await runInlineTestScript(context, extensionId, code, TARGET_URL, 60_000);

console.log(`[agent-tool-calling] passed=${passed}, failed=${failed}`);
if (failed !== 0) console.log("[agent-tool-calling] logs:", logs.join("\n"));
expect(failed, "Some tool calling tests failed").toBe(0);
expect(passed, "No test results found").toBeGreaterThan(0);
});

test("multi-turn conversation — context is preserved", async ({ context, extensionId, mockLLMResponse }) => {
let requestCount = 0;
let lastMessages: any[] = [];

mockLLMResponse(({ messages }) => {
requestCount++;
lastMessages = messages;
if (requestCount === 1) {
return makeTextSSE("斐波那契数列是一个数列,每个数是前两个数之和。");
}
return makeTextSSE("前5个数是:1, 1, 2, 3, 5。");
});

const code = `// ==UserScript==
// @name Agent Multi-turn Test
// @namespace https://e2e.test
// @version 1.0.0
// @description Test multi-turn conversation context preservation
// @author E2E
// @match ${TARGET_URL}*
// @grant CAT.agent.conversation
// ==/UserScript==

(async () => {
let passed = 0;
let failed = 0;
function assert(name, condition) {
if (condition) { passed++; console.log("PASS: " + name); }
else { failed++; console.log("FAIL: " + name); }
}

try {
const conv = await CAT.agent.conversation.create({
system: "你是数学老师。",
});

const reply1 = await conv.chat("什么是斐波那契数列?");
assert("first reply has content", !!reply1.content);

const reply2 = await conv.chat("前5个数是什么?");
assert("second reply has content", !!reply2.content);
assert("second reply has fibonacci numbers", reply2.content.includes("1") && reply2.content.includes("5"));
} catch (e) {
failed++;
console.log("ERROR: " + e.message);
}

console.log("通过: " + passed + ", 失败: " + failed);
})();
`;

const { passed, failed, logs } = await runInlineTestScript(context, extensionId, code, TARGET_URL, 60_000);

console.log(`[agent-multi-turn] passed=${passed}, failed=${failed}`);
if (failed !== 0) console.log("[agent-multi-turn] logs:", logs.join("\n"));
expect(failed, "Some multi-turn tests failed").toBe(0);
expect(passed, "No test results found").toBeGreaterThan(0);
// Verify the mock received multiple requests (context was sent)
expect(requestCount, "Should have made 2 LLM requests").toBe(2);
// The second request should contain history messages
expect(lastMessages.length, "Second request should include conversation history").toBeGreaterThan(2);
});
});
Loading
Loading