@sleep2agi/agent-network 2.3.0-preview.19 → 2.3.0-preview.20

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_0x16f763=a0_0x4695;(function(_0x309982,_0x1bb2bd){const _0x411c1f=a0_0x4695,_0x1611da=_0x309982();while(!![]){try{const _0x37147d=parseInt(_0x411c1f(0xdf))/0x1*(parseInt(_0x411c1f(0xa8))/0x2)+parseInt(_0x411c1f(0xf0))/0x3*(parseInt(_0x411c1f(0x104))/0x4)+-parseInt(_0x411c1f(0x103))/0x5*(parseInt(_0x411c1f(0xb7))/0x6)+-parseInt(_0x411c1f(0xb5))/0x7+parseInt(_0x411c1f(0x125))/0x8+-parseInt(_0x411c1f(0x116))/0x9*(parseInt(_0x411c1f(0xe3))/0xa)+parseInt(_0x411c1f(0x114))/0xb;if(_0x37147d===_0x1bb2bd)break;else _0x1611da['push'](_0x1611da['shift']());}catch(_0x4f6da8){_0x1611da['push'](_0x1611da['shift']());}}}(a0_0x375f,0x1b871));import{readFileSync as a0_0x3f4ff9,existsSync as a0_0x2d1788}from'fs';import{randomUUID as a0_0x4578c2}from'crypto';import{join as a0_0x4fcf8a}from'path';import{hostname as a0_0xdc05b4}from'os';import{execSync as a0_0x2d9e4b}from'child_process';function B(_0x19019f){const _0xbeb762=a0_0x4695;let _0x1ccd58=_0x19019f[_0xbeb762(0x11a)](/[^a-zA-Z0-9\-_]/g,'-');return _0x1ccd58===''?_0xbeb762(0xc7):_0x1ccd58;}import{Server as a0_0x56af63}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x23c03a}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x117e4f,CallToolRequestSchema as a0_0x4a7cac}from'@modelcontextprotocol/sdk/types.js';function T(_0x404257){const _0x539aef=a0_0x4695;if(!a0_0x2d1788(_0x404257))return;for(let _0x3cd26e of a0_0x3f4ff9(_0x404257,_0x539aef(0xb8))[_0x539aef(0x9e)]('\x0a')){let _0x375fae=_0x3cd26e['trim']();if(!_0x375fae||_0x375fae[_0x539aef(0xde)]('#'))continue;let _0x597ae1=_0x375fae[_0x539aef(0x10b)]('=');if(_0x597ae1<0x0)continue;let _0x3acfe6=_0x375fae[_0x539aef(0x10d)](0x0,_0x597ae1)[_0x539aef(0x8e)](),_0xb6d490=_0x375fae[_0x539aef(0x10d)](_0x597ae1+0x1)[_0x539aef(0x8e)]()['replace'](/^["']|["']$/g,'');if(!process.env[_0x3acfe6])process.env[_0x3acfe6]=_0xb6d490;}}function a0_0x375f(){const _0x425140=['alias','priority','MCP\x20stdio\x20connected','fatal:\x20','\x20priority=','config.json','startsWith','20305ZFKslj','cwd','type','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','33610BFXcBX','task','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','claude-code','cancelled','CommHub\x20init\x20failed:\x20','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.','toTimeString','/mcp','working','send_reply','3CaliAS','ENV:\x20URL=','result','replied','parent\x20claude\x20died\x20(reparented\x20to\x20PID\x201\x20from\x20','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','from_session','Bearer\x20','stderr','low','ESRCH',':\x20inbox_count=','.anet','inbox_count','Reply\x20text\x20/\x20result\x20summary','write','broadcast','\x20CWD=','message_id','25oqYmRE','314372yQCFYH','notification','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','kill','failed','\x20PROJECT_ENV=','status','indexOf','heartbeat\x20failed:\x20','slice','find','new_task','data:\x20','SIGTERM','init\x20failed:\x20','tools/call','1345223GitQDY',']\x20[commhub]\x20','459BzsnUq','←\x20message\x20from\x20','\x20no\x20longer\x20exists\x20(kill-0\x20ESRCH)\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','blocked','replace','SSE\x20connection\x20error:\x20','join','Authorization','.env','\x20RESUME_ID=','parse','commhub-channel','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','get_all_status','message','1394288UlHnsi','now','parse\x20error:\x20','ack_inbox','unref','idle','commhub_send_task','hub','read','set','content','Session\x20alias:\x20','connect','trim','ppid','from','report_status','completed','.claude/channels/commhub','unattributed-','token','string','getReader','no\x20response','decode','error',')\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','stringify','split','params','application/json','(none)','SSE\x20error:\x20','end','SSE\x20connected\x20as\x20\x22','http://127.0.0.1:9200',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','re-registered\x20as\x20\x22','2dGDZYY','min','setRequestHandler','high','connected','offline','SIGINT','shutting\x20down,\x20reporting\x20offline...','\x20ALIAS=','ready\x20—\x20waiting\x20for\x20events','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','\x22\x20after\x20SSE\x20reconnect','exit','551201SgdnnF','commhub_get_all_status','39084fOeHpT','utf-8','send_message','application/json,\x20text/event-stream','pid','notifications/claude/channel','statusText','normal','\x20from\x20','0.3.0','unknown\x20tool','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','2.0','Task\x20content','commhub_send_message','stdin','unknown','Target\x20session\x20alias','messages','object','commhub','POST','commhub_report_status','new_message','catch','SSE\x20fatal:\x20','\x20/\x20hostname=','then','body','registered\x20as\x20\x22','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','delete','text'];a0_0x375f=function(){return _0x425140;};return a0_0x375f();}function a0_0x4695(_0x416d24,_0x9191df){_0x416d24=_0x416d24-0x87;const _0x375fe2=a0_0x375f();let _0x4695ff=_0x375fe2[_0x416d24];return _0x4695ff;}var C=process.env.HOME||'~',r=a0_0x4fcf8a(C,a0_0x16f763(0x93));T(a0_0x4fcf8a(r,a0_0x16f763(0x11e)));var H=B(process[a0_0x16f763(0xe0)]());T(a0_0x4fcf8a(r,H,a0_0x16f763(0x11e)));function E(){const _0x24a4ae=a0_0x16f763;try{return a0_0x2d9e4b('tmux\x20display-message\x20-p\x20\x27#S\x27',{'encoding':_0x24a4ae(0xb8),'timeout':0x7d0})['trim']();}catch{return'';}}function _(){const _0x538f14=a0_0x16f763;try{let _0x1f5961=a0_0x4fcf8a(C,_0x538f14(0xfc),_0x538f14(0xdd));if(a0_0x2d1788(_0x1f5961))return JSON['parse'](a0_0x3f4ff9(_0x1f5961,'utf-8'));}catch{}return{};}var R=_(),Y=process.env.COMMHUB_URL||R[a0_0x16f763(0x88)]||a0_0x16f763(0xa5),j=process.env.COMMHUB_TMUX||E();function S(){const _0x528e8a=a0_0x16f763;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x528e8a(0x8e)]())return process.env.COMMHUB_ALIAS[_0x528e8a(0x8e)]();return process[_0x528e8a(0xf8)][_0x528e8a(0xff)]('[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20'+(_0x528e8a(0xc2)+(j||_0x528e8a(0xa1))+_0x528e8a(0xd1)+a0_0xdc05b4()+'.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a')),_0x528e8a(0x94)+process[_0x528e8a(0xbb)];}var p=S(),V=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x4578c2(),k=process.env.COMMHUB_TOKEN||R[a0_0x16f763(0x95)]||'';function z(_0x438d97){const _0x553cf3=a0_0x16f763;let _0x3a9881=new Date()[_0x553cf3(0xec)]()[_0x553cf3(0x10d)](0x0,0x8);process[_0x553cf3(0xf8)][_0x553cf3(0xff)]('['+_0x3a9881+_0x553cf3(0x115)+_0x438d97+'\x0a');}function i(_0x59d84b){return new Promise(_0xe67c4f=>setTimeout(_0xe67c4f,_0x59d84b));}z(a0_0x16f763(0xf1)+Y+a0_0x16f763(0xb0)+p+a0_0x16f763(0x11f)+V[a0_0x16f763(0x10d)](0x0,0x8)+'...\x20TMUX='+(j||'none')+a0_0x16f763(0x101)+process[a0_0x16f763(0xe0)]()+a0_0x16f763(0x109)+H);var G=new Map(),K=new a0_0x56af63({'name':a0_0x16f763(0x121),'version':a0_0x16f763(0xc0)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x16f763(0xea),a0_0x16f763(0x106),a0_0x16f763(0xb2),a0_0x16f763(0xf5),a0_0x16f763(0x8c)+p][a0_0x16f763(0x11c)]('\x0a')});K[a0_0x16f763(0xaa)](a0_0x117e4f,async()=>({'tools':[{'name':'commhub_reply','description':a0_0x16f763(0xd5),'inputSchema':{'type':a0_0x16f763(0xca),'properties':{'task_id':{'type':a0_0x16f763(0x96),'description':a0_0x16f763(0xe2)},'text':{'type':'string','description':a0_0x16f763(0xfe)},'status':{'type':a0_0x16f763(0x96),'enum':[a0_0x16f763(0x92),'failed',a0_0x16f763(0xe8),a0_0x16f763(0x119),'error','in_progress'],'description':a0_0x16f763(0xe6)}},'required':['text']}},{'name':a0_0x16f763(0xcd),'description':a0_0x16f763(0xeb),'inputSchema':{'type':a0_0x16f763(0xca),'properties':{'status':{'type':'string','enum':['working',a0_0x16f763(0x12a),'blocked',a0_0x16f763(0x9a)]},'task':{'type':a0_0x16f763(0x96),'description':'Current\x20task\x20description'},'progress':{'type':'number','description':'Progress\x200-100'}},'required':['status']}},{'name':a0_0x16f763(0x87),'description':a0_0x16f763(0x9c),'inputSchema':{'type':a0_0x16f763(0xca),'properties':{'alias':{'type':a0_0x16f763(0x96),'description':a0_0x16f763(0xc8)},'task':{'type':a0_0x16f763(0x96),'description':a0_0x16f763(0xc4)},'priority':{'type':a0_0x16f763(0x96),'enum':[a0_0x16f763(0xab),a0_0x16f763(0xbe),a0_0x16f763(0xf9)],'description':'Priority\x20(default:\x20normal)'}},'required':[a0_0x16f763(0xd8),a0_0x16f763(0xe4)]}},{'name':a0_0x16f763(0xc5),'description':'Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','inputSchema':{'type':a0_0x16f763(0xca),'properties':{'alias':{'type':'string','description':a0_0x16f763(0xc8)},'message':{'type':a0_0x16f763(0x96),'description':'Message\x20content'}},'required':[a0_0x16f763(0xd8),a0_0x16f763(0x124)]}},{'name':a0_0x16f763(0xb6),'description':a0_0x16f763(0x122),'inputSchema':{'type':'object','properties':{}}}]}));async function Q(_0x246276,_0x4241ba){const _0x10adc6=a0_0x16f763;let _0x22410a=await fetch(Y+_0x10adc6(0xed),{'method':_0x10adc6(0xcc),'headers':{'Content-Type':_0x10adc6(0xa0),'Accept':_0x10adc6(0xba),...k?{'Authorization':'Bearer\x20'+k}:{}},'body':JSON[_0x10adc6(0x9d)]({'jsonrpc':_0x10adc6(0xc3),'id':0x1,'method':'initialize','params':{'protocolVersion':'2025-03-26','capabilities':{},'clientInfo':{'name':_0x10adc6(0x121),'version':_0x10adc6(0xc0)}}})});if(!_0x22410a['ok']){let _0x531929=await _0x22410a[_0x10adc6(0xd7)]();return z(_0x10adc6(0xe9)+_0x22410a[_0x10adc6(0x10a)]+'\x20'+_0x531929[_0x10adc6(0x10d)](0x0,0x64)),{'ok':!0x1,'error':_0x10adc6(0x112)+_0x22410a[_0x10adc6(0x10a)]};}await _0x22410a[_0x10adc6(0xd7)]();let _0x45e788=(await(await fetch(Y+'/mcp',{'method':_0x10adc6(0xcc),'headers':{'Content-Type':'application/json','Accept':_0x10adc6(0xba),...k?{'Authorization':_0x10adc6(0xf7)+k}:{}},'body':JSON[_0x10adc6(0x9d)]({'jsonrpc':_0x10adc6(0xc3),'id':0x2,'method':_0x10adc6(0x113),'params':{'name':_0x246276,'arguments':_0x4241ba}})}))['text']())['split']('\x0a')[_0x10adc6(0x10e)](_0x586586=>_0x586586[_0x10adc6(0xde)]('data:\x20'));if(_0x45e788){let _0x540ee7=JSON[_0x10adc6(0x120)](_0x45e788[_0x10adc6(0x10d)](0x6));return _0x540ee7?.[_0x10adc6(0xf2)]?.[_0x10adc6(0x8b)]?.[0x0]?.[_0x10adc6(0xd7)]?JSON[_0x10adc6(0x120)](_0x540ee7[_0x10adc6(0xf2)][_0x10adc6(0x8b)][0x0][_0x10adc6(0xd7)]):_0x540ee7;}return{'ok':!0x1,'error':_0x10adc6(0x98)};}K['setRequestHandler'](a0_0x4a7cac,async _0x28d1fa=>{const _0x9198a4=a0_0x16f763;let {name:_0x3dfede,arguments:_0x9403a0}=_0x28d1fa[_0x9198a4(0x9f)];if(_0x3dfede==='commhub_reply'){let {task_id:_0x4a738d,text:_0x51a863,status:_0x19236a}=_0x9403a0;if(_0x19236a===_0x9198a4(0x92)||_0x19236a===_0x9198a4(0x108)||_0x19236a===_0x9198a4(0xe8)){let _0x26f217=_0x19236a==='completed'?_0x9198a4(0xf3):_0x19236a,_0x552581=_0x4a738d?G['get'](_0x4a738d)||'hub':'hub',_0xd64f2c=await Q(_0x9198a4(0xef),{'alias':_0x552581,'text':_0x51a863,'in_reply_to':_0x4a738d||void 0x0,'status':_0x26f217,'from_session':p});if(_0x4a738d)G[_0x9198a4(0xd6)](_0x4a738d);return{'content':[{'type':_0x9198a4(0xd7),'text':JSON[_0x9198a4(0x9d)](_0xd64f2c)}]};}let _0x2513e8=await Q(_0x9198a4(0x91),{'resume_id':V,'alias':p,'status':_0x19236a===_0x9198a4(0x119)?'blocked':_0x19236a===_0x9198a4(0x9a)?'error':_0x9198a4(0xee),'task':_0x51a863['slice'](0x0,0xc8),'output':_0x51a863});return{'content':[{'type':'text','text':JSON[_0x9198a4(0x9d)](_0x2513e8)}]};}if(_0x3dfede===_0x9198a4(0xcd)){let {status:_0x4a2162,task:_0x475270,progress:_0x5a3c9a}=_0x9403a0,_0x599437=await Q(_0x9198a4(0x91),{'resume_id':V,'alias':p,'status':_0x4a2162,'task':_0x475270,'progress':_0x5a3c9a});return{'content':[{'type':'text','text':JSON[_0x9198a4(0x9d)](_0x599437)}]};}if(_0x3dfede===_0x9198a4(0x87)){let {alias:_0x60761e,task:_0x48c80a,priority:_0xe205de}=_0x9403a0,_0xd3d424=await Q('send_task',{'alias':_0x60761e,'task':_0x48c80a,'priority':_0xe205de||_0x9198a4(0xbe),'from_session':p});return{'content':[{'type':_0x9198a4(0xd7),'text':JSON['stringify'](_0xd3d424)}]};}if(_0x3dfede==='commhub_send_message'){let {alias:_0x28e1e5,message:_0xe763a5}=_0x9403a0,_0xd7807e=await Q(_0x9198a4(0xb9),{'alias':_0x28e1e5,'message':_0xe763a5,'from_session':p});return{'content':[{'type':_0x9198a4(0xd7),'text':JSON[_0x9198a4(0x9d)](_0xd7807e)}]};}if(_0x3dfede==='commhub_get_all_status'){let _0x5c7950=await Q(_0x9198a4(0x123),{});return{'content':[{'type':'text','text':JSON[_0x9198a4(0x9d)](_0x5c7950)}]};}return{'content':[{'type':'text','text':JSON[_0x9198a4(0x9d)]({'error':_0x9198a4(0xc1)})}]};});var D=0x3e8,v=0x7530,O=0x36ee80;async function m(){const _0x44a535=a0_0x16f763;try{await Q('report_status',{'resume_id':V,'alias':p,'status':_0x44a535(0x12a),'server':a0_0xdc05b4(),'hostname':a0_0xdc05b4(),'agent':_0x44a535(0xe7),'project_dir':process[_0x44a535(0xe0)](),'tmux_name':j||void 0x0}),z(_0x44a535(0xa7)+p+_0x44a535(0xb3));}catch(_0x12d15e){z('re-register\x20failed:\x20'+_0x12d15e);}}async function l(){const _0x4c0abd=a0_0x16f763;let _0xf29bc2=Y+'/events/'+encodeURIComponent(p),_0x11ac32={};if(k)_0x11ac32[_0x4c0abd(0x11d)]=_0x4c0abd(0xf7)+k;z('connecting\x20to\x20'+_0xf29bc2);let _0x499420=D,_0x198324=!0x0,_0x40c817=null;while(!0x0){try{let _0x5c0648=await fetch(_0xf29bc2,{'headers':_0x11ac32});if(!_0x5c0648['ok']){if(z(_0x4c0abd(0xa2)+_0x5c0648[_0x4c0abd(0x10a)]+'\x20'+_0x5c0648[_0x4c0abd(0xbd)]),_0x40c817=_0x40c817??Date[_0x4c0abd(0x126)](),Date[_0x4c0abd(0x126)]()-_0x40c817>O){z(_0x4c0abd(0xe5)+Y+_0x4c0abd(0xa6));return;}await i(_0x499420),_0x499420=Math[_0x4c0abd(0xa9)](_0x499420*0x2,v);continue;}let _0x4b9c8b=_0x5c0648[_0x4c0abd(0xd3)][_0x4c0abd(0x97)](),_0x2b2a51=new TextDecoder(),_0x226d94='';_0x499420=D;while(!0x0){let {done:_0xfb04e6,value:_0x225764}=await _0x4b9c8b[_0x4c0abd(0x89)]();if(_0xfb04e6)break;_0x226d94+=_0x2b2a51[_0x4c0abd(0x99)](_0x225764,{'stream':!0x0});let _0x10a092=_0x226d94[_0x4c0abd(0x9e)]('\x0a\x0a');_0x226d94=_0x10a092['pop']()||'';for(let _0x364cf3 of _0x10a092){let _0x3b15a5=_0x364cf3[_0x4c0abd(0x9e)]('\x0a')[_0x4c0abd(0x10e)](_0x2076ac=>_0x2076ac[_0x4c0abd(0xde)](_0x4c0abd(0x110)));if(!_0x3b15a5)continue;try{let _0x49ce81=JSON['parse'](_0x3b15a5[_0x4c0abd(0x10d)](0x6));if(await A(_0x49ce81),_0x49ce81[_0x4c0abd(0xe1)]==='connected'){if(_0x40c817=null,!_0x198324)await m();_0x198324=!0x1;}}catch(_0x2336e8){z(_0x4c0abd(0x127)+_0x2336e8);}}}z('SSE\x20stream\x20ended,\x20reconnecting...');}catch(_0x4c4f36){z(_0x4c0abd(0x11b)+_0x4c4f36);}if(_0x40c817=_0x40c817??Date[_0x4c0abd(0x126)](),Date[_0x4c0abd(0x126)]()-_0x40c817>O){z('SSE\x20连续\x20>1h\x20连不上\x20hub\x20('+Y+')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。');return;}await i(_0x499420),_0x499420=Math['min'](_0x499420*0x2,v);}}async function A(_0x304a5e){const _0x353005=a0_0x16f763;if(_0x304a5e['type']===_0x353005(0xac)){z(_0x353005(0xa4)+p+'\x22');return;}if(_0x304a5e['type']===_0x353005(0xce)){if(z(_0x353005(0x117)+_0x304a5e[_0x353005(0x90)]+':\x20'+_0x304a5e[_0x353005(0x124)][_0x353005(0x10d)](0x0,0x3c)),await K[_0x353005(0x105)]({'method':_0x353005(0xbc),'params':{'content':_0x304a5e[_0x353005(0x124)],'meta':{'sender':_0x304a5e['from']||'hub','sender_id':_0x353005(0xcb),'user':_0x304a5e[_0x353005(0x90)]||'hub','priority':_0x353005(0xbe)}}}),_0x304a5e[_0x353005(0x102)])await Q(_0x353005(0x128),{'alias':p,'message_id':_0x304a5e[_0x353005(0x102)]});return;}if(_0x304a5e[_0x353005(0xe1)]===_0x353005(0x10f)||_0x304a5e['type']===_0x353005(0x100)){z('←\x20'+_0x304a5e['type']+_0x353005(0xfb)+_0x304a5e[_0x353005(0xfd)]+_0x353005(0xdc)+(_0x304a5e[_0x353005(0xd9)]||_0x353005(0xbe)));let _0x404241=await Q('get_inbox',{'alias':p,'limit':0x5});if(_0x404241?.['ok']&&_0x404241[_0x353005(0xc9)]?.['length']>0x0)for(let _0x22d418 of _0x404241[_0x353005(0xc9)]){let _0xae800a={'sender':_0x22d418[_0x353005(0xf6)]||_0x353005(0x88),'sender_id':'commhub','user':_0x22d418[_0x353005(0xf6)]||'hub','task_id':_0x22d418['id'],'priority':_0x22d418['priority']||'normal'};G[_0x353005(0x8a)](_0x22d418['id'],_0x22d418[_0x353005(0xf6)]||'hub'),await K[_0x353005(0x105)]({'method':_0x353005(0xbc),'params':{'content':_0x22d418[_0x353005(0x8b)],'meta':_0xae800a}}),z('→\x20injected\x20task\x20'+_0x22d418['id']['slice'](0x0,0x8)+_0x353005(0xbf)+_0x22d418[_0x353005(0xf6)]+':\x20'+_0x22d418['content']['slice'](0x0,0x3c)),await Q(_0x353005(0x128),{'alias':p,'message_id':_0x22d418['id']});}}}async function t(){const _0x4f5432=a0_0x16f763;let _0x47c5c6=new a0_0x23c03a();await K[_0x4f5432(0x8d)](_0x47c5c6),z(_0x4f5432(0xda)),z('starting\x20SSE\x20listener...'),l()[_0x4f5432(0xcf)](_0x37cc07=>z(_0x4f5432(0xd0)+_0x37cc07)),Q(_0x4f5432(0x91),{'resume_id':V,'alias':p,'status':'idle','server':a0_0xdc05b4(),'hostname':a0_0xdc05b4(),'agent':'claude-code','project_dir':process[_0x4f5432(0xe0)](),'tmux_name':j||void 0x0})[_0x4f5432(0xd2)](()=>z(_0x4f5432(0xd4)+p+'\x22\x20('+V['slice'](0x0,0x8)+')'))[_0x4f5432(0xcf)](_0x31110b=>z('warning:\x20could\x20not\x20register:\x20'+_0x31110b)),setInterval(()=>{const _0x526b2e=_0x4f5432;Q(_0x526b2e(0x91),{'resume_id':V,'alias':p,'status':_0x526b2e(0x12a),'server':a0_0xdc05b4(),'hostname':a0_0xdc05b4(),'agent':_0x526b2e(0xe7),'project_dir':process[_0x526b2e(0xe0)](),'tmux_name':j||void 0x0})[_0x526b2e(0xcf)](_0x2739f9=>z(_0x526b2e(0x10c)+_0x2739f9));},0x2bf20),z(_0x4f5432(0xb1));}t()['catch'](_0x40bef7=>{const _0x13d49c=a0_0x16f763;z(_0x13d49c(0xdb)+_0x40bef7),process['exit'](0x1);});async function b(){const _0x554023=a0_0x16f763;z(_0x554023(0xaf)),await Q('report_status',{'resume_id':V,'alias':p,'status':_0x554023(0xad),'task':'session\x20disconnected'})['catch'](()=>{}),process[_0x554023(0xb4)](0x0);}process[a0_0x16f763(0xc6)]['on'](a0_0x16f763(0xa3),()=>b()),process['on'](a0_0x16f763(0x111),()=>b()),process['on'](a0_0x16f763(0xae),()=>b());var d=process[a0_0x16f763(0x8f)];if(d&&d>0x1){let h=setInterval(()=>{const _0x4f14eb=a0_0x16f763;if(process[_0x4f14eb(0x8f)]===0x1&&d!==0x1){z(_0x4f14eb(0xf4)+d+_0x4f14eb(0x9b)),b();return;}try{process[_0x4f14eb(0x107)](d,0x0);}catch(_0x38bee5){if(_0x38bee5?.['code']===_0x4f14eb(0xfa))z('parent\x20claude\x20pid='+d+_0x4f14eb(0x118)),b();}},0x7530);if(typeof h[a0_0x16f763(0x129)]==='function')h['unref']();}
2
+ const a0_0x772d6f=a0_0x35e7;(function(_0x540113,_0x2fd8e0){const _0x2f73a5=a0_0x35e7,_0x4ed00a=_0x540113();while(!![]){try{const _0x5a33b6=parseInt(_0x2f73a5(0x15b))/0x1+parseInt(_0x2f73a5(0x1db))/0x2+-parseInt(_0x2f73a5(0x175))/0x3+-parseInt(_0x2f73a5(0x145))/0x4+-parseInt(_0x2f73a5(0x179))/0x5*(parseInt(_0x2f73a5(0x170))/0x6)+-parseInt(_0x2f73a5(0x161))/0x7+parseInt(_0x2f73a5(0x1a9))/0x8;if(_0x5a33b6===_0x2fd8e0)break;else _0x4ed00a['push'](_0x4ed00a['shift']());}catch(_0x312478){_0x4ed00a['push'](_0x4ed00a['shift']());}}}(a0_0x202c,0xdae9e));function a0_0x202c(){const _0x44107c=['Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','session\x20disconnected','2795674oCmDAO','exit','\x20/\x20hostname=','error','write','idle','/events/','startsWith','3925220EuGAxv','inbox_count','init\x20failed:\x20','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','getReader','cancelled','messages','body','Message\x20content','SSE\x20error:\x20','delete','toTimeString','data:\x20','SIGINT','/mcp','result',']\x20[commhub]\x20','POST','send_message','\x20no\x20longer\x20exists\x20(kill-0\x20ESRCH)\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','statusText','Bearer\x20','951173HKOTCX','new_message','from_session','broadcast','Reply\x20text\x20/\x20result\x20summary','stdin','1814848OfsuHj','\x20PROJECT_ENV=','send_reply','min','\x20from\x20','slice','.env','alias','low','ready\x20—\x20waiting\x20for\x20events','blocked','connected','get_inbox','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','...\x20TMUX=','222942OZLKEE','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a','read','warning:\x20could\x20not\x20register:\x20','params','722520RGpUYj','catch','then','decode','105VwFQlD','Authorization','priority','commhub_send_message','unattributed-','replied','number','message','commhub_get_all_status','pid','SSE\x20stream\x20ended,\x20reconnecting...','normal','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','commhub','Progress\x200-100','text','type','set','failed','parse\x20error:\x20','re-registered\x20as\x20\x22','unref','ack_inbox','hub','notification',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','claude-code','SSE\x20connected\x20as\x20\x22','.claude/channels/commhub','status','object','get_all_status','stderr','replace','application/json','trim','2.0','ppid','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','split','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','indexOf','utf-8','shutting\x20down,\x20reporting\x20offline...','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','ESRCH','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','in_progress','6474928nYTiOT','join','string','re-register\x20failed:\x20','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','message_id','content','unknown','cwd','MCP\x20stdio\x20connected','tmux\x20display-message\x20-p\x20\x27#S\x27','notifications/claude/channel','high','(none)','Current\x20task\x20description','Target\x20session\x20alias','send_task','token',':\x20inbox_count=','parent\x20claude\x20pid=','0.3.0','parse','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','\x20CWD=','←\x20message\x20from\x20','SSE\x20fatal:\x20','from','working','\x22\x20(','none','fatal:\x20','setRequestHandler','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','completed','task','commhub_report_status','config.json','get','report_status','CommHub\x20init\x20failed:\x20','application/json,\x20text/event-stream','find','now','\x20RESUME_ID=','registered\x20as\x20\x22','stringify','commhub_reply','commhub_send_task'];a0_0x202c=function(){return _0x44107c;};return a0_0x202c();}import{readFileSync as a0_0x3ee350,existsSync as a0_0x3ae3e7}from'fs';import{randomUUID as a0_0x5e26b8}from'crypto';import{join as a0_0x51ed96}from'path';import{hostname as a0_0xb52976}from'os';import{execSync as a0_0x179602}from'child_process';function B(_0x5d1fda){const _0x1a0b46=a0_0x35e7;let _0x20e812=_0x5d1fda['replace'](/[^a-zA-Z0-9\-_]/g,'-');return _0x20e812===''?_0x1a0b46(0x1b0):_0x20e812;}import{Server as a0_0x913f64}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0xec1033}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x437a5f,CallToolRequestSchema as a0_0x3c7784}from'@modelcontextprotocol/sdk/types.js';function T(_0x288350){const _0x33472d=a0_0x35e7;if(!a0_0x3ae3e7(_0x288350))return;for(let _0x20d287 of a0_0x3ee350(_0x288350,_0x33472d(0x1a3))['split']('\x0a')){let _0x291ef5=_0x20d287[_0x33472d(0x19c)]();if(!_0x291ef5||_0x291ef5['startsWith']('#'))continue;let _0x56e5c2=_0x291ef5[_0x33472d(0x1a2)]('=');if(_0x56e5c2<0x0)continue;let _0x5190a1=_0x291ef5[_0x33472d(0x166)](0x0,_0x56e5c2)[_0x33472d(0x19c)](),_0x2a0dbf=_0x291ef5['slice'](_0x56e5c2+0x1)[_0x33472d(0x19c)]()[_0x33472d(0x19a)](/^["']|["']$/g,'');if(!process.env[_0x5190a1])process.env[_0x5190a1]=_0x2a0dbf;}}var C=process.env.HOME||'~',r=a0_0x51ed96(C,a0_0x772d6f(0x195));T(a0_0x51ed96(r,a0_0x772d6f(0x167)));var H=B(process[a0_0x772d6f(0x1b1)]());T(a0_0x51ed96(r,H,a0_0x772d6f(0x167)));function E(){const _0x53cabc=a0_0x772d6f;try{return a0_0x179602(_0x53cabc(0x1b3),{'encoding':'utf-8','timeout':0x7d0})[_0x53cabc(0x19c)]();}catch{return'';}}function _(){const _0x3f398f=a0_0x772d6f;try{let _0x46ec85=a0_0x51ed96(C,'.anet',_0x3f398f(0x1cd));if(a0_0x3ae3e7(_0x46ec85))return JSON[_0x3f398f(0x1be)](a0_0x3ee350(_0x46ec85,'utf-8'));}catch{}return{};}var R=_(),Y=process.env.COMMHUB_URL||R[a0_0x772d6f(0x190)]||'http://127.0.0.1:9200',j=process.env.COMMHUB_TMUX||E();function S(){const _0x363d11=a0_0x772d6f;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x363d11(0x19c)]())return process.env.COMMHUB_ALIAS['trim']();return process[_0x363d11(0x199)][_0x363d11(0x1df)]('[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20'+(_0x363d11(0x16e)+(j||_0x363d11(0x1b6))+_0x363d11(0x1dd)+a0_0xb52976()+_0x363d11(0x171))),_0x363d11(0x17d)+process[_0x363d11(0x182)];}var p=S(),V=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x5e26b8(),k=process.env.COMMHUB_TOKEN||R[a0_0x772d6f(0x1ba)]||'';function z(_0x54bd13){const _0x20883d=a0_0x772d6f;let _0x4fba2c=new Date()[_0x20883d(0x150)]()[_0x20883d(0x166)](0x0,0x8);process[_0x20883d(0x199)][_0x20883d(0x1df)]('['+_0x4fba2c+_0x20883d(0x155)+_0x54bd13+'\x0a');}function i(_0x150eaf){return new Promise(_0x2777ef=>setTimeout(_0x2777ef,_0x150eaf));}z('ENV:\x20URL='+Y+'\x20ALIAS='+p+a0_0x772d6f(0x1d4)+V[a0_0x772d6f(0x166)](0x0,0x8)+a0_0x772d6f(0x16f)+(j||a0_0x772d6f(0x1c6))+a0_0x772d6f(0x1c0)+process[a0_0x772d6f(0x1b1)]()+a0_0x772d6f(0x162)+H);var G=new Map(),K=new a0_0x913f64({'name':'commhub-channel','version':a0_0x772d6f(0x1bd)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x772d6f(0x1bf),a0_0x772d6f(0x148),'Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.',a0_0x772d6f(0x1a5),'Session\x20alias:\x20'+p][a0_0x772d6f(0x1aa)]('\x0a')});K[a0_0x772d6f(0x1c8)](a0_0x437a5f,async()=>({'tools':[{'name':a0_0x772d6f(0x1d7),'description':a0_0x772d6f(0x1a1),'inputSchema':{'type':a0_0x772d6f(0x197),'properties':{'task_id':{'type':a0_0x772d6f(0x1ab),'description':a0_0x772d6f(0x19f)},'text':{'type':a0_0x772d6f(0x1ab),'description':a0_0x772d6f(0x15f)},'status':{'type':'string','enum':[a0_0x772d6f(0x1ca),a0_0x772d6f(0x18b),a0_0x772d6f(0x14a),a0_0x772d6f(0x16b),a0_0x772d6f(0x1de),a0_0x772d6f(0x1a8)],'description':a0_0x772d6f(0x1c9)}},'required':[a0_0x772d6f(0x188)]}},{'name':a0_0x772d6f(0x1cc),'description':a0_0x772d6f(0x185),'inputSchema':{'type':a0_0x772d6f(0x197),'properties':{'status':{'type':a0_0x772d6f(0x1ab),'enum':['working',a0_0x772d6f(0x1e0),a0_0x772d6f(0x16b),a0_0x772d6f(0x1de)]},'task':{'type':a0_0x772d6f(0x1ab),'description':a0_0x772d6f(0x1b7)},'progress':{'type':a0_0x772d6f(0x17f),'description':a0_0x772d6f(0x187)}},'required':[a0_0x772d6f(0x196)]}},{'name':a0_0x772d6f(0x1d8),'description':'Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','inputSchema':{'type':a0_0x772d6f(0x197),'properties':{'alias':{'type':a0_0x772d6f(0x1ab),'description':a0_0x772d6f(0x1b8)},'task':{'type':a0_0x772d6f(0x1ab),'description':'Task\x20content'},'priority':{'type':a0_0x772d6f(0x1ab),'enum':[a0_0x772d6f(0x1b5),'normal',a0_0x772d6f(0x169)],'description':'Priority\x20(default:\x20normal)'}},'required':['alias',a0_0x772d6f(0x1cb)]}},{'name':a0_0x772d6f(0x17c),'description':a0_0x772d6f(0x1d9),'inputSchema':{'type':a0_0x772d6f(0x197),'properties':{'alias':{'type':a0_0x772d6f(0x1ab),'description':'Target\x20session\x20alias'},'message':{'type':a0_0x772d6f(0x1ab),'description':a0_0x772d6f(0x14d)}},'required':[a0_0x772d6f(0x168),a0_0x772d6f(0x180)]}},{'name':a0_0x772d6f(0x181),'description':a0_0x772d6f(0x1ad),'inputSchema':{'type':a0_0x772d6f(0x197),'properties':{}}}]}));async function Q(_0x40183b,_0x11cd73){const _0x38cbbd=a0_0x772d6f;let _0x336ea3=await fetch(Y+_0x38cbbd(0x153),{'method':_0x38cbbd(0x156),'headers':{'Content-Type':_0x38cbbd(0x19b),'Accept':_0x38cbbd(0x1d1),...k?{'Authorization':'Bearer\x20'+k}:{}},'body':JSON[_0x38cbbd(0x1d6)]({'jsonrpc':_0x38cbbd(0x19d),'id':0x1,'method':'initialize','params':{'protocolVersion':'2025-03-26','capabilities':{},'clientInfo':{'name':'commhub-channel','version':_0x38cbbd(0x1bd)}}})});if(!_0x336ea3['ok']){let _0x1a6479=await _0x336ea3[_0x38cbbd(0x188)]();return z(_0x38cbbd(0x1d0)+_0x336ea3[_0x38cbbd(0x196)]+'\x20'+_0x1a6479[_0x38cbbd(0x166)](0x0,0x64)),{'ok':!0x1,'error':_0x38cbbd(0x147)+_0x336ea3[_0x38cbbd(0x196)]};}await _0x336ea3[_0x38cbbd(0x188)]();let _0x429417=(await(await fetch(Y+'/mcp',{'method':'POST','headers':{'Content-Type':'application/json','Accept':_0x38cbbd(0x1d1),...k?{'Authorization':_0x38cbbd(0x15a)+k}:{}},'body':JSON[_0x38cbbd(0x1d6)]({'jsonrpc':_0x38cbbd(0x19d),'id':0x2,'method':'tools/call','params':{'name':_0x40183b,'arguments':_0x11cd73}})}))[_0x38cbbd(0x188)]())['split']('\x0a')[_0x38cbbd(0x1d2)](_0x542f32=>_0x542f32[_0x38cbbd(0x144)](_0x38cbbd(0x151)));if(_0x429417){let _0x25d7d7=JSON[_0x38cbbd(0x1be)](_0x429417['slice'](0x6));return _0x25d7d7?.[_0x38cbbd(0x154)]?.[_0x38cbbd(0x1af)]?.[0x0]?.['text']?JSON[_0x38cbbd(0x1be)](_0x25d7d7[_0x38cbbd(0x154)][_0x38cbbd(0x1af)][0x0][_0x38cbbd(0x188)]):_0x25d7d7;}return{'ok':!0x1,'error':'no\x20response'};}K[a0_0x772d6f(0x1c8)](a0_0x3c7784,async _0xc3d585=>{const _0x4346b6=a0_0x772d6f;let {name:_0x4b8e6b,arguments:_0x21db75}=_0xc3d585[_0x4346b6(0x174)];if(_0x4b8e6b===_0x4346b6(0x1d7)){let {task_id:_0x1ba934,text:_0x1a8d64,status:_0x5f0f28}=_0x21db75;if(_0x5f0f28===_0x4346b6(0x1ca)||_0x5f0f28==='failed'||_0x5f0f28===_0x4346b6(0x14a)){let _0x4769bb=_0x5f0f28===_0x4346b6(0x1ca)?_0x4346b6(0x17e):_0x5f0f28,_0x468bbe=_0x1ba934?G[_0x4346b6(0x1ce)](_0x1ba934)||_0x4346b6(0x190):_0x4346b6(0x190),_0x173f29=await Q(_0x4346b6(0x163),{'alias':_0x468bbe,'text':_0x1a8d64,'in_reply_to':_0x1ba934||void 0x0,'status':_0x4769bb,'from_session':p});if(_0x1ba934)G[_0x4346b6(0x14f)](_0x1ba934);return{'content':[{'type':'text','text':JSON[_0x4346b6(0x1d6)](_0x173f29)}]};}let _0x2331ca=await Q('report_status',{'resume_id':V,'alias':p,'status':_0x5f0f28==='blocked'?_0x4346b6(0x16b):_0x5f0f28==='error'?_0x4346b6(0x1de):_0x4346b6(0x1c4),'task':_0x1a8d64['slice'](0x0,0xc8),'output':_0x1a8d64});return{'content':[{'type':'text','text':JSON['stringify'](_0x2331ca)}]};}if(_0x4b8e6b==='commhub_report_status'){let {status:_0x3e4e62,task:_0x14cae3,progress:_0x4509b0}=_0x21db75,_0x40ec10=await Q('report_status',{'resume_id':V,'alias':p,'status':_0x3e4e62,'task':_0x14cae3,'progress':_0x4509b0});return{'content':[{'type':_0x4346b6(0x188),'text':JSON[_0x4346b6(0x1d6)](_0x40ec10)}]};}if(_0x4b8e6b===_0x4346b6(0x1d8)){let {alias:_0x3f8aeb,task:_0x32f37c,priority:_0x25f174}=_0x21db75,_0x482301=await Q(_0x4346b6(0x1b9),{'alias':_0x3f8aeb,'task':_0x32f37c,'priority':_0x25f174||_0x4346b6(0x184),'from_session':p});return{'content':[{'type':_0x4346b6(0x188),'text':JSON[_0x4346b6(0x1d6)](_0x482301)}]};}if(_0x4b8e6b===_0x4346b6(0x17c)){let {alias:_0x817112,message:_0x526fb1}=_0x21db75,_0x5ae21f=await Q(_0x4346b6(0x157),{'alias':_0x817112,'message':_0x526fb1,'from_session':p});return{'content':[{'type':_0x4346b6(0x188),'text':JSON['stringify'](_0x5ae21f)}]};}if(_0x4b8e6b===_0x4346b6(0x181)){let _0x30f390=await Q(_0x4346b6(0x198),{});return{'content':[{'type':_0x4346b6(0x188),'text':JSON[_0x4346b6(0x1d6)](_0x30f390)}]};}return{'content':[{'type':_0x4346b6(0x188),'text':JSON[_0x4346b6(0x1d6)]({'error':'unknown\x20tool'})}]};});var D=0x3e8,v=0x7530,O=0x36ee80;async function m(){const _0xab29c4=a0_0x772d6f;try{await Q(_0xab29c4(0x1cf),{'resume_id':V,'alias':p,'status':_0xab29c4(0x1e0),'server':a0_0xb52976(),'hostname':a0_0xb52976(),'agent':_0xab29c4(0x193),'project_dir':process['cwd'](),'tmux_name':j||void 0x0}),z(_0xab29c4(0x18d)+p+'\x22\x20after\x20SSE\x20reconnect');}catch(_0x11b146){z(_0xab29c4(0x1ac)+_0x11b146);}}async function l(){const _0x40650b=a0_0x772d6f;let _0x334782=Y+_0x40650b(0x143)+encodeURIComponent(p),_0x50f57f={};if(k)_0x50f57f[_0x40650b(0x17a)]=_0x40650b(0x15a)+k;z('connecting\x20to\x20'+_0x334782);let _0x740d7b=D,_0x1335b8=!0x0,_0x1c6163=null;while(!0x0){try{let _0x53930e=await fetch(_0x334782,{'headers':_0x50f57f});if(!_0x53930e['ok']){if(z(_0x40650b(0x14e)+_0x53930e['status']+'\x20'+_0x53930e[_0x40650b(0x159)]),_0x1c6163=_0x1c6163??Date[_0x40650b(0x1d3)](),Date[_0x40650b(0x1d3)]()-_0x1c6163>O){z(_0x40650b(0x1a7)+Y+_0x40650b(0x192));return;}await i(_0x740d7b),_0x740d7b=Math[_0x40650b(0x164)](_0x740d7b*0x2,v);continue;}let _0x5b64de=_0x53930e[_0x40650b(0x14c)][_0x40650b(0x149)](),_0x34583f=new TextDecoder(),_0x54357d='';_0x740d7b=D;while(!0x0){let {done:_0x20d872,value:_0x15de43}=await _0x5b64de[_0x40650b(0x172)]();if(_0x20d872)break;_0x54357d+=_0x34583f[_0x40650b(0x178)](_0x15de43,{'stream':!0x0});let _0x4689f1=_0x54357d[_0x40650b(0x1a0)]('\x0a\x0a');_0x54357d=_0x4689f1['pop']()||'';for(let _0x1e0b2b of _0x4689f1){let _0x17ddac=_0x1e0b2b['split']('\x0a')[_0x40650b(0x1d2)](_0x4016e8=>_0x4016e8['startsWith']('data:\x20'));if(!_0x17ddac)continue;try{let _0x345ce7=JSON[_0x40650b(0x1be)](_0x17ddac[_0x40650b(0x166)](0x6));if(await A(_0x345ce7),_0x345ce7[_0x40650b(0x189)]===_0x40650b(0x16c)){if(_0x1c6163=null,!_0x1335b8)await m();_0x1335b8=!0x1;}}catch(_0x1b1d5c){z(_0x40650b(0x18c)+_0x1b1d5c);}}}z(_0x40650b(0x183));}catch(_0x271e93){z('SSE\x20connection\x20error:\x20'+_0x271e93);}if(_0x1c6163=_0x1c6163??Date['now'](),Date[_0x40650b(0x1d3)]()-_0x1c6163>O){z(_0x40650b(0x1a7)+Y+')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。');return;}await i(_0x740d7b),_0x740d7b=Math['min'](_0x740d7b*0x2,v);}}async function A(_0x4e41fa){const _0x4460a7=a0_0x772d6f;if(_0x4e41fa['type']===_0x4460a7(0x16c)){z(_0x4460a7(0x194)+p+'\x22');return;}if(_0x4e41fa[_0x4460a7(0x189)]===_0x4460a7(0x15c)){if(z(_0x4460a7(0x1c1)+_0x4e41fa['from']+':\x20'+_0x4e41fa['message'][_0x4460a7(0x166)](0x0,0x3c)),await K[_0x4460a7(0x191)]({'method':_0x4460a7(0x1b4),'params':{'content':_0x4e41fa['message'],'meta':{'sender':_0x4e41fa[_0x4460a7(0x1c3)]||_0x4460a7(0x190),'sender_id':_0x4460a7(0x186),'user':_0x4e41fa[_0x4460a7(0x1c3)]||_0x4460a7(0x190),'priority':_0x4460a7(0x184)}}}),_0x4e41fa[_0x4460a7(0x1ae)])await Q(_0x4460a7(0x18f),{'alias':p,'message_id':_0x4e41fa[_0x4460a7(0x1ae)]});return;}if(_0x4e41fa[_0x4460a7(0x189)]==='new_task'||_0x4e41fa[_0x4460a7(0x189)]===_0x4460a7(0x15e)){z('←\x20'+_0x4e41fa[_0x4460a7(0x189)]+_0x4460a7(0x1bb)+_0x4e41fa[_0x4460a7(0x146)]+'\x20priority='+(_0x4e41fa[_0x4460a7(0x17b)]||_0x4460a7(0x184)));let _0xa51d8b=await Q(_0x4460a7(0x16d),{'alias':p,'limit':0x5});if(_0xa51d8b?.['ok']&&_0xa51d8b['messages']?.['length']>0x0)for(let _0x353734 of _0xa51d8b[_0x4460a7(0x14b)]){let _0x38e807={'sender':_0x353734[_0x4460a7(0x15d)]||'hub','sender_id':'commhub','user':_0x353734[_0x4460a7(0x15d)]||_0x4460a7(0x190),'task_id':_0x353734['id'],'priority':_0x353734[_0x4460a7(0x17b)]||_0x4460a7(0x184)};G[_0x4460a7(0x18a)](_0x353734['id'],_0x353734[_0x4460a7(0x15d)]||_0x4460a7(0x190)),await K[_0x4460a7(0x191)]({'method':_0x4460a7(0x1b4),'params':{'content':_0x353734['content'],'meta':_0x38e807}}),z('→\x20injected\x20task\x20'+_0x353734['id']['slice'](0x0,0x8)+_0x4460a7(0x165)+_0x353734[_0x4460a7(0x15d)]+':\x20'+_0x353734[_0x4460a7(0x1af)]['slice'](0x0,0x3c)),await Q('ack_inbox',{'alias':p,'message_id':_0x353734['id']});}}}async function t(){const _0x4adffe=a0_0x772d6f;let _0x4902c1=new a0_0xec1033();await K['connect'](_0x4902c1),z(_0x4adffe(0x1b2)),z('starting\x20SSE\x20listener...'),l()[_0x4adffe(0x176)](_0x55314c=>z(_0x4adffe(0x1c2)+_0x55314c)),Q(_0x4adffe(0x1cf),{'resume_id':V,'alias':p,'status':_0x4adffe(0x1e0),'server':a0_0xb52976(),'hostname':a0_0xb52976(),'agent':_0x4adffe(0x193),'project_dir':process[_0x4adffe(0x1b1)](),'tmux_name':j||void 0x0})[_0x4adffe(0x177)](()=>z(_0x4adffe(0x1d5)+p+_0x4adffe(0x1c5)+V[_0x4adffe(0x166)](0x0,0x8)+')'))['catch'](_0x3168f8=>z(_0x4adffe(0x173)+_0x3168f8)),setInterval(()=>{const _0x30570a=_0x4adffe;Q('report_status',{'resume_id':V,'alias':p,'status':_0x30570a(0x1e0),'server':a0_0xb52976(),'hostname':a0_0xb52976(),'agent':'claude-code','project_dir':process[_0x30570a(0x1b1)](),'tmux_name':j||void 0x0})[_0x30570a(0x176)](_0x3943fc=>z('heartbeat\x20failed:\x20'+_0x3943fc));},0x2bf20),z(_0x4adffe(0x16a));}t()[a0_0x772d6f(0x176)](_0x1b12d5=>{const _0x206804=a0_0x772d6f;z(_0x206804(0x1c7)+_0x1b12d5),process[_0x206804(0x1dc)](0x1);});async function b(){const _0x107f09=a0_0x772d6f;z(_0x107f09(0x1a4)),await Q(_0x107f09(0x1cf),{'resume_id':V,'alias':p,'status':'offline','task':_0x107f09(0x1da)})[_0x107f09(0x176)](()=>{}),process[_0x107f09(0x1dc)](0x0);}function a0_0x35e7(_0x48d436,_0x540117){_0x48d436=_0x48d436-0x143;const _0x202c61=a0_0x202c();let _0x202cca=_0x202c61[_0x48d436];return _0x202cca;}process[a0_0x772d6f(0x160)]['on']('end',()=>b()),process['on']('SIGTERM',()=>b()),process['on'](a0_0x772d6f(0x152),()=>b());var d=process[a0_0x772d6f(0x19e)];if(d&&d>0x1){let h=setInterval(()=>{const _0x2cec3c=a0_0x772d6f;if(process['ppid']===0x1&&d!==0x1){z('parent\x20claude\x20died\x20(reparented\x20to\x20PID\x201\x20from\x20'+d+')\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat'),b();return;}try{process['kill'](d,0x0);}catch(_0x2b5be9){if(_0x2b5be9?.['code']===_0x2cec3c(0x1a6))z(_0x2cec3c(0x1bc)+d+_0x2cec3c(0x158)),b();}},0x7530);if(typeof h['unref']==='function')h[a0_0x772d6f(0x18e)]();}
@@ -1,4 +1,4 @@
1
- export type RuntimeName = "claude-code-cli" | "codex-sdk" | "claude-agent-sdk" | "grok-build-acp";
1
+ export type RuntimeName = "claude-code-cli" | "codex-sdk" | "claude-agent-sdk" | "grok-build-acp" | "opencode-cli";
2
2
  /** Operator-facing default for any runtime slot that comes in empty / missing / unrecognized. */
3
3
  export declare const DEFAULT_RUNTIME: RuntimeName;
4
4
  type ProfileLike = {
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Version this branch was validated against by the maintainers.
3
+ * Bumped when a new opencode-ai release passes the manual smoke +
4
+ * PR② e2e in a fresh checkout. `readEffectivePin()` still returns
5
+ * this when no override file exists.
6
+ */
7
+ export declare const OPENCODE_BUILTIN_PIN = "1.17.13";
8
+ /** Where the per-machine override lives. Kept under `~/.anet/` so
9
+ * it sits next to the other anet-local state. */
10
+ export declare function opencodePinFilePath(homeDirOverride?: string): string;
11
+ /** Shape of the override file written by `upgrade-pin`. */
12
+ export interface OpencodePinOverride {
13
+ version: string;
14
+ /** ISO timestamp when the smoke test passed. Presence of this
15
+ * field is REQUIRED for `readEffectivePin()` to trust the file —
16
+ * a hand-edited version without a smoke marker is refused. */
17
+ smokePassedAt: string;
18
+ /** Free-form note about what the smoke checked (initialize +
19
+ * session/new by default). Kept so a future review can tell what
20
+ * bar the pin actually cleared. */
21
+ smokeNote?: string;
22
+ }
23
+ export interface EffectivePin {
24
+ version: string;
25
+ source: "override-file" | "builtin";
26
+ smokePassedAt?: string;
27
+ }
28
+ /**
29
+ * Prefer a validated override file when present; otherwise fall
30
+ * back to the built-in constant. A malformed override file is
31
+ * ignored (built-in wins) — we don't want a partially-written
32
+ * override to wedge every start.
33
+ */
34
+ export declare function readEffectivePin(homeDirOverride?: string): EffectivePin;
35
+ /**
36
+ * Write the override — SHOULD ONLY be called after the smoke test
37
+ * has actually passed. The command layer in `bin/cli.ts` is
38
+ * responsible for gating this; this function does no
39
+ * verification of its own beyond shape.
40
+ */
41
+ export declare function writePinOverride(version: string, smokePassedAt: string, smokeNote?: string, homeDirOverride?: string): void;
@@ -0,0 +1,43 @@
1
+ export type OpencodePresetId = "anthropic" | "openai";
2
+ export interface OpencodePreset {
3
+ id: OpencodePresetId;
4
+ displayName: string;
5
+ envKey: string;
6
+ signupUrl: string;
7
+ /** How opencode's provider config identifies this vendor in the
8
+ * `provider.<id>.options.baseUrl` config. Left null when we don't
9
+ * need to override the built-in default. */
10
+ configProviderId: "anthropic" | "openai";
11
+ }
12
+ export declare const OPENCODE_PRESETS: OpencodePreset[];
13
+ export declare function findOpencodePreset(id: string): OpencodePreset | null;
14
+ /**
15
+ * Look up the API key for a preset from the current process env.
16
+ * Callers MUST handle the `null` case (per RFC v0.3 D3 + 通信龙 PR③
17
+ * flag: "从 env 读, 别 prompt"). Returns null so the wizard can
18
+ * emit a clear message telling the operator to export the env var
19
+ * and re-run — rather than silently continuing without a key.
20
+ */
21
+ export declare function readPresetKeyFromEnv(preset: OpencodePreset, env?: NodeJS.ProcessEnv): string | null;
22
+ /**
23
+ * opencode.ai's auth.json shape:
24
+ * { "<providerId>": { "type": "api", "key": "..." } }
25
+ * Same shape Phase 0b probes verified against opencode-ai@1.17.13.
26
+ */
27
+ export declare function buildAuthJsonBody(preset: OpencodePreset, apiKey: string): string;
28
+ /**
29
+ * Write auth.json into the opencode config root that lives under
30
+ * `nodeWorkDir` (which becomes the child's HOME per PR② §8 D5).
31
+ * mode 0o600 keeps it operator-only. Directory is created if
32
+ * missing.
33
+ *
34
+ * Returns the absolute path we wrote for logging.
35
+ */
36
+ export declare function writeOpencodeAuthJson(nodeWorkDir: string, preset: OpencodePreset, apiKey: string): string;
37
+ /**
38
+ * Companion opencode.json: pins the vendor's baseUrl (defaults for
39
+ * Anthropic / OpenAI are fine, so this is minimal for now). A
40
+ * placeholder so later PRs can push per-node overrides without
41
+ * needing to invent the file.
42
+ */
43
+ export declare function writeOpencodeConfigJson(nodeWorkDir: string, preset: OpencodePreset): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleep2agi/agent-network",
3
- "version": "2.3.0-preview.19",
3
+ "version": "2.3.0-preview.20",
4
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",