@vibecontrols/plugin-sdk 2026.1107.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.
Files changed (51) hide show
  1. package/README.md +1 -1
  2. package/dist/audit/index.d.ts +7 -13
  3. package/dist/audit/index.js +13 -14
  4. package/dist/broadcast/index.d.ts +6 -12
  5. package/dist/broadcast/index.js +8 -9
  6. package/dist/cli/index.d.ts +7 -72
  7. package/dist/cli/index.js +1 -104
  8. package/dist/cli-CGyu31Cn.js +104 -0
  9. package/dist/config/index.d.ts +18 -24
  10. package/dist/config/index.js +56 -61
  11. package/dist/context/index.d.ts +26 -32
  12. package/dist/context/index.js +33 -21
  13. package/dist/contract/index.d.ts +2 -413
  14. package/dist/contract/index.js +11 -12
  15. package/dist/host/fs-safety.d.ts +13 -17
  16. package/dist/host/fs-safety.js +223 -217
  17. package/dist/host/os.d.ts +2 -68
  18. package/dist/host/os.js +15 -7
  19. package/dist/host/paths.d.ts +2 -36
  20. package/dist/host/paths.js +44 -44
  21. package/dist/host/request-security.d.ts +6 -7
  22. package/dist/host/request-security.js +26 -14
  23. package/dist/http/index.d.ts +23 -25
  24. package/dist/http/index.js +60 -65
  25. package/dist/index-BM4zNXSR.d.ts +25 -0
  26. package/dist/index-D946chPf.d.ts +410 -0
  27. package/dist/index-Q_hnxaN_.d.ts +60 -0
  28. package/dist/index.d.ts +44 -18
  29. package/dist/index.js +16 -749
  30. package/dist/install/index.d.ts +46 -50
  31. package/dist/install/index.js +269 -189
  32. package/dist/lifecycle/index.d.ts +24 -30
  33. package/dist/lifecycle/index.js +18 -30
  34. package/dist/log/index.d.ts +10 -15
  35. package/dist/log/index.js +19 -20
  36. package/dist/os-DoFa9kjr.d.ts +67 -0
  37. package/dist/paths-h28H4Xeb.d.ts +35 -0
  38. package/dist/providers/index.d.ts +50 -56
  39. package/dist/providers/index.js +101 -126
  40. package/dist/routes/index.d.ts +22 -28
  41. package/dist/routes/index.js +80 -72
  42. package/dist/storage/index.d.ts +2 -38
  43. package/dist/storage/index.js +1 -67
  44. package/dist/storage-DkNBaJHC.js +64 -0
  45. package/dist/subprocess/index.d.ts +5 -11
  46. package/dist/subprocess/index.js +85 -56
  47. package/dist/telemetry/index.d.ts +15 -21
  48. package/dist/telemetry/index.js +35 -36
  49. package/dist/testing/index.d.ts +6 -28
  50. package/dist/testing/index.js +87 -88
  51. package/package.json +10 -10
