@sleep2agi/agent-network 2.3.0-preview.33 → 2.3.0-preview.35
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 +13 -3
- 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 +13 -1
- package/dist/src/opencode-agent-node-pair.d.ts +14 -0
- package/dist/src/opencode-auth-login.d.ts +43 -0
- package/dist/src/opencode-launch-env.d.ts +13 -0
- package/dist/src/opencode-owner-mode.d.ts +6 -0
- package/dist/src/opencode-package-binary.d.ts +21 -0
- package/dist/src/opencode-pin.d.ts +11 -8
- package/dist/src/opencode-preset.d.ts +38 -8
- package/dist/src/opencode-runtime-binding.d.ts +30 -0
- package/dist/src/opencode-safe-root.d.ts +27 -0
- package/dist/src/opencode-smoke-env.d.ts +1 -0
- package/package.json +5 -4
package/dist/src/node-server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
const a0_0x54e1f5=a0_0x57c3;(function(_0x15c99e,_0x41a28b){const _0x111653=a0_0x57c3,_0x4afc6e=_0x15c99e();while(!![]){try{const _0x37480b=parseInt(_0x111653(0x1a5))/0x1+-parseInt(_0x111653(0x1c3))/0x2*(parseInt(_0x111653(0x1bb))/0x3)+-parseInt(_0x111653(0x1a1))/0x4+-parseInt(_0x111653(0x197))/0x5+parseInt(_0x111653(0x167))/0x6+-parseInt(_0x111653(0x16e))/0x7*(-parseInt(_0x111653(0x1d0))/0x8)+parseInt(_0x111653(0x155))/0x9;if(_0x37480b===_0x41a28b)break;else _0x4afc6e['push'](_0x4afc6e['shift']());}catch(_0x183f43){_0x4afc6e['push'](_0x4afc6e['shift']());}}}(a0_0x52e6,0x52061));import{readFileSync as a0_0x21e889,existsSync as a0_0x5352c4}from'fs';import{randomUUID as a0_0xa2952e}from'crypto';import{join as a0_0x133f12}from'path';import{hostname as a0_0x39878a}from'os';import{execSync as a0_0x587a87}from'child_process';function B(_0xc23bf3){const _0x4f280a=a0_0x57c3;let _0x5d337f=_0xc23bf3[_0x4f280a(0x1c4)](/[^a-zA-Z0-9\-_]/g,'-');return _0x5d337f===''?_0x4f280a(0x193):_0x5d337f;}import{Server as a0_0x5a94eb}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x3c9bae}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x114469,CallToolRequestSchema as a0_0x15bb0c}from'@modelcontextprotocol/sdk/types.js';function T(_0x202e25){const _0x4e51c1=a0_0x57c3;if(!a0_0x5352c4(_0x202e25))return;for(let _0x597202 of a0_0x21e889(_0x202e25,_0x4e51c1(0x184))[_0x4e51c1(0x172)]('\x0a')){let _0x1135af=_0x597202['trim']();if(!_0x1135af||_0x1135af['startsWith']('#'))continue;let _0x4b1616=_0x1135af[_0x4e51c1(0x1a8)]('=');if(_0x4b1616<0x0)continue;let _0x88d0c5=_0x1135af[_0x4e51c1(0x1a7)](0x0,_0x4b1616)[_0x4e51c1(0x165)](),_0x57c15e=_0x1135af[_0x4e51c1(0x1a7)](_0x4b1616+0x1)[_0x4e51c1(0x165)]()[_0x4e51c1(0x1c4)](/^["']|["']$/g,'');if(!process.env[_0x88d0c5])process.env[_0x88d0c5]=_0x57c15e;}}var C=process.env.HOME||'~',r=a0_0x133f12(C,a0_0x54e1f5(0x182));T(a0_0x133f12(r,a0_0x54e1f5(0x140)));var H=B(process[a0_0x54e1f5(0x1b7)]());T(a0_0x133f12(r,H,'.env'));function E(){const _0x2af521=a0_0x54e1f5;try{return a0_0x587a87(_0x2af521(0x18b),{'encoding':_0x2af521(0x184),'timeout':0x7d0})[_0x2af521(0x165)]();}catch{return'';}}function _(){const _0x647ff=a0_0x54e1f5;try{let _0x1d5daa=a0_0x133f12(C,_0x647ff(0x15d),'config.json');if(a0_0x5352c4(_0x1d5daa))return JSON[_0x647ff(0x1bd)](a0_0x21e889(_0x1d5daa,_0x647ff(0x184)));}catch{}return{};}var R=_(),Y=process.env.COMMHUB_URL||R[a0_0x54e1f5(0x13f)]||'http://127.0.0.1:9200',j=process.env.COMMHUB_TMUX||E();function S(){const _0x400ec3=a0_0x54e1f5;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x400ec3(0x165)]())return process.env.COMMHUB_ALIAS['trim']();return process[_0x400ec3(0x196)][_0x400ec3(0x15b)]('[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20'+(_0x400ec3(0x185)+(j||'(none)')+'\x20/\x20hostname='+a0_0x39878a()+'.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a')),_0x400ec3(0x176)+process[_0x400ec3(0x1b1)];}function a0_0x57c3(_0x28a39d,_0x8ce590){_0x28a39d=_0x28a39d-0x13c;const _0x52e6af=a0_0x52e6();let _0x57c3a0=_0x52e6af[_0x28a39d];return _0x57c3a0;}var p=S(),V=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0xa2952e(),k=process.env.COMMHUB_TOKEN||R['token']||'';function z(_0x22fd17){const _0x26e951=a0_0x54e1f5;let _0x5b8559=new Date()['toTimeString']()[_0x26e951(0x1a7)](0x0,0x8);process[_0x26e951(0x196)]['write']('['+_0x5b8559+_0x26e951(0x18f)+_0x22fd17+'\x0a');}function i(_0x287030){return new Promise(_0xddb40b=>setTimeout(_0xddb40b,_0x287030));}z(a0_0x54e1f5(0x1a0)+Y+a0_0x54e1f5(0x17e)+p+'\x20RESUME_ID='+V[a0_0x54e1f5(0x1a7)](0x0,0x8)+'...\x20TMUX='+(j||a0_0x54e1f5(0x146))+'\x20CWD='+process[a0_0x54e1f5(0x1b7)]()+'\x20PROJECT_ENV='+H);var G=new Map(),K=new a0_0x5a94eb({'name':a0_0x54e1f5(0x177),'version':a0_0x54e1f5(0x166)},{'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_0x54e1f5(0x1bf),a0_0x54e1f5(0x156),a0_0x54e1f5(0x1b0),'Session\x20alias:\x20'+p][a0_0x54e1f5(0x16f)]('\x0a')});K['setRequestHandler'](a0_0x114469,async()=>({'tools':[{'name':a0_0x54e1f5(0x195),'description':a0_0x54e1f5(0x1ae),'inputSchema':{'type':a0_0x54e1f5(0x1ce),'properties':{'task_id':{'type':a0_0x54e1f5(0x181),'description':'The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)'},'text':{'type':a0_0x54e1f5(0x181),'description':a0_0x54e1f5(0x14b)},'status':{'type':'string','enum':[a0_0x54e1f5(0x19e),a0_0x54e1f5(0x1cb),a0_0x54e1f5(0x152),'blocked','error',a0_0x54e1f5(0x192)],'description':a0_0x54e1f5(0x180)}},'required':[a0_0x54e1f5(0x1c9)]}},{'name':a0_0x54e1f5(0x1b6),'description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':'object','properties':{'status':{'type':'string','enum':['working',a0_0x54e1f5(0x169),a0_0x54e1f5(0x1c8),a0_0x54e1f5(0x13c)]},'task':{'type':'string','description':a0_0x54e1f5(0x1cc)},'progress':{'type':'number','description':'Progress\x200-100'}},'required':[a0_0x54e1f5(0x188)]}},{'name':'commhub_send_task','description':'Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','inputSchema':{'type':'object','properties':{'alias':{'type':'string','description':a0_0x54e1f5(0x160)},'task':{'type':a0_0x54e1f5(0x181),'description':'Task\x20content'},'priority':{'type':a0_0x54e1f5(0x181),'enum':[a0_0x54e1f5(0x17a),a0_0x54e1f5(0x19f),a0_0x54e1f5(0x18d)],'description':a0_0x54e1f5(0x154)}},'required':[a0_0x54e1f5(0x19d),a0_0x54e1f5(0x162)]}},{'name':a0_0x54e1f5(0x1b2),'description':a0_0x54e1f5(0x1cd),'inputSchema':{'type':a0_0x54e1f5(0x1ce),'properties':{'alias':{'type':a0_0x54e1f5(0x181),'description':a0_0x54e1f5(0x160)},'message':{'type':'string','description':a0_0x54e1f5(0x199)}},'required':[a0_0x54e1f5(0x19d),a0_0x54e1f5(0x1b4)]}},{'name':a0_0x54e1f5(0x14d),'description':a0_0x54e1f5(0x178),'inputSchema':{'type':a0_0x54e1f5(0x1ce),'properties':{}}}]}));async function Q(_0x320092,_0x37bf53){const _0x2fbc62=a0_0x54e1f5;let _0x3af874=await fetch(Y+_0x2fbc62(0x170),{'method':'POST','headers':{'Content-Type':'application/json','Accept':_0x2fbc62(0x18c),...k?{'Authorization':_0x2fbc62(0x14f)+k}:{}},'body':JSON[_0x2fbc62(0x151)]({'jsonrpc':_0x2fbc62(0x1ba),'id':0x1,'method':'initialize','params':{'protocolVersion':_0x2fbc62(0x158),'capabilities':{},'clientInfo':{'name':_0x2fbc62(0x177),'version':_0x2fbc62(0x166)}}})});if(!_0x3af874['ok']){let _0x2f3307=await _0x3af874[_0x2fbc62(0x1c9)]();return z('CommHub\x20init\x20failed:\x20'+_0x3af874[_0x2fbc62(0x188)]+'\x20'+_0x2f3307['slice'](0x0,0x64)),{'ok':!0x1,'error':_0x2fbc62(0x18e)+_0x3af874['status']};}await _0x3af874[_0x2fbc62(0x1c9)]();let _0xb39705=(await(await fetch(Y+_0x2fbc62(0x170),{'method':_0x2fbc62(0x161),'headers':{'Content-Type':_0x2fbc62(0x17b),'Accept':_0x2fbc62(0x18c),...k?{'Authorization':_0x2fbc62(0x14f)+k}:{}},'body':JSON[_0x2fbc62(0x151)]({'jsonrpc':_0x2fbc62(0x1ba),'id':0x2,'method':_0x2fbc62(0x168),'params':{'name':_0x320092,'arguments':_0x37bf53}})}))['text']())[_0x2fbc62(0x172)]('\x0a')[_0x2fbc62(0x1af)](_0x3def90=>_0x3def90['startsWith']('data:\x20'));if(_0xb39705){let _0x6b4cfd=JSON['parse'](_0xb39705['slice'](0x6));return _0x6b4cfd?.[_0x2fbc62(0x1bc)]?.[_0x2fbc62(0x175)]?.[0x0]?.[_0x2fbc62(0x1c9)]?JSON[_0x2fbc62(0x1bd)](_0x6b4cfd[_0x2fbc62(0x1bc)][_0x2fbc62(0x175)][0x0][_0x2fbc62(0x1c9)]):_0x6b4cfd;}return{'ok':!0x1,'error':_0x2fbc62(0x1a9)};}function a0_0x52e6(){const _0x2cfeea=['set','session\x20disconnected','Target\x20session\x20alias','POST','task','send_reply','function','trim','0.3.0','3667680wBKPto','tools/call','idle','warning:\x20could\x20not\x20register:\x20','notification','send_message','ready\x20—\x20waiting\x20for\x20events','70896HsJGyx','join','/mcp','min','split','priority','SIGTERM','content','unattributed-','commhub-channel','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','read','high','application/json','end','SSE\x20stream\x20ended,\x20reconnecting...','\x20ALIAS=','\x20from\x20','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','string','.claude/channels/commhub','→\x20injected\x20task\x20','utf-8','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','new_message','body','status','replied','report_status','tmux\x20display-message\x20-p\x20\x27#S\x27','application/json,\x20text/event-stream','low','init\x20failed:\x20',']\x20[commhub]\x20','stdin','from','in_progress','unknown','connected','commhub_reply','stderr','2480565lDZlnY','parent\x20claude\x20died\x20(reparented\x20to\x20PID\x201\x20from\x20','Message\x20content','starting\x20SSE\x20listener...','SSE\x20connected\x20as\x20\x22','shutting\x20down,\x20reporting\x20offline...','alias','completed','normal','ENV:\x20URL=','653212DDtrfj','parent\x20claude\x20pid=','setRequestHandler','connect','132387UNEyXD','ack_inbox','slice','indexOf','no\x20response','offline','now',':\x20inbox_count=','type','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','find','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','pid','commhub_send_message','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','message','\x20no\x20longer\x20exists\x20(kill-0\x20ESRCH)\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','commhub_report_status','cwd','←\x20message\x20from\x20','new_task','2.0','42gNfbWA','result','parse','re-registered\x20as\x20\x22','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','catch','get_inbox','parse\x20error:\x20','38772bUdwMc','replace','messages','message_id','pop','blocked','text','MCP\x20stdio\x20connected','failed','Current\x20task\x20description','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','object','ESRCH','200XgBwJn','delete','registered\x20as\x20\x22','error',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','startsWith','hub','.env','unref','get','ppid','length','exit','none','connecting\x20to\x20','notifications/claude/channel','then','claude-code','Reply\x20text\x20/\x20result\x20summary','SSE\x20error:\x20','commhub_get_all_status','re-register\x20failed:\x20','Bearer\x20','kill','stringify','cancelled','params','Priority\x20(default:\x20normal)','2429298YwbcbA','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','getReader','2025-03-26','SSE\x20connection\x20error:\x20','commhub_send_task','write','from_session','.anet'];a0_0x52e6=function(){return _0x2cfeea;};return a0_0x52e6();}K[a0_0x54e1f5(0x1a3)](a0_0x15bb0c,async _0x2f7a11=>{const _0x57282c=a0_0x54e1f5;let {name:_0x283b21,arguments:_0x147151}=_0x2f7a11[_0x57282c(0x153)];if(_0x283b21==='commhub_reply'){let {task_id:_0x14ebe7,text:_0x112722,status:_0x1a6a63}=_0x147151;if(_0x1a6a63==='completed'||_0x1a6a63===_0x57282c(0x1cb)||_0x1a6a63==='cancelled'){let _0x54c4a8=_0x1a6a63===_0x57282c(0x19e)?_0x57282c(0x189):_0x1a6a63,_0x242d74=_0x14ebe7?G[_0x57282c(0x142)](_0x14ebe7)||_0x57282c(0x13f):_0x57282c(0x13f),_0x5e1a5b=await Q(_0x57282c(0x163),{'alias':_0x242d74,'text':_0x112722,'in_reply_to':_0x14ebe7||void 0x0,'status':_0x54c4a8,'from_session':p});if(_0x14ebe7)G[_0x57282c(0x1d1)](_0x14ebe7);return{'content':[{'type':_0x57282c(0x1c9),'text':JSON[_0x57282c(0x151)](_0x5e1a5b)}]};}let _0x624518=await Q('report_status',{'resume_id':V,'alias':p,'status':_0x1a6a63===_0x57282c(0x1c8)?_0x57282c(0x1c8):_0x1a6a63===_0x57282c(0x13c)?_0x57282c(0x13c):'working','task':_0x112722[_0x57282c(0x1a7)](0x0,0xc8),'output':_0x112722});return{'content':[{'type':_0x57282c(0x1c9),'text':JSON[_0x57282c(0x151)](_0x624518)}]};}if(_0x283b21===_0x57282c(0x1b6)){let {status:_0x765cd4,task:_0x23249e,progress:_0xf8040f}=_0x147151,_0x301e7d=await Q(_0x57282c(0x18a),{'resume_id':V,'alias':p,'status':_0x765cd4,'task':_0x23249e,'progress':_0xf8040f});return{'content':[{'type':_0x57282c(0x1c9),'text':JSON[_0x57282c(0x151)](_0x301e7d)}]};}if(_0x283b21===_0x57282c(0x15a)){let {alias:_0x1d8a09,task:_0x20db38,priority:_0x33e1ae}=_0x147151,_0x69a594=await Q('send_task',{'alias':_0x1d8a09,'task':_0x20db38,'priority':_0x33e1ae||_0x57282c(0x19f),'from_session':p});return{'content':[{'type':_0x57282c(0x1c9),'text':JSON[_0x57282c(0x151)](_0x69a594)}]};}if(_0x283b21===_0x57282c(0x1b2)){let {alias:_0x58032f,message:_0x82ad7}=_0x147151,_0x1a17dc=await Q(_0x57282c(0x16c),{'alias':_0x58032f,'message':_0x82ad7,'from_session':p});return{'content':[{'type':_0x57282c(0x1c9),'text':JSON[_0x57282c(0x151)](_0x1a17dc)}]};}if(_0x283b21===_0x57282c(0x14d)){let _0x439d82=await Q('get_all_status',{});return{'content':[{'type':'text','text':JSON['stringify'](_0x439d82)}]};}return{'content':[{'type':'text','text':JSON[_0x57282c(0x151)]({'error':'unknown\x20tool'})}]};});var D=0x3e8,v=0x7530,O=0x36ee80;async function m(){const _0x3e9efd=a0_0x54e1f5;try{await Q(_0x3e9efd(0x18a),{'resume_id':V,'alias':p,'status':_0x3e9efd(0x169),'server':a0_0x39878a(),'hostname':a0_0x39878a(),'agent':'claude-code','project_dir':process[_0x3e9efd(0x1b7)](),'tmux_name':j||void 0x0}),z(_0x3e9efd(0x1be)+p+'\x22\x20after\x20SSE\x20reconnect');}catch(_0x35bc04){z(_0x3e9efd(0x14e)+_0x35bc04);}}async function l(){const _0x569f7b=a0_0x54e1f5;let _0x1945a9=Y+'/events/'+encodeURIComponent(p),_0x196300={};if(k)_0x196300['Authorization']=_0x569f7b(0x14f)+k;z(_0x569f7b(0x147)+_0x1945a9);let _0x1c1831=D,_0x5c3b04=!0x0,_0x136f92=null;while(!0x0){try{let _0x20b769=await fetch(_0x1945a9,{'headers':_0x196300});if(!_0x20b769['ok']){if(z(_0x569f7b(0x14c)+_0x20b769['status']+'\x20'+_0x20b769['statusText']),_0x136f92=_0x136f92??Date['now'](),Date[_0x569f7b(0x1ab)]()-_0x136f92>O){z(_0x569f7b(0x1b3)+Y+')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。');return;}await i(_0x1c1831),_0x1c1831=Math[_0x569f7b(0x171)](_0x1c1831*0x2,v);continue;}let _0x314663=_0x20b769[_0x569f7b(0x187)][_0x569f7b(0x157)](),_0x35ecb6=new TextDecoder(),_0x4ddb95='';_0x1c1831=D;while(!0x0){let {done:_0x1ed64d,value:_0x27257d}=await _0x314663[_0x569f7b(0x179)]();if(_0x1ed64d)break;_0x4ddb95+=_0x35ecb6['decode'](_0x27257d,{'stream':!0x0});let _0x4bfcf7=_0x4ddb95[_0x569f7b(0x172)]('\x0a\x0a');_0x4ddb95=_0x4bfcf7[_0x569f7b(0x1c7)]()||'';for(let _0x302a35 of _0x4bfcf7){let _0xe046ea=_0x302a35[_0x569f7b(0x172)]('\x0a')[_0x569f7b(0x1af)](_0xffc5ec=>_0xffc5ec[_0x569f7b(0x13e)]('data:\x20'));if(!_0xe046ea)continue;try{let _0x5b1d28=JSON[_0x569f7b(0x1bd)](_0xe046ea[_0x569f7b(0x1a7)](0x6));if(await A(_0x5b1d28),_0x5b1d28[_0x569f7b(0x1ad)]===_0x569f7b(0x194)){if(_0x136f92=null,!_0x5c3b04)await m();_0x5c3b04=!0x1;}}catch(_0x1358e6){z(_0x569f7b(0x1c2)+_0x1358e6);}}}z(_0x569f7b(0x17d));}catch(_0x1b4133){z(_0x569f7b(0x159)+_0x1b4133);}if(_0x136f92=_0x136f92??Date[_0x569f7b(0x1ab)](),Date[_0x569f7b(0x1ab)]()-_0x136f92>O){z(_0x569f7b(0x1b3)+Y+_0x569f7b(0x13d));return;}await i(_0x1c1831),_0x1c1831=Math['min'](_0x1c1831*0x2,v);}}async function A(_0x40b414){const _0x11b489=a0_0x54e1f5;if(_0x40b414[_0x11b489(0x1ad)]===_0x11b489(0x194)){z(_0x11b489(0x19b)+p+'\x22');return;}if(_0x40b414[_0x11b489(0x1ad)]===_0x11b489(0x186)){if(z(_0x11b489(0x1b8)+_0x40b414['from']+':\x20'+_0x40b414['message']['slice'](0x0,0x3c)),await K[_0x11b489(0x16b)]({'method':_0x11b489(0x148),'params':{'content':_0x40b414[_0x11b489(0x1b4)],'meta':{'sender':_0x40b414[_0x11b489(0x191)]||'hub','sender_id':'commhub','user':_0x40b414['from']||'hub','priority':_0x11b489(0x19f)}}}),_0x40b414[_0x11b489(0x1c6)])await Q(_0x11b489(0x1a6),{'alias':p,'message_id':_0x40b414[_0x11b489(0x1c6)]});return;}if(_0x40b414['type']===_0x11b489(0x1b9)||_0x40b414[_0x11b489(0x1ad)]==='broadcast'){z('←\x20'+_0x40b414[_0x11b489(0x1ad)]+_0x11b489(0x1ac)+_0x40b414['inbox_count']+'\x20priority='+(_0x40b414[_0x11b489(0x173)]||'normal'));let _0x36ef11=await Q(_0x11b489(0x1c1),{'alias':p,'limit':0x5});if(_0x36ef11?.['ok']&&_0x36ef11['messages']?.[_0x11b489(0x144)]>0x0)for(let _0x367b67 of _0x36ef11[_0x11b489(0x1c5)]){let _0x3b7b27={'sender':_0x367b67[_0x11b489(0x15c)]||'hub','sender_id':'commhub','user':_0x367b67[_0x11b489(0x15c)]||_0x11b489(0x13f),'task_id':_0x367b67['id'],'priority':_0x367b67[_0x11b489(0x173)]||_0x11b489(0x19f)};G[_0x11b489(0x15e)](_0x367b67['id'],_0x367b67[_0x11b489(0x15c)]||_0x11b489(0x13f)),await K[_0x11b489(0x16b)]({'method':_0x11b489(0x148),'params':{'content':_0x367b67[_0x11b489(0x175)],'meta':_0x3b7b27}}),z(_0x11b489(0x183)+_0x367b67['id'][_0x11b489(0x1a7)](0x0,0x8)+_0x11b489(0x17f)+_0x367b67[_0x11b489(0x15c)]+':\x20'+_0x367b67['content']['slice'](0x0,0x3c)),await Q(_0x11b489(0x1a6),{'alias':p,'message_id':_0x367b67['id']});}}}async function t(){const _0x2821ce=a0_0x54e1f5;let _0x4c3ee1=new a0_0x3c9bae();await K[_0x2821ce(0x1a4)](_0x4c3ee1),z(_0x2821ce(0x1ca)),z(_0x2821ce(0x19a)),l()[_0x2821ce(0x1c0)](_0x4b0935=>z('SSE\x20fatal:\x20'+_0x4b0935)),Q(_0x2821ce(0x18a),{'resume_id':V,'alias':p,'status':_0x2821ce(0x169),'server':a0_0x39878a(),'hostname':a0_0x39878a(),'agent':'claude-code','project_dir':process['cwd'](),'tmux_name':j||void 0x0})[_0x2821ce(0x149)](()=>z(_0x2821ce(0x1d2)+p+'\x22\x20('+V['slice'](0x0,0x8)+')'))[_0x2821ce(0x1c0)](_0x5bc0f4=>z(_0x2821ce(0x16a)+_0x5bc0f4)),setInterval(()=>{const _0x5df461=_0x2821ce;Q(_0x5df461(0x18a),{'resume_id':V,'alias':p,'status':_0x5df461(0x169),'server':a0_0x39878a(),'hostname':a0_0x39878a(),'agent':_0x5df461(0x14a),'project_dir':process[_0x5df461(0x1b7)](),'tmux_name':j||void 0x0})['catch'](_0xbe936e=>z('heartbeat\x20failed:\x20'+_0xbe936e));},0x2bf20),z(_0x2821ce(0x16d));}t()[a0_0x54e1f5(0x1c0)](_0x34c1ba=>{const _0x1168ea=a0_0x54e1f5;z('fatal:\x20'+_0x34c1ba),process[_0x1168ea(0x145)](0x1);});async function b(){const _0x272d7e=a0_0x54e1f5;z(_0x272d7e(0x19c)),await Q('report_status',{'resume_id':V,'alias':p,'status':_0x272d7e(0x1aa),'task':_0x272d7e(0x15f)})[_0x272d7e(0x1c0)](()=>{}),process[_0x272d7e(0x145)](0x0);}process[a0_0x54e1f5(0x190)]['on'](a0_0x54e1f5(0x17c),()=>b()),process['on'](a0_0x54e1f5(0x174),()=>b()),process['on']('SIGINT',()=>b());var d=process[a0_0x54e1f5(0x143)];if(d&&d>0x1){let h=setInterval(()=>{const _0x1a98ee=a0_0x54e1f5;if(process[_0x1a98ee(0x143)]===0x1&&d!==0x1){z(_0x1a98ee(0x198)+d+')\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat'),b();return;}try{process[_0x1a98ee(0x150)](d,0x0);}catch(_0x6da9d5){if(_0x6da9d5?.['code']===_0x1a98ee(0x1cf))z(_0x1a98ee(0x1a2)+d+_0x1a98ee(0x1b5)),b();}},0x7530);if(typeof h[a0_0x54e1f5(0x141)]===a0_0x54e1f5(0x164))h[a0_0x54e1f5(0x141)]();}
|
|
2
|
+
const a0_0x59a7e7=a0_0x3ac4;function a0_0x3ac4(_0x5052af,_0x4ceea3){_0x5052af=_0x5052af-0x176;const _0x4c9737=a0_0x4c97();let _0x3ac4ac=_0x4c9737[_0x5052af];return _0x3ac4ac;}(function(_0x2678a8,_0x1e5a10){const _0x41a1fa=a0_0x3ac4,_0xf5dda8=_0x2678a8();while(!![]){try{const _0x1f9874=-parseInt(_0x41a1fa(0x1b4))/0x1+parseInt(_0x41a1fa(0x1e7))/0x2+parseInt(_0x41a1fa(0x17d))/0x3+-parseInt(_0x41a1fa(0x1b3))/0x4+-parseInt(_0x41a1fa(0x1c3))/0x5+parseInt(_0x41a1fa(0x1be))/0x6*(-parseInt(_0x41a1fa(0x1ae))/0x7)+parseInt(_0x41a1fa(0x19f))/0x8;if(_0x1f9874===_0x1e5a10)break;else _0xf5dda8['push'](_0xf5dda8['shift']());}catch(_0x304cdc){_0xf5dda8['push'](_0xf5dda8['shift']());}}}(a0_0x4c97,0x490ef));import{readFileSync as a0_0x442ed9,existsSync as a0_0x398191}from'fs';import{randomUUID as a0_0x2726dc}from'crypto';import{join as a0_0x1576ba}from'path';import{hostname as a0_0x1ca798}from'os';import{execSync as a0_0x136732}from'child_process';function B(_0x4f94ad){const _0x2aee39=a0_0x3ac4;let _0x5fda6d=_0x4f94ad['replace'](/[^a-zA-Z0-9\-_]/g,'-');return _0x5fda6d===''?_0x2aee39(0x1fe):_0x5fda6d;}import{Server as a0_0x129abd}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x93ee58}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x317cc4,CallToolRequestSchema as a0_0x395ef7}from'@modelcontextprotocol/sdk/types.js';function T(_0x5d3a5a){const _0x1451c3=a0_0x3ac4;if(!a0_0x398191(_0x5d3a5a))return;for(let _0x13be43 of a0_0x442ed9(_0x5d3a5a,'utf-8')['split']('\x0a')){let _0x4c6dfd=_0x13be43[_0x1451c3(0x204)]();if(!_0x4c6dfd||_0x4c6dfd[_0x1451c3(0x1df)]('#'))continue;let _0x5612e6=_0x4c6dfd[_0x1451c3(0x212)]('=');if(_0x5612e6<0x0)continue;let _0x4753eb=_0x4c6dfd[_0x1451c3(0x1a9)](0x0,_0x5612e6)[_0x1451c3(0x204)](),_0x1045f7=_0x4c6dfd['slice'](_0x5612e6+0x1)[_0x1451c3(0x204)]()['replace'](/^["']|["']$/g,'');if(!process.env[_0x4753eb])process.env[_0x4753eb]=_0x1045f7;}}var C=process.env.HOME||'~',r=a0_0x1576ba(C,a0_0x59a7e7(0x20a));T(a0_0x1576ba(r,a0_0x59a7e7(0x184)));var H=B(process['cwd']());T(a0_0x1576ba(r,H,'.env'));function E(){const _0x5b6e87=a0_0x59a7e7;try{return a0_0x136732(_0x5b6e87(0x1cd),{'encoding':_0x5b6e87(0x1bb),'timeout':0x7d0})[_0x5b6e87(0x204)]();}catch{return'';}}function _(){const _0x15b08b=a0_0x59a7e7;try{let _0x1a0742=a0_0x1576ba(C,'.anet',_0x15b08b(0x1e3));if(a0_0x398191(_0x1a0742))return JSON[_0x15b08b(0x20b)](a0_0x442ed9(_0x1a0742,_0x15b08b(0x1bb)));}catch{}return{};}var R=_(),Y=process.env.COMMHUB_URL||R[a0_0x59a7e7(0x1c1)]||a0_0x59a7e7(0x1cf),j=process.env.COMMHUB_TMUX||E();function a0_0x4c97(){const _0x353fe7=['send_task','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20','normal','string','type','MCP\x20stdio\x20connected','initialize','alias','cancelled','delete','replied','/mcp','ready\x20—\x20waiting\x20for\x20events','ENV:\x20URL=','inbox_count','unknown','priority','send_reply','from_session','min','commhub_send_task','trim','low','unattributed-','\x20/\x20hostname=','stdin','get','.claude/channels/commhub','parse',')\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','Reply\x20text\x20/\x20result\x20summary','completed','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','send_message','function','indexOf','\x20priority=','high','Progress\x200-100','offline','get_all_status','result','SSE\x20stream\x20ended,\x20reconnecting...','POST','/events/','Authorization','notifications/claude/channel','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','write','1761519bCuMAU','token','0.3.0','Target\x20session\x20alias','\x20CWD=','2025-03-26','content','.env','params','set','warning:\x20could\x20not\x20register:\x20','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','\x20no\x20longer\x20exists\x20(kill-0\x20ESRCH)\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','split','new_task','now','number','cwd','Reply\x20to\x20a\x20CommHub\x20task.\x20Use\x20status=\x22completed\x22\x20(terminal)\x20to\x20push\x20the\x20reply\x20to\x20the\x20Dashboard/sender\x20in\x20real\x20time\x20(send_reply\x20→\x20new_reply\x20SSE);\x20non-terminal\x20status\x20(in_progress/blocked/error)\x20only\x20updates\x20session\x20status\x20(report_status)\x20and\x20does\x20NOT\x20reach\x20the\x20Dashboard.','Session\x20alias:\x20','read','setRequestHandler','status','starting\x20SSE\x20listener...','Reply\x20using\x20the\x20commhub_reply\x20tool.\x20IMPORTANT:\x20to\x20make\x20your\x20reply\x20appear\x20in\x20the\x20Dashboard\x20chat\x20and\x20reach\x20the\x20sender\x20in\x20real\x20time,\x20use\x20status=\x22completed\x22\x20(a\x20terminal\x20status:\x20completed/failed/cancelled)\x20—\x20that\x20routes\x20to\x20send_reply\x20and\x20emits\x20the\x20new_reply\x20SSE\x20event\x20the\x20Dashboard\x20listens\x20for.\x20A\x20non-terminal\x20status\x20(in_progress/blocked/error)\x20only\x20updates\x20your\x20session\x20status\x20via\x20report_status\x20and\x20does\x20NOT\x20show\x20in\x20the\x20Dashboard,\x20even\x20though\x20the\x20call\x20returns\x20ok.','SIGTERM','code','from','notification','init\x20failed:\x20','ack_inbox','shutting\x20down,\x20reporting\x20offline...','idle','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','2736664sFgict','catch','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','working','length','kill','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','claude-code','statusText','slice','text','SSE\x20connected\x20as\x20\x22','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','commhub_get_all_status','1344784iFdJWv','Task\x20content','unref','blocked','commhub_report_status','686992ZthdwB','100101HFThfA','pid','exit','toTimeString','failed',':\x20inbox_count=','parent\x20claude\x20died\x20(reparented\x20to\x20PID\x201\x20from\x20','utf-8','parent\x20claude\x20pid=','parse\x20error:\x20','6cNCaqe','commhub_reply','then','hub','message_id','1639595ONcOfQ','report_status','2.0','Message\x20content','application/json,\x20text/event-stream','Priority\x20(default:\x20normal)','object','SSE\x20fatal:\x20','ESRCH','application/json','tmux\x20display-message\x20-p\x20\x27#S\x27','decode','http://127.0.0.1:9200','broadcast','getReader','data:\x20','connect','registered\x20as\x20\x22','connected','SIGINT','session\x20disconnected','Current\x20task\x20description','body','unknown\x20tool','←\x20message\x20from\x20','fatal:\x20','message','new_message','startsWith',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','end','in_progress','config.json','Bearer\x20','error','find','323742rzIWQH','no\x20response','tools/call','commhub','ppid','\x22\x20(','stringify','commhub_send_message'];a0_0x4c97=function(){return _0x353fe7;};return a0_0x4c97();}function S(){const _0x480196=a0_0x59a7e7;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x480196(0x204)]())return process.env.COMMHUB_ALIAS[_0x480196(0x204)]();return process['stderr'][_0x480196(0x17c)](_0x480196(0x1f0)+('would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME='+(j||'(none)')+_0x480196(0x207)+a0_0x1ca798()+_0x480196(0x1a1))),_0x480196(0x206)+process[_0x480196(0x1b5)];}var p=S(),V=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x2726dc(),k=process.env.COMMHUB_TOKEN||R[a0_0x59a7e7(0x17e)]||'';function z(_0x3ee7cd){const _0x209133=a0_0x59a7e7;let _0x33302d=new Date()[_0x209133(0x1b7)]()[_0x209133(0x1a9)](0x0,0x8);process['stderr']['write']('['+_0x33302d+']\x20[commhub]\x20'+_0x3ee7cd+'\x0a');}function i(_0x5773c4){return new Promise(_0x19a2b7=>setTimeout(_0x19a2b7,_0x5773c4));}z(a0_0x59a7e7(0x1fc)+Y+'\x20ALIAS='+p+'\x20RESUME_ID='+V['slice'](0x0,0x8)+'...\x20TMUX='+(j||'none')+a0_0x59a7e7(0x181)+process[a0_0x59a7e7(0x18e)]()+'\x20PROJECT_ENV='+H);var G=new Map(),K=new a0_0x129abd({'name':'commhub-channel','version':a0_0x59a7e7(0x17f)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x59a7e7(0x1ac),a0_0x59a7e7(0x188),a0_0x59a7e7(0x195),a0_0x59a7e7(0x17b),a0_0x59a7e7(0x190)+p]['join']('\x0a')});K[a0_0x59a7e7(0x192)](a0_0x317cc4,async()=>({'tools':[{'name':a0_0x59a7e7(0x1bf),'description':a0_0x59a7e7(0x18f),'inputSchema':{'type':a0_0x59a7e7(0x1c9),'properties':{'task_id':{'type':a0_0x59a7e7(0x1f2),'description':a0_0x59a7e7(0x1a2)},'text':{'type':a0_0x59a7e7(0x1f2),'description':a0_0x59a7e7(0x20d)},'status':{'type':a0_0x59a7e7(0x1f2),'enum':[a0_0x59a7e7(0x20e),a0_0x59a7e7(0x1b8),a0_0x59a7e7(0x1f7),'blocked','error',a0_0x59a7e7(0x1e2)],'description':a0_0x59a7e7(0x20f)}},'required':[a0_0x59a7e7(0x1aa)]}},{'name':a0_0x59a7e7(0x1b2),'description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':'object','properties':{'status':{'type':a0_0x59a7e7(0x1f2),'enum':[a0_0x59a7e7(0x1a3),a0_0x59a7e7(0x19d),a0_0x59a7e7(0x1b1),a0_0x59a7e7(0x1e5)]},'task':{'type':a0_0x59a7e7(0x1f2),'description':a0_0x59a7e7(0x1d8)},'progress':{'type':a0_0x59a7e7(0x18d),'description':a0_0x59a7e7(0x215)}},'required':[a0_0x59a7e7(0x193)]}},{'name':a0_0x59a7e7(0x203),'description':'Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','inputSchema':{'type':a0_0x59a7e7(0x1c9),'properties':{'alias':{'type':a0_0x59a7e7(0x1f2),'description':a0_0x59a7e7(0x180)},'task':{'type':a0_0x59a7e7(0x1f2),'description':a0_0x59a7e7(0x1af)},'priority':{'type':a0_0x59a7e7(0x1f2),'enum':[a0_0x59a7e7(0x214),a0_0x59a7e7(0x1f1),a0_0x59a7e7(0x205)],'description':a0_0x59a7e7(0x1c8)}},'required':[a0_0x59a7e7(0x1f6),'task']}},{'name':a0_0x59a7e7(0x1ee),'description':'Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','inputSchema':{'type':a0_0x59a7e7(0x1c9),'properties':{'alias':{'type':'string','description':a0_0x59a7e7(0x180)},'message':{'type':'string','description':a0_0x59a7e7(0x1c6)}},'required':[a0_0x59a7e7(0x1f6),a0_0x59a7e7(0x1dd)]}},{'name':a0_0x59a7e7(0x1ad),'description':a0_0x59a7e7(0x19e),'inputSchema':{'type':a0_0x59a7e7(0x1c9),'properties':{}}}]}));async function Q(_0x1cb689,_0x4ec7bc){const _0x1dfb1a=a0_0x59a7e7;let _0x526e20=await fetch(Y+'/mcp',{'method':_0x1dfb1a(0x177),'headers':{'Content-Type':_0x1dfb1a(0x1cc),'Accept':_0x1dfb1a(0x1c7),...k?{'Authorization':'Bearer\x20'+k}:{}},'body':JSON[_0x1dfb1a(0x1ed)]({'jsonrpc':'2.0','id':0x1,'method':_0x1dfb1a(0x1f5),'params':{'protocolVersion':_0x1dfb1a(0x182),'capabilities':{},'clientInfo':{'name':'commhub-channel','version':_0x1dfb1a(0x17f)}}})});if(!_0x526e20['ok']){let _0x483409=await _0x526e20[_0x1dfb1a(0x1aa)]();return z('CommHub\x20init\x20failed:\x20'+_0x526e20[_0x1dfb1a(0x193)]+'\x20'+_0x483409[_0x1dfb1a(0x1a9)](0x0,0x64)),{'ok':!0x1,'error':_0x1dfb1a(0x19a)+_0x526e20['status']};}await _0x526e20[_0x1dfb1a(0x1aa)]();let _0x5d9484=(await(await fetch(Y+_0x1dfb1a(0x1fa),{'method':_0x1dfb1a(0x177),'headers':{'Content-Type':_0x1dfb1a(0x1cc),'Accept':_0x1dfb1a(0x1c7),...k?{'Authorization':_0x1dfb1a(0x1e4)+k}:{}},'body':JSON[_0x1dfb1a(0x1ed)]({'jsonrpc':_0x1dfb1a(0x1c5),'id':0x2,'method':_0x1dfb1a(0x1e9),'params':{'name':_0x1cb689,'arguments':_0x4ec7bc}})}))[_0x1dfb1a(0x1aa)]())[_0x1dfb1a(0x18a)]('\x0a')[_0x1dfb1a(0x1e6)](_0x5827a2=>_0x5827a2['startsWith'](_0x1dfb1a(0x1d2)));if(_0x5d9484){let _0x283166=JSON[_0x1dfb1a(0x20b)](_0x5d9484[_0x1dfb1a(0x1a9)](0x6));return _0x283166?.['result']?.[_0x1dfb1a(0x183)]?.[0x0]?.[_0x1dfb1a(0x1aa)]?JSON['parse'](_0x283166[_0x1dfb1a(0x218)][_0x1dfb1a(0x183)][0x0][_0x1dfb1a(0x1aa)]):_0x283166;}return{'ok':!0x1,'error':_0x1dfb1a(0x1e8)};}K[a0_0x59a7e7(0x192)](a0_0x395ef7,async _0x35ae21=>{const _0x203eb6=a0_0x59a7e7;let {name:_0x562ade,arguments:_0x5837b7}=_0x35ae21[_0x203eb6(0x185)];if(_0x562ade===_0x203eb6(0x1bf)){let {task_id:_0x5eb8ef,text:_0x532c9a,status:_0x38ee0c}=_0x5837b7;if(_0x38ee0c===_0x203eb6(0x20e)||_0x38ee0c==='failed'||_0x38ee0c===_0x203eb6(0x1f7)){let _0x1e1f35=_0x38ee0c==='completed'?_0x203eb6(0x1f9):_0x38ee0c,_0x4aeedd=_0x5eb8ef?G[_0x203eb6(0x209)](_0x5eb8ef)||_0x203eb6(0x1c1):_0x203eb6(0x1c1),_0x18237d=await Q(_0x203eb6(0x200),{'alias':_0x4aeedd,'text':_0x532c9a,'in_reply_to':_0x5eb8ef||void 0x0,'status':_0x1e1f35,'from_session':p});if(_0x5eb8ef)G[_0x203eb6(0x1f8)](_0x5eb8ef);return{'content':[{'type':_0x203eb6(0x1aa),'text':JSON['stringify'](_0x18237d)}]};}let _0x1f9baf=await Q(_0x203eb6(0x1c4),{'resume_id':V,'alias':p,'status':_0x38ee0c==='blocked'?_0x203eb6(0x1b1):_0x38ee0c===_0x203eb6(0x1e5)?_0x203eb6(0x1e5):_0x203eb6(0x1a3),'task':_0x532c9a[_0x203eb6(0x1a9)](0x0,0xc8),'output':_0x532c9a});return{'content':[{'type':_0x203eb6(0x1aa),'text':JSON[_0x203eb6(0x1ed)](_0x1f9baf)}]};}if(_0x562ade===_0x203eb6(0x1b2)){let {status:_0x432b94,task:_0x865a74,progress:_0x50094e}=_0x5837b7,_0x247e86=await Q(_0x203eb6(0x1c4),{'resume_id':V,'alias':p,'status':_0x432b94,'task':_0x865a74,'progress':_0x50094e});return{'content':[{'type':_0x203eb6(0x1aa),'text':JSON[_0x203eb6(0x1ed)](_0x247e86)}]};}if(_0x562ade===_0x203eb6(0x203)){let {alias:_0x143bd1,task:_0x136858,priority:_0x29d124}=_0x5837b7,_0x431497=await Q(_0x203eb6(0x1ef),{'alias':_0x143bd1,'task':_0x136858,'priority':_0x29d124||_0x203eb6(0x1f1),'from_session':p});return{'content':[{'type':_0x203eb6(0x1aa),'text':JSON['stringify'](_0x431497)}]};}if(_0x562ade===_0x203eb6(0x1ee)){let {alias:_0x59fe2a,message:_0x1a6552}=_0x5837b7,_0x39d071=await Q(_0x203eb6(0x210),{'alias':_0x59fe2a,'message':_0x1a6552,'from_session':p});return{'content':[{'type':_0x203eb6(0x1aa),'text':JSON[_0x203eb6(0x1ed)](_0x39d071)}]};}if(_0x562ade===_0x203eb6(0x1ad)){let _0x3e554e=await Q(_0x203eb6(0x217),{});return{'content':[{'type':_0x203eb6(0x1aa),'text':JSON[_0x203eb6(0x1ed)](_0x3e554e)}]};}return{'content':[{'type':'text','text':JSON[_0x203eb6(0x1ed)]({'error':_0x203eb6(0x1da)})}]};});var D=0x3e8,v=0x7530,O=0x36ee80;async function m(){const _0x509f45=a0_0x59a7e7;try{await Q('report_status',{'resume_id':V,'alias':p,'status':_0x509f45(0x19d),'server':a0_0x1ca798(),'hostname':a0_0x1ca798(),'agent':'claude-code','project_dir':process['cwd'](),'tmux_name':j||void 0x0}),z('re-registered\x20as\x20\x22'+p+'\x22\x20after\x20SSE\x20reconnect');}catch(_0x5b116b){z('re-register\x20failed:\x20'+_0x5b116b);}}async function l(){const _0x33ed29=a0_0x59a7e7;let _0x102d8c=Y+_0x33ed29(0x178)+encodeURIComponent(p),_0x162d95={};if(k)_0x162d95[_0x33ed29(0x179)]=_0x33ed29(0x1e4)+k;z('connecting\x20to\x20'+_0x102d8c);let _0x2867f2=D,_0x4f8698=!0x0,_0x5f5ab1=null;while(!0x0){try{let _0x2c2191=await fetch(_0x102d8c,{'headers':_0x162d95});if(!_0x2c2191['ok']){if(z('SSE\x20error:\x20'+_0x2c2191['status']+'\x20'+_0x2c2191[_0x33ed29(0x1a8)]),_0x5f5ab1=_0x5f5ab1??Date[_0x33ed29(0x18c)](),Date['now']()-_0x5f5ab1>O){z(_0x33ed29(0x1a6)+Y+_0x33ed29(0x1e0));return;}await i(_0x2867f2),_0x2867f2=Math[_0x33ed29(0x202)](_0x2867f2*0x2,v);continue;}let _0x5211c1=_0x2c2191[_0x33ed29(0x1d9)][_0x33ed29(0x1d1)](),_0x2ee030=new TextDecoder(),_0x51a1ab='';_0x2867f2=D;while(!0x0){let {done:_0x59f9c1,value:_0x38c8f4}=await _0x5211c1[_0x33ed29(0x191)]();if(_0x59f9c1)break;_0x51a1ab+=_0x2ee030[_0x33ed29(0x1ce)](_0x38c8f4,{'stream':!0x0});let _0x2f5491=_0x51a1ab['split']('\x0a\x0a');_0x51a1ab=_0x2f5491['pop']()||'';for(let _0x30cea3 of _0x2f5491){let _0x1e51db=_0x30cea3['split']('\x0a')[_0x33ed29(0x1e6)](_0x50f4b0=>_0x50f4b0[_0x33ed29(0x1df)](_0x33ed29(0x1d2)));if(!_0x1e51db)continue;try{let _0x4339f9=JSON[_0x33ed29(0x20b)](_0x1e51db[_0x33ed29(0x1a9)](0x6));if(await A(_0x4339f9),_0x4339f9[_0x33ed29(0x1f3)]===_0x33ed29(0x1d5)){if(_0x5f5ab1=null,!_0x4f8698)await m();_0x4f8698=!0x1;}}catch(_0x4c7fc0){z(_0x33ed29(0x1bd)+_0x4c7fc0);}}}z(_0x33ed29(0x176));}catch(_0x2dd639){z('SSE\x20connection\x20error:\x20'+_0x2dd639);}if(_0x5f5ab1=_0x5f5ab1??Date[_0x33ed29(0x18c)](),Date[_0x33ed29(0x18c)]()-_0x5f5ab1>O){z(_0x33ed29(0x1a6)+Y+')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。');return;}await i(_0x2867f2),_0x2867f2=Math['min'](_0x2867f2*0x2,v);}}async function A(_0x4e2c34){const _0x2c250e=a0_0x59a7e7;if(_0x4e2c34['type']===_0x2c250e(0x1d5)){z(_0x2c250e(0x1ab)+p+'\x22');return;}if(_0x4e2c34[_0x2c250e(0x1f3)]===_0x2c250e(0x1de)){if(z(_0x2c250e(0x1db)+_0x4e2c34[_0x2c250e(0x198)]+':\x20'+_0x4e2c34[_0x2c250e(0x1dd)][_0x2c250e(0x1a9)](0x0,0x3c)),await K['notification']({'method':_0x2c250e(0x17a),'params':{'content':_0x4e2c34['message'],'meta':{'sender':_0x4e2c34['from']||_0x2c250e(0x1c1),'sender_id':_0x2c250e(0x1ea),'user':_0x4e2c34['from']||_0x2c250e(0x1c1),'priority':_0x2c250e(0x1f1)}}}),_0x4e2c34[_0x2c250e(0x1c2)])await Q(_0x2c250e(0x19b),{'alias':p,'message_id':_0x4e2c34[_0x2c250e(0x1c2)]});return;}if(_0x4e2c34[_0x2c250e(0x1f3)]===_0x2c250e(0x18b)||_0x4e2c34[_0x2c250e(0x1f3)]===_0x2c250e(0x1d0)){z('←\x20'+_0x4e2c34[_0x2c250e(0x1f3)]+_0x2c250e(0x1b9)+_0x4e2c34[_0x2c250e(0x1fd)]+_0x2c250e(0x213)+(_0x4e2c34[_0x2c250e(0x1ff)]||_0x2c250e(0x1f1)));let _0x125918=await Q('get_inbox',{'alias':p,'limit':0x5});if(_0x125918?.['ok']&&_0x125918['messages']?.[_0x2c250e(0x1a4)]>0x0)for(let _0xf72ebb of _0x125918['messages']){let _0x47b456={'sender':_0xf72ebb['from_session']||_0x2c250e(0x1c1),'sender_id':_0x2c250e(0x1ea),'user':_0xf72ebb[_0x2c250e(0x201)]||_0x2c250e(0x1c1),'task_id':_0xf72ebb['id'],'priority':_0xf72ebb[_0x2c250e(0x1ff)]||_0x2c250e(0x1f1)};G[_0x2c250e(0x186)](_0xf72ebb['id'],_0xf72ebb[_0x2c250e(0x201)]||_0x2c250e(0x1c1)),await K[_0x2c250e(0x199)]({'method':_0x2c250e(0x17a),'params':{'content':_0xf72ebb[_0x2c250e(0x183)],'meta':_0x47b456}}),z('→\x20injected\x20task\x20'+_0xf72ebb['id'][_0x2c250e(0x1a9)](0x0,0x8)+'\x20from\x20'+_0xf72ebb['from_session']+':\x20'+_0xf72ebb[_0x2c250e(0x183)][_0x2c250e(0x1a9)](0x0,0x3c)),await Q(_0x2c250e(0x19b),{'alias':p,'message_id':_0xf72ebb['id']});}}}async function t(){const _0x58b3c3=a0_0x59a7e7;let _0x131917=new a0_0x93ee58();await K[_0x58b3c3(0x1d3)](_0x131917),z(_0x58b3c3(0x1f4)),z(_0x58b3c3(0x194)),l()[_0x58b3c3(0x1a0)](_0x2a16c3=>z(_0x58b3c3(0x1ca)+_0x2a16c3)),Q('report_status',{'resume_id':V,'alias':p,'status':_0x58b3c3(0x19d),'server':a0_0x1ca798(),'hostname':a0_0x1ca798(),'agent':_0x58b3c3(0x1a7),'project_dir':process[_0x58b3c3(0x18e)](),'tmux_name':j||void 0x0})[_0x58b3c3(0x1c0)](()=>z(_0x58b3c3(0x1d4)+p+_0x58b3c3(0x1ec)+V[_0x58b3c3(0x1a9)](0x0,0x8)+')'))[_0x58b3c3(0x1a0)](_0xdd5af1=>z(_0x58b3c3(0x187)+_0xdd5af1)),setInterval(()=>{const _0x591e15=_0x58b3c3;Q(_0x591e15(0x1c4),{'resume_id':V,'alias':p,'status':_0x591e15(0x19d),'server':a0_0x1ca798(),'hostname':a0_0x1ca798(),'agent':'claude-code','project_dir':process[_0x591e15(0x18e)](),'tmux_name':j||void 0x0})[_0x591e15(0x1a0)](_0x202335=>z('heartbeat\x20failed:\x20'+_0x202335));},0x2bf20),z(_0x58b3c3(0x1fb));}t()[a0_0x59a7e7(0x1a0)](_0x45c51c=>{const _0x415aad=a0_0x59a7e7;z(_0x415aad(0x1dc)+_0x45c51c),process['exit'](0x1);});async function b(){const _0xca1c6d=a0_0x59a7e7;z(_0xca1c6d(0x19c)),await Q(_0xca1c6d(0x1c4),{'resume_id':V,'alias':p,'status':_0xca1c6d(0x216),'task':_0xca1c6d(0x1d7)})[_0xca1c6d(0x1a0)](()=>{}),process[_0xca1c6d(0x1b6)](0x0);}process[a0_0x59a7e7(0x208)]['on'](a0_0x59a7e7(0x1e1),()=>b()),process['on'](a0_0x59a7e7(0x196),()=>b()),process['on'](a0_0x59a7e7(0x1d6),()=>b());var d=process[a0_0x59a7e7(0x1eb)];if(d&&d>0x1){let h=setInterval(()=>{const _0x13b05a=a0_0x59a7e7;if(process[_0x13b05a(0x1eb)]===0x1&&d!==0x1){z(_0x13b05a(0x1ba)+d+_0x13b05a(0x20c)),b();return;}try{process[_0x13b05a(0x1a5)](d,0x0);}catch(_0x4a43fe){if(_0x4a43fe?.[_0x13b05a(0x197)]===_0x13b05a(0x1cb))z(_0x13b05a(0x1bc)+d+_0x13b05a(0x189)),b();}},0x7530);if(typeof h[a0_0x59a7e7(0x1b0)]===a0_0x59a7e7(0x211))h['unref']();}
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
export type RuntimeName = "claude-code-cli" | "codex-sdk" | "claude-agent-sdk" | "grok-build-acp" | "opencode-cli" | "codex-app-server";
|
|
2
|
-
/** Operator-facing default for
|
|
2
|
+
/** Operator-facing default for a runtime slot that is empty or missing. */
|
|
3
3
|
export declare const DEFAULT_RUNTIME: RuntimeName;
|
|
4
|
+
export declare const SUPPORTED_RUNTIME_NAMES: readonly RuntimeName[];
|
|
4
5
|
type ProfileLike = {
|
|
5
6
|
runtime?: string;
|
|
6
7
|
codexRuntime?: string;
|
|
7
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Legacy normalization used by display and migration code. Missing, empty,
|
|
11
|
+
* and unknown values all use the safe default for backward compatibility.
|
|
12
|
+
* Security-sensitive create/start paths must call `normalizeRuntimeStrict`.
|
|
13
|
+
*/
|
|
8
14
|
export declare function normalizeRuntime(profileOrRuntime?: ProfileLike | string): RuntimeName;
|
|
15
|
+
/**
|
|
16
|
+
* Canonicalize a runtime at an execution boundary. Missing/empty still means
|
|
17
|
+
* the documented default, but any non-empty unknown value is rejected so a
|
|
18
|
+
* typo or future runtime cannot silently execute as Claude.
|
|
19
|
+
*/
|
|
20
|
+
export declare function normalizeRuntimeStrict(profileOrRuntime?: ProfileLike | string): RuntimeName;
|
|
9
21
|
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const OPENCODE_AGENT_NETWORK_VERSION = "2.3.0-preview.34";
|
|
2
|
+
export declare const OPENCODE_AGENT_NODE_VERSION = "2.5.0-preview.26";
|
|
3
|
+
export declare const OPENCODE_AGENT_NODE_SPEC = "@sleep2agi/agent-node@2.5.0-preview.26";
|
|
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;
|
|
@@ -0,0 +1,43 @@
|
|
|
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>;
|
|
@@ -0,0 +1,13 @@
|
|
|
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;
|
|
@@ -0,0 +1,6 @@
|
|
|
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;
|
|
@@ -0,0 +1,21 @@
|
|
|
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,10 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Version this branch was validated against by the maintainers.
|
|
3
|
-
* Bumped when a new opencode-ai release passes the
|
|
4
|
-
* PR② e2e in a fresh checkout. `readEffectivePin()` still returns
|
|
5
|
-
* this when no override file exists.
|
|
3
|
+
* Bumped when a new opencode-ai release passes the full Docker/E2E gate.
|
|
6
4
|
*/
|
|
7
|
-
export declare const OPENCODE_BUILTIN_PIN = "1.
|
|
5
|
+
export declare const OPENCODE_BUILTIN_PIN = "1.18.1";
|
|
6
|
+
/** Exact upstream remediation shared by every CLI failure path. */
|
|
7
|
+
export declare function opencodeExactInstallCommand(version?: string): string;
|
|
8
|
+
/** Preserve package-identity diagnostics while always leaving a missing or
|
|
9
|
+
* untrusted install with an actionable exact-pin command. */
|
|
10
|
+
export declare function formatOpencodePackageIdentityFailure(expectedVersion: string, detail: string): string;
|
|
8
11
|
/** Where the per-machine override lives. Kept under `~/.anet/` so
|
|
9
12
|
* it sits next to the other anet-local state. */
|
|
10
13
|
export declare function opencodePinFilePath(homeDirOverride?: string): string;
|
|
@@ -26,10 +29,10 @@ export interface EffectivePin {
|
|
|
26
29
|
smokePassedAt?: string;
|
|
27
30
|
}
|
|
28
31
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
32
|
+
* Recognize a validated override only when it records the exact built-in
|
|
33
|
+
* release pin. A different locally-smoked version is deliberately ignored:
|
|
34
|
+
* the lightweight ACP smoke does not replace the maintainer's full security
|
|
35
|
+
* and reply-path gate. Malformed/stale files also fall back to the built-in.
|
|
33
36
|
*/
|
|
34
37
|
export declare function readEffectivePin(homeDirOverride?: string): EffectivePin;
|
|
35
38
|
/**
|
|
@@ -10,6 +10,17 @@ 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", "webfetch", "websearch", "question"];
|
|
22
|
+
export declare function buildOpencodeDefaultToolsPolicy(): Record<string, false>;
|
|
23
|
+
export declare function buildOpencodeDefaultPermissionPolicy(): Record<string, "deny">;
|
|
13
24
|
export declare function findOpencodePreset(id: string): OpencodePreset | null;
|
|
14
25
|
/**
|
|
15
26
|
* Look up the API key for a preset from the current process env.
|
|
@@ -22,22 +33,41 @@ export declare function readPresetKeyFromEnv(preset: OpencodePreset, env?: NodeJ
|
|
|
22
33
|
/**
|
|
23
34
|
* opencode.ai's auth.json shape:
|
|
24
35
|
* { "<providerId>": { "type": "api", "key": "..." } }
|
|
25
|
-
* Same shape
|
|
36
|
+
* Same shape verified against the release pin opencode-ai@1.18.1.
|
|
26
37
|
*/
|
|
27
38
|
export declare function buildAuthJsonBody(preset: OpencodePreset, apiKey: string): string;
|
|
39
|
+
export type OpencodePrivateProfileFilename = "config.json" | ".env";
|
|
40
|
+
/**
|
|
41
|
+
* Establish the boundary before saveProfile/rewritePlainSecrets writes the
|
|
42
|
+
* node token or dotenv key. The expected shape is exactly
|
|
43
|
+
* `<project>/.anet/nodes/<node>`. Every existing path is inspected with
|
|
44
|
+
* lstat + O_NOFOLLOW and inode checks; absent private directories are created
|
|
45
|
+
* one component at a time. A pre-planted node-root/config/.env symlink is a
|
|
46
|
+
* hard error before any secret-bearing write.
|
|
47
|
+
*/
|
|
48
|
+
export declare function prepareOpencodeNodeForProfileWrite(nodeWorkDir: string): string;
|
|
49
|
+
export declare function readOpencodePrivateProfileFile(nodeWorkDir: string, filename: OpencodePrivateProfileFilename): string | undefined;
|
|
50
|
+
export declare function writeOpencodePrivateProfileFile(nodeWorkDir: string, filename: OpencodePrivateProfileFilename, body: string): string;
|
|
28
51
|
/**
|
|
29
52
|
* Write auth.json into the opencode config root that lives under
|
|
30
|
-
* `nodeWorkDir` (
|
|
31
|
-
*
|
|
32
|
-
*
|
|
53
|
+
* `nodeWorkDir` (the per-node OpenCode data root). mode 0o600 limits
|
|
54
|
+
* filesystem access to the owning OS account; it does not prevent a
|
|
55
|
+
* same-uid OpenCode child from opening the file directly. Directory is
|
|
56
|
+
* created if missing.
|
|
33
57
|
*
|
|
34
58
|
* Returns the absolute path we wrote for logging.
|
|
35
59
|
*/
|
|
36
60
|
export declare function writeOpencodeAuthJson(nodeWorkDir: string, preset: OpencodePreset, apiKey: string): string;
|
|
37
61
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
|
|
62
|
+
* New keyless nodes must not inherit a private-but-preplanted credential.
|
|
63
|
+
* Keep the file present as an explicit empty object so the creation log's
|
|
64
|
+
* "auth not configured" statement matches the state OpenCode will consume.
|
|
65
|
+
*/
|
|
66
|
+
export declare function clearOpencodeAuthJson(nodeWorkDir: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* Companion opencode.json: records only the selected blessed provider
|
|
69
|
+
* identity and safe-by-default tool policy. Pre-existing model routing and
|
|
70
|
+
* arbitrary OpenCode integrations are stripped; operators may explicitly set
|
|
71
|
+
* a model after creation, which the runtime's separate safe renderer retains.
|
|
42
72
|
*/
|
|
43
73
|
export declare function writeOpencodeConfigJson(nodeWorkDir: string, preset: OpencodePreset): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const OPENCODE_RUNTIME_BINDING_SCHEMA_VERSION: 1;
|
|
2
|
+
export declare const OPENCODE_RUNTIME_BINDING_RUNTIME: "opencode-cli";
|
|
3
|
+
export declare const OPENCODE_RUNTIME_BINDINGS_DIRECTORY = "opencode-runtime-bindings";
|
|
4
|
+
export interface OpencodeRuntimeBinding {
|
|
5
|
+
schemaVersion: typeof OPENCODE_RUNTIME_BINDING_SCHEMA_VERSION;
|
|
6
|
+
runtime: typeof OPENCODE_RUNTIME_BINDING_RUNTIME;
|
|
7
|
+
projectRoot: string;
|
|
8
|
+
nodeId: string;
|
|
9
|
+
}
|
|
10
|
+
/** Windows reports synthetic POSIX permission bits; retain all other checks there. */
|
|
11
|
+
export declare function isOpencodeRuntimeBindingModeSecure(mode: number, exactMode?: number, platform?: NodeJS.Platform): boolean;
|
|
12
|
+
/** Resolve the deterministic binding path without creating HOME state. */
|
|
13
|
+
export declare function opencodeRuntimeBindingPath(nodeWorkDir: string, homeDirectory?: string): string;
|
|
14
|
+
/** Persist an external, immutable-by-config record that this node was created as OpenCode. */
|
|
15
|
+
export declare function writeOpencodeRuntimeBinding(nodeWorkDir: string, homeDirectory?: string): string;
|
|
16
|
+
/** Read and validate a binding. Missing bindings return undefined; unsafe or tampered state throws. */
|
|
17
|
+
export declare function readOpencodeRuntimeBinding(nodeWorkDir: string, homeDirectory?: string): OpencodeRuntimeBinding | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Remove only the exact, validated binding for this node. Missing exact state is
|
|
20
|
+
* idempotent; malformed, replaced, or unsafe state always fails closed.
|
|
21
|
+
*/
|
|
22
|
+
export declare function removeOpencodeRuntimeBinding(nodeWorkDir: string, homeDirectory?: string): boolean;
|
|
23
|
+
/** Assert that the external record exists and exactly identifies this node as opencode-cli. */
|
|
24
|
+
export declare function assertExactOpencodeRuntimeBinding(nodeWorkDir: string, homeDirectory?: string): OpencodeRuntimeBinding;
|
|
25
|
+
/**
|
|
26
|
+
* Refuse OpenCode node state committed to a surrounding Git index. A normal
|
|
27
|
+
* non-Git project is allowed. Git is always invoked directly with argv and a
|
|
28
|
+
* literal pathspec; no shell or command interpolation is used.
|
|
29
|
+
*/
|
|
30
|
+
export declare function assertOpencodeNodeStateUntracked(nodeWorkDir: string): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildOpencodeSmokeEnv(parentEnv: NodeJS.ProcessEnv, smokeRoot: string, cwd?: string): NodeJS.ProcessEnv;
|
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
|
|
3
|
+
"version": "2.3.0-preview.35",
|
|
4
|
+
"description": "AI Agent Network CLI — Local-first multi-agent orchestration across 6 runtimes (Claude Code CLI / Claude Agent SDK / Codex SDK / Codex app-server / Grok Build ACP / OpenCode CLI) and 8+ LLM providers. Apache 2.0.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/client.js",
|
|
7
7
|
"types": "dist/client.d.ts",
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
"directory": "agent-network"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
|
-
"access": "public"
|
|
57
|
+
"access": "public",
|
|
58
|
+
"tag": "preview"
|
|
58
59
|
},
|
|
59
60
|
"bugs": {
|
|
60
61
|
"url": "https://github.com/sleep2agi/agent-network/issues"
|
|
@@ -81,4 +82,4 @@
|
|
|
81
82
|
"hono": "^4.12.21",
|
|
82
83
|
"qs": "^6.15.2"
|
|
83
84
|
}
|
|
84
|
-
}
|
|
85
|
+
}
|