@sleep2agi/agent-network 2.3.0-preview.129 → 2.3.0-preview.130

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.
@@ -0,0 +1,41 @@
1
+ export declare const PEER_REPLY_TOOL_NAME = "commhub_send_peer_reply";
2
+ export interface ChannelPeerReplyInput {
3
+ task_id?: unknown;
4
+ text?: unknown;
5
+ status?: unknown;
6
+ alias?: unknown;
7
+ }
8
+ export interface ChannelPeerReplyDeps {
9
+ /** One Hub MCP tool call. Returns the parsed tool payload (ok:false on rejection); may throw on transport failure. */
10
+ call: (tool: string, args: Record<string, unknown>) => Promise<any>;
11
+ fromAlias: string;
12
+ /** Sender alias the channel recorded when it injected this task_id (in-memory; may be unknown after a restart). */
13
+ originatorOf?: (taskId: string) => string | undefined;
14
+ /** channel meta task_id is the inbox ROW id; map it to the logical tasks.task_id when known. */
15
+ logicalTaskIdOf?: (taskId: string) => string | undefined;
16
+ }
17
+ export type ChannelPeerReplyRoute = "atomic" | "wake-then-close" | "reply-only";
18
+ export interface ChannelPeerReplyResult {
19
+ ok: boolean;
20
+ route?: ChannelPeerReplyRoute;
21
+ /** The original task is now terminal. */
22
+ closed: boolean;
23
+ /** A wake was delivered to the peer (atomic result row or fallback send_task). */
24
+ woke: boolean;
25
+ task_id?: string;
26
+ error?: string;
27
+ message?: string;
28
+ wake_task_id?: string | null;
29
+ fallback_reason?: string;
30
+ upstream?: unknown;
31
+ }
32
+ /** The Hub rejected the ATOMIC route for a capability reason and wrote nothing. */
33
+ export declare function peerReplyFallbackReason(payload: any): string | null;
34
+ export declare function validatePeerReplyInput(input: ChannelPeerReplyInput): {
35
+ ok: true;
36
+ taskId: string;
37
+ text: string;
38
+ status: "completed" | "failed";
39
+ alias?: string;
40
+ } | ChannelPeerReplyResult;
41
+ export declare function sendChannelPeerReply(input: ChannelPeerReplyInput, deps: ChannelPeerReplyDeps): Promise<ChannelPeerReplyResult>;
@@ -1 +1 @@
1
- const a0_0x5d395c=a0_0x5553;(function(_0x2049ca,_0x45eabd){const _0x5edff4=a0_0x5553,_0x2471e0=_0x2049ca();while(!![]){try{const _0x18c5b8=-parseInt(_0x5edff4(0x1b0))/0x1+parseInt(_0x5edff4(0x169))/0x2+parseInt(_0x5edff4(0x199))/0x3*(-parseInt(_0x5edff4(0x1b2))/0x4)+-parseInt(_0x5edff4(0x1ab))/0x5+-parseInt(_0x5edff4(0x17b))/0x6+parseInt(_0x5edff4(0x1ba))/0x7*(parseInt(_0x5edff4(0x187))/0x8)+-parseInt(_0x5edff4(0x1b1))/0x9*(-parseInt(_0x5edff4(0x19e))/0xa);if(_0x18c5b8===_0x45eabd)break;else _0x2471e0['push'](_0x2471e0['shift']());}catch(_0x148236){_0x2471e0['push'](_0x2471e0['shift']());}}}(a0_0x38f4,0xe213f));import{EventEmitter as a0_0x196e24}from'events';import{hostname as a0_0x5b7e5c}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x54381c,_0x6b108)=>(_0x54381c??_0x6b108)[a0_0x5d395c(0x192)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5d395c(0x18f)](0x0,0xf0);function N(_0x2204ec){const _0x1642f2=a0_0x5d395c;return(_0x2204ec instanceof Error?_0x2204ec['message']:String(_0x2204ec??_0x1642f2(0x1aa)))[_0x1642f2(0x192)](K,'[REDACTED]')[_0x1642f2(0x192)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x1642f2(0x18f)](0x0,0xf0);}function O(_0x21bbe4,_0x33c7b2=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5d395c(0x196)){const _0x1a3ab8=a0_0x5d395c;if(_0x33c7b2)return JSON[_0x1a3ab8(0x195)](_0x21bbe4);let _0xc75d90=L(_0x21bbe4[_0x1a3ab8(0x1d8)],'<missing>'),_0x56665e=L(_0x21bbe4[_0x1a3ab8(0x1ce)],_0x1a3ab8(0x17e)),_0xf61e8d=_0x21bbe4['error_code']?_0x1a3ab8(0x185)+_0x21bbe4[_0x1a3ab8(0x18e)]+':'+(_0x21bbe4[_0x1a3ab8(0x1d9)]??''):'';return _0x1a3ab8(0x190)+_0x21bbe4[_0x1a3ab8(0x17d)]+_0x1a3ab8(0x179)+L(_0x21bbe4[_0x1a3ab8(0x16c)],'<unknown>')+_0x1a3ab8(0x1b3)+L(_0x21bbe4[_0x1a3ab8(0x163)],'<unknown>')+_0x1a3ab8(0x186)+_0x56665e+_0x1a3ab8(0x1df)+_0xc75d90+_0x1a3ab8(0x181)+L(_0x21bbe4[_0x1a3ab8(0x1cc)],_0x1a3ab8(0x1c3))+_0x1a3ab8(0x1cf)+_0x21bbe4[_0x1a3ab8(0x171)]+_0x1a3ab8(0x17c)+_0x21bbe4[_0x1a3ab8(0x1a4)]+'\x20lifecycle='+_0x21bbe4[_0x1a3ab8(0x176)]+_0xf61e8d;}function a0_0x5553(_0x28fb70,_0x5144cc){_0x28fb70=_0x28fb70-0x163;const _0x38f4d2=a0_0x38f4();let _0x55531b=_0x38f4d2[_0x28fb70];return _0x55531b;}function U(_0x1f7330){const _0x324411=a0_0x5d395c;return{'event':{'sending':_0x324411(0x174),'delivered':_0x324411(0x188),'failed':_0x324411(0x1da),'acked':'task.ack','started':_0x324411(0x18d),'replied':'task.replied','expired':_0x324411(0x1c2)}[_0x1f7330[_0x324411(0x17d)]],..._0x1f7330};}function j(_0x564ff4){const _0x5208d0=a0_0x5d395c;let _0x14e6f6=_0x564ff4?.[_0x5208d0(0x1ce)]||_0x564ff4?.[_0x5208d0(0x16a)]||_0x564ff4?.['id'];if(_0x14e6f6)return String(_0x14e6f6);let _0x304575=_0x564ff4?.['content']?.[0x0]?.[_0x5208d0(0x1e1)];if(typeof _0x304575!==_0x5208d0(0x1e3))return null;try{let _0x8ad82=JSON['parse'](_0x304575);return _0x8ad82?.[_0x5208d0(0x1ce)]||_0x8ad82?.[_0x5208d0(0x16a)]||_0x8ad82?.['id']||null;}catch{return null;}}function a0_0x38f4(){const _0x361af7=['parse','startsWith','heartbeatInterval','application/json','duration_ms','send','2.0','min','autoConnect','tools/call','unknown\x20error','3541230QDcQyA','resumeId','mcp_http','toString','running','974262jYDCvE','5382TjTgOX','4xlNYrn','\x20to=','content','emit','catch','alias','message','send_message','7pfAgSh','text/event-stream','sdk-','not_tracked','new_message','type','processInbox','heartbeatTimer','task.expired','<unknown>','SSE\x20reconnecting\x20in\x20','token','fromAlias','name','new_task','broadcast','CommHub\x20response\x20omitted\x20task_id','registered','network_id','networkId','task_id','\x20transport=','connectSSE','reply','url','lifecycleTracking','server','sleep','signal','normal','parent_task_id','error_message','task.send.failed','report_status','idle','decode','body','\x20parent_task_id=','pop','text','read','string','Authorization','match','to_alias','reconnectDelay','send_failed','offline','disconnect','sending','50194yPEaKY','message_id','POST','from_alias','log','SSE\x20error:\x20','AbortError','connected','transport','cwd','abort','task.send.start','data:\x20','lifecycle_tracking','call','application/json,\x20text/event-stream','\x20from=','agent','256128nShGLQ','\x20duration_ms=','status','<pending>','now','SSE\x20connected','\x20network_id=','getReader','heartbeat\x20failed:\x20','get_all_status','\x20error=','\x20task_id=','12239320xOiFiK','task.send.delivered','s...','parentTaskId','error','ack_inbox','task.started','error_code','slice','[commhub:task]\x20','disconnected','replace','SSE\x20failed:\x20','sseAbort','stringify','json','from_session','connect','4897425SLXthQ','/mcp','result','Bearer\x20','completed','45630EFmfdp','send_reply'];a0_0x38f4=function(){return _0x361af7;};return a0_0x38f4();}async function X(_0x227264,_0x542aa6){const _0x1104a9=a0_0x5d395c;let _0x33c353=_0x542aa6[_0x1104a9(0x17f)]??Date['now'],_0x44ce08=_0x33c353(),_0x3816d3=(_0xb09f31,_0x5d10bd,_0xdabd1a,_0x403648)=>{const _0xd96912=_0x1104a9;_0x542aa6[_0xd96912(0x16d)](O(U({'from_alias':_0x227264[_0xd96912(0x1c6)],'to_alias':_0x227264['toAlias'],'task_id':_0x5d10bd,'parent_task_id':_0x227264['parentTaskId'],'network_id':_0x227264[_0xd96912(0x1cd)],'transport':_0x227264[_0xd96912(0x171)],'status':_0xb09f31,'duration_ms':_0x33c353()-_0x44ce08,'lifecycle_tracking':_0x227264[_0xd96912(0x1d3)],..._0xdabd1a!==void 0x0?{'error_code':_0x403648||'send_failed','error_message':N(_0xdabd1a)}:{}})));};_0x3816d3(_0x1104a9(0x168),null);try{let _0x3d7961=await _0x542aa6[_0x1104a9(0x1a5)](),_0x5aa0a2=j(_0x3d7961);if(_0x5aa0a2)_0x3816d3('delivered',_0x5aa0a2);else{if(_0x3d7961?.['ok']===!0x1||_0x3d7961?.[_0x1104a9(0x18b)])_0x3816d3('failed',_0x5aa0a2,_0x3d7961?.[_0x1104a9(0x18b)]||'CommHub\x20rejected\x20task','send_rejected');else _0x3816d3('failed',null,_0x1104a9(0x1ca),'missing_task_id');}return _0x3d7961;}catch(_0x4b74a5){throw _0x3816d3('failed',null,_0x4b74a5,_0x1104a9(0x165)),_0x4b74a5;}}async function Y(_0x157924,_0x25771c){const _0x13f564=a0_0x5d395c;return X({'fromAlias':_0x157924['fromAlias'],'toAlias':_0x157924['alias'],'parentTaskId':_0x157924[_0x13f564(0x18a)]||null,'networkId':_0x157924[_0x13f564(0x1cd)]||null,'transport':_0x13f564(0x1ad),'lifecycleTracking':_0x13f564(0x1bd)},_0x25771c);}class $ extends a0_0x196e24{['url'];[a0_0x5d395c(0x1b7)];[a0_0x5d395c(0x1c5)];['agent'];[a0_0x5d395c(0x1ac)];[a0_0x5d395c(0x1a2)];[a0_0x5d395c(0x164)];[a0_0x5d395c(0x1c1)];[a0_0x5d395c(0x194)];[a0_0x5d395c(0x1af)]=!0x1;constructor(_0x5e6142){const _0xc215d=a0_0x5d395c;super();if(this['url']=_0x5e6142[_0xc215d(0x1d2)][_0xc215d(0x192)](/\/$/,''),this['alias']=_0x5e6142[_0xc215d(0x1b7)],this[_0xc215d(0x1c5)]=_0x5e6142[_0xc215d(0x1c5)],this[_0xc215d(0x17a)]=_0x5e6142[_0xc215d(0x17a)]||'sdk',this[_0xc215d(0x1ac)]=_0xc215d(0x1bc)+_0x5e6142['alias']+'-'+Date[_0xc215d(0x17f)]()[_0xc215d(0x1ae)](0x24),this['heartbeatInterval']=_0x5e6142[_0xc215d(0x1a2)]??0x2bf20,this['reconnectDelay']=_0x5e6142[_0xc215d(0x164)]??0xbb8,_0x5e6142[_0xc215d(0x1a8)]!==!0x1)this['connect']();}['log'](_0x1d34cb){const _0x45bdee=a0_0x5d395c;console[_0x45bdee(0x16d)]('['+new Date()['toTimeString']()[_0x45bdee(0x18f)](0x0,0x8)+']\x20[commhub:'+this[_0x45bdee(0x1b7)]+']\x20'+_0x1d34cb);}async[a0_0x5d395c(0x177)](_0x1a0154,_0x3b160d){const _0x4d2c71=a0_0x5d395c;let _0xf4fc88={'Content-Type':_0x4d2c71(0x1a3),'Accept':_0x4d2c71(0x178)};if(this[_0x4d2c71(0x1c5)])_0xf4fc88[_0x4d2c71(0x1e4)]=_0x4d2c71(0x19c)+this['token'];let _0x42ebbe=await(await fetch(this[_0x4d2c71(0x1d2)]+_0x4d2c71(0x19a),{'method':_0x4d2c71(0x16b),'headers':_0xf4fc88,'body':JSON[_0x4d2c71(0x195)]({'jsonrpc':_0x4d2c71(0x1a6),'id':Date[_0x4d2c71(0x17f)](),'method':_0x4d2c71(0x1a9),'params':{'name':_0x1a0154,'arguments':_0x3b160d}})}))[_0x4d2c71(0x1e1)](),_0x5caac1=_0x42ebbe[_0x4d2c71(0x1e5)](/data: (.+)/),_0x14b072=_0x5caac1?JSON[_0x4d2c71(0x1a0)](_0x5caac1[0x1]):JSON[_0x4d2c71(0x1a0)](_0x42ebbe),_0x3af791=_0x14b072?.[_0x4d2c71(0x19b)]?.[_0x4d2c71(0x1b4)]?.[0x0]?.['text'];return _0x3af791?JSON[_0x4d2c71(0x1a0)](_0x3af791):_0x14b072;}async[a0_0x5d395c(0x198)](){const _0x899f13=a0_0x5d395c;if(this['running'])return;this['running']=!0x0,await this[_0x899f13(0x17d)]('idle'),this[_0x899f13(0x16d)](_0x899f13(0x1cb)),this[_0x899f13(0x1c1)]=setInterval(()=>{const _0x4436a8=_0x899f13;this[_0x4436a8(0x17d)](_0x4436a8(0x1dc))['catch'](_0x2f87ed=>this['log'](_0x4436a8(0x183)+_0x2f87ed[_0x4436a8(0x1b8)]));},this[_0x899f13(0x1a2)]),this[_0x899f13(0x1d0)]();}async[a0_0x5d395c(0x167)](){const _0x18c883=a0_0x5d395c;if(this[_0x18c883(0x1af)]=!0x1,this[_0x18c883(0x194)]?.[_0x18c883(0x173)](),this[_0x18c883(0x1c1)])clearInterval(this[_0x18c883(0x1c1)]);await this[_0x18c883(0x17d)](_0x18c883(0x166))[_0x18c883(0x1b6)](()=>{}),this[_0x18c883(0x16d)](_0x18c883(0x191));}async[a0_0x5d395c(0x1a5)](_0x53e91e,_0xd68458,_0x48fc90=a0_0x5d395c(0x1d7)){const _0xa50331=a0_0x5d395c;return Y({'alias':_0x53e91e,'fromAlias':this[_0xa50331(0x1b7)]},{'log':_0x4839ab=>console[_0xa50331(0x16d)](_0x4839ab),'send':()=>this['call']('send_task',{'alias':_0x53e91e,'task':_0xd68458,'priority':_0x48fc90,'from_session':this[_0xa50331(0x1b7)]})});}async[a0_0x5d395c(0x1b8)](_0x172e70,_0x505ebd){const _0x4b7164=a0_0x5d395c;return this['call'](_0x4b7164(0x1b9),{'alias':_0x172e70,'message':_0x505ebd,'from_session':this[_0x4b7164(0x1b7)]});}async[a0_0x5d395c(0x1d1)](_0x44b682,_0x5bf4ec,_0x3e3ce6=a0_0x5d395c(0x19d)){const _0x911d70=a0_0x5d395c;return this[_0x911d70(0x177)](_0x911d70(0x19f),{'in_reply_to':_0x44b682,'text':_0x5bf4ec,'status':_0x3e3ce6});}async[a0_0x5d395c(0x17d)](_0x3338bf,_0x259bd1){const _0x682eba=a0_0x5d395c;return this[_0x682eba(0x177)](_0x682eba(0x1db),{'resume_id':this['resumeId'],'alias':this[_0x682eba(0x1b7)],'status':_0x3338bf,'server':a0_0x5b7e5c(),'hostname':a0_0x5b7e5c(),'agent':this['agent'],'project_dir':process[_0x682eba(0x172)](),..._0x259bd1});}async['getAllStatus'](){const _0x58c547=a0_0x5d395c;return this['call'](_0x58c547(0x184),{});}async[a0_0x5d395c(0x1c9)](_0x2ed343,_0x25013a){const _0xed2a02=a0_0x5d395c;return this[_0xed2a02(0x177)](_0xed2a02(0x1c9),{'message':_0x2ed343,'filter_server':_0x25013a?.[_0xed2a02(0x1d4)],'filter_status':_0x25013a?.[_0xed2a02(0x17d)]});}async[a0_0x5d395c(0x1d0)](){const _0x98b085=a0_0x5d395c;let _0x47bf8c=encodeURIComponent(this[_0x98b085(0x1b7)]),_0x52d331=this[_0x98b085(0x1d2)]+'/events/'+_0x47bf8c,_0x32c263=this['reconnectDelay'];while(this[_0x98b085(0x1af)]){try{this[_0x98b085(0x194)]=new AbortController();let _0xd60ecb={'Accept':_0x98b085(0x1bb)};if(this[_0x98b085(0x1c5)])_0xd60ecb['Authorization']=_0x98b085(0x19c)+this[_0x98b085(0x1c5)];let _0x1dc686=await fetch(_0x52d331,{'headers':_0xd60ecb,'signal':this['sseAbort'][_0x98b085(0x1d6)]});if(!_0x1dc686['ok']||!_0x1dc686[_0x98b085(0x1de)]){this[_0x98b085(0x16d)](_0x98b085(0x193)+_0x1dc686[_0x98b085(0x17d)]),await this['sleep'](_0x32c263),_0x32c263=Math[_0x98b085(0x1a7)](_0x32c263*1.5,0xea60);continue;}_0x32c263=this[_0x98b085(0x164)];let _0x5bcd85=_0x1dc686[_0x98b085(0x1de)][_0x98b085(0x182)](),_0x46969d=new TextDecoder(),_0x3ca111='';while(this[_0x98b085(0x1af)]){let {done:_0x5ce54d,value:_0xa65cee}=await _0x5bcd85[_0x98b085(0x1e2)]();if(_0x5ce54d)break;_0x3ca111+=_0x46969d[_0x98b085(0x1dd)](_0xa65cee,{'stream':!0x0});let _0x48a351=_0x3ca111['split']('\x0a');_0x3ca111=_0x48a351[_0x98b085(0x1e0)]()||'';for(let _0x27fb53 of _0x48a351){if(!_0x27fb53[_0x98b085(0x1a1)](_0x98b085(0x175)))continue;try{let _0x854c9e=JSON[_0x98b085(0x1a0)](_0x27fb53[_0x98b085(0x18f)](0x6));if(_0x854c9e[_0x98b085(0x1bf)]===_0x98b085(0x170)){this[_0x98b085(0x16d)](_0x98b085(0x180)),this[_0x98b085(0x1b5)](_0x98b085(0x170));continue;}if(_0x854c9e['type']===_0x98b085(0x1c8)||_0x854c9e[_0x98b085(0x1bf)]===_0x98b085(0x1be)||_0x854c9e[_0x98b085(0x1bf)]==='broadcast')await this[_0x98b085(0x1c0)]();}catch{}}}}catch(_0x3a1159){if(_0x3a1159[_0x98b085(0x1c7)]===_0x98b085(0x16f))break;this['emit']('error',_0x3a1159),this[_0x98b085(0x16d)](_0x98b085(0x16e)+_0x3a1159[_0x98b085(0x1b8)]);}if(this['running'])this['emit'](_0x98b085(0x191)),this['log'](_0x98b085(0x1c4)+_0x32c263/0x3e8+_0x98b085(0x189)),await this[_0x98b085(0x1d5)](_0x32c263),_0x32c263=Math['min'](_0x32c263*1.5,0xea60);}}async[a0_0x5d395c(0x1c0)](){const _0x5db871=a0_0x5d395c;try{let _0x5dc358=(await this[_0x5db871(0x177)]('get_inbox',{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x2f6677 of _0x5dc358)await this['call'](_0x5db871(0x18c),{'alias':this['alias'],'message_id':_0x2f6677['id']}),this[_0x5db871(0x16d)]('←\x20'+_0x2f6677[_0x5db871(0x197)]+':\x20'+_0x2f6677[_0x5db871(0x1b4)][_0x5db871(0x18f)](0x0,0x3c)),this[_0x5db871(0x1b5)]('task',_0x2f6677),this[_0x5db871(0x1b5)](_0x5db871(0x1b8),_0x2f6677);}catch(_0x23305c){this[_0x5db871(0x16d)]('inbox\x20error:\x20'+_0x23305c[_0x5db871(0x1b8)]);}}[a0_0x5d395c(0x1d5)](_0x1bcda6){return new Promise(_0x1e628f=>setTimeout(_0x1e628f,_0x1bcda6));}}var F=$;export{F as default,$ as CommHub};
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};
@@ -0,0 +1,146 @@
1
+ /** The explicit, documented-as-unsafe override. Spelled once so help, messages and tests agree. */
2
+ export declare const ALLOW_SHARED_CODEX_LOGIN_FLAG = "--allow-shared-codex-login";
3
+ /** Per-node record of where the node's codex credential came from. */
4
+ export declare const CODEX_AUTH_ORIGIN_FILE = ".codex-auth-origin.json";
5
+ /** Host-index filename for a node's origin record: same directory-derived key as
6
+ * #1918's record, different suffix, so neither overwrites the other. */
7
+ export declare function codexOriginIndexFile(nodeDir: string): string;
8
+ export type CodexLoginSource = {
9
+ kind: "host";
10
+ path: string;
11
+ } | {
12
+ kind: "fork";
13
+ sourceAlias: string;
14
+ } | {
15
+ kind: "account";
16
+ profileId: string;
17
+ };
18
+ export interface CodexLoginHolder {
19
+ readonly alias: string;
20
+ /** Canonical node directory — the identity. */
21
+ readonly nodeDir: string;
22
+ /** "current": its last published fingerprint; "origin": the credential it was given. */
23
+ readonly via: "current" | "origin";
24
+ }
25
+ /**
26
+ * Fingerprint of an auth.json on disk, or null when there is none or it carries
27
+ * no refresh token (an API-key login does not rotate, so sharing it is not this
28
+ * failure). The text is hashed and dropped; nothing here returns or logs it.
29
+ */
30
+ export declare function codexLoginFingerprintOfFile(authJsonPath: string): string | null;
31
+ export interface FindHoldersOptions {
32
+ readonly fingerprint: string;
33
+ /** The node being given the credential — excluded from the result. */
34
+ readonly selfNodeDir: string;
35
+ /** Injected for tests; production uses the host index under ~/.anet. */
36
+ readonly indexDir?: string;
37
+ /** `.anet/nodes` roots to scan besides the host index. Default: the parent of selfNodeDir. */
38
+ readonly siblingRoots?: readonly string[];
39
+ }
40
+ /**
41
+ * Every OTHER node on this host whose published fingerprint, or recorded
42
+ * credential origin, equals `fingerprint`. Read-only: it never deletes, never
43
+ * writes, and never opens another node's auth.json.
44
+ *
45
+ * A record whose node directory no longer exists describes a node that is
46
+ * gone and is ignored (#1918's liveness rule: existence, not age).
47
+ */
48
+ export declare function findCodexLoginHolders(opts: FindHoldersOptions): CodexLoginHolder[];
49
+ export interface StagingDecisionInput {
50
+ /** The node that would receive the credential. */
51
+ readonly alias: string;
52
+ /** Its codex-home — named in the fix instruction. */
53
+ readonly targetCodexHome: string;
54
+ /** Fingerprint of the credential about to be handed over; null = not a rotating login. */
55
+ readonly fingerprint: string | null;
56
+ readonly holders: readonly CodexLoginHolder[];
57
+ readonly source: CodexLoginSource;
58
+ readonly allowShared: boolean;
59
+ /** Extra "how to fix" line for this command (e.g. fork's --no-codex-login). */
60
+ readonly extraFix?: readonly string[];
61
+ }
62
+ export type StagingDecision = {
63
+ readonly kind: "ok";
64
+ readonly lines: string[];
65
+ } | {
66
+ readonly kind: "refuse";
67
+ readonly lines: string[];
68
+ } | {
69
+ readonly kind: "override";
70
+ readonly lines: string[];
71
+ };
72
+ /**
73
+ * Decide whether handing this credential to this node is allowed, and the exact
74
+ * text to print. Pure — the callers own the I/O and the exit code (1, per #2321).
75
+ */
76
+ export declare function decideCodexLoginStaging(i: StagingDecisionInput): StagingDecision;
77
+ export interface RecordOriginOptions {
78
+ readonly nodeDir: string;
79
+ readonly alias: string;
80
+ readonly fingerprint: string;
81
+ readonly source: CodexLoginSource;
82
+ readonly indexDir?: string;
83
+ readonly now?: Date;
84
+ }
85
+ /**
86
+ * Record which credential a node was handed (8-hex fingerprint + where from).
87
+ * Best effort: a failure is returned as a message, never thrown — a node must
88
+ * not fail to start because bookkeeping failed.
89
+ */
90
+ export declare function recordCodexLoginOrigin(o: RecordOriginOptions): string | null;
91
+ export interface SharedLoginGroup {
92
+ /** 8-hex refresh fingerprint — not a credential. */
93
+ readonly fingerprint: string;
94
+ readonly aliases: string[];
95
+ }
96
+ /**
97
+ * For `anet doctor`: groups of ≥2 live nodes whose CURRENT published
98
+ * fingerprint is the same. Read-only; aliases only.
99
+ */
100
+ export declare function sharedCodexLoginGroups(opts?: {
101
+ indexDir?: string;
102
+ nodeRoots?: readonly string[];
103
+ }): SharedLoginGroup[];
104
+ export interface EvaluateStagingOptions {
105
+ /** The node that would receive the credential (may not exist yet, e.g. a fork target). */
106
+ readonly nodeDir: string;
107
+ readonly alias: string;
108
+ readonly targetCodexHome: string;
109
+ /** The auth.json about to be copied. Read only to hash it. */
110
+ readonly sourceAuthPath: string;
111
+ readonly source: CodexLoginSource;
112
+ readonly allowShared: boolean;
113
+ readonly extraFix?: readonly string[];
114
+ /** Holders known without any record — a fork's source node always holds its own login. */
115
+ readonly knownHolders?: readonly CodexLoginHolder[];
116
+ readonly indexDir?: string;
117
+ readonly siblingRoots?: readonly string[];
118
+ }
119
+ export type EvaluatedStaging = StagingDecision & {
120
+ readonly fingerprint: string | null;
121
+ readonly holders: readonly CodexLoginHolder[];
122
+ };
123
+ /**
124
+ * Fingerprint → holders → decision, in one call, for every staging path.
125
+ * Writes nothing; the caller records the origin once the credential has
126
+ * actually been handed over (see recordCodexLoginOrigin).
127
+ */
128
+ export declare function evaluateCodexLoginStaging(o: EvaluateStagingOptions): EvaluatedStaging;
129
+ /**
130
+ * `anet node codex fork --no-codex-login` deliberately leaves the target without
131
+ * a credential, and home_isolated would fail on exactly that. The caller runs
132
+ * the real check with the credential treated as present (so every OTHER rule —
133
+ * directory mode, CommHub token, env-file token — is still evaluated) and passes
134
+ * the result here: a pass is re-worded to say what is still owed, a failure
135
+ * stays the failure it is.
136
+ */
137
+ export declare function homeCheckPendingOwnLogin<C extends {
138
+ status: string;
139
+ detail: string;
140
+ }>(checkAssumingLogin: C, codexHome: string): C;
141
+ /** The step of a host stage plan that newly hands a node a login: auth.json where the node has none.
142
+ * A "host-newer" re-stage is an existing node and is not gated (it still gets the #1918 warning). */
143
+ export declare function newLoginStep<T extends {
144
+ name: string;
145
+ reason: string;
146
+ }>(plan: readonly T[]): T | undefined;