@sleep2agi/agent-network 2.3.0-preview.27 → 2.3.0-preview.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -120
- package/dist/bin/cli.d.ts +1 -1
- package/dist/bin/cli.js +1 -1
- package/dist/src/client.js +1 -1
- package/dist/src/im/feishu/worker.js +1 -1
- package/dist/src/node-server.js +1 -1
- package/dist/src/normalize-runtime.d.ts +1 -1
- package/dist/src/opencode-pin.d.ts +1 -6
- package/dist/src/opencode-preset.d.ts +8 -37
- package/package.json +4 -8
- package/dist/src/grok-attach-client.d.ts +0 -115
- package/dist/src/grok-copresence-profile.d.ts +0 -44
- package/dist/src/opencode-agent-node-pair.d.ts +0 -14
- package/dist/src/opencode-auth-login.d.ts +0 -43
- package/dist/src/opencode-launch-env.d.ts +0 -13
- package/dist/src/opencode-owner-mode.d.ts +0 -6
- package/dist/src/opencode-package-binary.d.ts +0 -21
- package/dist/src/opencode-safe-root.d.ts +0 -27
- package/dist/src/opencode-smoke-env.d.ts +0 -1
- package/dist/src/runtime-choices.d.ts +0 -15
package/dist/src/node-server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
const a0_0x53cab8=a0_0x56c5;(function(_0x44c8c0,_0x3e595d){const _0x814fea=a0_0x56c5,_0x2e16d2=_0x44c8c0();while(!![]){try{const _0x437f8a=-parseInt(_0x814fea(0x107))/0x1*(-parseInt(_0x814fea(0x106))/0x2)+parseInt(_0x814fea(0x124))/0x3+-parseInt(_0x814fea(0x174))/0x4+parseInt(_0x814fea(0x10a))/0x5+parseInt(_0x814fea(0x142))/0x6+-parseInt(_0x814fea(0xf8))/0x7*(-parseInt(_0x814fea(0x10d))/0x8)+-parseInt(_0x814fea(0x156))/0x9;if(_0x437f8a===_0x3e595d)break;else _0x2e16d2['push'](_0x2e16d2['shift']());}catch(_0x58502f){_0x2e16d2['push'](_0x2e16d2['shift']());}}}(a0_0x2481,0xd3ae3));import{readFileSync as a0_0x4429aa,existsSync as a0_0x1cefb3}from'fs';import{randomUUID as a0_0x19a542}from'crypto';import{join as a0_0xd5ed86}from'path';import{hostname as a0_0x16a31b}from'os';import{execSync as a0_0x4cfe2a}from'child_process';function a0_0x56c5(_0xe1292f,_0x2f110f){_0xe1292f=_0xe1292f-0xeb;const _0x24819a=a0_0x2481();let _0x56c53c=_0x24819a[_0xe1292f];return _0x56c53c;}function B(_0x122956){let _0xf684e7=_0x122956['replace'](/[^a-zA-Z0-9\-_]/g,'-');return _0xf684e7===''?'unknown':_0xf684e7;}import{Server as a0_0x3a585f}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x52ce92}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0xd1d407,CallToolRequestSchema as a0_0x2c9c1d}from'@modelcontextprotocol/sdk/types.js';function T(_0x56cb20){const _0x467cb9=a0_0x56c5;if(!a0_0x1cefb3(_0x56cb20))return;for(let _0x2dd8f9 of a0_0x4429aa(_0x56cb20,'utf-8')['split']('\x0a')){let _0x53f76f=_0x2dd8f9[_0x467cb9(0xed)]();if(!_0x53f76f||_0x53f76f[_0x467cb9(0x17e)]('#'))continue;let _0x343f00=_0x53f76f['indexOf']('=');if(_0x343f00<0x0)continue;let _0x1dd33c=_0x53f76f[_0x467cb9(0x182)](0x0,_0x343f00)[_0x467cb9(0xed)](),_0x328260=_0x53f76f[_0x467cb9(0x182)](_0x343f00+0x1)[_0x467cb9(0xed)]()['replace'](/^["']|["']$/g,'');if(!process.env[_0x1dd33c])process.env[_0x1dd33c]=_0x328260;}}function a0_0x2481(){const _0x5b948f=['startsWith','failed','connected','utf-8','slice','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','send_reply','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','error','application/json','toTimeString','completed','ESRCH','parse','0.3.0','trim','warning:\x20could\x20not\x20register:\x20','length','get_all_status','\x20/\x20hostname=','type',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','Progress\x200-100','read','broadcast','object','467397Ktrwxv','end','MCP\x20stdio\x20connected','min','/events/','ready\x20—\x20waiting\x20for\x20events','SSE\x20fatal:\x20','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','messages','.env','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','none','Target\x20session\x20alias','\x20CWD=','502954DGhsBO','4wWQZeV','Reply\x20text\x20/\x20result\x20summary','priority','3321965qlnBEb','from','result','192zXzMjG','commhub_reply','data:\x20','application/json,\x20text/event-stream','stringify','params','hub','in_progress','task','unknown\x20tool',':\x20inbox_count=','tools/call','status','registered\x20as\x20\x22','decode','ppid','Priority\x20(default:\x20normal)','Current\x20task\x20description','Authorization','get_inbox','SSE\x20connected\x20as\x20\x22','write','blocked','3721278yhykTc','token','message','pop','2025-03-26','unref','split','config.json','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a','now','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','no\x20response','low','connect','function','cancelled','content','inbox_count','claude-code','working','\x20from\x20','commhub_report_status','heartbeat\x20failed:\x20','set','Task\x20content','re-register\x20failed:\x20','SSE\x20connection\x20error:\x20','8183946ZchHue','number','\x22\x20after\x20SSE\x20reconnect','idle','commhub_send_task','report_status','send_message','commhub','statusText','parent\x20claude\x20pid=','getReader','body','delete','normal','text','new_task','Message\x20content','init\x20failed:\x20','stdin','SIGINT','43684893EdnmBr','Session\x20alias:\x20','setRequestHandler','SSE\x20error:\x20','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','from_session','(none)','session\x20disconnected','commhub_send_message','new_message','then','connecting\x20to\x20','message_id','get','string','unattributed-','CommHub\x20init\x20failed:\x20','\x20priority=','commhub-channel','catch','POST','SSE\x20stream\x20ended,\x20reconnecting...','notifications/claude/channel','find','2.0','.claude/channels/commhub','cwd',']\x20[commhub]\x20','high','code','625208vByHRA','alias','exit','SIGTERM','http://127.0.0.1:9200','commhub_get_all_status','starting\x20SSE\x20listener...','←\x20message\x20from\x20','.anet','notification'];a0_0x2481=function(){return _0x5b948f;};return a0_0x2481();}var C=process.env.HOME||'~',r=a0_0xd5ed86(C,a0_0x53cab8(0x16f));T(a0_0xd5ed86(r,'.env'));var H=B(process[a0_0x53cab8(0x170)]());T(a0_0xd5ed86(r,H,a0_0x53cab8(0x101)));function E(){const _0x406752=a0_0x53cab8;try{return a0_0x4cfe2a('tmux\x20display-message\x20-p\x20\x27#S\x27',{'encoding':_0x406752(0x181),'timeout':0x7d0})['trim']();}catch{return'';}}function _(){const _0x310b2c=a0_0x53cab8;try{let _0x7eaa8e=a0_0xd5ed86(C,_0x310b2c(0x17c),_0x310b2c(0x12b));if(a0_0x1cefb3(_0x7eaa8e))return JSON[_0x310b2c(0xeb)](a0_0x4429aa(_0x7eaa8e,_0x310b2c(0x181)));}catch{}return{};}var R=_(),Y=process.env.COMMHUB_URL||R[a0_0x53cab8(0x113)]||a0_0x53cab8(0x178),j=process.env.COMMHUB_TMUX||E();function S(){const _0x321ef9=a0_0x53cab8;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x321ef9(0xed)]())return process.env.COMMHUB_ALIAS[_0x321ef9(0xed)]();return process['stderr']['write']('[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20'+(_0x321ef9(0x12e)+(j||_0x321ef9(0x15c))+_0x321ef9(0xf1)+a0_0x16a31b()+_0x321ef9(0x12f))),_0x321ef9(0x165)+process['pid'];}var p=S(),V=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x19a542(),k=process.env.COMMHUB_TOKEN||R[a0_0x53cab8(0x125)]||'';function z(_0x4b3b12){const _0x55e715=a0_0x53cab8;let _0x43e8d8=new Date()[_0x55e715(0x189)]()[_0x55e715(0x182)](0x0,0x8);process['stderr'][_0x55e715(0x122)]('['+_0x43e8d8+_0x55e715(0x171)+_0x4b3b12+'\x0a');}function i(_0x5edcd1){return new Promise(_0x48cecb=>setTimeout(_0x48cecb,_0x5edcd1));}z('ENV:\x20URL='+Y+'\x20ALIAS='+p+'\x20RESUME_ID='+V['slice'](0x0,0x8)+'...\x20TMUX='+(j||a0_0x53cab8(0x103))+a0_0x53cab8(0x105)+process[a0_0x53cab8(0x170)]()+'\x20PROJECT_ENV='+H);var G=new Map(),K=new a0_0x3a585f({'name':a0_0x53cab8(0x168),'version':a0_0x53cab8(0xec)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x53cab8(0xff),'These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.',a0_0x53cab8(0x184),a0_0x53cab8(0x102),a0_0x53cab8(0x157)+p]['join']('\x0a')});K[a0_0x53cab8(0x158)](a0_0xd1d407,async()=>({'tools':[{'name':a0_0x53cab8(0x10e),'description':'Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','inputSchema':{'type':a0_0x53cab8(0xf7),'properties':{'task_id':{'type':a0_0x53cab8(0x164),'description':a0_0x53cab8(0x12c)},'text':{'type':a0_0x53cab8(0x164),'description':a0_0x53cab8(0x108)},'status':{'type':a0_0x53cab8(0x164),'enum':[a0_0x53cab8(0x18a),a0_0x53cab8(0x17f),a0_0x53cab8(0x136),'blocked',a0_0x53cab8(0x187),a0_0x53cab8(0x114)],'description':a0_0x53cab8(0x15a)}},'required':[a0_0x53cab8(0x150)]}},{'name':a0_0x53cab8(0x13c),'description':a0_0x53cab8(0x186),'inputSchema':{'type':'object','properties':{'status':{'type':a0_0x53cab8(0x164),'enum':[a0_0x53cab8(0x13a),a0_0x53cab8(0x145),a0_0x53cab8(0x123),a0_0x53cab8(0x187)]},'task':{'type':'string','description':a0_0x53cab8(0x11e)},'progress':{'type':a0_0x53cab8(0x143),'description':a0_0x53cab8(0xf4)}},'required':[a0_0x53cab8(0x119)]}},{'name':a0_0x53cab8(0x146),'description':a0_0x53cab8(0x12d),'inputSchema':{'type':a0_0x53cab8(0xf7),'properties':{'alias':{'type':a0_0x53cab8(0x164),'description':a0_0x53cab8(0x104)},'task':{'type':a0_0x53cab8(0x164),'description':a0_0x53cab8(0x13f)},'priority':{'type':a0_0x53cab8(0x164),'enum':[a0_0x53cab8(0x172),a0_0x53cab8(0x14f),a0_0x53cab8(0x133)],'description':a0_0x53cab8(0x11d)}},'required':['alias',a0_0x53cab8(0x115)]}},{'name':a0_0x53cab8(0x15e),'description':'Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','inputSchema':{'type':a0_0x53cab8(0xf7),'properties':{'alias':{'type':a0_0x53cab8(0x164),'description':a0_0x53cab8(0x104)},'message':{'type':a0_0x53cab8(0x164),'description':a0_0x53cab8(0x152)}},'required':[a0_0x53cab8(0x175),a0_0x53cab8(0x126)]}},{'name':a0_0x53cab8(0x179),'description':a0_0x53cab8(0x131),'inputSchema':{'type':a0_0x53cab8(0xf7),'properties':{}}}]}));async function Q(_0x1a9e77,_0x99f2b1){const _0xc5d447=a0_0x53cab8;let _0x1be83a=await fetch(Y+'/mcp',{'method':_0xc5d447(0x16a),'headers':{'Content-Type':_0xc5d447(0x188),'Accept':_0xc5d447(0x110),...k?{'Authorization':'Bearer\x20'+k}:{}},'body':JSON[_0xc5d447(0x111)]({'jsonrpc':_0xc5d447(0x16e),'id':0x1,'method':'initialize','params':{'protocolVersion':_0xc5d447(0x128),'capabilities':{},'clientInfo':{'name':_0xc5d447(0x168),'version':'0.3.0'}}})});if(!_0x1be83a['ok']){let _0x18d8fb=await _0x1be83a[_0xc5d447(0x150)]();return z(_0xc5d447(0x166)+_0x1be83a[_0xc5d447(0x119)]+'\x20'+_0x18d8fb[_0xc5d447(0x182)](0x0,0x64)),{'ok':!0x1,'error':_0xc5d447(0x153)+_0x1be83a[_0xc5d447(0x119)]};}await _0x1be83a[_0xc5d447(0x150)]();let _0x15398c=(await(await fetch(Y+'/mcp',{'method':_0xc5d447(0x16a),'headers':{'Content-Type':_0xc5d447(0x188),'Accept':_0xc5d447(0x110),...k?{'Authorization':'Bearer\x20'+k}:{}},'body':JSON[_0xc5d447(0x111)]({'jsonrpc':_0xc5d447(0x16e),'id':0x2,'method':_0xc5d447(0x118),'params':{'name':_0x1a9e77,'arguments':_0x99f2b1}})}))[_0xc5d447(0x150)]())[_0xc5d447(0x12a)]('\x0a')[_0xc5d447(0x16d)](_0x5dd473=>_0x5dd473['startsWith'](_0xc5d447(0x10f)));if(_0x15398c){let _0x46e998=JSON[_0xc5d447(0xeb)](_0x15398c[_0xc5d447(0x182)](0x6));return _0x46e998?.[_0xc5d447(0x10c)]?.[_0xc5d447(0x137)]?.[0x0]?.[_0xc5d447(0x150)]?JSON[_0xc5d447(0xeb)](_0x46e998['result']['content'][0x0][_0xc5d447(0x150)]):_0x46e998;}return{'ok':!0x1,'error':_0xc5d447(0x132)};}K[a0_0x53cab8(0x158)](a0_0x2c9c1d,async _0x47c5ab=>{const _0x5ab68b=a0_0x53cab8;let {name:_0x3a3a4c,arguments:_0x5eff6d}=_0x47c5ab[_0x5ab68b(0x112)];if(_0x3a3a4c===_0x5ab68b(0x10e)){let {task_id:_0x25359a,text:_0x22ae0c,status:_0x422d18}=_0x5eff6d;if(_0x422d18==='completed'||_0x422d18===_0x5ab68b(0x17f)||_0x422d18==='cancelled'){let _0xf3083b=_0x422d18===_0x5ab68b(0x18a)?'replied':_0x422d18,_0x4dd758=_0x25359a?G[_0x5ab68b(0x163)](_0x25359a)||_0x5ab68b(0x113):_0x5ab68b(0x113),_0x45b097=await Q(_0x5ab68b(0x185),{'alias':_0x4dd758,'text':_0x22ae0c,'in_reply_to':_0x25359a||void 0x0,'status':_0xf3083b,'from_session':p});if(_0x25359a)G[_0x5ab68b(0x14e)](_0x25359a);return{'content':[{'type':_0x5ab68b(0x150),'text':JSON[_0x5ab68b(0x111)](_0x45b097)}]};}let _0x3a666c=await Q('report_status',{'resume_id':V,'alias':p,'status':_0x422d18==='blocked'?_0x5ab68b(0x123):_0x422d18===_0x5ab68b(0x187)?'error':_0x5ab68b(0x13a),'task':_0x22ae0c[_0x5ab68b(0x182)](0x0,0xc8),'output':_0x22ae0c});return{'content':[{'type':'text','text':JSON[_0x5ab68b(0x111)](_0x3a666c)}]};}if(_0x3a3a4c===_0x5ab68b(0x13c)){let {status:_0x4cd566,task:_0x1fb2ad,progress:_0x2f632e}=_0x5eff6d,_0xd28ba9=await Q(_0x5ab68b(0x147),{'resume_id':V,'alias':p,'status':_0x4cd566,'task':_0x1fb2ad,'progress':_0x2f632e});return{'content':[{'type':'text','text':JSON['stringify'](_0xd28ba9)}]};}if(_0x3a3a4c===_0x5ab68b(0x146)){let {alias:_0x10c417,task:_0x3ba73f,priority:_0x35dc23}=_0x5eff6d,_0x1c4c1c=await Q('send_task',{'alias':_0x10c417,'task':_0x3ba73f,'priority':_0x35dc23||'normal','from_session':p});return{'content':[{'type':_0x5ab68b(0x150),'text':JSON[_0x5ab68b(0x111)](_0x1c4c1c)}]};}if(_0x3a3a4c===_0x5ab68b(0x15e)){let {alias:_0x5a2b26,message:_0x2168ea}=_0x5eff6d,_0x414eb4=await Q(_0x5ab68b(0x148),{'alias':_0x5a2b26,'message':_0x2168ea,'from_session':p});return{'content':[{'type':_0x5ab68b(0x150),'text':JSON['stringify'](_0x414eb4)}]};}if(_0x3a3a4c==='commhub_get_all_status'){let _0x377a59=await Q(_0x5ab68b(0xf0),{});return{'content':[{'type':'text','text':JSON['stringify'](_0x377a59)}]};}return{'content':[{'type':'text','text':JSON[_0x5ab68b(0x111)]({'error':_0x5ab68b(0x116)})}]};});var D=0x3e8,v=0x7530,O=0x36ee80;async function m(){const _0xda9c05=a0_0x53cab8;try{await Q(_0xda9c05(0x147),{'resume_id':V,'alias':p,'status':_0xda9c05(0x145),'server':a0_0x16a31b(),'hostname':a0_0x16a31b(),'agent':_0xda9c05(0x139),'project_dir':process[_0xda9c05(0x170)](),'tmux_name':j||void 0x0}),z('re-registered\x20as\x20\x22'+p+_0xda9c05(0x144));}catch(_0x49c2ba){z(_0xda9c05(0x140)+_0x49c2ba);}}async function l(){const _0x2b35b5=a0_0x53cab8;let _0x5e83dd=Y+_0x2b35b5(0xfc)+encodeURIComponent(p),_0x3b8dba={};if(k)_0x3b8dba[_0x2b35b5(0x11f)]='Bearer\x20'+k;z(_0x2b35b5(0x161)+_0x5e83dd);let _0x545750=D,_0x27f339=!0x0,_0x2370d3=null;while(!0x0){try{let _0x2c5e75=await fetch(_0x5e83dd,{'headers':_0x3b8dba});if(!_0x2c5e75['ok']){if(z(_0x2b35b5(0x159)+_0x2c5e75[_0x2b35b5(0x119)]+'\x20'+_0x2c5e75[_0x2b35b5(0x14a)]),_0x2370d3=_0x2370d3??Date[_0x2b35b5(0x130)](),Date['now']()-_0x2370d3>O){z(_0x2b35b5(0x183)+Y+_0x2b35b5(0xf3));return;}await i(_0x545750),_0x545750=Math[_0x2b35b5(0xfb)](_0x545750*0x2,v);continue;}let _0x35a63d=_0x2c5e75[_0x2b35b5(0x14d)][_0x2b35b5(0x14c)](),_0x5bff21=new TextDecoder(),_0x4df713='';_0x545750=D;while(!0x0){let {done:_0xfd2f1,value:_0x57d1ae}=await _0x35a63d[_0x2b35b5(0xf5)]();if(_0xfd2f1)break;_0x4df713+=_0x5bff21[_0x2b35b5(0x11b)](_0x57d1ae,{'stream':!0x0});let _0xa8f5d9=_0x4df713[_0x2b35b5(0x12a)]('\x0a\x0a');_0x4df713=_0xa8f5d9[_0x2b35b5(0x127)]()||'';for(let _0x1d6081 of _0xa8f5d9){let _0x2d24a5=_0x1d6081['split']('\x0a')[_0x2b35b5(0x16d)](_0x18de99=>_0x18de99[_0x2b35b5(0x17e)]('data:\x20'));if(!_0x2d24a5)continue;try{let _0x1f417d=JSON['parse'](_0x2d24a5['slice'](0x6));if(await A(_0x1f417d),_0x1f417d['type']===_0x2b35b5(0x180)){if(_0x2370d3=null,!_0x27f339)await m();_0x27f339=!0x1;}}catch(_0x98112b){z('parse\x20error:\x20'+_0x98112b);}}}z(_0x2b35b5(0x16b));}catch(_0x1acf2a){z(_0x2b35b5(0x141)+_0x1acf2a);}if(_0x2370d3=_0x2370d3??Date[_0x2b35b5(0x130)](),Date[_0x2b35b5(0x130)]()-_0x2370d3>O){z(_0x2b35b5(0x183)+Y+_0x2b35b5(0xf3));return;}await i(_0x545750),_0x545750=Math[_0x2b35b5(0xfb)](_0x545750*0x2,v);}}async function A(_0x5c5f58){const _0x43d6ae=a0_0x53cab8;if(_0x5c5f58[_0x43d6ae(0xf2)]===_0x43d6ae(0x180)){z(_0x43d6ae(0x121)+p+'\x22');return;}if(_0x5c5f58[_0x43d6ae(0xf2)]===_0x43d6ae(0x15f)){if(z(_0x43d6ae(0x17b)+_0x5c5f58[_0x43d6ae(0x10b)]+':\x20'+_0x5c5f58[_0x43d6ae(0x126)][_0x43d6ae(0x182)](0x0,0x3c)),await K[_0x43d6ae(0x17d)]({'method':_0x43d6ae(0x16c),'params':{'content':_0x5c5f58[_0x43d6ae(0x126)],'meta':{'sender':_0x5c5f58[_0x43d6ae(0x10b)]||_0x43d6ae(0x113),'sender_id':'commhub','user':_0x5c5f58['from']||_0x43d6ae(0x113),'priority':_0x43d6ae(0x14f)}}}),_0x5c5f58[_0x43d6ae(0x162)])await Q('ack_inbox',{'alias':p,'message_id':_0x5c5f58[_0x43d6ae(0x162)]});return;}if(_0x5c5f58[_0x43d6ae(0xf2)]===_0x43d6ae(0x151)||_0x5c5f58[_0x43d6ae(0xf2)]===_0x43d6ae(0xf6)){z('←\x20'+_0x5c5f58[_0x43d6ae(0xf2)]+_0x43d6ae(0x117)+_0x5c5f58[_0x43d6ae(0x138)]+_0x43d6ae(0x167)+(_0x5c5f58[_0x43d6ae(0x109)]||_0x43d6ae(0x14f)));let _0x46221e=await Q(_0x43d6ae(0x120),{'alias':p,'limit':0x5});if(_0x46221e?.['ok']&&_0x46221e[_0x43d6ae(0x100)]?.[_0x43d6ae(0xef)]>0x0)for(let _0x36d79f of _0x46221e[_0x43d6ae(0x100)]){let _0x41bd13={'sender':_0x36d79f[_0x43d6ae(0x15b)]||_0x43d6ae(0x113),'sender_id':_0x43d6ae(0x149),'user':_0x36d79f['from_session']||_0x43d6ae(0x113),'task_id':_0x36d79f['id'],'priority':_0x36d79f[_0x43d6ae(0x109)]||'normal'};G[_0x43d6ae(0x13e)](_0x36d79f['id'],_0x36d79f[_0x43d6ae(0x15b)]||_0x43d6ae(0x113)),await K[_0x43d6ae(0x17d)]({'method':'notifications/claude/channel','params':{'content':_0x36d79f[_0x43d6ae(0x137)],'meta':_0x41bd13}}),z('→\x20injected\x20task\x20'+_0x36d79f['id'][_0x43d6ae(0x182)](0x0,0x8)+_0x43d6ae(0x13b)+_0x36d79f[_0x43d6ae(0x15b)]+':\x20'+_0x36d79f['content'][_0x43d6ae(0x182)](0x0,0x3c)),await Q('ack_inbox',{'alias':p,'message_id':_0x36d79f['id']});}}}async function t(){const _0x344229=a0_0x53cab8;let _0x50a8db=new a0_0x52ce92();await K[_0x344229(0x134)](_0x50a8db),z(_0x344229(0xfa)),z(_0x344229(0x17a)),l()[_0x344229(0x169)](_0x17aa74=>z(_0x344229(0xfe)+_0x17aa74)),Q(_0x344229(0x147),{'resume_id':V,'alias':p,'status':'idle','server':a0_0x16a31b(),'hostname':a0_0x16a31b(),'agent':_0x344229(0x139),'project_dir':process[_0x344229(0x170)](),'tmux_name':j||void 0x0})[_0x344229(0x160)](()=>z(_0x344229(0x11a)+p+'\x22\x20('+V[_0x344229(0x182)](0x0,0x8)+')'))[_0x344229(0x169)](_0x3e42b3=>z(_0x344229(0xee)+_0x3e42b3)),setInterval(()=>{const _0x56718e=_0x344229;Q(_0x56718e(0x147),{'resume_id':V,'alias':p,'status':'idle','server':a0_0x16a31b(),'hostname':a0_0x16a31b(),'agent':_0x56718e(0x139),'project_dir':process['cwd'](),'tmux_name':j||void 0x0})['catch'](_0x1e8e89=>z(_0x56718e(0x13d)+_0x1e8e89));},0x2bf20),z(_0x344229(0xfd));}t()[a0_0x53cab8(0x169)](_0x215b98=>{const _0x59b512=a0_0x53cab8;z('fatal:\x20'+_0x215b98),process[_0x59b512(0x176)](0x1);});async function b(){const _0x12edcd=a0_0x53cab8;z('shutting\x20down,\x20reporting\x20offline...'),await Q(_0x12edcd(0x147),{'resume_id':V,'alias':p,'status':'offline','task':_0x12edcd(0x15d)})['catch'](()=>{}),process['exit'](0x0);}process[a0_0x53cab8(0x154)]['on'](a0_0x53cab8(0xf9),()=>b()),process['on'](a0_0x53cab8(0x177),()=>b()),process['on'](a0_0x53cab8(0x155),()=>b());var d=process[a0_0x53cab8(0x11c)];if(d&&d>0x1){let h=setInterval(()=>{const _0x869c16=a0_0x53cab8;if(process[_0x869c16(0x11c)]===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(_0x51f5f7){if(_0x51f5f7?.[_0x869c16(0x173)]===_0x869c16(0x18b))z(_0x869c16(0x14b)+d+'\x20no\x20longer\x20exists\x20(kill-0\x20ESRCH)\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat'),b();}},0x7530);if(typeof h[a0_0x53cab8(0x129)]===a0_0x53cab8(0x135))h[a0_0x53cab8(0x129)]();}
|
|
2
|
+
const a0_0x14223e=a0_0x5950;(function(_0x5a3d98,_0x49575a){const _0x451ec0=a0_0x5950,_0x3b119d=_0x5a3d98();while(!![]){try{const _0x270efd=parseInt(_0x451ec0(0xcd))/0x1+-parseInt(_0x451ec0(0x129))/0x2*(-parseInt(_0x451ec0(0xc4))/0x3)+-parseInt(_0x451ec0(0x13e))/0x4*(-parseInt(_0x451ec0(0x12e))/0x5)+parseInt(_0x451ec0(0x14e))/0x6+-parseInt(_0x451ec0(0xd8))/0x7*(parseInt(_0x451ec0(0xb2))/0x8)+-parseInt(_0x451ec0(0x132))/0x9*(-parseInt(_0x451ec0(0xe7))/0xa)+-parseInt(_0x451ec0(0x102))/0xb*(parseInt(_0x451ec0(0xbc))/0xc);if(_0x270efd===_0x49575a)break;else _0x3b119d['push'](_0x3b119d['shift']());}catch(_0x1408ed){_0x3b119d['push'](_0x3b119d['shift']());}}}(a0_0x4341,0x71a62));import{readFileSync as a0_0x7ea341,existsSync as a0_0x3dfa56}from'fs';import{randomUUID as a0_0x456985}from'crypto';import{join as a0_0x3243e8}from'path';import{hostname as a0_0x112773}from'os';import{execSync as a0_0x4a75a3}from'child_process';function B(_0x34e47a){const _0x3e2555=a0_0x5950;let _0xcb2b03=_0x34e47a[_0x3e2555(0xd9)](/[^a-zA-Z0-9\-_]/g,'-');return _0xcb2b03===''?_0x3e2555(0x10d):_0xcb2b03;}import{Server as a0_0x3b09c5}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x116dab}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0xce8bd,CallToolRequestSchema as a0_0x48025d}from'@modelcontextprotocol/sdk/types.js';function T(_0x1d0a32){const _0xd1089=a0_0x5950;if(!a0_0x3dfa56(_0x1d0a32))return;for(let _0x408afa of a0_0x7ea341(_0x1d0a32,'utf-8')[_0xd1089(0x11a)]('\x0a')){let _0x3303e8=_0x408afa[_0xd1089(0xd5)]();if(!_0x3303e8||_0x3303e8[_0xd1089(0x11d)]('#'))continue;let _0x2ad69c=_0x3303e8[_0xd1089(0xf6)]('=');if(_0x2ad69c<0x0)continue;let _0x520006=_0x3303e8[_0xd1089(0x149)](0x0,_0x2ad69c)['trim'](),_0xb3ebc2=_0x3303e8[_0xd1089(0x149)](_0x2ad69c+0x1)[_0xd1089(0xd5)]()[_0xd1089(0xd9)](/^["']|["']$/g,'');if(!process.env[_0x520006])process.env[_0x520006]=_0xb3ebc2;}}var C=process.env.HOME||'~',r=a0_0x3243e8(C,a0_0x14223e(0x126));T(a0_0x3243e8(r,'.env'));var H=B(process[a0_0x14223e(0xce)]());T(a0_0x3243e8(r,H,a0_0x14223e(0x135)));function E(){const _0x415935=a0_0x14223e;try{return a0_0x4a75a3(_0x415935(0x117),{'encoding':_0x415935(0xb3),'timeout':0x7d0})[_0x415935(0xd5)]();}catch{return'';}}function _(){const _0x3ef354=a0_0x14223e;try{let _0x30d8f3=a0_0x3243e8(C,_0x3ef354(0xf4),'config.json');if(a0_0x3dfa56(_0x30d8f3))return JSON[_0x3ef354(0x136)](a0_0x7ea341(_0x30d8f3,_0x3ef354(0xb3)));}catch{}return{};}var R=_(),Y=process.env.COMMHUB_URL||R[a0_0x14223e(0x13b)]||a0_0x14223e(0x105),j=process.env.COMMHUB_TMUX||E();function S(){const _0x1e7f9a=a0_0x14223e;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x1e7f9a(0xd5)]())return process.env.COMMHUB_ALIAS[_0x1e7f9a(0xd5)]();return process[_0x1e7f9a(0xe5)][_0x1e7f9a(0xd3)]('[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20'+(_0x1e7f9a(0xb6)+(j||_0x1e7f9a(0xe4))+'\x20/\x20hostname='+a0_0x112773()+_0x1e7f9a(0x10e))),_0x1e7f9a(0x11f)+process[_0x1e7f9a(0x124)];}var p=S(),V=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x456985(),k=process.env.COMMHUB_TOKEN||R[a0_0x14223e(0x103)]||'';function z(_0x4729f3){const _0x3ba185=a0_0x14223e;let _0x2b7603=new Date()[_0x3ba185(0xb1)]()[_0x3ba185(0x149)](0x0,0x8);process[_0x3ba185(0xe5)]['write']('['+_0x2b7603+_0x3ba185(0x14a)+_0x4729f3+'\x0a');}function i(_0x4f09ec){return new Promise(_0xeb2e1=>setTimeout(_0xeb2e1,_0x4f09ec));}z(a0_0x14223e(0xfb)+Y+a0_0x14223e(0xf3)+p+a0_0x14223e(0xba)+V[a0_0x14223e(0x149)](0x0,0x8)+a0_0x14223e(0xc5)+(j||a0_0x14223e(0xea))+a0_0x14223e(0xd1)+process['cwd']()+a0_0x14223e(0xf1)+H);var G=new Map(),K=new a0_0x3b09c5({'name':a0_0x14223e(0xca),'version':a0_0x14223e(0xfd)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':['Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>',a0_0x14223e(0xc9),'Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.',a0_0x14223e(0xda),a0_0x14223e(0xd0)+p][a0_0x14223e(0xb8)]('\x0a')});K[a0_0x14223e(0x110)](a0_0xce8bd,async()=>({'tools':[{'name':a0_0x14223e(0xe2),'description':a0_0x14223e(0x142),'inputSchema':{'type':a0_0x14223e(0xc6),'properties':{'task_id':{'type':'string','description':a0_0x14223e(0xb9)},'text':{'type':a0_0x14223e(0xee),'description':a0_0x14223e(0x134)},'status':{'type':a0_0x14223e(0xee),'enum':['completed',a0_0x14223e(0x123),a0_0x14223e(0xb0),a0_0x14223e(0x138),a0_0x14223e(0x146),a0_0x14223e(0xde)],'description':'Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates'}},'required':[a0_0x14223e(0x14d)]}},{'name':a0_0x14223e(0x150),'description':a0_0x14223e(0x128),'inputSchema':{'type':a0_0x14223e(0xc6),'properties':{'status':{'type':a0_0x14223e(0xee),'enum':[a0_0x14223e(0xe3),a0_0x14223e(0xfe),a0_0x14223e(0x138),a0_0x14223e(0x146)]},'task':{'type':a0_0x14223e(0xee),'description':'Current\x20task\x20description'},'progress':{'type':'number','description':a0_0x14223e(0xed)}},'required':[a0_0x14223e(0x14c)]}},{'name':a0_0x14223e(0xb4),'description':'Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','inputSchema':{'type':'object','properties':{'alias':{'type':a0_0x14223e(0xee),'description':a0_0x14223e(0x100)},'task':{'type':'string','description':a0_0x14223e(0x115)},'priority':{'type':'string','enum':[a0_0x14223e(0xe9),a0_0x14223e(0xd4),a0_0x14223e(0xec)],'description':a0_0x14223e(0x112)}},'required':[a0_0x14223e(0xd7),a0_0x14223e(0xcc)]}},{'name':'commhub_send_message','description':a0_0x14223e(0xbe),'inputSchema':{'type':a0_0x14223e(0xc6),'properties':{'alias':{'type':'string','description':'Target\x20session\x20alias'},'message':{'type':a0_0x14223e(0xee),'description':a0_0x14223e(0xc3)}},'required':[a0_0x14223e(0xd7),a0_0x14223e(0xcf)]}},{'name':a0_0x14223e(0xcb),'description':a0_0x14223e(0x152),'inputSchema':{'type':a0_0x14223e(0xc6),'properties':{}}}]}));async function Q(_0x4cb777,_0x131ee7){const _0x2a9a3f=a0_0x14223e;let _0x2476d8=await fetch(Y+'/mcp',{'method':_0x2a9a3f(0x109),'headers':{'Content-Type':_0x2a9a3f(0x122),'Accept':_0x2a9a3f(0x12d),...k?{'Authorization':_0x2a9a3f(0x141)+k}:{}},'body':JSON[_0x2a9a3f(0x10b)]({'jsonrpc':_0x2a9a3f(0xbf),'id':0x1,'method':_0x2a9a3f(0xd2),'params':{'protocolVersion':_0x2a9a3f(0xaf),'capabilities':{},'clientInfo':{'name':_0x2a9a3f(0xca),'version':'0.3.0'}}})});if(!_0x2476d8['ok']){let _0x67d053=await _0x2476d8[_0x2a9a3f(0x14d)]();return z('CommHub\x20init\x20failed:\x20'+_0x2476d8[_0x2a9a3f(0x14c)]+'\x20'+_0x67d053[_0x2a9a3f(0x149)](0x0,0x64)),{'ok':!0x1,'error':'init\x20failed:\x20'+_0x2476d8[_0x2a9a3f(0x14c)]};}await _0x2476d8[_0x2a9a3f(0x14d)]();let _0x4e6507=(await(await fetch(Y+_0x2a9a3f(0xf5),{'method':_0x2a9a3f(0x109),'headers':{'Content-Type':_0x2a9a3f(0x122),'Accept':'application/json,\x20text/event-stream',...k?{'Authorization':_0x2a9a3f(0x141)+k}:{}},'body':JSON[_0x2a9a3f(0x10b)]({'jsonrpc':_0x2a9a3f(0xbf),'id':0x2,'method':_0x2a9a3f(0xf7),'params':{'name':_0x4cb777,'arguments':_0x131ee7}})}))[_0x2a9a3f(0x14d)]())[_0x2a9a3f(0x11a)]('\x0a')['find'](_0xdaa69d=>_0xdaa69d[_0x2a9a3f(0x11d)]('data:\x20'));if(_0x4e6507){let _0x12a504=JSON[_0x2a9a3f(0x136)](_0x4e6507[_0x2a9a3f(0x149)](0x6));return _0x12a504?.[_0x2a9a3f(0x101)]?.[_0x2a9a3f(0xff)]?.[0x0]?.[_0x2a9a3f(0x14d)]?JSON[_0x2a9a3f(0x136)](_0x12a504[_0x2a9a3f(0x101)]['content'][0x0]['text']):_0x12a504;}return{'ok':!0x1,'error':_0x2a9a3f(0x11c)};}K['setRequestHandler'](a0_0x48025d,async _0x204571=>{const _0xd12ff8=a0_0x14223e;let {name:_0xd48453,arguments:_0x52c8a9}=_0x204571[_0xd12ff8(0x13a)];if(_0xd48453===_0xd12ff8(0xe2)){let {task_id:_0x28fda6,text:_0x3fc706,status:_0x30318e}=_0x52c8a9;if(_0x30318e==='completed'||_0x30318e===_0xd12ff8(0x123)||_0x30318e===_0xd12ff8(0xb0)){let _0xc8502c=_0x30318e===_0xd12ff8(0xf0)?_0xd12ff8(0xe8):_0x30318e,_0x4d48eb=_0x28fda6?G[_0xd12ff8(0x111)](_0x28fda6)||_0xd12ff8(0x13b):'hub',_0xa26a89=await Q('send_reply',{'alias':_0x4d48eb,'text':_0x3fc706,'in_reply_to':_0x28fda6||void 0x0,'status':_0xc8502c,'from_session':p});if(_0x28fda6)G[_0xd12ff8(0x106)](_0x28fda6);return{'content':[{'type':_0xd12ff8(0x14d),'text':JSON['stringify'](_0xa26a89)}]};}let _0x2e24cd=await Q('report_status',{'resume_id':V,'alias':p,'status':_0x30318e==='blocked'?_0xd12ff8(0x138):_0x30318e===_0xd12ff8(0x146)?'error':_0xd12ff8(0xe3),'task':_0x3fc706[_0xd12ff8(0x149)](0x0,0xc8),'output':_0x3fc706});return{'content':[{'type':_0xd12ff8(0x14d),'text':JSON[_0xd12ff8(0x10b)](_0x2e24cd)}]};}if(_0xd48453==='commhub_report_status'){let {status:_0x548011,task:_0x5804d8,progress:_0x38bc7e}=_0x52c8a9,_0x4c3b37=await Q(_0xd12ff8(0xc0),{'resume_id':V,'alias':p,'status':_0x548011,'task':_0x5804d8,'progress':_0x38bc7e});return{'content':[{'type':'text','text':JSON['stringify'](_0x4c3b37)}]};}if(_0xd48453==='commhub_send_task'){let {alias:_0x57a4e2,task:_0x2b3438,priority:_0x32725e}=_0x52c8a9,_0x1286d1=await Q(_0xd12ff8(0x151),{'alias':_0x57a4e2,'task':_0x2b3438,'priority':_0x32725e||_0xd12ff8(0xd4),'from_session':p});return{'content':[{'type':_0xd12ff8(0x14d),'text':JSON[_0xd12ff8(0x10b)](_0x1286d1)}]};}if(_0xd48453==='commhub_send_message'){let {alias:_0x2b157b,message:_0x24bf6c}=_0x52c8a9,_0x35414e=await Q('send_message',{'alias':_0x2b157b,'message':_0x24bf6c,'from_session':p});return{'content':[{'type':_0xd12ff8(0x14d),'text':JSON[_0xd12ff8(0x10b)](_0x35414e)}]};}if(_0xd48453===_0xd12ff8(0xcb)){let _0x13db44=await Q(_0xd12ff8(0xfa),{});return{'content':[{'type':_0xd12ff8(0x14d),'text':JSON[_0xd12ff8(0x10b)](_0x13db44)}]};}return{'content':[{'type':_0xd12ff8(0x14d),'text':JSON[_0xd12ff8(0x10b)]({'error':_0xd12ff8(0x13c)})}]};});var D=0x3e8,v=0x7530,O=0x36ee80;async function m(){const _0x99b6ee=a0_0x14223e;try{await Q(_0x99b6ee(0xc0),{'resume_id':V,'alias':p,'status':_0x99b6ee(0xfe),'server':a0_0x112773(),'hostname':a0_0x112773(),'agent':_0x99b6ee(0x137),'project_dir':process[_0x99b6ee(0xce)](),'tmux_name':j||void 0x0}),z('re-registered\x20as\x20\x22'+p+_0x99b6ee(0x12a));}catch(_0x359329){z(_0x99b6ee(0xb5)+_0x359329);}}async function l(){const _0x541a13=a0_0x14223e;let _0x16ef88=Y+'/events/'+encodeURIComponent(p),_0x484303={};if(k)_0x484303[_0x541a13(0x11e)]=_0x541a13(0x141)+k;z(_0x541a13(0x108)+_0x16ef88);let _0x11b249=D,_0xe356a2=!0x0,_0x3c29ec=null;while(!0x0){try{let _0x3285a8=await fetch(_0x16ef88,{'headers':_0x484303});if(!_0x3285a8['ok']){if(z('SSE\x20error:\x20'+_0x3285a8['status']+'\x20'+_0x3285a8[_0x541a13(0x10a)]),_0x3c29ec=_0x3c29ec??Date[_0x541a13(0xf9)](),Date[_0x541a13(0xf9)]()-_0x3c29ec>O){z(_0x541a13(0xdb)+Y+_0x541a13(0x14b));return;}await i(_0x11b249),_0x11b249=Math[_0x541a13(0x11b)](_0x11b249*0x2,v);continue;}let _0x1e4b9a=_0x3285a8['body'][_0x541a13(0x119)](),_0x842c95=new TextDecoder(),_0x3e77bf='';_0x11b249=D;while(!0x0){let {done:_0x55454b,value:_0x44db12}=await _0x1e4b9a['read']();if(_0x55454b)break;_0x3e77bf+=_0x842c95[_0x541a13(0xe1)](_0x44db12,{'stream':!0x0});let _0x55d336=_0x3e77bf[_0x541a13(0x11a)]('\x0a\x0a');_0x3e77bf=_0x55d336['pop']()||'';for(let _0x1871ee of _0x55d336){let _0x5d0865=_0x1871ee['split']('\x0a')[_0x541a13(0xfc)](_0x308f67=>_0x308f67[_0x541a13(0x11d)](_0x541a13(0xbb)));if(!_0x5d0865)continue;try{let _0x4f9328=JSON['parse'](_0x5d0865[_0x541a13(0x149)](0x6));if(await A(_0x4f9328),_0x4f9328[_0x541a13(0xb7)]===_0x541a13(0x12f)){if(_0x3c29ec=null,!_0xe356a2)await m();_0xe356a2=!0x1;}}catch(_0x4b21c9){z(_0x541a13(0xe0)+_0x4b21c9);}}}z(_0x541a13(0xc8));}catch(_0xf253e5){z(_0x541a13(0x10f)+_0xf253e5);}if(_0x3c29ec=_0x3c29ec??Date[_0x541a13(0xf9)](),Date[_0x541a13(0xf9)]()-_0x3c29ec>O){z(_0x541a13(0xdb)+Y+')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。');return;}await i(_0x11b249),_0x11b249=Math[_0x541a13(0x11b)](_0x11b249*0x2,v);}}async function A(_0x525264){const _0x331c89=a0_0x14223e;if(_0x525264['type']===_0x331c89(0x12f)){z(_0x331c89(0x13f)+p+'\x22');return;}if(_0x525264['type']===_0x331c89(0x148)){if(z('←\x20message\x20from\x20'+_0x525264[_0x331c89(0xc7)]+':\x20'+_0x525264[_0x331c89(0xcf)][_0x331c89(0x149)](0x0,0x3c)),await K[_0x331c89(0xd6)]({'method':'notifications/claude/channel','params':{'content':_0x525264[_0x331c89(0xcf)],'meta':{'sender':_0x525264[_0x331c89(0xc7)]||_0x331c89(0x13b),'sender_id':'commhub','user':_0x525264['from']||_0x331c89(0x13b),'priority':_0x331c89(0xd4)}}}),_0x525264[_0x331c89(0xc1)])await Q(_0x331c89(0x118),{'alias':p,'message_id':_0x525264[_0x331c89(0xc1)]});return;}if(_0x525264[_0x331c89(0xb7)]===_0x331c89(0xf2)||_0x525264[_0x331c89(0xb7)]==='broadcast'){z('←\x20'+_0x525264[_0x331c89(0xb7)]+_0x331c89(0x125)+_0x525264[_0x331c89(0xeb)]+_0x331c89(0xe6)+(_0x525264['priority']||_0x331c89(0xd4)));let _0x2f41f7=await Q(_0x331c89(0x140),{'alias':p,'limit':0x5});if(_0x2f41f7?.['ok']&&_0x2f41f7[_0x331c89(0x131)]?.[_0x331c89(0xdd)]>0x0)for(let _0x38119a of _0x2f41f7[_0x331c89(0x131)]){let _0x204a8f={'sender':_0x38119a[_0x331c89(0x145)]||_0x331c89(0x13b),'sender_id':_0x331c89(0x116),'user':_0x38119a[_0x331c89(0x145)]||'hub','task_id':_0x38119a['id'],'priority':_0x38119a[_0x331c89(0x143)]||_0x331c89(0xd4)};G['set'](_0x38119a['id'],_0x38119a[_0x331c89(0x145)]||'hub'),await K[_0x331c89(0xd6)]({'method':_0x331c89(0xbd),'params':{'content':_0x38119a[_0x331c89(0xff)],'meta':_0x204a8f}}),z(_0x331c89(0x147)+_0x38119a['id'][_0x331c89(0x149)](0x0,0x8)+'\x20from\x20'+_0x38119a[_0x331c89(0x145)]+':\x20'+_0x38119a['content'][_0x331c89(0x149)](0x0,0x3c)),await Q(_0x331c89(0x118),{'alias':p,'message_id':_0x38119a['id']});}}}async function t(){const _0x23d2c5=a0_0x14223e;let _0x1ba702=new a0_0x116dab();await K['connect'](_0x1ba702),z('MCP\x20stdio\x20connected'),z('starting\x20SSE\x20listener...'),l()[_0x23d2c5(0xc2)](_0x375cc5=>z(_0x23d2c5(0x104)+_0x375cc5)),Q(_0x23d2c5(0xc0),{'resume_id':V,'alias':p,'status':_0x23d2c5(0xfe),'server':a0_0x112773(),'hostname':a0_0x112773(),'agent':_0x23d2c5(0x137),'project_dir':process[_0x23d2c5(0xce)](),'tmux_name':j||void 0x0})['then'](()=>z('registered\x20as\x20\x22'+p+_0x23d2c5(0xf8)+V[_0x23d2c5(0x149)](0x0,0x8)+')'))[_0x23d2c5(0xc2)](_0x2dbf22=>z(_0x23d2c5(0x144)+_0x2dbf22)),setInterval(()=>{const _0x370707=_0x23d2c5;Q('report_status',{'resume_id':V,'alias':p,'status':'idle','server':a0_0x112773(),'hostname':a0_0x112773(),'agent':_0x370707(0x137),'project_dir':process[_0x370707(0xce)](),'tmux_name':j||void 0x0})[_0x370707(0xc2)](_0x5ea933=>z(_0x370707(0x120)+_0x5ea933));},0x2bf20),z(_0x23d2c5(0x13d));}t()[a0_0x14223e(0xc2)](_0x504cad=>{const _0x315a40=a0_0x14223e;z('fatal:\x20'+_0x504cad),process[_0x315a40(0x12c)](0x1);});async function b(){const _0x186d0b=a0_0x14223e;z(_0x186d0b(0x139)),await Q(_0x186d0b(0xc0),{'resume_id':V,'alias':p,'status':_0x186d0b(0xdc),'task':'session\x20disconnected'})[_0x186d0b(0xc2)](()=>{}),process[_0x186d0b(0x12c)](0x0);}process[a0_0x14223e(0x130)]['on'](a0_0x14223e(0x14f),()=>b()),process['on'](a0_0x14223e(0x121),()=>b()),process['on'](a0_0x14223e(0x113),()=>b());function a0_0x5950(_0x2ef1ee,_0x502bb0){_0x2ef1ee=_0x2ef1ee-0xaf;const _0x4341bd=a0_0x4341();let _0x5950a9=_0x4341bd[_0x2ef1ee];return _0x5950a9;}var d=process[a0_0x14223e(0xef)];if(d&&d>0x1){let h=setInterval(()=>{const _0x542b9a=a0_0x14223e;if(process[_0x542b9a(0xef)]===0x1&&d!==0x1){z(_0x542b9a(0x114)+d+_0x542b9a(0x10c)),b();return;}try{process[_0x542b9a(0x12b)](d,0x0);}catch(_0x3d43da){if(_0x3d43da?.['code']===_0x542b9a(0xdf))z(_0x542b9a(0x127)+d+'\x20no\x20longer\x20exists\x20(kill-0\x20ESRCH)\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat'),b();}},0x7530);if(typeof h[a0_0x14223e(0x107)]===a0_0x14223e(0x133))h[a0_0x14223e(0x107)]();}function a0_0x4341(){const _0x2b7db9=['now','get_all_status','ENV:\x20URL=','find','0.3.0','idle','content','Target\x20session\x20alias','result','11EgFbIw','token','SSE\x20fatal:\x20','http://127.0.0.1:9200','delete','unref','connecting\x20to\x20','POST','statusText','stringify',')\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','unknown','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a','SSE\x20connection\x20error:\x20','setRequestHandler','get','Priority\x20(default:\x20normal)','SIGINT','parent\x20claude\x20died\x20(reparented\x20to\x20PID\x201\x20from\x20','Task\x20content','commhub','tmux\x20display-message\x20-p\x20\x27#S\x27','ack_inbox','getReader','split','min','no\x20response','startsWith','Authorization','unattributed-','heartbeat\x20failed:\x20','SIGTERM','application/json','failed','pid',':\x20inbox_count=','.claude/channels/commhub','parent\x20claude\x20pid=','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','2302YjpLCU','\x22\x20after\x20SSE\x20reconnect','kill','exit','application/json,\x20text/event-stream','1042835HvxZdt','connected','stdin','messages','5772285kHVtcO','function','Reply\x20text\x20/\x20result\x20summary','.env','parse','claude-code','blocked','shutting\x20down,\x20reporting\x20offline...','params','hub','unknown\x20tool','ready\x20—\x20waiting\x20for\x20events','4ZZTsqJ','SSE\x20connected\x20as\x20\x22','get_inbox','Bearer\x20','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','priority','warning:\x20could\x20not\x20register:\x20','from_session','error','→\x20injected\x20task\x20','new_message','slice',']\x20[commhub]\x20',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','status','text','1530438nNIfMY','end','commhub_report_status','send_task','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','2025-03-26','cancelled','toTimeString','114696oxaPBc','utf-8','commhub_send_task','re-register\x20failed:\x20','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','type','join','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','\x20RESUME_ID=','data:\x20','24745008ydhRLB','notifications/claude/channel','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','2.0','report_status','message_id','catch','Message\x20content','1563nhecyO','...\x20TMUX=','object','from','SSE\x20stream\x20ended,\x20reconnecting...','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','commhub-channel','commhub_get_all_status','task','923273LmyWyC','cwd','message','Session\x20alias:\x20','\x20CWD=','initialize','write','normal','trim','notification','alias','49XtxVhd','replace','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','offline','length','in_progress','ESRCH','parse\x20error:\x20','decode','commhub_reply','working','(none)','stderr','\x20priority=','10NrtyYg','replied','high','none','inbox_count','low','Progress\x200-100','string','ppid','completed','\x20PROJECT_ENV=','new_task','\x20ALIAS=','.anet','/mcp','indexOf','tools/call','\x22\x20('];a0_0x4341=function(){return _0x2b7db9;};return a0_0x4341();}
|
|
@@ -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" | "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
4
|
type ProfileLike = {
|
|
@@ -4,12 +4,7 @@
|
|
|
4
4
|
* PR② e2e in a fresh checkout. `readEffectivePin()` still returns
|
|
5
5
|
* this when no override file exists.
|
|
6
6
|
*/
|
|
7
|
-
export declare const OPENCODE_BUILTIN_PIN = "1.
|
|
8
|
-
/** Exact upstream remediation shared by every CLI failure path. */
|
|
9
|
-
export declare function opencodeExactInstallCommand(version?: string): string;
|
|
10
|
-
/** Preserve package-identity diagnostics while always leaving a missing or
|
|
11
|
-
* untrusted install with an actionable exact-pin command. */
|
|
12
|
-
export declare function formatOpencodePackageIdentityFailure(expectedVersion: string, detail: string): string;
|
|
7
|
+
export declare const OPENCODE_BUILTIN_PIN = "1.17.13";
|
|
13
8
|
/** Where the per-machine override lives. Kept under `~/.anet/` so
|
|
14
9
|
* it sits next to the other anet-local state. */
|
|
15
10
|
export declare function opencodePinFilePath(homeDirOverride?: string): string;
|
|
@@ -10,16 +10,6 @@ export interface OpencodePreset {
|
|
|
10
10
|
configProviderId: "anthropic" | "openai";
|
|
11
11
|
}
|
|
12
12
|
export declare const OPENCODE_PRESETS: OpencodePreset[];
|
|
13
|
-
/**
|
|
14
|
-
* OpenCode tools disabled for the default `opencode-cli` profile.
|
|
15
|
-
*
|
|
16
|
-
* This policy reduces the model's ambient filesystem/shell surface. It is
|
|
17
|
-
* deliberately represented in the generated opencode.json so operators can
|
|
18
|
-
* inspect the default, but it is not an OS security boundary: a same-uid
|
|
19
|
-
* OpenCode process can still read files allowed by normal filesystem ACLs.
|
|
20
|
-
*/
|
|
21
|
-
export declare const OPENCODE_DEFAULT_DISABLED_TOOLS: readonly ["bash", "read", "glob", "grep", "edit", "write", "list", "task", "skill", "question"];
|
|
22
|
-
export declare function buildOpencodeDefaultToolsPolicy(): Record<string, false>;
|
|
23
13
|
export declare function findOpencodePreset(id: string): OpencodePreset | null;
|
|
24
14
|
/**
|
|
25
15
|
* Look up the API key for a preset from the current process env.
|
|
@@ -32,41 +22,22 @@ export declare function readPresetKeyFromEnv(preset: OpencodePreset, env?: NodeJ
|
|
|
32
22
|
/**
|
|
33
23
|
* opencode.ai's auth.json shape:
|
|
34
24
|
* { "<providerId>": { "type": "api", "key": "..." } }
|
|
35
|
-
* Same shape
|
|
25
|
+
* Same shape Phase 0b probes verified against opencode-ai@1.17.13.
|
|
36
26
|
*/
|
|
37
27
|
export declare function buildAuthJsonBody(preset: OpencodePreset, apiKey: string): string;
|
|
38
|
-
export type OpencodePrivateProfileFilename = "config.json" | ".env";
|
|
39
|
-
/**
|
|
40
|
-
* Establish the boundary before saveProfile/rewritePlainSecrets writes the
|
|
41
|
-
* node token or dotenv key. The expected shape is exactly
|
|
42
|
-
* `<project>/.anet/nodes/<node>`. Every existing path is inspected with
|
|
43
|
-
* lstat + O_NOFOLLOW and inode checks; absent private directories are created
|
|
44
|
-
* one component at a time. A pre-planted node-root/config/.env symlink is a
|
|
45
|
-
* hard error before any secret-bearing write.
|
|
46
|
-
*/
|
|
47
|
-
export declare function prepareOpencodeNodeForProfileWrite(nodeWorkDir: string): string;
|
|
48
|
-
export declare function readOpencodePrivateProfileFile(nodeWorkDir: string, filename: OpencodePrivateProfileFilename): string | undefined;
|
|
49
|
-
export declare function writeOpencodePrivateProfileFile(nodeWorkDir: string, filename: OpencodePrivateProfileFilename, body: string): string;
|
|
50
28
|
/**
|
|
51
29
|
* Write auth.json into the opencode config root that lives under
|
|
52
|
-
* `nodeWorkDir` (the per
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* created if missing.
|
|
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.
|
|
56
33
|
*
|
|
57
34
|
* Returns the absolute path we wrote for logging.
|
|
58
35
|
*/
|
|
59
36
|
export declare function writeOpencodeAuthJson(nodeWorkDir: string, preset: OpencodePreset, apiKey: string): string;
|
|
60
37
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
|
|
65
|
-
export declare function clearOpencodeAuthJson(nodeWorkDir: string): string;
|
|
66
|
-
/**
|
|
67
|
-
* Companion opencode.json: records only the selected blessed provider
|
|
68
|
-
* identity and safe-by-default tool policy. Pre-existing model routing and
|
|
69
|
-
* arbitrary OpenCode integrations are stripped; operators may explicitly set
|
|
70
|
-
* a model after creation, which the runtime's separate safe renderer retains.
|
|
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.
|
|
71
42
|
*/
|
|
72
43
|
export declare function writeOpencodeConfigJson(nodeWorkDir: string, preset: OpencodePreset): string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleep2agi/agent-network",
|
|
3
|
-
"version": "2.3.0-preview.
|
|
4
|
-
"description": "AI Agent Network CLI — Local-first multi-agent orchestration across Claude
|
|
3
|
+
"version": "2.3.0-preview.29",
|
|
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"
|
|
@@ -85,4 +81,4 @@
|
|
|
85
81
|
"hono": "^4.12.21",
|
|
86
82
|
"qs": "^6.15.2"
|
|
87
83
|
}
|
|
88
|
-
}
|
|
84
|
+
}
|
|
@@ -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>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare const OPENCODE_AGENT_NETWORK_VERSION = "2.3.0-preview.27";
|
|
2
|
-
export declare const OPENCODE_AGENT_NODE_VERSION = "2.5.0-preview.23";
|
|
3
|
-
export declare const OPENCODE_AGENT_NODE_SPEC = "@sleep2agi/agent-node@2.5.0-preview.23";
|
|
4
|
-
export declare function opencodeExactPairInstallCommand(): string;
|
|
5
|
-
/** Runtime capability advertised by agent-node's operator-facing help. */
|
|
6
|
-
export declare function agentNodeHelpSupportsOpencode(help: string): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Resolve a package-owned agent-node entrypoint and verify its immutable
|
|
9
|
-
* release identity before it can receive `opencode-cli`. Capability text is
|
|
10
|
-
* not a security boundary: an older preview already advertised the runtime.
|
|
11
|
-
*/
|
|
12
|
-
export declare function validateAgentNodePackageEntrypoint(rawEntrypoint: string, packageSpec: string, expectedVersion?: string, forbiddenRoots?: readonly string[]): string;
|
|
13
|
-
/** Skip invalid/local PATH shims and return the first exact trusted package. */
|
|
14
|
-
export declare function resolveAgentNodePackageEntrypointFromPath(searchPath: string, packageSpec: string, expectedVersion: string, forbiddenRoots?: readonly string[]): string;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { OpencodePresetId } from "./opencode-preset";
|
|
2
|
-
export declare const OPENCODE_AUTH_LOGIN_ROOT_PREFIX = "opencode-auth-login-";
|
|
3
|
-
export declare const OPENCODE_AUTH_LOGIN_OWNER_FILE = ".owner.json";
|
|
4
|
-
export declare const OPENCODE_AUTH_LOGIN_CLEANUP_PREFIX = ".anet-opencode-auth-cleanup-";
|
|
5
|
-
export interface OpencodeAuthLoginSandbox {
|
|
6
|
-
readonly nodeWorkDir: string;
|
|
7
|
-
readonly provider: OpencodePresetId;
|
|
8
|
-
readonly root: string;
|
|
9
|
-
readonly cwd: string;
|
|
10
|
-
readonly authPath: string;
|
|
11
|
-
readonly env: Readonly<NodeJS.ProcessEnv>;
|
|
12
|
-
}
|
|
13
|
-
export interface CreateOpencodeAuthLoginSandboxOptions {
|
|
14
|
-
nodeWorkDir: string;
|
|
15
|
-
provider: OpencodePresetId | string;
|
|
16
|
-
parentEnv?: NodeJS.ProcessEnv;
|
|
17
|
-
/** Internal/test-only trusted external base override. */
|
|
18
|
-
launchBase?: string;
|
|
19
|
-
}
|
|
20
|
-
export interface OpencodeAuthLoginCredential {
|
|
21
|
-
provider: OpencodePresetId;
|
|
22
|
-
type: "api";
|
|
23
|
-
key: string;
|
|
24
|
-
}
|
|
25
|
-
/** Deterministic exact-1.18.1 login argv for the selected API-key flow. */
|
|
26
|
-
export declare function buildOpencodeAuthLoginArgs(provider: OpencodePresetId | string): string[];
|
|
27
|
-
/** Prepare a fresh, node-scoped environment for one interactive login. */
|
|
28
|
-
export declare function createOpencodeAuthLoginSandbox(options: CreateOpencodeAuthLoginSandboxOptions): OpencodeAuthLoginSandbox;
|
|
29
|
-
/** Repeat external-root ancestor and inode validation immediately before the
|
|
30
|
-
* vetted upstream binary is spawned. */
|
|
31
|
-
export declare function revalidateOpencodeAuthLoginSandbox(sandbox: OpencodeAuthLoginSandbox): void;
|
|
32
|
-
/**
|
|
33
|
-
* Read only the selected provider's exact API-key shape from the fresh root.
|
|
34
|
-
* OAuth/browser-login records and mixed/multi-provider documents are refused.
|
|
35
|
-
*/
|
|
36
|
-
export declare function readOpencodeAuthLoginCredential(sandbox: OpencodeAuthLoginSandbox): OpencodeAuthLoginCredential;
|
|
37
|
-
/** Safely remove a sandbox created by this process. Idempotent after removal. */
|
|
38
|
-
export declare function cleanupOpencodeAuthLoginSandbox(sandbox: OpencodeAuthLoginSandbox): void;
|
|
39
|
-
/**
|
|
40
|
-
* Lifecycle helper for CLI integration. Spawn/wait/read the credential inside
|
|
41
|
-
* `action`; the fresh tree is cleaned on success, child failure, or throw.
|
|
42
|
-
*/
|
|
43
|
-
export declare function withOpencodeAuthLoginSandbox<T>(options: CreateOpencodeAuthLoginSandboxOptions, action: (sandbox: OpencodeAuthLoginSandbox) => T | Promise<T>): Promise<T>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Process-loader hooks that must never cross the opencode-cli launcher
|
|
3
|
-
* boundary. The exact agent-node package/entrypoint check happens before the
|
|
4
|
-
* node profile env is merged; allowing that profile to supply one of these
|
|
5
|
-
* variables would let code run before the verified entrypoint's first line.
|
|
6
|
-
*/
|
|
7
|
-
export declare const OPENCODE_AGENT_NODE_LOADER_ENV_KEYS: readonly ["NODE_OPTIONS", "NODE_PATH", "NODE_V8_COVERAGE", "NODE_REDIRECT_WARNINGS", "NODE_COMPILE_CACHE", "BUN_OPTIONS", "BUN_PRELOAD", "LD_PRELOAD", "LD_LIBRARY_PATH", "LD_AUDIT", "LD_DEBUG_OUTPUT", "DYLD_INSERT_LIBRARIES", "DYLD_LIBRARY_PATH", "DYLD_FRAMEWORK_PATH", "DYLD_FALLBACK_LIBRARY_PATH", "OPENSSL_CONF", "OPENSSL_ENGINES", "OPENSSL_MODULES"];
|
|
8
|
-
/**
|
|
9
|
-
* Return a child env that preserves the launcher's original executable search
|
|
10
|
-
* path and removes pre-entrypoint loader/write hooks. Other operator settings
|
|
11
|
-
* (locale, proxy, custom CA, channel integration) remain backward-compatible.
|
|
12
|
-
*/
|
|
13
|
-
export declare function hardenOpencodeAgentNodeEnv(source: NodeJS.ProcessEnv, launcherPath: string | undefined): NodeJS.ProcessEnv;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/** Linux user-private-group compatibility for ordinary umask 0002 installs. */
|
|
2
|
-
export declare function opencodeOwnedPathModeIsSafe(stat: {
|
|
3
|
-
uid: number;
|
|
4
|
-
gid: number;
|
|
5
|
-
mode: number | bigint;
|
|
6
|
-
}, runtimeUid?: number | undefined, runtimeGid?: number | undefined): boolean;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export interface ValidateOpencodePackageBinaryOptions {
|
|
2
|
-
expectedVersion: string;
|
|
3
|
-
/** A package payload may not be inside, or contain, the current project or
|
|
4
|
-
* node state tree. This rejects project-local same-version impersonators. */
|
|
5
|
-
forbiddenRoots?: readonly string[];
|
|
6
|
-
}
|
|
7
|
-
/** Current cwd plus every enclosing source-workspace boundary. This catches a
|
|
8
|
-
* monorepo root's node_modules when anet is invoked from packages/app. */
|
|
9
|
-
export declare function discoverOpencodeForbiddenRoots(cwd?: string): string[];
|
|
10
|
-
/**
|
|
11
|
-
* Bind an executable to the exact npm `opencode-ai` payload identity.
|
|
12
|
-
*
|
|
13
|
-
* `--version` output alone is not an identity boundary: a checkout can put a
|
|
14
|
-
* same-version credential-stealing shim first on PATH. Only the canonical
|
|
15
|
-
* package entrypoint with matching package metadata and trusted path modes is
|
|
16
|
-
* admitted. The returned path is the one callers must spawn verbatim.
|
|
17
|
-
*/
|
|
18
|
-
export declare function validateOpencodePackageBinary(rawBinary: string, options: ValidateOpencodePackageBinaryOptions): string;
|
|
19
|
-
/** Resolve the first *valid package-owned* OpenCode entry on PATH. Invalid
|
|
20
|
-
* project-local shims are skipped so a later trusted global install can win. */
|
|
21
|
-
export declare function resolveOpencodePackageBinaryFromPath(searchPath: string, options: ValidateOpencodePackageBinaryOptions): string;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/** Exact 1.18.1 project/instruction discovery surface plus project-root
|
|
2
|
-
* redirects. Any existing entry, including a broken symlink, is a refusal. */
|
|
3
|
-
export declare const OPENCODE_SAFE_ANCESTOR_CANDIDATES: readonly ["opencode.jsonc", "opencode.json", ".opencode", "AGENTS.md", "CLAUDE.md", "CONTEXT.md", ".claude", ".agents", ".git"];
|
|
4
|
-
interface PathIdentity {
|
|
5
|
-
path: string;
|
|
6
|
-
dev: number | bigint;
|
|
7
|
-
ino: number | bigint;
|
|
8
|
-
}
|
|
9
|
-
export interface OpencodeSafeExternalRoot {
|
|
10
|
-
readonly base: string;
|
|
11
|
-
readonly root: string;
|
|
12
|
-
readonly cwd: string;
|
|
13
|
-
readonly dev: number | bigint;
|
|
14
|
-
readonly ino: number | bigint;
|
|
15
|
-
readonly baseDev: number | bigint;
|
|
16
|
-
readonly baseIno: number | bigint;
|
|
17
|
-
readonly ancestors: readonly PathIdentity[];
|
|
18
|
-
}
|
|
19
|
-
export declare function resolveOpencodeTrustedRuntimeBase(explicit?: string): PathIdentity;
|
|
20
|
-
export declare function createOpencodeSafeExternalRoot(options: {
|
|
21
|
-
prefix: string;
|
|
22
|
-
boundaries?: readonly string[];
|
|
23
|
-
base?: string;
|
|
24
|
-
}): OpencodeSafeExternalRoot;
|
|
25
|
-
export declare function revalidateOpencodeSafeExternalRoot(context: OpencodeSafeExternalRoot): void;
|
|
26
|
-
export declare function cleanupOpencodeSafeExternalRoot(context: OpencodeSafeExternalRoot): void;
|
|
27
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function buildOpencodeSmokeEnv(parentEnv: NodeJS.ProcessEnv, smokeRoot: string, cwd?: string): NodeJS.ProcessEnv;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { RuntimeName } from "./normalize-runtime";
|
|
2
|
-
export interface RuntimeChoice {
|
|
3
|
-
value: RuntimeName;
|
|
4
|
-
name: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Single source of truth for every `anet node create` runtime picker.
|
|
8
|
-
*
|
|
9
|
-
* Keep this exact and ordered: the release gate imports this pure module to
|
|
10
|
-
* prove that the rendered seven-way preview picker has neither a missing
|
|
11
|
-
* OpenCode entry nor an unreviewed eighth choice.
|
|
12
|
-
*/
|
|
13
|
-
export declare const RUNTIME_CHOICES: readonly RuntimeChoice[];
|
|
14
|
-
/** Inquirer mutates choice objects in some prompt paths; return fresh rows. */
|
|
15
|
-
export declare function createRuntimeChoices(): RuntimeChoice[];
|