@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
3 lines (2 loc) • 2.35 kB
JavaScript
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } }
import{PRIVATE_FDS_FINAL_ENV,UNPARSEABLE_TABLE,takePrivateDescriptors}from"./chunk-GKBPYB3Q.js";function runtimeExecArgv(execArgv=process.execArgv,bun=process.versions.bun!==void 0){let args=[];for(let index=0;index<execArgv.length;index++){let arg=execArgv[index];if(bun){if(arg==="-e"||arg==="--eval"||arg==="-p"||arg==="--print"||arg==="-pe"){index++;continue}if(arg.startsWith("-e")||arg.startsWith("-p"))continue}if(arg==="-e"||arg==="--eval"||arg==="-pe"||arg==="--input-type"||arg==="--input_type"){index++;continue}if(arg==="-p"||arg==="--print"){execArgv[index+1]!==void 0&&!execArgv[index+1].startsWith("-")&&index++;continue}arg==="-i"||arg==="--interactive"||arg.startsWith("--interactive=")||arg.startsWith("--eval=")||arg.startsWith("--print=")||arg.startsWith("--input-type=")||arg.startsWith("--input_type=")||args.push(arg)}return args}import{closeSync}from"node:fs";var TABLE_ENV="SENPI_PRIVATE_FDS";function preparePrivateFdSpawn(options,hop={},forward=takePrivateDescriptors()){let env={...options.env??process.env};delete env[TABLE_ENV],delete env[PRIVATE_FDS_FINAL_ENV];let base=options.stdio??"pipe",stdio=typeof base=="string"?[base,base,base]:[...base],owned=[];if(forward.kind==="unparseable")env[TABLE_ENV]=UNPARSEABLE_TABLE;else if(forward.entries.size>0){let carries=!options.shell,table={};for(let[name,fd]of forward.entries){let descriptors=fd===null?[]:typeof fd=="number"?[fd]:fd;if(owned.push(...descriptors),fd!==null&&carries){for(let descriptor of descriptors){for(;stdio.length<=descriptor;)stdio.push("ignore");stdio[descriptor]=descriptor}table[name]=fd}else table[name]=null}env[TABLE_ENV]=JSON.stringify(table)}return env[TABLE_ENV]!==void 0&&hop.final&&(env[PRIVATE_FDS_FINAL_ENV]="1"),{options:{...options,env,stdio},close(){for(let fd of owned)closeSync(fd)}}}function spawnWithPrivateFds(spawn,command,args,options,hop={}){let transfer=preparePrivateFdSpawn(options,hop);try{return spawn(command,args,transfer.options)}finally{transfer.close()}}export{runtimeExecArgv,preparePrivateFdSpawn,spawnWithPrivateFds};