@vibecontrols/plugin-sdk 2026.1107.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 +10 -10
@@ -1,135 +1,110 @@
1
- // src/context/index.ts
2
- var CONTEXT_PROVIDER_TYPE = "context";
3
- var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@vibecontrols/plugin-sdk:contextProviders@1");
4
- function getRegistry() {
5
- const slots = globalThis;
6
- const existing = slots[REGISTRY_KEY];
7
- if (existing) return existing;
8
- const created = /* @__PURE__ */ new Map();
9
- slots[REGISTRY_KEY] = created;
10
- return created;
11
- }
12
- function registerContextProvider(provider, hostServices) {
13
- if (!provider || typeof provider.name !== "string" || provider.name.length === 0) {
14
- throw new Error("ContextProvider.name is required");
15
- }
16
- if (typeof provider.getContext !== "function") {
17
- throw new Error("ContextProvider.getContext must be a function");
18
- }
19
- getRegistry().set(provider.name, provider);
20
- hostServices?.serviceRegistry?.registerProvider?.(CONTEXT_PROVIDER_TYPE, provider, provider.name);
21
- }
22
- function listContextProviders() {
23
- return Array.from(getRegistry().values());
24
- }
25
- function getContextProvider(name) {
26
- return getRegistry().get(name);
27
- }
28
-
1
+ import { getContextProvider, listContextProviders, registerContextProvider } from "../context/index.js";
29
2
  // src/providers/index.ts
3
+ /** Map `process.platform` onto the SDK's `SupportedOS` union (defaults to linux). */
30
4
  function currentSupportedOS(p = process.platform) {
31
- if (p === "darwin") return "darwin";
32
- if (p === "win32") return "win32";
33
- return "linux";
5
+ if (p === "darwin") return "darwin";
6
+ if (p === "win32") return "win32";
7
+ return "linux";
34
8
  }
9
+ /**
10
+ * The single, shared META→provider provisioning sequence. A META plugin calls
11
+ * this from its `provisionProviders` hook with its own `metaProviders`; the
12
+ * agent injects `host.plugins` (the provisioning façade). For each provider
13
+ * that is a platform default (`defaultOn` includes the current OS) this runs:
14
+ *
15
+ * install → loadProvider → runPrereqs → electDefault
16
+ *
17
+ * Opt-in providers (no `defaultOn` match) are skipped — they install on demand.
18
+ * Honours `host.plugins.skipInstall()` (operator `--no-install-deps`): providers
19
+ * are still loaded + elected, but no package/binary install is attempted.
20
+ * No-ops cleanly when `host.plugins` is absent (older agent / untrusted plugin).
21
+ * Best-effort and isolated per provider — one provider failing never aborts the
22
+ * others, so a META degrades gracefully rather than blocking boot.
23
+ */
35
24
  async function provisionMetaProviders(host, metaProviders, platform = currentSupportedOS()) {
36
- const plugins = host.plugins;
37
- if (!plugins || !metaProviders?.length) return;
38
- const skip = plugins.skipInstall?.() ?? false;
39
- for (const ref of metaProviders) {
40
- if (!ref.defaultOn?.includes(platform)) continue;
41
- try {
42
- if (!skip) await plugins.install?.(ref.packageName, { refreshLatest: true });
43
- await plugins.loadProvider?.(ref.packageName);
44
- await plugins.runPrereqs?.(ref.packageName, { skipInstall: skip });
45
- if (ref.providerType && ref.pluginName) {
46
- await plugins.electDefault?.(ref.providerType, ref.pluginName);
47
- }
48
- } catch {
49
- }
50
- }
25
+ const plugins = host.plugins;
26
+ if (!plugins || !metaProviders?.length) return;
27
+ const skip = plugins.skipInstall?.() ?? false;
28
+ for (const ref of metaProviders) {
29
+ if (!ref.defaultOn?.includes(platform)) continue;
30
+ try {
31
+ if (!skip) await plugins.install?.(ref.packageName, { refreshLatest: true });
32
+ await plugins.loadProvider?.(ref.packageName);
33
+ await plugins.runPrereqs?.(ref.packageName, { skipInstall: skip });
34
+ if (ref.providerType && ref.pluginName) await plugins.electDefault?.(ref.providerType, ref.pluginName);
35
+ } catch {}
36
+ }
51
37
  }
