@sleep2agi/agent-network 2.3.0-preview.103 → 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.
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a0_0x78f856=a0_0x4c67;(function(_0x15b692,_0x3456c4){const _0x209c6b=a0_0x4c67,_0x3efb04=_0x15b692();while(!![]){try{const _0x8d47c2=-parseInt(_0x209c6b(0x260))/0x1*(-parseInt(_0x209c6b(0x253))/0x2)+-parseInt(_0x209c6b(0x267))/0x3+-parseInt(_0x209c6b(0x20f))/0x4*(parseInt(_0x209c6b(0x22d))/0x5)+-parseInt(_0x209c6b(0x224))/0x6*(parseInt(_0x209c6b(0x24a))/0x7)+-parseInt(_0x209c6b(0x20a))/0x8*(-parseInt(_0x209c6b(0x214))/0x9)+parseInt(_0x209c6b(0x23d))/0xa*(parseInt(_0x209c6b(0x24f))/0xb)+-parseInt(_0x209c6b(0x226))/0xc*(-parseInt(_0x209c6b(0x1f6))/0xd);if(_0x8d47c2===_0x3456c4)break;else _0x3efb04['push'](_0x3efb04['shift']());}catch(_0x54073c){_0x3efb04['push'](_0x3efb04['shift']());}}}(a0_0x5c99,0x420b8));import{EventEmitter as a0_0x33dc6a}from'events';function a0_0x5c99(){const _0x460a75=['700TvyqFl','failed','toAlias','application/json','name','Bearer\x20',']\x20[commhub:','new_task','call','<unknown>','running','alias','error_message','/events/','catch','error_code','631010yyjfMO','\x20to=','body','split','\x20lifecycle=','resumeId','url','connected','Authorization','data:\x20','autoConnect','sdk-','text/event-stream','21679NUkNCD','lifecycle_tracking','text','AbortError','SSE\x20reconnecting\x20in\x20','11zEEdYb','tools/call','duration_ms','task.started','17264qslVub','sdk','read','lifecycleTracking','type','transport','CommHub\x20rejected\x20task','\x20network_id=','content','send_reply','delivered','log','completed','24UCPqKX','task.send.delivered','missing_task_id','task','getReader','task.send.start','get_all_status','421566mpMbAa','result','to_alias','[REDACTED]','fromAlias','min','registered','SSE\x20error:\x20','reconnectDelay','POST','mcp_http','token','task.send.failed','now','\x20from=','string','send','<pending>','task_id','[commhub:task]\x20','networkId','getAllStatus','broadcast','13KTmDyV','<missing>','decode','sending','agent','parse','2.0','disconnect','messages','processInbox','\x20transport=','idle','abort','\x20duration_ms=','send_failed','\x20parent_task_id=','task.replied','startsWith','replace','from_session','24tqShIF','send_message','\x20error=','new_message','heartbeatInterval','3028azISMc','server','ack_inbox','emit','sleep','78129xeRKkB','CommHub\x20response\x20omitted\x20task_id','heartbeatTimer','inbox\x20error:\x20','status','normal','SSE\x20failed:\x20','disconnected','pop','stringify','match','task.expired','signal','heartbeat\x20failed:\x20','reply','task.ack','894tUxpZz','sseAbort','8185956tqZFPl','message','message_id','not_tracked','connectSSE','slice','error'];a0_0x5c99=function(){return _0x460a75;};return a0_0x5c99();}import{hostname as a0_0x3cb95e}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x55332b,_0x293f6f)=>(_0x55332b??_0x293f6f)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x78f856(0x22b)](0x0,0xf0);function N(_0x10a0ae){const _0x32b73e=a0_0x78f856;return(_0x10a0ae instanceof Error?_0x10a0ae['message']:String(_0x10a0ae??'unknown\x20error'))[_0x32b73e(0x208)](K,_0x32b73e(0x26a))[_0x32b73e(0x208)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x32b73e(0x22b)](0x0,0xf0);}function O(_0x159a22,_0x1e8c9c=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x3c8ea0=a0_0x78f856;if(_0x1e8c9c)return JSON['stringify'](_0x159a22);let _0x8521db=L(_0x159a22['parent_task_id'],_0x3c8ea0(0x1f7)),_0x1b276e=L(_0x159a22[_0x3c8ea0(0x1f1)],_0x3c8ea0(0x1f0)),_0x52375d=_0x159a22[_0x3c8ea0(0x23c)]?_0x3c8ea0(0x20c)+_0x159a22[_0x3c8ea0(0x23c)]+':'+(_0x159a22[_0x3c8ea0(0x239)]??''):'';return _0x3c8ea0(0x1f2)+_0x159a22[_0x3c8ea0(0x218)]+_0x3c8ea0(0x275)+L(_0x159a22['from_alias'],_0x3c8ea0(0x236))+_0x3c8ea0(0x23e)+L(_0x159a22[_0x3c8ea0(0x269)],_0x3c8ea0(0x236))+'\x20task_id='+_0x1b276e+_0x3c8ea0(0x205)+_0x8521db+_0x3c8ea0(0x25a)+L(_0x159a22['network_id'],'<unknown>')+_0x3c8ea0(0x200)+_0x159a22[_0x3c8ea0(0x258)]+_0x3c8ea0(0x203)+_0x159a22[_0x3c8ea0(0x251)]+_0x3c8ea0(0x241)+_0x159a22[_0x3c8ea0(0x24b)]+_0x52375d;}function U(_0x332d41){const _0x4872ee=a0_0x78f856;return{'event':{'sending':_0x4872ee(0x265),'delivered':_0x4872ee(0x261),'failed':_0x4872ee(0x273),'acked':_0x4872ee(0x223),'started':_0x4872ee(0x252),'replied':_0x4872ee(0x206),'expired':_0x4872ee(0x21f)}[_0x332d41[_0x4872ee(0x218)]],..._0x332d41};}function j(_0x58a26){const _0x596c62=a0_0x78f856;let _0x4dd93d=_0x58a26?.['task_id']||_0x58a26?.[_0x596c62(0x228)]||_0x58a26?.['id'];if(_0x4dd93d)return String(_0x4dd93d);let _0x4e6c74=_0x58a26?.[_0x596c62(0x25b)]?.[0x0]?.[_0x596c62(0x24c)];if(typeof _0x4e6c74!==_0x596c62(0x276))return null;try{let _0x9dbec6=JSON[_0x596c62(0x1fb)](_0x4e6c74);return _0x9dbec6?.[_0x596c62(0x1f1)]||_0x9dbec6?.[_0x596c62(0x228)]||_0x9dbec6?.['id']||null;}catch{return null;}}async function X(_0x39570d,_0x329e62){const _0x1b4d98=a0_0x78f856;let _0x2d74ed=_0x329e62[_0x1b4d98(0x274)]??Date[_0x1b4d98(0x274)],_0x3d1c97=_0x2d74ed(),_0x1abf7d=(_0x3ec254,_0x6866cb,_0x5a6958,_0x569d85)=>{const _0x5ed6d2=_0x1b4d98;_0x329e62['log'](O(U({'from_alias':_0x39570d['fromAlias'],'to_alias':_0x39570d[_0x5ed6d2(0x22f)],'task_id':_0x6866cb,'parent_task_id':_0x39570d['parentTaskId'],'network_id':_0x39570d[_0x5ed6d2(0x1f3)],'transport':_0x39570d[_0x5ed6d2(0x258)],'status':_0x3ec254,'duration_ms':_0x2d74ed()-_0x3d1c97,'lifecycle_tracking':_0x39570d[_0x5ed6d2(0x256)],..._0x5a6958!==void 0x0?{'error_code':_0x569d85||'send_failed','error_message':N(_0x5a6958)}:{}})));};_0x1abf7d(_0x1b4d98(0x1f9),null);try{let _0x206b5a=await _0x329e62['send'](),_0x4ee670=j(_0x206b5a);if(_0x4ee670)_0x1abf7d(_0x1b4d98(0x25d),_0x4ee670);else{if(_0x206b5a?.['ok']===!0x1||_0x206b5a?.[_0x1b4d98(0x22c)])_0x1abf7d(_0x1b4d98(0x22e),_0x4ee670,_0x206b5a?.['error']||_0x1b4d98(0x259),'send_rejected');else _0x1abf7d(_0x1b4d98(0x22e),null,_0x1b4d98(0x215),_0x1b4d98(0x262));}return _0x206b5a;}catch(_0x39ecea){throw _0x1abf7d('failed',null,_0x39ecea,_0x1b4d98(0x204)),_0x39ecea;}}async function Y(_0x408ea4,_0x177629){const _0x37078c=a0_0x78f856;return X({'fromAlias':_0x408ea4[_0x37078c(0x26b)],'toAlias':_0x408ea4[_0x37078c(0x238)],'parentTaskId':_0x408ea4['parentTaskId']||null,'networkId':_0x408ea4[_0x37078c(0x1f3)]||null,'transport':_0x37078c(0x271),'lifecycleTracking':_0x37078c(0x229)},_0x177629);}function a0_0x4c67(_0x1a388d,_0x8693c5){_0x1a388d=_0x1a388d-0x1ef;const _0x5c99f7=a0_0x5c99();let _0x4c6703=_0x5c99f7[_0x1a388d];return _0x4c6703;}class $ extends a0_0x33dc6a{[a0_0x78f856(0x243)];[a0_0x78f856(0x238)];[a0_0x78f856(0x272)];[a0_0x78f856(0x1fa)];[a0_0x78f856(0x242)];[a0_0x78f856(0x20e)];[a0_0x78f856(0x26f)];[a0_0x78f856(0x216)];[a0_0x78f856(0x225)];['running']=!0x1;constructor(_0x94c3d5){const _0x12e923=a0_0x78f856;super();if(this[_0x12e923(0x243)]=_0x94c3d5[_0x12e923(0x243)][_0x12e923(0x208)](/\/$/,''),this[_0x12e923(0x238)]=_0x94c3d5[_0x12e923(0x238)],this[_0x12e923(0x272)]=_0x94c3d5[_0x12e923(0x272)],this['agent']=_0x94c3d5[_0x12e923(0x1fa)]||_0x12e923(0x254),this[_0x12e923(0x242)]=_0x12e923(0x248)+_0x94c3d5[_0x12e923(0x238)]+'-'+Date['now']()['toString'](0x24),this[_0x12e923(0x20e)]=_0x94c3d5[_0x12e923(0x20e)]??0x2bf20,this['reconnectDelay']=_0x94c3d5[_0x12e923(0x26f)]??0xbb8,_0x94c3d5[_0x12e923(0x247)]!==!0x1)this['connect']();}[a0_0x78f856(0x25e)](_0x4a709c){const _0xd0d02b=a0_0x78f856;console[_0xd0d02b(0x25e)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0xd0d02b(0x233)+this[_0xd0d02b(0x238)]+']\x20'+_0x4a709c);}async[a0_0x78f856(0x235)](_0x1b33c2,_0x2f4365){const _0x2e30c5=a0_0x78f856;let _0x165e68={'Content-Type':_0x2e30c5(0x230),'Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x165e68[_0x2e30c5(0x245)]=_0x2e30c5(0x232)+this[_0x2e30c5(0x272)];let _0x38ded9=await(await fetch(this[_0x2e30c5(0x243)]+'/mcp',{'method':_0x2e30c5(0x270),'headers':_0x165e68,'body':JSON[_0x2e30c5(0x21d)]({'jsonrpc':_0x2e30c5(0x1fc),'id':Date[_0x2e30c5(0x274)](),'method':_0x2e30c5(0x250),'params':{'name':_0x1b33c2,'arguments':_0x2f4365}})}))[_0x2e30c5(0x24c)](),_0x57f42d=_0x38ded9[_0x2e30c5(0x21e)](/data: (.+)/),_0x280e57=_0x57f42d?JSON['parse'](_0x57f42d[0x1]):JSON[_0x2e30c5(0x1fb)](_0x38ded9),_0xa3a4d=_0x280e57?.[_0x2e30c5(0x268)]?.['content']?.[0x0]?.[_0x2e30c5(0x24c)];return _0xa3a4d?JSON[_0x2e30c5(0x1fb)](_0xa3a4d):_0x280e57;}async['connect'](){const _0x522cfd=a0_0x78f856;if(this['running'])return;this['running']=!0x0,await this[_0x522cfd(0x218)](_0x522cfd(0x201)),this[_0x522cfd(0x25e)](_0x522cfd(0x26d)),this['heartbeatTimer']=setInterval(()=>{const _0x531f17=_0x522cfd;this[_0x531f17(0x218)](_0x531f17(0x201))[_0x531f17(0x23b)](_0x3f81c2=>this['log'](_0x531f17(0x221)+_0x3f81c2['message']));},this[_0x522cfd(0x20e)]),this['connectSSE']();}async[a0_0x78f856(0x1fd)](){const _0x2743ab=a0_0x78f856;if(this[_0x2743ab(0x237)]=!0x1,this['sseAbort']?.[_0x2743ab(0x202)](),this[_0x2743ab(0x216)])clearInterval(this[_0x2743ab(0x216)]);await this[_0x2743ab(0x218)]('offline')[_0x2743ab(0x23b)](()=>{}),this[_0x2743ab(0x25e)](_0x2743ab(0x21b));}async[a0_0x78f856(0x1ef)](_0x43f6d4,_0x577f98,_0xd3b6e6=a0_0x78f856(0x219)){const _0x4b1f94=a0_0x78f856;return Y({'alias':_0x43f6d4,'fromAlias':this[_0x4b1f94(0x238)]},{'log':_0x931e94=>console[_0x4b1f94(0x25e)](_0x931e94),'send':()=>this[_0x4b1f94(0x235)]('send_task',{'alias':_0x43f6d4,'task':_0x577f98,'priority':_0xd3b6e6,'from_session':this['alias']})});}async[a0_0x78f856(0x227)](_0x3f3e76,_0x263232){const _0x3d33a1=a0_0x78f856;return this[_0x3d33a1(0x235)](_0x3d33a1(0x20b),{'alias':_0x3f3e76,'message':_0x263232,'from_session':this[_0x3d33a1(0x238)]});}async[a0_0x78f856(0x222)](_0x5ef90f,_0x5da895,_0x2f59d9=a0_0x78f856(0x25f)){const _0x42319f=a0_0x78f856;return this[_0x42319f(0x235)](_0x42319f(0x25c),{'in_reply_to':_0x5ef90f,'text':_0x5da895,'status':_0x2f59d9});}async[a0_0x78f856(0x218)](_0x2fe3a9,_0xd10c43){const _0x1c168a=a0_0x78f856;return this['call']('report_status',{'resume_id':this['resumeId'],'alias':this[_0x1c168a(0x238)],'status':_0x2fe3a9,'server':a0_0x3cb95e(),'hostname':a0_0x3cb95e(),'agent':this[_0x1c168a(0x1fa)],'project_dir':process['cwd'](),..._0xd10c43});}async[a0_0x78f856(0x1f4)](){const _0x50aaef=a0_0x78f856;return this[_0x50aaef(0x235)](_0x50aaef(0x266),{});}async['broadcast'](_0x31654a,_0x84b58b){const _0x2a5a42=a0_0x78f856;return this[_0x2a5a42(0x235)](_0x2a5a42(0x1f5),{'message':_0x31654a,'filter_server':_0x84b58b?.[_0x2a5a42(0x210)],'filter_status':_0x84b58b?.[_0x2a5a42(0x218)]});}async[a0_0x78f856(0x22a)](){const _0x5abd52=a0_0x78f856;let _0x364599=encodeURIComponent(this['alias']),_0x1209f8=this[_0x5abd52(0x243)]+_0x5abd52(0x23a)+_0x364599,_0x44e665=this[_0x5abd52(0x26f)];while(this[_0x5abd52(0x237)]){try{this[_0x5abd52(0x225)]=new AbortController();let _0x2d8f21={'Accept':_0x5abd52(0x249)};if(this[_0x5abd52(0x272)])_0x2d8f21['Authorization']=_0x5abd52(0x232)+this['token'];let _0x763963=await fetch(_0x1209f8,{'headers':_0x2d8f21,'signal':this[_0x5abd52(0x225)][_0x5abd52(0x220)]});if(!_0x763963['ok']||!_0x763963[_0x5abd52(0x23f)]){this[_0x5abd52(0x25e)](_0x5abd52(0x21a)+_0x763963[_0x5abd52(0x218)]),await this[_0x5abd52(0x213)](_0x44e665),_0x44e665=Math[_0x5abd52(0x26c)](_0x44e665*1.5,0xea60);continue;}_0x44e665=this[_0x5abd52(0x26f)];let _0x28a39b=_0x763963[_0x5abd52(0x23f)][_0x5abd52(0x264)](),_0x4ece51=new TextDecoder(),_0x4621e3='';while(this['running']){let {done:_0x1db90f,value:_0x1be220}=await _0x28a39b[_0x5abd52(0x255)]();if(_0x1db90f)break;_0x4621e3+=_0x4ece51[_0x5abd52(0x1f8)](_0x1be220,{'stream':!0x0});let _0x494c12=_0x4621e3[_0x5abd52(0x240)]('\x0a');_0x4621e3=_0x494c12[_0x5abd52(0x21c)]()||'';for(let _0x570f4c of _0x494c12){if(!_0x570f4c[_0x5abd52(0x207)](_0x5abd52(0x246)))continue;try{let _0x4e3791=JSON[_0x5abd52(0x1fb)](_0x570f4c['slice'](0x6));if(_0x4e3791[_0x5abd52(0x257)]===_0x5abd52(0x244)){this[_0x5abd52(0x25e)]('SSE\x20connected'),this['emit'](_0x5abd52(0x244));continue;}if(_0x4e3791['type']===_0x5abd52(0x234)||_0x4e3791[_0x5abd52(0x257)]===_0x5abd52(0x20d)||_0x4e3791['type']==='broadcast')await this[_0x5abd52(0x1ff)]();}catch{}}}}catch(_0x343a7f){if(_0x343a7f[_0x5abd52(0x231)]===_0x5abd52(0x24d))break;this[_0x5abd52(0x212)](_0x5abd52(0x22c),_0x343a7f),this[_0x5abd52(0x25e)](_0x5abd52(0x26e)+_0x343a7f[_0x5abd52(0x227)]);}if(this[_0x5abd52(0x237)])this['emit']('disconnected'),this[_0x5abd52(0x25e)](_0x5abd52(0x24e)+_0x44e665/0x3e8+'s...'),await this[_0x5abd52(0x213)](_0x44e665),_0x44e665=Math[_0x5abd52(0x26c)](_0x44e665*1.5,0xea60);}}async['processInbox'](){const _0xfcfce=a0_0x78f856;try{let _0x34d4f1=(await this[_0xfcfce(0x235)]('get_inbox',{'alias':this[_0xfcfce(0x238)],'limit':0xa}))?.[_0xfcfce(0x1fe)]||[];for(let _0x42f299 of _0x34d4f1)await this[_0xfcfce(0x235)](_0xfcfce(0x211),{'alias':this[_0xfcfce(0x238)],'message_id':_0x42f299['id']}),this['log']('←\x20'+_0x42f299[_0xfcfce(0x209)]+':\x20'+_0x42f299[_0xfcfce(0x25b)]['slice'](0x0,0x3c)),this[_0xfcfce(0x212)](_0xfcfce(0x263),_0x42f299),this['emit']('message',_0x42f299);}catch(_0x2c5641){this[_0xfcfce(0x25e)](_0xfcfce(0x217)+_0x2c5641[_0xfcfce(0x227)]);}}['sleep'](_0x5cbb24){return new Promise(_0x510de8=>setTimeout(_0x510de8,_0x5cbb24));}}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;
|