@sleep2agi/agent-network 2.3.0-preview.28 → 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 -7
- 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/codex-app-server-release.d.ts +0 -17
- 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_0x6498e1=a0_0x12a8;(function(_0x244026,_0x4b000b){const _0x1e3187=a0_0x12a8,_0x36596e=_0x244026();while(!![]){try{const _0x243d7b=-parseInt(_0x1e3187(0x1da))/0x1*(-parseInt(_0x1e3187(0x24d))/0x2)+-parseInt(_0x1e3187(0x21c))/0x3+parseInt(_0x1e3187(0x231))/0x4*(parseInt(_0x1e3187(0x22e))/0x5)+parseInt(_0x1e3187(0x1d5))/0x6+-parseInt(_0x1e3187(0x1c7))/0x7*(-parseInt(_0x1e3187(0x252))/0x8)+-parseInt(_0x1e3187(0x1d1))/0x9*(-parseInt(_0x1e3187(0x210))/0xa)+-parseInt(_0x1e3187(0x1d8))/0xb;if(_0x243d7b===_0x4b000b)break;else _0x36596e['push'](_0x36596e['shift']());}catch(_0x2aee3d){_0x36596e['push'](_0x36596e['shift']());}}}(a0_0x53f1,0xc5d48));import{readFileSync as a0_0x3142f2,existsSync as a0_0x5942ba}from'fs';import{randomUUID as a0_0x4dbfec}from'crypto';import{join as a0_0x2f0246}from'path';import{hostname as a0_0x1a2197}from'os';import{execSync as a0_0x5ceba6}from'child_process';function B(_0x3959b2){const _0x5d9373=a0_0x12a8;let _0x1f4ad=_0x3959b2[_0x5d9373(0x24f)](/[^a-zA-Z0-9\-_]/g,'-');return _0x1f4ad===''?_0x5d9373(0x202):_0x1f4ad;}import{Server as a0_0x5309a2}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x5852f2}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0xf8f288,CallToolRequestSchema as a0_0x32ca40}from'@modelcontextprotocol/sdk/types.js';function T(_0x46458a){const _0x462a9a=a0_0x12a8;if(!a0_0x5942ba(_0x46458a))return;for(let _0x5c230a of a0_0x3142f2(_0x46458a,_0x462a9a(0x1c3))[_0x462a9a(0x257)]('\x0a')){let _0x2cb8bd=_0x5c230a[_0x462a9a(0x226)]();if(!_0x2cb8bd||_0x2cb8bd[_0x462a9a(0x1f7)]('#'))continue;let _0x3e9534=_0x2cb8bd[_0x462a9a(0x266)]('=');if(_0x3e9534<0x0)continue;let _0x300125=_0x2cb8bd['slice'](0x0,_0x3e9534)['trim'](),_0x5938df=_0x2cb8bd[_0x462a9a(0x1d4)](_0x3e9534+0x1)[_0x462a9a(0x226)]()[_0x462a9a(0x24f)](/^["']|["']$/g,'');if(!process.env[_0x300125])process.env[_0x300125]=_0x5938df;}}var C=process.env.HOME||'~',r=a0_0x2f0246(C,a0_0x6498e1(0x20a));T(a0_0x2f0246(r,a0_0x6498e1(0x1dc)));var H=B(process[a0_0x6498e1(0x211)]());T(a0_0x2f0246(r,H,'.env'));function E(){const _0x52b40c=a0_0x6498e1;try{return a0_0x5ceba6(_0x52b40c(0x1ed),{'encoding':_0x52b40c(0x1c3),'timeout':0x7d0})['trim']();}catch{return'';}}function a0_0x53f1(){const _0xeed2d4=['error','set','stdin','blocked','working','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','unknown','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','normal','SSE\x20stream\x20ended,\x20reconnecting...','initialize','stringify','SIGINT','alias','.claude/channels/commhub','low','parent\x20claude\x20died\x20(reparented\x20to\x20PID\x201\x20from\x20','unref','pop','setRequestHandler','50Ctymru','cwd','Reply\x20text\x20/\x20result\x20summary','Target\x20session\x20alias','failed','get_all_status','then','string','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20','connected','unattributed-','\x20no\x20longer\x20exists\x20(kill-0\x20ESRCH)\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','1221624luWVXO','result','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a','status','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','decode','read','POST','data:\x20','commhub_send_task','trim','text','\x20ALIAS=','high','now','Authorization','application/json,\x20text/event-stream','config.json','10kdyvHw','find','MCP\x20stdio\x20connected','312844pGGcDy','number','body','Progress\x200-100','2025-03-26','\x20priority=','unknown\x20tool','send_task','2.0','connect','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','Task\x20content','notification','kill',']\x20[commhub]\x20','get_inbox','no\x20response','ack_inbox','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','exit','SIGTERM','←\x20message\x20from\x20','SSE\x20fatal:\x20','broadcast','0.3.0','priority',':\x20inbox_count=','session\x20disconnected','1710746VnojtZ','catch','replace','commhub-channel',')\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','6421688SsHKdT','application/json','ppid','\x22\x20after\x20SSE\x20reconnect','Current\x20task\x20description','split','messages','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','CommHub\x20init\x20failed:\x20','task','Priority\x20(default:\x20normal)','token','ESRCH','re-register\x20failed:\x20','SSE\x20connected\x20as\x20\x22','commhub_send_message','content','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','\x20/\x20hostname=','\x20RESUME_ID=','indexOf','Message\x20content','join','completed','report_status','hub','utf-8','.anet','parent\x20claude\x20pid=','code','14kDZzqc','min','connecting\x20to\x20','object','send_message','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','toTimeString','\x20PROJECT_ENV=','fatal:\x20','ENV:\x20URL=','2638206XcefbA','offline','statusText','slice','212784AsyGnN','pid','commhub_reply','31909141PJwLmA','\x20CWD=','1suwBDk','from','.env','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','delete','get','idle',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','claude-code','SSE\x20error:\x20','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','type','Session\x20alias:\x20','\x20from\x20','(none)','parse','stderr','→\x20injected\x20task\x20','tools/call','tmux\x20display-message\x20-p\x20\x27#S\x27','Bearer\x20','from_session','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','commhub_get_all_status','SSE\x20connection\x20error:\x20','commhub','ready\x20—\x20waiting\x20for\x20events','write','registered\x20as\x20\x22','startsWith','message','message_id','\x22\x20(','new_task'];a0_0x53f1=function(){return _0xeed2d4;};return a0_0x53f1();}function _(){const _0x1dd500=a0_0x6498e1;try{let _0x8420f8=a0_0x2f0246(C,_0x1dd500(0x1c4),_0x1dd500(0x22d));if(a0_0x5942ba(_0x8420f8))return JSON['parse'](a0_0x3142f2(_0x8420f8,_0x1dd500(0x1c3)));}catch{}return{};}var R=_(),Y=process.env.COMMHUB_URL||R[a0_0x6498e1(0x1c2)]||'http://127.0.0.1:9200',j=process.env.COMMHUB_TMUX||E();function S(){const _0x3a076e=a0_0x6498e1;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x3a076e(0x226)]())return process.env.COMMHUB_ALIAS[_0x3a076e(0x226)]();return process[_0x3a076e(0x1ea)][_0x3a076e(0x1f5)](_0x3a076e(0x218)+(_0x3a076e(0x23b)+(j||_0x3a076e(0x1e8))+_0x3a076e(0x264)+a0_0x1a2197()+_0x3a076e(0x21e))),_0x3a076e(0x21a)+process[_0x3a076e(0x1d6)];}var p=S(),V=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x4dbfec(),k=process.env.COMMHUB_TOKEN||R[a0_0x6498e1(0x25d)]||'';function z(_0x2c5ae9){const _0x57a4a3=a0_0x6498e1;let _0x3d1a51=new Date()[_0x57a4a3(0x1cd)]()[_0x57a4a3(0x1d4)](0x0,0x8);process[_0x57a4a3(0x1ea)][_0x57a4a3(0x1f5)]('['+_0x3d1a51+_0x57a4a3(0x23f)+_0x2c5ae9+'\x0a');}function i(_0x7acbf4){return new Promise(_0x918c4d=>setTimeout(_0x918c4d,_0x7acbf4));}z(a0_0x6498e1(0x1d0)+Y+a0_0x6498e1(0x228)+p+a0_0x6498e1(0x265)+V['slice'](0x0,0x8)+'...\x20TMUX='+(j||'none')+a0_0x6498e1(0x1d9)+process['cwd']()+a0_0x6498e1(0x1ce)+H);function a0_0x12a8(_0x42932b,_0x168bc2){_0x42932b=_0x42932b-0x1c2;const _0x53f185=a0_0x53f1();let _0x12a8f5=_0x53f185[_0x42932b];return _0x12a8f5;}var G=new Map(),K=new a0_0x5309a2({'name':a0_0x6498e1(0x250),'version':a0_0x6498e1(0x249)},{'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_0x6498e1(0x201),a0_0x6498e1(0x1dd),a0_0x6498e1(0x1cc),a0_0x6498e1(0x1e6)+p][a0_0x6498e1(0x268)]('\x0a')});K[a0_0x6498e1(0x20f)](a0_0xf8f288,async()=>({'tools':[{'name':a0_0x6498e1(0x1d7),'description':a0_0x6498e1(0x259),'inputSchema':{'type':a0_0x6498e1(0x1ca),'properties':{'task_id':{'type':a0_0x6498e1(0x217),'description':'The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)'},'text':{'type':a0_0x6498e1(0x217),'description':a0_0x6498e1(0x212)},'status':{'type':a0_0x6498e1(0x217),'enum':[a0_0x6498e1(0x269),'failed','cancelled','blocked',a0_0x6498e1(0x1fc),'in_progress'],'description':a0_0x6498e1(0x203)}},'required':[a0_0x6498e1(0x227)]}},{'name':'commhub_report_status','description':a0_0x6498e1(0x1e4),'inputSchema':{'type':a0_0x6498e1(0x1ca),'properties':{'status':{'type':a0_0x6498e1(0x217),'enum':[a0_0x6498e1(0x200),a0_0x6498e1(0x1e0),a0_0x6498e1(0x1ff),a0_0x6498e1(0x1fc)]},'task':{'type':a0_0x6498e1(0x217),'description':a0_0x6498e1(0x256)},'progress':{'type':a0_0x6498e1(0x232),'description':a0_0x6498e1(0x234)}},'required':[a0_0x6498e1(0x21f)]}},{'name':a0_0x6498e1(0x225),'description':a0_0x6498e1(0x243),'inputSchema':{'type':'object','properties':{'alias':{'type':a0_0x6498e1(0x217),'description':a0_0x6498e1(0x213)},'task':{'type':a0_0x6498e1(0x217),'description':a0_0x6498e1(0x23c)},'priority':{'type':a0_0x6498e1(0x217),'enum':[a0_0x6498e1(0x229),'normal',a0_0x6498e1(0x20b)],'description':a0_0x6498e1(0x25c)}},'required':[a0_0x6498e1(0x209),a0_0x6498e1(0x25b)]}},{'name':'commhub_send_message','description':a0_0x6498e1(0x220),'inputSchema':{'type':a0_0x6498e1(0x1ca),'properties':{'alias':{'type':a0_0x6498e1(0x217),'description':a0_0x6498e1(0x213)},'message':{'type':'string','description':a0_0x6498e1(0x267)}},'required':[a0_0x6498e1(0x209),a0_0x6498e1(0x1f8)]}},{'name':'commhub_get_all_status','description':a0_0x6498e1(0x1f0),'inputSchema':{'type':a0_0x6498e1(0x1ca),'properties':{}}}]}));async function Q(_0x4e0162,_0x2255aa){const _0x30caa0=a0_0x6498e1;let _0xaa0c0f=await fetch(Y+'/mcp',{'method':_0x30caa0(0x223),'headers':{'Content-Type':_0x30caa0(0x253),'Accept':_0x30caa0(0x22c),...k?{'Authorization':_0x30caa0(0x1ee)+k}:{}},'body':JSON['stringify']({'jsonrpc':_0x30caa0(0x239),'id':0x1,'method':_0x30caa0(0x206),'params':{'protocolVersion':_0x30caa0(0x235),'capabilities':{},'clientInfo':{'name':'commhub-channel','version':_0x30caa0(0x249)}}})});if(!_0xaa0c0f['ok']){let _0x7422ca=await _0xaa0c0f[_0x30caa0(0x227)]();return z(_0x30caa0(0x25a)+_0xaa0c0f['status']+'\x20'+_0x7422ca[_0x30caa0(0x1d4)](0x0,0x64)),{'ok':!0x1,'error':'init\x20failed:\x20'+_0xaa0c0f[_0x30caa0(0x21f)]};}await _0xaa0c0f['text']();let _0x449b1f=(await(await fetch(Y+'/mcp',{'method':_0x30caa0(0x223),'headers':{'Content-Type':'application/json','Accept':_0x30caa0(0x22c),...k?{'Authorization':_0x30caa0(0x1ee)+k}:{}},'body':JSON[_0x30caa0(0x207)]({'jsonrpc':'2.0','id':0x2,'method':_0x30caa0(0x1ec),'params':{'name':_0x4e0162,'arguments':_0x2255aa}})}))[_0x30caa0(0x227)]())[_0x30caa0(0x257)]('\x0a')[_0x30caa0(0x22f)](_0x1f716d=>_0x1f716d[_0x30caa0(0x1f7)](_0x30caa0(0x224)));if(_0x449b1f){let _0x414ea9=JSON[_0x30caa0(0x1e9)](_0x449b1f['slice'](0x6));return _0x414ea9?.[_0x30caa0(0x21d)]?.['content']?.[0x0]?.[_0x30caa0(0x227)]?JSON[_0x30caa0(0x1e9)](_0x414ea9[_0x30caa0(0x21d)]['content'][0x0][_0x30caa0(0x227)]):_0x414ea9;}return{'ok':!0x1,'error':_0x30caa0(0x241)};}K[a0_0x6498e1(0x20f)](a0_0x32ca40,async _0x466126=>{const _0x3a4aa8=a0_0x6498e1;let {name:_0x50c34b,arguments:_0x1b3012}=_0x466126['params'];if(_0x50c34b===_0x3a4aa8(0x1d7)){let {task_id:_0x147a32,text:_0x171793,status:_0x5130bc}=_0x1b3012;if(_0x5130bc===_0x3a4aa8(0x269)||_0x5130bc===_0x3a4aa8(0x214)||_0x5130bc==='cancelled'){let _0x47123b=_0x5130bc==='completed'?'replied':_0x5130bc,_0x542e2c=_0x147a32?G[_0x3a4aa8(0x1df)](_0x147a32)||_0x3a4aa8(0x1c2):'hub',_0x5c7460=await Q('send_reply',{'alias':_0x542e2c,'text':_0x171793,'in_reply_to':_0x147a32||void 0x0,'status':_0x47123b,'from_session':p});if(_0x147a32)G[_0x3a4aa8(0x1de)](_0x147a32);return{'content':[{'type':_0x3a4aa8(0x227),'text':JSON[_0x3a4aa8(0x207)](_0x5c7460)}]};}let _0x491898=await Q('report_status',{'resume_id':V,'alias':p,'status':_0x5130bc===_0x3a4aa8(0x1ff)?_0x3a4aa8(0x1ff):_0x5130bc===_0x3a4aa8(0x1fc)?_0x3a4aa8(0x1fc):'working','task':_0x171793[_0x3a4aa8(0x1d4)](0x0,0xc8),'output':_0x171793});return{'content':[{'type':_0x3a4aa8(0x227),'text':JSON[_0x3a4aa8(0x207)](_0x491898)}]};}if(_0x50c34b==='commhub_report_status'){let {status:_0x427df2,task:_0x36a16d,progress:_0x476ce0}=_0x1b3012,_0x419e82=await Q(_0x3a4aa8(0x26a),{'resume_id':V,'alias':p,'status':_0x427df2,'task':_0x36a16d,'progress':_0x476ce0});return{'content':[{'type':'text','text':JSON[_0x3a4aa8(0x207)](_0x419e82)}]};}if(_0x50c34b==='commhub_send_task'){let {alias:_0x2c34a9,task:_0x46b1bd,priority:_0x5daa19}=_0x1b3012,_0x36f1ba=await Q(_0x3a4aa8(0x238),{'alias':_0x2c34a9,'task':_0x46b1bd,'priority':_0x5daa19||_0x3a4aa8(0x204),'from_session':p});return{'content':[{'type':_0x3a4aa8(0x227),'text':JSON['stringify'](_0x36f1ba)}]};}if(_0x50c34b===_0x3a4aa8(0x261)){let {alias:_0x1f601c,message:_0xbb1133}=_0x1b3012,_0x58fe62=await Q(_0x3a4aa8(0x1cb),{'alias':_0x1f601c,'message':_0xbb1133,'from_session':p});return{'content':[{'type':'text','text':JSON[_0x3a4aa8(0x207)](_0x58fe62)}]};}if(_0x50c34b===_0x3a4aa8(0x1f1)){let _0x36109c=await Q(_0x3a4aa8(0x215),{});return{'content':[{'type':_0x3a4aa8(0x227),'text':JSON['stringify'](_0x36109c)}]};}return{'content':[{'type':_0x3a4aa8(0x227),'text':JSON[_0x3a4aa8(0x207)]({'error':_0x3a4aa8(0x237)})}]};});var D=0x3e8,v=0x7530,O=0x36ee80;async function m(){const _0x3fd6d5=a0_0x6498e1;try{await Q('report_status',{'resume_id':V,'alias':p,'status':_0x3fd6d5(0x1e0),'server':a0_0x1a2197(),'hostname':a0_0x1a2197(),'agent':_0x3fd6d5(0x1e2),'project_dir':process[_0x3fd6d5(0x211)](),'tmux_name':j||void 0x0}),z('re-registered\x20as\x20\x22'+p+_0x3fd6d5(0x255));}catch(_0x2fac46){z(_0x3fd6d5(0x25f)+_0x2fac46);}}async function l(){const _0x5e0fcd=a0_0x6498e1;let _0x6987c7=Y+'/events/'+encodeURIComponent(p),_0x4f6bb4={};if(k)_0x4f6bb4[_0x5e0fcd(0x22b)]=_0x5e0fcd(0x1ee)+k;z(_0x5e0fcd(0x1c9)+_0x6987c7);let _0xc318e1=D,_0x457bba=!0x0,_0x43a182=null;while(!0x0){try{let _0x2679b0=await fetch(_0x6987c7,{'headers':_0x4f6bb4});if(!_0x2679b0['ok']){if(z(_0x5e0fcd(0x1e3)+_0x2679b0[_0x5e0fcd(0x21f)]+'\x20'+_0x2679b0[_0x5e0fcd(0x1d3)]),_0x43a182=_0x43a182??Date[_0x5e0fcd(0x22a)](),Date['now']()-_0x43a182>O){z(_0x5e0fcd(0x263)+Y+_0x5e0fcd(0x1e1));return;}await i(_0xc318e1),_0xc318e1=Math[_0x5e0fcd(0x1c8)](_0xc318e1*0x2,v);continue;}let _0x3923c7=_0x2679b0[_0x5e0fcd(0x233)]['getReader'](),_0x2d73e6=new TextDecoder(),_0x1f50a8='';_0xc318e1=D;while(!0x0){let {done:_0x195078,value:_0x3228b4}=await _0x3923c7[_0x5e0fcd(0x222)]();if(_0x195078)break;_0x1f50a8+=_0x2d73e6[_0x5e0fcd(0x221)](_0x3228b4,{'stream':!0x0});let _0x1cb17d=_0x1f50a8[_0x5e0fcd(0x257)]('\x0a\x0a');_0x1f50a8=_0x1cb17d[_0x5e0fcd(0x20e)]()||'';for(let _0x390013 of _0x1cb17d){let _0x5ec830=_0x390013['split']('\x0a')[_0x5e0fcd(0x22f)](_0xa2fbdd=>_0xa2fbdd[_0x5e0fcd(0x1f7)](_0x5e0fcd(0x224)));if(!_0x5ec830)continue;try{let _0x1567f0=JSON[_0x5e0fcd(0x1e9)](_0x5ec830[_0x5e0fcd(0x1d4)](0x6));if(await A(_0x1567f0),_0x1567f0[_0x5e0fcd(0x1e5)]===_0x5e0fcd(0x219)){if(_0x43a182=null,!_0x457bba)await m();_0x457bba=!0x1;}}catch(_0x1f40e0){z('parse\x20error:\x20'+_0x1f40e0);}}}z(_0x5e0fcd(0x205));}catch(_0xda38da){z(_0x5e0fcd(0x1f2)+_0xda38da);}if(_0x43a182=_0x43a182??Date[_0x5e0fcd(0x22a)](),Date[_0x5e0fcd(0x22a)]()-_0x43a182>O){z(_0x5e0fcd(0x263)+Y+')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。');return;}await i(_0xc318e1),_0xc318e1=Math[_0x5e0fcd(0x1c8)](_0xc318e1*0x2,v);}}async function A(_0xefe6ed){const _0x57ce02=a0_0x6498e1;if(_0xefe6ed[_0x57ce02(0x1e5)]==='connected'){z(_0x57ce02(0x260)+p+'\x22');return;}if(_0xefe6ed[_0x57ce02(0x1e5)]==='new_message'){if(z(_0x57ce02(0x246)+_0xefe6ed[_0x57ce02(0x1db)]+':\x20'+_0xefe6ed[_0x57ce02(0x1f8)][_0x57ce02(0x1d4)](0x0,0x3c)),await K['notification']({'method':'notifications/claude/channel','params':{'content':_0xefe6ed[_0x57ce02(0x1f8)],'meta':{'sender':_0xefe6ed[_0x57ce02(0x1db)]||_0x57ce02(0x1c2),'sender_id':_0x57ce02(0x1f3),'user':_0xefe6ed[_0x57ce02(0x1db)]||'hub','priority':_0x57ce02(0x204)}}}),_0xefe6ed[_0x57ce02(0x1f9)])await Q(_0x57ce02(0x242),{'alias':p,'message_id':_0xefe6ed[_0x57ce02(0x1f9)]});return;}if(_0xefe6ed['type']===_0x57ce02(0x1fb)||_0xefe6ed[_0x57ce02(0x1e5)]===_0x57ce02(0x248)){z('←\x20'+_0xefe6ed[_0x57ce02(0x1e5)]+_0x57ce02(0x24b)+_0xefe6ed['inbox_count']+_0x57ce02(0x236)+(_0xefe6ed[_0x57ce02(0x24a)]||'normal'));let _0x44d95c=await Q(_0x57ce02(0x240),{'alias':p,'limit':0x5});if(_0x44d95c?.['ok']&&_0x44d95c[_0x57ce02(0x258)]?.['length']>0x0)for(let _0x24ef1f of _0x44d95c[_0x57ce02(0x258)]){let _0xd3095f={'sender':_0x24ef1f[_0x57ce02(0x1ef)]||_0x57ce02(0x1c2),'sender_id':_0x57ce02(0x1f3),'user':_0x24ef1f[_0x57ce02(0x1ef)]||'hub','task_id':_0x24ef1f['id'],'priority':_0x24ef1f[_0x57ce02(0x24a)]||_0x57ce02(0x204)};G[_0x57ce02(0x1fd)](_0x24ef1f['id'],_0x24ef1f[_0x57ce02(0x1ef)]||_0x57ce02(0x1c2)),await K[_0x57ce02(0x23d)]({'method':'notifications/claude/channel','params':{'content':_0x24ef1f[_0x57ce02(0x262)],'meta':_0xd3095f}}),z(_0x57ce02(0x1eb)+_0x24ef1f['id'][_0x57ce02(0x1d4)](0x0,0x8)+_0x57ce02(0x1e7)+_0x24ef1f[_0x57ce02(0x1ef)]+':\x20'+_0x24ef1f[_0x57ce02(0x262)][_0x57ce02(0x1d4)](0x0,0x3c)),await Q(_0x57ce02(0x242),{'alias':p,'message_id':_0x24ef1f['id']});}}}async function t(){const _0x45229e=a0_0x6498e1;let _0x21b46a=new a0_0x5852f2();await K[_0x45229e(0x23a)](_0x21b46a),z(_0x45229e(0x230)),z('starting\x20SSE\x20listener...'),l()['catch'](_0x253586=>z(_0x45229e(0x247)+_0x253586)),Q(_0x45229e(0x26a),{'resume_id':V,'alias':p,'status':_0x45229e(0x1e0),'server':a0_0x1a2197(),'hostname':a0_0x1a2197(),'agent':_0x45229e(0x1e2),'project_dir':process[_0x45229e(0x211)](),'tmux_name':j||void 0x0})[_0x45229e(0x216)](()=>z(_0x45229e(0x1f6)+p+_0x45229e(0x1fa)+V['slice'](0x0,0x8)+')'))['catch'](_0x16071d=>z('warning:\x20could\x20not\x20register:\x20'+_0x16071d)),setInterval(()=>{const _0x5c3775=_0x45229e;Q(_0x5c3775(0x26a),{'resume_id':V,'alias':p,'status':_0x5c3775(0x1e0),'server':a0_0x1a2197(),'hostname':a0_0x1a2197(),'agent':_0x5c3775(0x1e2),'project_dir':process[_0x5c3775(0x211)](),'tmux_name':j||void 0x0})[_0x5c3775(0x24e)](_0x337921=>z('heartbeat\x20failed:\x20'+_0x337921));},0x2bf20),z(_0x45229e(0x1f4));}t()['catch'](_0x34b6de=>{const _0x2e4da7=a0_0x6498e1;z(_0x2e4da7(0x1cf)+_0x34b6de),process[_0x2e4da7(0x244)](0x1);});async function b(){const _0x256fdc=a0_0x6498e1;z('shutting\x20down,\x20reporting\x20offline...'),await Q(_0x256fdc(0x26a),{'resume_id':V,'alias':p,'status':_0x256fdc(0x1d2),'task':_0x256fdc(0x24c)})[_0x256fdc(0x24e)](()=>{}),process[_0x256fdc(0x244)](0x0);}process[a0_0x6498e1(0x1fe)]['on']('end',()=>b()),process['on'](a0_0x6498e1(0x245),()=>b()),process['on'](a0_0x6498e1(0x208),()=>b());var d=process[a0_0x6498e1(0x254)];if(d&&d>0x1){let h=setInterval(()=>{const _0x2915d1=a0_0x6498e1;if(process[_0x2915d1(0x254)]===0x1&&d!==0x1){z(_0x2915d1(0x20c)+d+_0x2915d1(0x251)),b();return;}try{process[_0x2915d1(0x23e)](d,0x0);}catch(_0x373226){if(_0x373226?.[_0x2915d1(0x1c6)]===_0x2915d1(0x25e))z(_0x2915d1(0x1c5)+d+_0x2915d1(0x21b)),b();}},0x7530);if(typeof h[a0_0x6498e1(0x20d)]==='function')h[a0_0x6498e1(0x20d)]();}
|
|
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,12 +1,6 @@
|
|
|
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
|
-
/**
|
|
5
|
-
* Runtimes launched through the agent-node supervisor rather than by spawning
|
|
6
|
-
* the Claude Code CLI directly. Keep this predicate exhaustive so adding a
|
|
7
|
-
* runtime cannot silently fall into the Claude launcher branch.
|
|
8
|
-
*/
|
|
9
|
-
export declare function runtimeUsesAgentNode(runtime: RuntimeName): boolean;
|
|
10
4
|
type ProfileLike = {
|
|
11
5
|
runtime?: string;
|
|
12
6
|
codexRuntime?: string;
|
|
@@ -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,17 +0,0 @@
|
|
|
1
|
-
/** Exact RFC-030 release pair validated against the real WebSocket wire. */
|
|
2
|
-
export declare const CODEX_APP_SERVER_CLI_VERSION = "0.144.0";
|
|
3
|
-
export declare const CODEX_APP_SERVER_AGENT_NODE_VERSION = "2.5.0-preview.24";
|
|
4
|
-
export declare const CODEX_APP_SERVER_AGENT_NODE_SPEC = "@sleep2agi/agent-node@2.5.0-preview.24";
|
|
5
|
-
export declare function codexAppServerCliVersion(output: string): string | null;
|
|
6
|
-
export declare function agentNodeHelpSupportsCodexAppServer(help: string): boolean;
|
|
7
|
-
export declare function codexAppServerExactInstallCommand(): string;
|
|
8
|
-
export interface CodexNativeIdentity {
|
|
9
|
-
binary: string;
|
|
10
|
-
packageRoot: string;
|
|
11
|
-
version: string;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Resolve the native executable from an exact global npm package root. The
|
|
15
|
-
* JS/npm shim is never executed with the node token in its environment.
|
|
16
|
-
*/
|
|
17
|
-
export declare function resolveCodexNativeIdentity(npmGlobalRoot: string, expectedVersion?: string, platform?: NodeJS.Platform, arch?: NodeJS.Architecture): CodexNativeIdentity;
|
|
@@ -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.28";
|
|
2
|
-
export declare const OPENCODE_AGENT_NODE_VERSION = "2.5.0-preview.24";
|
|
3
|
-
export declare const OPENCODE_AGENT_NODE_SPEC = "@sleep2agi/agent-node@2.5.0-preview.24";
|
|
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[];
|