@vibecontrols/plugin-sdk 2026.1108.1 → 2026.1123.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/paths.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { homedir, platform, tmpdir } from
|
|
2
|
-
import { join } from
|
|
3
|
-
|
|
1
|
+
import { homedir, platform, tmpdir } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
4
3
|
// src/host/paths.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
47
|
+
|
|
48
48
|
//# sourceMappingURL=paths.js.map
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
interface RequestIpServer {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
|
|
19
|
+
return hostname.toLowerCase().replace(/^\[|\]$/g, "");
|
|
5
20
|
}
|
|
6
21
|
function isLikelyLocalRequest(request, server) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
34
|
+
|
|
23
35
|
//# sourceMappingURL=request-security.js.map
|
package/dist/http/index.d.ts
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
21
|
-
|
|
19
|
+
export interface RequestOptions {
|
|
20
|
+
headers?: Record<string, string>;
|
|
21
|
+
signal?: AbortSignal;
|
|
22
22
|
}
|
|
23
|
-
declare class HttpClient {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
}
|
package/dist/http/index.js
CHANGED
|
@@ -1,70 +1,65 @@
|
|
|
1
1
|
// src/http/index.ts
|
|
2
2
|
var HttpClient = class {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
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 };
|