52
38
  var ProviderRegistry = class {
53
- constructor(hostServices) {
54
- this.hostServices = hostServices;
55
- }
56
- hostServices;
57
- /**
58
- * Register a context provider. Convenience wrapper for the standalone
59
- * `registerContextProvider` helper exported from `@vibecontrols/plugin-sdk/context`.
60
- */
61
- registerContextProvider(provider) {
62
- registerContextProvider(provider, this.hostServices);
63
- }
64
- /** List every registered context provider. */
65
- listContextProviders() {
66
- return listContextProviders();
67
- }
68
- /** Resolve a context provider by name. */
69
- getContextProvider(name) {
70
- return getContextProvider(name);
71
- }
72
- getServiceRegistry() {
73
- return this.hostServices?.serviceRegistry;
74
- }
75
- /**
76
- * Register a provider implementation (session / tunnel / ai) on the
77
- * agent's per-type provider registry. Maps onto the agent's
78
- * `registerProvider(type, provider, pluginName)` shape.
79
- */
80
- registerProvider(type, name, provider) {
81
- this.hostServices?.serviceRegistry?.registerProvider?.(type, provider, name);
82
- }
83
- /**
84
- * Resolve a provider for a given type. With one argument, returns the
85
- * default-resolved provider (matching the agent's
86
- * `serviceRegistry.getProvider<T>(type)` shape). With two arguments,
87
- * resolves a *specific* provider by `(type, name)` via the agent's
88
- * `getProviderByName` — which is what consumers like session-manager
89
- * actually want when iterating registered providers.
90
- *
91
- * Previously the two-argument form bug-existed: it
92
- * verified the name was present in `listProvidersForType` but then
93
- * returned the type's *default* provider regardless, so every
94
- * per-name lookup yielded the same object. We now call
95
- * `getProviderByName` when the host exposes it, and only fall back
96
- * to the default-resolved getter for hosts that pre-date that
97
- * method.
98
- */
99
- getProvider(type, name) {
100
- const reg = this.hostServices?.serviceRegistry;
101
- if (!reg) return void 0;
102
- if (name === void 0) return reg.getProvider?.(type);
103
- if (reg.getProviderByName) return reg.getProviderByName(type, name);
104
- if (!reg.listProvidersForType) return void 0;
105
- const entries = reg.listProvidersForType(type) ?? [];
106
- const present = entries.some(
107
- (entry) => typeof entry === "string" ? entry === name : entry.pluginName === name
108
- );
109
- if (!present) return void 0;
110
- return reg.getProvider?.(type);
111
- }
112
- listProviders(type) {
113
- const reg = this.hostServices?.serviceRegistry;
114
- const entries = reg?.listProvidersForType?.(type) ?? [];
115
- return entries.map((entry) => typeof entry === "string" ? entry : entry.pluginName);
116
- }
117
- /**
118
- * Register a CLI contribution bundle (status sections + doctor checks).
119
- * No-op when the host doesn't expose `cliContributors`.
120
- */
121
- withCliContribution(contribution) {
122
- const contributors = this.hostServices?.cliContributors;
123
- if (!contributors) return;
124
- for (const section of contribution.statusSections ?? []) {
125
- contributors.addStatusSection?.(section);
126
- }
127
- for (const check of contribution.doctorChecks ?? []) {
128
- contributors.addDoctorCheck?.(check);
129
- }
130
- }
39
+ hostServices;
40
+ constructor(hostServices) {
41
+ this.hostServices = hostServices;
42
+ }
43
+ /**
44
+ * Register a context provider. Convenience wrapper for the standalone
45
+ * `registerContextProvider` helper exported from `@vibecontrols/plugin-sdk/context`.
46
+ */
47
+ registerContextProvider(provider) {
48
+ registerContextProvider(provider, this.hostServices);
49
+ }
50
+ /** List every registered context provider. */
51
+ listContextProviders() {
52
+ return listContextProviders();
53
+ }
54
+ /** Resolve a context provider by name. */
55
+ getContextProvider(name) {
56
+ return getContextProvider(name);
57
+ }
58
+ getServiceRegistry() {
59
+ return this.hostServices?.serviceRegistry;
60
+ }
61
+ /**
62
+ * Register a provider implementation (session / tunnel / ai) on the
63
+ * agent's per-type provider registry. Maps onto the agent's
64
+ * `registerProvider(type, provider, pluginName)` shape.
65
+ */
66
+ registerProvider(type, name, provider) {
67
+ this.hostServices?.serviceRegistry?.registerProvider?.(type, provider, name);
68
+ }
69
+ /**
70
+ * Resolve a provider for a given type. With one argument, returns the
71
+ * default-resolved provider (matching the agent's
72
+ * `serviceRegistry.getProvider<T>(type)` shape). With two arguments,
73
+ * resolves a *specific* provider by `(type, name)` via the agent's
74
+ * `getProviderByName` — which is what consumers like session-manager
75
+ * actually want when iterating registered providers.
76
+ *
77
+ * Previously the two-argument form bug-existed: it
78
+ * verified the name was present in `listProvidersForType` but then
79
+ * returned the type's *default* provider regardless, so every
80
+ * per-name lookup yielded the same object. We now call
81
+ * `getProviderByName` when the host exposes it, and only fall back
82
+ * to the default-resolved getter for hosts that pre-date that
83
+ * method.
84
+ */
85
+ getProvider(type, name) {
86
+ const reg = this.hostServices?.serviceRegistry;
87
+ if (!reg) return void 0;
88
+ if (name === void 0) return reg.getProvider?.(type);
89
+ if (reg.getProviderByName) return reg.getProviderByName(type, name);
90
+ if (!reg.listProvidersForType) return void 0;
91
+ if (!(reg.listProvidersForType(type) ?? []).some((entry) => typeof entry === "string" ? entry === name : entry.pluginName === name)) return void 0;
92
+ return reg.getProvider?.(type);
93
+ }
94
+ listProviders(type) {
95
+ return ((this.hostServices?.serviceRegistry)?.listProvidersForType?.(type) ?? []).map((entry) => typeof entry === "string" ? entry : entry.pluginName);
96
+ }
97
+ /**
98
+ * Register a CLI contribution bundle (status sections + doctor checks).
99
+ * No-op when the host doesn't expose `cliContributors`.
100
+ */
101
+ withCliContribution(contribution) {
102
+ const contributors = this.hostServices?.cliContributors;
103
+ if (!contributors) return;
104
+ for (const section of contribution.statusSections ?? []) contributors.addStatusSection?.(section);
105
+ for (const check of contribution.doctorChecks ?? []) contributors.addDoctorCheck?.(check);
106
+ }
131
107
  };
