@sleep2agi/agent-network 2.3.0-preview.15 → 2.3.0-preview.17
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.js +1 -1
- package/dist/src/client.js +1 -1
- package/dist/src/im/feishu/adapter.d.ts +11 -0
- package/dist/src/im/feishu/hub-upload.d.ts +88 -0
- package/dist/src/im/feishu/outbound-route.d.ts +62 -0
- package/dist/src/im/feishu/worker.js +157 -131
- package/dist/src/im/types.d.ts +30 -1
- package/dist/src/node-server.js +1 -1
- package/package.json +1 -1
package/dist/src/im/types.d.ts
CHANGED
|
@@ -72,13 +72,42 @@ export interface NormalizedIMEvent {
|
|
|
72
72
|
mentioned: boolean;
|
|
73
73
|
content: {
|
|
74
74
|
text?: string;
|
|
75
|
-
/** Local filesystem paths to already-downloaded images.
|
|
75
|
+
/** Local filesystem paths to already-downloaded images.
|
|
76
|
+
*
|
|
77
|
+
* RFC-020 §17 backward-compat shim: the new richer
|
|
78
|
+
* `attachments[]` field below is the canonical source going
|
|
79
|
+
* forward. `images` stays a `string[]` of paths so an older
|
|
80
|
+
* agent-node worker reading this envelope across a rolling
|
|
81
|
+
* upgrade doesn't crash. New workers prefer `attachments`,
|
|
82
|
+
* old workers ignore it and keep using `images`. */
|
|
76
83
|
images?: string[];
|
|
77
84
|
files?: {
|
|
78
85
|
name: string;
|
|
79
86
|
path?: string;
|
|
80
87
|
url?: string;
|
|
81
88
|
}[];
|
|
89
|
+
/** RFC-020 §17 cross-machine attachment descriptors.
|
|
90
|
+
*
|
|
91
|
+
* Each entry mirrors `meta.attachments[]` on commhub tasks
|
|
92
|
+
* (`{ type, file_id?, path?, mime?, name?, size? }`). The
|
|
93
|
+
* feishu bridge populates `file_id` by uploading inbound
|
|
94
|
+
* files to `/api/upload` so cross-host agents delegated via
|
|
95
|
+
* `commhub_send_task(meta.attachments=...)` can fetch via
|
|
96
|
+
* `/api/files/<id>`. When upload fails, `file_id` is absent
|
|
97
|
+
* and the descriptor degrades to path-only (single-host
|
|
98
|
+
* still works via local Read; no regression vs pre-fix
|
|
99
|
+
* baseline).
|
|
100
|
+
*
|
|
101
|
+
* Always populated alongside `images` for the same files —
|
|
102
|
+
* duplication is intentional for rolling-upgrade safety. */
|
|
103
|
+
attachments?: Array<{
|
|
104
|
+
type: "image" | "file";
|
|
105
|
+
path?: string;
|
|
106
|
+
file_id?: string;
|
|
107
|
+
mime?: string;
|
|
108
|
+
name?: string;
|
|
109
|
+
size?: number;
|
|
110
|
+
}>;
|
|
82
111
|
};
|
|
83
112
|
/**
|
|
84
113
|
* Original platform payload. Default: held in memory only and dropped after
|
package/dist/src/node-server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
const a0_0x4af176=a0_0x545f;(function(_0x511c95,_0x48b1f6){const _0x2bc64b=a0_0x545f,_0x50e01d=_0x511c95();while(!![]){try{const _0x3d1d54=-parseInt(_0x2bc64b(0x101))/0x1+-parseInt(_0x2bc64b(0x92))/0x2*(-parseInt(_0x2bc64b(0x98))/0x3)+parseInt(_0x2bc64b(0xa3))/0x4+-parseInt(_0x2bc64b(0xd4))/0x5+-parseInt(_0x2bc64b(0xd9))/0x6*(-parseInt(_0x2bc64b(0xce))/0x7)+-parseInt(_0x2bc64b(0x107))/0x8*(parseInt(_0x2bc64b(0xa8))/0x9)+parseInt(_0x2bc64b(0xe9))/0xa;if(_0x3d1d54===_0x48b1f6)break;else _0x50e01d['push'](_0x50e01d['shift']());}catch(_0x204359){_0x50e01d['push'](_0x50e01d['shift']());}}}(a0_0x22f8,0xd0e4f));import{readFileSync as a0_0x4c6eab,existsSync as a0_0x503a76}from'fs';import{randomUUID as a0_0xa33948}from'crypto';import{join as a0_0x2d6bf0}from'path';import{hostname as a0_0xfed9a0}from'os';function a0_0x545f(_0x2cd6ff,_0x5bb3f3){_0x2cd6ff=_0x2cd6ff-0x77;const _0x22f85b=a0_0x22f8();let _0x545f98=_0x22f85b[_0x2cd6ff];return _0x545f98;}import{execSync as a0_0x3b2733}from'child_process';import{Server as a0_0x48c90d}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0xfdc6e8}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x51a7e5,CallToolRequestSchema as a0_0x1de7a4}from'@modelcontextprotocol/sdk/types.js';function I(_0x33b14d){const _0x4ef175=a0_0x545f;if(!a0_0x503a76(_0x33b14d))return;for(let _0x5729ec of a0_0x4c6eab(_0x33b14d,_0x4ef175(0xdb))['split']('\x0a')){let _0x5a35dd=_0x5729ec[_0x4ef175(0xc7)]();if(!_0x5a35dd||_0x5a35dd[_0x4ef175(0xbe)]('#'))continue;let _0x46a7b6=_0x5a35dd[_0x4ef175(0x112)]('=');if(_0x46a7b6<0x0)continue;let _0x306fc0=_0x5a35dd[_0x4ef175(0xf4)](0x0,_0x46a7b6)[_0x4ef175(0xc7)](),_0x4a8711=_0x5a35dd[_0x4ef175(0xf4)](_0x46a7b6+0x1)[_0x4ef175(0xc7)]()[_0x4ef175(0x10d)](/^["']|["']$/g,'');if(!process.env[_0x306fc0])process.env[_0x306fc0]=_0x4a8711;}}var L=process.env.HOME||'~',U=a0_0x2d6bf0(L,a0_0x4af176(0xcc));I(a0_0x2d6bf0(U,a0_0x4af176(0x8a)));function a0_0x22f8(){const _0x48e437=['parse','5635828ywbXkv','from_session','SSE\x20fatal:\x20','2025-03-26','SIGINT','18Rlmqhh','application/json','claude-code','new_task','re-registered\x20as\x20\x22','hub','replied','broadcast','\x20from\x20','normal','low','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','type','heartbeat\x20failed:\x20','tools/call',']\x20[commhub]\x20',':\x20inbox_count=','shutting\x20down,\x20reporting\x20offline...','then','(none)','token','get_inbox','startsWith','result','completed','exit','working','now','report_status','error','length','trim','join','Task\x20content','new_message','none','.claude/channels/commhub','\x20/\x20hostname=','77VeLCSO','ready\x20—\x20waiting\x20for\x20events','message_id','offline','session\x20disconnected','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','1362115aoPPwj','warning:\x20could\x20not\x20register:\x20','unknown\x20tool','\x20CWD=','Session\x20alias:\x20','299244fsShCy','MCP\x20stdio\x20connected','utf-8','connect','notification','application/json,\x20text/event-stream','commhub_get_all_status','Reply\x20text\x20/\x20result\x20summary','data:\x20','parse\x20error:\x20','idle','cancelled','catch','Current\x20task\x20description','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','commhub_send_message','19911630mvrUcM','setRequestHandler','in_progress','/events/','cwd','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','priority','SIGTERM','commhub_reply','.anet','slice','ack_inbox','status','params','connected','2.0','read','from','\x20priority=','getReader','notifications/claude/channel','\x20ALIAS=','Bearer\x20','1388087kxqasz','object','0.3.0','SSE\x20connection\x20error:\x20','commhub_report_status','POST','5808576Gmlxvi','message','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','commhub','stderr','alias','replace','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','CommHub\x20init\x20failed:\x20','high','→\x20injected\x20task\x20','indexOf','find','min','tmux\x20display-message\x20-p\x20\x27#S\x27','pid','Priority\x20(default:\x20normal)','commhub-channel','\x20RESUME_ID=','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','toTimeString','failed','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','Target\x20session\x20alias','pop','split','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','unattributed-','blocked','←\x20message\x20from\x20','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','fatal:\x20','.env','text','send_message','string','commhub_send_task','ENV:\x20URL=',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','delete','294zWAlnK','number','get_all_status','config.json','send_reply','\x22\x20(','399KitvtH','content','SSE\x20error:\x20','write','send_task','messages','stringify','SSE\x20stream\x20ended,\x20reconnecting...','body','initialize'];a0_0x22f8=function(){return _0x48e437;};return a0_0x22f8();}var v=process[a0_0x4af176(0xed)]()[a0_0x4af176(0x10d)](/\//g,'-');I(a0_0x2d6bf0(U,v,a0_0x4af176(0x8a)));function d(){const _0x23a65a=a0_0x4af176;try{return a0_0x3b2733(_0x23a65a(0x77),{'encoding':_0x23a65a(0xdb),'timeout':0x7d0})['trim']();}catch{return'';}}function m(){const _0x1eb84e=a0_0x4af176;try{let _0x4dfdc3=a0_0x2d6bf0(L,_0x1eb84e(0xf3),_0x1eb84e(0x95));if(a0_0x503a76(_0x4dfdc3))return JSON['parse'](a0_0x4c6eab(_0x4dfdc3,'utf-8'));}catch{}return{};}var u=m(),j=process.env.COMMHUB_URL||u['hub']||'http://127.0.0.1:9200',f=process.env.COMMHUB_TMUX||d();function r(){const _0x1d555e=a0_0x4af176;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS['trim']())return process.env.COMMHUB_ALIAS[_0x1d555e(0xc7)]();return process[_0x1d555e(0x10b)][_0x1d555e(0x9b)]('[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20'+(_0x1d555e(0x84)+(f||_0x1d555e(0xbb))+_0x1d555e(0xcd)+a0_0xfed9a0()+'.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a')),_0x1d555e(0x85)+process[_0x1d555e(0x78)];}var G=r(),K=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0xa33948(),F=process.env.COMMHUB_TOKEN||u[a0_0x4af176(0xbc)]||'';function W(_0xd99f9b){const _0x4a7a30=a0_0x4af176;let _0xb05abb=new Date()[_0x4a7a30(0x7e)]()[_0x4a7a30(0xf4)](0x0,0x8);process[_0x4a7a30(0x10b)]['write']('['+_0xb05abb+_0x4a7a30(0xb7)+_0xd99f9b+'\x0a');}function N(_0x31de4b){return new Promise(_0x4654bc=>setTimeout(_0x4654bc,_0x31de4b));}W(a0_0x4af176(0x8f)+j+a0_0x4af176(0xff)+G+a0_0x4af176(0x7b)+K[a0_0x4af176(0xf4)](0x0,0x8)+'...\x20TMUX='+(f||a0_0x4af176(0xcb))+a0_0x4af176(0xd7)+process[a0_0x4af176(0xed)]()+'\x20PROJECT_ENV='+v);var D=new Map(),x=new a0_0x48c90d({'name':a0_0x4af176(0x7a),'version':a0_0x4af176(0x103)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x4af176(0xd3),a0_0x4af176(0xe7),a0_0x4af176(0x7c),a0_0x4af176(0x88),a0_0x4af176(0xd8)+G][a0_0x4af176(0xc8)]('\x0a')});x[a0_0x4af176(0xea)](a0_0x51a7e5,async()=>({'tools':[{'name':a0_0x4af176(0xf2),'description':a0_0x4af176(0x7d),'inputSchema':{'type':a0_0x4af176(0x102),'properties':{'task_id':{'type':a0_0x4af176(0x8d),'description':a0_0x4af176(0x109)},'text':{'type':a0_0x4af176(0x8d),'description':a0_0x4af176(0xe0)},'status':{'type':'string','enum':[a0_0x4af176(0xc0),'failed',a0_0x4af176(0xe4),'blocked',a0_0x4af176(0xc5),a0_0x4af176(0xeb)],'description':a0_0x4af176(0x10e)}},'required':[a0_0x4af176(0x8b)]}},{'name':a0_0x4af176(0x105),'description':a0_0x4af176(0x80),'inputSchema':{'type':'object','properties':{'status':{'type':a0_0x4af176(0x8d),'enum':[a0_0x4af176(0xc2),a0_0x4af176(0xe3),'blocked',a0_0x4af176(0xc5)]},'task':{'type':'string','description':a0_0x4af176(0xe6)},'progress':{'type':a0_0x4af176(0x93),'description':'Progress\x200-100'}},'required':[a0_0x4af176(0xf6)]}},{'name':a0_0x4af176(0x8e),'description':a0_0x4af176(0xef),'inputSchema':{'type':a0_0x4af176(0x102),'properties':{'alias':{'type':a0_0x4af176(0x8d),'description':'Target\x20session\x20alias'},'task':{'type':'string','description':a0_0x4af176(0xc9)},'priority':{'type':a0_0x4af176(0x8d),'enum':[a0_0x4af176(0x110),a0_0x4af176(0xb1),a0_0x4af176(0xb2)],'description':a0_0x4af176(0x79)}},'required':['alias','task']}},{'name':a0_0x4af176(0xe8),'description':a0_0x4af176(0xb3),'inputSchema':{'type':'object','properties':{'alias':{'type':'string','description':a0_0x4af176(0x81)},'message':{'type':a0_0x4af176(0x8d),'description':'Message\x20content'}},'required':[a0_0x4af176(0x10c),a0_0x4af176(0x108)]}},{'name':a0_0x4af176(0xdf),'description':'Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','inputSchema':{'type':a0_0x4af176(0x102),'properties':{}}}]}));async function Y(_0x3b01fc,_0x2aacb5){const _0x532a85=a0_0x4af176;let _0x286ce7=await fetch(j+'/mcp',{'method':_0x532a85(0x106),'headers':{'Content-Type':_0x532a85(0xa9),'Accept':_0x532a85(0xde),...F?{'Authorization':'Bearer\x20'+F}:{}},'body':JSON['stringify']({'jsonrpc':_0x532a85(0xf9),'id':0x1,'method':_0x532a85(0xa1),'params':{'protocolVersion':_0x532a85(0xa6),'capabilities':{},'clientInfo':{'name':_0x532a85(0x7a),'version':_0x532a85(0x103)}}})});if(!_0x286ce7['ok']){let _0x46e917=await _0x286ce7[_0x532a85(0x8b)]();return W(_0x532a85(0x10f)+_0x286ce7[_0x532a85(0xf6)]+'\x20'+_0x46e917[_0x532a85(0xf4)](0x0,0x64)),{'ok':!0x1,'error':'init\x20failed:\x20'+_0x286ce7['status']};}await _0x286ce7['text']();let _0x58705b=(await(await fetch(j+'/mcp',{'method':'POST','headers':{'Content-Type':_0x532a85(0xa9),'Accept':'application/json,\x20text/event-stream',...F?{'Authorization':_0x532a85(0x100)+F}:{}},'body':JSON[_0x532a85(0x9e)]({'jsonrpc':_0x532a85(0xf9),'id':0x2,'method':_0x532a85(0xb6),'params':{'name':_0x3b01fc,'arguments':_0x2aacb5}})}))[_0x532a85(0x8b)]())[_0x532a85(0x83)]('\x0a')[_0x532a85(0x113)](_0x6bcdac=>_0x6bcdac[_0x532a85(0xbe)](_0x532a85(0xe1)));if(_0x58705b){let _0x4c6a3a=JSON[_0x532a85(0xa2)](_0x58705b[_0x532a85(0xf4)](0x6));return _0x4c6a3a?.[_0x532a85(0xbf)]?.[_0x532a85(0x99)]?.[0x0]?.[_0x532a85(0x8b)]?JSON['parse'](_0x4c6a3a['result'][_0x532a85(0x99)][0x0][_0x532a85(0x8b)]):_0x4c6a3a;}return{'ok':!0x1,'error':'no\x20response'};}x[a0_0x4af176(0xea)](a0_0x1de7a4,async _0x2ac923=>{const _0x5ee869=a0_0x4af176;let {name:_0x3de94b,arguments:_0x387073}=_0x2ac923[_0x5ee869(0xf7)];if(_0x3de94b===_0x5ee869(0xf2)){let {task_id:_0x4320ef,text:_0x5a162a,status:_0x5c1b28}=_0x387073;if(_0x5c1b28==='completed'||_0x5c1b28===_0x5ee869(0x7f)||_0x5c1b28===_0x5ee869(0xe4)){let _0x1c03de=_0x5c1b28===_0x5ee869(0xc0)?_0x5ee869(0xae):_0x5c1b28,_0x486fb2=_0x4320ef?D['get'](_0x4320ef)||_0x5ee869(0xad):_0x5ee869(0xad),_0x338335=await Y(_0x5ee869(0x96),{'alias':_0x486fb2,'text':_0x5a162a,'in_reply_to':_0x4320ef||void 0x0,'status':_0x1c03de,'from_session':G});if(_0x4320ef)D[_0x5ee869(0x91)](_0x4320ef);return{'content':[{'type':_0x5ee869(0x8b),'text':JSON[_0x5ee869(0x9e)](_0x338335)}]};}let _0x37251a=await Y(_0x5ee869(0xc4),{'resume_id':K,'alias':G,'status':_0x5c1b28===_0x5ee869(0x86)?'blocked':_0x5c1b28==='error'?_0x5ee869(0xc5):_0x5ee869(0xc2),'task':_0x5a162a[_0x5ee869(0xf4)](0x0,0xc8),'output':_0x5a162a});return{'content':[{'type':'text','text':JSON['stringify'](_0x37251a)}]};}if(_0x3de94b===_0x5ee869(0x105)){let {status:_0x256ccd,task:_0x33e6a2,progress:_0x11b6d7}=_0x387073,_0xbf9692=await Y('report_status',{'resume_id':K,'alias':G,'status':_0x256ccd,'task':_0x33e6a2,'progress':_0x11b6d7});return{'content':[{'type':_0x5ee869(0x8b),'text':JSON[_0x5ee869(0x9e)](_0xbf9692)}]};}if(_0x3de94b===_0x5ee869(0x8e)){let {alias:_0x378f0f,task:_0x5aed6f,priority:_0x769f9d}=_0x387073,_0x46a09c=await Y(_0x5ee869(0x9c),{'alias':_0x378f0f,'task':_0x5aed6f,'priority':_0x769f9d||_0x5ee869(0xb1),'from_session':G});return{'content':[{'type':_0x5ee869(0x8b),'text':JSON[_0x5ee869(0x9e)](_0x46a09c)}]};}if(_0x3de94b==='commhub_send_message'){let {alias:_0x1b9789,message:_0x185627}=_0x387073,_0x3cb0c0=await Y(_0x5ee869(0x8c),{'alias':_0x1b9789,'message':_0x185627,'from_session':G});return{'content':[{'type':_0x5ee869(0x8b),'text':JSON[_0x5ee869(0x9e)](_0x3cb0c0)}]};}if(_0x3de94b===_0x5ee869(0xdf)){let _0x477c4c=await Y(_0x5ee869(0x94),{});return{'content':[{'type':_0x5ee869(0x8b),'text':JSON[_0x5ee869(0x9e)](_0x477c4c)}]};}return{'content':[{'type':_0x5ee869(0x8b),'text':JSON[_0x5ee869(0x9e)]({'error':_0x5ee869(0xd6)})}]};});var O=0x3e8,R=0x7530,T=0x36ee80;async function l(){const _0x167234=a0_0x4af176;try{await Y(_0x167234(0xc4),{'resume_id':K,'alias':G,'status':_0x167234(0xe3),'server':a0_0xfed9a0(),'hostname':a0_0xfed9a0(),'agent':'claude-code','project_dir':process[_0x167234(0xed)](),'tmux_name':f||void 0x0}),W(_0x167234(0xac)+G+'\x22\x20after\x20SSE\x20reconnect');}catch(_0x1b1e01){W('re-register\x20failed:\x20'+_0x1b1e01);}}async function o(){const _0x32c244=a0_0x4af176;let _0x1224ac=j+_0x32c244(0xec)+encodeURIComponent(G),_0x45fecd={};if(F)_0x45fecd['Authorization']=_0x32c244(0x100)+F;W('connecting\x20to\x20'+_0x1224ac);let _0x3adfda=O,_0x337a20=!0x0,_0x127c57=null;while(!0x0){try{let _0x36f2fd=await fetch(_0x1224ac,{'headers':_0x45fecd});if(!_0x36f2fd['ok']){if(W(_0x32c244(0x9a)+_0x36f2fd['status']+'\x20'+_0x36f2fd['statusText']),_0x127c57=_0x127c57??Date['now'](),Date[_0x32c244(0xc3)]()-_0x127c57>T){W(_0x32c244(0xee)+j+_0x32c244(0x90));return;}await N(_0x3adfda),_0x3adfda=Math[_0x32c244(0x114)](_0x3adfda*0x2,R);continue;}let _0x3df1c2=_0x36f2fd[_0x32c244(0xa0)][_0x32c244(0xfd)](),_0x2485d4=new TextDecoder(),_0x41ee6e='';_0x3adfda=O;while(!0x0){let {done:_0x591d98,value:_0x115fd2}=await _0x3df1c2[_0x32c244(0xfa)]();if(_0x591d98)break;_0x41ee6e+=_0x2485d4['decode'](_0x115fd2,{'stream':!0x0});let _0x218fd9=_0x41ee6e[_0x32c244(0x83)]('\x0a\x0a');_0x41ee6e=_0x218fd9[_0x32c244(0x82)]()||'';for(let _0x207717 of _0x218fd9){let _0x4c603f=_0x207717[_0x32c244(0x83)]('\x0a')['find'](_0x3f8a9b=>_0x3f8a9b[_0x32c244(0xbe)](_0x32c244(0xe1)));if(!_0x4c603f)continue;try{let _0x306acb=JSON[_0x32c244(0xa2)](_0x4c603f['slice'](0x6));if(await a(_0x306acb),_0x306acb['type']===_0x32c244(0xf8)){if(_0x127c57=null,!_0x337a20)await l();_0x337a20=!0x1;}}catch(_0x2988d2){W(_0x32c244(0xe2)+_0x2988d2);}}}W(_0x32c244(0x9f));}catch(_0xc2db2a){W(_0x32c244(0x104)+_0xc2db2a);}if(_0x127c57=_0x127c57??Date['now'](),Date[_0x32c244(0xc3)]()-_0x127c57>T){W(_0x32c244(0xee)+j+_0x32c244(0x90));return;}await N(_0x3adfda),_0x3adfda=Math[_0x32c244(0x114)](_0x3adfda*0x2,R);}}async function a(_0x45ae6e){const _0x488c48=a0_0x4af176;if(_0x45ae6e[_0x488c48(0xb4)]===_0x488c48(0xf8)){W('SSE\x20connected\x20as\x20\x22'+G+'\x22');return;}if(_0x45ae6e[_0x488c48(0xb4)]===_0x488c48(0xca)){if(W(_0x488c48(0x87)+_0x45ae6e[_0x488c48(0xfb)]+':\x20'+_0x45ae6e[_0x488c48(0x108)][_0x488c48(0xf4)](0x0,0x3c)),await x[_0x488c48(0xdd)]({'method':'notifications/claude/channel','params':{'content':_0x45ae6e['message'],'meta':{'sender':_0x45ae6e[_0x488c48(0xfb)]||'hub','sender_id':_0x488c48(0x10a),'user':_0x45ae6e['from']||'hub','priority':_0x488c48(0xb1)}}}),_0x45ae6e[_0x488c48(0xd0)])await Y(_0x488c48(0xf5),{'alias':G,'message_id':_0x45ae6e['message_id']});return;}if(_0x45ae6e[_0x488c48(0xb4)]===_0x488c48(0xab)||_0x45ae6e[_0x488c48(0xb4)]===_0x488c48(0xaf)){W('←\x20'+_0x45ae6e[_0x488c48(0xb4)]+_0x488c48(0xb8)+_0x45ae6e['inbox_count']+_0x488c48(0xfc)+(_0x45ae6e['priority']||'normal'));let _0x2b77ea=await Y(_0x488c48(0xbd),{'alias':G,'limit':0x5});if(_0x2b77ea?.['ok']&&_0x2b77ea[_0x488c48(0x9d)]?.[_0x488c48(0xc6)]>0x0)for(let _0x429689 of _0x2b77ea[_0x488c48(0x9d)]){let _0x2ab5d5={'sender':_0x429689['from_session']||_0x488c48(0xad),'sender_id':_0x488c48(0x10a),'user':_0x429689[_0x488c48(0xa4)]||_0x488c48(0xad),'task_id':_0x429689['id'],'priority':_0x429689[_0x488c48(0xf0)]||'normal'};D['set'](_0x429689['id'],_0x429689[_0x488c48(0xa4)]||'hub'),await x[_0x488c48(0xdd)]({'method':_0x488c48(0xfe),'params':{'content':_0x429689['content'],'meta':_0x2ab5d5}}),W(_0x488c48(0x111)+_0x429689['id'][_0x488c48(0xf4)](0x0,0x8)+_0x488c48(0xb0)+_0x429689[_0x488c48(0xa4)]+':\x20'+_0x429689['content'][_0x488c48(0xf4)](0x0,0x3c)),await Y(_0x488c48(0xf5),{'alias':G,'message_id':_0x429689['id']});}}}async function n(){const _0x2da011=a0_0x4af176;let _0x302113=new a0_0xfdc6e8();await x[_0x2da011(0xdc)](_0x302113),W(_0x2da011(0xda)),W('starting\x20SSE\x20listener...'),o()['catch'](_0x5b8a5f=>W(_0x2da011(0xa5)+_0x5b8a5f)),Y(_0x2da011(0xc4),{'resume_id':K,'alias':G,'status':_0x2da011(0xe3),'server':a0_0xfed9a0(),'hostname':a0_0xfed9a0(),'agent':_0x2da011(0xaa),'project_dir':process[_0x2da011(0xed)](),'tmux_name':f||void 0x0})[_0x2da011(0xba)](()=>W('registered\x20as\x20\x22'+G+_0x2da011(0x97)+K[_0x2da011(0xf4)](0x0,0x8)+')'))[_0x2da011(0xe5)](_0x1b7260=>W(_0x2da011(0xd5)+_0x1b7260)),setInterval(()=>{const _0x2066ca=_0x2da011;Y(_0x2066ca(0xc4),{'resume_id':K,'alias':G,'status':_0x2066ca(0xe3),'server':a0_0xfed9a0(),'hostname':a0_0xfed9a0(),'agent':_0x2066ca(0xaa),'project_dir':process['cwd'](),'tmux_name':f||void 0x0})[_0x2066ca(0xe5)](_0xc0d8a=>W(_0x2066ca(0xb5)+_0xc0d8a));},0x2bf20),W(_0x2da011(0xcf));}n()[a0_0x4af176(0xe5)](_0x355a17=>{const _0x2d7fe7=a0_0x4af176;W(_0x2d7fe7(0x89)+_0x355a17),process[_0x2d7fe7(0xc1)](0x1);});async function b(){const _0x2dfcc9=a0_0x4af176;W(_0x2dfcc9(0xb9)),await Y(_0x2dfcc9(0xc4),{'resume_id':K,'alias':G,'status':_0x2dfcc9(0xd1),'task':_0x2dfcc9(0xd2)})[_0x2dfcc9(0xe5)](()=>{}),process['exit'](0x0);}process['stdin']['on']('end',()=>b()),process['on'](a0_0x4af176(0xf1),()=>b()),process['on'](a0_0x4af176(0xa7),()=>b());
|
|
2
|
+
const a0_0x207c84=a0_0x34e2;(function(_0x1eaeb3,_0x121379){const _0x3fdf4a=a0_0x34e2,_0x45a2be=_0x1eaeb3();while(!![]){try{const _0x5e8586=parseInt(_0x3fdf4a(0xf8))/0x1*(parseInt(_0x3fdf4a(0xf6))/0x2)+-parseInt(_0x3fdf4a(0x113))/0x3+parseInt(_0x3fdf4a(0xcc))/0x4+-parseInt(_0x3fdf4a(0xc7))/0x5+-parseInt(_0x3fdf4a(0x14a))/0x6*(-parseInt(_0x3fdf4a(0x12f))/0x7)+-parseInt(_0x3fdf4a(0x11e))/0x8+-parseInt(_0x3fdf4a(0x143))/0x9*(parseInt(_0x3fdf4a(0xe5))/0xa);if(_0x5e8586===_0x121379)break;else _0x45a2be['push'](_0x45a2be['shift']());}catch(_0x836805){_0x45a2be['push'](_0x45a2be['shift']());}}}(a0_0x5a90,0x84dd7));import{readFileSync as a0_0x50d4f9,existsSync as a0_0x4387f7}from'fs';import{randomUUID as a0_0x41f2b3}from'crypto';import{join as a0_0x4f7719}from'path';import{hostname as a0_0x301448}from'os';import{execSync as a0_0x25c7b0}from'child_process';import{Server as a0_0x536752}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x5e5224}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x42b977,CallToolRequestSchema as a0_0x49ff91}from'@modelcontextprotocol/sdk/types.js';function I(_0x147f88){const _0x1e5a06=a0_0x34e2;if(!a0_0x4387f7(_0x147f88))return;for(let _0x2d7cfa of a0_0x50d4f9(_0x147f88,'utf-8')[_0x1e5a06(0xda)]('\x0a')){let _0x73ffad=_0x2d7cfa[_0x1e5a06(0x14b)]();if(!_0x73ffad||_0x73ffad['startsWith']('#'))continue;let _0x29b1b8=_0x73ffad['indexOf']('=');if(_0x29b1b8<0x0)continue;let _0x95a6b3=_0x73ffad['slice'](0x0,_0x29b1b8)[_0x1e5a06(0x14b)](),_0x4a69aa=_0x73ffad[_0x1e5a06(0xec)](_0x29b1b8+0x1)['trim']()[_0x1e5a06(0xfe)](/^["']|["']$/g,'');if(!process.env[_0x95a6b3])process.env[_0x95a6b3]=_0x4a69aa;}}var L=process.env.HOME||'~',U=a0_0x4f7719(L,a0_0x207c84(0xe6));I(a0_0x4f7719(U,a0_0x207c84(0xbf)));var v=process['cwd']()['replace'](/\//g,'-');I(a0_0x4f7719(U,v,a0_0x207c84(0xbf)));function d(){const _0x39c9ac=a0_0x207c84;try{return a0_0x25c7b0(_0x39c9ac(0x132),{'encoding':_0x39c9ac(0x144),'timeout':0x7d0})['trim']();}catch{return'';}}function m(){const _0x2e45de=a0_0x207c84;try{let _0xe81e5a=a0_0x4f7719(L,_0x2e45de(0x138),_0x2e45de(0xd1));if(a0_0x4387f7(_0xe81e5a))return JSON[_0x2e45de(0xfc)](a0_0x50d4f9(_0xe81e5a,_0x2e45de(0x144)));}catch{}return{};}var u=m(),j=process.env.COMMHUB_URL||u['hub']||a0_0x207c84(0x10b),f=process.env.COMMHUB_TMUX||d();function r(){const _0x2ee023=a0_0x207c84;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x2ee023(0x14b)]())return process.env.COMMHUB_ALIAS['trim']();return process[_0x2ee023(0xf3)][_0x2ee023(0xff)](_0x2ee023(0x13c)+(_0x2ee023(0xef)+(f||'(none)')+_0x2ee023(0x147)+a0_0x301448()+'.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a')),_0x2ee023(0x103)+process[_0x2ee023(0xe2)];}var G=r(),K=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x41f2b3(),F=process.env.COMMHUB_TOKEN||u['token']||'';function W(_0x17abcc){const _0x296dff=a0_0x207c84;let _0x303155=new Date()[_0x296dff(0xc6)]()[_0x296dff(0xec)](0x0,0x8);process['stderr'][_0x296dff(0xff)]('['+_0x303155+_0x296dff(0xe9)+_0x17abcc+'\x0a');}function N(_0x35a33f){return new Promise(_0x463c45=>setTimeout(_0x463c45,_0x35a33f));}function a0_0x5a90(){const _0x38dcc3=['pid','offline','session\x20disconnected','10ciiekR','.claude/channels/commhub','low','Target\x20session\x20alias',']\x20[commhub]\x20','alias','getReader','slice','failed','MCP\x20stdio\x20connected','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','min','get','then','stderr','exit','2025-03-26','2KcrWEE','ack_inbox','719059PVhfQN','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','task','commhub_send_task','parse','end','replace','write','shutting\x20down,\x20reporting\x20offline...','working','broadcast','unattributed-','\x20CWD=','send_reply','connected','data:\x20','initialize','content','commhub_report_status','http://127.0.0.1:9200','commhub_send_message','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','Message\x20content','no\x20response','Task\x20content','Current\x20task\x20description','cancelled','268962PGFOvc','read','object','/events/','CommHub\x20init\x20failed:\x20','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','Bearer\x20','pop','unknown\x20tool','\x22\x20after\x20SSE\x20reconnect','1534976zrrtLT','stdin','startsWith','normal','notification','hub','string','priority','params','ENV:\x20URL=','SSE\x20error:\x20','in_progress','stringify','cwd','Authorization','Progress\x200-100','message','3892fwgYqt','blocked','SSE\x20stream\x20ended,\x20reconnecting...','tmux\x20display-message\x20-p\x20\x27#S\x27','0.3.0','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','body',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','ready\x20—\x20waiting\x20for\x20events','.anet','application/json,\x20text/event-stream','report_status','commhub_reply','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20','send_message','←\x20message\x20from\x20','init\x20failed:\x20','completed','send_task','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','14640228kJtdtA','utf-8','claude-code','from','\x20/\x20hostname=','join','messages','10254uwNDfp','trim','SIGINT','\x20ALIAS=','find','\x20from\x20','setRequestHandler','now','get_all_status','re-register\x20failed:\x20','parse\x20error:\x20','warning:\x20could\x20not\x20register:\x20','commhub_get_all_status','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','POST','/mcp','length','from_session','.env','application/json','none','new_message','→\x20injected\x20task\x20','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','\x20RESUME_ID=','toTimeString','296340yPoQAJ','type','commhub-channel','SSE\x20fatal:\x20','registered\x20as\x20\x22','3369752TmDeks','connecting\x20to\x20','Priority\x20(default:\x20normal)','number','connect','config.json','SSE\x20connected\x20as\x20\x22','text','\x20PROJECT_ENV=','replied','catch','error','message_id','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','split','heartbeat\x20failed:\x20','tools/call','idle','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','SIGTERM','status','2.0'];a0_0x5a90=function(){return _0x38dcc3;};return a0_0x5a90();}W(a0_0x207c84(0x127)+j+a0_0x207c84(0x14d)+G+a0_0x207c84(0xc5)+K['slice'](0x0,0x8)+'...\x20TMUX='+(f||a0_0x207c84(0xc1))+a0_0x207c84(0x104)+process[a0_0x207c84(0x12b)]()+a0_0x207c84(0xd4)+v);var D=new Map(),x=new a0_0x536752({'name':a0_0x207c84(0xc9),'version':a0_0x207c84(0x133)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x207c84(0x142),a0_0x207c84(0xd9),a0_0x207c84(0xc4),a0_0x207c84(0xde),'Session\x20alias:\x20'+G][a0_0x207c84(0x148)]('\x0a')});x[a0_0x207c84(0xb3)](a0_0x42b977,async()=>({'tools':[{'name':a0_0x207c84(0x13b),'description':a0_0x207c84(0x134),'inputSchema':{'type':a0_0x207c84(0x115),'properties':{'task_id':{'type':a0_0x207c84(0x124),'description':a0_0x207c84(0xba)},'text':{'type':'string','description':'Reply\x20text\x20/\x20result\x20summary'},'status':{'type':a0_0x207c84(0x124),'enum':[a0_0x207c84(0x140),'failed',a0_0x207c84(0x112),a0_0x207c84(0x130),a0_0x207c84(0xd7),a0_0x207c84(0x129)],'description':a0_0x207c84(0xf9)}},'required':['text']}},{'name':a0_0x207c84(0x10a),'description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':a0_0x207c84(0x115),'properties':{'status':{'type':a0_0x207c84(0x124),'enum':[a0_0x207c84(0x101),a0_0x207c84(0xdd),a0_0x207c84(0x130),'error']},'task':{'type':'string','description':a0_0x207c84(0x111)},'progress':{'type':a0_0x207c84(0xcf),'description':a0_0x207c84(0x12d)}},'required':[a0_0x207c84(0xe0)]}},{'name':a0_0x207c84(0xfb),'description':a0_0x207c84(0x10d),'inputSchema':{'type':a0_0x207c84(0x115),'properties':{'alias':{'type':a0_0x207c84(0x124),'description':'Target\x20session\x20alias'},'task':{'type':'string','description':a0_0x207c84(0x110)},'priority':{'type':a0_0x207c84(0x124),'enum':['high','normal',a0_0x207c84(0xe7)],'description':a0_0x207c84(0xce)}},'required':[a0_0x207c84(0xea),a0_0x207c84(0xfa)]}},{'name':a0_0x207c84(0x10c),'description':a0_0x207c84(0x119),'inputSchema':{'type':'object','properties':{'alias':{'type':a0_0x207c84(0x124),'description':a0_0x207c84(0xe8)},'message':{'type':a0_0x207c84(0x124),'description':a0_0x207c84(0x10e)}},'required':[a0_0x207c84(0xea),a0_0x207c84(0x12e)]}},{'name':a0_0x207c84(0xb9),'description':'Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','inputSchema':{'type':a0_0x207c84(0x115),'properties':{}}}]}));async function Y(_0x2f39ea,_0x4505f2){const _0x524f40=a0_0x207c84;let _0x5ee99e=await fetch(j+_0x524f40(0xbc),{'method':_0x524f40(0xbb),'headers':{'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream',...F?{'Authorization':_0x524f40(0x11a)+F}:{}},'body':JSON[_0x524f40(0x12a)]({'jsonrpc':_0x524f40(0xe1),'id':0x1,'method':_0x524f40(0x108),'params':{'protocolVersion':_0x524f40(0xf5),'capabilities':{},'clientInfo':{'name':_0x524f40(0xc9),'version':_0x524f40(0x133)}}})});if(!_0x5ee99e['ok']){let _0x59dea7=await _0x5ee99e['text']();return W(_0x524f40(0x117)+_0x5ee99e['status']+'\x20'+_0x59dea7['slice'](0x0,0x64)),{'ok':!0x1,'error':_0x524f40(0x13f)+_0x5ee99e[_0x524f40(0xe0)]};}await _0x5ee99e[_0x524f40(0xd3)]();let _0xee90e4=(await(await fetch(j+_0x524f40(0xbc),{'method':_0x524f40(0xbb),'headers':{'Content-Type':_0x524f40(0xc0),'Accept':_0x524f40(0x139),...F?{'Authorization':_0x524f40(0x11a)+F}:{}},'body':JSON['stringify']({'jsonrpc':_0x524f40(0xe1),'id':0x2,'method':_0x524f40(0xdc),'params':{'name':_0x2f39ea,'arguments':_0x4505f2}})}))[_0x524f40(0xd3)]())['split']('\x0a')['find'](_0x9a49b7=>_0x9a49b7['startsWith'](_0x524f40(0x107)));if(_0xee90e4){let _0x405604=JSON[_0x524f40(0xfc)](_0xee90e4[_0x524f40(0xec)](0x6));return _0x405604?.['result']?.['content']?.[0x0]?.[_0x524f40(0xd3)]?JSON[_0x524f40(0xfc)](_0x405604['result'][_0x524f40(0x109)][0x0]['text']):_0x405604;}return{'ok':!0x1,'error':_0x524f40(0x10f)};}x[a0_0x207c84(0xb3)](a0_0x49ff91,async _0x36a00e=>{const _0x767b65=a0_0x207c84;let {name:_0x33b73f,arguments:_0x592afc}=_0x36a00e[_0x767b65(0x126)];if(_0x33b73f===_0x767b65(0x13b)){let {task_id:_0x65197e,text:_0xa4abd8,status:_0x33f88a}=_0x592afc;if(_0x33f88a===_0x767b65(0x140)||_0x33f88a===_0x767b65(0xed)||_0x33f88a===_0x767b65(0x112)){let _0x3e0830=_0x33f88a===_0x767b65(0x140)?_0x767b65(0xd5):_0x33f88a,_0x2e8170=_0x65197e?D[_0x767b65(0xf1)](_0x65197e)||_0x767b65(0x123):_0x767b65(0x123),_0xf66f99=await Y(_0x767b65(0x105),{'alias':_0x2e8170,'text':_0xa4abd8,'in_reply_to':_0x65197e||void 0x0,'status':_0x3e0830,'from_session':G});if(_0x65197e)D['delete'](_0x65197e);return{'content':[{'type':_0x767b65(0xd3),'text':JSON[_0x767b65(0x12a)](_0xf66f99)}]};}let _0x1132f4=await Y('report_status',{'resume_id':K,'alias':G,'status':_0x33f88a==='blocked'?'blocked':_0x33f88a===_0x767b65(0xd7)?'error':_0x767b65(0x101),'task':_0xa4abd8[_0x767b65(0xec)](0x0,0xc8),'output':_0xa4abd8});return{'content':[{'type':_0x767b65(0xd3),'text':JSON[_0x767b65(0x12a)](_0x1132f4)}]};}if(_0x33b73f===_0x767b65(0x10a)){let {status:_0x4ee255,task:_0x3b1149,progress:_0x53d870}=_0x592afc,_0x164ff8=await Y(_0x767b65(0x13a),{'resume_id':K,'alias':G,'status':_0x4ee255,'task':_0x3b1149,'progress':_0x53d870});return{'content':[{'type':_0x767b65(0xd3),'text':JSON[_0x767b65(0x12a)](_0x164ff8)}]};}if(_0x33b73f===_0x767b65(0xfb)){let {alias:_0xb9df3d,task:_0x4b9988,priority:_0x37584f}=_0x592afc,_0x24f111=await Y(_0x767b65(0x141),{'alias':_0xb9df3d,'task':_0x4b9988,'priority':_0x37584f||_0x767b65(0x121),'from_session':G});return{'content':[{'type':'text','text':JSON[_0x767b65(0x12a)](_0x24f111)}]};}if(_0x33b73f===_0x767b65(0x10c)){let {alias:_0x2f14b9,message:_0x35ebb7}=_0x592afc,_0x28a828=await Y(_0x767b65(0x13d),{'alias':_0x2f14b9,'message':_0x35ebb7,'from_session':G});return{'content':[{'type':_0x767b65(0xd3),'text':JSON['stringify'](_0x28a828)}]};}if(_0x33b73f===_0x767b65(0xb9)){let _0x33d709=await Y(_0x767b65(0xb5),{});return{'content':[{'type':_0x767b65(0xd3),'text':JSON[_0x767b65(0x12a)](_0x33d709)}]};}return{'content':[{'type':_0x767b65(0xd3),'text':JSON[_0x767b65(0x12a)]({'error':_0x767b65(0x11c)})}]};});var O=0x3e8,R=0x7530,T=0x36ee80;async function l(){const _0x33054b=a0_0x207c84;try{await Y(_0x33054b(0x13a),{'resume_id':K,'alias':G,'status':_0x33054b(0xdd),'server':a0_0x301448(),'hostname':a0_0x301448(),'agent':_0x33054b(0x145),'project_dir':process[_0x33054b(0x12b)](),'tmux_name':f||void 0x0}),W('re-registered\x20as\x20\x22'+G+_0x33054b(0x11d));}catch(_0x4fbf7c){W(_0x33054b(0xb6)+_0x4fbf7c);}}async function o(){const _0x2dbdc5=a0_0x207c84;let _0x3a8980=j+_0x2dbdc5(0x116)+encodeURIComponent(G),_0x3d5b57={};if(F)_0x3d5b57[_0x2dbdc5(0x12c)]='Bearer\x20'+F;W(_0x2dbdc5(0xcd)+_0x3a8980);let _0x30c71b=O,_0x5921d5=!0x0,_0x470ab2=null;while(!0x0){try{let _0x501fdf=await fetch(_0x3a8980,{'headers':_0x3d5b57});if(!_0x501fdf['ok']){if(W(_0x2dbdc5(0x128)+_0x501fdf['status']+'\x20'+_0x501fdf['statusText']),_0x470ab2=_0x470ab2??Date['now'](),Date[_0x2dbdc5(0xb4)]()-_0x470ab2>T){W('SSE\x20连续\x20>1h\x20连不上\x20hub\x20('+j+_0x2dbdc5(0x136));return;}await N(_0x30c71b),_0x30c71b=Math[_0x2dbdc5(0xf0)](_0x30c71b*0x2,R);continue;}let _0x532b03=_0x501fdf[_0x2dbdc5(0x135)][_0x2dbdc5(0xeb)](),_0x13e7ae=new TextDecoder(),_0x1e9093='';_0x30c71b=O;while(!0x0){let {done:_0x371a51,value:_0x19dba9}=await _0x532b03[_0x2dbdc5(0x114)]();if(_0x371a51)break;_0x1e9093+=_0x13e7ae['decode'](_0x19dba9,{'stream':!0x0});let _0x533305=_0x1e9093[_0x2dbdc5(0xda)]('\x0a\x0a');_0x1e9093=_0x533305[_0x2dbdc5(0x11b)]()||'';for(let _0x49a336 of _0x533305){let _0x42c6cb=_0x49a336[_0x2dbdc5(0xda)]('\x0a')[_0x2dbdc5(0x14e)](_0x478061=>_0x478061[_0x2dbdc5(0x120)](_0x2dbdc5(0x107)));if(!_0x42c6cb)continue;try{let _0x5d2097=JSON[_0x2dbdc5(0xfc)](_0x42c6cb[_0x2dbdc5(0xec)](0x6));if(await a(_0x5d2097),_0x5d2097[_0x2dbdc5(0xc8)]===_0x2dbdc5(0x106)){if(_0x470ab2=null,!_0x5921d5)await l();_0x5921d5=!0x1;}}catch(_0x36b764){W(_0x2dbdc5(0xb7)+_0x36b764);}}}W(_0x2dbdc5(0x131));}catch(_0x519dcd){W('SSE\x20connection\x20error:\x20'+_0x519dcd);}if(_0x470ab2=_0x470ab2??Date[_0x2dbdc5(0xb4)](),Date[_0x2dbdc5(0xb4)]()-_0x470ab2>T){W(_0x2dbdc5(0x118)+j+_0x2dbdc5(0x136));return;}await N(_0x30c71b),_0x30c71b=Math[_0x2dbdc5(0xf0)](_0x30c71b*0x2,R);}}async function a(_0xe52f5f){const _0x1d545f=a0_0x207c84;if(_0xe52f5f['type']===_0x1d545f(0x106)){W(_0x1d545f(0xd2)+G+'\x22');return;}if(_0xe52f5f[_0x1d545f(0xc8)]===_0x1d545f(0xc2)){if(W(_0x1d545f(0x13e)+_0xe52f5f[_0x1d545f(0x146)]+':\x20'+_0xe52f5f[_0x1d545f(0x12e)][_0x1d545f(0xec)](0x0,0x3c)),await x[_0x1d545f(0x122)]({'method':'notifications/claude/channel','params':{'content':_0xe52f5f[_0x1d545f(0x12e)],'meta':{'sender':_0xe52f5f[_0x1d545f(0x146)]||_0x1d545f(0x123),'sender_id':'commhub','user':_0xe52f5f[_0x1d545f(0x146)]||_0x1d545f(0x123),'priority':_0x1d545f(0x121)}}}),_0xe52f5f[_0x1d545f(0xd8)])await Y('ack_inbox',{'alias':G,'message_id':_0xe52f5f['message_id']});return;}if(_0xe52f5f[_0x1d545f(0xc8)]==='new_task'||_0xe52f5f[_0x1d545f(0xc8)]===_0x1d545f(0x102)){W('←\x20'+_0xe52f5f[_0x1d545f(0xc8)]+':\x20inbox_count='+_0xe52f5f['inbox_count']+'\x20priority='+(_0xe52f5f[_0x1d545f(0x125)]||'normal'));let _0x55528b=await Y('get_inbox',{'alias':G,'limit':0x5});if(_0x55528b?.['ok']&&_0x55528b[_0x1d545f(0x149)]?.[_0x1d545f(0xbd)]>0x0)for(let _0x224e35 of _0x55528b['messages']){let _0x3b70a2={'sender':_0x224e35[_0x1d545f(0xbe)]||_0x1d545f(0x123),'sender_id':'commhub','user':_0x224e35[_0x1d545f(0xbe)]||'hub','task_id':_0x224e35['id'],'priority':_0x224e35[_0x1d545f(0x125)]||_0x1d545f(0x121)};D['set'](_0x224e35['id'],_0x224e35[_0x1d545f(0xbe)]||_0x1d545f(0x123)),await x['notification']({'method':'notifications/claude/channel','params':{'content':_0x224e35['content'],'meta':_0x3b70a2}}),W(_0x1d545f(0xc3)+_0x224e35['id'][_0x1d545f(0xec)](0x0,0x8)+_0x1d545f(0xb2)+_0x224e35[_0x1d545f(0xbe)]+':\x20'+_0x224e35[_0x1d545f(0x109)]['slice'](0x0,0x3c)),await Y(_0x1d545f(0xf7),{'alias':G,'message_id':_0x224e35['id']});}}}async function n(){const _0x4a7542=a0_0x207c84;let _0x57fe6b=new a0_0x5e5224();await x[_0x4a7542(0xd0)](_0x57fe6b),W(_0x4a7542(0xee)),W('starting\x20SSE\x20listener...'),o()[_0x4a7542(0xd6)](_0x471c8f=>W(_0x4a7542(0xca)+_0x471c8f)),Y('report_status',{'resume_id':K,'alias':G,'status':'idle','server':a0_0x301448(),'hostname':a0_0x301448(),'agent':_0x4a7542(0x145),'project_dir':process['cwd'](),'tmux_name':f||void 0x0})[_0x4a7542(0xf2)](()=>W(_0x4a7542(0xcb)+G+'\x22\x20('+K[_0x4a7542(0xec)](0x0,0x8)+')'))[_0x4a7542(0xd6)](_0x43bc32=>W(_0x4a7542(0xb8)+_0x43bc32)),setInterval(()=>{const _0x27112b=_0x4a7542;Y(_0x27112b(0x13a),{'resume_id':K,'alias':G,'status':'idle','server':a0_0x301448(),'hostname':a0_0x301448(),'agent':_0x27112b(0x145),'project_dir':process[_0x27112b(0x12b)](),'tmux_name':f||void 0x0})[_0x27112b(0xd6)](_0x45390b=>W(_0x27112b(0xdb)+_0x45390b));},0x2bf20),W(_0x4a7542(0x137));}n()['catch'](_0xe4a1a6=>{const _0x877923=a0_0x207c84;W('fatal:\x20'+_0xe4a1a6),process[_0x877923(0xf4)](0x1);});async function b(){const _0x310a97=a0_0x207c84;W(_0x310a97(0x100)),await Y(_0x310a97(0x13a),{'resume_id':K,'alias':G,'status':_0x310a97(0xe3),'task':_0x310a97(0xe4)})[_0x310a97(0xd6)](()=>{}),process[_0x310a97(0xf4)](0x0);}function a0_0x34e2(_0x2ce9d1,_0x3b8cb4){_0x2ce9d1=_0x2ce9d1-0xb2;const _0x5a9042=a0_0x5a90();let _0x34e2e3=_0x5a9042[_0x2ce9d1];return _0x34e2e3;}process[a0_0x207c84(0x11f)]['on'](a0_0x207c84(0xfd),()=>b()),process['on'](a0_0x207c84(0xdf),()=>b()),process['on'](a0_0x207c84(0x14c),()=>b());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleep2agi/agent-network",
|
|
3
|
-
"version": "2.3.0-preview.
|
|
3
|
+
"version": "2.3.0-preview.17",
|
|
4
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",
|