@sleep2agi/agent-network 2.3.0-preview.98 → 2.3.0-preview.99
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_0x5ce150=a0_0x4c89;(function(_0x21ab87,_0x3d289f){const _0x4cf448=a0_0x4c89,_0x40eb47=_0x21ab87();while(!![]){try{const _0x1a7e71=-parseInt(_0x4cf448(0x18e))/0x1+parseInt(_0x4cf448(0x1cd))/0x2+parseInt(_0x4cf448(0x19e))/0x3+-parseInt(_0x4cf448(0x198))/0x4*(-parseInt(_0x4cf448(0x1b8))/0x5)+-parseInt(_0x4cf448(0x1a7))/0x6+parseInt(_0x4cf448(0x1e9))/0x7+-parseInt(_0x4cf448(0x1a1))/0x8*(parseInt(_0x4cf448(0x1c5))/0x9);if(_0x1a7e71===_0x3d289f)break;else _0x40eb47['push'](_0x40eb47['shift']());}catch(_0x5f445b){_0x40eb47['push'](_0x40eb47['shift']());}}}(a0_0x5349,0xa0ae0));import{EventEmitter as a0_0x4b6e45}from'events';import{hostname as a0_0xabc1ad}from'os';function a0_0x4c89(_0x28d206,_0x2bbda6){_0x28d206=_0x28d206-0x182;const _0x534949=a0_0x5349();let _0x4c8921=_0x534949[_0x28d206];return _0x4c8921;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x489f7a,_0x5b86d7)=>(_0x489f7a??_0x5b86d7)[a0_0x5ce150(0x1a3)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5ce150(0x1ac)](0x0,0xf0);function N(_0x1eef63){const _0x1f84b1=a0_0x5ce150;return(_0x1eef63 instanceof Error?_0x1eef63[_0x1f84b1(0x1d5)]:String(_0x1eef63??_0x1f84b1(0x188)))[_0x1f84b1(0x1a3)](K,_0x1f84b1(0x1ae))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x21881f,_0xe95d2d=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5ce150(0x1b1)){const _0x52c4eb=a0_0x5ce150;if(_0xe95d2d)return JSON[_0x52c4eb(0x1ef)](_0x21881f);let _0x375e24=L(_0x21881f['parent_task_id'],_0x52c4eb(0x1d1)),_0x1a9463=L(_0x21881f['task_id'],_0x52c4eb(0x1fa)),_0x39ec6e=_0x21881f[_0x52c4eb(0x192)]?'\x20error='+_0x21881f[_0x52c4eb(0x192)]+':'+(_0x21881f['error_message']??''):'';return _0x52c4eb(0x1b6)+_0x21881f[_0x52c4eb(0x1bf)]+'\x20from='+L(_0x21881f[_0x52c4eb(0x18b)],_0x52c4eb(0x182))+_0x52c4eb(0x1c6)+L(_0x21881f[_0x52c4eb(0x193)],_0x52c4eb(0x182))+_0x52c4eb(0x1dc)+_0x1a9463+'\x20parent_task_id='+_0x375e24+_0x52c4eb(0x1d0)+L(_0x21881f[_0x52c4eb(0x1c4)],_0x52c4eb(0x182))+'\x20transport='+_0x21881f[_0x52c4eb(0x1e3)]+_0x52c4eb(0x1d7)+_0x21881f[_0x52c4eb(0x1cf)]+_0x52c4eb(0x1f0)+_0x21881f[_0x52c4eb(0x1f9)]+_0x39ec6e;}function U(_0x10b219){const _0xf000ac=a0_0x5ce150;return{'event':{'sending':_0xf000ac(0x1a5),'delivered':_0xf000ac(0x18a),'failed':_0xf000ac(0x1dd),'acked':'task.ack','started':_0xf000ac(0x1ed),'replied':_0xf000ac(0x1ec),'expired':'task.expired'}[_0x10b219['status']],..._0x10b219};}function j(_0x27faf0){const _0x447825=a0_0x5ce150;let _0x563c9a=_0x27faf0?.[_0x447825(0x1f5)]||_0x27faf0?.[_0x447825(0x1ab)]||_0x27faf0?.['id'];if(_0x563c9a)return String(_0x563c9a);let _0x51829e=_0x27faf0?.['content']?.[0x0]?.['text'];if(typeof _0x51829e!=='string')return null;try{let _0x49f72b=JSON[_0x447825(0x191)](_0x51829e);return _0x49f72b?.[_0x447825(0x1f5)]||_0x49f72b?.['message_id']||_0x49f72b?.['id']||null;}catch{return null;}}async function X(_0x20f4a4,_0x59f919){const _0x1dc49e=a0_0x5ce150;let _0x1f88c2=_0x59f919[_0x1dc49e(0x1b0)]??Date['now'],_0x22c188=_0x1f88c2(),_0x33cc92=(_0x294cc3,_0x3668c9,_0x38f778,_0x329b6d)=>{const _0x86ed17=_0x1dc49e;_0x59f919['log'](O(U({'from_alias':_0x20f4a4['fromAlias'],'to_alias':_0x20f4a4[_0x86ed17(0x1b7)],'task_id':_0x3668c9,'parent_task_id':_0x20f4a4[_0x86ed17(0x1e8)],'network_id':_0x20f4a4[_0x86ed17(0x190)],'transport':_0x20f4a4[_0x86ed17(0x1e3)],'status':_0x294cc3,'duration_ms':_0x1f88c2()-_0x22c188,'lifecycle_tracking':_0x20f4a4[_0x86ed17(0x1c2)],..._0x38f778!==void 0x0?{'error_code':_0x329b6d||_0x86ed17(0x186),'error_message':N(_0x38f778)}:{}})));};_0x33cc92(_0x1dc49e(0x1d3),null);try{let _0x2e85a9=await _0x59f919[_0x1dc49e(0x1a0)](),_0xda4e78=j(_0x2e85a9);if(_0xda4e78)_0x33cc92(_0x1dc49e(0x1e4),_0xda4e78);else{if(_0x2e85a9?.['ok']===!0x1||_0x2e85a9?.['error'])_0x33cc92(_0x1dc49e(0x1a2),_0xda4e78,_0x2e85a9?.[_0x1dc49e(0x19c)]||_0x1dc49e(0x1e1),_0x1dc49e(0x1d8));else _0x33cc92(_0x1dc49e(0x1a2),null,'CommHub\x20response\x20omitted\x20task_id',_0x1dc49e(0x19a));}return _0x2e85a9;}catch(_0x4fb411){throw _0x33cc92(_0x1dc49e(0x1a2),null,_0x4fb411,_0x1dc49e(0x186)),_0x4fb411;}}async function Y(_0x5e2608,_0x54c36c){const _0xd304bc=a0_0x5ce150;return X({'fromAlias':_0x5e2608['fromAlias'],'toAlias':_0x5e2608[_0xd304bc(0x19b)],'parentTaskId':_0x5e2608[_0xd304bc(0x1e8)]||null,'networkId':_0x5e2608['networkId']||null,'transport':_0xd304bc(0x1e7),'lifecycleTracking':'not_tracked'},_0x54c36c);}class $ extends a0_0x4b6e45{[a0_0x5ce150(0x1d6)];[a0_0x5ce150(0x19b)];['token'];[a0_0x5ce150(0x1bd)];[a0_0x5ce150(0x1ba)];[a0_0x5ce150(0x195)];[a0_0x5ce150(0x1a4)];[a0_0x5ce150(0x1b5)];[a0_0x5ce150(0x1df)];[a0_0x5ce150(0x1c7)]=!0x1;constructor(_0x98701d){const _0x4d60f8=a0_0x5ce150;super();if(this['url']=_0x98701d[_0x4d60f8(0x1d6)][_0x4d60f8(0x1a3)](/\/$/,''),this[_0x4d60f8(0x19b)]=_0x98701d['alias'],this[_0x4d60f8(0x1cb)]=_0x98701d[_0x4d60f8(0x1cb)],this[_0x4d60f8(0x1bd)]=_0x98701d[_0x4d60f8(0x1bd)]||_0x4d60f8(0x1ea),this[_0x4d60f8(0x1ba)]='sdk-'+_0x98701d['alias']+'-'+Date[_0x4d60f8(0x1b0)]()[_0x4d60f8(0x187)](0x24),this[_0x4d60f8(0x195)]=_0x98701d['heartbeatInterval']??0x2bf20,this[_0x4d60f8(0x1a4)]=_0x98701d[_0x4d60f8(0x1a4)]??0xbb8,_0x98701d['autoConnect']!==!0x1)this[_0x4d60f8(0x1b3)]();}[a0_0x5ce150(0x1e2)](_0x5ed5ae){const _0x16b128=a0_0x5ce150;console[_0x16b128(0x1e2)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x16b128(0x1de)+this[_0x16b128(0x19b)]+']\x20'+_0x5ed5ae);}async[a0_0x5ce150(0x184)](_0x22dcc3,_0x3c754c){const _0x5b9b03=a0_0x5ce150;let _0x1c81a4={'Content-Type':'application/json','Accept':_0x5b9b03(0x1c8)};if(this[_0x5b9b03(0x1cb)])_0x1c81a4[_0x5b9b03(0x18f)]=_0x5b9b03(0x19f)+this[_0x5b9b03(0x1cb)];let _0x1cf32a=await(await fetch(this['url']+'/mcp',{'method':'POST','headers':_0x1c81a4,'body':JSON[_0x5b9b03(0x1ef)]({'jsonrpc':_0x5b9b03(0x1c3),'id':Date[_0x5b9b03(0x1b0)](),'method':'tools/call','params':{'name':_0x22dcc3,'arguments':_0x3c754c}})}))[_0x5b9b03(0x1be)](),_0x59f5f3=_0x1cf32a[_0x5b9b03(0x1bb)](/data: (.+)/),_0xe22b83=_0x59f5f3?JSON['parse'](_0x59f5f3[0x1]):JSON[_0x5b9b03(0x191)](_0x1cf32a),_0x2aea2f=_0xe22b83?.[_0x5b9b03(0x1eb)]?.[_0x5b9b03(0x1ce)]?.[0x0]?.[_0x5b9b03(0x1be)];return _0x2aea2f?JSON[_0x5b9b03(0x191)](_0x2aea2f):_0xe22b83;}async['connect'](){const _0x1ab9ea=a0_0x5ce150;if(this[_0x1ab9ea(0x1c7)])return;this[_0x1ab9ea(0x1c7)]=!0x0,await this['status'](_0x1ab9ea(0x1a9)),this[_0x1ab9ea(0x1e2)](_0x1ab9ea(0x1d2)),this[_0x1ab9ea(0x1b5)]=setInterval(()=>{const _0x591a77=_0x1ab9ea;this['status'](_0x591a77(0x1a9))[_0x591a77(0x1f3)](_0x4dc4c8=>this[_0x591a77(0x1e2)]('heartbeat\x20failed:\x20'+_0x4dc4c8['message']));},this[_0x1ab9ea(0x195)]),this[_0x1ab9ea(0x1c0)]();}async['disconnect'](){const _0x1098f7=a0_0x5ce150;if(this[_0x1098f7(0x1c7)]=!0x1,this['sseAbort']?.['abort'](),this['heartbeatTimer'])clearInterval(this[_0x1098f7(0x1b5)]);await this[_0x1098f7(0x1bf)](_0x1098f7(0x1f6))[_0x1098f7(0x1f3)](()=>{}),this['log']('disconnected');}async[a0_0x5ce150(0x1a0)](_0x208463,_0x1823dc,_0x5c7760=a0_0x5ce150(0x197)){const _0x16c310=a0_0x5ce150;return Y({'alias':_0x208463,'fromAlias':this[_0x16c310(0x19b)]},{'log':_0x57e8e1=>console[_0x16c310(0x1e2)](_0x57e8e1),'send':()=>this[_0x16c310(0x184)](_0x16c310(0x194),{'alias':_0x208463,'task':_0x1823dc,'priority':_0x5c7760,'from_session':this[_0x16c310(0x19b)]})});}async[a0_0x5ce150(0x1d5)](_0x2bbb65,_0x5ca9e6){const _0x323824=a0_0x5ce150;return this[_0x323824(0x184)](_0x323824(0x1ad),{'alias':_0x2bbb65,'message':_0x5ca9e6,'from_session':this[_0x323824(0x19b)]});}async[a0_0x5ce150(0x1db)](_0x44823c,_0x576077,_0x1f4ea9='completed'){const _0x5a5aaf=a0_0x5ce150;return this[_0x5a5aaf(0x184)](_0x5a5aaf(0x189),{'in_reply_to':_0x44823c,'text':_0x576077,'status':_0x1f4ea9});}async[a0_0x5ce150(0x1bf)](_0x2897a4,_0x8ce420){const _0xd78f81=a0_0x5ce150;return this['call'](_0xd78f81(0x1af),{'resume_id':this[_0xd78f81(0x1ba)],'alias':this[_0xd78f81(0x19b)],'status':_0x2897a4,'server':a0_0xabc1ad(),'hostname':a0_0xabc1ad(),'agent':this[_0xd78f81(0x1bd)],'project_dir':process['cwd'](),..._0x8ce420});}async[a0_0x5ce150(0x1b9)](){const _0x21a073=a0_0x5ce150;return this[_0x21a073(0x184)](_0x21a073(0x19d),{});}async[a0_0x5ce150(0x18c)](_0x5b2b3d,_0x5358bc){const _0x1aa2c9=a0_0x5ce150;return this[_0x1aa2c9(0x184)](_0x1aa2c9(0x18c),{'message':_0x5b2b3d,'filter_server':_0x5358bc?.[_0x1aa2c9(0x1bc)],'filter_status':_0x5358bc?.[_0x1aa2c9(0x1bf)]});}async[a0_0x5ce150(0x1c0)](){const _0x16ed68=a0_0x5ce150;let _0x47eaf6=encodeURIComponent(this[_0x16ed68(0x19b)]),_0x29b45b=this[_0x16ed68(0x1d6)]+_0x16ed68(0x1da)+_0x47eaf6,_0x343516=this[_0x16ed68(0x1a4)];while(this[_0x16ed68(0x1c7)]){try{this[_0x16ed68(0x1df)]=new AbortController();let _0x5c093f={'Accept':_0x16ed68(0x1ca)};if(this[_0x16ed68(0x1cb)])_0x5c093f[_0x16ed68(0x18f)]=_0x16ed68(0x19f)+this[_0x16ed68(0x1cb)];let _0x3a7b3e=await fetch(_0x29b45b,{'headers':_0x5c093f,'signal':this[_0x16ed68(0x1df)][_0x16ed68(0x185)]});if(!_0x3a7b3e['ok']||!_0x3a7b3e[_0x16ed68(0x1f8)]){this['log'](_0x16ed68(0x1d4)+_0x3a7b3e[_0x16ed68(0x1bf)]),await this['sleep'](_0x343516),_0x343516=Math['min'](_0x343516*1.5,0xea60);continue;}_0x343516=this[_0x16ed68(0x1a4)];let _0x27e596=_0x3a7b3e['body'][_0x16ed68(0x1d9)](),_0x2f35cf=new TextDecoder(),_0x28d283='';while(this[_0x16ed68(0x1c7)]){let {done:_0x42605b,value:_0x2b1afb}=await _0x27e596[_0x16ed68(0x1a6)]();if(_0x42605b)break;_0x28d283+=_0x2f35cf[_0x16ed68(0x1b4)](_0x2b1afb,{'stream':!0x0});let _0x39d8ac=_0x28d283[_0x16ed68(0x1f7)]('\x0a');_0x28d283=_0x39d8ac[_0x16ed68(0x1f2)]()||'';for(let _0xbf586 of _0x39d8ac){if(!_0xbf586[_0x16ed68(0x1e0)]('data:\x20'))continue;try{let _0x49ea99=JSON['parse'](_0xbf586[_0x16ed68(0x1ac)](0x6));if(_0x49ea99[_0x16ed68(0x1a8)]===_0x16ed68(0x183)){this[_0x16ed68(0x1e2)](_0x16ed68(0x1f4)),this[_0x16ed68(0x18d)](_0x16ed68(0x183));continue;}if(_0x49ea99['type']==='new_task'||_0x49ea99[_0x16ed68(0x1a8)]===_0x16ed68(0x196)||_0x49ea99[_0x16ed68(0x1a8)]===_0x16ed68(0x18c))await this[_0x16ed68(0x1e6)]();}catch{}}}}catch(_0x92c90c){if(_0x92c90c[_0x16ed68(0x1c1)]==='AbortError')break;this[_0x16ed68(0x18d)](_0x16ed68(0x19c),_0x92c90c),this[_0x16ed68(0x1e2)](_0x16ed68(0x1c9)+_0x92c90c[_0x16ed68(0x1d5)]);}if(this[_0x16ed68(0x1c7)])this[_0x16ed68(0x18d)](_0x16ed68(0x1b2)),this[_0x16ed68(0x1e2)]('SSE\x20reconnecting\x20in\x20'+_0x343516/0x3e8+_0x16ed68(0x1e5)),await this[_0x16ed68(0x1ee)](_0x343516),_0x343516=Math['min'](_0x343516*1.5,0xea60);}}async[a0_0x5ce150(0x1e6)](){const _0x30e77b=a0_0x5ce150;try{let _0x1331a5=(await this[_0x30e77b(0x184)](_0x30e77b(0x1aa),{'alias':this[_0x30e77b(0x19b)],'limit':0xa}))?.['messages']||[];for(let _0x305ef3 of _0x1331a5)await this['call'](_0x30e77b(0x199),{'alias':this[_0x30e77b(0x19b)],'message_id':_0x305ef3['id']}),this['log']('←\x20'+_0x305ef3['from_session']+':\x20'+_0x305ef3['content'][_0x30e77b(0x1ac)](0x0,0x3c)),this[_0x30e77b(0x18d)](_0x30e77b(0x1cc),_0x305ef3),this['emit'](_0x30e77b(0x1d5),_0x305ef3);}catch(_0x285fad){this[_0x30e77b(0x1e2)](_0x30e77b(0x1f1)+_0x285fad[_0x30e77b(0x1d5)]);}}[a0_0x5ce150(0x1ee)](_0x3e0384){return new Promise(_0x29db68=>setTimeout(_0x29db68,_0x3e0384));}}var F=$;function a0_0x5349(){const _0x4d5e64=['5359314fFYdtX','type','idle','get_inbox','message_id','slice','send_message','[REDACTED]','report_status','now','json','disconnected','connect','decode','heartbeatTimer','[commhub:task]\x20','toAlias','25LEzsGg','getAllStatus','resumeId','match','server','agent','text','status','connectSSE','name','lifecycleTracking','2.0','network_id','9NwxMPN','\x20to=','running','application/json,\x20text/event-stream','SSE\x20error:\x20','text/event-stream','token','task','1740606SfTJmU','content','duration_ms','\x20network_id=','<missing>','registered','sending','SSE\x20failed:\x20','message','url','\x20duration_ms=','send_rejected','getReader','/events/','reply','\x20task_id=','task.send.failed',']\x20[commhub:','sseAbort','startsWith','CommHub\x20rejected\x20task','log','transport','delivered','s...','processInbox','mcp_http','parentTaskId','6356805OiSPtK','sdk','result','task.replied','task.started','sleep','stringify','\x20lifecycle=','inbox\x20error:\x20','pop','catch','SSE\x20connected','task_id','offline','split','body','lifecycle_tracking','<pending>','<unknown>','connected','call','signal','send_failed','toString','unknown\x20error','send_reply','task.send.delivered','from_alias','broadcast','emit','205650YRNAwj','Authorization','networkId','parse','error_code','to_alias','send_task','heartbeatInterval','new_message','normal','120568pncWDT','ack_inbox','missing_task_id','alias','error','get_all_status','2406156xehTnD','Bearer\x20','send','7793336VsdzVq','failed','replace','reconnectDelay','task.send.start','read'];a0_0x5349=function(){return _0x4d5e64;};return a0_0x5349();}export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x5854f1=a0_0x1b4b;(function(_0x53c16b,_0x3a5df4){const _0x533106=a0_0x1b4b,_0x345704=_0x53c16b();while(!![]){try{const _0x4b26d3=-parseInt(_0x533106(0x1b5))/0x1*(-parseInt(_0x533106(0x1a4))/0x2)+parseInt(_0x533106(0x14e))/0x3+parseInt(_0x533106(0x198))/0x4+-parseInt(_0x533106(0x18d))/0x5+-parseInt(_0x533106(0x15a))/0x6*(-parseInt(_0x533106(0x171))/0x7)+parseInt(_0x533106(0x14f))/0x8*(parseInt(_0x533106(0x14b))/0x9)+parseInt(_0x533106(0x19a))/0xa*(-parseInt(_0x533106(0x1a3))/0xb);if(_0x4b26d3===_0x3a5df4)break;else _0x345704['push'](_0x345704['shift']());}catch(_0x1876a3){_0x345704['push'](_0x345704['shift']());}}}(a0_0x4618,0xe8e9c));import{EventEmitter as a0_0x468ae6}from'events';import{hostname as a0_0x3b9f9e}from'os';function a0_0x1b4b(_0x55aedb,_0x301d5c){_0x55aedb=_0x55aedb-0x13e;const _0x461872=a0_0x4618();let _0x1b4b0b=_0x461872[_0x55aedb];return _0x1b4b0b;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x46efde,_0x25faf2)=>(_0x46efde??_0x25faf2)[a0_0x5854f1(0x18a)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x1f2cee){const _0x3b920e=a0_0x5854f1;return(_0x1f2cee instanceof Error?_0x1f2cee[_0x3b920e(0x185)]:String(_0x1f2cee??_0x3b920e(0x18b)))['replace'](K,_0x3b920e(0x1ab))[_0x3b920e(0x18a)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x3b920e(0x176)](0x0,0xf0);}function O(_0x214625,_0x5c52a5=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5854f1(0x14c)){const _0x59e3c0=a0_0x5854f1;if(_0x5c52a5)return JSON[_0x59e3c0(0x151)](_0x214625);let _0x322e33=L(_0x214625[_0x59e3c0(0x153)],_0x59e3c0(0x182)),_0x282b22=L(_0x214625['task_id'],_0x59e3c0(0x19e)),_0x3834df=_0x214625[_0x59e3c0(0x17d)]?_0x59e3c0(0x187)+_0x214625[_0x59e3c0(0x17d)]+':'+(_0x214625[_0x59e3c0(0x17a)]??''):'';return _0x59e3c0(0x186)+_0x214625[_0x59e3c0(0x1a2)]+_0x59e3c0(0x1ae)+L(_0x214625[_0x59e3c0(0x168)],_0x59e3c0(0x1b2))+'\x20to='+L(_0x214625[_0x59e3c0(0x147)],_0x59e3c0(0x1b2))+_0x59e3c0(0x164)+_0x282b22+_0x59e3c0(0x19b)+_0x322e33+'\x20network_id='+L(_0x214625[_0x59e3c0(0x19f)],_0x59e3c0(0x1b2))+'\x20transport='+_0x214625[_0x59e3c0(0x179)]+_0x59e3c0(0x158)+_0x214625[_0x59e3c0(0x1ad)]+_0x59e3c0(0x18e)+_0x214625[_0x59e3c0(0x155)]+_0x3834df;}function U(_0x50d7c0){const _0x5077bc=a0_0x5854f1;return{'event':{'sending':_0x5077bc(0x167),'delivered':_0x5077bc(0x1a0),'failed':_0x5077bc(0x145),'acked':'task.ack','started':_0x5077bc(0x165),'replied':_0x5077bc(0x189),'expired':_0x5077bc(0x1ba)}[_0x50d7c0[_0x5077bc(0x1a2)]],..._0x50d7c0};}function j(_0x99ff25){const _0x302cd1=a0_0x5854f1;let _0x30ac17=_0x99ff25?.[_0x302cd1(0x159)]||_0x99ff25?.[_0x302cd1(0x15b)]||_0x99ff25?.['id'];if(_0x30ac17)return String(_0x30ac17);let _0x10eb42=_0x99ff25?.[_0x302cd1(0x166)]?.[0x0]?.['text'];if(typeof _0x10eb42!==_0x302cd1(0x1a8))return null;try{let _0x394be3=JSON[_0x302cd1(0x152)](_0x10eb42);return _0x394be3?.['task_id']||_0x394be3?.[_0x302cd1(0x15b)]||_0x394be3?.['id']||null;}catch{return null;}}async function X(_0x4a440a,_0x315d56){const _0x3e8747=a0_0x5854f1;let _0x1ef1fd=_0x315d56[_0x3e8747(0x1bf)]??Date['now'],_0x72bcb8=_0x1ef1fd(),_0x2d2b3c=(_0x2a2f87,_0x1a764f,_0x230c05,_0x4c4f78)=>{const _0x4c83de=_0x3e8747;_0x315d56[_0x4c83de(0x15c)](O(U({'from_alias':_0x4a440a[_0x4c83de(0x15d)],'to_alias':_0x4a440a[_0x4c83de(0x1a1)],'task_id':_0x1a764f,'parent_task_id':_0x4a440a[_0x4c83de(0x146)],'network_id':_0x4a440a[_0x4c83de(0x1a7)],'transport':_0x4a440a['transport'],'status':_0x2a2f87,'duration_ms':_0x1ef1fd()-_0x72bcb8,'lifecycle_tracking':_0x4a440a[_0x4c83de(0x13f)],..._0x230c05!==void 0x0?{'error_code':_0x4c4f78||_0x4c83de(0x142),'error_message':N(_0x230c05)}:{}})));};_0x2d2b3c(_0x3e8747(0x16c),null);try{let _0x30a9df=await _0x315d56['send'](),_0xe7acd8=j(_0x30a9df);if(_0xe7acd8)_0x2d2b3c(_0x3e8747(0x15f),_0xe7acd8);else{if(_0x30a9df?.['ok']===!0x1||_0x30a9df?.[_0x3e8747(0x141)])_0x2d2b3c(_0x3e8747(0x17f),_0xe7acd8,_0x30a9df?.[_0x3e8747(0x141)]||_0x3e8747(0x13e),'send_rejected');else _0x2d2b3c('failed',null,_0x3e8747(0x150),_0x3e8747(0x173));}return _0x30a9df;}catch(_0x4423b9){throw _0x2d2b3c(_0x3e8747(0x17f),null,_0x4423b9,'send_failed'),_0x4423b9;}}async function Y(_0x372538,_0x4d7a6b){const _0x3b3c3a=a0_0x5854f1;return X({'fromAlias':_0x372538[_0x3b3c3a(0x15d)],'toAlias':_0x372538[_0x3b3c3a(0x16e)],'parentTaskId':_0x372538['parentTaskId']||null,'networkId':_0x372538['networkId']||null,'transport':_0x3b3c3a(0x1b4),'lifecycleTracking':'not_tracked'},_0x4d7a6b);}class $ extends a0_0x468ae6{['url'];[a0_0x5854f1(0x16e)];[a0_0x5854f1(0x184)];[a0_0x5854f1(0x149)];[a0_0x5854f1(0x1aa)];['heartbeatInterval'];['reconnectDelay'];['heartbeatTimer'];[a0_0x5854f1(0x18f)];[a0_0x5854f1(0x143)]=!0x1;constructor(_0x5a2987){const _0x44a414=a0_0x5854f1;super();if(this[_0x44a414(0x1bb)]=_0x5a2987[_0x44a414(0x1bb)][_0x44a414(0x18a)](/\/$/,''),this[_0x44a414(0x16e)]=_0x5a2987[_0x44a414(0x16e)],this[_0x44a414(0x184)]=_0x5a2987[_0x44a414(0x184)],this[_0x44a414(0x149)]=_0x5a2987[_0x44a414(0x149)]||_0x44a414(0x19c),this[_0x44a414(0x1aa)]=_0x44a414(0x199)+_0x5a2987[_0x44a414(0x16e)]+'-'+Date[_0x44a414(0x1bf)]()[_0x44a414(0x193)](0x24),this[_0x44a414(0x1bc)]=_0x5a2987[_0x44a414(0x1bc)]??0x2bf20,this[_0x44a414(0x154)]=_0x5a2987[_0x44a414(0x154)]??0xbb8,_0x5a2987[_0x44a414(0x181)]!==!0x1)this['connect']();}[a0_0x5854f1(0x15c)](_0x5ed4c2){const _0x17ecde=a0_0x5854f1;console[_0x17ecde(0x15c)]('['+new Date()[_0x17ecde(0x1ac)]()[_0x17ecde(0x176)](0x0,0x8)+']\x20[commhub:'+this[_0x17ecde(0x16e)]+']\x20'+_0x5ed4c2);}async[a0_0x5854f1(0x1b7)](_0x5eb968,_0x10a88e){const _0x5267cc=a0_0x5854f1;let _0x4b2bce={'Content-Type':_0x5267cc(0x1c1),'Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x4b2bce['Authorization']=_0x5267cc(0x16f)+this[_0x5267cc(0x184)];let _0x27556f=await(await fetch(this[_0x5267cc(0x1bb)]+_0x5267cc(0x195),{'method':_0x5267cc(0x1a9),'headers':_0x4b2bce,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date[_0x5267cc(0x1bf)](),'method':_0x5267cc(0x194),'params':{'name':_0x5eb968,'arguments':_0x10a88e}})}))[_0x5267cc(0x14a)](),_0x4f9627=_0x27556f['match'](/data: (.+)/),_0x55d1fb=_0x4f9627?JSON[_0x5267cc(0x152)](_0x4f9627[0x1]):JSON['parse'](_0x27556f),_0x32963a=_0x55d1fb?.['result']?.['content']?.[0x0]?.[_0x5267cc(0x14a)];return _0x32963a?JSON[_0x5267cc(0x152)](_0x32963a):_0x55d1fb;}async[a0_0x5854f1(0x156)](){const _0x2d74d1=a0_0x5854f1;if(this['running'])return;this['running']=!0x0,await this[_0x2d74d1(0x1a2)](_0x2d74d1(0x1b3)),this[_0x2d74d1(0x15c)]('registered'),this[_0x2d74d1(0x148)]=setInterval(()=>{const _0x500123=_0x2d74d1;this[_0x500123(0x1a2)]('idle')[_0x500123(0x140)](_0x3eece5=>this[_0x500123(0x15c)]('heartbeat\x20failed:\x20'+_0x3eece5['message']));},this[_0x2d74d1(0x1bc)]),this[_0x2d74d1(0x1b1)]();}async['disconnect'](){const _0x3ab2ef=a0_0x5854f1;if(this['running']=!0x1,this[_0x3ab2ef(0x18f)]?.[_0x3ab2ef(0x191)](),this['heartbeatTimer'])clearInterval(this[_0x3ab2ef(0x148)]);await this['status']('offline')[_0x3ab2ef(0x140)](()=>{}),this['log'](_0x3ab2ef(0x1b6));}async[a0_0x5854f1(0x175)](_0x2f8ed1,_0x11a82e,_0x5440d4=a0_0x5854f1(0x19d)){const _0x42ba03=a0_0x5854f1;return Y({'alias':_0x2f8ed1,'fromAlias':this['alias']},{'log':_0x46e857=>console[_0x42ba03(0x15c)](_0x46e857),'send':()=>this['call'](_0x42ba03(0x16d),{'alias':_0x2f8ed1,'task':_0x11a82e,'priority':_0x5440d4,'from_session':this[_0x42ba03(0x16e)]})});}async[a0_0x5854f1(0x185)](_0x20f8c9,_0x1add28){const _0x26e86c=a0_0x5854f1;return this[_0x26e86c(0x1b7)](_0x26e86c(0x14d),{'alias':_0x20f8c9,'message':_0x1add28,'from_session':this[_0x26e86c(0x16e)]});}async[a0_0x5854f1(0x190)](_0x4eda71,_0x20468a,_0xde8a06='completed'){const _0x19e966=a0_0x5854f1;return this[_0x19e966(0x1b7)]('send_reply',{'in_reply_to':_0x4eda71,'text':_0x20468a,'status':_0xde8a06});}async[a0_0x5854f1(0x1a2)](_0x8e74b,_0x5985c0){const _0x1379ac=a0_0x5854f1;return this[_0x1379ac(0x1b7)](_0x1379ac(0x15e),{'resume_id':this[_0x1379ac(0x1aa)],'alias':this['alias'],'status':_0x8e74b,'server':a0_0x3b9f9e(),'hostname':a0_0x3b9f9e(),'agent':this[_0x1379ac(0x149)],'project_dir':process[_0x1379ac(0x174)](),..._0x5985c0});}async['getAllStatus'](){const _0x287c77=a0_0x5854f1;return this[_0x287c77(0x1b7)](_0x287c77(0x1a5),{});}async['broadcast'](_0x2d9cdf,_0x187e5f){const _0x2c1a7f=a0_0x5854f1;return this[_0x2c1a7f(0x1b7)](_0x2c1a7f(0x16a),{'message':_0x2d9cdf,'filter_server':_0x187e5f?.[_0x2c1a7f(0x1c0)],'filter_status':_0x187e5f?.['status']});}async[a0_0x5854f1(0x1b1)](){const _0xd1ab75=a0_0x5854f1;let _0x3d5a15=encodeURIComponent(this[_0xd1ab75(0x16e)]),_0x5f6b5c=this[_0xd1ab75(0x1bb)]+'/events/'+_0x3d5a15,_0x474cb9=this[_0xd1ab75(0x154)];while(this['running']){try{this[_0xd1ab75(0x18f)]=new AbortController();let _0x438690={'Accept':_0xd1ab75(0x1b8)};if(this[_0xd1ab75(0x184)])_0x438690[_0xd1ab75(0x177)]=_0xd1ab75(0x16f)+this[_0xd1ab75(0x184)];let _0x37fa17=await fetch(_0x5f6b5c,{'headers':_0x438690,'signal':this[_0xd1ab75(0x18f)][_0xd1ab75(0x16b)]});if(!_0x37fa17['ok']||!_0x37fa17[_0xd1ab75(0x1be)]){this[_0xd1ab75(0x15c)]('SSE\x20failed:\x20'+_0x37fa17[_0xd1ab75(0x1a2)]),await this[_0xd1ab75(0x197)](_0x474cb9),_0x474cb9=Math[_0xd1ab75(0x180)](_0x474cb9*1.5,0xea60);continue;}_0x474cb9=this[_0xd1ab75(0x154)];let _0x33ecce=_0x37fa17['body'][_0xd1ab75(0x1b0)](),_0x3bd71e=new TextDecoder(),_0x432334='';while(this[_0xd1ab75(0x143)]){let {done:_0x41fcf7,value:_0x31c674}=await _0x33ecce[_0xd1ab75(0x17e)]();if(_0x41fcf7)break;_0x432334+=_0x3bd71e[_0xd1ab75(0x157)](_0x31c674,{'stream':!0x0});let _0x334d3f=_0x432334[_0xd1ab75(0x172)]('\x0a');_0x432334=_0x334d3f['pop']()||'';for(let _0x3b8fff of _0x334d3f){if(!_0x3b8fff[_0xd1ab75(0x162)](_0xd1ab75(0x1af)))continue;try{let _0x4bfade=JSON[_0xd1ab75(0x152)](_0x3b8fff[_0xd1ab75(0x176)](0x6));if(_0x4bfade[_0xd1ab75(0x1bd)]===_0xd1ab75(0x196)){this[_0xd1ab75(0x15c)](_0xd1ab75(0x178)),this[_0xd1ab75(0x192)](_0xd1ab75(0x196));continue;}if(_0x4bfade[_0xd1ab75(0x1bd)]===_0xd1ab75(0x1a6)||_0x4bfade[_0xd1ab75(0x1bd)]===_0xd1ab75(0x163)||_0x4bfade[_0xd1ab75(0x1bd)]==='broadcast')await this[_0xd1ab75(0x17b)]();}catch{}}}}catch(_0x317143){if(_0x317143[_0xd1ab75(0x183)]===_0xd1ab75(0x1b9))break;this[_0xd1ab75(0x192)](_0xd1ab75(0x141),_0x317143),this[_0xd1ab75(0x15c)](_0xd1ab75(0x144)+_0x317143['message']);}if(this[_0xd1ab75(0x143)])this[_0xd1ab75(0x192)](_0xd1ab75(0x1b6)),this['log'](_0xd1ab75(0x161)+_0x474cb9/0x3e8+_0xd1ab75(0x170)),await this[_0xd1ab75(0x197)](_0x474cb9),_0x474cb9=Math[_0xd1ab75(0x180)](_0x474cb9*1.5,0xea60);}}async[a0_0x5854f1(0x17b)](){const _0x1f59ab=a0_0x5854f1;try{let _0x3ba8f4=(await this['call'](_0x1f59ab(0x18c),{'alias':this[_0x1f59ab(0x16e)],'limit':0xa}))?.[_0x1f59ab(0x17c)]||[];for(let _0x194787 of _0x3ba8f4)await this[_0x1f59ab(0x1b7)](_0x1f59ab(0x169),{'alias':this[_0x1f59ab(0x16e)],'message_id':_0x194787['id']}),this[_0x1f59ab(0x15c)]('←\x20'+_0x194787['from_session']+':\x20'+_0x194787[_0x1f59ab(0x166)][_0x1f59ab(0x176)](0x0,0x3c)),this[_0x1f59ab(0x192)](_0x1f59ab(0x160),_0x194787),this[_0x1f59ab(0x192)](_0x1f59ab(0x185),_0x194787);}catch(_0x3cff12){this[_0x1f59ab(0x15c)](_0x1f59ab(0x188)+_0x3cff12[_0x1f59ab(0x185)]);}}[a0_0x5854f1(0x197)](_0x287f8a){return new Promise(_0x84a403=>setTimeout(_0x84a403,_0x287f8a));}}var F=$;function a0_0x4618(){const _0x3cb583=['stringify','parse','parent_task_id','reconnectDelay','lifecycle_tracking','connect','decode','\x20duration_ms=','task_id','12cWffOg','message_id','log','fromAlias','report_status','delivered','task','SSE\x20reconnecting\x20in\x20','startsWith','new_message','\x20task_id=','task.started','content','task.send.start','from_alias','ack_inbox','broadcast','signal','sending','send_task','alias','Bearer\x20','s...','1819202buQwnx','split','missing_task_id','cwd','send','slice','Authorization','SSE\x20connected','transport','error_message','processInbox','messages','error_code','read','failed','min','autoConnect','<missing>','name','token','message','[commhub:task]\x20','\x20error=','inbox\x20error:\x20','task.replied','replace','unknown\x20error','get_inbox','499720jnFyVD','\x20lifecycle=','sseAbort','reply','abort','emit','toString','tools/call','/mcp','connected','sleep','3626784RcQdUm','sdk-','11000szmRhm','\x20parent_task_id=','sdk','normal','<pending>','network_id','task.send.delivered','toAlias','status','32054BKqXCn','4TKTFci','get_all_status','new_task','networkId','string','POST','resumeId','[REDACTED]','toTimeString','duration_ms','\x20from=','data:\x20','getReader','connectSSE','<unknown>','idle','mcp_http','842799cfvlqV','disconnected','call','text/event-stream','AbortError','task.expired','url','heartbeatInterval','type','body','now','server','application/json','CommHub\x20rejected\x20task','lifecycleTracking','catch','error','send_failed','running','SSE\x20error:\x20','task.send.failed','parentTaskId','to_alias','heartbeatTimer','agent','text','9617409pZxWaG','json','send_message','236067OyNHuI','8MeYMvG','CommHub\x20response\x20omitted\x20task_id'];a0_0x4618=function(){return _0x3cb583;};return a0_0x4618();}export{F as default,$ as CommHub};
|
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
/** Per-node record, written into the node dir next to the other state files. */
|
|
2
2
|
export declare const CODEX_AUTH_FINGERPRINT_FILE = ".codex-auth-fingerprint.json";
|
|
3
|
+
/**
|
|
4
|
+
* Host-wide index of the same records — the read side's source of truth.
|
|
5
|
+
*
|
|
6
|
+
* Under `~/.anet/` because that is already this repo's host-scoped state
|
|
7
|
+
* directory (global config lives there) and it does not move with `cwd`, which
|
|
8
|
+
* is the entire point: the nodes that need to see each other are in different
|
|
9
|
+
* workspaces.
|
|
10
|
+
*/
|
|
11
|
+
export declare function codexFingerprintIndexDir(home?: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Index filename for a node.
|
|
14
|
+
*
|
|
15
|
+
* 🔴 Derived from the node's DIRECTORY, never its alias. Aliases are not unique
|
|
16
|
+
* across workspaces — the reference fleet runs `TMA门户鲸2号` beside
|
|
17
|
+
* `TMA门户鲸`, and nothing stops two workspaces from using one name — so an
|
|
18
|
+
* alias-keyed file would let one node silently overwrite another's record,
|
|
19
|
+
* re-creating the very blindness this index fixes. A directory cannot be two
|
|
20
|
+
* nodes.
|
|
21
|
+
*
|
|
22
|
+
* 🔴 And derived from the directory rather than from `node_id`, even though the
|
|
23
|
+
* CLI has one handy: agent-node's `NODE_ID` can be empty (older configs), so
|
|
24
|
+
* a node_id key would need a fallback — and then the same node would write
|
|
25
|
+
* one filename from one launch path and a different one from the other,
|
|
26
|
+
* leaving two records that look like two nodes sharing a credential. One
|
|
27
|
+
* deterministic key from an input both call sites already have is worth more
|
|
28
|
+
* than a prettier name. `node_id` is still recorded, for humans.
|
|
29
|
+
*/
|
|
30
|
+
export declare function codexFingerprintIndexFile(nodeDir: string): string;
|
|
3
31
|
/** Length of the stored fingerprint. Collisions at 8 hex are ~1 in 4 billion;
|
|
4
32
|
* a false "these two share a login" warning costs a second look, while the
|
|
5
33
|
* value staying short keeps it obviously non-reversible in logs. */
|
|
@@ -8,8 +36,12 @@ export declare const FINGERPRINT_LENGTH = 8;
|
|
|
8
36
|
* on 29 of 29 samples, with no jitter. Used only to phrase "how long until the
|
|
9
37
|
* shared copy dies" when we have an `exp` but no `iat`. */
|
|
10
38
|
export declare const ACCESS_TOKEN_LIFETIME_SECONDS = 864000;
|
|
39
|
+
/** Past this, a published record's age is shown beside the alias. It does not
|
|
40
|
+
* suppress the warning: a node that has not started in a week still holds the
|
|
41
|
+
* shared credential. See the liveness note on `checkCodexCredentialSharing`. */
|
|
42
|
+
export declare const STALE_RECORD_NOTICE_MS: number;
|
|
11
43
|
export interface CodexAuthFingerprintRecord {
|
|
12
|
-
readonly schema_version: 1 | 2;
|
|
44
|
+
readonly schema_version: 1 | 2 | 3;
|
|
13
45
|
readonly alias: string;
|
|
14
46
|
/** sha256(refresh_token) truncated — never the token. */
|
|
15
47
|
readonly fingerprint: string;
|
|
@@ -22,6 +54,14 @@ export interface CodexAuthFingerprintRecord {
|
|
|
22
54
|
* one credential" from "two nodes pointed at one directory", which need
|
|
23
55
|
* different fixes. */
|
|
24
56
|
readonly codex_home?: string | null;
|
|
57
|
+
/** v3: the node directory this record describes, canonical. Three jobs: it is
|
|
58
|
+
* the identity used to de-duplicate the index against the sibling scan and to
|
|
59
|
+
* exclude self; and it is the liveness test — if this directory is gone, the
|
|
60
|
+
* node is gone and the record must not accuse anyone. */
|
|
61
|
+
readonly node_dir?: string;
|
|
62
|
+
/** v3: recorded for humans reading the index by hand. Never the key: it can be
|
|
63
|
+
* absent, and a key that is sometimes absent produces two records per node. */
|
|
64
|
+
readonly node_id?: string | null;
|
|
25
65
|
}
|
|
26
66
|
/**
|
|
27
67
|
* Hash the refresh token out of an auth.json body.
|
|
@@ -53,13 +93,20 @@ export interface NodeFingerprint {
|
|
|
53
93
|
readonly accessExpiresAt?: Date | null;
|
|
54
94
|
/** The CODEX_HOME this fingerprint came from, if known. */
|
|
55
95
|
readonly codexHome?: string | null;
|
|
96
|
+
/** Canonical node directory — identity for de-duplication and self-exclusion. */
|
|
97
|
+
readonly nodeDir?: string | null;
|
|
56
98
|
}
|
|
57
99
|
/**
|
|
58
100
|
* Other nodes holding the same credential chain as `self`.
|
|
59
101
|
*
|
|
60
102
|
* Records with no fingerprint are skipped rather than grouped: "unknown" is
|
|
61
|
-
* not a match.
|
|
62
|
-
*
|
|
103
|
+
* not a match.
|
|
104
|
+
*
|
|
105
|
+
* 🔴 Self is excluded by node DIRECTORY when both sides carry one, and only
|
|
106
|
+
* falls back to alias for pre-v3 records. Once the read side is host-wide,
|
|
107
|
+
* alias stops being an identity: two workspaces may each hold a node called
|
|
108
|
+
* the same thing, and excluding by name would hide a genuine collision
|
|
109
|
+
* between them — the exact failure this index was added to fix.
|
|
63
110
|
*/
|
|
64
111
|
export declare function collidingNodes(records: readonly NodeFingerprint[], self: NodeFingerprint): NodeFingerprint[];
|
|
65
112
|
/**
|
|
@@ -122,10 +169,15 @@ export interface CodexCredentialSharingCheck {
|
|
|
122
169
|
readonly alias: string;
|
|
123
170
|
/** The CODEX_HOME whose auth.json this node will actually use. */
|
|
124
171
|
readonly codexHome: string;
|
|
172
|
+
/** Recorded for humans reading the index; never used as a key. Optional
|
|
173
|
+
* because agent-node's can be empty on older configs. */
|
|
174
|
+
readonly nodeId?: string | null;
|
|
125
175
|
/** Where the warning goes. Defaults to stderr. */
|
|
126
176
|
readonly say?: (message: string) => void;
|
|
127
177
|
/** Injected for tests; production passes nothing. */
|
|
128
178
|
readonly now?: Date;
|
|
179
|
+
/** Injected for tests; production uses the real host index under `~/.anet`. */
|
|
180
|
+
readonly indexDir?: string;
|
|
129
181
|
}
|
|
130
182
|
/**
|
|
131
183
|
* The whole operation: read this node's credential, publish an 8-hex record,
|
|
@@ -142,6 +194,17 @@ export interface CodexCredentialSharingCheck {
|
|
|
142
194
|
* one node in sequence, and whichever runs last must leave the current
|
|
143
195
|
* value, never an older one.
|
|
144
196
|
*
|
|
197
|
+
* 🔴 Liveness is EXISTENCE, not age. An index record outlives the node that
|
|
198
|
+
* wrote it, and a stale one accusing a node that no longer exists is worse
|
|
199
|
+
* than silence — it teaches operators to ignore the warning. So a record
|
|
200
|
+
* whose `node_dir` is gone is dropped and its index entry deleted.
|
|
201
|
+
* Age deliberately does NOT filter: on the reference fleet two of the three
|
|
202
|
+
* nodes in the worst-affected group were not running at all, and six of 29
|
|
203
|
+
* credential files had not been touched in days, while still holding the
|
|
204
|
+
* shared copy. An age cutoff would have hidden precisely the collisions
|
|
205
|
+
* worth reporting. Age is surfaced in the warning instead, so the operator
|
|
206
|
+
* can judge how old the claim is.
|
|
207
|
+
*
|
|
145
208
|
* Never throws and never refuses: observability must not be the reason a node
|
|
146
209
|
* will not start.
|
|
147
210
|
*/
|