@sleep2agi/agent-network 2.3.0-preview.1 → 2.3.0-preview.10
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/dist/bin/cli.d.ts +2 -1
- package/dist/bin/cli.js +1 -1
- package/dist/src/client.js +1 -1
- package/dist/src/im/access-resolve.d.ts +103 -0
- package/dist/src/im/feishu/adapter.d.ts +69 -1
- package/dist/src/im/feishu/bridge.d.ts +7 -0
- package/dist/src/im/feishu/markdown-image-renderer.d.ts +61 -0
- package/dist/src/im/feishu/outbound-marker.d.ts +140 -0
- package/dist/src/im/feishu/outbound-paths.d.ts +50 -0
- package/dist/src/im/feishu/worker.js +360 -16
- package/dist/src/im/types.d.ts +8 -0
- package/dist/src/node-server.js +1 -1
- package/dist/src/normalize-runtime.d.ts +9 -0
- package/dist/src/supervise-child.d.ts +69 -0
- package/package.json +6 -3
package/dist/src/im/types.d.ts
CHANGED
|
@@ -115,6 +115,14 @@ export interface NormalizedIMMessage {
|
|
|
115
115
|
replyToMessageId?: string;
|
|
116
116
|
/** Ephemeral / visible-to-sender-only. Slack only; others ignore. */
|
|
117
117
|
ephemeral?: boolean;
|
|
118
|
+
/** Caption-mode hint (RFC-020 §15.2): bypass markdown-card / markdown→PNG
|
|
119
|
+
* rendering and send as plain text. Set by the bridge when the same
|
|
120
|
+
* dispatch loop is also sending one or more attachment files — the text
|
|
121
|
+
* is a caption ("here's the report"), not the deliverable. Without this
|
|
122
|
+
* hint, Vincent's "make me a PDF" UAT had the bot's accompanying
|
|
123
|
+
* description heading + bullet list rendered to PNG via #329, which
|
|
124
|
+
* read as "you sent another image" instead of "you sent my file". */
|
|
125
|
+
forceTextOnly?: boolean;
|
|
118
126
|
/** Tie back to the commhub task that produced this message. */
|
|
119
127
|
correlation: {
|
|
120
128
|
taskId: string;
|
package/dist/src/node-server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
const a0_0x2f6489=a0_0x910f;(function(_0x10285f,_0x31ae8e){const _0x252300=a0_0x910f,_0x29240d=_0x10285f();while(!![]){try{const _0x240ff0=-parseInt(_0x252300(0x1d7))/0x1*(-parseInt(_0x252300(0x235))/0x2)+-parseInt(_0x252300(0x1d5))/0x3*(-parseInt(_0x252300(0x220))/0x4)+-parseInt(_0x252300(0x1b3))/0x5+-parseInt(_0x252300(0x221))/0x6+-parseInt(_0x252300(0x23e))/0x7*(parseInt(_0x252300(0x1cd))/0x8)+parseInt(_0x252300(0x20b))/0x9+parseInt(_0x252300(0x201))/0xa;if(_0x240ff0===_0x31ae8e)break;else _0x29240d['push'](_0x29240d['shift']());}catch(_0x7d01d6){_0x29240d['push'](_0x29240d['shift']());}}}(a0_0x26a1,0x6ff10));import{readFileSync as a0_0x125c3b,existsSync as a0_0x4d8313}from'fs';import{randomUUID as a0_0x57c336}from'crypto';import{join as a0_0x293d60}from'path';import{hostname as a0_0x26e9c9}from'os';import{execSync as a0_0x4c624f}from'child_process';import{Server as a0_0x11b58c}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x57ed7a}from'@modelcontextprotocol/sdk/server/stdio.js';function a0_0x910f(_0x5d44f4,_0x2fe00d){_0x5d44f4=_0x5d44f4-0x1af;const _0x26a11c=a0_0x26a1();let _0x910f7=_0x26a11c[_0x5d44f4];return _0x910f7;}import{ListToolsRequestSchema as a0_0x4a3abc,CallToolRequestSchema as a0_0x49d6db}from'@modelcontextprotocol/sdk/types.js';function I(_0x912882){const _0x5b7df3=a0_0x910f;if(!a0_0x4d8313(_0x912882))return;for(let _0x161f68 of a0_0x125c3b(_0x912882,_0x5b7df3(0x236))[_0x5b7df3(0x1d4)]('\x0a')){let _0x28c117=_0x161f68[_0x5b7df3(0x244)]();if(!_0x28c117||_0x28c117[_0x5b7df3(0x246)]('#'))continue;let _0x13a768=_0x28c117['indexOf']('=');if(_0x13a768<0x0)continue;let _0x3ed58c=_0x28c117[_0x5b7df3(0x210)](0x0,_0x13a768)[_0x5b7df3(0x244)](),_0x287877=_0x28c117[_0x5b7df3(0x210)](_0x13a768+0x1)[_0x5b7df3(0x244)]()[_0x5b7df3(0x208)](/^["']|["']$/g,'');if(!process.env[_0x3ed58c])process.env[_0x3ed58c]=_0x287877;}}var L=process.env.HOME||'~',U=a0_0x293d60(L,a0_0x2f6489(0x1e3));I(a0_0x293d60(U,a0_0x2f6489(0x1e1)));var v=process[a0_0x2f6489(0x1dd)]()[a0_0x2f6489(0x208)](/\//g,'-');I(a0_0x293d60(U,v,a0_0x2f6489(0x1e1)));function d(){const _0x3b3e6c=a0_0x2f6489;try{return a0_0x4c624f(_0x3b3e6c(0x1c1),{'encoding':_0x3b3e6c(0x236),'timeout':0x7d0})[_0x3b3e6c(0x244)]();}catch{return'';}}function m(){const _0x1c7b18=a0_0x2f6489;try{let _0x2f66c3=a0_0x293d60(L,'.anet',_0x1c7b18(0x1d9));if(a0_0x4d8313(_0x2f66c3))return JSON['parse'](a0_0x125c3b(_0x2f66c3,_0x1c7b18(0x236)));}catch{}return{};}var u=m(),j=process.env.COMMHUB_URL||u[a0_0x2f6489(0x1ce)]||a0_0x2f6489(0x24b),f=process.env.COMMHUB_TMUX||d();function r(){const _0x3a4531=a0_0x2f6489;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS['trim']())return process.env.COMMHUB_ALIAS['trim']();return process[_0x3a4531(0x22d)][_0x3a4531(0x1bc)](_0x3a4531(0x21c)+(_0x3a4531(0x1c7)+(f||_0x3a4531(0x1ff))+_0x3a4531(0x1c9)+a0_0x26e9c9()+_0x3a4531(0x230))),_0x3a4531(0x243)+process[_0x3a4531(0x234)];}var G=r(),K=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x57c336(),F=process.env.COMMHUB_TOKEN||u[a0_0x2f6489(0x1d6)]||'';function W(_0x432d7e){const _0x1f663a=a0_0x2f6489;let _0x3ac2ec=new Date()[_0x1f663a(0x1f3)]()[_0x1f663a(0x210)](0x0,0x8);process['stderr']['write']('['+_0x3ac2ec+_0x1f663a(0x23b)+_0x432d7e+'\x0a');}function N(_0x5b13a9){return new Promise(_0x32ec43=>setTimeout(_0x32ec43,_0x5b13a9));}W(a0_0x2f6489(0x24a)+j+a0_0x2f6489(0x245)+G+a0_0x2f6489(0x1cb)+K[a0_0x2f6489(0x210)](0x0,0x8)+'...\x20TMUX='+(f||a0_0x2f6489(0x218))+a0_0x2f6489(0x242)+process[a0_0x2f6489(0x1dd)]()+a0_0x2f6489(0x1cc)+v);var D=new Map(),x=new a0_0x11b58c({'name':a0_0x2f6489(0x228),'version':a0_0x2f6489(0x20d)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x2f6489(0x1af),a0_0x2f6489(0x1b8),a0_0x2f6489(0x240),'You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','Session\x20alias:\x20'+G][a0_0x2f6489(0x1f5)]('\x0a')});x[a0_0x2f6489(0x214)](a0_0x4a3abc,async()=>({'tools':[{'name':a0_0x2f6489(0x1f4),'description':a0_0x2f6489(0x204),'inputSchema':{'type':a0_0x2f6489(0x1dc),'properties':{'task_id':{'type':a0_0x2f6489(0x1c6),'description':'The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)'},'text':{'type':a0_0x2f6489(0x1c6),'description':'Reply\x20text\x20/\x20result\x20summary'},'status':{'type':a0_0x2f6489(0x1c6),'enum':[a0_0x2f6489(0x1c0),a0_0x2f6489(0x1b7),a0_0x2f6489(0x1be),'blocked','error','in_progress'],'description':'Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates'}},'required':[a0_0x2f6489(0x1e4)]}},{'name':a0_0x2f6489(0x1ea),'description':a0_0x2f6489(0x1b0),'inputSchema':{'type':'object','properties':{'status':{'type':a0_0x2f6489(0x1c6),'enum':[a0_0x2f6489(0x1f9),'idle',a0_0x2f6489(0x20e),a0_0x2f6489(0x1fa)]},'task':{'type':'string','description':a0_0x2f6489(0x21a)},'progress':{'type':a0_0x2f6489(0x224),'description':'Progress\x200-100'}},'required':[a0_0x2f6489(0x1b2)]}},{'name':a0_0x2f6489(0x22f),'description':'Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','inputSchema':{'type':a0_0x2f6489(0x1dc),'properties':{'alias':{'type':a0_0x2f6489(0x1c6),'description':a0_0x2f6489(0x1ef)},'task':{'type':a0_0x2f6489(0x1c6),'description':a0_0x2f6489(0x1ba)},'priority':{'type':a0_0x2f6489(0x1c6),'enum':[a0_0x2f6489(0x206),a0_0x2f6489(0x1bd),'low'],'description':a0_0x2f6489(0x1f1)}},'required':[a0_0x2f6489(0x1d1),'task']}},{'name':a0_0x2f6489(0x241),'description':a0_0x2f6489(0x203),'inputSchema':{'type':a0_0x2f6489(0x1dc),'properties':{'alias':{'type':a0_0x2f6489(0x1c6),'description':a0_0x2f6489(0x1ef)},'message':{'type':'string','description':a0_0x2f6489(0x1da)}},'required':[a0_0x2f6489(0x1d1),a0_0x2f6489(0x225)]}},{'name':'commhub_get_all_status','description':a0_0x2f6489(0x219),'inputSchema':{'type':a0_0x2f6489(0x1dc),'properties':{}}}]}));async function Y(_0x43e00e,_0x330ede){const _0x5ad611=a0_0x2f6489;let _0xeb0fe3=await fetch(j+_0x5ad611(0x1bf),{'method':'POST','headers':{'Content-Type':_0x5ad611(0x1fd),'Accept':'application/json,\x20text/event-stream',...F?{'Authorization':_0x5ad611(0x21d)+F}:{}},'body':JSON[_0x5ad611(0x1c4)]({'jsonrpc':'2.0','id':0x1,'method':_0x5ad611(0x215),'params':{'protocolVersion':_0x5ad611(0x20c),'capabilities':{},'clientInfo':{'name':_0x5ad611(0x228),'version':_0x5ad611(0x20d)}}})});if(!_0xeb0fe3['ok']){let _0x21e042=await _0xeb0fe3['text']();return W(_0x5ad611(0x216)+_0xeb0fe3[_0x5ad611(0x1b2)]+'\x20'+_0x21e042[_0x5ad611(0x210)](0x0,0x64)),{'ok':!0x1,'error':'init\x20failed:\x20'+_0xeb0fe3[_0x5ad611(0x1b2)]};}await _0xeb0fe3[_0x5ad611(0x1e4)]();let _0x2e6801=(await(await fetch(j+_0x5ad611(0x1bf),{'method':_0x5ad611(0x223),'headers':{'Content-Type':_0x5ad611(0x1fd),'Accept':'application/json,\x20text/event-stream',...F?{'Authorization':_0x5ad611(0x21d)+F}:{}},'body':JSON[_0x5ad611(0x1c4)]({'jsonrpc':_0x5ad611(0x232),'id':0x2,'method':_0x5ad611(0x1b9),'params':{'name':_0x43e00e,'arguments':_0x330ede}})}))[_0x5ad611(0x1e4)]())[_0x5ad611(0x1d4)]('\x0a')[_0x5ad611(0x239)](_0x50e346=>_0x50e346[_0x5ad611(0x246)](_0x5ad611(0x226)));if(_0x2e6801){let _0x558dbe=JSON[_0x5ad611(0x231)](_0x2e6801[_0x5ad611(0x210)](0x6));return _0x558dbe?.[_0x5ad611(0x238)]?.[_0x5ad611(0x1c8)]?.[0x0]?.[_0x5ad611(0x1e4)]?JSON[_0x5ad611(0x231)](_0x558dbe[_0x5ad611(0x238)][_0x5ad611(0x1c8)][0x0][_0x5ad611(0x1e4)]):_0x558dbe;}return{'ok':!0x1,'error':_0x5ad611(0x247)};}x[a0_0x2f6489(0x214)](a0_0x49d6db,async _0x6c7e78=>{const _0x67f01=a0_0x2f6489;let {name:_0x5d7ba4,arguments:_0x4bd0a8}=_0x6c7e78['params'];if(_0x5d7ba4===_0x67f01(0x1f4)){let {task_id:_0x97858b,text:_0x2a3a1a,status:_0x27e114}=_0x4bd0a8;if(_0x27e114===_0x67f01(0x1c0)||_0x27e114==='failed'||_0x27e114===_0x67f01(0x1be)){let _0x25d572=_0x27e114==='completed'?_0x67f01(0x233):_0x27e114,_0x368820=_0x97858b?D[_0x67f01(0x213)](_0x97858b)||_0x67f01(0x1ce):_0x67f01(0x1ce),_0x143467=await Y(_0x67f01(0x1f8),{'alias':_0x368820,'text':_0x2a3a1a,'in_reply_to':_0x97858b||void 0x0,'status':_0x25d572,'from_session':G});if(_0x97858b)D[_0x67f01(0x1e6)](_0x97858b);return{'content':[{'type':_0x67f01(0x1e4),'text':JSON[_0x67f01(0x1c4)](_0x143467)}]};}let _0x45b44e=await Y(_0x67f01(0x1d0),{'resume_id':K,'alias':G,'status':_0x27e114==='blocked'?'blocked':_0x27e114==='error'?_0x67f01(0x1fa):_0x67f01(0x1f9),'task':_0x2a3a1a[_0x67f01(0x210)](0x0,0xc8),'output':_0x2a3a1a});return{'content':[{'type':_0x67f01(0x1e4),'text':JSON[_0x67f01(0x1c4)](_0x45b44e)}]};}if(_0x5d7ba4===_0x67f01(0x1ea)){let {status:_0x243ced,task:_0x6b3607,progress:_0x24b30b}=_0x4bd0a8,_0x5cf599=await Y(_0x67f01(0x1d0),{'resume_id':K,'alias':G,'status':_0x243ced,'task':_0x6b3607,'progress':_0x24b30b});return{'content':[{'type':'text','text':JSON[_0x67f01(0x1c4)](_0x5cf599)}]};}if(_0x5d7ba4===_0x67f01(0x22f)){let {alias:_0x2774a0,task:_0x21befa,priority:_0x718814}=_0x4bd0a8,_0x5adf2f=await Y(_0x67f01(0x209),{'alias':_0x2774a0,'task':_0x21befa,'priority':_0x718814||_0x67f01(0x1bd),'from_session':G});return{'content':[{'type':_0x67f01(0x1e4),'text':JSON[_0x67f01(0x1c4)](_0x5adf2f)}]};}if(_0x5d7ba4==='commhub_send_message'){let {alias:_0x55f867,message:_0x119296}=_0x4bd0a8,_0x37cfcf=await Y(_0x67f01(0x237),{'alias':_0x55f867,'message':_0x119296,'from_session':G});return{'content':[{'type':_0x67f01(0x1e4),'text':JSON[_0x67f01(0x1c4)](_0x37cfcf)}]};}if(_0x5d7ba4===_0x67f01(0x249)){let _0x475d0b=await Y(_0x67f01(0x1f0),{});return{'content':[{'type':_0x67f01(0x1e4),'text':JSON[_0x67f01(0x1c4)](_0x475d0b)}]};}return{'content':[{'type':_0x67f01(0x1e4),'text':JSON['stringify']({'error':_0x67f01(0x1b4)})}]};});var O=0x3e8,R=0x7530,T=0x36ee80;async function l(){const _0x328c5e=a0_0x2f6489;try{await Y(_0x328c5e(0x1d0),{'resume_id':K,'alias':G,'status':_0x328c5e(0x1e9),'server':a0_0x26e9c9(),'hostname':a0_0x26e9c9(),'agent':_0x328c5e(0x1f2),'project_dir':process[_0x328c5e(0x1dd)](),'tmux_name':f||void 0x0}),W(_0x328c5e(0x21f)+G+'\x22\x20after\x20SSE\x20reconnect');}catch(_0x807f81){W(_0x328c5e(0x1cf)+_0x807f81);}}async function o(){const _0x462214=a0_0x2f6489;let _0x2b4bf=j+_0x462214(0x20a)+encodeURIComponent(G),_0x6d743f={};if(F)_0x6d743f[_0x462214(0x1fe)]=_0x462214(0x21d)+F;W(_0x462214(0x1e0)+_0x2b4bf);let _0x29848f=O,_0x4dd33d=!0x0,_0x85c049=null;while(!0x0){try{let _0x2ce17d=await fetch(_0x2b4bf,{'headers':_0x6d743f});if(!_0x2ce17d['ok']){if(W(_0x462214(0x1f6)+_0x2ce17d[_0x462214(0x1b2)]+'\x20'+_0x2ce17d['statusText']),_0x85c049=_0x85c049??Date[_0x462214(0x1db)](),Date['now']()-_0x85c049>T){W(_0x462214(0x217)+j+_0x462214(0x22a));return;}await N(_0x29848f),_0x29848f=Math[_0x462214(0x24c)](_0x29848f*0x2,R);continue;}let _0x68713e=_0x2ce17d[_0x462214(0x1c3)][_0x462214(0x1ee)](),_0x37bc22=new TextDecoder(),_0x48b9e8='';_0x29848f=O;while(!0x0){let {done:_0x5848e3,value:_0x48e64b}=await _0x68713e[_0x462214(0x22e)]();if(_0x5848e3)break;_0x48b9e8+=_0x37bc22[_0x462214(0x1b6)](_0x48e64b,{'stream':!0x0});let _0x109970=_0x48b9e8[_0x462214(0x1d4)]('\x0a\x0a');_0x48b9e8=_0x109970[_0x462214(0x207)]()||'';for(let _0x464724 of _0x109970){let _0x5bb1ec=_0x464724[_0x462214(0x1d4)]('\x0a')[_0x462214(0x239)](_0x257d8a=>_0x257d8a['startsWith'](_0x462214(0x226)));if(!_0x5bb1ec)continue;try{let _0x3904b3=JSON['parse'](_0x5bb1ec[_0x462214(0x210)](0x6));if(await a(_0x3904b3),_0x3904b3['type']===_0x462214(0x205)){if(_0x85c049=null,!_0x4dd33d)await l();_0x4dd33d=!0x1;}}catch(_0x195748){W('parse\x20error:\x20'+_0x195748);}}}W(_0x462214(0x248));}catch(_0x208427){W(_0x462214(0x1e7)+_0x208427);}if(_0x85c049=_0x85c049??Date['now'](),Date[_0x462214(0x1db)]()-_0x85c049>T){W(_0x462214(0x217)+j+_0x462214(0x22a));return;}await N(_0x29848f),_0x29848f=Math[_0x462214(0x24c)](_0x29848f*0x2,R);}}async function a(_0x3cb4d0){const _0x177a92=a0_0x2f6489;if(_0x3cb4d0[_0x177a92(0x23c)]===_0x177a92(0x205)){W(_0x177a92(0x1b1)+G+'\x22');return;}if(_0x3cb4d0[_0x177a92(0x23c)]===_0x177a92(0x23f)){if(W(_0x177a92(0x23d)+_0x3cb4d0[_0x177a92(0x1d2)]+':\x20'+_0x3cb4d0[_0x177a92(0x225)][_0x177a92(0x210)](0x0,0x3c)),await x['notification']({'method':_0x177a92(0x1fc),'params':{'content':_0x3cb4d0[_0x177a92(0x225)],'meta':{'sender':_0x3cb4d0[_0x177a92(0x1d2)]||_0x177a92(0x1ce),'sender_id':_0x177a92(0x1eb),'user':_0x3cb4d0['from']||_0x177a92(0x1ce),'priority':_0x177a92(0x1bd)}}}),_0x3cb4d0[_0x177a92(0x23a)])await Y('ack_inbox',{'alias':G,'message_id':_0x3cb4d0['message_id']});return;}if(_0x3cb4d0[_0x177a92(0x23c)]===_0x177a92(0x222)||_0x3cb4d0[_0x177a92(0x23c)]===_0x177a92(0x229)){W('←\x20'+_0x3cb4d0[_0x177a92(0x23c)]+':\x20inbox_count='+_0x3cb4d0[_0x177a92(0x20f)]+'\x20priority='+(_0x3cb4d0[_0x177a92(0x1c5)]||_0x177a92(0x1bd)));let _0x45477f=await Y(_0x177a92(0x227),{'alias':G,'limit':0x5});if(_0x45477f?.['ok']&&_0x45477f['messages']?.['length']>0x0)for(let _0x1456fe of _0x45477f[_0x177a92(0x1df)]){let _0x2867d5={'sender':_0x1456fe[_0x177a92(0x1d8)]||_0x177a92(0x1ce),'sender_id':_0x177a92(0x1eb),'user':_0x1456fe[_0x177a92(0x1d8)]||'hub','task_id':_0x1456fe['id'],'priority':_0x1456fe[_0x177a92(0x1c5)]||_0x177a92(0x1bd)};D[_0x177a92(0x1fb)](_0x1456fe['id'],_0x1456fe['from_session']||_0x177a92(0x1ce)),await x[_0x177a92(0x22c)]({'method':_0x177a92(0x1fc),'params':{'content':_0x1456fe[_0x177a92(0x1c8)],'meta':_0x2867d5}}),W(_0x177a92(0x21b)+_0x1456fe['id'][_0x177a92(0x210)](0x0,0x8)+_0x177a92(0x1f7)+_0x1456fe[_0x177a92(0x1d8)]+':\x20'+_0x1456fe[_0x177a92(0x1c8)]['slice'](0x0,0x3c)),await Y(_0x177a92(0x1de),{'alias':G,'message_id':_0x1456fe['id']});}}}async function n(){const _0x67c7e0=a0_0x2f6489;let _0x4b278a=new a0_0x57ed7a();await x[_0x67c7e0(0x1d3)](_0x4b278a),W(_0x67c7e0(0x1bb)),W(_0x67c7e0(0x1ed)),o()[_0x67c7e0(0x21e)](_0x44845c=>W('SSE\x20fatal:\x20'+_0x44845c)),Y(_0x67c7e0(0x1d0),{'resume_id':K,'alias':G,'status':_0x67c7e0(0x1e9),'server':a0_0x26e9c9(),'hostname':a0_0x26e9c9(),'agent':_0x67c7e0(0x1f2),'project_dir':process['cwd'](),'tmux_name':f||void 0x0})[_0x67c7e0(0x22b)](()=>W(_0x67c7e0(0x1ca)+G+_0x67c7e0(0x212)+K['slice'](0x0,0x8)+')'))['catch'](_0x2d793d=>W(_0x67c7e0(0x1c2)+_0x2d793d)),setInterval(()=>{const _0x29e1c4=_0x67c7e0;Y(_0x29e1c4(0x1d0),{'resume_id':K,'alias':G,'status':_0x29e1c4(0x1e9),'server':a0_0x26e9c9(),'hostname':a0_0x26e9c9(),'agent':'claude-code','project_dir':process[_0x29e1c4(0x1dd)](),'tmux_name':f||void 0x0})['catch'](_0x3266a1=>W(_0x29e1c4(0x1b5)+_0x3266a1));},0x2bf20),W('ready\x20—\x20waiting\x20for\x20events');}n()[a0_0x2f6489(0x21e)](_0x5cf806=>{const _0x544197=a0_0x2f6489;W(_0x544197(0x200)+_0x5cf806),process[_0x544197(0x1e2)](0x1);});async function b(){const _0x4792be=a0_0x2f6489;W(_0x4792be(0x1ec)),await Y(_0x4792be(0x1d0),{'resume_id':K,'alias':G,'status':_0x4792be(0x1e5),'task':_0x4792be(0x202)})['catch'](()=>{}),process['exit'](0x0);}function a0_0x26a1(){const _0x16e9a3=['Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','connected','high','pop','replace','send_task','/events/','2098539ewpQsv','2025-03-26','0.3.0','blocked','inbox_count','slice','SIGINT','\x22\x20(','get','setRequestHandler','initialize','CommHub\x20init\x20failed:\x20','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','none','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','Current\x20task\x20description','→\x20injected\x20task\x20','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20','Bearer\x20','catch','re-registered\x20as\x20\x22','135384SjeJgn','1809060PeZmym','new_task','POST','number','message','data:\x20','get_inbox','commhub-channel','broadcast',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','then','notification','stderr','read','commhub_send_task','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a','parse','2.0','replied','pid','4vEJiwy','utf-8','send_message','result','find','message_id',']\x20[commhub]\x20','type','←\x20message\x20from\x20','105WmlXAI','new_message','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','commhub_send_message','\x20CWD=','unattributed-','trim','\x20ALIAS=','startsWith','no\x20response','SSE\x20stream\x20ended,\x20reconnecting...','commhub_get_all_status','ENV:\x20URL=','http://127.0.0.1:9200','min','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','SSE\x20connected\x20as\x20\x22','status','1671705ttOHou','unknown\x20tool','heartbeat\x20failed:\x20','decode','failed','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','tools/call','Task\x20content','MCP\x20stdio\x20connected','write','normal','cancelled','/mcp','completed','tmux\x20display-message\x20-p\x20\x27#S\x27','warning:\x20could\x20not\x20register:\x20','body','stringify','priority','string','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','content','\x20/\x20hostname=','registered\x20as\x20\x22','\x20RESUME_ID=','\x20PROJECT_ENV=','206224mpKvdl','hub','re-register\x20failed:\x20','report_status','alias','from','connect','split','51PSphXB','token','253513AuHoLA','from_session','config.json','Message\x20content','now','object','cwd','ack_inbox','messages','connecting\x20to\x20','.env','exit','.claude/channels/commhub','text','offline','delete','SSE\x20connection\x20error:\x20','SIGTERM','idle','commhub_report_status','commhub','shutting\x20down,\x20reporting\x20offline...','starting\x20SSE\x20listener...','getReader','Target\x20session\x20alias','get_all_status','Priority\x20(default:\x20normal)','claude-code','toTimeString','commhub_reply','join','SSE\x20error:\x20','\x20from\x20','send_reply','working','error','set','notifications/claude/channel','application/json','Authorization','(none)','fatal:\x20','1654540KfjULG','session\x20disconnected','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.'];a0_0x26a1=function(){return _0x16e9a3;};return a0_0x26a1();}process['stdin']['on']('end',()=>b()),process['on'](a0_0x2f6489(0x1e8),()=>b()),process['on'](a0_0x2f6489(0x211),()=>b());
|
|
2
|
+
const a0_0x380998=a0_0x12b3;(function(_0x28b549,_0x153647){const _0x13c369=a0_0x12b3,_0x12e83e=_0x28b549();while(!![]){try{const _0x5e1e78=-parseInt(_0x13c369(0xd5))/0x1+-parseInt(_0x13c369(0xd2))/0x2+-parseInt(_0x13c369(0xbf))/0x3*(parseInt(_0x13c369(0x7c))/0x4)+-parseInt(_0x13c369(0xdf))/0x5*(-parseInt(_0x13c369(0xd9))/0x6)+parseInt(_0x13c369(0x7e))/0x7*(-parseInt(_0x13c369(0x7d))/0x8)+-parseInt(_0x13c369(0xe9))/0x9+parseInt(_0x13c369(0x101))/0xa;if(_0x5e1e78===_0x153647)break;else _0x12e83e['push'](_0x12e83e['shift']());}catch(_0x389e2d){_0x12e83e['push'](_0x12e83e['shift']());}}}(a0_0x4b27,0x953fd));import{readFileSync as a0_0x42f320,existsSync as a0_0x5c9ad6}from'fs';import{randomUUID as a0_0x2ff352}from'crypto';import{join as a0_0x2ecd40}from'path';import{hostname as a0_0x5e751e}from'os';import{execSync as a0_0x149dfc}from'child_process';import{Server as a0_0x4667b6}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x1b5e4b}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x31ba96,CallToolRequestSchema as a0_0x3c32fe}from'@modelcontextprotocol/sdk/types.js';function I(_0xfc1a73){const _0x8e5c92=a0_0x12b3;if(!a0_0x5c9ad6(_0xfc1a73))return;for(let _0x568b92 of a0_0x42f320(_0xfc1a73,_0x8e5c92(0x9f))[_0x8e5c92(0xf7)]('\x0a')){let _0x3e73d9=_0x568b92['trim']();if(!_0x3e73d9||_0x3e73d9[_0x8e5c92(0x10b)]('#'))continue;let _0xfadf0e=_0x3e73d9['indexOf']('=');if(_0xfadf0e<0x0)continue;let _0x2db6ba=_0x3e73d9['slice'](0x0,_0xfadf0e)[_0x8e5c92(0xc6)](),_0x2d85c2=_0x3e73d9[_0x8e5c92(0xb2)](_0xfadf0e+0x1)['trim']()['replace'](/^["']|["']$/g,'');if(!process.env[_0x2db6ba])process.env[_0x2db6ba]=_0x2d85c2;}}function a0_0x12b3(_0x19ba6a,_0x5deca8){_0x19ba6a=_0x19ba6a-0x7a;const _0x4b2734=a0_0x4b27();let _0x12b3eb=_0x4b2734[_0x19ba6a];return _0x12b3eb;}var L=process.env.HOME||'~',U=a0_0x2ecd40(L,'.claude/channels/commhub');I(a0_0x2ecd40(U,a0_0x380998(0xbb)));var v=process[a0_0x380998(0xa0)]()[a0_0x380998(0xa4)](/\//g,'-');I(a0_0x2ecd40(U,v,a0_0x380998(0xbb)));function d(){const _0x226267=a0_0x380998;try{return a0_0x149dfc(_0x226267(0xbd),{'encoding':_0x226267(0x9f),'timeout':0x7d0})[_0x226267(0xc6)]();}catch{return'';}}function m(){const _0x284231=a0_0x380998;try{let _0x11b39b=a0_0x2ecd40(L,_0x284231(0x8a),_0x284231(0xb9));if(a0_0x5c9ad6(_0x11b39b))return JSON['parse'](a0_0x42f320(_0x11b39b,_0x284231(0x9f)));}catch{}return{};}var u=m(),j=process.env.COMMHUB_URL||u[a0_0x380998(0xae)]||a0_0x380998(0xe1),f=process.env.COMMHUB_TMUX||d();function r(){const _0x3649bd=a0_0x380998;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x3649bd(0xc6)]())return process.env.COMMHUB_ALIAS['trim']();return process[_0x3649bd(0xaa)][_0x3649bd(0x85)](_0x3649bd(0xfc)+('would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME='+(f||_0x3649bd(0xfb))+_0x3649bd(0xbe)+a0_0x5e751e()+_0x3649bd(0xd1))),_0x3649bd(0x10a)+process[_0x3649bd(0xa7)];}var G=r(),K=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x2ff352(),F=process.env.COMMHUB_TOKEN||u[a0_0x380998(0xf8)]||'';function W(_0x297dd6){const _0x5acba9=a0_0x380998;let _0x4b3a55=new Date()['toTimeString']()[_0x5acba9(0xb2)](0x0,0x8);process['stderr'][_0x5acba9(0x85)]('['+_0x4b3a55+_0x5acba9(0xc1)+_0x297dd6+'\x0a');}function N(_0x46fcf6){return new Promise(_0x4757f9=>setTimeout(_0x4757f9,_0x46fcf6));}function a0_0x4b27(){const _0x169b27=['\x20priority=','\x20RESUME_ID=','new_task','re-registered\x20as\x20\x22','\x20from\x20','commhub_send_task','stringify','notifications/claude/channel','ready\x20—\x20waiting\x20for\x20events','SIGTERM','now','commhub_reply','working','2.0','join','report_status','message','initialize','utf-8','cwd','POST','session\x20disconnected','high','replace','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','\x22\x20after\x20SSE\x20reconnect','pid','Reply\x20text\x20/\x20result\x20summary','idle','stderr','SSE\x20fatal:\x20','application/json,\x20text/event-stream','parse','hub','SSE\x20error:\x20','get_all_status','fatal:\x20','slice','completed','ack_inbox','in_progress','blocked','application/json','content','config.json','number','.env','CommHub\x20init\x20failed:\x20','tmux\x20display-message\x20-p\x20\x27#S\x27','\x20/\x20hostname=','5049wgxeoz','warning:\x20could\x20not\x20register:\x20',']\x20[commhub]\x20','claude-code','heartbeat\x20failed:\x20','unknown\x20tool','ENV:\x20URL=','trim','connecting\x20to\x20','parse\x20error:\x20','low','statusText','inbox_count','re-register\x20failed:\x20','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','send_task','status','data:\x20','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a','192774sAEAvS','send_reply','Task\x20content','956212lEuUPD','notification','text','type','18twPGJm','object','commhub','0.3.0','pop','commhub_report_status','1550680SvCZRZ','none','http://127.0.0.1:9200','message_id','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','cancelled','Current\x20task\x20description','SSE\x20stream\x20ended,\x20reconnecting...','priority','length','3619962YoNpJV','body','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','broadcast','tools/call','setRequestHandler','commhub-channel','alias','/mcp','read','replied','messages','starting\x20SSE\x20listener...','normal','split','token','connected','error','(none)','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20','commhub_send_message',':\x20inbox_count=','from_session','commhub_get_all_status','30702400VXoxda','←\x20message\x20from\x20','no\x20response','Target\x20session\x20alias','task','2025-03-26','failed','Priority\x20(default:\x20normal)','Bearer\x20','unattributed-','startsWith','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','SIGINT','min','then','\x20CWD=','1772YkHHfu','8Tdpffg','8322559IjbPyn','string','set','catch','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','write',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','from','get_inbox','registered\x20as\x20\x22','.anet','find','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.'];a0_0x4b27=function(){return _0x169b27;};return a0_0x4b27();}W(a0_0x380998(0xc5)+j+'\x20ALIAS='+G+a0_0x380998(0x8e)+K['slice'](0x0,0x8)+'...\x20TMUX='+(f||a0_0x380998(0xe0))+a0_0x380998(0x7b)+process[a0_0x380998(0xa0)]()+'\x20PROJECT_ENV='+v);var D=new Map(),x=new a0_0x4667b6({'name':a0_0x380998(0xef),'version':a0_0x380998(0xdc)},{'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>','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.',a0_0x380998(0xa5),'Session\x20alias:\x20'+G][a0_0x380998(0x9b)]('\x0a')});x[a0_0x380998(0xee)](a0_0x31ba96,async()=>({'tools':[{'name':a0_0x380998(0x98),'description':a0_0x380998(0xe3),'inputSchema':{'type':a0_0x380998(0xda),'properties':{'task_id':{'type':a0_0x380998(0x7f),'description':a0_0x380998(0xcd)},'text':{'type':a0_0x380998(0x7f),'description':a0_0x380998(0xa8)},'status':{'type':a0_0x380998(0x7f),'enum':['completed',a0_0x380998(0x107),a0_0x380998(0xe4),'blocked',a0_0x380998(0xfa),a0_0x380998(0xb5)],'description':a0_0x380998(0x83)}},'required':['text']}},{'name':a0_0x380998(0xde),'description':a0_0x380998(0x10c),'inputSchema':{'type':'object','properties':{'status':{'type':'string','enum':[a0_0x380998(0x99),a0_0x380998(0xa9),'blocked',a0_0x380998(0xfa)]},'task':{'type':a0_0x380998(0x7f),'description':a0_0x380998(0xe5)},'progress':{'type':a0_0x380998(0xba),'description':'Progress\x200-100'}},'required':[a0_0x380998(0xcf)]}},{'name':'commhub_send_task','description':a0_0x380998(0x8c),'inputSchema':{'type':'object','properties':{'alias':{'type':'string','description':a0_0x380998(0x104)},'task':{'type':'string','description':a0_0x380998(0xd4)},'priority':{'type':a0_0x380998(0x7f),'enum':[a0_0x380998(0xa3),'normal',a0_0x380998(0xc9)],'description':a0_0x380998(0x108)}},'required':[a0_0x380998(0xf0),a0_0x380998(0x105)]}},{'name':'commhub_send_message','description':a0_0x380998(0xeb),'inputSchema':{'type':a0_0x380998(0xda),'properties':{'alias':{'type':'string','description':a0_0x380998(0x104)},'message':{'type':'string','description':'Message\x20content'}},'required':[a0_0x380998(0xf0),'message']}},{'name':a0_0x380998(0x100),'description':a0_0x380998(0x82),'inputSchema':{'type':a0_0x380998(0xda),'properties':{}}}]}));async function Y(_0x2139b7,_0x699203){const _0x22a0aa=a0_0x380998;let _0x4a65ca=await fetch(j+_0x22a0aa(0xf1),{'method':'POST','headers':{'Content-Type':_0x22a0aa(0xb7),'Accept':_0x22a0aa(0xac),...F?{'Authorization':'Bearer\x20'+F}:{}},'body':JSON['stringify']({'jsonrpc':_0x22a0aa(0x9a),'id':0x1,'method':_0x22a0aa(0x9e),'params':{'protocolVersion':_0x22a0aa(0x106),'capabilities':{},'clientInfo':{'name':'commhub-channel','version':'0.3.0'}}})});if(!_0x4a65ca['ok']){let _0x1c1f6d=await _0x4a65ca['text']();return W(_0x22a0aa(0xbc)+_0x4a65ca[_0x22a0aa(0xcf)]+'\x20'+_0x1c1f6d[_0x22a0aa(0xb2)](0x0,0x64)),{'ok':!0x1,'error':'init\x20failed:\x20'+_0x4a65ca[_0x22a0aa(0xcf)]};}await _0x4a65ca[_0x22a0aa(0xd7)]();let _0x157660=(await(await fetch(j+_0x22a0aa(0xf1),{'method':_0x22a0aa(0xa1),'headers':{'Content-Type':'application/json','Accept':_0x22a0aa(0xac),...F?{'Authorization':'Bearer\x20'+F}:{}},'body':JSON[_0x22a0aa(0x93)]({'jsonrpc':'2.0','id':0x2,'method':_0x22a0aa(0xed),'params':{'name':_0x2139b7,'arguments':_0x699203}})}))['text']())['split']('\x0a')[_0x22a0aa(0x8b)](_0x3aeb40=>_0x3aeb40[_0x22a0aa(0x10b)](_0x22a0aa(0xd0)));if(_0x157660){let _0x216c9e=JSON[_0x22a0aa(0xad)](_0x157660[_0x22a0aa(0xb2)](0x6));return _0x216c9e?.['result']?.['content']?.[0x0]?.[_0x22a0aa(0xd7)]?JSON[_0x22a0aa(0xad)](_0x216c9e['result'][_0x22a0aa(0xb8)][0x0]['text']):_0x216c9e;}return{'ok':!0x1,'error':_0x22a0aa(0x103)};}x['setRequestHandler'](a0_0x3c32fe,async _0x241681=>{const _0x47538f=a0_0x380998;let {name:_0x52cf82,arguments:_0x46542a}=_0x241681['params'];if(_0x52cf82===_0x47538f(0x98)){let {task_id:_0x5da52a,text:_0x25c1ab,status:_0x54d13b}=_0x46542a;if(_0x54d13b===_0x47538f(0xb3)||_0x54d13b===_0x47538f(0x107)||_0x54d13b===_0x47538f(0xe4)){let _0x45cfd5=_0x54d13b==='completed'?_0x47538f(0xf3):_0x54d13b,_0x428380=_0x5da52a?D['get'](_0x5da52a)||_0x47538f(0xae):'hub',_0x335be7=await Y(_0x47538f(0xd3),{'alias':_0x428380,'text':_0x25c1ab,'in_reply_to':_0x5da52a||void 0x0,'status':_0x45cfd5,'from_session':G});if(_0x5da52a)D['delete'](_0x5da52a);return{'content':[{'type':_0x47538f(0xd7),'text':JSON['stringify'](_0x335be7)}]};}let _0x468190=await Y(_0x47538f(0x9c),{'resume_id':K,'alias':G,'status':_0x54d13b===_0x47538f(0xb6)?_0x47538f(0xb6):_0x54d13b===_0x47538f(0xfa)?'error':'working','task':_0x25c1ab[_0x47538f(0xb2)](0x0,0xc8),'output':_0x25c1ab});return{'content':[{'type':_0x47538f(0xd7),'text':JSON[_0x47538f(0x93)](_0x468190)}]};}if(_0x52cf82==='commhub_report_status'){let {status:_0x159940,task:_0x50b63a,progress:_0x27e0ce}=_0x46542a,_0x3a1b21=await Y(_0x47538f(0x9c),{'resume_id':K,'alias':G,'status':_0x159940,'task':_0x50b63a,'progress':_0x27e0ce});return{'content':[{'type':_0x47538f(0xd7),'text':JSON[_0x47538f(0x93)](_0x3a1b21)}]};}if(_0x52cf82===_0x47538f(0x92)){let {alias:_0x1547c9,task:_0x5b5be7,priority:_0x57163a}=_0x46542a,_0x20e20c=await Y(_0x47538f(0xce),{'alias':_0x1547c9,'task':_0x5b5be7,'priority':_0x57163a||_0x47538f(0xf6),'from_session':G});return{'content':[{'type':_0x47538f(0xd7),'text':JSON[_0x47538f(0x93)](_0x20e20c)}]};}if(_0x52cf82===_0x47538f(0xfd)){let {alias:_0x5e2a08,message:_0x410fb1}=_0x46542a,_0x5e6054=await Y('send_message',{'alias':_0x5e2a08,'message':_0x410fb1,'from_session':G});return{'content':[{'type':_0x47538f(0xd7),'text':JSON['stringify'](_0x5e6054)}]};}if(_0x52cf82==='commhub_get_all_status'){let _0x31c97f=await Y(_0x47538f(0xb0),{});return{'content':[{'type':_0x47538f(0xd7),'text':JSON['stringify'](_0x31c97f)}]};}return{'content':[{'type':'text','text':JSON['stringify']({'error':_0x47538f(0xc4)})}]};});var O=0x3e8,R=0x7530,T=0x36ee80;async function l(){const _0x17ccb6=a0_0x380998;try{await Y(_0x17ccb6(0x9c),{'resume_id':K,'alias':G,'status':_0x17ccb6(0xa9),'server':a0_0x5e751e(),'hostname':a0_0x5e751e(),'agent':_0x17ccb6(0xc2),'project_dir':process[_0x17ccb6(0xa0)](),'tmux_name':f||void 0x0}),W(_0x17ccb6(0x90)+G+_0x17ccb6(0xa6));}catch(_0x1e8e96){W(_0x17ccb6(0xcc)+_0x1e8e96);}}async function o(){const _0x47b8df=a0_0x380998;let _0x4afd03=j+'/events/'+encodeURIComponent(G),_0x335321={};if(F)_0x335321['Authorization']=_0x47b8df(0x109)+F;W(_0x47b8df(0xc7)+_0x4afd03);let _0x3fe71c=O,_0x355dbc=!0x0,_0x1b14d8=null;while(!0x0){try{let _0x3f89fa=await fetch(_0x4afd03,{'headers':_0x335321});if(!_0x3f89fa['ok']){if(W(_0x47b8df(0xaf)+_0x3f89fa[_0x47b8df(0xcf)]+'\x20'+_0x3f89fa[_0x47b8df(0xca)]),_0x1b14d8=_0x1b14d8??Date[_0x47b8df(0x97)](),Date['now']()-_0x1b14d8>T){W(_0x47b8df(0x84)+j+_0x47b8df(0x86));return;}await N(_0x3fe71c),_0x3fe71c=Math['min'](_0x3fe71c*0x2,R);continue;}let _0x1143b8=_0x3f89fa[_0x47b8df(0xea)]['getReader'](),_0x42e450=new TextDecoder(),_0x5e7c22='';_0x3fe71c=O;while(!0x0){let {done:_0x3dff46,value:_0x403988}=await _0x1143b8[_0x47b8df(0xf2)]();if(_0x3dff46)break;_0x5e7c22+=_0x42e450['decode'](_0x403988,{'stream':!0x0});let _0x519dd8=_0x5e7c22[_0x47b8df(0xf7)]('\x0a\x0a');_0x5e7c22=_0x519dd8[_0x47b8df(0xdd)]()||'';for(let _0x3a3725 of _0x519dd8){let _0xf06343=_0x3a3725[_0x47b8df(0xf7)]('\x0a')['find'](_0xf9f1ca=>_0xf9f1ca['startsWith'](_0x47b8df(0xd0)));if(!_0xf06343)continue;try{let _0x50e5cd=JSON[_0x47b8df(0xad)](_0xf06343['slice'](0x6));if(await a(_0x50e5cd),_0x50e5cd[_0x47b8df(0xd8)]===_0x47b8df(0xf9)){if(_0x1b14d8=null,!_0x355dbc)await l();_0x355dbc=!0x1;}}catch(_0x2bac13){W(_0x47b8df(0xc8)+_0x2bac13);}}}W(_0x47b8df(0xe6));}catch(_0x45e305){W('SSE\x20connection\x20error:\x20'+_0x45e305);}if(_0x1b14d8=_0x1b14d8??Date[_0x47b8df(0x97)](),Date['now']()-_0x1b14d8>T){W(_0x47b8df(0x84)+j+_0x47b8df(0x86));return;}await N(_0x3fe71c),_0x3fe71c=Math[_0x47b8df(0x10e)](_0x3fe71c*0x2,R);}}async function a(_0x5f32cc){const _0x5c9286=a0_0x380998;if(_0x5f32cc['type']===_0x5c9286(0xf9)){W('SSE\x20connected\x20as\x20\x22'+G+'\x22');return;}if(_0x5f32cc[_0x5c9286(0xd8)]==='new_message'){if(W(_0x5c9286(0x102)+_0x5f32cc[_0x5c9286(0x87)]+':\x20'+_0x5f32cc[_0x5c9286(0x9d)][_0x5c9286(0xb2)](0x0,0x3c)),await x[_0x5c9286(0xd6)]({'method':_0x5c9286(0x94),'params':{'content':_0x5f32cc[_0x5c9286(0x9d)],'meta':{'sender':_0x5f32cc[_0x5c9286(0x87)]||_0x5c9286(0xae),'sender_id':_0x5c9286(0xdb),'user':_0x5f32cc[_0x5c9286(0x87)]||'hub','priority':_0x5c9286(0xf6)}}}),_0x5f32cc[_0x5c9286(0xe2)])await Y(_0x5c9286(0xb4),{'alias':G,'message_id':_0x5f32cc['message_id']});return;}if(_0x5f32cc['type']===_0x5c9286(0x8f)||_0x5f32cc[_0x5c9286(0xd8)]===_0x5c9286(0xec)){W('←\x20'+_0x5f32cc[_0x5c9286(0xd8)]+_0x5c9286(0xfe)+_0x5f32cc[_0x5c9286(0xcb)]+_0x5c9286(0x8d)+(_0x5f32cc[_0x5c9286(0xe7)]||'normal'));let _0x44fdb0=await Y(_0x5c9286(0x88),{'alias':G,'limit':0x5});if(_0x44fdb0?.['ok']&&_0x44fdb0['messages']?.[_0x5c9286(0xe8)]>0x0)for(let _0x17e6d8 of _0x44fdb0[_0x5c9286(0xf4)]){let _0x5b91ff={'sender':_0x17e6d8['from_session']||_0x5c9286(0xae),'sender_id':_0x5c9286(0xdb),'user':_0x17e6d8['from_session']||_0x5c9286(0xae),'task_id':_0x17e6d8['id'],'priority':_0x17e6d8[_0x5c9286(0xe7)]||'normal'};D[_0x5c9286(0x80)](_0x17e6d8['id'],_0x17e6d8[_0x5c9286(0xff)]||_0x5c9286(0xae)),await x[_0x5c9286(0xd6)]({'method':'notifications/claude/channel','params':{'content':_0x17e6d8[_0x5c9286(0xb8)],'meta':_0x5b91ff}}),W('→\x20injected\x20task\x20'+_0x17e6d8['id'][_0x5c9286(0xb2)](0x0,0x8)+_0x5c9286(0x91)+_0x17e6d8['from_session']+':\x20'+_0x17e6d8['content']['slice'](0x0,0x3c)),await Y(_0x5c9286(0xb4),{'alias':G,'message_id':_0x17e6d8['id']});}}}async function n(){const _0xe61ea1=a0_0x380998;let _0x19b5ac=new a0_0x1b5e4b();await x['connect'](_0x19b5ac),W('MCP\x20stdio\x20connected'),W(_0xe61ea1(0xf5)),o()[_0xe61ea1(0x81)](_0x2e92b7=>W(_0xe61ea1(0xab)+_0x2e92b7)),Y('report_status',{'resume_id':K,'alias':G,'status':'idle','server':a0_0x5e751e(),'hostname':a0_0x5e751e(),'agent':_0xe61ea1(0xc2),'project_dir':process[_0xe61ea1(0xa0)](),'tmux_name':f||void 0x0})[_0xe61ea1(0x7a)](()=>W(_0xe61ea1(0x89)+G+'\x22\x20('+K['slice'](0x0,0x8)+')'))['catch'](_0x5ae1b9=>W(_0xe61ea1(0xc0)+_0x5ae1b9)),setInterval(()=>{const _0x43b8b8=_0xe61ea1;Y(_0x43b8b8(0x9c),{'resume_id':K,'alias':G,'status':'idle','server':a0_0x5e751e(),'hostname':a0_0x5e751e(),'agent':_0x43b8b8(0xc2),'project_dir':process['cwd'](),'tmux_name':f||void 0x0})[_0x43b8b8(0x81)](_0x34369a=>W(_0x43b8b8(0xc3)+_0x34369a));},0x2bf20),W(_0xe61ea1(0x95));}n()[a0_0x380998(0x81)](_0x143a51=>{const _0x4de9c1=a0_0x380998;W(_0x4de9c1(0xb1)+_0x143a51),process['exit'](0x1);});async function b(){const _0x1af1b5=a0_0x380998;W('shutting\x20down,\x20reporting\x20offline...'),await Y(_0x1af1b5(0x9c),{'resume_id':K,'alias':G,'status':'offline','task':_0x1af1b5(0xa2)})[_0x1af1b5(0x81)](()=>{}),process['exit'](0x0);}process['stdin']['on']('end',()=>b()),process['on'](a0_0x380998(0x96),()=>b()),process['on'](a0_0x380998(0x10d),()=>b());
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type RuntimeName = "claude-code-cli" | "codex-sdk" | "claude-agent-sdk" | "grok-build-acp";
|
|
2
|
+
/** Operator-facing default for any runtime slot that comes in empty / missing / unrecognized. */
|
|
3
|
+
export declare const DEFAULT_RUNTIME: RuntimeName;
|
|
4
|
+
type ProfileLike = {
|
|
5
|
+
runtime?: string;
|
|
6
|
+
codexRuntime?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function normalizeRuntime(profileOrRuntime?: ProfileLike | string): RuntimeName;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-iteration controller passed into `runOnce`. Today exposes only
|
|
3
|
+
* `markStable`; a future stop-the-current-iteration affordance would
|
|
4
|
+
* be a sibling field on this interface.
|
|
5
|
+
*/
|
|
6
|
+
export interface SupervisedIterationController {
|
|
7
|
+
/**
|
|
8
|
+
* Signal that this iteration crossed the "actually working" threshold.
|
|
9
|
+
* Resets the backoff to `baseDelayMs` and zeroes the cumulative
|
|
10
|
+
* downtime counter. Safe to call multiple times per iteration — only
|
|
11
|
+
* the first call has effect within a single iteration.
|
|
12
|
+
*/
|
|
13
|
+
markStable(): void;
|
|
14
|
+
}
|
|
15
|
+
export interface SuperviseChildOpts {
|
|
16
|
+
/** Short label for log / error messages. e.g. "feishu" / "sse". */
|
|
17
|
+
label: string;
|
|
18
|
+
/** Returns true when the supervisor should stop without rescheduling. */
|
|
19
|
+
shutdownGate: () => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* One iteration of the supervised child. Resolves when the iteration
|
|
22
|
+
* ends (child exits / stream closes); throws to log + reschedule.
|
|
23
|
+
* Receives a controller for the iteration to call `markStable` on
|
|
24
|
+
* once the work crosses its "really working" threshold.
|
|
25
|
+
*/
|
|
26
|
+
runOnce: (ctrl: SupervisedIterationController) => Promise<void>;
|
|
27
|
+
/** Initial backoff delay in ms. Default 1_000. */
|
|
28
|
+
baseDelayMs?: number;
|
|
29
|
+
/** Maximum backoff after exponential growth. Default 30_000. */
|
|
30
|
+
maxDelayMs?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Jitter ratio (±N×delay). Default 0.25 (±25%). Set 0 to disable.
|
|
33
|
+
* The waited time per backoff is `max(100, delay + delay * jitter *
|
|
34
|
+
* (Math.random() * 2 - 1))`.
|
|
35
|
+
*/
|
|
36
|
+
jitterRatio?: number;
|
|
37
|
+
/**
|
|
38
|
+
* If cumulative downtime (consecutive iterations that did NOT call
|
|
39
|
+
* markStable, plus their inter-iteration sleeps) exceeds this, the
|
|
40
|
+
* supervisor invokes `onAbandon` and returns. Default `Infinity`
|
|
41
|
+
* (never abandon). Set to a finite value (e.g. 3_600_000 = 1 h) to
|
|
42
|
+
* give up after a long unsuccessful run.
|
|
43
|
+
*/
|
|
44
|
+
abandonAfterMs?: number;
|
|
45
|
+
/** Called once if the supervisor abandons. */
|
|
46
|
+
onAbandon?: () => void;
|
|
47
|
+
/** Called with the runOnce error before scheduling the next iteration. */
|
|
48
|
+
onError?: (err: unknown) => void;
|
|
49
|
+
/** Called before sleeping with the resolved backoff (and the jittered wait). */
|
|
50
|
+
onRetryWait?: (waitMs: number, backoffMs: number) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Sleep primitive — overridden by tests to skip real timers. Default
|
|
53
|
+
* uses `setTimeout`. Must respect `ms <= 0` as "no wait".
|
|
54
|
+
*/
|
|
55
|
+
sleep?: (ms: number) => Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Random source — overridden by tests for deterministic jitter.
|
|
58
|
+
* Default `Math.random`.
|
|
59
|
+
*/
|
|
60
|
+
random?: () => number;
|
|
61
|
+
/** Current-time source — overridden by tests. Default `Date.now`. */
|
|
62
|
+
now?: () => number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Run the supervisor loop. Resolves when the shutdown gate triggers or
|
|
66
|
+
* the abandon threshold fires; never throws (runOnce errors are routed
|
|
67
|
+
* to `onError`).
|
|
68
|
+
*/
|
|
69
|
+
export declare function superviseChild(opts: SuperviseChildOpts): Promise<void>;
|
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
|
|
3
|
+
"version": "2.3.0-preview.10",
|
|
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",
|
|
@@ -65,10 +65,13 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@inquirer/prompts": "^8.4.3",
|
|
68
|
-
"@larksuiteoapi/node-sdk": "^1.42.0"
|
|
68
|
+
"@larksuiteoapi/node-sdk": "^1.42.0",
|
|
69
|
+
"markdown-it": "^14.1.0",
|
|
70
|
+
"puppeteer-core": "^24.10.2"
|
|
69
71
|
},
|
|
70
72
|
"devDependencies": {
|
|
71
73
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
74
|
+
"@types/markdown-it": "^14.1.2",
|
|
72
75
|
"@types/node": "^25.0.0",
|
|
73
76
|
"javascript-obfuscator": "^5.4.1",
|
|
74
77
|
"node-pty": "^1.1.0",
|