@sleep2agi/agent-network 2.3.0-preview.103 → 2.3.0-preview.105
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_0x55e633=a0_0x3693;(function(_0x3fae93,_0x40a9dc){const _0x13071f=a0_0x3693,_0x10b107=_0x3fae93();while(!![]){try{const _0x49fbab=-parseInt(_0x13071f(0x103))/0x1+parseInt(_0x13071f(0x154))/0x2*(-parseInt(_0x13071f(0x167))/0x3)+parseInt(_0x13071f(0x11e))/0x4+-parseInt(_0x13071f(0x138))/0x5*(parseInt(_0x13071f(0x12a))/0x6)+-parseInt(_0x13071f(0x124))/0x7+parseInt(_0x13071f(0x142))/0x8*(-parseInt(_0x13071f(0x155))/0x9)+parseInt(_0x13071f(0x145))/0xa;if(_0x49fbab===_0x40a9dc)break;else _0x10b107['push'](_0x10b107['shift']());}catch(_0x2925eb){_0x10b107['push'](_0x10b107['shift']());}}}(a0_0x4d95,0xcc8fd));import{EventEmitter as a0_0x613f9f}from'events';import{hostname as a0_0x4de8e5}from'os';function a0_0x3693(_0x7e6f01,_0x980096){_0x7e6f01=_0x7e6f01-0xfb;const _0x4d9567=a0_0x4d95();let _0x369370=_0x4d9567[_0x7e6f01];return _0x369370;}function a0_0x4d95(){const _0x2c9832=['read','task.started','inbox\x20error:\x20','\x20lifecycle=','message','slice','cwd','heartbeatInterval','messages','1205184rtIzHV','result','text','content','json','lifecycleTracking','544824LpbNGl','connected','application/json','now','min','failed','728016akFdCL','status','type','running','lifecycle_tracking','new_message','network_id','<unknown>','mcp_http','text/event-stream','\x20transport=','\x20duration_ms=','report_status','alias','35rXUahm','get_inbox','not_tracked','\x20to=','broadcast','transport','reply','from_session','\x20network_id=','connectSSE','8odQWcI','sending','/mcp','43803160mbXVuX','/events/','normal','getReader','\x20from=','[REDACTED]','Authorization','\x20error=','CommHub\x20response\x20omitted\x20task_id','disconnected','message_id','toString','task.send.failed','connect','<pending>','10OBKFjo','6453585ZHHzhy','resumeId','task.send.start','send_failed','toAlias','[commhub:task]\x20','offline','catch','agent','name','stringify','reconnectDelay','SSE\x20error:\x20','emit','heartbeatTimer','server','from_alias','task.replied','814446eINhJM','2.0','missing_task_id','<missing>','fromAlias','parse','log','SSE\x20connected','completed','\x20parent_task_id=','task_id','idle','getAllStatus','application/json,\x20text/event-stream','sdk-','error_code','url','token','signal','duration_ms','error','parentTaskId','call','send','SSE\x20reconnecting\x20in\x20','send_message','842068YDDjLI','body','networkId','processInbox','pop','task','replace','decode','match','task.send.delivered','disconnect','task.expired','sleep','send_task','task.ack','AbortError','tools/call','new_task'];a0_0x4d95=function(){return _0x2c9832;};return a0_0x4d95();}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x3e60ef,_0x455f3b)=>(_0x3e60ef??_0x455f3b)[a0_0x55e633(0x109)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x3374c6){const _0x41e62a=a0_0x55e633;return(_0x3374c6 instanceof Error?_0x3374c6[_0x41e62a(0x119)]:String(_0x3374c6??'unknown\x20error'))['replace'](K,_0x41e62a(0x14a))[_0x41e62a(0x109)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x41e62a(0x11a)](0x0,0xf0);}function O(_0x15c3c1,_0x806c93=process.env.ANET_TASK_TRACE_FORMAT===a0_0x55e633(0x122)){const _0x4b463d=a0_0x55e633;if(_0x806c93)return JSON['stringify'](_0x15c3c1);let _0x5f8617=L(_0x15c3c1['parent_task_id'],_0x4b463d(0x16a)),_0x4349be=L(_0x15c3c1[_0x4b463d(0x171)],_0x4b463d(0x153)),_0x12ad76=_0x15c3c1[_0x4b463d(0x176)]?_0x4b463d(0x14c)+_0x15c3c1[_0x4b463d(0x176)]+':'+(_0x15c3c1['error_message']??''):'';return _0x4b463d(0x15a)+_0x15c3c1[_0x4b463d(0x12b)]+_0x4b463d(0x149)+L(_0x15c3c1[_0x4b463d(0x165)],_0x4b463d(0x131))+_0x4b463d(0x13b)+L(_0x15c3c1['to_alias'],_0x4b463d(0x131))+'\x20task_id='+_0x4349be+_0x4b463d(0x170)+_0x5f8617+_0x4b463d(0x140)+L(_0x15c3c1[_0x4b463d(0x130)],_0x4b463d(0x131))+_0x4b463d(0x134)+_0x15c3c1[_0x4b463d(0x13d)]+_0x4b463d(0x135)+_0x15c3c1[_0x4b463d(0xfc)]+_0x4b463d(0x118)+_0x15c3c1[_0x4b463d(0x12e)]+_0x12ad76;}function U(_0x62b3db){const _0x1e2d09=a0_0x55e633;return{'event':{'sending':_0x1e2d09(0x157),'delivered':_0x1e2d09(0x10c),'failed':_0x1e2d09(0x151),'acked':_0x1e2d09(0x111),'started':_0x1e2d09(0x116),'replied':_0x1e2d09(0x166),'expired':_0x1e2d09(0x10e)}[_0x62b3db[_0x1e2d09(0x12b)]],..._0x62b3db};}function j(_0x42e04d){const _0x287406=a0_0x55e633;let _0x24b566=_0x42e04d?.[_0x287406(0x171)]||_0x42e04d?.[_0x287406(0x14f)]||_0x42e04d?.['id'];if(_0x24b566)return String(_0x24b566);let _0x87a7da=_0x42e04d?.['content']?.[0x0]?.['text'];if(typeof _0x87a7da!=='string')return null;try{let _0x4b38f9=JSON[_0x287406(0x16c)](_0x87a7da);return _0x4b38f9?.[_0x287406(0x171)]||_0x4b38f9?.[_0x287406(0x14f)]||_0x4b38f9?.['id']||null;}catch{return null;}}async function X(_0x1b8a69,_0x50dedb){const _0x18b736=a0_0x55e633;let _0x3b7511=_0x50dedb[_0x18b736(0x127)]??Date[_0x18b736(0x127)],_0x39c815=_0x3b7511(),_0x14ae51=(_0x411cec,_0x1a525a,_0x525889,_0x378645)=>{const _0x4f2a70=_0x18b736;_0x50dedb[_0x4f2a70(0x16d)](O(U({'from_alias':_0x1b8a69[_0x4f2a70(0x16b)],'to_alias':_0x1b8a69[_0x4f2a70(0x159)],'task_id':_0x1a525a,'parent_task_id':_0x1b8a69[_0x4f2a70(0xfe)],'network_id':_0x1b8a69[_0x4f2a70(0x105)],'transport':_0x1b8a69['transport'],'status':_0x411cec,'duration_ms':_0x3b7511()-_0x39c815,'lifecycle_tracking':_0x1b8a69[_0x4f2a70(0x123)],..._0x525889!==void 0x0?{'error_code':_0x378645||_0x4f2a70(0x158),'error_message':N(_0x525889)}:{}})));};_0x14ae51(_0x18b736(0x143),null);try{let _0x3ea21a=await _0x50dedb['send'](),_0x10bacc=j(_0x3ea21a);if(_0x10bacc)_0x14ae51('delivered',_0x10bacc);else{if(_0x3ea21a?.['ok']===!0x1||_0x3ea21a?.[_0x18b736(0xfd)])_0x14ae51(_0x18b736(0x129),_0x10bacc,_0x3ea21a?.[_0x18b736(0xfd)]||'CommHub\x20rejected\x20task','send_rejected');else _0x14ae51(_0x18b736(0x129),null,_0x18b736(0x14d),_0x18b736(0x169));}return _0x3ea21a;}catch(_0x43bdc4){throw _0x14ae51(_0x18b736(0x129),null,_0x43bdc4,_0x18b736(0x158)),_0x43bdc4;}}async function Y(_0x21b699,_0x178f98){const _0x5a0199=a0_0x55e633;return X({'fromAlias':_0x21b699[_0x5a0199(0x16b)],'toAlias':_0x21b699['alias'],'parentTaskId':_0x21b699['parentTaskId']||null,'networkId':_0x21b699['networkId']||null,'transport':_0x5a0199(0x132),'lifecycleTracking':_0x5a0199(0x13a)},_0x178f98);}class $ extends a0_0x613f9f{[a0_0x55e633(0x177)];['alias'];[a0_0x55e633(0x178)];[a0_0x55e633(0x15d)];[a0_0x55e633(0x156)];['heartbeatInterval'];[a0_0x55e633(0x160)];[a0_0x55e633(0x163)];['sseAbort'];[a0_0x55e633(0x12d)]=!0x1;constructor(_0x2007cd){const _0x3237ac=a0_0x55e633;super();if(this[_0x3237ac(0x177)]=_0x2007cd[_0x3237ac(0x177)][_0x3237ac(0x109)](/\/$/,''),this[_0x3237ac(0x137)]=_0x2007cd[_0x3237ac(0x137)],this[_0x3237ac(0x178)]=_0x2007cd[_0x3237ac(0x178)],this[_0x3237ac(0x15d)]=_0x2007cd['agent']||'sdk',this[_0x3237ac(0x156)]=_0x3237ac(0x175)+_0x2007cd['alias']+'-'+Date['now']()[_0x3237ac(0x150)](0x24),this[_0x3237ac(0x11c)]=_0x2007cd['heartbeatInterval']??0x2bf20,this[_0x3237ac(0x160)]=_0x2007cd[_0x3237ac(0x160)]??0xbb8,_0x2007cd['autoConnect']!==!0x1)this['connect']();}[a0_0x55e633(0x16d)](_0x517b8e){const _0x380af4=a0_0x55e633;console[_0x380af4(0x16d)]('['+new Date()['toTimeString']()[_0x380af4(0x11a)](0x0,0x8)+']\x20[commhub:'+this[_0x380af4(0x137)]+']\x20'+_0x517b8e);}async[a0_0x55e633(0xff)](_0x47fab2,_0x3bf43f){const _0x28c4c3=a0_0x55e633;let _0xb84bd1={'Content-Type':_0x28c4c3(0x126),'Accept':_0x28c4c3(0x174)};if(this[_0x28c4c3(0x178)])_0xb84bd1[_0x28c4c3(0x14b)]='Bearer\x20'+this[_0x28c4c3(0x178)];let _0x2c9322=await(await fetch(this['url']+_0x28c4c3(0x144),{'method':'POST','headers':_0xb84bd1,'body':JSON[_0x28c4c3(0x15f)]({'jsonrpc':_0x28c4c3(0x168),'id':Date[_0x28c4c3(0x127)](),'method':_0x28c4c3(0x113),'params':{'name':_0x47fab2,'arguments':_0x3bf43f}})}))[_0x28c4c3(0x120)](),_0x1246cc=_0x2c9322[_0x28c4c3(0x10b)](/data: (.+)/),_0x4d4c58=_0x1246cc?JSON[_0x28c4c3(0x16c)](_0x1246cc[0x1]):JSON[_0x28c4c3(0x16c)](_0x2c9322),_0x11b802=_0x4d4c58?.[_0x28c4c3(0x11f)]?.[_0x28c4c3(0x121)]?.[0x0]?.[_0x28c4c3(0x120)];return _0x11b802?JSON[_0x28c4c3(0x16c)](_0x11b802):_0x4d4c58;}async[a0_0x55e633(0x152)](){const _0x5b3bdf=a0_0x55e633;if(this[_0x5b3bdf(0x12d)])return;this[_0x5b3bdf(0x12d)]=!0x0,await this['status'](_0x5b3bdf(0x172)),this[_0x5b3bdf(0x16d)]('registered'),this[_0x5b3bdf(0x163)]=setInterval(()=>{const _0x410903=_0x5b3bdf;this[_0x410903(0x12b)](_0x410903(0x172))[_0x410903(0x15c)](_0x164191=>this[_0x410903(0x16d)]('heartbeat\x20failed:\x20'+_0x164191[_0x410903(0x119)]));},this['heartbeatInterval']),this[_0x5b3bdf(0x141)]();}async[a0_0x55e633(0x10d)](){const _0x3bad82=a0_0x55e633;if(this[_0x3bad82(0x12d)]=!0x1,this['sseAbort']?.['abort'](),this[_0x3bad82(0x163)])clearInterval(this['heartbeatTimer']);await this['status'](_0x3bad82(0x15b))[_0x3bad82(0x15c)](()=>{}),this['log'](_0x3bad82(0x14e));}async[a0_0x55e633(0x100)](_0xbf9245,_0x3fc3f7,_0x205251=a0_0x55e633(0x147)){const _0x148da7=a0_0x55e633;return Y({'alias':_0xbf9245,'fromAlias':this[_0x148da7(0x137)]},{'log':_0x531897=>console[_0x148da7(0x16d)](_0x531897),'send':()=>this['call'](_0x148da7(0x110),{'alias':_0xbf9245,'task':_0x3fc3f7,'priority':_0x205251,'from_session':this['alias']})});}async[a0_0x55e633(0x119)](_0x38cb48,_0x405f74){const _0x39809f=a0_0x55e633;return this[_0x39809f(0xff)](_0x39809f(0x102),{'alias':_0x38cb48,'message':_0x405f74,'from_session':this[_0x39809f(0x137)]});}async[a0_0x55e633(0x13e)](_0x4521b4,_0x10845a,_0x4a75fc=a0_0x55e633(0x16f)){const _0x2eca70=a0_0x55e633;return this[_0x2eca70(0xff)]('send_reply',{'in_reply_to':_0x4521b4,'text':_0x10845a,'status':_0x4a75fc});}async[a0_0x55e633(0x12b)](_0x3a401c,_0x3b0d99){const _0x44024d=a0_0x55e633;return this['call'](_0x44024d(0x136),{'resume_id':this[_0x44024d(0x156)],'alias':this[_0x44024d(0x137)],'status':_0x3a401c,'server':a0_0x4de8e5(),'hostname':a0_0x4de8e5(),'agent':this[_0x44024d(0x15d)],'project_dir':process[_0x44024d(0x11b)](),..._0x3b0d99});}async[a0_0x55e633(0x173)](){const _0x2a87db=a0_0x55e633;return this[_0x2a87db(0xff)]('get_all_status',{});}async[a0_0x55e633(0x13c)](_0x4d2ecb,_0x2641b9){const _0x57d64e=a0_0x55e633;return this[_0x57d64e(0xff)](_0x57d64e(0x13c),{'message':_0x4d2ecb,'filter_server':_0x2641b9?.[_0x57d64e(0x164)],'filter_status':_0x2641b9?.[_0x57d64e(0x12b)]});}async[a0_0x55e633(0x141)](){const _0x3a72c1=a0_0x55e633;let _0x9bf425=encodeURIComponent(this[_0x3a72c1(0x137)]),_0x98bd5f=this[_0x3a72c1(0x177)]+_0x3a72c1(0x146)+_0x9bf425,_0x2679cb=this[_0x3a72c1(0x160)];while(this['running']){try{this['sseAbort']=new AbortController();let _0x25814e={'Accept':_0x3a72c1(0x133)};if(this['token'])_0x25814e['Authorization']='Bearer\x20'+this[_0x3a72c1(0x178)];let _0xa9c475=await fetch(_0x98bd5f,{'headers':_0x25814e,'signal':this['sseAbort'][_0x3a72c1(0xfb)]});if(!_0xa9c475['ok']||!_0xa9c475[_0x3a72c1(0x104)]){this[_0x3a72c1(0x16d)]('SSE\x20failed:\x20'+_0xa9c475[_0x3a72c1(0x12b)]),await this['sleep'](_0x2679cb),_0x2679cb=Math[_0x3a72c1(0x128)](_0x2679cb*1.5,0xea60);continue;}_0x2679cb=this['reconnectDelay'];let _0xc2cc=_0xa9c475['body'][_0x3a72c1(0x148)](),_0x24f0ae=new TextDecoder(),_0x4da92c='';while(this['running']){let {done:_0x3b9680,value:_0x438beb}=await _0xc2cc[_0x3a72c1(0x115)]();if(_0x3b9680)break;_0x4da92c+=_0x24f0ae[_0x3a72c1(0x10a)](_0x438beb,{'stream':!0x0});let _0x314796=_0x4da92c['split']('\x0a');_0x4da92c=_0x314796[_0x3a72c1(0x107)]()||'';for(let _0x3e41c8 of _0x314796){if(!_0x3e41c8['startsWith']('data:\x20'))continue;try{let _0x26eaee=JSON['parse'](_0x3e41c8['slice'](0x6));if(_0x26eaee[_0x3a72c1(0x12c)]===_0x3a72c1(0x125)){this[_0x3a72c1(0x16d)](_0x3a72c1(0x16e)),this[_0x3a72c1(0x162)]('connected');continue;}if(_0x26eaee['type']===_0x3a72c1(0x114)||_0x26eaee[_0x3a72c1(0x12c)]===_0x3a72c1(0x12f)||_0x26eaee[_0x3a72c1(0x12c)]===_0x3a72c1(0x13c))await this[_0x3a72c1(0x106)]();}catch{}}}}catch(_0x28f2c9){if(_0x28f2c9[_0x3a72c1(0x15e)]===_0x3a72c1(0x112))break;this[_0x3a72c1(0x162)](_0x3a72c1(0xfd),_0x28f2c9),this[_0x3a72c1(0x16d)](_0x3a72c1(0x161)+_0x28f2c9[_0x3a72c1(0x119)]);}if(this[_0x3a72c1(0x12d)])this[_0x3a72c1(0x162)](_0x3a72c1(0x14e)),this['log'](_0x3a72c1(0x101)+_0x2679cb/0x3e8+'s...'),await this[_0x3a72c1(0x10f)](_0x2679cb),_0x2679cb=Math[_0x3a72c1(0x128)](_0x2679cb*1.5,0xea60);}}async[a0_0x55e633(0x106)](){const _0xa6e61=a0_0x55e633;try{let _0x104d69=(await this[_0xa6e61(0xff)](_0xa6e61(0x139),{'alias':this['alias'],'limit':0xa}))?.[_0xa6e61(0x11d)]||[];for(let _0x9dab26 of _0x104d69)await this[_0xa6e61(0xff)]('ack_inbox',{'alias':this['alias'],'message_id':_0x9dab26['id']}),this['log']('←\x20'+_0x9dab26[_0xa6e61(0x13f)]+':\x20'+_0x9dab26[_0xa6e61(0x121)]['slice'](0x0,0x3c)),this[_0xa6e61(0x162)](_0xa6e61(0x108),_0x9dab26),this[_0xa6e61(0x162)](_0xa6e61(0x119),_0x9dab26);}catch(_0x174ec3){this['log'](_0xa6e61(0x117)+_0x174ec3[_0xa6e61(0x119)]);}}[a0_0x55e633(0x10f)](_0x181ea6){return new Promise(_0x1dac04=>setTimeout(_0x1dac04,_0x181ea6));}}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;
|