diff --git a/CHANGELOG.md b/CHANGELOG.md index 4918cc47..a6054e77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - When ChatGPT's page could not draw an answer, prodex saved the page's own error, "This response couldn’t load", as the answer, and the consult reported done with its request verified. `pro browser recover` saved the same sentence again, because the tab was already on the thread and was not loaded again. Found 2026-10-30 in the browser container: Chromium could not start threads there, and ChatGPT held the finished answer ("OK") while the page showed the error in its place. A send now stops as `answer_render_failed` and names the `recover` command. Recovery loads the thread once more when it finds the error, and returns the answer drawn after that. If the error is still there, recovery stops as `answer_render_failed` instead of saving it. Checked live on WSL by marking an answer the way the failed page did: 0.40.48 recovered the error text; the fix blocked the send, then recovered "PROBE7731" once the page could draw it. +- `--tool " "` (a tool name of only spaces, such as an empty script variable) was accepted, and the prompt went out with no tool and no warning. Measured 2026-10-29. MCP `pro_consult` with a blank entry in `tools` did the same. Both now stop before the browser with "--tool is blank". ## 0.40.48 diff --git a/src/cli-pro.ts b/src/cli-pro.ts index 3fea6ab9..a56f9f66 100644 --- a/src/cli-pro.ts +++ b/src/cli-pro.ts @@ -1371,6 +1371,11 @@ export async function runAskProCommand( // --tool turns on a composer tool (deep-research, web-search, // create-image, or any label the menu shows) for this send. const tools = readRepeatedFlag(parsedAskPro.optionArgs, "--tool"); + // A tool is opened by its label, so a value that is only spaces names none: + // the prompt went out with no tool and nothing said so. + if (tools.some((tool) => !tool.trim())) { + throw new Error("--tool is blank; name a composer tool (web-search, create-image), or leave the option out."); + } if (tools.length > 0 && !hasSendMode) { throw new Error("--tool only applies when sending (`prodex pro browser ask`); the dry-run preview cannot open ChatGPT's tools menu."); } diff --git a/tests/cli-pro-browser-send.test.ts b/tests/cli-pro-browser-send.test.ts index 8adeff61..f7b14fec 100644 --- a/tests/cli-pro-browser-send.test.ts +++ b/tests/cli-pro-browser-send.test.ts @@ -3573,3 +3573,21 @@ describe("blank project names", () => { await expect(runCli(["setup", "--project", " "], io(cwd))).rejects.toThrow(/--project .*blank/); }); }); + +describe("blank composer tools", () => { + // Measured 2026-10-29: `--tool " "` (a script's empty variable, say) was + // accepted and the prompt went out with no tool at all, so a send that asked + // for a tool got none without a word. MCP pro_consult passes its tools here. + const io = (cwd: string) => ({ cwd, stdout: () => {}, stderr: () => {} }); + beforeEach(() => { + sendChatGptPromptMock.mockClear(); + }); + + it.each([" ", "\t"])("refuses --tool %j before touching the browser", async (value) => { + const cwd = await mkdtemp(path.join(tmpdir(), "prodex-pro-send-")); + await expect(runCli(["pro", "browser", "ask", "--send", "--tool", "web-search", "--tool", value, "Review this"], io(cwd))).rejects.toThrow( + /--tool .*blank/ + ); + expect(sendChatGptPromptMock).not.toHaveBeenCalled(); + }); +}); diff --git a/tests/mcp-consult.test.ts b/tests/mcp-consult.test.ts index 7d9f509d..b14dbe93 100644 --- a/tests/mcp-consult.test.ts +++ b/tests/mcp-consult.test.ts @@ -271,6 +271,12 @@ describe("pro_consult MCP tool registration", () => { }); describe("performBrowserConsultForMcp", () => { + it("refuses a blank tool before sending", async () => { + const cwd = await mkdtemp(path.join(tmpdir(), "prodex-mcp-consult-")); + await expect(performBrowserConsultForMcp(cwd, { prompt: "Question", tools: [" "] })).rejects.toThrow(/--tool .*blank/); + expect(sendChatGptPromptMock).not.toHaveBeenCalled(); + }); + it("threads selection options into the send and returns structured fields", async () => { const cwd = await mkdtemp(path.join(tmpdir(), "prodex-mcp-consult-")); sendChatGptPromptMock.mockResolvedValueOnce({