@sleep2agi/agent-network 2.3.0-preview.130 → 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 +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_0x54dcea=a0_0x3c4d;(function(_0x2dce84,_0x5d2160){const _0x3bad70=a0_0x3c4d,_0x4a79ce=_0x2dce84();while(!![]){try{const _0x1366c9=-parseInt(_0x3bad70(0x13c))/0x1+parseInt(_0x3bad70(0x182))/0x2*(-parseInt(_0x3bad70(0x174))/0x3)+parseInt(_0x3bad70(0x11b))/0x4*(parseInt(_0x3bad70(0x19d))/0x5)+parseInt(_0x3bad70(0x126))/0x6*(parseInt(_0x3bad70(0x141))/0x7)+-parseInt(_0x3bad70(0x18a))/0x8*(parseInt(_0x3bad70(0x140))/0x9)+parseInt(_0x3bad70(0x172))/0xa+-parseInt(_0x3bad70(0x13a))/0xb*(parseInt(_0x3bad70(0x185))/0xc);if(_0x1366c9===_0x5d2160)break;else _0x4a79ce['push'](_0x4a79ce['shift']());}catch(_0x3a6238){_0x4a79ce['push'](_0x4a79ce['shift']());}}}(a0_0x5a1a,0x4fbc3));import{EventEmitter as a0_0x236648}from'events';function a0_0x3c4d(_0x25d33f,_0x18f813){_0x25d33f=_0x25d33f-0x11b;const _0x5a1a5c=a0_0x5a1a();let _0x3c4d8b=_0x5a1a5c[_0x25d33f];return _0x3c4d8b;}import{hostname as a0_0x47ae1d}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x25b62d,_0x3f933b)=>(_0x25b62d??_0x3f933b)[a0_0x54dcea(0x19b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x54dcea(0x193)](0x0,0xf0);function N(_0x4d7650){const _0x4335c4=a0_0x54dcea;return(_0x4d7650 instanceof Error?_0x4d7650[_0x4335c4(0x17e)]:String(_0x4d7650??'unknown\x20error'))[_0x4335c4(0x19b)](K,_0x4335c4(0x146))[_0x4335c4(0x19b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x4335c4(0x193)](0x0,0xf0);}function O(_0x2d484f,_0x34db13=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x3e7023=a0_0x54dcea;if(_0x34db13)return JSON[_0x3e7023(0x189)](_0x2d484f);let _0x8aeff1=L(_0x2d484f[_0x3e7023(0x15d)],_0x3e7023(0x12f)),_0x4c1f50=L(_0x2d484f['task_id'],_0x3e7023(0x143)),_0x26cb6b=_0x2d484f['error_code']?_0x3e7023(0x181)+_0x2d484f[_0x3e7023(0x17c)]+':'+(_0x2d484f[_0x3e7023(0x11e)]??''):'';return _0x3e7023(0x12b)+_0x2d484f[_0x3e7023(0x16c)]+'\x20from='+L(_0x2d484f['from_alias'],_0x3e7023(0x132))+_0x3e7023(0x164)+L(_0x2d484f[_0x3e7023(0x170)],_0x3e7023(0x132))+'\x20task_id='+_0x4c1f50+_0x3e7023(0x154)+_0x8aeff1+_0x3e7023(0x15a)+L(_0x2d484f[_0x3e7023(0x16d)],'<unknown>')+_0x3e7023(0x124)+_0x2d484f[_0x3e7023(0x125)]+'\x20duration_ms='+_0x2d484f[_0x3e7023(0x178)]+_0x3e7023(0x12a)+_0x2d484f[_0x3e7023(0x186)]+_0x26cb6b;}function U(_0x379a26){const _0x2a0914=a0_0x54dcea;return{'event':{'sending':_0x2a0914(0x17f),'delivered':_0x2a0914(0x14b),'failed':_0x2a0914(0x177),'acked':_0x2a0914(0x175),'started':_0x2a0914(0x153),'replied':_0x2a0914(0x14e),'expired':'task.expired'}[_0x379a26[_0x2a0914(0x16c)]],..._0x379a26};}function j(_0x1a4622){const _0x411e00=a0_0x54dcea;let _0x506af2=_0x1a4622?.[_0x411e00(0x11c)]||_0x1a4622?.[_0x411e00(0x160)]||_0x1a4622?.['id'];if(_0x506af2)return String(_0x506af2);let _0x4bb7e1=_0x1a4622?.[_0x411e00(0x18f)]?.[0x0]?.[_0x411e00(0x16f)];if(typeof _0x4bb7e1!==_0x411e00(0x17d))return null;try{let _0x2fc3da=JSON['parse'](_0x4bb7e1);return _0x2fc3da?.[_0x411e00(0x11c)]||_0x2fc3da?.[_0x411e00(0x160)]||_0x2fc3da?.['id']||null;}catch{return null;}}async function X(_0x57c2d2,_0x1f2941){const _0x58a73c=a0_0x54dcea;let _0x5d8629=_0x1f2941['now']??Date[_0x58a73c(0x183)],_0x21fd68=_0x5d8629(),_0x4e84be=(_0x4ed604,_0x36bb57,_0x3e586f,_0x3f3f6b)=>{const _0x2ec303=_0x58a73c;_0x1f2941[_0x2ec303(0x158)](O(U({'from_alias':_0x57c2d2[_0x2ec303(0x168)],'to_alias':_0x57c2d2['toAlias'],'task_id':_0x36bb57,'parent_task_id':_0x57c2d2[_0x2ec303(0x142)],'network_id':_0x57c2d2['networkId'],'transport':_0x57c2d2[_0x2ec303(0x125)],'status':_0x4ed604,'duration_ms':_0x5d8629()-_0x21fd68,'lifecycle_tracking':_0x57c2d2[_0x2ec303(0x138)],..._0x3e586f!==void 0x0?{'error_code':_0x3f3f6b||_0x2ec303(0x15b),'error_message':N(_0x3e586f)}:{}})));};_0x4e84be(_0x58a73c(0x1a0),null);try{let _0x3b5ebe=await _0x1f2941[_0x58a73c(0x162)](),_0x9ff2c7=j(_0x3b5ebe);if(_0x9ff2c7)_0x4e84be(_0x58a73c(0x122),_0x9ff2c7);else{if(_0x3b5ebe?.['ok']===!0x1||_0x3b5ebe?.[_0x58a73c(0x144)])_0x4e84be(_0x58a73c(0x198),_0x9ff2c7,_0x3b5ebe?.['error']||'CommHub\x20rejected\x20task',_0x58a73c(0x199));else _0x4e84be(_0x58a73c(0x198),null,_0x58a73c(0x134),_0x58a73c(0x17b));}return _0x3b5ebe;}catch(_0x2d5ab5){throw _0x4e84be(_0x58a73c(0x198),null,_0x2d5ab5,_0x58a73c(0x15b)),_0x2d5ab5;}}function a0_0x5a1a(){const _0x56f4d4=['parse','task.replied','idle','connected','normal','sleep','task.started','\x20parent_task_id=','SSE\x20reconnecting\x20in\x20','POST','agent','log','catch','\x20network_id=','send_failed','SSE\x20connected','parent_task_id','abort','startsWith','message_id','task','send','match','\x20to=','s...','autoConnect','tools/call','fromAlias','/events/','2.0','connect','status','network_id','result','text','to_alias','signal','1305230RErtzb','offline','1667661lKYvZW','task.ack','not_tracked','task.send.failed','duration_ms','emit','body','missing_task_id','error_code','string','message','task.send.start','pop','\x20error=','2TlYDfV','now','new_message','796788LvoNeW','lifecycle_tracking','cwd','broadcast','stringify','8QdXrmK','SSE\x20error:\x20','min','ack_inbox','send_message','content','heartbeatTimer','heartbeatInterval','registered','slice','AbortError','disconnected','application/json','alias','failed','send_rejected','token','replace','new_task','10szIxyH','processInbox','split','sending','881404PDWoXD','task_id','text/event-stream','error_message','sseAbort','type','/mcp','delivered','inbox\x20error:\x20','\x20transport=','transport','1006554lhsSna','reconnectDelay','disconnect','send_reply','\x20lifecycle=','[commhub:task]\x20','Bearer\x20','networkId','name','<missing>','mcp_http','get_inbox','<unknown>','call','CommHub\x20response\x20omitted\x20task_id','completed','connectSSE','from_session','lifecycleTracking','getReader','22NEZJlr','Authorization','13173TkQpMY','report_status','sdk','resumeId','414441igXdDn','21hWSJAA','parentTaskId','<pending>','error','url','[REDACTED]','decode','data:\x20','heartbeat\x20failed:\x20','read','task.send.delivered','running'];a0_0x5a1a=function(){return _0x56f4d4;};return a0_0x5a1a();}async function Y(_0x1ff4e9,_0x1016cc){const _0x164cfa=a0_0x54dcea;return X({'fromAlias':_0x1ff4e9['fromAlias'],'toAlias':_0x1ff4e9['alias'],'parentTaskId':_0x1ff4e9[_0x164cfa(0x142)]||null,'networkId':_0x1ff4e9[_0x164cfa(0x12d)]||null,'transport':_0x164cfa(0x130),'lifecycleTracking':_0x164cfa(0x176)},_0x1016cc);}class $ extends a0_0x236648{[a0_0x54dcea(0x145)];[a0_0x54dcea(0x197)];[a0_0x54dcea(0x19a)];[a0_0x54dcea(0x157)];[a0_0x54dcea(0x13f)];['heartbeatInterval'];[a0_0x54dcea(0x127)];['heartbeatTimer'];[a0_0x54dcea(0x11f)];[a0_0x54dcea(0x14c)]=!0x1;constructor(_0x185603){const _0x384373=a0_0x54dcea;super();if(this['url']=_0x185603['url'][_0x384373(0x19b)](/\/$/,''),this[_0x384373(0x197)]=_0x185603[_0x384373(0x197)],this[_0x384373(0x19a)]=_0x185603[_0x384373(0x19a)],this[_0x384373(0x157)]=_0x185603[_0x384373(0x157)]||_0x384373(0x13e),this[_0x384373(0x13f)]='sdk-'+_0x185603['alias']+'-'+Date[_0x384373(0x183)]()['toString'](0x24),this[_0x384373(0x191)]=_0x185603[_0x384373(0x191)]??0x2bf20,this[_0x384373(0x127)]=_0x185603[_0x384373(0x127)]??0xbb8,_0x185603[_0x384373(0x166)]!==!0x1)this['connect']();}[a0_0x54dcea(0x158)](_0x40195a){const _0x3d6bdb=a0_0x54dcea;console[_0x3d6bdb(0x158)]('['+new Date()['toTimeString']()[_0x3d6bdb(0x193)](0x0,0x8)+']\x20[commhub:'+this[_0x3d6bdb(0x197)]+']\x20'+_0x40195a);}async[a0_0x54dcea(0x133)](_0x447676,_0x556eb2){const _0x5b4e3c=a0_0x54dcea;let _0xf0dcd7={'Content-Type':_0x5b4e3c(0x196),'Accept':'application/json,\x20text/event-stream'};if(this[_0x5b4e3c(0x19a)])_0xf0dcd7['Authorization']=_0x5b4e3c(0x12c)+this[_0x5b4e3c(0x19a)];let _0x1af82c=await(await fetch(this[_0x5b4e3c(0x145)]+_0x5b4e3c(0x121),{'method':_0x5b4e3c(0x156),'headers':_0xf0dcd7,'body':JSON['stringify']({'jsonrpc':_0x5b4e3c(0x16a),'id':Date[_0x5b4e3c(0x183)](),'method':_0x5b4e3c(0x167),'params':{'name':_0x447676,'arguments':_0x556eb2}})}))['text'](),_0x4f7ecf=_0x1af82c[_0x5b4e3c(0x163)](/data: (.+)/),_0x251b83=_0x4f7ecf?JSON[_0x5b4e3c(0x14d)](_0x4f7ecf[0x1]):JSON[_0x5b4e3c(0x14d)](_0x1af82c),_0x2466df=_0x251b83?.[_0x5b4e3c(0x16e)]?.['content']?.[0x0]?.[_0x5b4e3c(0x16f)];return _0x2466df?JSON[_0x5b4e3c(0x14d)](_0x2466df):_0x251b83;}async[a0_0x54dcea(0x16b)](){const _0x25c9c6=a0_0x54dcea;if(this[_0x25c9c6(0x14c)])return;this[_0x25c9c6(0x14c)]=!0x0,await this[_0x25c9c6(0x16c)](_0x25c9c6(0x14f)),this[_0x25c9c6(0x158)](_0x25c9c6(0x192)),this[_0x25c9c6(0x190)]=setInterval(()=>{const _0x24036c=_0x25c9c6;this[_0x24036c(0x16c)](_0x24036c(0x14f))[_0x24036c(0x159)](_0x16480e=>this[_0x24036c(0x158)](_0x24036c(0x149)+_0x16480e[_0x24036c(0x17e)]));},this[_0x25c9c6(0x191)]),this[_0x25c9c6(0x136)]();}async[a0_0x54dcea(0x128)](){const _0x25e17a=a0_0x54dcea;if(this[_0x25e17a(0x14c)]=!0x1,this[_0x25e17a(0x11f)]?.[_0x25e17a(0x15e)](),this[_0x25e17a(0x190)])clearInterval(this[_0x25e17a(0x190)]);await this[_0x25e17a(0x16c)](_0x25e17a(0x173))[_0x25e17a(0x159)](()=>{}),this['log']('disconnected');}async['send'](_0x30915a,_0x1981cb,_0x545311=a0_0x54dcea(0x151)){const _0x28739c=a0_0x54dcea;return Y({'alias':_0x30915a,'fromAlias':this[_0x28739c(0x197)]},{'log':_0x42ca47=>console[_0x28739c(0x158)](_0x42ca47),'send':()=>this[_0x28739c(0x133)]('send_task',{'alias':_0x30915a,'task':_0x1981cb,'priority':_0x545311,'from_session':this[_0x28739c(0x197)]})});}async[a0_0x54dcea(0x17e)](_0x400bcd,_0x332e31){const _0x33de38=a0_0x54dcea;return this[_0x33de38(0x133)](_0x33de38(0x18e),{'alias':_0x400bcd,'message':_0x332e31,'from_session':this[_0x33de38(0x197)]});}async['reply'](_0x3fd746,_0x3c998d,_0x31da76=a0_0x54dcea(0x135)){const _0x4fe890=a0_0x54dcea;return this[_0x4fe890(0x133)](_0x4fe890(0x129),{'in_reply_to':_0x3fd746,'text':_0x3c998d,'status':_0x31da76});}async[a0_0x54dcea(0x16c)](_0x3680e6,_0x1496c4){const _0x5797f2=a0_0x54dcea;return this['call'](_0x5797f2(0x13d),{'resume_id':this[_0x5797f2(0x13f)],'alias':this['alias'],'status':_0x3680e6,'server':a0_0x47ae1d(),'hostname':a0_0x47ae1d(),'agent':this[_0x5797f2(0x157)],'project_dir':process[_0x5797f2(0x187)](),..._0x1496c4});}async['getAllStatus'](){const _0x5c2dee=a0_0x54dcea;return this[_0x5c2dee(0x133)]('get_all_status',{});}async['broadcast'](_0x982f52,_0x4b84aa){const _0x42f36c=a0_0x54dcea;return this[_0x42f36c(0x133)](_0x42f36c(0x188),{'message':_0x982f52,'filter_server':_0x4b84aa?.['server'],'filter_status':_0x4b84aa?.[_0x42f36c(0x16c)]});}async[a0_0x54dcea(0x136)](){const _0x25899d=a0_0x54dcea;let _0x3b06f7=encodeURIComponent(this[_0x25899d(0x197)]),_0x51a0a0=this['url']+_0x25899d(0x169)+_0x3b06f7,_0x3a27e1=this['reconnectDelay'];while(this[_0x25899d(0x14c)]){try{this['sseAbort']=new AbortController();let _0x3c3991={'Accept':_0x25899d(0x11d)};if(this['token'])_0x3c3991[_0x25899d(0x13b)]=_0x25899d(0x12c)+this[_0x25899d(0x19a)];let _0x256473=await fetch(_0x51a0a0,{'headers':_0x3c3991,'signal':this[_0x25899d(0x11f)][_0x25899d(0x171)]});if(!_0x256473['ok']||!_0x256473[_0x25899d(0x17a)]){this['log']('SSE\x20failed:\x20'+_0x256473[_0x25899d(0x16c)]),await this[_0x25899d(0x152)](_0x3a27e1),_0x3a27e1=Math[_0x25899d(0x18c)](_0x3a27e1*1.5,0xea60);continue;}_0x3a27e1=this[_0x25899d(0x127)];let _0x480cf3=_0x256473[_0x25899d(0x17a)][_0x25899d(0x139)](),_0x2a5636=new TextDecoder(),_0x22599f='';while(this[_0x25899d(0x14c)]){let {done:_0x2e6050,value:_0x4d98c6}=await _0x480cf3[_0x25899d(0x14a)]();if(_0x2e6050)break;_0x22599f+=_0x2a5636[_0x25899d(0x147)](_0x4d98c6,{'stream':!0x0});let _0x6cd1c1=_0x22599f[_0x25899d(0x19f)]('\x0a');_0x22599f=_0x6cd1c1[_0x25899d(0x180)]()||'';for(let _0x3bd05b of _0x6cd1c1){if(!_0x3bd05b[_0x25899d(0x15f)](_0x25899d(0x148)))continue;try{let _0xe20962=JSON['parse'](_0x3bd05b[_0x25899d(0x193)](0x6));if(_0xe20962[_0x25899d(0x120)]===_0x25899d(0x150)){this[_0x25899d(0x158)](_0x25899d(0x15c)),this[_0x25899d(0x179)]('connected');continue;}if(_0xe20962[_0x25899d(0x120)]===_0x25899d(0x19c)||_0xe20962[_0x25899d(0x120)]===_0x25899d(0x184)||_0xe20962['type']===_0x25899d(0x188))await this[_0x25899d(0x19e)]();}catch{}}}}catch(_0xe19233){if(_0xe19233[_0x25899d(0x12e)]===_0x25899d(0x194))break;this[_0x25899d(0x179)]('error',_0xe19233),this[_0x25899d(0x158)](_0x25899d(0x18b)+_0xe19233[_0x25899d(0x17e)]);}if(this['running'])this[_0x25899d(0x179)](_0x25899d(0x195)),this['log'](_0x25899d(0x155)+_0x3a27e1/0x3e8+_0x25899d(0x165)),await this[_0x25899d(0x152)](_0x3a27e1),_0x3a27e1=Math['min'](_0x3a27e1*1.5,0xea60);}}async['processInbox'](){const _0x4c9e71=a0_0x54dcea;try{let _0x14b0ea=(await this[_0x4c9e71(0x133)](_0x4c9e71(0x131),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x3856bb of _0x14b0ea)await this[_0x4c9e71(0x133)](_0x4c9e71(0x18d),{'alias':this[_0x4c9e71(0x197)],'message_id':_0x3856bb['id']}),this['log']('←\x20'+_0x3856bb[_0x4c9e71(0x137)]+':\x20'+_0x3856bb[_0x4c9e71(0x18f)][_0x4c9e71(0x193)](0x0,0x3c)),this['emit'](_0x4c9e71(0x161),_0x3856bb),this[_0x4c9e71(0x179)](_0x4c9e71(0x17e),_0x3856bb);}catch(_0xed40aa){this[_0x4c9e71(0x158)](_0x4c9e71(0x123)+_0xed40aa['message']);}}[a0_0x54dcea(0x152)](_0x5cd5c4){return new Promise(_0x495dd1=>setTimeout(_0x495dd1,_0x5cd5c4));}}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
|
+
};
|