shenxiang-ai-cli 0.4.2 → 0.4.3
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.
- package/dist/index.js +27 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -737,7 +737,7 @@ function banner() {
|
|
|
737
737
|
const w = chalk.white.bold;
|
|
738
738
|
const lines = [
|
|
739
739
|
``,
|
|
740
|
-
` ${p("/\\_/\\")} ${b("\u6C88\u7FD4\u7684AI\u52A9\u624B")} ${m("v0.4.
|
|
740
|
+
` ${p("/\\_/\\")} ${b("\u6C88\u7FD4\u7684AI\u52A9\u624B")} ${m("v0.4.3")}`,
|
|
741
741
|
` ${p("(")} ${y("o")}${p(".")}${y("o")} ${p(")")} ${d("\u7EC8\u7AEF\u91CC\u7684AI\u5168\u6808\u5F00\u53D1\u642D\u6863")}`,
|
|
742
742
|
` ${p("> ")}${r("^")}${p(" <")}`,
|
|
743
743
|
` ${p("/|")}${p(" |")}${p("\\")} ${d("\u4F60\u7684\u7F16\u7A0B\u597D\u4F19\u4F34")} ${chalk.hex("#A78BFA")("\u{1F43E}")}`,
|
|
@@ -1874,10 +1874,30 @@ var Agent = class {
|
|
|
1874
1874
|
let hasTextOutput = false;
|
|
1875
1875
|
let hasThinkingOutput = false;
|
|
1876
1876
|
let toolSpinnerStarted = false;
|
|
1877
|
+
let idleTimer = null;
|
|
1878
|
+
const resetIdleTimer = () => {
|
|
1879
|
+
if (idleTimer) clearTimeout(idleTimer);
|
|
1880
|
+
idleTimer = setTimeout(() => {
|
|
1881
|
+
if (!spinner.isSpinning && spinnerStopped) {
|
|
1882
|
+
spinner.text = "AI \u6B63\u5728\u601D\u8003...";
|
|
1883
|
+
spinner.start();
|
|
1884
|
+
}
|
|
1885
|
+
}, 1500);
|
|
1886
|
+
};
|
|
1887
|
+
const clearIdleTimer = () => {
|
|
1888
|
+
if (idleTimer) {
|
|
1889
|
+
clearTimeout(idleTimer);
|
|
1890
|
+
idleTimer = null;
|
|
1891
|
+
}
|
|
1892
|
+
};
|
|
1877
1893
|
try {
|
|
1878
1894
|
for await (const chunk of provider.chatStream(this.messages, this.tools, config3)) {
|
|
1879
|
-
|
|
1895
|
+
resetIdleTimer();
|
|
1896
|
+
if (spinner.isSpinning && (chunk.type === "text" || chunk.type === "thinking")) {
|
|
1880
1897
|
spinner.stop();
|
|
1898
|
+
}
|
|
1899
|
+
if (!spinnerStopped && (chunk.type === "text" || chunk.type === "tool_call" || chunk.type === "thinking")) {
|
|
1900
|
+
if (spinner.isSpinning) spinner.stop();
|
|
1881
1901
|
spinnerStopped = true;
|
|
1882
1902
|
if (chunk.type === "thinking") {
|
|
1883
1903
|
process.stdout.write("\n");
|
|
@@ -1960,14 +1980,14 @@ var Agent = class {
|
|
|
1960
1980
|
}
|
|
1961
1981
|
}
|
|
1962
1982
|
} catch (err) {
|
|
1963
|
-
|
|
1964
|
-
if (
|
|
1983
|
+
clearIdleTimer();
|
|
1984
|
+
if (spinner.isSpinning) spinner.stop();
|
|
1965
1985
|
const msg = err instanceof Error ? err.message : String(err);
|
|
1966
1986
|
printError(t("errors.apiError", { message: msg }));
|
|
1967
1987
|
return "";
|
|
1968
1988
|
}
|
|
1969
|
-
|
|
1970
|
-
if (
|
|
1989
|
+
clearIdleTimer();
|
|
1990
|
+
if (spinner.isSpinning) spinner.stop();
|
|
1971
1991
|
if (responseText) {
|
|
1972
1992
|
process.stdout.write("\n");
|
|
1973
1993
|
}
|
|
@@ -3148,7 +3168,7 @@ function fmtTokens3(n) {
|
|
|
3148
3168
|
var program = new Command();
|
|
3149
3169
|
var config2 = getConfig();
|
|
3150
3170
|
setLocale(config2.locale);
|
|
3151
|
-
program.name("sxai").description(t("description")).version("0.4.
|
|
3171
|
+
program.name("sxai").description(t("description")).version("0.4.3");
|
|
3152
3172
|
program.command("chat", { isDefault: true }).description("\u542F\u52A8\u4EA4\u4E92\u5F0FAI\u5BF9\u8BDD\uFF08\u9ED8\u8BA4\u547D\u4EE4\uFF09").option("-m, --model <model>", "\u6307\u5B9AAI\u6A21\u578B", config2.model).option("-y, --yolo", "\u81EA\u52A8\u6A21\u5F0F\uFF1A\u8DF3\u8FC7\u6240\u6709\u786E\u8BA4\uFF0C\u8BA9AI\u81EA\u4E3B\u6267\u884C").action(async (options) => {
|
|
3153
3173
|
if (options.model && options.model !== config2.model) {
|
|
3154
3174
|
setConfig("model", options.model);
|