@nuvin/nuvin-core 1.9.2 → 1.9.4
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/VERSION +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +86 -18
- package/package.json +1 -1
package/dist/VERSION
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1622,6 +1622,7 @@ declare class BashTool implements FunctionTool<BashParams, ToolExecutionContext,
|
|
|
1622
1622
|
*/
|
|
1623
1623
|
execute(p: BashParams, ctx?: ToolExecutionContext): Promise<BashResult>;
|
|
1624
1624
|
private execOnce;
|
|
1625
|
+
private killProcessGroup;
|
|
1625
1626
|
private defaultShell;
|
|
1626
1627
|
private shellExists;
|
|
1627
1628
|
private shellArgs;
|
package/dist/index.js
CHANGED
|
@@ -1406,7 +1406,7 @@ var AgentOrchestrator = class {
|
|
|
1406
1406
|
toInvocations(toolCalls) {
|
|
1407
1407
|
return convertToolCalls(toolCalls, {
|
|
1408
1408
|
strict: this.cfg.strictToolValidation ?? false,
|
|
1409
|
-
throwOnError:
|
|
1409
|
+
throwOnError: false
|
|
1410
1410
|
});
|
|
1411
1411
|
}
|
|
1412
1412
|
};
|
|
@@ -3026,13 +3026,15 @@ var BashTool = class {
|
|
|
3026
3026
|
const executable = this.defaultShell();
|
|
3027
3027
|
const execArgs = this.shellArgs(cmd, executable);
|
|
3028
3028
|
let child;
|
|
3029
|
+
const isWindows = os3.platform() === "win32";
|
|
3029
3030
|
try {
|
|
3030
3031
|
child = spawn(executable, execArgs, {
|
|
3031
3032
|
cwd,
|
|
3032
3033
|
env: process.env,
|
|
3033
3034
|
stdio: ["ignore", "pipe", "pipe"],
|
|
3034
3035
|
shell: false,
|
|
3035
|
-
windowsHide: true
|
|
3036
|
+
windowsHide: true,
|
|
3037
|
+
detached: !isWindows
|
|
3036
3038
|
});
|
|
3037
3039
|
} catch (error) {
|
|
3038
3040
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -3040,18 +3042,23 @@ var BashTool = class {
|
|
|
3040
3042
|
}
|
|
3041
3043
|
throw error;
|
|
3042
3044
|
}
|
|
3043
|
-
child.
|
|
3045
|
+
child.once("error", (err2) => {
|
|
3044
3046
|
if ("code" in err2 && err2.code === "ENOENT") {
|
|
3045
|
-
child.
|
|
3047
|
+
if (!child.killed) {
|
|
3048
|
+
child.emit("close", -1, null);
|
|
3049
|
+
}
|
|
3046
3050
|
}
|
|
3047
3051
|
});
|
|
3048
3052
|
let timer = null;
|
|
3053
|
+
let abortKillTimer = null;
|
|
3054
|
+
let abortHandler = null;
|
|
3049
3055
|
let timedOut = false;
|
|
3056
|
+
let truncated = false;
|
|
3050
3057
|
const deadline = new Promise((_, rej) => {
|
|
3051
3058
|
timer = setTimeout(() => {
|
|
3052
3059
|
timedOut = true;
|
|
3053
3060
|
try {
|
|
3054
|
-
|
|
3061
|
+
this.killProcessGroup(child, isWindows);
|
|
3055
3062
|
} catch {
|
|
3056
3063
|
}
|
|
3057
3064
|
rej(new Error(`Command timed out after ${timeoutMs} ms`));
|
|
@@ -3059,13 +3066,16 @@ var BashTool = class {
|
|
|
3059
3066
|
});
|
|
3060
3067
|
const abort = new Promise((_, rej) => {
|
|
3061
3068
|
if (signal) {
|
|
3062
|
-
|
|
3063
|
-
if (timer)
|
|
3069
|
+
abortHandler = () => {
|
|
3070
|
+
if (timer) {
|
|
3071
|
+
clearTimeout(timer);
|
|
3072
|
+
timer = null;
|
|
3073
|
+
}
|
|
3064
3074
|
try {
|
|
3065
|
-
|
|
3066
|
-
setTimeout(() => {
|
|
3075
|
+
this.killProcessGroup(child, isWindows, "SIGTERM");
|
|
3076
|
+
abortKillTimer = setTimeout(() => {
|
|
3067
3077
|
if (child && !child.killed) {
|
|
3068
|
-
|
|
3078
|
+
this.killProcessGroup(child, isWindows);
|
|
3069
3079
|
}
|
|
3070
3080
|
}, 1e3);
|
|
3071
3081
|
} catch {
|
|
@@ -3081,29 +3091,69 @@ var BashTool = class {
|
|
|
3081
3091
|
const stdout = [];
|
|
3082
3092
|
const stderr = [];
|
|
3083
3093
|
let total = 0;
|
|
3084
|
-
const
|
|
3094
|
+
const stdoutHandler = (chunk) => {
|
|
3095
|
+
if (truncated) return;
|
|
3096
|
+
total += chunk.length;
|
|
3097
|
+
if (total > maxOutputBytes) {
|
|
3098
|
+
truncated = true;
|
|
3099
|
+
stdout.push(Buffer.from(`
|
|
3100
|
+
[truncated at ${maxOutputBytes} bytes]
|
|
3101
|
+
`));
|
|
3102
|
+
this.killProcessGroup(child, isWindows);
|
|
3103
|
+
return;
|
|
3104
|
+
}
|
|
3105
|
+
stdout.push(chunk);
|
|
3106
|
+
};
|
|
3107
|
+
const stderrHandler = (chunk) => {
|
|
3108
|
+
if (truncated) return;
|
|
3085
3109
|
total += chunk.length;
|
|
3086
3110
|
if (total > maxOutputBytes) {
|
|
3087
|
-
|
|
3111
|
+
truncated = true;
|
|
3112
|
+
stderr.push(Buffer.from(`
|
|
3088
3113
|
[truncated at ${maxOutputBytes} bytes]
|
|
3089
3114
|
`));
|
|
3090
|
-
|
|
3115
|
+
this.killProcessGroup(child, isWindows);
|
|
3091
3116
|
return;
|
|
3092
3117
|
}
|
|
3093
|
-
|
|
3118
|
+
stderr.push(chunk);
|
|
3094
3119
|
};
|
|
3095
3120
|
if (child.stdout) {
|
|
3096
|
-
child.stdout.on("data",
|
|
3121
|
+
child.stdout.on("data", stdoutHandler);
|
|
3097
3122
|
}
|
|
3098
3123
|
if (child.stderr) {
|
|
3099
|
-
child.stderr.on("data",
|
|
3124
|
+
child.stderr.on("data", stderrHandler);
|
|
3100
3125
|
}
|
|
3126
|
+
const cleanup = () => {
|
|
3127
|
+
if (timer) {
|
|
3128
|
+
clearTimeout(timer);
|
|
3129
|
+
timer = null;
|
|
3130
|
+
}
|
|
3131
|
+
if (abortKillTimer) {
|
|
3132
|
+
clearTimeout(abortKillTimer);
|
|
3133
|
+
abortKillTimer = null;
|
|
3134
|
+
}
|
|
3135
|
+
if (signal && abortHandler) {
|
|
3136
|
+
signal.removeEventListener("abort", abortHandler);
|
|
3137
|
+
abortHandler = null;
|
|
3138
|
+
}
|
|
3139
|
+
if (child.stdout) {
|
|
3140
|
+
child.stdout.off("data", stdoutHandler);
|
|
3141
|
+
}
|
|
3142
|
+
if (child.stderr) {
|
|
3143
|
+
child.stderr.off("data", stderrHandler);
|
|
3144
|
+
}
|
|
3145
|
+
if (child && child.pid && !child.killed) {
|
|
3146
|
+
try {
|
|
3147
|
+
this.killProcessGroup(child, isWindows);
|
|
3148
|
+
} catch {
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
};
|
|
3101
3152
|
const exit = new Promise((res) => {
|
|
3102
3153
|
child.on("close", (code, signal2) => res({ code, signal: signal2 }));
|
|
3103
3154
|
});
|
|
3104
3155
|
try {
|
|
3105
3156
|
const { code, signal: exitSignal } = await Promise.race([exit, deadline, abort]);
|
|
3106
|
-
if (timer) clearTimeout(timer);
|
|
3107
3157
|
const outText = Buffer.concat(stdout).toString("utf8");
|
|
3108
3158
|
const errText = Buffer.concat(stderr).toString("utf8");
|
|
3109
3159
|
const output = stripAnsi ? stripAnsiAndControls(outText + errText) : outText + errText;
|
|
@@ -3125,7 +3175,6 @@ ${output}` : "";
|
|
|
3125
3175
|
}
|
|
3126
3176
|
return okText(output, { code, signal: exitSignal, cwd, stripped: stripAnsi });
|
|
3127
3177
|
} catch (e) {
|
|
3128
|
-
if (timer) clearTimeout(timer);
|
|
3129
3178
|
const message = e instanceof Error ? e.message : String(e);
|
|
3130
3179
|
if (message === "ABORTED" || signal?.aborted) {
|
|
3131
3180
|
const outText = Buffer.concat(stdout).toString("utf8");
|
|
@@ -3140,6 +3189,24 @@ ${output}` : "";
|
|
|
3140
3189
|
return err(message, { cwd }, "timeout" /* Timeout */);
|
|
3141
3190
|
}
|
|
3142
3191
|
return err(message, { cwd }, "unknown" /* Unknown */);
|
|
3192
|
+
} finally {
|
|
3193
|
+
cleanup();
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
killProcessGroup(child, isWindows, signal = "SIGKILL") {
|
|
3197
|
+
if (!child.pid) return;
|
|
3198
|
+
if (isWindows) {
|
|
3199
|
+
try {
|
|
3200
|
+
spawn("taskkill", ["/pid", child.pid.toString(), "/T", "/F"], { stdio: "ignore" });
|
|
3201
|
+
} catch {
|
|
3202
|
+
child.kill(signal);
|
|
3203
|
+
}
|
|
3204
|
+
} else {
|
|
3205
|
+
try {
|
|
3206
|
+
process.kill(-child.pid, signal);
|
|
3207
|
+
} catch {
|
|
3208
|
+
child.kill(signal);
|
|
3209
|
+
}
|
|
3143
3210
|
}
|
|
3144
3211
|
}
|
|
3145
3212
|
defaultShell() {
|
|
@@ -5953,6 +6020,7 @@ function normalizeModelLimits(provider, model) {
|
|
|
5953
6020
|
}
|
|
5954
6021
|
var FALLBACK_LIMITS = {
|
|
5955
6022
|
zai: {
|
|
6023
|
+
"glm-4.7": { contextWindow: 2e5, maxOutput: 128e3 },
|
|
5956
6024
|
"glm-4.6": { contextWindow: 2e5, maxOutput: 128e3 }
|
|
5957
6025
|
},
|
|
5958
6026
|
openrouter: {
|