@sleep2agi/agent-network 2.3.0-preview.102 → 2.3.0-preview.104

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.
@@ -1 +1 @@
1
- const a0_0x3caadc=a0_0x279f;(function(_0x43e06a,_0x481827){const _0x2afafc=a0_0x279f,_0x5ce236=_0x43e06a();while(!![]){try{const _0x49e292=parseInt(_0x2afafc(0x150))/0x1+parseInt(_0x2afafc(0x16b))/0x2*(parseInt(_0x2afafc(0x17a))/0x3)+-parseInt(_0x2afafc(0x1a2))/0x4+-parseInt(_0x2afafc(0x16d))/0x5*(-parseInt(_0x2afafc(0x1a9))/0x6)+parseInt(_0x2afafc(0x151))/0x7+-parseInt(_0x2afafc(0x18b))/0x8+-parseInt(_0x2afafc(0x1c9))/0x9*(parseInt(_0x2afafc(0x156))/0xa);if(_0x49e292===_0x481827)break;else _0x5ce236['push'](_0x5ce236['shift']());}catch(_0x3697dc){_0x5ce236['push'](_0x5ce236['shift']());}}}(a0_0x1e49,0x7feea));import{EventEmitter as a0_0x345dea}from'events';import{hostname as a0_0x1e075f}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x492509,_0x2e2466)=>(_0x492509??_0x2e2466)[a0_0x3caadc(0x1ae)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x3caadc(0x154)](0x0,0xf0);function N(_0x56b598){const _0x8cae11=a0_0x3caadc;return(_0x56b598 instanceof Error?_0x56b598[_0x8cae11(0x1ad)]:String(_0x56b598??_0x8cae11(0x187)))[_0x8cae11(0x1ae)](K,_0x8cae11(0x1ca))[_0x8cae11(0x1ae)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x8cae11(0x154)](0x0,0xf0);}function a0_0x279f(_0xf9f2e2,_0x41aa7d){_0xf9f2e2=_0xf9f2e2-0x14e;const _0x1e4984=a0_0x1e49();let _0x279fe7=_0x1e4984[_0xf9f2e2];return _0x279fe7;}function O(_0x4f6f1b,_0x365c7d=process.env.ANET_TASK_TRACE_FORMAT===a0_0x3caadc(0x180)){const _0x1784fd=a0_0x3caadc;if(_0x365c7d)return JSON[_0x1784fd(0x1c4)](_0x4f6f1b);let _0x31bbd8=L(_0x4f6f1b[_0x1784fd(0x164)],_0x1784fd(0x1a8)),_0xde3bed=L(_0x4f6f1b['task_id'],_0x1784fd(0x17b)),_0x43dcb5=_0x4f6f1b[_0x1784fd(0x194)]?'\x20error='+_0x4f6f1b[_0x1784fd(0x194)]+':'+(_0x4f6f1b[_0x1784fd(0x14e)]??''):'';return _0x1784fd(0x18e)+_0x4f6f1b['status']+_0x1784fd(0x189)+L(_0x4f6f1b[_0x1784fd(0x188)],_0x1784fd(0x183))+_0x1784fd(0x1a7)+L(_0x4f6f1b[_0x1784fd(0x1c7)],_0x1784fd(0x183))+'\x20task_id='+_0xde3bed+_0x1784fd(0x1b2)+_0x31bbd8+_0x1784fd(0x19a)+L(_0x4f6f1b[_0x1784fd(0x1b4)],_0x1784fd(0x183))+_0x1784fd(0x15b)+_0x4f6f1b['transport']+_0x1784fd(0x15a)+_0x4f6f1b[_0x1784fd(0x1b1)]+_0x1784fd(0x16f)+_0x4f6f1b[_0x1784fd(0x1a3)]+_0x43dcb5;}function U(_0x127d8d){const _0x1b3911=a0_0x3caadc;return{'event':{'sending':'task.send.start','delivered':'task.send.delivered','failed':_0x1b3911(0x1a6),'acked':_0x1b3911(0x1c8),'started':_0x1b3911(0x18c),'replied':_0x1b3911(0x191),'expired':_0x1b3911(0x1a0)}[_0x127d8d['status']],..._0x127d8d};}function j(_0x2f39d3){const _0x3b5989=a0_0x3caadc;let _0x2b6da1=_0x2f39d3?.[_0x3b5989(0x1cb)]||_0x2f39d3?.[_0x3b5989(0x15f)]||_0x2f39d3?.['id'];if(_0x2b6da1)return String(_0x2b6da1);let _0x202681=_0x2f39d3?.[_0x3b5989(0x177)]?.[0x0]?.[_0x3b5989(0x1c2)];if(typeof _0x202681!==_0x3b5989(0x155))return null;try{let _0x1ea2ee=JSON['parse'](_0x202681);return _0x1ea2ee?.[_0x3b5989(0x1cb)]||_0x1ea2ee?.[_0x3b5989(0x15f)]||_0x1ea2ee?.['id']||null;}catch{return null;}}async function X(_0x3804b6,_0x1c6f98){const _0x313b0b=a0_0x3caadc;let _0x3eb2f3=_0x1c6f98[_0x313b0b(0x17c)]??Date[_0x313b0b(0x17c)],_0x2c028f=_0x3eb2f3(),_0x5a42fb=(_0x1e33fc,_0xa96f0,_0x114f16,_0x544264)=>{const _0x3c449d=_0x313b0b;_0x1c6f98[_0x3c449d(0x198)](O(U({'from_alias':_0x3804b6[_0x3c449d(0x17e)],'to_alias':_0x3804b6['toAlias'],'task_id':_0xa96f0,'parent_task_id':_0x3804b6[_0x3c449d(0x1c6)],'network_id':_0x3804b6[_0x3c449d(0x18a)],'transport':_0x3804b6[_0x3c449d(0x15d)],'status':_0x1e33fc,'duration_ms':_0x3eb2f3()-_0x2c028f,'lifecycle_tracking':_0x3804b6[_0x3c449d(0x1b7)],..._0x114f16!==void 0x0?{'error_code':_0x544264||_0x3c449d(0x1ac),'error_message':N(_0x114f16)}:{}})));};_0x5a42fb(_0x313b0b(0x168),null);try{let _0x1e0a0b=await _0x1c6f98[_0x313b0b(0x169)](),_0x15d072=j(_0x1e0a0b);if(_0x15d072)_0x5a42fb(_0x313b0b(0x171),_0x15d072);else{if(_0x1e0a0b?.['ok']===!0x1||_0x1e0a0b?.[_0x313b0b(0x1c5)])_0x5a42fb(_0x313b0b(0x1aa),_0x15d072,_0x1e0a0b?.[_0x313b0b(0x1c5)]||_0x313b0b(0x1a5),_0x313b0b(0x175));else _0x5a42fb(_0x313b0b(0x1aa),null,_0x313b0b(0x1c3),_0x313b0b(0x160));}return _0x1e0a0b;}catch(_0x5c001d){throw _0x5a42fb(_0x313b0b(0x1aa),null,_0x5c001d,_0x313b0b(0x1ac)),_0x5c001d;}}async function Y(_0x1fdcd8,_0x2dcd9d){const _0x1d74a9=a0_0x3caadc;return X({'fromAlias':_0x1fdcd8[_0x1d74a9(0x17e)],'toAlias':_0x1fdcd8[_0x1d74a9(0x176)],'parentTaskId':_0x1fdcd8[_0x1d74a9(0x1c6)]||null,'networkId':_0x1fdcd8['networkId']||null,'transport':_0x1d74a9(0x1b5),'lifecycleTracking':'not_tracked'},_0x2dcd9d);}class $ extends a0_0x345dea{['url'];[a0_0x3caadc(0x176)];[a0_0x3caadc(0x1ba)];[a0_0x3caadc(0x166)];['resumeId'];[a0_0x3caadc(0x179)];['reconnectDelay'];[a0_0x3caadc(0x19d)];[a0_0x3caadc(0x163)];[a0_0x3caadc(0x15e)]=!0x1;constructor(_0xb18629){const _0x20c5ae=a0_0x3caadc;super();if(this[_0x20c5ae(0x14f)]=_0xb18629[_0x20c5ae(0x14f)][_0x20c5ae(0x1ae)](/\/$/,''),this[_0x20c5ae(0x176)]=_0xb18629[_0x20c5ae(0x176)],this[_0x20c5ae(0x1ba)]=_0xb18629['token'],this[_0x20c5ae(0x166)]=_0xb18629[_0x20c5ae(0x166)]||_0x20c5ae(0x153),this[_0x20c5ae(0x1a4)]=_0x20c5ae(0x1b3)+_0xb18629[_0x20c5ae(0x176)]+'-'+Date['now']()[_0x20c5ae(0x152)](0x24),this[_0x20c5ae(0x179)]=_0xb18629[_0x20c5ae(0x179)]??0x2bf20,this[_0x20c5ae(0x17d)]=_0xb18629[_0x20c5ae(0x17d)]??0xbb8,_0xb18629['autoConnect']!==!0x1)this[_0x20c5ae(0x178)]();}[a0_0x3caadc(0x198)](_0x320ff9){const _0x46b288=a0_0x3caadc;console[_0x46b288(0x198)]('['+new Date()['toTimeString']()[_0x46b288(0x154)](0x0,0x8)+_0x46b288(0x1b9)+this[_0x46b288(0x176)]+']\x20'+_0x320ff9);}async['call'](_0x3bc3a8,_0x470fb0){const _0x26593c=a0_0x3caadc;let _0x43c42a={'Content-Type':'application/json','Accept':_0x26593c(0x196)};if(this[_0x26593c(0x1ba)])_0x43c42a[_0x26593c(0x18d)]='Bearer\x20'+this[_0x26593c(0x1ba)];let _0x5f020c=await(await fetch(this['url']+'/mcp',{'method':'POST','headers':_0x43c42a,'body':JSON[_0x26593c(0x1c4)]({'jsonrpc':'2.0','id':Date['now'](),'method':'tools/call','params':{'name':_0x3bc3a8,'arguments':_0x470fb0}})}))['text'](),_0x2ac740=_0x5f020c['match'](/data: (.+)/),_0x5cb15b=_0x2ac740?JSON['parse'](_0x2ac740[0x1]):JSON[_0x26593c(0x19f)](_0x5f020c),_0x2cdc1d=_0x5cb15b?.['result']?.[_0x26593c(0x177)]?.[0x0]?.[_0x26593c(0x1c2)];return _0x2cdc1d?JSON[_0x26593c(0x19f)](_0x2cdc1d):_0x5cb15b;}async[a0_0x3caadc(0x178)](){const _0x189c6e=a0_0x3caadc;if(this[_0x189c6e(0x15e)])return;this['running']=!0x0,await this[_0x189c6e(0x195)](_0x189c6e(0x193)),this[_0x189c6e(0x198)](_0x189c6e(0x1bc)),this['heartbeatTimer']=setInterval(()=>{const _0xbcd4de=_0x189c6e;this[_0xbcd4de(0x195)](_0xbcd4de(0x193))[_0xbcd4de(0x186)](_0x1d6631=>this[_0xbcd4de(0x198)]('heartbeat\x20failed:\x20'+_0x1d6631['message']));},this[_0x189c6e(0x179)]),this[_0x189c6e(0x157)]();}async[a0_0x3caadc(0x1b8)](){const _0x217993=a0_0x3caadc;if(this[_0x217993(0x15e)]=!0x1,this[_0x217993(0x163)]?.[_0x217993(0x1cc)](),this[_0x217993(0x19d)])clearInterval(this[_0x217993(0x19d)]);await this['status'](_0x217993(0x199))['catch'](()=>{}),this[_0x217993(0x198)](_0x217993(0x1af));}async[a0_0x3caadc(0x169)](_0x4ef5b8,_0x856bc,_0x53ae19=a0_0x3caadc(0x19c)){const _0x3c97e2=a0_0x3caadc;return Y({'alias':_0x4ef5b8,'fromAlias':this[_0x3c97e2(0x176)]},{'log':_0x34f57b=>console[_0x3c97e2(0x198)](_0x34f57b),'send':()=>this[_0x3c97e2(0x184)]('send_task',{'alias':_0x4ef5b8,'task':_0x856bc,'priority':_0x53ae19,'from_session':this['alias']})});}async[a0_0x3caadc(0x1ad)](_0x5aea61,_0x2d40e0){const _0x3bde78=a0_0x3caadc;return this[_0x3bde78(0x184)]('send_message',{'alias':_0x5aea61,'message':_0x2d40e0,'from_session':this[_0x3bde78(0x176)]});}async[a0_0x3caadc(0x19e)](_0x164bbd,_0x16e1cc,_0x1bcd8d=a0_0x3caadc(0x170)){const _0x44600e=a0_0x3caadc;return this[_0x44600e(0x184)](_0x44600e(0x1c0),{'in_reply_to':_0x164bbd,'text':_0x16e1cc,'status':_0x1bcd8d});}async[a0_0x3caadc(0x195)](_0x19f80a,_0x26cd60){const _0xb5c040=a0_0x3caadc;return this[_0xb5c040(0x184)](_0xb5c040(0x182),{'resume_id':this[_0xb5c040(0x1a4)],'alias':this['alias'],'status':_0x19f80a,'server':a0_0x1e075f(),'hostname':a0_0x1e075f(),'agent':this[_0xb5c040(0x166)],'project_dir':process[_0xb5c040(0x1bd)](),..._0x26cd60});}async[a0_0x3caadc(0x159)](){const _0x221233=a0_0x3caadc;return this[_0x221233(0x184)](_0x221233(0x15c),{});}async[a0_0x3caadc(0x1bf)](_0x1fc507,_0x3ba774){const _0x2e6369=a0_0x3caadc;return this[_0x2e6369(0x184)](_0x2e6369(0x1bf),{'message':_0x1fc507,'filter_server':_0x3ba774?.[_0x2e6369(0x18f)],'filter_status':_0x3ba774?.[_0x2e6369(0x195)]});}async['connectSSE'](){const _0x3e4aeb=a0_0x3caadc;let _0x42b9b7=encodeURIComponent(this[_0x3e4aeb(0x176)]),_0x48b2cd=this['url']+_0x3e4aeb(0x1ab)+_0x42b9b7,_0x20e3da=this[_0x3e4aeb(0x17d)];while(this[_0x3e4aeb(0x15e)]){try{this[_0x3e4aeb(0x163)]=new AbortController();let _0x20207e={'Accept':_0x3e4aeb(0x17f)};if(this[_0x3e4aeb(0x1ba)])_0x20207e[_0x3e4aeb(0x18d)]=_0x3e4aeb(0x181)+this['token'];let _0x500167=await fetch(_0x48b2cd,{'headers':_0x20207e,'signal':this['sseAbort']['signal']});if(!_0x500167['ok']||!_0x500167[_0x3e4aeb(0x16a)]){this[_0x3e4aeb(0x198)](_0x3e4aeb(0x1c1)+_0x500167[_0x3e4aeb(0x195)]),await this[_0x3e4aeb(0x16c)](_0x20e3da),_0x20e3da=Math[_0x3e4aeb(0x173)](_0x20e3da*1.5,0xea60);continue;}_0x20e3da=this[_0x3e4aeb(0x17d)];let _0x226bc4=_0x500167[_0x3e4aeb(0x16a)][_0x3e4aeb(0x1a1)](),_0xf0b77a=new TextDecoder(),_0x3ec7fb='';while(this[_0x3e4aeb(0x15e)]){let {done:_0x45669c,value:_0x217644}=await _0x226bc4[_0x3e4aeb(0x172)]();if(_0x45669c)break;_0x3ec7fb+=_0xf0b77a['decode'](_0x217644,{'stream':!0x0});let _0x264810=_0x3ec7fb[_0x3e4aeb(0x161)]('\x0a');_0x3ec7fb=_0x264810[_0x3e4aeb(0x185)]()||'';for(let _0x94c486 of _0x264810){if(!_0x94c486[_0x3e4aeb(0x197)](_0x3e4aeb(0x190)))continue;try{let _0x322bde=JSON[_0x3e4aeb(0x19f)](_0x94c486['slice'](0x6));if(_0x322bde['type']==='connected'){this[_0x3e4aeb(0x198)](_0x3e4aeb(0x165)),this[_0x3e4aeb(0x167)]('connected');continue;}if(_0x322bde['type']===_0x3e4aeb(0x1be)||_0x322bde[_0x3e4aeb(0x1bb)]==='new_message'||_0x322bde[_0x3e4aeb(0x1bb)]===_0x3e4aeb(0x1bf))await this[_0x3e4aeb(0x1b6)]();}catch{}}}}catch(_0x36cddc){if(_0x36cddc[_0x3e4aeb(0x19b)]==='AbortError')break;this['emit'](_0x3e4aeb(0x1c5),_0x36cddc),this[_0x3e4aeb(0x198)](_0x3e4aeb(0x174)+_0x36cddc[_0x3e4aeb(0x1ad)]);}if(this['running'])this['emit'](_0x3e4aeb(0x1af)),this[_0x3e4aeb(0x198)](_0x3e4aeb(0x192)+_0x20e3da/0x3e8+_0x3e4aeb(0x1b0)),await this[_0x3e4aeb(0x16c)](_0x20e3da),_0x20e3da=Math[_0x3e4aeb(0x173)](_0x20e3da*1.5,0xea60);}}async['processInbox'](){const _0x34ab19=a0_0x3caadc;try{let _0x4e8f4f=(await this['call'](_0x34ab19(0x16e),{'alias':this[_0x34ab19(0x176)],'limit':0xa}))?.['messages']||[];for(let _0x2fbd27 of _0x4e8f4f)await this['call'](_0x34ab19(0x158),{'alias':this['alias'],'message_id':_0x2fbd27['id']}),this[_0x34ab19(0x198)]('←\x20'+_0x2fbd27['from_session']+':\x20'+_0x2fbd27['content']['slice'](0x0,0x3c)),this[_0x34ab19(0x167)](_0x34ab19(0x162),_0x2fbd27),this[_0x34ab19(0x167)](_0x34ab19(0x1ad),_0x2fbd27);}catch(_0x78a348){this[_0x34ab19(0x198)]('inbox\x20error:\x20'+_0x78a348[_0x34ab19(0x1ad)]);}}[a0_0x3caadc(0x16c)](_0x1094d5){return new Promise(_0x2982a6=>setTimeout(_0x2982a6,_0x1094d5));}}function a0_0x1e49(){const _0x5b459a=['167949WRDwPl','<pending>','now','reconnectDelay','fromAlias','text/event-stream','json','Bearer\x20','report_status','<unknown>','call','pop','catch','unknown\x20error','from_alias','\x20from=','networkId','4470776nsxWId','task.started','Authorization','[commhub:task]\x20','server','data:\x20','task.replied','SSE\x20reconnecting\x20in\x20','idle','error_code','status','application/json,\x20text/event-stream','startsWith','log','offline','\x20network_id=','name','normal','heartbeatTimer','reply','parse','task.expired','getReader','1597620QueZMA','lifecycle_tracking','resumeId','CommHub\x20rejected\x20task','task.send.failed','\x20to=','<missing>','6KkTlKK','failed','/events/','send_failed','message','replace','disconnected','s...','duration_ms','\x20parent_task_id=','sdk-','network_id','mcp_http','processInbox','lifecycleTracking','disconnect',']\x20[commhub:','token','type','registered','cwd','new_task','broadcast','send_reply','SSE\x20failed:\x20','text','CommHub\x20response\x20omitted\x20task_id','stringify','error','parentTaskId','to_alias','task.ack','206784wUuewm','[REDACTED]','task_id','abort','error_message','url','414651XonMgI','4510100RDmLvV','toString','sdk','slice','string','20oKEJdO','connectSSE','ack_inbox','getAllStatus','\x20duration_ms=','\x20transport=','get_all_status','transport','running','message_id','missing_task_id','split','task','sseAbort','parent_task_id','SSE\x20connected','agent','emit','sending','send','body','4NqDFeZ','sleep','1786485CYdZxD','get_inbox','\x20lifecycle=','completed','delivered','read','min','SSE\x20error:\x20','send_rejected','alias','content','connect','heartbeatInterval'];a0_0x1e49=function(){return _0x5b459a;};return a0_0x1e49();}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x58f292=a0_0x2b50;(function(_0x11dfe7,_0x1c1686){const _0x293626=a0_0x2b50,_0x31aab2=_0x11dfe7();while(!![]){try{const _0x39247e=-parseInt(_0x293626(0x1ed))/0x1*(parseInt(_0x293626(0x1c9))/0x2)+-parseInt(_0x293626(0x1fb))/0x3+-parseInt(_0x293626(0x1ad))/0x4*(-parseInt(_0x293626(0x1d2))/0x5)+parseInt(_0x293626(0x1b6))/0x6*(-parseInt(_0x293626(0x221))/0x7)+-parseInt(_0x293626(0x216))/0x8+parseInt(_0x293626(0x201))/0x9*(-parseInt(_0x293626(0x1e3))/0xa)+-parseInt(_0x293626(0x1a9))/0xb*(-parseInt(_0x293626(0x1f6))/0xc);if(_0x39247e===_0x1c1686)break;else _0x31aab2['push'](_0x31aab2['shift']());}catch(_0x4af9d7){_0x31aab2['push'](_0x31aab2['shift']());}}}(a0_0x286d,0x1fd39));import{EventEmitter as a0_0xc65660}from'events';import{hostname as a0_0x3598c4}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2c114d,_0x8ab9bf)=>(_0x2c114d??_0x8ab9bf)[a0_0x58f292(0x1c2)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x58f292(0x1ce)](0x0,0xf0);function N(_0x13ffa7){const _0x46ea44=a0_0x58f292;return(_0x13ffa7 instanceof Error?_0x13ffa7['message']:String(_0x13ffa7??_0x46ea44(0x220)))[_0x46ea44(0x1c2)](K,'[REDACTED]')[_0x46ea44(0x1c2)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x46ea44(0x1ce)](0x0,0xf0);}function O(_0xf6f491,_0x86cfd1=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x102345=a0_0x58f292;if(_0x86cfd1)return JSON[_0x102345(0x1f8)](_0xf6f491);let _0x3521c9=L(_0xf6f491['parent_task_id'],_0x102345(0x1f1)),_0x16f967=L(_0xf6f491[_0x102345(0x1d3)],_0x102345(0x1d0)),_0x5d59e7=_0xf6f491[_0x102345(0x1e6)]?_0x102345(0x218)+_0xf6f491['error_code']+':'+(_0xf6f491['error_message']??''):'';return'[commhub:task]\x20'+_0xf6f491[_0x102345(0x204)]+_0x102345(0x1bf)+L(_0xf6f491['from_alias'],_0x102345(0x1e8))+_0x102345(0x1fd)+L(_0xf6f491[_0x102345(0x1c3)],'<unknown>')+'\x20task_id='+_0x16f967+_0x102345(0x1bc)+_0x3521c9+_0x102345(0x1bb)+L(_0xf6f491[_0x102345(0x1b7)],_0x102345(0x1e8))+_0x102345(0x217)+_0xf6f491[_0x102345(0x1fc)]+_0x102345(0x1e2)+_0xf6f491['duration_ms']+_0x102345(0x1a8)+_0xf6f491[_0x102345(0x1aa)]+_0x5d59e7;}function U(_0xf42f99){const _0x3c1d42=a0_0x58f292;return{'event':{'sending':_0x3c1d42(0x207),'delivered':_0x3c1d42(0x1af),'failed':_0x3c1d42(0x1a4),'acked':_0x3c1d42(0x1cd),'started':_0x3c1d42(0x1f4),'replied':_0x3c1d42(0x213),'expired':'task.expired'}[_0xf42f99[_0x3c1d42(0x204)]],..._0xf42f99};}function j(_0x545d2e){const _0x290269=a0_0x58f292;let _0x1c6158=_0x545d2e?.[_0x290269(0x1d3)]||_0x545d2e?.[_0x290269(0x1e4)]||_0x545d2e?.['id'];if(_0x1c6158)return String(_0x1c6158);let _0x103702=_0x545d2e?.[_0x290269(0x1d4)]?.[0x0]?.['text'];if(typeof _0x103702!==_0x290269(0x1ec))return null;try{let _0x84ed35=JSON[_0x290269(0x1ae)](_0x103702);return _0x84ed35?.[_0x290269(0x1d3)]||_0x84ed35?.[_0x290269(0x1e4)]||_0x84ed35?.['id']||null;}catch{return null;}}async function X(_0x7b0a8f,_0x277862){const _0x397ac8=a0_0x58f292;let _0x568d87=_0x277862[_0x397ac8(0x1d1)]??Date[_0x397ac8(0x1d1)],_0x5b71cf=_0x568d87(),_0x5bad4d=(_0xac9877,_0x2bd6f7,_0x55420e,_0x4d68ac)=>{const _0x56320e=_0x397ac8;_0x277862['log'](O(U({'from_alias':_0x7b0a8f[_0x56320e(0x202)],'to_alias':_0x7b0a8f[_0x56320e(0x1fe)],'task_id':_0x2bd6f7,'parent_task_id':_0x7b0a8f[_0x56320e(0x211)],'network_id':_0x7b0a8f[_0x56320e(0x1ab)],'transport':_0x7b0a8f[_0x56320e(0x1fc)],'status':_0xac9877,'duration_ms':_0x568d87()-_0x5b71cf,'lifecycle_tracking':_0x7b0a8f[_0x56320e(0x1a3)],..._0x55420e!==void 0x0?{'error_code':_0x4d68ac||_0x56320e(0x1d8),'error_message':N(_0x55420e)}:{}})));};_0x5bad4d(_0x397ac8(0x20f),null);try{let _0x1f2fd5=await _0x277862[_0x397ac8(0x219)](),_0x48ea86=j(_0x1f2fd5);if(_0x48ea86)_0x5bad4d(_0x397ac8(0x1ea),_0x48ea86);else{if(_0x1f2fd5?.['ok']===!0x1||_0x1f2fd5?.[_0x397ac8(0x1df)])_0x5bad4d(_0x397ac8(0x1e1),_0x48ea86,_0x1f2fd5?.[_0x397ac8(0x1df)]||_0x397ac8(0x205),_0x397ac8(0x1c7));else _0x5bad4d(_0x397ac8(0x1e1),null,_0x397ac8(0x1f3),_0x397ac8(0x223));}return _0x1f2fd5;}catch(_0x2c4fe3){throw _0x5bad4d(_0x397ac8(0x1e1),null,_0x2c4fe3,_0x397ac8(0x1d8)),_0x2c4fe3;}}function a0_0x2b50(_0x4fc2d9,_0x4ad351){_0x4fc2d9=_0x4fc2d9-0x1a3;const _0x286d6d=a0_0x286d();let _0x2b50ed=_0x286d6d[_0x4fc2d9];return _0x2b50ed;}function a0_0x286d(){const _0x5a25c7=['text/event-stream','heartbeatTimer','getAllStatus','Bearer\x20','normal','offline','task','sending','application/json','parentTaskId','AbortError','task.replied',']\x20[commhub:','body','384792FdhwGz','\x20transport=','\x20error=','send','text','SSE\x20reconnecting\x20in\x20','abort','resumeId','min','not_tracked','unknown\x20error','296149sjcOgs','url','missing_task_id','call','lifecycleTracking','task.send.failed','data:\x20','new_task','disconnected','\x20lifecycle=','3663YyqhKR','lifecycle_tracking','networkId','autoConnect','168yOVNhO','parse','task.send.delivered','pop','report_status','POST','toString','toTimeString','inbox\x20error:\x20','18atDJBk','network_id','catch','get_inbox','cwd','\x20network_id=','\x20parent_task_id=','name','send_reply','\x20from=','type','alias','replace','to_alias','get_all_status','tools/call','new_message','send_rejected','running','354qDFYZe','heartbeatInterval','server','reconnectDelay','task.ack','slice','connect','<pending>','now','26725YOfcIL','task_id','content','sseAbort','result','send_message','send_failed','sdk','read','SSE\x20connected','2.0','token','log','error','/mcp','failed','\x20duration_ms=','10flsUlo','message_id','agent','error_code','disconnect','<unknown>','broadcast','delivered','sleep','string','1041IGTDrS','SSE\x20failed:\x20','getReader','processInbox','<missing>','messages','CommHub\x20response\x20omitted\x20task_id','task.started','message','24612AIJPDK','connectSSE','stringify','ack_inbox','idle','736986gbJhHh','transport','\x20to=','toAlias','completed','connected','1549557Xmcoqe','fromAlias','emit','status','CommHub\x20rejected\x20task','signal','task.send.start'];a0_0x286d=function(){return _0x5a25c7;};return a0_0x286d();}async function Y(_0x4fd231,_0x2bd4d8){const _0x2877e0=a0_0x58f292;return X({'fromAlias':_0x4fd231[_0x2877e0(0x202)],'toAlias':_0x4fd231[_0x2877e0(0x1c1)],'parentTaskId':_0x4fd231['parentTaskId']||null,'networkId':_0x4fd231[_0x2877e0(0x1ab)]||null,'transport':'mcp_http','lifecycleTracking':_0x2877e0(0x21f)},_0x2bd4d8);}class $ extends a0_0xc65660{['url'];[a0_0x58f292(0x1c1)];[a0_0x58f292(0x1dd)];['agent'];[a0_0x58f292(0x21d)];[a0_0x58f292(0x1ca)];[a0_0x58f292(0x1cc)];[a0_0x58f292(0x209)];[a0_0x58f292(0x1d5)];[a0_0x58f292(0x1c8)]=!0x1;constructor(_0x690eec){const _0x50c1c6=a0_0x58f292;super();if(this[_0x50c1c6(0x222)]=_0x690eec[_0x50c1c6(0x222)]['replace'](/\/$/,''),this[_0x50c1c6(0x1c1)]=_0x690eec['alias'],this['token']=_0x690eec[_0x50c1c6(0x1dd)],this[_0x50c1c6(0x1e5)]=_0x690eec['agent']||_0x50c1c6(0x1d9),this[_0x50c1c6(0x21d)]='sdk-'+_0x690eec[_0x50c1c6(0x1c1)]+'-'+Date['now']()[_0x50c1c6(0x1b3)](0x24),this[_0x50c1c6(0x1ca)]=_0x690eec['heartbeatInterval']??0x2bf20,this[_0x50c1c6(0x1cc)]=_0x690eec[_0x50c1c6(0x1cc)]??0xbb8,_0x690eec[_0x50c1c6(0x1ac)]!==!0x1)this[_0x50c1c6(0x1cf)]();}[a0_0x58f292(0x1de)](_0x1842db){const _0x36faff=a0_0x58f292;console[_0x36faff(0x1de)]('['+new Date()[_0x36faff(0x1b4)]()[_0x36faff(0x1ce)](0x0,0x8)+_0x36faff(0x214)+this[_0x36faff(0x1c1)]+']\x20'+_0x1842db);}async[a0_0x58f292(0x224)](_0x182a33,_0x185a76){const _0x47d587=a0_0x58f292;let _0x26e0a3={'Content-Type':_0x47d587(0x210),'Accept':'application/json,\x20text/event-stream'};if(this[_0x47d587(0x1dd)])_0x26e0a3['Authorization']='Bearer\x20'+this[_0x47d587(0x1dd)];let _0x4d3a57=await(await fetch(this[_0x47d587(0x222)]+_0x47d587(0x1e0),{'method':_0x47d587(0x1b2),'headers':_0x26e0a3,'body':JSON[_0x47d587(0x1f8)]({'jsonrpc':_0x47d587(0x1dc),'id':Date['now'](),'method':_0x47d587(0x1c5),'params':{'name':_0x182a33,'arguments':_0x185a76}})}))[_0x47d587(0x21a)](),_0x40b178=_0x4d3a57['match'](/data: (.+)/),_0x2c3edc=_0x40b178?JSON[_0x47d587(0x1ae)](_0x40b178[0x1]):JSON[_0x47d587(0x1ae)](_0x4d3a57),_0x428075=_0x2c3edc?.[_0x47d587(0x1d6)]?.[_0x47d587(0x1d4)]?.[0x0]?.['text'];return _0x428075?JSON[_0x47d587(0x1ae)](_0x428075):_0x2c3edc;}async[a0_0x58f292(0x1cf)](){const _0x14b344=a0_0x58f292;if(this[_0x14b344(0x1c8)])return;this[_0x14b344(0x1c8)]=!0x0,await this[_0x14b344(0x204)](_0x14b344(0x1fa)),this[_0x14b344(0x1de)]('registered'),this[_0x14b344(0x209)]=setInterval(()=>{const _0x30540f=_0x14b344;this[_0x30540f(0x204)](_0x30540f(0x1fa))[_0x30540f(0x1b8)](_0x562526=>this[_0x30540f(0x1de)]('heartbeat\x20failed:\x20'+_0x562526['message']));},this['heartbeatInterval']),this['connectSSE']();}async[a0_0x58f292(0x1e7)](){const _0x5d7ba9=a0_0x58f292;if(this[_0x5d7ba9(0x1c8)]=!0x1,this['sseAbort']?.[_0x5d7ba9(0x21c)](),this['heartbeatTimer'])clearInterval(this[_0x5d7ba9(0x209)]);await this[_0x5d7ba9(0x204)](_0x5d7ba9(0x20d))[_0x5d7ba9(0x1b8)](()=>{}),this[_0x5d7ba9(0x1de)](_0x5d7ba9(0x1a7));}async[a0_0x58f292(0x219)](_0x4a640c,_0x47f41e,_0x59f86c=a0_0x58f292(0x20c)){const _0x493f0c=a0_0x58f292;return Y({'alias':_0x4a640c,'fromAlias':this[_0x493f0c(0x1c1)]},{'log':_0x984fae=>console[_0x493f0c(0x1de)](_0x984fae),'send':()=>this[_0x493f0c(0x224)]('send_task',{'alias':_0x4a640c,'task':_0x47f41e,'priority':_0x59f86c,'from_session':this['alias']})});}async[a0_0x58f292(0x1f5)](_0x21d455,_0x215afa){const _0x4b71d8=a0_0x58f292;return this[_0x4b71d8(0x224)](_0x4b71d8(0x1d7),{'alias':_0x21d455,'message':_0x215afa,'from_session':this['alias']});}async['reply'](_0x391735,_0x173dfd,_0x4d004e=a0_0x58f292(0x1ff)){const _0x48f132=a0_0x58f292;return this['call'](_0x48f132(0x1be),{'in_reply_to':_0x391735,'text':_0x173dfd,'status':_0x4d004e});}async[a0_0x58f292(0x204)](_0x357d8a,_0x53dfba){const _0x2ce065=a0_0x58f292;return this[_0x2ce065(0x224)](_0x2ce065(0x1b1),{'resume_id':this['resumeId'],'alias':this[_0x2ce065(0x1c1)],'status':_0x357d8a,'server':a0_0x3598c4(),'hostname':a0_0x3598c4(),'agent':this[_0x2ce065(0x1e5)],'project_dir':process[_0x2ce065(0x1ba)](),..._0x53dfba});}async[a0_0x58f292(0x20a)](){const _0x1c2b10=a0_0x58f292;return this[_0x1c2b10(0x224)](_0x1c2b10(0x1c4),{});}async[a0_0x58f292(0x1e9)](_0x1a4bf0,_0x1d8c47){const _0x5000b1=a0_0x58f292;return this['call']('broadcast',{'message':_0x1a4bf0,'filter_server':_0x1d8c47?.[_0x5000b1(0x1cb)],'filter_status':_0x1d8c47?.[_0x5000b1(0x204)]});}async[a0_0x58f292(0x1f7)](){const _0x4d83f5=a0_0x58f292;let _0x5bf203=encodeURIComponent(this[_0x4d83f5(0x1c1)]),_0x110425=this[_0x4d83f5(0x222)]+'/events/'+_0x5bf203,_0x141d14=this[_0x4d83f5(0x1cc)];while(this[_0x4d83f5(0x1c8)]){try{this[_0x4d83f5(0x1d5)]=new AbortController();let _0x480fb7={'Accept':_0x4d83f5(0x208)};if(this['token'])_0x480fb7['Authorization']=_0x4d83f5(0x20b)+this['token'];let _0x5acaad=await fetch(_0x110425,{'headers':_0x480fb7,'signal':this['sseAbort'][_0x4d83f5(0x206)]});if(!_0x5acaad['ok']||!_0x5acaad[_0x4d83f5(0x215)]){this['log'](_0x4d83f5(0x1ee)+_0x5acaad[_0x4d83f5(0x204)]),await this[_0x4d83f5(0x1eb)](_0x141d14),_0x141d14=Math[_0x4d83f5(0x21e)](_0x141d14*1.5,0xea60);continue;}_0x141d14=this['reconnectDelay'];let _0x35ca9a=_0x5acaad['body'][_0x4d83f5(0x1ef)](),_0x564c15=new TextDecoder(),_0x4f9d84='';while(this['running']){let {done:_0x47eb26,value:_0x260943}=await _0x35ca9a[_0x4d83f5(0x1da)]();if(_0x47eb26)break;_0x4f9d84+=_0x564c15['decode'](_0x260943,{'stream':!0x0});let _0x1438d9=_0x4f9d84['split']('\x0a');_0x4f9d84=_0x1438d9[_0x4d83f5(0x1b0)]()||'';for(let _0x6f0776 of _0x1438d9){if(!_0x6f0776['startsWith'](_0x4d83f5(0x1a5)))continue;try{let _0x59c97f=JSON[_0x4d83f5(0x1ae)](_0x6f0776[_0x4d83f5(0x1ce)](0x6));if(_0x59c97f[_0x4d83f5(0x1c0)]===_0x4d83f5(0x200)){this[_0x4d83f5(0x1de)](_0x4d83f5(0x1db)),this['emit'](_0x4d83f5(0x200));continue;}if(_0x59c97f['type']===_0x4d83f5(0x1a6)||_0x59c97f[_0x4d83f5(0x1c0)]===_0x4d83f5(0x1c6)||_0x59c97f['type']===_0x4d83f5(0x1e9))await this[_0x4d83f5(0x1f0)]();}catch{}}}}catch(_0x5c3327){if(_0x5c3327[_0x4d83f5(0x1bd)]===_0x4d83f5(0x212))break;this[_0x4d83f5(0x203)]('error',_0x5c3327),this[_0x4d83f5(0x1de)]('SSE\x20error:\x20'+_0x5c3327[_0x4d83f5(0x1f5)]);}if(this[_0x4d83f5(0x1c8)])this[_0x4d83f5(0x203)]('disconnected'),this['log'](_0x4d83f5(0x21b)+_0x141d14/0x3e8+'s...'),await this[_0x4d83f5(0x1eb)](_0x141d14),_0x141d14=Math['min'](_0x141d14*1.5,0xea60);}}async[a0_0x58f292(0x1f0)](){const _0x54a48e=a0_0x58f292;try{let _0x45e3a1=(await this['call'](_0x54a48e(0x1b9),{'alias':this[_0x54a48e(0x1c1)],'limit':0xa}))?.[_0x54a48e(0x1f2)]||[];for(let _0x2bb9ec of _0x45e3a1)await this['call'](_0x54a48e(0x1f9),{'alias':this[_0x54a48e(0x1c1)],'message_id':_0x2bb9ec['id']}),this[_0x54a48e(0x1de)]('←\x20'+_0x2bb9ec['from_session']+':\x20'+_0x2bb9ec['content'][_0x54a48e(0x1ce)](0x0,0x3c)),this[_0x54a48e(0x203)](_0x54a48e(0x20e),_0x2bb9ec),this[_0x54a48e(0x203)](_0x54a48e(0x1f5),_0x2bb9ec);}catch(_0x2e35cd){this['log'](_0x54a48e(0x1b5)+_0x2e35cd[_0x54a48e(0x1f5)]);}}[a0_0x58f292(0x1eb)](_0x51bcfc){return new Promise(_0x3962bc=>setTimeout(_0x3962bc,_0x51bcfc));}}var F=$;export{F as default,$ as CommHub};
@@ -51,3 +51,41 @@ export interface ForkSides {
51
51
  }
