@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.
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,7 +1,3 @@
1
- import { HostServices, PluginNukeContext, NukeResult } from '../contract/index.js';
2
- import '../host/os.js';
3
- import '../host/paths.js';
4
-
5
1
  /**
6
2
  * @vibecontrols/plugin-sdk/lifecycle
7
3
  *
@@ -11,31 +7,29 @@ import '../host/paths.js';
11
7
  *
12
8
  * Cross-platform: pure JS, no fs / spawn.
13
9
  */
14
-
15
- interface LifecycleSpec {
16
- /** Plugin name — used for telemetry tagging + skip log messages. */
17
- name: string;
18
- /** Optional init handler — called with hostServices on onServerStart. */
19
- onInit?: (hostServices: HostServices) => void | Promise<void>;
20
- /** Optional shutdown handler — called with hostServices on onServerStop. */
21
- onShutdown?: (hostServices: HostServices) => void | Promise<void>;
22
- /**
23
- * Optional nuke handler — called with hostServices + ctx on `vibe nuke`,
24
- * BEFORE the plugin is uninstalled and while the daemon is still up. Use it
25
- * to reap the plugin's own detached processes, binaries, and persisted
26
- * state. Honour `ctx.dryRun`.
27
- */
28
- onNuke?: (hostServices: HostServices, ctx: PluginNukeContext) => void | NukeResult | Promise<void | NukeResult>;
29
- /** Telemetry event name to auto-emit on init (after onInit returns). */
30
- telemetryEventName?: string;
31
- /** process.platform values the plugin does NOT support — early-return on match. */
32
- skipPlatforms?: NodeJS.Platform[];
10
+ import { c as PluginNukeContext, o as NukeResult, r as HostServices } from "../index-D946chPf.js";
11
+ export interface LifecycleSpec {
12
+ /** Plugin name — used for telemetry tagging + skip log messages. */
13
+ name: string;
14
+ /** Optional init handler — called with hostServices on onServerStart. */
15
+ onInit?: (hostServices: HostServices) => void | Promise<void>;
16
+ /** Optional shutdown handler — called with hostServices on onServerStop. */
17
+ onShutdown?: (hostServices: HostServices) => void | Promise<void>;
18
+ /**
19
+ * Optional nuke handler — called with hostServices + ctx on `vibe nuke`,
20
+ * BEFORE the plugin is uninstalled and while the daemon is still up. Use it
21
+ * to reap the plugin's own detached processes, binaries, and persisted
22
+ * state. Honour `ctx.dryRun`.
23
+ */
24
+ onNuke?: (hostServices: HostServices, ctx: PluginNukeContext) => void | NukeResult | Promise<void | NukeResult>;
25
+ /** Telemetry event name to auto-emit on init (after onInit returns). */
26
+ telemetryEventName?: string;
27
+ /** process.platform values the plugin does NOT support — early-return on match. */
28
+ skipPlatforms?: NodeJS.Platform[];
33
29
  }
34
- interface LifecycleHooks {
35
- onServerStart: (app: unknown, hostServices: HostServices) => Promise<void>;
36
- onServerStop: (hostServices: HostServices) => Promise<void>;
37
- onNuke: (hostServices: HostServices, ctx: PluginNukeContext) => Promise<void | NukeResult>;
30
+ export interface LifecycleHooks {
31
+ onServerStart: (app: unknown, hostServices: HostServices) => Promise<void>;
32
+ onServerStop: (hostServices: HostServices) => Promise<void>;
33
+ onNuke: (hostServices: HostServices, ctx: PluginNukeContext) => Promise<void | NukeResult>;
38
34
  }
39
- declare function createLifecycleHooks(spec: LifecycleSpec): LifecycleHooks;
40
-
41
- export { type LifecycleHooks, type LifecycleSpec, createLifecycleHooks };
35
+ export declare function createLifecycleHooks(spec: LifecycleSpec): LifecycleHooks;
@@ -1,35 +1,23 @@
1
1
  // src/lifecycle/index.ts
2
2
  function createLifecycleHooks(spec) {
3
- const { name, onInit, onShutdown, onNuke, telemetryEventName, skipPlatforms } = spec;
4
- return {
5
- onServerStart: async (_app, hostServices) => {
6
- if (skipPlatforms && skipPlatforms.includes(process.platform)) {
7
- process.stderr.write(
8
- `[${name}] skipping init on unsupported platform '${process.platform}'
9
- `
10
- );
11
- return;
12
- }
13
- if (onInit) {
14
- await onInit(hostServices);
15
- }
16
- if (telemetryEventName) {
17
- hostServices.telemetry?.emit(telemetryEventName, { plugin: name });
18
- }
19
- },
20
- onServerStop: async (hostServices) => {
21
- if (onShutdown) {
22
- await onShutdown(hostServices);
23
- }
24
- },
25
- onNuke: async (hostServices, ctx) => {
26
- if (onNuke) {
27
- return onNuke(hostServices, ctx);
28
- }
29
- }
30
- };
3
+ const { name, onInit, onShutdown, onNuke, telemetryEventName, skipPlatforms } = spec;
4
+ return {
5
+ onServerStart: async (_app, hostServices) => {
6
+ if (skipPlatforms && skipPlatforms.includes(process.platform)) {
7
+ process.stderr.write(`[${name}] skipping init on unsupported platform '${process.platform}'\n`);
8
+ return;
9
+ }
10
+ if (onInit) await onInit(hostServices);
11
+ if (telemetryEventName) hostServices.telemetry?.emit(telemetryEventName, { plugin: name });
12
+ },
13
+ onServerStop: async (hostServices) => {
14
+ if (onShutdown) await onShutdown(hostServices);
15
+ },
16
+ onNuke: async (hostServices, ctx) => {
17
+ if (onNuke) return onNuke(hostServices, ctx);
18
+ }
19
+ };
31
20
  }
32
-
33
21
  export { createLifecycleHooks };
34
- //# sourceMappingURL=index.js.map
22
+
35
23
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,3 @@
1
- import { SdkLogger } from '../contract/index.js';
2
- import '../host/os.js';
3
- import '../host/paths.js';
4
-
5
1
  /**
6
2
  * @vibecontrols/plugin-sdk/log
7
3
  *
@@ -9,16 +5,15 @@ import '../host/paths.js';
9
5
  * `log.info("started")` instead of `logger.info("my-plugin", "started")`
10
6
  * at every call-site. No-op when the underlying logger is absent.
11
7
  */
12
-
8
+ import { m as SdkLogger } from "../index-D946chPf.js";
13
9
  type Meta = Record<string, unknown>;
14
- declare class BoundLogger {
15
- private readonly logger;
16
- private readonly source;
17
- constructor(logger: SdkLogger | undefined, source: string);
18
- info(message: string, meta?: Meta): void;
19
- warn(message: string, meta?: Meta): void;
20
- error(message: string, meta?: Meta): void;
21
- debug(message: string, meta?: Meta): void;
10
+ export declare class BoundLogger {
11
+ private readonly logger;
12
+ private readonly source;
13
+ constructor(logger: SdkLogger | undefined, source: string);
14
+ info(message: string, meta?: Meta): void;
15
+ warn(message: string, meta?: Meta): void;
16
+ error(message: string, meta?: Meta): void;
17
+ debug(message: string, meta?: Meta): void;
22
18
  }
23
-
24
- export { BoundLogger };
19
+ export {};
package/dist/log/index.js CHANGED
@@ -1,25 +1,24 @@
1
1
  // src/log/index.ts
2
2
  var BoundLogger = class {
3
- constructor(logger, source) {
4
- this.logger = logger;
5
- this.source = source;
6
- }
7
- logger;
8
- source;
9
- info(message, meta) {
10
- this.logger?.info?.(this.source, message, meta);
11
- }
12
- warn(message, meta) {
13
- this.logger?.warn?.(this.source, message, meta);
14
- }
15
- error(message, meta) {
16
- this.logger?.error?.(this.source, message, meta);
17
- }
18
- debug(message, meta) {
19
- this.logger?.debug?.(this.source, message, meta);
20
- }
3
+ logger;
4
+ source;
5
+ constructor(logger, source) {
6
+ this.logger = logger;
7
+ this.source = source;
8
+ }
9
+ info(message, meta) {
10
+ this.logger?.info?.(this.source, message, meta);
11
+ }
12
+ warn(message, meta) {
13
+ this.logger?.warn?.(this.source, message, meta);
14
+ }
15
+ error(message, meta) {
16
+ this.logger?.error?.(this.source, message, meta);
17
+ }
18
+ debug(message, meta) {
19
+ this.logger?.debug?.(this.source, message, meta);
20
+ }
21
21
  };
22
-
23
22
  export { BoundLogger };
24
- //# sourceMappingURL=index.js.map
23
+
25
24
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,67 @@
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
+ export { platformLabel as a, manualInstallHint as i, PlatformLabel as n, SupportedPlatform as r, OsAdapter as t };
@@ -0,0 +1,35 @@
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
+ export { paths as n, PathHelpers as t };
@@ -1,8 +1,3 @@
1
- import { HostServices, ServiceRegistry, SupportedOS, MetaProviderRef } from '../contract/index.js';
2
- import { ContextProvider } from '../context/index.js';
3
- import '../host/os.js';
4
- import '../host/paths.js';
5
-
6
1
  /**
7
2
  * @vibecontrols/plugin-sdk/providers
8
3
  *
@@ -10,13 +5,14 @@ import '../host/paths.js';
10
5
  * `register` and consumer plugins call `get` / `list`. Every method is a
11
6
  * graceful no-op when the host has no registry.
12
7
  */
13
-
14
- interface CliContribution {
15
- statusSections?: unknown[];
16
- doctorChecks?: unknown[];
8
+ import { _ as SupportedOS, a as MetaProviderRef, h as ServiceRegistry, r as HostServices } from "../index-D946chPf.js";
9
+ import { ContextProvider } from "../context/index.js";
10
+ export interface CliContribution {
11
+ statusSections?: unknown[];
12
+ doctorChecks?: unknown[];
17
13
  }
18
14
  /** Map `process.platform` onto the SDK's `SupportedOS` union (defaults to linux). */
19
- declare function currentSupportedOS(p?: NodeJS.Platform): SupportedOS;
15
+ export declare function currentSupportedOS(p?: NodeJS.Platform): SupportedOS;
20
16
  /**
21
17
  * The single, shared META→provider provisioning sequence. A META plugin calls
22
18
  * this from its `provisionProviders` hook with its own `metaProviders`; the
@@ -32,49 +28,47 @@ declare function currentSupportedOS(p?: NodeJS.Platform): SupportedOS;
32
28
  * Best-effort and isolated per provider — one provider failing never aborts the
33
29
  * others, so a META degrades gracefully rather than blocking boot.
34
30
  */
35
- declare function provisionMetaProviders(host: HostServices, metaProviders: ReadonlyArray<MetaProviderRef> | undefined, platform?: SupportedOS): Promise<void>;
36
- declare class ProviderRegistry {
37
- private readonly hostServices?;
38
- constructor(hostServices?: HostServices | undefined);
39
- /**
40
- * Register a context provider. Convenience wrapper for the standalone
41
- * `registerContextProvider` helper exported from `@vibecontrols/plugin-sdk/context`.
42
- */
43
- registerContextProvider(provider: ContextProvider): void;
44
- /** List every registered context provider. */
45
- listContextProviders(): ContextProvider[];
46
- /** Resolve a context provider by name. */
47
- getContextProvider(name: string): ContextProvider | undefined;
48
- getServiceRegistry(): ServiceRegistry | undefined;
49
- /**
50
- * Register a provider implementation (session / tunnel / ai) on the
51
- * agent's per-type provider registry. Maps onto the agent's
52
- * `registerProvider(type, provider, pluginName)` shape.
53
- */
54
- registerProvider<T>(type: string, name: string, provider: T): void;
55
- /**
56
- * Resolve a provider for a given type. With one argument, returns the
57
- * default-resolved provider (matching the agent's
58
- * `serviceRegistry.getProvider<T>(type)` shape). With two arguments,
59
- * resolves a *specific* provider by `(type, name)` via the agent's
60
- * `getProviderByName` — which is what consumers like session-manager
61
- * actually want when iterating registered providers.
62
- *
63
- * Previously the two-argument form bug-existed: it
64
- * verified the name was present in `listProvidersForType` but then
65
- * returned the type's *default* provider regardless, so every
66
- * per-name lookup yielded the same object. We now call
67
- * `getProviderByName` when the host exposes it, and only fall back
68
- * to the default-resolved getter for hosts that pre-date that
69
- * method.
70
- */
71
- getProvider<T>(type: string, name?: string): T | undefined;
72
- listProviders(type: string): string[];
73
- /**
74
- * Register a CLI contribution bundle (status sections + doctor checks).
75
- * No-op when the host doesn't expose `cliContributors`.
76
- */
77
- withCliContribution(contribution: CliContribution): void;
78
- }
79
-
80
- export { type CliContribution, ProviderRegistry, currentSupportedOS, provisionMetaProviders };
31
+ export declare function provisionMetaProviders(host: HostServices, metaProviders: ReadonlyArray<MetaProviderRef> | undefined, platform?: SupportedOS): Promise<void>;
32
+ export declare class ProviderRegistry {
33
+ private readonly hostServices?;
34
+ constructor(hostServices?: HostServices | undefined);
35
+ /**
36
+ * Register a context provider. Convenience wrapper for the standalone
37
+ * `registerContextProvider` helper exported from `@vibecontrols/plugin-sdk/context`.
38
+ */
39
+ registerContextProvider(provider: ContextProvider): void;
40
+ /** List every registered context provider. */
41
+ listContextProviders(): ContextProvider[];
42
+ /** Resolve a context provider by name. */
43
+ getContextProvider(name: string): ContextProvider | undefined;
44
+ getServiceRegistry(): ServiceRegistry | undefined;
45
+ /**
46
+ * Register a provider implementation (session / tunnel / ai) on the
47
+ * agent's per-type provider registry. Maps onto the agent's
48
+ * `registerProvider(type, provider, pluginName)` shape.
49
+ */
50
+ registerProvider<T>(type: string, name: string, provider: T): void;
51
+ /**
52
+ * Resolve a provider for a given type. With one argument, returns the
53
+ * default-resolved provider (matching the agent's
54
+ * `serviceRegistry.getProvider<T>(type)` shape). With two arguments,
55
+ * resolves a *specific* provider by `(type, name)` via the agent's
56
+ * `getProviderByName` — which is what consumers like session-manager
57
+ * actually want when iterating registered providers.
58
+ *
59
+ * Previously the two-argument form bug-existed: it
60
+ * verified the name was present in `listProvidersForType` but then
61
+ * returned the type's *default* provider regardless, so every
62
+ * per-name lookup yielded the same object. We now call
63
+ * `getProviderByName` when the host exposes it, and only fall back
64
+ * to the default-resolved getter for hosts that pre-date that
65
+ * method.
66
+ */
67
+ getProvider<T>(type: string, name?: string): T | undefined;
68
+ listProviders(type: string): string[];
69
+ /**
70
+ * Register a CLI contribution bundle (status sections + doctor checks).
71
+ * No-op when the host doesn't expose `cliContributors`.
72
+ */
73
+ withCliContribution(contribution: CliContribution): void;
74
+ }