@sleep2agi/agent-network 2.3.0-preview.1 → 2.3.0-preview.2
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/bin/cli.js +1 -1
- package/dist/src/client.js +1 -1
- package/dist/src/node-server.js +1 -1
- package/dist/src/supervise-child.d.ts +69 -0
- package/package.json +1 -1
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a0_0x238205=a0_0x2b7c;function a0_0x2b7c(_0x175c5d,_0x2926b1){_0x175c5d=_0x175c5d-0x85;const _0x23a12f=a0_0x23a1();let _0x2b7c69=_0x23a12f[_0x175c5d];return _0x2b7c69;}(function(_0xb48d31,_0x3723fb){const _0x480c8f=a0_0x2b7c,_0x326564=_0xb48d31();while(!![]){try{const _0x381c99=-parseInt(_0x480c8f(0x9e))/0x1+parseInt(_0x480c8f(0xc3))/0x2+-parseInt(_0x480c8f(0x94))/0x3+-parseInt(_0x480c8f(0xa3))/0x4+-parseInt(_0x480c8f(0xab))/0x5+-parseInt(_0x480c8f(0xd4))/0x6*(parseInt(_0x480c8f(0xcb))/0x7)+parseInt(_0x480c8f(0xcf))/0x8;if(_0x381c99===_0x3723fb)break;else _0x326564['push'](_0x326564['shift']());}catch(_0x27405c){_0x326564['push'](_0x326564['shift']());}}}(a0_0x23a1,0x8127b));import{EventEmitter as a0_0x215187}from'events';import{hostname as a0_0x57b3e8}from'os';class T extends a0_0x215187{[a0_0x238205(0xad)];[a0_0x238205(0xb4)];[a0_0x238205(0xc0)];['agent'];[a0_0x238205(0xd2)];[a0_0x238205(0xae)];[a0_0x238205(0x99)];[a0_0x238205(0x9f)];[a0_0x238205(0xaf)];[a0_0x238205(0xd3)]=!0x1;constructor(_0x385ded){const _0x35e6f0=a0_0x238205;super();if(this[_0x35e6f0(0xad)]=_0x385ded['url'][_0x35e6f0(0xc5)](/\/$/,''),this['alias']=_0x385ded[_0x35e6f0(0xb4)],this[_0x35e6f0(0xc0)]=_0x385ded[_0x35e6f0(0xc0)],this[_0x35e6f0(0xb8)]=_0x385ded[_0x35e6f0(0xb8)]||'sdk',this[_0x35e6f0(0xd2)]=_0x35e6f0(0x92)+_0x385ded[_0x35e6f0(0xb4)]+'-'+Date[_0x35e6f0(0xb1)]()['toString'](0x24),this['heartbeatInterval']=_0x385ded[_0x35e6f0(0xae)]??0x2bf20,this[_0x35e6f0(0x99)]=_0x385ded[_0x35e6f0(0x99)]??0xbb8,_0x385ded['autoConnect']!==!0x1)this[_0x35e6f0(0xa2)]();}[a0_0x238205(0xac)](_0x4840fe){const _0x52658d=a0_0x238205;console['log']('['+new Date()[_0x52658d(0xa5)]()[_0x52658d(0xaa)](0x0,0x8)+_0x52658d(0x91)+this[_0x52658d(0xb4)]+']\x20'+_0x4840fe);}async[a0_0x238205(0x96)](_0x517436,_0x2a96c8){const _0x1d3e28=a0_0x238205;let _0x38450b={'Content-Type':_0x1d3e28(0xbf),'Accept':_0x1d3e28(0xa8)};if(this[_0x1d3e28(0xc0)])_0x38450b[_0x1d3e28(0x93)]=_0x1d3e28(0xbe)+this[_0x1d3e28(0xc0)];let _0x3cecd1=await(await fetch(this[_0x1d3e28(0xad)]+_0x1d3e28(0x8a),{'method':_0x1d3e28(0x8c),'headers':_0x38450b,'body':JSON[_0x1d3e28(0xd8)]({'jsonrpc':'2.0','id':Date['now'](),'method':_0x1d3e28(0xc7),'params':{'name':_0x517436,'arguments':_0x2a96c8}})}))[_0x1d3e28(0xa0)](),_0x431d3c=_0x3cecd1['match'](/data: (.+)/),_0x3783ee=_0x431d3c?JSON[_0x1d3e28(0xcc)](_0x431d3c[0x1]):JSON[_0x1d3e28(0xcc)](_0x3cecd1),_0xcfafca=_0x3783ee?.['result']?.[_0x1d3e28(0xbc)]?.[0x0]?.[_0x1d3e28(0xa0)];return _0xcfafca?JSON[_0x1d3e28(0xcc)](_0xcfafca):_0x3783ee;}async[a0_0x238205(0xa2)](){const _0x1bc965=a0_0x238205;if(this[_0x1bc965(0xd3)])return;this[_0x1bc965(0xd3)]=!0x0,await this[_0x1bc965(0xa1)](_0x1bc965(0xa6)),this[_0x1bc965(0xac)](_0x1bc965(0xd7)),this['heartbeatTimer']=setInterval(()=>{const _0x1760d2=_0x1bc965;this['status'](_0x1760d2(0xa6))[_0x1760d2(0xb2)](_0x44a3b6=>this[_0x1760d2(0xac)](_0x1760d2(0xd1)+_0x44a3b6['message']));},this[_0x1bc965(0xae)]),this[_0x1bc965(0xc9)]();}async[a0_0x238205(0x8e)](){const _0x51fa1c=a0_0x238205;if(this[_0x51fa1c(0xd3)]=!0x1,this['sseAbort']?.[_0x51fa1c(0xb7)](),this['heartbeatTimer'])clearInterval(this[_0x51fa1c(0x9f)]);await this[_0x51fa1c(0xa1)]('offline')[_0x51fa1c(0xb2)](()=>{}),this[_0x51fa1c(0xac)]('disconnected');}async[a0_0x238205(0x86)](_0x372dfe,_0x44cc24,_0x22957a='normal'){const _0x29c4b8=a0_0x238205;return this[_0x29c4b8(0x96)](_0x29c4b8(0x8b),{'alias':_0x372dfe,'task':_0x44cc24,'priority':_0x22957a,'from_session':this['alias']});}async['message'](_0x989e93,_0x493467){const _0x12fe94=a0_0x238205;return this[_0x12fe94(0x96)](_0x12fe94(0xd6),{'alias':_0x989e93,'message':_0x493467,'from_session':this['alias']});}async[a0_0x238205(0xa9)](_0x42872c,_0x35fb9b,_0x2c4a30=a0_0x238205(0xca)){const _0x2b0c57=a0_0x238205;return this['call'](_0x2b0c57(0xba),{'in_reply_to':_0x42872c,'text':_0x35fb9b,'status':_0x2c4a30});}async[a0_0x238205(0xa1)](_0x3a3f60,_0x2e5e21){const _0x4098ec=a0_0x238205;return this[_0x4098ec(0x96)](_0x4098ec(0xcd),{'resume_id':this[_0x4098ec(0xd2)],'alias':this[_0x4098ec(0xb4)],'status':_0x3a3f60,'server':a0_0x57b3e8(),'hostname':a0_0x57b3e8(),'agent':this[_0x4098ec(0xb8)],'project_dir':process['cwd'](),..._0x2e5e21});}async[a0_0x238205(0x89)](){return this['call']('get_all_status',{});}async[a0_0x238205(0x87)](_0x275aea,_0x5a5e2f){const _0x3ed4fc=a0_0x238205;return this[_0x3ed4fc(0x96)](_0x3ed4fc(0x87),{'message':_0x275aea,'filter_server':_0x5a5e2f?.[_0x3ed4fc(0xd9)],'filter_status':_0x5a5e2f?.[_0x3ed4fc(0xa1)]});}async['connectSSE'](){const _0x12de34=a0_0x238205;let _0x2fe4c8=encodeURIComponent(this['alias']),_0x3a9f03=this[_0x12de34(0xad)]+_0x12de34(0xb0)+_0x2fe4c8,_0x1aecc9=this[_0x12de34(0x99)];while(this[_0x12de34(0xd3)]){try{this[_0x12de34(0xaf)]=new AbortController();let _0x2cddf1={'Accept':_0x12de34(0x9d)};if(this[_0x12de34(0xc0)])_0x2cddf1[_0x12de34(0x93)]=_0x12de34(0xbe)+this[_0x12de34(0xc0)];let _0x33eda3=await fetch(_0x3a9f03,{'headers':_0x2cddf1,'signal':this[_0x12de34(0xaf)]['signal']});if(!_0x33eda3['ok']||!_0x33eda3['body']){this[_0x12de34(0xac)]('SSE\x20failed:\x20'+_0x33eda3[_0x12de34(0xa1)]),await this[_0x12de34(0xb3)](_0x1aecc9),_0x1aecc9=Math['min'](_0x1aecc9*1.5,0xea60);continue;}_0x1aecc9=this[_0x12de34(0x99)];let _0x341aac=_0x33eda3['body'][_0x12de34(0x8f)](),_0x35cc8e=new TextDecoder(),_0x4b108b='';while(this['running']){let {done:_0x24050f,value:_0x1bfb06}=await _0x341aac[_0x12de34(0x88)]();if(_0x24050f)break;_0x4b108b+=_0x35cc8e[_0x12de34(0x85)](_0x1bfb06,{'stream':!0x0});let _0x5e200b=_0x4b108b[_0x12de34(0x8d)]('\x0a');_0x4b108b=_0x5e200b[_0x12de34(0x9b)]()||'';for(let _0x384271 of _0x5e200b){if(!_0x384271[_0x12de34(0xb5)](_0x12de34(0xc1)))continue;try{let _0x3a961e=JSON[_0x12de34(0xcc)](_0x384271[_0x12de34(0xaa)](0x6));if(_0x3a961e[_0x12de34(0x95)]===_0x12de34(0x9a)){this[_0x12de34(0xac)]('SSE\x20connected'),this[_0x12de34(0x98)]('connected');continue;}if(_0x3a961e['type']===_0x12de34(0xa4)||_0x3a961e[_0x12de34(0x95)]===_0x12de34(0xce)||_0x3a961e[_0x12de34(0x95)]===_0x12de34(0x87))await this['processInbox']();}catch{}}}}catch(_0x571d98){if(_0x571d98[_0x12de34(0xa7)]===_0x12de34(0xc2))break;this[_0x12de34(0x98)](_0x12de34(0xbb),_0x571d98),this[_0x12de34(0xac)](_0x12de34(0xb9)+_0x571d98[_0x12de34(0x9c)]);}if(this[_0x12de34(0xd3)])this['emit'](_0x12de34(0xbd)),this[_0x12de34(0xac)]('SSE\x20reconnecting\x20in\x20'+_0x1aecc9/0x3e8+_0x12de34(0xc6)),await this[_0x12de34(0xb3)](_0x1aecc9),_0x1aecc9=Math[_0x12de34(0xb6)](_0x1aecc9*1.5,0xea60);}}async['processInbox'](){const _0x17178b=a0_0x238205;try{let _0x48b1bc=(await this[_0x17178b(0x96)](_0x17178b(0xd0),{'alias':this[_0x17178b(0xb4)],'limit':0xa}))?.[_0x17178b(0x90)]||[];for(let _0x34f496 of _0x48b1bc)await this['call'](_0x17178b(0xc8),{'alias':this[_0x17178b(0xb4)],'message_id':_0x34f496['id']}),this['log']('←\x20'+_0x34f496[_0x17178b(0xd5)]+':\x20'+_0x34f496[_0x17178b(0xbc)][_0x17178b(0xaa)](0x0,0x3c)),this[_0x17178b(0x98)](_0x17178b(0x97),_0x34f496),this[_0x17178b(0x98)]('message',_0x34f496);}catch(_0x7e4517){this['log'](_0x17178b(0xc4)+_0x7e4517['message']);}}[a0_0x238205(0xb3)](_0x53c25e){return new Promise(_0xb360dd=>setTimeout(_0xb360dd,_0x53c25e));}}var $=T;function a0_0x23a1(){const _0x5453aa=['data:\x20','AbortError','299620tuVXUi','inbox\x20error:\x20','replace','s...','tools/call','ack_inbox','connectSSE','completed','13237xRPZks','parse','report_status','new_message','27442120rKbIIY','get_inbox','heartbeat\x20failed:\x20','resumeId','running','1614SnCWod','from_session','send_message','registered','stringify','server','decode','send','broadcast','read','getAllStatus','/mcp','send_task','POST','split','disconnect','getReader','messages',']\x20[commhub:','sdk-','Authorization','1888005nrYQPX','type','call','task','emit','reconnectDelay','connected','pop','message','text/event-stream','848563eiDPPz','heartbeatTimer','text','status','connect','359936YELHsR','new_task','toTimeString','idle','name','application/json,\x20text/event-stream','reply','slice','4872475dnIcop','log','url','heartbeatInterval','sseAbort','/events/','now','catch','sleep','alias','startsWith','min','abort','agent','SSE\x20error:\x20','send_reply','error','content','disconnected','Bearer\x20','application/json','token'];a0_0x23a1=function(){return _0x5453aa;};return a0_0x23a1();}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_0x2f6489=a0_0x910f;(function(_0x10285f,_0x31ae8e){const _0x252300=a0_0x910f,_0x29240d=_0x10285f();while(!![]){try{const _0x240ff0=-parseInt(_0x252300(0x1d7))/0x1*(-parseInt(_0x252300(0x235))/0x2)+-parseInt(_0x252300(0x1d5))/0x3*(-parseInt(_0x252300(0x220))/0x4)+-parseInt(_0x252300(0x1b3))/0x5+-parseInt(_0x252300(0x221))/0x6+-parseInt(_0x252300(0x23e))/0x7*(parseInt(_0x252300(0x1cd))/0x8)+parseInt(_0x252300(0x20b))/0x9+parseInt(_0x252300(0x201))/0xa;if(_0x240ff0===_0x31ae8e)break;else _0x29240d['push'](_0x29240d['shift']());}catch(_0x7d01d6){_0x29240d['push'](_0x29240d['shift']());}}}(a0_0x26a1,0x6ff10));import{readFileSync as a0_0x125c3b,existsSync as a0_0x4d8313}from'fs';import{randomUUID as a0_0x57c336}from'crypto';import{join as a0_0x293d60}from'path';import{hostname as a0_0x26e9c9}from'os';import{execSync as a0_0x4c624f}from'child_process';import{Server as a0_0x11b58c}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x57ed7a}from'@modelcontextprotocol/sdk/server/stdio.js';function a0_0x910f(_0x5d44f4,_0x2fe00d){_0x5d44f4=_0x5d44f4-0x1af;const _0x26a11c=a0_0x26a1();let _0x910f7=_0x26a11c[_0x5d44f4];return _0x910f7;}import{ListToolsRequestSchema as a0_0x4a3abc,CallToolRequestSchema as a0_0x49d6db}from'@modelcontextprotocol/sdk/types.js';function I(_0x912882){const _0x5b7df3=a0_0x910f;if(!a0_0x4d8313(_0x912882))return;for(let _0x161f68 of a0_0x125c3b(_0x912882,_0x5b7df3(0x236))[_0x5b7df3(0x1d4)]('\x0a')){let _0x28c117=_0x161f68[_0x5b7df3(0x244)]();if(!_0x28c117||_0x28c117[_0x5b7df3(0x246)]('#'))continue;let _0x13a768=_0x28c117['indexOf']('=');if(_0x13a768<0x0)continue;let _0x3ed58c=_0x28c117[_0x5b7df3(0x210)](0x0,_0x13a768)[_0x5b7df3(0x244)](),_0x287877=_0x28c117[_0x5b7df3(0x210)](_0x13a768+0x1)[_0x5b7df3(0x244)]()[_0x5b7df3(0x208)](/^["']|["']$/g,'');if(!process.env[_0x3ed58c])process.env[_0x3ed58c]=_0x287877;}}var L=process.env.HOME||'~',U=a0_0x293d60(L,a0_0x2f6489(0x1e3));I(a0_0x293d60(U,a0_0x2f6489(0x1e1)));var v=process[a0_0x2f6489(0x1dd)]()[a0_0x2f6489(0x208)](/\//g,'-');I(a0_0x293d60(U,v,a0_0x2f6489(0x1e1)));function d(){const _0x3b3e6c=a0_0x2f6489;try{return a0_0x4c624f(_0x3b3e6c(0x1c1),{'encoding':_0x3b3e6c(0x236),'timeout':0x7d0})[_0x3b3e6c(0x244)]();}catch{return'';}}function m(){const _0x1c7b18=a0_0x2f6489;try{let _0x2f66c3=a0_0x293d60(L,'.anet',_0x1c7b18(0x1d9));if(a0_0x4d8313(_0x2f66c3))return JSON['parse'](a0_0x125c3b(_0x2f66c3,_0x1c7b18(0x236)));}catch{}return{};}var u=m(),j=process.env.COMMHUB_URL||u[a0_0x2f6489(0x1ce)]||a0_0x2f6489(0x24b),f=process.env.COMMHUB_TMUX||d();function r(){const _0x3a4531=a0_0x2f6489;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS['trim']())return process.env.COMMHUB_ALIAS['trim']();return process[_0x3a4531(0x22d)][_0x3a4531(0x1bc)](_0x3a4531(0x21c)+(_0x3a4531(0x1c7)+(f||_0x3a4531(0x1ff))+_0x3a4531(0x1c9)+a0_0x26e9c9()+_0x3a4531(0x230))),_0x3a4531(0x243)+process[_0x3a4531(0x234)];}var G=r(),K=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x57c336(),F=process.env.COMMHUB_TOKEN||u[a0_0x2f6489(0x1d6)]||'';function W(_0x432d7e){const _0x1f663a=a0_0x2f6489;let _0x3ac2ec=new Date()[_0x1f663a(0x1f3)]()[_0x1f663a(0x210)](0x0,0x8);process['stderr']['write']('['+_0x3ac2ec+_0x1f663a(0x23b)+_0x432d7e+'\x0a');}function N(_0x5b13a9){return new Promise(_0x32ec43=>setTimeout(_0x32ec43,_0x5b13a9));}W(a0_0x2f6489(0x24a)+j+a0_0x2f6489(0x245)+G+a0_0x2f6489(0x1cb)+K[a0_0x2f6489(0x210)](0x0,0x8)+'...\x20TMUX='+(f||a0_0x2f6489(0x218))+a0_0x2f6489(0x242)+process[a0_0x2f6489(0x1dd)]()+a0_0x2f6489(0x1cc)+v);var D=new Map(),x=new a0_0x11b58c({'name':a0_0x2f6489(0x228),'version':a0_0x2f6489(0x20d)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x2f6489(0x1af),a0_0x2f6489(0x1b8),a0_0x2f6489(0x240),'You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','Session\x20alias:\x20'+G][a0_0x2f6489(0x1f5)]('\x0a')});x[a0_0x2f6489(0x214)](a0_0x4a3abc,async()=>({'tools':[{'name':a0_0x2f6489(0x1f4),'description':a0_0x2f6489(0x204),'inputSchema':{'type':a0_0x2f6489(0x1dc),'properties':{'task_id':{'type':a0_0x2f6489(0x1c6),'description':'The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)'},'text':{'type':a0_0x2f6489(0x1c6),'description':'Reply\x20text\x20/\x20result\x20summary'},'status':{'type':a0_0x2f6489(0x1c6),'enum':[a0_0x2f6489(0x1c0),a0_0x2f6489(0x1b7),a0_0x2f6489(0x1be),'blocked','error','in_progress'],'description':'Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates'}},'required':[a0_0x2f6489(0x1e4)]}},{'name':a0_0x2f6489(0x1ea),'description':a0_0x2f6489(0x1b0),'inputSchema':{'type':'object','properties':{'status':{'type':a0_0x2f6489(0x1c6),'enum':[a0_0x2f6489(0x1f9),'idle',a0_0x2f6489(0x20e),a0_0x2f6489(0x1fa)]},'task':{'type':'string','description':a0_0x2f6489(0x21a)},'progress':{'type':a0_0x2f6489(0x224),'description':'Progress\x200-100'}},'required':[a0_0x2f6489(0x1b2)]}},{'name':a0_0x2f6489(0x22f),'description':'Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','inputSchema':{'type':a0_0x2f6489(0x1dc),'properties':{'alias':{'type':a0_0x2f6489(0x1c6),'description':a0_0x2f6489(0x1ef)},'task':{'type':a0_0x2f6489(0x1c6),'description':a0_0x2f6489(0x1ba)},'priority':{'type':a0_0x2f6489(0x1c6),'enum':[a0_0x2f6489(0x206),a0_0x2f6489(0x1bd),'low'],'description':a0_0x2f6489(0x1f1)}},'required':[a0_0x2f6489(0x1d1),'task']}},{'name':a0_0x2f6489(0x241),'description':a0_0x2f6489(0x203),'inputSchema':{'type':a0_0x2f6489(0x1dc),'properties':{'alias':{'type':a0_0x2f6489(0x1c6),'description':a0_0x2f6489(0x1ef)},'message':{'type':'string','description':a0_0x2f6489(0x1da)}},'required':[a0_0x2f6489(0x1d1),a0_0x2f6489(0x225)]}},{'name':'commhub_get_all_status','description':a0_0x2f6489(0x219),'inputSchema':{'type':a0_0x2f6489(0x1dc),'properties':{}}}]}));async function Y(_0x43e00e,_0x330ede){const _0x5ad611=a0_0x2f6489;let _0xeb0fe3=await fetch(j+_0x5ad611(0x1bf),{'method':'POST','headers':{'Content-Type':_0x5ad611(0x1fd),'Accept':'application/json,\x20text/event-stream',...F?{'Authorization':_0x5ad611(0x21d)+F}:{}},'body':JSON[_0x5ad611(0x1c4)]({'jsonrpc':'2.0','id':0x1,'method':_0x5ad611(0x215),'params':{'protocolVersion':_0x5ad611(0x20c),'capabilities':{},'clientInfo':{'name':_0x5ad611(0x228),'version':_0x5ad611(0x20d)}}})});if(!_0xeb0fe3['ok']){let _0x21e042=await _0xeb0fe3['text']();return W(_0x5ad611(0x216)+_0xeb0fe3[_0x5ad611(0x1b2)]+'\x20'+_0x21e042[_0x5ad611(0x210)](0x0,0x64)),{'ok':!0x1,'error':'init\x20failed:\x20'+_0xeb0fe3[_0x5ad611(0x1b2)]};}await _0xeb0fe3[_0x5ad611(0x1e4)]();let _0x2e6801=(await(await fetch(j+_0x5ad611(0x1bf),{'method':_0x5ad611(0x223),'headers':{'Content-Type':_0x5ad611(0x1fd),'Accept':'application/json,\x20text/event-stream',...F?{'Authorization':_0x5ad611(0x21d)+F}:{}},'body':JSON[_0x5ad611(0x1c4)]({'jsonrpc':_0x5ad611(0x232),'id':0x2,'method':_0x5ad611(0x1b9),'params':{'name':_0x43e00e,'arguments':_0x330ede}})}))[_0x5ad611(0x1e4)]())[_0x5ad611(0x1d4)]('\x0a')[_0x5ad611(0x239)](_0x50e346=>_0x50e346[_0x5ad611(0x246)](_0x5ad611(0x226)));if(_0x2e6801){let _0x558dbe=JSON[_0x5ad611(0x231)](_0x2e6801[_0x5ad611(0x210)](0x6));return _0x558dbe?.[_0x5ad611(0x238)]?.[_0x5ad611(0x1c8)]?.[0x0]?.[_0x5ad611(0x1e4)]?JSON[_0x5ad611(0x231)](_0x558dbe[_0x5ad611(0x238)][_0x5ad611(0x1c8)][0x0][_0x5ad611(0x1e4)]):_0x558dbe;}return{'ok':!0x1,'error':_0x5ad611(0x247)};}x[a0_0x2f6489(0x214)](a0_0x49d6db,async _0x6c7e78=>{const _0x67f01=a0_0x2f6489;let {name:_0x5d7ba4,arguments:_0x4bd0a8}=_0x6c7e78['params'];if(_0x5d7ba4===_0x67f01(0x1f4)){let {task_id:_0x97858b,text:_0x2a3a1a,status:_0x27e114}=_0x4bd0a8;if(_0x27e114===_0x67f01(0x1c0)||_0x27e114==='failed'||_0x27e114===_0x67f01(0x1be)){let _0x25d572=_0x27e114==='completed'?_0x67f01(0x233):_0x27e114,_0x368820=_0x97858b?D[_0x67f01(0x213)](_0x97858b)||_0x67f01(0x1ce):_0x67f01(0x1ce),_0x143467=await Y(_0x67f01(0x1f8),{'alias':_0x368820,'text':_0x2a3a1a,'in_reply_to':_0x97858b||void 0x0,'status':_0x25d572,'from_session':G});if(_0x97858b)D[_0x67f01(0x1e6)](_0x97858b);return{'content':[{'type':_0x67f01(0x1e4),'text':JSON[_0x67f01(0x1c4)](_0x143467)}]};}let _0x45b44e=await Y(_0x67f01(0x1d0),{'resume_id':K,'alias':G,'status':_0x27e114==='blocked'?'blocked':_0x27e114==='error'?_0x67f01(0x1fa):_0x67f01(0x1f9),'task':_0x2a3a1a[_0x67f01(0x210)](0x0,0xc8),'output':_0x2a3a1a});return{'content':[{'type':_0x67f01(0x1e4),'text':JSON[_0x67f01(0x1c4)](_0x45b44e)}]};}if(_0x5d7ba4===_0x67f01(0x1ea)){let {status:_0x243ced,task:_0x6b3607,progress:_0x24b30b}=_0x4bd0a8,_0x5cf599=await Y(_0x67f01(0x1d0),{'resume_id':K,'alias':G,'status':_0x243ced,'task':_0x6b3607,'progress':_0x24b30b});return{'content':[{'type':'text','text':JSON[_0x67f01(0x1c4)](_0x5cf599)}]};}if(_0x5d7ba4===_0x67f01(0x22f)){let {alias:_0x2774a0,task:_0x21befa,priority:_0x718814}=_0x4bd0a8,_0x5adf2f=await Y(_0x67f01(0x209),{'alias':_0x2774a0,'task':_0x21befa,'priority':_0x718814||_0x67f01(0x1bd),'from_session':G});return{'content':[{'type':_0x67f01(0x1e4),'text':JSON[_0x67f01(0x1c4)](_0x5adf2f)}]};}if(_0x5d7ba4==='commhub_send_message'){let {alias:_0x55f867,message:_0x119296}=_0x4bd0a8,_0x37cfcf=await Y(_0x67f01(0x237),{'alias':_0x55f867,'message':_0x119296,'from_session':G});return{'content':[{'type':_0x67f01(0x1e4),'text':JSON[_0x67f01(0x1c4)](_0x37cfcf)}]};}if(_0x5d7ba4===_0x67f01(0x249)){let _0x475d0b=await Y(_0x67f01(0x1f0),{});return{'content':[{'type':_0x67f01(0x1e4),'text':JSON[_0x67f01(0x1c4)](_0x475d0b)}]};}return{'content':[{'type':_0x67f01(0x1e4),'text':JSON['stringify']({'error':_0x67f01(0x1b4)})}]};});var O=0x3e8,R=0x7530,T=0x36ee80;async function l(){const _0x328c5e=a0_0x2f6489;try{await Y(_0x328c5e(0x1d0),{'resume_id':K,'alias':G,'status':_0x328c5e(0x1e9),'server':a0_0x26e9c9(),'hostname':a0_0x26e9c9(),'agent':_0x328c5e(0x1f2),'project_dir':process[_0x328c5e(0x1dd)](),'tmux_name':f||void 0x0}),W(_0x328c5e(0x21f)+G+'\x22\x20after\x20SSE\x20reconnect');}catch(_0x807f81){W(_0x328c5e(0x1cf)+_0x807f81);}}async function o(){const _0x462214=a0_0x2f6489;let _0x2b4bf=j+_0x462214(0x20a)+encodeURIComponent(G),_0x6d743f={};if(F)_0x6d743f[_0x462214(0x1fe)]=_0x462214(0x21d)+F;W(_0x462214(0x1e0)+_0x2b4bf);let _0x29848f=O,_0x4dd33d=!0x0,_0x85c049=null;while(!0x0){try{let _0x2ce17d=await fetch(_0x2b4bf,{'headers':_0x6d743f});if(!_0x2ce17d['ok']){if(W(_0x462214(0x1f6)+_0x2ce17d[_0x462214(0x1b2)]+'\x20'+_0x2ce17d['statusText']),_0x85c049=_0x85c049??Date[_0x462214(0x1db)](),Date['now']()-_0x85c049>T){W(_0x462214(0x217)+j+_0x462214(0x22a));return;}await N(_0x29848f),_0x29848f=Math[_0x462214(0x24c)](_0x29848f*0x2,R);continue;}let _0x68713e=_0x2ce17d[_0x462214(0x1c3)][_0x462214(0x1ee)](),_0x37bc22=new TextDecoder(),_0x48b9e8='';_0x29848f=O;while(!0x0){let {done:_0x5848e3,value:_0x48e64b}=await _0x68713e[_0x462214(0x22e)]();if(_0x5848e3)break;_0x48b9e8+=_0x37bc22[_0x462214(0x1b6)](_0x48e64b,{'stream':!0x0});let _0x109970=_0x48b9e8[_0x462214(0x1d4)]('\x0a\x0a');_0x48b9e8=_0x109970[_0x462214(0x207)]()||'';for(let _0x464724 of _0x109970){let _0x5bb1ec=_0x464724[_0x462214(0x1d4)]('\x0a')[_0x462214(0x239)](_0x257d8a=>_0x257d8a['startsWith'](_0x462214(0x226)));if(!_0x5bb1ec)continue;try{let _0x3904b3=JSON['parse'](_0x5bb1ec[_0x462214(0x210)](0x6));if(await a(_0x3904b3),_0x3904b3['type']===_0x462214(0x205)){if(_0x85c049=null,!_0x4dd33d)await l();_0x4dd33d=!0x1;}}catch(_0x195748){W('parse\x20error:\x20'+_0x195748);}}}W(_0x462214(0x248));}catch(_0x208427){W(_0x462214(0x1e7)+_0x208427);}if(_0x85c049=_0x85c049??Date['now'](),Date[_0x462214(0x1db)]()-_0x85c049>T){W(_0x462214(0x217)+j+_0x462214(0x22a));return;}await N(_0x29848f),_0x29848f=Math[_0x462214(0x24c)](_0x29848f*0x2,R);}}async function a(_0x3cb4d0){const _0x177a92=a0_0x2f6489;if(_0x3cb4d0[_0x177a92(0x23c)]===_0x177a92(0x205)){W(_0x177a92(0x1b1)+G+'\x22');return;}if(_0x3cb4d0[_0x177a92(0x23c)]===_0x177a92(0x23f)){if(W(_0x177a92(0x23d)+_0x3cb4d0[_0x177a92(0x1d2)]+':\x20'+_0x3cb4d0[_0x177a92(0x225)][_0x177a92(0x210)](0x0,0x3c)),await x['notification']({'method':_0x177a92(0x1fc),'params':{'content':_0x3cb4d0[_0x177a92(0x225)],'meta':{'sender':_0x3cb4d0[_0x177a92(0x1d2)]||_0x177a92(0x1ce),'sender_id':_0x177a92(0x1eb),'user':_0x3cb4d0['from']||_0x177a92(0x1ce),'priority':_0x177a92(0x1bd)}}}),_0x3cb4d0[_0x177a92(0x23a)])await Y('ack_inbox',{'alias':G,'message_id':_0x3cb4d0['message_id']});return;}if(_0x3cb4d0[_0x177a92(0x23c)]===_0x177a92(0x222)||_0x3cb4d0[_0x177a92(0x23c)]===_0x177a92(0x229)){W('←\x20'+_0x3cb4d0[_0x177a92(0x23c)]+':\x20inbox_count='+_0x3cb4d0[_0x177a92(0x20f)]+'\x20priority='+(_0x3cb4d0[_0x177a92(0x1c5)]||_0x177a92(0x1bd)));let _0x45477f=await Y(_0x177a92(0x227),{'alias':G,'limit':0x5});if(_0x45477f?.['ok']&&_0x45477f['messages']?.['length']>0x0)for(let _0x1456fe of _0x45477f[_0x177a92(0x1df)]){let _0x2867d5={'sender':_0x1456fe[_0x177a92(0x1d8)]||_0x177a92(0x1ce),'sender_id':_0x177a92(0x1eb),'user':_0x1456fe[_0x177a92(0x1d8)]||'hub','task_id':_0x1456fe['id'],'priority':_0x1456fe[_0x177a92(0x1c5)]||_0x177a92(0x1bd)};D[_0x177a92(0x1fb)](_0x1456fe['id'],_0x1456fe['from_session']||_0x177a92(0x1ce)),await x[_0x177a92(0x22c)]({'method':_0x177a92(0x1fc),'params':{'content':_0x1456fe[_0x177a92(0x1c8)],'meta':_0x2867d5}}),W(_0x177a92(0x21b)+_0x1456fe['id'][_0x177a92(0x210)](0x0,0x8)+_0x177a92(0x1f7)+_0x1456fe[_0x177a92(0x1d8)]+':\x20'+_0x1456fe[_0x177a92(0x1c8)]['slice'](0x0,0x3c)),await Y(_0x177a92(0x1de),{'alias':G,'message_id':_0x1456fe['id']});}}}async function n(){const _0x67c7e0=a0_0x2f6489;let _0x4b278a=new a0_0x57ed7a();await x[_0x67c7e0(0x1d3)](_0x4b278a),W(_0x67c7e0(0x1bb)),W(_0x67c7e0(0x1ed)),o()[_0x67c7e0(0x21e)](_0x44845c=>W('SSE\x20fatal:\x20'+_0x44845c)),Y(_0x67c7e0(0x1d0),{'resume_id':K,'alias':G,'status':_0x67c7e0(0x1e9),'server':a0_0x26e9c9(),'hostname':a0_0x26e9c9(),'agent':_0x67c7e0(0x1f2),'project_dir':process['cwd'](),'tmux_name':f||void 0x0})[_0x67c7e0(0x22b)](()=>W(_0x67c7e0(0x1ca)+G+_0x67c7e0(0x212)+K['slice'](0x0,0x8)+')'))['catch'](_0x2d793d=>W(_0x67c7e0(0x1c2)+_0x2d793d)),setInterval(()=>{const _0x29e1c4=_0x67c7e0;Y(_0x29e1c4(0x1d0),{'resume_id':K,'alias':G,'status':_0x29e1c4(0x1e9),'server':a0_0x26e9c9(),'hostname':a0_0x26e9c9(),'agent':'claude-code','project_dir':process[_0x29e1c4(0x1dd)](),'tmux_name':f||void 0x0})['catch'](_0x3266a1=>W(_0x29e1c4(0x1b5)+_0x3266a1));},0x2bf20),W('ready\x20—\x20waiting\x20for\x20events');}n()[a0_0x2f6489(0x21e)](_0x5cf806=>{const _0x544197=a0_0x2f6489;W(_0x544197(0x200)+_0x5cf806),process[_0x544197(0x1e2)](0x1);});async function b(){const _0x4792be=a0_0x2f6489;W(_0x4792be(0x1ec)),await Y(_0x4792be(0x1d0),{'resume_id':K,'alias':G,'status':_0x4792be(0x1e5),'task':_0x4792be(0x202)})['catch'](()=>{}),process['exit'](0x0);}function a0_0x26a1(){const _0x16e9a3=['Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','connected','high','pop','replace','send_task','/events/','2098539ewpQsv','2025-03-26','0.3.0','blocked','inbox_count','slice','SIGINT','\x22\x20(','get','setRequestHandler','initialize','CommHub\x20init\x20failed:\x20','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','none','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','Current\x20task\x20description','→\x20injected\x20task\x20','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20','Bearer\x20','catch','re-registered\x20as\x20\x22','135384SjeJgn','1809060PeZmym','new_task','POST','number','message','data:\x20','get_inbox','commhub-channel','broadcast',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','then','notification','stderr','read','commhub_send_task','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a','parse','2.0','replied','pid','4vEJiwy','utf-8','send_message','result','find','message_id',']\x20[commhub]\x20','type','←\x20message\x20from\x20','105WmlXAI','new_message','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','commhub_send_message','\x20CWD=','unattributed-','trim','\x20ALIAS=','startsWith','no\x20response','SSE\x20stream\x20ended,\x20reconnecting...','commhub_get_all_status','ENV:\x20URL=','http://127.0.0.1:9200','min','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','SSE\x20connected\x20as\x20\x22','status','1671705ttOHou','unknown\x20tool','heartbeat\x20failed:\x20','decode','failed','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','tools/call','Task\x20content','MCP\x20stdio\x20connected','write','normal','cancelled','/mcp','completed','tmux\x20display-message\x20-p\x20\x27#S\x27','warning:\x20could\x20not\x20register:\x20','body','stringify','priority','string','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','content','\x20/\x20hostname=','registered\x20as\x20\x22','\x20RESUME_ID=','\x20PROJECT_ENV=','206224mpKvdl','hub','re-register\x20failed:\x20','report_status','alias','from','connect','split','51PSphXB','token','253513AuHoLA','from_session','config.json','Message\x20content','now','object','cwd','ack_inbox','messages','connecting\x20to\x20','.env','exit','.claude/channels/commhub','text','offline','delete','SSE\x20connection\x20error:\x20','SIGTERM','idle','commhub_report_status','commhub','shutting\x20down,\x20reporting\x20offline...','starting\x20SSE\x20listener...','getReader','Target\x20session\x20alias','get_all_status','Priority\x20(default:\x20normal)','claude-code','toTimeString','commhub_reply','join','SSE\x20error:\x20','\x20from\x20','send_reply','working','error','set','notifications/claude/channel','application/json','Authorization','(none)','fatal:\x20','1654540KfjULG','session\x20disconnected','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.'];a0_0x26a1=function(){return _0x16e9a3;};return a0_0x26a1();}process['stdin']['on']('end',()=>b()),process['on'](a0_0x2f6489(0x1e8),()=>b()),process['on'](a0_0x2f6489(0x211),()=>b());
|
|
2
|
+
const a0_0x193669=a0_0x2430;(function(_0x593117,_0xa976d7){const _0x7bd123=a0_0x2430,_0x5da658=_0x593117();while(!![]){try{const _0x84ab2e=parseInt(_0x7bd123(0x1f3))/0x1*(parseInt(_0x7bd123(0x1c0))/0x2)+-parseInt(_0x7bd123(0x190))/0x3+-parseInt(_0x7bd123(0x1ea))/0x4+parseInt(_0x7bd123(0x19f))/0x5+-parseInt(_0x7bd123(0x1c7))/0x6*(-parseInt(_0x7bd123(0x20c))/0x7)+parseInt(_0x7bd123(0x1d3))/0x8*(parseInt(_0x7bd123(0x1be))/0x9)+-parseInt(_0x7bd123(0x1dc))/0xa;if(_0x84ab2e===_0xa976d7)break;else _0x5da658['push'](_0x5da658['shift']());}catch(_0x493ec9){_0x5da658['push'](_0x5da658['shift']());}}}(a0_0x2a6f,0x4f63c));import{readFileSync as a0_0x44c519,existsSync as a0_0x19da89}from'fs';import{randomUUID as a0_0x4968da}from'crypto';import{join as a0_0x1843f3}from'path';import{hostname as a0_0x4ad13a}from'os';import{execSync as a0_0x4a5f1d}from'child_process';import{Server as a0_0x2a8829}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x58076e}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x449c53,CallToolRequestSchema as a0_0x1520fd}from'@modelcontextprotocol/sdk/types.js';function I(_0x2ca5de){const _0x2e5a27=a0_0x2430;if(!a0_0x19da89(_0x2ca5de))return;for(let _0x908165 of a0_0x44c519(_0x2ca5de,'utf-8')[_0x2e5a27(0x1e6)]('\x0a')){let _0x3448a=_0x908165[_0x2e5a27(0x211)]();if(!_0x3448a||_0x3448a['startsWith']('#'))continue;let _0x5df3da=_0x3448a[_0x2e5a27(0x20e)]('=');if(_0x5df3da<0x0)continue;let _0x31dc80=_0x3448a[_0x2e5a27(0x1ab)](0x0,_0x5df3da)[_0x2e5a27(0x211)](),_0x35d471=_0x3448a[_0x2e5a27(0x1ab)](_0x5df3da+0x1)[_0x2e5a27(0x211)]()['replace'](/^["']|["']$/g,'');if(!process.env[_0x31dc80])process.env[_0x31dc80]=_0x35d471;}}var L=process.env.HOME||'~',U=a0_0x1843f3(L,a0_0x193669(0x1f0));I(a0_0x1843f3(U,a0_0x193669(0x1c1)));var v=process[a0_0x193669(0x19a)]()[a0_0x193669(0x1c3)](/\//g,'-');I(a0_0x1843f3(U,v,a0_0x193669(0x1c1)));function d(){const _0x3d9960=a0_0x193669;try{return a0_0x4a5f1d('tmux\x20display-message\x20-p\x20\x27#S\x27',{'encoding':_0x3d9960(0x19c),'timeout':0x7d0})['trim']();}catch{return'';}}function m(){const _0xb86702=a0_0x193669;try{let _0x2c700e=a0_0x1843f3(L,'.anet',_0xb86702(0x19b));if(a0_0x19da89(_0x2c700e))return JSON[_0xb86702(0x21e)](a0_0x44c519(_0x2c700e,_0xb86702(0x19c)));}catch{}return{};}var u=m(),j=process.env.COMMHUB_URL||u[a0_0x193669(0x217)]||a0_0x193669(0x1f2),f=process.env.COMMHUB_TMUX||d();function r(){const _0x146d32=a0_0x193669;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x146d32(0x211)]())return process.env.COMMHUB_ALIAS[_0x146d32(0x211)]();return process[_0x146d32(0x215)][_0x146d32(0x1fb)]('[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20'+('would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME='+(f||_0x146d32(0x1f5))+_0x146d32(0x1ac)+a0_0x4ad13a()+'.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a')),'unattributed-'+process['pid'];}var G=r(),K=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x4968da(),F=process.env.COMMHUB_TOKEN||u[a0_0x193669(0x1b9)]||'';function W(_0x59cf3d){const _0x300654=a0_0x193669;let _0x4f98e1=new Date()[_0x300654(0x1bc)]()[_0x300654(0x1ab)](0x0,0x8);process[_0x300654(0x215)][_0x300654(0x1fb)]('['+_0x4f98e1+_0x300654(0x1fd)+_0x59cf3d+'\x0a');}function a0_0x2430(_0x4b1b7f,_0x26d08c){_0x4b1b7f=_0x4b1b7f-0x18e;const _0x2a6fa3=a0_0x2a6f();let _0x2430c0=_0x2a6fa3[_0x4b1b7f];return _0x2430c0;}function N(_0x550ac0){return new Promise(_0x47cd66=>setTimeout(_0x47cd66,_0x550ac0));}W(a0_0x193669(0x1a7)+j+'\x20ALIAS='+G+'\x20RESUME_ID='+K[a0_0x193669(0x1ab)](0x0,0x8)+'...\x20TMUX='+(f||a0_0x193669(0x1ee))+a0_0x193669(0x1cc)+process[a0_0x193669(0x19a)]()+a0_0x193669(0x218)+v);var D=new Map(),x=new a0_0x2a8829({'name':'commhub-channel','version':a0_0x193669(0x210)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x193669(0x196),a0_0x193669(0x1bd),a0_0x193669(0x1c4),'You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.',a0_0x193669(0x1e5)+G][a0_0x193669(0x208)]('\x0a')});function a0_0x2a6f(){const _0x156167=['stringify','new_message','2553060GLQrgK','Target\x20session\x20alias','commhub_get_all_status','SSE\x20stream\x20ended,\x20reconnecting...','shutting\x20down,\x20reporting\x20offline...','replied','message','registered\x20as\x20\x22','ENV:\x20URL=','setRequestHandler','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','connecting\x20to\x20','slice','\x20/\x20hostname=','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','completed','SSE\x20error:\x20','low','no\x20response','alias','blocked','data:\x20','text','fatal:\x20','params','commhub_report_status','token','object','priority','toTimeString','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','117Zqnabv','warning:\x20could\x20not\x20register:\x20','68754wDoSya','.env','Message\x20content','replace','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','find','content','1211172CAhCtd','parse\x20error:\x20','startsWith','catch','commhub_send_message','\x20CWD=','offline','SSE\x20connected\x20as\x20\x22','stdin','inbox_count','unknown\x20tool','Current\x20task\x20description','299400qMUItP','from_session','commhub_send_task','decode','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','commhub','min','Bearer\x20','idle','4293020lxYKSl','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','commhub_reply','notification','commhub-channel','error','length','2.0','type','Session\x20alias:\x20','split','CommHub\x20init\x20failed:\x20','Reply\x20text\x20/\x20result\x20summary','cancelled','1828884FATaHN','MCP\x20stdio\x20connected','session\x20disconnected','exit','none','string','.claude/channels/commhub','statusText','http://127.0.0.1:9200','1CTmwyE','claude-code','(none)','in_progress','from','body','ack_inbox','task','write','SIGTERM',']\x20[commhub]\x20','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','new_task','status','ready\x20—\x20waiting\x20for\x20events','message_id',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','end','get_all_status','\x20from\x20',':\x20inbox_count=','join','tools/call','result','getReader','7HrRCHO','Task\x20content','indexOf','/mcp','0.3.0','trim','report_status','now','notifications/claude/channel','stderr','re-registered\x20as\x20\x22','hub','\x20PROJECT_ENV=','pop','connected','\x22\x20after\x20SSE\x20reconnect','set','broadcast','parse','delete','working','re-register\x20failed:\x20','application/json,\x20text/event-stream','connect','65019dTPoOM','normal','get_inbox','failed','Priority\x20(default:\x20normal)','starting\x20SSE\x20listener...','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','Progress\x200-100','initialize','POST','cwd','config.json','utf-8'];a0_0x2a6f=function(){return _0x156167;};return a0_0x2a6f();}x[a0_0x193669(0x1a8)](a0_0x449c53,async()=>({'tools':[{'name':a0_0x193669(0x1de),'description':a0_0x193669(0x1dd),'inputSchema':{'type':a0_0x193669(0x1ba),'properties':{'task_id':{'type':a0_0x193669(0x1ef),'description':a0_0x193669(0x1fe)},'text':{'type':a0_0x193669(0x1ef),'description':a0_0x193669(0x1e8)},'status':{'type':a0_0x193669(0x1ef),'enum':[a0_0x193669(0x1ae),a0_0x193669(0x193),a0_0x193669(0x1e9),'blocked',a0_0x193669(0x1e1),a0_0x193669(0x1f6)],'description':a0_0x193669(0x1a9)}},'required':['text']}},{'name':a0_0x193669(0x1b8),'description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':a0_0x193669(0x1ba),'properties':{'status':{'type':a0_0x193669(0x1ef),'enum':['working','idle',a0_0x193669(0x1b3),a0_0x193669(0x1e1)]},'task':{'type':a0_0x193669(0x1ef),'description':a0_0x193669(0x1d2)},'progress':{'type':'number','description':a0_0x193669(0x197)}},'required':[a0_0x193669(0x200)]}},{'name':a0_0x193669(0x1d5),'description':a0_0x193669(0x1ad),'inputSchema':{'type':a0_0x193669(0x1ba),'properties':{'alias':{'type':'string','description':a0_0x193669(0x1a0)},'task':{'type':'string','description':a0_0x193669(0x20d)},'priority':{'type':a0_0x193669(0x1ef),'enum':['high','normal',a0_0x193669(0x1b0)],'description':a0_0x193669(0x194)}},'required':[a0_0x193669(0x1b2),a0_0x193669(0x1fa)]}},{'name':'commhub_send_message','description':'Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','inputSchema':{'type':'object','properties':{'alias':{'type':a0_0x193669(0x1ef),'description':a0_0x193669(0x1a0)},'message':{'type':a0_0x193669(0x1ef),'description':a0_0x193669(0x1c2)}},'required':[a0_0x193669(0x1b2),a0_0x193669(0x1a5)]}},{'name':a0_0x193669(0x1a1),'description':'Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','inputSchema':{'type':a0_0x193669(0x1ba),'properties':{}}}]}));async function Y(_0x168976,_0x124495){const _0x5b522e=a0_0x193669;let _0x2470ce=await fetch(j+_0x5b522e(0x20f),{'method':_0x5b522e(0x199),'headers':{'Content-Type':'application/json','Accept':_0x5b522e(0x18e),...F?{'Authorization':_0x5b522e(0x1da)+F}:{}},'body':JSON['stringify']({'jsonrpc':'2.0','id':0x1,'method':_0x5b522e(0x198),'params':{'protocolVersion':'2025-03-26','capabilities':{},'clientInfo':{'name':_0x5b522e(0x1e0),'version':_0x5b522e(0x210)}}})});if(!_0x2470ce['ok']){let _0x43c200=await _0x2470ce[_0x5b522e(0x1b5)]();return W(_0x5b522e(0x1e7)+_0x2470ce[_0x5b522e(0x200)]+'\x20'+_0x43c200['slice'](0x0,0x64)),{'ok':!0x1,'error':'init\x20failed:\x20'+_0x2470ce[_0x5b522e(0x200)]};}await _0x2470ce[_0x5b522e(0x1b5)]();let _0x5af720=(await(await fetch(j+_0x5b522e(0x20f),{'method':_0x5b522e(0x199),'headers':{'Content-Type':'application/json','Accept':_0x5b522e(0x18e),...F?{'Authorization':_0x5b522e(0x1da)+F}:{}},'body':JSON[_0x5b522e(0x19d)]({'jsonrpc':_0x5b522e(0x1e3),'id':0x2,'method':_0x5b522e(0x209),'params':{'name':_0x168976,'arguments':_0x124495}})}))[_0x5b522e(0x1b5)]())[_0x5b522e(0x1e6)]('\x0a')[_0x5b522e(0x1c5)](_0x4f6d24=>_0x4f6d24[_0x5b522e(0x1c9)](_0x5b522e(0x1b4)));if(_0x5af720){let _0x4d72bd=JSON[_0x5b522e(0x21e)](_0x5af720[_0x5b522e(0x1ab)](0x6));return _0x4d72bd?.['result']?.['content']?.[0x0]?.['text']?JSON[_0x5b522e(0x21e)](_0x4d72bd[_0x5b522e(0x20a)][_0x5b522e(0x1c6)][0x0][_0x5b522e(0x1b5)]):_0x4d72bd;}return{'ok':!0x1,'error':_0x5b522e(0x1b1)};}x[a0_0x193669(0x1a8)](a0_0x1520fd,async _0x244963=>{const _0x778788=a0_0x193669;let {name:_0x48f7e9,arguments:_0x1639fe}=_0x244963[_0x778788(0x1b7)];if(_0x48f7e9===_0x778788(0x1de)){let {task_id:_0x187c97,text:_0x6adb20,status:_0x59f23f}=_0x1639fe;if(_0x59f23f===_0x778788(0x1ae)||_0x59f23f===_0x778788(0x193)||_0x59f23f==='cancelled'){let _0x31028a=_0x59f23f===_0x778788(0x1ae)?_0x778788(0x1a4):_0x59f23f,_0x37db71=_0x187c97?D['get'](_0x187c97)||_0x778788(0x217):_0x778788(0x217),_0x520dd7=await Y('send_reply',{'alias':_0x37db71,'text':_0x6adb20,'in_reply_to':_0x187c97||void 0x0,'status':_0x31028a,'from_session':G});if(_0x187c97)D[_0x778788(0x21f)](_0x187c97);return{'content':[{'type':_0x778788(0x1b5),'text':JSON['stringify'](_0x520dd7)}]};}let _0x163b96=await Y(_0x778788(0x212),{'resume_id':K,'alias':G,'status':_0x59f23f===_0x778788(0x1b3)?_0x778788(0x1b3):_0x59f23f===_0x778788(0x1e1)?'error':_0x778788(0x220),'task':_0x6adb20[_0x778788(0x1ab)](0x0,0xc8),'output':_0x6adb20});return{'content':[{'type':_0x778788(0x1b5),'text':JSON['stringify'](_0x163b96)}]};}if(_0x48f7e9==='commhub_report_status'){let {status:_0x5dac0d,task:_0x3236a8,progress:_0xc33f86}=_0x1639fe,_0x218117=await Y(_0x778788(0x212),{'resume_id':K,'alias':G,'status':_0x5dac0d,'task':_0x3236a8,'progress':_0xc33f86});return{'content':[{'type':_0x778788(0x1b5),'text':JSON[_0x778788(0x19d)](_0x218117)}]};}if(_0x48f7e9===_0x778788(0x1d5)){let {alias:_0x6cb6b8,task:_0x176a6a,priority:_0x305b0e}=_0x1639fe,_0x3cac46=await Y('send_task',{'alias':_0x6cb6b8,'task':_0x176a6a,'priority':_0x305b0e||_0x778788(0x191),'from_session':G});return{'content':[{'type':_0x778788(0x1b5),'text':JSON[_0x778788(0x19d)](_0x3cac46)}]};}if(_0x48f7e9===_0x778788(0x1cb)){let {alias:_0x1c102f,message:_0xed3ef7}=_0x1639fe,_0x59f59e=await Y('send_message',{'alias':_0x1c102f,'message':_0xed3ef7,'from_session':G});return{'content':[{'type':_0x778788(0x1b5),'text':JSON[_0x778788(0x19d)](_0x59f59e)}]};}if(_0x48f7e9===_0x778788(0x1a1)){let _0x4e0c26=await Y(_0x778788(0x205),{});return{'content':[{'type':_0x778788(0x1b5),'text':JSON[_0x778788(0x19d)](_0x4e0c26)}]};}return{'content':[{'type':_0x778788(0x1b5),'text':JSON['stringify']({'error':_0x778788(0x1d1)})}]};});var O=0x3e8,R=0x7530,T=0x36ee80;async function l(){const _0x33edc8=a0_0x193669;try{await Y(_0x33edc8(0x212),{'resume_id':K,'alias':G,'status':'idle','server':a0_0x4ad13a(),'hostname':a0_0x4ad13a(),'agent':_0x33edc8(0x1f4),'project_dir':process[_0x33edc8(0x19a)](),'tmux_name':f||void 0x0}),W(_0x33edc8(0x216)+G+_0x33edc8(0x21b));}catch(_0x597ba7){W(_0x33edc8(0x221)+_0x597ba7);}}async function o(){const _0x1b9c74=a0_0x193669;let _0x54d47c=j+'/events/'+encodeURIComponent(G),_0x472a59={};if(F)_0x472a59['Authorization']=_0x1b9c74(0x1da)+F;W(_0x1b9c74(0x1aa)+_0x54d47c);let _0x2730b0=O,_0x3c5e4b=!0x0,_0x788c4e=null;while(!0x0){try{let _0x4e6f39=await fetch(_0x54d47c,{'headers':_0x472a59});if(!_0x4e6f39['ok']){if(W(_0x1b9c74(0x1af)+_0x4e6f39[_0x1b9c74(0x200)]+'\x20'+_0x4e6f39[_0x1b9c74(0x1f1)]),_0x788c4e=_0x788c4e??Date['now'](),Date[_0x1b9c74(0x213)]()-_0x788c4e>T){W(_0x1b9c74(0x1d7)+j+_0x1b9c74(0x203));return;}await N(_0x2730b0),_0x2730b0=Math[_0x1b9c74(0x1d9)](_0x2730b0*0x2,R);continue;}let _0x1958c6=_0x4e6f39[_0x1b9c74(0x1f8)][_0x1b9c74(0x20b)](),_0x50f421=new TextDecoder(),_0x54c148='';_0x2730b0=O;while(!0x0){let {done:_0x27b274,value:_0xd8f27f}=await _0x1958c6['read']();if(_0x27b274)break;_0x54c148+=_0x50f421[_0x1b9c74(0x1d6)](_0xd8f27f,{'stream':!0x0});let _0xbd4b97=_0x54c148[_0x1b9c74(0x1e6)]('\x0a\x0a');_0x54c148=_0xbd4b97[_0x1b9c74(0x219)]()||'';for(let _0x31f2d2 of _0xbd4b97){let _0x47f9eb=_0x31f2d2[_0x1b9c74(0x1e6)]('\x0a')['find'](_0x22f8ca=>_0x22f8ca['startsWith'](_0x1b9c74(0x1b4)));if(!_0x47f9eb)continue;try{let _0x4752d0=JSON['parse'](_0x47f9eb[_0x1b9c74(0x1ab)](0x6));if(await a(_0x4752d0),_0x4752d0[_0x1b9c74(0x1e4)]===_0x1b9c74(0x21a)){if(_0x788c4e=null,!_0x3c5e4b)await l();_0x3c5e4b=!0x1;}}catch(_0x437e2e){W(_0x1b9c74(0x1c8)+_0x437e2e);}}}W(_0x1b9c74(0x1a2));}catch(_0x35991c){W('SSE\x20connection\x20error:\x20'+_0x35991c);}if(_0x788c4e=_0x788c4e??Date[_0x1b9c74(0x213)](),Date['now']()-_0x788c4e>T){W(_0x1b9c74(0x1d7)+j+')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。');return;}await N(_0x2730b0),_0x2730b0=Math[_0x1b9c74(0x1d9)](_0x2730b0*0x2,R);}}async function a(_0x32771b){const _0x5978c7=a0_0x193669;if(_0x32771b['type']==='connected'){W(_0x5978c7(0x1ce)+G+'\x22');return;}if(_0x32771b[_0x5978c7(0x1e4)]===_0x5978c7(0x19e)){if(W('←\x20message\x20from\x20'+_0x32771b[_0x5978c7(0x1f7)]+':\x20'+_0x32771b[_0x5978c7(0x1a5)][_0x5978c7(0x1ab)](0x0,0x3c)),await x[_0x5978c7(0x1df)]({'method':_0x5978c7(0x214),'params':{'content':_0x32771b['message'],'meta':{'sender':_0x32771b[_0x5978c7(0x1f7)]||_0x5978c7(0x217),'sender_id':_0x5978c7(0x1d8),'user':_0x32771b[_0x5978c7(0x1f7)]||_0x5978c7(0x217),'priority':_0x5978c7(0x191)}}}),_0x32771b[_0x5978c7(0x202)])await Y(_0x5978c7(0x1f9),{'alias':G,'message_id':_0x32771b[_0x5978c7(0x202)]});return;}if(_0x32771b[_0x5978c7(0x1e4)]===_0x5978c7(0x1ff)||_0x32771b[_0x5978c7(0x1e4)]===_0x5978c7(0x21d)){W('←\x20'+_0x32771b['type']+_0x5978c7(0x207)+_0x32771b[_0x5978c7(0x1d0)]+'\x20priority='+(_0x32771b[_0x5978c7(0x1bb)]||_0x5978c7(0x191)));let _0x15e15b=await Y(_0x5978c7(0x192),{'alias':G,'limit':0x5});if(_0x15e15b?.['ok']&&_0x15e15b['messages']?.[_0x5978c7(0x1e2)]>0x0)for(let _0x1be1f6 of _0x15e15b['messages']){let _0x528625={'sender':_0x1be1f6['from_session']||'hub','sender_id':_0x5978c7(0x1d8),'user':_0x1be1f6[_0x5978c7(0x1d4)]||_0x5978c7(0x217),'task_id':_0x1be1f6['id'],'priority':_0x1be1f6['priority']||_0x5978c7(0x191)};D[_0x5978c7(0x21c)](_0x1be1f6['id'],_0x1be1f6['from_session']||_0x5978c7(0x217)),await x[_0x5978c7(0x1df)]({'method':_0x5978c7(0x214),'params':{'content':_0x1be1f6[_0x5978c7(0x1c6)],'meta':_0x528625}}),W('→\x20injected\x20task\x20'+_0x1be1f6['id'][_0x5978c7(0x1ab)](0x0,0x8)+_0x5978c7(0x206)+_0x1be1f6[_0x5978c7(0x1d4)]+':\x20'+_0x1be1f6[_0x5978c7(0x1c6)][_0x5978c7(0x1ab)](0x0,0x3c)),await Y(_0x5978c7(0x1f9),{'alias':G,'message_id':_0x1be1f6['id']});}}}async function n(){const _0x602df3=a0_0x193669;let _0x3540b6=new a0_0x58076e();await x[_0x602df3(0x18f)](_0x3540b6),W(_0x602df3(0x1eb)),W(_0x602df3(0x195)),o()['catch'](_0x45a77a=>W('SSE\x20fatal:\x20'+_0x45a77a)),Y(_0x602df3(0x212),{'resume_id':K,'alias':G,'status':_0x602df3(0x1db),'server':a0_0x4ad13a(),'hostname':a0_0x4ad13a(),'agent':_0x602df3(0x1f4),'project_dir':process[_0x602df3(0x19a)](),'tmux_name':f||void 0x0})['then'](()=>W(_0x602df3(0x1a6)+G+'\x22\x20('+K['slice'](0x0,0x8)+')'))[_0x602df3(0x1ca)](_0x6addf4=>W(_0x602df3(0x1bf)+_0x6addf4)),setInterval(()=>{const _0x2fab15=_0x602df3;Y(_0x2fab15(0x212),{'resume_id':K,'alias':G,'status':_0x2fab15(0x1db),'server':a0_0x4ad13a(),'hostname':a0_0x4ad13a(),'agent':'claude-code','project_dir':process['cwd'](),'tmux_name':f||void 0x0})[_0x2fab15(0x1ca)](_0x27cc4b=>W('heartbeat\x20failed:\x20'+_0x27cc4b));},0x2bf20),W(_0x602df3(0x201));}n()[a0_0x193669(0x1ca)](_0x583d21=>{const _0x1833cf=a0_0x193669;W(_0x1833cf(0x1b6)+_0x583d21),process[_0x1833cf(0x1ed)](0x1);});async function b(){const _0x25c833=a0_0x193669;W(_0x25c833(0x1a3)),await Y(_0x25c833(0x212),{'resume_id':K,'alias':G,'status':_0x25c833(0x1cd),'task':_0x25c833(0x1ec)})[_0x25c833(0x1ca)](()=>{}),process[_0x25c833(0x1ed)](0x0);}process[a0_0x193669(0x1cf)]['on'](a0_0x193669(0x204),()=>b()),process['on'](a0_0x193669(0x1fc),()=>b()),process['on']('SIGINT',()=>b());
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-iteration controller passed into `runOnce`. Today exposes only
|
|
3
|
+
* `markStable`; a future stop-the-current-iteration affordance would
|
|
4
|
+
* be a sibling field on this interface.
|
|
5
|
+
*/
|
|
6
|
+
export interface SupervisedIterationController {
|
|
7
|
+
/**
|
|
8
|
+
* Signal that this iteration crossed the "actually working" threshold.
|
|
9
|
+
* Resets the backoff to `baseDelayMs` and zeroes the cumulative
|
|
10
|
+
* downtime counter. Safe to call multiple times per iteration — only
|
|
11
|
+
* the first call has effect within a single iteration.
|
|
12
|
+
*/
|
|
13
|
+
markStable(): void;
|
|
14
|
+
}
|
|
15
|
+
export interface SuperviseChildOpts {
|
|
16
|
+
/** Short label for log / error messages. e.g. "feishu" / "sse". */
|
|
17
|
+
label: string;
|
|
18
|
+
/** Returns true when the supervisor should stop without rescheduling. */
|
|
19
|
+
shutdownGate: () => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* One iteration of the supervised child. Resolves when the iteration
|
|
22
|
+
* ends (child exits / stream closes); throws to log + reschedule.
|
|
23
|
+
* Receives a controller for the iteration to call `markStable` on
|
|
24
|
+
* once the work crosses its "really working" threshold.
|
|
25
|
+
*/
|
|
26
|
+
runOnce: (ctrl: SupervisedIterationController) => Promise<void>;
|
|
27
|
+
/** Initial backoff delay in ms. Default 1_000. */
|
|
28
|
+
baseDelayMs?: number;
|
|
29
|
+
/** Maximum backoff after exponential growth. Default 30_000. */
|
|
30
|
+
maxDelayMs?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Jitter ratio (±N×delay). Default 0.25 (±25%). Set 0 to disable.
|
|
33
|
+
* The waited time per backoff is `max(100, delay + delay * jitter *
|
|
34
|
+
* (Math.random() * 2 - 1))`.
|
|
35
|
+
*/
|
|
36
|
+
jitterRatio?: number;
|
|
37
|
+
/**
|
|
38
|
+
* If cumulative downtime (consecutive iterations that did NOT call
|
|
39
|
+
* markStable, plus their inter-iteration sleeps) exceeds this, the
|
|
40
|
+
* supervisor invokes `onAbandon` and returns. Default `Infinity`
|
|
41
|
+
* (never abandon). Set to a finite value (e.g. 3_600_000 = 1 h) to
|
|
42
|
+
* give up after a long unsuccessful run.
|
|
43
|
+
*/
|
|
44
|
+
abandonAfterMs?: number;
|
|
45
|
+
/** Called once if the supervisor abandons. */
|
|
46
|
+
onAbandon?: () => void;
|
|
47
|
+
/** Called with the runOnce error before scheduling the next iteration. */
|
|
48
|
+
onError?: (err: unknown) => void;
|
|
49
|
+
/** Called before sleeping with the resolved backoff (and the jittered wait). */
|
|
50
|
+
onRetryWait?: (waitMs: number, backoffMs: number) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Sleep primitive — overridden by tests to skip real timers. Default
|
|
53
|
+
* uses `setTimeout`. Must respect `ms <= 0` as "no wait".
|
|
54
|
+
*/
|
|
55
|
+
sleep?: (ms: number) => Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Random source — overridden by tests for deterministic jitter.
|
|
58
|
+
* Default `Math.random`.
|
|
59
|
+
*/
|
|
60
|
+
random?: () => number;
|
|
61
|
+
/** Current-time source — overridden by tests. Default `Date.now`. */
|
|
62
|
+
now?: () => number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Run the supervisor loop. Resolves when the shutdown gate triggers or
|
|
66
|
+
* the abandon threshold fires; never throws (runOnce errors are routed
|
|
67
|
+
* to `onError`).
|
|
68
|
+
*/
|
|
69
|
+
export declare function superviseChild(opts: SuperviseChildOpts): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleep2agi/agent-network",
|
|
3
|
-
"version": "2.3.0-preview.
|
|
3
|
+
"version": "2.3.0-preview.2",
|
|
4
4
|
"description": "AI Agent Network CLI \u2014 Local-first multi-agent orchestration across 4 runtimes (Claude Code CLI / Claude Agent SDK / Codex SDK / Grok Build ACP) and 8+ LLM providers (Anthropic / OpenAI / xAI Grok / MiniMax / DeepSeek / GLM / Kimi / InternLM / Xiaomi MiMo / OpenRouter). Apache 2.0.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/client.js",
|