@vellumai/cli 0.12.5-dev.202609251517.7e75308 → 0.12.5-dev.202609251714.4e37a15
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/node_modules/@vellumai/environments/src/shell.test.ts +13 -1
- package/node_modules/@vellumai/environments/src/shell.ts +22 -1
- package/node_modules/@vellumai/local-mode/node_modules/@vellumai/environments/src/shell.test.ts +13 -1
- package/node_modules/@vellumai/local-mode/node_modules/@vellumai/environments/src/shell.ts +22 -1
- package/package.json +1 -1
|
@@ -3,18 +3,30 @@ import { describe, expect, test } from "bun:test";
|
|
|
3
3
|
import {
|
|
4
4
|
buildShellInvocation,
|
|
5
5
|
buildShellSpawnFlags,
|
|
6
|
+
CHILD_OOM_SCORE_ADJ,
|
|
6
7
|
pathListDelimiter,
|
|
7
8
|
prependUniquePathEntries,
|
|
8
9
|
} from "./shell.js";
|
|
9
10
|
|
|
10
11
|
describe("buildShellInvocation", () => {
|
|
11
12
|
test("uses Bash on POSIX hosts", () => {
|
|
12
|
-
expect(buildShellInvocation("printf hello", "
|
|
13
|
+
expect(buildShellInvocation("printf hello", "darwin")).toEqual({
|
|
13
14
|
command: "bash",
|
|
14
15
|
args: ["-c", "--", "printf hello"],
|
|
15
16
|
});
|
|
16
17
|
});
|
|
17
18
|
|
|
19
|
+
test("raises the shell's OOM-kill priority on Linux", () => {
|
|
20
|
+
expect(buildShellInvocation("printf hello", "linux")).toEqual({
|
|
21
|
+
command: "bash",
|
|
22
|
+
args: [
|
|
23
|
+
"-c",
|
|
24
|
+
"--",
|
|
25
|
+
`echo ${CHILD_OOM_SCORE_ADJ} 2>/dev/null >/proc/self/oom_score_adj; printf hello`,
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
18
30
|
test("uses encoded non-interactive PowerShell on Windows", () => {
|
|
19
31
|
const invocation = buildShellInvocation(
|
|
20
32
|
"Write-Output 'hello 世界'",
|
|
@@ -24,6 +24,23 @@ if (-not $__vellumCommandSucceeded) {
|
|
|
24
24
|
}
|
|
25
25
|
exit 0`;
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* `oom_score_adj` for assistant-owned tool processes. Any positive value
|
|
29
|
+
* outranks a 0-scored process; 1000 makes a tool the kernel's first choice
|
|
30
|
+
* whenever the container runs out of memory, so the assistant itself is never
|
|
31
|
+
* the victim of a runaway command.
|
|
32
|
+
*/
|
|
33
|
+
export const CHILD_OOM_SCORE_ADJ = 1000;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Prefix for a Bash `-c` script that raises the shell's own OOM-kill priority
|
|
37
|
+
* before the command runs. Every process the command forks inherits it. Bash
|
|
38
|
+
* performs a builtin's redirection itself, so `/proc/self` is the shell.
|
|
39
|
+
* Redirections apply left to right, so stderr goes to /dev/null before the
|
|
40
|
+
* procfs open can fail and complain about it.
|
|
41
|
+
*/
|
|
42
|
+
const LINUX_OOM_SCORE_ADJ_PREFIX = `echo ${CHILD_OOM_SCORE_ADJ} 2>/dev/null >/proc/self/oom_score_adj; `;
|
|
43
|
+
|
|
27
44
|
export function buildShellInvocation(
|
|
28
45
|
command: string,
|
|
29
46
|
hostPlatform: NodeJS.Platform = process.platform,
|
|
@@ -45,7 +62,11 @@ export function buildShellInvocation(
|
|
|
45
62
|
],
|
|
46
63
|
};
|
|
47
64
|
}
|
|
48
|
-
|
|
65
|
+
const script =
|
|
66
|
+
hostPlatform === "linux"
|
|
67
|
+
? `${LINUX_OOM_SCORE_ADJ_PREFIX}${command}`
|
|
68
|
+
: command;
|
|
69
|
+
return { command: "bash", args: ["-c", "--", script] };
|
|
49
70
|
}
|
|
50
71
|
|
|
51
72
|
/**
|
package/node_modules/@vellumai/local-mode/node_modules/@vellumai/environments/src/shell.test.ts
CHANGED
|
@@ -3,18 +3,30 @@ import { describe, expect, test } from "bun:test";
|
|
|
3
3
|
import {
|
|
4
4
|
buildShellInvocation,
|
|
5
5
|
buildShellSpawnFlags,
|
|
6
|
+
CHILD_OOM_SCORE_ADJ,
|
|
6
7
|
pathListDelimiter,
|
|
7
8
|
prependUniquePathEntries,
|
|
8
9
|
} from "./shell.js";
|
|
9
10
|
|
|
10
11
|
describe("buildShellInvocation", () => {
|
|
11
12
|
test("uses Bash on POSIX hosts", () => {
|
|
12
|
-
expect(buildShellInvocation("printf hello", "
|
|
13
|
+
expect(buildShellInvocation("printf hello", "darwin")).toEqual({
|
|
13
14
|
command: "bash",
|
|
14
15
|
args: ["-c", "--", "printf hello"],
|
|
15
16
|
});
|
|
16
17
|
});
|
|
17
18
|
|
|
19
|
+
test("raises the shell's OOM-kill priority on Linux", () => {
|
|
20
|
+
expect(buildShellInvocation("printf hello", "linux")).toEqual({
|
|
21
|
+
command: "bash",
|
|
22
|
+
args: [
|
|
23
|
+
"-c",
|
|
24
|
+
"--",
|
|
25
|
+
`echo ${CHILD_OOM_SCORE_ADJ} 2>/dev/null >/proc/self/oom_score_adj; printf hello`,
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
18
30
|
test("uses encoded non-interactive PowerShell on Windows", () => {
|
|
19
31
|
const invocation = buildShellInvocation(
|
|
20
32
|
"Write-Output 'hello 世界'",
|
|
@@ -24,6 +24,23 @@ if (-not $__vellumCommandSucceeded) {
|
|
|
24
24
|
}
|
|
25
25
|
exit 0`;
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* `oom_score_adj` for assistant-owned tool processes. Any positive value
|
|
29
|
+
* outranks a 0-scored process; 1000 makes a tool the kernel's first choice
|
|
30
|
+
* whenever the container runs out of memory, so the assistant itself is never
|
|
31
|
+
* the victim of a runaway command.
|
|
32
|
+
*/
|
|
33
|
+
export const CHILD_OOM_SCORE_ADJ = 1000;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Prefix for a Bash `-c` script that raises the shell's own OOM-kill priority
|
|
37
|
+
* before the command runs. Every process the command forks inherits it. Bash
|
|
38
|
+
* performs a builtin's redirection itself, so `/proc/self` is the shell.
|
|
39
|
+
* Redirections apply left to right, so stderr goes to /dev/null before the
|
|
40
|
+
* procfs open can fail and complain about it.
|
|
41
|
+
*/
|
|
42
|
+
const LINUX_OOM_SCORE_ADJ_PREFIX = `echo ${CHILD_OOM_SCORE_ADJ} 2>/dev/null >/proc/self/oom_score_adj; `;
|
|
43
|
+
|
|
27
44
|
export function buildShellInvocation(
|
|
28
45
|
command: string,
|
|
29
46
|
hostPlatform: NodeJS.Platform = process.platform,
|
|
@@ -45,7 +62,11 @@ export function buildShellInvocation(
|
|
|
45
62
|
],
|
|
46
63
|
};
|
|
47
64
|
}
|
|
48
|
-
|
|
65
|
+
const script =
|
|
66
|
+
hostPlatform === "linux"
|
|
67
|
+
? `${LINUX_OOM_SCORE_ADJ_PREFIX}${command}`
|
|
68
|
+
: command;
|
|
69
|
+
return { command: "bash", args: ["-c", "--", script] };
|
|
49
70
|
}
|
|
50
71
|
|
|
51
72
|
/**
|