@sleep2agi/agent-network 2.3.0-preview.0 → 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/gitignore-writeback.d.ts +21 -0
- 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_0x428199=a0_0x17e9;(function(_0xa49539,_0x5e61de){const _0x557910=a0_0x17e9,_0x439bd5=_0xa49539();while(!![]){try{const _0x34a65d=parseInt(_0x557910(0x14c))/0x1+parseInt(_0x557910(0x151))/0x2*(-parseInt(_0x557910(0x147))/0x3)+parseInt(_0x557910(0x13d))/0x4+parseInt(_0x557910(0x14b))/0x5*(-parseInt(_0x557910(0x19b))/0x6)+parseInt(_0x557910(0x199))/0x7+parseInt(_0x557910(0x14d))/0x8+-parseInt(_0x557910(0x16a))/0x9*(parseInt(_0x557910(0x178))/0xa);if(_0x34a65d===_0x5e61de)break;else _0x439bd5['push'](_0x439bd5['shift']());}catch(_0x37fedf){_0x439bd5['push'](_0x439bd5['shift']());}}}(a0_0x10b9,0x34b38));import{readFileSync as a0_0x567be1,existsSync as a0_0x113046}from'fs';import{randomUUID as a0_0x518187}from'crypto';function a0_0x17e9(_0x1b32dd,_0x157267){_0x1b32dd=_0x1b32dd-0x11d;const _0x10b9e4=a0_0x10b9();let _0x17e984=_0x10b9e4[_0x1b32dd];return _0x17e984;}import{join as a0_0x3e60b7}from'path';import{hostname as a0_0x224891}from'os';import{execSync as a0_0xf75b1a}from'child_process';import{Server as a0_0x2b1d99}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x3db5a7}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x4277b,CallToolRequestSchema as a0_0x2ac4fd}from'@modelcontextprotocol/sdk/types.js';function I(_0x51f8be){const _0x5345a0=a0_0x17e9;if(!a0_0x113046(_0x51f8be))return;for(let _0x3a248e of a0_0x567be1(_0x51f8be,_0x5345a0(0x156))[_0x5345a0(0x157)]('\x0a')){let _0xe4a48=_0x3a248e[_0x5345a0(0x153)]();if(!_0xe4a48||_0xe4a48[_0x5345a0(0x152)]('#'))continue;let _0x280f25=_0xe4a48[_0x5345a0(0x1ac)]('=');if(_0x280f25<0x0)continue;let _0x3b07ac=_0xe4a48['slice'](0x0,_0x280f25)[_0x5345a0(0x153)](),_0x921fb3=_0xe4a48[_0x5345a0(0x173)](_0x280f25+0x1)['trim']()[_0x5345a0(0x133)](/^["']|["']$/g,'');if(!process.env[_0x3b07ac])process.env[_0x3b07ac]=_0x921fb3;}}var L=process.env.HOME||'~',U=a0_0x3e60b7(L,a0_0x428199(0x15c));I(a0_0x3e60b7(U,a0_0x428199(0x195)));var v=process[a0_0x428199(0x14e)]()[a0_0x428199(0x133)](/\//g,'-');I(a0_0x3e60b7(U,v,a0_0x428199(0x195)));function d(){const _0x1ab4fb=a0_0x428199;try{return a0_0xf75b1a(_0x1ab4fb(0x128),{'encoding':_0x1ab4fb(0x156),'timeout':0x7d0})[_0x1ab4fb(0x153)]();}catch{return'';}}function m(){const _0x516498=a0_0x428199;try{let _0x46f8aa=a0_0x3e60b7(L,_0x516498(0x14a),'config.json');if(a0_0x113046(_0x46f8aa))return JSON[_0x516498(0x129)](a0_0x567be1(_0x46f8aa,_0x516498(0x156)));}catch{}return{};}var u=m(),j=process.env.COMMHUB_URL||u[a0_0x428199(0x12e)]||'http://127.0.0.1:9200',f=process.env.COMMHUB_TMUX||d();function r(){const _0x1c6d4f=a0_0x428199;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS['trim']())return process.env.COMMHUB_ALIAS[_0x1c6d4f(0x153)]();return process[_0x1c6d4f(0x185)]['write'](_0x1c6d4f(0x124)+(_0x1c6d4f(0x1a0)+(f||_0x1c6d4f(0x1aa))+_0x1c6d4f(0x1a2)+a0_0x224891()+'.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a')),_0x1c6d4f(0x17c)+process[_0x1c6d4f(0x180)];}var G=r(),K=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x518187(),F=process.env.COMMHUB_TOKEN||u[a0_0x428199(0x122)]||'';function W(_0x12a078){const _0x4b591f=a0_0x428199;let _0xc869d5=new Date()[_0x4b591f(0x161)]()[_0x4b591f(0x173)](0x0,0x8);process[_0x4b591f(0x185)][_0x4b591f(0x182)]('['+_0xc869d5+_0x4b591f(0x1a9)+_0x12a078+'\x0a');}function N(_0x2ad54a){return new Promise(_0x28eddc=>setTimeout(_0x28eddc,_0x2ad54a));}W(a0_0x428199(0x155)+j+a0_0x428199(0x186)+G+'\x20RESUME_ID='+K[a0_0x428199(0x173)](0x0,0x8)+a0_0x428199(0x13e)+(f||'none')+a0_0x428199(0x134)+process[a0_0x428199(0x14e)]()+a0_0x428199(0x175)+v);var D=new Map(),x=new a0_0x2b1d99({'name':'commhub-channel','version':'0.3.0'},{'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_0x428199(0x187),a0_0x428199(0x18e),'You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.',a0_0x428199(0x192)+G][a0_0x428199(0x143)]('\x0a')});x[a0_0x428199(0x148)](a0_0x4277b,async()=>({'tools':[{'name':a0_0x428199(0x1a4),'description':a0_0x428199(0x135),'inputSchema':{'type':'object','properties':{'task_id':{'type':a0_0x428199(0x194),'description':a0_0x428199(0x142)},'text':{'type':a0_0x428199(0x194),'description':a0_0x428199(0x165)},'status':{'type':a0_0x428199(0x194),'enum':[a0_0x428199(0x139),'failed',a0_0x428199(0x15e),'blocked','error',a0_0x428199(0x19f)],'description':'Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates'}},'required':[a0_0x428199(0x17a)]}},{'name':a0_0x428199(0x140),'description':a0_0x428199(0x197),'inputSchema':{'type':a0_0x428199(0x125),'properties':{'status':{'type':a0_0x428199(0x194),'enum':[a0_0x428199(0x12d),a0_0x428199(0x1a7),a0_0x428199(0x13a),a0_0x428199(0x15f)]},'task':{'type':a0_0x428199(0x194),'description':a0_0x428199(0x1a6)},'progress':{'type':a0_0x428199(0x16d),'description':a0_0x428199(0x17d)}},'required':['status']}},{'name':a0_0x428199(0x181),'description':a0_0x428199(0x146),'inputSchema':{'type':a0_0x428199(0x125),'properties':{'alias':{'type':a0_0x428199(0x194),'description':a0_0x428199(0x149)},'task':{'type':a0_0x428199(0x194),'description':a0_0x428199(0x18f)},'priority':{'type':'string','enum':[a0_0x428199(0x15d),'normal','low'],'description':a0_0x428199(0x184)}},'required':[a0_0x428199(0x183),a0_0x428199(0x141)]}},{'name':a0_0x428199(0x127),'description':a0_0x428199(0x126),'inputSchema':{'type':'object','properties':{'alias':{'type':'string','description':a0_0x428199(0x149)},'message':{'type':'string','description':'Message\x20content'}},'required':['alias',a0_0x428199(0x16b)]}},{'name':a0_0x428199(0x164),'description':a0_0x428199(0x12f),'inputSchema':{'type':a0_0x428199(0x125),'properties':{}}}]}));async function Y(_0x8f4818,_0x253e65){const _0x572991=a0_0x428199;let _0xff4c40=await fetch(j+_0x572991(0x1b0),{'method':_0x572991(0x136),'headers':{'Content-Type':_0x572991(0x18b),'Accept':_0x572991(0x171),...F?{'Authorization':_0x572991(0x158)+F}:{}},'body':JSON[_0x572991(0x15a)]({'jsonrpc':_0x572991(0x170),'id':0x1,'method':_0x572991(0x121),'params':{'protocolVersion':_0x572991(0x189),'capabilities':{},'clientInfo':{'name':_0x572991(0x1ab),'version':'0.3.0'}}})});if(!_0xff4c40['ok']){let _0x1d2b56=await _0xff4c40['text']();return W(_0x572991(0x12b)+_0xff4c40[_0x572991(0x191)]+'\x20'+_0x1d2b56['slice'](0x0,0x64)),{'ok':!0x1,'error':_0x572991(0x120)+_0xff4c40[_0x572991(0x191)]};}await _0xff4c40[_0x572991(0x17a)]();let _0x1d9bd9=(await(await fetch(j+_0x572991(0x1b0),{'method':'POST','headers':{'Content-Type':_0x572991(0x18b),'Accept':'application/json,\x20text/event-stream',...F?{'Authorization':_0x572991(0x158)+F}:{}},'body':JSON[_0x572991(0x15a)]({'jsonrpc':_0x572991(0x170),'id':0x2,'method':_0x572991(0x12c),'params':{'name':_0x8f4818,'arguments':_0x253e65}})}))[_0x572991(0x17a)]())['split']('\x0a')['find'](_0x503bad=>_0x503bad['startsWith'](_0x572991(0x1b1)));if(_0x1d9bd9){let _0x5abd29=JSON[_0x572991(0x129)](_0x1d9bd9['slice'](0x6));return _0x5abd29?.[_0x572991(0x1a3)]?.[_0x572991(0x145)]?.[0x0]?.[_0x572991(0x17a)]?JSON[_0x572991(0x129)](_0x5abd29['result'][_0x572991(0x145)][0x0][_0x572991(0x17a)]):_0x5abd29;}return{'ok':!0x1,'error':_0x572991(0x193)};}x[a0_0x428199(0x148)](a0_0x2ac4fd,async _0x1fd039=>{const _0x27e9d7=a0_0x428199;let {name:_0x4362d5,arguments:_0x24acd4}=_0x1fd039[_0x27e9d7(0x154)];if(_0x4362d5==='commhub_reply'){let {task_id:_0x5b6a4e,text:_0x296269,status:_0x1fc0ab}=_0x24acd4;if(_0x1fc0ab==='completed'||_0x1fc0ab==='failed'||_0x1fc0ab===_0x27e9d7(0x15e)){let _0x48d45a=_0x1fc0ab===_0x27e9d7(0x139)?_0x27e9d7(0x1ae):_0x1fc0ab,_0x11afeb=_0x5b6a4e?D[_0x27e9d7(0x18a)](_0x5b6a4e)||_0x27e9d7(0x12e):_0x27e9d7(0x12e),_0x11d770=await Y(_0x27e9d7(0x190),{'alias':_0x11afeb,'text':_0x296269,'in_reply_to':_0x5b6a4e||void 0x0,'status':_0x48d45a,'from_session':G});if(_0x5b6a4e)D['delete'](_0x5b6a4e);return{'content':[{'type':_0x27e9d7(0x17a),'text':JSON['stringify'](_0x11d770)}]};}let _0x1f2340=await Y(_0x27e9d7(0x167),{'resume_id':K,'alias':G,'status':_0x1fc0ab===_0x27e9d7(0x13a)?_0x27e9d7(0x13a):_0x1fc0ab===_0x27e9d7(0x15f)?_0x27e9d7(0x15f):_0x27e9d7(0x12d),'task':_0x296269['slice'](0x0,0xc8),'output':_0x296269});return{'content':[{'type':_0x27e9d7(0x17a),'text':JSON[_0x27e9d7(0x15a)](_0x1f2340)}]};}if(_0x4362d5===_0x27e9d7(0x140)){let {status:_0x598a74,task:_0x5eafe7,progress:_0x29b1b4}=_0x24acd4,_0x3180e9=await Y(_0x27e9d7(0x167),{'resume_id':K,'alias':G,'status':_0x598a74,'task':_0x5eafe7,'progress':_0x29b1b4});return{'content':[{'type':'text','text':JSON[_0x27e9d7(0x15a)](_0x3180e9)}]};}if(_0x4362d5===_0x27e9d7(0x181)){let {alias:_0x1976bb,task:_0x2f92b4,priority:_0x155388}=_0x24acd4,_0x2f289c=await Y('send_task',{'alias':_0x1976bb,'task':_0x2f92b4,'priority':_0x155388||_0x27e9d7(0x17b),'from_session':G});return{'content':[{'type':_0x27e9d7(0x17a),'text':JSON['stringify'](_0x2f289c)}]};}if(_0x4362d5===_0x27e9d7(0x127)){let {alias:_0x152708,message:_0x48d6a3}=_0x24acd4,_0x1c2e36=await Y('send_message',{'alias':_0x152708,'message':_0x48d6a3,'from_session':G});return{'content':[{'type':_0x27e9d7(0x17a),'text':JSON[_0x27e9d7(0x15a)](_0x1c2e36)}]};}if(_0x4362d5==='commhub_get_all_status'){let _0x5a8100=await Y('get_all_status',{});return{'content':[{'type':'text','text':JSON[_0x27e9d7(0x15a)](_0x5a8100)}]};}return{'content':[{'type':_0x27e9d7(0x17a),'text':JSON[_0x27e9d7(0x15a)]({'error':'unknown\x20tool'})}]};});var O=0x3e8,R=0x7530,T=0x36ee80;async function l(){const _0x1b92bf=a0_0x428199;try{await Y(_0x1b92bf(0x167),{'resume_id':K,'alias':G,'status':_0x1b92bf(0x1a7),'server':a0_0x224891(),'hostname':a0_0x224891(),'agent':_0x1b92bf(0x19e),'project_dir':process['cwd'](),'tmux_name':f||void 0x0}),W(_0x1b92bf(0x163)+G+_0x1b92bf(0x17f));}catch(_0x57c27d){W(_0x1b92bf(0x162)+_0x57c27d);}}async function o(){const _0x5ba89a=a0_0x428199;let _0x4008d6=j+_0x5ba89a(0x18d)+encodeURIComponent(G),_0x44e10a={};if(F)_0x44e10a['Authorization']='Bearer\x20'+F;W(_0x5ba89a(0x169)+_0x4008d6);let _0x4dca3e=O,_0x3c893e=!0x0,_0x1eaac0=null;while(!0x0){try{let _0x2529a9=await fetch(_0x4008d6,{'headers':_0x44e10a});if(!_0x2529a9['ok']){if(W(_0x5ba89a(0x174)+_0x2529a9['status']+'\x20'+_0x2529a9[_0x5ba89a(0x196)]),_0x1eaac0=_0x1eaac0??Date['now'](),Date[_0x5ba89a(0x13f)]()-_0x1eaac0>T){W('SSE\x20连续\x20>1h\x20连不上\x20hub\x20('+j+_0x5ba89a(0x172));return;}await N(_0x4dca3e),_0x4dca3e=Math[_0x5ba89a(0x13c)](_0x4dca3e*0x2,R);continue;}let _0x367499=_0x2529a9['body'][_0x5ba89a(0x15b)](),_0x5b6827=new TextDecoder(),_0x5265b9='';_0x4dca3e=O;while(!0x0){let {done:_0x10b8aa,value:_0x40412b}=await _0x367499['read']();if(_0x10b8aa)break;_0x5265b9+=_0x5b6827['decode'](_0x40412b,{'stream':!0x0});let _0x7d6a04=_0x5265b9[_0x5ba89a(0x157)]('\x0a\x0a');_0x5265b9=_0x7d6a04[_0x5ba89a(0x150)]()||'';for(let _0x1327bc of _0x7d6a04){let _0x4c778a=_0x1327bc['split']('\x0a')['find'](_0x4cd08e=>_0x4cd08e[_0x5ba89a(0x152)](_0x5ba89a(0x1b1)));if(!_0x4c778a)continue;try{let _0xaf659b=JSON[_0x5ba89a(0x129)](_0x4c778a[_0x5ba89a(0x173)](0x6));if(await a(_0xaf659b),_0xaf659b[_0x5ba89a(0x160)]===_0x5ba89a(0x123)){if(_0x1eaac0=null,!_0x3c893e)await l();_0x3c893e=!0x1;}}catch(_0x869b94){W(_0x5ba89a(0x1af)+_0x869b94);}}}W('SSE\x20stream\x20ended,\x20reconnecting...');}catch(_0x2b92de){W(_0x5ba89a(0x131)+_0x2b92de);}if(_0x1eaac0=_0x1eaac0??Date[_0x5ba89a(0x13f)](),Date[_0x5ba89a(0x13f)]()-_0x1eaac0>T){W(_0x5ba89a(0x179)+j+_0x5ba89a(0x172));return;}await N(_0x4dca3e),_0x4dca3e=Math[_0x5ba89a(0x13c)](_0x4dca3e*0x2,R);}}function a0_0x10b9(){const _0x3bb166=['completed','blocked','priority','min','1656204eUvJpA','...\x20TMUX=','now','commhub_report_status','task','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','join','from','content','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','981FhRVFj','setRequestHandler','Target\x20session\x20alias','.anet','50YixqeM','66220WrWnhF','567808ZwHDHD','cwd','length','pop','1678EngiOP','startsWith','trim','params','ENV:\x20URL=','utf-8','split','Bearer\x20','ready\x20—\x20waiting\x20for\x20events','stringify','getReader','.claude/channels/commhub','high','cancelled','error','type','toTimeString','re-register\x20failed:\x20','re-registered\x20as\x20\x22','commhub_get_all_status','Reply\x20text\x20/\x20result\x20summary','commhub','report_status','catch','connecting\x20to\x20','45SyRkzn','message','shutting\x20down,\x20reporting\x20offline...','number','from_session','set','2.0','application/json,\x20text/event-stream',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','slice','SSE\x20error:\x20','\x20PROJECT_ENV=','new_task','broadcast','100180YztqMu','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','text','normal','unattributed-','Progress\x200-100','ack_inbox','\x22\x20after\x20SSE\x20reconnect','pid','commhub_send_task','write','alias','Priority\x20(default:\x20normal)','stderr','\x20ALIAS=','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.',':\x20inbox_count=','2025-03-26','get','application/json','new_message','/events/','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','Task\x20content','send_reply','status','Session\x20alias:\x20','no\x20response','string','.env','statusText','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','notifications/claude/channel','1989470mbniBl','→\x20injected\x20task\x20','177090AbpNYg','notification','message_id','claude-code','in_progress','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','warning:\x20could\x20not\x20register:\x20','\x20/\x20hostname=','result','commhub_reply','←\x20message\x20from\x20','Current\x20task\x20description','idle','MCP\x20stdio\x20connected',']\x20[commhub]\x20','(none)','commhub-channel','indexOf','exit','replied','parse\x20error:\x20','/mcp','data:\x20','fatal:\x20','\x22\x20(','messages','end','init\x20failed:\x20','initialize','token','connected','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20','object','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','commhub_send_message','tmux\x20display-message\x20-p\x20\x27#S\x27','parse','starting\x20SSE\x20listener...','CommHub\x20init\x20failed:\x20','tools/call','working','hub','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','session\x20disconnected','SSE\x20connection\x20error:\x20','registered\x20as\x20\x22','replace','\x20CWD=','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','POST','get_inbox','SIGINT'];a0_0x10b9=function(){return _0x3bb166;};return a0_0x10b9();}async function a(_0x3243ee){const _0x19889d=a0_0x428199;if(_0x3243ee[_0x19889d(0x160)]===_0x19889d(0x123)){W('SSE\x20connected\x20as\x20\x22'+G+'\x22');return;}if(_0x3243ee['type']===_0x19889d(0x18c)){if(W(_0x19889d(0x1a5)+_0x3243ee[_0x19889d(0x144)]+':\x20'+_0x3243ee[_0x19889d(0x16b)]['slice'](0x0,0x3c)),await x[_0x19889d(0x19c)]({'method':'notifications/claude/channel','params':{'content':_0x3243ee[_0x19889d(0x16b)],'meta':{'sender':_0x3243ee[_0x19889d(0x144)]||_0x19889d(0x12e),'sender_id':_0x19889d(0x166),'user':_0x3243ee[_0x19889d(0x144)]||_0x19889d(0x12e),'priority':_0x19889d(0x17b)}}}),_0x3243ee[_0x19889d(0x19d)])await Y(_0x19889d(0x17e),{'alias':G,'message_id':_0x3243ee[_0x19889d(0x19d)]});return;}if(_0x3243ee['type']===_0x19889d(0x176)||_0x3243ee[_0x19889d(0x160)]===_0x19889d(0x177)){W('←\x20'+_0x3243ee[_0x19889d(0x160)]+_0x19889d(0x188)+_0x3243ee['inbox_count']+'\x20priority='+(_0x3243ee[_0x19889d(0x13b)]||_0x19889d(0x17b)));let _0x3f005f=await Y(_0x19889d(0x137),{'alias':G,'limit':0x5});if(_0x3f005f?.['ok']&&_0x3f005f['messages']?.[_0x19889d(0x14f)]>0x0)for(let _0x335fc1 of _0x3f005f[_0x19889d(0x11e)]){let _0x45daa4={'sender':_0x335fc1['from_session']||_0x19889d(0x12e),'sender_id':_0x19889d(0x166),'user':_0x335fc1[_0x19889d(0x16e)]||'hub','task_id':_0x335fc1['id'],'priority':_0x335fc1[_0x19889d(0x13b)]||_0x19889d(0x17b)};D[_0x19889d(0x16f)](_0x335fc1['id'],_0x335fc1[_0x19889d(0x16e)]||_0x19889d(0x12e)),await x[_0x19889d(0x19c)]({'method':_0x19889d(0x198),'params':{'content':_0x335fc1[_0x19889d(0x145)],'meta':_0x45daa4}}),W(_0x19889d(0x19a)+_0x335fc1['id']['slice'](0x0,0x8)+'\x20from\x20'+_0x335fc1[_0x19889d(0x16e)]+':\x20'+_0x335fc1[_0x19889d(0x145)][_0x19889d(0x173)](0x0,0x3c)),await Y(_0x19889d(0x17e),{'alias':G,'message_id':_0x335fc1['id']});}}}async function n(){const _0x2b9737=a0_0x428199;let _0x518b51=new a0_0x3db5a7();await x['connect'](_0x518b51),W(_0x2b9737(0x1a8)),W(_0x2b9737(0x12a)),o()[_0x2b9737(0x168)](_0x2deead=>W('SSE\x20fatal:\x20'+_0x2deead)),Y(_0x2b9737(0x167),{'resume_id':K,'alias':G,'status':'idle','server':a0_0x224891(),'hostname':a0_0x224891(),'agent':_0x2b9737(0x19e),'project_dir':process['cwd'](),'tmux_name':f||void 0x0})['then'](()=>W(_0x2b9737(0x132)+G+_0x2b9737(0x11d)+K['slice'](0x0,0x8)+')'))[_0x2b9737(0x168)](_0x1e1056=>W(_0x2b9737(0x1a1)+_0x1e1056)),setInterval(()=>{const _0x4b1785=_0x2b9737;Y(_0x4b1785(0x167),{'resume_id':K,'alias':G,'status':_0x4b1785(0x1a7),'server':a0_0x224891(),'hostname':a0_0x224891(),'agent':_0x4b1785(0x19e),'project_dir':process['cwd'](),'tmux_name':f||void 0x0})[_0x4b1785(0x168)](_0x5a9af3=>W('heartbeat\x20failed:\x20'+_0x5a9af3));},0x2bf20),W(_0x2b9737(0x159));}n()[a0_0x428199(0x168)](_0x428e41=>{const _0x459451=a0_0x428199;W(_0x459451(0x1b2)+_0x428e41),process[_0x459451(0x1ad)](0x1);});async function b(){const _0x2d10cf=a0_0x428199;W(_0x2d10cf(0x16c)),await Y(_0x2d10cf(0x167),{'resume_id':K,'alias':G,'status':'offline','task':_0x2d10cf(0x130)})[_0x2d10cf(0x168)](()=>{}),process[_0x2d10cf(0x1ad)](0x0);}process['stdin']['on'](a0_0x428199(0x11f),()=>b()),process['on']('SIGTERM',()=>b()),process['on'](a0_0x428199(0x138),()=>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",
|