@vibecontrols/plugin-sdk 2026.1108.1 → 2026.1110.1
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 +1 -1
- package/dist/audit/index.d.ts +7 -13
- package/dist/audit/index.js +13 -14
- package/dist/broadcast/index.d.ts +6 -12
- package/dist/broadcast/index.js +8 -9
- package/dist/cli/index.d.ts +7 -72
- package/dist/cli/index.js +1 -104
- package/dist/cli-CGyu31Cn.js +104 -0
- package/dist/config/index.d.ts +18 -24
- package/dist/config/index.js +56 -61
- package/dist/context/index.d.ts +26 -32
- package/dist/context/index.js +33 -21
- package/dist/contract/index.d.ts +2 -413
- package/dist/contract/index.js +11 -12
- package/dist/host/fs-safety.d.ts +13 -17
- package/dist/host/fs-safety.js +223 -217
- package/dist/host/os.d.ts +2 -68
- package/dist/host/os.js +15 -7
- package/dist/host/paths.d.ts +2 -36
- package/dist/host/paths.js +44 -44
- package/dist/host/request-security.d.ts +6 -7
- package/dist/host/request-security.js +26 -14
- package/dist/http/index.d.ts +23 -25
- package/dist/http/index.js +60 -65
- package/dist/index-BM4zNXSR.d.ts +25 -0
- package/dist/index-D946chPf.d.ts +410 -0
- package/dist/index-Q_hnxaN_.d.ts +60 -0
- package/dist/index.d.ts +44 -18
- package/dist/index.js +16 -749
- package/dist/install/index.d.ts +46 -50
- package/dist/install/index.js +269 -189
- package/dist/lifecycle/index.d.ts +24 -30
- package/dist/lifecycle/index.js +18 -30
- package/dist/log/index.d.ts +10 -15
- package/dist/log/index.js +19 -20
- package/dist/os-DoFa9kjr.d.ts +67 -0
- package/dist/paths-h28H4Xeb.d.ts +35 -0
- package/dist/providers/index.d.ts +50 -56
- package/dist/providers/index.js +101 -126
- package/dist/routes/index.d.ts +22 -28
- package/dist/routes/index.js +80 -72
- package/dist/storage/index.d.ts +2 -38
- package/dist/storage/index.js +1 -67
- package/dist/storage-DkNBaJHC.js +64 -0
- package/dist/subprocess/index.d.ts +5 -11
- package/dist/subprocess/index.js +85 -56
- package/dist/telemetry/index.d.ts +15 -21
- package/dist/telemetry/index.js +35 -36
- package/dist/testing/index.d.ts +6 -28
- package/dist/testing/index.js +87 -88
- package/package.json +8 -8
package/dist/host/fs-safety.js
CHANGED
|
@@ -1,255 +1,261 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { closeSync, constants, fstatSync, lstatSync, openSync, promises, readSync, realpathSync, statSync } from "node:fs";
|
|
5
4
|
// src/host/fs-safety.ts
|
|
5
|
+
/**
|
|
6
|
+
* @vibecontrols/plugin-sdk/host/fs-safety
|
|
7
|
+
*
|
|
8
|
+
* Filesystem-jail helpers for plugins that touch user-supplied paths (e.g. a
|
|
9
|
+
* session's working directory). `resolveSafePath` confines access to the
|
|
10
|
+
* allowed roots (`VIBECONTROLS_ALLOWED_ROOTS` or cwd/home/tmp), rejects a
|
|
11
|
+
* symlinked final component, and canonicalises via realpath so parent-symlink
|
|
12
|
+
* escapes are caught. Ported verbatim from the agent's internal
|
|
13
|
+
* `core/safe-paths.ts` so meta plugins owning host routes (session-manager)
|
|
14
|
+
* no longer reach into agent internals. Pure `node:fs`/`os`/`path`.
|
|
15
|
+
*/
|
|
6
16
|
function positiveIntFromEnv(name, fallback) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
const parsed = parseInt(process.env[name] ?? "", 10);
|
|
18
|
+
return Number.isInteger(parsed) && parsed > 0 ? parsed : fallback;
|
|
19
|
+
}
|
|
20
|
+
const MAX_FILE_READ_BYTES = positiveIntFromEnv("VIBECONTROLS_MAX_FILE_READ_BYTES", 10485760);
|
|
21
|
+
const MAX_DIRECTORY_ENTRIES = positiveIntFromEnv("VIBECONTROLS_MAX_DIRECTORY_ENTRIES", 2e3);
|
|
22
|
+
const SENSITIVE_PATTERNS = [
|
|
23
|
+
/(?:^|\/)\.env(?:\..*)?$/,
|
|
24
|
+
/\.pem$/,
|
|
25
|
+
/\.key$/,
|
|
26
|
+
/(?:^|\/)id_rsa(?:$|\.)/,
|
|
27
|
+
/(?:^|\/)\.ssh(?:\/|$)/,
|
|
28
|
+
/(?:^|\/)\.git\/config$/,
|
|
29
|
+
/(?:^|\/)\.npmrc$/
|
|
30
|
+
];
|
|
31
|
+
const POSIX_PROTECTED_PATHS = [
|
|
32
|
+
"/",
|
|
33
|
+
"/etc",
|
|
34
|
+
"/usr",
|
|
35
|
+
"/bin",
|
|
36
|
+
"/sbin",
|
|
37
|
+
"/var",
|
|
38
|
+
"/opt"
|
|
23
39
|
];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"C:\\ProgramData"
|
|
40
|
+
const WIN32_PROTECTED_PATHS = [
|
|
41
|
+
"C:\\Windows",
|
|
42
|
+
"C:\\Program Files",
|
|
43
|
+
"C:\\Program Files (x86)",
|
|
44
|
+
"C:\\ProgramData"
|
|
30
45
|
];
|
|
31
46
|
function protectedPathsForHost() {
|
|
32
|
-
|
|
47
|
+
return process.platform === "win32" ? WIN32_PROTECTED_PATHS : POSIX_PROTECTED_PATHS;
|
|
33
48
|
}
|
|
34
49
|
function normalizeForCompare(p) {
|
|
35
|
-
|
|
50
|
+
return process.platform === "win32" ? p.toLowerCase() : p;
|
|
36
51
|
}
|
|
37
52
|
function configuredRoots() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
53
|
+
const raw = process.env.VIBECONTROLS_ALLOWED_ROOTS;
|
|
54
|
+
if (raw) return raw.split(path.delimiter).map((entry) => entry.trim()).filter(Boolean);
|
|
55
|
+
return [
|
|
56
|
+
process.cwd(),
|
|
57
|
+
os.homedir(),
|
|
58
|
+
os.tmpdir()
|
|
59
|
+
].filter(Boolean);
|
|
43
60
|
}
|
|
44
61
|
async function realpathIfExists(candidate) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
62
|
+
try {
|
|
63
|
+
return await promises.realpath(candidate);
|
|
64
|
+
} catch {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
50
67
|
}
|
|
51
68
|
async function allowedRootRealpaths() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
69
|
+
const roots = [];
|
|
70
|
+
for (const root of configuredRoots()) {
|
|
71
|
+
const resolved = path.resolve(root);
|
|
72
|
+
const real = await realpathIfExists(resolved) ?? resolved;
|
|
73
|
+
if (!roots.includes(real)) roots.push(real);
|
|
74
|
+
}
|
|
75
|
+
return roots;
|
|
59
76
|
}
|
|
60
77
|
function isWithinRoot(target, root) {
|
|
61
|
-
|
|
62
|
-
|
|
78
|
+
const relative = path.relative(root, target);
|
|
79
|
+
return relative === "" || !!relative && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
63
80
|
}
|
|
64
81
|
async function assertUnderAllowedRoot(realPath) {
|
|
65
|
-
|
|
66
|
-
if (!roots.some((root) => isWithinRoot(realPath, root))) {
|
|
67
|
-
throw new Error("Access denied: path is outside allowed directories");
|
|
68
|
-
}
|
|
82
|
+
if (!(await allowedRootRealpaths()).some((root) => isWithinRoot(realPath, root))) throw new Error("Access denied: path is outside allowed directories");
|
|
69
83
|
}
|
|
70
84
|
async function nearestExistingParent(candidate) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
let current = path.dirname(candidate);
|
|
86
|
+
while (current && current !== path.dirname(current)) {
|
|
87
|
+
const real = await realpathIfExists(current);
|
|
88
|
+
if (real) return real;
|
|
89
|
+
current = path.dirname(current);
|
|
90
|
+
}
|
|
91
|
+
const rootReal = await realpathIfExists(current || path.parse(candidate).root);
|
|
92
|
+
if (!rootReal) throw new Error("Path parent does not exist");
|
|
93
|
+
return rootReal;
|
|
80
94
|
}
|
|
81
95
|
async function assertFinalIsNotSymlink(candidate) {
|
|
82
|
-
|
|
83
|
-
if (stat?.isSymbolicLink()) {
|
|
84
|
-
throw new Error("Access denied: symbolic links are not allowed");
|
|
85
|
-
}
|
|
96
|
+
if ((await promises.lstat(path.resolve(candidate)).catch(() => null))?.isSymbolicLink()) throw new Error("Access denied: symbolic links are not allowed");
|
|
86
97
|
}
|
|
87
98
|
function isSensitivePath(filePath) {
|
|
88
|
-
|
|
99
|
+
return SENSITIVE_PATTERNS.some((pattern) => pattern.test(filePath));
|
|
89
100
|
}
|
|
90
101
|
function looksLikePosixProtected(raw) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
102
|
+
if (!raw.startsWith("/")) return false;
|
|
103
|
+
const fwd = raw.replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
104
|
+
return POSIX_PROTECTED_PATHS.some((p) => fwd === p || fwd.startsWith(p === "/" ? "/" : `${p}/`));
|
|
94
105
|
}
|
|
95
106
|
function isProtectedPath(filePath) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
107
|
+
const normalized = path.resolve(filePath);
|
|
108
|
+
const realIfExists = (() => {
|
|
109
|
+
try {
|
|
110
|
+
return realpathSync(normalized);
|
|
111
|
+
} catch {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
})();
|
|
115
|
+
const candidates = realIfExists ? [normalized, realIfExists] : [normalized];
|
|
116
|
+
const tmpRaw = os.tmpdir();
|
|
117
|
+
const homeRaw = os.homedir();
|
|
118
|
+
const tmpReal = (() => {
|
|
119
|
+
try {
|
|
120
|
+
return realpathSync(tmpRaw);
|
|
121
|
+
} catch {
|
|
122
|
+
return tmpRaw;
|
|
123
|
+
}
|
|
124
|
+
})();
|
|
125
|
+
const homeReal = (() => {
|
|
126
|
+
try {
|
|
127
|
+
return realpathSync(homeRaw);
|
|
128
|
+
} catch {
|
|
129
|
+
return homeRaw;
|
|
130
|
+
}
|
|
131
|
+
})();
|
|
132
|
+
const sep = path.sep;
|
|
133
|
+
const allowPrefixes = [
|
|
134
|
+
tmpRaw,
|
|
135
|
+
tmpReal,
|
|
136
|
+
homeRaw,
|
|
137
|
+
homeReal
|
|
138
|
+
];
|
|
139
|
+
for (const candidate of candidates) {
|
|
140
|
+
const cmp = normalizeForCompare(candidate);
|
|
141
|
+
if (allowPrefixes.some((prefix) => {
|
|
142
|
+
const pCmp = normalizeForCompare(prefix);
|
|
143
|
+
return cmp === pCmp || cmp.startsWith(pCmp + sep);
|
|
144
|
+
})) return false;
|
|
145
|
+
}
|
|
146
|
+
if (candidates.some((candidate) => {
|
|
147
|
+
const cmp = normalizeForCompare(candidate);
|
|
148
|
+
return protectedPathsForHost().some((protectedPath) => {
|
|
149
|
+
const pCmp = normalizeForCompare(protectedPath);
|
|
150
|
+
return cmp === pCmp || cmp.startsWith(pCmp + sep);
|
|
151
|
+
});
|
|
152
|
+
})) return true;
|
|
153
|
+
return looksLikePosixProtected(filePath);
|
|
142
154
|
}
|
|
143
155
|
async function resolveSafePath(inputPath, options = {}) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
156
|
+
if (!inputPath || inputPath.includes("\0")) throw new Error("Invalid path");
|
|
157
|
+
const normalized = path.resolve(inputPath);
|
|
158
|
+
await assertFinalIsNotSymlink(normalized);
|
|
159
|
+
const realPath = await realpathIfExists(normalized);
|
|
160
|
+
if (realPath) {
|
|
161
|
+
await assertUnderAllowedRoot(realPath);
|
|
162
|
+
return {
|
|
163
|
+
path: normalized,
|
|
164
|
+
realPath
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (options.mustExist) throw new Error("Path not found");
|
|
168
|
+
if (!options.forWrite) {
|
|
169
|
+
await assertUnderAllowedRoot(normalized);
|
|
170
|
+
return {
|
|
171
|
+
path: normalized,
|
|
172
|
+
realPath: normalized
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
await assertUnderAllowedRoot(await nearestExistingParent(normalized));
|
|
176
|
+
return {
|
|
177
|
+
path: normalized,
|
|
178
|
+
realPath: normalized
|
|
179
|
+
};
|
|
164
180
|
}
|
|
165
181
|
async function assertReadableFileSize(filePath) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
throw new Error(
|
|
169
|
-
`File is too large to read safely (${stats.size} bytes, max ${MAX_FILE_READ_BYTES})`
|
|
170
|
-
);
|
|
171
|
-
}
|
|
182
|
+
const stats = await promises.stat(filePath);
|
|
183
|
+
if (stats.isFile() && stats.size > MAX_FILE_READ_BYTES) throw new Error(`File is too large to read safely (${stats.size} bytes, max ${MAX_FILE_READ_BYTES})`);
|
|
172
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* A8 — atomic, symlink-safe file read.
|
|
187
|
+
*
|
|
188
|
+
* Closes the resolve-then-open TOCTOU window in the prior implementation
|
|
189
|
+
* (a symlink swap between `lstat` and `readFile` could redirect the read
|
|
190
|
+
* to /etc/passwd or any other root-owned file).
|
|
191
|
+
*
|
|
192
|
+
* POSIX: `open(2)` with `O_NOFOLLOW` errors with `ELOOP` if the final
|
|
193
|
+
* path component is a symlink, and we read via the resulting fd so the
|
|
194
|
+
* file identity is pinned for the duration of the read.
|
|
195
|
+
*
|
|
196
|
+
* Windows: `O_NOFOLLOW` isn't honoured the same way — we lstat, reject
|
|
197
|
+
* symlinks explicitly, then re-stat by realpath and confirm the same
|
|
198
|
+
* inode before reading.
|
|
199
|
+
*/
|
|
173
200
|
function safeReadFile(filePath) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
if (stat.size > MAX_FILE_READ_BYTES) {
|
|
218
|
-
throw new Error(
|
|
219
|
-
`File is too large to read safely (${stat.size} bytes, max ${MAX_FILE_READ_BYTES})`
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
const buf = Buffer.allocUnsafe(stat.size);
|
|
223
|
-
let read = 0;
|
|
224
|
-
while (read < stat.size) {
|
|
225
|
-
const n = readSync(fd, buf, read, stat.size - read, read);
|
|
226
|
-
if (n <= 0) break;
|
|
227
|
-
read += n;
|
|
228
|
-
}
|
|
229
|
-
return read === stat.size ? buf : buf.subarray(0, read);
|
|
230
|
-
} finally {
|
|
231
|
-
closeSync(fd);
|
|
232
|
-
}
|
|
201
|
+
if (process.platform === "win32") {
|
|
202
|
+
const lstat = lstatSync(filePath);
|
|
203
|
+
if (lstat.isSymbolicLink()) throw new Error("Access denied: symbolic links are not allowed");
|
|
204
|
+
const real = realpathSync.native(filePath);
|
|
205
|
+
const realStat = statSync(real);
|
|
206
|
+
if (realStat.ino !== lstat.ino) throw new Error("Access denied: path swapped under check");
|
|
207
|
+
if (realStat.size > MAX_FILE_READ_BYTES) throw new Error(`File is too large to read safely (${realStat.size} bytes, max ${MAX_FILE_READ_BYTES})`);
|
|
208
|
+
const fd = openSync(real, constants.O_RDONLY);
|
|
209
|
+
try {
|
|
210
|
+
const buf = Buffer.allocUnsafe(realStat.size);
|
|
211
|
+
let read = 0;
|
|
212
|
+
while (read < realStat.size) {
|
|
213
|
+
const n = readSync(fd, buf, read, realStat.size - read, read);
|
|
214
|
+
if (n <= 0) break;
|
|
215
|
+
read += n;
|
|
216
|
+
}
|
|
217
|
+
return read === realStat.size ? buf : buf.subarray(0, read);
|
|
218
|
+
} finally {
|
|
219
|
+
closeSync(fd);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
let fd;
|
|
223
|
+
try {
|
|
224
|
+
fd = openSync(filePath, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
225
|
+
} catch (err) {
|
|
226
|
+
const code = err.code;
|
|
227
|
+
if (code === "ELOOP" || code === "EMLINK") throw new Error("Access denied: symbolic links are not allowed", { cause: err });
|
|
228
|
+
throw err;
|
|
229
|
+
}
|
|
230
|
+
try {
|
|
231
|
+
const stat = fstatSync(fd);
|
|
232
|
+
if (stat.size > MAX_FILE_READ_BYTES) throw new Error(`File is too large to read safely (${stat.size} bytes, max ${MAX_FILE_READ_BYTES})`);
|
|
233
|
+
const buf = Buffer.allocUnsafe(stat.size);
|
|
234
|
+
let read = 0;
|
|
235
|
+
while (read < stat.size) {
|
|
236
|
+
const n = readSync(fd, buf, read, stat.size - read, read);
|
|
237
|
+
if (n <= 0) break;
|
|
238
|
+
read += n;
|
|
239
|
+
}
|
|
240
|
+
return read === stat.size ? buf : buf.subarray(0, read);
|
|
241
|
+
} finally {
|
|
242
|
+
closeSync(fd);
|
|
243
|
+
}
|
|
233
244
|
}
|
|
234
245
|
async function listDirectoryCapped(filePath) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
await closeResult.catch(() => void 0);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
return entries;
|
|
246
|
+
const dir = await promises.opendir(filePath);
|
|
247
|
+
const entries = [];
|
|
248
|
+
try {
|
|
249
|
+
for await (const entry of dir) {
|
|
250
|
+
entries.push(entry);
|
|
251
|
+
if (entries.length > MAX_DIRECTORY_ENTRIES) throw new Error(`Directory has too many entries (>${MAX_DIRECTORY_ENTRIES})`);
|
|
252
|
+
}
|
|
253
|
+
} finally {
|
|
254
|
+
const closeResult = dir.close?.();
|
|
255
|
+
if (closeResult && typeof closeResult.catch === "function") await closeResult.catch(() => void 0);
|
|
256
|
+
}
|
|
257
|
+
return entries;
|
|
251
258
|
}
|
|
252
|
-
|
|
253
259
|
export { MAX_DIRECTORY_ENTRIES, MAX_FILE_READ_BYTES, assertReadableFileSize, isProtectedPath, isSensitivePath, listDirectoryCapped, resolveSafePath, safeReadFile };
|
|
254
|
-
|
|
260
|
+
|
|
255
261
|
//# sourceMappingURL=fs-safety.js.map
|
package/dist/host/os.d.ts
CHANGED
|
@@ -1,68 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* OS adapter contract — the minimum surface a plugin can rely on for
|
|
5
|
-
* platform-specific operations. The agent supplies a richer implementation
|
|
6
|
-
* (vibecontrols-agent/src/core/os-adapter.ts); this SDK type is intentionally
|
|
7
|
-
* narrow so plugins type-check against the publicly committed contract and
|
|
8
|
-
* the agent stays free to add private members.
|
|
9
|
-
*
|
|
10
|
-
* Every method is optional so plugins must defensively use optional chaining
|
|
11
|
-
* or check presence before invoking — same defensive pattern the rest of
|
|
12
|
-
* HostServices follows.
|
|
13
|
-
*/
|
|
14
|
-
type SupportedPlatform = "linux" | "darwin" | "win32";
|
|
15
|
-
/** Human-readable OS label for operator-facing messages. */
|
|
16
|
-
type PlatformLabel = "macOS" | "Windows" | "Linux" | "WSL";
|
|
17
|
-
interface OsAdapter {
|
|
18
|
-
readonly platform?: SupportedPlatform;
|
|
19
|
-
readonly isWSL?: boolean;
|
|
20
|
-
readonly homeDir?: string;
|
|
21
|
-
readonly tmpDir?: string;
|
|
22
|
-
readonly pathSep?: string;
|
|
23
|
-
readonly eol?: string;
|
|
24
|
-
/** Executable suffix ("" on POSIX, ".exe" on Windows). */
|
|
25
|
-
readonly executableSuffix?: string;
|
|
26
|
-
/**
|
|
27
|
-
* Returns the absolute path to a command on PATH, or null when missing.
|
|
28
|
-
* The agent impl resolves against the LIVE `process.env.PATH` (not the
|
|
29
|
-
* startup snapshot Bun.which captures), so a tool installed mid-run is
|
|
30
|
-
* found. Pass `{ refreshPath: true }` to force re-reading the live PATH.
|
|
31
|
-
*/
|
|
32
|
-
which?(cmd: string, opts?: {
|
|
33
|
-
refreshPath?: boolean;
|
|
34
|
-
}): string | null;
|
|
35
|
-
isProcessAlive?(pid: number): boolean;
|
|
36
|
-
killProcessTree?(pid: number, signal: NodeJS.Signals): boolean;
|
|
37
|
-
listChildPids?(parentPid: number): number[];
|
|
38
|
-
/** npm global *bin* dir (`.../bin`) — where global executables land. */
|
|
39
|
-
npmGlobalBin?(): string | null;
|
|
40
|
-
/** npm global *root* dir (output of `npm root -g`) — where global packages install. */
|
|
41
|
-
npmGlobalRoot?(): string | null;
|
|
42
|
-
bunGlobalBin?(): string | null;
|
|
43
|
-
/** Quote a string for inclusion in a shell command on this OS. */
|
|
44
|
-
shellQuote?(value: string): string;
|
|
45
|
-
shellInvocation?(): {
|
|
46
|
-
cmd: string;
|
|
47
|
-
flag: string;
|
|
48
|
-
};
|
|
49
|
-
/** Build a Bun.spawn argv that runs a shell pipeline through the native shell. */
|
|
50
|
-
shellArgv?(script: string): string[];
|
|
51
|
-
processGroupSpawnOpts?(): Record<string, unknown>;
|
|
52
|
-
/** Human-readable OS label ("macOS"/"Windows"/"Linux"/"WSL") for messages. */
|
|
53
|
-
platformLabel?(): PlatformLabel;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Pure helper: human-readable OS label. Use in operator-facing strings instead
|
|
57
|
-
* of inlining `process.platform === "win32" ? "Windows" : ...` ternaries.
|
|
58
|
-
*/
|
|
59
|
-
declare function platformLabel(p?: NodeJS.Platform, isWSL?: boolean): PlatformLabel;
|
|
60
|
-
/**
|
|
61
|
-
* Pure helper: pick the platform-appropriate manual-install instruction from a
|
|
62
|
-
* per-OS recipe map. Replaces the per-plugin `ttydManualInstall()` /
|
|
63
|
-
* `tmuxManualInstall()` platform switches that were copy-pasted across plugins.
|
|
64
|
-
* Falls back to the `linux` recipe when the current platform has no entry.
|
|
65
|
-
*/
|
|
66
|
-
declare function manualInstallHint(recipes: Partial<Record<SupportedPlatform, string>>, p?: NodeJS.Platform): string;
|
|
67
|
-
|
|
68
|
-
export { type OsAdapter, type PlatformLabel, type SupportedPlatform, manualInstallHint, platformLabel };
|
|
1
|
+
import { a as platformLabel, i as manualInstallHint, n as PlatformLabel, r as SupportedPlatform, t as OsAdapter } from "../os-DoFa9kjr.js";
|
|
2
|
+
export { OsAdapter, PlatformLabel, SupportedPlatform, manualInstallHint, platformLabel };
|
package/dist/host/os.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
// src/host/os.ts
|
|
2
|
+
/**
|
|
3
|
+
* Pure helper: human-readable OS label. Use in operator-facing strings instead
|
|
4
|
+
* of inlining `process.platform === "win32" ? "Windows" : ...` ternaries.
|
|
5
|
+
*/
|
|
2
6
|
function platformLabel(p = process.platform, isWSL = false) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
if (p === "darwin") return "macOS";
|
|
8
|
+
if (p === "win32") return "Windows";
|
|
9
|
+
return isWSL ? "WSL" : "Linux";
|
|
6
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Pure helper: pick the platform-appropriate manual-install instruction from a
|
|
13
|
+
* per-OS recipe map. Replaces the per-plugin `ttydManualInstall()` /
|
|
14
|
+
* `tmuxManualInstall()` platform switches that were copy-pasted across plugins.
|
|
15
|
+
* Falls back to the `linux` recipe when the current platform has no entry.
|
|
16
|
+
*/
|
|
7
17
|
function manualInstallHint(recipes, p = process.platform) {
|
|
8
|
-
|
|
9
|
-
return recipes[key] ?? recipes.linux ?? "";
|
|
18
|
+
return recipes[p === "darwin" || p === "win32" ? p : "linux"] ?? recipes.linux ?? "";
|
|
10
19
|
}
|
|
11
|
-
|
|
12
20
|
export { manualInstallHint, platformLabel };
|
|
13
|
-
|
|
21
|
+
|
|
14
22
|
//# sourceMappingURL=os.js.map
|
package/dist/host/paths.d.ts
CHANGED
|
@@ -1,36 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Cross-platform path helpers. Plugins that need an XDG-style directory or
|
|
5
|
-
* a platform-correct executable name should import from here rather than
|
|
6
|
-
* hand-rolling `process.platform === "win32" ? "...exe" : "..."` ternaries
|
|
7
|
-
* or `process.env.HOME ?? "."` fallbacks (the latter is broken on Windows,
|
|
8
|
-
* where USERPROFILE is the canonical variable).
|
|
9
|
-
*
|
|
10
|
-
* The exports are pure functions backed by `node:os` + `node:path`, so they
|
|
11
|
-
* work without any host wiring. The agent supplies HostServices.paths as a
|
|
12
|
-
* field for forward-compat, but plugins can also import the default `paths`
|
|
13
|
-
* const directly when the host hasn't injected one.
|
|
14
|
-
*/
|
|
15
|
-
interface PathHelpers {
|
|
16
|
-
/** OS-correct user home (`HOME` on POSIX, `USERPROFILE` on Windows). */
|
|
17
|
-
homeDir(): string;
|
|
18
|
-
/**
|
|
19
|
-
* OS-correct per-app config directory:
|
|
20
|
-
* linux: `$XDG_CONFIG_HOME/<scope>` or `~/.config/<scope>`
|
|
21
|
-
* darwin: `~/Library/Application Support/<scope>`
|
|
22
|
-
* win32: `%APPDATA%\<scope>`
|
|
23
|
-
*/
|
|
24
|
-
configDir(scope: string): string;
|
|
25
|
-
/** Same shape as configDir but for cache (`~/.cache`, `~/Library/Caches`, `%LOCALAPPDATA%\<scope>\Cache`). */
|
|
26
|
-
cacheDir(scope: string): string;
|
|
27
|
-
/** Same shape as configDir but for state/data (`~/.local/share`, `~/Library/Application Support`, `%LOCALAPPDATA%\<scope>`). */
|
|
28
|
-
dataDir(scope: string): string;
|
|
29
|
-
/** OS-correct temp dir (`/tmp`, `%TEMP%` on Windows). */
|
|
30
|
-
tmpDir(): string;
|
|
31
|
-
/** Returns the executable name with `.exe` appended on Windows, unchanged elsewhere. */
|
|
32
|
-
exeName(base: string): string;
|
|
33
|
-
}
|
|
34
|
-
declare const paths: PathHelpers;
|
|
35
|
-
|
|
36
|
-
export { type PathHelpers, paths };
|
|
1
|
+
import { n as paths, t as PathHelpers } from "../paths-h28H4Xeb.js";
|
|
2
|
+
export { PathHelpers, paths };
|