@saber2pr/ai-agent 0.0.29 → 0.0.31

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.
@@ -14,10 +14,10 @@ const prompts_1 = require("@langchain/core/prompts");
14
14
  const langgraph_1 = require("@langchain/langgraph");
15
15
  const prebuilt_1 = require("@langchain/langgraph/prebuilt");
16
16
  const openai_1 = require("@langchain/openai");
17
- const builtin_1 = require("../tools/builtin");
18
- const convertToLangChainTool_1 = require("../utils/convertToLangChainTool");
19
17
  const index_js_1 = require("@modelcontextprotocol/sdk/client/index.js");
20
18
  const stdio_js_1 = require("@modelcontextprotocol/sdk/client/stdio.js");
19
+ const builtin_1 = require("../tools/builtin");
20
+ const convertToLangChainTool_1 = require("../utils/convertToLangChainTool");
21
21
  const jsonSchemaToZod_1 = require("../utils/jsonSchemaToZod");
22
22
  exports.CONFIG_FILE = path_1.default.join(os_1.default.homedir(), ".saber2pr-agent.json");
23
23
  // ✅ 全局设置:修复 AbortSignal 监听器数量警告
@@ -365,13 +365,19 @@ class McpGraphAgent {
365
365
  进度:{doneCount}/{targetCount}
366
366
  已审计文件:{auditedList}
367
367
 
368
- # 格式要求
368
+ # 🛠️ 工具调用规范
369
369
  1. Arguments 必须是纯粹的 JSON 对象,严禁将其作为字符串放入引号中。
370
370
  2. 严禁对 JSON 内容进行二次转义。
371
+ 3. **禁止空操作**:如果你认为任务已完成或不需要调用工具,请不要输出任何 Action 结构。严禁使用 "None"、"null" 或空字符串作为工具名称。
372
+
373
+ # 🎯 核心指令
374
+ 1. **任务终结判定**:当你已经读取了用户要求的文件、回答了问题或完成了审计目标时,必须立即提供最终回复。
375
+ 2. **回复格式**:任务完成时,请以 "Final Answer:" 开头进行总结,此时不再调用任何工具。
376
+ 3. **避免重复**:不要重复调用相同的工具和参数。如果工具返回错误,请分析原因(如参数 Schema 错误)而不是盲目重试。{recentToolCalls}
371
377
 
372
- # 指令
373
- 1. 避免陷入在同一个文件上的无限循环尝试。
374
- 2. 不要重复调用相同的工具和参数,如果工具已经返回结果,请基于结果继续工作而不是再次调用。{recentToolCalls}
378
+ # 📝 审计任务专项
379
+ 1. 避免在同一个文件上陷入无限循环尝试。
380
+ 2. 优先通过 \`list_directory\` 了解全局,再深入具体文件。
375
381
  {extraPrompt}`;
376
382
  // 2. 核心逻辑:处理消息上下文
377
383
  let inputMessages;
package/lib/core/agent.js CHANGED
@@ -42,11 +42,11 @@ const openai_1 = __importDefault(require("openai"));
42
42
  const os_1 = __importDefault(require("os"));
43
43
  const path_1 = __importDefault(require("path"));
44
44
  const readline = __importStar(require("readline"));
45
+ const zod_to_json_schema_1 = require("zod-to-json-schema");
45
46
  const index_js_1 = require("@modelcontextprotocol/sdk/client/index.js");
46
47
  const stdio_js_1 = require("@modelcontextprotocol/sdk/client/stdio.js");
47
48
  const config_1 = require("../config/config");
48
49
  const builtin_1 = require("../tools/builtin");
49
- const zod_to_json_schema_1 = require("zod-to-json-schema");
50
50
  const jsonSchemaToZod_1 = require("../utils/jsonSchemaToZod");
51
51
  class McpAgent {
52
52
  constructor(options) {
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getTsLspTools = void 0;
4
+ const zod_1 = require("zod");
4
5
  const ts_context_mcp_1 = require("@saber2pr/ts-context-mcp");
5
6
  const createTool_1 = require("../../utils/createTool");
6
- const zod_1 = require("zod");
7
7
  const getTsLspTools = (targetDir) => {
8
8
  const engine = new ts_context_mcp_1.PromptEngine(targetDir);
9
9
  return [
@@ -1,5 +1,5 @@
1
- import { Client } from '@modelcontextprotocol/sdk/client/index';
2
1
  import { z } from 'zod';
2
+ import { Client } from '@modelcontextprotocol/sdk/client/index';
3
3
  import { AgentGraphModel } from '../model/AgentGraphModel';
4
4
  export interface ApiConfig {
5
5
  baseURL: string;
@@ -1,5 +1,5 @@
1
- import { DynamicStructuredTool } from "@langchain/core/tools";
2
- import { ToolInfo } from "../types/type";
1
+ import { DynamicStructuredTool } from '@langchain/core/tools';
2
+ import { ToolInfo } from '../types/type';
3
3
  export declare function convertToLangChainTool(info: ToolInfo): DynamicStructuredTool<import("zod").ZodObject<any, import("zod").UnknownKeysParam, import("zod").ZodTypeAny, {
4
4
  [x: string]: any;
5
5
  }, {
@@ -1,5 +1,5 @@
1
- import { ToolInfo } from '../types/type';
2
1
  import { z } from 'zod';
2
+ import { ToolInfo } from '../types/type';
3
3
  export interface CreateToolOptions {
4
4
  name: string;
5
5
  description: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saber2pr/ai-agent",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "description": "AI Assistant CLI.",
5
5
  "author": "saber2pr",
6
6
  "license": "ISC",