@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
package/README.md CHANGED
@@ -209,7 +209,7 @@ Key commands:
209
209
  | `bun run lint` | ESLint (`@burdenoff/toolchain/eslint/node` profile) |
210
210
  | `bun fmt` / `bun run format:check` | Format with `bun fmt` (reads `prettier.config.js`) / check only |
211
211
  | `bun test` | Unit tests (`tests/**/*.test.ts`) |
212
- | `bun run build` | Build `dist/` with tsup (ESM + `.d.ts`) |
212
+ | `bun run build` | Build `dist/` with tsdown (ESM + `.d.ts`) |
213
213
  | `bun run sanity` | `boff sanity`: format check, lint, type check, build, tests with the coverage gate, knip and `pack:check`; cached per step, so an unchanged tree re-runs in under a second (`bun run sanity:force` ignores the cache) |
214
214
 
215
215
  1. `bun install`
@@ -1,19 +1,13 @@
1
- import { HostServices } from '../contract/index.js';
2
- import '../host/os.js';
3
- import '../host/paths.js';
4
-
5
1
  /**
6
2
  * @vibecontrols/plugin-sdk/audit
7
3
  *
8
4
  * `AuditLogger` binds `source` to the plugin name and forwards events to
9
5
  * `hostServices.audit?.emit`. No-op when the host doesn't expose audit.
10
6
  */
11
-
12
- declare class AuditLogger {
13
- private readonly source;
14
- private readonly hostServices?;
15
- constructor(source: string, hostServices?: HostServices | undefined);
16
- emit(event: string, payload?: Record<string, unknown>): void;
17
- }
18
-
19
- export { AuditLogger };
7
+ import { r as HostServices } from "../index-D946chPf.js";
8
+ export declare class AuditLogger {
9
+ private readonly source;
10
+ private readonly hostServices?;
11
+ constructor(source: string, hostServices?: HostServices | undefined);
12
+ emit(event: string, payload?: Record<string, unknown>): void;
13
+ }
@@ -1,19 +1,18 @@
1
1
  // src/audit/index.ts
2
2
  var AuditLogger = class {
3
- constructor(source, hostServices) {
4
- this.source = source;
5
- this.hostServices = hostServices;
6
- }
7
- source;
8
- hostServices;
9
- emit(event, payload) {
10
- this.hostServices?.audit?.emit(event, {
11
- source: this.source,
12
- ...payload ?? {}
13
- });
14
- }
3
+ source;
4
+ hostServices;
5
+ constructor(source, hostServices) {
6
+ this.source = source;
7
+ this.hostServices = hostServices;
8
+ }
9
+ emit(event, payload) {
10
+ this.hostServices?.audit?.emit(event, {
11
+ source: this.source,
12
+ ...payload ?? {}
13
+ });
14
+ }
15
15
  };
16
-
17
16
  export { AuditLogger };
18
- //# sourceMappingURL=index.js.map
17
+
19
18
  //# sourceMappingURL=index.js.map
@@ -1,17 +1,11 @@
1
- import { HostServices } from '../contract/index.js';
2
- import '../host/os.js';
3
- import '../host/paths.js';
4
-
5
1
  /**
6
2
  * @vibecontrols/plugin-sdk/broadcast
7
3
  *
8
4
  * Type-safe wrapper over `hostServices.broadcast` — no-op when absent.
9
5
  */
10
-
11
- declare class BroadcastEmitter {
12
- private readonly hostServices?;
13
- constructor(hostServices?: HostServices | undefined);
14
- broadcast<T>(type: string, payload: T): void;
15
- }
16
-
17
- export { BroadcastEmitter };
6
+ import { r as HostServices } from "../index-D946chPf.js";
7
+ export declare class BroadcastEmitter {
8
+ private readonly hostServices?;
9
+ constructor(hostServices?: HostServices | undefined);
10
+ broadcast<T>(type: string, payload: T): void;
11
+ }
@@ -1,14 +1,13 @@
1
1
  // src/broadcast/index.ts
