{"record":{"id":"2271cd3ee88234e9","repo":"Hmbown/CodeWhale","slug":"open-application-needs-name-bundle-id-or-pid","errorCode":null,"errorMessage":"open_application needs name, bundle_id or pid","messagePattern":"open_application needs name, bundle_id or pid","errorType":"exception","errorClass":"ExecError","httpStatus":null,"severity":"warning","filePath":"crates/tui/plugins/computer-use/src/backends/darwin.mjs","lineNumber":763,"sourceCode":"        installed: true,\n        note: \"Installed catalog from /Applications, /System/Applications and ~/Applications; running flags reflect this moment. This scan takes a moment.\",\n      };\n    }\n    const r = await native(\"list_apps\");\n    const apps = Array.isArray(r?.apps) ? r.apps : [];\n    const shown = selectApps(apps, args?.all === true);\n    return {\n      apps: shown,\n      total: apps.length,\n      filtered: args?.all === true ? \"all\" : \"regular\",\n      ...(shown.length !== apps.length ? { note: \"Regular (user-facing) apps only — pass all:true to include menu-bar helpers and background processes.\" } : {}),\n    };\n  }\n\n  async function listWindows({ app_ref } = {}) { return native(\"list_windows\", { app_ref: app_ref === undefined ? state.inputApp ?? undefined : app_ref }); }\n\n  async function openApplication({ name, bundle_id: bid, pid, url: urlArg, activate = false } = {}) {\n    if (!name && !bid && !pid) throw new ExecError(\"open_application needs name, bundle_id or pid\");\n    // Failed selection must not leave an earlier app armed for shared input.\n    state.foregroundInput = false;\n    state.inputApp = null;\n    // pid is the most specific identity and the only one that separates two\n    // processes of the same bundle (e.g. a second Chrome on its own profile),\n    // so it wins when given.\n    const find = {};\n    if (pid) find.pid = pid; else if (bid) find.bundle_id = bid; else find.name = String(name).replace(/\\.app$/, \"\");\n    let p;\n    let launched = false;\n    // Binding an already-running app must not ask LaunchServices to reopen\n    // it: reopen can raise windows even with open -g on some applications.\n    if (!urlArg) {\n      try { p = await native(\"app_info\", { app_ref: find, activate }); }\n      catch (error) {\n        if (!error.message.includes(\"application not found\")) throw error;\n      }\n    }","sourceCodeStart":745,"sourceCodeEnd":781,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/plugins/computer-use/src/backends/darwin.mjs#L745-L781","documentation":"openApplication resolves an application by name, bundle_id, or pid; the library requires at least one identity and throws this immediately when all three are absent/undefined. As a guard it also clears any previously armed foreground-input binding before failing.","triggerScenarios":"Calling open_application with no arguments, an empty object, or where the variables holding name/bundle_id/pid are all undefined at the call site.","commonSituations":"Constructing arguments dynamically from upstream data where all fields happen to be missing; passing the object with misspelled keys (e.g. bundleId instead of bundle_id); an agent emitting an open_application tool call with empty parameters.","solutions":["Pass at least one of name, bundle_id, or pid.","Prefer pid when you have it — it is the only identity that distinguishes two processes of the same bundle.","Run list_apps first to obtain exact names/pids.","Fix key spelling: the bundle identifier parameter is bundle_id (snake_case), not bundleId."],"exampleFix":"// before\nawait backend.openApplication({});\n// after\nawait backend.openApplication({ bundle_id: \"com.google.Chrome\" });","handlingStrategy":"validation","validationCode":"const hasIdentity = a => !!(a && (a.name || a.bundle_id || a.pid));\nif (!hasIdentity(args)) throw new Error('open_application requires name, bundle_id or pid');","typeGuard":"const isOpenArgs = a => a != null && (typeof a.name === 'string' || typeof a.bundle_id === 'string' || Number.isInteger(a.pid));","tryCatchPattern":"try {\n  await backend.openApplication(args);\n} catch (e) {\n  if (String(e.message).startsWith('open_application needs')) {\n    // fix arguments before retrying\n  } else throw e;\n}","preventionTips":["Always resolve the target via list_apps before opening.","Use snake_case bundle_id, not bundleId.","Validate dynamic argument objects for at least one identity key before the call."],"tags":["validation","missing-argument","macos"],"backgroundTag":"missing-required-argument","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T16:17:23.217Z"}