@sleep2agi/agent-network 2.3.0-preview.46 → 2.3.0-preview.48
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/client.js +1 -1
- package/dist/src/copresence-deps.d.ts +4 -2
- package/dist/src/grok-attach-client.d.ts +15 -1
- package/dist/src/grok-copresence-orchestration.d.ts +70 -0
- package/dist/src/im/correlation-store.d.ts +34 -0
- package/dist/src/im/feishu/bridge.d.ts +30 -2
- package/dist/src/im/feishu/worker.js +180 -168
- package/dist/src/node-server-payload.d.ts +66 -0
- package/dist/src/node-server.js +7 -7
- package/dist/src/opencode-agent-node-pair.d.ts +6 -6
- package/package.json +1 -1
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a0_0x4980fc=a0_0x23bc;(function(_0xb4a6ad,_0x398198){const _0x333aae=a0_0x23bc,_0x3c9e65=_0xb4a6ad();while(!![]){try{const _0x14d4b2=parseInt(_0x333aae(0x1aa))/0x1+parseInt(_0x333aae(0x19b))/0x2*(-parseInt(_0x333aae(0x1b4))/0x3)+parseInt(_0x333aae(0x1e9))/0x4+-parseInt(_0x333aae(0x18c))/0x5*(-parseInt(_0x333aae(0x1b5))/0x6)+-parseInt(_0x333aae(0x198))/0x7+parseInt(_0x333aae(0x1bf))/0x8+-parseInt(_0x333aae(0x1e5))/0x9*(parseInt(_0x333aae(0x1e7))/0xa);if(_0x14d4b2===_0x398198)break;else _0x3c9e65['push'](_0x3c9e65['shift']());}catch(_0x1232e0){_0x3c9e65['push'](_0x3c9e65['shift']());}}}(a0_0x6acc,0xc812a));import{EventEmitter as a0_0x17aad3}from'events';import{hostname as a0_0x13ecf0}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x43a7dd,_0x32cea0)=>(_0x43a7dd??_0x32cea0)[a0_0x4980fc(0x1a3)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x4980fc(0x1fc)](0x0,0xf0);function N(_0x29a5f0){const _0x2f1c8b=a0_0x4980fc;return(_0x29a5f0 instanceof Error?_0x29a5f0['message']:String(_0x29a5f0??_0x2f1c8b(0x207)))[_0x2f1c8b(0x1a3)](K,_0x2f1c8b(0x1e1))[_0x2f1c8b(0x1a3)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x2f1c8b(0x1fc)](0x0,0xf0);}function a0_0x6acc(){const _0x210a42=['report_status','\x20from=','s...','task.send.start','offline','SSE\x20error:\x20','send_message','now','660807TNEvaT','log','name','2qwaUlP','networkId','result','call','tools/call','get_inbox','\x20task_id=','\x20to=','replace','emit','content','fromAlias','/mcp','reconnectDelay','connected','106484YKXTrk','alias','AbortError','toAlias','error','message','\x20lifecycle=','\x20parent_task_id=','text/event-stream','parentTaskId','1438941QaHQPH','14154DHgGdH','parse','pop','send_reply','toTimeString','POST','disconnected','task.send.failed','task','message_id','7188472vRYgSk','url','ack_inbox','signal','send','error_code','transport','text','from_session','stringify','catch','registered','send_failed','failed','idle','lifecycle_tracking','status','<unknown>','processInbox','connectSSE','task.send.delivered','application/json','Authorization',']\x20[commhub:','agent','getAllStatus','toString','match','read','application/json,\x20text/event-stream','CommHub\x20response\x20omitted\x20task_id','startsWith','body','autoConnect','[REDACTED]','task.expired','[commhub:task]\x20','SSE\x20failed:\x20','2989962VZEDHx','Bearer\x20','10pCaJqv','task.ack','33212dFVbpP','send_rejected','type','\x20transport=','heartbeatTimer','/events/','messages','new_task','data:\x20','task.replied','resumeId','token','task_id','server','missing_task_id','abort','<missing>','decode','reply','slice','get_all_status','connect','heartbeatInterval','normal','cwd','\x20duration_ms=','min','sseAbort','running','sleep','unknown\x20error','lifecycleTracking','\x20network_id=','1510DrYwwz','from_alias','broadcast','SSE\x20connected'];a0_0x6acc=function(){return _0x210a42;};return a0_0x6acc();}function O(_0x5e812f,_0x591cff=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x3b0153=a0_0x4980fc;if(_0x591cff)return JSON['stringify'](_0x5e812f);let _0x7d671b=L(_0x5e812f['parent_task_id'],_0x3b0153(0x1f9)),_0x330964=L(_0x5e812f[_0x3b0153(0x1f5)],'<pending>'),_0x33b7db=_0x5e812f[_0x3b0153(0x1c4)]?'\x20error='+_0x5e812f[_0x3b0153(0x1c4)]+':'+(_0x5e812f['error_message']??''):'';return _0x3b0153(0x1e3)+_0x5e812f[_0x3b0153(0x1cf)]+_0x3b0153(0x191)+L(_0x5e812f[_0x3b0153(0x18d)],_0x3b0153(0x1d0))+_0x3b0153(0x1a2)+L(_0x5e812f['to_alias'],_0x3b0153(0x1d0))+_0x3b0153(0x1a1)+_0x330964+_0x3b0153(0x1b1)+_0x7d671b+_0x3b0153(0x18b)+L(_0x5e812f['network_id'],_0x3b0153(0x1d0))+_0x3b0153(0x1ec)+_0x5e812f[_0x3b0153(0x1c5)]+_0x3b0153(0x202)+_0x5e812f['duration_ms']+_0x3b0153(0x1b0)+_0x5e812f[_0x3b0153(0x1ce)]+_0x33b7db;}function U(_0x213cd9){const _0xc5ab79=a0_0x4980fc;return{'event':{'sending':_0xc5ab79(0x193),'delivered':_0xc5ab79(0x1d3),'failed':_0xc5ab79(0x1bc),'acked':_0xc5ab79(0x1e8),'started':'task.started','replied':_0xc5ab79(0x1f2),'expired':_0xc5ab79(0x1e2)}[_0x213cd9[_0xc5ab79(0x1cf)]],..._0x213cd9};}function a0_0x23bc(_0x12e802,_0x5b6362){_0x12e802=_0x12e802-0x18a;const _0x6acc37=a0_0x6acc();let _0x23bcb3=_0x6acc37[_0x12e802];return _0x23bcb3;}function j(_0x108a63){const _0x55ef0b=a0_0x4980fc;let _0x595d2d=_0x108a63?.['task_id']||_0x108a63?.[_0x55ef0b(0x1be)]||_0x108a63?.['id'];if(_0x595d2d)return String(_0x595d2d);let _0x262448=_0x108a63?.[_0x55ef0b(0x1a5)]?.[0x0]?.['text'];if(typeof _0x262448!=='string')return null;try{let _0x33c072=JSON[_0x55ef0b(0x1b6)](_0x262448);return _0x33c072?.[_0x55ef0b(0x1f5)]||_0x33c072?.['message_id']||_0x33c072?.['id']||null;}catch{return null;}}async function X(_0x1735a6,_0x5ae9e0){const _0x4719ea=a0_0x4980fc;let _0x2d832e=_0x5ae9e0['now']??Date[_0x4719ea(0x197)],_0x427b42=_0x2d832e(),_0xea66a3=(_0x584d04,_0x588d7c,_0x449923,_0x324465)=>{const _0x24ddfe=_0x4719ea;_0x5ae9e0[_0x24ddfe(0x199)](O(U({'from_alias':_0x1735a6[_0x24ddfe(0x1a6)],'to_alias':_0x1735a6[_0x24ddfe(0x1ad)],'task_id':_0x588d7c,'parent_task_id':_0x1735a6[_0x24ddfe(0x1b3)],'network_id':_0x1735a6['networkId'],'transport':_0x1735a6['transport'],'status':_0x584d04,'duration_ms':_0x2d832e()-_0x427b42,'lifecycle_tracking':_0x1735a6[_0x24ddfe(0x18a)],..._0x449923!==void 0x0?{'error_code':_0x324465||_0x24ddfe(0x1cb),'error_message':N(_0x449923)}:{}})));};_0xea66a3('sending',null);try{let _0x2b84ad=await _0x5ae9e0[_0x4719ea(0x1c3)](),_0x252d7a=j(_0x2b84ad);if(_0x252d7a)_0xea66a3('delivered',_0x252d7a);else{if(_0x2b84ad?.['ok']===!0x1||_0x2b84ad?.[_0x4719ea(0x1ae)])_0xea66a3(_0x4719ea(0x1cc),_0x252d7a,_0x2b84ad?.['error']||'CommHub\x20rejected\x20task',_0x4719ea(0x1ea));else _0xea66a3(_0x4719ea(0x1cc),null,_0x4719ea(0x1dd),_0x4719ea(0x1f7));}return _0x2b84ad;}catch(_0x72d42c){throw _0xea66a3(_0x4719ea(0x1cc),null,_0x72d42c,_0x4719ea(0x1cb)),_0x72d42c;}}async function Y(_0x24eb91,_0x2a958b){const _0x5290ef=a0_0x4980fc;return X({'fromAlias':_0x24eb91['fromAlias'],'toAlias':_0x24eb91[_0x5290ef(0x1ab)],'parentTaskId':_0x24eb91[_0x5290ef(0x1b3)]||null,'networkId':_0x24eb91[_0x5290ef(0x19c)]||null,'transport':'mcp_http','lifecycleTracking':'not_tracked'},_0x2a958b);}class $ extends a0_0x17aad3{[a0_0x4980fc(0x1c0)];['alias'];[a0_0x4980fc(0x1f4)];['agent'];[a0_0x4980fc(0x1f3)];[a0_0x4980fc(0x1ff)];[a0_0x4980fc(0x1a8)];['heartbeatTimer'];[a0_0x4980fc(0x204)];[a0_0x4980fc(0x205)]=!0x1;constructor(_0x5a1b73){const _0x45f9f5=a0_0x4980fc;super();if(this['url']=_0x5a1b73[_0x45f9f5(0x1c0)][_0x45f9f5(0x1a3)](/\/$/,''),this[_0x45f9f5(0x1ab)]=_0x5a1b73[_0x45f9f5(0x1ab)],this[_0x45f9f5(0x1f4)]=_0x5a1b73[_0x45f9f5(0x1f4)],this[_0x45f9f5(0x1d7)]=_0x5a1b73[_0x45f9f5(0x1d7)]||'sdk',this[_0x45f9f5(0x1f3)]='sdk-'+_0x5a1b73[_0x45f9f5(0x1ab)]+'-'+Date[_0x45f9f5(0x197)]()[_0x45f9f5(0x1d9)](0x24),this[_0x45f9f5(0x1ff)]=_0x5a1b73[_0x45f9f5(0x1ff)]??0x2bf20,this[_0x45f9f5(0x1a8)]=_0x5a1b73[_0x45f9f5(0x1a8)]??0xbb8,_0x5a1b73[_0x45f9f5(0x1e0)]!==!0x1)this[_0x45f9f5(0x1fe)]();}[a0_0x4980fc(0x199)](_0x55f344){const _0x32016d=a0_0x4980fc;console[_0x32016d(0x199)]('['+new Date()[_0x32016d(0x1b9)]()['slice'](0x0,0x8)+_0x32016d(0x1d6)+this[_0x32016d(0x1ab)]+']\x20'+_0x55f344);}async['call'](_0x1d2d6b,_0x476cb4){const _0x2dd211=a0_0x4980fc;let _0x5b5fb9={'Content-Type':_0x2dd211(0x1d4),'Accept':_0x2dd211(0x1dc)};if(this[_0x2dd211(0x1f4)])_0x5b5fb9['Authorization']=_0x2dd211(0x1e6)+this[_0x2dd211(0x1f4)];let _0x277617=await(await fetch(this['url']+_0x2dd211(0x1a7),{'method':_0x2dd211(0x1ba),'headers':_0x5b5fb9,'body':JSON[_0x2dd211(0x1c8)]({'jsonrpc':'2.0','id':Date[_0x2dd211(0x197)](),'method':_0x2dd211(0x19f),'params':{'name':_0x1d2d6b,'arguments':_0x476cb4}})}))[_0x2dd211(0x1c6)](),_0x16e663=_0x277617[_0x2dd211(0x1da)](/data: (.+)/),_0x3c3efd=_0x16e663?JSON[_0x2dd211(0x1b6)](_0x16e663[0x1]):JSON[_0x2dd211(0x1b6)](_0x277617),_0x3455d7=_0x3c3efd?.[_0x2dd211(0x19d)]?.['content']?.[0x0]?.[_0x2dd211(0x1c6)];return _0x3455d7?JSON[_0x2dd211(0x1b6)](_0x3455d7):_0x3c3efd;}async[a0_0x4980fc(0x1fe)](){const _0x213024=a0_0x4980fc;if(this[_0x213024(0x205)])return;this[_0x213024(0x205)]=!0x0,await this[_0x213024(0x1cf)](_0x213024(0x1cd)),this['log'](_0x213024(0x1ca)),this[_0x213024(0x1ed)]=setInterval(()=>{const _0x4e6899=_0x213024;this[_0x4e6899(0x1cf)](_0x4e6899(0x1cd))[_0x4e6899(0x1c9)](_0x27e858=>this[_0x4e6899(0x199)]('heartbeat\x20failed:\x20'+_0x27e858['message']));},this[_0x213024(0x1ff)]),this[_0x213024(0x1d2)]();}async['disconnect'](){const _0x1caa9a=a0_0x4980fc;if(this[_0x1caa9a(0x205)]=!0x1,this['sseAbort']?.[_0x1caa9a(0x1f8)](),this[_0x1caa9a(0x1ed)])clearInterval(this['heartbeatTimer']);await this[_0x1caa9a(0x1cf)](_0x1caa9a(0x194))[_0x1caa9a(0x1c9)](()=>{}),this[_0x1caa9a(0x199)](_0x1caa9a(0x1bb));}async[a0_0x4980fc(0x1c3)](_0x304445,_0x573085,_0x4d928e=a0_0x4980fc(0x200)){const _0x502322=a0_0x4980fc;return Y({'alias':_0x304445,'fromAlias':this['alias']},{'log':_0x17b3de=>console[_0x502322(0x199)](_0x17b3de),'send':()=>this[_0x502322(0x19e)]('send_task',{'alias':_0x304445,'task':_0x573085,'priority':_0x4d928e,'from_session':this[_0x502322(0x1ab)]})});}async[a0_0x4980fc(0x1af)](_0x3264f1,_0x2e73f5){const _0x5ab58c=a0_0x4980fc;return this[_0x5ab58c(0x19e)](_0x5ab58c(0x196),{'alias':_0x3264f1,'message':_0x2e73f5,'from_session':this[_0x5ab58c(0x1ab)]});}async[a0_0x4980fc(0x1fb)](_0x418dd8,_0x55a95b,_0x2b581e='completed'){const _0x5199b1=a0_0x4980fc;return this[_0x5199b1(0x19e)](_0x5199b1(0x1b8),{'in_reply_to':_0x418dd8,'text':_0x55a95b,'status':_0x2b581e});}async[a0_0x4980fc(0x1cf)](_0x51c360,_0x7cebf0){const _0x418e80=a0_0x4980fc;return this[_0x418e80(0x19e)](_0x418e80(0x190),{'resume_id':this[_0x418e80(0x1f3)],'alias':this[_0x418e80(0x1ab)],'status':_0x51c360,'server':a0_0x13ecf0(),'hostname':a0_0x13ecf0(),'agent':this[_0x418e80(0x1d7)],'project_dir':process[_0x418e80(0x201)](),..._0x7cebf0});}async[a0_0x4980fc(0x1d8)](){const _0x32b82e=a0_0x4980fc;return this[_0x32b82e(0x19e)](_0x32b82e(0x1fd),{});}async[a0_0x4980fc(0x18e)](_0x2e86a3,_0x3b860b){const _0x366513=a0_0x4980fc;return this['call'](_0x366513(0x18e),{'message':_0x2e86a3,'filter_server':_0x3b860b?.[_0x366513(0x1f6)],'filter_status':_0x3b860b?.[_0x366513(0x1cf)]});}async[a0_0x4980fc(0x1d2)](){const _0x8ecaf9=a0_0x4980fc;let _0x3e335d=encodeURIComponent(this['alias']),_0x57cb80=this['url']+_0x8ecaf9(0x1ee)+_0x3e335d,_0x5ced82=this[_0x8ecaf9(0x1a8)];while(this[_0x8ecaf9(0x205)]){try{this[_0x8ecaf9(0x204)]=new AbortController();let _0x2c8470={'Accept':_0x8ecaf9(0x1b2)};if(this['token'])_0x2c8470[_0x8ecaf9(0x1d5)]=_0x8ecaf9(0x1e6)+this[_0x8ecaf9(0x1f4)];let _0x32a70c=await fetch(_0x57cb80,{'headers':_0x2c8470,'signal':this[_0x8ecaf9(0x204)][_0x8ecaf9(0x1c2)]});if(!_0x32a70c['ok']||!_0x32a70c[_0x8ecaf9(0x1df)]){this[_0x8ecaf9(0x199)](_0x8ecaf9(0x1e4)+_0x32a70c[_0x8ecaf9(0x1cf)]),await this[_0x8ecaf9(0x206)](_0x5ced82),_0x5ced82=Math['min'](_0x5ced82*1.5,0xea60);continue;}_0x5ced82=this['reconnectDelay'];let _0x319530=_0x32a70c[_0x8ecaf9(0x1df)]['getReader'](),_0x5362d9=new TextDecoder(),_0xf9e69b='';while(this[_0x8ecaf9(0x205)]){let {done:_0x386c67,value:_0x1c35b5}=await _0x319530[_0x8ecaf9(0x1db)]();if(_0x386c67)break;_0xf9e69b+=_0x5362d9[_0x8ecaf9(0x1fa)](_0x1c35b5,{'stream':!0x0});let _0x30c332=_0xf9e69b['split']('\x0a');_0xf9e69b=_0x30c332[_0x8ecaf9(0x1b7)]()||'';for(let _0xa566f4 of _0x30c332){if(!_0xa566f4[_0x8ecaf9(0x1de)](_0x8ecaf9(0x1f1)))continue;try{let _0x210fd3=JSON['parse'](_0xa566f4[_0x8ecaf9(0x1fc)](0x6));if(_0x210fd3[_0x8ecaf9(0x1eb)]===_0x8ecaf9(0x1a9)){this[_0x8ecaf9(0x199)](_0x8ecaf9(0x18f)),this['emit'](_0x8ecaf9(0x1a9));continue;}if(_0x210fd3[_0x8ecaf9(0x1eb)]===_0x8ecaf9(0x1f0)||_0x210fd3[_0x8ecaf9(0x1eb)]==='new_message'||_0x210fd3[_0x8ecaf9(0x1eb)]==='broadcast')await this[_0x8ecaf9(0x1d1)]();}catch{}}}}catch(_0x4d6508){if(_0x4d6508[_0x8ecaf9(0x19a)]===_0x8ecaf9(0x1ac))break;this[_0x8ecaf9(0x1a4)](_0x8ecaf9(0x1ae),_0x4d6508),this[_0x8ecaf9(0x199)](_0x8ecaf9(0x195)+_0x4d6508['message']);}if(this[_0x8ecaf9(0x205)])this[_0x8ecaf9(0x1a4)](_0x8ecaf9(0x1bb)),this[_0x8ecaf9(0x199)]('SSE\x20reconnecting\x20in\x20'+_0x5ced82/0x3e8+_0x8ecaf9(0x192)),await this[_0x8ecaf9(0x206)](_0x5ced82),_0x5ced82=Math[_0x8ecaf9(0x203)](_0x5ced82*1.5,0xea60);}}async['processInbox'](){const _0x1b050c=a0_0x4980fc;try{let _0x3e398a=(await this[_0x1b050c(0x19e)](_0x1b050c(0x1a0),{'alias':this[_0x1b050c(0x1ab)],'limit':0xa}))?.[_0x1b050c(0x1ef)]||[];for(let _0x261f64 of _0x3e398a)await this['call'](_0x1b050c(0x1c1),{'alias':this[_0x1b050c(0x1ab)],'message_id':_0x261f64['id']}),this['log']('←\x20'+_0x261f64[_0x1b050c(0x1c7)]+':\x20'+_0x261f64[_0x1b050c(0x1a5)][_0x1b050c(0x1fc)](0x0,0x3c)),this['emit'](_0x1b050c(0x1bd),_0x261f64),this[_0x1b050c(0x1a4)](_0x1b050c(0x1af),_0x261f64);}catch(_0x41dfe5){this[_0x1b050c(0x199)]('inbox\x20error:\x20'+_0x41dfe5[_0x1b050c(0x1af)]);}}['sleep'](_0x1c0039){return new Promise(_0x2d0f19=>setTimeout(_0x2d0f19,_0x1c0039));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x1808a5=a0_0x51ca;(function(_0x4dbe43,_0x59b7ee){const _0x131f44=a0_0x51ca,_0x41c7f5=_0x4dbe43();while(!![]){try{const _0x5617a8=-parseInt(_0x131f44(0x178))/0x1+parseInt(_0x131f44(0x1b3))/0x2*(parseInt(_0x131f44(0x17f))/0x3)+-parseInt(_0x131f44(0x143))/0x4*(parseInt(_0x131f44(0x191))/0x5)+parseInt(_0x131f44(0x163))/0x6*(-parseInt(_0x131f44(0x186))/0x7)+-parseInt(_0x131f44(0x198))/0x8*(parseInt(_0x131f44(0x173))/0x9)+parseInt(_0x131f44(0x17e))/0xa+-parseInt(_0x131f44(0x166))/0xb*(-parseInt(_0x131f44(0x167))/0xc);if(_0x5617a8===_0x59b7ee)break;else _0x41c7f5['push'](_0x41c7f5['shift']());}catch(_0x36b2d9){_0x41c7f5['push'](_0x41c7f5['shift']());}}}(a0_0x14a5,0x40b72));import{EventEmitter as a0_0x269aca}from'events';function a0_0x51ca(_0xe64ce5,_0x14c7ae){_0xe64ce5=_0xe64ce5-0x140;const _0x14a51a=a0_0x14a5();let _0x51ca49=_0x14a51a[_0xe64ce5];return _0x51ca49;}import{hostname as a0_0x272304}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2ccd78,_0x553188)=>(_0x2ccd78??_0x553188)[a0_0x1808a5(0x16f)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x1808a5(0x14e)](0x0,0xf0);function N(_0x5e641d){const _0x270683=a0_0x1808a5;return(_0x5e641d instanceof Error?_0x5e641d[_0x270683(0x193)]:String(_0x5e641d??_0x270683(0x19b)))['replace'](K,_0x270683(0x165))[_0x270683(0x16f)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x477992,_0x5212f5=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x95230f=a0_0x1808a5;if(_0x5212f5)return JSON[_0x95230f(0x1bf)](_0x477992);let _0x3ee312=L(_0x477992[_0x95230f(0x17d)],_0x95230f(0x19d)),_0x20f16b=L(_0x477992[_0x95230f(0x177)],_0x95230f(0x18e)),_0x64106d=_0x477992[_0x95230f(0x14a)]?'\x20error='+_0x477992[_0x95230f(0x14a)]+':'+(_0x477992['error_message']??''):'';return _0x95230f(0x17b)+_0x477992[_0x95230f(0x16a)]+'\x20from='+L(_0x477992[_0x95230f(0x18d)],_0x95230f(0x1ab))+_0x95230f(0x18f)+L(_0x477992['to_alias'],'<unknown>')+_0x95230f(0x1a0)+_0x20f16b+'\x20parent_task_id='+_0x3ee312+_0x95230f(0x16d)+L(_0x477992[_0x95230f(0x192)],'<unknown>')+_0x95230f(0x140)+_0x477992[_0x95230f(0x158)]+'\x20duration_ms='+_0x477992['duration_ms']+_0x95230f(0x144)+_0x477992[_0x95230f(0x1ac)]+_0x64106d;}function a0_0x14a5(){const _0xd6f6f7=['running','30kPDdDk','processInbox','[REDACTED]','4193321zZylUf','12eqAHdq','task.send.start','task.send.failed','status','failed','messages','\x20network_id=','CommHub\x20response\x20omitted\x20task_id','replace','alias','application/json','normal','1372860kkUHIb','offline','2.0','idle','task_id','43065fEcQpz','min','catch','[commhub:task]\x20','reconnectDelay','parent_task_id','4354150NlOmGY','159RMfUyn','lifecycleTracking','url','parse','disconnected','connect','error','569905SkXVyX','resumeId','toString','not_tracked','/mcp','name','decode','from_alias','<pending>','\x20to=','content','145omwplW','network_id','message','tools/call','type','now','mcp_http','8lfxlXE','registered','pop','unknown\x20error','reply','<missing>','POST','task','\x20task_id=','ack_inbox','missing_task_id','get_inbox','result','send_message','delivered','connectSSE','SSE\x20failed:\x20','text/event-stream','heartbeat\x20failed:\x20','<unknown>','lifecycle_tracking','send_failed','sending','read','task.send.delivered','fromAlias','Authorization','7354eNMsZu','heartbeatInterval','sdk-','call','heartbeatTimer','log','autoConnect','s...','CommHub\x20rejected\x20task','data:\x20','toAlias','report_status','stringify','networkId','\x20transport=','send_rejected','new_task','19828EKLwxz','\x20lifecycle=','send','Bearer\x20','send_task','abort','from_session','error_code','emit','get_all_status','broadcast','slice','body','message_id','string',']\x20[commhub:','startsWith','new_message','token','application/json,\x20text/event-stream','getReader','transport','split','text','signal','SSE\x20connected','agent','sseAbort','parentTaskId','sleep','connected'];a0_0x14a5=function(){return _0xd6f6f7;};return a0_0x14a5();}function U(_0x2586c8){const _0x143e6=a0_0x1808a5;return{'event':{'sending':_0x143e6(0x168),'delivered':_0x143e6(0x1b0),'failed':_0x143e6(0x169),'acked':'task.ack','started':'task.started','replied':'task.replied','expired':'task.expired'}[_0x2586c8[_0x143e6(0x16a)]],..._0x2586c8};}function j(_0x141435){const _0xec007e=a0_0x1808a5;let _0x21a7da=_0x141435?.[_0xec007e(0x177)]||_0x141435?.[_0xec007e(0x150)]||_0x141435?.['id'];if(_0x21a7da)return String(_0x21a7da);let _0x25d748=_0x141435?.['content']?.[0x0]?.[_0xec007e(0x15a)];if(typeof _0x25d748!==_0xec007e(0x151))return null;try{let _0x5a0d2a=JSON[_0xec007e(0x182)](_0x25d748);return _0x5a0d2a?.[_0xec007e(0x177)]||_0x5a0d2a?.[_0xec007e(0x150)]||_0x5a0d2a?.['id']||null;}catch{return null;}}async function X(_0x2fda12,_0x16f46f){const _0x2bc7a1=a0_0x1808a5;let _0x17ee72=_0x16f46f[_0x2bc7a1(0x196)]??Date[_0x2bc7a1(0x196)],_0x15723a=_0x17ee72(),_0xe27869=(_0x29a5bb,_0x4cd7f1,_0x586eee,_0x1b4ddf)=>{const _0xbd962a=_0x2bc7a1;_0x16f46f[_0xbd962a(0x1b8)](O(U({'from_alias':_0x2fda12[_0xbd962a(0x1b1)],'to_alias':_0x2fda12[_0xbd962a(0x1bd)],'task_id':_0x4cd7f1,'parent_task_id':_0x2fda12[_0xbd962a(0x15f)],'network_id':_0x2fda12[_0xbd962a(0x1c0)],'transport':_0x2fda12[_0xbd962a(0x158)],'status':_0x29a5bb,'duration_ms':_0x17ee72()-_0x15723a,'lifecycle_tracking':_0x2fda12[_0xbd962a(0x180)],..._0x586eee!==void 0x0?{'error_code':_0x1b4ddf||'send_failed','error_message':N(_0x586eee)}:{}})));};_0xe27869(_0x2bc7a1(0x1ae),null);try{let _0xad09e2=await _0x16f46f[_0x2bc7a1(0x145)](),_0x2f611c=j(_0xad09e2);if(_0x2f611c)_0xe27869(_0x2bc7a1(0x1a6),_0x2f611c);else{if(_0xad09e2?.['ok']===!0x1||_0xad09e2?.[_0x2bc7a1(0x185)])_0xe27869('failed',_0x2f611c,_0xad09e2?.[_0x2bc7a1(0x185)]||_0x2bc7a1(0x1bb),_0x2bc7a1(0x141));else _0xe27869(_0x2bc7a1(0x16b),null,_0x2bc7a1(0x16e),_0x2bc7a1(0x1a2));}return _0xad09e2;}catch(_0x299b83){throw _0xe27869('failed',null,_0x299b83,_0x2bc7a1(0x1ad)),_0x299b83;}}async function Y(_0x5a4669,_0x88b723){const _0x2c627d=a0_0x1808a5;return X({'fromAlias':_0x5a4669[_0x2c627d(0x1b1)],'toAlias':_0x5a4669[_0x2c627d(0x170)],'parentTaskId':_0x5a4669[_0x2c627d(0x15f)]||null,'networkId':_0x5a4669[_0x2c627d(0x1c0)]||null,'transport':_0x2c627d(0x197),'lifecycleTracking':_0x2c627d(0x189)},_0x88b723);}class $ extends a0_0x269aca{[a0_0x1808a5(0x181)];['alias'];[a0_0x1808a5(0x155)];[a0_0x1808a5(0x15d)];[a0_0x1808a5(0x187)];[a0_0x1808a5(0x1b4)];['reconnectDelay'];[a0_0x1808a5(0x1b7)];['sseAbort'];[a0_0x1808a5(0x162)]=!0x1;constructor(_0x1614f0){const _0x40ffac=a0_0x1808a5;super();if(this['url']=_0x1614f0['url'][_0x40ffac(0x16f)](/\/$/,''),this[_0x40ffac(0x170)]=_0x1614f0[_0x40ffac(0x170)],this[_0x40ffac(0x155)]=_0x1614f0[_0x40ffac(0x155)],this[_0x40ffac(0x15d)]=_0x1614f0['agent']||'sdk',this[_0x40ffac(0x187)]=_0x40ffac(0x1b5)+_0x1614f0[_0x40ffac(0x170)]+'-'+Date[_0x40ffac(0x196)]()[_0x40ffac(0x188)](0x24),this['heartbeatInterval']=_0x1614f0['heartbeatInterval']??0x2bf20,this[_0x40ffac(0x17c)]=_0x1614f0['reconnectDelay']??0xbb8,_0x1614f0[_0x40ffac(0x1b9)]!==!0x1)this[_0x40ffac(0x184)]();}[a0_0x1808a5(0x1b8)](_0x5ec3ca){const _0x53ae7b=a0_0x1808a5;console[_0x53ae7b(0x1b8)]('['+new Date()['toTimeString']()[_0x53ae7b(0x14e)](0x0,0x8)+_0x53ae7b(0x152)+this[_0x53ae7b(0x170)]+']\x20'+_0x5ec3ca);}async['call'](_0x354da1,_0x36fe55){const _0x448280=a0_0x1808a5;let _0x515e09={'Content-Type':_0x448280(0x171),'Accept':_0x448280(0x156)};if(this[_0x448280(0x155)])_0x515e09['Authorization']=_0x448280(0x146)+this['token'];let _0x9c46e0=await(await fetch(this[_0x448280(0x181)]+_0x448280(0x18a),{'method':_0x448280(0x19e),'headers':_0x515e09,'body':JSON['stringify']({'jsonrpc':_0x448280(0x175),'id':Date[_0x448280(0x196)](),'method':_0x448280(0x194),'params':{'name':_0x354da1,'arguments':_0x36fe55}})}))[_0x448280(0x15a)](),_0xdb07fc=_0x9c46e0['match'](/data: (.+)/),_0x2f3765=_0xdb07fc?JSON['parse'](_0xdb07fc[0x1]):JSON[_0x448280(0x182)](_0x9c46e0),_0x402853=_0x2f3765?.[_0x448280(0x1a4)]?.[_0x448280(0x190)]?.[0x0]?.[_0x448280(0x15a)];return _0x402853?JSON[_0x448280(0x182)](_0x402853):_0x2f3765;}async['connect'](){const _0x3c999f=a0_0x1808a5;if(this[_0x3c999f(0x162)])return;this[_0x3c999f(0x162)]=!0x0,await this[_0x3c999f(0x16a)](_0x3c999f(0x176)),this[_0x3c999f(0x1b8)](_0x3c999f(0x199)),this['heartbeatTimer']=setInterval(()=>{const _0x28943f=_0x3c999f;this[_0x28943f(0x16a)](_0x28943f(0x176))[_0x28943f(0x17a)](_0x155200=>this[_0x28943f(0x1b8)](_0x28943f(0x1aa)+_0x155200[_0x28943f(0x193)]));},this[_0x3c999f(0x1b4)]),this[_0x3c999f(0x1a7)]();}async['disconnect'](){const _0x3dd5ba=a0_0x1808a5;if(this['running']=!0x1,this[_0x3dd5ba(0x15e)]?.[_0x3dd5ba(0x148)](),this[_0x3dd5ba(0x1b7)])clearInterval(this[_0x3dd5ba(0x1b7)]);await this['status'](_0x3dd5ba(0x174))[_0x3dd5ba(0x17a)](()=>{}),this['log'](_0x3dd5ba(0x183));}async[a0_0x1808a5(0x145)](_0x5916bd,_0x216cef,_0x308d88=a0_0x1808a5(0x172)){const _0x313256=a0_0x1808a5;return Y({'alias':_0x5916bd,'fromAlias':this[_0x313256(0x170)]},{'log':_0x4ff3d6=>console['log'](_0x4ff3d6),'send':()=>this[_0x313256(0x1b6)](_0x313256(0x147),{'alias':_0x5916bd,'task':_0x216cef,'priority':_0x308d88,'from_session':this['alias']})});}async['message'](_0x5de8c1,_0x12221a){const _0x38eecb=a0_0x1808a5;return this[_0x38eecb(0x1b6)](_0x38eecb(0x1a5),{'alias':_0x5de8c1,'message':_0x12221a,'from_session':this[_0x38eecb(0x170)]});}async[a0_0x1808a5(0x19c)](_0x20eea6,_0x43ff2c,_0xa52fc7='completed'){const _0x10846e=a0_0x1808a5;return this[_0x10846e(0x1b6)]('send_reply',{'in_reply_to':_0x20eea6,'text':_0x43ff2c,'status':_0xa52fc7});}async['status'](_0x294de0,_0x469955){const _0x2a37d1=a0_0x1808a5;return this['call'](_0x2a37d1(0x1be),{'resume_id':this[_0x2a37d1(0x187)],'alias':this[_0x2a37d1(0x170)],'status':_0x294de0,'server':a0_0x272304(),'hostname':a0_0x272304(),'agent':this[_0x2a37d1(0x15d)],'project_dir':process['cwd'](),..._0x469955});}async['getAllStatus'](){const _0x2f219a=a0_0x1808a5;return this['call'](_0x2f219a(0x14c),{});}async[a0_0x1808a5(0x14d)](_0xf592a6,_0x4bbca5){const _0x31945e=a0_0x1808a5;return this[_0x31945e(0x1b6)](_0x31945e(0x14d),{'message':_0xf592a6,'filter_server':_0x4bbca5?.['server'],'filter_status':_0x4bbca5?.[_0x31945e(0x16a)]});}async[a0_0x1808a5(0x1a7)](){const _0x42d796=a0_0x1808a5;let _0x4be0eb=encodeURIComponent(this['alias']),_0x2f629e=this['url']+'/events/'+_0x4be0eb,_0x5f0b0e=this['reconnectDelay'];while(this[_0x42d796(0x162)]){try{this[_0x42d796(0x15e)]=new AbortController();let _0x210d7a={'Accept':_0x42d796(0x1a9)};if(this['token'])_0x210d7a[_0x42d796(0x1b2)]='Bearer\x20'+this[_0x42d796(0x155)];let _0x5c75be=await fetch(_0x2f629e,{'headers':_0x210d7a,'signal':this[_0x42d796(0x15e)][_0x42d796(0x15b)]});if(!_0x5c75be['ok']||!_0x5c75be[_0x42d796(0x14f)]){this['log'](_0x42d796(0x1a8)+_0x5c75be[_0x42d796(0x16a)]),await this[_0x42d796(0x160)](_0x5f0b0e),_0x5f0b0e=Math[_0x42d796(0x179)](_0x5f0b0e*1.5,0xea60);continue;}_0x5f0b0e=this[_0x42d796(0x17c)];let _0x1fa8fc=_0x5c75be[_0x42d796(0x14f)][_0x42d796(0x157)](),_0x5c3350=new TextDecoder(),_0x40c11c='';while(this['running']){let {done:_0x50ba14,value:_0x311a32}=await _0x1fa8fc[_0x42d796(0x1af)]();if(_0x50ba14)break;_0x40c11c+=_0x5c3350[_0x42d796(0x18c)](_0x311a32,{'stream':!0x0});let _0x53b002=_0x40c11c[_0x42d796(0x159)]('\x0a');_0x40c11c=_0x53b002[_0x42d796(0x19a)]()||'';for(let _0xd345d of _0x53b002){if(!_0xd345d[_0x42d796(0x153)](_0x42d796(0x1bc)))continue;try{let _0x43c19d=JSON['parse'](_0xd345d[_0x42d796(0x14e)](0x6));if(_0x43c19d[_0x42d796(0x195)]===_0x42d796(0x161)){this[_0x42d796(0x1b8)](_0x42d796(0x15c)),this[_0x42d796(0x14b)]('connected');continue;}if(_0x43c19d[_0x42d796(0x195)]===_0x42d796(0x142)||_0x43c19d[_0x42d796(0x195)]===_0x42d796(0x154)||_0x43c19d[_0x42d796(0x195)]===_0x42d796(0x14d))await this[_0x42d796(0x164)]();}catch{}}}}catch(_0x507283){if(_0x507283[_0x42d796(0x18b)]==='AbortError')break;this['emit'](_0x42d796(0x185),_0x507283),this[_0x42d796(0x1b8)]('SSE\x20error:\x20'+_0x507283['message']);}if(this['running'])this[_0x42d796(0x14b)](_0x42d796(0x183)),this[_0x42d796(0x1b8)]('SSE\x20reconnecting\x20in\x20'+_0x5f0b0e/0x3e8+_0x42d796(0x1ba)),await this['sleep'](_0x5f0b0e),_0x5f0b0e=Math['min'](_0x5f0b0e*1.5,0xea60);}}async[a0_0x1808a5(0x164)](){const _0x59d40b=a0_0x1808a5;try{let _0x2fe330=(await this[_0x59d40b(0x1b6)](_0x59d40b(0x1a3),{'alias':this[_0x59d40b(0x170)],'limit':0xa}))?.[_0x59d40b(0x16c)]||[];for(let _0x19bc47 of _0x2fe330)await this[_0x59d40b(0x1b6)](_0x59d40b(0x1a1),{'alias':this['alias'],'message_id':_0x19bc47['id']}),this[_0x59d40b(0x1b8)]('←\x20'+_0x19bc47[_0x59d40b(0x149)]+':\x20'+_0x19bc47[_0x59d40b(0x190)]['slice'](0x0,0x3c)),this[_0x59d40b(0x14b)](_0x59d40b(0x19f),_0x19bc47),this[_0x59d40b(0x14b)](_0x59d40b(0x193),_0x19bc47);}catch(_0x1fdedd){this[_0x59d40b(0x1b8)]('inbox\x20error:\x20'+_0x1fdedd[_0x59d40b(0x193)]);}}[a0_0x1808a5(0x160)](_0x49d098){return new Promise(_0x1bda73=>setTimeout(_0x1bda73,_0x49d098));}}var F=$;export{F as default,$ as CommHub};
|
|
@@ -6,8 +6,10 @@ export interface CopresenceDep {
|
|
|
6
6
|
readonly why: string;
|
|
7
7
|
}
|
|
8
8
|
export type CommandProbe = (cmd: string) => boolean;
|
|
9
|
-
|
|
10
|
-
export
|
|
9
|
+
/** Which agent binary this co-presence lane is built on. */
|
|
10
|
+
export type CopresenceAgent = "codex" | "grok";
|
|
11
|
+
export declare function copresenceDeps(probe: CommandProbe, platform?: NodeJS.Platform, agent?: CopresenceAgent): CopresenceDep[];
|
|
12
|
+
export declare function missingCopresenceDeps(probe: CommandProbe, platform?: NodeJS.Platform, agent?: CopresenceAgent): CopresenceDep[];
|
|
11
13
|
/** One block naming every gap and how to close it — never one gap at a time. */
|
|
12
14
|
export declare function describeMissingDeps(missing: readonly CopresenceDep[], displayName: string): string;
|
|
13
15
|
/**
|
|
@@ -45,7 +45,12 @@ export interface GrokAttachResizeFrame {
|
|
|
45
45
|
cols: number;
|
|
46
46
|
rows: number;
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
/** Asks the node to switch models (issue #879); allowed on control connections. */
|
|
49
|
+
export interface GrokAttachSetModelFrame {
|
|
50
|
+
type: "set-model";
|
|
51
|
+
model: string;
|
|
52
|
+
}
|
|
53
|
+
export type GrokAttachClientFrame = GrokAttachInputFrame | GrokAttachResizeFrame | GrokAttachSetModelFrame | GrokAttachDetachFrame;
|
|
49
54
|
export interface GrokAttachInputSource {
|
|
50
55
|
on(event: "data", listener: (chunk: unknown) => void): unknown;
|
|
51
56
|
on(event: "end", listener: () => void): unknown;
|
|
@@ -105,6 +110,15 @@ export interface GrokAttachSession {
|
|
|
105
110
|
readonly closed: Promise<GrokAttachCloseInfo>;
|
|
106
111
|
detach(): void;
|
|
107
112
|
resize(cols?: number, rows?: number): void;
|
|
113
|
+
/**
|
|
114
|
+
* Ask the node to switch models (issue #879).
|
|
115
|
+
*
|
|
116
|
+
* The outcome does not come back from this call — it arrives as a `status`
|
|
117
|
+
* frame carrying `modelSwitch`, because the node may accept, refuse
|
|
118
|
+
* (busy / unchanged / invalid), or fail while re-spawning. Callers read it
|
|
119
|
+
* through `onStatus`.
|
|
120
|
+
*/
|
|
121
|
+
setModel(model: string): void;
|
|
108
122
|
}
|
|
109
123
|
export declare class GrokAttachRemoteError extends Error {
|
|
110
124
|
readonly code: string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** tmux session names. The attachable TUI owns the bare alias so that
|
|
2
|
+
* `tmux attach -t '=<alias>'` lands a human on the TUI, matching the codex
|
|
3
|
+
* lane exactly — an operator should not have to remember which runtime a node
|
|
4
|
+
* uses in order to know where to attach. */
|
|
5
|
+
export declare function grokCopresenceSessions(displayName: string): {
|
|
6
|
+
node: string;
|
|
7
|
+
tui: string;
|
|
8
|
+
};
|
|
9
|
+
export type GrokAttachSocketState = "missing" | "not_a_socket" | "ready";
|
|
10
|
+
/** Readiness is "the attach socket exists AND is a socket", never "the child
|
|
11
|
+
* process started". A grok leader that dies during startup leaves either no
|
|
12
|
+
* socket at all or a stale regular file from an aborted run; both used to read
|
|
13
|
+
* as ready because nothing looked. */
|
|
14
|
+
export declare function grokAttachSocketState(entry: {
|
|
15
|
+
isSocket(): boolean;
|
|
16
|
+
} | null | undefined): GrokAttachSocketState;
|
|
17
|
+
/** Set on the node child so that `anet node start` inside the tmux session does
|
|
18
|
+
* not re-enter this orchestration and fork bomb. The codex lane guards on the
|
|
19
|
+
* same variable (cli.ts: `process.env.ANET_COPRESENCE_BRIDGE !== "1"`); using a
|
|
20
|
+
* second name would leave two guards that must be kept in sync by hand. */
|
|
21
|
+
export declare const GROK_COPRESENCE_CHILD_ENV = "ANET_COPRESENCE_BRIDGE";
|
|
22
|
+
export interface GrokCopresenceDiagnosis {
|
|
23
|
+
readonly ok: boolean;
|
|
24
|
+
readonly lines: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
/** One block naming every reason this node cannot run the shared TUI, not one
|
|
27
|
+
* exit per reason. A node that is both the wrong runtime AND missing its
|
|
28
|
+
* attach socket should learn both in one run. */
|
|
29
|
+
/** Platforms whose PTY / IPC / isolation primitives the grok co-presence lane
|
|
30
|
+
* has actually been validated on. agent-node refuses anywhere else, and it does
|
|
31
|
+
* so only after the node has been created and started once:
|
|
32
|
+
*
|
|
33
|
+
* [agent-node] grok-build-cli co-presence 无法在 darwin 上运行,缺少:
|
|
34
|
+
* 平台 darwin 尚未验证过共存所需的 PTY / IPC / 隔离原语
|
|
35
|
+
*
|
|
36
|
+
* Learned the expensive way on a Mac mini: install anet, install agent-node,
|
|
37
|
+
* create the node, start it — and only then find out the platform is refused.
|
|
38
|
+
* A one-command launcher that lets someone get that far has not saved them
|
|
39
|
+
* anything, so say it in the same breath as every other gap. */
|
|
40
|
+
export declare const GROK_COPRESENCE_PLATFORMS: readonly NodeJS.Platform[];
|
|
41
|
+
export declare function diagnoseGrokCopresence(input: {
|
|
42
|
+
runtime: string;
|
|
43
|
+
displayName: string;
|
|
44
|
+
grokCopresence?: boolean;
|
|
45
|
+
grokAttachSocket?: string;
|
|
46
|
+
platform?: NodeJS.Platform;
|
|
47
|
+
}): GrokCopresenceDiagnosis;
|
|
48
|
+
/** True when a plain `anet node start <name>` (no flag) should bring the shared
|
|
49
|
+
* TUI up by itself.
|
|
50
|
+
*
|
|
51
|
+
* 🔴 Deliberately NOT keyed on `grokCopresence`. That field is set to true at
|
|
52
|
+
* CREATE time for every grok-build-cli node, so reading it here would silently
|
|
53
|
+
* change what `anet node start` does for every grok node that already exists —
|
|
54
|
+
* they would stop running in the foreground and fork into tmux, unasked. Caught
|
|
55
|
+
* exactly that way: a start without the flag entered the orchestration.
|
|
56
|
+
*
|
|
57
|
+
* The codex lane looks the same but is not: `codexCopresence` is written only
|
|
58
|
+
* when the operator passes the flag. So grok needs its own record of the
|
|
59
|
+
* operator's choice, and `grokCopresenceAuto` is it. */
|
|
60
|
+
export declare function grokCopresenceRequested(flagPassed: boolean, profile: {
|
|
61
|
+
runtime?: unknown;
|
|
62
|
+
grokCopresence?: unknown;
|
|
63
|
+
grokCopresenceAuto?: unknown;
|
|
64
|
+
}): boolean;
|
|
65
|
+
/** Record the operator's opt-in so the NEXT start needs no flag — and only then.
|
|
66
|
+
* Never infer it from `grokCopresence`, which create sets by default. */
|
|
67
|
+
export declare function shouldPersistGrokCopresence(flagPassed: boolean, profile: {
|
|
68
|
+
runtime?: unknown;
|
|
69
|
+
grokCopresenceAuto?: unknown;
|
|
70
|
+
}): boolean;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { IMCorrelationStore, IMTaskCorrelation } from "./types";
|
|
2
|
+
export interface JsonIMCorrelationStoreOptions {
|
|
3
|
+
now?: () => number;
|
|
4
|
+
/** How long idempotency keys remain valid. Defaults to 24h. */
|
|
5
|
+
seenTtlMs?: number;
|
|
6
|
+
/** How long terminal correlations remain queryable. Defaults to 24h. */
|
|
7
|
+
terminalTtlMs?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Small durable store for RFC-020 §2.9④ / §4.4 correlation state.
|
|
11
|
+
*
|
|
12
|
+
* The first gateway PR needs this as a standalone data structure before the
|
|
13
|
+
* bridge is rewired: idempotency keys survive process restart, and task replies
|
|
14
|
+
* can be routed back to their originating IM conversation.
|
|
15
|
+
*/
|
|
16
|
+
export declare class JsonIMCorrelationStore implements IMCorrelationStore {
|
|
17
|
+
private readonly path;
|
|
18
|
+
private readonly now;
|
|
19
|
+
private readonly seenTtlMs;
|
|
20
|
+
private readonly terminalTtlMs;
|
|
21
|
+
constructor(path: string, options?: JsonIMCorrelationStoreOptions);
|
|
22
|
+
hasSeen(idempotencyKey: string): Promise<string | null>;
|
|
23
|
+
recordSeen(idempotencyKey: string, taskId: string): Promise<void>;
|
|
24
|
+
getCorrelation(taskId: string): Promise<IMTaskCorrelation | null>;
|
|
25
|
+
putCorrelation(taskId: string, correlation: IMTaskCorrelation): Promise<void>;
|
|
26
|
+
updateStatus(taskId: string, status: IMTaskCorrelation["status"]): Promise<void>;
|
|
27
|
+
gc(now: number): Promise<{
|
|
28
|
+
removed: number;
|
|
29
|
+
}>;
|
|
30
|
+
private isExpired;
|
|
31
|
+
private load;
|
|
32
|
+
private save;
|
|
33
|
+
}
|
|
34
|
+
export declare function createJsonIMCorrelationStore(path: string, options?: JsonIMCorrelationStoreOptions): IMCorrelationStore;
|
|
@@ -29,8 +29,29 @@
|
|
|
29
29
|
* M4: agent-node spawn integration (fork(this) wired by agent-node).
|
|
30
30
|
* M5: group @bot trigger refinement, image up/down, Docker smoke.
|
|
31
31
|
*/
|
|
32
|
-
import type { NormalizedIMEvent } from "../types.js";
|
|
32
|
+
import type { IMCorrelationStore, NormalizedIMEvent } from "../types.js";
|
|
33
33
|
import { FeishuAdapter } from "./adapter.js";
|
|
34
|
+
export type IMBridgeCommHubInboxMessage = {
|
|
35
|
+
id: string;
|
|
36
|
+
type?: string;
|
|
37
|
+
content: string;
|
|
38
|
+
from_session?: string;
|
|
39
|
+
in_reply_to?: string;
|
|
40
|
+
meta?: unknown;
|
|
41
|
+
};
|
|
42
|
+
export interface IMBridgeCommHubClient {
|
|
43
|
+
sendTask(args: {
|
|
44
|
+
alias: string;
|
|
45
|
+
task: string;
|
|
46
|
+
priority?: "high" | "normal" | "low";
|
|
47
|
+
ttlSeconds?: number;
|
|
48
|
+
meta?: unknown;
|
|
49
|
+
}): Promise<{
|
|
50
|
+
taskId: string;
|
|
51
|
+
}>;
|
|
52
|
+
getInbox(alias: string): Promise<IMBridgeCommHubInboxMessage[]>;
|
|
53
|
+
ackInbox(alias: string, messageId: string): Promise<void>;
|
|
54
|
+
}
|
|
34
55
|
export interface FeishuBridgeOptions {
|
|
35
56
|
/** Absolute path to `.anet/nodes/<node>/channels/feishu/`. */
|
|
36
57
|
channelDir: string;
|
|
@@ -46,6 +67,12 @@ export interface FeishuBridgeOptions {
|
|
|
46
67
|
onEvent?: (event: NormalizedIMEvent) => Promise<void>;
|
|
47
68
|
/** Fatal WS failure after initial readiness (for worker lifecycle ownership). */
|
|
48
69
|
onTerminalError?: (error: Error) => void;
|
|
70
|
+
/** Persistent task/message correlation state. Defaults to channelDir/state.json. */
|
|
71
|
+
correlationStore?: IMCorrelationStore;
|
|
72
|
+
/** CommHub task transport. Defaults to COMMHUB_URL/COMMHUB_TOKEN when available. */
|
|
73
|
+
commhubClient?: IMBridgeCommHubClient;
|
|
74
|
+
/** Poll interval for CommHub replies. Defaults to 1500ms. */
|
|
75
|
+
commhubPollMs?: number;
|
|
49
76
|
}
|
|
50
77
|
/** Bridge → parent: inbound IM event ready for think(). */
|
|
51
78
|
export interface BridgeIncomingEnvelope {
|
|
@@ -127,7 +154,8 @@ export type WithRateLimitHandle = {
|
|
|
127
154
|
* the agent-node.log (closes the prior silent-success blindspot).
|
|
128
155
|
*/
|
|
129
156
|
/** @internal exported for test harness; not intended for production callers. */
|
|
130
|
-
export declare function createIPCEventHandler(adapter: FeishuAdapter, ttlMs: number, ackPlaceholder: boolean): (event: NormalizedIMEvent) => Promise<void>;
|
|
157
|
+
export declare function createIPCEventHandler(adapter: FeishuAdapter, ttlMs: number, ackPlaceholder: boolean, correlationStore?: IMCorrelationStore): (event: NormalizedIMEvent) => Promise<void>;
|
|
158
|
+
export declare function createCommHubEventHandler(nodeAlias: string, adapter: FeishuAdapter, ttlMs: number, ackPlaceholder: boolean, correlationStore: IMCorrelationStore | undefined, commhubClient: IMBridgeCommHubClient, pollMs?: number): (event: NormalizedIMEvent) => Promise<void>;
|
|
131
159
|
export { FeishuAdapter } from "./adapter.js";
|
|
132
160
|
export { loadFeishuChannelConfig } from "./config.js";
|
|
133
161
|
export type { FeishuAccessList, FeishuChannelConfig, FeishuChannelEnv, } from "./config.js";
|