2
2
  var BroadcastEmitter = class {
3
- constructor(hostServices) {
4
- this.hostServices = hostServices;
5
- }
6
- hostServices;
7
- broadcast(type, payload) {
8
- this.hostServices?.broadcast?.(type, payload);
9
- }
3
+ hostServices;
4
+ constructor(hostServices) {
5
+ this.hostServices = hostServices;
6
+ }
7
+ broadcast(type, payload) {
8
+ this.hostServices?.broadcast?.(type, payload);
9
+ }
10
10
  };
11
-
12
11
  export { BroadcastEmitter };
13
- //# sourceMappingURL=index.js.map
12
+
14
13
  //# sourceMappingURL=index.js.map
@@ -1,75 +1,10 @@
1
- import { Command } from 'commander';
2
-
3
1
  /**
4
- * Multi-mode output dispatcher.
2
+ * @vibecontrols/plugin-sdk/cli — CLI scaffolding helpers.
5
3
  *
6
- * Lifted from vibecontrols-agent/src/cli/utils/multimode.ts but trimmed:
7
- * the SDK doesn't ship the agent's `isInteractive()` helper since plugins
8
- * can't depend on opentui from the SDK. Instead we use a stdout-isTTY +
9
- * env CI/NO_COLOR check inline.
4
+ * Re-exports `runMultimode`, `pickOutputMode`, `redact`, and the
5
+ * `CliCommandBuilder`. commander is a peerDep — only `command-builder` /
6
+ * the `Command` type pull it; downstream plugins that don't ship a CLI
7
+ * can still import multimode + redact without commander installed.
10
8
  */
