Simplify method signature. (#15114)

This commit is contained in:
Tommaso Sciortino
2025-12-15 13:18:04 -08:00
committed by GitHub
parent d236df5b21
commit bb0c0d8ee3
17 changed files with 184 additions and 213 deletions

View File

@@ -98,7 +98,7 @@ describe('run_shell_command', () => {
const prompt = `Please run the command "echo hello-world" and show me the output`;
const result = await rig.run(prompt);
const result = await rig.run({ args: prompt });
const foundToolCall = await rig.waitForToolCall('run_shell_command');
@@ -161,13 +161,11 @@ describe('run_shell_command', () => {
const prompt = `use ${command} to tell me how many lines there are in ${testFile}`;
// Provide the prompt via stdin to simulate non-interactive mode
const result = await rig.run(
{
stdin: prompt,
yolo: false,
},
`--allowed-tools=run_shell_command(${tool})`,
);
const result = await rig.run({
args: [`--allowed-tools=run_shell_command(${tool})`],
stdin: prompt,
yolo: false,
});
const foundToolCall = await rig.waitForToolCall('run_shell_command', 15000);
@@ -206,13 +204,11 @@ describe('run_shell_command', () => {
const { command } = getLineCountCommand();
const prompt = `use ${command} to tell me how many lines there are in ${testFile}`;
const result = await rig.run(
{
stdin: prompt,
yolo: false,
},
'--allowed-tools=run_shell_command',
);
const result = await rig.run({
args: '--allowed-tools=run_shell_command',
stdin: prompt,
yolo: false,
});
const foundToolCall = await rig.waitForToolCall('run_shell_command', 15000);
@@ -245,7 +241,7 @@ describe('run_shell_command', () => {
const prompt = `use ${command} to tell me how many lines there are in ${testFile}`;
const result = await rig.run({
prompt: prompt,
args: prompt,
yolo: true,
});
@@ -277,13 +273,11 @@ describe('run_shell_command', () => {
const { tool, command } = getLineCountCommand();
const prompt = `use ${command} to tell me how many lines there are in ${testFile}`;
const result = await rig.run(
{
stdin: prompt,
yolo: false,
},
`--allowed-tools=ShellTool(${tool})`,
);
const result = await rig.run({
args: `--allowed-tools=ShellTool(${tool})`,
stdin: prompt,
yolo: false,
});
const foundToolCall = await rig.waitForToolCall('run_shell_command', 15000);
@@ -325,14 +319,14 @@ describe('run_shell_command', () => {
`use both ${command} and ls to count the number of lines in files in this ` +
`directory. Do not pipe these commands into each other, run them separately.`;
const result = await rig.run(
{
stdin: prompt,
yolo: false,
},
`--allowed-tools=run_shell_command(${tool})`,
'--allowed-tools=run_shell_command(ls)',
);
const result = await rig.run({
args: [
`--allowed-tools=run_shell_command(${tool})`,
'--allowed-tools=run_shell_command(ls)',
],
stdin: prompt,
yolo: false,
});
for (const expected in ['ls', tool]) {
const foundToolCall = await rig.waitForToolCall(
@@ -380,13 +374,11 @@ describe('run_shell_command', () => {
`If the command fails because it is not permitted, respond with the single word FAIL. ` +
`If it succeeds, respond with SUCCESS.`;
const result = await rig.run(
{
stdin: prompt,
yolo: false,
},
`--allowed-tools=run_shell_command(${allowedCommand})`,
);
const result = await rig.run({
args: `--allowed-tools=run_shell_command(${allowedCommand})`,
stdin: prompt,
yolo: false,
});
if (!result.toLowerCase().includes('fail')) {
printDebugInfo(rig, result, {
@@ -443,13 +435,11 @@ describe('run_shell_command', () => {
const chained = getChainedEchoCommand();
const shellInjection = `!{${chained.command}}`;
await rig.run(
{
stdin: `${shellInjection}\n`,
yolo: false,
},
`--allowed-tools=ShellTool(${chained.allowPattern})`,
);
await rig.run({
args: `--allowed-tools=ShellTool(${chained.allowPattern})`,
stdin: `${shellInjection}\n`,
yolo: false,
});
// CLI should refuse to execute the chained command without scheduling run_shell_command.
const toolLogs = rig
@@ -474,14 +464,14 @@ describe('run_shell_command', () => {
const { tool } = getLineCountCommand();
const prompt = `Please run the command "echo test-allow-all" and show me the output`;
const result = await rig.run(
{
stdin: prompt,
yolo: false,
},
`--allowed-tools=run_shell_command(${tool})`,
'--allowed-tools=run_shell_command',
);
const result = await rig.run({
args: [
`--allowed-tools=run_shell_command(${tool})`,
'--allowed-tools=run_shell_command',
],
stdin: prompt,
yolo: false,
});
const foundToolCall = await rig.waitForToolCall('run_shell_command', 15000);
@@ -523,7 +513,7 @@ describe('run_shell_command', () => {
try {
const prompt = `Use echo to learn the value of the environment variable named ${varName} and tell me what it is.`;
const result = await rig.run(prompt);
const result = await rig.run({ args: prompt });
const foundToolCall = await rig.waitForToolCall('run_shell_command');
@@ -551,7 +541,7 @@ describe('run_shell_command', () => {
rig.createFile(fileName, 'test content');
const prompt = `Run a shell command to list the files in the current directory and tell me what they are.`;
const result = await rig.run(prompt);
const result = await rig.run({ args: prompt });
const foundToolCall = await rig.waitForToolCall('run_shell_command');
@@ -577,9 +567,9 @@ describe('run_shell_command', () => {
settings: { tools: { core: ['run_shell_command'] } },
});
const invalidCommand = getInvalidCommand();
const result = await rig.run(
`I am testing the error handling of the run_shell_command tool. Please attempt to run the following command, which I know has invalid syntax: \`${invalidCommand}\`. If the command fails as expected, please return the word FAIL, otherwise return the word SUCCESS.`,
);
const result = await rig.run({
args: `I am testing the error handling of the run_shell_command tool. Please attempt to run the following command, which I know has invalid syntax: \`${invalidCommand}\`. If the command fails as expected, please return the word FAIL, otherwise return the word SUCCESS.`,
});
expect(result).toContain('FAIL');
const escapedInvalidCommand = JSON.stringify(invalidCommand).slice(1, -1);