@sleep2agi/agent-network 2.3.0-preview.48 → 2.3.0-preview.49
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_0x1808a5=a0_0x51ca;(function(_0x4dbe43,_0x59b7ee){const _0x131f44=a0_0x51ca,_0x41c7f5=_0x4dbe43();while(!![]){try{const _0x5617a8=-parseInt(_0x131f44(0x178))/0x1+parseInt(_0x131f44(0x1b3))/0x2*(parseInt(_0x131f44(0x17f))/0x3)+-parseInt(_0x131f44(0x143))/0x4*(parseInt(_0x131f44(0x191))/0x5)+parseInt(_0x131f44(0x163))/0x6*(-parseInt(_0x131f44(0x186))/0x7)+-parseInt(_0x131f44(0x198))/0x8*(parseInt(_0x131f44(0x173))/0x9)+parseInt(_0x131f44(0x17e))/0xa+-parseInt(_0x131f44(0x166))/0xb*(-parseInt(_0x131f44(0x167))/0xc);if(_0x5617a8===_0x59b7ee)break;else _0x41c7f5['push'](_0x41c7f5['shift']());}catch(_0x36b2d9){_0x41c7f5['push'](_0x41c7f5['shift']());}}}(a0_0x14a5,0x40b72));import{EventEmitter as a0_0x269aca}from'events';function a0_0x51ca(_0xe64ce5,_0x14c7ae){_0xe64ce5=_0xe64ce5-0x140;const _0x14a51a=a0_0x14a5();let _0x51ca49=_0x14a51a[_0xe64ce5];return _0x51ca49;}import{hostname as a0_0x272304}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2ccd78,_0x553188)=>(_0x2ccd78??_0x553188)[a0_0x1808a5(0x16f)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x1808a5(0x14e)](0x0,0xf0);function N(_0x5e641d){const _0x270683=a0_0x1808a5;return(_0x5e641d instanceof Error?_0x5e641d[_0x270683(0x193)]:String(_0x5e641d??_0x270683(0x19b)))['replace'](K,_0x270683(0x165))[_0x270683(0x16f)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x477992,_0x5212f5=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x95230f=a0_0x1808a5;if(_0x5212f5)return JSON[_0x95230f(0x1bf)](_0x477992);let _0x3ee312=L(_0x477992[_0x95230f(0x17d)],_0x95230f(0x19d)),_0x20f16b=L(_0x477992[_0x95230f(0x177)],_0x95230f(0x18e)),_0x64106d=_0x477992[_0x95230f(0x14a)]?'\x20error='+_0x477992[_0x95230f(0x14a)]+':'+(_0x477992['error_message']??''):'';return _0x95230f(0x17b)+_0x477992[_0x95230f(0x16a)]+'\x20from='+L(_0x477992[_0x95230f(0x18d)],_0x95230f(0x1ab))+_0x95230f(0x18f)+L(_0x477992['to_alias'],'<unknown>')+_0x95230f(0x1a0)+_0x20f16b+'\x20parent_task_id='+_0x3ee312+_0x95230f(0x16d)+L(_0x477992[_0x95230f(0x192)],'<unknown>')+_0x95230f(0x140)+_0x477992[_0x95230f(0x158)]+'\x20duration_ms='+_0x477992['duration_ms']+_0x95230f(0x144)+_0x477992[_0x95230f(0x1ac)]+_0x64106d;}function a0_0x14a5(){const _0xd6f6f7=['running','30kPDdDk','processInbox','[REDACTED]','4193321zZylUf','12eqAHdq','task.send.start','task.send.failed','status','failed','messages','\x20network_id=','CommHub\x20response\x20omitted\x20task_id','replace','alias','application/json','normal','1372860kkUHIb','offline','2.0','idle','task_id','43065fEcQpz','min','catch','[commhub:task]\x20','reconnectDelay','parent_task_id','4354150NlOmGY','159RMfUyn','lifecycleTracking','url','parse','disconnected','connect','error','569905SkXVyX','resumeId','toString','not_tracked','/mcp','name','decode','from_alias','<pending>','\x20to=','content','145omwplW','network_id','message','tools/call','type','now','mcp_http','8lfxlXE','registered','pop','unknown\x20error','reply','<missing>','POST','task','\x20task_id=','ack_inbox','missing_task_id','get_inbox','result','send_message','delivered','connectSSE','SSE\x20failed:\x20','text/event-stream','heartbeat\x20failed:\x20','<unknown>','lifecycle_tracking','send_failed','sending','read','task.send.delivered','fromAlias','Authorization','7354eNMsZu','heartbeatInterval','sdk-','call','heartbeatTimer','log','autoConnect','s...','CommHub\x20rejected\x20task','data:\x20','toAlias','report_status','stringify','networkId','\x20transport=','send_rejected','new_task','19828EKLwxz','\x20lifecycle=','send','Bearer\x20','send_task','abort','from_session','error_code','emit','get_all_status','broadcast','slice','body','message_id','string',']\x20[commhub:','startsWith','new_message','token','application/json,\x20text/event-stream','getReader','transport','split','text','signal','SSE\x20connected','agent','sseAbort','parentTaskId','sleep','connected'];a0_0x14a5=function(){return _0xd6f6f7;};return a0_0x14a5();}function U(_0x2586c8){const _0x143e6=a0_0x1808a5;return{'event':{'sending':_0x143e6(0x168),'delivered':_0x143e6(0x1b0),'failed':_0x143e6(0x169),'acked':'task.ack','started':'task.started','replied':'task.replied','expired':'task.expired'}[_0x2586c8[_0x143e6(0x16a)]],..._0x2586c8};}function j(_0x141435){const _0xec007e=a0_0x1808a5;let _0x21a7da=_0x141435?.[_0xec007e(0x177)]||_0x141435?.[_0xec007e(0x150)]||_0x141435?.['id'];if(_0x21a7da)return String(_0x21a7da);let _0x25d748=_0x141435?.['content']?.[0x0]?.[_0xec007e(0x15a)];if(typeof _0x25d748!==_0xec007e(0x151))return null;try{let _0x5a0d2a=JSON[_0xec007e(0x182)](_0x25d748);return _0x5a0d2a?.[_0xec007e(0x177)]||_0x5a0d2a?.[_0xec007e(0x150)]||_0x5a0d2a?.['id']||null;}catch{return null;}}async function X(_0x2fda12,_0x16f46f){const _0x2bc7a1=a0_0x1808a5;let _0x17ee72=_0x16f46f[_0x2bc7a1(0x196)]??Date[_0x2bc7a1(0x196)],_0x15723a=_0x17ee72(),_0xe27869=(_0x29a5bb,_0x4cd7f1,_0x586eee,_0x1b4ddf)=>{const _0xbd962a=_0x2bc7a1;_0x16f46f[_0xbd962a(0x1b8)](O(U({'from_alias':_0x2fda12[_0xbd962a(0x1b1)],'to_alias':_0x2fda12[_0xbd962a(0x1bd)],'task_id':_0x4cd7f1,'parent_task_id':_0x2fda12[_0xbd962a(0x15f)],'network_id':_0x2fda12[_0xbd962a(0x1c0)],'transport':_0x2fda12[_0xbd962a(0x158)],'status':_0x29a5bb,'duration_ms':_0x17ee72()-_0x15723a,'lifecycle_tracking':_0x2fda12[_0xbd962a(0x180)],..._0x586eee!==void 0x0?{'error_code':_0x1b4ddf||'send_failed','error_message':N(_0x586eee)}:{}})));};_0xe27869(_0x2bc7a1(0x1ae),null);try{let _0xad09e2=await _0x16f46f[_0x2bc7a1(0x145)](),_0x2f611c=j(_0xad09e2);if(_0x2f611c)_0xe27869(_0x2bc7a1(0x1a6),_0x2f611c);else{if(_0xad09e2?.['ok']===!0x1||_0xad09e2?.[_0x2bc7a1(0x185)])_0xe27869('failed',_0x2f611c,_0xad09e2?.[_0x2bc7a1(0x185)]||_0x2bc7a1(0x1bb),_0x2bc7a1(0x141));else _0xe27869(_0x2bc7a1(0x16b),null,_0x2bc7a1(0x16e),_0x2bc7a1(0x1a2));}return _0xad09e2;}catch(_0x299b83){throw _0xe27869('failed',null,_0x299b83,_0x2bc7a1(0x1ad)),_0x299b83;}}async function Y(_0x5a4669,_0x88b723){const _0x2c627d=a0_0x1808a5;return X({'fromAlias':_0x5a4669[_0x2c627d(0x1b1)],'toAlias':_0x5a4669[_0x2c627d(0x170)],'parentTaskId':_0x5a4669[_0x2c627d(0x15f)]||null,'networkId':_0x5a4669[_0x2c627d(0x1c0)]||null,'transport':_0x2c627d(0x197),'lifecycleTracking':_0x2c627d(0x189)},_0x88b723);}class $ extends a0_0x269aca{[a0_0x1808a5(0x181)];['alias'];[a0_0x1808a5(0x155)];[a0_0x1808a5(0x15d)];[a0_0x1808a5(0x187)];[a0_0x1808a5(0x1b4)];['reconnectDelay'];[a0_0x1808a5(0x1b7)];['sseAbort'];[a0_0x1808a5(0x162)]=!0x1;constructor(_0x1614f0){const _0x40ffac=a0_0x1808a5;super();if(this['url']=_0x1614f0['url'][_0x40ffac(0x16f)](/\/$/,''),this[_0x40ffac(0x170)]=_0x1614f0[_0x40ffac(0x170)],this[_0x40ffac(0x155)]=_0x1614f0[_0x40ffac(0x155)],this[_0x40ffac(0x15d)]=_0x1614f0['agent']||'sdk',this[_0x40ffac(0x187)]=_0x40ffac(0x1b5)+_0x1614f0[_0x40ffac(0x170)]+'-'+Date[_0x40ffac(0x196)]()[_0x40ffac(0x188)](0x24),this['heartbeatInterval']=_0x1614f0['heartbeatInterval']??0x2bf20,this[_0x40ffac(0x17c)]=_0x1614f0['reconnectDelay']??0xbb8,_0x1614f0[_0x40ffac(0x1b9)]!==!0x1)this[_0x40ffac(0x184)]();}[a0_0x1808a5(0x1b8)](_0x5ec3ca){const _0x53ae7b=a0_0x1808a5;console[_0x53ae7b(0x1b8)]('['+new Date()['toTimeString']()[_0x53ae7b(0x14e)](0x0,0x8)+_0x53ae7b(0x152)+this[_0x53ae7b(0x170)]+']\x20'+_0x5ec3ca);}async['call'](_0x354da1,_0x36fe55){const _0x448280=a0_0x1808a5;let _0x515e09={'Content-Type':_0x448280(0x171),'Accept':_0x448280(0x156)};if(this[_0x448280(0x155)])_0x515e09['Authorization']=_0x448280(0x146)+this['token'];let _0x9c46e0=await(await fetch(this[_0x448280(0x181)]+_0x448280(0x18a),{'method':_0x448280(0x19e),'headers':_0x515e09,'body':JSON['stringify']({'jsonrpc':_0x448280(0x175),'id':Date[_0x448280(0x196)](),'method':_0x448280(0x194),'params':{'name':_0x354da1,'arguments':_0x36fe55}})}))[_0x448280(0x15a)](),_0xdb07fc=_0x9c46e0['match'](/data: (.+)/),_0x2f3765=_0xdb07fc?JSON['parse'](_0xdb07fc[0x1]):JSON[_0x448280(0x182)](_0x9c46e0),_0x402853=_0x2f3765?.[_0x448280(0x1a4)]?.[_0x448280(0x190)]?.[0x0]?.[_0x448280(0x15a)];return _0x402853?JSON[_0x448280(0x182)](_0x402853):_0x2f3765;}async['connect'](){const _0x3c999f=a0_0x1808a5;if(this[_0x3c999f(0x162)])return;this[_0x3c999f(0x162)]=!0x0,await this[_0x3c999f(0x16a)](_0x3c999f(0x176)),this[_0x3c999f(0x1b8)](_0x3c999f(0x199)),this['heartbeatTimer']=setInterval(()=>{const _0x28943f=_0x3c999f;this[_0x28943f(0x16a)](_0x28943f(0x176))[_0x28943f(0x17a)](_0x155200=>this[_0x28943f(0x1b8)](_0x28943f(0x1aa)+_0x155200[_0x28943f(0x193)]));},this[_0x3c999f(0x1b4)]),this[_0x3c999f(0x1a7)]();}async['disconnect'](){const _0x3dd5ba=a0_0x1808a5;if(this['running']=!0x1,this[_0x3dd5ba(0x15e)]?.[_0x3dd5ba(0x148)](),this[_0x3dd5ba(0x1b7)])clearInterval(this[_0x3dd5ba(0x1b7)]);await this['status'](_0x3dd5ba(0x174))[_0x3dd5ba(0x17a)](()=>{}),this['log'](_0x3dd5ba(0x183));}async[a0_0x1808a5(0x145)](_0x5916bd,_0x216cef,_0x308d88=a0_0x1808a5(0x172)){const _0x313256=a0_0x1808a5;return Y({'alias':_0x5916bd,'fromAlias':this[_0x313256(0x170)]},{'log':_0x4ff3d6=>console['log'](_0x4ff3d6),'send':()=>this[_0x313256(0x1b6)](_0x313256(0x147),{'alias':_0x5916bd,'task':_0x216cef,'priority':_0x308d88,'from_session':this['alias']})});}async['message'](_0x5de8c1,_0x12221a){const _0x38eecb=a0_0x1808a5;return this[_0x38eecb(0x1b6)](_0x38eecb(0x1a5),{'alias':_0x5de8c1,'message':_0x12221a,'from_session':this[_0x38eecb(0x170)]});}async[a0_0x1808a5(0x19c)](_0x20eea6,_0x43ff2c,_0xa52fc7='completed'){const _0x10846e=a0_0x1808a5;return this[_0x10846e(0x1b6)]('send_reply',{'in_reply_to':_0x20eea6,'text':_0x43ff2c,'status':_0xa52fc7});}async['status'](_0x294de0,_0x469955){const _0x2a37d1=a0_0x1808a5;return this['call'](_0x2a37d1(0x1be),{'resume_id':this[_0x2a37d1(0x187)],'alias':this[_0x2a37d1(0x170)],'status':_0x294de0,'server':a0_0x272304(),'hostname':a0_0x272304(),'agent':this[_0x2a37d1(0x15d)],'project_dir':process['cwd'](),..._0x469955});}async['getAllStatus'](){const _0x2f219a=a0_0x1808a5;return this['call'](_0x2f219a(0x14c),{});}async[a0_0x1808a5(0x14d)](_0xf592a6,_0x4bbca5){const _0x31945e=a0_0x1808a5;return this[_0x31945e(0x1b6)](_0x31945e(0x14d),{'message':_0xf592a6,'filter_server':_0x4bbca5?.['server'],'filter_status':_0x4bbca5?.[_0x31945e(0x16a)]});}async[a0_0x1808a5(0x1a7)](){const _0x42d796=a0_0x1808a5;let _0x4be0eb=encodeURIComponent(this['alias']),_0x2f629e=this['url']+'/events/'+_0x4be0eb,_0x5f0b0e=this['reconnectDelay'];while(this[_0x42d796(0x162)]){try{this[_0x42d796(0x15e)]=new AbortController();let _0x210d7a={'Accept':_0x42d796(0x1a9)};if(this['token'])_0x210d7a[_0x42d796(0x1b2)]='Bearer\x20'+this[_0x42d796(0x155)];let _0x5c75be=await fetch(_0x2f629e,{'headers':_0x210d7a,'signal':this[_0x42d796(0x15e)][_0x42d796(0x15b)]});if(!_0x5c75be['ok']||!_0x5c75be[_0x42d796(0x14f)]){this['log'](_0x42d796(0x1a8)+_0x5c75be[_0x42d796(0x16a)]),await this[_0x42d796(0x160)](_0x5f0b0e),_0x5f0b0e=Math[_0x42d796(0x179)](_0x5f0b0e*1.5,0xea60);continue;}_0x5f0b0e=this[_0x42d796(0x17c)];let _0x1fa8fc=_0x5c75be[_0x42d796(0x14f)][_0x42d796(0x157)](),_0x5c3350=new TextDecoder(),_0x40c11c='';while(this['running']){let {done:_0x50ba14,value:_0x311a32}=await _0x1fa8fc[_0x42d796(0x1af)]();if(_0x50ba14)break;_0x40c11c+=_0x5c3350[_0x42d796(0x18c)](_0x311a32,{'stream':!0x0});let _0x53b002=_0x40c11c[_0x42d796(0x159)]('\x0a');_0x40c11c=_0x53b002[_0x42d796(0x19a)]()||'';for(let _0xd345d of _0x53b002){if(!_0xd345d[_0x42d796(0x153)](_0x42d796(0x1bc)))continue;try{let _0x43c19d=JSON['parse'](_0xd345d[_0x42d796(0x14e)](0x6));if(_0x43c19d[_0x42d796(0x195)]===_0x42d796(0x161)){this[_0x42d796(0x1b8)](_0x42d796(0x15c)),this[_0x42d796(0x14b)]('connected');continue;}if(_0x43c19d[_0x42d796(0x195)]===_0x42d796(0x142)||_0x43c19d[_0x42d796(0x195)]===_0x42d796(0x154)||_0x43c19d[_0x42d796(0x195)]===_0x42d796(0x14d))await this[_0x42d796(0x164)]();}catch{}}}}catch(_0x507283){if(_0x507283[_0x42d796(0x18b)]==='AbortError')break;this['emit'](_0x42d796(0x185),_0x507283),this[_0x42d796(0x1b8)]('SSE\x20error:\x20'+_0x507283['message']);}if(this['running'])this[_0x42d796(0x14b)](_0x42d796(0x183)),this[_0x42d796(0x1b8)]('SSE\x20reconnecting\x20in\x20'+_0x5f0b0e/0x3e8+_0x42d796(0x1ba)),await this['sleep'](_0x5f0b0e),_0x5f0b0e=Math['min'](_0x5f0b0e*1.5,0xea60);}}async[a0_0x1808a5(0x164)](){const _0x59d40b=a0_0x1808a5;try{let _0x2fe330=(await this[_0x59d40b(0x1b6)](_0x59d40b(0x1a3),{'alias':this[_0x59d40b(0x170)],'limit':0xa}))?.[_0x59d40b(0x16c)]||[];for(let _0x19bc47 of _0x2fe330)await this[_0x59d40b(0x1b6)](_0x59d40b(0x1a1),{'alias':this['alias'],'message_id':_0x19bc47['id']}),this[_0x59d40b(0x1b8)]('←\x20'+_0x19bc47[_0x59d40b(0x149)]+':\x20'+_0x19bc47[_0x59d40b(0x190)]['slice'](0x0,0x3c)),this[_0x59d40b(0x14b)](_0x59d40b(0x19f),_0x19bc47),this[_0x59d40b(0x14b)](_0x59d40b(0x193),_0x19bc47);}catch(_0x1fdedd){this[_0x59d40b(0x1b8)]('inbox\x20error:\x20'+_0x1fdedd[_0x59d40b(0x193)]);}}[a0_0x1808a5(0x160)](_0x49d098){return new Promise(_0x1bda73=>setTimeout(_0x1bda73,_0x49d098));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0xd22e14=a0_0x577f;function a0_0x577f(_0x156dac,_0x221cfe){_0x156dac=_0x156dac-0xc0;const _0x58dd58=a0_0x58dd();let _0x577f53=_0x58dd58[_0x156dac];return _0x577f53;}(function(_0x1d1314,_0x3f478f){const _0x53d495=a0_0x577f,_0x70bc36=_0x1d1314();while(!![]){try{const _0x4994aa=parseInt(_0x53d495(0xe8))/0x1*(-parseInt(_0x53d495(0xde))/0x2)+-parseInt(_0x53d495(0xe0))/0x3+parseInt(_0x53d495(0xc0))/0x4+parseInt(_0x53d495(0xe4))/0x5*(-parseInt(_0x53d495(0xc3))/0x6)+-parseInt(_0x53d495(0x11a))/0x7*(parseInt(_0x53d495(0x130))/0x8)+parseInt(_0x53d495(0x10d))/0x9*(parseInt(_0x53d495(0xd9))/0xa)+parseInt(_0x53d495(0x12a))/0xb*(parseInt(_0x53d495(0xf2))/0xc);if(_0x4994aa===_0x3f478f)break;else _0x70bc36['push'](_0x70bc36['shift']());}catch(_0x1d1526){_0x70bc36['push'](_0x70bc36['shift']());}}}(a0_0x58dd,0x7d31a));import{EventEmitter as a0_0x434893}from'events';import{hostname as a0_0x73d679}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x49931b,_0x4be464)=>(_0x49931b??_0x4be464)[a0_0xd22e14(0xf5)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0xd22e14(0x11e)](0x0,0xf0);function N(_0x225e09){const _0xc06f7f=a0_0xd22e14;return(_0x225e09 instanceof Error?_0x225e09['message']:String(_0x225e09??_0xc06f7f(0x10e)))[_0xc06f7f(0xf5)](K,_0xc06f7f(0xc8))[_0xc06f7f(0xf5)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0xc06f7f(0x11e)](0x0,0xf0);}function O(_0x4c6b1c,_0x13ddeb=process.env.ANET_TASK_TRACE_FORMAT===a0_0xd22e14(0x138)){const _0x4d3752=a0_0xd22e14;if(_0x13ddeb)return JSON['stringify'](_0x4c6b1c);let _0x55df5b=L(_0x4c6b1c[_0x4d3752(0xce)],_0x4d3752(0xf7)),_0x38d669=L(_0x4c6b1c[_0x4d3752(0xc4)],'<pending>'),_0xd005f9=_0x4c6b1c['error_code']?_0x4d3752(0xd6)+_0x4c6b1c['error_code']+':'+(_0x4c6b1c[_0x4d3752(0x106)]??''):'';return _0x4d3752(0xcd)+_0x4c6b1c[_0x4d3752(0xdb)]+'\x20from='+L(_0x4c6b1c['from_alias'],_0x4d3752(0xc7))+'\x20to='+L(_0x4c6b1c[_0x4d3752(0x108)],_0x4d3752(0xc7))+_0x4d3752(0xe6)+_0x38d669+_0x4d3752(0xc2)+_0x55df5b+_0x4d3752(0x132)+L(_0x4c6b1c[_0x4d3752(0x102)],_0x4d3752(0xc7))+_0x4d3752(0x126)+_0x4c6b1c[_0x4d3752(0xe7)]+'\x20duration_ms='+_0x4c6b1c['duration_ms']+_0x4d3752(0x120)+_0x4c6b1c[_0x4d3752(0x12c)]+_0xd005f9;}function U(_0x6ca7c7){const _0x49fb70=a0_0xd22e14;return{'event':{'sending':_0x49fb70(0x133),'delivered':_0x49fb70(0xdd),'failed':_0x49fb70(0xf0),'acked':_0x49fb70(0xcf),'started':_0x49fb70(0xd8),'replied':_0x49fb70(0xc5),'expired':_0x49fb70(0xfd)}[_0x6ca7c7['status']],..._0x6ca7c7};}function j(_0x3a2405){const _0x84511=a0_0xd22e14;let _0x15e4ae=_0x3a2405?.[_0x84511(0xc4)]||_0x3a2405?.[_0x84511(0x105)]||_0x3a2405?.['id'];if(_0x15e4ae)return String(_0x15e4ae);let _0x38bd0a=_0x3a2405?.[_0x84511(0xfe)]?.[0x0]?.[_0x84511(0x121)];if(typeof _0x38bd0a!==_0x84511(0xef))return null;try{let _0x2cbf5e=JSON[_0x84511(0x10f)](_0x38bd0a);return _0x2cbf5e?.[_0x84511(0xc4)]||_0x2cbf5e?.[_0x84511(0x105)]||_0x2cbf5e?.['id']||null;}catch{return null;}}async function X(_0xd13016,_0x1d4f7f){const _0x1dfacb=a0_0xd22e14;let _0x5080cb=_0x1d4f7f[_0x1dfacb(0xd3)]??Date[_0x1dfacb(0xd3)],_0x390743=_0x5080cb(),_0x1f1bbc=(_0x32b5b5,_0x43e76b,_0x2e3713,_0x553098)=>{const _0x10b7c9=_0x1dfacb;_0x1d4f7f[_0x10b7c9(0xf8)](O(U({'from_alias':_0xd13016[_0x10b7c9(0x114)],'to_alias':_0xd13016[_0x10b7c9(0xf1)],'task_id':_0x43e76b,'parent_task_id':_0xd13016[_0x10b7c9(0xf9)],'network_id':_0xd13016['networkId'],'transport':_0xd13016['transport'],'status':_0x32b5b5,'duration_ms':_0x5080cb()-_0x390743,'lifecycle_tracking':_0xd13016['lifecycleTracking'],..._0x2e3713!==void 0x0?{'error_code':_0x553098||_0x10b7c9(0xe2),'error_message':N(_0x2e3713)}:{}})));};_0x1f1bbc('sending',null);try{let _0x68d09e=await _0x1d4f7f['send'](),_0x229ce2=j(_0x68d09e);if(_0x229ce2)_0x1f1bbc(_0x1dfacb(0x11d),_0x229ce2);else{if(_0x68d09e?.['ok']===!0x1||_0x68d09e?.[_0x1dfacb(0x113)])_0x1f1bbc('failed',_0x229ce2,_0x68d09e?.[_0x1dfacb(0x113)]||_0x1dfacb(0x11f),_0x1dfacb(0xc6));else _0x1f1bbc(_0x1dfacb(0x119),null,_0x1dfacb(0xcb),_0x1dfacb(0x136));}return _0x68d09e;}catch(_0x4008cf){throw _0x1f1bbc(_0x1dfacb(0x119),null,_0x4008cf,_0x1dfacb(0xe2)),_0x4008cf;}}async function Y(_0xd2358,_0x46a346){const _0x3f954f=a0_0xd22e14;return X({'fromAlias':_0xd2358['fromAlias'],'toAlias':_0xd2358[_0x3f954f(0x10c)],'parentTaskId':_0xd2358[_0x3f954f(0xf9)]||null,'networkId':_0xd2358[_0x3f954f(0xee)]||null,'transport':_0x3f954f(0xfc),'lifecycleTracking':_0x3f954f(0x10a)},_0x46a346);}class $ extends a0_0x434893{[a0_0xd22e14(0x139)];[a0_0xd22e14(0x10c)];[a0_0xd22e14(0x110)];['agent'];['resumeId'];['heartbeatInterval'];['reconnectDelay'];[a0_0xd22e14(0x122)];[a0_0xd22e14(0xfa)];[a0_0xd22e14(0x107)]=!0x1;constructor(_0x457a5){const _0x46f622=a0_0xd22e14;super();if(this['url']=_0x457a5['url'][_0x46f622(0xf5)](/\/$/,''),this[_0x46f622(0x10c)]=_0x457a5[_0x46f622(0x10c)],this[_0x46f622(0x110)]=_0x457a5[_0x46f622(0x110)],this['agent']=_0x457a5[_0x46f622(0x116)]||_0x46f622(0x12b),this[_0x46f622(0x129)]='sdk-'+_0x457a5[_0x46f622(0x10c)]+'-'+Date[_0x46f622(0xd3)]()[_0x46f622(0xd4)](0x24),this[_0x46f622(0xed)]=_0x457a5[_0x46f622(0xed)]??0x2bf20,this[_0x46f622(0xd2)]=_0x457a5['reconnectDelay']??0xbb8,_0x457a5[_0x46f622(0xfb)]!==!0x1)this['connect']();}[a0_0xd22e14(0xf8)](_0x348bf5){const _0x450c54=a0_0xd22e14;console['log']('['+new Date()['toTimeString']()[_0x450c54(0x11e)](0x0,0x8)+_0x450c54(0x100)+this[_0x450c54(0x10c)]+']\x20'+_0x348bf5);}async[a0_0xd22e14(0x124)](_0x22e6b3,_0x63d323){const _0x528471=a0_0xd22e14;let _0xec98f6={'Content-Type':_0x528471(0xd7),'Accept':'application/json,\x20text/event-stream'};if(this[_0x528471(0x110)])_0xec98f6[_0x528471(0x127)]=_0x528471(0xf3)+this[_0x528471(0x110)];let _0x20c434=await(await fetch(this[_0x528471(0x139)]+_0x528471(0x111),{'method':'POST','headers':_0xec98f6,'body':JSON['stringify']({'jsonrpc':_0x528471(0xec),'id':Date['now'](),'method':_0x528471(0x118),'params':{'name':_0x22e6b3,'arguments':_0x63d323}})}))[_0x528471(0x121)](),_0x7d56a5=_0x20c434[_0x528471(0xe5)](/data: (.+)/),_0x1923be=_0x7d56a5?JSON[_0x528471(0x10f)](_0x7d56a5[0x1]):JSON[_0x528471(0x10f)](_0x20c434),_0x512b5d=_0x1923be?.[_0x528471(0xd1)]?.[_0x528471(0xfe)]?.[0x0]?.['text'];return _0x512b5d?JSON[_0x528471(0x10f)](_0x512b5d):_0x1923be;}async[a0_0xd22e14(0xea)](){const _0x83c0b8=a0_0xd22e14;if(this['running'])return;this[_0x83c0b8(0x107)]=!0x0,await this['status'](_0x83c0b8(0x131)),this[_0x83c0b8(0xf8)](_0x83c0b8(0x11b)),this[_0x83c0b8(0x122)]=setInterval(()=>{const _0x7b9ebb=_0x83c0b8;this[_0x7b9ebb(0xdb)]('idle')[_0x7b9ebb(0x135)](_0x37b5ef=>this[_0x7b9ebb(0xf8)](_0x7b9ebb(0x137)+_0x37b5ef[_0x7b9ebb(0xdc)]));},this[_0x83c0b8(0xed)]),this[_0x83c0b8(0xdf)]();}async['disconnect'](){const _0x2bf9fc=a0_0xd22e14;if(this['running']=!0x1,this[_0x2bf9fc(0xfa)]?.['abort'](),this['heartbeatTimer'])clearInterval(this[_0x2bf9fc(0x122)]);await this[_0x2bf9fc(0xdb)](_0x2bf9fc(0xda))[_0x2bf9fc(0x135)](()=>{}),this['log'](_0x2bf9fc(0xcc));}async[a0_0xd22e14(0xeb)](_0x23968c,_0x5bd7eb,_0x168ef4=a0_0xd22e14(0x10b)){const _0x2aaaca=a0_0xd22e14;return Y({'alias':_0x23968c,'fromAlias':this[_0x2aaaca(0x10c)]},{'log':_0x33e743=>console[_0x2aaaca(0xf8)](_0x33e743),'send':()=>this[_0x2aaaca(0x124)](_0x2aaaca(0x125),{'alias':_0x23968c,'task':_0x5bd7eb,'priority':_0x168ef4,'from_session':this[_0x2aaaca(0x10c)]})});}async[a0_0xd22e14(0xdc)](_0x73a19b,_0x422c12){const _0x42b86e=a0_0xd22e14;return this[_0x42b86e(0x124)](_0x42b86e(0x123),{'alias':_0x73a19b,'message':_0x422c12,'from_session':this[_0x42b86e(0x10c)]});}async['reply'](_0x1aa6f0,_0x87a4d3,_0xbd659e=a0_0xd22e14(0xe3)){const _0x506c71=a0_0xd22e14;return this[_0x506c71(0x124)]('send_reply',{'in_reply_to':_0x1aa6f0,'text':_0x87a4d3,'status':_0xbd659e});}async[a0_0xd22e14(0xdb)](_0x4ce3b0,_0x1fba53){const _0x5127fa=a0_0xd22e14;return this[_0x5127fa(0x124)](_0x5127fa(0xe9),{'resume_id':this['resumeId'],'alias':this[_0x5127fa(0x10c)],'status':_0x4ce3b0,'server':a0_0x73d679(),'hostname':a0_0x73d679(),'agent':this[_0x5127fa(0x116)],'project_dir':process['cwd'](),..._0x1fba53});}async['getAllStatus'](){const _0x8b21cb=a0_0xd22e14;return this['call'](_0x8b21cb(0xc9),{});}async['broadcast'](_0x195e48,_0x4744d3){const _0x494f8e=a0_0xd22e14;return this[_0x494f8e(0x124)]('broadcast',{'message':_0x195e48,'filter_server':_0x4744d3?.['server'],'filter_status':_0x4744d3?.[_0x494f8e(0xdb)]});}async[a0_0xd22e14(0xdf)](){const _0x144a09=a0_0xd22e14;let _0x2f2b0e=encodeURIComponent(this[_0x144a09(0x10c)]),_0x247441=this[_0x144a09(0x139)]+_0x144a09(0x11c)+_0x2f2b0e,_0x5b76e5=this[_0x144a09(0xd2)];while(this[_0x144a09(0x107)]){try{this[_0x144a09(0xfa)]=new AbortController();let _0x3af5ae={'Accept':_0x144a09(0x134)};if(this['token'])_0x3af5ae['Authorization']=_0x144a09(0xf3)+this[_0x144a09(0x110)];let _0x232c74=await fetch(_0x247441,{'headers':_0x3af5ae,'signal':this[_0x144a09(0xfa)]['signal']});if(!_0x232c74['ok']||!_0x232c74['body']){this[_0x144a09(0xf8)]('SSE\x20failed:\x20'+_0x232c74[_0x144a09(0xdb)]),await this['sleep'](_0x5b76e5),_0x5b76e5=Math[_0x144a09(0x115)](_0x5b76e5*1.5,0xea60);continue;}_0x5b76e5=this[_0x144a09(0xd2)];let _0x4cb610=_0x232c74['body']['getReader'](),_0x37a21b=new TextDecoder(),_0x2af45b='';while(this[_0x144a09(0x107)]){let {done:_0xbd8184,value:_0x2aec28}=await _0x4cb610[_0x144a09(0x112)]();if(_0xbd8184)break;_0x2af45b+=_0x37a21b[_0x144a09(0x103)](_0x2aec28,{'stream':!0x0});let _0x3090c6=_0x2af45b[_0x144a09(0x12e)]('\x0a');_0x2af45b=_0x3090c6['pop']()||'';for(let _0x4d642a of _0x3090c6){if(!_0x4d642a[_0x144a09(0xf4)](_0x144a09(0x109)))continue;try{let _0x5337e8=JSON[_0x144a09(0x10f)](_0x4d642a[_0x144a09(0x11e)](0x6));if(_0x5337e8[_0x144a09(0xc1)]==='connected'){this[_0x144a09(0xf8)](_0x144a09(0xd5)),this[_0x144a09(0x101)](_0x144a09(0x128));continue;}if(_0x5337e8[_0x144a09(0xc1)]==='new_task'||_0x5337e8[_0x144a09(0xc1)]==='new_message'||_0x5337e8[_0x144a09(0xc1)]===_0x144a09(0x117))await this[_0x144a09(0xff)]();}catch{}}}}catch(_0xb0eda2){if(_0xb0eda2[_0x144a09(0xe1)]===_0x144a09(0x104))break;this['emit']('error',_0xb0eda2),this[_0x144a09(0xf8)]('SSE\x20error:\x20'+_0xb0eda2[_0x144a09(0xdc)]);}if(this[_0x144a09(0x107)])this[_0x144a09(0x101)]('disconnected'),this[_0x144a09(0xf8)](_0x144a09(0x12d)+_0x5b76e5/0x3e8+_0x144a09(0xd0)),await this[_0x144a09(0xf6)](_0x5b76e5),_0x5b76e5=Math[_0x144a09(0x115)](_0x5b76e5*1.5,0xea60);}}async['processInbox'](){const _0x38e38e=a0_0xd22e14;try{let _0x4b58a8=(await this[_0x38e38e(0x124)]('get_inbox',{'alias':this[_0x38e38e(0x10c)],'limit':0xa}))?.['messages']||[];for(let _0x48763c of _0x4b58a8)await this[_0x38e38e(0x124)]('ack_inbox',{'alias':this[_0x38e38e(0x10c)],'message_id':_0x48763c['id']}),this[_0x38e38e(0xf8)]('←\x20'+_0x48763c[_0x38e38e(0xca)]+':\x20'+_0x48763c[_0x38e38e(0xfe)][_0x38e38e(0x11e)](0x0,0x3c)),this[_0x38e38e(0x101)](_0x38e38e(0x12f),_0x48763c),this[_0x38e38e(0x101)](_0x38e38e(0xdc),_0x48763c);}catch(_0x1fbeed){this[_0x38e38e(0xf8)]('inbox\x20error:\x20'+_0x1fbeed[_0x38e38e(0xdc)]);}}[a0_0xd22e14(0xf6)](_0x52bd8d){return new Promise(_0x31f66f=>setTimeout(_0x31f66f,_0x52bd8d));}}var F=$;function a0_0x58dd(){const _0x31373f=['CommHub\x20response\x20omitted\x20task_id','disconnected','[commhub:task]\x20','parent_task_id','task.ack','s...','result','reconnectDelay','now','toString','SSE\x20connected','\x20error=','application/json','task.started','20PDLRXU','offline','status','message','task.send.delivered','2yApTnq','connectSSE','2916048ledaMH','name','send_failed','completed','5HVefun','match','\x20task_id=','transport','691738BUmITr','report_status','connect','send','2.0','heartbeatInterval','networkId','string','task.send.failed','toAlias','343428ISLoou','Bearer\x20','startsWith','replace','sleep','<missing>','log','parentTaskId','sseAbort','autoConnect','mcp_http','task.expired','content','processInbox',']\x20[commhub:','emit','network_id','decode','AbortError','message_id','error_message','running','to_alias','data:\x20','not_tracked','normal','alias','4218624XFwodf','unknown\x20error','parse','token','/mcp','read','error','fromAlias','min','agent','broadcast','tools/call','failed','7gcycnw','registered','/events/','delivered','slice','CommHub\x20rejected\x20task','\x20lifecycle=','text','heartbeatTimer','send_message','call','send_task','\x20transport=','Authorization','connected','resumeId','374mRNKUJ','sdk','lifecycle_tracking','SSE\x20reconnecting\x20in\x20','split','task','413128qLDXZR','idle','\x20network_id=','task.send.start','text/event-stream','catch','missing_task_id','heartbeat\x20failed:\x20','json','url','3090240bMwFnO','type','\x20parent_task_id=','2729334sQQtzI','task_id','task.replied','send_rejected','<unknown>','[REDACTED]','get_all_status','from_session'];a0_0x58dd=function(){return _0x31373f;};return a0_0x58dd();}export{F as default,$ as CommHub};
|
|
@@ -2,22 +2,36 @@
|
|
|
2
2
|
* RFC-020 §2.5 / RFC-002 §2.2 — Feishu bridge worker.
|
|
3
3
|
*
|
|
4
4
|
* Entry point spawned by agent-node when a node profile has `channels.feishu`
|
|
5
|
-
* enabled.
|
|
6
|
-
* "agent-node direct bridge" model, not the full commhub-gateway:
|
|
5
|
+
* enabled. This worker owns the FeishuAdapter and its WSClient connection.
|
|
7
6
|
*
|
|
8
|
-
*
|
|
9
|
-
* - Inbound IM event → access whitelist gate → forward to agent-node's main
|
|
10
|
-
* `think()` via parent IPC.
|
|
11
|
-
* - think() result → adapter.send() back to the originating conversation.
|
|
7
|
+
* 🔴 There are TWO outbound paths, and which one runs is decided at line ~445:
|
|
12
8
|
*
|
|
13
|
-
*
|
|
9
|
+
* const client = commhubClient ?? createEnvCommHubClient();
|
|
10
|
+
* if (client) return createCommHubEventHandler(...); // (A)
|
|
11
|
+
* if (typeof process.send === "function") ... // (B)
|
|
12
|
+
*
|
|
13
|
+
* (A) CommHub task dispatch — **the default on any real node.**
|
|
14
|
+
* `createEnvCommHubClient()` returns null only when neither COMMHUB_URL
|
|
15
|
+
* nor ANET_HUB_URL is set, and every provisioned node has one. Replies
|
|
16
|
+
* carry `in_reply_to`, and the correlation store tracks task status.
|
|
17
|
+
* (B) parent IPC → agent-node's `think()` — the fallback when there is no
|
|
18
|
+
* hub URL in env (standalone / test harness).
|
|
19
|
+
*
|
|
20
|
+
* Both paths end at adapter.send() back to the originating conversation.
|
|
21
|
+
*
|
|
22
|
+
* 🔴 This block used to say the opposite —— verbatim:
|
|
23
|
+
* "IM messages do NOT pass through commhub task dispatch."
|
|
24
|
+
* That was true of the 2026-06-24 first cut, and stayed in the file after
|
|
25
|
+
* the commhub path landed (#1252, merged 2026-08-27). It is the first thing
|
|
26
|
+
* anyone reads in this file, so it mis-answered the question "does Feishu go
|
|
27
|
+
* through CommHub" for at least one reader before being caught. If you change
|
|
28
|
+
* which path is default, change these lines in the same commit.
|
|
29
|
+
*
|
|
30
|
+
* Still true of both paths (unchanged from the first cut):
|
|
14
31
|
* - No separate gateway ntok_ / dedicated commhub alias.
|
|
15
|
-
* - IM messages do NOT pass through commhub task dispatch.
|
|
16
|
-
* - Feishu messages do NOT appear in Dashboard topology / Chat.
|
|
17
32
|
*
|
|
18
|
-
* The
|
|
19
|
-
*
|
|
20
|
-
* — tracked in #182.
|
|
33
|
+
* The remaining §2.9 work (meta_json columns, SSE passthrough, Dashboard
|
|
34
|
+
* topology / Chat visibility for Feishu conversations) is tracked in #182.
|
|
21
35
|
*
|
|
22
36
|
* Milestones:
|
|
23
37
|
* M1: worker entry scaffold.
|
|
@@ -73,6 +87,8 @@ export interface FeishuBridgeOptions {
|
|
|
73
87
|
commhubClient?: IMBridgeCommHubClient;
|
|
74
88
|
/** Poll interval for CommHub replies. Defaults to 1500ms. */
|
|
75
89
|
commhubPollMs?: number;
|
|
90
|
+
/** 出站传输模式。省略时按 ANET_FEISHU_BRIDGE_MODE,再省略则 "direct"。 */
|
|
91
|
+
bridgeMode?: FeishuBridgeMode;
|
|
76
92
|
}
|
|
77
93
|
/** Bridge → parent: inbound IM event ready for think(). */
|
|
78
94
|
export interface BridgeIncomingEnvelope {
|
|
@@ -130,6 +146,24 @@ export type WithRateLimitHandle = {
|
|
|
130
146
|
floodKeyCount: number;
|
|
131
147
|
};
|
|
132
148
|
};
|
|
149
|
+
/**
|
|
150
|
+
* 出站传输模式。**显式声明,不靠环境变量在场与否去猜。**
|
|
151
|
+
*
|
|
152
|
+
* direct — parent IPC → agent-node 的 think()。**默认。**
|
|
153
|
+
* 2026-06-24 的第一版路径,飞书消息不进 CommHub 任务分发,
|
|
154
|
+
* 也不出现在 Dashboard 拓扑 / Chat 里。
|
|
155
|
+
* commhub — 入站事件变成一个 CommHub task,回复带 in_reply_to,
|
|
156
|
+
* correlation store 跟踪状态。**必须显式打开。**
|
|
157
|
+
*
|
|
158
|
+
* 🔴 为什么要显式:在此之前是 `commhubClient ?? createEnvCommHubClient()` ——
|
|
159
|
+
* 有 COMMHUB_URL 就走 commhub、没有就悄悄回落 IPC。两条路径的可观测性、
|
|
160
|
+
* Dashboard 可见性、失败语义完全不同,而**运维看不出自己在哪条上**,
|
|
161
|
+
* 文件头注释也因此和代码说了相反的话长达一次发布。
|
|
162
|
+
*/
|
|
163
|
+
export type FeishuBridgeMode = "commhub" | "direct";
|
|
164
|
+
export declare const DEFAULT_FEISHU_BRIDGE_MODE: FeishuBridgeMode;
|
|
165
|
+
/** 解析模式。优先级:显式入参 > 环境变量 > 默认。非法值直接抛,不静默取默认。 */
|
|
166
|
+
export declare function resolveFeishuBridgeMode(explicit?: FeishuBridgeMode, env?: NodeJS.ProcessEnv): FeishuBridgeMode;
|
|
133
167
|
/**
|
|
134
168
|
* IPC handler — forwards inbound events to the parent agent-node and routes
|
|
135
169
|
* the parent's reply back to Feishu via the adapter. The parent contract is
|