@vibecontrols/plugin-sdk 2026.527.1 → 2026.528.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.
@@ -1,4 +1,6 @@
1
1
  import { HostServices } from '../contract/index.js';
2
+ import '../host/os.js';
3
+ import '../host/paths.js';
2
4
 
3
5
  /**
4
6
  * @vibecontrols/plugin-sdk/audit
@@ -1,4 +1,6 @@
1
1
  import { HostServices } from '../contract/index.js';
2
+ import '../host/os.js';
3
+ import '../host/paths.js';
2
4
 
3
5
  /**
4
6
  * @vibecontrols/plugin-sdk/broadcast
@@ -1,4 +1,6 @@
1
1
  import { HostServices, SdkLogger } from '../contract/index.js';
2
+ import '../host/os.js';
3
+ import '../host/paths.js';
2
4
 
3
5
  /**
4
6
  * @vibecontrols/plugin-sdk/config
@@ -1,4 +1,6 @@
1
1
  import { HostServices } from '../contract/index.js';
2
+ import '../host/os.js';
3
+ import '../host/paths.js';
2
4
 
3
5
  /**
4
6
  * @vibecontrols/plugin-sdk/context
@@ -1,3 +1,6 @@
1
+ import { OsAdapter } from '../host/os.js';
2
+ import { PathHelpers } from '../host/paths.js';
3
+
1
4
  /**
2
5
  * @vibecontrols/plugin-sdk/contract
3
6
  *
@@ -11,6 +14,7 @@
11
14
  * vibecontrols-agent/src/core/profile-context.ts:62-151,
12
15
  * vibecontrols-agent/src/core/plugin-capabilities.ts.
13
16
  */
17
+
14
18
  interface PluginCapabilities {
15
19
  storage?: "none" | "read" | "rw";
16
20
  secrets?: "none" | "read" | "rw";
@@ -119,7 +123,19 @@ interface HostServices {
119
123
  telemetry?: {
120
124
  emit(event: string, payload?: Record<string, unknown>): void;
121
125
  };
122
- os?: unknown;
126
+ /**
127
+ * OS adapter — the agent injects an instance of its own OsAdapter at
128
+ * boot (see vibecontrols-agent/src/core/os-adapter.ts). Plugins should
129
+ * import the `OsAdapter` type from `@vibecontrols/plugin-sdk/host/os`
130
+ * for type-only references and treat every field as optional.
131
+ */
132
+ os?: OsAdapter;
133
+ /**
134
+ * Cross-platform path helpers. Defaults to the pure-functions impl
135
+ * exported from `@vibecontrols/plugin-sdk/host/paths` (`paths`); the
136
+ * agent overrides only if it needs to override scope behaviour.
137
+ */
138
+ paths?: PathHelpers;
123
139
  }
124
140
  interface ProfileContext {
125
141
  name: string;
@@ -0,0 +1,42 @@
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
+ interface OsAdapter {
16
+ readonly platform?: SupportedPlatform;
17
+ readonly isWSL?: boolean;
18
+ readonly homeDir?: string;
19
+ readonly tmpDir?: string;
20
+ readonly pathSep?: string;
21
+ readonly eol?: string;
22
+ /** Executable suffix ("" on POSIX, ".exe" on Windows). */
23
+ readonly executableSuffix?: string;
24
+ /** Returns the absolute path to a command on PATH, or null when missing. */
25
+ which?(cmd: string): string | null;
26
+ isProcessAlive?(pid: number): boolean;
27
+ killProcessTree?(pid: number, signal: NodeJS.Signals): boolean;
28
+ listChildPids?(parentPid: number): number[];
29
+ npmGlobalBin?(): string | null;
30
+ bunGlobalBin?(): string | null;
31
+ /** Quote a string for inclusion in a shell command on this OS. */
32
+ shellQuote?(value: string): string;
33
+ shellInvocation?(): {
34
+ cmd: string;
35
+ flag: string;
36
+ };
37
+ /** Build a Bun.spawn argv that runs a shell pipeline through the native shell. */
38
+ shellArgv?(script: string): string[];
39
+ processGroupSpawnOpts?(): Record<string, unknown>;
40
+ }
41
+
42
+ export type { OsAdapter, SupportedPlatform };
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=os.js.map
3
+ //# sourceMappingURL=os.js.map
@@ -0,0 +1,36 @@
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 };
@@ -0,0 +1,48 @@
1
+ import { homedir, platform, tmpdir } from 'os';
2
+ import { join } from 'path';
3
+
4
+ // 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
+ }
44
+ };
45
+
46
+ export { paths };
47
+ //# sourceMappingURL=paths.js.map
48
+ //# sourceMappingURL=paths.js.map
package/dist/index.d.ts CHANGED
@@ -12,5 +12,7 @@ export { CliContribution, ProviderRegistry } from './providers/index.js';
12
12
  export { CONTEXT_PROVIDER_TYPE, ContextContribution, ContextProvider, ContextRequest, getContextProvider, listContextProviders, registerContextProvider } from './context/index.js';
