{
  "schema": 1,
  "id": "ext.codex",
  "name": "ChatGPT Codex",
  "version": "2.1.2",
  "category": "tool",
  "description": "OpenAI Codex as a chat agent: models from the Codex CLI or its model cache, reasoning effort per model, sandbox modes, web search, resumable sessions, images and plan. Plus tasks and an AGENTS.md template. Ships executable code.",
  "author": "Lumen",
  "icon": "Cx",
  "color": "#10a37f",
  "license": "MIT",
  "minAppVersion": "0.5.2",
  "keywords": [
    "codex",
    "chatgpt",
    "openai",
    "ai",
    "agent",
    "cli"
  ],
  "readme": "# ChatGPT Codex\n\nOpenAI Codex as a chat agent in Lumen. Each message starts the installed\nCodex CLI (`codex exec`); your login, `AGENTS.md` and `~/.codex/config.toml`\napply.\n\n## Chat\n\n- **Modes** are sandbox levels: *In project* (default), *Read only* and — only\n  when enabled — *Full access*\n- **Tools** with preview: commands with their output, changed files to\n  open, MCP calls, web searches\n- **Plan**: Codex's to-do list as a card with progress\n- **Tokens and duration** per answer\n- **Multiple chats**, **resume earlier sessions** (from `~/.codex/sessions`)\n- **Models** from `~/.codex/models_cache.json` or from `codex app-server`\n  (`model/list`) — ↻ next to the picker asks the CLI again\n- **Reasoning effort per model** chosen in the chat — only the levels the model\n  supports; Lumen remembers the choice per model\n- Switch **models** directly in the chat, paste or attach **images**,\n  `@` for files, send the open file and selection along\n\n## Settings\n\n*Settings → Extensions → ChatGPT Codex*: path to `codex`, profile,\ndefault model, model list source, more models, default reasoning effort,\nreasoning summary, verbosity, hide reasoning, web search, network in the sandbox, approval policy,\nfull access, more writable folders, Git check, more\nconfiguration (`-c key=value`) and environment variables.\n\n## Project\n\n- **Project type** `ChatGPT Codex` — detected by `AGENTS.md` or `.codex/`, with the\n  tasks *Start Codex*, *Resume last session*, *Sign in*,\n  *Show MCP servers* and *Install Codex*\n- **Template** `AGENTS.md` with commands and conventions\n\n## Requirements\n\n```sh\nnpm install -g @openai/codex\ncodex login\n```\n\nThe extension ships executable code that must be confirmed on installation.\nIt only starts the program you have installed.\n",
  "settings": [
    {
      "key": "codexPath",
      "label": "Path to codex",
      "type": "path",
      "pathKind": "file",
      "section": "Program",
      "default": "",
      "placeholder": "search automatically",
      "hint": "Leave empty to find codex on the PATH and in the usual folders."
    },
    {
      "key": "profile",
      "label": "Profile from config.toml",
      "type": "text",
      "section": "Program",
      "default": "",
      "placeholder": "none",
      "hint": "A profile from ~/.codex/config.toml that applies to every message."
    },
    {
      "key": "model",
      "label": "Default model",
      "type": "text",
      "section": "Model",
      "default": "",
      "placeholder": "as in config.toml",
      "hint": "Applies while \"Default\" is chosen in the chat — e.g. gpt-5-codex. The chat picker comes from Codex itself."
    },
    {
      "key": "modelSource",
      "label": "Model list from",
      "type": "select",
      "section": "Model",
      "default": "auto",
      "hint": "\"Automatic\" reads ~/.codex/models_cache.json and asks codex app-server when the file is missing or you reload.",
      "choices": [
        {
          "value": "auto",
          "label": "Automatic (cache, else CLI)"
        },
        {
          "value": "cache",
          "label": "models_cache.json only"
        },
        {
          "value": "cli",
          "label": "Always codex app-server"
        }
      ]
    },
    {
      "key": "showLegacyModels",
      "label": "Offer older and hidden models",
      "type": "toggle",
      "section": "Model",
      "default": "false",
      "hint": "Also adds models that Codex hides in its own list."
    },
    {
      "key": "modelCacheMinutes",
      "label": "CLI-Cache model list (minutes)",
      "type": "number",
      "section": "Model",
      "default": "60",
      "min": 0,
      "max": 10080,
      "when": "modelSource=cli"
    },
    {
      "key": "extraModels",
      "label": "More models",
      "type": "textarea",
      "section": "Model",
      "rows": 2,
      "default": "",
      "placeholder": "gpt-5-codex | GPT-5 Codex (pinned)",
      "hint": "In addition to the Codex list — one model ID per line, optionally with \"| Display name\"."
    },
    {
      "key": "reasoningEffort",
      "label": "Default reasoning effort",
      "type": "select",
      "section": "Model",
      "default": "auto",
      "choices": [
        {
          "value": "auto",
          "label": "As in config.toml"
        },
        {
          "value": "none",
          "label": "None"
        },
        {
          "value": "minimal",
          "label": "Minimal"
        },
        {
          "value": "low",
          "label": "Low"
        },
        {
          "value": "medium",
          "label": "Medium"
        },
        {
          "value": "high",
          "label": "High"
        },
        {
          "value": "xhigh",
          "label": "Very high"
        }
      ],
      "hint": "Applies while no effort is chosen in the chat. In the chat it can be set per model — only the levels the model supports are offered."
    },
    {
      "key": "reasoningSummary",
      "label": "Reasoning summary",
      "type": "select",
      "section": "Model",
      "default": "default",
      "choices": [
        {
          "value": "default",
          "label": "As in config.toml"
        },
        {
          "value": "auto",
          "label": "Automatic"
        },
        {
          "value": "concise",
          "label": "Concise"
        },
        {
          "value": "detailed",
          "label": "Detailed"
        },
        {
          "value": "none",
          "label": "None"
        }
      ]
    },
    {
      "key": "verbosity",
      "label": "Answer verbosity",
      "type": "select",
      "section": "Model",
      "default": "auto",
      "choices": [
        {
          "value": "auto",
          "label": "As in config.toml"
        },
        {
          "value": "low",
          "label": "Concise"
        },
        {
          "value": "medium",
          "label": "Medium"
        },
        {
          "value": "high",
          "label": "Detailed"
        }
      ]
    },
    {
      "key": "hideReasoning",
      "label": "Hide reasoning",
      "type": "toggle",
      "section": "Model",
      "default": "false"
    },
    {
      "key": "webSearch",
      "label": "Web search",
      "type": "select",
      "section": "Tools",
      "default": "auto",
      "choices": [
        {
          "value": "auto",
          "label": "As in config.toml"
        },
        {
          "value": "live",
          "label": "Live"
        },
        {
          "value": "cached",
          "label": "From the cache"
        },
        {
          "value": "disabled",
          "label": "Off"
        }
      ]
    },
    {
      "key": "networkAccess",
      "label": "Network in \"In project\" sandbox mode",
      "type": "select",
      "section": "Tools",
      "default": "auto",
      "hint": "Whether commands in the \"In project\" mode may access the network (npm install, curl …).",
      "choices": [
        {
          "value": "auto",
          "label": "As in config.toml"
        },
        {
          "value": "true",
          "label": "Allowed"
        },
        {
          "value": "false",
          "label": "Blocked"
        }
      ]
    },
    {
      "key": "approvalPolicy",
      "label": "Approval policy",
      "type": "select",
      "section": "Permissions",
      "default": "never",
      "hint": "Codex cannot ask questions in the chat — what it may do is set by the sandbox mode. \"Never ask\" keeps Codex from waiting for an answer.",
      "choices": [
        {
          "value": "never",
          "label": "Never ask"
        },
        {
          "value": "on-failure",
          "label": "On failure"
        },
        {
          "value": "on-request",
          "label": "On the model's request"
        },
        {
          "value": "untrusted",
          "label": "For untrusted commands"
        },
        {
          "value": "auto",
          "label": "As in config.toml"
        }
      ]
    },
    {
      "key": "allowFullAccess",
      "label": "Allow \"Full access\" mode",
      "type": "toggle",
      "section": "Permissions",
      "default": "false",
      "hint": "Warning: without a sandbox Codex can change any file and run any command. Use only in isolated environments."
    },
    {
      "key": "additionalDirectories",
      "label": "More writable folders",
      "type": "textarea",
      "section": "Permissions",
      "rows": 2,
      "default": "",
      "placeholder": "~/shared-lib",
      "hint": "One per line."
    },
    {
      "key": "skipGitRepoCheck",
      "label": "Also work outside Git repositories",
      "type": "toggle",
      "section": "Permissions",
      "default": "true"
    },
    {
      "key": "configOverrides",
      "label": "More configuration (-c)",
      "type": "textarea",
      "section": "Advanced",
      "rows": 3,
      "default": "",
      "placeholder": "model_verbosity=\"low\"\nhide_agent_reasoning=true",
      "hint": "One key=value per line in TOML format, as with `codex -c`."
    },
    {
      "key": "env",
      "label": "Environment variables",
      "type": "textarea",
      "section": "Advanced",
      "rows": 3,
      "default": "",
      "placeholder": "OPENAI_API_KEY=…\nHTTPS_PROXY=http://proxy:3128",
      "hint": "KEY=VALUE, one per line."
    }
  ],
  "pages": [],
  "agents": [
    {
      "id": "codex",
      "name": "Codex",
      "description": "Ask Codex about your project: explain code, find bugs, make changes. What Codex may do is set by the mode.",
      "icon": "Cx",
      "location": "right",
      "images": true,
      "placeholder": "Message Codex …  (Enter to send, Shift+Enter for a new line, @ files)",
      "modelSetting": "model",
      "models": [],
      "modes": [
        {
          "id": "workspace-write",
          "label": "In project",
          "description": "Reads everything, changes and runs only in the project folder"
        },
        {
          "id": "read-only",
          "label": "Read only",
          "description": "Reads and plans, changes nothing"
        },
        {
          "id": "danger-full-access",
          "label": "Full access",
          "description": "No sandbox — must be enabled in the settings"
        }
      ],
      "suggestions": [
        "Explain the structure of this project.",
        "Find possible bugs in the open file.",
        "Write tests for the current selection.",
        "Create an AGENTS.md for this project."
      ]
    }
  ],
  "views": [],
  "commands": [],
  "code": {
    "main": "import { createRequire as __lumenRequire } from 'node:module'; const require = __lumenRequire(import.meta.url);\nimport{spawn as C}from\"node:child_process\";import E from\"node:fs\";import f from\"node:fs/promises\";import k from\"node:os\";import l from\"node:path\";import $ from\"node:readline\";var L=new Set([\"read-only\",\"workspace-write\",\"danger-full-access\"]),H=new Set([\"never\",\"on-request\",\"on-failure\",\"untrusted\"]),F=new Set([\"none\",\"minimal\",\"low\",\"medium\",\"high\",\"xhigh\"]),J=new Set([\"auto\",\"concise\",\"detailed\",\"none\"]),W=new Set([\"low\",\"medium\",\"high\"]),z=2e4,S=6e3,X={\"image/png\":\".png\",\"image/jpeg\":\".jpg\",\"image/gif\":\".gif\",\"image/webp\":\".webp\"},V=300,w=new Map,g={key:\"\",at:0,list:[]},I=e=>String(e??\"\").split(/\\r?\\n/).map(t=>t.trim()).filter(Boolean),Z=e=>e===\"true\",q=e=>e.replace(/^~(?=\\/|$)/,k.homedir()),A=()=>process.env.CODEX_HOME||l.join(k.homedir(),\".codex\");function R(e){let t={};for(let o of String(e??\"\").split(/\\r?\\n/)){let n=/^\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*=\\s*(.*)$/.exec(o);n&&(t[n[1]]=n[2])}return t}function D(e){let t=process.platform===\"win32\"?\"codex.cmd\":\"codex\";if(e&&e!==\"codex\"){if(!E.existsSync(e))throw new Error(`codex not found at ${e}`);return e}let o=k.homedir(),n=[...(process.env.PATH??\"\").split(l.delimiter),l.join(o,\".local\",\"bin\"),l.join(o,\".npm-global\",\"bin\"),l.join(o,\".bun\",\"bin\"),l.join(o,\".cargo\",\"bin\"),\"/usr/local/bin\",\"/opt/homebrew/bin\"];for(let i of n.filter(Boolean)){let a=l.join(i,t);if(E.existsSync(a))return a}throw new Error(\"Codex is not installed. Install it (npm install -g @openai/codex), sign in with `codex login`, or set its path under Settings \\u2192 Extensions \\u2192 ChatGPT Codex.\")}function K(e,t){if(!L.has(e))throw new Error(`Unknown mode: ${e}`);if(e===\"danger-full-access\"&&!Z(t.allowFullAccess))throw new Error(\"\\u201CFull access\\u201D is switched off. Enable it under Settings \\u2192 Extensions \\u2192 ChatGPT Codex first.\");return e}var p=e=>`\"${String(e).replace(/\\\\/g,\"\\\\\\\\\").replace(/\"/g,'\\\\\"')}\"`;function Q(e){let t=e.effort||e.settings.reasoningEffort;if(!(!t||t===\"auto\")){if(!F.has(t))throw new Error(`Unknown reasoning effort: ${t}`);return t}}function Y(e,t){let{cwd:o,mode:n,sessionId:i,model:a,settings:r}=e,s=Q(e),c=[\"exec\",\"--experimental-json\"];for(let u of I(r.configOverrides))c.push(\"--config\",u);let d=a||(r.model!==\"auto\"?r.model:\"\");d&&c.push(\"--model\",d),r.profile&&c.push(\"--config\",`profile=${p(r.profile)}`),c.push(\"--sandbox\",K(n,r)),c.push(\"--cd\",o);for(let u of I(r.additionalDirectories))c.push(\"--add-dir\",q(u));r.skipGitRepoCheck!==\"false\"&&c.push(\"--skip-git-repo-check\"),s&&c.push(\"--config\",`model_reasoning_effort=${p(s)}`),J.has(r.reasoningSummary)&&c.push(\"--config\",`model_reasoning_summary=${p(r.reasoningSummary)}`),W.has(r.verbosity)&&c.push(\"--config\",`model_verbosity=${p(r.verbosity)}`),r.hideReasoning===\"true\"&&c.push(\"--config\",\"hide_agent_reasoning=true\"),(r.networkAccess===\"true\"||r.networkAccess===\"false\")&&c.push(\"--config\",`sandbox_workspace_write.network_access=${r.networkAccess}`),r.webSearch&&r.webSearch!==\"auto\"&&c.push(\"--config\",`web_search=${p(r.webSearch)}`),H.has(r.approvalPolicy)&&c.push(\"--config\",`approval_policy=${p(r.approvalPolicy)}`),i&&c.push(\"resume\",i);for(let u of t)c.push(\"--image\",u);return c}async function ee(e=[]){let t=[],o=null;for(let n of e){if(n.path&&/\\.(png|jpe?g|gif|webp)$/i.test(n.path)){t.push(n.path);continue}let i=X[n.mimeType];if(!n.data||!i)continue;o??=await f.mkdtemp(l.join(k.tmpdir(),\"lumen-codex-\"));let a=l.join(o,`image-${t.length+1}${i}`);await f.writeFile(a,Buffer.from(n.data,\"base64\")),t.push(a)}return{files:t,cleanup:()=>o?f.rm(o,{recursive:!0,force:!0}):Promise.resolve()}}function te(e,t=[]){let o=t.filter(n=>n.path&&!/\\.(png|jpe?g|gif|webp)$/i.test(n.path));return o.length?`${e}\n\nFiles: ${o.map(n=>n.path).join(\", \")}`:e}function P(e){let t=String(e??\"\");return t.length<=S?t:`${t.slice(0,S)}\n\\u2026 (${t.length-S} more characters)`}var ne={add:\"Write\",update:\"Edit\",delete:\"Delete\"};function oe(e){if(e.error?.message)return e.error.message;let t=Array.isArray(e.result?.content)?e.result.content:[];return P(t.map(o=>o.type===\"text\"?o.text:`[${o.type}]`).join(`\n`))}function j(e){let t=Array.isArray(e.items)?e.items:[],o=t.findIndex(n=>!n.completed);return t.map((n,i)=>n.completed?{text:n.text,status:\"completed\"}:{text:n.text,status:i===o?\"in_progress\":\"pending\"})}function se(e){if(e.type===\"command_execution\")return[{kind:\"assistant\",blocks:[{type:\"tool\",id:e.id,name:\"Shell\",input:{command:e.command}}]}];if(e.type===\"mcp_tool_call\"){let t=e.arguments&&typeof e.arguments==\"object\"?e.arguments:{arguments:e.arguments};return[{kind:\"assistant\",blocks:[{type:\"tool\",id:e.id,name:`${e.server}.${e.tool}`,input:t}]}]}return e.type===\"web_search\"?[{kind:\"assistant\",blocks:[{type:\"tool\",id:e.id,name:\"WebSearch\",input:{query:e.query}}]}]:e.type===\"todo_list\"?[{kind:\"todos\",items:j(e)}]:[]}function re(e,t){if(e.type===\"agent_message\")return[{kind:\"assistant\",blocks:[{type:\"text\",text:e.text??\"\"}]}];if(e.type===\"reasoning\")return[{kind:\"assistant\",blocks:[{type:\"thinking\",text:e.text??\"\"}]}];if(e.type===\"command_execution\"){let o=e.status===\"failed\"||typeof e.exit_code==\"number\"&&e.exit_code!==0;return[{kind:\"toolResult\",toolUseId:e.id,text:P(e.aggregated_output),isError:o}]}return e.type===\"file_change\"?(e.changes??[]).flatMap((o,n)=>{let i=`${e.id}-${n}`,a=l.isAbsolute(o.path)?o.path:l.join(t,o.path);return[{kind:\"assistant\",blocks:[{type:\"tool\",id:i,name:ne[o.kind]??\"Edit\",input:{file_path:a}}]},{kind:\"toolResult\",toolUseId:i,text:\"\",isError:e.status===\"failed\"}]}):e.type===\"mcp_tool_call\"?[{kind:\"toolResult\",toolUseId:e.id,text:oe(e),isError:e.status===\"failed\"}]:e.type===\"web_search\"?[{kind:\"toolResult\",toolUseId:e.id,text:\"\",isError:!1}]:e.type===\"todo_list\"?[{kind:\"todos\",items:j(e)}]:e.type===\"error\"?[{kind:\"error\",message:e.message}]:[]}function v(e,t){return{inputTokens:e?.input_tokens,outputTokens:(e?.output_tokens??0)+(e?.reasoning_output_tokens??0),cacheReadTokens:e?.cached_input_tokens,cacheWriteTokens:e?.cache_write_input_tokens,durationMs:Date.now()-t}}function ie(e,t){return e.type===\"thread.started\"?[{kind:\"session\",sessionId:e.thread_id,model:t.model}]:e.type===\"turn.started\"?[{kind:\"status\",text:\"\"}]:e.type===\"item.started\"?se(e.item):e.type===\"item.updated\"&&e.item?.type===\"todo_list\"?[{kind:\"todos\",items:j(e.item)}]:e.type===\"item.completed\"?re(e.item,t.cwd):e.type===\"turn.completed\"?[{kind:\"result\",isError:!1,text:\"\",usage:v(e.usage,t.startedAt)}]:e.type===\"turn.failed\"?[{kind:\"result\",isError:!0,text:e.error?.message??\"The turn failed\",usage:v(null,t.startedAt)}]:e.type===\"error\"?[{kind:\"error\",message:e.message}]:[]}async function ae(e){let t=[],o=async(n,i)=>{let a=await f.readdir(n,{withFileTypes:!0}).catch(()=>[]);for(let r of a){let s=l.join(n,r.name);r.isDirectory()&&i<3&&await o(s,i+1),r.isFile()&&r.name.endsWith(\".jsonl\")&&t.push(s)}};return await o(e,0),t.sort((n,i)=>l.basename(i).localeCompare(l.basename(n))).slice(0,V)}function ce(e){let t=e?.payload??e;if(t?.type===\"user_message\"&&typeof t.message==\"string\")return t.message;if(t?.type!==\"message\"||t.role!==\"user\"||!Array.isArray(t.content))return\"\";let o=t.content.map(n=>n.text??\"\").join(\" \").trim();return o.startsWith(\"<\")?\"\":o}async function le(e){let t=E.createReadStream(e,{encoding:\"utf8\",end:262144}),o=$.createInterface({input:t,crlfDelay:1/0}),n={id:\"\",cwd:\"\",title:\"\"};try{for await(let i of o){let a;try{a=JSON.parse(i)}catch{continue}let r=a?.payload??{};if(!n.id&&(a?.type===\"session_meta\"||r.id)&&typeof r.id==\"string\"&&(n.id=r.id,n.cwd=typeof r.cwd==\"string\"?r.cwd:\"\"),n.title||(n.title=ce(a)),n.id&&n.title)break}}finally{o.close(),t.destroy()}return n}async function de(e){let t=l.join(A(),\"sessions\"),o=await ae(t),n=[];for(let i of o){let a=await le(i).catch(()=>null);if(!a?.id||l.resolve(a.cwd||\"/\")!==l.resolve(e))continue;let r=await f.stat(i).catch(()=>null);if(n.push({id:a.id,title:(a.title||a.id).split(`\n`)[0].slice(0,80),updatedAt:r?.mtimeMs}),n.length>=40)break}return n.sort((i,a)=>(a.updatedAt??0)-(i.updatedAt??0))}function ue(e){if(typeof e==\"string\")return{id:e};let t=e?.effort??e?.reasoningEffort??e?.reasoning_effort??e?.id;return typeof t!=\"string\"||!t?null:{id:t,description:e.description||void 0}}var N=e=>Array.isArray(e)?e.map(ue).filter(Boolean):void 0;async function b(e=!1){let t=await f.readFile(l.join(A(),\"models_cache.json\"),\"utf8\").catch(()=>\"\");if(!t)return[];let o=JSON.parse(t);return(Array.isArray(o.models)?o.models:[]).filter(n=>n?.slug&&(e||(n.visibility??\"list\")===\"list\")).sort((n,i)=>(n.priority??1e9)-(i.priority??1e9)).map(n=>({id:n.slug,label:n.display_name||n.slug,description:[n.visibility===\"list\"||!n.visibility?\"\":\"Older model\",n.description].filter(Boolean).join(\" \\u2014 \")||void 0,efforts:N(n.supported_reasoning_levels),defaultEffort:n.default_reasoning_level||void 0}))}function fe(e){let t=C(D(e.codexPath),[\"app-server\"],{env:{...process.env,...R(e.env)},shell:process.platform===\"win32\",windowsHide:!0}),o=new Map,n=0,i=s=>{for(let{reject:c}of o.values())c(s);o.clear()};t.once(\"error\",i),t.once(\"close\",s=>i(new Error(`codex app-server exited with code ${s}`))),t.stdin.on(\"error\",()=>{});let a=$.createInterface({input:t.stdout,crlfDelay:1/0});a.on(\"line\",s=>{let c;try{c=JSON.parse(s)}catch{return}let d=o.get(c?.id);if(d){if(o.delete(c.id),c.error){d.reject(new Error(c.error.message??\"codex app-server failed\"));return}d.resolve(c.result)}});let r=s=>t.stdin.write(`${JSON.stringify(s)}\n`);return{request(s,c){let d=++n;return new Promise((u,y)=>{o.set(d,{resolve:u,reject:y}),r({id:d,method:s,params:c})})},notify:(s,c)=>r(c?{method:s,params:c}:{method:s}),close(){a.close(),t.stdin.end(),t.kill(\"SIGTERM\")}}}async function pe(e,t=!1){let o=fe(e),n,i=new Promise((r,s)=>{n=setTimeout(()=>s(new Error(\"codex did not report its models in time\")),z)}),a=async()=>{await o.request(\"initialize\",{clientInfo:{name:\"lumen\",title:\"Lumen\",version:\"1.0.0\"}}),o.notify(\"initialized\");let r=[],s;for(let c=0;c<10;c++){let d=await o.request(\"model/list\",{...s?{cursor:s}:{},...t?{includeHidden:!0}:{}});if(r.push(...d?.data??d?.models??d?.items??[]),s=d?.nextCursor??d?.next_cursor,!s)break}return r};try{return(await Promise.race([a(),i])).filter(s=>(s?.model||s?.id||s?.slug)&&(t||!s.hidden)).map(s=>({id:s.model||s.id||s.slug,label:s.displayName||s.display_name||s.model||s.id,description:[s.hidden?\"Older model\":\"\",s.description].filter(Boolean).join(\" \\u2014 \")||void 0,efforts:N(s.supportedReasoningEfforts??s.supported_reasoning_levels),defaultEffort:s.defaultReasoningEffort||s.default_reasoning_level||void 0,isDefault:s.isDefault===!0}))}finally{clearTimeout(n),o.close()}}async function me(){let t=(await f.readFile(l.join(A(),\"config.toml\"),\"utf8\").catch(()=>\"\")).split(/^\\s*\\[/m)[0];return/^\\s*model\\s*=\\s*[\"']([^\"']+)[\"']/m.exec(t)?.[1]??\"\"}function U(e){return I(e).map(t=>{let[o,n]=t.split(\"|\").map(i=>i.trim());return{id:o,label:n||o,efforts:[...F].map(i=>({id:i}))}})}async function he(e,t){let o=e.modelSource||\"auto\",n=e.showLegacyModels===\"true\";if(o===\"cache\")return b(n);let i=JSON.stringify([e.codexPath,e.env,n]),a=Number(e.modelCacheMinutes||60),r=g.key===i&&Date.now()-g.at<Math.max(0,a)*6e4;if(o===\"auto\"&&!t){let s=await b(n).catch(()=>[]);if(s.length)return s}if(r&&!t&&g.list.length)return g.list;try{let s=await pe(e,n);return g={key:i,at:Date.now(),list:s},s}catch(s){if(o===\"cli\")throw s;return console.warn(\"[codex] could not list models via codex app-server:\",s.message),b(n)}}async function ge({settings:e={},refresh:t=!1}={}){let o=await he(e,t);if(!o.some(i=>i.isDefault)){let i=await me(),a=o.find(r=>r.id===i);a&&(a.isDefault=!0)}let n=new Set(o.map(i=>i.id));return[...o,...U(e.extraModels).filter(i=>!n.has(i.id))]}async function we(e,t){let{chatId:o,text:n,cwd:i,attachments:a,settings:r}=e,s=D(r.codexPath),c=await ee(a),d={cwd:i,model:e.model||r.model||void 0,startedAt:Date.now()},u=C(s,Y(e,c.files),{cwd:i,env:{...process.env,...R(r.env)},shell:process.platform===\"win32\",windowsHide:!0}),y={child:u,stopped:!1};w.set(o,y);let T=[];u.stderr?.on(\"data\",m=>T.push(m));let O=new Promise((m,x)=>{u.once(\"error\",x),u.once(\"close\",(h,_)=>m({code:h,signal:_}))});O.catch(()=>{}),u.stdin?.end(te(n,a));try{let m=$.createInterface({input:u.stdout,crlfDelay:1/0});for await(let B of m){let M;try{M=JSON.parse(B)}catch{continue}for(let G of ie(M,d))t(G)}let{code:x,signal:h}=await O;if(y.stopped||x===0&&!h)return;let _=Buffer.concat(T).toString(\"utf8\").trim().split(`\n`).slice(-12).join(`\n`);throw new Error(`codex exited with ${h?`signal ${h}`:`code ${x}`}${_?`:\n${_}`:\"\"}`)}finally{w.delete(o),await c.cleanup().catch(()=>{})}}var ye={async send(e,t){if(w.has(e.chatId))throw new Error(\"Codex is still answering\");await we(e,t)},answer(){return!1},interrupt(e){let t=w.get(e);t&&(t.stopped=!0,t.child.kill(\"SIGTERM\"),setTimeout(()=>{t.child.exitCode===null&&t.child.signalCode===null&&t.child.kill(\"SIGKILL\")},3e3))},sessions:e=>de(e),models:e=>ge(e).catch(t=>(console.warn(\"[codex] could not list models:\",t.message),U(e?.settings?.extraModels)))};function Ie(e){return e.agents.register(\"codex\",ye),()=>{for(let t of w.values())t.stopped=!0,t.child.kill(\"SIGTERM\")}}export{Ie as activate};\n"
  },
  "addon": {
    "schema": 1,
    "languages": [],
    "themes": [],
    "commands": [],
    "events": [],
    "templates": [
      {
        "id": "codex-project",
        "name": "Codex Projekt",
        "description": "AGENTS.md with commands and conventions for Codex.",
        "kindId": "codex",
        "icon": "Cx",
        "color": "#10a37f",
        "open": "AGENTS.md",
        "next": "Start Codex from the task list.",
        "fields": [
          {
            "id": "description",
            "label": "Description",
            "section": "Projekt",
            "placeholder": "What does the project do?",
            "required": false
          },
          {
            "id": "commands",
            "label": "Build and test commands",
            "section": "Projekt",
            "placeholder": "npm test",
            "required": false,
            "mono": true
          }
        ],
        "files": [
          {
            "path": "AGENTS.md",
            "content": "# {{name}}\n\n{{description}}\n\n## Commands\n\n```sh\n{{commands}}\n```\n\n## Conventions\n\n- Small, reviewable changes\n- Run the tests before finishing\n"
          }
        ]
      }
    ],
    "projectKinds": [
      {
        "id": "codex",
        "name": "ChatGPT Codex",
        "icon": "Cx",
        "color": "#10a37f",
        "markers": [
          "AGENTS.md",
          ".codex"
        ],
        "priority": 1,
        "buildFile": "AGENTS.md",
        "tasks": [
          {
            "id": "session",
            "label": "Start Codex",
            "command": "codex",
            "args": [],
            "group": "run",
            "detail": "New session in the project folder"
          },
          {
            "id": "resume",
            "label": "Resume last session",
            "command": "codex",
            "args": [
              "resume",
              "--last"
            ],
            "group": "run"
          },
          {
            "id": "login",
            "label": "Sign in",
            "command": "codex",
            "args": [
              "login"
            ],
            "group": "other",
            "detail": "With a ChatGPT account or API key"
          },
          {
            "id": "mcp",
            "label": "Show MCP servers",
            "command": "codex",
            "args": [
              "mcp",
              "list"
            ],
            "group": "other"
          },
          {
            "id": "install",
            "label": "Install Codex",
            "command": "npm",
            "args": [
              "install",
              "-g",
              "@openai/codex"
            ],
            "group": "build",
            "detail": "Requires Node.js"
          }
        ],
        "facts": [
          {
            "label": "Instructions",
            "file": "AGENTS.md",
            "pattern": "^#\\s+(.+)$"
          }
        ]
      }
    ],
    "snippets": [],
    "id": "ext.codex",
    "name": "ChatGPT Codex",
    "version": "2.1.2",
    "description": "OpenAI Codex as a chat agent: models from the Codex CLI or its model cache, reasoning effort per model, sandbox modes, web search, resumable sessions, images and plan. Plus tasks and an AGENTS.md template. Ships executable code.",
    "author": "Lumen",
    "icon": "Cx",
    "color": "#10a37f",
    "category": "tool"
  }
}
