@vibecontrols/plugin-sdk 2026.509.2 → 2026.527.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.
@@ -9,5 +9,5 @@ exact = true
9
9
  shell = "bun"
10
10
 
11
11
  [install.scopes]
12
- burdenoff = { username = "ci-publisher", password = "$VERDACCIO_PASSWORD", url = "https://verdaccio.tooling.internal.burdenoff.com/" }
13
- vibecontrols = { username = "ci-publisher", password = "$VERDACCIO_PASSWORD", url = "https://verdaccio.tooling.internal.burdenoff.com/" }
12
+ burdenoff = { token = "$NPM_TOKEN", url = "https://registry.npmjs.org/" }
13
+ vibecontrols = { token = "$NPM_TOKEN", url = "https://registry.npmjs.org/" }
@@ -0,0 +1,63 @@
1
+ import { HostServices } from '../contract/index.js';
2
+
3
+ /**
4
+ * @vibecontrols/plugin-sdk/context
5
+ *
6
+ * Lets a plugin contribute a structured snapshot of its runtime state to the
7
+ * agent's combined context endpoint. The agent calls every registered provider
8
+ * in parallel, applies a per-provider timeout, and serves the merged result
9
+ * over `/api/profiles/:profile/context*`.
10
+ *
11
+ * Registration is held in a process-wide registry anchored on `globalThis`
12
+ * (see `getRegistry` below) so providers register once and stay visible to the
13
+ * agent's aggregator regardless of how many times the SDK is bundled. They are
14
+ * also mirrored into the host `ServiceRegistry` for discoverability via
15
+ * `listProvidersForType("context")`.
16
+ *
17
+ * Contract:
18
+ * - One provider per `name`; re-registering replaces.
19
+ * - `getContext` must be safe to call concurrently and idempotent. It should
20
+ * respond within `timeoutMs` (defaults to 2000ms in the agent's aggregator).
21
+ * - The returned `data` is opaque to the agent — plugins decide shape.
22
+ * - Consumer plugins MUST redact credentials before returning. The aggregator
23
+ * does not sanitise contributions.
24
+ */
25
+
26
+ /** Single context contribution returned by a plugin. */
27
+ interface ContextContribution {
28
+ /** Stable identifier of the contributing plugin. */
29
+ pluginName: string;
30
+ /** Free-form description so LLMs / humans understand the section. */
31
+ description?: string;
32
+ /** Optional ISO-8601 timestamp. Agent fills `generatedAt` if absent. */
33
+ generatedAt?: string;
34
+ /** Structured payload. Shape is plugin-defined. */
35
+ data: Record<string, unknown>;
36
+ }
37
+ /** Optional args passed by the agent to scope a contribution. */
38
+ interface ContextRequest {
39
+ /** Profile name the agent is serving. */
40
+ profile: string;
41
+ /** Vibe id, if the caller scoped the request. */
42
+ vibeId?: string;
43
+ }
44
+ /** Provider plugins register one of these per provider name. */
45
+ interface ContextProvider {
46
+ /** Stable identifier — must be unique across the agent process. */
47
+ name: string;
48
+ /** Max time the aggregator waits before recording a timeout. Defaults to 2000ms in the agent. */
49
+ timeoutMs?: number;
50
+ getContext(req: ContextRequest): Promise<ContextContribution>;
51
+ }
52
+ /** Provider-type tag used in the shared host service registry. */
53
+ declare const CONTEXT_PROVIDER_TYPE = "context";
54
+ /** Register a context provider. Re-registering with the same name replaces. */
55
+ declare function registerContextProvider(provider: ContextProvider, hostServices?: HostServices): void;
56
+ /** Returns every registered context provider, in insertion order. */
57
+ declare function listContextProviders(): ContextProvider[];
58
+ /** Resolve a context provider by name, or `undefined` if not registered. */
59
+ declare function getContextProvider(name: string): ContextProvider | undefined;
60
+ /** Test helper — wipe the registry. Not exported from the SDK barrel. */
61
+ declare function __resetContextProvidersForTests(): void;
62
+
63
+ export { CONTEXT_PROVIDER_TYPE, type ContextContribution, type ContextProvider, type ContextRequest, __resetContextProvidersForTests, getContextProvider, listContextProviders, registerContextProvider };
@@ -0,0 +1,34 @@
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
+ function __resetContextProvidersForTests() {
29
+ getRegistry().clear();
30
+ }
31
+
32
+ export { CONTEXT_PROVIDER_TYPE, __resetContextProvidersForTests, getContextProvider, listContextProviders, registerContextProvider };
33
+ //# sourceMappingURL=index.js.map
34
+ //# sourceMappingURL=index.js.map
@@ -58,6 +58,17 @@ interface StorageProvider {
58
58
  interface ServiceRegistry {
59
59
  registerProvider?(type: string, provider: unknown, pluginName: string): void;
60
60
  getProvider?<T>(type: string): T | undefined;
61
+ /**
62
+ * Resolve a *specific* provider by `(type, pluginName)`. Mirrors the
63
+ * agent's `serviceRegistry.getProviderByName<T>(type, pluginName)`
64
+ * (`vibecontrols-agent/src/core/service-registry.ts:168`). Lets
65
+ * `ProviderRegistry.getProvider(type, name)` actually return the
66
+ * named provider instead of silently falling back to the type's
67
+ * default — without this the session-manager's `/providers` route
68
+ * returns the same default-provider object for every plugin name it
69
+ * looks up. [BOFF-2620]
70
+ */
71
+ getProviderByName?<T>(type: string, pluginName: string): T | undefined;
61
72
  registerService?(pluginName: string, serviceName: string, service: unknown): void;
62
73
  getService?<T>(pluginName: string, serviceName: string): T | undefined;
63
74
  listProvidersForType?(type: string): string[] | Array<{
@@ -132,6 +143,12 @@ interface VibePlugin {
132
143
  apiPrefix?: string;
133
144
  createRoutes?: () => unknown;
134
145
  onServerStart?: (app: unknown, hostServices: HostServices) => void | Promise<void>;
146
+ /**
147
+ * Optional post-start hook — agent fires this AFTER `onServerStart` and
148
+ * after the Elysia app is listening, so plugins can schedule background
149
+ * work (queue processors, watchers) or register context providers.
150
+ */
151
+ onServerReady?: (app: unknown, hostServices: HostServices) => void | Promise<void>;
135
152
  onServerStop?: (hostServices: HostServices) => void | Promise<void>;
136
153
  onCliSetup?: (program: unknown, hostServices: HostServices) => void;
137
154
  }
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { ConfigManager } from './config/index.js';
9
9
  export { findAvailablePort, gracefulKill, isProcessAlive, sleep } from './subprocess/index.js';
10
10
  export { HttpClient, HttpClientOptions, RequestOptions } from './http/index.js';
11
11
  export { CliContribution, ProviderRegistry } from './providers/index.js';
12
+ export { CONTEXT_PROVIDER_TYPE, ContextContribution, ContextProvider, ContextRequest, getContextProvider, listContextProviders, registerContextProvider } from './context/index.js';
12
13
  export { AuditLogger } from './audit/index.js';
13
14
  export { BroadcastEmitter } from './broadcast/index.js';
14
15
  import 'commander';
package/dist/index.js CHANGED
@@ -528,12 +528,55 @@ var HttpClient = class {
528
528
  }
529
529
  };
530
530
 
531
+ // src/context/index.ts
532
+ var CONTEXT_PROVIDER_TYPE = "context";
533
+ var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@vibecontrols/plugin-sdk:contextProviders@1");
534
+ function getRegistry() {
535
+ const slots = globalThis;
536
+ const existing = slots[REGISTRY_KEY];
537
+ if (existing) return existing;
538
+ const created = /* @__PURE__ */ new Map();
539
+ slots[REGISTRY_KEY] = created;
540
+ return created;
541
+ }
542
+ function registerContextProvider(provider, hostServices) {
543
+ if (!provider || typeof provider.name !== "string" || provider.name.length === 0) {
544
+ throw new Error("ContextProvider.name is required");
545
+ }
546
+ if (typeof provider.getContext !== "function") {
547
+ throw new Error("ContextProvider.getContext must be a function");
548
+ }
549
+ getRegistry().set(provider.name, provider);
550
+ hostServices?.serviceRegistry?.registerProvider?.(CONTEXT_PROVIDER_TYPE, provider, provider.name);
551
+ }
552
+ function listContextProviders() {
553
+ return Array.from(getRegistry().values());
554
+ }
555
+ function getContextProvider(name) {
556
+ return getRegistry().get(name);
557
+ }
558
+
531
559
  // src/providers/index.ts
532
560
  var ProviderRegistry = class {
533
561
  constructor(hostServices) {
534
562
  this.hostServices = hostServices;
535
563
  }
536
564
  hostServices;
565
+ /**
566
+ * Register a context provider. Convenience wrapper for the standalone
567
+ * `registerContextProvider` helper exported from `@vibecontrols/plugin-sdk/context`.
568
+ */
569
+ registerContextProvider(provider) {
570
+ registerContextProvider(provider, this.hostServices);
571
+ }
572
+ /** List every registered context provider. */
573
+ listContextProviders() {
574
+ return listContextProviders();
575
+ }
576
+ /** Resolve a context provider by name. */
577
+ getContextProvider(name) {
578
+ return getContextProvider(name);
579
+ }
537
580
  getServiceRegistry() {
538
581
  return this.hostServices?.serviceRegistry;
539
582
  }
@@ -549,16 +592,23 @@ var ProviderRegistry = class {
549
592
  * Resolve a provider for a given type. With one argument, returns the
550
593
  * default-resolved provider (matching the agent's
551
594
  * `serviceRegistry.getProvider<T>(type)` shape). With two arguments,
552
- * resolves a *specific* provider by name — the agent's registry only
553
- * exposes a default-resolved getter, so we list per-type entries and
554
- * verify the name is present. The two-argument form preserves the
555
- * original SDK signature so consumer plugins (e.g. session-manager)
556
- * keep compiling.
595
+ * resolves a *specific* provider by `(type, name)` via the agent's
596
+ * `getProviderByName` — which is what consumers like session-manager
597
+ * actually want when iterating registered providers.
598
+ *
599
+ * Previously the two-argument form bug-existed (BOFF-2620): it
600
+ * verified the name was present in `listProvidersForType` but then
601
+ * returned the type's *default* provider regardless, so every
602
+ * per-name lookup yielded the same object. We now call
603
+ * `getProviderByName` when the host exposes it, and only fall back
604
+ * to the default-resolved getter for hosts that pre-date that
605
+ * method.
557
606
  */
558
607
  getProvider(type, name) {
559
608
  const reg = this.hostServices?.serviceRegistry;
560
609
  if (!reg) return void 0;
561
610
  if (name === void 0) return reg.getProvider?.(type);
611
+ if (reg.getProviderByName) return reg.getProviderByName(type, name);
562
612
  if (!reg.listProvidersForType) return void 0;
563
613
  const entries = reg.listProvidersForType(type) ?? [];
564
614
  const present = entries.some(
@@ -615,6 +665,6 @@ var BroadcastEmitter = class {
615
665
  }
616
666
  };
617
667
 
618
- export { AuditLogger, BoundLogger, BroadcastEmitter, CliCommandBuilder, ConfigManager, FULL_TRUST_CAPS, HttpClient, NamespaceStore, ProviderRegistry, RoutesBuilder, TelemetryEmitter, TypedStore, createLifecycleHooks, findAvailablePort, gracefulKill, isProcessAlive, maybePrintJson, pickOutputMode, redact, runMultimode, sleep };
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 };
619
669
  //# sourceMappingURL=index.js.map
620
670
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,5 @@
1
1
  import { HostServices, ServiceRegistry } from '../contract/index.js';
2
+ import { ContextProvider } from '../context/index.js';
2
3
 
3
4
  /**
4
5
  * @vibecontrols/plugin-sdk/providers
@@ -15,6 +16,15 @@ interface CliContribution {
15
16
  declare class ProviderRegistry {
16
17
  private readonly hostServices?;
17
18
  constructor(hostServices?: HostServices | undefined);
19
+ /**
20
+ * Register a context provider. Convenience wrapper for the standalone
21
+ * `registerContextProvider` helper exported from `@vibecontrols/plugin-sdk/context`.
22
+ */
23
+ registerContextProvider(provider: ContextProvider): void;
24
+ /** List every registered context provider. */
25
+ listContextProviders(): ContextProvider[];
26
+ /** Resolve a context provider by name. */
27
+ getContextProvider(name: string): ContextProvider | undefined;
18
28
  getServiceRegistry(): ServiceRegistry | undefined;
19
29
  /**
20
30
  * Register a provider implementation (session / tunnel / ai) on the
@@ -26,11 +36,17 @@ declare class ProviderRegistry {
26
36
  * Resolve a provider for a given type. With one argument, returns the
27
37
  * default-resolved provider (matching the agent's
28
38
  * `serviceRegistry.getProvider<T>(type)` shape). With two arguments,
29
- * resolves a *specific* provider by name — the agent's registry only
30
- * exposes a default-resolved getter, so we list per-type entries and
31
- * verify the name is present. The two-argument form preserves the
32
- * original SDK signature so consumer plugins (e.g. session-manager)
33
- * keep compiling.
39
+ * resolves a *specific* provider by `(type, name)` via the agent's
40
+ * `getProviderByName` — which is what consumers like session-manager
41
+ * actually want when iterating registered providers.
42
+ *
43
+ * Previously the two-argument form bug-existed (BOFF-2620): it
44
+ * verified the name was present in `listProvidersForType` but then
45
+ * returned the type's *default* provider regardless, so every
46
+ * per-name lookup yielded the same object. We now call
47
+ * `getProviderByName` when the host exposes it, and only fall back
48
+ * to the default-resolved getter for hosts that pre-date that
49
+ * method.
34
50
  */
35
51
  getProvider<T>(type: string, name?: string): T | undefined;
36
52
  listProviders(type: string): string[];
@@ -1,9 +1,52 @@
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
29
  // src/providers/index.ts
2
30
  var ProviderRegistry = class {
3
31
  constructor(hostServices) {
4
32
  this.hostServices = hostServices;
5
33
  }
6
34
  hostServices;
35
+ /**
36
+ * Register a context provider. Convenience wrapper for the standalone
37
+ * `registerContextProvider` helper exported from `@vibecontrols/plugin-sdk/context`.
38
+ */
39
+ registerContextProvider(provider) {
40
+ registerContextProvider(provider, this.hostServices);
41
+ }
42
+ /** List every registered context provider. */
43
+ listContextProviders() {
44
+ return listContextProviders();
45
+ }
46
+ /** Resolve a context provider by name. */
47
+ getContextProvider(name) {
48
+ return getContextProvider(name);
49
+ }
7
50
  getServiceRegistry() {
8
51
  return this.hostServices?.serviceRegistry;
9
52
  }
@@ -19,16 +62,23 @@ var ProviderRegistry = class {
19
62
  * Resolve a provider for a given type. With one argument, returns the
20
63
  * default-resolved provider (matching the agent's
21
64
  * `serviceRegistry.getProvider<T>(type)` shape). With two arguments,
22
- * resolves a *specific* provider by name — the agent's registry only
23
- * exposes a default-resolved getter, so we list per-type entries and
24
- * verify the name is present. The two-argument form preserves the
25
- * original SDK signature so consumer plugins (e.g. session-manager)
26
- * keep compiling.
65
+ * resolves a *specific* provider by `(type, name)` via the agent's
66
+ * `getProviderByName` — which is what consumers like session-manager
67
+ * actually want when iterating registered providers.
68
+ *
69
+ * Previously the two-argument form bug-existed (BOFF-2620): it
70
+ * verified the name was present in `listProvidersForType` but then
71
+ * returned the type's *default* provider regardless, so every
72
+ * per-name lookup yielded the same object. We now call
73
+ * `getProviderByName` when the host exposes it, and only fall back
74
+ * to the default-resolved getter for hosts that pre-date that
75
+ * method.
27
76
  */
28
77
  getProvider(type, name) {
29
78
  const reg = this.hostServices?.serviceRegistry;
30
79
  if (!reg) return void 0;
31
80
  if (name === void 0) return reg.getProvider?.(type);
81
+ if (reg.getProviderByName) return reg.getProviderByName(type, name);
32
82
  if (!reg.listProvidersForType) return void 0;
33
83
  const entries = reg.listProvidersForType(type) ?? [];
34
84
  const present = entries.some(
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@vibecontrols/plugin-sdk",
3
- "version": "2026.509.2",
3
+ "version": "2026.527.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": {
7
- "bun": ">=1.3.10"
7
+ "bun": ">=1.3.14"
8
8
  },
9
9
  "author": {
10
10
  "name": "Vignesh T.V",
@@ -61,6 +61,10 @@
61
61
  "import": "./dist/providers/index.js",
62
62
  "types": "./dist/providers/index.d.ts"
63
63
  },
64
+ "./context": {
65
+ "import": "./dist/context/index.js",
66
+ "types": "./dist/context/index.d.ts"
67
+ },
64
68
  "./audit": {
65
69
  "import": "./dist/audit/index.js",
66
70
  "types": "./dist/audit/index.d.ts"