11
- type OutputMode = "auto" | "interactive" | "plain" | "json";
12
- interface OutputFlags {
13
- json?: boolean;
14
- plain?: boolean;
15
- interactive?: boolean;
16
- }
17
- interface MultimodeOptions<T> {
18
- fetchData: () => Promise<T> | T;
19
- plain: (data: T) => void | Promise<void>;
20
- interactive?: (data: T) => Promise<void>;
21
- json?: (data: T) => unknown;
22
- mode?: OutputMode;
23
- }
24
- /** Resolve user-supplied CLI flags into an OutputMode. */
25
- declare function pickOutputMode(flags: OutputFlags): OutputMode;
26
- declare function runMultimode<T>(opts: MultimodeOptions<T>): Promise<void>;
27
- /**
28
- * Convenience: emit `data` as JSON if `--json` is set; return `true` when
29
- * something was printed. Mutating commands (start/stop/install/...) reach
30
- * for this when they want a scriptable JSON opt-in.
31
- */
32
- declare function maybePrintJson(flags: OutputFlags, data: unknown): boolean;
33
-
34
- /**
35
- * Recursive sensitive-field stripper. Replaces values for keys matching the
36
- * sensitive regex with the literal string "[redacted]". Walks arrays, plain
37
- * objects, and leaves primitives / null / undefined untouched.
38
- */
39
- declare function redact<T>(value: T): T;
40
-
41
- /**
42
- * CliCommandBuilder — fluent helper that wires the standard `--json` /
43
- * `--plain` flags onto a Commander command and routes the action through
44
- * `runMultimode`. Removes the ~30-line boilerplate every plugin author
45
- * pastes for status/list commands.
46
- *
47
- * commander is a peerDep — this module imports `Command` as a *type* from
48
- * "commander" so the SDK builds without commander present, and runs only
49
- * when the consumer installed it.
50
- */
51
-
52
- interface StatusCommandSpec<T> {
53
- description: string;
54
- fetchData: () => Promise<T> | T;
55
- /** Plain renderer override. Defaults to `JSON.stringify` if absent. */
56
- format?: (data: T) => void | Promise<void>;
57
- /**
58
- * Apply redaction before any renderer. Strips sensitive keys recursively
59
- * (see ./redaction.ts).
60
- */
61
- redact?: boolean;
62
- }
63
- declare class CliCommandBuilder {
64
- private readonly program;
65
- constructor(program: Command);
66
- /**
67
- * Register a `<name>` sub-command that fetches once and renders via
68
- * `--json` / `--plain` / interactive (when stdout is a TTY).
69
- */
70
- addStatusCommand<T>(name: string, spec: StatusCommandSpec<T>): this;
71
- /** Escape hatch: hand back the underlying commander Command. */
72
- command(): Command;
73
- }
74
-
75
- export { CliCommandBuilder, type MultimodeOptions, type OutputFlags, type OutputMode, type StatusCommandSpec, maybePrintJson, pickOutputMode, redact, runMultimode };
9
+ import { a as OutputFlags, c as pickOutputMode, i as MultimodeOptions, l as runMultimode, n as StatusCommandSpec, o as OutputMode, r as redact, s as maybePrintJson, t as CliCommandBuilder } from "../index-Q_hnxaN_.js";
10
+ export { CliCommandBuilder, type MultimodeOptions, type OutputFlags, type OutputMode, type StatusCommandSpec, maybePrintJson, pickOutputMode, redact, runMultimode };
package/dist/cli/index.js CHANGED
@@ -1,104 +1 @@
1
- // src/cli/multimode.ts
2
- function pickOutputMode(flags) {
3
- if (flags.json) return "json";
4
- if (flags.plain) return "plain";
5
- if (flags.interactive) return "interactive";
6
- return "auto";
7
- }
8
- function isCi() {
9
- return !!process.env.CI || !!process.env.NO_COLOR || process.env.TERM === "dumb";
10
- }
11
- function stdoutIsTty() {
12
- return Boolean(process.stdout.isTTY);
13
- }
14
- async function runMultimode(opts) {
15
- const data = await opts.fetchData();
16
- const mode = opts.mode ?? "auto";
17
- if (mode === "json") {
18
- const shaped = opts.json ? opts.json(data) : data;
19
- process.stdout.write(`${JSON.stringify(shaped, null, 2)}
20
- `);
21
- return;
22
- }
23
- if (mode === "plain") {
24
- await opts.plain(data);
25
- return;
26
- }
27
- const wantInteractive = (mode === "interactive" || stdoutIsTty() && !isCi()) && !!opts.interactive;
28
- if (wantInteractive && opts.interactive) {
29
- try {
30
- await opts.interactive(data);
31
- return;
32
- } catch {
33
- }
34
- }
35
- await opts.plain(data);
36
- }
37
- function maybePrintJson(flags, data) {
38
- if (!flags.json) return false;
39
- process.stdout.write(`${JSON.stringify(data, null, 2)}
40
- `);
41
- return true;
42
- }
43
-
44
- // src/cli/redaction.ts
45
- var SENSITIVE_KEY_RE = /(token|secret|password|apikey|api_key|key|auth|credential|email)/i;
46
- function redact(value) {
47
- return redactInner(value);
48
- }
49
- function redactInner(value) {
50
- if (value === null || value === void 0) return value;
51
- if (Array.isArray(value)) return value.map(redactInner);
52
- if (typeof value === "object") {
53
- const out = {};
54
- for (const [k, v] of Object.entries(value)) {
55
- if (SENSITIVE_KEY_RE.test(k)) {
56
- out[k] = "[redacted]";
57
- continue;
58
- }
59
- out[k] = redactInner(v);
60
- }
61
- return out;
62
- }
63
- return value;
64
- }
65
-
66
- // src/cli/command-builder.ts
67
- var CliCommandBuilder = class {
68
- constructor(program) {
69
- this.program = program;
70
- }
71
- program;
72
- /**
73
- * Register a `<name>` sub-command that fetches once and renders via
74
- * `--json` / `--plain` / interactive (when stdout is a TTY).
75
- */
76
- addStatusCommand(name, spec) {
77
- this.program.command(name).description(spec.description).option("--json", "emit JSON for scripting").option("--plain", "force plain text (no opentui)").action(async (opts) => {
78
- const mode = pickOutputMode(opts);
79
- await runMultimode({
80
- mode,
81
- fetchData: spec.fetchData,
82
- plain: async (data) => {
83
- const view = spec.redact ? redact(data) : data;
84
- if (spec.format) {
85
- await spec.format(view);
86
- return;
87
- }
88
- process.stdout.write(`${JSON.stringify(view, null, 2)}
89
- `);
90
- },
91
- json: (data) => spec.redact ? redact(data) : data
92
- });
93
- });
94
- return this;
95
- }
96
- /** Escape hatch: hand back the underlying commander Command. */
97
- command() {
98
- return this.program;
99
- }
100
- };
101
-
102
- export { CliCommandBuilder, maybePrintJson, pickOutputMode, redact, runMultimode };
103
- //# sourceMappingURL=index.js.map
104
- //# sourceMappingURL=index.js.map
1
+ export { t as CliCommandBuilder, r as maybePrintJson, i as pickOutputMode, n as redact, a as runMultimode } from "../cli-CGyu31Cn.js";
@@ -0,0 +1,104 @@
1
+ // src/cli/multimode.ts
2
+ /** Resolve user-supplied CLI flags into an OutputMode. */
3
+ function pickOutputMode(flags) {
4
+ if (flags.json) return "json";
5
+ if (flags.plain) return "plain";
6
+ if (flags.interactive) return "interactive";
7
+ return "auto";
8
+ }
9
+ function isCi() {
10
+ return !!process.env.CI || !!process.env.NO_COLOR || process.env.TERM === "dumb";
11
+ }
12
+ function stdoutIsTty() {
13
+ return Boolean(process.stdout.isTTY);
14
+ }
15
+ async function runMultimode(opts) {
16
+ const data = await opts.fetchData();
17
+ const mode = opts.mode ?? "auto";
18
+ if (mode === "json") {
19
+ const shaped = opts.json ? opts.json(data) : data;
20
+ process.stdout.write(`${JSON.stringify(shaped, null, 2)}\n`);
21
+ return;
22
+ }
23
+ if (mode === "plain") {
24
+ await opts.plain(data);
25
+ return;
26
+ }
27
+ if ((mode === "interactive" || stdoutIsTty() && !isCi()) && !!opts.interactive && opts.interactive) try {
28
+ await opts.interactive(data);
29
+ return;
30
+ } catch {}
31
+ await opts.plain(data);
32
+ }
33
+ /**
34
+ * Convenience: emit `data` as JSON if `--json` is set; return `true` when
35
+ * something was printed. Mutating commands (start/stop/install/...) reach
36
+ * for this when they want a scriptable JSON opt-in.
37
+ */
38
+ function maybePrintJson(flags, data) {
39
+ if (!flags.json) return false;
40
+ process.stdout.write(`${JSON.stringify(data, null, 2)}\n`);
41
+ return true;
42
+ }
43
+ // src/cli/redaction.ts
44
+ /**
45
+ * Recursive sensitive-field stripper. Replaces values for keys matching the
46
+ * sensitive regex with the literal string "[redacted]". Walks arrays, plain
47
+ * objects, and leaves primitives / null / undefined untouched.
48
+ */
49
+ const SENSITIVE_KEY_RE = /(token|secret|password|apikey|api_key|key|auth|credential|email)/i;
50
+ function redact(value) {
51
+ return redactInner(value);
52
+ }
53
+ function redactInner(value) {
54
+ if (value === null || value === void 0) return value;
55
+ if (Array.isArray(value)) return value.map(redactInner);
56
+ if (typeof value === "object") {
57
+ const out = {};
58
+ for (const [k, v] of Object.entries(value)) {
59
+ if (SENSITIVE_KEY_RE.test(k)) {
60
+ out[k] = "[redacted]";
61
+ continue;
62
+ }
63
+ out[k] = redactInner(v);
64
+ }
65
+ return out;
66
+ }
67
+ return value;
68
+ }
69
+ // src/cli/command-builder.ts
70
+ var CliCommandBuilder = class {
71
+ program;
72
+ constructor(program) {
73
+ this.program = program;
74
+ }
75
+ /**
76
+ * Register a `<name>` sub-command that fetches once and renders via
77
+ * `--json` / `--plain` / interactive (when stdout is a TTY).
78
+ */
79
+ addStatusCommand(name, spec) {
80
+ this.program.command(name).description(spec.description).option("--json", "emit JSON for scripting").option("--plain", "force plain text (no opentui)").action(async (opts) => {
81
+ await runMultimode({
82
+ mode: pickOutputMode(opts),
83
+ fetchData: spec.fetchData,
84
+ plain: async (data) => {
85
+ const view = spec.redact ? redact(data) : data;
86
+ if (spec.format) {
87
+ await spec.format(view);
88
+ return;
89
+ }
90
+ process.stdout.write(`${JSON.stringify(view, null, 2)}\n`);
91
+ },
92
+ json: (data) => spec.redact ? redact(data) : data
93
+ });
94
+ });
95
+ return this;
96
+ }
97
+ /** Escape hatch: hand back the underlying commander Command. */
98
+ command() {
99
+ return this.program;
100
+ }
101
+ };
102
+ export { runMultimode as a, pickOutputMode as i, redact as n, maybePrintJson as r, CliCommandBuilder as t };
103
+
104
+ //# sourceMappingURL=cli-CGyu31Cn.js.map
@@ -1,7 +1,3 @@
1
- import { HostServices, SdkLogger } from '../contract/index.js';
2
- import '../host/os.js';
3
- import '../host/paths.js';
4
-
5
1
  /**
6
2
  * @vibecontrols/plugin-sdk/config
7
3
  *
@@ -14,23 +10,21 @@ import '../host/paths.js';
14
10
  * with sane fallbacks; invalid values warn through the logger and return
15
11
  * the default.
16
12
  */