13
13
  export { AuditLogger } from './audit/index.js';
14
14
  export { BroadcastEmitter } from './broadcast/index.js';
15
+ export { OsAdapter, SupportedPlatform } from './host/os.js';
16
+ export { PathHelpers, paths } from './host/paths.js';
15
17
  import 'commander';
16
18
  import 'elysia';
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { Elysia } from 'elysia';
2
2
  import { createServer } from 'net';
3
+ import { homedir, platform, tmpdir } from 'os';
4
+ import { join } from 'path';
3
5
 
4
6
  // src/contract/index.ts
5
7
  var FULL_TRUST_CAPS = {
@@ -664,7 +666,47 @@ var BroadcastEmitter = class {
664
666
  this.hostServices?.broadcast?.(type, payload);
665
667
  }
666
668
  };
669
+ var HOME = () => homedir();
670
+ var paths = {
671
+ homeDir: HOME,
672
+ configDir(scope) {
673
+ const p = platform();
674
+ if (p === "win32") {
675
+ return join(process.env.APPDATA ?? join(HOME(), "AppData", "Roaming"), scope);
676
+ }
677
+ if (p === "darwin") {
678
+ return join(HOME(), "Library", "Application Support", scope);
679
+ }
680
+ return join(process.env.XDG_CONFIG_HOME ?? join(HOME(), ".config"), scope);
681
+ },
682
+ cacheDir(scope) {
683
+ const p = platform();
684
+ if (p === "win32") {
685
+ return join(process.env.LOCALAPPDATA ?? join(HOME(), "AppData", "Local"), scope, "Cache");
686
+ }
687
+ if (p === "darwin") {
688
+ return join(HOME(), "Library", "Caches", scope);
689
+ }
690
+ return join(process.env.XDG_CACHE_HOME ?? join(HOME(), ".cache"), scope);
691
+ },
692
+ dataDir(scope) {
693
+ const p = platform();
694
+ if (p === "win32") {
695
+ return join(process.env.LOCALAPPDATA ?? join(HOME(), "AppData", "Local"), scope);
696
+ }
697
+ if (p === "darwin") {
698
+ return join(HOME(), "Library", "Application Support", scope);
699
+ }
700
+ return join(process.env.XDG_DATA_HOME ?? join(HOME(), ".local", "share"), scope);
701
+ },
702
+ tmpDir() {
703
+ return tmpdir();
704
+ },
705
+ exeName(base) {
706
+ return platform() === "win32" ? `${base}.exe` : base;
707
+ }
708
+ };
667
709
 