132
-
133
108
  export { ProviderRegistry, currentSupportedOS, provisionMetaProviders };
134
- //# sourceMappingURL=index.js.map
109
+
135
110
  //# sourceMappingURL=index.js.map
@@ -1,8 +1,3 @@
1
- import { Elysia } from 'elysia';
2
- import { HostServices } from '../contract/index.js';
3
- import '../host/os.js';
4
- import '../host/paths.js';
5
-
6
1
  /**
7
2
  * @vibecontrols/plugin-sdk/routes
8
3
  *
@@ -14,26 +9,25 @@ import '../host/paths.js';
14
9
  * If a plugin doesn't ship HTTP routes it never imports this module so
15
10
  * elysia stays an optional peer.
16
11
  */
17
-
18
- type ApiKeyResolver = () => string | Promise<string>;
19
- declare class RoutesBuilder {
20
- private readonly pluginName;
21
- private readonly hostServices?;
22
- private prefix?;
23
- private apiKeyResolver?;
24
- private errorHandlerEnabled;
25
- private loggingEnabled;
26
- constructor(pluginName: string, hostServices?: HostServices | undefined);
27
- withPrefix(prefix: string): this;
28
- withAuth(getApiKey: ApiKeyResolver): this;
29
- withErrorHandler(): this;
30
- withLogging(): this;
31
- /**
32
- * Build the configured Elysia instance. Plugins typically call
33
- * `.derive` / `.get` / `.post` on the result before returning it from
34
- * `createRoutes()`.
35
- */
36
- build(): Elysia;
37
- }
38
-
39
- export { type ApiKeyResolver, RoutesBuilder };
12
+ import { r as HostServices } from "../index-D946chPf.js";
13
+ import { Elysia } from "elysia";
14
+ export type ApiKeyResolver = () => string | Promise<string>;
15
+ export declare class RoutesBuilder {
16
+ private readonly pluginName;
17
+ private readonly hostServices?;
18
+ private prefix?;
19
+ private apiKeyResolver?;
20
+ private errorHandlerEnabled;
21
+ private loggingEnabled;
22
+ constructor(pluginName: string, hostServices?: HostServices | undefined);
23
+ withPrefix(prefix: string): this;
24
+ withAuth(getApiKey: ApiKeyResolver): this;
25
+ withErrorHandler(): this;
26
+ withLogging(): this;
27
+ /**
28
+ * Build the configured Elysia instance. Plugins typically call
29
+ * `.derive` / `.get` / `.post` on the result before returning it from
30
+ * `createRoutes()`.
31
+ */
32
+ build(): Elysia;
33
+ }
@@ -1,77 +1,85 @@
1
- import { Elysia } from 'elysia';
2
-
1
+ import { Elysia } from "elysia";
3
2
  // src/routes/index.ts
