@sleep2agi/agent-network 2.3.0-preview.131 → 2.3.0-preview.133
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 +2 -2
- package/dist/src/cli-errors.d.ts +39 -0
- package/dist/src/cli-help.d.ts +10 -0
- package/dist/src/client.js +1 -1
- package/dist/src/node-delete-hub.d.ts +42 -0
- package/dist/src/node-server.js +7 -7
- package/dist/src/opencode-agent-node-pair.d.ts +6 -6
- package/dist/src/secret-shell-guidance.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 把一个密钥变成 `<前缀>…<末 4 位>`。
|
|
3
|
+
* utok_abcdef…(40 字符)…wxyz → utok_…wxyz
|
|
4
|
+
* 太短(去掉前缀后不足 12 个字符)时连末 4 位也不给:短密钥露 4 位等于露了一大半。
|
|
5
|
+
*/
|
|
6
|
+
export declare function maskSecret(value: unknown): string;
|
|
7
|
+
/** 把任意文本里看得出的密钥都换成掩码。用在一切「把别处来的字符串打出来」的地方。 */
|
|
8
|
+
export declare function redactSecrets(text: string): string;
|
|
9
|
+
/** 深拷贝一个对象,键名像密钥的字符串值换成掩码,其余字符串值走 redactSecrets。 */
|
|
10
|
+
export declare function redactSecretFields<T>(value: T): T;
|
|
11
|
+
/** 任意「错误」值 → 一句可读文本。对象取 message / error.message / code,实在没有就 JSON。 */
|
|
12
|
+
export declare function errorText(x: unknown): string;
|
|
13
|
+
/**
|
|
14
|
+
* Hub 的失败响应体 → 一句话。hub 的 REST 路由回 `{ ok:false, error:"<字符串>" }`,
|
|
15
|
+
* 但 500 兜底(server/src/serve-error.ts)回 `{ error:{ code, message }, message }` ——
|
|
16
|
+
* 直接 `${res.error}` 就是 `[object Object]`。
|
|
17
|
+
*/
|
|
18
|
+
export declare function hubErrorText(res: unknown): string;
|
|
19
|
+
export interface CliErrorReport {
|
|
20
|
+
/** 第一行:出了什么事。 */
|
|
21
|
+
summary: string;
|
|
22
|
+
/** 下一步该敲的命令(每条一行)。 */
|
|
23
|
+
next: string[];
|
|
24
|
+
/** 为日志解析保留的 `FATAL: Error: CODE` 形状(只在消息本身是错误码时)。 */
|
|
25
|
+
fatalCode?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function isDebugEnabled(env?: Record<string, string | undefined>): boolean;
|
|
28
|
+
export declare function isNetworkError(err: any): boolean;
|
|
29
|
+
export declare function describeCliError(err: any, ctx?: {
|
|
30
|
+
hub?: string;
|
|
31
|
+
configPath?: string;
|
|
32
|
+
}): CliErrorReport;
|
|
33
|
+
/** 顶层 catch 用:产出要打到 stderr 的全部行(已脱敏)。stack 只在 ANET_DEBUG=1 时附上。 */
|
|
34
|
+
export declare function formatTopLevelError(err: any, opts?: {
|
|
35
|
+
hub?: string;
|
|
36
|
+
env?: Record<string, string | undefined>;
|
|
37
|
+
}): string[];
|
|
38
|
+
/** 「连 hub 失败」的原因,一句短语。用在已经写了 `Cannot reach <hub>:` 的地方。 */
|
|
39
|
+
export declare function hubReachReason(err: any): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const NODE_DELETE_USAGE = "Usage: anet node delete <node-id|node-name> [--force]\n anet node delete <node_id> --hub-only [--hub <url>]\n\nStop the node, delete its local config (.anet/nodes/<id>/), then remove its\nrow on the Hub so it no longer shows as offline.\n\n --force Required to actually delete (without it, prints what would go)\n --hub-only Only remove the Hub row (the retry command printed when the Hub\n could not be reached); takes the node_id from that warning\n --hub <url> Hub to use with --hub-only (default: your login's Hub)\n\nThe Hub row is matched by node_id only \u2014 never by name \u2014 so a node elsewhere\nthat reuses the same name is left untouched.\nIf the Hub is unreachable or refuses, the local files are still deleted, a\nwarning prints the exact retry command, and the exit code is 1.";
|
|
2
|
+
/** path (space-joined) → usage text. `{cmd}` is replaced by the word the user typed (hub/server). */
|
|
3
|
+
export declare const COMMAND_HELP: Record<string, string>;
|
|
4
|
+
/**
|
|
5
|
+
* The most specific help entry for argv (e.g. ["node","delete","x","--help"]).
|
|
6
|
+
* Only the leading positional words are the command path; the longest prefix
|
|
7
|
+
* with an entry wins. `minDepth` lets the caller skip bare group entries when a
|
|
8
|
+
* richer group printer exists in bin/cli.ts.
|
|
9
|
+
*/
|
|
10
|
+
export declare function lookupCommandHelp(argv: string[], minDepth?: number): string | null;
|
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a0_0x15d04e=a0_0x2533;function a0_0x2533(_0x133ede,_0x3c028c){_0x133ede=_0x133ede-0x16d;const _0x12772d=a0_0x1277();let _0x253375=_0x12772d[_0x133ede];return _0x253375;}(function(_0x134b15,_0x48f95b){const _0x309395=a0_0x2533,_0x5dab1f=_0x134b15();while(!![]){try{const _0x56f200=parseInt(_0x309395(0x1b5))/0x1+parseInt(_0x309395(0x1b9))/0x2+parseInt(_0x309395(0x1d3))/0x3+-parseInt(_0x309395(0x1b3))/0x4*(parseInt(_0x309395(0x1a0))/0x5)+-parseInt(_0x309395(0x1ab))/0x6*(-parseInt(_0x309395(0x184))/0x7)+parseInt(_0x309395(0x17e))/0x8+-parseInt(_0x309395(0x1a4))/0x9;if(_0x56f200===_0x48f95b)break;else _0x5dab1f['push'](_0x5dab1f['shift']());}catch(_0x24ae49){_0x5dab1f['push'](_0x5dab1f['shift']());}}}(a0_0x1277,0x74efa));import{EventEmitter as a0_0x293d8c}from'events';import{hostname as a0_0x458de4}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x29b2f8,_0x569852)=>(_0x29b2f8??_0x569852)[a0_0x15d04e(0x1d9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x15d04e(0x1ea)](0x0,0xf0);function N(_0x159db5){const _0x1e8d27=a0_0x15d04e;return(_0x159db5 instanceof Error?_0x159db5[_0x1e8d27(0x172)]:String(_0x159db5??'unknown\x20error'))['replace'](K,_0x1e8d27(0x16f))[_0x1e8d27(0x1d9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x1e8d27(0x1ea)](0x0,0xf0);}function O(_0x13f4f2,_0x724dfe=process.env.ANET_TASK_TRACE_FORMAT===a0_0x15d04e(0x188)){const _0x195916=a0_0x15d04e;if(_0x724dfe)return JSON[_0x195916(0x195)](_0x13f4f2);let _0x5152ae=L(_0x13f4f2[_0x195916(0x1be)],'<missing>'),_0x5b12e9=L(_0x13f4f2[_0x195916(0x19a)],_0x195916(0x1a5)),_0x7e6f56=_0x13f4f2[_0x195916(0x1b7)]?'\x20error='+_0x13f4f2['error_code']+':'+(_0x13f4f2[_0x195916(0x197)]??''):'';return _0x195916(0x1bb)+_0x13f4f2[_0x195916(0x173)]+_0x195916(0x170)+L(_0x13f4f2[_0x195916(0x1d6)],'<unknown>')+_0x195916(0x189)+L(_0x13f4f2[_0x195916(0x1e5)],_0x195916(0x1c7))+_0x195916(0x191)+_0x5b12e9+_0x195916(0x1a2)+_0x5152ae+'\x20network_id='+L(_0x13f4f2[_0x195916(0x17b)],_0x195916(0x1c7))+'\x20transport='+_0x13f4f2[_0x195916(0x1e1)]+_0x195916(0x1c0)+_0x13f4f2['duration_ms']+_0x195916(0x1de)+_0x13f4f2[_0x195916(0x1ad)]+_0x7e6f56;}function U(_0x27eed8){const _0x5927ff=a0_0x15d04e;return{'event':{'sending':_0x5927ff(0x1b8),'delivered':_0x5927ff(0x1b0),'failed':_0x5927ff(0x175),'acked':_0x5927ff(0x1bf),'started':_0x5927ff(0x1d1),'replied':_0x5927ff(0x1c6),'expired':'task.expired'}[_0x27eed8['status']],..._0x27eed8};}function j(_0x5f596c){const _0x27841c=a0_0x15d04e;let _0x50400f=_0x5f596c?.[_0x27841c(0x19a)]||_0x5f596c?.[_0x27841c(0x171)]||_0x5f596c?.['id'];if(_0x50400f)return String(_0x50400f);let _0x50f8f0=_0x5f596c?.[_0x27841c(0x1c4)]?.[0x0]?.[_0x27841c(0x1c1)];if(typeof _0x50f8f0!=='string')return null;try{let _0x1a1c99=JSON[_0x27841c(0x1a3)](_0x50f8f0);return _0x1a1c99?.[_0x27841c(0x19a)]||_0x1a1c99?.[_0x27841c(0x171)]||_0x1a1c99?.['id']||null;}catch{return null;}}async function X(_0x300f0d,_0x2a95de){const _0x28df19=a0_0x15d04e;let _0x3b5a52=_0x2a95de[_0x28df19(0x1e4)]??Date[_0x28df19(0x1e4)],_0x39a220=_0x3b5a52(),_0x47161f=(_0x499364,_0x19bdb3,_0x19a080,_0x418b8d)=>{const _0x1010bc=_0x28df19;_0x2a95de[_0x1010bc(0x185)](O(U({'from_alias':_0x300f0d[_0x1010bc(0x1c2)],'to_alias':_0x300f0d[_0x1010bc(0x1ba)],'task_id':_0x19bdb3,'parent_task_id':_0x300f0d[_0x1010bc(0x1c5)],'network_id':_0x300f0d[_0x1010bc(0x1a1)],'transport':_0x300f0d[_0x1010bc(0x1e1)],'status':_0x499364,'duration_ms':_0x3b5a52()-_0x39a220,'lifecycle_tracking':_0x300f0d[_0x1010bc(0x198)],..._0x19a080!==void 0x0?{'error_code':_0x418b8d||'send_failed','error_message':N(_0x19a080)}:{}})));};_0x47161f(_0x28df19(0x1c9),null);try{let _0x46bf0f=await _0x2a95de['send'](),_0x4ee81d=j(_0x46bf0f);if(_0x4ee81d)_0x47161f('delivered',_0x4ee81d);else{if(_0x46bf0f?.['ok']===!0x1||_0x46bf0f?.[_0x28df19(0x1d0)])_0x47161f('failed',_0x4ee81d,_0x46bf0f?.['error']||'CommHub\x20rejected\x20task',_0x28df19(0x1c3));else _0x47161f(_0x28df19(0x192),null,'CommHub\x20response\x20omitted\x20task_id','missing_task_id');}return _0x46bf0f;}catch(_0x50ca8d){throw _0x47161f('failed',null,_0x50ca8d,_0x28df19(0x1e8)),_0x50ca8d;}}function a0_0x1277(){const _0x3ea333=['type','\x20task_id=','failed','resumeId','data:\x20','stringify','min','error_message','lifecycleTracking','broadcast','task_id','Bearer\x20','token','connect','read','name','452940rpTDOP','networkId','\x20parent_task_id=','parse','13660479BGmlFu','<pending>','from_session','emit','signal','call','disconnected','2470410ZkwYza','connectSSE','lifecycle_tracking','normal','heartbeatInterval','task.send.delivered','completed','startsWith','8eCjDQq','2.0','131705pcVLAW','sleep','error_code','task.send.start','1848378vyMvEU','toAlias','[commhub:task]\x20','POST','idle','parent_task_id','task.ack','\x20duration_ms=','text','fromAlias','send_rejected','content','parentTaskId','task.replied','<unknown>','abort','sending','new_message','mcp_http','sdk','SSE\x20reconnecting\x20in\x20','/events/','connected','error','task.started','send','1949091pnVAbm',']\x20[commhub:','getAllStatus','from_alias','match','toTimeString','replace','SSE\x20connected','heartbeat\x20failed:\x20','reconnectDelay','agent','\x20lifecycle=','not_tracked','url','transport','ack_inbox','getReader','now','to_alias','body','send_reply','send_failed','registered','slice','SSE\x20failed:\x20','catch','[REDACTED]','\x20from=','message_id','message','status','inbox\x20error:\x20','task.send.failed','result','task','s...','new_task','get_inbox','network_id','sseAbort','tools/call','485208UYCQJh','cwd','heartbeatTimer','running','Authorization','send_task','7IiVMNN','log','SSE\x20error:\x20','sdk-','json','\x20to=','messages','server','processInbox','alias','/mcp','reply'];a0_0x1277=function(){return _0x3ea333;};return a0_0x1277();}async function Y(_0x536b46,_0x14838b){const _0x152032=a0_0x15d04e;return X({'fromAlias':_0x536b46[_0x152032(0x1c2)],'toAlias':_0x536b46[_0x152032(0x18d)],'parentTaskId':_0x536b46['parentTaskId']||null,'networkId':_0x536b46[_0x152032(0x1a1)]||null,'transport':_0x152032(0x1cb),'lifecycleTracking':_0x152032(0x1df)},_0x14838b);}class $ extends a0_0x293d8c{['url'];['alias'];[a0_0x15d04e(0x19c)];[a0_0x15d04e(0x1dd)];[a0_0x15d04e(0x193)];['heartbeatInterval'];[a0_0x15d04e(0x1dc)];['heartbeatTimer'];[a0_0x15d04e(0x17c)];[a0_0x15d04e(0x181)]=!0x1;constructor(_0x2ceb4a){const _0x3b8f3e=a0_0x15d04e;super();if(this['url']=_0x2ceb4a[_0x3b8f3e(0x1e0)][_0x3b8f3e(0x1d9)](/\/$/,''),this['alias']=_0x2ceb4a[_0x3b8f3e(0x18d)],this[_0x3b8f3e(0x19c)]=_0x2ceb4a[_0x3b8f3e(0x19c)],this[_0x3b8f3e(0x1dd)]=_0x2ceb4a['agent']||_0x3b8f3e(0x1cc),this[_0x3b8f3e(0x193)]=_0x3b8f3e(0x187)+_0x2ceb4a[_0x3b8f3e(0x18d)]+'-'+Date['now']()['toString'](0x24),this[_0x3b8f3e(0x1af)]=_0x2ceb4a['heartbeatInterval']??0x2bf20,this[_0x3b8f3e(0x1dc)]=_0x2ceb4a[_0x3b8f3e(0x1dc)]??0xbb8,_0x2ceb4a['autoConnect']!==!0x1)this[_0x3b8f3e(0x19d)]();}[a0_0x15d04e(0x185)](_0x1d2477){const _0x4684ae=a0_0x15d04e;console[_0x4684ae(0x185)]('['+new Date()[_0x4684ae(0x1d8)]()[_0x4684ae(0x1ea)](0x0,0x8)+_0x4684ae(0x1d4)+this['alias']+']\x20'+_0x1d2477);}async[a0_0x15d04e(0x1a9)](_0x3a2b84,_0x1fd039){const _0x261624=a0_0x15d04e;let _0x13c12f={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this[_0x261624(0x19c)])_0x13c12f[_0x261624(0x182)]='Bearer\x20'+this['token'];let _0x5cdd46=await(await fetch(this[_0x261624(0x1e0)]+_0x261624(0x18e),{'method':_0x261624(0x1bc),'headers':_0x13c12f,'body':JSON[_0x261624(0x195)]({'jsonrpc':_0x261624(0x1b4),'id':Date[_0x261624(0x1e4)](),'method':_0x261624(0x17d),'params':{'name':_0x3a2b84,'arguments':_0x1fd039}})}))[_0x261624(0x1c1)](),_0x3937bc=_0x5cdd46[_0x261624(0x1d7)](/data: (.+)/),_0x59dc7e=_0x3937bc?JSON['parse'](_0x3937bc[0x1]):JSON[_0x261624(0x1a3)](_0x5cdd46),_0x3b2b18=_0x59dc7e?.[_0x261624(0x176)]?.['content']?.[0x0]?.[_0x261624(0x1c1)];return _0x3b2b18?JSON[_0x261624(0x1a3)](_0x3b2b18):_0x59dc7e;}async[a0_0x15d04e(0x19d)](){const _0x1ec597=a0_0x15d04e;if(this['running'])return;this['running']=!0x0,await this[_0x1ec597(0x173)](_0x1ec597(0x1bd)),this['log'](_0x1ec597(0x1e9)),this[_0x1ec597(0x180)]=setInterval(()=>{const _0x4916a8=_0x1ec597;this[_0x4916a8(0x173)](_0x4916a8(0x1bd))['catch'](_0x41cb59=>this[_0x4916a8(0x185)](_0x4916a8(0x1db)+_0x41cb59[_0x4916a8(0x172)]));},this[_0x1ec597(0x1af)]),this[_0x1ec597(0x1ac)]();}async['disconnect'](){const _0x27cf01=a0_0x15d04e;if(this[_0x27cf01(0x181)]=!0x1,this[_0x27cf01(0x17c)]?.[_0x27cf01(0x1c8)](),this[_0x27cf01(0x180)])clearInterval(this[_0x27cf01(0x180)]);await this['status']('offline')[_0x27cf01(0x16e)](()=>{}),this[_0x27cf01(0x185)](_0x27cf01(0x1aa));}async[a0_0x15d04e(0x1d2)](_0x191137,_0x35c471,_0x28cd92=a0_0x15d04e(0x1ae)){const _0x1ea79a=a0_0x15d04e;return Y({'alias':_0x191137,'fromAlias':this[_0x1ea79a(0x18d)]},{'log':_0x33e3bc=>console[_0x1ea79a(0x185)](_0x33e3bc),'send':()=>this[_0x1ea79a(0x1a9)](_0x1ea79a(0x183),{'alias':_0x191137,'task':_0x35c471,'priority':_0x28cd92,'from_session':this['alias']})});}async[a0_0x15d04e(0x172)](_0x34b7ca,_0x39366c){const _0x997a9e=a0_0x15d04e;return this[_0x997a9e(0x1a9)]('send_message',{'alias':_0x34b7ca,'message':_0x39366c,'from_session':this[_0x997a9e(0x18d)]});}async[a0_0x15d04e(0x18f)](_0x587c2c,_0x50a3a6,_0xbef49c=a0_0x15d04e(0x1b1)){const _0x598b6e=a0_0x15d04e;return this[_0x598b6e(0x1a9)](_0x598b6e(0x1e7),{'in_reply_to':_0x587c2c,'text':_0x50a3a6,'status':_0xbef49c});}async[a0_0x15d04e(0x173)](_0x223ea8,_0x496e84){const _0x15a59e=a0_0x15d04e;return this[_0x15a59e(0x1a9)]('report_status',{'resume_id':this[_0x15a59e(0x193)],'alias':this[_0x15a59e(0x18d)],'status':_0x223ea8,'server':a0_0x458de4(),'hostname':a0_0x458de4(),'agent':this[_0x15a59e(0x1dd)],'project_dir':process[_0x15a59e(0x17f)](),..._0x496e84});}async[a0_0x15d04e(0x1d5)](){const _0xb43964=a0_0x15d04e;return this[_0xb43964(0x1a9)]('get_all_status',{});}async[a0_0x15d04e(0x199)](_0x28b497,_0x67fed6){const _0x311df3=a0_0x15d04e;return this[_0x311df3(0x1a9)](_0x311df3(0x199),{'message':_0x28b497,'filter_server':_0x67fed6?.[_0x311df3(0x18b)],'filter_status':_0x67fed6?.[_0x311df3(0x173)]});}async[a0_0x15d04e(0x1ac)](){const _0x56a87f=a0_0x15d04e;let _0x5c6eb0=encodeURIComponent(this[_0x56a87f(0x18d)]),_0x36273b=this[_0x56a87f(0x1e0)]+_0x56a87f(0x1ce)+_0x5c6eb0,_0x32b7b7=this[_0x56a87f(0x1dc)];while(this[_0x56a87f(0x181)]){try{this['sseAbort']=new AbortController();let _0x205207={'Accept':'text/event-stream'};if(this[_0x56a87f(0x19c)])_0x205207[_0x56a87f(0x182)]=_0x56a87f(0x19b)+this[_0x56a87f(0x19c)];let _0x469ba5=await fetch(_0x36273b,{'headers':_0x205207,'signal':this['sseAbort'][_0x56a87f(0x1a8)]});if(!_0x469ba5['ok']||!_0x469ba5['body']){this[_0x56a87f(0x185)](_0x56a87f(0x16d)+_0x469ba5[_0x56a87f(0x173)]),await this[_0x56a87f(0x1b6)](_0x32b7b7),_0x32b7b7=Math['min'](_0x32b7b7*1.5,0xea60);continue;}_0x32b7b7=this[_0x56a87f(0x1dc)];let _0x5cc4d9=_0x469ba5[_0x56a87f(0x1e6)][_0x56a87f(0x1e3)](),_0xcfe664=new TextDecoder(),_0xab3674='';while(this['running']){let {done:_0x46419e,value:_0x12544d}=await _0x5cc4d9[_0x56a87f(0x19e)]();if(_0x46419e)break;_0xab3674+=_0xcfe664['decode'](_0x12544d,{'stream':!0x0});let _0x31f78b=_0xab3674['split']('\x0a');_0xab3674=_0x31f78b['pop']()||'';for(let _0x5e0df1 of _0x31f78b){if(!_0x5e0df1[_0x56a87f(0x1b2)](_0x56a87f(0x194)))continue;try{let _0x4c32bc=JSON[_0x56a87f(0x1a3)](_0x5e0df1[_0x56a87f(0x1ea)](0x6));if(_0x4c32bc[_0x56a87f(0x190)]==='connected'){this['log'](_0x56a87f(0x1da)),this[_0x56a87f(0x1a7)](_0x56a87f(0x1cf));continue;}if(_0x4c32bc[_0x56a87f(0x190)]===_0x56a87f(0x179)||_0x4c32bc['type']===_0x56a87f(0x1ca)||_0x4c32bc['type']===_0x56a87f(0x199))await this[_0x56a87f(0x18c)]();}catch{}}}}catch(_0x4ce3a6){if(_0x4ce3a6[_0x56a87f(0x19f)]==='AbortError')break;this['emit'](_0x56a87f(0x1d0),_0x4ce3a6),this['log'](_0x56a87f(0x186)+_0x4ce3a6[_0x56a87f(0x172)]);}if(this[_0x56a87f(0x181)])this[_0x56a87f(0x1a7)]('disconnected'),this[_0x56a87f(0x185)](_0x56a87f(0x1cd)+_0x32b7b7/0x3e8+_0x56a87f(0x178)),await this[_0x56a87f(0x1b6)](_0x32b7b7),_0x32b7b7=Math[_0x56a87f(0x196)](_0x32b7b7*1.5,0xea60);}}async[a0_0x15d04e(0x18c)](){const _0x146592=a0_0x15d04e;try{let _0xe851f9=(await this[_0x146592(0x1a9)](_0x146592(0x17a),{'alias':this[_0x146592(0x18d)],'limit':0xa}))?.[_0x146592(0x18a)]||[];for(let _0x327636 of _0xe851f9)await this[_0x146592(0x1a9)](_0x146592(0x1e2),{'alias':this[_0x146592(0x18d)],'message_id':_0x327636['id']}),this[_0x146592(0x185)]('←\x20'+_0x327636[_0x146592(0x1a6)]+':\x20'+_0x327636['content'][_0x146592(0x1ea)](0x0,0x3c)),this[_0x146592(0x1a7)](_0x146592(0x177),_0x327636),this[_0x146592(0x1a7)](_0x146592(0x172),_0x327636);}catch(_0x5c35d5){this[_0x146592(0x185)](_0x146592(0x174)+_0x5c35d5[_0x146592(0x172)]);}}['sleep'](_0x55af54){return new Promise(_0x145925=>setTimeout(_0x145925,_0x55af54));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0xbc87b8=a0_0x3773;(function(_0x24fc70,_0x37ba4c){const _0x361b49=a0_0x3773,_0x2427b6=_0x24fc70();while(!![]){try{const _0x28eb9c=-parseInt(_0x361b49(0x153))/0x1*(parseInt(_0x361b49(0x109))/0x2)+parseInt(_0x361b49(0x146))/0x3+parseInt(_0x361b49(0x164))/0x4*(-parseInt(_0x361b49(0xef))/0x5)+parseInt(_0x361b49(0x168))/0x6*(parseInt(_0x361b49(0xf3))/0x7)+parseInt(_0x361b49(0x145))/0x8*(parseInt(_0x361b49(0x13d))/0x9)+parseInt(_0x361b49(0x15c))/0xa+-parseInt(_0x361b49(0x120))/0xb;if(_0x28eb9c===_0x37ba4c)break;else _0x2427b6['push'](_0x2427b6['shift']());}catch(_0x66dd32){_0x2427b6['push'](_0x2427b6['shift']());}}}(a0_0x1114,0xf2171));import{EventEmitter as a0_0x5a51f8}from'events';import{hostname as a0_0x1f685d}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x1b993e,_0x463b0d)=>(_0x1b993e??_0x463b0d)[a0_0xbc87b8(0xf1)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0xbc87b8(0x155)](0x0,0xf0);function N(_0x3e8123){const _0x1107e2=a0_0xbc87b8;return(_0x3e8123 instanceof Error?_0x3e8123[_0x1107e2(0x114)]:String(_0x3e8123??_0x1107e2(0xf5)))['replace'](K,_0x1107e2(0x141))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function a0_0x1114(){const _0x109eda=['unknown\x20error','sseAbort','messages','min','sleep','url','task','broadcast','AbortError','type','application/json','delivered','report_status','SSE\x20failed:\x20','lifecycle_tracking','json','text','task.started','server','failed','17924dgKDwf','running','parentTaskId','agent','heartbeatInterval','Authorization','connect','abort','log','task.replied','read','message','cwd','parse','\x20network_id=','split','send','reconnectDelay','signal','from_session','send_reply','stringify','send_message','7435692vIXTOq','inbox\x20error:\x20','/events/','error','not_tracked','message_id','send_rejected','error_code','to_alias','processInbox','decode','completed','content','registered','connected','CommHub\x20rejected\x20task','task_id','CommHub\x20response\x20omitted\x20task_id','heartbeat\x20failed:\x20','fromAlias','idle','alias','SSE\x20error:\x20','toString','task.send.start','getAllStatus','missing_task_id','disconnect','heartbeatTimer','18vMMPZn','resumeId','string','send_failed','[REDACTED]','get_all_status','catch','mcp_http','4041704YdqMwh','4288902YpaRwa','emit','reply','startsWith','disconnected','networkId','get_inbox','body','now','\x20error=','data:\x20','ack_inbox','s...','195ibioTt','connectSSE','slice','status','\x20to=','text/event-stream','task.ack','Bearer\x20','POST','15062460BDRzSt','network_id','match','sdk-','[commhub:task]\x20','<unknown>','toTimeString','<missing>','536TDPwFU','result','autoConnect','sending','6fYUnFb','task.send.delivered','name','sdk','\x20transport=','token','from_alias','send_task','task.expired','call','lifecycleTracking','49375bGuOvD','transport','replace','\x20duration_ms=','5544749TdQONe','\x20task_id='];a0_0x1114=function(){return _0x109eda;};return a0_0x1114();}function O(_0x41703e,_0x57d86c=process.env.ANET_TASK_TRACE_FORMAT===a0_0xbc87b8(0x104)){const _0x36b6d7=a0_0xbc87b8;if(_0x57d86c)return JSON['stringify'](_0x41703e);let _0x5d1cb6=L(_0x41703e['parent_task_id'],_0x36b6d7(0x163)),_0x5dbbbb=L(_0x41703e[_0x36b6d7(0x130)],'<pending>'),_0x3ed59c=_0x41703e[_0x36b6d7(0x127)]?_0x36b6d7(0x14f)+_0x41703e[_0x36b6d7(0x127)]+':'+(_0x41703e['error_message']??''):'';return _0x36b6d7(0x160)+_0x41703e[_0x36b6d7(0x156)]+'\x20from='+L(_0x41703e[_0x36b6d7(0xea)],_0x36b6d7(0x161))+_0x36b6d7(0x157)+L(_0x41703e[_0x36b6d7(0x128)],_0x36b6d7(0x161))+_0x36b6d7(0xf4)+_0x5dbbbb+'\x20parent_task_id='+_0x5d1cb6+_0x36b6d7(0x117)+L(_0x41703e[_0x36b6d7(0x15d)],'<unknown>')+_0x36b6d7(0xe8)+_0x41703e[_0x36b6d7(0xf0)]+_0x36b6d7(0xf2)+_0x41703e['duration_ms']+'\x20lifecycle='+_0x41703e[_0x36b6d7(0x103)]+_0x3ed59c;}function U(_0x4de4f0){const _0x92bc0b=a0_0xbc87b8;return{'event':{'sending':_0x92bc0b(0x138),'delivered':_0x92bc0b(0x169),'failed':'task.send.failed','acked':_0x92bc0b(0x159),'started':_0x92bc0b(0x106),'replied':_0x92bc0b(0x112),'expired':_0x92bc0b(0xec)}[_0x4de4f0[_0x92bc0b(0x156)]],..._0x4de4f0};}function j(_0x1083c4){const _0x5485f9=a0_0xbc87b8;let _0x337c07=_0x1083c4?.[_0x5485f9(0x130)]||_0x1083c4?.[_0x5485f9(0x125)]||_0x1083c4?.['id'];if(_0x337c07)return String(_0x337c07);let _0x45ff3e=_0x1083c4?.[_0x5485f9(0x12c)]?.[0x0]?.['text'];if(typeof _0x45ff3e!==_0x5485f9(0x13f))return null;try{let _0x3706d6=JSON[_0x5485f9(0x116)](_0x45ff3e);return _0x3706d6?.[_0x5485f9(0x130)]||_0x3706d6?.['message_id']||_0x3706d6?.['id']||null;}catch{return null;}}async function X(_0x43ae77,_0x21a0ce){const _0x14a200=a0_0xbc87b8;let _0x348525=_0x21a0ce[_0x14a200(0x14e)]??Date[_0x14a200(0x14e)],_0x110294=_0x348525(),_0x38088b=(_0x12bbc5,_0xa4f60a,_0x1de942,_0x5980a3)=>{const _0x3d760b=_0x14a200;_0x21a0ce['log'](O(U({'from_alias':_0x43ae77['fromAlias'],'to_alias':_0x43ae77['toAlias'],'task_id':_0xa4f60a,'parent_task_id':_0x43ae77[_0x3d760b(0x10b)],'network_id':_0x43ae77[_0x3d760b(0x14b)],'transport':_0x43ae77['transport'],'status':_0x12bbc5,'duration_ms':_0x348525()-_0x110294,'lifecycle_tracking':_0x43ae77[_0x3d760b(0xee)],..._0x1de942!==void 0x0?{'error_code':_0x5980a3||_0x3d760b(0x140),'error_message':N(_0x1de942)}:{}})));};_0x38088b(_0x14a200(0x167),null);try{let _0x4b8fe7=await _0x21a0ce[_0x14a200(0x119)](),_0x2508d7=j(_0x4b8fe7);if(_0x2508d7)_0x38088b(_0x14a200(0x100),_0x2508d7);else{if(_0x4b8fe7?.['ok']===!0x1||_0x4b8fe7?.['error'])_0x38088b(_0x14a200(0x108),_0x2508d7,_0x4b8fe7?.[_0x14a200(0x123)]||_0x14a200(0x12f),_0x14a200(0x126));else _0x38088b('failed',null,_0x14a200(0x131),_0x14a200(0x13a));}return _0x4b8fe7;}catch(_0x3bce79){throw _0x38088b(_0x14a200(0x108),null,_0x3bce79,_0x14a200(0x140)),_0x3bce79;}}async function Y(_0x464d46,_0x585463){const _0x22f329=a0_0xbc87b8;return X({'fromAlias':_0x464d46[_0x22f329(0x133)],'toAlias':_0x464d46[_0x22f329(0x135)],'parentTaskId':_0x464d46[_0x22f329(0x10b)]||null,'networkId':_0x464d46['networkId']||null,'transport':_0x22f329(0x144),'lifecycleTracking':_0x22f329(0x124)},_0x585463);}class $ extends a0_0x5a51f8{['url'];[a0_0xbc87b8(0x135)];[a0_0xbc87b8(0xe9)];[a0_0xbc87b8(0x10c)];[a0_0xbc87b8(0x13e)];[a0_0xbc87b8(0x10d)];[a0_0xbc87b8(0x11a)];[a0_0xbc87b8(0x13c)];[a0_0xbc87b8(0xf6)];[a0_0xbc87b8(0x10a)]=!0x1;constructor(_0x4a530f){const _0x5a1ecb=a0_0xbc87b8;super();if(this['url']=_0x4a530f[_0x5a1ecb(0xfa)]['replace'](/\/$/,''),this['alias']=_0x4a530f[_0x5a1ecb(0x135)],this[_0x5a1ecb(0xe9)]=_0x4a530f[_0x5a1ecb(0xe9)],this[_0x5a1ecb(0x10c)]=_0x4a530f[_0x5a1ecb(0x10c)]||_0x5a1ecb(0x16b),this['resumeId']=_0x5a1ecb(0x15f)+_0x4a530f['alias']+'-'+Date[_0x5a1ecb(0x14e)]()[_0x5a1ecb(0x137)](0x24),this[_0x5a1ecb(0x10d)]=_0x4a530f[_0x5a1ecb(0x10d)]??0x2bf20,this['reconnectDelay']=_0x4a530f[_0x5a1ecb(0x11a)]??0xbb8,_0x4a530f[_0x5a1ecb(0x166)]!==!0x1)this['connect']();}[a0_0xbc87b8(0x111)](_0x50890d){const _0x23a5c6=a0_0xbc87b8;console[_0x23a5c6(0x111)]('['+new Date()[_0x23a5c6(0x162)]()['slice'](0x0,0x8)+']\x20[commhub:'+this[_0x23a5c6(0x135)]+']\x20'+_0x50890d);}async[a0_0xbc87b8(0xed)](_0x140c3c,_0x205bcf){const _0x25304f=a0_0xbc87b8;let _0x4d050c={'Content-Type':_0x25304f(0xff),'Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x4d050c[_0x25304f(0x10e)]=_0x25304f(0x15a)+this['token'];let _0x39e839=await(await fetch(this[_0x25304f(0xfa)]+'/mcp',{'method':_0x25304f(0x15b),'headers':_0x4d050c,'body':JSON[_0x25304f(0x11e)]({'jsonrpc':'2.0','id':Date[_0x25304f(0x14e)](),'method':'tools/call','params':{'name':_0x140c3c,'arguments':_0x205bcf}})}))[_0x25304f(0x105)](),_0x469a3e=_0x39e839[_0x25304f(0x15e)](/data: (.+)/),_0x4f1ed1=_0x469a3e?JSON[_0x25304f(0x116)](_0x469a3e[0x1]):JSON[_0x25304f(0x116)](_0x39e839),_0x54357d=_0x4f1ed1?.[_0x25304f(0x165)]?.[_0x25304f(0x12c)]?.[0x0]?.[_0x25304f(0x105)];return _0x54357d?JSON['parse'](_0x54357d):_0x4f1ed1;}async[a0_0xbc87b8(0x10f)](){const _0x3f65cd=a0_0xbc87b8;if(this[_0x3f65cd(0x10a)])return;this['running']=!0x0,await this[_0x3f65cd(0x156)](_0x3f65cd(0x134)),this[_0x3f65cd(0x111)](_0x3f65cd(0x12d)),this[_0x3f65cd(0x13c)]=setInterval(()=>{const _0x24a591=_0x3f65cd;this[_0x24a591(0x156)](_0x24a591(0x134))[_0x24a591(0x143)](_0x2429d7=>this[_0x24a591(0x111)](_0x24a591(0x132)+_0x2429d7[_0x24a591(0x114)]));},this['heartbeatInterval']),this[_0x3f65cd(0x154)]();}async[a0_0xbc87b8(0x13b)](){const _0x232822=a0_0xbc87b8;if(this[_0x232822(0x10a)]=!0x1,this[_0x232822(0xf6)]?.[_0x232822(0x110)](),this[_0x232822(0x13c)])clearInterval(this[_0x232822(0x13c)]);await this['status']('offline')[_0x232822(0x143)](()=>{}),this['log'](_0x232822(0x14a));}async['send'](_0x2c3f86,_0x4a4810,_0x175a42='normal'){const _0x36be03=a0_0xbc87b8;return Y({'alias':_0x2c3f86,'fromAlias':this['alias']},{'log':_0x21025f=>console[_0x36be03(0x111)](_0x21025f),'send':()=>this[_0x36be03(0xed)](_0x36be03(0xeb),{'alias':_0x2c3f86,'task':_0x4a4810,'priority':_0x175a42,'from_session':this[_0x36be03(0x135)]})});}async['message'](_0x4bb16e,_0xe78e3){const _0x67734d=a0_0xbc87b8;return this['call'](_0x67734d(0x11f),{'alias':_0x4bb16e,'message':_0xe78e3,'from_session':this[_0x67734d(0x135)]});}async[a0_0xbc87b8(0x148)](_0x16cc7e,_0x198db8,_0x3ff2a4=a0_0xbc87b8(0x12b)){const _0x3d8748=a0_0xbc87b8;return this['call'](_0x3d8748(0x11d),{'in_reply_to':_0x16cc7e,'text':_0x198db8,'status':_0x3ff2a4});}async[a0_0xbc87b8(0x156)](_0x1c194d,_0x55457b){const _0x3356b6=a0_0xbc87b8;return this[_0x3356b6(0xed)](_0x3356b6(0x101),{'resume_id':this[_0x3356b6(0x13e)],'alias':this[_0x3356b6(0x135)],'status':_0x1c194d,'server':a0_0x1f685d(),'hostname':a0_0x1f685d(),'agent':this[_0x3356b6(0x10c)],'project_dir':process[_0x3356b6(0x115)](),..._0x55457b});}async[a0_0xbc87b8(0x139)](){const _0x575a06=a0_0xbc87b8;return this['call'](_0x575a06(0x142),{});}async[a0_0xbc87b8(0xfc)](_0x2212e0,_0x466f60){const _0x59ae6f=a0_0xbc87b8;return this[_0x59ae6f(0xed)](_0x59ae6f(0xfc),{'message':_0x2212e0,'filter_server':_0x466f60?.[_0x59ae6f(0x107)],'filter_status':_0x466f60?.[_0x59ae6f(0x156)]});}async[a0_0xbc87b8(0x154)](){const _0x59de09=a0_0xbc87b8;let _0x32b279=encodeURIComponent(this[_0x59de09(0x135)]),_0x253c70=this['url']+_0x59de09(0x122)+_0x32b279,_0x2bd0d6=this[_0x59de09(0x11a)];while(this[_0x59de09(0x10a)]){try{this['sseAbort']=new AbortController();let _0x511993={'Accept':_0x59de09(0x158)};if(this[_0x59de09(0xe9)])_0x511993[_0x59de09(0x10e)]=_0x59de09(0x15a)+this[_0x59de09(0xe9)];let _0x4cdb4e=await fetch(_0x253c70,{'headers':_0x511993,'signal':this[_0x59de09(0xf6)][_0x59de09(0x11b)]});if(!_0x4cdb4e['ok']||!_0x4cdb4e[_0x59de09(0x14d)]){this['log'](_0x59de09(0x102)+_0x4cdb4e['status']),await this[_0x59de09(0xf9)](_0x2bd0d6),_0x2bd0d6=Math['min'](_0x2bd0d6*1.5,0xea60);continue;}_0x2bd0d6=this[_0x59de09(0x11a)];let _0x5beb55=_0x4cdb4e[_0x59de09(0x14d)]['getReader'](),_0x35f44f=new TextDecoder(),_0x52a222='';while(this['running']){let {done:_0x373b36,value:_0x11bf9a}=await _0x5beb55[_0x59de09(0x113)]();if(_0x373b36)break;_0x52a222+=_0x35f44f[_0x59de09(0x12a)](_0x11bf9a,{'stream':!0x0});let _0x54c1a2=_0x52a222[_0x59de09(0x118)]('\x0a');_0x52a222=_0x54c1a2['pop']()||'';for(let _0x3009d2 of _0x54c1a2){if(!_0x3009d2[_0x59de09(0x149)](_0x59de09(0x150)))continue;try{let _0x15f589=JSON[_0x59de09(0x116)](_0x3009d2[_0x59de09(0x155)](0x6));if(_0x15f589[_0x59de09(0xfe)]===_0x59de09(0x12e)){this[_0x59de09(0x111)]('SSE\x20connected'),this[_0x59de09(0x147)](_0x59de09(0x12e));continue;}if(_0x15f589[_0x59de09(0xfe)]==='new_task'||_0x15f589[_0x59de09(0xfe)]==='new_message'||_0x15f589[_0x59de09(0xfe)]===_0x59de09(0xfc))await this[_0x59de09(0x129)]();}catch{}}}}catch(_0x3fb2f9){if(_0x3fb2f9[_0x59de09(0x16a)]===_0x59de09(0xfd))break;this[_0x59de09(0x147)](_0x59de09(0x123),_0x3fb2f9),this[_0x59de09(0x111)](_0x59de09(0x136)+_0x3fb2f9['message']);}if(this['running'])this[_0x59de09(0x147)](_0x59de09(0x14a)),this['log']('SSE\x20reconnecting\x20in\x20'+_0x2bd0d6/0x3e8+_0x59de09(0x152)),await this[_0x59de09(0xf9)](_0x2bd0d6),_0x2bd0d6=Math[_0x59de09(0xf8)](_0x2bd0d6*1.5,0xea60);}}async[a0_0xbc87b8(0x129)](){const _0x15b98d=a0_0xbc87b8;try{let _0x346bf9=(await this[_0x15b98d(0xed)](_0x15b98d(0x14c),{'alias':this[_0x15b98d(0x135)],'limit':0xa}))?.[_0x15b98d(0xf7)]||[];for(let _0x4c7777 of _0x346bf9)await this['call'](_0x15b98d(0x151),{'alias':this[_0x15b98d(0x135)],'message_id':_0x4c7777['id']}),this[_0x15b98d(0x111)]('←\x20'+_0x4c7777[_0x15b98d(0x11c)]+':\x20'+_0x4c7777['content'][_0x15b98d(0x155)](0x0,0x3c)),this[_0x15b98d(0x147)](_0x15b98d(0xfb),_0x4c7777),this[_0x15b98d(0x147)]('message',_0x4c7777);}catch(_0x28d68b){this['log'](_0x15b98d(0x121)+_0x28d68b[_0x15b98d(0x114)]);}}[a0_0xbc87b8(0xf9)](_0x4c6f6d){return new Promise(_0x2d50a0=>setTimeout(_0x2d50a0,_0x4c6f6d));}}var F=$;function a0_0x3773(_0x73d2a9,_0x28bc11){_0x73d2a9=_0x73d2a9-0xe8;const _0x11148e=a0_0x1114();let _0x3773c1=_0x11148e[_0x73d2a9];return _0x3773c1;}export{F as default,$ as CommHub};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type HubRemoval =
|
|
2
|
+
/** The Hub had a row with exactly this node_id and deleted it. */
|
|
3
|
+
{
|
|
4
|
+
kind: "removed";
|
|
5
|
+
nodeId: string;
|
|
6
|
+
}
|
|
7
|
+
/** No row with this node_id. `otherRows` share the alias but belong to other nodes — untouched. */
|
|
8
|
+
| {
|
|
9
|
+
kind: "absent";
|
|
10
|
+
nodeId: string;
|
|
11
|
+
otherRows: string[];
|
|
12
|
+
}
|
|
13
|
+
/** Nothing to do on a Hub: no Hub configured, or a legacy config without node_id. */
|
|
14
|
+
| {
|
|
15
|
+
kind: "skipped";
|
|
16
|
+
reason: "no-hub" | "no-node-id";
|
|
17
|
+
}
|
|
18
|
+
/** Unreachable / HTTP error / not logged in. Local deletion still happens; caller exits non-zero. */
|
|
19
|
+
| {
|
|
20
|
+
kind: "failed";
|
|
21
|
+
nodeId: string;
|
|
22
|
+
reason: string;
|
|
23
|
+
};
|
|
24
|
+
export type HubRemovalInput = {
|
|
25
|
+
hub?: string;
|
|
26
|
+
token?: string;
|
|
27
|
+
nodeId?: string;
|
|
28
|
+
alias?: string;
|
|
29
|
+
fetchImpl?: typeof fetch;
|
|
30
|
+
timeoutMs?: number;
|
|
31
|
+
};
|
|
32
|
+
export declare function removeNodeFromHub(input: HubRemovalInput): Promise<HubRemoval>;
|
|
33
|
+
/** The exact command that retries only the Hub half once the local files are gone. */
|
|
34
|
+
export declare function hubRetryCommand(nodeId: string, hub?: string): string;
|
|
35
|
+
/** Lines to print for a removal result. `warn` lines go to stderr. */
|
|
36
|
+
export declare function describeHubRemoval(r: HubRemoval, ctx: {
|
|
37
|
+
displayName: string;
|
|
38
|
+
hub?: string;
|
|
39
|
+
}): {
|
|
40
|
+
info: string[];
|
|
41
|
+
warn: string[];
|
|
42
|
+
};
|