668
- export { AuditLogger, BoundLogger, BroadcastEmitter, CONTEXT_PROVIDER_TYPE, CliCommandBuilder, ConfigManager, FULL_TRUST_CAPS, HttpClient, NamespaceStore, ProviderRegistry, RoutesBuilder, TelemetryEmitter, TypedStore, createLifecycleHooks, findAvailablePort, getContextProvider, gracefulKill, isProcessAlive, listContextProviders, maybePrintJson, pickOutputMode, redact, registerContextProvider, runMultimode, sleep };
710
+ export { AuditLogger, BoundLogger, BroadcastEmitter, CONTEXT_PROVIDER_TYPE, CliCommandBuilder, ConfigManager, FULL_TRUST_CAPS, HttpClient, NamespaceStore, ProviderRegistry, RoutesBuilder, TelemetryEmitter, TypedStore, createLifecycleHooks, findAvailablePort, getContextProvider, gracefulKill, isProcessAlive, listContextProviders, maybePrintJson, paths, pickOutputMode, redact, registerContextProvider, runMultimode, sleep };
669
711
  //# sourceMappingURL=index.js.map
670
712
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,6 @@
1
1
  import { HostServices } from '../contract/index.js';
2
+ import '../host/os.js';
3
+ import '../host/paths.js';
2
4
 
3
5
  /**
4
6
  * @vibecontrols/plugin-sdk/lifecycle
@@ -1,4 +1,6 @@
1
1
  import { SdkLogger } from '../contract/index.js';
2
+ import '../host/os.js';
3
+ import '../host/paths.js';
2
4
 
3
5
  /**
4
6
  * @vibecontrols/plugin-sdk/log
@@ -1,5 +1,7 @@
1
1
  import { HostServices, ServiceRegistry } from '../contract/index.js';
2
2
  import { ContextProvider } from '../context/index.js';
3
+ import '../host/os.js';
4
+ import '../host/paths.js';
3
5
 
4
6
  /**
5
7
  * @vibecontrols/plugin-sdk/providers
@@ -1,5 +1,7 @@
1
1
  import { Elysia } from 'elysia';
2
2
  import { HostServices } from '../contract/index.js';
3
+ import '../host/os.js';
4
+ import '../host/paths.js';
3
5
 
4
6
  /**
5
7
  * @vibecontrols/plugin-sdk/routes
@@ -1,4 +1,6 @@
1
1
  import { StorageProvider, SdkLogger } from '../contract/index.js';
2
+ import '../host/os.js';
3
+ import '../host/paths.js';
2
4
 
3
5
  /**
4
6
  * Typed wrappers over a `StorageProvider`.
@@ -1,4 +1,6 @@
1
1
  import { SdkLogger } from '../contract/index.js';
2
+ import '../host/os.js';
3
+ import '../host/paths.js';
2
4
 
3
5
  /**
4
6
  * @vibecontrols/plugin-sdk/subprocess
@@ -1,4 +1,6 @@
1
1
  import { HostServices } from '../contract/index.js';
2
+ import '../host/os.js';
3
+ import '../host/paths.js';
2
4
 
3
5
  /**
4
6
  * @vibecontrols/plugin-sdk/telemetry
@@ -1,4 +1,6 @@
1
1
  import { HostServices, ProfileContext, VibePluginFactory } from '../contract/index.js';
2
+ import '../host/os.js';
3
+ import '../host/paths.js';
2
4
 
3
5
  /**
4
6
  * Mock factories for unit-testing plugins built on the SDK.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibecontrols/plugin-sdk",
3
- "version": "2026.527.1",
3
+ "version": "2026.528.1",
4
4
  "type": "module",
5
5
  "description": "VibeControls Plugin SDK — shared contract, lifecycle, CLI, telemetry, storage helpers for all vibe-plugin-* packages.",
6
6
  "engines": {
@@ -76,6 +76,14 @@
76
76
  "./testing": {
77
77
  "import": "./dist/testing/index.js",
78
78
  "types": "./dist/testing/index.d.ts"
79
+ },
80
+ "./host/os": {
81
+ "import": "./dist/host/os.js",
82
+ "types": "./dist/host/os.d.ts"
83
+ },
84
+ "./host/paths": {
85
+ "import": "./dist/host/paths.js",
86
+ "types": "./dist/host/paths.d.ts"
79
87
  }
80
88
  },
81
89
  "scripts": {