17
-
18
- declare class ConfigManager {
19
- private readonly pluginName;
20
- private readonly hostServices?;
21
- private readonly logger?;
22
- private readonly envPrefix;
23
- constructor(pluginName: string, hostServices?: HostServices | undefined, logger?: SdkLogger | undefined);
24
- private envName;
25
- /**
26
- * Resolve a string config value. Returns `defaultValue` (or undefined)
27
- * when neither env nor host config has it.
28
- */
29
- get(key: string, defaultValue?: string): Promise<string | undefined>;
30
- /** Like `get`, but throw if the key resolves to undefined / empty. */
31
- getRequired(key: string): Promise<string>;
32
- getInt(key: string, defaultValue?: number): Promise<number | undefined>;
33
- getBoolean(key: string, defaultValue?: boolean): Promise<boolean | undefined>;
34
- }
35
-
36
- export { ConfigManager };
13
+ import { m as SdkLogger, r as HostServices } from "../index-D946chPf.js";
14
+ export declare class ConfigManager {
15
+ private readonly pluginName;
16
+ private readonly hostServices?;
17
+ private readonly logger?;
18
+ private readonly envPrefix;
19
+ constructor(pluginName: string, hostServices?: HostServices | undefined, logger?: SdkLogger | undefined);
20
+ private envName;
21
+ /**
22
+ * Resolve a string config value. Returns `defaultValue` (or undefined)
23
+ * when neither env nor host config has it.
24
+ */
25
+ get(key: string, defaultValue?: string): Promise<string | undefined>;
26
+ /** Like `get`, but throw if the key resolves to undefined / empty. */
27
+ getRequired(key: string): Promise<string>;
28
+ getInt(key: string, defaultValue?: number): Promise<number | undefined>;
29
+ getBoolean(key: string, defaultValue?: boolean): Promise<boolean | undefined>;
30
+ }
@@ -1,66 +1,61 @@
1
1
  // src/config/index.ts
