@exelerus/openclaw-vexscan 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,177 @@
1
+ import { spawn } from "child_process";
2
+ import { existsSync } from "fs";
3
+ import { homedir, platform, arch } from "os";
4
+ import { join } from "path";
5
+ import type { ExecResult } from "./types.js";
6
+
7
+ const REPO = "edimuj/vexscan";
8
+ const INSTALL_DIR = join(homedir(), ".local", "bin");
9
+
10
+ /**
11
+ * Common locations to search for the vexscan binary
12
+ */
13
+ const SEARCH_PATHS = [
14
+ join(INSTALL_DIR, "vexscan"),
15
+ join(homedir(), ".cargo", "bin", "vexscan"),
16
+ "/usr/local/bin/vexscan",
17
+ "/opt/homebrew/bin/vexscan",
18
+ ];
19
+
20
+ /**
21
+ * Find vexscan binary in common locations
22
+ */
23
+ export async function findVexscan(): Promise<string | null> {
24
+ // Check if in PATH
25
+ const inPath = await checkInPath("vexscan");
26
+ if (inPath) return "vexscan";
27
+
28
+ // Check common locations
29
+ for (const path of SEARCH_PATHS) {
30
+ if (existsSync(path)) {
31
+ return path;
32
+ }
33
+ }
34
+
35
+ return null;
36
+ }
37
+
38
+ /**
39
+ * Check if a command exists in PATH
40
+ */
41
+ async function checkInPath(cmd: string): Promise<boolean> {
42
+ return new Promise((resolve) => {
43
+ const proc = spawn("which", [cmd], { stdio: "pipe" });
44
+ proc.on("close", (code) => resolve(code === 0));
45
+ proc.on("error", () => resolve(false));
46
+ });
47
+ }
48
+
49
+ /**
50
+ * Install vexscan from GitHub releases
51
+ */
52
+ export async function installVexscan(): Promise<string | null> {
53
+ const os = platform();
54
+ const cpu = arch();
55
+
56
+ // Determine asset name
57
+ let osName: string;
58
+ switch (os) {
59
+ case "darwin":
60
+ osName = "macos";
61
+ break;
62
+ case "linux":
63
+ osName = "linux";
64
+ break;
65
+ default:
66
+ return null; // Windows not supported via this method
67
+ }
68
+
69
+ let archName: string;
70
+ switch (cpu) {
71
+ case "x64":
72
+ archName = "x86_64";
73
+ break;
74
+ case "arm64":
75
+ archName = "aarch64";
76
+ break;
77
+ default:
78
+ return null;
79
+ }
80
+
81
+ const assetName = `vexscan-${osName}-${archName}`;
82
+
83
+ try {
84
+ // Get latest version
85
+ const response = await fetch(`https://api.github.com/repos/${REPO}/releases/latest`);
86
+ if (!response.ok) return null;
87
+
88
+ const release = (await response.json()) as { tag_name: string };
89
+ const version = release.tag_name;
90
+
91
+ const downloadUrl = `https://github.com/${REPO}/releases/download/${version}/${assetName}`;
92
+
93
+ // Download binary
94
+ const binaryResponse = await fetch(downloadUrl);
95
+ if (!binaryResponse.ok) return null;
96
+
97
+ const binary = await binaryResponse.arrayBuffer();
98
+
99
+ // Write to install dir
100
+ const { mkdir, writeFile, chmod } = await import("fs/promises");
101
+ await mkdir(INSTALL_DIR, { recursive: true });
102
+
103
+ const binaryPath = join(INSTALL_DIR, "vexscan");
104
+ await writeFile(binaryPath, Buffer.from(binary));
105
+ await chmod(binaryPath, 0o755);
106
+
107
+ return binaryPath;
108
+ } catch {
109
+ return null;
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Execute an arbitrary command with arguments
115
+ */
116
+ export async function execCommand(cmd: string, args: string[]): Promise<ExecResult> {
117
+ return new Promise((resolve, reject) => {
118
+ const proc = spawn(cmd, args, {
119
+ stdio: ["ignore", "pipe", "pipe"],
120
+ env: { ...process.env, NO_COLOR: "1" },
121
+ });
122
+
123
+ let stdout = "";
124
+ let stderr = "";
125
+
126
+ proc.stdout.on("data", (data) => {
127
+ stdout += data.toString();
128
+ });
129
+
130
+ proc.stderr.on("data", (data) => {
131
+ stderr += data.toString();
132
+ });
133
+
134
+ proc.on("close", (code) => {
135
+ resolve({ stdout, stderr, exitCode: code ?? 0 });
136
+ });
137
+
138
+ proc.on("error", (err) => {
139
+ reject(err);
140
+ });
141
+ });
142
+ }
143
+
144
+ /**
145
+ * Execute vexscan CLI with arguments
146
+ */
147
+ export async function execVexscan(cliPath: string, args: string[]): Promise<ExecResult> {
148
+ return new Promise((resolve, reject) => {
149
+ const proc = spawn(cliPath, args, {
150
+ stdio: ["ignore", "pipe", "pipe"],
151
+ env: { ...process.env, NO_COLOR: "1" },
152
+ });
153
+
154
+ let stdout = "";
155
+ let stderr = "";
156
+
157
+ proc.stdout.on("data", (data) => {
158
+ stdout += data.toString();
159
+ });
160
+
161
+ proc.stderr.on("data", (data) => {
162
+ stderr += data.toString();
163
+ });
164
+
165
+ proc.on("close", (code) => {
166
+ resolve({
167
+ stdout,
168
+ stderr,
169
+ exitCode: code ?? 0,
170
+ });
171
+ });
172
+
173
+ proc.on("error", (err) => {
174
+ reject(err);
175
+ });
176
+ });
177
+ }
@@ -0,0 +1,84 @@
1
+ declare module "openclaw/plugin-sdk" {
2
+ import type { TSchema } from "@sinclair/typebox";
3
+
4
+ type OpenClawPluginConfigSchema = {
5
+ safeParse?: (value: unknown) => {
6
+ success: boolean;
7
+ data?: unknown;
8
+ error?: { issues?: Array<{ message: string }> };
9
+ };
10
+ };
11
+
12
+ type OpenClawPluginToolOptions = {
13
+ name?: string;
14
+ names?: string[];
15
+ optional?: boolean;
16
+ };
17
+
18
+ type OpenClawPluginToolContext = {
19
+ config: any;
20
+ sessionKey?: string;
21
+ sandboxed?: boolean;
22
+ };
23
+
24
+ type AgentTool = {
25
+ name: string;
26
+ description: string;
27
+ parameters: TSchema;
28
+ execute(toolCallId: string, params: Record<string, unknown>): Promise<{
29
+ content: { type: string; text: string }[];
30
+ details?: unknown;
31
+ }>;
32
+ };
33
+
34
+ type OpenClawPluginToolFactory = (
35
+ ctx: OpenClawPluginToolContext,
36
+ ) => AgentTool | AgentTool[] | null | undefined;
37
+
38
+ type OpenClawPluginService = {
39
+ id: string;
40
+ start(): Promise<void>;
41
+ stop(): Promise<void>;
42
+ };
43
+
44
+ type OpenClawPluginApi = {
45
+ id: string;
46
+ name: string;
47
+ version?: string;
48
+ description?: string;
49
+ source: string;
50
+ config: any;
51
+ pluginConfig?: Record<string, unknown>;
52
+ runtime: any;
53
+ logger: {
54
+ info(msg: string): void;
55
+ warn(msg: string): void;
56
+ error(msg: string): void;
57
+ };
58
+ registerTool: (
59
+ tool: AgentTool | OpenClawPluginToolFactory,
60
+ opts?: OpenClawPluginToolOptions,
61
+ ) => void;
62
+ registerCli: (
63
+ registrar: (ctx: { program: any }) => void,
64
+ opts?: { commands?: string[] },
65
+ ) => void;
66
+ registerService: (service: OpenClawPluginService) => void;
67
+ registerHook: (events: string | string[], handler: (...args: any[]) => any, opts?: any) => void;
68
+ on: (hookName: string, handler: (...args: any[]) => any, opts?: { priority?: number }) => void;
69
+ resolvePath: (input: string) => string;
70
+ };
71
+
72
+ function emptyPluginConfigSchema(): OpenClawPluginConfigSchema;
73
+
74
+ export type {
75
+ OpenClawPluginApi,
76
+ OpenClawPluginConfigSchema,
77
+ OpenClawPluginToolOptions,
78
+ OpenClawPluginToolFactory,
79
+ OpenClawPluginToolContext,
80
+ OpenClawPluginService,
81
+ AgentTool,
82
+ };
83
+ export { emptyPluginConfigSchema };
84
+ }
package/src/types.ts ADDED
@@ -0,0 +1,53 @@
1
+ export interface VexscanConfig {
2
+ enabled: boolean;
3
+ scanOnInstall: boolean;
4
+ minSeverity: string;
5
+ thirdPartyOnly: boolean;
6
+ skipDeps: boolean;
7
+ cliPath?: string;
8
+ }
9
+
10
+ export interface ScanResult {
11
+ scan_root: string;
12
+ platform?: string;
13
+ total_findings?: number;
14
+ max_severity?: string;
15
+ findings_by_severity?: Record<string, number>;
16
+ total_time_ms: number;
17
+ results: FileResult[];
18
+ }
19
+
20
+ export interface FileResult {
21
+ path: string;
22
+ findings: Finding[];
23
+ }
24
+
25
+ export interface Finding {
26
+ rule_id: string;
27
+ title: string;
28
+ description: string;
29
+ severity: string;
30
+ category: string;
31
+ location: Location;
32
+ snippet: string;
33
+ remediation?: string;
34
+ }
35
+
36
+ export interface Location {
37
+ file: string;
38
+ start_line: number;
39
+ end_line: number;
40
+ start_column: number;
41
+ end_column: number;
42
+ }
43
+
44
+ export interface VetResult extends ScanResult {
45
+ source: string;
46
+ branch?: string;
47
+ }
48
+
49
+ export interface ExecResult {
50
+ stdout: string;
51
+ stderr: string;
52
+ exitCode: number;
53
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "sourceMap": true,
9
+ "outDir": "dist",
10
+ "rootDir": ".",
11
+ "strict": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true,
14
+ "forceConsistentCasingInFileNames": true
15
+ },
16
+ "include": ["index.ts", "src/**/*.ts"],
17
+ "exclude": ["node_modules", "dist"]
18
+ }