3
+ /**
4
+ * @vibecontrols/plugin-sdk/routes
5
+ *
6
+ * RoutesBuilder — fluent wrapper around an Elysia instance with the four
7
+ * concerns every plugin reimplements: prefix, API-key auth, error handler,
8
+ * request logging.
9
+ *
10
+ * Elysia is a peer dependency — both type and value come from the consumer.
11
+ * If a plugin doesn't ship HTTP routes it never imports this module so
12
+ * elysia stays an optional peer.
13
+ */
4
14
  var RoutesBuilder = class {
5
- constructor(pluginName, hostServices) {
6
- this.pluginName = pluginName;
7
- this.hostServices = hostServices;
8
- }
9
- pluginName;
10
- hostServices;
11
- prefix;
12
- apiKeyResolver;
13
- errorHandlerEnabled = false;
14
- loggingEnabled = false;
15
- withPrefix(prefix) {
16
- this.prefix = prefix;
17
- return this;
18
- }
19
- withAuth(getApiKey) {
20
- this.apiKeyResolver = getApiKey;
21
- return this;
22
- }
23
- withErrorHandler() {
24
- this.errorHandlerEnabled = true;
25
- return this;
26
- }
27
- withLogging() {
28
- this.loggingEnabled = true;
29
- return this;
30
- }
31
- /**
32
- * Build the configured Elysia instance. Plugins typically call
33
- * `.derive` / `.get` / `.post` on the result before returning it from
34
- * `createRoutes()`.
35
- */
36
- build() {
37
- const opts = this.prefix ? { prefix: this.prefix } : void 0;
38
- const app = new Elysia(opts);
39
- if (this.apiKeyResolver) {
40
- const resolver = this.apiKeyResolver;
41
- app.onBeforeHandle(async ({ request, set }) => {
42
- const supplied = request.headers.get("x-api-key");
43
- const expected = await resolver();
44
- if (!supplied || supplied !== expected) {
45
- set.status = 401;
46
- return { error: "unauthorized" };
47
- }
48
- return;
49
- });
50
- }
51
- if (this.errorHandlerEnabled) {
52
- const pluginName = this.pluginName;
53
- const logger = this.hostServices?.logger;
54
- app.onError(({ error, set }) => {
55
- const message = error instanceof Error ? error.message : String(error);
56
- logger?.error?.(pluginName, "route error", { message });
57
- set.status = 500;
58
- return { error: message };
59
- });
60
- }
61
- if (this.loggingEnabled) {
62
- const pluginName = this.pluginName;
63
- const logger = this.hostServices?.logger;
64
- app.onRequest(({ request }) => {
65
- logger?.debug?.(pluginName, "request", {
66
- method: request.method,
67
- url: request.url
68
- });
69
- });
70
- }
71
- return app;
72
- }
15
+ pluginName;
16
+ hostServices;
17
+ prefix;
18
+ apiKeyResolver;
19
+ errorHandlerEnabled = false;
20
+ loggingEnabled = false;
21
+ constructor(pluginName, hostServices) {
22
+ this.pluginName = pluginName;
23
+ this.hostServices = hostServices;
24
+ }
25
+ withPrefix(prefix) {
26
+ this.prefix = prefix;
27
+ return this;
28
+ }
29
+ withAuth(getApiKey) {
30
+ this.apiKeyResolver = getApiKey;
31
+ return this;
32
+ }
33
+ withErrorHandler() {
34
+ this.errorHandlerEnabled = true;
35
+ return this;
36
+ }
37
+ withLogging() {
38
+ this.loggingEnabled = true;
39
+ return this;
40
+ }
41
+ /**
42
+ * Build the configured Elysia instance. Plugins typically call
43
+ * `.derive` / `.get` / `.post` on the result before returning it from
44
+ * `createRoutes()`.
45
+ */
46
+ build() {
47
+ const opts = this.prefix ? { prefix: this.prefix } : void 0;
48
+ const app = new Elysia(opts);
49
+ if (this.apiKeyResolver) {
50
+ const resolver = this.apiKeyResolver;
51
+ app.onBeforeHandle(async ({ request, set }) => {
52
+ const supplied = request.headers.get("x-api-key");
53
+ const expected = await resolver();
54
+ if (!supplied || supplied !== expected) {
55
+ set.status = 401;
56
+ return { error: "unauthorized" };
57
+ }
58
+ });
59
+ }
60
+ if (this.errorHandlerEnabled) {
61
+ const pluginName = this.pluginName;
62
+ const logger = this.hostServices?.logger;
63
+ app.onError(({ error, set }) => {
64
+ const message = error instanceof Error ? error.message : String(error);
65
+ logger?.error?.(pluginName, "route error", { message });
66
+ set.status = 500;
67
+ return { error: message };
68
+ });
69
+ }
70
+ if (this.loggingEnabled) {
71
+ const pluginName = this.pluginName;
72
+ const logger = this.hostServices?.logger;
73
+ app.onRequest(({ request }) => {
74
+ logger?.debug?.(pluginName, "request", {
75
+ method: request.method,
76
+ url: request.url
77
+ });
78
+ });
79
+ }
80
+ return app;
81
+ }
73
82
  };