2
2
  var ConfigManager = class {
3
- constructor(pluginName, hostServices, logger) {
4
- this.pluginName = pluginName;
5
- this.hostServices = hostServices;
6
- this.logger = logger;
7
- this.envPrefix = `VIBE_${pluginName.toUpperCase().replace(/-/g, "_")}_`;
8
- }
9
- pluginName;
10
- hostServices;
11
- logger;
12
- envPrefix;
13
- envName(key) {
14
- return `${this.envPrefix}${key.toUpperCase().replace(/-/g, "_")}`;
15
- }
16
- /**
17
- * Resolve a string config value. Returns `defaultValue` (or undefined)
18
- * when neither env nor host config has it.
19
- */
20
- async get(key, defaultValue) {
21
- const fromEnv = process.env[this.envName(key)];
22
- if (fromEnv !== void 0 && fromEnv !== "") return fromEnv;
23
- const fromHost = await this.hostServices?.getConfig?.(`${this.pluginName}.${key}`);
24
- if (fromHost !== void 0 && fromHost !== "") return fromHost;
25
- return defaultValue;
26
- }
27
- /** Like `get`, but throw if the key resolves to undefined / empty. */
28
- async getRequired(key) {
29
- const v = await this.get(key);
30
- if (v === void 0 || v === "") {
31
- throw new Error(
32
- `[${this.pluginName}] required config '${key}' is missing (env ${this.envName(key)} or host config '${this.pluginName}.${key}')`
33
- );
34
- }
35
- return v;
36
- }
37
- async getInt(key, defaultValue) {
38
- const raw = await this.get(key);
39
- if (raw === void 0) return defaultValue;
40
- const parsed = Number.parseInt(raw, 10);
41
- if (Number.isNaN(parsed)) {
42
- this.logger?.warn?.(this.pluginName, "ConfigManager: invalid int", {
43
- key,
44
- raw
45
- });
46
- return defaultValue;
47
- }
48
- return parsed;
49
- }
50
- async getBoolean(key, defaultValue) {
51
- const raw = await this.get(key);
52
- if (raw === void 0) return defaultValue;
53
- const v = raw.toLowerCase();
54
- if (v === "true" || v === "1" || v === "yes" || v === "on") return true;
55
- if (v === "false" || v === "0" || v === "no" || v === "off") return false;
56
- this.logger?.warn?.(this.pluginName, "ConfigManager: invalid bool", {
57
- key,
58
- raw
59
- });
60
- return defaultValue;
61
- }
3
+ pluginName;
4
+ hostServices;
5
+ logger;
6
+ envPrefix;
7
+ constructor(pluginName, hostServices, logger) {
8
+ this.pluginName = pluginName;
9
+ this.hostServices = hostServices;
10
+ this.logger = logger;
11
+ this.envPrefix = `VIBE_${pluginName.toUpperCase().replace(/-/g, "_")}_`;
12
+ }
13
+ envName(key) {
14
+ return `${this.envPrefix}${key.toUpperCase().replace(/-/g, "_")}`;
15
+ }
16
+ /**
17
+ * Resolve a string config value. Returns `defaultValue` (or undefined)
18
+ * when neither env nor host config has it.
19
+ */
20
+ async get(key, defaultValue) {
21
+ const fromEnv = process.env[this.envName(key)];
22
+ if (fromEnv !== void 0 && fromEnv !== "") return fromEnv;
23
+ const fromHost = await this.hostServices?.getConfig?.(`${this.pluginName}.${key}`);
24
+ if (fromHost !== void 0 && fromHost !== "") return fromHost;
25
+ return defaultValue;
26
+ }
27
+ /** Like `get`, but throw if the key resolves to undefined / empty. */
28
+ async getRequired(key) {
29
+ const v = await this.get(key);
30
+ if (v === void 0 || v === "") throw new Error(`[${this.pluginName}] required config '${key}' is missing (env ${this.envName(key)} or host config '${this.pluginName}.${key}')`);
31
+ return v;
32
+ }
33
+ async getInt(key, defaultValue) {
34
+ const raw = await this.get(key);
35
+ if (raw === void 0) return defaultValue;
36
+ const parsed = Number.parseInt(raw, 10);
37
+ if (Number.isNaN(parsed)) {
38
+ this.logger?.warn?.(this.pluginName, "ConfigManager: invalid int", {
39
+ key,
40
+ raw
41
+ });
42
+ return defaultValue;
43
+ }
44
+ return parsed;
45
+ }
46
+ async getBoolean(key, defaultValue) {
47
+ const raw = await this.get(key);
48
+ if (raw === void 0) return defaultValue;
49
+ const v = raw.toLowerCase();
50
+ if (v === "true" || v === "1" || v === "yes" || v === "on") return true;
51
+ if (v === "false" || v === "0" || v === "no" || v === "off") return false;
52
+ this.logger?.warn?.(this.pluginName, "ConfigManager: invalid bool", {
53
+ key,
54
+ raw
55
+ });
56
+ return defaultValue;
57
+ }
62
58
  };