52
52
  /** fork_isolation:身份 / HOME / thread / rollout 文件 / tmux 名五处都不同,且 rollout 是等长复制、没带 token 文件。 */
53
53
  export declare function checkForkIsolation(s: ForkSides): ReceiptCheck;
54
+ /** gap 1 — `--workdir` used to have to pre-exist. Create it (recursively) when missing; still refuse a path that exists
55
+ * but is not a directory. Returns whether this call created it, so the receipt can say so. */
56
+ export declare function ensureForkWorkdir(path: string): {
57
+ created: boolean;
58
+ };
59
+ /**
60
+ * gap 2 — codex records trust per workspace as `[projects."<abs path>"]` tables in config.toml. A copied config still
61
+ * names the **source** workspace, so the target keeps trusting (and, in the TUI, offering) the wrong directory.
62
+ * Rewrite only the table headers whose quoted path equals `from`, to `to`; every other line is left byte-identical.
63
+ * If a `[projects."<to>"]` table already exists, the source table is dropped instead of duplicated (TOML forbids
64
+ * defining a table twice). Line-aware on purpose: no global substitution of the path string elsewhere in the file.
65
+ */
66
+ export declare function rewriteTrustedProjects(toml: string, from: string, to: string): {
67
+ text: string;
68
+ rewritten: number;
69
+ dropped: number;
70
+ };
71
+ /**
72
+ * gap 3 — the last `turn_context` in a rollout names the model (and provider) the source ran on; codex resumes with
73
+ * that unless the target config says otherwise. Read it from the tail of the file (rollouts reach hundreds of MB;
74
+ * never load the whole thing) so `fork --model` can warn when the override differs.
75
+ */
76
+ export declare function readLastTurnContextModel(rolloutPath: string, tailBytes?: number): {
77
+ model: string | null;
78
+ provider: string | null;
79
+ };
80
+ /** What the fork receipt records for the #1951 gaps, as one informational check (never blocks; `port` is the
81
+ * loopback port pre-assigned for the app-server, first start uses it as its preferred port and re-probes if taken). */
82
+ export interface ForkGapFacts {
83
+ readonly workdir_created: boolean;
84
+ readonly trusted_rewritten: number;
85
+ readonly trusted_dropped: number;
86
+ readonly model_override: string | null;
87
+ readonly source_last_model: string | null;
88
+ readonly port: number | null;
89
+ readonly agents_md_carried: boolean;
90
+ }
91
+ export declare function forkGapsCheck(f: ForkGapFacts): ReceiptCheck;