74
-
75
83
  export { RoutesBuilder };
76
- //# sourceMappingURL=index.js.map
84
+
77
85
  //# sourceMappingURL=index.js.map
@@ -1,38 +1,2 @@
1
- import { StorageProvider, SdkLogger } from '../contract/index.js';
2
- import '../host/os.js';
3
- import '../host/paths.js';
4
-
5
- /**
6
- * Typed wrappers over a `StorageProvider`.
7
- *
8
- * `TypedStore<T>` is a single-key handle: `get/set/delete` against a fixed
9
- * (namespace, key) pair, with JSON serialisation + corrupt-payload recovery.
10
- * `NamespaceStore` groups multiple typed handles under one namespace and
11
- * exposes raw get/set/delete for ad-hoc access.
12
- */
13
-
14
- declare class TypedStore<T> {
15
- private readonly storage;
16
- private readonly namespace;
17
- private readonly key;
18
- private readonly logger?;
19
- private readonly pluginName;
20
- constructor(storage: StorageProvider, namespace: string, key: string, logger?: SdkLogger | undefined, pluginName?: string);
21
- get(): Promise<T | null>;
22
- set(value: T): Promise<void>;
23
- delete(): Promise<boolean>;
24
- }
25
- declare class NamespaceStore {
26
- private readonly storage;
27
- private readonly namespace;
28
- private readonly logger?;
29
- private readonly pluginName;
30
- constructor(storage: StorageProvider, namespace: string, logger?: SdkLogger | undefined, pluginName?: string);
31
- /** Get a typed handle for `(this.namespace, key)`. */
32
- typed<T>(key: string): TypedStore<T>;
33
- get<T = unknown>(key: string): Promise<T | null>;
34
- set<T = unknown>(key: string, value: T): Promise<void>;
35
- delete(key: string): Promise<boolean>;
36
- }
37
-
38
- export { NamespaceStore, TypedStore };
1
+ import { n as TypedStore, t as NamespaceStore } from "../index-BM4zNXSR.js";
2
+ export { NamespaceStore, TypedStore };
@@ -1,67 +1 @@
1
- // src/storage/typed-store.ts
2
- var TypedStore = class {
3
- constructor(storage, namespace, key, logger, pluginName = "plugin") {
4
- this.storage = storage;
5
- this.namespace = namespace;
6
- this.key = key;
7
- this.logger = logger;
8
- this.pluginName = pluginName;
9
- }
10
- storage;
11
- namespace;
12
- key;
13
- logger;
14
- pluginName;
15
- async get() {
16
- const raw = await this.storage.get(this.namespace, this.key);
17
- if (raw === null || raw === void 0) return null;
18
- if (typeof raw !== "string") {
19
- return raw;
20
- }
21
- try {
22
- return JSON.parse(raw);
23
- } catch (err) {
24
- this.logger?.error?.(this.pluginName, "TypedStore: corrupt JSON", {
25
- namespace: this.namespace,
26
- key: this.key,
27
- message: err instanceof Error ? err.message : String(err)
28
- });
29
- return null;
30
- }
31
- }
32
- async set(value) {
33
- await this.storage.set(this.namespace, this.key, JSON.stringify(value));
34
- }
35
- async delete() {
36
- return this.storage.delete(this.namespace, this.key);
37
- }
38
- };
39
- var NamespaceStore = class {
40
- constructor(storage, namespace, logger, pluginName = "plugin") {
41
- this.storage = storage;
42
- this.namespace = namespace;
43
- this.logger = logger;
44
- this.pluginName = pluginName;
45
- }
46
- storage;
47
- namespace;
48
- logger;
49
- pluginName;
50
- /** Get a typed handle for `(this.namespace, key)`. */
51
- typed(key) {
52
- return new TypedStore(this.storage, this.namespace, key, this.logger, this.pluginName);
53
- }
54
- async get(key) {
55
- return this.storage.get(this.namespace, key);
56
- }
57
- async set(key, value) {
58
- return this.storage.set(this.namespace, key, value);
59
- }
60
- async delete(key) {
61
- return this.storage.delete(this.namespace, key);
62
- }
63
- };
64
-
65
- export { NamespaceStore, TypedStore };
66
- //# sourceMappingURL=index.js.map
67
- //# sourceMappingURL=index.js.map
1
+ export { t as NamespaceStore, n as TypedStore } from "../storage-DkNBaJHC.js";
@@ -0,0 +1,64 @@
1
+ // src/storage/typed-store.ts
2
+ var TypedStore = class {
3
+ storage;
4
+ namespace;
5
+ key;
6
+ logger;
7
+ pluginName;
8
+ constructor(storage, namespace, key, logger, pluginName = "plugin") {
9
+ this.storage = storage;
10
+ this.namespace = namespace;
11
+ this.key = key;
12
+ this.logger = logger;
13
+ this.pluginName = pluginName;
14
+ }
15
+ async get() {
16
+ const raw = await this.storage.get(this.namespace, this.key);
17
+ if (raw === null || raw === void 0) return null;
18
+ if (typeof raw !== "string") return raw;
19
+ try {
20
+ return JSON.parse(raw);
21
+ } catch (err) {
22
+ this.logger?.error?.(this.pluginName, "TypedStore: corrupt JSON", {
23
+ namespace: this.namespace,
24
+ key: this.key,
25
+ message: err instanceof Error ? err.message : String(err)
26
+ });
27
+ return null;
28
+ }
29
+ }
30
+ async set(value) {
31
+ await this.storage.set(this.namespace, this.key, JSON.stringify(value));
32
+ }
33
+ async delete() {
34
+ return this.storage.delete(this.namespace, this.key);
35
+ }
36
+ };
37
+ var NamespaceStore = class {
38
+ storage;
39
+ namespace;
40
+ logger;
41
+ pluginName;
42
+ constructor(storage, namespace, logger, pluginName = "plugin") {
43
+ this.storage = storage;
44
+ this.namespace = namespace;
45
+ this.logger = logger;
46
+ this.pluginName = pluginName;
47
+ }
48
+ /** Get a typed handle for `(this.namespace, key)`. */
49
+ typed(key) {
50
+ return new TypedStore(this.storage, this.namespace, key, this.logger, this.pluginName);
51
+ }
52
+ async get(key) {
53
+ return this.storage.get(this.namespace, key);
54
+ }
55
+ async set(key, value) {
56
+ return this.storage.set(this.namespace, key, value);
57
+ }
58
+ async delete(key) {
59
+ return this.storage.delete(this.namespace, key);
60
+ }
61
+ };
62
+ export { TypedStore as n, NamespaceStore as t };
63
+
64
+ //# sourceMappingURL=storage-DkNBaJHC.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/subprocess
7
3
  *