63
-
64
59
  export { ConfigManager };
65
- //# sourceMappingURL=index.js.map
60
+
66
61
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,3 @@
1
- import { HostServices } from '../contract/index.js';
2
- import '../host/os.js';
3
- import '../host/paths.js';
4
-
5
1
  /**
6
2
  * @vibecontrols/plugin-sdk/context
7
3
  *
@@ -24,42 +20,40 @@ import '../host/paths.js';
24
20
  * - Consumer plugins MUST redact credentials before returning. The aggregator
25
21
  * does not sanitise contributions.
26
22
  */
27
-
23
+ import { r as HostServices } from "../index-D946chPf.js";
28
24
  /** Single context contribution returned by a plugin. */
29
- interface ContextContribution {
30
- /** Stable identifier of the contributing plugin. */
31
- pluginName: string;
32
- /** Free-form description so LLMs / humans understand the section. */
33
- description?: string;
34
- /** Optional ISO-8601 timestamp. Agent fills `generatedAt` if absent. */
35
- generatedAt?: string;
36
- /** Structured payload. Shape is plugin-defined. */
37
- data: Record<string, unknown>;
25
+ export interface ContextContribution {
26
+ /** Stable identifier of the contributing plugin. */
27
+ pluginName: string;
28
+ /** Free-form description so LLMs / humans understand the section. */
29
+ description?: string;
30
+ /** Optional ISO-8601 timestamp. Agent fills `generatedAt` if absent. */
31
+ generatedAt?: string;
32
+ /** Structured payload. Shape is plugin-defined. */
33
+ data: Record<string, unknown>;
38
34
  }
39
35
  /** Optional args passed by the agent to scope a contribution. */
40
- interface ContextRequest {
41
- /** Profile name the agent is serving. */
42
- profile: string;
43
- /** Vibe id, if the caller scoped the request. */
44
- vibeId?: string;
36
+ export interface ContextRequest {
37
+ /** Profile name the agent is serving. */
38
+ profile: string;
39
+ /** Vibe id, if the caller scoped the request. */
40
+ vibeId?: string;
45
41
  }
46
42
  /** Provider plugins register one of these per provider name. */
47
- interface ContextProvider {
48
- /** Stable identifier — must be unique across the agent process. */
49
- name: string;
50
- /** Max time the aggregator waits before recording a timeout. Defaults to 2000ms in the agent. */
51
- timeoutMs?: number;
52
- getContext(req: ContextRequest): Promise<ContextContribution>;
43
+ export interface ContextProvider {
44
+ /** Stable identifier — must be unique across the agent process. */
45
+ name: string;
46
+ /** Max time the aggregator waits before recording a timeout. Defaults to 2000ms in the agent. */
47
+ timeoutMs?: number;
48
+ getContext(req: ContextRequest): Promise<ContextContribution>;
53
49
  }
54
50
  /** Provider-type tag used in the shared host service registry. */
55
- declare const CONTEXT_PROVIDER_TYPE = "context";
51
+ export declare const CONTEXT_PROVIDER_TYPE = "context";
56
52
  /** Register a context provider. Re-registering with the same name replaces. */
57
- declare function registerContextProvider(provider: ContextProvider, hostServices?: HostServices): void;
53
+ export declare function registerContextProvider(provider: ContextProvider, hostServices?: HostServices): void;
58
54
  /** Returns every registered context provider, in insertion order. */
59
- declare function listContextProviders(): ContextProvider[];
55
+ export declare function listContextProviders(): ContextProvider[];
60
56
  /** Resolve a context provider by name, or `undefined` if not registered. */
61
- declare function getContextProvider(name: string): ContextProvider | undefined;
57
+ export declare function getContextProvider(name: string): ContextProvider | undefined;
62
58
  /** Test helper — wipe the registry. Not exported from the SDK barrel. */
63
- declare function __resetContextProvidersForTests(): void;
64
-
65
- export { CONTEXT_PROVIDER_TYPE, type ContextContribution, type ContextProvider, type ContextRequest, __resetContextProvidersForTests, getContextProvider, listContextProviders, registerContextProvider };
59
+ export declare function __resetContextProvidersForTests(): void;