diff --git a/package-lock.json b/package-lock.json index 54c2c5e276..585df3feae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2237,6 +2237,7 @@ "integrity": "sha512-t54CUOsFMappY1Jbzb7fetWeO0n6K0k/4+/ZpkS+3Joz8I4VcvY9OiEBFRYISqaI2fq5sCiPtAjRDOzVYG8m+Q==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@octokit/auth-token": "^6.0.0", "@octokit/graphql": "^9.0.2", @@ -2417,6 +2418,7 @@ "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz", "integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==", "license": "Apache-2.0", + "peer": true, "engines": { "node": ">=8.0.0" } @@ -2466,6 +2468,7 @@ "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.5.0.tgz", "integrity": "sha512-ka4H8OM6+DlUhSAZpONu0cPBtPPTQKxbxVzC4CzVx5+K4JnroJVBtDzLAMx4/3CDTJXRvVFhpFjtl4SaiTNoyQ==", "license": "Apache-2.0", + "peer": true, "dependencies": { "@opentelemetry/semantic-conventions": "^1.29.0" }, @@ -2840,6 +2843,7 @@ "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.5.0.tgz", "integrity": "sha512-F8W52ApePshpoSrfsSk1H2yJn9aKjCrbpQF1M9Qii0GHzbfVeFUB+rc3X4aggyZD8x9Gu3Slua+s6krmq6Dt8g==", "license": "Apache-2.0", + "peer": true, "dependencies": { "@opentelemetry/core": "2.5.0", "@opentelemetry/semantic-conventions": "^1.29.0" @@ -2873,6 +2877,7 @@ "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-2.5.0.tgz", "integrity": "sha512-BeJLtU+f5Gf905cJX9vXFQorAr6TAfK3SPvTFqP+scfIpDQEJfRaGJWta7sJgP+m4dNtBf9y3yvBKVAZZtJQVA==", "license": "Apache-2.0", + "peer": true, "dependencies": { "@opentelemetry/core": "2.5.0", "@opentelemetry/resources": "2.5.0" @@ -2927,6 +2932,7 @@ "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-2.5.0.tgz", "integrity": "sha512-VzRf8LzotASEyNDUxTdaJ9IRJ1/h692WyArDBInf5puLCjxbICD6XkHgpuudis56EndyS7LYFmtTMny6UABNdQ==", "license": "Apache-2.0", + "peer": true, "dependencies": { "@opentelemetry/core": "2.5.0", "@opentelemetry/resources": "2.5.0", @@ -4100,6 +4106,7 @@ "integrity": "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA==", "devOptional": true, "license": "MIT", + "peer": true, "dependencies": { "csstype": "^3.0.2" } @@ -4374,6 +4381,7 @@ "integrity": "sha512-6sMvZePQrnZH2/cJkwRpkT7DxoAWh+g6+GFRK6bV3YQo7ogi3SX5rgF6099r5Q53Ma5qeT7LGmOmuIutF4t3lA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.35.0", "@typescript-eslint/types": "8.35.0", @@ -5366,6 +5374,7 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -7905,6 +7914,7 @@ "integrity": "sha512-GsGizj2Y1rCWDu6XoEekL3RLilp0voSePurjZIkxL3wlm5o5EC9VpgaP7lrCvjnkuLvzFBQWB3vWB3K5KQTveQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", @@ -8425,6 +8435,7 @@ "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", "license": "MIT", + "peer": true, "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.1", @@ -9733,6 +9744,7 @@ "resolved": "https://registry.npmjs.org/hono/-/hono-4.11.9.tgz", "integrity": "sha512-Eaw2YTGM6WOxA6CXbckaEvslr2Ne4NFsKrvc0v97JD5awbmeBLO5w9Ho9L9kmKonrwF9RJlW6BxT1PVv/agBHQ==", "license": "MIT", + "peer": true, "engines": { "node": ">=16.9.0" } @@ -10033,6 +10045,7 @@ "resolved": "https://registry.npmjs.org/@jrichman/ink/-/ink-6.4.10.tgz", "integrity": "sha512-kjJqZFkGVm0QyJmga/L02rsFJroF1aP2bhXEGkpuuT7clB6/W+gxAbLNw7ZaJrG6T30DgqOT92Pu6C9mK1FWyg==", "license": "MIT", + "peer": true, "dependencies": { "@alcalzone/ansi-tokenize": "^0.2.1", "ansi-escapes": "^7.0.0", @@ -13713,6 +13726,7 @@ "resolved": "https://registry.npmjs.org/react/-/react-19.2.0.tgz", "integrity": "sha512-tmbWg6W31tQLeB5cdIBOicJDJRR2KzXsV7uSK9iNfLWQ5bIZfxuPEHp7M8wiHyHnn0DD1i7w3Zmin0FtkrwoCQ==", "license": "MIT", + "peer": true, "engines": { "node": ">=0.10.0" } @@ -13723,6 +13737,7 @@ "integrity": "sha512-ePrwPfxAnB+7hgnEr8vpKxL9cmnp7F322t8oqcPshbIQQhDKgFDW4tjhF2wjVbdXF9O/nyuy3sQWd9JGpiLPvA==", "devOptional": true, "license": "MIT", + "peer": true, "dependencies": { "shell-quote": "^1.6.1", "ws": "^7" @@ -15885,6 +15900,7 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -16108,7 +16124,8 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", "dev": true, - "license": "0BSD" + "license": "0BSD", + "peer": true }, "node_modules/tsx": { "version": "4.20.3", @@ -16116,6 +16133,7 @@ "integrity": "sha512-qjbnuR9Tr+FJOMBqJCW5ehvIo/buZq7vH7qD7JziU98h6l3qGy0a/yPFjwO+y0/T7GFpNgNAvEcPPVfyT8rrPQ==", "devOptional": true, "license": "MIT", + "peer": true, "dependencies": { "esbuild": "~0.25.0", "get-tsconfig": "^4.7.5" @@ -16276,6 +16294,7 @@ "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", "devOptional": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -16483,6 +16502,7 @@ "resolved": "https://registry.npmjs.org/vite/-/vite-7.2.2.tgz", "integrity": "sha512-BxAKBWmIbrDgrokdGZH1IgkIk/5mMHDreLDmCJ0qpyJaAteP8NvMhkwr/ZCQNqNH97bw/dANTE9PDzqwJghfMQ==", "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.5.0", @@ -16596,6 +16616,7 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -16608,6 +16629,7 @@ "resolved": "https://registry.npmjs.org/vitest/-/vitest-3.2.4.tgz", "integrity": "sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==", "license": "MIT", + "peer": true, "dependencies": { "@types/chai": "^5.2.2", "@vitest/expect": "3.2.4", @@ -17239,6 +17261,7 @@ "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", "license": "MIT", + "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } @@ -17553,6 +17576,7 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, diff --git a/packages/core/src/core/__snapshots__/prompts.test.ts.snap b/packages/core/src/core/__snapshots__/prompts.test.ts.snap index 22d0e6f71a..b19f8f8686 100644 --- a/packages/core/src/core/__snapshots__/prompts.test.ts.snap +++ b/packages/core/src/core/__snapshots__/prompts.test.ts.snap @@ -631,6 +631,17 @@ Operate using a **Research -> Strategy -> Execution** lifecycle. For the Executi - **Tools vs. Text:** Use tools for actions, text output *only* for communication. Do not add explanatory comments within tool calls. - **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly without excessive justification. Offer alternatives if appropriate. +## Standard Subprocess Protocol + +For any tool that executes a subprocess (including shell commands and project-specific discovered tools), the following information is returned: + +- **Output:** The combined content of stdout and stderr. Can be \`(empty)\` or partial on error or for unwaited background processes. +- **Exit Code:** The numeric exit code of the process. Only included if non-zero (indicating failure). +- **Error:** A descriptive message if a process-level error occurred (e.g., command not found). +- **Signal:** The name or number of the signal that terminated the process (if applicable). +- **Background PIDs:** A list of PIDs for any background processes started by the command. +- **Process Group PGID:** The process group ID, which can be used to terminate the process group if needed. + ## Security and Safety Rules - **Explain Critical Commands:** Before executing commands with \`run_shell_command\` that modify the file system, codebase, or system state, you *must* provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this). - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information. @@ -769,6 +780,17 @@ Operate using a **Research -> Strategy -> Execution** lifecycle. For the Executi - **Tools vs. Text:** Use tools for actions, text output *only* for communication. Do not add explanatory comments within tool calls. - **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly without excessive justification. Offer alternatives if appropriate. +## Standard Subprocess Protocol + +For any tool that executes a subprocess (including shell commands and project-specific discovered tools), the following information is returned: + +- **Output:** The combined content of stdout and stderr. Can be \`(empty)\` or partial on error or for unwaited background processes. +- **Exit Code:** The numeric exit code of the process. Only included if non-zero (indicating failure). +- **Error:** A descriptive message if a process-level error occurred (e.g., command not found). +- **Signal:** The name or number of the signal that terminated the process (if applicable). +- **Background PIDs:** A list of PIDs for any background processes started by the command. +- **Process Group PGID:** The process group ID, which can be used to terminate the process group if needed. + ## Security and Safety Rules - **Explain Critical Commands:** Before executing commands with \`run_shell_command\` that modify the file system, codebase, or system state, you *must* provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this). - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information. @@ -890,6 +912,17 @@ Operate using a **Research -> Strategy -> Execution** lifecycle. For the Executi - **Tools vs. Text:** Use tools for actions, text output *only* for communication. Do not add explanatory comments within tool calls. - **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly without excessive justification. Offer alternatives if appropriate. +## Standard Subprocess Protocol + +For any tool that executes a subprocess (including shell commands and project-specific discovered tools), the following information is returned: + +- **Output:** The combined content of stdout and stderr. Can be \`(empty)\` or partial on error or for unwaited background processes. +- **Exit Code:** The numeric exit code of the process. Only included if non-zero (indicating failure). +- **Error:** A descriptive message if a process-level error occurred (e.g., command not found). +- **Signal:** The name or number of the signal that terminated the process (if applicable). +- **Background PIDs:** A list of PIDs for any background processes started by the command. +- **Process Group PGID:** The process group ID, which can be used to terminate the process group if needed. + ## Security and Safety Rules - **Explain Critical Commands:** Before executing commands with \`run_shell_command\` that modify the file system, codebase, or system state, you *must* provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this). - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information. @@ -1510,6 +1543,17 @@ Operate using a **Research -> Strategy -> Execution** lifecycle. For the Executi - **Tools vs. Text:** Use tools for actions, text output *only* for communication. Do not add explanatory comments within tool calls. - **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly without excessive justification. Offer alternatives if appropriate. +## Standard Subprocess Protocol + +For any tool that executes a subprocess (including shell commands and project-specific discovered tools), the following information is returned: + +- **Output:** The combined content of stdout and stderr. Can be \`(empty)\` or partial on error or for unwaited background processes. +- **Exit Code:** The numeric exit code of the process. Only included if non-zero (indicating failure). +- **Error:** A descriptive message if a process-level error occurred (e.g., command not found). +- **Signal:** The name or number of the signal that terminated the process (if applicable). +- **Background PIDs:** A list of PIDs for any background processes started by the command. +- **Process Group PGID:** The process group ID, which can be used to terminate the process group if needed. + ## Security and Safety Rules - **Explain Critical Commands:** Before executing commands with \`run_shell_command\` that modify the file system, codebase, or system state, you *must* provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this). - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information. @@ -1648,6 +1692,17 @@ Operate using a **Research -> Strategy -> Execution** lifecycle. For the Executi - **Tools vs. Text:** Use tools for actions, text output *only* for communication. Do not add explanatory comments within tool calls. - **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly without excessive justification. Offer alternatives if appropriate. +## Standard Subprocess Protocol + +For any tool that executes a subprocess (including shell commands and project-specific discovered tools), the following information is returned: + +- **Output:** The combined content of stdout and stderr. Can be \`(empty)\` or partial on error or for unwaited background processes. +- **Exit Code:** The numeric exit code of the process. Only included if non-zero (indicating failure). +- **Error:** A descriptive message if a process-level error occurred (e.g., command not found). +- **Signal:** The name or number of the signal that terminated the process (if applicable). +- **Background PIDs:** A list of PIDs for any background processes started by the command. +- **Process Group PGID:** The process group ID, which can be used to terminate the process group if needed. + ## Security and Safety Rules - **Explain Critical Commands:** Before executing commands with \`run_shell_command\` that modify the file system, codebase, or system state, you *must* provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this). - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information. @@ -1790,6 +1845,17 @@ Operate using a **Research -> Strategy -> Execution** lifecycle. For the Executi - **Tools vs. Text:** Use tools for actions, text output *only* for communication. Do not add explanatory comments within tool calls. - **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly without excessive justification. Offer alternatives if appropriate. +## Standard Subprocess Protocol + +For any tool that executes a subprocess (including shell commands and project-specific discovered tools), the following information is returned: + +- **Output:** The combined content of stdout and stderr. Can be \`(empty)\` or partial on error or for unwaited background processes. +- **Exit Code:** The numeric exit code of the process. Only included if non-zero (indicating failure). +- **Error:** A descriptive message if a process-level error occurred (e.g., command not found). +- **Signal:** The name or number of the signal that terminated the process (if applicable). +- **Background PIDs:** A list of PIDs for any background processes started by the command. +- **Process Group PGID:** The process group ID, which can be used to terminate the process group if needed. + ## Security and Safety Rules - **Explain Critical Commands:** Before executing commands with \`run_shell_command\` that modify the file system, codebase, or system state, you *must* provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this). - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information. @@ -2070,6 +2136,17 @@ Operate using a **Research -> Strategy -> Execution** lifecycle. For the Executi - **Tools vs. Text:** Use tools for actions, text output *only* for communication. Do not add explanatory comments within tool calls. - **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly without excessive justification. Offer alternatives if appropriate. +## Standard Subprocess Protocol + +For any tool that executes a subprocess (including shell commands and project-specific discovered tools), the following information is returned: + +- **Output:** The combined content of stdout and stderr. Can be \`(empty)\` or partial on error or for unwaited background processes. +- **Exit Code:** The numeric exit code of the process. Only included if non-zero (indicating failure). +- **Error:** A descriptive message if a process-level error occurred (e.g., command not found). +- **Signal:** The name or number of the signal that terminated the process (if applicable). +- **Background PIDs:** A list of PIDs for any background processes started by the command. +- **Process Group PGID:** The process group ID, which can be used to terminate the process group if needed. + ## Security and Safety Rules - **Explain Critical Commands:** Before executing commands with \`run_shell_command\` that modify the file system, codebase, or system state, you *must* provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this). - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information. @@ -2207,6 +2284,17 @@ Operate using a **Research -> Strategy -> Execution** lifecycle. For the Executi - **Tools vs. Text:** Use tools for actions, text output *only* for communication. Do not add explanatory comments within tool calls. - **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly without excessive justification. Offer alternatives if appropriate. +## Standard Subprocess Protocol + +For any tool that executes a subprocess (including shell commands and project-specific discovered tools), the following information is returned: + +- **Output:** The combined content of stdout and stderr. Can be \`(empty)\` or partial on error or for unwaited background processes. +- **Exit Code:** The numeric exit code of the process. Only included if non-zero (indicating failure). +- **Error:** A descriptive message if a process-level error occurred (e.g., command not found). +- **Signal:** The name or number of the signal that terminated the process (if applicable). +- **Background PIDs:** A list of PIDs for any background processes started by the command. +- **Process Group PGID:** The process group ID, which can be used to terminate the process group if needed. + ## Security and Safety Rules - **Explain Critical Commands:** Before executing commands with \`run_shell_command\` that modify the file system, codebase, or system state, you *must* provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this). - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information. @@ -2345,6 +2433,17 @@ Operate using a **Research -> Strategy -> Execution** lifecycle. For the Executi - **Tools vs. Text:** Use tools for actions, text output *only* for communication. Do not add explanatory comments within tool calls. - **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly without excessive justification. Offer alternatives if appropriate. +## Standard Subprocess Protocol + +For any tool that executes a subprocess (including shell commands and project-specific discovered tools), the following information is returned: + +- **Output:** The combined content of stdout and stderr. Can be \`(empty)\` or partial on error or for unwaited background processes. +- **Exit Code:** The numeric exit code of the process. Only included if non-zero (indicating failure). +- **Error:** A descriptive message if a process-level error occurred (e.g., command not found). +- **Signal:** The name or number of the signal that terminated the process (if applicable). +- **Background PIDs:** A list of PIDs for any background processes started by the command. +- **Process Group PGID:** The process group ID, which can be used to terminate the process group if needed. + ## Security and Safety Rules - **Explain Critical Commands:** Before executing commands with \`run_shell_command\` that modify the file system, codebase, or system state, you *must* provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this). - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information. @@ -2722,6 +2821,17 @@ Operate using a **Research -> Strategy -> Execution** lifecycle. For the Executi - **Tools vs. Text:** Use tools for actions, text output *only* for communication. Do not add explanatory comments within tool calls. - **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly without excessive justification. Offer alternatives if appropriate. +## Standard Subprocess Protocol + +For any tool that executes a subprocess (including shell commands and project-specific discovered tools), the following information is returned: + +- **Output:** The combined content of stdout and stderr. Can be \`(empty)\` or partial on error or for unwaited background processes. +- **Exit Code:** The numeric exit code of the process. Only included if non-zero (indicating failure). +- **Error:** A descriptive message if a process-level error occurred (e.g., command not found). +- **Signal:** The name or number of the signal that terminated the process (if applicable). +- **Background PIDs:** A list of PIDs for any background processes started by the command. +- **Process Group PGID:** The process group ID, which can be used to terminate the process group if needed. + ## Security and Safety Rules - **Explain Critical Commands:** Before executing commands with \`run_shell_command\` that modify the file system, codebase, or system state, you *must* provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this). - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information. @@ -2860,6 +2970,17 @@ Operate using a **Research -> Strategy -> Execution** lifecycle. For the Executi - **Tools vs. Text:** Use tools for actions, text output *only* for communication. Do not add explanatory comments within tool calls. - **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly without excessive justification. Offer alternatives if appropriate. +## Standard Subprocess Protocol + +For any tool that executes a subprocess (including shell commands and project-specific discovered tools), the following information is returned: + +- **Output:** The combined content of stdout and stderr. Can be \`(empty)\` or partial on error or for unwaited background processes. +- **Exit Code:** The numeric exit code of the process. Only included if non-zero (indicating failure). +- **Error:** A descriptive message if a process-level error occurred (e.g., command not found). +- **Signal:** The name or number of the signal that terminated the process (if applicable). +- **Background PIDs:** A list of PIDs for any background processes started by the command. +- **Process Group PGID:** The process group ID, which can be used to terminate the process group if needed. + ## Security and Safety Rules - **Explain Critical Commands:** Before executing commands with \`run_shell_command\` that modify the file system, codebase, or system state, you *must* provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this). - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information. @@ -3109,6 +3230,17 @@ Operate using a **Research -> Strategy -> Execution** lifecycle. For the Executi - **Tools vs. Text:** Use tools for actions, text output *only* for communication. Do not add explanatory comments within tool calls. - **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly without excessive justification. Offer alternatives if appropriate. +## Standard Subprocess Protocol + +For any tool that executes a subprocess (including shell commands and project-specific discovered tools), the following information is returned: + +- **Output:** The combined content of stdout and stderr. Can be \`(empty)\` or partial on error or for unwaited background processes. +- **Exit Code:** The numeric exit code of the process. Only included if non-zero (indicating failure). +- **Error:** A descriptive message if a process-level error occurred (e.g., command not found). +- **Signal:** The name or number of the signal that terminated the process (if applicable). +- **Background PIDs:** A list of PIDs for any background processes started by the command. +- **Process Group PGID:** The process group ID, which can be used to terminate the process group if needed. + ## Security and Safety Rules - **Explain Critical Commands:** Before executing commands with \`run_shell_command\` that modify the file system, codebase, or system state, you *must* provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this). - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information. @@ -3247,6 +3379,17 @@ Operate using a **Research -> Strategy -> Execution** lifecycle. For the Executi - **Tools vs. Text:** Use tools for actions, text output *only* for communication. Do not add explanatory comments within tool calls. - **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly without excessive justification. Offer alternatives if appropriate. +## Standard Subprocess Protocol + +For any tool that executes a subprocess (including shell commands and project-specific discovered tools), the following information is returned: + +- **Output:** The combined content of stdout and stderr. Can be \`(empty)\` or partial on error or for unwaited background processes. +- **Exit Code:** The numeric exit code of the process. Only included if non-zero (indicating failure). +- **Error:** A descriptive message if a process-level error occurred (e.g., command not found). +- **Signal:** The name or number of the signal that terminated the process (if applicable). +- **Background PIDs:** A list of PIDs for any background processes started by the command. +- **Process Group PGID:** The process group ID, which can be used to terminate the process group if needed. + ## Security and Safety Rules - **Explain Critical Commands:** Before executing commands with \`run_shell_command\` that modify the file system, codebase, or system state, you *must* provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this). - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information. diff --git a/packages/core/src/tools/__snapshots__/shell.test.ts.snap b/packages/core/src/tools/__snapshots__/shell.test.ts.snap index 471ce45f6e..5c3c2fa245 100644 --- a/packages/core/src/tools/__snapshots__/shell.test.ts.snap +++ b/packages/core/src/tools/__snapshots__/shell.test.ts.snap @@ -1,20 +1,13 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`ShellTool > getDescription > should return the non-windows description when not on windows 1`] = ` -"This tool executes a given shell command as \`bash -c \`. Command can start background processes using \`&\`. Command is executed as a subprocess that leads its own process group. Command process group can be terminated as \`kill -- -PGID\` or signaled as \`kill -s SIGNAL -- -PGID\`. +"This tool executes a given shell command as \`bash -c \`. Command can start background processes using \`&\`. Efficiency Guidelines: - Quiet Flags: Always prefer silent or quiet flags (e.g., \`npm install --silent\`, \`git --no-pager\`) to reduce output volume while still capturing necessary information. - Pagination: Always disable terminal pagination to ensure commands terminate (e.g., use \`git --no-pager\`, \`systemctl --no-pager\`, or set \`PAGER=cat\`). - The following information is returned: - - Output: Combined stdout/stderr. Can be \`(empty)\` or partial on error and for any unwaited background processes. - Exit Code: Only included if non-zero (command failed). - Error: Only included if a process-level error occurred (e.g., spawn failure). - Signal: Only included if process was terminated by a signal. - Background PIDs: Only included if background processes were started. - Process Group PGID: Only included if available." + The following information is returned: [Protocol: Subprocess]" `; exports[`ShellTool > getDescription > should return the windows description when on windows 1`] = ` @@ -24,46 +17,25 @@ exports[`ShellTool > getDescription > should return the windows description when - Quiet Flags: Always prefer silent or quiet flags (e.g., \`npm install --silent\`, \`git --no-pager\`) to reduce output volume while still capturing necessary information. - Pagination: Always disable terminal pagination to ensure commands terminate (e.g., use \`git --no-pager\`, \`systemctl --no-pager\`, or set \`PAGER=cat\`). - The following information is returned: - - Output: Combined stdout/stderr. Can be \`(empty)\` or partial on error and for any unwaited background processes. - Exit Code: Only included if non-zero (command failed). - Error: Only included if a process-level error occurred (e.g., spawn failure). - Signal: Only included if process was terminated by a signal. - Background PIDs: Only included if background processes were started. - Process Group PGID: Only included if available." + The following information is returned: [Protocol: Subprocess]" `; exports[`ShellTool > getSchema > should return the base schema when no modelId is provided 1`] = ` -"This tool executes a given shell command as \`bash -c \`. Command can start background processes using \`&\`. Command is executed as a subprocess that leads its own process group. Command process group can be terminated as \`kill -- -PGID\` or signaled as \`kill -s SIGNAL -- -PGID\`. +"This tool executes a given shell command as \`bash -c \`. Command can start background processes using \`&\`. Efficiency Guidelines: - Quiet Flags: Always prefer silent or quiet flags (e.g., \`npm install --silent\`, \`git --no-pager\`) to reduce output volume while still capturing necessary information. - Pagination: Always disable terminal pagination to ensure commands terminate (e.g., use \`git --no-pager\`, \`systemctl --no-pager\`, or set \`PAGER=cat\`). - The following information is returned: - - Output: Combined stdout/stderr. Can be \`(empty)\` or partial on error and for any unwaited background processes. - Exit Code: Only included if non-zero (command failed). - Error: Only included if a process-level error occurred (e.g., spawn failure). - Signal: Only included if process was terminated by a signal. - Background PIDs: Only included if background processes were started. - Process Group PGID: Only included if available." + The following information is returned: [Protocol: Subprocess]" `; exports[`ShellTool > getSchema > should return the schema from the resolver when modelId is provided 1`] = ` -"This tool executes a given shell command as \`bash -c \`. Command can start background processes using \`&\`. Command is executed as a subprocess that leads its own process group. Command process group can be terminated as \`kill -- -PGID\` or signaled as \`kill -s SIGNAL -- -PGID\`. +"This tool executes a given shell command as \`bash -c \`. Command can start background processes using \`&\`. Efficiency Guidelines: - Quiet Flags: Always prefer silent or quiet flags (e.g., \`npm install --silent\`, \`git --no-pager\`) to reduce output volume while still capturing necessary information. - Pagination: Always disable terminal pagination to ensure commands terminate (e.g., use \`git --no-pager\`, \`systemctl --no-pager\`, or set \`PAGER=cat\`). - The following information is returned: - - Output: Combined stdout/stderr. Can be \`(empty)\` or partial on error and for any unwaited background processes. - Exit Code: Only included if non-zero (command failed). - Error: Only included if a process-level error occurred (e.g., spawn failure). - Signal: Only included if process was terminated by a signal. - Background PIDs: Only included if background processes were started. - Process Group PGID: Only included if available." + The following information is returned: [Protocol: Subprocess]" `; diff --git a/packages/core/src/tools/definitions/__snapshots__/coreToolsModelSnapshots.test.ts.snap b/packages/core/src/tools/definitions/__snapshots__/coreToolsModelSnapshots.test.ts.snap index 99180cc735..2dc559565f 100644 --- a/packages/core/src/tools/definitions/__snapshots__/coreToolsModelSnapshots.test.ts.snap +++ b/packages/core/src/tools/definitions/__snapshots__/coreToolsModelSnapshots.test.ts.snap @@ -568,20 +568,13 @@ A good instruction should concisely answer: exports[`coreTools snapshots for specific models > Model: gemini-2.5-pro > snapshot for tool: run_shell_command 1`] = ` { - "description": "This tool executes a given shell command as \`bash -c \`. To run a command in the background, set the \`is_background\` parameter to true. Do NOT use \`&\` to background commands. Command is executed as a subprocess that leads its own process group. Command process group can be terminated as \`kill -- -PGID\` or signaled as \`kill -s SIGNAL -- -PGID\`. + "description": "This tool executes a given shell command as \`bash -c \`. To run a command in the background, set the \`is_background\` parameter to true. Do NOT use \`&\` to background commands. Efficiency Guidelines: - Quiet Flags: Always prefer silent or quiet flags (e.g., \`npm install --silent\`, \`git --no-pager\`) to reduce output volume while still capturing necessary information. - Pagination: Always disable terminal pagination to ensure commands terminate (e.g., use \`git --no-pager\`, \`systemctl --no-pager\`, or set \`PAGER=cat\`). - The following information is returned: - - Output: Combined stdout/stderr. Can be \`(empty)\` or partial on error and for any unwaited background processes. - Exit Code: Only included if non-zero (command failed). - Error: Only included if a process-level error occurred (e.g., spawn failure). - Signal: Only included if process was terminated by a signal. - Background PIDs: Only included if background processes were started. - Process Group PGID: Only included if available.", + The following information is returned: [Protocol: Subprocess]", "name": "run_shell_command", "parametersJsonSchema": { "properties": { @@ -1357,20 +1350,13 @@ A good instruction should concisely answer: exports[`coreTools snapshots for specific models > Model: gemini-3-pro-preview > snapshot for tool: run_shell_command 1`] = ` { - "description": "This tool executes a given shell command as \`bash -c \`. To run a command in the background, set the \`is_background\` parameter to true. Do NOT use \`&\` to background commands. Command is executed as a subprocess that leads its own process group. Command process group can be terminated as \`kill -- -PGID\` or signaled as \`kill -s SIGNAL -- -PGID\`. + "description": "This tool executes a given shell command as \`bash -c \`. To run a command in the background, set the \`is_background\` parameter to true. Do NOT use \`&\` to background commands. Efficiency Guidelines: - Quiet Flags: Always prefer silent or quiet flags (e.g., \`npm install --silent\`, \`git --no-pager\`) to reduce output volume while still capturing necessary information. - Pagination: Always disable terminal pagination to ensure commands terminate (e.g., use \`git --no-pager\`, \`systemctl --no-pager\`, or set \`PAGER=cat\`). - The following information is returned: - - Output: Combined stdout/stderr. Can be \`(empty)\` or partial on error and for any unwaited background processes. - Exit Code: Only included if non-zero (command failed). - Error: Only included if a process-level error occurred (e.g., spawn failure). - Signal: Only included if process was terminated by a signal. - Background PIDs: Only included if background processes were started. - Process Group PGID: Only included if available.", + The following information is returned: [Protocol: Subprocess]", "name": "run_shell_command", "parametersJsonSchema": { "properties": { diff --git a/packages/core/src/tools/tool-registry.test.ts b/packages/core/src/tools/tool-registry.test.ts index 963830200d..df3eb57df3 100644 --- a/packages/core/src/tools/tool-registry.test.ts +++ b/packages/core/src/tools/tool-registry.test.ts @@ -550,7 +550,7 @@ describe('ToolRegistry', () => { expect(result.error?.type).toBe( ToolErrorType.DISCOVERED_TOOL_EXECUTION_ERROR, ); - expect(result.llmContent).toContain('Stderr: Something went wrong'); + expect(result.llmContent).toContain('Output: Something went wrong'); expect(result.llmContent).toContain('Exit Code: 1'); }); diff --git a/packages/core/src/tools/tool-registry.ts b/packages/core/src/tools/tool-registry.ts index 60b1451838..c6b419fa96 100644 --- a/packages/core/src/tools/tool-registry.ts +++ b/packages/core/src/tools/tool-registry.ts @@ -103,13 +103,19 @@ class DiscoveredToolInvocation extends BaseToolInvocation< // if there is any error, non-zero exit code, signal, or stderr, return error details instead of stdout if (error || code !== 0 || signal || stderr) { - const llmContent = [ - `Stdout: ${stdout || '(empty)'}`, - `Stderr: ${stderr || '(empty)'}`, - `Error: ${error ?? '(none)'}`, - `Exit Code: ${code ?? '(none)'}`, - `Signal: ${signal ?? '(none)'}`, - ].join('\n'); + const llmContentParts = [ + `Output: ${(stdout + stderr).trim() || '(empty)'}`, + ]; + if (error) { + llmContentParts.push(`Error: ${error}`); + } + if (code !== null && code !== 0) { + llmContentParts.push(`Exit Code: ${code}`); + } + if (signal) { + llmContentParts.push(`Signal: ${signal}`); + } + const llmContent = llmContentParts.join('\n'); return { llmContent, returnDisplay: llmContent, @@ -153,13 +159,7 @@ Tool discovery and call commands can be configured in project or user settings. When called, the tool call command is executed as a subprocess. On success, tool output is returned as a json string. -Otherwise, the following information is returned: - -Stdout: Output on stdout stream. Can be \`(empty)\` or partial. -Stderr: Output on stderr stream. Can be \`(empty)\` or partial. -Error: Error or \`(none)\` if no error was reported for the subprocess. -Exit Code: Exit code or \`(none)\` if terminated by signal. -Signal: Signal number or \`(none)\` if no signal was received. +Otherwise, the following information is returned: [Protocol: Subprocess] `; super( prefixedName,