@sleep2agi/agent-network 2.3.0-preview.23 → 2.3.0-preview.25

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.
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env bun
2
- const a0_0x3b6422=a0_0xf80d;(function(_0x574999,_0x77944f){const _0x161710=a0_0xf80d,_0xea13ec=_0x574999();while(!![]){try{const _0x5ac65b=-parseInt(_0x161710(0x1d7))/0x1+-parseInt(_0x161710(0x1d6))/0x2+-parseInt(_0x161710(0x1f5))/0x3+-parseInt(_0x161710(0x183))/0x4+-parseInt(_0x161710(0x1ce))/0x5+-parseInt(_0x161710(0x209))/0x6*(-parseInt(_0x161710(0x1a2))/0x7)+-parseInt(_0x161710(0x1ba))/0x8*(-parseInt(_0x161710(0x1e3))/0x9);if(_0x5ac65b===_0x77944f)break;else _0xea13ec['push'](_0xea13ec['shift']());}catch(_0x8636e2){_0xea13ec['push'](_0xea13ec['shift']());}}}(a0_0x21d0,0x716aa));import{readFileSync as a0_0x91ce9,existsSync as a0_0x28dea3}from'fs';import{randomUUID as a0_0x510387}from'crypto';import{join as a0_0x362b52}from'path';import{hostname as a0_0x453644}from'os';import{execSync as a0_0x558b7a}from'child_process';function B(_0x1a0ce0){const _0x1f0e4e=a0_0xf80d;let _0x5d9e21=_0x1a0ce0[_0x1f0e4e(0x1c1)](/[^a-zA-Z0-9\-_]/g,'-');return _0x5d9e21===''?'unknown':_0x5d9e21;}import{Server as a0_0x3d67c8}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0xc69828}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x643f8c,CallToolRequestSchema as a0_0x700957}from'@modelcontextprotocol/sdk/types.js';function T(_0x54347e){const _0x38d283=a0_0xf80d;if(!a0_0x28dea3(_0x54347e))return;for(let _0x280977 of a0_0x91ce9(_0x54347e,'utf-8')[_0x38d283(0x1f2)]('\x0a')){let _0x1bc511=_0x280977[_0x38d283(0x1f9)]();if(!_0x1bc511||_0x1bc511[_0x38d283(0x1fa)]('#'))continue;let _0x609a2c=_0x1bc511[_0x38d283(0x1a0)]('=');if(_0x609a2c<0x0)continue;let _0xbb42cb=_0x1bc511[_0x38d283(0x1cf)](0x0,_0x609a2c)[_0x38d283(0x1f9)](),_0x4b81fe=_0x1bc511['slice'](_0x609a2c+0x1)[_0x38d283(0x1f9)]()[_0x38d283(0x1c1)](/^["']|["']$/g,'');if(!process.env[_0xbb42cb])process.env[_0xbb42cb]=_0x4b81fe;}}var C=process.env.HOME||'~',r=a0_0x362b52(C,a0_0x3b6422(0x1d9));T(a0_0x362b52(r,a0_0x3b6422(0x1e0)));var H=B(process['cwd']());T(a0_0x362b52(r,H,a0_0x3b6422(0x1e0)));function E(){const _0x10e5d2=a0_0x3b6422;try{return a0_0x558b7a(_0x10e5d2(0x1b4),{'encoding':_0x10e5d2(0x1a8),'timeout':0x7d0})['trim']();}catch{return'';}}function _(){const _0x35605c=a0_0x3b6422;try{let _0x50f503=a0_0x362b52(C,_0x35605c(0x208),_0x35605c(0x191));if(a0_0x28dea3(_0x50f503))return JSON[_0x35605c(0x1c6)](a0_0x91ce9(_0x50f503,_0x35605c(0x1a8)));}catch{}return{};}var R=_(),Y=process.env.COMMHUB_URL||R[a0_0x3b6422(0x1d0)]||a0_0x3b6422(0x1da),j=process.env.COMMHUB_TMUX||E();function S(){const _0x2de900=a0_0x3b6422;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x2de900(0x1f9)]())return process.env.COMMHUB_ALIAS['trim']();return process[_0x2de900(0x19c)][_0x2de900(0x1b1)]('[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20'+(_0x2de900(0x18e)+(j||_0x2de900(0x1c3))+'\x20/\x20hostname='+a0_0x453644()+_0x2de900(0x195))),'unattributed-'+process[_0x2de900(0x1bf)];}function a0_0xf80d(_0x2f8a46,_0xd7a82f){_0x2f8a46=_0x2f8a46-0x182;const _0x21d0fd=a0_0x21d0();let _0xf80d59=_0x21d0fd[_0x2f8a46];return _0xf80d59;}var p=S(),V=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x510387(),k=process.env.COMMHUB_TOKEN||R['token']||'';function z(_0x11da4f){const _0x283b69=a0_0x3b6422;let _0x2713bd=new Date()[_0x283b69(0x1ac)]()['slice'](0x0,0x8);process['stderr']['write']('['+_0x2713bd+']\x20[commhub]\x20'+_0x11da4f+'\x0a');}function i(_0x24ebdc){return new Promise(_0x3a48b4=>setTimeout(_0x3a48b4,_0x24ebdc));}z(a0_0x3b6422(0x1b6)+Y+a0_0x3b6422(0x192)+p+'\x20RESUME_ID='+V[a0_0x3b6422(0x1cf)](0x0,0x8)+a0_0x3b6422(0x1cc)+(j||'none')+a0_0x3b6422(0x217)+process[a0_0x3b6422(0x20b)]()+a0_0x3b6422(0x202)+H);var G=new Map(),K=new a0_0x3d67c8({'name':a0_0x3b6422(0x1a7),'version':a0_0x3b6422(0x1e5)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x3b6422(0x1f8),a0_0x3b6422(0x1a1),a0_0x3b6422(0x1fc),a0_0x3b6422(0x188),'Session\x20alias:\x20'+p]['join']('\x0a')});K[a0_0x3b6422(0x18b)](a0_0x643f8c,async()=>({'tools':[{'name':a0_0x3b6422(0x1ca),'description':a0_0x3b6422(0x1ee),'inputSchema':{'type':a0_0x3b6422(0x18f),'properties':{'task_id':{'type':a0_0x3b6422(0x207),'description':a0_0x3b6422(0x193)},'text':{'type':a0_0x3b6422(0x207),'description':a0_0x3b6422(0x204)},'status':{'type':a0_0x3b6422(0x207),'enum':['completed',a0_0x3b6422(0x1f0),'cancelled','blocked',a0_0x3b6422(0x1dd),a0_0x3b6422(0x1e1)],'description':'Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates'}},'required':[a0_0x3b6422(0x1d4)]}},{'name':a0_0x3b6422(0x199),'description':a0_0x3b6422(0x20e),'inputSchema':{'type':a0_0x3b6422(0x18f),'properties':{'status':{'type':'string','enum':[a0_0x3b6422(0x19e),a0_0x3b6422(0x1bc),a0_0x3b6422(0x1ab),a0_0x3b6422(0x1dd)]},'task':{'type':a0_0x3b6422(0x207),'description':a0_0x3b6422(0x182)},'progress':{'type':'number','description':a0_0x3b6422(0x1e6)}},'required':['status']}},{'name':a0_0x3b6422(0x1d1),'description':'Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','inputSchema':{'type':a0_0x3b6422(0x18f),'properties':{'alias':{'type':'string','description':a0_0x3b6422(0x1d8)},'task':{'type':a0_0x3b6422(0x207),'description':a0_0x3b6422(0x1d3)},'priority':{'type':a0_0x3b6422(0x207),'enum':[a0_0x3b6422(0x1db),a0_0x3b6422(0x1f7),a0_0x3b6422(0x1ad)],'description':'Priority\x20(default:\x20normal)'}},'required':[a0_0x3b6422(0x1f1),a0_0x3b6422(0x1c4)]}},{'name':a0_0x3b6422(0x1a5),'description':a0_0x3b6422(0x211),'inputSchema':{'type':a0_0x3b6422(0x18f),'properties':{'alias':{'type':a0_0x3b6422(0x207),'description':a0_0x3b6422(0x1d8)},'message':{'type':a0_0x3b6422(0x207),'description':'Message\x20content'}},'required':[a0_0x3b6422(0x1f1),a0_0x3b6422(0x1aa)]}},{'name':a0_0x3b6422(0x215),'description':a0_0x3b6422(0x1df),'inputSchema':{'type':a0_0x3b6422(0x18f),'properties':{}}}]}));function a0_0x21d0(){const _0x24ea14=['SSE\x20fatal:\x20','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','MCP\x20stdio\x20connected','from','setRequestHandler','notifications/claude/channel','send_reply','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','object','connecting\x20to\x20','config.json','\x20ALIAS=','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','notification','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a','\x22\x20after\x20SSE\x20reconnect','\x20no\x20longer\x20exists\x20(kill-0\x20ESRCH)\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','from_session','commhub_report_status','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','result','stderr',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','working','priority','indexOf','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','1631zAyssS','broadcast','warning:\x20could\x20not\x20register:\x20','commhub_send_message','claude-code','commhub-channel','utf-8','2025-03-26','message','blocked','toTimeString','low','unref','heartbeat\x20failed:\x20','report_status','write','SIGTERM','SSE\x20connection\x20error:\x20','tmux\x20display-message\x20-p\x20\x27#S\x27','shutting\x20down,\x20reporting\x20offline...','ENV:\x20URL=','session\x20disconnected','starting\x20SSE\x20listener...','Bearer\x20','11768lMKTjh','new_message','idle','ack_inbox','getReader','pid','now','replace','end','(none)','task','stringify','parse','2.0','read','offline','commhub_reply','cancelled','...\x20TMUX=','send_message','2423555VCexEf','slice','hub','commhub_send_task','/events/','Task\x20content','text','get_all_status','192662ghuabL','344026vvLOaB','Target\x20session\x20alias','.claude/channels/commhub','http://127.0.0.1:9200','high',')\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','error','initialize','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','.env','in_progress','function','8730TasCYa','length','0.3.0','Progress\x200-100','unknown\x20tool','kill','/mcp','parse\x20error:\x20','fatal:\x20','application/json','status','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','POST','failed','alias','split','\x22\x20(','SSE\x20stream\x20ended,\x20reconnecting...','486288ZWwGpN','exit','normal','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','trim','startsWith','statusText','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','application/json,\x20text/event-stream','catch','min','connected','connect','\x20PROJECT_ENV=','parent\x20claude\x20died\x20(reparented\x20to\x20PID\x201\x20from\x20','Reply\x20text\x20/\x20result\x20summary','ESRCH','code','string','.anet','10254yfOqyE','no\x20response','cwd','SSE\x20connected\x20as\x20\x22','data:\x20','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','commhub','message_id','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','completed','type','content','commhub_get_all_status','→\x20injected\x20task\x20','\x20CWD=','messages','replied','re-registered\x20as\x20\x22','Current\x20task\x20description','1093396CaTcMC','parent\x20claude\x20pid=','stdin','get_inbox'];a0_0x21d0=function(){return _0x24ea14;};return a0_0x21d0();}async function Q(_0xd6be26,_0x1f6996){const _0x5758ed=a0_0x3b6422;let _0x1e8ee9=await fetch(Y+'/mcp',{'method':_0x5758ed(0x1ef),'headers':{'Content-Type':_0x5758ed(0x1ec),'Accept':_0x5758ed(0x1fd),...k?{'Authorization':_0x5758ed(0x1b9)+k}:{}},'body':JSON[_0x5758ed(0x1c5)]({'jsonrpc':_0x5758ed(0x1c7),'id':0x1,'method':_0x5758ed(0x1de),'params':{'protocolVersion':_0x5758ed(0x1a9),'capabilities':{},'clientInfo':{'name':_0x5758ed(0x1a7),'version':'0.3.0'}}})});if(!_0x1e8ee9['ok']){let _0x410b38=await _0x1e8ee9[_0x5758ed(0x1d4)]();return z('CommHub\x20init\x20failed:\x20'+_0x1e8ee9[_0x5758ed(0x1ed)]+'\x20'+_0x410b38['slice'](0x0,0x64)),{'ok':!0x1,'error':'init\x20failed:\x20'+_0x1e8ee9['status']};}await _0x1e8ee9['text']();let _0x20ec5f=(await(await fetch(Y+_0x5758ed(0x1e9),{'method':_0x5758ed(0x1ef),'headers':{'Content-Type':_0x5758ed(0x1ec),'Accept':_0x5758ed(0x1fd),...k?{'Authorization':_0x5758ed(0x1b9)+k}:{}},'body':JSON['stringify']({'jsonrpc':_0x5758ed(0x1c7),'id':0x2,'method':'tools/call','params':{'name':_0xd6be26,'arguments':_0x1f6996}})}))['text']())[_0x5758ed(0x1f2)]('\x0a')['find'](_0x2a8db8=>_0x2a8db8[_0x5758ed(0x1fa)](_0x5758ed(0x20d)));if(_0x20ec5f){let _0x4c521c=JSON['parse'](_0x20ec5f[_0x5758ed(0x1cf)](0x6));return _0x4c521c?.[_0x5758ed(0x19b)]?.[_0x5758ed(0x214)]?.[0x0]?.[_0x5758ed(0x1d4)]?JSON['parse'](_0x4c521c['result'][_0x5758ed(0x214)][0x0][_0x5758ed(0x1d4)]):_0x4c521c;}return{'ok':!0x1,'error':_0x5758ed(0x20a)};}K[a0_0x3b6422(0x18b)](a0_0x700957,async _0xa151d2=>{const _0x9a0ebe=a0_0x3b6422;let {name:_0x2320e3,arguments:_0x23ceb2}=_0xa151d2['params'];if(_0x2320e3===_0x9a0ebe(0x1ca)){let {task_id:_0x52cdd2,text:_0x3b54c8,status:_0x300608}=_0x23ceb2;if(_0x300608===_0x9a0ebe(0x212)||_0x300608===_0x9a0ebe(0x1f0)||_0x300608===_0x9a0ebe(0x1cb)){let _0x2c8468=_0x300608==='completed'?_0x9a0ebe(0x219):_0x300608,_0x2445e9=_0x52cdd2?G['get'](_0x52cdd2)||_0x9a0ebe(0x1d0):_0x9a0ebe(0x1d0),_0x2c07f7=await Q(_0x9a0ebe(0x18d),{'alias':_0x2445e9,'text':_0x3b54c8,'in_reply_to':_0x52cdd2||void 0x0,'status':_0x2c8468,'from_session':p});if(_0x52cdd2)G['delete'](_0x52cdd2);return{'content':[{'type':_0x9a0ebe(0x1d4),'text':JSON[_0x9a0ebe(0x1c5)](_0x2c07f7)}]};}let _0x306a01=await Q(_0x9a0ebe(0x1b0),{'resume_id':V,'alias':p,'status':_0x300608==='blocked'?'blocked':_0x300608===_0x9a0ebe(0x1dd)?_0x9a0ebe(0x1dd):'working','task':_0x3b54c8[_0x9a0ebe(0x1cf)](0x0,0xc8),'output':_0x3b54c8});return{'content':[{'type':_0x9a0ebe(0x1d4),'text':JSON['stringify'](_0x306a01)}]};}if(_0x2320e3===_0x9a0ebe(0x199)){let {status:_0x4a2f1c,task:_0x3345c2,progress:_0x11dccc}=_0x23ceb2,_0x2ef8a0=await Q(_0x9a0ebe(0x1b0),{'resume_id':V,'alias':p,'status':_0x4a2f1c,'task':_0x3345c2,'progress':_0x11dccc});return{'content':[{'type':_0x9a0ebe(0x1d4),'text':JSON[_0x9a0ebe(0x1c5)](_0x2ef8a0)}]};}if(_0x2320e3==='commhub_send_task'){let {alias:_0xd03809,task:_0x208804,priority:_0x548efb}=_0x23ceb2,_0x5744b5=await Q('send_task',{'alias':_0xd03809,'task':_0x208804,'priority':_0x548efb||_0x9a0ebe(0x1f7),'from_session':p});return{'content':[{'type':_0x9a0ebe(0x1d4),'text':JSON['stringify'](_0x5744b5)}]};}if(_0x2320e3==='commhub_send_message'){let {alias:_0x786e64,message:_0x2f5871}=_0x23ceb2,_0xcfbef1=await Q(_0x9a0ebe(0x1cd),{'alias':_0x786e64,'message':_0x2f5871,'from_session':p});return{'content':[{'type':_0x9a0ebe(0x1d4),'text':JSON[_0x9a0ebe(0x1c5)](_0xcfbef1)}]};}if(_0x2320e3==='commhub_get_all_status'){let _0x22f60c=await Q(_0x9a0ebe(0x1d5),{});return{'content':[{'type':_0x9a0ebe(0x1d4),'text':JSON[_0x9a0ebe(0x1c5)](_0x22f60c)}]};}return{'content':[{'type':_0x9a0ebe(0x1d4),'text':JSON['stringify']({'error':_0x9a0ebe(0x1e7)})}]};});var D=0x3e8,v=0x7530,O=0x36ee80;async function m(){const _0x314ad8=a0_0x3b6422;try{await Q(_0x314ad8(0x1b0),{'resume_id':V,'alias':p,'status':_0x314ad8(0x1bc),'server':a0_0x453644(),'hostname':a0_0x453644(),'agent':_0x314ad8(0x1a6),'project_dir':process['cwd'](),'tmux_name':j||void 0x0}),z(_0x314ad8(0x21a)+p+_0x314ad8(0x196));}catch(_0x4775f2){z('re-register\x20failed:\x20'+_0x4775f2);}}async function l(){const _0xd92624=a0_0x3b6422;let _0x184204=Y+_0xd92624(0x1d2)+encodeURIComponent(p),_0x4eabaa={};if(k)_0x4eabaa['Authorization']=_0xd92624(0x1b9)+k;z(_0xd92624(0x190)+_0x184204);let _0x37cedf=D,_0x321365=!0x0,_0x2710b9=null;while(!0x0){try{let _0xe7d7d4=await fetch(_0x184204,{'headers':_0x4eabaa});if(!_0xe7d7d4['ok']){if(z('SSE\x20error:\x20'+_0xe7d7d4[_0xd92624(0x1ed)]+'\x20'+_0xe7d7d4[_0xd92624(0x1fb)]),_0x2710b9=_0x2710b9??Date[_0xd92624(0x1c0)](),Date[_0xd92624(0x1c0)]()-_0x2710b9>O){z(_0xd92624(0x19a)+Y+_0xd92624(0x19d));return;}await i(_0x37cedf),_0x37cedf=Math[_0xd92624(0x1ff)](_0x37cedf*0x2,v);continue;}let _0x5c2bb4=_0xe7d7d4['body'][_0xd92624(0x1be)](),_0x17c1ea=new TextDecoder(),_0x146e58='';_0x37cedf=D;while(!0x0){let {done:_0x36ebaa,value:_0x469c99}=await _0x5c2bb4[_0xd92624(0x1c8)]();if(_0x36ebaa)break;_0x146e58+=_0x17c1ea['decode'](_0x469c99,{'stream':!0x0});let _0x49fc8c=_0x146e58[_0xd92624(0x1f2)]('\x0a\x0a');_0x146e58=_0x49fc8c['pop']()||'';for(let _0x39e68b of _0x49fc8c){let _0x10d791=_0x39e68b['split']('\x0a')['find'](_0xaa2933=>_0xaa2933[_0xd92624(0x1fa)](_0xd92624(0x20d)));if(!_0x10d791)continue;try{let _0x111e22=JSON[_0xd92624(0x1c6)](_0x10d791[_0xd92624(0x1cf)](0x6));if(await A(_0x111e22),_0x111e22[_0xd92624(0x213)]===_0xd92624(0x200)){if(_0x2710b9=null,!_0x321365)await m();_0x321365=!0x1;}}catch(_0x3c3a71){z(_0xd92624(0x1ea)+_0x3c3a71);}}}z(_0xd92624(0x1f4));}catch(_0x29e3e3){z(_0xd92624(0x1b3)+_0x29e3e3);}if(_0x2710b9=_0x2710b9??Date['now'](),Date[_0xd92624(0x1c0)]()-_0x2710b9>O){z(_0xd92624(0x19a)+Y+')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。');return;}await i(_0x37cedf),_0x37cedf=Math['min'](_0x37cedf*0x2,v);}}async function A(_0x44db47){const _0x46402d=a0_0x3b6422;if(_0x44db47[_0x46402d(0x213)]===_0x46402d(0x200)){z(_0x46402d(0x20c)+p+'\x22');return;}if(_0x44db47[_0x46402d(0x213)]===_0x46402d(0x1bb)){if(z('←\x20message\x20from\x20'+_0x44db47[_0x46402d(0x18a)]+':\x20'+_0x44db47[_0x46402d(0x1aa)][_0x46402d(0x1cf)](0x0,0x3c)),await K[_0x46402d(0x194)]({'method':'notifications/claude/channel','params':{'content':_0x44db47[_0x46402d(0x1aa)],'meta':{'sender':_0x44db47[_0x46402d(0x18a)]||_0x46402d(0x1d0),'sender_id':_0x46402d(0x20f),'user':_0x44db47[_0x46402d(0x18a)]||_0x46402d(0x1d0),'priority':'normal'}}}),_0x44db47[_0x46402d(0x210)])await Q(_0x46402d(0x1bd),{'alias':p,'message_id':_0x44db47[_0x46402d(0x210)]});return;}if(_0x44db47[_0x46402d(0x213)]==='new_task'||_0x44db47[_0x46402d(0x213)]===_0x46402d(0x1a3)){z('←\x20'+_0x44db47[_0x46402d(0x213)]+':\x20inbox_count='+_0x44db47['inbox_count']+'\x20priority='+(_0x44db47[_0x46402d(0x19f)]||'normal'));let _0x293c38=await Q(_0x46402d(0x186),{'alias':p,'limit':0x5});if(_0x293c38?.['ok']&&_0x293c38[_0x46402d(0x218)]?.[_0x46402d(0x1e4)]>0x0)for(let _0x4fac11 of _0x293c38[_0x46402d(0x218)]){let _0x3a0145={'sender':_0x4fac11[_0x46402d(0x198)]||'hub','sender_id':_0x46402d(0x20f),'user':_0x4fac11[_0x46402d(0x198)]||_0x46402d(0x1d0),'task_id':_0x4fac11['id'],'priority':_0x4fac11[_0x46402d(0x19f)]||_0x46402d(0x1f7)};G['set'](_0x4fac11['id'],_0x4fac11[_0x46402d(0x198)]||'hub'),await K[_0x46402d(0x194)]({'method':_0x46402d(0x18c),'params':{'content':_0x4fac11['content'],'meta':_0x3a0145}}),z(_0x46402d(0x216)+_0x4fac11['id'][_0x46402d(0x1cf)](0x0,0x8)+'\x20from\x20'+_0x4fac11[_0x46402d(0x198)]+':\x20'+_0x4fac11[_0x46402d(0x214)][_0x46402d(0x1cf)](0x0,0x3c)),await Q(_0x46402d(0x1bd),{'alias':p,'message_id':_0x4fac11['id']});}}}async function t(){const _0x2298a3=a0_0x3b6422;let _0x2797e6=new a0_0xc69828();await K[_0x2298a3(0x201)](_0x2797e6),z(_0x2298a3(0x189)),z(_0x2298a3(0x1b8)),l()[_0x2298a3(0x1fe)](_0x2ec07d=>z(_0x2298a3(0x187)+_0x2ec07d)),Q(_0x2298a3(0x1b0),{'resume_id':V,'alias':p,'status':'idle','server':a0_0x453644(),'hostname':a0_0x453644(),'agent':_0x2298a3(0x1a6),'project_dir':process['cwd'](),'tmux_name':j||void 0x0})['then'](()=>z('registered\x20as\x20\x22'+p+_0x2298a3(0x1f3)+V[_0x2298a3(0x1cf)](0x0,0x8)+')'))[_0x2298a3(0x1fe)](_0x35baca=>z(_0x2298a3(0x1a4)+_0x35baca)),setInterval(()=>{const _0x4d2a97=_0x2298a3;Q('report_status',{'resume_id':V,'alias':p,'status':_0x4d2a97(0x1bc),'server':a0_0x453644(),'hostname':a0_0x453644(),'agent':'claude-code','project_dir':process['cwd'](),'tmux_name':j||void 0x0})[_0x4d2a97(0x1fe)](_0x51b1db=>z(_0x4d2a97(0x1af)+_0x51b1db));},0x2bf20),z('ready\x20—\x20waiting\x20for\x20events');}t()[a0_0x3b6422(0x1fe)](_0x5ac334=>{const _0x2f911e=a0_0x3b6422;z(_0x2f911e(0x1eb)+_0x5ac334),process[_0x2f911e(0x1f6)](0x1);});async function b(){const _0x3af293=a0_0x3b6422;z(_0x3af293(0x1b5)),await Q(_0x3af293(0x1b0),{'resume_id':V,'alias':p,'status':_0x3af293(0x1c9),'task':_0x3af293(0x1b7)})[_0x3af293(0x1fe)](()=>{}),process[_0x3af293(0x1f6)](0x0);}process[a0_0x3b6422(0x185)]['on'](a0_0x3b6422(0x1c2),()=>b()),process['on'](a0_0x3b6422(0x1b2),()=>b()),process['on']('SIGINT',()=>b());var d=process['ppid'];if(d&&d>0x1){let h=setInterval(()=>{const _0x2d8840=a0_0x3b6422;if(process['ppid']===0x1&&d!==0x1){z(_0x2d8840(0x203)+d+_0x2d8840(0x1dc)),b();return;}try{process[_0x2d8840(0x1e8)](d,0x0);}catch(_0x3da0a1){if(_0x3da0a1?.[_0x2d8840(0x206)]===_0x2d8840(0x205))z(_0x2d8840(0x184)+d+_0x2d8840(0x197)),b();}},0x7530);if(typeof h['unref']===a0_0x3b6422(0x1e2))h[a0_0x3b6422(0x1ae)]();}
2
+ const a0_0x587abe=a0_0x51e5;(function(_0x3e5928,_0x47b6eb){const _0x4b89ce=a0_0x51e5,_0x3a517f=_0x3e5928();while(!![]){try{const _0x1fbb40=-parseInt(_0x4b89ce(0x1ee))/0x1*(parseInt(_0x4b89ce(0x21d))/0x2)+parseInt(_0x4b89ce(0x236))/0x3*(-parseInt(_0x4b89ce(0x27f))/0x4)+parseInt(_0x4b89ce(0x1f8))/0x5+-parseInt(_0x4b89ce(0x20c))/0x6+parseInt(_0x4b89ce(0x287))/0x7+parseInt(_0x4b89ce(0x264))/0x8+-parseInt(_0x4b89ce(0x265))/0x9*(-parseInt(_0x4b89ce(0x270))/0xa);if(_0x1fbb40===_0x47b6eb)break;else _0x3a517f['push'](_0x3a517f['shift']());}catch(_0x4dd588){_0x3a517f['push'](_0x3a517f['shift']());}}}(a0_0x38d9,0xa3aa9));import{readFileSync as a0_0x4a71cf,existsSync as a0_0x5298bd}from'fs';import{randomUUID as a0_0x102173}from'crypto';function a0_0x51e5(_0x29aee7,_0x39e586){_0x29aee7=_0x29aee7-0x1e3;const _0x38d960=a0_0x38d9();let _0x51e569=_0x38d960[_0x29aee7];return _0x51e569;}import{join as a0_0x5b0fb5}from'path';import{hostname as a0_0x162e43}from'os';import{execSync as a0_0xc90d0}from'child_process';function B(_0x1e96b6){const _0x1327a2=a0_0x51e5;let _0x5f44f5=_0x1e96b6[_0x1327a2(0x257)](/[^a-zA-Z0-9\-_]/g,'-');return _0x5f44f5===''?_0x1327a2(0x209):_0x5f44f5;}import{Server as a0_0x4cdf5a}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x9ca236}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x466cbe,CallToolRequestSchema as a0_0x58e28e}from'@modelcontextprotocol/sdk/types.js';function T(_0x37698c){const _0x35b6d9=a0_0x51e5;if(!a0_0x5298bd(_0x37698c))return;for(let _0x5c0970 of a0_0x4a71cf(_0x37698c,_0x35b6d9(0x1fc))[_0x35b6d9(0x23d)]('\x0a')){let _0x51e593=_0x5c0970['trim']();if(!_0x51e593||_0x51e593[_0x35b6d9(0x250)]('#'))continue;let _0x3af32e=_0x51e593[_0x35b6d9(0x20e)]('=');if(_0x3af32e<0x0)continue;let _0x518ac5=_0x51e593[_0x35b6d9(0x281)](0x0,_0x3af32e)[_0x35b6d9(0x280)](),_0x2f4e5d=_0x51e593[_0x35b6d9(0x281)](_0x3af32e+0x1)[_0x35b6d9(0x280)]()[_0x35b6d9(0x257)](/^["']|["']$/g,'');if(!process.env[_0x518ac5])process.env[_0x518ac5]=_0x2f4e5d;}}var C=process.env.HOME||'~',r=a0_0x5b0fb5(C,a0_0x587abe(0x20f));T(a0_0x5b0fb5(r,a0_0x587abe(0x224)));var H=B(process[a0_0x587abe(0x222)]());T(a0_0x5b0fb5(r,H,'.env'));function a0_0x38d9(){const _0x432e86=['heartbeat\x20failed:\x20','none','SSE\x20fatal:\x20','object','Session\x20alias:\x20','offline','normal','get_inbox','Current\x20task\x20description','commhub_reply','replied','0.3.0','hub','startsWith','idle','SSE\x20connection\x20error:\x20','cancelled','send_reply','connected','blocked','replace','unknown\x20tool','notification','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','pop','warning:\x20could\x20not\x20register:\x20','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','SIGTERM','parse','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','tmux\x20display-message\x20-p\x20\x27#S\x27','new_task','ready\x20—\x20waiting\x20for\x20events','2285512MbfoQA','14840361MlVvOH','\x20ALIAS=','→\x20injected\x20task\x20','Bearer\x20','re-registered\x20as\x20\x22','data:\x20','ENV:\x20URL=','task','Target\x20session\x20alias','SIGINT','re-register\x20failed:\x20','10nysabP','content','.anet','function','stringify','claude-code','length','new_message','no\x20response','params','fatal:\x20','kill','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','send_message','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','4184fBtlPa','trim','slice','broadcast','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','POST','registered\x20as\x20\x22','exit','5304012LEPUsW','ppid','session\x20disconnected','min','stderr','connect','MCP\x20stdio\x20connected','\x20priority=','inbox_count','working','CommHub\x20init\x20failed:\x20','from_session','\x22\x20after\x20SSE\x20reconnect','...\x20TMUX=','10042VDKiiN','http://127.0.0.1:9200','number','commhub_report_status','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','string','from','error','Task\x20content','1125260QUkZvL','code','application/json,\x20text/event-stream','join','utf-8','decode','notifications/claude/channel','result','SSE\x20connected\x20as\x20\x22','/mcp','parent\x20claude\x20pid=','now','find','commhub-channel','status','SSE\x20error:\x20','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','unknown','set','2025-03-26','5083446HqOxaF','commhub','indexOf','.claude/channels/commhub','toTimeString','\x20from\x20','message','type','connecting\x20to\x20','text','priority','config.json','unattributed-','write','commhub_send_task','setRequestHandler','completed','54sKqixg','starting\x20SSE\x20listener...','in_progress','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','stdin','cwd','failed','.env','Message\x20content','commhub_send_message','\x20no\x20longer\x20exists\x20(kill-0\x20ESRCH)\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','\x20PROJECT_ENV=','delete','unref','(none)','/events/','then','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','ESRCH','alias','Progress\x200-100','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','\x20RESUME_ID=','2.0','message_id','3237tXaJZS','SSE\x20stream\x20ended,\x20reconnecting...','messages','token',':\x20inbox_count=','catch','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','split','init\x20failed:\x20',')\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','report_status','initialize','high'];a0_0x38d9=function(){return _0x432e86;};return a0_0x38d9();}function E(){const _0x101918=a0_0x587abe;try{return a0_0xc90d0(_0x101918(0x261),{'encoding':_0x101918(0x1fc),'timeout':0x7d0})[_0x101918(0x280)]();}catch{return'';}}function _(){const _0x1d67a3=a0_0x587abe;try{let _0x1d7740=a0_0x5b0fb5(C,_0x1d67a3(0x272),_0x1d67a3(0x217));if(a0_0x5298bd(_0x1d7740))return JSON[_0x1d67a3(0x25f)](a0_0x4a71cf(_0x1d7740,_0x1d67a3(0x1fc)));}catch{}return{};}var R=_(),Y=process.env.COMMHUB_URL||R[a0_0x587abe(0x24f)]||a0_0x587abe(0x1ef),j=process.env.COMMHUB_TMUX||E();function S(){const _0x549b1b=a0_0x587abe;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x549b1b(0x280)]())return process.env.COMMHUB_ALIAS[_0x549b1b(0x280)]();return process[_0x549b1b(0x1e4)][_0x549b1b(0x219)](_0x549b1b(0x1f2)+(_0x549b1b(0x283)+(j||_0x549b1b(0x22b))+'\x20/\x20hostname='+a0_0x162e43()+'.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a')),_0x549b1b(0x218)+process['pid'];}var p=S(),V=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x102173(),k=process.env.COMMHUB_TOKEN||R[a0_0x587abe(0x239)]||'';function z(_0x137bf3){const _0x17537f=a0_0x587abe;let _0x345728=new Date()[_0x17537f(0x210)]()['slice'](0x0,0x8);process[_0x17537f(0x1e4)]['write']('['+_0x345728+']\x20[commhub]\x20'+_0x137bf3+'\x0a');}function i(_0x4ffe80){return new Promise(_0x2a7093=>setTimeout(_0x2a7093,_0x4ffe80));}z(a0_0x587abe(0x26b)+Y+a0_0x587abe(0x266)+p+a0_0x587abe(0x233)+V[a0_0x587abe(0x281)](0x0,0x8)+a0_0x587abe(0x1ed)+(j||a0_0x587abe(0x244))+'\x20CWD='+process[a0_0x587abe(0x222)]()+a0_0x587abe(0x228)+H);var G=new Map(),K=new a0_0x4cdf5a({'name':a0_0x587abe(0x205),'version':a0_0x587abe(0x24e)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x587abe(0x25d),'These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.',a0_0x587abe(0x27e),a0_0x587abe(0x247)+p][a0_0x587abe(0x1fb)]('\x0a')});K['setRequestHandler'](a0_0x466cbe,async()=>({'tools':[{'name':a0_0x587abe(0x24c),'description':a0_0x587abe(0x260),'inputSchema':{'type':a0_0x587abe(0x246),'properties':{'task_id':{'type':a0_0x587abe(0x1f4),'description':a0_0x587abe(0x208)},'text':{'type':'string','description':'Reply\x20text\x20/\x20result\x20summary'},'status':{'type':a0_0x587abe(0x1f4),'enum':[a0_0x587abe(0x21c),a0_0x587abe(0x223),'cancelled',a0_0x587abe(0x256),'error',a0_0x587abe(0x21f)],'description':a0_0x587abe(0x22e)}},'required':['text']}},{'name':a0_0x587abe(0x1f1),'description':a0_0x587abe(0x220),'inputSchema':{'type':a0_0x587abe(0x246),'properties':{'status':{'type':a0_0x587abe(0x1f4),'enum':[a0_0x587abe(0x1e9),'idle','blocked',a0_0x587abe(0x1f6)]},'task':{'type':a0_0x587abe(0x1f4),'description':a0_0x587abe(0x24b)},'progress':{'type':a0_0x587abe(0x1f0),'description':a0_0x587abe(0x231)}},'required':[a0_0x587abe(0x206)]}},{'name':a0_0x587abe(0x21a),'description':a0_0x587abe(0x232),'inputSchema':{'type':'object','properties':{'alias':{'type':a0_0x587abe(0x1f4),'description':a0_0x587abe(0x26d)},'task':{'type':a0_0x587abe(0x1f4),'description':a0_0x587abe(0x1f7)},'priority':{'type':a0_0x587abe(0x1f4),'enum':[a0_0x587abe(0x242),'normal','low'],'description':'Priority\x20(default:\x20normal)'}},'required':[a0_0x587abe(0x230),a0_0x587abe(0x26c)]}},{'name':a0_0x587abe(0x226),'description':a0_0x587abe(0x23c),'inputSchema':{'type':a0_0x587abe(0x246),'properties':{'alias':{'type':'string','description':a0_0x587abe(0x26d)},'message':{'type':'string','description':a0_0x587abe(0x225)}},'required':[a0_0x587abe(0x230),'message']}},{'name':'commhub_get_all_status','description':a0_0x587abe(0x27c),'inputSchema':{'type':'object','properties':{}}}]}));async function Q(_0x4f5628,_0x274d1e){const _0x1edacd=a0_0x587abe;let _0x1769e1=await fetch(Y+_0x1edacd(0x201),{'method':_0x1edacd(0x284),'headers':{'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream',...k?{'Authorization':_0x1edacd(0x268)+k}:{}},'body':JSON[_0x1edacd(0x274)]({'jsonrpc':_0x1edacd(0x234),'id':0x1,'method':_0x1edacd(0x241),'params':{'protocolVersion':_0x1edacd(0x20b),'capabilities':{},'clientInfo':{'name':_0x1edacd(0x205),'version':'0.3.0'}}})});if(!_0x1769e1['ok']){let _0xc7021=await _0x1769e1[_0x1edacd(0x215)]();return z(_0x1edacd(0x1ea)+_0x1769e1[_0x1edacd(0x206)]+'\x20'+_0xc7021[_0x1edacd(0x281)](0x0,0x64)),{'ok':!0x1,'error':_0x1edacd(0x23e)+_0x1769e1['status']};}await _0x1769e1[_0x1edacd(0x215)]();let _0x48255b=(await(await fetch(Y+_0x1edacd(0x201),{'method':_0x1edacd(0x284),'headers':{'Content-Type':'application/json','Accept':_0x1edacd(0x1fa),...k?{'Authorization':_0x1edacd(0x268)+k}:{}},'body':JSON['stringify']({'jsonrpc':_0x1edacd(0x234),'id':0x2,'method':'tools/call','params':{'name':_0x4f5628,'arguments':_0x274d1e}})}))[_0x1edacd(0x215)]())['split']('\x0a')[_0x1edacd(0x204)](_0x3c4c86=>_0x3c4c86[_0x1edacd(0x250)](_0x1edacd(0x26a)));if(_0x48255b){let _0x5916ff=JSON[_0x1edacd(0x25f)](_0x48255b[_0x1edacd(0x281)](0x6));return _0x5916ff?.[_0x1edacd(0x1ff)]?.[_0x1edacd(0x271)]?.[0x0]?.[_0x1edacd(0x215)]?JSON[_0x1edacd(0x25f)](_0x5916ff['result'][_0x1edacd(0x271)][0x0]['text']):_0x5916ff;}return{'ok':!0x1,'error':_0x1edacd(0x278)};}K[a0_0x587abe(0x21b)](a0_0x58e28e,async _0xb35a59=>{const _0x1c73e7=a0_0x587abe;let {name:_0x3c969e,arguments:_0xfdb947}=_0xb35a59[_0x1c73e7(0x279)];if(_0x3c969e===_0x1c73e7(0x24c)){let {task_id:_0x2dd6bc,text:_0x30a727,status:_0x37cd8f}=_0xfdb947;if(_0x37cd8f===_0x1c73e7(0x21c)||_0x37cd8f===_0x1c73e7(0x223)||_0x37cd8f===_0x1c73e7(0x253)){let _0x1057e0=_0x37cd8f===_0x1c73e7(0x21c)?_0x1c73e7(0x24d):_0x37cd8f,_0x5ec9f6=_0x2dd6bc?G['get'](_0x2dd6bc)||_0x1c73e7(0x24f):_0x1c73e7(0x24f),_0x376daf=await Q(_0x1c73e7(0x254),{'alias':_0x5ec9f6,'text':_0x30a727,'in_reply_to':_0x2dd6bc||void 0x0,'status':_0x1057e0,'from_session':p});if(_0x2dd6bc)G[_0x1c73e7(0x229)](_0x2dd6bc);return{'content':[{'type':'text','text':JSON[_0x1c73e7(0x274)](_0x376daf)}]};}let _0x1ded15=await Q(_0x1c73e7(0x240),{'resume_id':V,'alias':p,'status':_0x37cd8f===_0x1c73e7(0x256)?_0x1c73e7(0x256):_0x37cd8f==='error'?_0x1c73e7(0x1f6):_0x1c73e7(0x1e9),'task':_0x30a727['slice'](0x0,0xc8),'output':_0x30a727});return{'content':[{'type':_0x1c73e7(0x215),'text':JSON['stringify'](_0x1ded15)}]};}if(_0x3c969e===_0x1c73e7(0x1f1)){let {status:_0x3d9925,task:_0x240f77,progress:_0x5b2676}=_0xfdb947,_0x2f3118=await Q(_0x1c73e7(0x240),{'resume_id':V,'alias':p,'status':_0x3d9925,'task':_0x240f77,'progress':_0x5b2676});return{'content':[{'type':'text','text':JSON['stringify'](_0x2f3118)}]};}if(_0x3c969e==='commhub_send_task'){let {alias:_0x2fdb5c,task:_0x2401d8,priority:_0x47e3b7}=_0xfdb947,_0x41f6a4=await Q('send_task',{'alias':_0x2fdb5c,'task':_0x2401d8,'priority':_0x47e3b7||_0x1c73e7(0x249),'from_session':p});return{'content':[{'type':'text','text':JSON[_0x1c73e7(0x274)](_0x41f6a4)}]};}if(_0x3c969e===_0x1c73e7(0x226)){let {alias:_0x3e0f88,message:_0x560723}=_0xfdb947,_0x1929b3=await Q(_0x1c73e7(0x27d),{'alias':_0x3e0f88,'message':_0x560723,'from_session':p});return{'content':[{'type':'text','text':JSON['stringify'](_0x1929b3)}]};}if(_0x3c969e==='commhub_get_all_status'){let _0x3268a2=await Q('get_all_status',{});return{'content':[{'type':_0x1c73e7(0x215),'text':JSON[_0x1c73e7(0x274)](_0x3268a2)}]};}return{'content':[{'type':_0x1c73e7(0x215),'text':JSON[_0x1c73e7(0x274)]({'error':_0x1c73e7(0x258)})}]};});var D=0x3e8,v=0x7530,O=0x36ee80;async function m(){const _0x5f4b84=a0_0x587abe;try{await Q('report_status',{'resume_id':V,'alias':p,'status':_0x5f4b84(0x251),'server':a0_0x162e43(),'hostname':a0_0x162e43(),'agent':_0x5f4b84(0x275),'project_dir':process[_0x5f4b84(0x222)](),'tmux_name':j||void 0x0}),z(_0x5f4b84(0x269)+p+_0x5f4b84(0x1ec));}catch(_0x2a7b52){z(_0x5f4b84(0x26f)+_0x2a7b52);}}async function l(){const _0x27763e=a0_0x587abe;let _0xa6e9b6=Y+_0x27763e(0x22c)+encodeURIComponent(p),_0x4289b2={};if(k)_0x4289b2['Authorization']=_0x27763e(0x268)+k;z(_0x27763e(0x214)+_0xa6e9b6);let _0x420f43=D,_0x2c8291=!0x0,_0xc90ae3=null;while(!0x0){try{let _0x3dec73=await fetch(_0xa6e9b6,{'headers':_0x4289b2});if(!_0x3dec73['ok']){if(z(_0x27763e(0x207)+_0x3dec73[_0x27763e(0x206)]+'\x20'+_0x3dec73['statusText']),_0xc90ae3=_0xc90ae3??Date['now'](),Date[_0x27763e(0x203)]()-_0xc90ae3>O){z('SSE\x20连续\x20>1h\x20连不上\x20hub\x20('+Y+_0x27763e(0x1f3));return;}await i(_0x420f43),_0x420f43=Math[_0x27763e(0x1e3)](_0x420f43*0x2,v);continue;}let _0x5bc241=_0x3dec73['body']['getReader'](),_0xfa016d=new TextDecoder(),_0x2e3d50='';_0x420f43=D;while(!0x0){let {done:_0x4efede,value:_0x33cdb8}=await _0x5bc241['read']();if(_0x4efede)break;_0x2e3d50+=_0xfa016d[_0x27763e(0x1fd)](_0x33cdb8,{'stream':!0x0});let _0x5d9bbd=_0x2e3d50[_0x27763e(0x23d)]('\x0a\x0a');_0x2e3d50=_0x5d9bbd[_0x27763e(0x25b)]()||'';for(let _0x57dc20 of _0x5d9bbd){let _0x56eb3e=_0x57dc20[_0x27763e(0x23d)]('\x0a')['find'](_0x31f1cc=>_0x31f1cc[_0x27763e(0x250)](_0x27763e(0x26a)));if(!_0x56eb3e)continue;try{let _0x4967f7=JSON[_0x27763e(0x25f)](_0x56eb3e['slice'](0x6));if(await A(_0x4967f7),_0x4967f7[_0x27763e(0x213)]===_0x27763e(0x255)){if(_0xc90ae3=null,!_0x2c8291)await m();_0x2c8291=!0x1;}}catch(_0xb132fc){z('parse\x20error:\x20'+_0xb132fc);}}}z(_0x27763e(0x237));}catch(_0x3f5865){z(_0x27763e(0x252)+_0x3f5865);}if(_0xc90ae3=_0xc90ae3??Date[_0x27763e(0x203)](),Date[_0x27763e(0x203)]()-_0xc90ae3>O){z(_0x27763e(0x25a)+Y+_0x27763e(0x1f3));return;}await i(_0x420f43),_0x420f43=Math[_0x27763e(0x1e3)](_0x420f43*0x2,v);}}async function A(_0x348ad5){const _0x139558=a0_0x587abe;if(_0x348ad5[_0x139558(0x213)]===_0x139558(0x255)){z(_0x139558(0x200)+p+'\x22');return;}if(_0x348ad5[_0x139558(0x213)]===_0x139558(0x277)){if(z('←\x20message\x20from\x20'+_0x348ad5[_0x139558(0x1f5)]+':\x20'+_0x348ad5['message'][_0x139558(0x281)](0x0,0x3c)),await K[_0x139558(0x259)]({'method':_0x139558(0x1fe),'params':{'content':_0x348ad5[_0x139558(0x212)],'meta':{'sender':_0x348ad5[_0x139558(0x1f5)]||_0x139558(0x24f),'sender_id':_0x139558(0x20d),'user':_0x348ad5[_0x139558(0x1f5)]||_0x139558(0x24f),'priority':'normal'}}}),_0x348ad5['message_id'])await Q('ack_inbox',{'alias':p,'message_id':_0x348ad5[_0x139558(0x235)]});return;}if(_0x348ad5[_0x139558(0x213)]===_0x139558(0x262)||_0x348ad5[_0x139558(0x213)]===_0x139558(0x282)){z('←\x20'+_0x348ad5['type']+_0x139558(0x23a)+_0x348ad5[_0x139558(0x1e8)]+_0x139558(0x1e7)+(_0x348ad5[_0x139558(0x216)]||_0x139558(0x249)));let _0x415053=await Q(_0x139558(0x24a),{'alias':p,'limit':0x5});if(_0x415053?.['ok']&&_0x415053[_0x139558(0x238)]?.[_0x139558(0x276)]>0x0)for(let _0xeb97d0 of _0x415053['messages']){let _0x44b8f8={'sender':_0xeb97d0[_0x139558(0x1eb)]||_0x139558(0x24f),'sender_id':_0x139558(0x20d),'user':_0xeb97d0[_0x139558(0x1eb)]||_0x139558(0x24f),'task_id':_0xeb97d0['id'],'priority':_0xeb97d0[_0x139558(0x216)]||_0x139558(0x249)};G[_0x139558(0x20a)](_0xeb97d0['id'],_0xeb97d0[_0x139558(0x1eb)]||'hub'),await K[_0x139558(0x259)]({'method':_0x139558(0x1fe),'params':{'content':_0xeb97d0['content'],'meta':_0x44b8f8}}),z(_0x139558(0x267)+_0xeb97d0['id']['slice'](0x0,0x8)+_0x139558(0x211)+_0xeb97d0[_0x139558(0x1eb)]+':\x20'+_0xeb97d0['content'][_0x139558(0x281)](0x0,0x3c)),await Q('ack_inbox',{'alias':p,'message_id':_0xeb97d0['id']});}}}async function t(){const _0x170fe8=a0_0x587abe;let _0x5d052e=new a0_0x9ca236();await K[_0x170fe8(0x1e5)](_0x5d052e),z(_0x170fe8(0x1e6)),z(_0x170fe8(0x21e)),l()[_0x170fe8(0x23b)](_0x3514c0=>z(_0x170fe8(0x245)+_0x3514c0)),Q(_0x170fe8(0x240),{'resume_id':V,'alias':p,'status':'idle','server':a0_0x162e43(),'hostname':a0_0x162e43(),'agent':_0x170fe8(0x275),'project_dir':process[_0x170fe8(0x222)](),'tmux_name':j||void 0x0})[_0x170fe8(0x22d)](()=>z(_0x170fe8(0x285)+p+'\x22\x20('+V[_0x170fe8(0x281)](0x0,0x8)+')'))['catch'](_0x2e2888=>z(_0x170fe8(0x25c)+_0x2e2888)),setInterval(()=>{const _0x11f38b=_0x170fe8;Q(_0x11f38b(0x240),{'resume_id':V,'alias':p,'status':_0x11f38b(0x251),'server':a0_0x162e43(),'hostname':a0_0x162e43(),'agent':_0x11f38b(0x275),'project_dir':process[_0x11f38b(0x222)](),'tmux_name':j||void 0x0})[_0x11f38b(0x23b)](_0xb13bdc=>z(_0x11f38b(0x243)+_0xb13bdc));},0x2bf20),z(_0x170fe8(0x263));}t()[a0_0x587abe(0x23b)](_0x3a3995=>{const _0x5decca=a0_0x587abe;z(_0x5decca(0x27a)+_0x3a3995),process[_0x5decca(0x286)](0x1);});async function b(){const _0xd8e570=a0_0x587abe;z('shutting\x20down,\x20reporting\x20offline...'),await Q(_0xd8e570(0x240),{'resume_id':V,'alias':p,'status':_0xd8e570(0x248),'task':_0xd8e570(0x289)})['catch'](()=>{}),process[_0xd8e570(0x286)](0x0);}process[a0_0x587abe(0x221)]['on']('end',()=>b()),process['on'](a0_0x587abe(0x25e),()=>b()),process['on'](a0_0x587abe(0x26e),()=>b());var d=process['ppid'];if(d&&d>0x1){let h=setInterval(()=>{const _0x3086fd=a0_0x587abe;if(process[_0x3086fd(0x288)]===0x1&&d!==0x1){z('parent\x20claude\x20died\x20(reparented\x20to\x20PID\x201\x20from\x20'+d+_0x3086fd(0x23f)),b();return;}try{process[_0x3086fd(0x27b)](d,0x0);}catch(_0x51ca61){if(_0x51ca61?.[_0x3086fd(0x1f9)]===_0x3086fd(0x22f))z(_0x3086fd(0x202)+d+_0x3086fd(0x227)),b();}},0x7530);if(typeof h[a0_0x587abe(0x22a)]===a0_0x587abe(0x273))h[a0_0x587abe(0x22a)]();}
@@ -1,6 +1,14 @@
1
- export type RuntimeName = "claude-code-cli" | "codex-sdk" | "claude-agent-sdk" | "grok-build-acp" | "grok-build-cli" | "opencode-cli" | "codex-app-server";
1
+ export type RuntimeName = "claude-code-cli" | "codex-sdk" | "claude-agent-sdk" | "grok-build-acp" | "opencode-cli" | "codex-app-server";
2
2
  /** Operator-facing default for any runtime slot that comes in empty / missing / unrecognized. */
3
3
  export declare const DEFAULT_RUNTIME: RuntimeName;
4
+ /**
5
+ * Runtimes launched through the agent-node supervisor rather than by spawning
6
+ * the Claude Code CLI directly. Keep this predicate exhaustive so adding a
7
+ * runtime cannot silently fall into the Claude launcher branch.
8
+ */
9
+ export declare function runtimeUsesAgentNode(runtime: RuntimeName): boolean;
10
+ /** Runtimes whose explicit CLI choice must bypass the API-vendor picker. */
11
+ export declare function runtimeSkipsCreateVendorPicker(runtime: RuntimeName): boolean;
4
12
  type ProfileLike = {
5
13
  runtime?: string;
6
14
  codexRuntime?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sleep2agi/agent-network",
3
- "version": "2.3.0-preview.23",
4
- "description": "AI Agent Network CLI — Local-first multi-agent orchestration across Claude, Codex, Grok (ACP plus experimental co-presence TUI), and OpenCode runtimes. Apache 2.0.",
3
+ "version": "2.3.0-preview.25",
4
+ "description": "AI Agent Network CLI — 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",
7
7
  "types": "dist/client.d.ts",
@@ -36,9 +36,6 @@
36
36
  "grok",
37
37
  "xai",
38
38
  "grok-build-acp",
39
- "grok-build-cli",
40
- "grok-tui",
41
- "copresence",
42
39
  "acp",
43
40
  "minimax",
44
41
  "mimo",
@@ -57,8 +54,7 @@
57
54
  "directory": "agent-network"
58
55
  },
59
56
  "publishConfig": {
60
- "access": "public",
61
- "tag": "preview"
57
+ "access": "public"
62
58
  },
63
59
  "bugs": {
64
60
  "url": "https://github.com/sleep2agi/agent-network/issues"
@@ -1,115 +0,0 @@
1
- import type { Duplex } from "node:stream";
2
- export declare const GROK_ATTACH_PROTOCOL = "anet-grok-copresence-attach";
3
- export declare const GROK_ATTACH_PROTOCOL_VERSION = 1;
4
- export declare const GROK_ATTACH_DEFAULT_MAX_FRAME_BYTES: number;
5
- export declare const GROK_ATTACH_DEFAULT_MAX_BUFFER_BYTES: number;
6
- export declare const GROK_ATTACH_DEFAULT_HANDSHAKE_TIMEOUT_MS = 5000;
7
- export declare const GROK_ATTACH_DEFAULT_CLOSE_TIMEOUT_MS = 1000;
8
- export type GrokAttachJsonValue = null | boolean | number | string | GrokAttachJsonValue[] | {
9
- [key: string]: GrokAttachJsonValue;
10
- };
11
- export interface GrokAttachHelloFrame {
12
- type: "hello";
13
- protocol: typeof GROK_ATTACH_PROTOCOL;
14
- version: typeof GROK_ATTACH_PROTOCOL_VERSION;
15
- alias: string;
16
- sessionId: string;
17
- [key: string]: unknown;
18
- }
19
- export interface GrokAttachOutputFrame {
20
- type: "output";
21
- data: string;
22
- encoding: "base64";
23
- }
24
- export interface GrokAttachStatusFrame {
25
- type: "status";
26
- status: GrokAttachJsonValue;
27
- }
28
- export interface GrokAttachErrorFrame {
29
- type: "error";
30
- code: string;
31
- message: string;
32
- fatal: boolean;
33
- }
34
- export interface GrokAttachDetachFrame {
35
- type: "detach";
36
- }
37
- export type GrokAttachServerFrame = GrokAttachHelloFrame | GrokAttachOutputFrame | GrokAttachStatusFrame | GrokAttachErrorFrame | GrokAttachDetachFrame;
38
- export interface GrokAttachInputFrame {
39
- type: "input";
40
- data: string;
41
- encoding: "base64";
42
- }
43
- export interface GrokAttachResizeFrame {
44
- type: "resize";
45
- cols: number;
46
- rows: number;
47
- }
48
- export type GrokAttachClientFrame = GrokAttachInputFrame | GrokAttachResizeFrame | GrokAttachDetachFrame;
49
- export interface GrokAttachInputSource {
50
- on(event: "data", listener: (chunk: unknown) => void): unknown;
51
- on(event: "end", listener: () => void): unknown;
52
- off?(event: "data" | "end", listener: (...args: any[]) => void): unknown;
53
- removeListener?(event: "data" | "end", listener: (...args: any[]) => void): unknown;
54
- pause?(): unknown;
55
- resume?(): unknown;
56
- }
57
- export interface GrokAttachOutputSink {
58
- write(chunk: Uint8Array): boolean | void;
59
- columns?: number;
60
- rows?: number;
61
- once?(event: "drain", listener: () => void): unknown;
62
- }
63
- export interface GrokAttachSignalSource {
64
- on(event: "SIGWINCH", listener: () => void): unknown;
65
- off?(event: "SIGWINCH", listener: () => void): unknown;
66
- removeListener?(event: "SIGWINCH", listener: () => void): unknown;
67
- }
68
- export interface GrokAttachSocketStat {
69
- uid: number;
70
- isSocket(): boolean;
71
- isSymbolicLink(): boolean;
72
- }
73
- export interface GrokAttachDependencies {
74
- lstat?: (socketPath: string) => Promise<GrokAttachSocketStat>;
75
- getuid?: () => number | undefined;
76
- connect?: (socketPath: string) => Duplex;
77
- }
78
- export interface GrokAttachClientOptions {
79
- socketPath: string;
80
- input: GrokAttachInputSource;
81
- output: GrokAttachOutputSink;
82
- signalSource?: GrokAttachSignalSource;
83
- terminalSize?: () => {
84
- cols: number | undefined;
85
- rows: number | undefined;
86
- };
87
- maxFrameBytes?: number;
88
- maxBufferBytes?: number;
89
- handshakeTimeoutMs?: number;
90
- closeTimeoutMs?: number;
91
- detachOnInputEnd?: boolean;
92
- onHello?: (frame: GrokAttachHelloFrame) => void;
93
- onStatus?: (frame: GrokAttachStatusFrame) => void;
94
- onError?: (error: Error, frame?: GrokAttachErrorFrame) => void;
95
- onDetach?: (frame: GrokAttachDetachFrame) => void;
96
- dependencies?: GrokAttachDependencies;
97
- }
98
- export type GrokAttachCloseReason = "local-detach" | "input-end" | "remote-detach" | "socket-close" | "socket-error" | "protocol-error";
99
- export interface GrokAttachCloseInfo {
100
- reason: GrokAttachCloseReason;
101
- error?: Error;
102
- }
103
- export interface GrokAttachSession {
104
- readonly socketPath: string;
105
- readonly closed: Promise<GrokAttachCloseInfo>;
106
- detach(): void;
107
- resize(cols?: number, rows?: number): void;
108
- }
109
- export declare class GrokAttachRemoteError extends Error {
110
- readonly code: string;
111
- readonly fatal: boolean;
112
- constructor(frame: GrokAttachErrorFrame);
113
- }
114
- export declare function validateGrokAttachSocket(socketPath: string, dependencies?: GrokAttachDependencies): Promise<void>;
115
- export declare function connectGrokAttach(options: GrokAttachClientOptions): Promise<GrokAttachSession>;
@@ -1,44 +0,0 @@
1
- export declare const GROK_UNIX_SOCKET_PATH_MAX_BYTES = 100;
2
- export declare const GROK_COPRESENCE_CAPABILITY_MARKER = "ANET_CAPABILITY_GROK_COPRESENCE_V2";
3
- export declare const GROK_PREVIEW_RESOLVER_INHERITED_ENV_KEYS: readonly ["PATH", "TMPDIR", "TMP", "TEMP", "LANG", "LC_ALL", "LC_CTYPE", "TZ"];
4
- export declare const GROK_AGENT_NODE_INHERITED_ENV_KEYS: readonly ["PATH", "HOME", "TMPDIR", "TMP", "TEMP", "LANG", "LC_ALL", "LC_CTYPE", "TZ", "SHELL", "USER", "LOGNAME", "TERM", "COLORTERM", "NO_COLOR"];
5
- export declare const GROK_AGENT_NODE_OPTIONAL_ENV_KEYS: readonly ["GROK_BINARY", "GROK_HOME", "FLOCK_BINARY", "SETPRIV_BINARY", "UNSHARE_BINARY", "GROK_CLI_TIMEOUT_MS", "GROK_HANDSHAKE_TIMEOUT_MS", "LOG_LEVEL", "ANET_GOAL_TICK_MS", "COMMHUB_MAX_GOALS_PER_NODE"];
6
- /** Exact environment for the long-lived agent-node parent of the Grok TUI. */
7
- export declare function buildGrokAgentNodeEnv(parentEnv: NodeJS.ProcessEnv): Record<string, string>;
8
- export declare function grokPreviewResolverConfigPaths(home: string): {
9
- directory: string;
10
- userConfig: string;
11
- globalConfig: string;
12
- };
13
- /**
14
- * npm rejects loading the same file as both user and global config. Prepare
15
- * two distinct, empty, owner-only files without following a final symlink so
16
- * the resolver cannot inherit a user's ordinary npmrc credentials.
17
- */
18
- export declare function prepareGrokPreviewResolverConfigs(home: string): void;
19
- /** Exact environment for the short-lived npm resolver and capability probe. */
20
- export declare function buildGrokPreviewResolverEnv(parentEnv: NodeJS.ProcessEnv, home: string): Record<string, string>;
21
- /** Old headless-only agent-node builds already advertised grok-build-cli. */
22
- export declare function agentNodeHelpSupportsGrokCopresence(help: string): boolean;
23
- export interface GrokCopresenceProfileFields {
24
- grokCopresence: boolean;
25
- grokLeaderSocket?: string;
26
- grokAttachSocket?: string;
27
- }
28
- export interface GrokSocketPathOptions {
29
- cwd?: string;
30
- home?: string;
31
- xdgRuntimeDir?: string;
32
- uid?: number;
33
- platform?: NodeJS.Platform;
34
- }
35
- /**
36
- * Allocate deterministic, short Unix socket paths without creating anything.
37
- * The runtime owns directory creation and permissions; `anet node create`
38
- * only persists the identity of the two sockets.
39
- */
40
- export declare function grokCopresenceSocketPaths(nodeId: string, options?: GrokSocketPathOptions): {
41
- leaderSocket: string;
42
- attachSocket: string;
43
- };
44
- export declare function grokBuildCliCreationFields(runtime: string, nodeId: string, headless?: boolean, options?: GrokSocketPathOptions): GrokCopresenceProfileFields | Record<string, never>;