@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.
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 +8 -8
@@ -1,48 +1,48 @@
1
- import { homedir, platform, tmpdir } from 'os';
2
- import { join } from 'path';
3
-
1
+ import { homedir, platform, tmpdir } from "node:os";
2
+ import { join } from "node:path";
4
3
  // src/host/paths.ts
5
- var HOME = () => homedir();
6
- var paths = {
7
- homeDir: HOME,
8
- configDir(scope) {
9
- const p = platform();
10
- if (p === "win32") {
11
- return join(process.env.APPDATA ?? join(HOME(), "AppData", "Roaming"), scope);
12
- }
13
- if (p === "darwin") {
14
- return join(HOME(), "Library", "Application Support", scope);
15
- }
16
- return join(process.env.XDG_CONFIG_HOME ?? join(HOME(), ".config"), scope);
17
- },
18
- cacheDir(scope) {
19
- const p = platform();
20
- if (p === "win32") {
21
- return join(process.env.LOCALAPPDATA ?? join(HOME(), "AppData", "Local"), scope, "Cache");
22
- }
23
- if (p === "darwin") {
24
- return join(HOME(), "Library", "Caches", scope);
25
- }
26
- return join(process.env.XDG_CACHE_HOME ?? join(HOME(), ".cache"), scope);
27
- },
28
- dataDir(scope) {
29
- const p = platform();
30
- if (p === "win32") {
31
- return join(process.env.LOCALAPPDATA ?? join(HOME(), "AppData", "Local"), scope);
32
- }
33
- if (p === "darwin") {
34
- return join(HOME(), "Library", "Application Support", scope);
35
- }
36
- return join(process.env.XDG_DATA_HOME ?? join(HOME(), ".local", "share"), scope);
37
- },
38
- tmpDir() {
39
- return tmpdir();
40
- },
41
- exeName(base) {
42
- return platform() === "win32" ? `${base}.exe` : base;
43
- }
4
+ /**
5
+ * @vibecontrols/plugin-sdk/host/paths
6
+ *
7
+ * Cross-platform path helpers. Plugins that need an XDG-style directory or
8
+ * a platform-correct executable name should import from here rather than
9
+ * hand-rolling `process.platform === "win32" ? "...exe" : "..."` ternaries
10
+ * or `process.env.HOME ?? "."` fallbacks (the latter is broken on Windows,
11
+ * where USERPROFILE is the canonical variable).
12
+ *
13
+ * The exports are pure functions backed by `node:os` + `node:path`, so they
14
+ * work without any host wiring. The agent supplies HostServices.paths as a
15
+ * field for forward-compat, but plugins can also import the default `paths`
16
+ * const directly when the host hasn't injected one.
17
+ */
18
+ const HOME = () => homedir();
19
+ const paths = {
20
+ homeDir: HOME,
21
+ configDir(scope) {
22
+ const p = platform();
23
+ if (p === "win32") return join(process.env.APPDATA ?? join(HOME(), "AppData", "Roaming"), scope);
24
+ if (p === "darwin") return join(HOME(), "Library", "Application Support", scope);
25
+ return join(process.env.XDG_CONFIG_HOME ?? join(HOME(), ".config"), scope);
26
+ },
27
+ cacheDir(scope) {
28
+ const p = platform();
29
+ if (p === "win32") return join(process.env.LOCALAPPDATA ?? join(HOME(), "AppData", "Local"), scope, "Cache");
30
+ if (p === "darwin") return join(HOME(), "Library", "Caches", scope);
31
+ return join(process.env.XDG_CACHE_HOME ?? join(HOME(), ".cache"), scope);
32
+ },
33
+ dataDir(scope) {
34
+ const p = platform();
35
+ if (p === "win32") return join(process.env.LOCALAPPDATA ?? join(HOME(), "AppData", "Local"), scope);
36
+ if (p === "darwin") return join(HOME(), "Library", "Application Support", scope);
37
+ return join(process.env.XDG_DATA_HOME ?? join(HOME(), ".local", "share"), scope);
38
+ },
39
+ tmpDir() {
40
+ return tmpdir();
41
+ },
42
+ exeName(base) {
43
+ return platform() === "win32" ? `${base}.exe` : base;
44
+ }
44
45
  };
45
-
46
46
  export { paths };
47
- //# sourceMappingURL=paths.js.map
47
+
48
48
  //# sourceMappingURL=paths.js.map
@@ -1,9 +1,8 @@
1
1
  interface RequestIpServer {
2
- requestIP(request: Request): {
3
- address: string;
4
- } | null;
2
+ requestIP(request: Request): {
3
+ address: string;
4
+ } | null;
5
5
  }
6
- declare function isLikelyLocalRequest(request: Request, server?: RequestIpServer | null): boolean;
7
- declare function denyNonLocalMutation(request: Request, envOverride: string, server?: RequestIpServer | null): string | null;
8
-
9
- export { denyNonLocalMutation, isLikelyLocalRequest };
6
+ export declare function isLikelyLocalRequest(request: Request, server?: RequestIpServer | null): boolean;
7
+ export declare function denyNonLocalMutation(request: Request, envOverride: string, server?: RequestIpServer | null): string | null;
8
+ export {};
@@ -1,23 +1,35 @@
1
1
  // src/host/request-security.ts
2
- var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "0.0.0.0", "::1", "[::1]"]);
2
+ /**
3
+ * @vibecontrols/plugin-sdk/host/request-security
4
+ *
5
+ * Local-only request gating for sensitive host mutations (e.g. killing system
6
+ * sessions/terminals). `denyNonLocalMutation` returns an error string when a
7
+ * request did not originate from loopback and the named env override is unset,
8
+ * else `null`. Ported verbatim from the agent's `core/request-security.ts` so
9
+ * meta plugins can gate their own routes without depending on agent internals.
10
+ */
11
+ const LOOPBACK_HOSTS = /* @__PURE__ */ new Set([
12
+ "localhost",
13
+ "127.0.0.1",
14
+ "0.0.0.0",
15
+ "::1",
16
+ "[::1]"
17
+ ]);
3
18
  function normalizedHost(hostname) {
4
- return hostname.toLowerCase().replace(/^\[|\]$/g, "");
19
+ return hostname.toLowerCase().replace(/^\[|\]$/g, "");
5
20
  }
