@kmlckj/licos-bridge 0.0.1 → 0.0.3
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/README.md +6 -1
- package/dist/index.js +1 -1
- package/dist/lib/acp-runtime.js +1 -1
- package/dist/lib/agent-manager.js +1 -1
- package/dist/lib/cli.js +1 -1
- package/dist/lib/cloud.js +1 -1
- package/dist/lib/daemon.js +1 -1
- package/dist/lib/frameworks.js +1 -1
- package/dist/lib/ipc.js +1 -1
- package/dist/lib/local-commands.js +1 -1
- package/dist/lib/paths.js +1 -1
- package/dist/lib/service.js +1 -1
- package/dist/lib/utils.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,10 +46,15 @@ licos-bridge service uninstall
|
|
|
46
46
|
|
|
47
47
|
- `LICOS_BRIDGE_HOME`
|
|
48
48
|
- `LICOS_BRIDGE_AGENTS_HOME`
|
|
49
|
+
- `LICOS_BRIDGE_HANDSHAKE_URL`
|
|
50
|
+
- `LICOS_PLATFORM_BASE_URL`
|
|
51
|
+
- `AIOS_PLATFORM_BASE_URL`
|
|
49
52
|
|
|
50
53
|
## 云端协议入口
|
|
51
54
|
|
|
52
|
-
`--handshake-url` 可以是平台 base URL,也可以直接是 handshake endpoint
|
|
55
|
+
`--handshake-url` 可以是平台 base URL,也可以直接是 handshake endpoint。平台生成的连接命令会显式携带这个参数;如果手写命令,可以通过 `LICOS_BRIDGE_HANDSHAKE_URL`、`LICOS_PLATFORM_BASE_URL` 或 `AIOS_PLATFORM_BASE_URL` 提供。
|
|
56
|
+
|
|
57
|
+
桥接工具不再内置固定平台地址。没有命令参数、没有本地已保存地址、也没有环境变量时会直接报错,避免 dev/prod 环境串连。历史版本保存的 `https://www.licos.com` 默认地址在自动重连时会被拒绝,需要从目标平台重新复制连接命令。
|
|
53
58
|
|
|
54
59
|
默认 handshake path:
|
|
55
60
|
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const Y=h;(function(
|
|
2
|
+
const W=h;function b(){const Y=['/refresh','stop','licos-bridge\x20daemon\x20stopped.','daemon','11HRXkbk','error','5005710dKiGYb','status','stringify','mode','Deprecated:\x20','/pair','message','156443OaTuDg','log','19484aNEQBC','exitCode','1082438SokDsE','126OhTPsF','version','argv','349308eTqfdn','licos-bridge\x20daemon\x20is\x20not\x20running.','3398816mMVIEB','3VryYJT','update','123706SRBBbx','575TnRxrE'];b=function(){return Y;};return b();}function h(a,c){a=a-0xc8;const d=b();let e=d[a];return e;}(function(E,F){const U=h,G=E();while(!![]){try{const H=-parseInt(U(0xca))/0x1+parseInt(U(0xdd))/0x2*(-parseInt(U(0xc8))/0x3)+parseInt(U(0xdb))/0x4*(parseInt(U(0xcb))/0x5)+parseInt(U(0xde))/0x6*(-parseInt(U(0xd9))/0x7)+parseInt(U(0xe3))/0x8+-parseInt(U(0xe1))/0x9+parseInt(U(0xd2))/0xa*(parseInt(U(0xd0))/0xb);if(H===F)break;else G['push'](G['shift']());}catch(I){G['push'](G['shift']());}}}(b,0x4c4ca));import{parseArgs as j,printHelp as k}from'./lib/cli.js';import{ensureDaemon as p,ipcRequest as q,readDaemonInfo as u,startDaemon as v}from'./lib/ipc.js';import{buildSendPayload as w,packageVersion as x,printLogs as y,purgeBridge as z,runUpdate as A,statusSnapshot as B}from'./lib/local-commands.js';import{installService as C,uninstallService as D}from'./lib/service.js';(async function(E){const V=h,F=j(E);if(F['deprecated']&&console[V(0xd1)](V(0xd6)+F['deprecated']),'help'!==F[V(0xd5)]){if(V(0xdf)!==F[V(0xd5)]){if(V(0xcf)===F[V(0xd5)]){const {startDaemonServer:G}=await import('./lib/daemon.js');return void await G();}if(V(0xd3)===F['mode']){const H=await B();return void console['log'](JSON['stringify'](H,null,0x2));}if(V(0xcd)===F['mode']){const I=await u();return I?(await q('/stop',{},I),void console['log'](V(0xce))):void console['log'](V(0xe2));}if('refresh'===F['mode']){const J=await p(),K=await q(V(0xcc),{},J);return void console['log'](JSON['stringify'](K,null,0x2));}if('reload'===F['mode']){const L=await p(),M=await q('/reload',{'agentId':F['agentId']},L);return void console[V(0xda)](JSON['stringify'](M,null,0x2));}if(V(0xda)!==F['mode']){if(V(0xc9)!==F['mode']){if('purge'===F['mode'])return await z(),void console[V(0xda)]('licos-bridge\x20bridge\x20data\x20purged.');if('service-install'!==F[V(0xd5)]){if('service-uninstall'!==F[V(0xd5)]){if('pair'===F['mode']){const N=await p(),O=await q(V(0xd7),F,N);return void console['log'](JSON['stringify'](O,null,0x2));}if('connect'===F[V(0xd5)]){const P=await p(),Q=await q('/connect',F,P);return void console['log'](JSON[V(0xd4)](Q,null,0x2));}if('send'===F[V(0xd5)]){const R=await p(),S=await w(F),T=await q('/send',S,R);return void console['log'](JSON[V(0xd4)](T,null,0x2));}if('spawn-daemon'!==F['mode'])throw new Error('unsupported\x20command\x20mode:\x20'+F[V(0xd5)]);await v();}else await D();}else await C();}else await A();}else await y(F);}else console[V(0xda)](await x());}else k();}(process[W(0xe0)]['slice'](0x2))['catch'](E=>{const X=W;console[X(0xd1)](E instanceof Error?E[X(0xd8)]:String(E)),process[X(0xdc)]=0x1;}));
|
package/dist/lib/acp-runtime.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const H=d;(function(x,y){const C=d,z=x();while(!![]){try{const A=parseInt(C(0x192))/0x1*(-parseInt(C(0x195))/0x2)+parseInt(C(0x18c))/0x3+parseInt(C(0x187))/0x4*(parseInt(C(0x17e))/0x5)+parseInt(C(0x17d))/0x6+-parseInt(C(0x18a))/0x7+parseInt(C(0x190))/0x8*(-parseInt(C(0x193))/0x9)+-parseInt(C(0x177))/0xa*(parseInt(C(0x19a))/0xb);if(A===y)break;else z['push'](z['shift']());}catch(B){z['push'](z['shift']());}}}(b,0x42856));import{spawn as f}from'node:child_process';import{readFile as g,writeFile as j}from'node:fs/promises';import{Readable as k,Writable as l}from'node:stream';import m from'node:path';import*as q from'@agentclientprotocol/sdk';import{resolveAcpBin as u}from'./frameworks.js';function d(a,c){a=a-0x174;const e=b();let f=e[a];return f;}import{ensureDir as v,safeResolve as w}from'./utils.js';export class AcpRuntime{constructor({agentConfig:x,onUpdate:y,onClientRequest:z,logger:A}){const D=d;this['agentConfig']=x,this['onUpdate']=y,this['onClientRequest']=z,this[D(0x19f)]=A,this['sessions']=new Map(),this['process']=void 0x0,this[D(0x17a)]=void 0x0,this['closed']=!0x1;}async['start'](){const E=d;if(this['connection'])return;await v(this[E(0x194)][E(0x191)]);const x=await u(this[E(0x194)][E(0x185)]);this[E(0x18e)]=f(x['command'],x['args'],{'cwd':this['agentConfig']['workspace'],'stdio':['pipe','pipe',E(0x19e)],'windowsHide':!0x0,'env':{...process.env,'LICOS_BRIDGE_AGENT_ID':this['agentConfig']['agentId'],'LICOS_BRIDGE_FRAMEWORK':this['agentConfig'][E(0x185)]}}),this[E(0x18e)][E(0x175)]?.['on'](E(0x196),A=>{const F=E;this[F(0x19f)]?.(F(0x184),{'agentId':this[F(0x194)][F(0x179)],'text':A[F(0x19d)]('utf8')['trim']()});}),this['process']['on']('exit',(A,B)=>{const G=E;this['closed']=!0x0,this[G(0x17a)]=void 0x0,this['logger']?.('acp\x20process\x20exited',{'agentId':this[G(0x194)][G(0x179)],'code':A,'signal':B});});const y=q[E(0x174)](l['toWeb'](this[E(0x18e)]['stdin']),k['toWeb'](this[E(0x18e)]['stdout'])),z=new h(this);this['connection']=new q['ClientSideConnection'](()=>z,y),await this[E(0x17a)]['initialize']({'protocolVersion':q['PROTOCOL_VERSION'],'clientCapabilities':{'fs':{'readTextFile':!0x0,'writeTextFile':!0x0}}});}async[H(0x181)](x,y={}){const I=H;await this['start']();const z=this['sessions'][I(0x18d)](x);if(z)return z;const A=await this[I(0x17a)]['newSession']({'cwd':this[I(0x194)]['workspace'],'mcpServers':y['mcpServers']??this['agentConfig']['mcpServers']??[],'_meta':y[I(0x17b)]});return this[I(0x188)][I(0x176)](x,A[I(0x199)]),A['sessionId'];}async[H(0x180)](x){const J=H,y=x['sessionId'];if(!y)throw new Error(J(0x17c));const z=await this['ensureSession'](y,x);return this[J(0x17a)][J(0x180)]({...x,'sessionId':z});}async['cancel'](x){const K=H,y=this['sessions']['get'](x[K(0x199)]);this[K(0x17a)]&&y&&await this[K(0x17a)][K(0x18f)]({...x,'sessionId':y});}async['stop'](x='stop'){const L=H;this['closed']=!0x0,this['logger']?.('stopping\x20acp\x20runtime',{'agentId':this['agentConfig']['agentId'],'reason':x}),this['process']?.['kill'](),this['process']=void 0x0,this[L(0x17a)]=void 0x0,this['sessions']['clear']();}[H(0x18b)](){const M=H;return Boolean(this['process']&&!this['closed']&&null===this['process'][M(0x182)]);}}function b(){const S=['20ZFZola','startsWith','agentId','connection','_meta','session/prompt\x20missing\x20sessionId','3227142MRBlJd','5SSKkYM','requestPermission','prompt','ensureSession','exitCode','dirname','acp\x20stderr','framework','runtime','1760076zobEWQ','sessions','options','551663LeitjR','isAlive','1106346KEIZzx','get','process','cancel','8OKlhyt','workspace','153vFwCBH','3638637mlSWcp','agentConfig','2348KzMPgw','data','path','optionId','sessionId','2263052GlZwam','onUpdate','kind','toString','pipe','logger','ndJsonStream','stderr','set'];b=function(){return S;};return b();}class h{constructor(x){const N=H;this[N(0x186)]=x;}async['sessionUpdate'](x){const O=H;await this['runtime'][O(0x19b)]?.(this['runtime']['agentConfig'],x);}async[H(0x17f)](x){const P=H,y=await this['runtime']['onClientRequest']?.(this['runtime'][P(0x194)],'session/request_permission',x);if(y)return y;const z=x[P(0x189)]?.['find'](A=>String(A[P(0x19c)]||'')[P(0x178)]('allow'))??x['options']?.[0x0];return z?.[P(0x198)]?{'outcome':{'outcome':'selected','optionId':z[P(0x198)]}}:{'outcome':{'outcome':'cancelled'}};}async['readTextFile'](x){const Q=H,y=w(this[Q(0x186)]['agentConfig']['workspace'],x[Q(0x197)]);return{'content':await g(y,'utf8')};}async['writeTextFile'](x){const R=H,y=w(this['runtime']['agentConfig']['workspace'],x['path']);return await v(m[R(0x183)](y)),await j(y,x['content']??'','utf8'),{};}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function b(){const aN=['9dHKNIJ','relPath','directory','skillId','text','deployType','loadPersistedAgents','replace','isFile','description','build','find','has','trunc','adm-zip','toISOString','workspace','min','938296hGXrGq','path','platform','now','getData','isArray','entryName',':\x20missing\x20_meta.cozeAgentId','8410tOXIqj','icon','getEntries','content','updateAgentSkills','forwardClientRequest','byteLength','iconUrl','running','stop','cozeAgentId','name','logs','model','installedAt','trim','accessToken','listSkills','cozeIdentity','\x0adescription:\x20','skill_md','match','_agent/getFileContent:\x20missing\x20path','runtimeProvider','1115890qYvQKo','.turbo','removeSkills','configFile','agent\x20','addSkills','runtime','112pkwKEF','.cache','join','enabled','sessionId','_meta','cloud','logger','4839XpnIex','size','handleSession','14397880cDGFMt','register','config','2936472swcIyq','mtimeMs','installSkill','truncated','agent\x20not\x20found:\x20','__pycache__','isDirectory','node_modules','fileTreeExclude','access_token','createOrUpdate','subarray','requireAgent','catch','AGENTS.md','564poXrMK','---\x0aname:\x20','localeCompare','prompt','agentId','depth','2082472rfDkcZ','skills','archive_url','utf8','session/new','skillMd','SKILL.md','push','agents','maxDepth','dist'];b=function(){return aN;};return b();}const ah=j;(function(R,U){const ag=j,V=R();while(!![]){try{const W=-parseInt(ag(0x1d1))/0x1*(parseInt(ag(0x1b2))/0x2)+parseInt(ag(0x1d9))/0x3*(-parseInt(ag(0x1ee))/0x4)+parseInt(ag(0x1ca))/0x5+-parseInt(ag(0x1df))/0x6+-parseInt(ag(0x1f4))/0x7+parseInt(ag(0x1aa))/0x8*(parseInt(ag(0x198))/0x9)+parseInt(ag(0x1dc))/0xa;if(W===U)break;else V['push'](V['shift']());}catch(X){V['push'](V['shift']());}}}(b,0x48028));import{randomUUID as q}from'node:crypto';import{readdir as x,readFile as z,rm as B,stat as C,writeFile as D}from'node:fs/promises';import E from'node:path';import{AcpRuntime as F}from'./acp-runtime.js';function j(a,c){a=a-0x194;const d=b();let e=d[a];return e;}import{agentPaths as G,resolvePaths as H}from'./paths.js';import{ensureDir as J,normalizeFramework as K,pathExists as L,readJson as M,safeName as N,safeRelativePath as O,safeResolve as P,writeJson as Q}from'./utils.js';const k=new Set([ah(0x1e6),'.git','.next','.nuxt',ah(0x1cb),ah(0x1d2),ah(0x197),ah(0x1a2),'target','coverage','.venv',ah(0x1e4)]);export class AgentManager{constructor({cloud:R,logger:U}){const ai=ah;this['cloud']=R,this[ai(0x1d8)]=U,this[ai(0x195)]=new Map();}async[ah(0x19e)](){const aj=ah,R=H();await J(R['agentsRoot']);const U=await x(R['agentsRoot'],{'withFileTypes':!0x0})[aj(0x1ec)](()=>[]);for(const V of U){if(!V['isDirectory']())continue;const W=G(V['name'])[aj(0x1cd)],X=await M(W)[aj(0x1ec)](()=>{});X?.['agentId']&&!X['disconnectedAt']&&this[aj(0x1dd)](X);}}[ah(0x1dd)](R){const ak=ah,U={'deployType':'local',...R,'framework':K(R['framework'])};return this[ak(0x195)]['set'](U['agentId'],{'config':U,'runtime':void 0x0,'lastActiveAt':Date['now']()}),U;}async[ah(0x1e9)](R={}){const al=ah,U=R[al(0x1f2)]||R['id']||q(),V=G(U);await J(V['workspace']),await J(V[al(0x1be)]);const W=await M(V['configFile'],{})['catch'](()=>({})),X={...W,'agentId':U,'name':R[al(0x1bd)]||W['name']||U,'framework':K(R['framework']||R[al(0x1c9)]||R['runtime_provider']||W['framework']||'codex'),'deployType':al(0x1d7)===R['_meta']?.['cozeDeployType']?al(0x1d7):R['deployType']||W['deployType']||'local','workspace':R['workspace']||W['workspace']||V[al(0x1a8)],'cozeIdentity':R[al(0x1c4)]??R['instructions']??W[al(0x1c4)]??'','model':R['model']??W[al(0x1bf)],'modelInfo':R['modelInfo']??W['modelInfo'],'mcpServers':R['mcpServers']??W['mcpServers']??[],'updatedAt':new Date()[al(0x1a7)](),'createdAt':W['createdAt']||new Date()['toISOString']()};return X['cozeIdentity']&&await async function(Y){const am=al,Z=Y['cozeIdentity'][am(0x1c1)]();if(!Z)return;await J(Y[am(0x1a8)]);const a0='claude-code'===Y['framework']?['CLAUDE.md','AGENTS.md']:[am(0x1ed)];for(const a1 of a0){const a2=E['join'](Y[am(0x1a8)],a1);if(!await L(a2)){await D(a2,Z+'\x0a','utf8');continue;}const a3=await z(a2,am(0x1f7));a3['includes'](Z)||await D(a2,a3['trimEnd']()+'\x0a\x0a'+Z+'\x0a',am(0x1f7));}}(X),await Q(V[al(0x1cd)],X,0x180),this['register'](X);}async['disconnect'](R,U){const an=ah,V=this['agents']['get'](R);V?.['runtime']&&await V[an(0x1d0)]['stop'](U||'disconnect'),this[an(0x195)]['delete'](R);const W=G(R)['configFile'],X=await M(W,{})[an(0x1ec)](()=>({}));await Q(W,{...X,'disconnectedAt':Date[an(0x1ad)](),'disconnectReason':U||''},0x180);}async['reload'](R){const ao=ah,U=R?[this[ao(0x1eb)]({'agentId':R})]:[...this['agents']['values']()],V=[];for(const W of U)W[ao(0x1d0)]&&(await W['runtime'][ao(0x1bb)]('reload'),W['runtime']=void 0x0),V['push'](W[ao(0x1de)]['agentId']);return{'ok':!0x0,'reloaded':V};}async['detail'](R={}){const ap=ah,U=this[ap(0x1eb)](R);return{'agent':A(U['config']),'health':this['health']()[ap(0x1a3)](V=>V['agentId']===U['config']['agentId'])};}async['getFileTree'](R={}){const aq=ah,U=this[aq(0x1eb)](R),V=U[aq(0x1de)][aq(0x1a8)],W=O(R[aq(0x1ab)]??R['filePath']??''),X=P(V,W),Y=I(R[aq(0x196)]??R[aq(0x1f3)]??0x5,0x0,0x14),Z=function(a1,a2){const ar=aq,a3=new Set(k);for(const a4 of a1[ar(0x1e7)]??[])a3['add'](a4);for(const a5 of a2['exclude']??[])a3['add'](a5);for(const a6 of a2['include']??[])a3['delete'](a6);return a3;}(U['config'],R),a0={'count':0x0,'truncated':!0x1};return{'workspace':V,'path':W,'tree':await y(V,X,W,Y,Z,a0),'truncated':a0[aq(0x1e2)],'totalNodes':a0['count']};}async['getFileContent'](R={}){const as=ah,U=this['requireAgent'](R)['config'][as(0x1a8)],V=O(R['path']??R['filePath']);if(!V)throw new Error(as(0x1c8));const W=P(U,V),X=await C(W);if(!X[as(0x1a0)]())throw new Error('not\x20a\x20file:\x20'+V);const Y=I(R['maxBytes']??0x100000,0x1,0xa00000),Z=await z(W),a0=Z['byteLength']>Y?Z[as(0x1ea)](0x0,Y):Z;return{'path':V,'size':Z[as(0x1b8)],'content':a0['toString'](R['encoding']||as(0x1f7)),'encoding':R['encoding']||as(0x1f7),'truncated':Z[as(0x1b8)]>Y,'mtimeMs':X['mtimeMs']};}async[ah(0x1c3)](R={}){const at=ah,U=this[at(0x1eb)](R);return{'agentId':U['config'][at(0x1f2)],'skills':S(U['config']['skills']??[])};}async[ah(0x1cf)](R={}){const au=ah,U=this[au(0x1eb)](R),V=Array[au(0x1af)](R['skills'])?R[au(0x1f5)]:[];if(0x0===V['length'])return{'installedSkills':[],'skills':S(U['config'][au(0x1f5)]??[])};const W=[],X=S(U['config']['skills']??[]),Y=new Map(X['map']((Z,a0)=>[Z['skillId'],a0]));for(const Z of V){const a0=await this['installSkill'](U['config'],Z,R);Y[au(0x1a4)](a0['skillId'])?X[Y['get'](a0[au(0x19b)])]=a0:(Y['set'](a0['skillId'],X['length']),X['push'](a0)),W[au(0x194)](a0);}return await this[au(0x1b6)](U,X,'skills-added'),{'installedSkills':W,'skills':X};}async[ah(0x1cc)](R={}){const av=ah,U=this['requireAgent'](R),V=new Set((R['skillIds']??R['skills']??[])['map'](Z=>'string'==typeof Z?Z:v(Z)));if(0x0===V['size'])return{'ok':!0x0,'skills':S(U[av(0x1de)][av(0x1f5)]??[])};const W=S(U['config']['skills']??[]),X=[],Y=[];for(const Z of W){if(!V['has'](Z['skillId'])){X[av(0x194)](Z);continue;}const a0=P(U[av(0x1de)]['workspace'],Z[av(0x199)]);await B(a0,{'recursive':!0x0,'force':!0x0}),Y['push'](Z);}return await this[av(0x1b6)](U,X,'skills-removed'),{'ok':!0x0,'removedSkills':Y,'skills':X};}async[ah(0x1db)](R,U){const aw=ah,V=U?.[aw(0x1d6)]?.[aw(0x1bc)]||U?.['agentId'];if(!V)throw new Error(R+aw(0x1b1));const W=this['agents']['get'](V);if(!W)throw new Error(aw(0x1e3)+V);if(W['lastActiveAt']=Date['now'](),aw(0x1f8)===R)return{'sessionId':U[aw(0x1d5)]||q()};if('session/cancel'===R)return await W['runtime']?.['cancel'](U),{'ok':!0x0};if('session/prompt'!==R)throw new Error('unsupported\x20session\x20method:\x20'+R);if('cloud'===W[aw(0x1de)]['deployType'])throw new Error(aw(0x1ce)+V+'\x20is\x20cloud\x20deploy\x20type;\x20local\x20bridge\x20does\x20not\x20spawn\x20it');const X=function(Y={}){const ax=aw,Z={...Y};if(!Array['isArray'](Z['prompt'])){const a0=Z['content']??Z['text']??Z['message']??'';Z[ax(0x1f1)]=[{'type':'text','text':String(a0)}];}return Z;}(U);return W['runtime']||(W[aw(0x1d0)]=new F({'agentConfig':W['config'],'onUpdate':(Y,Z)=>this[aw(0x1d7)]['sendNotification']('session/update',{...Z,'_meta':{...Z['_meta']||{},'cozeAgentId':Y['agentId'],'cozeCloudSessionId':X['sessionId'],'licosTurnId':X[aw(0x1d6)]?.['licosTurnId']}}),'onClientRequest':(Y,Z,a0)=>this[aw(0x1d7)][aw(0x1b7)](Y,Z,a0),'logger':this['logger']})),W['runtime']['prompt'](X);}async['stopAll'](R){for(const U of this['agents']['values']())await U['runtime']?.['stop'](R);}[ah(0x1eb)](R={}){const ay=ah,U=R?.['_meta']?.['cozeAgentId']||R?.['agentId']||R?.['id'];if(!U)throw new Error('missing\x20agentId');const V=this['agents']['get'](U);if(!V)throw new Error(ay(0x1e3)+U);return V;}async['updateAgentSkills'](R,U,V){const az=ah;R['config']['skills']=S(U),R[az(0x1de)]['updatedAt']=new Date()['toISOString'](),await Q(G(R['config']['agentId'])['configFile'],R[az(0x1de)],0x180),R[az(0x1d0)]&&(await R['runtime']['stop'](V),R['runtime']=void 0x0);}async[ah(0x1e1)](R,U,V){const aB=ah,W=v(U),X=N(W,'skill'),Y=O(U['relPath']||'.skills/'+X),Z=P(R['workspace'],Y);await B(Z,{'recursive':!0x0,'force':!0x0}),await J(Z),U['files']?await async function(a1,a2){const aA=j;if(Array['isArray'](a2))for(const a3 of a2){const a4=O(a3[aA(0x1ab)]||a3[aA(0x1bd)]);await J(E['dirname'](E[aA(0x1d3)](a1,a4))),await D(P(a1,a4),String(a3[aA(0x1b5)]??''),'utf8');}else for(const [a5,a6]of Object['entries'](a2)){const a7=O(a5);await J(E['dirname'](E[aA(0x1d3)](a1,a7))),await D(P(a1,a7),String(a6??''),'utf8');}}(Z,U['files']):U['content']||U[aB(0x1f9)]||U[aB(0x1c6)]?await D(E['join'](Z,'SKILL.md'),String(U[aB(0x1b5)]??U['skillMd']??U['skill_md']),'utf8'):$(U)?await async function(a1,a2,a3){const aC=aB,a4=$(a2),a5={},a6=a2['token']||a2['accessToken']||a2[aC(0x1e8)]||a3['token']||a3[aC(0x1c2)]||a3['access_token'];a6&&(a5['authorization']='Bearer\x20'+a6);const a7=await fetch(a4,{'headers':a5});if(!a7['ok'])throw new Error('download\x20skill\x20failed:\x20HTTP\x20'+a7['status']+'\x20'+await a7[aC(0x19c)]());const a8=Buffer['from'](await a7['arrayBuffer']());await async function(a9,aa){const aD=aC,{default:ab}=await import(aD(0x1a6)),ac=new ab(aa);for(const ad of ac[aD(0x1b4)]()){if(ad['isDirectory'])continue;const ae=O(ad[aD(0x1b0)]),af=P(a9,ae);await J(E['dirname'](af)),await D(af,ad[aD(0x1ae)]());}}(a1,a8);}(Z,U,V):await D(E[aB(0x1d3)](Z,aB(0x1fa)),function(a1){const aE=aB,a2=a1['name']||v(a1),a3=a1[aE(0x1a1)]||'';return aE(0x1ef)+a2+aE(0x1c5)+a3+'\x0a---\x0a\x0a#\x20'+a2+'\x0a\x0a'+a3+'\x0a';}(U),'utf8');const a0=await async function(a1){const aF=aB,a2=await z(E[aF(0x1d3)](a1,'SKILL.md'),aF(0x1f7))['catch'](()=>''),a3=a2['match'](/^---\s*([\s\S]*?)\s*---/),a4=a3?.[0x1]||a2;return{'name':T(a4,'name')||a2[aF(0x1c7)](/^#\s+(.+)$/m)?.[0x1]?.[aF(0x1c1)](),'description':T(a4,'description')||T(a4,'desc')||''};}(Z);return{'skillId':W,'name':a0['name']||U[aB(0x1bd)]||W,'description':a0[aB(0x1a1)]||U[aB(0x1a1)]||'','sourceType':U['sourceType']||U['source']||U['type']||'platform','iconUrl':U['iconUrl']||U[aB(0x1b3)]||'','relPath':Y,'enabled':!0x1!==U[aB(0x1d4)],'installedAt':new Date()['toISOString']()};}['health'](){const aG=ah;return[...this['agents']['values']()]['map'](R=>({'agentId':R[aG(0x1de)][aG(0x1f2)],'name':R['config'][aG(0x1bd)],'framework':R['config']['framework'],'deployType':R['config'][aG(0x19d)],'status':R['runtime']?.['isAlive']()?aG(0x1ba):'idle','lastActiveAt':R['lastActiveAt']}));}}async function y(R,U,V,W,X,Y){const aH=ah;if(Y['count']>=0xbb8)return void(Y['truncated']=!0x0);Y['count']+=0x1;const Z=await C(U),a0={'name':V?E['basename'](V):'','path':V,'type':Z['isDirectory']()?aH(0x19a):'file','size':Z[aH(0x1da)],'mtimeMs':Z[aH(0x1e0)]};if(!Z[aH(0x1e5)]()||W<=0x0)return a0;const a1=await x(U,{'withFileTypes':!0x0}),a2=[];for(const a3 of a1['sort']((a4,a5)=>a4['name'][aH(0x1f0)](a5['name']))){if(X['has'](a3[aH(0x1bd)]))continue;const a4=V?V+'/'+a3[aH(0x1bd)]:a3['name'],a5=await y(R,P(R,a4),a4,W-0x1,X,Y);if(a5&&a2['push'](a5),Y[aH(0x1e2)])break;}return a0['children']=a2,a0;}function I(R,U,V){const aI=ah,W=Number(R);return Number['isFinite'](W)?Math['max'](U,Math[aI(0x1a9)](V,Math[aI(0x1a5)](W))):U;}function A(R){const {cozeIdentity:U,...V}=R;return{...V,'hasIdentity':Boolean(U),'skills':S(R['skills']??[])};}function S(R){const aJ=ah;return R['map'](U=>({'skillId':U['skillId']||U['id'],'name':U['name']||U['skillId']||U['id'],'description':U['description']||'','sourceType':U['sourceType']||U['source']||aJ(0x1ac),'iconUrl':U[aJ(0x1b9)]||U['icon']||'','relPath':O(U['relPath']||'.skills/'+N(U['skillId']||U['id']||U[aJ(0x1bd)],'skill')),'enabled':!0x1!==U['enabled'],'installedAt':U[aJ(0x1c0)]}))['filter'](U=>U['skillId']);}function v(R){const aK=ah,U=R?.[aK(0x19b)]||R?.['id']||R?.['code']||R?.['name'];if(!U)throw new Error('_agent/addSkills:\x20skillId\x20is\x20required');return String(U);}function $(R){const aL=ah;return R['downloadUrl']||R['download_url']||R['packageUrl']||R['package_url']||R['archiveUrl']||R[aL(0x1f6)]||R['url'];}function T(R,U){const aM=ah,V=U[aM(0x19f)](/[.*+?^${}()|[\]\\]/g,'\x5c$&'),W=R[aM(0x1c7)](new RegExp('^'+V+'\x5cs*:\x5cs*(.+)$','mi'));return W?.[0x1]?.[aM(0x19f)](/^['"]|['"]$/g,'')[aM(0x1c1)]();}
|
|
1
|
+
const ah=j;(function(R,U){const ag=j,V=R();while(!![]){try{const W=parseInt(ag(0xd6))/0x1+-parseInt(ag(0xfc))/0x2+parseInt(ag(0xe9))/0x3+-parseInt(ag(0xa5))/0x4*(parseInt(ag(0xb4))/0x5)+parseInt(ag(0x102))/0x6*(-parseInt(ag(0x106))/0x7)+-parseInt(ag(0xf4))/0x8+parseInt(ag(0xa2))/0x9;if(W===U)break;else V['push'](V['shift']());}catch(X){V['push'](V['shift']());}}}(b,0x896a8));import{randomUUID as q}from'node:crypto';import{readdir as x,readFile as z,rm as B,stat as C,writeFile as D}from'node:fs/promises';import E from'node:path';function j(a,c){a=a-0x97;const d=b();let e=d[a];return e;}function b(){const aO=['deployType','---\x0aname:\x20','AGENTS.md','url','cloud','3199113qfXVlq','logger','get','agent\x20','find','isArray','logs','match','catch','iconUrl','string','4586904bWlpvw','sendNotification','disconnect','now','workspace','path','directory','trimEnd','1738712VwFOwP','codex','join','access_token','entryName','map','6432306fFnwQk','coverage','agents','size','7DGszUh','max','session/prompt','requireAgent','\x0adescription:\x20','session/new','session/cancel','updateAgentSkills','values','skill_md','register','stop','skills','14511591esrPQA','\x0a---\x0a\x0a#\x20','licosTurnId','1168VvRrNQ','accessToken','downloadUrl','files','_meta','include','cozeIdentity','cozeDeployType','getFileContent','prompt','configFile','relPath','status','framework','utf8','2780ohIIfB','skills-removed','agentsRoot','claude-code','updatedAt','runtime','token','isDirectory','message','local','not\x20a\x20file:\x20','exclude','sourceType','entries','skillId','isAlive','agent\x20not\x20found:\x20','installSkill','.next','add','content','text','count','health','arrayBuffer','truncated','runtime_provider','description','filter','CLAUDE.md','platform','trunc','skillMd','agentId','561208broJTK','getData','name','mcpServers','config','push','forwardClientRequest','download\x20skill\x20failed:\x20HTTP\x20','maxBytes','has','from','SKILL.md','package_url','source'];b=function(){return aO;};return b();}import{AcpRuntime as F}from'./acp-runtime.js';import{agentPaths as G,resolvePaths as H}from'./paths.js';import{ensureDir as J,normalizeFramework as K,pathExists as L,readJson as M,safeName as N,safeRelativePath as O,safeResolve as P,writeJson as Q}from'./utils.js';const k=new Set(['node_modules','.git',ah(0xc6),'.nuxt','.turbo','.cache','dist','build','target',ah(0x103),'.venv','__pycache__']);export class AgentManager{constructor({cloud:R,logger:U}){this['cloud']=R,this['logger']=U,this['agents']=new Map();}async['loadPersistedAgents'](){const ai=ah,R=H();await J(R['agentsRoot']);const U=await x(R[ai(0xb6)],{'withFileTypes':!0x0})[ai(0xf1)](()=>[]);for(const V of U){if(!V[ai(0xbb)]())continue;const W=G(V['name'])['configFile'],X=await M(W)[ai(0xf1)](()=>{});X?.['agentId']&&!X['disconnectedAt']&&this[ai(0x9f)](X);}}[ah(0x9f)](R){const aj=ah,U={'deployType':aj(0xbd),...R,'framework':K(R['framework'])};return this['agents']['set'](U['agentId'],{'config':U,'runtime':void 0x0,'lastActiveAt':Date['now']()}),U;}async['createOrUpdate'](R={}){const ak=ah,U=R[ak(0xd5)]||R['id']||q(),V=G(U);await J(V['workspace']),await J(V[ak(0xef)]);const W=await M(V[ak(0xaf)],{})[ak(0xf1)](()=>({})),X={...W,'agentId':U,'name':R['name']||W['name']||U,'framework':K(R['framework']||R['runtimeProvider']||R['runtime_provider']||W['framework']||ak(0xfd)),'deployType':ak(0xe8)===R['_meta']?.[ak(0xac)]?ak(0xe8):R[ak(0xe4)]||W['deployType']||'local','workspace':R['workspace']||W['workspace']||V['workspace'],'cozeIdentity':R['cozeIdentity']??R['instructions']??W[ak(0xab)]??'','model':R['model']??W['model'],'modelInfo':R['modelInfo']??W['modelInfo'],'mcpServers':R[ak(0xd9)]??W[ak(0xd9)]??[],'updatedAt':new Date()['toISOString'](),'createdAt':W['createdAt']||new Date()['toISOString']()};return X[ak(0xab)]&&await async function(Y){const al=ak,Z=Y['cozeIdentity']['trim']();if(!Z)return;await J(Y[al(0xf8)]);const a0=al(0xb7)===Y['framework']?[al(0xd1),al(0xe6)]:['AGENTS.md'];for(const a1 of a0){const a2=E['join'](Y[al(0xf8)],a1);if(!await L(a2)){await D(a2,Z+'\x0a','utf8');continue;}const a3=await z(a2,al(0xb3));a3['includes'](Z)||await D(a2,a3[al(0xfb)]()+'\x0a\x0a'+Z+'\x0a',al(0xb3));}}(X),await Q(V['configFile'],X,0x180),this[ak(0x9f)](X);}async[ah(0xf6)](R,U){const am=ah,V=this[am(0x104)][am(0xeb)](R);V?.['runtime']&&await V['runtime']['stop'](U||am(0xf6)),this[am(0x104)]['delete'](R);const W=G(R)[am(0xaf)],X=await M(W,{})[am(0xf1)](()=>({}));await Q(W,{...X,'disconnectedAt':Date['now'](),'disconnectReason':U||''},0x180);}async['reload'](R){const an=ah,U=R?[this['requireAgent']({'agentId':R})]:[...this['agents'][an(0x9d)]()],V=[];for(const W of U)W[an(0xb9)]&&(await W['runtime'][an(0xa0)]('reload'),W[an(0xb9)]=void 0x0),V[an(0xdb)](W['config'][an(0xd5)]);return{'ok':!0x0,'reloaded':V};}async['detail'](R={}){const ao=ah,U=this['requireAgent'](R);return{'agent':A(U['config']),'health':this[ao(0xcb)]()[ao(0xed)](V=>V[ao(0xd5)]===U['config'][ao(0xd5)])};}async['getFileTree'](R={}){const ap=ah,U=this['requireAgent'](R),V=U['config']['workspace'],W=O(R[ap(0xf9)]??R['filePath']??''),X=P(V,W),Y=I(R['maxDepth']??R['depth']??0x5,0x0,0x14),Z=function(a1,a2){const aq=ap,a3=new Set(k);for(const a4 of a1['fileTreeExclude']??[])a3[aq(0xc7)](a4);for(const a5 of a2[aq(0xbf)]??[])a3[aq(0xc7)](a5);for(const a6 of a2[aq(0xaa)]??[])a3['delete'](a6);return a3;}(U[ap(0xda)],R),a0={'count':0x0,'truncated':!0x1};return{'workspace':V,'path':W,'tree':await y(V,X,W,Y,Z,a0),'truncated':a0[ap(0xcd)],'totalNodes':a0['count']};}async[ah(0xad)](R={}){const ar=ah,U=this['requireAgent'](R)['config']['workspace'],V=O(R['path']??R['filePath']);if(!V)throw new Error('_agent/getFileContent:\x20missing\x20path');const W=P(U,V),X=await C(W);if(!X['isFile']())throw new Error(ar(0xbe)+V);const Y=I(R[ar(0xde)]??0x100000,0x1,0xa00000),Z=await z(W),a0=Z['byteLength']>Y?Z['subarray'](0x0,Y):Z;return{'path':V,'size':Z['byteLength'],'content':a0['toString'](R['encoding']||ar(0xb3)),'encoding':R['encoding']||'utf8','truncated':Z['byteLength']>Y,'mtimeMs':X['mtimeMs']};}async['listSkills'](R={}){const as=ah,U=this['requireAgent'](R);return{'agentId':U['config'][as(0xd5)],'skills':S(U['config']['skills']??[])};}async['addSkills'](R={}){const at=ah,U=this[at(0x98)](R),V=Array[at(0xee)](R['skills'])?R['skills']:[];if(0x0===V['length'])return{'installedSkills':[],'skills':S(U['config']['skills']??[])};const W=[],X=S(U['config'][at(0xa1)]??[]),Y=new Map(X[at(0x101)]((Z,a0)=>[Z['skillId'],a0]));for(const Z of V){const a0=await this[at(0xc5)](U['config'],Z,R);Y['has'](a0['skillId'])?X[Y['get'](a0[at(0xc2)])]=a0:(Y['set'](a0[at(0xc2)],X['length']),X[at(0xdb)](a0)),W['push'](a0);}return await this[at(0x9c)](U,X,'skills-added'),{'installedSkills':W,'skills':X};}async['removeSkills'](R={}){const au=ah,U=this['requireAgent'](R),V=new Set((R['skillIds']??R['skills']??[])['map'](Z=>au(0xf3)==typeof Z?Z:v(Z)));if(0x0===V[au(0x105)])return{'ok':!0x0,'skills':S(U['config']['skills']??[])};const W=S(U['config']['skills']??[]),X=[],Y=[];for(const Z of W){if(!V['has'](Z['skillId'])){X['push'](Z);continue;}const a0=P(U[au(0xda)]['workspace'],Z['relPath']);await B(a0,{'recursive':!0x0,'force':!0x0}),Y['push'](Z);}return await this['updateAgentSkills'](U,X,au(0xb5)),{'ok':!0x0,'removedSkills':Y,'skills':X};}async['handleSession'](R,U){const av=ah,V=U?.['_meta']?.['cozeAgentId']||U?.[av(0xd5)];if(!V)throw new Error(R+':\x20missing\x20_meta.cozeAgentId');let W=this[av(0x104)]['get'](V);const X=K(U['framework']||U['runtimeProvider']||U[av(0xce)]||W?.['config']['framework']||'codex');if(!W||W['config'][av(0xb2)]!==X){W?.['runtime']&&await W['runtime'][av(0xa0)]('framework-changed');const Z=W?.['config']??{};await this['createOrUpdate']({...Z,'agentId':V,'name':U['name']||Z['name']||V,'framework':X,'runtimeProvider':X}),W=this['agents']['get'](V);}if(!W)throw new Error('agent\x20not\x20found:\x20'+V);if(W['lastActiveAt']=Date[av(0xf7)](),av(0x9a)===R)return{'sessionId':U['sessionId']||q()};if(av(0x9b)===R)return await W[av(0xb9)]?.['cancel'](U),{'ok':!0x0};if(av(0x97)!==R)throw new Error('unsupported\x20session\x20method:\x20'+R);if('cloud'===W[av(0xda)]['deployType'])throw new Error(av(0xec)+V+'\x20is\x20cloud\x20deploy\x20type;\x20local\x20bridge\x20does\x20not\x20spawn\x20it');const Y=function(a0={}){const aw=av,a1={...a0};if(!Array[aw(0xee)](a1['prompt'])){const a2=a1['content']??a1[aw(0xc9)]??a1[aw(0xbc)]??'';a1[aw(0xae)]=[{'type':'text','text':String(a2)}];}return a1;}(U);return W['runtime']||(W[av(0xb9)]=new F({'agentConfig':W[av(0xda)],'onUpdate':(a0,a1)=>this['cloud'][av(0xf5)]('session/update',{...a1,'_meta':{...a1['_meta']||{},'cozeAgentId':a0['agentId'],'cozeCloudSessionId':Y['sessionId'],'licosTurnId':Y['_meta']?.[av(0xa4)]}}),'onClientRequest':(a0,a1,a2)=>this['cloud'][av(0xdc)](a0,a1,a2),'logger':this[av(0xea)]})),W['runtime']['prompt'](Y);}async['stopAll'](R){const ax=ah;for(const U of this[ax(0x104)]['values']())await U[ax(0xb9)]?.[ax(0xa0)](R);}[ah(0x98)](R={}){const ay=ah,U=R?.[ay(0xa9)]?.['cozeAgentId']||R?.[ay(0xd5)]||R?.['id'];if(!U)throw new Error('missing\x20agentId');const V=this['agents'][ay(0xeb)](U);if(!V)throw new Error(ay(0xc4)+U);return V;}async['updateAgentSkills'](R,U,V){const az=ah;R[az(0xda)]['skills']=S(U),R['config'][az(0xb8)]=new Date()['toISOString'](),await Q(G(R['config']['agentId'])['configFile'],R['config'],0x180),R['runtime']&&(await R[az(0xb9)]['stop'](V),R['runtime']=void 0x0);}async['installSkill'](R,U,V){const aB=ah,W=v(U),X=N(W,'skill'),Y=O(U['relPath']||'.skills/'+X),Z=P(R['workspace'],Y);await B(Z,{'recursive':!0x0,'force':!0x0}),await J(Z),U['files']?await async function(a1,a2){const aA=j;if(Array['isArray'](a2))for(const a3 of a2){const a4=O(a3['path']||a3[aA(0xd8)]);await J(E['dirname'](E['join'](a1,a4))),await D(P(a1,a4),String(a3[aA(0xc8)]??''),aA(0xb3));}else for(const [a5,a6]of Object[aA(0xc1)](a2)){const a7=O(a5);await J(E['dirname'](E['join'](a1,a7))),await D(P(a1,a7),String(a6??''),'utf8');}}(Z,U[aB(0xa8)]):U[aB(0xc8)]||U[aB(0xd4)]||U['skill_md']?await D(E[aB(0xfe)](Z,'SKILL.md'),String(U[aB(0xc8)]??U['skillMd']??U[aB(0x9e)]),'utf8'):$(U)?await async function(a1,a2,a3){const aC=aB,a4=$(a2),a5={},a6=a2[aC(0xba)]||a2[aC(0xa6)]||a2['access_token']||a3['token']||a3['accessToken']||a3[aC(0xff)];a6&&(a5['authorization']='Bearer\x20'+a6);const a7=await fetch(a4,{'headers':a5});if(!a7['ok'])throw new Error(aC(0xdd)+a7[aC(0xb1)]+'\x20'+await a7[aC(0xc9)]());const a8=Buffer[aC(0xe0)](await a7[aC(0xcc)]());await async function(a9,aa){const aD=aC,{default:ab}=await import('adm-zip'),ac=new ab(aa);for(const ad of ac['getEntries']()){if(ad['isDirectory'])continue;const ae=O(ad[aD(0x100)]),af=P(a9,ae);await J(E['dirname'](af)),await D(af,ad[aD(0xd7)]());}}(a1,a8);}(Z,U,V):await D(E['join'](Z,aB(0xe1)),function(a1){const aE=aB,a2=a1['name']||v(a1),a3=a1[aE(0xcf)]||'';return aE(0xe5)+a2+aE(0x99)+a3+aE(0xa3)+a2+'\x0a\x0a'+a3+'\x0a';}(U),aB(0xb3));const a0=await async function(a1){const aF=aB,a2=await z(E['join'](a1,'SKILL.md'),'utf8')[aF(0xf1)](()=>''),a3=a2[aF(0xf0)](/^---\s*([\s\S]*?)\s*---/),a4=a3?.[0x1]||a2;return{'name':T(a4,'name')||a2['match'](/^#\s+(.+)$/m)?.[0x1]?.['trim'](),'description':T(a4,'description')||T(a4,'desc')||''};}(Z);return{'skillId':W,'name':a0[aB(0xd8)]||U['name']||W,'description':a0['description']||U['description']||'','sourceType':U[aB(0xc0)]||U[aB(0xe3)]||U['type']||aB(0xd2),'iconUrl':U[aB(0xf2)]||U['icon']||'','relPath':Y,'enabled':!0x1!==U['enabled'],'installedAt':new Date()['toISOString']()};}['health'](){const aG=ah;return[...this[aG(0x104)]['values']()]['map'](R=>({'agentId':R[aG(0xda)][aG(0xd5)],'name':R['config'][aG(0xd8)],'framework':R['config']['framework'],'deployType':R['config']['deployType'],'status':R[aG(0xb9)]?.[aG(0xc3)]()?'running':'idle','lastActiveAt':R['lastActiveAt']}));}}async function y(R,U,V,W,X,Y){const aH=ah;if(Y['count']>=0xbb8)return void(Y['truncated']=!0x0);Y[aH(0xca)]+=0x1;const Z=await C(U),a0={'name':V?E['basename'](V):'','path':V,'type':Z['isDirectory']()?aH(0xfa):'file','size':Z['size'],'mtimeMs':Z['mtimeMs']};if(!Z[aH(0xbb)]()||W<=0x0)return a0;const a1=await x(U,{'withFileTypes':!0x0}),a2=[];for(const a3 of a1['sort']((a4,a5)=>a4[aH(0xd8)]['localeCompare'](a5['name']))){if(X[aH(0xdf)](a3['name']))continue;const a4=V?V+'/'+a3[aH(0xd8)]:a3['name'],a5=await y(R,P(R,a4),a4,W-0x1,X,Y);if(a5&&a2[aH(0xdb)](a5),Y[aH(0xcd)])break;}return a0['children']=a2,a0;}function I(R,U,V){const aI=ah,W=Number(R);return Number['isFinite'](W)?Math[aI(0x107)](U,Math['min'](V,Math[aI(0xd3)](W))):U;}function A(R){const aJ=ah,{cozeIdentity:U,...V}=R;return{...V,'hasIdentity':Boolean(U),'skills':S(R[aJ(0xa1)]??[])};}function S(R){const aK=ah;return R['map'](U=>({'skillId':U['skillId']||U['id'],'name':U[aK(0xd8)]||U[aK(0xc2)]||U['id'],'description':U['description']||'','sourceType':U['sourceType']||U['source']||aK(0xd2),'iconUrl':U['iconUrl']||U['icon']||'','relPath':O(U[aK(0xb0)]||'.skills/'+N(U[aK(0xc2)]||U['id']||U['name'],'skill')),'enabled':!0x1!==U['enabled'],'installedAt':U['installedAt']}))[aK(0xd0)](U=>U[aK(0xc2)]);}function v(R){const aL=ah,U=R?.['skillId']||R?.['id']||R?.['code']||R?.[aL(0xd8)];if(!U)throw new Error('_agent/addSkills:\x20skillId\x20is\x20required');return String(U);}function $(R){const aM=ah;return R[aM(0xa7)]||R['download_url']||R['packageUrl']||R[aM(0xe2)]||R['archiveUrl']||R['archive_url']||R[aM(0xe7)];}function T(R,U){const aN=ah,V=U['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&'),W=R[aN(0xf0)](new RegExp('^'+V+'\x5cs*:\x5cs*(.+)$','mi'));return W?.[0x1]?.['replace'](/^['"]|['"]$/g,'')['trim']();}
|
package/dist/lib/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,d){const o=b,f=c();while(!![]){try{const g=-parseInt(o(
|
|
1
|
+
function b(c,d){c=c-0x16d;const e=a();let f=e[c];return f;}(function(c,d){const o=b,f=c();while(!![]){try{const g=-parseInt(o(0x192))/0x1+parseInt(o(0x187))/0x2*(parseInt(o(0x191))/0x3)+parseInt(o(0x181))/0x4+-parseInt(o(0x174))/0x5+-parseInt(o(0x17d))/0x6*(parseInt(o(0x185))/0x7)+parseInt(o(0x17b))/0x8+parseInt(o(0x189))/0x9*(parseInt(o(0x18e))/0xa);if(g===d)break;else f['push'](f['shift']());}catch(h){f['push'](f['shift']());}}}(a,0xdaa73));export function parseArgs(c){const p=b,d=[...c];if(0x0===d['length']||e(d,'--help')||e(d,'-h'))return{'mode':p(0x190)};if(e(d,'--version')||e(d,'-v'))return{'mode':'version'};if(e(d,'--daemon'))return{'mode':'daemon'};if(e(d,'--status'))return{'mode':'status','deprecated':p(0x186)};if(e(d,'--stop'))return{'mode':'stop','deprecated':p(0x177)};if(e(d,'--refresh'))return{'mode':'refresh','deprecated':p(0x183)};if(e(d,'--install-service'))return{'mode':'service-install','deprecated':'--install-service\x20->\x20service\x20install'};if(e(d,p(0x17e)))return{'mode':p(0x193),'deprecated':p(0x170)};const [f,g]=d;if(p(0x17f)===f)return{'mode':'status'};if('stop'===f)return{'mode':'stop'};if(p(0x179)===f)return{'mode':p(0x179)};if(p(0x182)===f)return{'mode':'reload','agentId':n(d,'--agent-id')};if('log'===f)return{'mode':'log','agentId':n(d,p(0x172)),'date':n(d,p(0x17a)),'tail':Number(n(d,'-n')??n(d,'--tail')??0xc8),'follow':e(d,'-f')||e(d,p(0x18f)),'level':n(d,p(0x178)),'grep':n(d,p(0x16e)),'raw':e(d,'--raw'),'list':e(d,'--list')};if(p(0x16d)===f)return{'mode':p(0x16d)};if('purge'===f)return{'mode':'purge'};if('service'===f&&'install'===g)return{'mode':'service-install'};if('service'===f&&p(0x16f)===g)return{'mode':p(0x18a)};if(p(0x18c)===f)return{'mode':p(0x18c),'patToken':n(d,'--pat-token'),'env':n(d,'--env'),'handshakeUrl':n(d,'--handshake-url'),'frontierUrl':n(d,p(0x18d)),'mockScenario':n(d,'--mock-scenario'),'agentId':n(d,p(0x172))};if('send'===f)return function(k){const q=p,l=k[0x1],m=k[0x2];return['image',q(0x180)]['includes'](l)&&m?{'mode':'send','kind':l,'target':m,'agentId':n(k,'--agent-id'),'sessionId':n(k,q(0x171)),'caption':n(k,'--caption'),'name':n(k,'--name'),'groupFile':e(k,'--group-file'),'mime':n(k,'--mime')}:{'mode':'help'};}(d);if('daemon'===f)return{'mode':'spawn-daemon'};const h=n(d,'--pat-token'),j=n(d,p(0x188));return h&&j?{'mode':'pair','patToken':h,'pairCode':j,'agentId':n(d,'--agent-id'),'env':n(d,'--env'),'handshakeUrl':n(d,p(0x176)),'frontierUrl':n(d,p(0x18d)),'mockScenario':n(d,p(0x173))}:{'mode':p(0x190)};}export function printHelp(){const r=b;console[r(0x18b)]('licos-bridge\x20-\x20local\x20bridge\x20daemon\x20for\x20LICOS\x20Agent\x20Service\x0a\x0aPair\x20(paste\x20from\x20cloud\x20UI;\x20start/reuse\x20daemon\x20and\x20deliver\x20pair-code):\x0a\x20\x20npx\x20-y\x20--registry=https://registry.npmmirror.com\x20@kmlckj/licos-bridge@latest\x20--pat-token=<token>\x20--pair-code=<code>\x20--handshake-url=<url>\x0a\x0aDaemon\x20control:\x0a\x20\x20licos-bridge\x20status\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20show\x20daemon\x20status\x0a\x20\x20licos-bridge\x20stop\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20stop\x20daemon\x0a\x20\x20licos-bridge\x20refresh\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20re-detect\x20local\x20agent\x20binaries\x0a\x20\x20licos-bridge\x20reload\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20recycle\x20all\x20agent\x20subprocesses\x0a\x20\x20licos-bridge\x20reload\x20--agent-id\x20<id>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20recycle\x20one\x20agent\x20subprocess\x0a\x0aView\x20logs:\x0a\x20\x20licos-bridge\x20log\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20bridge\x20last\x20200\x20lines\x0a\x20\x20licos-bridge\x20log\x20--agent-id\x20<id>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20agent\x20related\x20logs\x0a\x20\x20licos-bridge\x20log\x20[--agent-id\x20<id>]\x20[--date\x20YYYY-MM-DD]\x20\x5c\x0a\x20\x20\x20\x20\x20\x20[-n\x20<N>]\x20[-f]\x20[--level\x20<l>]\x20[--grep\x20<s>]\x20[--raw]\x20[--list]\x0a\x0aUpdate:\x0a\x20\x20licos-bridge\x20update\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20stop\x20daemon\x20and\x20run\x20latest\x20package\x20connect\x0a\x20\x20licos-bridge\x20purge\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20stop\x20daemon\x20+\x20unregister\x20supervisor\x20+\x20remove\x20bridge\x20data\x0a\x0aOS\x20supervisor\x20(auto-start\x20on\x20login):\x0a\x20\x20licos-bridge\x20service\x20install\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20register\x20supervisor\x0a\x20\x20licos-bridge\x20service\x20uninstall\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20unregister\x20supervisor\x0a\x0aReconnect:\x0a\x20\x20licos-bridge\x20connect\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20reconnect\x20using\x20stored\x20PAT\x0a\x20\x20licos-bridge\x20connect\x20--pat-token\x20<token>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20reconnect\x20using\x20specified\x20PAT\x0a\x20\x20licos-bridge\x20connect\x20--env=dev\x20--handshake-url=<url>\x20\x20\x20\x20\x20\x20\x20\x20\x20reconnect\x20with\x20route\x20override\x0a\x0aSend\x20file\x20/\x20image:\x0a\x20\x20licos-bridge\x20send\x20image\x20<path>\x20--agent-id\x20<id>\x20--session-id\x20<id>\x20[--caption\x20\x22...\x22]\x0a\x20\x20licos-bridge\x20send\x20file\x20\x20<path>\x20--agent-id\x20<id>\x20--session-id\x20<id>\x20[--caption\x20\x22...\x22]\x20[--name\x20\x22report.pdf\x22]\x0a\x20\x20licos-bridge\x20send\x20file\x20<uri>\x20--agent-id\x20<id>\x20--session-id\x20<id>\x20--group-file\x20--mime\x20<mimeType>\x20[--name\x20\x22...\x22]\x0a\x0aPair\x20flags:\x0a\x20\x20--env\x20<value>\x0a\x20\x20--handshake-url\x20<url>\x20\x20\x20\x20\x20\x20\x20required\x20unless\x20LICOS_BRIDGE_HANDSHAKE_URL\x20is\x20set\x20or\x20a\x20saved\x20pairing\x20has\x20it\x0a\x20\x20--frontier-url\x20<url>\x0a\x20\x20env:\x20LICOS_BRIDGE_HANDSHAKE_URL,\x20LICOS_PLATFORM_BASE_URL,\x20AIOS_PLATFORM_BASE_URL\x0a\x20\x20--mock-scenario\x20<name>\x0a\x0aInfo:\x0a\x20\x20licos-bridge\x20--version\x20|\x20-v\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20print\x20current\x20bridge\x20version\x0a\x20\x20licos-bridge\x20--help\x20\x20\x20\x20|\x20-h\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20show\x20this\x20help\x0a\x0aDeprecated\x20flags:\x0a\x20\x20--status\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20->\x20licos-bridge\x20status\x0a\x20\x20--stop\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20->\x20licos-bridge\x20stop\x0a\x20\x20--install-service\x20\x20\x20->\x20licos-bridge\x20service\x20install\x0a\x20\x20--uninstall\x20\x20\x20\x20\x20\x20\x20\x20\x20->\x20licos-bridge\x20purge\x0a\x0aCompatibility:\x0a\x20\x20coze-bridge\x20is\x20provided\x20as\x20a\x20bin\x20alias.\x0a\x0aInternal:\x0a\x20\x20<node>\x20<entry>\x20--daemon\x0a');}function e(c,d){return c['includes'](d);}function n(c,d){const s=b,f=d+'=',g=c['find'](j=>j['startsWith'](f));if(g)return g[s(0x17c)](f['length']);const h=c[s(0x184)](d);return h>=0x0&&c[h+0x1]&&!c[h+0x1][s(0x175)]('--')?c[h+0x1]:void 0x0;}function a(){const t=['--frontier-url','2720lMUZOK','--follow','help','6TxqkLx','639078DtRZsj','purge','update','--grep','uninstall','--uninstall\x20->\x20purge','--session-id','--agent-id','--mock-scenario','6514630QyYYrZ','startsWith','--handshake-url','--stop\x20->\x20stop','--level','refresh','--date','4992760janxcP','slice','282ojdaEI','--uninstall','status','file','4295160fvTkfH','reload','--refresh\x20->\x20refresh','indexOf','18172QzdSSN','--status\x20->\x20status','888278DkXwBj','--pair-code','12357xBTWYM','service-uninstall','log','connect'];a=function(){return t;};return a();}
|
package/dist/lib/cloud.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function f(a,c){a=a-0x1a4;const d=b();let e=d[a];return e;}const E=f;(function(v,w){const D=f,x=v();while(!![]){try{const y=parseInt(D(0x1db))/0x1+parseInt(D(0x1a9))/0x2*(-parseInt(D(0x1bb))/0x3)+parseInt(D(0x1b0))/0x4+-parseInt(D(0x1b9))/0x5+parseInt(D(0x1ba))/0x6+parseInt(D(0x1b2))/0x7*(parseInt(D(0x1c4))/0x8)+-parseInt(D(0x1d2))/0x9*(-parseInt(D(0x1c1))/0xa);if(y===w)break;else x['push'](x['shift']());}catch(z){x['push'](x['shift']());}}}(b,0x1981b));import j from'ws';import{detectFrameworks as k}from'./frameworks.js';function b(){const a1=['configFile','restore','result','frontier\x20error','reconnect','895335WHoQmb','239130XTERba','30fExTCJ','error','handshake\x20failed:\x20HTTP\x20','env','pending','close','80nUjHIR','sendResponse','frontierToken','4184Gjfain','bridgeClientId','https://www.licos.com','frontier\x20frame\x20failed','health','access_token','text','catch','restored','OPEN','now','pair','utf8','2.0','48573NTHfcg','slice','LICOS_BRIDGE_HANDSHAKE_URL','stringify','sendBridgeFile','json','device_id','sendFrame','agentId','113627YajgFa','handlers','set','/api/v1/workbench/local-agent-bridge/handshake','pairing','frontier_token','session/','pairCode','closing\x20frontier','reject','startsWith','delete','arch','application/json','isConnected','sendHealth','patToken','handshake-url\x20is\x20required;\x20copy\x20the\x20connection\x20command\x20from\x20the\x20current\x20platform\x20or\x20set\x20LICOS_BRIDGE_HANDSHAKE_URL','connect','11084soLwUq','toISOString','message','logger','_agent/pair','get','heartbeatTimer','19020RJXFYM','handshake','1841zedYXz','connectStored'];b=function(){return a1;};return b();}import{joinUrl as l,readJson as m,writeJson as q}from'./utils.js';import{resolvePaths as u}from'./paths.js';const s=E(0x1c6),a=E(0x1de),c=[E(0x1d4),'LICOS_PLATFORM_BASE_URL','AIOS_PLATFORM_BASE_URL'];export class CloudConnector{constructor({logger:v}){const F=E;this['logger']=v,this['ws']=void 0x0,this['pairing']=void 0x0,this['handlers']=new Map(),this['pending']=new Map(),this[F(0x1af)]=void 0x0,this['agentManager']=void 0x0;}['setAgentManager'](v){this['agentManager']=v;}['on'](v,w){const G=E;this[G(0x1dc)][G(0x1dd)](v,w);}async[E(0x1b5)](){const H=E,v=await m(u()['configFile'],{})['catch'](()=>({}));v?.['pairing']?.[H(0x1a6)]&&v?.[H(0x1df)]?.['pairCode']&&await this['pair'](v['pairing'],{'restored':!0x0})['catch'](w=>{const I=H;this[I(0x1ac)]?.('restore\x20pair\x20failed',{'error':String(w)});});}async[E(0x1cf)](v,w={}){const J=E;this['pairing']={'handshakeUrl':h(v,w),'frontierUrl':v['frontierUrl'],'env':v['env'],'mockScenario':v['mockScenario'],'agentId':v[J(0x1da)],'patToken':v['patToken'],'pairCode':v[J(0x1e2)]},await q(u()[J(0x1b4)],{'pairing':this['pairing'],'updatedAt':new Date()[J(0x1aa)]()},0x180);const x=await this['handshake'](),y=v['frontierUrl']||g(x,['frontierUrl','frontier_url']);return y&&await this['connect'](y,x),!w[J(0x1cc)]&&v[J(0x1da)]&&this['sendNotification'](J(0x1ad),{'agentId':v['agentId']})['catch'](()=>{}),{'ok':!0x0,'deviceId':g(x,['deviceId',J(0x1d8)]),'bridgeClientId':g(x,[J(0x1c5),'bridge_client_id']),'frontierConnected':Boolean(this['ws']&&this['ws']['readyState']===j[J(0x1cd)])};}async[E(0x1b3)](v={}){const K=E,w=await m(u()['configFile'],{})['catch'](()=>({})),x=w?.[K(0x1df)]??{},y=v['patToken']||x[K(0x1a6)];if(!y)throw new Error('connect\x20requires\x20stored\x20pat-token\x20or\x20--pat-token');return this['pair']({...x,...v,'patToken':y,'pairCode':v[K(0x1e2)]??x['pairCode']},{'connectOnly':!0x0});}async[E(0x1b1)](){const M=E,v=await k(),w=function(z){const L=f;if(!z)throw new Error(L(0x1a7));return/\/handshake\/?$/['test'](z)?z:l(z,a);}(this['pairing']['handshakeUrl']),x=await fetch(w,{'method':'POST','headers':{'content-type':M(0x1e8),'authorization':'Bearer\x20'+this[M(0x1df)][M(0x1a6)],...this['pairing'][M(0x1be)]?{'x-licos-env':this['pairing'][M(0x1be)]}:{},...this[M(0x1df)]['mockScenario']?{'x-mock-scenario':this['pairing']['mockScenario']}:{}},'body':JSON['stringify']({'pairCode':this['pairing']['pairCode'],'pair_code':this['pairing'][M(0x1e2)],'agentId':this['pairing']['agentId'],'agent_id':this[M(0x1df)][M(0x1da)],'mockScenario':this['pairing']['mockScenario'],'mock_scenario':this['pairing']['mockScenario'],'device':{'hostname':process.env.COMPUTERNAME||process.env.HOSTNAME||'','platform':process['platform'],'arch':process[M(0x1e7)],'nodeVersion':process['version']},'frameworks':v})});if(!x['ok'])throw new Error(M(0x1bd)+x['status']+'\x20'+await x[M(0x1ca)]());const y=await x[M(0x1d7)]();return y['data']??y;}async[E(0x1a8)](v,w){const N=E;await this['stop'](N(0x1b8));const x=g(w,['accessToken',N(0x1c9),N(0x1c3),N(0x1e0)])||this['pairing'][N(0x1a6)];this['ws']=new j(v,{'headers':{'authorization':'Bearer\x20'+x,...this[N(0x1df)][N(0x1be)]?{'x-licos-env':this[N(0x1df)][N(0x1be)]}:{}}}),this['ws']['on']('open',()=>{const O=N;this['logger']?.('frontier\x20connected',{'frontierUrl':v}),this[O(0x1a5)]()['catch'](()=>{}),this['heartbeatTimer']=setInterval(()=>this[O(0x1a5)]()[O(0x1cb)](()=>{}),0x2710);}),this['ws']['on'](N(0x1ab),y=>{const P=N;this['handleFrame'](y['toString'](P(0x1d0)))['catch'](z=>{const Q=P;this['logger']?.(Q(0x1c7),{'error':String(z)});});}),this['ws']['on'](N(0x1c0),(y,z)=>{this['logger']?.('frontier\x20closed',{'code':y,'reason':z['toString']()}),clearInterval(this['heartbeatTimer']),this['heartbeatTimer']=void 0x0;}),this['ws']['on'](N(0x1bc),y=>{const R=N;this['logger']?.(R(0x1b7),{'error':String(y)});});}async['handleFrame'](v){const S=E,w=JSON['parse'](v);if(void 0x0!==w['id']&&(void 0x0!==w[S(0x1b6)]||void 0x0!==w['error'])){const z=this['pending'][S(0x1ae)](w['id']);return void(z&&(this[S(0x1bf)][S(0x1e6)](w['id']),w[S(0x1bc)]?z[S(0x1e4)](new Error(w['error']['message']||JSON['stringify'](w['error']))):z['resolve'](w['result'])));}const x=w['method']||w['type'],y=this[S(0x1dc)][S(0x1ae)](x)||(x?.[S(0x1e5)](S(0x1e1))?this['handlers'][S(0x1ae)]('session/*'):void 0x0);if(y)try{const A=await y(w['params']??w['content']??{});void 0x0!==w['id']&&await this[S(0x1c2)](w['id'],A);}catch(B){if(void 0x0===w['id'])throw B;await this[S(0x1c2)](w['id'],void 0x0,{'code':-0x7f5b,'message':B[S(0x1ab)]||String(B)});}else void 0x0!==w['id']&&await this[S(0x1c2)](w['id'],void 0x0,{'code':-0x7f59,'message':'method\x20not\x20found:\x20'+x});}async['sendHealth'](){const T=E;await this['sendNotification']('_agent/health',{'agents':this['agentManager']?.[T(0x1c8)]()??[],'ts':Date[T(0x1ce)]()});}async['sendNotification'](v,w){await this['sendFrame']({'jsonrpc':'2.0','method':v,'params':w});}async[E(0x1c2)](v,w,x){const U=E;await this[U(0x1d9)](x?{'jsonrpc':'2.0','id':v,'error':x}:{'jsonrpc':U(0x1d1),'id':v,'result':w});}async['sendRequest'](v,w,x=0x7530){const V=E,y=Date['now']()+'-'+Math['random']()['toString'](0x10)[V(0x1d3)](0x2);return await this['sendFrame']({'jsonrpc':V(0x1d1),'id':y,'method':v,'params':w}),new Promise((z,A)=>{const B=setTimeout(()=>{this['pending']['delete'](y),A(new Error(v+'\x20timed\x20out'));},x);this['pending']['set'](y,{'resolve':C=>{clearTimeout(B),z(C);},'reject':C=>{clearTimeout(B),A(C);}});});}async['forwardClientRequest'](v,w,x){const W=E;if(this[W(0x1a4)]())return this['sendRequest']('_agent/client_request',{'agentId':v['agentId'],'method':w,'params':x})['catch'](()=>{});}async[E(0x1d6)](v){if(!this['isConnected']())throw new Error('frontier\x20is\x20not\x20connected');return this['sendRequest']('_agent/sendFile',v,0x1d4c0);}async[E(0x1d9)](v){const X=E;if(!this['isConnected']())throw new Error('frontier\x20is\x20not\x20connected');this['ws']['send'](JSON[X(0x1d5)](v));}['isConnected'](){const Y=E;return Boolean(this['ws']&&this['ws']['readyState']===j[Y(0x1cd)]);}async['stop'](v){const Z=E;clearInterval(this[Z(0x1af)]),this[Z(0x1af)]=void 0x0,this['ws']&&(this['logger']?.(Z(0x1e3),{'reason':v}),this['ws']['close'](),this['ws']=void 0x0);}}function h(v,w){const a0=E,x=p(v?.['handshakeUrl']);if(x){if((w['restored']||w['connectOnly'])&&function(z){const A=z['replace'](/\/+$/,'');return A===s||A===''+s+a;}(x)){const z=d();if(z)return z;throw new Error('stored\x20handshake-url\x20points\x20to\x20legacy\x20default\x20https://www.licos.com;\x20copy\x20a\x20fresh\x20connection\x20command\x20from\x20the\x20target\x20platform\x20or\x20set\x20LICOS_BRIDGE_HANDSHAKE_URL');}return x;}const y=d();if(y)return y;throw new Error(a0(0x1a7));}function d(){for(const v of c){const w=p(process.env[v]);if(w)return w;}}function p(v){if(null!=v)return String(v)['trim']()||void 0x0;}function g(v,w){for(const x of w)if(void 0x0!==v?.[x]&&null!==v[x]&&''!==v[x])return v[x];}
|
package/dist/lib/daemon.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(z,A){const N=f,B=z();while(!![]){try{const C=parseInt(N(
|
|
1
|
+
(function(z,A){const N=f,B=z();while(!![]){try{const C=parseInt(N(0x1b2))/0x1*(parseInt(N(0x19f))/0x2)+parseInt(N(0x19d))/0x3+parseInt(N(0x1a2))/0x4+-parseInt(N(0x1a8))/0x5*(-parseInt(N(0x1b8))/0x6)+-parseInt(N(0x1ab))/0x7+parseInt(N(0x1a4))/0x8*(-parseInt(N(0x198))/0x9)+parseInt(N(0x19c))/0xa*(parseInt(N(0x1a7))/0xb);if(C===A)break;else B['push'](B['shift']());}catch(D){B['push'](B['shift']());}}}(b,0x259ec));function f(a,c){a=a-0x18c;const d=b();let e=d[a];return e;}import{createServer as g}from'node:http';import{randomBytes as h}from'node:crypto';import{detectFrameworks as j}from'./frameworks.js';import{AgentManager as k}from'./agent-manager.js';import{CloudConnector as m}from'./cloud.js';import{resolvePaths as q}from'./paths.js';function b(){const V=['url','1035230lnwEic','stopAll','application/json;\x20charset=utf-8','/connect','close','end','toString','1CSQFEn','ipc\x20request\x20failed','/status','/send','createOrUpdate','_agent/addSkills','6DHKEfr','POST','ipc\x20stop','bridgeRoot','Bearer\x20','daemon\x20started','pair','writeHead','length','getFileContent','_method','parse','127.0.0.1','method','exit','port','connectStored','27vTmdDZ','data','session/cancel','pidFile','1270uxBMbz','354132jPAosQ','authorization','51668unLgbJ','pid','session/*','272648BdkXoR','_agent/getFileContent','520176rFELXG','_agent/update','utf8','1991JiCakH','1310105jsjgbq','/refresh'];b=function(){return V;};return b();}import{appendLog as u,ensureDir as v,readText as w,writeJson as x,writePrivateText as y}from'./utils.js';export async function startDaemonServer(){const O=f,z=q();await v(z[O(0x1bb)]),await v(z['agentsRoot']);const A=(F,G)=>u(z['logFile'],F,G)['catch'](()=>{}),B=new m({'logger':A}),C=new k({'cloud':B,'logger':A});B['setAgentManager'](C),await C['loadPersistedAgents'](),B['on']('_agent/create',F=>C[O(0x1b6)](F)),B['on']('_agent/detail',F=>C['detail'](F)),B['on'](O(0x1a5),F=>C['createOrUpdate'](F)),B['on']('_agent/disconnect',async F=>(await C['disconnect'](F['agentId'],F['reason']),{'ok':!0x0})),B['on']('_agent/health',()=>({'agents':C['health']()})),B['on']('_agent/getFileTree',F=>C['getFileTree'](F)),B['on'](O(0x1a3),F=>C[O(0x190)](F)),B['on']('_agent/listSkills',F=>C['listSkills'](F)),B['on'](O(0x1b7),F=>C['addSkills'](F)),B['on']('_agent/removeSkills',F=>C['removeSkills'](F)),B['on'](O(0x1a1),F=>C['handleSession'](F['method']||F[O(0x191)]||'session/prompt',F)),B['on']('session/new',F=>C['handleSession']('session/new',F)),B['on']('session/prompt',F=>C['handleSession']('session/prompt',F)),B['on'](O(0x19a),F=>C['handleSession'](O(0x19a),F));const D=await async function(F){const G=await w(F['tokenFile']);if(G?.['trim']())return G['trim']();const H=h(0x18)['toString']('hex');return await y(F['tokenFile'],H),await x(F['configFile'],{'createdAt':new Date()['toISOString']()},0x180),H;}(z),E=g(async(F,G)=>{const S=O;try{if(!function(I,J){const P=f;return(I['headers'][P(0x19e)]||'')===P(0x1bc)+J;}(F,D))return p(G,0x191,{'ok':!0x1,'error':'unauthorized'});const H=await function(I){return new Promise((J,K)=>{const Q=f,L=[];I['on'](Q(0x199),M=>L['push'](M)),I['on']('error',K),I['on'](Q(0x1b0),()=>{const R=Q;if(0x0===L[R(0x18f)])return J({});const M=Buffer['concat'](L)[R(0x1b1)](R(0x1a6));J(M?JSON[R(0x192)](M):{});});});}(F);if('GET'===F[S(0x194)]&&S(0x1b4)===F['url'])return p(G,0xc8,{'ok':!0x0,'pid':process[S(0x1a0)],'frontierConnected':B['isConnected'](),'frameworks':await j(),'agents':C['health']()});if(S(0x1b9)===F[S(0x194)]&&'/pair'===F[S(0x1aa)])return p(G,0xc8,await B[S(0x18d)](H));if('POST'===F['method']&&S(0x1ae)===F['url'])return p(G,0xc8,await B[S(0x197)](H));if('POST'===F['method']&&S(0x1a9)===F['url'])return p(G,0xc8,{'ok':!0x0,'frameworks':await j()});if(S(0x1b9)===F[S(0x194)]&&'/reload'===F['url'])return p(G,0xc8,await C['reload'](H['agentId']));if('POST'===F['method']&&S(0x1b5)===F[S(0x1aa)])return p(G,0xc8,await B['sendBridgeFile'](H));if('POST'===F['method']&&'/stop'===F[S(0x1aa)])return p(G,0xc8,{'ok':!0x0}),await B['stop']('ipc\x20stop'),await C[S(0x1ac)](S(0x1ba)),void E[S(0x1af)](()=>process[S(0x195)](0x0));p(G,0x194,{'ok':!0x1,'error':'not\x20found'});}catch(I){await A(S(0x1b3),{'url':F[S(0x1aa)],'error':String(I)}),p(G,0x1f4,{'ok':!0x1,'error':I['message']||String(I)});}});E['listen'](0x0,O(0x193),async()=>{const T=O,F=E['address']();await y(z['portFile'],String(F[T(0x196)])),await y(z[T(0x19b)],String(process['pid'])),await A(T(0x18c),{'pid':process[T(0x1a0)],'port':F['port']}),await B['restore']();});}function p(z,A,B){const U=f;z[U(0x18e)](A,{'content-type':U(0x1ad)}),z['end'](JSON['stringify'](B));}
|
package/dist/lib/frameworks.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(k,l){const y=d,m=k();while(!![]){try{const p
|
|
1
|
+
(function(k,l){const y=d,m=k();while(!![]){try{const p=-parseInt(y(0xf6))/0x1*(parseInt(y(0xfe))/0x2)+-parseInt(y(0xf0))/0x3+parseInt(y(0xf1))/0x4*(parseInt(y(0xf9))/0x5)+parseInt(y(0xf3))/0x6+parseInt(y(0xed))/0x7+-parseInt(y(0xfd))/0x8+parseInt(y(0xff))/0x9;if(p===l)break;else m['push'](m['shift']());}catch(q){m['push'](m['shift']());}}}(b,0x18a67));import{fileURLToPath as f}from'node:url';import{readFile as g}from'node:fs/promises';function d(a,c){a=a-0xed;const e=b();let f=e[a];return f;}import h from'node:path';import{commandVersion as i,findExecutable as j}from'./utils.js';export async function detectFrameworks(){const z=d,k=[],l=j('claude'),m=j(z(0xfb)),p=j(z(0xf7));return k[z(0xf5)]({'id':z(0xfa),'name':'Claude\x20Code','installed':Boolean(l),'command':l,'version':l?i(l):void 0x0,'acpPackage':z(0xf8),'acpBin':z(0xf2)}),k['push']({'id':'codex','name':z(0xfc),'installed':Boolean(m||await r('@zed-industries/codex-acp/bin/codex-acp.js')),'command':m,'version':m?i(m):void 0x0,'acpPackage':'@zed-industries/codex-acp','acpBin':'codex-acp'}),k['push']({'id':'openclaw','name':'OpenClaw','installed':Boolean(p),'command':p,'version':p?i(p):void 0x0,'acpPackage':void 0x0,'acpBin':void 0x0}),k;}export async function resolveAcpBin(k){const A=d;if('codex'===k){const l=import.meta.resolve('@zed-industries/codex-acp/bin/codex-acp.js');return{'command':process[A(0xee)],'args':[f(l)]};}if(A(0xfa)===k)return async function(m,p){const B=A,q=import.meta.resolve(m+B(0x100)),u=f(q),v=h['dirname'](u),w=JSON['parse'](await g(u,'utf8')),x='string'==typeof w[B(0xef)]?w['bin']:w[B(0xef)]?.[p];if(!x)throw new Error(m+B(0xf4)+p);return{'command':process[B(0xee)],'args':[h['join'](v,x)]};}('@agentclientprotocol/claude-agent-acp','claude-agent-acp');throw new Error('ACP\x20runtime\x20is\x20not\x20supported\x20for\x20framework:\x20'+k);}function b(){const C=['67560KUGtpK','\x20package.json\x20has\x20no\x20bin\x20','push','53117zxniaM','openclaw','@agentclientprotocol/claude-agent-acp','860egqfCt','claude-code','codex','Codex','823608vCPRpe','2qyLnGH','1891827fMTiBy','/package.json','340025ACgRPe','execPath','bin','567909pKVYVB','4100hRsXfZ','claude-agent-acp'];b=function(){return C;};return b();}async function r(k){try{return import.meta.resolve(k),!0x0;}catch{return!0x1;}}
|
package/dist/lib/ipc.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(m,p){const A=c,q=m();while(!![]){try{const s
|
|
1
|
+
(function(m,p){const A=c,q=m();while(!![]){try{const s=-parseInt(A(0x19d))/0x1*(-parseInt(A(0x197))/0x2)+parseInt(A(0x19f))/0x3+-parseInt(A(0x19c))/0x4*(-parseInt(A(0x19a))/0x5)+-parseInt(A(0x193))/0x6+parseInt(A(0x194))/0x7*(-parseInt(A(0x1a1))/0x8)+parseInt(A(0x195))/0x9*(parseInt(A(0x1a2))/0xa)+parseInt(A(0x192))/0xb;if(s===p)break;else q['push'](q['shift']());}catch(u){q['push'](q['shift']());}}}(b,0xed407));function c(a,d){a=a-0x190;const e=b();let f=e[a];return f;}import{fileURLToPath as d}from'node:url';import f from'node:path';import{resolvePaths as g}from'./paths.js';import{isProcessAlive as h,readText as j,sleep as k,spawnDetached as l}from'./utils.js';export async function readDaemonInfo(){const B=c,q=g(),[u,v,w]=await Promise['all']([j(q[B(0x1a3)]),j(q['portFile']),j(q[B(0x1a4)])]),x=Number(u),y=Number(v),z=w?.[B(0x19b)]();if(x&&y&&z&&h(x))return{'pid':x,'port':y,'token':z};}function b(){const E=['GET','2305710QAtMhl','/status','304QMSUdS','4789370BqMyeS','pidFile','tokenFile','catch','stringify','9813397UkpTbM','9676482tkWREn','246407atcdoI','9ojUozj','json','2QXDaDM','port','dirname','7678285ZkdyMo','trim','4NHYGAn','246877MBsbJz'];b=function(){return E;};return b();}export async function ensureDaemon(){const m=await readDaemonInfo();if(m)return m;await startDaemon();for(let p=0x0;p<0x50;p+=0x1){const q=await readDaemonInfo();if(q)return q;await k(0x64);}throw new Error('licos-bridge\x20daemon\x20did\x20not\x20start\x20in\x20time');}export async function startDaemon(){const C=c,m=f['resolve'](f[C(0x199)](d(import.meta.url)),'..','index.js');l(m,['--daemon']);}export async function ipcRequest(m,p,q){const D=c,s=await fetch('http://127.0.0.1:'+q[D(0x198)]+m,{'method':'/status'===m?D(0x19e):'POST','headers':{'authorization':'Bearer\x20'+q['token'],'content-type':'application/json'},'body':D(0x1a0)===m?void 0x0:JSON[D(0x191)](p??{})}),u=await s[D(0x196)]()[D(0x190)](()=>({}));if(!s['ok'])throw new Error(u['error']||'IPC\x20'+m+'\x20failed:\x20HTTP\x20'+s['status']);return u;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(D,E){const V=h,F=D();while(!![]){try{const G
|
|
1
|
+
(function(D,E){const V=h,F=D();while(!![]){try{const G=-parseInt(V(0xc6))/0x1+-parseInt(V(0x9c))/0x2*(-parseInt(V(0xc5))/0x3)+-parseInt(V(0xa3))/0x4*(parseInt(V(0xaa))/0x5)+-parseInt(V(0xac))/0x6+parseInt(V(0xc9))/0x7*(-parseInt(V(0xae))/0x8)+-parseInt(V(0xa8))/0x9*(-parseInt(V(0xa0))/0xa)+parseInt(V(0xa9))/0xb;if(G===E)break;else F['push'](F['shift']());}catch(H){F['push'](F['shift']());}}}(b,0x709da));import{spawnSync as j}from'node:child_process';import{readdir as k,readFile as m,stat as q}from'node:fs/promises';import{fileURLToPath as u}from'node:url';import v from'node:path';function b(){const a4=['/stop','0.0.0','.txt','image/png','bridgeRoot','6PFCLCV','795773PMuYKT','send\x20requires\x20--agent-id','length','234493FkXXmw','name','send\x20requires\x20--session-id','584346YbSRxC','platform','send\x20--group-file\x20requires\x20--mime','.pdf','20UeCKzP','--ignore-existing','includes','996eKQNvz','filter','grep','join','connect','756693KxyVqb','11860266Gfpasq','4210dSEDhi','size','777048hvtDcI','file\x20too\x20large:\x20','56lWqVtX','agentId','.jpg','status','@kmlckj/licos-bridge@latest','.log','target','not\x20a\x20file:\x20','kind','catch','isFile','split','resolve','slice','bridge-','test','npx.cmd','sessionId'];b=function(){return a4;};return b();}import{detectFrameworks as w}from'./frameworks.js';import{ipcRequest as x,readDaemonInfo as y}from'./ipc.js';import{resolvePaths as z}from'./paths.js';import{readJson as A,readText as B,removeDir as C}from'./utils.js';function h(a,c){a=a-0x9a;const d=b();let e=d[a];return e;}export async function statusSnapshot(){const W=h,D=await y();if(!D)return{'running':!0x1,'frameworks':await w()};const E=await x('/status',void 0x0,D)[W(0xb7)](F=>({'ok':!0x1,'error':F['message']||String(F)}));return{'running':!0x0,'pid':D['pid'],...E};}export async function purgeBridge(){const X=h,D=await y();D&&await x(X(0xc0),{},D)[X(0xb7)](()=>{});const {uninstallService:E}=await import('./service.js');await E()['catch'](()=>{}),await C(z()[X(0xc4)]);}export async function packageVersion(){const Y=h,D=await A(v[Y(0xba)](v['dirname'](u(import.meta.url)),'..','..','package.json'),void 0x0)[Y(0xb7)](()=>{});return D?.['version']||Y(0xc1);}export async function printLogs(D={}){const Z=h,E=z();if(D['list']){const J=await k(E['bridgeRoot'])[Z(0xb7)](()=>[]);for(const K of J[Z(0xa4)](L=>/^bridge(?:-\d{4}-\d{2}-\d{2})?\.log$/[Z(0xbd)](L))['sort']())console['log'](K);return;}const F=D['date']?v['join'](E[Z(0xc4)],Z(0xbc)+D['date']+Z(0xb3)):E['logFile'],G=await B(F)??'';let H=G[Z(0xb9)](/\r?\n/)['filter'](Boolean);D[Z(0xaf)]&&(H=H['filter'](L=>L['includes'](D['agentId']))),D[Z(0xa5)]&&(H=H['filter'](L=>L[Z(0xa2)](D[Z(0xa5)]))),D['level']&&(H=H[Z(0xa4)](L=>L['toLowerCase']()['includes'](String(D['level'])['toLowerCase']())));const I=Number['isFinite'](D['tail'])?D['tail']:0xc8;I>0x0&&(H=H['slice'](-I));for(const L of H)console['log'](L);D['follow']&&await async function(M,N,O){let P=N;await new Promise(Q=>{const R=setInterval(async()=>{const a0=h,S=await B(M)??'';if(S[a0(0xc8)]>P){let T=S[a0(0xbb)](P)['split'](/\r?\n/)['filter'](Boolean);P=S['length'],O['agentId']&&(T=T[a0(0xa4)](U=>U['includes'](O['agentId']))),O['grep']&&(T=T['filter'](U=>U[a0(0xa2)](O['grep'])));for(const U of T)console['log'](U);}},0x3e8);process['on']('SIGINT',()=>{clearInterval(R),Q();});});}(E['logFile'],G[Z(0xc8)],D);}export async function runUpdate(){const a1=h,D=await y();D&&await x('/stop',{},D)['catch'](()=>{});const E='win32'===process[a1(0x9d)]?a1(0xbe):'npx',F=['-y',a1(0xa1),a1(0xb2),a1(0xa7)];if(0x0!==j(E,F,{'stdio':'inherit','windowsHide':!0x0})[a1(0xb1)])throw new Error('update\x20failed:\x20'+E+'\x20'+F[a1(0xa6)]('\x20'));}export async function buildSendPayload(D){const a2=h;if(!D['agentId'])throw new Error(a2(0xc7));if(!D['sessionId'])throw new Error(a2(0x9b));if(D['groupFile']){if(!D['mime'])throw new Error(a2(0x9e));return{'kind':D[a2(0xb6)],'uri':D[a2(0xb4)],'agentId':D['agentId'],'sessionId':D['sessionId'],'caption':D['caption'],'name':D[a2(0x9a)],'groupFile':!0x0,'mime':D['mime']};}const E=await q(D['target']);if(!E[a2(0xb8)]())throw new Error(a2(0xb5)+D[a2(0xb4)]);if(E['size']>0x3200000)throw new Error(a2(0xad)+E[a2(0xab)]+'\x20bytes\x20(max\x2052428800)');const F=await m(D['target']);return{'kind':D['kind'],'agentId':D['agentId'],'sessionId':D[a2(0xbf)],'caption':D['caption'],'name':D['name']||v['basename'](D['target']),'mime':D['mime']||f(D[a2(0xb4)],D['kind']),'size':F['byteLength'],'contentBase64':F['toString']('base64')};}function f(D,E){const a3=h,F=v['extname'](D)['toLowerCase']();if('image'===E){if('.png'===F)return a3(0xc3);if([a3(0xb0),'.jpeg'][a3(0xa2)](F))return'image/jpeg';if('.gif'===F)return'image/gif';if('.webp'===F)return'image/webp';}return a3(0x9f)===F?'application/pdf':a3(0xc2)===F?'text/plain':'.md'===F?'text/markdown':'.json'===F?'application/json':'application/octet-stream';}
|
package/dist/lib/paths.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(f,g){const k=b,h=f();while(!![]){try{const i=-parseInt(k(
|
|
1
|
+
function a(){const n=['44qHRFvt','842720NFkTbG','15FJiwRE','resolve','5009529LiYpkf','bridge.token','322556lzAWQo','48746mDUAds','1099926ZqFARd','config.json','21504141rPIvhw','bridge.port','3086275GFqTYN','agentsRoot','join'];a=function(){return n;};return a();}(function(f,g){const k=b,h=f();while(!![]){try{const i=-parseInt(k(0x8b))/0x1*(parseInt(k(0x84))/0x2)+-parseInt(k(0x86))/0x3*(-parseInt(k(0x8a))/0x4)+-parseInt(k(0x90))/0x5+parseInt(k(0x8c))/0x6+-parseInt(k(0x88))/0x7+parseInt(k(0x85))/0x8+parseInt(k(0x8e))/0x9;if(i===g)break;else h['push'](h['shift']());}catch(j){h['push'](h['shift']());}}}(a,0xa5033));import c from'node:os';function b(c,d){c=c-0x83;const e=a();let f=e[c];return f;}import d from'node:path';export function resolvePaths(){const l=b,f=process.env.LICOS_BRIDGE_HOME?d[l(0x87)](process.env.LICOS_BRIDGE_HOME):d['join'](c['homedir'](),'.licos'),g=d['join'](f,'bridge');return{'root':f,'bridgeRoot':g,'agentsRoot':process.env.LICOS_BRIDGE_AGENTS_HOME?d[l(0x87)](process.env.LICOS_BRIDGE_AGENTS_HOME):d['join'](f,'agents'),'pidFile':d[l(0x83)](g,'bridge.pid'),'portFile':d['join'](g,l(0x8f)),'tokenFile':d[l(0x83)](g,l(0x89)),'logFile':d['join'](g,'bridge.log'),'configFile':d['join'](g,l(0x8d)),'serviceLogFile':d['join'](g,'service.log')};}export function agentPaths(f){const m=b,g=resolvePaths(),h=d['join'](g[m(0x91)],f);return{'root':h,'configFile':d[m(0x83)](h,'config.json'),'workspace':d[m(0x83)](h,'workspace'),'logs':d[m(0x83)](h,'logs')};}
|
package/dist/lib/service.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(m,p){const y=c,q=m();while(!![]){try{const u=-parseInt(y(
|
|
1
|
+
const z=c;(function(m,p){const y=c,q=m();while(!![]){try{const u=-parseInt(y(0x9c))/0x1*(-parseInt(y(0xa9))/0x2)+-parseInt(y(0xae))/0x3*(parseInt(y(0x94))/0x4)+-parseInt(y(0xa0))/0x5*(-parseInt(y(0xa4))/0x6)+-parseInt(y(0x9a))/0x7+-parseInt(y(0x93))/0x8*(-parseInt(y(0x98))/0x9)+parseInt(y(0x9e))/0xa*(-parseInt(y(0xb1))/0xb)+parseInt(y(0xb5))/0xc;if(u===p)break;else q['push'](q['shift']());}catch(v){q['push'](q['shift']());}}}(b,0xcdc46));import{spawnSync as d}from'node:child_process';import{fileURLToPath as f}from'node:url';import g from'node:path';import{ensureDir as h,writePrivateText as j}from'./utils.js';function b(){const F=['dirname','30PwAiMd','join','15uBkjqB','systemd\x20user\x20service\x20removed:\x20licos-bridge.service','\x20failed','launchctl','2211078vmDZLt','index.js','log','\x20--daemon\x0aRestart=always\x0aRestartSec=3\x0a\x0a[Install]\x0aWantedBy=default.target\x0a','</string>\x0a</dict></plist>\x0a','4yMpvql','/TN','.service','/Library/LaunchAgents/com.licos.bridge.plist','licos-bridge','3296352QbCZRw','disable','--now','4763946TaohHA','execPath','launchd\x20service\x20installed:\x20com.licos.bridge','/.config/systemd/user','17047776fUnAOc','daemon-reload','systemctl','win32','63736oywleu','4jxeuWt','</string><string>--daemon</string></array>\x0a\x20\x20<key>RunAtLoad</key><true/>\x0a\x20\x20<key>KeepAlive</key><true/>\x0a\x20\x20<key>StandardOutPath</key><string>','platform','/Create','1791kRJDMr','unload','11000402qbrRpJ','--user','350365DdhIWI'];b=function(){return F;};return b();}import{resolvePaths as k}from'./paths.js';const t='LICOS\x20Bridge',a=z(0xad);function c(a,d){a=a-0x92;const e=b();let f=e[a];return f;}export async function installService(){const A=z,m=g['resolve'](g[A(0x9d)](f(import.meta.url)),'..',A(0xa5));if(A(0x92)===process['platform']){const u='\x22'+process[A(0xb2)]+'\x22\x20\x22'+m+'\x22\x20--daemon';return l('schtasks.exe',[A(0x97),'/TN',t,'/SC','ONLOGON','/TR',u,'/F']),void console['log']('Windows\x20login\x20task\x20installed:\x20LICOS\x20Bridge');}if('darwin'===process['platform']){const v=process.env.HOME+'/Library/LaunchAgents/com.licos.bridge.plist';return await h(g['dirname'](v)),await j(v,function(w){const B=A,x=k()['serviceLogFile'];return'<?xml\x20version=\x221.0\x22\x20encoding=\x22UTF-8\x22?>\x0a<!DOCTYPE\x20plist\x20PUBLIC\x20\x22-//Apple//DTD\x20PLIST\x201.0//EN\x22\x20\x22http://www.apple.com/DTDs/PropertyList-1.0.dtd\x22>\x0a<plist\x20version=\x221.0\x22><dict>\x0a\x20\x20<key>Label</key><string>com.licos.bridge</string>\x0a\x20\x20<key>ProgramArguments</key><array><string>'+process['execPath']+'</string><string>'+w+B(0x95)+x+'</string>\x0a\x20\x20<key>StandardErrorPath</key><string>'+x+B(0xa8);}(m)),l(A(0xa3),['load','-w',v]),void console['log'](A(0xb3));}const p=process.env.HOME+A(0xb4),q=g[A(0x9f)](p,a+'.service');await h(p),await j(q,function(w){const C=A;return'[Unit]\x0aDescription=LICOS\x20local\x20agent\x20bridge\x0a\x0a[Service]\x0aExecStart='+process[C(0xb2)]+'\x20'+w+C(0xa7);}(m)),l('systemctl',['--user',A(0xb6)]),l(A(0xb7),[A(0x9b),'enable',A(0xb0),a+A(0xab)]),console[A(0xa6)]('systemd\x20user\x20service\x20installed:\x20licos-bridge.service');}export async function uninstallService(){const D=z;return'win32'===process['platform']?(l('schtasks.exe',['/Delete',D(0xaa),t,'/F'],{'allowFailure':!0x0}),void console['log']('Windows\x20login\x20task\x20removed:\x20LICOS\x20Bridge')):'darwin'===process[D(0x96)]?(l('launchctl',[D(0x99),'-w',process.env.HOME+D(0xac)],{'allowFailure':!0x0}),void console['log']('launchd\x20service\x20removed:\x20com.licos.bridge')):(l(D(0xb7),['--user',D(0xaf),D(0xb0),a+'.service'],{'allowFailure':!0x0}),void console[D(0xa6)](D(0xa1)));}function l(m,p,q={}){const E=z;if(0x0!==d(m,p,{'stdio':'inherit','windowsHide':!0x0})['status']&&!q['allowFailure'])throw new Error(m+'\x20'+p['join']('\x20')+E(0xa2));}
|
package/dist/lib/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const G=d;(function(w,x){const B=d,y=w();while(!![]){try{const z=-parseInt(B(0x172))/0x1*(-parseInt(B(0x17a))/0x2)+-parseInt(B(0x178))/0x3+parseInt(B(0x164))/0x4+-parseInt(B(0x175))/0x5*(-parseInt(B(0x173))/0x6)+-parseInt(B(0x16c))/0x7*(parseInt(B(0x170))/0x8)+-parseInt(B(0x174))/0x9*(-parseInt(B(0x162))/0xa)+-parseInt(B(0x16f))/0xb;if(z===x)break;else y['push'](y['shift']());}catch(A){y['push'](y['shift']());}}}(b,0xb8a65));import{spawn as f,spawnSync as g}from'node:child_process';import{chmod as h,mkdir as j,readFile as k,rm as l,stat as m,writeFile as p}from'node:fs/promises';import{existsSync as q}from'node:fs';import v from'node:path';export function sleep(w){return new Promise(x=>setTimeout(x,w));}export async function ensureDir(w){await j(w,{'recursive':!0x0});}export async function readText(w){const C=d;try{return await k(w,C(0x176));}catch(x){if(C(0x15f)===x?.['code'])return;throw x;}}export async function readJson(w,x=void 0x0){const y=await readText(w);return void 0x0===y?x:JSON['parse'](y);}export async function writeJson(w,x,y){const D=d;await ensureDir(v['dirname'](w)),await p(w,JSON['stringify'](x,null,0x2)+'\x0a',D(0x176)),y&&'win32'!==process['platform']&&await h(w,y);}export async function writePrivateText(w,x){await ensureDir(v['dirname'](w)),await p(w,x,'utf8'),'win32'!==process['platform']&&await h(w,0x180);}export async function removeDir(w){await l(w,{'recursive':!0x0,'force':!0x0});}export async function pathExists(w){try{return await m(w),!0x0;}catch(x){if('ENOENT'===x?.['code'])return!0x1;throw x;}}export function isProcessAlive(w){const E=d;if(!w||Number['isNaN'](w))return!0x1;try{return process[E(0x179)](w,0x0),!0x0;}catch{return!0x1;}}export async function appendLog(w,x,y){const z='['+new Date()['toISOString']()+']\x20'+x+(y?'\x20'+JSON['stringify'](y):'')+'\x0a';await ensureDir(v['dirname'](w)),await p(w,z,{'encoding':'utf8','flag':'a'});}export function findExecutable(w){const F=d,x=F(0x165)===process[F(0x16b)]?F(0x163):'command',y='win32'===process[F(0x16b)]?[w]:['-v',w],z=g(x,y,{'shell':'win32'!==process['platform'],'encoding':'utf8','windowsHide':!0x0});if(0x0===z['status'])return z['stdout']['split'](/\r?\n/)['map'](A=>A['trim']())['find'](Boolean)||void 0x0;}export function commandVersion(w,x=[G(0x161)]){const H=G,y=g(w,x,{'encoding':H(0x176),'windowsHide':!0x0,'timeout':0x1388});if(0x0===y['status'])return(y['stdout']||y['stderr'])['trim']()['split'](/\r?\n/)[0x0]?.[H(0x177)]()||void 0x0;}export function spawnDetached(w,x=[]){const I=G,y=f(process[I(0x16d)],[w,...x],{'detached':!0x0,'stdio':'ignore','windowsHide':!0x0,'env':process.env});return y['unref'](),y['pid'];}export function safeResolve(w,x){const J=G,y=v['resolve'](w,x),z=v[J(0x160)](w,y);if(''===z||!z['startsWith']('..')&&!v['isAbsolute'](z))return y;throw new Error(J(0x171)+x);}export function safeRelativePath(w){const K=G,x=String(w||'')[K(0x167)](/\\/g,'/')['replace'](/^\/+/,'');if(!x||'.'===x)return'';const y=v['posix'][K(0x17c)](x);if('.'===y||''===y)return'';if(y['startsWith']('../')||'..'===y||v[K(0x166)](y))throw new Error('unsafe\x20relative\x20path:\x20'+w);return y;}export function safeName(w,x=G(0x16e)){const L=G;return String(w||'')['trim']()[L(0x167)](/[<>:"/\\|?*\x00-\x1f]+/g,'-')['replace'](/^\.+$/,'')[L(0x16a)](0x0,0x78)||x;}export function joinUrl(w,x){if(!w)return;const y=w['replace'](/\/+$/,'');return y['endsWith'](x)?y:''+y+x;}export function normalizeFramework(w){const M=G,x=String(w||'')[M(0x177)]()['toLowerCase']();return['claude','claude-code',M(0x168)]['includes'](x)?'claude-code':['codex','openai-codex']['includes'](x)?'codex':[M(0x169),'open-claw']['includes'](x)?'openclaw':x||M(0x17b);}function b(){const O=['8490ZnIFDS','utf8','trim','246207Qggwqv','kill','636214JYOrWw','codex','normalize','string','ENOENT','relative','--version','9500OwMBBk','where','4720440cBuxDW','win32','isAbsolute','replace','claudecode','openclaw','slice','platform','119cfFAFH','execPath','item','3453450QIhxnb','400648pvGYfL','path\x20escapes\x20workspace:\x20','1rCdwLL','138eBshIX','4419OjSJln'];b=function(){return O;};return b();}function d(a,c){a=a-0x15e;const e=b();let f=e[a];return f;}export function isReadableFilePath(w){const N=G;return N(0x15e)==typeof w&&w['length']>0x0&&q(w);}
|