devcon-cli 0.1.2 → 0.1.4
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/agent-bun.js +6 -6
- package/dist/agent-node.js +6 -6
- package/package.json +1 -1
package/dist/agent-bun.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import*as
|
|
4
|
-
`);for(let
|
|
5
|
-
`)}
|
|
6
|
-
`);
|
|
7
|
-
`),process.exit(1)}),
|
|
8
|
-
`),process.exit(1);
|
|
3
|
+
import*as U from"fs";import*as $ from"net";function L(G){let K=[],J=new Set,N=G.split(`
|
|
4
|
+
`);for(let z=1;z<N.length;z++){let j=N[z].trim();if(!j)continue;let F=j.split(/\s+/),R=F[1],Q=F[3];if(!R||!Q)continue;if(Q!=="0A")continue;let X=R.split(":")[1];if(!X)continue;let V=parseInt(X,16);if(V<=0||J.has(V))continue;let W=F[9];if(!W)continue;let Y=parseInt(W,10);if(isNaN(Y))continue;J.add(V),K.push({port:V,inode:Y})}return K.sort((z,j)=>z.port-j.port)}function O(){let G=new Map,K;try{K=U.readdirSync("/proc").filter((J)=>/^\d+$/.test(J))}catch{return G}for(let J of K){let N=parseInt(J,10),z=`/proc/${N}/fd`,j;try{j=U.readdirSync(z)}catch{continue}for(let F of j)try{let Q=U.readlinkSync(`${z}/${F}`).match(/^socket:\[(\d+)\]$/);if(Q)G.set(parseInt(Q[1],10),N)}catch{continue}}return G}function v(){let G=new Map,K;try{K=U.readdirSync("/proc").filter((J)=>/^\d+$/.test(J))}catch{return G}for(let J of K){let N=parseInt(J,10);try{let z=U.readFileSync(`/proc/${N}/stat`,"utf-8"),j=z.lastIndexOf(")");if(j===-1)continue;let R=z.slice(j+2).split(" "),Q=parseInt(R[1],10);if(!isNaN(Q))G.set(N,Q)}catch{continue}}return G}function w(G){let K=new Map;for(let[z,j]of G){let F=K.get(j);if(!F)F=[],K.set(j,F);F.push(z)}let J=new Set,N=[];for(let[z,j]of G)if(j===0&&z!==1)J.add(z),N.push(z);while(N.length>0){let z=N.shift(),j=K.get(z);if(j){for(let F of j)if(!J.has(F))J.add(F),N.push(F)}}return J}function A(){function G(j){process.stdout.write(JSON.stringify(j)+`
|
|
5
|
+
`)}G({type:"ready",pid:process.pid});let K="";function J(){let j="";try{j+=U.readFileSync("/proc/net/tcp","utf-8")}catch{}try{j+=U.readFileSync("/proc/net/tcp6","utf-8")}catch{}let F=L(j);if(F.length===0){if(K!=="")K="",G({type:"ports",ports:[]});return}let R=O(),Q=v(),X=w(Q),V=[];for(let{port:Y,inode:B}of F){let Z=R.get(B);if(Z!==void 0&&X.has(Z))V.push(Y)}let W=V.join(",");if(W!==K)K=W,G({type:"ports",ports:V})}J();let N=setInterval(J,1000),z="";process.stdin.setEncoding("utf-8"),process.stdin.on("data",(j)=>{z+=j;let F=z.split(`
|
|
6
|
+
`);z=F.pop();for(let R of F){if(!R.trim())continue;try{let Q=JSON.parse(R);if(Q.type==="stop")clearInterval(N),process.exit(0);if(Q.type==="ping")G({type:"ready",pid:process.pid})}catch{}}}),process.stdin.on("end",()=>{clearInterval(N),process.exit(0)})}function C(G){let K=["127.0.0.1","::1"],J=!1;function N(z){let j=$.createConnection({host:K[z],port:G},()=>{J=!0,process.stdin.pipe(j),j.pipe(process.stdout)});j.on("error",(F)=>{if(!J&&F.code==="ECONNREFUSED"&&z+1<K.length){N(z+1);return}process.stderr.write(`bridge error: ${F.message}
|
|
7
|
+
`),process.exit(1)}),j.on("close",()=>{if(J)process.exit(0)}),process.stdin.on("end",()=>{j.end()})}N(0)}var _=process.argv[2];if(_==="monitor")A();else if(_==="bridge"){let G=parseInt(process.argv[3],10);if(isNaN(G))process.stderr.write(`Usage: agent bridge <port>
|
|
8
|
+
`),process.exit(1);C(G)}else process.stderr.write(`Usage: agent <monitor|bridge> [port]
|
|
9
9
|
`),process.exit(1);
|
package/dist/agent-node.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import*as
|
|
3
|
-
`);for(let
|
|
4
|
-
`)}
|
|
5
|
-
`);
|
|
6
|
-
`),process.exit(1)}),
|
|
7
|
-
`),process.exit(1);
|
|
2
|
+
import*as U from"node:fs";import*as $ from"node:net";function L(G){let K=[],J=new Set,N=G.split(`
|
|
3
|
+
`);for(let z=1;z<N.length;z++){let j=N[z].trim();if(!j)continue;let F=j.split(/\s+/),R=F[1],Q=F[3];if(!R||!Q)continue;if(Q!=="0A")continue;let X=R.split(":")[1];if(!X)continue;let V=parseInt(X,16);if(V<=0||J.has(V))continue;let W=F[9];if(!W)continue;let Y=parseInt(W,10);if(isNaN(Y))continue;J.add(V),K.push({port:V,inode:Y})}return K.sort((z,j)=>z.port-j.port)}function O(){let G=new Map,K;try{K=U.readdirSync("/proc").filter((J)=>/^\d+$/.test(J))}catch{return G}for(let J of K){let N=parseInt(J,10),z=`/proc/${N}/fd`,j;try{j=U.readdirSync(z)}catch{continue}for(let F of j)try{let Q=U.readlinkSync(`${z}/${F}`).match(/^socket:\[(\d+)\]$/);if(Q)G.set(parseInt(Q[1],10),N)}catch{continue}}return G}function v(){let G=new Map,K;try{K=U.readdirSync("/proc").filter((J)=>/^\d+$/.test(J))}catch{return G}for(let J of K){let N=parseInt(J,10);try{let z=U.readFileSync(`/proc/${N}/stat`,"utf-8"),j=z.lastIndexOf(")");if(j===-1)continue;let R=z.slice(j+2).split(" "),Q=parseInt(R[1],10);if(!isNaN(Q))G.set(N,Q)}catch{continue}}return G}function w(G){let K=new Map;for(let[z,j]of G){let F=K.get(j);if(!F)F=[],K.set(j,F);F.push(z)}let J=new Set,N=[];for(let[z,j]of G)if(j===0&&z!==1)J.add(z),N.push(z);while(N.length>0){let z=N.shift(),j=K.get(z);if(j){for(let F of j)if(!J.has(F))J.add(F),N.push(F)}}return J}function A(){function G(j){process.stdout.write(JSON.stringify(j)+`
|
|
4
|
+
`)}G({type:"ready",pid:process.pid});let K="";function J(){let j="";try{j+=U.readFileSync("/proc/net/tcp","utf-8")}catch{}try{j+=U.readFileSync("/proc/net/tcp6","utf-8")}catch{}let F=L(j);if(F.length===0){if(K!=="")K="",G({type:"ports",ports:[]});return}let R=O(),Q=v(),X=w(Q),V=[];for(let{port:Y,inode:B}of F){let Z=R.get(B);if(Z!==void 0&&X.has(Z))V.push(Y)}let W=V.join(",");if(W!==K)K=W,G({type:"ports",ports:V})}J();let N=setInterval(J,1000),z="";process.stdin.setEncoding("utf-8"),process.stdin.on("data",(j)=>{z+=j;let F=z.split(`
|
|
5
|
+
`);z=F.pop();for(let R of F){if(!R.trim())continue;try{let Q=JSON.parse(R);if(Q.type==="stop")clearInterval(N),process.exit(0);if(Q.type==="ping")G({type:"ready",pid:process.pid})}catch{}}}),process.stdin.on("end",()=>{clearInterval(N),process.exit(0)})}function C(G){let K=["127.0.0.1","::1"],J=!1;function N(z){let j=$.createConnection({host:K[z],port:G},()=>{J=!0,process.stdin.pipe(j),j.pipe(process.stdout)});j.on("error",(F)=>{if(!J&&F.code==="ECONNREFUSED"&&z+1<K.length){N(z+1);return}process.stderr.write(`bridge error: ${F.message}
|
|
6
|
+
`),process.exit(1)}),j.on("close",()=>{if(J)process.exit(0)}),process.stdin.on("end",()=>{j.end()})}N(0)}var _=process.argv[2];if(_==="monitor")A();else if(_==="bridge"){let G=parseInt(process.argv[3],10);if(isNaN(G))process.stderr.write(`Usage: agent bridge <port>
|
|
7
|
+
`),process.exit(1);C(G)}else process.stderr.write(`Usage: agent <monitor|bridge> [port]
|
|
8
8
|
`),process.exit(1);
|