6
21
  function isLikelyLocalRequest(request, server) {
7
- const headers = request.headers;
8
- if (headers.has("cf-connecting-ip") || headers.has("x-forwarded-for") || headers.has("x-real-ip") || headers.has("forwarded")) {
9
- return false;
10
- }
11
- const peerAddress = server?.requestIP(request)?.address;
12
- if (!peerAddress) return false;
13
- return LOOPBACK_HOSTS.has(normalizedHost(peerAddress));
22
+ const headers = request.headers;
23
+ if (headers.has("cf-connecting-ip") || headers.has("x-forwarded-for") || headers.has("x-real-ip") || headers.has("forwarded")) return false;
24
+ const peerAddress = server?.requestIP(request)?.address;
25
+ if (!peerAddress) return false;
26
+ return LOOPBACK_HOSTS.has(normalizedHost(peerAddress));
14
27
  }
15
28
  function denyNonLocalMutation(request, envOverride, server) {
16
- if (isLikelyLocalRequest(request, server)) return null;
17
- if (process.env[envOverride] === "1") return null;
18
- return `This operation is local-only by default. Set ${envOverride}=1 to allow it over a tunnel.`;
29
+ if (isLikelyLocalRequest(request, server)) return null;
30
+ if (process.env[envOverride] === "1") return null;
31
+ return `This operation is local-only by default. Set ${envOverride}=1 to allow it over a tunnel.`;
19
32
  }
20
-
21
33
  export { denyNonLocalMutation, isLikelyLocalRequest };
22
- //# sourceMappingURL=request-security.js.map
34
+
23
35
  //# sourceMappingURL=request-security.js.map
@@ -6,30 +6,28 @@
6
6
  * `fetch` (Bun + Node 24 both ship it). No third-party HTTP deps so this
7
7
  * module stays peerless.
8
8
  */
