@nickyzj2023/ai 1.3.1 → 1.3.2

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/dist/cli.mjs +10 -5
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as get_time_default, c as runAgent, i as get_weather_default, o as defineModel, r as loadMCPTools } from "./src-DEDOOez9.mjs";
2
- import { extractErrorMessage } from "@nickyzj2023/utils";
2
+ import { compactStr, extractErrorMessage } from "@nickyzj2023/utils";
3
3
  import readline from "node:readline";
4
4
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
5
5
  import { homedir } from "node:os";
@@ -136,7 +136,7 @@ var TUI = class {
136
136
  /**
137
137
  * 为文本添加ANSI颜色;非TTY输出(重定向/管道)时返回原文本,避免日志出现转义码。
138
138
  * @param text 原始文本
139
- * @param ansiCode ANSI颜色代码,如 "90"(亮黑,大多数终端显示为灰色)
139
+ * @param ansiCode ANSI颜色代码,如"90"(亮黑,大多数终端显示为灰色)
140
140
  */
141
141
  colorize(text, ansiCode) {
142
142
  if (!process.stdout.isTTY) return text;
@@ -155,12 +155,17 @@ var TUI = class {
155
155
  /** 打印工具调用 */
156
156
  printToolCall(name, args) {
157
157
  this.preparePrint("tool_call");
158
- process.stdout.write(`[工具调用:${name}] ${args}`);
158
+ process.stdout.write(`[工具调用:${name}] ${args}\n`);
159
159
  }
160
160
  /** 打印工具结果 */
161
- printToolResult(name, result) {
161
+ printToolResult(name, result, options) {
162
+ const { ellipsis = true } = options ?? {};
163
+ const _result = ellipsis ? compactStr(result, {
164
+ maxLength: 200,
165
+ truncateMiddle: true
166
+ }) : result;
162
167
  this.preparePrint("tool_result");
163
- process.stdout.write(this.colorize(`[工具结果:${name}] ${result}`, "90"));
168
+ process.stdout.write(this.colorize(`[工具结果:${name}] ${_result}\n`, "90"));
164
169
  }
165
170
  formatter = new Intl.NumberFormat("en-US", {
166
171
  notation: "compact",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nickyzj2023/ai",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "我的“pi”,参考了pi-from-scratch",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",