@@ -1,255 +1,261 @@
1
- import { realpathSync, promises, lstatSync, statSync, openSync, constants, readSync, closeSync, fstatSync } from 'fs';
2
- import os from 'os';
3
- import path from 'path';
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
- const parsed = parseInt(process.env[name] ?? "", 10);
8
- return Number.isInteger(parsed) && parsed > 0 ? parsed : fallback;
9
- }
10
- var MAX_FILE_READ_BYTES = positiveIntFromEnv(
11
- "VIBECONTROLS_MAX_FILE_READ_BYTES",
12
- 10 * 1024 * 1024
13
- );
14
- var MAX_DIRECTORY_ENTRIES = positiveIntFromEnv("VIBECONTROLS_MAX_DIRECTORY_ENTRIES", 2e3);
15
- var SENSITIVE_PATTERNS = [
16
- /(?:^|\/)\.env(?:\..*)?$/,
17
- /\.pem$/,
18
- /\.key$/,
19
- /(?:^|\/)id_rsa(?:$|\.)/,
20
- /(?:^|\/)\.ssh(?:\/|$)/,
21
- /(?:^|\/)\.git\/config$/,
22
- /(?:^|\/)\.npmrc$/
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
- var POSIX_PROTECTED_PATHS = ["/", "/etc", "/usr", "/bin", "/sbin", "/var", "/opt"];
25
- var WIN32_PROTECTED_PATHS = [
26
- "C:\\Windows",
27
- "C:\\Program Files",
28
- "C:\\Program Files (x86)",
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
- return process.platform === "win32" ? WIN32_PROTECTED_PATHS : POSIX_PROTECTED_PATHS;
47
+ return process.platform === "win32" ? WIN32_PROTECTED_PATHS : POSIX_PROTECTED_PATHS;
33
48
  }
34
49
  function normalizeForCompare(p) {
35
- return process.platform === "win32" ? p.toLowerCase() : p;
50
+ return process.platform === "win32" ? p.toLowerCase() : p;
36
51
  }
37
52
  function configuredRoots() {
38
- const raw = process.env.VIBECONTROLS_ALLOWED_ROOTS;
39
- if (raw) {
40
- return raw.split(path.delimiter).map((entry) => entry.trim()).filter(Boolean);
41
- }
42
- return [process.cwd(), os.homedir(), os.tmpdir()].filter(Boolean);
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
- try {
46
- return await promises.realpath(candidate);
47
- } catch {
48
- return null;
49
- }
62
+ try {
63
+ return await promises.realpath(candidate);
64
+ } catch {
65
+ return null;
66
+ }
50
67
  }
51
68
  async function allowedRootRealpaths() {
52
- const roots = [];
53
- for (const root of configuredRoots()) {
54
- const resolved = path.resolve(root);
55
- const real = await realpathIfExists(resolved) ?? resolved;
56
- if (!roots.includes(real)) roots.push(real);
57
- }
58
- return roots;
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
- const relative = path.relative(root, target);
62
- return relative === "" || !!relative && !relative.startsWith("..") && !path.isAbsolute(relative);
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
- const roots = await allowedRootRealpaths();
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
- let current = path.dirname(candidate);
72
- while (current && current !== path.dirname(current)) {
73
- const real = await realpathIfExists(current);
74
- if (real) return real;
75
- current = path.dirname(current);
76
- }
77
- const rootReal = await realpathIfExists(current || path.parse(candidate).root);
78
- if (!rootReal) throw new Error("Path parent does not exist");
79
- return rootReal;
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
- const stat = await promises.lstat(path.resolve(candidate)).catch(() => null);
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
- return SENSITIVE_PATTERNS.some((pattern) => pattern.test(filePath));
99
+ return SENSITIVE_PATTERNS.some((pattern) => pattern.test(filePath));
89
100
  }
90
101
  function looksLikePosixProtected(raw) {
91
- if (!raw.startsWith("/")) return false;
92
- const fwd = raw.replace(/\\/g, "/").replace(/\/+/g, "/");
93
- return POSIX_PROTECTED_PATHS.some((p) => fwd === p || fwd.startsWith(p === "/" ? "/" : `${p}/`));
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
- const normalized = path.resolve(filePath);
97
- const realIfExists = (() => {
98
- try {
99
- return realpathSync(normalized);
100
- } catch {
101
- return null;
102
- }
103
- })();
104
- const candidates = realIfExists ? [normalized, realIfExists] : [normalized];
105
- const tmpRaw = os.tmpdir();
106
- const homeRaw = os.homedir();
107
- const tmpReal = (() => {
108
- try {
109
- return realpathSync(tmpRaw);
110
- } catch {
111
- return tmpRaw;
112
- }
113
- })();
114
- const homeReal = (() => {
115
- try {
116
- return realpathSync(homeRaw);
117
- } catch {
118
- return homeRaw;
119
- }
120
- })();
121
- const sep = path.sep;
122
- const allowPrefixes = [tmpRaw, tmpReal, homeRaw, homeReal];
123
- for (const candidate of candidates) {
124
- const cmp = normalizeForCompare(candidate);
125
- if (allowPrefixes.some((prefix) => {
126
- const pCmp = normalizeForCompare(prefix);
127
- return cmp === pCmp || cmp.startsWith(pCmp + sep);
128
- })) {
129
- return false;
130
- }
131
- }
132
- if (candidates.some((candidate) => {
133
- const cmp = normalizeForCompare(candidate);
134
- return protectedPathsForHost().some((protectedPath) => {
135
- const pCmp = normalizeForCompare(protectedPath);
136
- return cmp === pCmp || cmp.startsWith(pCmp + sep);
137
- });
138
- })) {
139
- return true;
140
- }
141
- return looksLikePosixProtected(filePath);
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
- if (!inputPath || inputPath.includes("\0")) {
145
- throw new Error("Invalid path");
146
- }
147
- const normalized = path.resolve(inputPath);
148
- await assertFinalIsNotSymlink(normalized);
149
- const realPath = await realpathIfExists(normalized);
150
- if (realPath) {
151
- await assertUnderAllowedRoot(realPath);
152
- return { path: normalized, realPath };
153
- }
154
- if (options.mustExist) {
155
- throw new Error("Path not found");
156
- }
157
- if (!options.forWrite) {
158
- await assertUnderAllowedRoot(normalized);
159
- return { path: normalized, realPath: normalized };
160
- }
161
- const parentReal = await nearestExistingParent(normalized);
162
- await assertUnderAllowedRoot(parentReal);
163
- return { path: normalized, realPath: normalized };
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
- const stats = await promises.stat(filePath);
167
- if (stats.isFile() && stats.size > MAX_FILE_READ_BYTES) {
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
- if (process.platform === "win32") {
175
- const lstat = lstatSync(filePath);
176
- if (lstat.isSymbolicLink()) {
177
- throw new Error("Access denied: symbolic links are not allowed");
178
- }
179
- const real = realpathSync.native(filePath);
180
- const realStat = statSync(real);
181
- if (realStat.ino !== lstat.ino) {
182
- throw new Error("Access denied: path swapped under check");
183
- }
184
- if (realStat.size > MAX_FILE_READ_BYTES) {
185
- throw new Error(
186
- `File is too large to read safely (${realStat.size} bytes, max ${MAX_FILE_READ_BYTES})`
187
- );
188
- }
189
- const fd2 = openSync(real, constants.O_RDONLY);
190
- try {
191
- const buf = Buffer.allocUnsafe(realStat.size);
192
- let read = 0;
193
- while (read < realStat.size) {
194
- const n = readSync(fd2, buf, read, realStat.size - read, read);
195
- if (n <= 0) break;
196
- read += n;
197
- }
198
- return read === realStat.size ? buf : buf.subarray(0, read);
199
- } finally {
200
- closeSync(fd2);
201
- }
202
- }
203
- let fd;
204
- try {
205
- fd = openSync(filePath, constants.O_RDONLY | constants.O_NOFOLLOW);
206
- } catch (err) {
207
- const code = err.code;
208
- if (code === "ELOOP" || code === "EMLINK") {
209
- throw new Error("Access denied: symbolic links are not allowed", {
210
- cause: err
211
- });
212
- }
213
- throw err;
214
- }
215
- try {
216
- const stat = fstatSync(fd);
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
- const dir = await promises.opendir(filePath);
236
- const entries = [];
237
- try {
238
- for await (const entry of dir) {
239
- entries.push(entry);
240
- if (entries.length > MAX_DIRECTORY_ENTRIES) {
241
- throw new Error(`Directory has too many entries (>${MAX_DIRECTORY_ENTRIES})`);
242
- }
243
- }
244
- } finally {
245
- const closeResult = dir.close?.();
246
- if (closeResult && typeof closeResult.catch === "function") {
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
- //# sourceMappingURL=fs-safety.js.map
260
+
255
261
  //# sourceMappingURL=fs-safety.js.map
package/dist/host/os.d.ts CHANGED
@@ -1,68 +1,2 @@
1
- /**
2
- * @vibecontrols/plugin-sdk/host/os
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
- if (p === "darwin") return "macOS";
4
- if (p === "win32") return "Windows";
5
- return isWSL ? "WSL" : "Linux";
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
- const key = p === "darwin" || p === "win32" ? p : "linux";
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
- //# sourceMappingURL=os.js.map
21
+
14
22
  //# sourceMappingURL=os.js.map
@@ -1,36 +1,2 @@
1
- /**
2
- * @vibecontrols/plugin-sdk/host/paths
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 };