@sleep2agi/agent-network 2.3.0-preview.131 → 2.3.0-preview.132
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 +2 -2
- 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_0x4b348a=a0_0x3f9c;(function(_0x5e7521,_0x51f549){const _0x12f5cb=a0_0x3f9c,_0x5e2f15=_0x5e7521();while(!![]){try{const _0x21b419=-parseInt(_0x12f5cb(0x9b))/0x1*(-parseInt(_0x12f5cb(0xb6))/0x2)+parseInt(_0x12f5cb(0xb5))/0x3+-parseInt(_0x12f5cb(0xd8))/0x4*(-parseInt(_0x12f5cb(0xfa))/0x5)+-parseInt(_0x12f5cb(0xcd))/0x6*(parseInt(_0x12f5cb(0xab))/0x7)+-parseInt(_0x12f5cb(0xf4))/0x8+parseInt(_0x12f5cb(0x107))/0x9+parseInt(_0x12f5cb(0xb2))/0xa;if(_0x21b419===_0x51f549)break;else _0x5e2f15['push'](_0x5e2f15['shift']());}catch(_0x5aee24){_0x5e2f15['push'](_0x5e2f15['shift']());}}}(a0_0x326d,0x5d1a8));import{EventEmitter as a0_0x85eb46}from'events';import{hostname as a0_0x4c51fd}from'os';function a0_0x326d(){const _0x4a1c7d=['delivered','new_task','\x20task_id=','getReader','application/json,\x20text/event-stream','send_reply','toTimeString','lifecycle_tracking','\x20error=','emit','network_id','task','parse','split','reconnectDelay','failed','error_message','<unknown>','6fRgMPi','startsWith','stringify','report_status','abort','signal','text','parent_task_id','toAlias','transport','name','1324MlaVVp','idle','processInbox','sdk','send_task','replace','task_id','catch','sseAbort','inbox\x20error:\x20','toString','autoConnect','SSE\x20failed:\x20','agent','alias','reply','\x20network_id=','status','content','error_code','completed','call','min','SSE\x20reconnecting\x20in\x20','\x20transport=','result','message_id','heartbeatTimer','6007672ZsmIpv','get_inbox','task.ack','sleep','POST','task.expired','3165KhSbsR','tools/call','2.0','<pending>','heartbeatInterval','AbortError','messages','send_rejected','Authorization','send_failed','networkId','to_alias','application/json','2065446wnItZf','error','send_message','server','\x20duration_ms=','now','from_alias','data:\x20','connectSSE','ack_inbox','parentTaskId','disconnected','broadcast','unknown\x20error','message','s...','resumeId','duration_ms','send','<missing>','fromAlias','type','CommHub\x20rejected\x20task','37obrksu','Bearer\x20',']\x20[commhub:','\x20lifecycle=','url','mcp_http','get_all_status','log','sdk-','running','offline','connected','disconnect','missing_task_id','connect','\x20from=','3675532vmvzYX','pop','read','token','new_message','text/event-stream','[commhub:task]\x20','1121960bMamxO','task.send.start','[REDACTED]','1922475HMxwTl','25154DFkYaB','slice','SSE\x20connected','body','match'];a0_0x326d=function(){return _0x4a1c7d;};return a0_0x326d();}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x25446e,_0x4a6730)=>(_0x25446e??_0x4a6730)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x4b348a(0xb7)](0x0,0xf0);function N(_0x270b75){const _0x43db1d=a0_0x4b348a;return(_0x270b75 instanceof Error?_0x270b75[_0x43db1d(0x115)]:String(_0x270b75??_0x43db1d(0x114)))[_0x43db1d(0xdd)](K,_0x43db1d(0xb4))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x43db1d(0xb7)](0x0,0xf0);}function O(_0x9595d5,_0x3c38b0=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x5118a2=a0_0x4b348a;if(_0x3c38b0)return JSON['stringify'](_0x9595d5);let _0x32a83e=L(_0x9595d5[_0x5118a2(0xd4)],_0x5118a2(0x11a)),_0x164c67=L(_0x9595d5['task_id'],_0x5118a2(0xfd)),_0x2f343e=_0x9595d5['error_code']?_0x5118a2(0xc3)+_0x9595d5[_0x5118a2(0xeb)]+':'+(_0x9595d5[_0x5118a2(0xcb)]??''):'';return _0x5118a2(0xb1)+_0x9595d5['status']+_0x5118a2(0xaa)+L(_0x9595d5[_0x5118a2(0x10d)],_0x5118a2(0xcc))+'\x20to='+L(_0x9595d5[_0x5118a2(0x105)],_0x5118a2(0xcc))+_0x5118a2(0xbd)+_0x164c67+'\x20parent_task_id='+_0x32a83e+_0x5118a2(0xe8)+L(_0x9595d5[_0x5118a2(0xc5)],_0x5118a2(0xcc))+_0x5118a2(0xf0)+_0x9595d5[_0x5118a2(0xd6)]+_0x5118a2(0x10b)+_0x9595d5[_0x5118a2(0x118)]+_0x5118a2(0x9e)+_0x9595d5[_0x5118a2(0xc2)]+_0x2f343e;}function U(_0x290c7a){const _0x24397a=a0_0x4b348a;return{'event':{'sending':_0x24397a(0xb3),'delivered':'task.send.delivered','failed':'task.send.failed','acked':_0x24397a(0xf6),'started':'task.started','replied':'task.replied','expired':_0x24397a(0xf9)}[_0x290c7a[_0x24397a(0xe9)]],..._0x290c7a};}function j(_0x516c21){const _0x386bb4=a0_0x4b348a;let _0x29bbbb=_0x516c21?.[_0x386bb4(0xde)]||_0x516c21?.[_0x386bb4(0xf2)]||_0x516c21?.['id'];if(_0x29bbbb)return String(_0x29bbbb);let _0xd17211=_0x516c21?.['content']?.[0x0]?.[_0x386bb4(0xd3)];if(typeof _0xd17211!=='string')return null;try{let _0x30b3ab=JSON[_0x386bb4(0xc7)](_0xd17211);return _0x30b3ab?.['task_id']||_0x30b3ab?.[_0x386bb4(0xf2)]||_0x30b3ab?.['id']||null;}catch{return null;}}async function X(_0x3c07a3,_0x57edea){const _0x375076=a0_0x4b348a;let _0x46383c=_0x57edea['now']??Date['now'],_0xb4191f=_0x46383c(),_0x4c3fa4=(_0x2eba23,_0x2b9942,_0x40c7be,_0x5b2193)=>{const _0x47d5a7=a0_0x3f9c;_0x57edea[_0x47d5a7(0xa2)](O(U({'from_alias':_0x3c07a3[_0x47d5a7(0x11b)],'to_alias':_0x3c07a3[_0x47d5a7(0xd5)],'task_id':_0x2b9942,'parent_task_id':_0x3c07a3[_0x47d5a7(0x111)],'network_id':_0x3c07a3[_0x47d5a7(0x104)],'transport':_0x3c07a3[_0x47d5a7(0xd6)],'status':_0x2eba23,'duration_ms':_0x46383c()-_0xb4191f,'lifecycle_tracking':_0x3c07a3['lifecycleTracking'],..._0x40c7be!==void 0x0?{'error_code':_0x5b2193||_0x47d5a7(0x103),'error_message':N(_0x40c7be)}:{}})));};_0x4c3fa4('sending',null);try{let _0x3b3396=await _0x57edea['send'](),_0x561181=j(_0x3b3396);if(_0x561181)_0x4c3fa4(_0x375076(0xbb),_0x561181);else{if(_0x3b3396?.['ok']===!0x1||_0x3b3396?.[_0x375076(0x108)])_0x4c3fa4(_0x375076(0xca),_0x561181,_0x3b3396?.[_0x375076(0x108)]||_0x375076(0x9a),_0x375076(0x101));else _0x4c3fa4(_0x375076(0xca),null,'CommHub\x20response\x20omitted\x20task_id',_0x375076(0xa8));}return _0x3b3396;}catch(_0x28f9a7){throw _0x4c3fa4('failed',null,_0x28f9a7,_0x375076(0x103)),_0x28f9a7;}}function a0_0x3f9c(_0xf6edb5,_0x850273){_0xf6edb5=_0xf6edb5-0x99;const _0x326deb=a0_0x326d();let _0x3f9cb4=_0x326deb[_0xf6edb5];return _0x3f9cb4;}async function Y(_0x2adb31,_0x3dbbb2){const _0x9b6218=a0_0x4b348a;return X({'fromAlias':_0x2adb31['fromAlias'],'toAlias':_0x2adb31['alias'],'parentTaskId':_0x2adb31['parentTaskId']||null,'networkId':_0x2adb31[_0x9b6218(0x104)]||null,'transport':_0x9b6218(0xa0),'lifecycleTracking':'not_tracked'},_0x3dbbb2);}class $ extends a0_0x85eb46{['url'];[a0_0x4b348a(0xe6)];[a0_0x4b348a(0xae)];[a0_0x4b348a(0xe5)];[a0_0x4b348a(0x117)];[a0_0x4b348a(0xfe)];[a0_0x4b348a(0xc9)];['heartbeatTimer'];[a0_0x4b348a(0xe0)];[a0_0x4b348a(0xa4)]=!0x1;constructor(_0x1f893a){const _0x751b84=a0_0x4b348a;super();if(this[_0x751b84(0x9f)]=_0x1f893a[_0x751b84(0x9f)][_0x751b84(0xdd)](/\/$/,''),this[_0x751b84(0xe6)]=_0x1f893a[_0x751b84(0xe6)],this[_0x751b84(0xae)]=_0x1f893a['token'],this[_0x751b84(0xe5)]=_0x1f893a[_0x751b84(0xe5)]||_0x751b84(0xdb),this[_0x751b84(0x117)]=_0x751b84(0xa3)+_0x1f893a[_0x751b84(0xe6)]+'-'+Date[_0x751b84(0x10c)]()[_0x751b84(0xe2)](0x24),this[_0x751b84(0xfe)]=_0x1f893a[_0x751b84(0xfe)]??0x2bf20,this[_0x751b84(0xc9)]=_0x1f893a['reconnectDelay']??0xbb8,_0x1f893a[_0x751b84(0xe3)]!==!0x1)this[_0x751b84(0xa9)]();}[a0_0x4b348a(0xa2)](_0x1e6bd6){const _0x27cb44=a0_0x4b348a;console[_0x27cb44(0xa2)]('['+new Date()[_0x27cb44(0xc1)]()['slice'](0x0,0x8)+_0x27cb44(0x9d)+this['alias']+']\x20'+_0x1e6bd6);}async[a0_0x4b348a(0xed)](_0x5930f5,_0x3f84e8){const _0x3e0ad3=a0_0x4b348a;let _0x589052={'Content-Type':_0x3e0ad3(0x106),'Accept':_0x3e0ad3(0xbf)};if(this[_0x3e0ad3(0xae)])_0x589052['Authorization']=_0x3e0ad3(0x9c)+this[_0x3e0ad3(0xae)];let _0x1020a6=await(await fetch(this[_0x3e0ad3(0x9f)]+'/mcp',{'method':_0x3e0ad3(0xf8),'headers':_0x589052,'body':JSON[_0x3e0ad3(0xcf)]({'jsonrpc':_0x3e0ad3(0xfc),'id':Date[_0x3e0ad3(0x10c)](),'method':_0x3e0ad3(0xfb),'params':{'name':_0x5930f5,'arguments':_0x3f84e8}})}))[_0x3e0ad3(0xd3)](),_0x45e517=_0x1020a6[_0x3e0ad3(0xba)](/data: (.+)/),_0x5c37ed=_0x45e517?JSON[_0x3e0ad3(0xc7)](_0x45e517[0x1]):JSON[_0x3e0ad3(0xc7)](_0x1020a6),_0x714471=_0x5c37ed?.[_0x3e0ad3(0xf1)]?.[_0x3e0ad3(0xea)]?.[0x0]?.['text'];return _0x714471?JSON['parse'](_0x714471):_0x5c37ed;}async[a0_0x4b348a(0xa9)](){const _0x1b5404=a0_0x4b348a;if(this['running'])return;this[_0x1b5404(0xa4)]=!0x0,await this[_0x1b5404(0xe9)](_0x1b5404(0xd9)),this[_0x1b5404(0xa2)]('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x5c736b=_0x1b5404;this[_0x5c736b(0xe9)](_0x5c736b(0xd9))[_0x5c736b(0xdf)](_0x574818=>this[_0x5c736b(0xa2)]('heartbeat\x20failed:\x20'+_0x574818[_0x5c736b(0x115)]));},this[_0x1b5404(0xfe)]),this['connectSSE']();}async[a0_0x4b348a(0xa7)](){const _0xbdf911=a0_0x4b348a;if(this[_0xbdf911(0xa4)]=!0x1,this[_0xbdf911(0xe0)]?.[_0xbdf911(0xd1)](),this['heartbeatTimer'])clearInterval(this[_0xbdf911(0xf3)]);await this[_0xbdf911(0xe9)](_0xbdf911(0xa5))[_0xbdf911(0xdf)](()=>{}),this[_0xbdf911(0xa2)](_0xbdf911(0x112));}async[a0_0x4b348a(0x119)](_0x34b14c,_0x4d2ad9,_0x5277fc='normal'){const _0x4538b3=a0_0x4b348a;return Y({'alias':_0x34b14c,'fromAlias':this[_0x4538b3(0xe6)]},{'log':_0x306e4e=>console[_0x4538b3(0xa2)](_0x306e4e),'send':()=>this['call'](_0x4538b3(0xdc),{'alias':_0x34b14c,'task':_0x4d2ad9,'priority':_0x5277fc,'from_session':this[_0x4538b3(0xe6)]})});}async['message'](_0x5e5d33,_0x146192){const _0x43fe1c=a0_0x4b348a;return this[_0x43fe1c(0xed)](_0x43fe1c(0x109),{'alias':_0x5e5d33,'message':_0x146192,'from_session':this[_0x43fe1c(0xe6)]});}async[a0_0x4b348a(0xe7)](_0x13bd8a,_0xfc3ac9,_0x5a7e15=a0_0x4b348a(0xec)){const _0x5ce771=a0_0x4b348a;return this[_0x5ce771(0xed)](_0x5ce771(0xc0),{'in_reply_to':_0x13bd8a,'text':_0xfc3ac9,'status':_0x5a7e15});}async[a0_0x4b348a(0xe9)](_0x5bf4c6,_0x858058){const _0x109ab9=a0_0x4b348a;return this[_0x109ab9(0xed)](_0x109ab9(0xd0),{'resume_id':this[_0x109ab9(0x117)],'alias':this[_0x109ab9(0xe6)],'status':_0x5bf4c6,'server':a0_0x4c51fd(),'hostname':a0_0x4c51fd(),'agent':this[_0x109ab9(0xe5)],'project_dir':process['cwd'](),..._0x858058});}async['getAllStatus'](){const _0x107bab=a0_0x4b348a;return this['call'](_0x107bab(0xa1),{});}async[a0_0x4b348a(0x113)](_0x511f71,_0x2ce99f){const _0x1229b0=a0_0x4b348a;return this['call'](_0x1229b0(0x113),{'message':_0x511f71,'filter_server':_0x2ce99f?.[_0x1229b0(0x10a)],'filter_status':_0x2ce99f?.[_0x1229b0(0xe9)]});}async[a0_0x4b348a(0x10f)](){const _0x53c1c4=a0_0x4b348a;let _0x5651e3=encodeURIComponent(this['alias']),_0x262bd7=this[_0x53c1c4(0x9f)]+'/events/'+_0x5651e3,_0x54e5f7=this[_0x53c1c4(0xc9)];while(this[_0x53c1c4(0xa4)]){try{this[_0x53c1c4(0xe0)]=new AbortController();let _0x1c2428={'Accept':_0x53c1c4(0xb0)};if(this['token'])_0x1c2428[_0x53c1c4(0x102)]='Bearer\x20'+this['token'];let _0x346063=await fetch(_0x262bd7,{'headers':_0x1c2428,'signal':this[_0x53c1c4(0xe0)][_0x53c1c4(0xd2)]});if(!_0x346063['ok']||!_0x346063[_0x53c1c4(0xb9)]){this[_0x53c1c4(0xa2)](_0x53c1c4(0xe4)+_0x346063['status']),await this[_0x53c1c4(0xf7)](_0x54e5f7),_0x54e5f7=Math[_0x53c1c4(0xee)](_0x54e5f7*1.5,0xea60);continue;}_0x54e5f7=this[_0x53c1c4(0xc9)];let _0x58c286=_0x346063[_0x53c1c4(0xb9)][_0x53c1c4(0xbe)](),_0x5f2197=new TextDecoder(),_0x12eeb3='';while(this['running']){let {done:_0x19c272,value:_0x14c8d0}=await _0x58c286[_0x53c1c4(0xad)]();if(_0x19c272)break;_0x12eeb3+=_0x5f2197['decode'](_0x14c8d0,{'stream':!0x0});let _0x3bd007=_0x12eeb3[_0x53c1c4(0xc8)]('\x0a');_0x12eeb3=_0x3bd007[_0x53c1c4(0xac)]()||'';for(let _0x2aad55 of _0x3bd007){if(!_0x2aad55[_0x53c1c4(0xce)](_0x53c1c4(0x10e)))continue;try{let _0x3424db=JSON[_0x53c1c4(0xc7)](_0x2aad55[_0x53c1c4(0xb7)](0x6));if(_0x3424db['type']===_0x53c1c4(0xa6)){this['log'](_0x53c1c4(0xb8)),this['emit']('connected');continue;}if(_0x3424db[_0x53c1c4(0x99)]===_0x53c1c4(0xbc)||_0x3424db['type']===_0x53c1c4(0xaf)||_0x3424db[_0x53c1c4(0x99)]===_0x53c1c4(0x113))await this[_0x53c1c4(0xda)]();}catch{}}}}catch(_0x9e7289){if(_0x9e7289[_0x53c1c4(0xd7)]===_0x53c1c4(0xff))break;this[_0x53c1c4(0xc4)](_0x53c1c4(0x108),_0x9e7289),this[_0x53c1c4(0xa2)]('SSE\x20error:\x20'+_0x9e7289[_0x53c1c4(0x115)]);}if(this[_0x53c1c4(0xa4)])this[_0x53c1c4(0xc4)](_0x53c1c4(0x112)),this['log'](_0x53c1c4(0xef)+_0x54e5f7/0x3e8+_0x53c1c4(0x116)),await this[_0x53c1c4(0xf7)](_0x54e5f7),_0x54e5f7=Math[_0x53c1c4(0xee)](_0x54e5f7*1.5,0xea60);}}async['processInbox'](){const _0x3a1440=a0_0x4b348a;try{let _0x1a1306=(await this[_0x3a1440(0xed)](_0x3a1440(0xf5),{'alias':this[_0x3a1440(0xe6)],'limit':0xa}))?.[_0x3a1440(0x100)]||[];for(let _0x184855 of _0x1a1306)await this[_0x3a1440(0xed)](_0x3a1440(0x110),{'alias':this[_0x3a1440(0xe6)],'message_id':_0x184855['id']}),this[_0x3a1440(0xa2)]('←\x20'+_0x184855['from_session']+':\x20'+_0x184855[_0x3a1440(0xea)][_0x3a1440(0xb7)](0x0,0x3c)),this[_0x3a1440(0xc4)](_0x3a1440(0xc6),_0x184855),this[_0x3a1440(0xc4)]('message',_0x184855);}catch(_0x3fee8b){this['log'](_0x3a1440(0xe1)+_0x3fee8b['message']);}}[a0_0x4b348a(0xf7)](_0x49d921){return new Promise(_0x586c06=>setTimeout(_0x586c06,_0x49d921));}}var F=$;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
|
+
};
|