Lines 1-21javascript
2import{spawn as _s}from"node:child_process";import{closeSync as ys,existsSync as tn,mkdirSync as Ss,openSync as ws,readFileSync as Gt,rmSync as Rs,statSync as We,writeFileSync as en}from"node:fs";import{dirname as Es,resolve as jt}from"node:path";import{fileURLToPath as xs}from"node:url";import{randomUUID as dt}from"node:crypto";var B="0.1.22";function j(){return new Date().toISOString()}function R(e,t=2){return String(e).padStart(t,"0")}function ee(e){let t=e>=0?"+":"-",n=Math.abs(e);return`${t}${R(Math.floor(n/60))}:${R(n%60)}`}function un(e){let t=-e.getTimezoneOffset();return[`${e.getFullY ...
3`):""}var tt=class{constructor(t){this.agent=t,this.sessionCounter=0}async sessionNew(){return this.sessionCounter+=1,{sessionId:`echo-${this.agent.agentId}-${this.sessionCounter}`}}async sessionPrompt(t,n){let r=Q(t.prompt);return n({sessionId:t.sessionId,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:r?`Echo runtime received: ${r}`:"Echo runtime received an empty prompt."}}}),{stopReason:"end_turn"}}async sessionCancel(){return{ok:!0}}};import{spawn as hn}from"node:child_process";var W="2.0",mn=3e4;function gn(e){return{code:Number.isInteger(e?.code)?e.code:-32e3,messa ...
5`);if(n<0)return;let s=this.headerBuffer.subarray(0,n).toString("utf8").match(/content-length:\s*(\d+)/i);
8`;this.child.stdin.write(s,n)}onNotification(t,n){let r=this.notificationHandlers.get(t)||new Set;return r.add(n),this.notificationHandlers.set(t,r),()=>{r.delete(n),r.size===0&&this.notificationHandlers.delete(t)}}onRequest(t,n){return this.requestHandlers.set(t,n),()=>this.requestHandlers.delete(t)}onExit(t){return this.exitHandlers.add(t),()=>this.exitHandlers.delete(t)}rejectAll(t){for
10${s}`:s;Ce(t,n,r,d,s)&&(o=1,u=1)}return s&&i&&(t.
11`,yt,b,i,n);let k=await Ir(b,St,i,n,x,this.target);(k.artifactCount>0||k.textCount>0||k.thoughtCount>0)&&p("info","runtime.cli","codex transcript updates collected",{target:this.agent.targetCode,sessionId:i,artifactCount:k.artifactCount,textCount:k.textCount,finalTextCount:k.finalTextCount,thoughtCount:k.thoughtCount,transcriptCount:k.transcriptCount});let Z=Xt.trim();Z&&p("debug","runtime.cli","runtime stderr",{target:this.agent.targetCode,sessionId:i,stderr:Z}),p("info","runtime.cli","runtime prompt finished",{target:this.agent.targetCode,sessionId:i,pid:g.pid,exitCode:w,signal:Qt,artifactCo ...
12`}}})}}}async sessionCancel(t){let n=a(t.sessionId),r=this.active.get(n);return r?(p("info","runtime.cli","cancelling runtime child",{target:this.agent.targetCode,sessionId:n,pid:r.pid}),ot(r,"SIGTERM"),this.active.delete(n),{ok:!0,cancelled:
13... [truncated ${r} characters]`}function $e(e){if(!c(e))return"";let t=c(e.update)?e.update:e,r=(c(t.content)?t.content:{}).text??t.text;return r==null?"":String(r)}function Kr(e){if(!c(e))return"";let t=c(e.update)?e.update:e;return a(t.sessionUpdate)}function jr(e){if(!Array.isArray(e))return"";let t=!1,n=[],r=[],s=[],i=()=>{n.length>0&&(r.push(n),n=[])};for(let u of e){let l=Kr(u),d=$e(u);if(!l){d&&s.push(d);continue}if(t=!0,l==="agent_message_chunk"){d&&n.push(d);continue}(l==="agent_thought_chunk"||l==="user_message_chunk"||l==="tool_call"||l==="tool_call_update"||l==="plan")&&i()}if(i() ...
14`?1:0)).trim()}function pt(e){let t=String(e||"").trim();if(!t)return null;try{let n
15`)}];return this.prompt({...t,agentId:r,sessionId:o,prompt:h,metadata:Gr(t,f)},n)}async requestPermission({agent:t,runtimeSessionId:n,request:r,emitUpdate:s}){let i=dt(),u=this.runtimeSessionIndex.get(`${t.agentId}:${n}`)?.sessionId||n||dt
16`).replaceAll("\\r","\r").replaceAll("\\t"," ").replaceAll('\\"','"').replaceAll("\\\\","\\")}function gs(e){let t=!1,n=!1;for(let r=0;r<e.length;r+=1){let s=e[r],i=e[r-1];if(s==="'"&&!n)t=!t;else if(s==='"'&&!t&&i!=="\\")n=!n;else if(s==="#"&&!t&&!n&&/\s/.test(i||""))return e.slice(0,r)}return e}import{createServer as Ts}from"node:http";function _t(e,t,n){let r=JSON.stringify(n);e.writeHead(t,{"content-type":"application/json; charset=utf-8","content-length":Buffer.byteLength(r)}),e.end(r)}function H(e={}){return{ok:!0,...e}}function zt(e,t,n){return{ok:!1,error:{code:e,message:t,...n===void ...
HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
bin/orcha-runtime-bridge.jsView on unpkg · L1 HighCommand Output Exfiltration
Source combines command execution, command-output handling, and outbound requests; review data flow before blocking.
bin/orcha-runtime-bridge.jsView on unpkg · L1 17`),console.log(JSON.stringify({status:"started",pid:i.pid,pidFile:e,logFile:t}))}async function Ye({quiet:e=!1}={}){let t=Wt(),n=Jt(t);if(
19`:""),p("info","runtime-bridge","runtime log cleanup completed",{logFile:e,retentionDays:t,removed:u})}catch(d){p("warn","runtime-bridge","runtime log cleanup failed",{logFile:e,error:String(d)})}}function Ds(e,t){try{let n=JSON.parse(e);if(!n||typeof n!="object")return!0;let r=typeof n.ts=="string"?Date.parse(n.ts):Number.NaN;return!Number.isFinite(r)||r>=t}catch{return!0}}function sn(){return on(process.env.ORCHA_RUNTIME_LOG_RETENTION_DAYS,As)}function $s(){return on(process.env.ORCHA_RUNTIME_LOG_CLEANUP_INTERVAL_MS,Ms)}function on(e,t){let n=Number.parseInt(String(e??""),10);return Number.i ...
Long lines were clipped for display.