@sleep2agi/agent-network 2.3.0-preview.110 → 2.3.0-preview.111
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_0x299df7=a0_0x1702;(function(_0x3c2861,_0x2ece58){const _0xc758b8=a0_0x1702,_0x32f1e7=_0x3c2861();while(!![]){try{const _0x897b03=-parseInt(_0xc758b8(0x1d1))/0x1*(-parseInt(_0xc758b8(0x1b8))/0x2)+-parseInt(_0xc758b8(0x198))/0x3+parseInt(_0xc758b8(0x1bd))/0x4*(parseInt(_0xc758b8(0x1db))/0x5)+-parseInt(_0xc758b8(0x1c4))/0x6+parseInt(_0xc758b8(0x194))/0x7+-parseInt(_0xc758b8(0x1a2))/0x8*(-parseInt(_0xc758b8(0x1eb))/0x9)+-parseInt(_0xc758b8(0x18b))/0xa*(parseInt(_0xc758b8(0x199))/0xb);if(_0x897b03===_0x2ece58)break;else _0x32f1e7['push'](_0x32f1e7['shift']());}catch(_0x5194b7){_0x32f1e7['push'](_0x32f1e7['shift']());}}}(a0_0x2af0,0xb1cf2));import{EventEmitter as a0_0x243591}from'events';import{hostname as a0_0x29b66a}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x412db3,_0xdc3f)=>(_0x412db3??_0xdc3f)[a0_0x299df7(0x1b1)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x299df7(0x1ff)](0x0,0xf0);function N(_0x1e1dc4){const _0x37cffa=a0_0x299df7;return(_0x1e1dc4 instanceof Error?_0x1e1dc4[_0x37cffa(0x1a7)]:String(_0x1e1dc4??'unknown\x20error'))[_0x37cffa(0x1b1)](K,'[REDACTED]')['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x37cffa(0x1ff)](0x0,0xf0);}function a0_0x2af0(){const _0x1be8a8=['SSE\x20failed:\x20','getAllStatus','parse','reply','startsWith','<missing>','error_code','network_id','type','toString','connect','sending','min','474120PttKzj','from_alias','report_status','failed','Bearer\x20','\x20transport=','stringify','send_reply','<pending>','fromAlias','to_alias','call','getReader','match','error','abort','url','send_task','sdk-','2.0','slice','\x20duration_ms=','inbox\x20error:\x20','application/json','duration_ms','data:\x20','\x20from=','task.started','47810vVpceb','idle','parentTaskId','status','SSE\x20reconnecting\x20in\x20','lifecycleTracking','connectSSE','running','reconnectDelay','6753355ktAjIL','text','message_id','send_rejected','1360965AaDQEq','2167nXQakN','cwd','disconnected','get_all_status','emit',']\x20[commhub:','processInbox','networkId','catch','32pGIQHp','now','agent','[commhub:task]\x20','json','message','log','sleep','heartbeatTimer','heartbeatInterval','pop','\x20error=','not_tracked','delivered','tools/call','replace','parent_task_id','text/event-stream','CommHub\x20response\x20omitted\x20task_id','sseAbort','send','connected','3826ajLoWa','Authorization','task.send.failed','mcp_http','new_message','8iirrEE','content','/mcp','s...','broadcast','token','POST','3166188GeCsbE','transport','ack_inbox','decode','task.replied','\x20network_id=','<unknown>','normal','signal','task.expired','application/json,\x20text/event-stream','task_id','from_session','73vmhcGp','body','heartbeat\x20failed:\x20','alias','SSE\x20error:\x20','resumeId','send_failed','task.send.start','new_task','read','3340955CtXfGp','toTimeString','\x20lifecycle='];a0_0x2af0=function(){return _0x1be8a8;};return a0_0x2af0();}function O(_0x2979fe,_0x5e97c0=process.env.ANET_TASK_TRACE_FORMAT===a0_0x299df7(0x1a6)){const _0xe754fc=a0_0x299df7;if(_0x5e97c0)return JSON[_0xe754fc(0x1f1)](_0x2979fe);let _0x1075ed=L(_0x2979fe[_0xe754fc(0x1b2)],_0xe754fc(0x1e3)),_0x4b31b8=L(_0x2979fe['task_id'],_0xe754fc(0x1f3)),_0x4489f5=_0x2979fe[_0xe754fc(0x1e4)]?_0xe754fc(0x1ad)+_0x2979fe[_0xe754fc(0x1e4)]+':'+(_0x2979fe['error_message']??''):'';return _0xe754fc(0x1a5)+_0x2979fe[_0xe754fc(0x18e)]+_0xe754fc(0x189)+L(_0x2979fe[_0xe754fc(0x1ec)],_0xe754fc(0x1ca))+'\x20to='+L(_0x2979fe[_0xe754fc(0x1f5)],_0xe754fc(0x1ca))+'\x20task_id='+_0x4b31b8+'\x20parent_task_id='+_0x1075ed+_0xe754fc(0x1c9)+L(_0x2979fe[_0xe754fc(0x1e5)],_0xe754fc(0x1ca))+_0xe754fc(0x1f0)+_0x2979fe[_0xe754fc(0x1c5)]+_0xe754fc(0x200)+_0x2979fe[_0xe754fc(0x187)]+_0xe754fc(0x1dd)+_0x2979fe['lifecycle_tracking']+_0x4489f5;}function U(_0x11919c){const _0x1cfabe=a0_0x299df7;return{'event':{'sending':_0x1cfabe(0x1d8),'delivered':'task.send.delivered','failed':_0x1cfabe(0x1ba),'acked':'task.ack','started':_0x1cfabe(0x18a),'replied':_0x1cfabe(0x1c8),'expired':_0x1cfabe(0x1cd)}[_0x11919c[_0x1cfabe(0x18e)]],..._0x11919c};}function j(_0x2162cf){const _0x369abc=a0_0x299df7;let _0x293409=_0x2162cf?.[_0x369abc(0x1cf)]||_0x2162cf?.['message_id']||_0x2162cf?.['id'];if(_0x293409)return String(_0x293409);let _0x4b3c43=_0x2162cf?.[_0x369abc(0x1be)]?.[0x0]?.[_0x369abc(0x195)];if(typeof _0x4b3c43!=='string')return null;try{let _0x319218=JSON[_0x369abc(0x1e0)](_0x4b3c43);return _0x319218?.[_0x369abc(0x1cf)]||_0x319218?.[_0x369abc(0x196)]||_0x319218?.['id']||null;}catch{return null;}}async function X(_0x2d0768,_0xfc4e68){const _0x2931eb=a0_0x299df7;let _0x2abfd4=_0xfc4e68[_0x2931eb(0x1a3)]??Date['now'],_0x24272d=_0x2abfd4(),_0x4a6715=(_0x5ee53f,_0x23c4e3,_0x1ad9b3,_0x34ad5a)=>{const _0x45f006=_0x2931eb;_0xfc4e68[_0x45f006(0x1a8)](O(U({'from_alias':_0x2d0768['fromAlias'],'to_alias':_0x2d0768['toAlias'],'task_id':_0x23c4e3,'parent_task_id':_0x2d0768[_0x45f006(0x18d)],'network_id':_0x2d0768[_0x45f006(0x1a0)],'transport':_0x2d0768[_0x45f006(0x1c5)],'status':_0x5ee53f,'duration_ms':_0x2abfd4()-_0x24272d,'lifecycle_tracking':_0x2d0768[_0x45f006(0x190)],..._0x1ad9b3!==void 0x0?{'error_code':_0x34ad5a||'send_failed','error_message':N(_0x1ad9b3)}:{}})));};_0x4a6715(_0x2931eb(0x1e9),null);try{let _0x3d2bb6=await _0xfc4e68[_0x2931eb(0x1b6)](),_0xaa36a4=j(_0x3d2bb6);if(_0xaa36a4)_0x4a6715(_0x2931eb(0x1af),_0xaa36a4);else{if(_0x3d2bb6?.['ok']===!0x1||_0x3d2bb6?.[_0x2931eb(0x1f9)])_0x4a6715(_0x2931eb(0x1ee),_0xaa36a4,_0x3d2bb6?.[_0x2931eb(0x1f9)]||'CommHub\x20rejected\x20task',_0x2931eb(0x197));else _0x4a6715(_0x2931eb(0x1ee),null,_0x2931eb(0x1b4),'missing_task_id');}return _0x3d2bb6;}catch(_0x535214){throw _0x4a6715(_0x2931eb(0x1ee),null,_0x535214,_0x2931eb(0x1d7)),_0x535214;}}async function Y(_0x8441f8,_0x205aa3){const _0x262aa1=a0_0x299df7;return X({'fromAlias':_0x8441f8[_0x262aa1(0x1f4)],'toAlias':_0x8441f8[_0x262aa1(0x1d4)],'parentTaskId':_0x8441f8[_0x262aa1(0x18d)]||null,'networkId':_0x8441f8['networkId']||null,'transport':_0x262aa1(0x1bb),'lifecycleTracking':_0x262aa1(0x1ae)},_0x205aa3);}function a0_0x1702(_0x3fa9a6,_0x4cdf26){_0x3fa9a6=_0x3fa9a6-0x185;const _0x2af0de=a0_0x2af0();let _0x1702f1=_0x2af0de[_0x3fa9a6];return _0x1702f1;}class $ extends a0_0x243591{['url'];['alias'];[a0_0x299df7(0x1c2)];[a0_0x299df7(0x1a4)];[a0_0x299df7(0x1d6)];[a0_0x299df7(0x1ab)];['reconnectDelay'];[a0_0x299df7(0x1aa)];[a0_0x299df7(0x1b5)];['running']=!0x1;constructor(_0x22b9dc){const _0x31ff1c=a0_0x299df7;super();if(this['url']=_0x22b9dc['url'][_0x31ff1c(0x1b1)](/\/$/,''),this['alias']=_0x22b9dc[_0x31ff1c(0x1d4)],this[_0x31ff1c(0x1c2)]=_0x22b9dc['token'],this['agent']=_0x22b9dc[_0x31ff1c(0x1a4)]||'sdk',this[_0x31ff1c(0x1d6)]=_0x31ff1c(0x1fd)+_0x22b9dc[_0x31ff1c(0x1d4)]+'-'+Date[_0x31ff1c(0x1a3)]()[_0x31ff1c(0x1e7)](0x24),this['heartbeatInterval']=_0x22b9dc[_0x31ff1c(0x1ab)]??0x2bf20,this[_0x31ff1c(0x193)]=_0x22b9dc[_0x31ff1c(0x193)]??0xbb8,_0x22b9dc['autoConnect']!==!0x1)this[_0x31ff1c(0x1e8)]();}['log'](_0x2878da){const _0x3dbbcf=a0_0x299df7;console['log']('['+new Date()[_0x3dbbcf(0x1dc)]()['slice'](0x0,0x8)+_0x3dbbcf(0x19e)+this['alias']+']\x20'+_0x2878da);}async[a0_0x299df7(0x1f6)](_0x5435ec,_0x260c01){const _0x42f2c8=a0_0x299df7;let _0x4d8388={'Content-Type':_0x42f2c8(0x186),'Accept':_0x42f2c8(0x1ce)};if(this['token'])_0x4d8388[_0x42f2c8(0x1b9)]='Bearer\x20'+this['token'];let _0xb7c83d=await(await fetch(this[_0x42f2c8(0x1fb)]+_0x42f2c8(0x1bf),{'method':_0x42f2c8(0x1c3),'headers':_0x4d8388,'body':JSON[_0x42f2c8(0x1f1)]({'jsonrpc':_0x42f2c8(0x1fe),'id':Date[_0x42f2c8(0x1a3)](),'method':_0x42f2c8(0x1b0),'params':{'name':_0x5435ec,'arguments':_0x260c01}})}))['text'](),_0x5f5c36=_0xb7c83d[_0x42f2c8(0x1f8)](/data: (.+)/),_0x25a33c=_0x5f5c36?JSON[_0x42f2c8(0x1e0)](_0x5f5c36[0x1]):JSON['parse'](_0xb7c83d),_0x523a6b=_0x25a33c?.['result']?.[_0x42f2c8(0x1be)]?.[0x0]?.['text'];return _0x523a6b?JSON[_0x42f2c8(0x1e0)](_0x523a6b):_0x25a33c;}async[a0_0x299df7(0x1e8)](){const _0x39682b=a0_0x299df7;if(this[_0x39682b(0x192)])return;this[_0x39682b(0x192)]=!0x0,await this['status']('idle'),this[_0x39682b(0x1a8)]('registered'),this[_0x39682b(0x1aa)]=setInterval(()=>{const _0x3fae7d=_0x39682b;this[_0x3fae7d(0x18e)](_0x3fae7d(0x18c))[_0x3fae7d(0x1a1)](_0x36515e=>this[_0x3fae7d(0x1a8)](_0x3fae7d(0x1d3)+_0x36515e[_0x3fae7d(0x1a7)]));},this['heartbeatInterval']),this[_0x39682b(0x191)]();}async['disconnect'](){const _0xc6488d=a0_0x299df7;if(this[_0xc6488d(0x192)]=!0x1,this['sseAbort']?.[_0xc6488d(0x1fa)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0xc6488d(0x18e)]('offline')[_0xc6488d(0x1a1)](()=>{}),this[_0xc6488d(0x1a8)](_0xc6488d(0x19b));}async[a0_0x299df7(0x1b6)](_0x5acb85,_0x41459f,_0x50dcc4=a0_0x299df7(0x1cb)){const _0x476d58=a0_0x299df7;return Y({'alias':_0x5acb85,'fromAlias':this[_0x476d58(0x1d4)]},{'log':_0x4505c9=>console['log'](_0x4505c9),'send':()=>this[_0x476d58(0x1f6)](_0x476d58(0x1fc),{'alias':_0x5acb85,'task':_0x41459f,'priority':_0x50dcc4,'from_session':this[_0x476d58(0x1d4)]})});}async['message'](_0x31cf67,_0x4f536d){const _0x521b86=a0_0x299df7;return this[_0x521b86(0x1f6)]('send_message',{'alias':_0x31cf67,'message':_0x4f536d,'from_session':this[_0x521b86(0x1d4)]});}async[a0_0x299df7(0x1e1)](_0x49fa7d,_0x5d1047,_0x991c81='completed'){const _0x50ccf2=a0_0x299df7;return this[_0x50ccf2(0x1f6)](_0x50ccf2(0x1f2),{'in_reply_to':_0x49fa7d,'text':_0x5d1047,'status':_0x991c81});}async[a0_0x299df7(0x18e)](_0x3953cc,_0x3bb175){const _0x30b470=a0_0x299df7;return this[_0x30b470(0x1f6)](_0x30b470(0x1ed),{'resume_id':this[_0x30b470(0x1d6)],'alias':this[_0x30b470(0x1d4)],'status':_0x3953cc,'server':a0_0x29b66a(),'hostname':a0_0x29b66a(),'agent':this['agent'],'project_dir':process[_0x30b470(0x19a)](),..._0x3bb175});}async[a0_0x299df7(0x1df)](){const _0x858caa=a0_0x299df7;return this[_0x858caa(0x1f6)](_0x858caa(0x19c),{});}async[a0_0x299df7(0x1c1)](_0x5b2edc,_0x41e67d){const _0x514c6d=a0_0x299df7;return this[_0x514c6d(0x1f6)](_0x514c6d(0x1c1),{'message':_0x5b2edc,'filter_server':_0x41e67d?.['server'],'filter_status':_0x41e67d?.['status']});}async[a0_0x299df7(0x191)](){const _0x497b93=a0_0x299df7;let _0x2386ef=encodeURIComponent(this['alias']),_0x4001d5=this['url']+'/events/'+_0x2386ef,_0x1b2390=this[_0x497b93(0x193)];while(this[_0x497b93(0x192)]){try{this[_0x497b93(0x1b5)]=new AbortController();let _0x17fc99={'Accept':_0x497b93(0x1b3)};if(this[_0x497b93(0x1c2)])_0x17fc99[_0x497b93(0x1b9)]=_0x497b93(0x1ef)+this[_0x497b93(0x1c2)];let _0x4ef46d=await fetch(_0x4001d5,{'headers':_0x17fc99,'signal':this['sseAbort'][_0x497b93(0x1cc)]});if(!_0x4ef46d['ok']||!_0x4ef46d[_0x497b93(0x1d2)]){this['log'](_0x497b93(0x1de)+_0x4ef46d[_0x497b93(0x18e)]),await this[_0x497b93(0x1a9)](_0x1b2390),_0x1b2390=Math['min'](_0x1b2390*1.5,0xea60);continue;}_0x1b2390=this['reconnectDelay'];let _0x253f76=_0x4ef46d['body'][_0x497b93(0x1f7)](),_0x53e39b=new TextDecoder(),_0x464446='';while(this[_0x497b93(0x192)]){let {done:_0x39afc2,value:_0x523d91}=await _0x253f76[_0x497b93(0x1da)]();if(_0x39afc2)break;_0x464446+=_0x53e39b[_0x497b93(0x1c7)](_0x523d91,{'stream':!0x0});let _0x3bd7b2=_0x464446['split']('\x0a');_0x464446=_0x3bd7b2[_0x497b93(0x1ac)]()||'';for(let _0x20bc34 of _0x3bd7b2){if(!_0x20bc34[_0x497b93(0x1e2)](_0x497b93(0x188)))continue;try{let _0x97957=JSON['parse'](_0x20bc34[_0x497b93(0x1ff)](0x6));if(_0x97957[_0x497b93(0x1e6)]===_0x497b93(0x1b7)){this[_0x497b93(0x1a8)]('SSE\x20connected'),this[_0x497b93(0x19d)](_0x497b93(0x1b7));continue;}if(_0x97957['type']===_0x497b93(0x1d9)||_0x97957[_0x497b93(0x1e6)]===_0x497b93(0x1bc)||_0x97957[_0x497b93(0x1e6)]===_0x497b93(0x1c1))await this[_0x497b93(0x19f)]();}catch{}}}}catch(_0x4f6052){if(_0x4f6052['name']==='AbortError')break;this[_0x497b93(0x19d)](_0x497b93(0x1f9),_0x4f6052),this[_0x497b93(0x1a8)](_0x497b93(0x1d5)+_0x4f6052[_0x497b93(0x1a7)]);}if(this[_0x497b93(0x192)])this[_0x497b93(0x19d)]('disconnected'),this[_0x497b93(0x1a8)](_0x497b93(0x18f)+_0x1b2390/0x3e8+_0x497b93(0x1c0)),await this[_0x497b93(0x1a9)](_0x1b2390),_0x1b2390=Math[_0x497b93(0x1ea)](_0x1b2390*1.5,0xea60);}}async[a0_0x299df7(0x19f)](){const _0x1ae8f4=a0_0x299df7;try{let _0xe0c788=(await this['call']('get_inbox',{'alias':this[_0x1ae8f4(0x1d4)],'limit':0xa}))?.['messages']||[];for(let _0x5ef687 of _0xe0c788)await this[_0x1ae8f4(0x1f6)](_0x1ae8f4(0x1c6),{'alias':this['alias'],'message_id':_0x5ef687['id']}),this[_0x1ae8f4(0x1a8)]('←\x20'+_0x5ef687[_0x1ae8f4(0x1d0)]+':\x20'+_0x5ef687['content'][_0x1ae8f4(0x1ff)](0x0,0x3c)),this['emit']('task',_0x5ef687),this['emit']('message',_0x5ef687);}catch(_0x5c76b9){this[_0x1ae8f4(0x1a8)](_0x1ae8f4(0x185)+_0x5c76b9[_0x1ae8f4(0x1a7)]);}}[a0_0x299df7(0x1a9)](_0x4bbc6d){return new Promise(_0x250412=>setTimeout(_0x250412,_0x4bbc6d));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
function a0_0x3382(){const _0xea0559=['SSE\x20failed:\x20','get_all_status','alias','abort','task.started','\x20duration_ms=','type','SSE\x20error:\x20','send','disconnected','data:\x20','AbortError','from_alias','615156FSeCEu','catch','s...','offline','heartbeatInterval','min','replace','text/event-stream','processInbox','\x20parent_task_id=','content','network_id','transport','parent_task_id','running','sseAbort','tools/call','connected','error','autoConnect','<pending>','application/json','CommHub\x20response\x20omitted\x20task_id','sleep','1723156XqVmlz','15794001rlVHYF','connectSSE','report_status','to_alias','new_message','task','broadcast','78qkZQEO','Authorization','\x20from=','cwd','task.expired','reconnectDelay','8568959otsEhV','slice','message','<unknown>','Bearer\x20','registered','SSE\x20reconnecting\x20in\x20','call','task.ack','signal','[REDACTED]','connect','fromAlias','application/json,\x20text/event-stream','\x20task_id=','\x20transport=','token','message_id','[commhub:task]\x20','missing_task_id','agent','inbox\x20error:\x20','6880405jcVnQQ','match','normal','5431482VZAhXy','2.0','\x20network_id=','/mcp','status','toTimeString','now','split','task_id','text','read','mcp_http','ack_inbox','parse','failed','startsWith','reply',']\x20[commhub:','POST','server','8hqXtQN','<missing>','getAllStatus','\x20to=','name','delivered','resumeId','unknown\x20error','97580CTmIxV','heartbeatTimer','send_failed','error_code','\x20error=','getReader','error_message','pop','send_task','get_inbox','disconnect','task.send.start','url','log','task.send.delivered','CommHub\x20rejected\x20task','emit','body','completed','stringify','duration_ms','string'];a0_0x3382=function(){return _0xea0559;};return a0_0x3382();}const a0_0x27e4e3=a0_0x1e42;function a0_0x1e42(_0xf905eb,_0x779b8d){_0xf905eb=_0xf905eb-0x12a;const _0x3382e0=a0_0x3382();let _0x1e4297=_0x3382e0[_0xf905eb];return _0x1e4297;}(function(_0x90da6,_0x3e6638){const _0x36ca51=a0_0x1e42,_0x20cd61=_0x90da6();while(!![]){try{const _0x562b6b=-parseInt(_0x36ca51(0x198))/0x1+-parseInt(_0x36ca51(0x132))/0x2+parseInt(_0x36ca51(0x13a))/0x3*(parseInt(_0x36ca51(0x175))/0x4)+parseInt(_0x36ca51(0x156))/0x5+parseInt(_0x36ca51(0x159))/0x6+parseInt(_0x36ca51(0x140))/0x7+parseInt(_0x36ca51(0x16d))/0x8*(-parseInt(_0x36ca51(0x133))/0x9);if(_0x562b6b===_0x3e6638)break;else _0x20cd61['push'](_0x20cd61['shift']());}catch(_0x21f0e5){_0x20cd61['push'](_0x20cd61['shift']());}}}(a0_0x3382,0xddb50));import{EventEmitter as a0_0x542b01}from'events';import{hostname as a0_0x4e6936}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xd41c9c,_0x182e26)=>(_0xd41c9c??_0x182e26)[a0_0x27e4e3(0x19e)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x467dfc){const _0x95e0ae=a0_0x27e4e3;return(_0x467dfc instanceof Error?_0x467dfc[_0x95e0ae(0x142)]:String(_0x467dfc??_0x95e0ae(0x174)))[_0x95e0ae(0x19e)](K,_0x95e0ae(0x14a))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x95e0ae(0x141)](0x0,0xf0);}function O(_0x1fe4e9,_0x5b6f2d=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x2037b8=a0_0x27e4e3;if(_0x5b6f2d)return JSON[_0x2037b8(0x188)](_0x1fe4e9);let _0x478d57=L(_0x1fe4e9[_0x2037b8(0x1a5)],_0x2037b8(0x16e)),_0x3273e3=L(_0x1fe4e9['task_id'],_0x2037b8(0x12e)),_0x36f482=_0x1fe4e9[_0x2037b8(0x178)]?_0x2037b8(0x179)+_0x1fe4e9['error_code']+':'+(_0x1fe4e9[_0x2037b8(0x17b)]??''):'';return _0x2037b8(0x152)+_0x1fe4e9[_0x2037b8(0x15d)]+_0x2037b8(0x13c)+L(_0x1fe4e9[_0x2037b8(0x197)],_0x2037b8(0x143))+_0x2037b8(0x170)+L(_0x1fe4e9[_0x2037b8(0x136)],_0x2037b8(0x143))+_0x2037b8(0x14e)+_0x3273e3+_0x2037b8(0x1a1)+_0x478d57+_0x2037b8(0x15b)+L(_0x1fe4e9[_0x2037b8(0x1a3)],_0x2037b8(0x143))+_0x2037b8(0x14f)+_0x1fe4e9['transport']+_0x2037b8(0x190)+_0x1fe4e9[_0x2037b8(0x189)]+'\x20lifecycle='+_0x1fe4e9['lifecycle_tracking']+_0x36f482;}function U(_0x5f36ca){const _0x480a19=a0_0x27e4e3;return{'event':{'sending':_0x480a19(0x180),'delivered':_0x480a19(0x183),'failed':'task.send.failed','acked':_0x480a19(0x148),'started':_0x480a19(0x18f),'replied':'task.replied','expired':_0x480a19(0x13e)}[_0x5f36ca[_0x480a19(0x15d)]],..._0x5f36ca};}function j(_0x256d22){const _0x32f770=a0_0x27e4e3;let _0x29aa0d=_0x256d22?.[_0x32f770(0x161)]||_0x256d22?.[_0x32f770(0x151)]||_0x256d22?.['id'];if(_0x29aa0d)return String(_0x29aa0d);let _0x3ee371=_0x256d22?.['content']?.[0x0]?.[_0x32f770(0x162)];if(typeof _0x3ee371!==_0x32f770(0x18a))return null;try{let _0x2ff83b=JSON[_0x32f770(0x166)](_0x3ee371);return _0x2ff83b?.[_0x32f770(0x161)]||_0x2ff83b?.[_0x32f770(0x151)]||_0x2ff83b?.['id']||null;}catch{return null;}}async function X(_0x52d832,_0x2485e7){const _0x573433=a0_0x27e4e3;let _0x198397=_0x2485e7[_0x573433(0x15f)]??Date[_0x573433(0x15f)],_0x4ac56e=_0x198397(),_0x129730=(_0x476382,_0xaee3ff,_0x43cbc7,_0x3c4187)=>{const _0x2cae9a=_0x573433;_0x2485e7['log'](O(U({'from_alias':_0x52d832[_0x2cae9a(0x14c)],'to_alias':_0x52d832['toAlias'],'task_id':_0xaee3ff,'parent_task_id':_0x52d832['parentTaskId'],'network_id':_0x52d832['networkId'],'transport':_0x52d832[_0x2cae9a(0x1a4)],'status':_0x476382,'duration_ms':_0x198397()-_0x4ac56e,'lifecycle_tracking':_0x52d832['lifecycleTracking'],..._0x43cbc7!==void 0x0?{'error_code':_0x3c4187||_0x2cae9a(0x177),'error_message':N(_0x43cbc7)}:{}})));};_0x129730('sending',null);try{let _0x30edb7=await _0x2485e7['send'](),_0x5ba6a8=j(_0x30edb7);if(_0x5ba6a8)_0x129730(_0x573433(0x172),_0x5ba6a8);else{if(_0x30edb7?.['ok']===!0x1||_0x30edb7?.[_0x573433(0x12c)])_0x129730(_0x573433(0x167),_0x5ba6a8,_0x30edb7?.['error']||_0x573433(0x184),'send_rejected');else _0x129730('failed',null,_0x573433(0x130),_0x573433(0x153));}return _0x30edb7;}catch(_0x29d035){throw _0x129730(_0x573433(0x167),null,_0x29d035,_0x573433(0x177)),_0x29d035;}}async function Y(_0xe417af,_0x359cab){const _0x4fe36a=a0_0x27e4e3;return X({'fromAlias':_0xe417af[_0x4fe36a(0x14c)],'toAlias':_0xe417af['alias'],'parentTaskId':_0xe417af['parentTaskId']||null,'networkId':_0xe417af['networkId']||null,'transport':_0x4fe36a(0x164),'lifecycleTracking':'not_tracked'},_0x359cab);}class $ extends a0_0x542b01{['url'];[a0_0x27e4e3(0x18d)];['token'];['agent'];[a0_0x27e4e3(0x173)];['heartbeatInterval'];[a0_0x27e4e3(0x13f)];[a0_0x27e4e3(0x176)];[a0_0x27e4e3(0x1a7)];[a0_0x27e4e3(0x1a6)]=!0x1;constructor(_0x47a35f){const _0x175230=a0_0x27e4e3;super();if(this[_0x175230(0x181)]=_0x47a35f[_0x175230(0x181)][_0x175230(0x19e)](/\/$/,''),this[_0x175230(0x18d)]=_0x47a35f['alias'],this[_0x175230(0x150)]=_0x47a35f['token'],this[_0x175230(0x154)]=_0x47a35f['agent']||'sdk',this[_0x175230(0x173)]='sdk-'+_0x47a35f[_0x175230(0x18d)]+'-'+Date[_0x175230(0x15f)]()['toString'](0x24),this[_0x175230(0x19c)]=_0x47a35f[_0x175230(0x19c)]??0x2bf20,this['reconnectDelay']=_0x47a35f[_0x175230(0x13f)]??0xbb8,_0x47a35f[_0x175230(0x12d)]!==!0x1)this[_0x175230(0x14b)]();}['log'](_0x143e0c){const _0x2563ab=a0_0x27e4e3;console['log']('['+new Date()[_0x2563ab(0x15e)]()[_0x2563ab(0x141)](0x0,0x8)+_0x2563ab(0x16a)+this[_0x2563ab(0x18d)]+']\x20'+_0x143e0c);}async[a0_0x27e4e3(0x147)](_0x4e3448,_0x368953){const _0x225fc6=a0_0x27e4e3;let _0x12b58d={'Content-Type':_0x225fc6(0x12f),'Accept':_0x225fc6(0x14d)};if(this[_0x225fc6(0x150)])_0x12b58d[_0x225fc6(0x13b)]=_0x225fc6(0x144)+this[_0x225fc6(0x150)];let _0x4e4719=await(await fetch(this[_0x225fc6(0x181)]+_0x225fc6(0x15c),{'method':_0x225fc6(0x16b),'headers':_0x12b58d,'body':JSON[_0x225fc6(0x188)]({'jsonrpc':_0x225fc6(0x15a),'id':Date[_0x225fc6(0x15f)](),'method':_0x225fc6(0x12a),'params':{'name':_0x4e3448,'arguments':_0x368953}})}))[_0x225fc6(0x162)](),_0x35c021=_0x4e4719[_0x225fc6(0x157)](/data: (.+)/),_0x1ca6f3=_0x35c021?JSON['parse'](_0x35c021[0x1]):JSON[_0x225fc6(0x166)](_0x4e4719),_0x346011=_0x1ca6f3?.['result']?.['content']?.[0x0]?.['text'];return _0x346011?JSON[_0x225fc6(0x166)](_0x346011):_0x1ca6f3;}async[a0_0x27e4e3(0x14b)](){const _0x52f34f=a0_0x27e4e3;if(this[_0x52f34f(0x1a6)])return;this['running']=!0x0,await this[_0x52f34f(0x15d)]('idle'),this['log'](_0x52f34f(0x145)),this['heartbeatTimer']=setInterval(()=>{const _0x4ffac7=_0x52f34f;this[_0x4ffac7(0x15d)]('idle')[_0x4ffac7(0x199)](_0x39cf5f=>this[_0x4ffac7(0x182)]('heartbeat\x20failed:\x20'+_0x39cf5f[_0x4ffac7(0x142)]));},this['heartbeatInterval']),this[_0x52f34f(0x134)]();}async[a0_0x27e4e3(0x17f)](){const _0x26df7f=a0_0x27e4e3;if(this[_0x26df7f(0x1a6)]=!0x1,this[_0x26df7f(0x1a7)]?.[_0x26df7f(0x18e)](),this[_0x26df7f(0x176)])clearInterval(this[_0x26df7f(0x176)]);await this[_0x26df7f(0x15d)](_0x26df7f(0x19b))[_0x26df7f(0x199)](()=>{}),this[_0x26df7f(0x182)](_0x26df7f(0x194));}async[a0_0x27e4e3(0x193)](_0x1dba3f,_0x52e665,_0x199b24=a0_0x27e4e3(0x158)){const _0x57d499=a0_0x27e4e3;return Y({'alias':_0x1dba3f,'fromAlias':this[_0x57d499(0x18d)]},{'log':_0x285353=>console['log'](_0x285353),'send':()=>this[_0x57d499(0x147)](_0x57d499(0x17d),{'alias':_0x1dba3f,'task':_0x52e665,'priority':_0x199b24,'from_session':this[_0x57d499(0x18d)]})});}async[a0_0x27e4e3(0x142)](_0x45e0c9,_0x23c08e){const _0x257c5b=a0_0x27e4e3;return this[_0x257c5b(0x147)]('send_message',{'alias':_0x45e0c9,'message':_0x23c08e,'from_session':this[_0x257c5b(0x18d)]});}async[a0_0x27e4e3(0x169)](_0x5d6985,_0xc2b49a,_0x3c4097=a0_0x27e4e3(0x187)){const _0x5db0db=a0_0x27e4e3;return this[_0x5db0db(0x147)]('send_reply',{'in_reply_to':_0x5d6985,'text':_0xc2b49a,'status':_0x3c4097});}async['status'](_0x224fad,_0x20c9bc){const _0x5021ac=a0_0x27e4e3;return this[_0x5021ac(0x147)](_0x5021ac(0x135),{'resume_id':this['resumeId'],'alias':this[_0x5021ac(0x18d)],'status':_0x224fad,'server':a0_0x4e6936(),'hostname':a0_0x4e6936(),'agent':this[_0x5021ac(0x154)],'project_dir':process[_0x5021ac(0x13d)](),..._0x20c9bc});}async[a0_0x27e4e3(0x16f)](){const _0x3d86a9=a0_0x27e4e3;return this['call'](_0x3d86a9(0x18c),{});}async[a0_0x27e4e3(0x139)](_0x227c4d,_0x4f718c){const _0x274cb4=a0_0x27e4e3;return this[_0x274cb4(0x147)](_0x274cb4(0x139),{'message':_0x227c4d,'filter_server':_0x4f718c?.[_0x274cb4(0x16c)],'filter_status':_0x4f718c?.[_0x274cb4(0x15d)]});}async[a0_0x27e4e3(0x134)](){const _0x573bb9=a0_0x27e4e3;let _0x59b837=encodeURIComponent(this['alias']),_0xc4b6a8=this[_0x573bb9(0x181)]+'/events/'+_0x59b837,_0x210804=this['reconnectDelay'];while(this[_0x573bb9(0x1a6)]){try{this[_0x573bb9(0x1a7)]=new AbortController();let _0x5814c0={'Accept':_0x573bb9(0x19f)};if(this['token'])_0x5814c0[_0x573bb9(0x13b)]=_0x573bb9(0x144)+this[_0x573bb9(0x150)];let _0x514cde=await fetch(_0xc4b6a8,{'headers':_0x5814c0,'signal':this[_0x573bb9(0x1a7)][_0x573bb9(0x149)]});if(!_0x514cde['ok']||!_0x514cde[_0x573bb9(0x186)]){this['log'](_0x573bb9(0x18b)+_0x514cde[_0x573bb9(0x15d)]),await this[_0x573bb9(0x131)](_0x210804),_0x210804=Math[_0x573bb9(0x19d)](_0x210804*1.5,0xea60);continue;}_0x210804=this[_0x573bb9(0x13f)];let _0x26fe44=_0x514cde['body'][_0x573bb9(0x17a)](),_0x98b346=new TextDecoder(),_0x1edf3b='';while(this[_0x573bb9(0x1a6)]){let {done:_0x27f79b,value:_0x1b5147}=await _0x26fe44[_0x573bb9(0x163)]();if(_0x27f79b)break;_0x1edf3b+=_0x98b346['decode'](_0x1b5147,{'stream':!0x0});let _0x576a7e=_0x1edf3b[_0x573bb9(0x160)]('\x0a');_0x1edf3b=_0x576a7e[_0x573bb9(0x17c)]()||'';for(let _0x4e2b06 of _0x576a7e){if(!_0x4e2b06[_0x573bb9(0x168)](_0x573bb9(0x195)))continue;try{let _0x3ce523=JSON[_0x573bb9(0x166)](_0x4e2b06[_0x573bb9(0x141)](0x6));if(_0x3ce523['type']===_0x573bb9(0x12b)){this[_0x573bb9(0x182)]('SSE\x20connected'),this['emit'](_0x573bb9(0x12b));continue;}if(_0x3ce523[_0x573bb9(0x191)]==='new_task'||_0x3ce523[_0x573bb9(0x191)]===_0x573bb9(0x137)||_0x3ce523[_0x573bb9(0x191)]===_0x573bb9(0x139))await this[_0x573bb9(0x1a0)]();}catch{}}}}catch(_0x4e6e0f){if(_0x4e6e0f[_0x573bb9(0x171)]===_0x573bb9(0x196))break;this[_0x573bb9(0x185)](_0x573bb9(0x12c),_0x4e6e0f),this[_0x573bb9(0x182)](_0x573bb9(0x192)+_0x4e6e0f['message']);}if(this[_0x573bb9(0x1a6)])this[_0x573bb9(0x185)](_0x573bb9(0x194)),this['log'](_0x573bb9(0x146)+_0x210804/0x3e8+_0x573bb9(0x19a)),await this[_0x573bb9(0x131)](_0x210804),_0x210804=Math[_0x573bb9(0x19d)](_0x210804*1.5,0xea60);}}async[a0_0x27e4e3(0x1a0)](){const _0x497900=a0_0x27e4e3;try{let _0x1208ed=(await this[_0x497900(0x147)](_0x497900(0x17e),{'alias':this[_0x497900(0x18d)],'limit':0xa}))?.['messages']||[];for(let _0x25d0c0 of _0x1208ed)await this[_0x497900(0x147)](_0x497900(0x165),{'alias':this[_0x497900(0x18d)],'message_id':_0x25d0c0['id']}),this[_0x497900(0x182)]('←\x20'+_0x25d0c0['from_session']+':\x20'+_0x25d0c0[_0x497900(0x1a2)][_0x497900(0x141)](0x0,0x3c)),this[_0x497900(0x185)](_0x497900(0x138),_0x25d0c0),this[_0x497900(0x185)](_0x497900(0x142),_0x25d0c0);}catch(_0x36ea44){this['log'](_0x497900(0x155)+_0x36ea44['message']);}}[a0_0x27e4e3(0x131)](_0x111f88){return new Promise(_0x1cf202=>setTimeout(_0x1cf202,_0x111f88));}}var F=$;export{F as default,$ as CommHub};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const CLAUDE_CODE_RULES_RUNTIME = "claude";
|
|
2
|
+
export interface RulesDoorbellDeps {
|
|
3
|
+
callCommHub: (method: string, params: Record<string, unknown>) => Promise<any>;
|
|
4
|
+
workDir: string;
|
|
5
|
+
log: (msg: string) => void;
|
|
6
|
+
}
|
|
7
|
+
/** SSE 事件分派:是 rules_file 门铃就处理并返回 true;其它事件原样返回 false。 */
|
|
8
|
+
export declare function handleRulesFileEvent(event: {
|
|
9
|
+
type?: unknown;
|
|
10
|
+
} | null | undefined, deps: RulesDoorbellDeps): Promise<boolean>;
|
|
11
|
+
/** 连上 / 重连后补拉一次:断线期间桌面端可能已发起请求(hub 侧 60s 内仍 pending)。 */
|
|
12
|
+
export declare function drainRulesFileRequests(deps: RulesDoorbellDeps, why: string): Promise<number>;
|