@sleep2agi/agent-network 2.3.0-preview.96 → 2.3.0-preview.97
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
|
-
function a0_0x2c82(_0x29e3b4,_0x50df15){_0x29e3b4=_0x29e3b4-0x16e;const _0x9a1373=a0_0x9a13();let _0x2c82be=_0x9a1373[_0x29e3b4];return _0x2c82be;}const a0_0x4bafa8=a0_0x2c82;(function(_0xd5fb87,_0x15a97d){const _0x2311d=a0_0x2c82,_0x3744a7=_0xd5fb87();while(!![]){try{const _0x1314e3=parseInt(_0x2311d(0x188))/0x1*(-parseInt(_0x2311d(0x1b5))/0x2)+-parseInt(_0x2311d(0x1ab))/0x3*(-parseInt(_0x2311d(0x1de))/0x4)+parseInt(_0x2311d(0x1bb))/0x5*(parseInt(_0x2311d(0x173))/0x6)+parseInt(_0x2311d(0x186))/0x7*(parseInt(_0x2311d(0x1d9))/0x8)+-parseInt(_0x2311d(0x1bd))/0x9+-parseInt(_0x2311d(0x1e5))/0xa*(-parseInt(_0x2311d(0x1d1))/0xb)+-parseInt(_0x2311d(0x1b6))/0xc*(-parseInt(_0x2311d(0x181))/0xd);if(_0x1314e3===_0x15a97d)break;else _0x3744a7['push'](_0x3744a7['shift']());}catch(_0x3381fa){_0x3744a7['push'](_0x3744a7['shift']());}}}(a0_0x9a13,0xb8152));import{EventEmitter as a0_0x59605c}from'events';import{hostname as a0_0x37c631}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x1bd959,_0x3fdeec)=>(_0x1bd959??_0x3fdeec)[a0_0x4bafa8(0x172)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x4bafa8(0x179)](0x0,0xf0);function N(_0x3f2a42){const _0x44a16d=a0_0x4bafa8;return(_0x3f2a42 instanceof Error?_0x3f2a42[_0x44a16d(0x1c7)]:String(_0x3f2a42??_0x44a16d(0x19e)))[_0x44a16d(0x172)](K,'[REDACTED]')['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x1d418a,_0x8245c2=process.env.ANET_TASK_TRACE_FORMAT===a0_0x4bafa8(0x197)){const _0x5d1a50=a0_0x4bafa8;if(_0x8245c2)return JSON[_0x5d1a50(0x199)](_0x1d418a);let _0x35c2ab=L(_0x1d418a[_0x5d1a50(0x18b)],_0x5d1a50(0x1ad)),_0x41d074=L(_0x1d418a['task_id'],_0x5d1a50(0x1e1)),_0x1d61e3=_0x1d418a[_0x5d1a50(0x1e6)]?_0x5d1a50(0x1e9)+_0x1d418a[_0x5d1a50(0x1e6)]+':'+(_0x1d418a['error_message']??''):'';return _0x5d1a50(0x18e)+_0x1d418a[_0x5d1a50(0x19b)]+'\x20from='+L(_0x1d418a[_0x5d1a50(0x189)],_0x5d1a50(0x19d))+'\x20to='+L(_0x1d418a[_0x5d1a50(0x16f)],_0x5d1a50(0x19d))+_0x5d1a50(0x175)+_0x41d074+_0x5d1a50(0x1af)+_0x35c2ab+_0x5d1a50(0x1a1)+L(_0x1d418a['network_id'],_0x5d1a50(0x19d))+_0x5d1a50(0x1c6)+_0x1d418a[_0x5d1a50(0x1a7)]+'\x20duration_ms='+_0x1d418a[_0x5d1a50(0x193)]+_0x5d1a50(0x1c9)+_0x1d418a[_0x5d1a50(0x1c5)]+_0x1d61e3;}function a0_0x9a13(){const _0x2830c5=['231GIglRz','sdk','4006mxQvkc','from_alias','signal','parent_task_id','not_tracked','delivered','[commhub:task]\x20','normal','task.replied','mcp_http','broadcast','duration_ms','networkId','connected','AbortError','json','task.send.delivered','stringify','failed','status','application/json,\x20text/event-stream','<unknown>','unknown\x20error','catch','messages','\x20network_id=','processInbox','task_id','lifecycleTracking','sleep','error','transport','task.ack','SSE\x20connected','decode','9789ulwsQJ','match','<missing>','send_task','\x20parent_task_id=','connectSSE','completed','resumeId','call','CommHub\x20response\x20omitted\x20task_id','654BYeAvX','24642444NdAWVf','task.expired','emit','task','text/event-stream','398060XSnUfF','content','11564136lebJaN','SSE\x20failed:\x20','send_reply','registered','send_failed','parse','cwd','alias','lifecycle_tracking','\x20transport=','message','idle','\x20lifecycle=','parentTaskId','send_message','pop','reconnectDelay','send','token','POST','82049eAlPEj','heartbeatInterval','text','tools/call','/mcp','send_rejected','heartbeat\x20failed:\x20','connect','72344QgloPw','disconnected','s...','startsWith','sseAbort','652CFlFdk','running','split','<pending>','url','new_message','inbox\x20error:\x20','410trUCSU','error_code','ack_inbox','SSE\x20reconnecting\x20in\x20','\x20error=','get_inbox','sdk-','to_alias','body','now','replace','12YSDbRp','getAllStatus','\x20task_id=','from_session','type','2.0','slice','Bearer\x20','heartbeatTimer','message_id','Authorization','string','disconnect','agent','13VlHEYb',']\x20[commhub:','log','task.send.failed','getReader'];a0_0x9a13=function(){return _0x2830c5;};return a0_0x9a13();}function U(_0x2ddd22){const _0x4d7772=a0_0x4bafa8;return{'event':{'sending':'task.send.start','delivered':_0x4d7772(0x198),'failed':_0x4d7772(0x184),'acked':_0x4d7772(0x1a8),'started':'task.started','replied':_0x4d7772(0x190),'expired':_0x4d7772(0x1b7)}[_0x2ddd22['status']],..._0x2ddd22};}function j(_0x285d05){const _0x48daf7=a0_0x4bafa8;let _0x4850f0=_0x285d05?.[_0x48daf7(0x1a3)]||_0x285d05?.[_0x48daf7(0x17c)]||_0x285d05?.['id'];if(_0x4850f0)return String(_0x4850f0);let _0x671a1d=_0x285d05?.['content']?.[0x0]?.[_0x48daf7(0x1d3)];if(typeof _0x671a1d!==_0x48daf7(0x17e))return null;try{let _0x252119=JSON[_0x48daf7(0x1c2)](_0x671a1d);return _0x252119?.['task_id']||_0x252119?.[_0x48daf7(0x17c)]||_0x252119?.['id']||null;}catch{return null;}}async function X(_0xbaaaaf,_0x22258e){const _0x2a03c7=a0_0x4bafa8;let _0x28ddf7=_0x22258e[_0x2a03c7(0x171)]??Date[_0x2a03c7(0x171)],_0x52105f=_0x28ddf7(),_0x29947=(_0x1527e3,_0x109547,_0x85e226,_0xfa6a56)=>{const _0x4e5c42=_0x2a03c7;_0x22258e[_0x4e5c42(0x183)](O(U({'from_alias':_0xbaaaaf['fromAlias'],'to_alias':_0xbaaaaf['toAlias'],'task_id':_0x109547,'parent_task_id':_0xbaaaaf[_0x4e5c42(0x1ca)],'network_id':_0xbaaaaf[_0x4e5c42(0x194)],'transport':_0xbaaaaf[_0x4e5c42(0x1a7)],'status':_0x1527e3,'duration_ms':_0x28ddf7()-_0x52105f,'lifecycle_tracking':_0xbaaaaf[_0x4e5c42(0x1a4)],..._0x85e226!==void 0x0?{'error_code':_0xfa6a56||_0x4e5c42(0x1c1),'error_message':N(_0x85e226)}:{}})));};_0x29947('sending',null);try{let _0x574cf5=await _0x22258e[_0x2a03c7(0x1ce)](),_0x4543e8=j(_0x574cf5);if(_0x4543e8)_0x29947(_0x2a03c7(0x18d),_0x4543e8);else{if(_0x574cf5?.['ok']===!0x1||_0x574cf5?.[_0x2a03c7(0x1a6)])_0x29947(_0x2a03c7(0x19a),_0x4543e8,_0x574cf5?.[_0x2a03c7(0x1a6)]||'CommHub\x20rejected\x20task',_0x2a03c7(0x1d6));else _0x29947(_0x2a03c7(0x19a),null,_0x2a03c7(0x1b4),'missing_task_id');}return _0x574cf5;}catch(_0x4612e8){throw _0x29947(_0x2a03c7(0x19a),null,_0x4612e8,'send_failed'),_0x4612e8;}}async function Y(_0x36c523,_0x8c14d5){const _0x55c4f9=a0_0x4bafa8;return X({'fromAlias':_0x36c523['fromAlias'],'toAlias':_0x36c523[_0x55c4f9(0x1c4)],'parentTaskId':_0x36c523[_0x55c4f9(0x1ca)]||null,'networkId':_0x36c523[_0x55c4f9(0x194)]||null,'transport':_0x55c4f9(0x191),'lifecycleTracking':_0x55c4f9(0x18c)},_0x8c14d5);}class $ extends a0_0x59605c{[a0_0x4bafa8(0x1e2)];['alias'];[a0_0x4bafa8(0x1cf)];[a0_0x4bafa8(0x180)];['resumeId'];['heartbeatInterval'];[a0_0x4bafa8(0x1cd)];[a0_0x4bafa8(0x17b)];[a0_0x4bafa8(0x1dd)];[a0_0x4bafa8(0x1df)]=!0x1;constructor(_0x5ec976){const _0x1ee2a3=a0_0x4bafa8;super();if(this[_0x1ee2a3(0x1e2)]=_0x5ec976[_0x1ee2a3(0x1e2)]['replace'](/\/$/,''),this['alias']=_0x5ec976[_0x1ee2a3(0x1c4)],this[_0x1ee2a3(0x1cf)]=_0x5ec976[_0x1ee2a3(0x1cf)],this[_0x1ee2a3(0x180)]=_0x5ec976[_0x1ee2a3(0x180)]||_0x1ee2a3(0x187),this[_0x1ee2a3(0x1b2)]=_0x1ee2a3(0x16e)+_0x5ec976[_0x1ee2a3(0x1c4)]+'-'+Date[_0x1ee2a3(0x171)]()['toString'](0x24),this['heartbeatInterval']=_0x5ec976[_0x1ee2a3(0x1d2)]??0x2bf20,this[_0x1ee2a3(0x1cd)]=_0x5ec976['reconnectDelay']??0xbb8,_0x5ec976['autoConnect']!==!0x1)this['connect']();}[a0_0x4bafa8(0x183)](_0x419303){const _0x18e13d=a0_0x4bafa8;console[_0x18e13d(0x183)]('['+new Date()['toTimeString']()[_0x18e13d(0x179)](0x0,0x8)+_0x18e13d(0x182)+this[_0x18e13d(0x1c4)]+']\x20'+_0x419303);}async[a0_0x4bafa8(0x1b3)](_0x150364,_0x11bcaa){const _0x3ac380=a0_0x4bafa8;let _0x3e2d13={'Content-Type':'application/json','Accept':_0x3ac380(0x19c)};if(this[_0x3ac380(0x1cf)])_0x3e2d13[_0x3ac380(0x17d)]=_0x3ac380(0x17a)+this[_0x3ac380(0x1cf)];let _0x4fe97d=await(await fetch(this[_0x3ac380(0x1e2)]+_0x3ac380(0x1d5),{'method':_0x3ac380(0x1d0),'headers':_0x3e2d13,'body':JSON[_0x3ac380(0x199)]({'jsonrpc':_0x3ac380(0x178),'id':Date['now'](),'method':_0x3ac380(0x1d4),'params':{'name':_0x150364,'arguments':_0x11bcaa}})}))[_0x3ac380(0x1d3)](),_0x1f00b2=_0x4fe97d[_0x3ac380(0x1ac)](/data: (.+)/),_0x2335f7=_0x1f00b2?JSON[_0x3ac380(0x1c2)](_0x1f00b2[0x1]):JSON[_0x3ac380(0x1c2)](_0x4fe97d),_0x2e277e=_0x2335f7?.['result']?.[_0x3ac380(0x1bc)]?.[0x0]?.[_0x3ac380(0x1d3)];return _0x2e277e?JSON['parse'](_0x2e277e):_0x2335f7;}async[a0_0x4bafa8(0x1d8)](){const _0x43b052=a0_0x4bafa8;if(this[_0x43b052(0x1df)])return;this[_0x43b052(0x1df)]=!0x0,await this['status'](_0x43b052(0x1c8)),this[_0x43b052(0x183)](_0x43b052(0x1c0)),this[_0x43b052(0x17b)]=setInterval(()=>{const _0x1ae2c3=_0x43b052;this[_0x1ae2c3(0x19b)](_0x1ae2c3(0x1c8))[_0x1ae2c3(0x19f)](_0x4f2af1=>this[_0x1ae2c3(0x183)](_0x1ae2c3(0x1d7)+_0x4f2af1[_0x1ae2c3(0x1c7)]));},this['heartbeatInterval']),this[_0x43b052(0x1b0)]();}async[a0_0x4bafa8(0x17f)](){const _0x36559f=a0_0x4bafa8;if(this[_0x36559f(0x1df)]=!0x1,this[_0x36559f(0x1dd)]?.['abort'](),this[_0x36559f(0x17b)])clearInterval(this[_0x36559f(0x17b)]);await this['status']('offline')['catch'](()=>{}),this[_0x36559f(0x183)]('disconnected');}async[a0_0x4bafa8(0x1ce)](_0x424513,_0x5aacf3,_0x33f0f0=a0_0x4bafa8(0x18f)){const _0x3a9e7a=a0_0x4bafa8;return Y({'alias':_0x424513,'fromAlias':this[_0x3a9e7a(0x1c4)]},{'log':_0x449526=>console[_0x3a9e7a(0x183)](_0x449526),'send':()=>this[_0x3a9e7a(0x1b3)](_0x3a9e7a(0x1ae),{'alias':_0x424513,'task':_0x5aacf3,'priority':_0x33f0f0,'from_session':this[_0x3a9e7a(0x1c4)]})});}async['message'](_0x5a6a47,_0xc86cf2){const _0x462919=a0_0x4bafa8;return this['call'](_0x462919(0x1cb),{'alias':_0x5a6a47,'message':_0xc86cf2,'from_session':this[_0x462919(0x1c4)]});}async['reply'](_0x1bbe0b,_0x4d35d8,_0x272584=a0_0x4bafa8(0x1b1)){const _0x14ed27=a0_0x4bafa8;return this[_0x14ed27(0x1b3)](_0x14ed27(0x1bf),{'in_reply_to':_0x1bbe0b,'text':_0x4d35d8,'status':_0x272584});}async[a0_0x4bafa8(0x19b)](_0x1eb430,_0x4d4f6a){const _0x59fce4=a0_0x4bafa8;return this[_0x59fce4(0x1b3)]('report_status',{'resume_id':this['resumeId'],'alias':this[_0x59fce4(0x1c4)],'status':_0x1eb430,'server':a0_0x37c631(),'hostname':a0_0x37c631(),'agent':this[_0x59fce4(0x180)],'project_dir':process[_0x59fce4(0x1c3)](),..._0x4d4f6a});}async[a0_0x4bafa8(0x174)](){const _0x4ae976=a0_0x4bafa8;return this[_0x4ae976(0x1b3)]('get_all_status',{});}async[a0_0x4bafa8(0x192)](_0x13adad,_0x318360){const _0x140c4=a0_0x4bafa8;return this[_0x140c4(0x1b3)](_0x140c4(0x192),{'message':_0x13adad,'filter_server':_0x318360?.['server'],'filter_status':_0x318360?.[_0x140c4(0x19b)]});}async[a0_0x4bafa8(0x1b0)](){const _0x533a69=a0_0x4bafa8;let _0x284025=encodeURIComponent(this[_0x533a69(0x1c4)]),_0x2f5e88=this[_0x533a69(0x1e2)]+'/events/'+_0x284025,_0xe3b1fd=this[_0x533a69(0x1cd)];while(this[_0x533a69(0x1df)]){try{this[_0x533a69(0x1dd)]=new AbortController();let _0x2fde69={'Accept':_0x533a69(0x1ba)};if(this[_0x533a69(0x1cf)])_0x2fde69[_0x533a69(0x17d)]=_0x533a69(0x17a)+this[_0x533a69(0x1cf)];let _0x379b3d=await fetch(_0x2f5e88,{'headers':_0x2fde69,'signal':this[_0x533a69(0x1dd)][_0x533a69(0x18a)]});if(!_0x379b3d['ok']||!_0x379b3d['body']){this[_0x533a69(0x183)](_0x533a69(0x1be)+_0x379b3d[_0x533a69(0x19b)]),await this['sleep'](_0xe3b1fd),_0xe3b1fd=Math['min'](_0xe3b1fd*1.5,0xea60);continue;}_0xe3b1fd=this['reconnectDelay'];let _0x27b566=_0x379b3d[_0x533a69(0x170)][_0x533a69(0x185)](),_0x434fcd=new TextDecoder(),_0x58c9b5='';while(this[_0x533a69(0x1df)]){let {done:_0x46c981,value:_0x549e43}=await _0x27b566['read']();if(_0x46c981)break;_0x58c9b5+=_0x434fcd[_0x533a69(0x1aa)](_0x549e43,{'stream':!0x0});let _0x171388=_0x58c9b5[_0x533a69(0x1e0)]('\x0a');_0x58c9b5=_0x171388[_0x533a69(0x1cc)]()||'';for(let _0xe1fa20 of _0x171388){if(!_0xe1fa20[_0x533a69(0x1dc)]('data:\x20'))continue;try{let _0x4567f1=JSON['parse'](_0xe1fa20['slice'](0x6));if(_0x4567f1[_0x533a69(0x177)]===_0x533a69(0x195)){this[_0x533a69(0x183)](_0x533a69(0x1a9)),this[_0x533a69(0x1b8)](_0x533a69(0x195));continue;}if(_0x4567f1[_0x533a69(0x177)]==='new_task'||_0x4567f1['type']===_0x533a69(0x1e3)||_0x4567f1[_0x533a69(0x177)]==='broadcast')await this[_0x533a69(0x1a2)]();}catch{}}}}catch(_0x14be2b){if(_0x14be2b['name']===_0x533a69(0x196))break;this[_0x533a69(0x1b8)](_0x533a69(0x1a6),_0x14be2b),this['log']('SSE\x20error:\x20'+_0x14be2b[_0x533a69(0x1c7)]);}if(this['running'])this['emit'](_0x533a69(0x1da)),this[_0x533a69(0x183)](_0x533a69(0x1e8)+_0xe3b1fd/0x3e8+_0x533a69(0x1db)),await this['sleep'](_0xe3b1fd),_0xe3b1fd=Math['min'](_0xe3b1fd*1.5,0xea60);}}async[a0_0x4bafa8(0x1a2)](){const _0x4efed8=a0_0x4bafa8;try{let _0x2bbef4=(await this['call'](_0x4efed8(0x1ea),{'alias':this[_0x4efed8(0x1c4)],'limit':0xa}))?.[_0x4efed8(0x1a0)]||[];for(let _0x29661c of _0x2bbef4)await this[_0x4efed8(0x1b3)](_0x4efed8(0x1e7),{'alias':this[_0x4efed8(0x1c4)],'message_id':_0x29661c['id']}),this[_0x4efed8(0x183)]('←\x20'+_0x29661c[_0x4efed8(0x176)]+':\x20'+_0x29661c['content'][_0x4efed8(0x179)](0x0,0x3c)),this[_0x4efed8(0x1b8)](_0x4efed8(0x1b9),_0x29661c),this[_0x4efed8(0x1b8)]('message',_0x29661c);}catch(_0xd0a5cc){this[_0x4efed8(0x183)](_0x4efed8(0x1e4)+_0xd0a5cc[_0x4efed8(0x1c7)]);}}[a0_0x4bafa8(0x1a5)](_0xfcde18){return new Promise(_0x507b15=>setTimeout(_0x507b15,_0xfcde18));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x1d2064=a0_0x1266;(function(_0x180b91,_0x148ca8){const _0x150974=a0_0x1266,_0x233117=_0x180b91();while(!![]){try{const _0x1c70c2=-parseInt(_0x150974(0x183))/0x1*(parseInt(_0x150974(0x154))/0x2)+parseInt(_0x150974(0x10b))/0x3+-parseInt(_0x150974(0x177))/0x4*(-parseInt(_0x150974(0x173))/0x5)+-parseInt(_0x150974(0x180))/0x6+parseInt(_0x150974(0x12c))/0x7*(-parseInt(_0x150974(0x185))/0x8)+parseInt(_0x150974(0x132))/0x9*(parseInt(_0x150974(0x15a))/0xa)+-parseInt(_0x150974(0x144))/0xb;if(_0x1c70c2===_0x148ca8)break;else _0x233117['push'](_0x233117['shift']());}catch(_0x3c2564){_0x233117['push'](_0x233117['shift']());}}}(a0_0x646a,0x52e5a));import{EventEmitter as a0_0xba609b}from'events';import{hostname as a0_0x39f3af}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x176564,_0x230396)=>(_0x176564??_0x230396)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x1d2064(0x15e)](0x0,0xf0);function N(_0xdcc1a6){const _0x29906a=a0_0x1d2064;return(_0xdcc1a6 instanceof Error?_0xdcc1a6[_0x29906a(0x12f)]:String(_0xdcc1a6??_0x29906a(0x178)))[_0x29906a(0x169)](K,_0x29906a(0x112))[_0x29906a(0x169)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x29906a(0x15e)](0x0,0xf0);}function O(_0x2841e2,_0x19f5a7=process.env.ANET_TASK_TRACE_FORMAT===a0_0x1d2064(0x12e)){const _0x3c368c=a0_0x1d2064;if(_0x19f5a7)return JSON[_0x3c368c(0x12b)](_0x2841e2);let _0xef2512=L(_0x2841e2[_0x3c368c(0x17e)],_0x3c368c(0x12a)),_0x27927d=L(_0x2841e2[_0x3c368c(0x15b)],_0x3c368c(0x17f)),_0x391ba7=_0x2841e2[_0x3c368c(0x125)]?_0x3c368c(0x118)+_0x2841e2[_0x3c368c(0x125)]+':'+(_0x2841e2['error_message']??''):'';return _0x3c368c(0x124)+_0x2841e2['status']+_0x3c368c(0x158)+L(_0x2841e2[_0x3c368c(0x162)],_0x3c368c(0x152))+_0x3c368c(0x14a)+L(_0x2841e2[_0x3c368c(0x13b)],'<unknown>')+_0x3c368c(0x13f)+_0x27927d+_0x3c368c(0x114)+_0xef2512+_0x3c368c(0x145)+L(_0x2841e2[_0x3c368c(0x150)],'<unknown>')+_0x3c368c(0x142)+_0x2841e2[_0x3c368c(0x168)]+_0x3c368c(0x16b)+_0x2841e2[_0x3c368c(0x11a)]+_0x3c368c(0x138)+_0x2841e2[_0x3c368c(0x113)]+_0x391ba7;}function U(_0x43e9dc){const _0x466699=a0_0x1d2064;return{'event':{'sending':'task.send.start','delivered':'task.send.delivered','failed':'task.send.failed','acked':_0x466699(0x136),'started':_0x466699(0x115),'replied':_0x466699(0x13d),'expired':'task.expired'}[_0x43e9dc['status']],..._0x43e9dc};}function a0_0x646a(){const _0x2859e0=['emit','[REDACTED]','lifecycle_tracking','\x20parent_task_id=','task.started','offline','running','\x20error=','send_rejected','duration_ms','send_failed','SSE\x20error:\x20','new_task','tools/call','min','processInbox','application/json','data:\x20','string','[commhub:task]\x20','error_code','s...','url','connectSSE','heartbeatInterval','<missing>','stringify','21ryKVsT','toString','json','message','/mcp','/events/','45RklLOC','send_task','decode','send_reply','task.ack','disconnect','\x20lifecycle=','text/event-stream','missing_task_id','to_alias','call','task.replied','networkId','\x20task_id=','delivered','registered','\x20transport=','sleep','1535644WxYkdZ','\x20network_id=','body','reconnectDelay','get_all_status','not_tracked','\x20to=','cwd','token','error','broadcast','getReader','network_id','connect','<unknown>','sdk','14JEtBep','autoConnect','signal','CommHub\x20response\x20omitted\x20task_id','\x20from=','type','1151180gmTGNX','task_id','SSE\x20connected','agent','slice','split','resumeId','result','from_alias','get_inbox','log','sdk-','failed','now','transport','replace','heartbeatTimer','\x20duration_ms=','parentTaskId','send','new_message','fromAlias','sending','text','POST','557365PTwSXB','content','abort','SSE\x20reconnecting\x20in\x20','4Qpowix','unknown\x20error','report_status','Authorization','status','getAllStatus','application/json,\x20text/event-stream','parent_task_id','<pending>','2686524OyplFV','parse','2.0','2258fDxLGW','sseAbort','697832gYgJUm','ack_inbox','idle','lifecycleTracking','match','read','toAlias','Bearer\x20','messages','completed','1552002NIDIIr','connected','send_message','alias','task','disconnected'];a0_0x646a=function(){return _0x2859e0;};return a0_0x646a();}function j(_0x5c2381){const _0x1f6646=a0_0x1d2064;let _0x4e1dbe=_0x5c2381?.['task_id']||_0x5c2381?.['message_id']||_0x5c2381?.['id'];if(_0x4e1dbe)return String(_0x4e1dbe);let _0x1a6e88=_0x5c2381?.[_0x1f6646(0x174)]?.[0x0]?.['text'];if(typeof _0x1a6e88!==_0x1f6646(0x123))return null;try{let _0x282af6=JSON[_0x1f6646(0x181)](_0x1a6e88);return _0x282af6?.[_0x1f6646(0x15b)]||_0x282af6?.['message_id']||_0x282af6?.['id']||null;}catch{return null;}}function a0_0x1266(_0x39a0c9,_0x5949ba){_0x39a0c9=_0x39a0c9-0x103;const _0x646acf=a0_0x646a();let _0x1266e4=_0x646acf[_0x39a0c9];return _0x1266e4;}async function X(_0x4b2073,_0x436f21){const _0x1dd640=a0_0x1d2064;let _0x32b876=_0x436f21[_0x1dd640(0x167)]??Date[_0x1dd640(0x167)],_0x26d543=_0x32b876(),_0x88c677=(_0x4afcd9,_0x3d7cf7,_0x8f99ac,_0x163e39)=>{const _0xd19f4c=_0x1dd640;_0x436f21['log'](O(U({'from_alias':_0x4b2073[_0xd19f4c(0x16f)],'to_alias':_0x4b2073[_0xd19f4c(0x107)],'task_id':_0x3d7cf7,'parent_task_id':_0x4b2073[_0xd19f4c(0x16c)],'network_id':_0x4b2073['networkId'],'transport':_0x4b2073[_0xd19f4c(0x168)],'status':_0x4afcd9,'duration_ms':_0x32b876()-_0x26d543,'lifecycle_tracking':_0x4b2073[_0xd19f4c(0x104)],..._0x8f99ac!==void 0x0?{'error_code':_0x163e39||'send_failed','error_message':N(_0x8f99ac)}:{}})));};_0x88c677(_0x1dd640(0x170),null);try{let _0x40745f=await _0x436f21[_0x1dd640(0x16d)](),_0x43d890=j(_0x40745f);if(_0x43d890)_0x88c677(_0x1dd640(0x140),_0x43d890);else{if(_0x40745f?.['ok']===!0x1||_0x40745f?.[_0x1dd640(0x14d)])_0x88c677(_0x1dd640(0x166),_0x43d890,_0x40745f?.[_0x1dd640(0x14d)]||'CommHub\x20rejected\x20task',_0x1dd640(0x119));else _0x88c677('failed',null,_0x1dd640(0x157),_0x1dd640(0x13a));}return _0x40745f;}catch(_0x45245a){throw _0x88c677(_0x1dd640(0x166),null,_0x45245a,_0x1dd640(0x11b)),_0x45245a;}}async function Y(_0x87284f,_0x427af5){const _0x345106=a0_0x1d2064;return X({'fromAlias':_0x87284f['fromAlias'],'toAlias':_0x87284f[_0x345106(0x10e)],'parentTaskId':_0x87284f[_0x345106(0x16c)]||null,'networkId':_0x87284f[_0x345106(0x13e)]||null,'transport':'mcp_http','lifecycleTracking':_0x345106(0x149)},_0x427af5);}class $ extends a0_0xba609b{['url'];[a0_0x1d2064(0x10e)];['token'];['agent'];[a0_0x1d2064(0x160)];[a0_0x1d2064(0x129)];[a0_0x1d2064(0x147)];[a0_0x1d2064(0x16a)];[a0_0x1d2064(0x184)];[a0_0x1d2064(0x117)]=!0x1;constructor(_0x3cbf34){const _0x4f27ac=a0_0x1d2064;super();if(this[_0x4f27ac(0x127)]=_0x3cbf34[_0x4f27ac(0x127)][_0x4f27ac(0x169)](/\/$/,''),this[_0x4f27ac(0x10e)]=_0x3cbf34[_0x4f27ac(0x10e)],this[_0x4f27ac(0x14c)]=_0x3cbf34[_0x4f27ac(0x14c)],this[_0x4f27ac(0x15d)]=_0x3cbf34[_0x4f27ac(0x15d)]||_0x4f27ac(0x153),this[_0x4f27ac(0x160)]=_0x4f27ac(0x165)+_0x3cbf34[_0x4f27ac(0x10e)]+'-'+Date[_0x4f27ac(0x167)]()[_0x4f27ac(0x12d)](0x24),this[_0x4f27ac(0x129)]=_0x3cbf34[_0x4f27ac(0x129)]??0x2bf20,this[_0x4f27ac(0x147)]=_0x3cbf34[_0x4f27ac(0x147)]??0xbb8,_0x3cbf34[_0x4f27ac(0x155)]!==!0x1)this[_0x4f27ac(0x151)]();}['log'](_0x4fd95b){const _0x1ccd77=a0_0x1d2064;console['log']('['+new Date()['toTimeString']()[_0x1ccd77(0x15e)](0x0,0x8)+']\x20[commhub:'+this['alias']+']\x20'+_0x4fd95b);}async['call'](_0x31d49a,_0x52b12a){const _0x42945e=a0_0x1d2064;let _0x5af303={'Content-Type':_0x42945e(0x121),'Accept':_0x42945e(0x17d)};if(this[_0x42945e(0x14c)])_0x5af303[_0x42945e(0x17a)]=_0x42945e(0x108)+this[_0x42945e(0x14c)];let _0x4c8213=await(await fetch(this[_0x42945e(0x127)]+_0x42945e(0x130),{'method':_0x42945e(0x172),'headers':_0x5af303,'body':JSON[_0x42945e(0x12b)]({'jsonrpc':_0x42945e(0x182),'id':Date[_0x42945e(0x167)](),'method':_0x42945e(0x11e),'params':{'name':_0x31d49a,'arguments':_0x52b12a}})}))[_0x42945e(0x171)](),_0x4a552d=_0x4c8213[_0x42945e(0x105)](/data: (.+)/),_0x19a50b=_0x4a552d?JSON[_0x42945e(0x181)](_0x4a552d[0x1]):JSON[_0x42945e(0x181)](_0x4c8213),_0xc06a07=_0x19a50b?.[_0x42945e(0x161)]?.[_0x42945e(0x174)]?.[0x0]?.[_0x42945e(0x171)];return _0xc06a07?JSON['parse'](_0xc06a07):_0x19a50b;}async['connect'](){const _0x12c255=a0_0x1d2064;if(this[_0x12c255(0x117)])return;this[_0x12c255(0x117)]=!0x0,await this[_0x12c255(0x17b)]('idle'),this[_0x12c255(0x164)](_0x12c255(0x141)),this[_0x12c255(0x16a)]=setInterval(()=>{const _0xdcd6a0=_0x12c255;this[_0xdcd6a0(0x17b)](_0xdcd6a0(0x103))['catch'](_0x1d1eab=>this['log']('heartbeat\x20failed:\x20'+_0x1d1eab['message']));},this[_0x12c255(0x129)]),this[_0x12c255(0x128)]();}async[a0_0x1d2064(0x137)](){const _0x49efa6=a0_0x1d2064;if(this[_0x49efa6(0x117)]=!0x1,this['sseAbort']?.[_0x49efa6(0x175)](),this[_0x49efa6(0x16a)])clearInterval(this['heartbeatTimer']);await this['status'](_0x49efa6(0x116))['catch'](()=>{}),this[_0x49efa6(0x164)](_0x49efa6(0x110));}async[a0_0x1d2064(0x16d)](_0x1539ac,_0x3f8c99,_0x161c2f='normal'){const _0x29883a=a0_0x1d2064;return Y({'alias':_0x1539ac,'fromAlias':this[_0x29883a(0x10e)]},{'log':_0x21a8e3=>console[_0x29883a(0x164)](_0x21a8e3),'send':()=>this[_0x29883a(0x13c)](_0x29883a(0x133),{'alias':_0x1539ac,'task':_0x3f8c99,'priority':_0x161c2f,'from_session':this['alias']})});}async[a0_0x1d2064(0x12f)](_0x55cf87,_0x51e982){const _0x59f179=a0_0x1d2064;return this[_0x59f179(0x13c)](_0x59f179(0x10d),{'alias':_0x55cf87,'message':_0x51e982,'from_session':this[_0x59f179(0x10e)]});}async['reply'](_0x3ce911,_0x537bf5,_0x2e802f=a0_0x1d2064(0x10a)){const _0x534ab8=a0_0x1d2064;return this[_0x534ab8(0x13c)](_0x534ab8(0x135),{'in_reply_to':_0x3ce911,'text':_0x537bf5,'status':_0x2e802f});}async['status'](_0x1abab2,_0x2ffc54){const _0x46f760=a0_0x1d2064;return this['call'](_0x46f760(0x179),{'resume_id':this['resumeId'],'alias':this[_0x46f760(0x10e)],'status':_0x1abab2,'server':a0_0x39f3af(),'hostname':a0_0x39f3af(),'agent':this['agent'],'project_dir':process[_0x46f760(0x14b)](),..._0x2ffc54});}async[a0_0x1d2064(0x17c)](){const _0x29922f=a0_0x1d2064;return this[_0x29922f(0x13c)](_0x29922f(0x148),{});}async[a0_0x1d2064(0x14e)](_0x2b8f6f,_0x151049){const _0x47f4d0=a0_0x1d2064;return this[_0x47f4d0(0x13c)](_0x47f4d0(0x14e),{'message':_0x2b8f6f,'filter_server':_0x151049?.['server'],'filter_status':_0x151049?.['status']});}async[a0_0x1d2064(0x128)](){const _0x538b00=a0_0x1d2064;let _0x1c2e2e=encodeURIComponent(this['alias']),_0x11dc47=this[_0x538b00(0x127)]+_0x538b00(0x131)+_0x1c2e2e,_0x526054=this['reconnectDelay'];while(this[_0x538b00(0x117)]){try{this['sseAbort']=new AbortController();let _0x2af4d4={'Accept':_0x538b00(0x139)};if(this[_0x538b00(0x14c)])_0x2af4d4[_0x538b00(0x17a)]=_0x538b00(0x108)+this[_0x538b00(0x14c)];let _0x3f987a=await fetch(_0x11dc47,{'headers':_0x2af4d4,'signal':this[_0x538b00(0x184)][_0x538b00(0x156)]});if(!_0x3f987a['ok']||!_0x3f987a['body']){this[_0x538b00(0x164)]('SSE\x20failed:\x20'+_0x3f987a[_0x538b00(0x17b)]),await this[_0x538b00(0x143)](_0x526054),_0x526054=Math[_0x538b00(0x11f)](_0x526054*1.5,0xea60);continue;}_0x526054=this[_0x538b00(0x147)];let _0x241b24=_0x3f987a[_0x538b00(0x146)][_0x538b00(0x14f)](),_0x4f3eff=new TextDecoder(),_0x3cea8e='';while(this['running']){let {done:_0x34fb27,value:_0x7d2147}=await _0x241b24[_0x538b00(0x106)]();if(_0x34fb27)break;_0x3cea8e+=_0x4f3eff[_0x538b00(0x134)](_0x7d2147,{'stream':!0x0});let _0x16ab31=_0x3cea8e[_0x538b00(0x15f)]('\x0a');_0x3cea8e=_0x16ab31['pop']()||'';for(let _0x4d5a85 of _0x16ab31){if(!_0x4d5a85['startsWith'](_0x538b00(0x122)))continue;try{let _0x22cd71=JSON[_0x538b00(0x181)](_0x4d5a85[_0x538b00(0x15e)](0x6));if(_0x22cd71[_0x538b00(0x159)]===_0x538b00(0x10c)){this[_0x538b00(0x164)](_0x538b00(0x15c)),this[_0x538b00(0x111)](_0x538b00(0x10c));continue;}if(_0x22cd71[_0x538b00(0x159)]===_0x538b00(0x11d)||_0x22cd71[_0x538b00(0x159)]===_0x538b00(0x16e)||_0x22cd71[_0x538b00(0x159)]===_0x538b00(0x14e))await this[_0x538b00(0x120)]();}catch{}}}}catch(_0xaab24b){if(_0xaab24b['name']==='AbortError')break;this['emit']('error',_0xaab24b),this[_0x538b00(0x164)](_0x538b00(0x11c)+_0xaab24b['message']);}if(this[_0x538b00(0x117)])this[_0x538b00(0x111)](_0x538b00(0x110)),this[_0x538b00(0x164)](_0x538b00(0x176)+_0x526054/0x3e8+_0x538b00(0x126)),await this[_0x538b00(0x143)](_0x526054),_0x526054=Math[_0x538b00(0x11f)](_0x526054*1.5,0xea60);}}async[a0_0x1d2064(0x120)](){const _0x24b28e=a0_0x1d2064;try{let _0x493349=(await this[_0x24b28e(0x13c)](_0x24b28e(0x163),{'alias':this[_0x24b28e(0x10e)],'limit':0xa}))?.[_0x24b28e(0x109)]||[];for(let _0xce7b95 of _0x493349)await this[_0x24b28e(0x13c)](_0x24b28e(0x186),{'alias':this[_0x24b28e(0x10e)],'message_id':_0xce7b95['id']}),this[_0x24b28e(0x164)]('←\x20'+_0xce7b95['from_session']+':\x20'+_0xce7b95[_0x24b28e(0x174)][_0x24b28e(0x15e)](0x0,0x3c)),this[_0x24b28e(0x111)](_0x24b28e(0x10f),_0xce7b95),this[_0x24b28e(0x111)]('message',_0xce7b95);}catch(_0x57c5aa){this[_0x24b28e(0x164)]('inbox\x20error:\x20'+_0x57c5aa[_0x24b28e(0x12f)]);}}['sleep'](_0xf639b4){return new Promise(_0x2c98a7=>setTimeout(_0x2c98a7,_0xf639b4));}}var F=$;export{F as default,$ as CommHub};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** Per-node record, written into the node dir next to the other state files. */
|
|
2
|
+
export declare const CODEX_AUTH_FINGERPRINT_FILE = ".codex-auth-fingerprint.json";
|
|
3
|
+
/** Length of the stored fingerprint. Collisions at 8 hex are ~1 in 4 billion;
|
|
4
|
+
* a false "these two share a login" warning costs a second look, while the
|
|
5
|
+
* value staying short keeps it obviously non-reversible in logs. */
|
|
6
|
+
export declare const FINGERPRINT_LENGTH = 8;
|
|
7
|
+
export interface CodexAuthFingerprintRecord {
|
|
8
|
+
readonly schema_version: 1;
|
|
9
|
+
readonly alias: string;
|
|
10
|
+
/** sha256(refresh_token) truncated — never the token. */
|
|
11
|
+
readonly fingerprint: string;
|
|
12
|
+
readonly written_at: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Hash the refresh token out of an auth.json body.
|
|
16
|
+
*
|
|
17
|
+
* Accepts both shapes seen in the wild: the current codex layout nests it
|
|
18
|
+
* under `tokens` (`{auth_mode, tokens:{id_token, access_token, refresh_token,
|
|
19
|
+
* account_id}, last_refresh}`), and older/plain bodies put `refresh_token` at
|
|
20
|
+
* the top level. Anything else — unparsable, absent, empty, non-string —
|
|
21
|
+
* returns null, because "we cannot tell" must not be reported as "no
|
|
22
|
+
* collision".
|
|
23
|
+
*/
|
|
24
|
+
export declare function fingerprintRefreshToken(authJsonText: string): string | null;
|
|
25
|
+
export interface NodeFingerprint {
|
|
26
|
+
readonly alias: string;
|
|
27
|
+
/** null when the node has no auth.json, or one we could not read. */
|
|
28
|
+
readonly fingerprint: string | null;
|
|
29
|
+
/** When the record was written; used to say how stale a claim is. */
|
|
30
|
+
readonly writtenAt?: string | null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Other nodes holding the same credential chain as `self`.
|
|
34
|
+
*
|
|
35
|
+
* Records with no fingerprint are skipped rather than grouped: "unknown" is
|
|
36
|
+
* not a match. Self is excluded by alias, so re-reading one's own record is
|
|
37
|
+
* harmless.
|
|
38
|
+
*/
|
|
39
|
+
export declare function collidingNodes(records: readonly NodeFingerprint[], self: NodeFingerprint): NodeFingerprint[];
|
|
40
|
+
/**
|
|
41
|
+
* The warning an operator sees at start. Returns [] when nothing collides —
|
|
42
|
+
* callers print exactly what they get, so silence is representable and the
|
|
43
|
+
* "no collision" path cannot accidentally print a scary empty banner.
|
|
44
|
+
*
|
|
45
|
+
* Deliberately a warning and never a refusal: every node on a host shares one
|
|
46
|
+
* login today, so refusing to start would take the whole box down at once
|
|
47
|
+
* over a condition that is survivable until the next refresh.
|
|
48
|
+
*/
|
|
49
|
+
export declare function sharedCredentialWarningLines(self: NodeFingerprint, colliding: readonly NodeFingerprint[]): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Two different things both read as "codex cannot refresh", and they need
|
|
52
|
+
* opposite remedies. Telling them apart is the whole value of this mapping:
|
|
53
|
+
* treating a transport failure as a rotation conflict sends an operator to
|
|
54
|
+
* copy someone else's auth.json, which is precisely how a shared-credential
|
|
55
|
+
* chain gets created.
|
|
56
|
+
*/
|
|
57
|
+
export type CodexRefreshFailureKind =
|
|
58
|
+
/** Someone else spent this refresh token first. */
|
|
59
|
+
"rotation-conflict"
|
|
60
|
+
/** The token endpoint is unreachable — nobody's token is rotating. */
|
|
61
|
+
| "token-endpoint-unreachable";
|
|
62
|
+
export interface CodexRefreshFailure {
|
|
63
|
+
readonly kind: CodexRefreshFailureKind;
|
|
64
|
+
readonly lines: string[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Name what actually went wrong with a codex refresh, and say what to do.
|
|
68
|
+
*
|
|
69
|
+
* Returns null for anything else, so callers fall through to whatever they
|
|
70
|
+
* printed before — an unrelated error must pass through unchanged.
|
|
71
|
+
*
|
|
72
|
+
* Order matters: a reuse rejection is a server answer and is checked first; a
|
|
73
|
+
* transport failure means no answer arrived at all.
|
|
74
|
+
*/
|
|
75
|
+
export declare function describeCodexRefreshFailure(text: string, colliding?: readonly NodeFingerprint[]): CodexRefreshFailure | null;
|