opc-agent 5.0.0-rc.21 → 5.0.0-rc.22

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.
Files changed (2) hide show
  1. package/TASK.md +38 -42
  2. package/package.json +1 -1
package/TASK.md CHANGED
@@ -1,42 +1,38 @@
1
- # TASK.md P1 批量任务
2
-
3
- ## 项目信息
4
- - 路径: C:\Users\mingjwan\opc-agent
5
- - 构建: `npx tsc --noEmit`(必须通过)
6
- - 风格: CommonJS, TypeScript 5.x, ES2022
7
- - 每个功能完成后 git commit
8
-
9
- ## 任务清单
10
-
11
- ### 1. gpt-4o-mini 硬编码改为 Ollama-first(5min)
12
- 搜索所有 `gpt-4o-mini` 硬编码,改为先检测本地 Ollama 可用模型,fallback `gpt-4o-mini`。
13
- - `src/` 目录全文搜索 `gpt-4o-mini`
14
- - 替换为: 读取 oad.yaml 配置的 model,如果没配就用 auto-detect(先 Ollama OpenAI)
15
-
16
- ### 2. handleMessageStream 走完整 pipeline(10min)
17
- `src/core/agent.ts` `handleMessageStream` 需要和 `handleMessage` 一样走完整的 pipeline:
18
- - Memory Prefetch(提取关键词 搜索记忆 注入 system message)
19
- - Memory Sync(检测记忆触发词 保存)
20
- - Context Window Guard(检查 token 截断)
21
- - OutputGuard(过滤 `<think>` 标签等)
22
- - 如果 handleMessageStream 不存在或是 stub,确认 handleMessage 已覆盖所有 pipeline 步骤
23
-
24
- ### 3. Provider Failover(10min)
25
- 在 `src/providers/` 中实现 provider failover:
26
- - 如果当前 provider 返回 429/500/502/503,自动切换到下一个可用 provider
27
- - Provider 优先级: oad.yaml 显式配置 > config.json > env > auto-detect
28
- - 实现 `FailoverProvider` wrapper:接受 provider 数组,逐个尝试
29
- - `createProvider` 中,如果检测到多个可用 provider,用 FailoverProvider 包装
30
-
31
- ### 4. `opc studio` 命令在 help 中显示(2min)
32
- 检查 `src/cli/` 目录,确保 `studio` 子命令注册到 commander program 中,`opc --help` 能看到。
33
-
34
- ### 5. License 修复(2min)
35
- - `package.json` 中 license 字段确认是 `Apache-2.0`
36
- - 如果存在 `LICENSE` 文件,确认内容正确
37
-
38
- ## 约束
39
- - 每个功能改完后 `npx tsc --noEmit` 必须通过
40
- - 不引入新依赖
41
- - 每个功能完成后 `git add -A && git commit`
42
- - 不修改测试文件(避免破坏现有测试)
1
+ # TASK: Add read_file + write_file builtin tools
2
+
3
+ ## Goal
4
+ Add two new builtin tools so the Agent can read and write files on the local filesystem during conversations.
5
+
6
+ ## Requirements
7
+
8
+ ### 1. `read_file` tool (`src/tools/builtin/read-file.ts`)
9
+ - Parameters: `path` (string, required), `offset` (number, optional, line to start from), `limit` (number, optional, max lines)
10
+ - Returns file content as string
11
+ - Security: resolve path relative to agent workspace (cwd), reject `..` traversal outside workspace
12
+ - Handle errors gracefully (file not found, permission denied)
13
+ - For binary files, return a message saying "Binary file, cannot display"
14
+ - Max read size: 100KB, truncate with message if exceeded
15
+
16
+ ### 2. `write_file` tool (`src/tools/builtin/write-file.ts`)
17
+ - Parameters: `path` (string, required), `content` (string, required), `append` (boolean, optional, default false)
18
+ - Creates parent directories automatically (`mkdirSync recursive`)
19
+ - Security: same path restriction as read_file
20
+ - Returns confirmation with bytes written and absolute path
21
+
22
+ ### 3. Register both tools
23
+ - Add to the builtin tools registry (check how existing tools like `web_search.ts`, `execute_code.ts` are registered)
24
+ - Follow the exact same pattern/interface as existing builtin tools
25
+
26
+ ### 4. Format
27
+ - Follow the existing builtin tool format in `src/tools/builtin/`
28
+ - Use `BuiltinTool` interface (or whatever interface the existing tools use)
29
+ - CommonJS compatible (module.exports or export)
30
+
31
+ ## Constraints
32
+ - TypeScript, CommonJS (module: commonjs, target: ES2022)
33
+ - No new dependencies
34
+ - Must pass `npx tsc --noEmit`
35
+
36
+ ## After completing
37
+ 1. Run `npx tsc --noEmit` to verify
38
+ 2. Run `git add -A && git commit -m "feat: read_file + write_file builtin tools"`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opc-agent",
3
- "version": "5.0.0-rc.21",
3
+ "version": "5.0.0-rc.22",
4
4
  "description": "Open Agent Framework — Build, test, and run AI Agents for business workstations",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",