{"record":{"id":"0206262dcff9238e","repo":"jackwener/OpenCLI","slug":"unknown-chatgpt-tool-tool","errorCode":null,"errorMessage":"Unknown ChatGPT tool \"${tool}\"","messagePattern":"Unknown ChatGPT tool \"(.+?)\"","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/chatgpt/utils.js","lineNumber":395,"sourceCode":"\nfunction requireKnownChatGPTModel(model) {\n    const key = String(model ?? '').trim().toLowerCase();\n    const targetKey = CHATGPT_MODEL_ALIASES[key] || key;\n    const option = CHATGPT_MODEL_TARGETS[targetKey];\n    if (!option) {\n        throw new ArgumentError(\n            `Unknown ChatGPT model \"${model}\"`,\n            `Choose one of: ${CHATGPT_MODEL_CHOICES.join(', ')}`,\n        );\n    }\n    return { key: targetKey, alias: key !== targetKey ? key : null, ...option };\n}\n\nfunction requireKnownChatGPTTool(tool) {\n    const key = String(tool ?? '').trim().toLowerCase();\n    const option = CHATGPT_TOOL_OPTIONS[key];\n    if (!option) {\n        throw new ArgumentError(\n            `Unknown ChatGPT tool \"${tool}\"`,\n            `Choose one of: ${CHATGPT_TOOL_CHOICES.join(', ')}`,\n        );\n    }\n    return { key, ...option };\n}\n\nexport async function getCurrentChatGPTModel(page) {\n    return requireObjectEvaluateResult(unwrapEvaluateResult(await page.evaluate(`(() => {\n        const isVisible = (el) => {\n            if (!(el instanceof HTMLElement)) return false;\n            const style = window.getComputedStyle(el);\n            if (style.display === 'none' || style.visibility === 'hidden') return false;\n            const rect = el.getBoundingClientRect();\n            return rect.width > 0 && rect.height > 0;\n        };\n        const normalize = (value) => String(value || '').replace(/\\\\s+/g, ' ').trim();\n        const escapeRegExp = (value) => String(value).replace(/[|\\\\\\\\{}()[\\\\]^$+*?.]/g, '\\\\\\\\$&');","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chatgpt/utils.js#L377-L413","documentation":"requireKnownChatGPTTool validates the requested tool name against CHATGPT_TOOL_OPTIONS (only 'deep-research' and 'web-search') and throws ArgumentError otherwise. Tools are ChatGPT composer capabilities the CLI can switch on via the UI; anything else is rejected up front with the list of valid choices.","triggerScenarios":"Calling a tool-selection path (requireKnownChatGPTTool via target) with names like 'search', 'code-interpreter', 'canvas', 'image-gen', or a localized variant not in the option map; the map only accepts the exact keys deep-research and web-search.","commonSituations":"Config scripts referencing ChatGPT features by their UI wording rather than the CLI's keys; expecting every ChatGPT GPT/tool to be selectable; older configs using names like 'browse' or 'research' alone.","solutions":["Use exactly 'deep-research' or 'web-search' as the tool value.","Check the error's suggestion text, which lists CHATGPT_TOOL_CHOICES.","Hyphenate multi-word tools ('web search' -> 'web-search'); lookup is lowercased but not whitespace-normalized.","Update the library if ChatGPT added new selectable tools you need."],"exampleFix":"// before\nawait chatgpt.tool({ tool: 'search' }); // ArgumentError\n// after\nawait chatgpt.tool({ tool: 'web-search' });","handlingStrategy":"validation","validationCode":"import { CHATGPT_TOOL_CHOICES } from '@jackwener/opencli/chatgpt/utils';\nif (!CHATGPT_TOOL_CHOICES.includes(String(tool ?? '').trim().toLowerCase())) {\n  throw new Error(`tool must be one of: ${CHATGPT_TOOL_CHOICES.join(', ')}`);\n}","typeGuard":"function isKnownChatGPTTool(tool) {\n  return tool === 'deep-research' || tool === 'web-search';\n}","tryCatchPattern":"try {\n  await selectChatGPTTool(page, tool);\n} catch (err) {\n  if (err instanceof ArgumentError && /Unknown ChatGPT tool/.test(err.message)) {\n    console.error(err.suggestion ?? err.message);\n  }\n  throw err;\n}","preventionTips":["Use the exact keys 'deep-research' and 'web-search' in configs.","Import CHATGPT_TOOL_CHOICES and validate user input against it.","Don't assume other ChatGPT features (canvas, code interpreter) are selectable tools here."],"tags":["validation","argument-error","chatgpt","tool-name"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}