9
- interface HttpClientOptions {
10
- /** Per-request timeout in ms. Default 10_000. */
11
- timeoutMs?: number;
12
- /** Total attempts (initial + retries). Default 3. */
13
- maxAttempts?: number;
14
- /** Default headers merged into every request. */
15
- defaultHeaders?: Record<string, string>;
16
- /** Override fetch implementation (tests). */
17
- fetchImpl?: typeof fetch;
9
+ export interface HttpClientOptions {
10
+ /** Per-request timeout in ms. Default 10_000. */
11
+ timeoutMs?: number;
12
+ /** Total attempts (initial + retries). Default 3. */
13
+ maxAttempts?: number;
14
+ /** Default headers merged into every request. */
15
+ defaultHeaders?: Record<string, string>;
16
+ /** Override fetch implementation (tests). */
17
+ fetchImpl?: typeof fetch;
18
18
  }
19
- interface RequestOptions {
20
- headers?: Record<string, string>;
21
- signal?: AbortSignal;
19
+ export interface RequestOptions {
20
+ headers?: Record<string, string>;
21
+ signal?: AbortSignal;
22
22
  }
23
- declare class HttpClient {
24
- private readonly baseUrl;
25
- private readonly timeoutMs;
26
- private readonly maxAttempts;
27
- private readonly defaultHeaders;
28
- private readonly fetchImpl;
29
- constructor(baseUrl: string, options?: HttpClientOptions);
30
- get<T>(path: string, options?: RequestOptions): Promise<T>;
31
- post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
32
- private request;
33
- }
34
-
35
- export { HttpClient, type HttpClientOptions, type RequestOptions };
23
+ export declare class HttpClient {
24
+ private readonly baseUrl;
25
+ private readonly timeoutMs;
26
+ private readonly maxAttempts;
27
+ private readonly defaultHeaders;
28
+ private readonly fetchImpl;
29
+ constructor(baseUrl: string, options?: HttpClientOptions);
30
+ get<T>(path: string, options?: RequestOptions): Promise<T>;
31
+ post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
32
+ private request;
33
+ }
@@ -1,70 +1,65 @@
1
1
  // src/http/index.ts
2
2
  var HttpClient = class {
3
- constructor(baseUrl, options = {}) {
4
- this.baseUrl = baseUrl;
5
- this.timeoutMs = options.timeoutMs ?? 1e4;
6
- this.maxAttempts = options.maxAttempts ?? 3;
7
- this.defaultHeaders = options.defaultHeaders ?? {};
8
- this.fetchImpl = options.fetchImpl ?? fetch;
9
- }
10
- baseUrl;
11
- timeoutMs;
12
- maxAttempts;
13
- defaultHeaders;
14
- fetchImpl;
15
- async get(path, options) {
16
- return this.request("GET", path, void 0, options);
17
- }
18
- async post(path, body, options) {
19
- return this.request("POST", path, body, options);
20
- }
21
- async request(method, path, body, options) {
22
- const url = `${this.baseUrl.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
23
- const headers = {
24
- ...this.defaultHeaders,
25
- ...options?.headers ?? {}
26
- };
27
- if (body !== void 0 && headers["content-type"] === void 0) {
28
- headers["content-type"] = "application/json";
29
- }
30
- let lastError;
31
- for (let attempt = 1; attempt <= this.maxAttempts; attempt++) {
32
- const controller = new AbortController();
33
- const timer = setTimeout(() => controller.abort(), this.timeoutMs);
34
- const callerSignal = options?.signal;
35
- const onCallerAbort = () => controller.abort();
36
- callerSignal?.addEventListener("abort", onCallerAbort, { once: true });
37
- try {
38
- const res = await this.fetchImpl(url, {
39
- method,
40
- headers,
41
- body: body === void 0 ? void 0 : JSON.stringify(body),
42
- signal: controller.signal
43
- });
44
- if (!res.ok) {
45
- throw new Error(`HTTP ${res.status} ${res.statusText} for ${method} ${url}`);
46
- }
47
- const text = await res.text();
48
- if (!text) return void 0;
49
- try {
50
- return JSON.parse(text);
51
- } catch {
52
- return text;
53
- }
54
- } catch (err) {
55
- lastError = err;
56
- if (attempt >= this.maxAttempts) break;
57
- const backoff = 100 * 2 ** (attempt - 1);
58
- await new Promise((r) => setTimeout(r, backoff));
59
- } finally {
60
- clearTimeout(timer);
61
- callerSignal?.removeEventListener("abort", onCallerAbort);
62
- }
63
- }
64
- throw lastError instanceof Error ? lastError : new Error(`HttpClient: request failed for ${method} ${url}`);
65
- }
3
+ baseUrl;
4
+ timeoutMs;
5
+ maxAttempts;
6
+ defaultHeaders;
7
+ fetchImpl;
8
+ constructor(baseUrl, options = {}) {
9
+ this.baseUrl = baseUrl;
10
+ this.timeoutMs = options.timeoutMs ?? 1e4;
11
+ this.maxAttempts = options.maxAttempts ?? 3;
12
+ this.defaultHeaders = options.defaultHeaders ?? {};
13
+ this.fetchImpl = options.fetchImpl ?? fetch;
14
+ }
15
+ async get(path, options) {
16
+ return this.request("GET", path, void 0, options);
17
+ }
18
+ async post(path, body, options) {
19
+ return this.request("POST", path, body, options);
20
+ }
21
+ async request(method, path, body, options) {
22
+ const url = `${this.baseUrl.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
23
+ const headers = {
24
+ ...this.defaultHeaders,
25
+ ...options?.headers ?? {}
26
+ };
27
+ if (body !== void 0 && headers["content-type"] === void 0) headers["content-type"] = "application/json";
28
+ let lastError;
29
+ for (let attempt = 1; attempt <= this.maxAttempts; attempt++) {
30
+ const controller = new AbortController();
31
+ const timer = setTimeout(() => controller.abort(), this.timeoutMs);
32
+ const callerSignal = options?.signal;
33
+ const onCallerAbort = () => controller.abort();
34
+ callerSignal?.addEventListener("abort", onCallerAbort, { once: true });
35
+ try {
36
+ const res = await this.fetchImpl(url, {
37
+ method,
38
+ headers,
39
+ body: body === void 0 ? void 0 : JSON.stringify(body),
40
+ signal: controller.signal
41
+ });
42
+ if (!res.ok) throw new Error(`HTTP ${res.status} ${res.statusText} for ${method} ${url}`);
43
+ const text = await res.text();
44
+ if (!text) return void 0;
45
+ try {
46
+ return JSON.parse(text);
47
+ } catch {
48
+ return text;
49
+ }
50
+ } catch (err) {
51
+ lastError = err;
52
+ if (attempt >= this.maxAttempts) break;
53
+ const backoff = 100 * 2 ** (attempt - 1);
54
+ await new Promise((r) => setTimeout(r, backoff));
55
+ } finally {
56
+ clearTimeout(timer);
57
+ callerSignal?.removeEventListener("abort", onCallerAbort);
58
+ }
59
+ }
60
+ throw lastError instanceof Error ? lastError : /* @__PURE__ */ new Error(`HttpClient: request failed for ${method} ${url}`);
61
+ }
66
62
  };
67
-
68
63
  export { HttpClient };
69
- //# sourceMappingURL=index.js.map
64
+
70
65
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,25 @@
1
+ import { g as StorageProvider, m as SdkLogger } from "./index-D946chPf.js";
2
+ declare class TypedStore<T> {
3
+ private readonly storage;
4
+ private readonly namespace;
5
+ private readonly key;
6
+ private readonly logger?;
7
+ private readonly pluginName;
8
+ constructor(storage: StorageProvider, namespace: string, key: string, logger?: SdkLogger | undefined, pluginName?: string);
9
+ get(): Promise<T | null>;
10
+ set(value: T): Promise<void>;
11
+ delete(): Promise<boolean>;
12
+ }
13
+ declare class NamespaceStore {
14
+ private readonly storage;
15
+ private readonly namespace;
16
+ private readonly logger?;
17
+ private readonly pluginName;
18
+ constructor(storage: StorageProvider, namespace: string, logger?: SdkLogger | undefined, pluginName?: string);
19
+ /** Get a typed handle for `(this.namespace, key)`. */
20
+ typed<T>(key: string): TypedStore<T>;
21
+ get<T = unknown>(key: string): Promise<T | null>;
22
+ set<T = unknown>(key: string, value: T): Promise<void>;
23
+ delete(key: string): Promise<boolean>;
24
+ }
25
+ export { TypedStore as n, NamespaceStore as t };