@@ -17,23 +13,21 @@ import '../host/paths.js';
17
13
  *
18
14
  * Cross-platform: pure Node + optional Bun runtime feature detection.
19
15
  */
20
-
21
- declare function sleep(ms: number): Promise<void>;
16
+ import { m as SdkLogger } from "../index-D946chPf.js";
17
+ export declare function sleep(ms: number): Promise<void>;
22
18
  /**
23
19
  * Returns true if a process with `pid` is reachable from this process.
24
20
  * Uses signal 0 — POSIX + Node's Windows shim both recognise it.
25
21
  */
26
- declare function isProcessAlive(pid: number): boolean;
22
+ export declare function isProcessAlive(pid: number): boolean;
27
23
  /**
28
24
  * Send SIGTERM, poll until the process exits or `timeoutMs` elapses, then
29
25
  * escalate to SIGKILL if necessary.
30
26
  */
31
- declare function gracefulKill(pid: number, timeoutMs?: number, logger?: SdkLogger): Promise<void>;
27
+ export declare function gracefulKill(pid: number, timeoutMs?: number, logger?: SdkLogger): Promise<void>;
32
28
  /**
33
29
  * Probe ports starting at `start` for `range` consecutive numbers; resolve
34
30
  * with the first one that bind-tests cleanly. Throws if the whole range is
35
31
  * occupied.
36
32
  */
37
- declare function findAvailablePort(start: number, range?: number): Promise<number>;
38
-
39
- export { findAvailablePort, gracefulKill, isProcessAlive, sleep };
33
+ export declare function findAvailablePort(start: number, range?: number): Promise<number>;