@sleep2agi/agent-network 2.0.0-preview.1 → 2.0.0-preview.10
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/README.md +156 -77
- package/dist/bin/cli.js +1 -1
- package/dist/src/client.js +1 -1
- package/dist/src/node-server.js +1 -1
- package/package.json +1 -1
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a0_0x5924(){const _0x283787=[']\x20[commhub:','4fOmjXH','sleep','call','3782277jqQbQD','decode','url','status','s...','ack_inbox','broadcast','resumeId','tools/call','disconnect','data:\x20','get_all_status','210ZkLfbd','heartbeatInterval','text','connected','connectSSE','startsWith','read','running','113289LjLATc','error','connect','completed','Bearer\x20','/mcp','split','sseAbort','processInbox','min','heartbeatTimer','messages','2evhDGh','report_status','name','disconnected','getAllStatus','now','cwd','/events/','agent','296VUNgZi','offline','961447vNcoFu','20826630jOAuwj','abort','result','replace','log','toString','SSE\x20connected','toTimeString','token','reply','SSE\x20error:\x20','match','send_task','new_task','280155dLODAx','36MHVFql','alias','320789hRQgfh','body','40mPArZE','getReader','task','2.0','message','idle','slice','signal','pop','autoConnect','POST','normal','Authorization','SSE\x20reconnecting\x20in\x20','parse','type','reconnectDelay','658879GZLlEr','application/json,\x20text/event-stream','emit','catch'];a0_0x5924=function(){return _0x283787;};return a0_0x5924();}const a0_0x5f0e84=a0_0x4ca4;(function(_0x2afd89,_0x3784f6){const _0x149f39=a0_0x4ca4,_0xaa1ecf=_0x2afd89();while(!![]){try{const _0x4cd049=-parseInt(_0x149f39(0x158))/0x1*(-parseInt(_0x149f39(0x14d))/0x2)+parseInt(_0x149f39(0x141))/0x3*(-parseInt(_0x149f39(0x12a))/0x4)+-parseInt(_0x149f39(0x10f))/0x5*(parseInt(_0x149f39(0x139))/0x6)+parseInt(_0x149f39(0x112))/0x7*(-parseInt(_0x149f39(0x156))/0x8)+parseInt(_0x149f39(0x12d))/0x9*(parseInt(_0x149f39(0x114))/0xa)+parseInt(_0x149f39(0x159))/0xb+parseInt(_0x149f39(0x110))/0xc*(parseInt(_0x149f39(0x125))/0xd);if(_0x4cd049===_0x3784f6)break;else _0xaa1ecf['push'](_0xaa1ecf['shift']());}catch(_0x4db657){_0xaa1ecf['push'](_0xaa1ecf['shift']());}}}(a0_0x5924,0xf286f));function a0_0x4ca4(_0x14e088,_0x29b125){_0x14e088=_0x14e088-0x104;const _0x5924b1=a0_0x5924();let _0x4ca41e=_0x5924b1[_0x14e088];return _0x4ca41e;}import{EventEmitter as a0_0x4e3fab}from'events';import{hostname as a0_0x567f53}from'os';class T extends a0_0x4e3fab{[a0_0x5f0e84(0x12f)];[a0_0x5f0e84(0x111)];[a0_0x5f0e84(0x109)];[a0_0x5f0e84(0x155)];[a0_0x5f0e84(0x134)];['heartbeatInterval'];[a0_0x5f0e84(0x124)];[a0_0x5f0e84(0x14b)];['sseAbort'];['running']=!0x1;constructor(_0x2f87c4){const _0x349308=a0_0x5f0e84;super();if(this['url']=_0x2f87c4[_0x349308(0x12f)][_0x349308(0x104)](/\/$/,''),this[_0x349308(0x111)]=_0x2f87c4['alias'],this['token']=_0x2f87c4[_0x349308(0x109)],this['agent']=_0x2f87c4['agent']||'sdk',this[_0x349308(0x134)]='sdk-'+_0x2f87c4['alias']+'-'+Date[_0x349308(0x152)]()[_0x349308(0x106)](0x24),this[_0x349308(0x13a)]=_0x2f87c4[_0x349308(0x13a)]??0x2bf20,this['reconnectDelay']=_0x2f87c4[_0x349308(0x124)]??0xbb8,_0x2f87c4[_0x349308(0x11d)]!==!0x1)this[_0x349308(0x143)]();}[a0_0x5f0e84(0x105)](_0x2e8e03){const _0xc648c5=a0_0x5f0e84;console[_0xc648c5(0x105)]('['+new Date()[_0xc648c5(0x108)]()['slice'](0x0,0x8)+_0xc648c5(0x129)+this['alias']+']\x20'+_0x2e8e03);}async['call'](_0x4be743,_0x498cf6){const _0x30f67a=a0_0x5f0e84;let _0x59503={'Content-Type':'application/json','Accept':_0x30f67a(0x126)};if(this[_0x30f67a(0x109)])_0x59503[_0x30f67a(0x120)]=_0x30f67a(0x145)+this[_0x30f67a(0x109)];let _0x4639a0=await(await fetch(this['url']+_0x30f67a(0x146),{'method':_0x30f67a(0x11e),'headers':_0x59503,'body':JSON['stringify']({'jsonrpc':_0x30f67a(0x117),'id':Date[_0x30f67a(0x152)](),'method':_0x30f67a(0x135),'params':{'name':_0x4be743,'arguments':_0x498cf6}})}))[_0x30f67a(0x13b)](),_0xa56513=_0x4639a0[_0x30f67a(0x10c)](/data: (.+)/),_0xb661d=_0xa56513?JSON[_0x30f67a(0x122)](_0xa56513[0x1]):JSON[_0x30f67a(0x122)](_0x4639a0),_0x539a89=_0xb661d?.[_0x30f67a(0x15b)]?.['content']?.[0x0]?.[_0x30f67a(0x13b)];return _0x539a89?JSON[_0x30f67a(0x122)](_0x539a89):_0xb661d;}async['connect'](){const _0x1245dd=a0_0x5f0e84;if(this['running'])return;this['running']=!0x0,await this['status'](_0x1245dd(0x119)),this['log']('registered'),this[_0x1245dd(0x14b)]=setInterval(()=>{const _0x3a12f9=_0x1245dd;this[_0x3a12f9(0x130)]('idle')[_0x3a12f9(0x128)](_0xf0b954=>this['log']('heartbeat\x20failed:\x20'+_0xf0b954[_0x3a12f9(0x118)]));},this[_0x1245dd(0x13a)]),this['connectSSE']();}async[a0_0x5f0e84(0x136)](){const _0x3d0bee=a0_0x5f0e84;if(this[_0x3d0bee(0x140)]=!0x1,this[_0x3d0bee(0x148)]?.[_0x3d0bee(0x15a)](),this[_0x3d0bee(0x14b)])clearInterval(this[_0x3d0bee(0x14b)]);await this[_0x3d0bee(0x130)](_0x3d0bee(0x157))[_0x3d0bee(0x128)](()=>{}),this[_0x3d0bee(0x105)](_0x3d0bee(0x150));}async['send'](_0x544ab1,_0x2674f1,_0x425088=a0_0x5f0e84(0x11f)){const _0x15f001=a0_0x5f0e84;return this[_0x15f001(0x12c)](_0x15f001(0x10d),{'alias':_0x544ab1,'task':_0x2674f1,'priority':_0x425088,'from_session':this[_0x15f001(0x111)]});}async['message'](_0x2b6cef,_0x5d5033){const _0x4409dc=a0_0x5f0e84;return this['call']('send_message',{'alias':_0x2b6cef,'message':_0x5d5033,'from_session':this[_0x4409dc(0x111)]});}async[a0_0x5f0e84(0x10a)](_0x536d8d,_0x254f59,_0x55d9ba=a0_0x5f0e84(0x144)){const _0x481494=a0_0x5f0e84;return this[_0x481494(0x12c)](_0x481494(0x10a),{'task_id':_0x536d8d,'text':_0x254f59,'status':_0x55d9ba});}async['status'](_0x4eefb2,_0x2033f3){const _0x4cf619=a0_0x5f0e84;return this[_0x4cf619(0x12c)](_0x4cf619(0x14e),{'resume_id':this[_0x4cf619(0x134)],'alias':this[_0x4cf619(0x111)],'status':_0x4eefb2,'server':a0_0x567f53(),'hostname':a0_0x567f53(),'agent':this[_0x4cf619(0x155)],'project_dir':process[_0x4cf619(0x153)](),..._0x2033f3});}async[a0_0x5f0e84(0x151)](){const _0x822c5f=a0_0x5f0e84;return this['call'](_0x822c5f(0x138),{});}async['broadcast'](_0x31c0d1,_0x237218){const _0x4d15db=a0_0x5f0e84;return this[_0x4d15db(0x12c)](_0x4d15db(0x133),{'message':_0x31c0d1,'filter_server':_0x237218?.['server'],'filter_status':_0x237218?.[_0x4d15db(0x130)]});}async[a0_0x5f0e84(0x13d)](){const _0x24ecc0=a0_0x5f0e84;let _0x42fbe9=encodeURIComponent(this[_0x24ecc0(0x111)]),_0x19b753=this['url']+_0x24ecc0(0x154)+_0x42fbe9,_0x18fa15=this[_0x24ecc0(0x124)];while(this[_0x24ecc0(0x140)]){try{this[_0x24ecc0(0x148)]=new AbortController();let _0x4d80b8={'Accept':'text/event-stream'};if(this['token'])_0x4d80b8[_0x24ecc0(0x120)]=_0x24ecc0(0x145)+this[_0x24ecc0(0x109)];let _0xb5800b=await fetch(_0x19b753,{'headers':_0x4d80b8,'signal':this[_0x24ecc0(0x148)][_0x24ecc0(0x11b)]});if(!_0xb5800b['ok']||!_0xb5800b[_0x24ecc0(0x113)]){this[_0x24ecc0(0x105)]('SSE\x20failed:\x20'+_0xb5800b[_0x24ecc0(0x130)]),await this[_0x24ecc0(0x12b)](_0x18fa15),_0x18fa15=Math['min'](_0x18fa15*1.5,0xea60);continue;}_0x18fa15=this[_0x24ecc0(0x124)];let _0x33c521=_0xb5800b['body'][_0x24ecc0(0x115)](),_0x57c6bf=new TextDecoder(),_0x457c48='';while(this[_0x24ecc0(0x140)]){let {done:_0x25b4bb,value:_0x398b89}=await _0x33c521[_0x24ecc0(0x13f)]();if(_0x25b4bb)break;_0x457c48+=_0x57c6bf[_0x24ecc0(0x12e)](_0x398b89,{'stream':!0x0});let _0x10aad1=_0x457c48[_0x24ecc0(0x147)]('\x0a');_0x457c48=_0x10aad1[_0x24ecc0(0x11c)]()||'';for(let _0x54f0c7 of _0x10aad1){if(!_0x54f0c7[_0x24ecc0(0x13e)](_0x24ecc0(0x137)))continue;try{let _0x44b480=JSON[_0x24ecc0(0x122)](_0x54f0c7[_0x24ecc0(0x11a)](0x6));if(_0x44b480[_0x24ecc0(0x123)]===_0x24ecc0(0x13c)){this['log'](_0x24ecc0(0x107)),this[_0x24ecc0(0x127)](_0x24ecc0(0x13c));continue;}if(_0x44b480[_0x24ecc0(0x123)]===_0x24ecc0(0x10e)||_0x44b480[_0x24ecc0(0x123)]==='new_message'||_0x44b480['type']===_0x24ecc0(0x133))await this[_0x24ecc0(0x149)]();}catch{}}}}catch(_0x5a5ed5){if(_0x5a5ed5[_0x24ecc0(0x14f)]==='AbortError')break;this[_0x24ecc0(0x127)](_0x24ecc0(0x142),_0x5a5ed5),this[_0x24ecc0(0x105)](_0x24ecc0(0x10b)+_0x5a5ed5[_0x24ecc0(0x118)]);}if(this['running'])this[_0x24ecc0(0x127)](_0x24ecc0(0x150)),this['log'](_0x24ecc0(0x121)+_0x18fa15/0x3e8+_0x24ecc0(0x131)),await this['sleep'](_0x18fa15),_0x18fa15=Math[_0x24ecc0(0x14a)](_0x18fa15*1.5,0xea60);}}async[a0_0x5f0e84(0x149)](){const _0x533dfd=a0_0x5f0e84;try{let _0x349e45=(await this[_0x533dfd(0x12c)]('get_inbox',{'alias':this[_0x533dfd(0x111)],'limit':0xa}))?.[_0x533dfd(0x14c)]||[];for(let _0x148f31 of _0x349e45)await this['call'](_0x533dfd(0x132),{'alias':this['alias'],'message_id':_0x148f31['id']}),this[_0x533dfd(0x105)]('←\x20'+_0x148f31['from_session']+':\x20'+_0x148f31['content'][_0x533dfd(0x11a)](0x0,0x3c)),this[_0x533dfd(0x127)](_0x533dfd(0x116),_0x148f31),this[_0x533dfd(0x127)](_0x533dfd(0x118),_0x148f31);}catch(_0x2ede0e){this[_0x533dfd(0x105)]('inbox\x20error:\x20'+_0x2ede0e[_0x533dfd(0x118)]);}}[a0_0x5f0e84(0x12b)](_0x157215){return new Promise(_0x3b449e=>setTimeout(_0x3b449e,_0x157215));}}var $=T;export{$ as default,T as CommHub};
|
package/dist/src/node-server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
const a0_0x4e5ac0=a0_0x2999;(function(_0x51044d,_0x358a1e){const _0x430d25=a0_0x2999,_0x44c354=_0x51044d();while(!![]){try{const _0x5a91bc=-parseInt(_0x430d25(0x168))/0x1*(-parseInt(_0x430d25(0x142))/0x2)+-parseInt(_0x430d25(0x12f))/0x3+-parseInt(_0x430d25(0x151))/0x4+-parseInt(_0x430d25(0x138))/0x5*(-parseInt(_0x430d25(0x123))/0x6)+-parseInt(_0x430d25(0x149))/0x7*(-parseInt(_0x430d25(0x126))/0x8)+-parseInt(_0x430d25(0x128))/0x9*(-parseInt(_0x430d25(0x12e))/0xa)+-parseInt(_0x430d25(0x158))/0xb;if(_0x5a91bc===_0x358a1e)break;else _0x44c354['push'](_0x44c354['shift']());}catch(_0x5e1d39){_0x44c354['push'](_0x44c354['shift']());}}}(a0_0xc492,0x33364));import{readFileSync as a0_0x5ee94b,existsSync as a0_0x56a5df}from'fs';import{join as a0_0x507a4f}from'path';import{hostname as a0_0x907404}from'os';import{execSync as a0_0x29d0d1}from'child_process';import{Server as a0_0x1d74b7}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x122abe}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x542812,CallToolRequestSchema as a0_0x577e4f}from'@modelcontextprotocol/sdk/types.js';function h(_0x221af1){const _0x298cf0=a0_0x2999;if(!a0_0x56a5df(_0x221af1))return;for(let _0x534b01 of a0_0x5ee94b(_0x221af1,'utf-8')[_0x298cf0(0x10f)]('\x0a')){let _0x1f8f48=_0x534b01[_0x298cf0(0x172)]();if(!_0x1f8f48||_0x1f8f48[_0x298cf0(0x153)]('#'))continue;let _0x149c4b=_0x1f8f48['indexOf']('=');if(_0x149c4b<0x0)continue;let _0x8cde08=_0x1f8f48[_0x298cf0(0x12a)](0x0,_0x149c4b)[_0x298cf0(0x172)](),_0x356af5=_0x1f8f48[_0x298cf0(0x12a)](_0x149c4b+0x1)[_0x298cf0(0x172)]()[_0x298cf0(0x10d)](/^["']|["']$/g,'');if(!process.env[_0x8cde08])process.env[_0x8cde08]=_0x356af5;}}var R=process.env.HOME||'~',p=a0_0x507a4f(R,a0_0x4e5ac0(0x16a));h(a0_0x507a4f(p,'.env'));var C=process[a0_0x4e5ac0(0x194)]()[a0_0x4e5ac0(0x10d)](/\//g,'-');function a0_0x2999(_0x331d08,_0x12a298){_0x331d08=_0x331d08-0x10c;const _0xc49219=a0_0xc492();let _0x299934=_0xc49219[_0x331d08];return _0x299934;}h(a0_0x507a4f(p,C,a0_0x4e5ac0(0x14d)));function _(){const _0x2c85e3=a0_0x4e5ac0;try{return a0_0x29d0d1(_0x2c85e3(0x124),{'encoding':_0x2c85e3(0x17d),'timeout':0x7d0})[_0x2c85e3(0x172)]();}catch{return'';}}function a0_0xc492(){const _0x1c3231=['ack_inbox','0.3.0','report_status','working','2.0','new_task','commhub-channel','join','from','parse\x20error:\x20','number','/events/','/mcp','exit','\x20from\x20','2sADOTo','Priority\x20(default:\x20normal)','.claude/channels/commhub','no\x20response','initialize','connected','commhub_send_message','message','claude-code','getReader','trim','\x22\x20(','messages','text','read',':\x20inbox_count=','commhub','stringify','in_progress','CommHub\x20init\x20failed:\x20','config.json','utf-8','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','report_completion','data:\x20','connect','registered\x20as\x20\x22','blocked','Task\x20status','randomUUID','end','\x20priority=','Target\x20session\x20alias','commhub_send_task','warning:\x20could\x20not\x20register:\x20','shutting\x20down,\x20reporting\x20offline...','pop','high','SSE\x20connection\x20error:\x20','string','init\x20failed:\x20','content','write','priority','cwd','type','hub','decode','message_id','replace','Authorization','split','task','body','then','SSE\x20stream\x20ended,\x20reconnecting...','starting\x20SSE\x20listener...','result','get_all_status','Progress\x200-100','normal','Bearer\x20','statusText','SSE\x20error:\x20','toTimeString','unknown\x20tool','length','none','notifications/claude/channel','commhub_get_all_status','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','6pRxrbh','tmux\x20display-message\x20-p\x20\x27#S\x27','\x20RESUME_ID=','8dLdvUB','SSE\x20fatal:\x20','59391xPBSQS','from_session','slice','stderr','MCP\x20stdio\x20connected','.anet','110mZMQFt','611904RMivfv','Task\x20content',']\x20[commhub]\x20','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','token','completed','POST','error','find','236435QWgTwv','parse','session\x20disconnected','commhub_report_status','ENV:\x20URL=','notification','Reply\x20text\x20/\x20result\x20summary','\x20ALIAS=','object','connecting\x20to\x20','254908rqjdTF','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','status','catch','application/json,\x20text/event-stream','...\x20TMUX=','2766694xKTJfu','broadcast','setRequestHandler','SSE\x20connected\x20as\x20\x22','.env','ready\x20—\x20waiting\x20for\x20events','Session\x20alias:\x20','application/json','1259928tadkcA','send_task','startsWith','low','alias','idle','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','454432xgFuKZ'];a0_0xc492=function(){return _0x1c3231;};return a0_0xc492();}function E(){const _0x4575e8=a0_0x4e5ac0;try{let _0xa9a06a=a0_0x507a4f(R,_0x4575e8(0x12d),_0x4575e8(0x17c));if(a0_0x56a5df(_0xa9a06a))return JSON[_0x4575e8(0x139)](a0_0x5ee94b(_0xa9a06a,_0x4575e8(0x17d)));}catch{}return{};}var T=E(),k=process.env.COMMHUB_URL||T[a0_0x4e5ac0(0x196)]||'http://127.0.0.1:9200',q=process.env.COMMHUB_TMUX||_(),Z=process.env.COMMHUB_ALIAS||q||a0_0x907404(),w=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||crypto[a0_0x4e5ac0(0x185)](),X=process.env.COMMHUB_TOKEN||T[a0_0x4e5ac0(0x133)]||'';function V(_0x2da062){const _0x5aa241=a0_0x4e5ac0;let _0x5212f1=new Date()[_0x5aa241(0x11c)]()[_0x5aa241(0x12a)](0x0,0x8);process[_0x5aa241(0x12b)][_0x5aa241(0x192)]('['+_0x5212f1+_0x5aa241(0x131)+_0x2da062+'\x0a');}function O(_0x5f085b){return new Promise(_0x1c9c5e=>setTimeout(_0x1c9c5e,_0x5f085b));}V(a0_0x4e5ac0(0x13c)+k+a0_0x4e5ac0(0x13f)+Z+a0_0x4e5ac0(0x125)+w[a0_0x4e5ac0(0x12a)](0x0,0x8)+a0_0x4e5ac0(0x148)+(q||a0_0x4e5ac0(0x11f))+'\x20CWD='+process[a0_0x4e5ac0(0x194)]()+'\x20PROJECT_ENV='+C);var K=new a0_0x1d74b7({'name':a0_0x4e5ac0(0x15f),'version':a0_0x4e5ac0(0x15a)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':['Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.',a0_0x4e5ac0(0x122),'You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.',a0_0x4e5ac0(0x14f)+Z][a0_0x4e5ac0(0x160)]('\x0a')});K[a0_0x4e5ac0(0x14b)](a0_0x542812,async()=>({'tools':[{'name':'commhub_reply','description':a0_0x4e5ac0(0x132),'inputSchema':{'type':'object','properties':{'task_id':{'type':a0_0x4e5ac0(0x18f),'description':a0_0x4e5ac0(0x144)},'text':{'type':'string','description':a0_0x4e5ac0(0x13e)},'status':{'type':a0_0x4e5ac0(0x18f),'enum':[a0_0x4e5ac0(0x134),a0_0x4e5ac0(0x183),a0_0x4e5ac0(0x136),a0_0x4e5ac0(0x17a)],'description':a0_0x4e5ac0(0x184)}},'required':[a0_0x4e5ac0(0x175)]}},{'name':a0_0x4e5ac0(0x13b),'description':a0_0x4e5ac0(0x143),'inputSchema':{'type':a0_0x4e5ac0(0x140),'properties':{'status':{'type':a0_0x4e5ac0(0x18f),'enum':['working',a0_0x4e5ac0(0x156),a0_0x4e5ac0(0x183),a0_0x4e5ac0(0x136)]},'task':{'type':a0_0x4e5ac0(0x18f),'description':'Current\x20task\x20description'},'progress':{'type':a0_0x4e5ac0(0x163),'description':a0_0x4e5ac0(0x117)}},'required':[a0_0x4e5ac0(0x145)]}},{'name':'commhub_send_task','description':'Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','inputSchema':{'type':a0_0x4e5ac0(0x140),'properties':{'alias':{'type':a0_0x4e5ac0(0x18f),'description':'Target\x20session\x20alias'},'task':{'type':a0_0x4e5ac0(0x18f),'description':a0_0x4e5ac0(0x130)},'priority':{'type':'string','enum':[a0_0x4e5ac0(0x18d),a0_0x4e5ac0(0x118),a0_0x4e5ac0(0x154)],'description':a0_0x4e5ac0(0x169)}},'required':[a0_0x4e5ac0(0x155),a0_0x4e5ac0(0x110)]}},{'name':'commhub_send_message','description':a0_0x4e5ac0(0x157),'inputSchema':{'type':a0_0x4e5ac0(0x140),'properties':{'alias':{'type':'string','description':a0_0x4e5ac0(0x188)},'message':{'type':a0_0x4e5ac0(0x18f),'description':'Message\x20content'}},'required':['alias',a0_0x4e5ac0(0x16f)]}},{'name':a0_0x4e5ac0(0x121),'description':a0_0x4e5ac0(0x17e),'inputSchema':{'type':a0_0x4e5ac0(0x140),'properties':{}}}]}));async function P(_0x3c5c02,_0x510361){const _0x28ee07=a0_0x4e5ac0;let _0x562d1c=await fetch(k+_0x28ee07(0x165),{'method':_0x28ee07(0x135),'headers':{'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream',...X?{'Authorization':_0x28ee07(0x119)+X}:{}},'body':JSON[_0x28ee07(0x179)]({'jsonrpc':_0x28ee07(0x15d),'id':0x1,'method':_0x28ee07(0x16c),'params':{'protocolVersion':'2025-03-26','capabilities':{},'clientInfo':{'name':_0x28ee07(0x15f),'version':_0x28ee07(0x15a)}}})});if(!_0x562d1c['ok']){let _0x5661d9=await _0x562d1c[_0x28ee07(0x175)]();return V(_0x28ee07(0x17b)+_0x562d1c[_0x28ee07(0x145)]+'\x20'+_0x5661d9['slice'](0x0,0x64)),{'ok':!0x1,'error':_0x28ee07(0x190)+_0x562d1c[_0x28ee07(0x145)]};}await _0x562d1c['text']();let _0x4615e3=(await(await fetch(k+'/mcp',{'method':_0x28ee07(0x135),'headers':{'Content-Type':_0x28ee07(0x150),'Accept':_0x28ee07(0x147),...X?{'Authorization':_0x28ee07(0x119)+X}:{}},'body':JSON[_0x28ee07(0x179)]({'jsonrpc':_0x28ee07(0x15d),'id':0x2,'method':'tools/call','params':{'name':_0x3c5c02,'arguments':_0x510361}})}))[_0x28ee07(0x175)]())[_0x28ee07(0x10f)]('\x0a')[_0x28ee07(0x137)](_0x28ee0c=>_0x28ee0c[_0x28ee07(0x153)]('data:\x20'));if(_0x4615e3){let _0x5ee184=JSON['parse'](_0x4615e3[_0x28ee07(0x12a)](0x6));return _0x5ee184?.[_0x28ee07(0x115)]?.[_0x28ee07(0x191)]?.[0x0]?.[_0x28ee07(0x175)]?JSON[_0x28ee07(0x139)](_0x5ee184[_0x28ee07(0x115)][_0x28ee07(0x191)][0x0][_0x28ee07(0x175)]):_0x5ee184;}return{'ok':!0x1,'error':_0x28ee07(0x16b)};}K[a0_0x4e5ac0(0x14b)](a0_0x577e4f,async _0x25a3ad=>{const _0x2c2613=a0_0x4e5ac0;let {name:_0x47fb3f,arguments:_0x5734a6}=_0x25a3ad['params'];if(_0x47fb3f==='commhub_reply'){let {task_id:_0x3cc870,text:_0x5d4149,status:_0x53f98d}=_0x5734a6;if(_0x53f98d==='completed'){let _0xb8212b=await P(_0x2c2613(0x17f),{'alias':Z,'task':_0x3cc870||'task','result':_0x5d4149});return{'content':[{'type':'text','text':JSON[_0x2c2613(0x179)](_0xb8212b)}]};}let _0x57dcae=await P(_0x2c2613(0x15b),{'resume_id':w,'alias':Z,'status':_0x53f98d===_0x2c2613(0x183)?_0x2c2613(0x183):_0x53f98d===_0x2c2613(0x136)?_0x2c2613(0x136):_0x2c2613(0x15c),'task':_0x5d4149[_0x2c2613(0x12a)](0x0,0xc8),'output':_0x5d4149});return{'content':[{'type':_0x2c2613(0x175),'text':JSON[_0x2c2613(0x179)](_0x57dcae)}]};}if(_0x47fb3f===_0x2c2613(0x13b)){let {status:_0xbea76b,task:_0x10c939,progress:_0x521f08}=_0x5734a6,_0x48b90d=await P(_0x2c2613(0x15b),{'resume_id':w,'alias':Z,'status':_0xbea76b,'task':_0x10c939,'progress':_0x521f08});return{'content':[{'type':'text','text':JSON[_0x2c2613(0x179)](_0x48b90d)}]};}if(_0x47fb3f===_0x2c2613(0x189)){let {alias:_0x7f3260,task:_0xeec80e,priority:_0x274af7}=_0x5734a6,_0x53998b=await P(_0x2c2613(0x152),{'alias':_0x7f3260,'task':_0xeec80e,'priority':_0x274af7||_0x2c2613(0x118),'from_session':Z});return{'content':[{'type':_0x2c2613(0x175),'text':JSON[_0x2c2613(0x179)](_0x53998b)}]};}if(_0x47fb3f===_0x2c2613(0x16e)){let {alias:_0x4aedfe,message:_0x2ac6a0}=_0x5734a6,_0x33be49=await P('send_message',{'alias':_0x4aedfe,'message':_0x2ac6a0,'from_session':Z});return{'content':[{'type':_0x2c2613(0x175),'text':JSON[_0x2c2613(0x179)](_0x33be49)}]};}if(_0x47fb3f===_0x2c2613(0x121)){let _0x246f83=await P(_0x2c2613(0x116),{});return{'content':[{'type':'text','text':JSON[_0x2c2613(0x179)](_0x246f83)}]};}return{'content':[{'type':_0x2c2613(0x175),'text':JSON[_0x2c2613(0x179)]({'error':_0x2c2613(0x11d)})}]};});async function c(){const _0x23c6c3=a0_0x4e5ac0;let _0x51165b=k+_0x23c6c3(0x164)+encodeURIComponent(Z),_0x1273b4={};if(X)_0x1273b4[_0x23c6c3(0x10e)]=_0x23c6c3(0x119)+X;V(_0x23c6c3(0x141)+_0x51165b);while(!0x0){try{let _0x3a6110=await fetch(_0x51165b,{'headers':_0x1273b4});if(!_0x3a6110['ok']){V(_0x23c6c3(0x11b)+_0x3a6110[_0x23c6c3(0x145)]+'\x20'+_0x3a6110[_0x23c6c3(0x11a)]),await O(0x1388);continue;}let _0x984e1=_0x3a6110[_0x23c6c3(0x111)][_0x23c6c3(0x171)](),_0x22a978=new TextDecoder(),_0x4a588c='';while(!0x0){let {done:_0x591df8,value:_0x372ea1}=await _0x984e1[_0x23c6c3(0x176)]();if(_0x591df8)break;_0x4a588c+=_0x22a978[_0x23c6c3(0x197)](_0x372ea1,{'stream':!0x0});let _0x5c634f=_0x4a588c[_0x23c6c3(0x10f)]('\x0a\x0a');_0x4a588c=_0x5c634f[_0x23c6c3(0x18c)]()||'';for(let _0x56cbf4 of _0x5c634f){let _0x9c6f15=_0x56cbf4[_0x23c6c3(0x10f)]('\x0a')[_0x23c6c3(0x137)](_0x999dba=>_0x999dba[_0x23c6c3(0x153)](_0x23c6c3(0x180)));if(!_0x9c6f15)continue;try{let _0x2f75ea=JSON[_0x23c6c3(0x139)](_0x9c6f15[_0x23c6c3(0x12a)](0x6));await v(_0x2f75ea);}catch(_0x4cb8d8){V(_0x23c6c3(0x162)+_0x4cb8d8);}}}V(_0x23c6c3(0x113));}catch(_0x2bf44b){V(_0x23c6c3(0x18e)+_0x2bf44b);}await O(0xbb8);}}async function v(_0x159ed9){const _0xd0772d=a0_0x4e5ac0;if(_0x159ed9[_0xd0772d(0x195)]===_0xd0772d(0x16d)){V(_0xd0772d(0x14c)+Z+'\x22');return;}if(_0x159ed9[_0xd0772d(0x195)]==='new_message'){if(V('←\x20message\x20from\x20'+_0x159ed9[_0xd0772d(0x161)]+':\x20'+_0x159ed9[_0xd0772d(0x16f)][_0xd0772d(0x12a)](0x0,0x3c)),await K['notification']({'method':_0xd0772d(0x120),'params':{'content':_0x159ed9['message'],'meta':{'sender':_0x159ed9[_0xd0772d(0x161)]||_0xd0772d(0x196),'sender_id':'commhub','user':_0x159ed9[_0xd0772d(0x161)]||_0xd0772d(0x196),'priority':_0xd0772d(0x118)}}}),_0x159ed9[_0xd0772d(0x10c)])await P('ack_inbox',{'alias':Z,'message_id':_0x159ed9[_0xd0772d(0x10c)]});return;}if(_0x159ed9[_0xd0772d(0x195)]===_0xd0772d(0x15e)||_0x159ed9['type']===_0xd0772d(0x14a)){V('←\x20'+_0x159ed9[_0xd0772d(0x195)]+_0xd0772d(0x177)+_0x159ed9['inbox_count']+_0xd0772d(0x187)+(_0x159ed9[_0xd0772d(0x193)]||_0xd0772d(0x118)));let _0xb2a905=await P('get_inbox',{'alias':Z,'limit':0x5});if(_0xb2a905?.['ok']&&_0xb2a905[_0xd0772d(0x174)]?.[_0xd0772d(0x11e)]>0x0)for(let _0x574053 of _0xb2a905[_0xd0772d(0x174)]){let _0x45631f={'sender':_0x574053[_0xd0772d(0x129)]||_0xd0772d(0x196),'sender_id':_0xd0772d(0x178),'user':_0x574053['from_session']||_0xd0772d(0x196),'task_id':_0x574053['id'],'priority':_0x574053['priority']||'normal'};await K[_0xd0772d(0x13d)]({'method':'notifications/claude/channel','params':{'content':_0x574053[_0xd0772d(0x191)],'meta':_0x45631f}}),V('→\x20injected\x20task\x20'+_0x574053['id'][_0xd0772d(0x12a)](0x0,0x8)+_0xd0772d(0x167)+_0x574053[_0xd0772d(0x129)]+':\x20'+_0x574053[_0xd0772d(0x191)]['slice'](0x0,0x3c)),await P(_0xd0772d(0x159),{'alias':Z,'message_id':_0x574053['id']});}}}async function u(){const _0x45d49f=a0_0x4e5ac0;let _0x5a7b30=new a0_0x122abe();await K[_0x45d49f(0x181)](_0x5a7b30),V(_0x45d49f(0x12c)),V(_0x45d49f(0x114)),c()[_0x45d49f(0x146)](_0x96d63e=>V(_0x45d49f(0x127)+_0x96d63e)),P(_0x45d49f(0x15b),{'resume_id':w,'alias':Z,'status':_0x45d49f(0x156),'server':a0_0x907404(),'hostname':a0_0x907404(),'agent':'claude-code','project_dir':process['cwd'](),'tmux_name':q||void 0x0})[_0x45d49f(0x112)](()=>V(_0x45d49f(0x182)+Z+_0x45d49f(0x173)+w['slice'](0x0,0x8)+')'))[_0x45d49f(0x146)](_0x3ed7c0=>V(_0x45d49f(0x18a)+_0x3ed7c0)),setInterval(()=>{const _0x4a2b69=_0x45d49f;P('report_status',{'resume_id':w,'alias':Z,'status':_0x4a2b69(0x156),'server':a0_0x907404(),'hostname':a0_0x907404(),'agent':_0x4a2b69(0x170),'project_dir':process['cwd'](),'tmux_name':q||void 0x0})['catch'](_0x9dcea2=>V('heartbeat\x20failed:\x20'+_0x9dcea2));},0x2bf20),V(_0x45d49f(0x14e));}u()[a0_0x4e5ac0(0x146)](_0x208507=>{const _0x2b2eed=a0_0x4e5ac0;V('fatal:\x20'+_0x208507),process[_0x2b2eed(0x166)](0x1);});async function f(){const _0x320d34=a0_0x4e5ac0;V(_0x320d34(0x18b)),await P(_0x320d34(0x15b),{'resume_id':w,'alias':Z,'status':_0x320d34(0x136),'task':_0x320d34(0x13a)})[_0x320d34(0x146)](()=>{}),process[_0x320d34(0x166)](0x0);}process['stdin']['on'](a0_0x4e5ac0(0x186),()=>f()),process['on']('SIGTERM',()=>f()),process['on']('SIGINT',()=>f());
|
|
2
|
+
const a0_0x54440c=a0_0x1bf7;(function(_0x1bd7fd,_0x1937f7){const _0x22636c=a0_0x1bf7,_0xcfe187=_0x1bd7fd();while(!![]){try{const _0x4ab90d=-parseInt(_0x22636c(0xfb))/0x1*(-parseInt(_0x22636c(0x175))/0x2)+-parseInt(_0x22636c(0x156))/0x3*(parseInt(_0x22636c(0x160))/0x4)+-parseInt(_0x22636c(0x172))/0x5+parseInt(_0x22636c(0x101))/0x6*(parseInt(_0x22636c(0x115))/0x7)+-parseInt(_0x22636c(0x134))/0x8*(-parseInt(_0x22636c(0x143))/0x9)+-parseInt(_0x22636c(0x109))/0xa*(parseInt(_0x22636c(0x159))/0xb)+parseInt(_0x22636c(0xfe))/0xc*(parseInt(_0x22636c(0x168))/0xd);if(_0x4ab90d===_0x1937f7)break;else _0xcfe187['push'](_0xcfe187['shift']());}catch(_0x34c4f6){_0xcfe187['push'](_0xcfe187['shift']());}}}(a0_0x58c6,0xeb921));import{readFileSync as a0_0x468840,existsSync as a0_0x3cdec9}from'fs';import{join as a0_0x13f622}from'path';import{hostname as a0_0x567625}from'os';import{execSync as a0_0x243e81}from'child_process';import{Server as a0_0x2f89ea}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x1dd8bb}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x4b56cb,CallToolRequestSchema as a0_0x448669}from'@modelcontextprotocol/sdk/types.js';function p(_0x161a70){const _0x327429=a0_0x1bf7;if(!a0_0x3cdec9(_0x161a70))return;for(let _0x19ec99 of a0_0x468840(_0x161a70,'utf-8')[_0x327429(0x151)]('\x0a')){let _0x298fb7=_0x19ec99[_0x327429(0x152)]();if(!_0x298fb7||_0x298fb7['startsWith']('#'))continue;let _0x511205=_0x298fb7[_0x327429(0x14e)]('=');if(_0x511205<0x0)continue;let _0xc5405c=_0x298fb7['slice'](0x0,_0x511205)[_0x327429(0x152)](),_0x2384d7=_0x298fb7[_0x327429(0x14a)](_0x511205+0x1)[_0x327429(0x152)]()[_0x327429(0x16c)](/^["']|["']$/g,'');if(!process.env[_0xc5405c])process.env[_0xc5405c]=_0x2384d7;}}var C=process.env.HOME||'~',T=a0_0x13f622(C,a0_0x54440c(0x124));function a0_0x1bf7(_0x20761e,_0x291aba){_0x20761e=_0x20761e-0xe9;const _0x58c68b=a0_0x58c6();let _0x1bf7c2=_0x58c68b[_0x20761e];return _0x1bf7c2;}p(a0_0x13f622(T,'.env'));var L=process['cwd']()[a0_0x54440c(0x16c)](/\//g,'-');p(a0_0x13f622(T,L,a0_0x54440c(0x118)));function U(){const _0x43f650=a0_0x54440c;try{return a0_0x243e81(_0x43f650(0x119),{'encoding':_0x43f650(0x14d),'timeout':0x7d0})[_0x43f650(0x152)]();}catch{return'';}}function c(){const _0x220ab7=a0_0x54440c;try{let _0x1884bb=a0_0x13f622(C,_0x220ab7(0x12b),_0x220ab7(0x127));if(a0_0x3cdec9(_0x1884bb))return JSON[_0x220ab7(0x166)](a0_0x468840(_0x1884bb,_0x220ab7(0x14d)));}catch{}return{};}var H=c(),D=process.env.COMMHUB_URL||H[a0_0x54440c(0x14b)]||a0_0x54440c(0x10a),f=process.env.COMMHUB_TMUX||U(),Z=process.env.COMMHUB_ALIAS||f||a0_0x567625(),w=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||crypto[a0_0x54440c(0xfc)](),X=process.env.COMMHUB_TOKEN||H[a0_0x54440c(0x129)]||'';function Y(_0x23cd0f){const _0x3ab089=a0_0x54440c;let _0x7b1d17=new Date()[_0x3ab089(0x162)]()[_0x3ab089(0x14a)](0x0,0x8);process[_0x3ab089(0x15a)][_0x3ab089(0x13f)]('['+_0x7b1d17+_0x3ab089(0x10f)+_0x23cd0f+'\x0a');}function h(_0x2d8620){return new Promise(_0x1befd9=>setTimeout(_0x1befd9,_0x2d8620));}Y('ENV:\x20URL='+D+a0_0x54440c(0x107)+Z+a0_0x54440c(0x100)+w['slice'](0x0,0x8)+a0_0x54440c(0x13b)+(f||a0_0x54440c(0x10b))+a0_0x54440c(0x103)+process[a0_0x54440c(0xee)]()+a0_0x54440c(0x11c)+L);var k=new Map(),K=new a0_0x2f89ea({'name':'commhub-channel','version':a0_0x54440c(0x169)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x54440c(0xf7),a0_0x54440c(0xf6),'Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.',a0_0x54440c(0x130),a0_0x54440c(0x15c)+Z][a0_0x54440c(0x17a)]('\x0a')});K[a0_0x54440c(0x111)](a0_0x4b56cb,async()=>({'tools':[{'name':a0_0x54440c(0x164),'description':'Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','inputSchema':{'type':a0_0x54440c(0xf1),'properties':{'task_id':{'type':'string','description':'The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)'},'text':{'type':a0_0x54440c(0x15f),'description':a0_0x54440c(0x16b)},'status':{'type':'string','enum':['completed','failed','cancelled','blocked',a0_0x54440c(0x14c),a0_0x54440c(0x174)],'description':'Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates'}},'required':[a0_0x54440c(0x179)]}},{'name':a0_0x54440c(0x14f),'description':a0_0x54440c(0x12c),'inputSchema':{'type':a0_0x54440c(0xf1),'properties':{'status':{'type':a0_0x54440c(0x15f),'enum':[a0_0x54440c(0x178),a0_0x54440c(0x11a),'blocked',a0_0x54440c(0x14c)]},'task':{'type':a0_0x54440c(0x15f),'description':a0_0x54440c(0x128)},'progress':{'type':a0_0x54440c(0x161),'description':a0_0x54440c(0x155)}},'required':[a0_0x54440c(0x13e)]}},{'name':'commhub_send_task','description':'Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','inputSchema':{'type':'object','properties':{'alias':{'type':a0_0x54440c(0x15f),'description':'Target\x20session\x20alias'},'task':{'type':a0_0x54440c(0x15f),'description':'Task\x20content'},'priority':{'type':'string','enum':['high',a0_0x54440c(0x123),'low'],'description':a0_0x54440c(0x120)}},'required':[a0_0x54440c(0x15d),a0_0x54440c(0xea)]}},{'name':a0_0x54440c(0x153),'description':a0_0x54440c(0x106),'inputSchema':{'type':a0_0x54440c(0xf1),'properties':{'alias':{'type':'string','description':a0_0x54440c(0x176)},'message':{'type':a0_0x54440c(0x15f),'description':a0_0x54440c(0x170)}},'required':['alias',a0_0x54440c(0x16d)]}},{'name':a0_0x54440c(0x173),'description':a0_0x54440c(0x13c),'inputSchema':{'type':a0_0x54440c(0xf1),'properties':{}}}]}));async function P(_0x40f2f6,_0xd57a7e){const _0x2f2e1f=a0_0x54440c;let _0x41a493=await fetch(D+_0x2f2e1f(0xf9),{'method':_0x2f2e1f(0xed),'headers':{'Content-Type':'application/json','Accept':_0x2f2e1f(0xf5),...X?{'Authorization':_0x2f2e1f(0x158)+X}:{}},'body':JSON[_0x2f2e1f(0x146)]({'jsonrpc':_0x2f2e1f(0x144),'id':0x1,'method':_0x2f2e1f(0x157),'params':{'protocolVersion':_0x2f2e1f(0x145),'capabilities':{},'clientInfo':{'name':_0x2f2e1f(0x12e),'version':'0.3.0'}}})});if(!_0x41a493['ok']){let _0x503eb1=await _0x41a493[_0x2f2e1f(0x179)]();return Y(_0x2f2e1f(0xf0)+_0x41a493[_0x2f2e1f(0x13e)]+'\x20'+_0x503eb1[_0x2f2e1f(0x14a)](0x0,0x64)),{'ok':!0x1,'error':_0x2f2e1f(0xff)+_0x41a493['status']};}await _0x41a493['text']();let _0x2d80fd=(await(await fetch(D+'/mcp',{'method':_0x2f2e1f(0xed),'headers':{'Content-Type':_0x2f2e1f(0x141),'Accept':_0x2f2e1f(0xf5),...X?{'Authorization':_0x2f2e1f(0x158)+X}:{}},'body':JSON[_0x2f2e1f(0x146)]({'jsonrpc':_0x2f2e1f(0x144),'id':0x2,'method':_0x2f2e1f(0x132),'params':{'name':_0x40f2f6,'arguments':_0xd57a7e}})}))[_0x2f2e1f(0x179)]())[_0x2f2e1f(0x151)]('\x0a')[_0x2f2e1f(0x121)](_0x4ab914=>_0x4ab914[_0x2f2e1f(0xe9)]('data:\x20'));if(_0x2d80fd){let _0x42e6be=JSON[_0x2f2e1f(0x166)](_0x2d80fd[_0x2f2e1f(0x14a)](0x6));return _0x42e6be?.[_0x2f2e1f(0x154)]?.[_0x2f2e1f(0x13a)]?.[0x0]?.[_0x2f2e1f(0x179)]?JSON[_0x2f2e1f(0x166)](_0x42e6be[_0x2f2e1f(0x154)][_0x2f2e1f(0x13a)][0x0][_0x2f2e1f(0x179)]):_0x42e6be;}return{'ok':!0x1,'error':_0x2f2e1f(0x116)};}K[a0_0x54440c(0x111)](a0_0x448669,async _0x47f9fe=>{const _0x10f520=a0_0x54440c;let {name:_0x23e66c,arguments:_0x5f5b95}=_0x47f9fe[_0x10f520(0x131)];if(_0x23e66c==='commhub_reply'){let {task_id:_0x4b9637,text:_0x524346,status:_0x58804c}=_0x5f5b95;if(_0x58804c===_0x10f520(0x147)||_0x58804c==='failed'||_0x58804c===_0x10f520(0x12f)){let _0x25e317=_0x58804c===_0x10f520(0x147)?_0x10f520(0x10c):_0x58804c,_0x98a7fb=_0x4b9637?k['get'](_0x4b9637)||'hub':_0x10f520(0x14b),_0x35b267=await P(_0x10f520(0x13d),{'alias':_0x98a7fb,'text':_0x524346,'in_reply_to':_0x4b9637||void 0x0,'status':_0x25e317,'from_session':Z});if(_0x4b9637)k[_0x10f520(0x165)](_0x4b9637);return{'content':[{'type':_0x10f520(0x179),'text':JSON['stringify'](_0x35b267)}]};}let _0x15b74c=await P(_0x10f520(0x110),{'resume_id':w,'alias':Z,'status':_0x58804c==='blocked'?_0x10f520(0xec):_0x58804c==='error'?_0x10f520(0x14c):_0x10f520(0x178),'task':_0x524346[_0x10f520(0x14a)](0x0,0xc8),'output':_0x524346});return{'content':[{'type':_0x10f520(0x179),'text':JSON[_0x10f520(0x146)](_0x15b74c)}]};}if(_0x23e66c===_0x10f520(0x14f)){let {status:_0x323660,task:_0x2cd53f,progress:_0x2e1ec3}=_0x5f5b95,_0x461dd7=await P(_0x10f520(0x110),{'resume_id':w,'alias':Z,'status':_0x323660,'task':_0x2cd53f,'progress':_0x2e1ec3});return{'content':[{'type':_0x10f520(0x179),'text':JSON[_0x10f520(0x146)](_0x461dd7)}]};}if(_0x23e66c===_0x10f520(0x16a)){let {alias:_0x4cf73e,task:_0x93ad7e,priority:_0x3ef929}=_0x5f5b95,_0x37db36=await P(_0x10f520(0x15e),{'alias':_0x4cf73e,'task':_0x93ad7e,'priority':_0x3ef929||_0x10f520(0x123),'from_session':Z});return{'content':[{'type':'text','text':JSON[_0x10f520(0x146)](_0x37db36)}]};}if(_0x23e66c==='commhub_send_message'){let {alias:_0x51429c,message:_0x210444}=_0x5f5b95,_0x5b84a8=await P('send_message',{'alias':_0x51429c,'message':_0x210444,'from_session':Z});return{'content':[{'type':_0x10f520(0x179),'text':JSON['stringify'](_0x5b84a8)}]};}if(_0x23e66c===_0x10f520(0x173)){let _0x24726b=await P('get_all_status',{});return{'content':[{'type':'text','text':JSON[_0x10f520(0x146)](_0x24726b)}]};}return{'content':[{'type':_0x10f520(0x179),'text':JSON[_0x10f520(0x146)]({'error':'unknown\x20tool'})}]};});async function v(){const _0x4abf16=a0_0x54440c;let _0x33a221=D+_0x4abf16(0x167)+encodeURIComponent(Z),_0xef970c={};if(X)_0xef970c[_0x4abf16(0xf4)]=_0x4abf16(0x158)+X;Y(_0x4abf16(0x105)+_0x33a221);while(!0x0){try{let _0x4b32e4=await fetch(_0x33a221,{'headers':_0xef970c});if(!_0x4b32e4['ok']){Y(_0x4abf16(0xeb)+_0x4b32e4[_0x4abf16(0x13e)]+'\x20'+_0x4b32e4['statusText']),await h(0x1388);continue;}let _0xa762a1=_0x4b32e4[_0x4abf16(0x140)][_0x4abf16(0x117)](),_0x29cfdb=new TextDecoder(),_0x425163='';while(!0x0){let {done:_0x580890,value:_0x45ee55}=await _0xa762a1[_0x4abf16(0x102)]();if(_0x580890)break;_0x425163+=_0x29cfdb['decode'](_0x45ee55,{'stream':!0x0});let _0x5d7329=_0x425163[_0x4abf16(0x151)]('\x0a\x0a');_0x425163=_0x5d7329[_0x4abf16(0x133)]()||'';for(let _0x4bea37 of _0x5d7329){let _0x107c88=_0x4bea37[_0x4abf16(0x151)]('\x0a')[_0x4abf16(0x121)](_0x40cd84=>_0x40cd84[_0x4abf16(0xe9)](_0x4abf16(0x150)));if(!_0x107c88)continue;try{let _0x286c2f=JSON[_0x4abf16(0x166)](_0x107c88[_0x4abf16(0x14a)](0x6));await u(_0x286c2f);}catch(_0x13c7e2){Y(_0x4abf16(0x125)+_0x13c7e2);}}}Y(_0x4abf16(0x148));}catch(_0xca2417){Y(_0x4abf16(0x137)+_0xca2417);}await h(0xbb8);}}async function u(_0x1f903d){const _0x3dc041=a0_0x54440c;if(_0x1f903d[_0x3dc041(0x149)]===_0x3dc041(0x16f)){Y('SSE\x20connected\x20as\x20\x22'+Z+'\x22');return;}if(_0x1f903d[_0x3dc041(0x149)]===_0x3dc041(0x135)){if(Y(_0x3dc041(0x177)+_0x1f903d[_0x3dc041(0x11b)]+':\x20'+_0x1f903d[_0x3dc041(0x16d)][_0x3dc041(0x14a)](0x0,0x3c)),await K[_0x3dc041(0x12a)]({'method':_0x3dc041(0x16e),'params':{'content':_0x1f903d[_0x3dc041(0x16d)],'meta':{'sender':_0x1f903d[_0x3dc041(0x11b)]||_0x3dc041(0x14b),'sender_id':'commhub','user':_0x1f903d[_0x3dc041(0x11b)]||_0x3dc041(0x14b),'priority':'normal'}}}),_0x1f903d['message_id'])await P(_0x3dc041(0xf2),{'alias':Z,'message_id':_0x1f903d[_0x3dc041(0x138)]});return;}if(_0x1f903d[_0x3dc041(0x149)]===_0x3dc041(0x126)||_0x1f903d[_0x3dc041(0x149)]===_0x3dc041(0xef)){Y('←\x20'+_0x1f903d[_0x3dc041(0x149)]+_0x3dc041(0x12d)+_0x1f903d['inbox_count']+_0x3dc041(0x114)+(_0x1f903d[_0x3dc041(0x171)]||_0x3dc041(0x123)));let _0x486858=await P(_0x3dc041(0x122),{'alias':Z,'limit':0x5});if(_0x486858?.['ok']&&_0x486858[_0x3dc041(0xfd)]?.['length']>0x0)for(let _0x5187fd of _0x486858[_0x3dc041(0xfd)]){let _0x5cb385={'sender':_0x5187fd[_0x3dc041(0x104)]||_0x3dc041(0x14b),'sender_id':_0x3dc041(0x11d),'user':_0x5187fd[_0x3dc041(0x104)]||_0x3dc041(0x14b),'task_id':_0x5187fd['id'],'priority':_0x5187fd[_0x3dc041(0x171)]||_0x3dc041(0x123)};k[_0x3dc041(0xfa)](_0x5187fd['id'],_0x5187fd[_0x3dc041(0x104)]||_0x3dc041(0x14b)),await K[_0x3dc041(0x12a)]({'method':_0x3dc041(0x16e),'params':{'content':_0x5187fd['content'],'meta':_0x5cb385}}),Y('→\x20injected\x20task\x20'+_0x5187fd['id'][_0x3dc041(0x14a)](0x0,0x8)+_0x3dc041(0x136)+_0x5187fd[_0x3dc041(0x104)]+':\x20'+_0x5187fd[_0x3dc041(0x13a)]['slice'](0x0,0x3c)),await P(_0x3dc041(0xf2),{'alias':Z,'message_id':_0x5187fd['id']});}}}function a0_0x58c6(){const _0x284429=['none','replied','fatal:\x20','catch',']\x20[commhub]\x20','report_status','setRequestHandler','registered\x20as\x20\x22','\x22\x20(','\x20priority=','539056vPccGc','no\x20response','getReader','.env','tmux\x20display-message\x20-p\x20\x27#S\x27','idle','from','\x20PROJECT_ENV=','commhub','connect','exit','Priority\x20(default:\x20normal)','find','get_inbox','normal','.claude/channels/commhub','parse\x20error:\x20','new_task','config.json','Current\x20task\x20description','token','notification','.anet','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.',':\x20inbox_count=','commhub-channel','cancelled','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','params','tools/call','pop','8qoMLIo','new_message','\x20from\x20','SSE\x20connection\x20error:\x20','message_id','ready\x20—\x20waiting\x20for\x20events','content','...\x20TMUX=','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','send_reply','status','write','body','application/json','claude-code','1287837mjVGdL','2.0','2025-03-26','stringify','completed','SSE\x20stream\x20ended,\x20reconnecting...','type','slice','hub','error','utf-8','indexOf','commhub_report_status','data:\x20','split','trim','commhub_send_message','result','Progress\x200-100','84MfNmse','initialize','Bearer\x20','671PSXzoY','stderr','SIGTERM','Session\x20alias:\x20','alias','send_task','string','234352RTUbWy','number','toTimeString','then','commhub_reply','delete','parse','/events/','36465eNowGx','0.3.0','commhub_send_task','Reply\x20text\x20/\x20result\x20summary','replace','message','notifications/claude/channel','connected','Message\x20content','priority','1368850OkyfQV','commhub_get_all_status','in_progress','15234hwjYVF','Target\x20session\x20alias','←\x20message\x20from\x20','working','text','join','startsWith','task','SSE\x20error:\x20','blocked','POST','cwd','broadcast','CommHub\x20init\x20failed:\x20','object','ack_inbox','end','Authorization','application/json,\x20text/event-stream','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','session\x20disconnected','/mcp','set','126npOUPc','randomUUID','messages','11580VOEZsv','init\x20failed:\x20','\x20RESUME_ID=','6EyNSEw','read','\x20CWD=','from_session','connecting\x20to\x20','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','\x20ALIAS=','SSE\x20fatal:\x20','165170zcZnod','http://127.0.0.1:9200'];a0_0x58c6=function(){return _0x284429;};return a0_0x58c6();}async function S(){const _0x280225=a0_0x54440c;let _0x123aff=new a0_0x1dd8bb();await K[_0x280225(0x11e)](_0x123aff),Y('MCP\x20stdio\x20connected'),Y('starting\x20SSE\x20listener...'),v()['catch'](_0x4662fc=>Y(_0x280225(0x108)+_0x4662fc)),P(_0x280225(0x110),{'resume_id':w,'alias':Z,'status':'idle','server':a0_0x567625(),'hostname':a0_0x567625(),'agent':_0x280225(0x142),'project_dir':process[_0x280225(0xee)](),'tmux_name':f||void 0x0})[_0x280225(0x163)](()=>Y(_0x280225(0x112)+Z+_0x280225(0x113)+w[_0x280225(0x14a)](0x0,0x8)+')'))[_0x280225(0x10e)](_0x16721f=>Y('warning:\x20could\x20not\x20register:\x20'+_0x16721f)),setInterval(()=>{const _0x501b48=_0x280225;P(_0x501b48(0x110),{'resume_id':w,'alias':Z,'status':_0x501b48(0x11a),'server':a0_0x567625(),'hostname':a0_0x567625(),'agent':_0x501b48(0x142),'project_dir':process[_0x501b48(0xee)](),'tmux_name':f||void 0x0})['catch'](_0x9ad3f9=>Y('heartbeat\x20failed:\x20'+_0x9ad3f9));},0x2bf20),Y(_0x280225(0x139));}S()[a0_0x54440c(0x10e)](_0x52916c=>{const _0x369773=a0_0x54440c;Y(_0x369773(0x10d)+_0x52916c),process['exit'](0x1);});async function N(){const _0x2842ce=a0_0x54440c;Y('shutting\x20down,\x20reporting\x20offline...'),await P(_0x2842ce(0x110),{'resume_id':w,'alias':Z,'status':_0x2842ce(0x14c),'task':_0x2842ce(0xf8)})[_0x2842ce(0x10e)](()=>{}),process[_0x2842ce(0x11f)](0x0);}process['stdin']['on'](a0_0x54440c(0xf3),()=>N()),process['on'](a0_0x54440c(0x15b),()=>N()),process['on']('SIGINT',()=>N());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleep2agi/agent-network",
|
|
3
|
-
"version": "2.0.0-preview.
|
|
3
|
+
"version": "2.0.0-preview.10",
|
|
4
4
|
"description": "AI Agent Network — Server + Client + Setup in one package. SSE real-time communication for multi-agent orchestration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/client.js",
|