@pen.dev/cli 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +13 -6
  2. package/dist/anthropic-messages-xcJLXjiT.mjs +40 -0
  3. package/dist/azure-openai-responses-CoA9_5_J.mjs +2 -0
  4. package/dist/dist-Dmu1Pp1Y.mjs +1580 -0
  5. package/dist/{dist-BY6vOcMF.mjs → dist-L3CkgNK3.mjs} +2 -2
  6. package/dist/{error-body-D2Mrqb4g.mjs → error-body-BBlqjbe7.mjs} +1 -1
  7. package/dist/google-generative-ai-CFHCNDEQ.mjs +2 -0
  8. package/dist/google-shared-DolBdAGX.mjs +318 -0
  9. package/dist/google-vertex-tT_ymu8S.mjs +2 -0
  10. package/dist/index.mjs +2 -2
  11. package/dist/lib-EA7A-_Pc.mjs +9 -0
  12. package/dist/mistral-conversations-CsN5eF3B.mjs +5 -0
  13. package/dist/models-BBd5zwn6.mjs +2 -0
  14. package/dist/node_modules/@highagency/pencil-wasm/package.json +1 -1
  15. package/dist/node_modules/@highagency/pencil-wasm/pencil.d.ts +3 -0
  16. package/dist/node_modules/@highagency/pencil-wasm/pencil.js +1 -1
  17. package/dist/node_modules/@highagency/pencil-wasm/pencil.wasm +0 -0
  18. package/dist/openai-CbFQ5q5I.mjs +18 -0
  19. package/dist/openai-codex-responses-BIh-ZL5a.mjs +8 -0
  20. package/dist/openai-completions-CLJSzdfY.mjs +6 -0
  21. package/dist/openai-responses-DKbl253t.mjs +2 -0
  22. package/dist/openai-responses-shared-Brqyk2bc.mjs +11 -0
  23. package/dist/{openrouter-images-BbBWg9zF.mjs → openrouter-images-C8mOFqx9.mjs} +1 -1
  24. package/dist/out/mcp-server-darwin-arm64 +0 -0
  25. package/dist/out/mcp-server-darwin-x64 +0 -0
  26. package/dist/out/mcp-server-linux-arm64 +0 -0
  27. package/dist/out/mcp-server-linux-x64 +0 -0
  28. package/dist/out/mcp-server-windows-arm64.exe +0 -0
  29. package/dist/out/mcp-server-windows-x64.exe +0 -0
  30. package/dist/out/skills/pen-dev/SKILL.md +204 -0
  31. package/dist/out/skills/pen-dev/execute.md +364 -0
  32. package/dist/out/skills/pen-dev/guide/code.md +198 -0
  33. package/dist/out/skills/pen-dev/guide/components.md +45 -0
  34. package/dist/out/skills/pen-dev/guide/design-system.md +556 -0
  35. package/dist/out/skills/pen-dev/guide/landing-page.md +31 -0
  36. package/dist/out/skills/pen-dev/guide/mobile-app.md +31 -0
  37. package/dist/out/skills/pen-dev/guide/slides.md +222 -0
  38. package/dist/out/skills/pen-dev/guide/table.md +37 -0
  39. package/dist/out/skills/pen-dev/guide/tailwind.md +328 -0
  40. package/dist/out/skills/pen-dev/guide/web-app.md +245 -0
  41. package/dist/out/skills/pen-dev/pen-schema.md +202 -0
  42. package/dist/out/skills/pen-dev/scripts-and-shaders.md +94 -0
  43. package/dist/{pi-messages-CSXUHkjV.mjs → pi-messages-CucvyzBS.mjs} +2 -2
  44. package/dist/transform-messages-1ulTEFY1.mjs +2 -0
  45. package/dist/typescript-D0uAMumm.mjs +6 -0
  46. package/package.json +3 -3
  47. package/dist/anthropic-messages-Bf-fvkNu.mjs +0 -40
  48. package/dist/azure-openai-responses-CzgVqECr.mjs +0 -2
  49. package/dist/completionchunk-BQtPqA8U.mjs +0 -28
  50. package/dist/dist-BEo0Z8Vf.mjs +0 -1558
  51. package/dist/google-generative-ai-DSOqI0LF.mjs +0 -2
  52. package/dist/google-shared-CetPT_Vt.mjs +0 -318
  53. package/dist/google-vertex-CPtOc5oU.mjs +0 -2
  54. package/dist/mistral-conversations-CUsdbDQ8.mjs +0 -10
  55. package/dist/models-CwK5xZH9.mjs +0 -2
  56. package/dist/openai-Brr_V-tF.mjs +0 -17
  57. package/dist/openai-codex-responses-Cb5pfH5S.mjs +0 -8
  58. package/dist/openai-completions-BvTlcCeP.mjs +0 -6
  59. package/dist/openai-responses-IuaLTEHh.mjs +0 -2
  60. package/dist/openai-responses-shared-D4d0NbBE.mjs +0 -11
  61. package/dist/otel-CaADOqYZ.mjs +0 -4
  62. package/dist/transform-messages-CSBQpmXO.mjs +0 -2
  63. /package/dist/{deferred-tools-D8j2Ra6f.mjs → deferred-tools-CozAnCQL.mjs} +0 -0
  64. /package/dist/{github-copilot-headers-DZOfokGy.mjs → github-copilot-headers-DCj7hJoC.mjs} +0 -0
  65. /package/dist/{hash-Kp92CI9R.mjs → hash-DNYCELl4.mjs} +0 -0
  66. /package/dist/{headers-BvGum5dc.mjs → headers-DlpC0ues.mjs} +0 -0
  67. /package/dist/{openai-prompt-cache-t4kk9puG.mjs → openai-prompt-cache-tVHrB8oW.mjs} +0 -0
  68. /package/dist/{photon_rs-BySSRmP5.mjs → photon_rs-o0nbTM4F.mjs} +0 -0
  69. /package/dist/{provider-retry-BM3ArvaW.mjs → provider-retry-GaV_ioT7.mjs} +0 -0
  70. /package/dist/{sanitize-unicode-CHjuq5rK.mjs → sanitize-unicode-D-15laVS.mjs} +0 -0
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import{promises as e,statSync as t}from"fs";import n from"os";import r from"path";import{createRequire as i}from"module";import{spawn as a}from"child_process";import o from"readline";async function s(t){if(t===void 0)return{cleanup:async()=>{}};if(!c(t))throw Error(`outputSchema must be a plain JSON object`);let i=await e.mkdtemp(r.join(n.tmpdir(),`codex-output-schema-`)),a=r.join(i,`schema.json`),o=async()=>{try{await e.rm(i,{recursive:!0,force:!0})}catch{}};try{return await e.writeFile(a,JSON.stringify(t),`utf8`),{schemaPath:a,cleanup:o}}catch(e){throw await o(),e}}function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var l=class{_exec;_options;_id;_threadOptions;get id(){return this._id}constructor(e,t,n,r=null){this._exec=e,this._options=t,this._id=r,this._threadOptions=n}async runStreamed(e,t={}){return{events:this.runStreamedInternal(e,t)}}async*runStreamedInternal(e,t={}){let{schemaPath:n,cleanup:r}=await s(t.outputSchema),i=this._threadOptions,{prompt:a,images:o}=u(e),c=this._exec.run({input:a,baseUrl:this._options.baseUrl,apiKey:this._options.apiKey,threadId:this._id,images:o,model:i?.model,sandboxMode:i?.sandboxMode,workingDirectory:i?.workingDirectory,skipGitRepoCheck:i?.skipGitRepoCheck,outputSchemaFile:n,modelReasoningEffort:i?.modelReasoningEffort,signal:t.signal,networkAccessEnabled:i?.networkAccessEnabled,webSearchMode:i?.webSearchMode,webSearchEnabled:i?.webSearchEnabled,approvalPolicy:i?.approvalPolicy,additionalDirectories:i?.additionalDirectories});try{for await(let e of c){let t;try{t=JSON.parse(e)}catch(t){throw Error(`Failed to parse item: ${e}`,{cause:t})}t.type===`thread.started`&&(this._id=t.thread_id),yield t}}finally{await r()}}async run(e,t={}){let n=this.runStreamedInternal(e,t),r=[],i=``,a=null,o=null;for await(let e of n)if(e.type===`item.completed`)e.item.type===`agent_message`&&(i=e.item.text),r.push(e.item);else if(e.type===`turn.completed`)a=e.usage;else if(e.type===`turn.failed`){o=e.error;break}if(o)throw Error(o.message);return{items:r,finalResponse:i,usage:a}}};function u(e){if(typeof e==`string`)return{prompt:e,images:[]};let t=[],n=[];for(let r of e)r.type===`text`?t.push(r.text):r.type===`local_image`&&n.push(r.path);return{prompt:t.join(`
2
+ import{promises as e,statSync as t}from"fs";import n from"path";import{createRequire as r}from"module";import i from"os";import{spawn as a}from"child_process";import o from"readline";async function s(t){if(t===void 0)return{cleanup:async()=>{}};if(!c(t))throw Error(`outputSchema must be a plain JSON object`);let r=await e.mkdtemp(n.join(i.tmpdir(),`codex-output-schema-`)),a=n.join(r,`schema.json`),o=async()=>{try{await e.rm(r,{recursive:!0,force:!0})}catch{}};try{return await e.writeFile(a,JSON.stringify(t),`utf8`),{schemaPath:a,cleanup:o}}catch(e){throw await o(),e}}function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var l=class{_exec;_options;_id;_threadOptions;get id(){return this._id}constructor(e,t,n,r=null){this._exec=e,this._options=t,this._id=r,this._threadOptions=n}async runStreamed(e,t={}){return{events:this.runStreamedInternal(e,t)}}async*runStreamedInternal(e,t={}){let{schemaPath:n,cleanup:r}=await s(t.outputSchema),i=this._threadOptions,{prompt:a,images:o}=u(e),c=this._exec.run({input:a,baseUrl:this._options.baseUrl,apiKey:this._options.apiKey,threadId:this._id,images:o,model:i?.model,sandboxMode:i?.sandboxMode,workingDirectory:i?.workingDirectory,skipGitRepoCheck:i?.skipGitRepoCheck,outputSchemaFile:n,modelReasoningEffort:i?.modelReasoningEffort,signal:t.signal,networkAccessEnabled:i?.networkAccessEnabled,webSearchMode:i?.webSearchMode,webSearchEnabled:i?.webSearchEnabled,approvalPolicy:i?.approvalPolicy,additionalDirectories:i?.additionalDirectories});try{for await(let e of c){let t;try{t=JSON.parse(e)}catch(t){throw Error(`Failed to parse item: ${e}`,{cause:t})}t.type===`thread.started`&&(this._id=t.thread_id),yield t}}finally{await r()}}async run(e,t={}){let n=this.runStreamedInternal(e,t),r=[],i=``,a=null,o=null;for await(let e of n)if(e.type===`item.completed`)e.item.type===`agent_message`&&(i=e.item.text),r.push(e.item);else if(e.type===`turn.completed`)a=e.usage;else if(e.type===`turn.failed`){o=e.error;break}if(o)throw Error(o.message);return{items:r,finalResponse:i,usage:a}}};function u(e){if(typeof e==`string`)return{prompt:e,images:[]};let t=[],n=[];for(let r of e)r.type===`text`?t.push(r.text):r.type===`local_image`&&n.push(r.path);return{prompt:t.join(`
3
3
 
4
- `),images:n}}var d=`CODEX_INTERNAL_ORIGINATOR_OVERRIDE`,f=`codex_sdk_ts`,p=`@openai/codex`,m={"x86_64-unknown-linux-musl":`@openai/codex-linux-x64`,"aarch64-unknown-linux-musl":`@openai/codex-linux-arm64`,"x86_64-apple-darwin":`@openai/codex-darwin-x64`,"aarch64-apple-darwin":`@openai/codex-darwin-arm64`,"x86_64-pc-windows-msvc":`@openai/codex-win32-x64`,"aarch64-pc-windows-msvc":`@openai/codex-win32-arm64`},h=i(import.meta.url),g=class{executablePath;pathDirs;envOverride;configOverrides;constructor(e=null,t,n){if(e)this.executablePath=e,this.pathDirs=[];else{let e=C();this.executablePath=e.executablePath,this.pathDirs=e.pathDirs}this.envOverride=t,this.configOverrides=n}async*run(e){let t=[`exec`,`--experimental-json`];if(this.configOverrides)for(let e of _(this.configOverrides))t.push(`--config`,e);if(e.baseUrl&&t.push(`--config`,`openai_base_url=${y(e.baseUrl,`openai_base_url`)}`),e.model&&t.push(`--model`,e.model),e.sandboxMode&&t.push(`--sandbox`,e.sandboxMode),e.workingDirectory&&t.push(`--cd`,e.workingDirectory),e.additionalDirectories?.length)for(let n of e.additionalDirectories)t.push(`--add-dir`,n);if(e.skipGitRepoCheck&&t.push(`--skip-git-repo-check`),e.outputSchemaFile&&t.push(`--output-schema`,e.outputSchemaFile),e.modelReasoningEffort&&t.push(`--config`,`model_reasoning_effort="${e.modelReasoningEffort}"`),e.networkAccessEnabled!==void 0&&t.push(`--config`,`sandbox_workspace_write.network_access=${e.networkAccessEnabled}`),e.webSearchMode?t.push(`--config`,`web_search="${e.webSearchMode}"`):e.webSearchEnabled===!0?t.push(`--config`,`web_search="live"`):e.webSearchEnabled===!1&&t.push(`--config`,`web_search="disabled"`),e.approvalPolicy&&t.push(`--config`,`approval_policy="${e.approvalPolicy}"`),e.threadId&&t.push(`resume`,e.threadId),e.images?.length)for(let n of e.images)t.push(`--image`,n);let n={};if(this.envOverride)Object.assign(n,this.envOverride);else for(let[e,t]of Object.entries(process.env))t!==void 0&&(n[e]=t);n[d]||(n[d]=f),e.apiKey&&(n.CODEX_API_KEY=e.apiKey),this.pathDirs.length>0&&E(n,this.pathDirs);let r=a(this.executablePath,t,{env:n,signal:e.signal}),i=null;if(r.once(`error`,e=>i=e),!r.stdin)throw r.kill(),Error(`Child process has no stdin`);if(r.stdin.write(e.input),r.stdin.end(),!r.stdout)throw r.kill(),Error(`Child process has no stdout`);let s=[];r.stderr&&r.stderr.on(`data`,e=>{s.push(e)});let c=new Promise(e=>{r.once(`exit`,(t,n)=>{e({code:t,signal:n})})}),l=o.createInterface({input:r.stdout,crlfDelay:1/0});try{for await(let e of l)yield e;if(i)throw i;let{code:e,signal:t}=await c;if(e!==0||t){let n=Buffer.concat(s),r=t?`signal ${t}`:`code ${e??1}`;throw Error(`Codex Exec exited with ${r}: ${n.toString(`utf8`)}`)}}finally{l.close(),r.removeAllListeners();try{r.killed||r.kill()}catch{}}}};function _(e){let t=[];return v(e,``,t),t}function v(e,t,n){if(!S(e))if(t){n.push(`${t}=${y(e,t)}`);return}else throw Error(`Codex config overrides must be a plain object`);let r=Object.entries(e);if(!(!t&&r.length===0)){if(t&&r.length===0){n.push(`${t}={}`);return}for(let[e,i]of r){if(!e)throw Error(`Codex config override keys must be non-empty strings`);if(i===void 0)continue;let r=t?`${t}.${e}`:e;S(i)?v(i,r,n):n.push(`${r}=${y(i,r)}`)}}}function y(e,t){if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`Codex config override at ${t} must be a finite number`);return`${e}`}else if(typeof e==`boolean`)return e?`true`:`false`;else if(Array.isArray(e))return`[${e.map((e,n)=>y(e,`${t}[${n}]`)).join(`, `)}]`;else if(S(e)){let n=[];for(let[r,i]of Object.entries(e)){if(!r)throw Error(`Codex config override keys must be non-empty strings`);i!==void 0&&n.push(`${x(r)} = ${y(i,`${t}.${r}`)}`)}return`{${n.join(`, `)}}`}else if(e===null)throw Error(`Codex config override at ${t} cannot be null`);else{let n=typeof e;throw Error(`Unsupported Codex config override value at ${t}: ${n}`)}}var b=/^[A-Za-z0-9_-]+$/;function x(e){return b.test(e)?e:JSON.stringify(e)}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C(){let{platform:e,arch:t}=process,n=null;switch(e){case`linux`:case`android`:switch(t){case`x64`:n=`x86_64-unknown-linux-musl`;break;case`arm64`:n=`aarch64-unknown-linux-musl`;break;default:break}break;case`darwin`:switch(t){case`x64`:n=`x86_64-apple-darwin`;break;case`arm64`:n=`aarch64-apple-darwin`;break;default:break}break;case`win32`:switch(t){case`x64`:n=`x86_64-pc-windows-msvc`;break;case`arm64`:n=`aarch64-pc-windows-msvc`;break;default:break}break;default:break}if(!n)throw Error(`Unsupported platform: ${e} (${t})`);let a=m[n];if(!a)throw Error(`Unsupported target triple: ${n}`);let o;try{let e=i(h.resolve(`${p}/package.json`)).resolve(`${a}/package.json`);o=r.join(r.dirname(e),`vendor`)}catch{throw Error(`Unable to locate Codex CLI binaries. Ensure ${p} is installed with optional dependencies.`)}let s=process.platform===`win32`?`codex.exe`:`codex`,c=w(o,n,s);if(!c)throw Error(`Unable to locate Codex CLI binaries for ${n}. Ensure ${p} is installed with optional dependencies.`);return c}function w(e,t,n){let i=r.join(e,t),a=r.join(i,`bin`,n);if(O(a)&&O(r.join(i,`codex-package.json`)))return{executablePath:a,pathDirs:T(r.join(i,`codex-path`))};let o=r.join(i,`codex`,n);return O(o)?{executablePath:o,pathDirs:T(r.join(i,`path`))}:null}function T(...e){return e.filter(k)}function E(e,t,n=process.platform){let i=D(e,n);if(n===`win32`)for(let t of Object.keys(e))t.toLowerCase()===`path`&&t!==i&&delete e[t];let a=(e[i]??``).split(r.delimiter).filter(e=>e.length>0&&!t.includes(e));e[i]=[...t,...a].join(r.delimiter)}function D(e,t){if(t!==`win32`)return`PATH`;let n=Object.keys(e).filter(e=>e.toLowerCase()===`path`);return n.includes(`Path`)?`Path`:n.at(-1)??`PATH`}function O(e){try{return t(e).isFile()}catch{return!1}}function k(e){try{return t(e).isDirectory()}catch{return!1}}var A=class{exec;options;constructor(e={}){let{codexPathOverride:t,env:n,config:r}=e;this.exec=new g(t,n,r),this.options=e}startThread(e={}){return new l(this.exec,this.options,e)}resumeThread(e,t={}){return new l(this.exec,this.options,t,e)}};export{A as Codex};
4
+ `),images:n}}var d=`CODEX_INTERNAL_ORIGINATOR_OVERRIDE`,f=`codex_sdk_ts`,p=`@openai/codex`,m={"x86_64-unknown-linux-musl":`@openai/codex-linux-x64`,"aarch64-unknown-linux-musl":`@openai/codex-linux-arm64`,"x86_64-apple-darwin":`@openai/codex-darwin-x64`,"aarch64-apple-darwin":`@openai/codex-darwin-arm64`,"x86_64-pc-windows-msvc":`@openai/codex-win32-x64`,"aarch64-pc-windows-msvc":`@openai/codex-win32-arm64`},h=r(import.meta.url),g=class{executablePath;pathDirs;envOverride;configOverrides;constructor(e=null,t,n){if(e)this.executablePath=e,this.pathDirs=[];else{let e=C();this.executablePath=e.executablePath,this.pathDirs=e.pathDirs}this.envOverride=t,this.configOverrides=n}async*run(e){let t=[`exec`,`--experimental-json`];if(this.configOverrides)for(let e of _(this.configOverrides))t.push(`--config`,e);if(e.baseUrl&&t.push(`--config`,`openai_base_url=${y(e.baseUrl,`openai_base_url`)}`),e.model&&t.push(`--model`,e.model),e.sandboxMode&&t.push(`--sandbox`,e.sandboxMode),e.workingDirectory&&t.push(`--cd`,e.workingDirectory),e.additionalDirectories?.length)for(let n of e.additionalDirectories)t.push(`--add-dir`,n);if(e.skipGitRepoCheck&&t.push(`--skip-git-repo-check`),e.outputSchemaFile&&t.push(`--output-schema`,e.outputSchemaFile),e.modelReasoningEffort&&t.push(`--config`,`model_reasoning_effort="${e.modelReasoningEffort}"`),e.networkAccessEnabled!==void 0&&t.push(`--config`,`sandbox_workspace_write.network_access=${e.networkAccessEnabled}`),e.webSearchMode?t.push(`--config`,`web_search="${e.webSearchMode}"`):e.webSearchEnabled===!0?t.push(`--config`,`web_search="live"`):e.webSearchEnabled===!1&&t.push(`--config`,`web_search="disabled"`),e.approvalPolicy&&t.push(`--config`,`approval_policy="${e.approvalPolicy}"`),e.threadId&&t.push(`resume`,e.threadId),e.images?.length)for(let n of e.images)t.push(`--image`,n);let n={};if(this.envOverride)Object.assign(n,this.envOverride);else for(let[e,t]of Object.entries(process.env))t!==void 0&&(n[e]=t);n[d]||(n[d]=f),e.apiKey&&(n.CODEX_API_KEY=e.apiKey),this.pathDirs.length>0&&E(n,this.pathDirs);let r=a(this.executablePath,t,{env:n,signal:e.signal}),i=null;if(r.once(`error`,e=>i=e),!r.stdin)throw r.kill(),Error(`Child process has no stdin`);if(r.stdin.write(e.input),r.stdin.end(),!r.stdout)throw r.kill(),Error(`Child process has no stdout`);let s=[];r.stderr&&r.stderr.on(`data`,e=>{s.push(e)});let c=new Promise(e=>{r.once(`exit`,(t,n)=>{e({code:t,signal:n})})}),l=o.createInterface({input:r.stdout,crlfDelay:1/0});try{for await(let e of l)yield e;if(i)throw i;let{code:e,signal:t}=await c;if(e!==0||t){let n=Buffer.concat(s),r=t?`signal ${t}`:`code ${e??1}`;throw Error(`Codex Exec exited with ${r}: ${n.toString(`utf8`)}`)}}finally{l.close(),r.removeAllListeners();try{r.killed||r.kill()}catch{}}}};function _(e){let t=[];return v(e,``,t),t}function v(e,t,n){if(!S(e))if(t){n.push(`${t}=${y(e,t)}`);return}else throw Error(`Codex config overrides must be a plain object`);let r=Object.entries(e);if(!(!t&&r.length===0)){if(t&&r.length===0){n.push(`${t}={}`);return}for(let[e,i]of r){if(!e)throw Error(`Codex config override keys must be non-empty strings`);if(i===void 0)continue;let r=t?`${t}.${e}`:e;S(i)?v(i,r,n):n.push(`${r}=${y(i,r)}`)}}}function y(e,t){if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`Codex config override at ${t} must be a finite number`);return`${e}`}else if(typeof e==`boolean`)return e?`true`:`false`;else if(Array.isArray(e))return`[${e.map((e,n)=>y(e,`${t}[${n}]`)).join(`, `)}]`;else if(S(e)){let n=[];for(let[r,i]of Object.entries(e)){if(!r)throw Error(`Codex config override keys must be non-empty strings`);i!==void 0&&n.push(`${x(r)} = ${y(i,`${t}.${r}`)}`)}return`{${n.join(`, `)}}`}else if(e===null)throw Error(`Codex config override at ${t} cannot be null`);else{let n=typeof e;throw Error(`Unsupported Codex config override value at ${t}: ${n}`)}}var b=/^[A-Za-z0-9_-]+$/;function x(e){return b.test(e)?e:JSON.stringify(e)}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C(){let{platform:e,arch:t}=process,i=null;switch(e){case`linux`:case`android`:switch(t){case`x64`:i=`x86_64-unknown-linux-musl`;break;case`arm64`:i=`aarch64-unknown-linux-musl`;break;default:break}break;case`darwin`:switch(t){case`x64`:i=`x86_64-apple-darwin`;break;case`arm64`:i=`aarch64-apple-darwin`;break;default:break}break;case`win32`:switch(t){case`x64`:i=`x86_64-pc-windows-msvc`;break;case`arm64`:i=`aarch64-pc-windows-msvc`;break;default:break}break;default:break}if(!i)throw Error(`Unsupported platform: ${e} (${t})`);let a=m[i];if(!a)throw Error(`Unsupported target triple: ${i}`);let o;try{let e=r(h.resolve(`${p}/package.json`)).resolve(`${a}/package.json`);o=n.join(n.dirname(e),`vendor`)}catch{throw Error(`Unable to locate Codex CLI binaries. Ensure ${p} is installed with optional dependencies.`)}let s=process.platform===`win32`?`codex.exe`:`codex`,c=w(o,i,s);if(!c)throw Error(`Unable to locate Codex CLI binaries for ${i}. Ensure ${p} is installed with optional dependencies.`);return c}function w(e,t,r){let i=n.join(e,t),a=n.join(i,`bin`,r);if(O(a)&&O(n.join(i,`codex-package.json`)))return{executablePath:a,pathDirs:T(n.join(i,`codex-path`))};let o=n.join(i,`codex`,r);return O(o)?{executablePath:o,pathDirs:T(n.join(i,`path`))}:null}function T(...e){return e.filter(k)}function E(e,t,r=process.platform){let i=D(e,r);if(r===`win32`)for(let t of Object.keys(e))t.toLowerCase()===`path`&&t!==i&&delete e[t];let a=(e[i]??``).split(n.delimiter).filter(e=>e.length>0&&!t.includes(e));e[i]=[...t,...a].join(n.delimiter)}function D(e,t){if(t!==`win32`)return`PATH`;let n=Object.keys(e).filter(e=>e.toLowerCase()===`path`);return n.includes(`Path`)?`Path`:n.at(-1)??`PATH`}function O(e){try{return t(e).isFile()}catch{return!1}}function k(e){try{return t(e).isDirectory()}catch{return!1}}var A=class{exec;options;constructor(e={}){let{codexPathOverride:t,env:n,config:r}=e;this.exec=new g(t,n,r),this.options=e}startThread(e={}){return new l(this.exec,this.options,e)}resumeThread(e,t={}){return new l(this.exec,this.options,t,e)}};export{A as Codex};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- function e(e){if(!(e instanceof Error))return{message:c(e),messageCarriesBody:!1};let r=e,i=t(r),a=n(r),o=a===void 0||e.message.includes(a);return{status:i,body:a,message:e.message,messageCarriesBody:o}}function t(e){if(typeof e.statusCode==`number`)return e.statusCode;if(typeof e.status==`number`)return e.status;if(typeof e.$metadata?.httpStatusCode==`number`)return e.$metadata.httpStatusCode;if(typeof e.$response?.statusCode==`number`)return e.$response.statusCode}function n(e){let t=r(e);if(t===void 0)return;let n=t.trim();if(n.length!==0)return s(n,4e3)}function r(e){if(typeof e.body==`string`)return e.body;if(a(e.error))return c(e.error);let t=e.$response?.body;if(typeof t==`string`)return t;if(!i(t)&&a(t))return c(t)}function i(e){return typeof e==`object`&&!!e&&`pipe`in e&&typeof e.pipe==`function`}function a(e){return typeof e==`object`&&!!e&&Object.keys(e).length>0}function o(e,t){return e.messageCarriesBody||e.status===void 0||e.body===void 0?t!==void 0&&e.status!==void 0?`${t} (${e.status}): ${e.message}`:e.message:t===void 0?`${e.status}: ${e.body}`:`${t} (${e.status}): ${e.body}`}function s(e,t){return e.length<=t?e:`${e.slice(0,t)}... [truncated ${e.length-t} chars]`}function c(e){try{let t=JSON.stringify(e);return t===void 0?String(e):t}catch{return String(e)}}export{e as n,o as t};
2
+ function e(e){if(!(e instanceof Error))return{message:c(e),messageCarriesBody:!1};let r=e,i=t(r),a=n(r),o=a===void 0||e.message.includes(a);return{status:i,body:a,message:e.message,messageCarriesBody:o}}function t(e){if(typeof e.statusCode==`number`)return e.statusCode;if(typeof e.status==`number`)return e.status;if(typeof e.$metadata?.httpStatusCode==`number`)return e.$metadata.httpStatusCode;if(typeof e.$response?.statusCode==`number`)return e.$response.statusCode}function n(e){let t=r(e);if(t===void 0)return;let n=t.trim();if(n.length!==0)return s(n,4e3)}function r(e){if(typeof e.body==`string`)return e.body;if(a(e.error))return c(e.error);let t=e.$response?.body;if(typeof t==`string`)return t;if(!i(t)&&a(t))return c(t)}function i(e){return typeof e==`object`&&!!e&&`pipe`in e&&typeof e.pipe==`function`}function a(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==Object.prototype&&t!==null?!1:Object.keys(e).length>0}function o(e,t){return e.messageCarriesBody||e.status===void 0||e.body===void 0?t!==void 0&&e.status!==void 0?`${t} (${e.status}): ${e.message}`:e.message:t===void 0?`${e.status}: ${e.body}`:`${t} (${e.status}): ${e.body}`}function s(e,t){return e.length<=t?e:`${e.slice(0,t)}... [truncated ${e.length-t} chars]`}function c(e){try{let t=JSON.stringify(e);return t===void 0?String(e):t}catch{return String(e)}}export{e as n,o as t};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{a as e}from"./diagnostics-B0j2bfEp.mjs";import{n as t,t as n}from"./models-BBd5zwn6.mjs";import{n as r}from"./headers-DlpC0ues.mjs";import{p as i,r as a}from"./transform-messages-1ulTEFY1.mjs";import{t as o}from"./sanitize-unicode-D-15laVS.mjs";import{n as s,t as c}from"./error-body-BBlqjbe7.mjs";import{a as l,c as u,i as d,l as f,n as p,o as m,r as h,s as g,t as _,u as v}from"./google-shared-DolBdAGX.mjs";let y=0;const b=(t,r,i)=>{let a=new e;return(async()=>{let e={role:`assistant`,content:[],api:`google-generative-ai`,provider:t.provider,model:t.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`pending`,timestamp:Date.now()};try{if(i?.fetch&&i.fetch!==globalThis.fetch)throw Error(`Custom fetch is not supported by the Google Generative AI adapter`);let o=i?.apiKey;if(!o)throw Error(`No API key for provider: ${t.provider}`);let s=S(t,o,i?.headers),c=C(t,r,i),l=await i?.onPayload?.(c,t);l!==void 0&&(c=l);let f=await u(()=>s.models.generateContentStream(c),i);a.push({type:`start`,partial:e});let p=null,m=e.content,_=()=>m.length-1;for await(let r of f){e.responseId||=r.responseId;let i=r.candidates?.[0];if(i?.content?.parts)for(let t of i.content.parts){if(t.text!==void 0){let n=h(t);(!p||n&&p.type!==`thinking`||!n&&p.type!==`text`)&&(p&&(p.type===`text`?a.push({type:`text_end`,contentIndex:m.length-1,content:p.text,partial:e}):a.push({type:`thinking_end`,contentIndex:_(),content:p.thinking,partial:e})),n?(p={type:`thinking`,thinking:``,thinkingSignature:void 0},e.content.push(p),a.push({type:`thinking_start`,contentIndex:_(),partial:e})):(p={type:`text`,text:``},e.content.push(p),a.push({type:`text_start`,contentIndex:_(),partial:e}))),p.type===`thinking`?(p.thinking+=t.text,p.thinkingSignature=g(p.thinkingSignature,t.thoughtSignature),a.push({type:`thinking_delta`,contentIndex:_(),delta:t.text,partial:e})):(p.text+=t.text,p.textSignature=g(p.textSignature,t.thoughtSignature),a.push({type:`text_delta`,contentIndex:_(),delta:t.text,partial:e}))}if(t.functionCall){p&&=(p.type===`text`?a.push({type:`text_end`,contentIndex:_(),content:p.text,partial:e}):a.push({type:`thinking_end`,contentIndex:_(),content:p.thinking,partial:e}),null);let n=t.functionCall.id,r={type:`toolCall`,id:!n||e.content.some(e=>e.type===`toolCall`&&e.id===n)?`${t.functionCall.name}_${Date.now()}_${++y}`:n,name:t.functionCall.name||``,arguments:t.functionCall.args??{},...t.thoughtSignature&&{thoughtSignature:t.thoughtSignature}};e.content.push(r),a.push({type:`toolcall_start`,contentIndex:_(),partial:e}),a.push({type:`toolcall_delta`,contentIndex:_(),delta:JSON.stringify(r.arguments),partial:e}),a.push({type:`toolcall_end`,contentIndex:_(),toolCall:r,partial:e})}}i?.finishReason&&(e.rawStopReason=i.finishReason,e.stopReason=d(i.finishReason),e.content.some(e=>e.type===`toolCall`)&&e.stopReason===`stop`&&(e.stopReason=`toolUse`)),r.usageMetadata&&(e.usage={input:(r.usageMetadata.promptTokenCount||0)-(r.usageMetadata.cachedContentTokenCount||0),output:(r.usageMetadata.candidatesTokenCount||0)+(r.usageMetadata.thoughtsTokenCount||0),cacheRead:r.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:r.usageMetadata.thoughtsTokenCount||0,totalTokens:r.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},n(t,e.usage))}if(p&&(p.type===`text`?a.push({type:`text_end`,contentIndex:_(),content:p.text,partial:e}):a.push({type:`thinking_end`,contentIndex:_(),content:p.thinking,partial:e})),i?.signal?.aborted)throw Error(`Request was aborted`);if(e.stopReason===`pending`)throw Error(`Google stream ended without a finish reason`);if(e.stopReason===`aborted`||e.stopReason===`error`){let t=e.rawStopReason?`Provider stopped with: ${e.rawStopReason}`:`An unknown error occurred`;throw Error(t)}a.push({type:`done`,reason:e.stopReason,message:e}),a.end()}catch(t){for(let t of e.content)`index`in t&&delete t.index;e.stopReason=i?.signal?.aborted?`aborted`:`error`,e.errorMessage=c(s(t)),a.push({type:`error`,reason:e.stopReason,error:e}),a.end()}})(),a},x=(e,n,r)=>{let i=r?.apiKey;if(!i)throw Error(`No API key for provider: ${e.provider}`);let o={...a(e,n,r,i),toolChoice:r?.toolChoice};if(!r?.reasoning)return b(e,n,{...o,thinking:{enabled:!1}});let s=m(e,t(e,r.reasoning)),c=e;return T(c)||E(c)||w(c)?b(e,n,{...o,thinking:{enabled:!0,level:O(s,c)}}):b(e,n,{...o,thinking:{enabled:!0,budgetTokens:k(c,s,r.thinkingBudgets)}})};function S(e,t,n){let a={};e.baseUrl&&(a.baseUrl=e.baseUrl,a.apiVersion=``);let o=r({"User-Agent":i(),...e.headers,...n});return o&&(a.headers=o),new v({apiKey:t,httpOptions:Object.keys(a).length>0?a:void 0})}function C(e,t,n={}){let r=_(e,t),i={};n.temperature!==void 0&&(i.temperature=n.temperature),n.maxTokens!==void 0&&(i.maxOutputTokens=n.maxTokens);let a=f(e.id),s=t.tools?.length?l(t.tools,n.toolChoice,a):void 0,c={...Object.keys(i).length>0&&i,...t.systemPrompt&&{systemInstruction:o(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:p(t.tools,!1,a)},...s!==void 0&&{toolConfig:{functionCallingConfig:{mode:s}}}};if(n.thinking?.enabled&&e.reasoning){let e={includeThoughts:!0};n.thinking.level===void 0?n.thinking.budgetTokens!==void 0&&(e.thinkingBudget=n.thinking.budgetTokens):e.thinkingLevel=n.thinking.level,c.thinkingConfig=e}else e.reasoning&&n.thinking&&!n.thinking.enabled&&(c.thinkingConfig=D(e));if(n.signal){if(n.signal.aborted)throw Error(`Request aborted`);c.abortSignal=n.signal}return{model:e.id,contents:r,config:c}}function w(e){return/gemma-?4/.test(e.id.toLowerCase())}function T(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function E(e){let t=e.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(t)||t===`gemini-flash-latest`||t===`gemini-flash-lite-latest`}function D(e){return T(e)?{thinkingLevel:`LOW`}:E(e)||w(e)?{thinkingLevel:`MINIMAL`}:{thinkingBudget:0}}function O(e,t){if(T(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}if(w(t))switch(e){case`minimal`:case`low`:return`MINIMAL`;case`medium`:case`high`:return`HIGH`}switch(e){case`minimal`:return`MINIMAL`;case`low`:return`LOW`;case`medium`:return`MEDIUM`;case`high`:return`HIGH`}}function k(e,t,n){return n?.[t]===void 0?e.id.includes(`2.5-pro`)?{minimal:128,low:2048,medium:8192,high:32768}[t]:e.id.includes(`2.5-flash-lite`)?{minimal:512,low:2048,medium:8192,high:24576}[t]:e.id.includes(`2.5-flash`)?{minimal:128,low:2048,medium:8192,high:24576}[t]:-1:n[t]}export{b as stream,x as streamSimple};