@vibecontrols/plugin-sdk 2026.509.1 → 2026.522.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 module-scoped map so multiple plugins can register
12
+ * distinct providers (the host's `ServiceRegistry.getProvider(type)` returns
13
+ * only the default-resolved provider per type, so we can't use it for a
14
+ * name-keyed lookup). All providers are still mirrored into the host registry
15
+ * for discoverability via `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,26 @@
1
+ // src/context/index.ts
2
+ var CONTEXT_PROVIDER_TYPE = "context";
3
+ var contextProviders = /* @__PURE__ */ new Map();
4
+ function registerContextProvider(provider, hostServices) {
5
+ if (!provider || typeof provider.name !== "string" || provider.name.length === 0) {
6
+ throw new Error("ContextProvider.name is required");
7
+ }
8
+ if (typeof provider.getContext !== "function") {
9
+ throw new Error("ContextProvider.getContext must be a function");
10
+ }
11
+ contextProviders.set(provider.name, provider);
12
+ hostServices?.serviceRegistry?.registerProvider?.(CONTEXT_PROVIDER_TYPE, provider, provider.name);
13
+ }
14
+ function listContextProviders() {
15
+ return Array.from(contextProviders.values());
16
+ }
17
+ function getContextProvider(name) {
18
+ return contextProviders.get(name);
19
+ }
20
+ function __resetContextProvidersForTests() {
21
+ contextProviders.clear();
22
+ }
23
+
24
+ export { CONTEXT_PROVIDER_TYPE, __resetContextProvidersForTests, getContextProvider, listContextProviders, registerContextProvider };
25
+ //# sourceMappingURL=index.js.map
26
+ //# sourceMappingURL=index.js.map
@@ -38,10 +38,32 @@ interface StorageProvider {
38
38
  delete(namespace: string, key: string): Promise<boolean>;
39
39
  list?(namespace: string): Promise<string[]>;
40
40
  }
41
+ /**
42
+ * Minimal façade over the agent's ServiceRegistry. Mirrors the agent's
43
+ * actual signatures (vibecontrols-agent/src/core/service-registry.ts):
44
+ *
45
+ * - `registerProvider(type, provider, pluginName)` — register a
46
+ * provider implementation under a provider type ("session", "tunnel",
47
+ * "ai"). The agent multiplexes providers per type and resolves a
48
+ * default via `getProvider<T>(type)`.
49
+ * - `getProvider<T>(type)` — return the default-resolved provider for
50
+ * the given type.
51
+ * - `registerService(pluginName, serviceName, service)` /
52
+ * `getService(pluginName, serviceName)` — namespaced bag for plugin-
53
+ * to-plugin services that aren't provider implementations.
54
+ *
55
+ * Every member is optional so SDK consumers tolerate partial or alt
56
+ * hosts. The SDK's `ProviderRegistry` wrapper picks the right method.
57
+ */
41
58
  interface ServiceRegistry {
42
- registerService<T>(type: string, name: string, instance: T): void;
43
- getService<T>(type: string, name: string): T | undefined;
44
- listProvidersForType?(type: string): string[];
59
+ registerProvider?(type: string, provider: unknown, pluginName: string): void;
60
+ getProvider?<T>(type: string): T | undefined;
61
+ registerService?(pluginName: string, serviceName: string, service: unknown): void;
62
+ getService?<T>(pluginName: string, serviceName: string): T | undefined;
63
+ listProvidersForType?(type: string): string[] | Array<{
64
+ pluginName: string;
65
+ isDefault: boolean;
66
+ }>;
45
67
  }
46
68
  interface SdkLogger {
47
69
  debug?(source: string, message: string, metadata?: Record<string, unknown>): void;
@@ -110,6 +132,12 @@ interface VibePlugin {
110
132
  apiPrefix?: string;
111
133
  createRoutes?: () => unknown;
112
134
  onServerStart?: (app: unknown, hostServices: HostServices) => void | Promise<void>;
135
+ /**
136
+ * Optional post-start hook — agent fires this AFTER `onServerStart` and
137
+ * after the Elysia app is listening, so plugins can schedule background
138
+ * work (queue processors, watchers) or register context providers.
139
+ */
140
+ onServerReady?: (app: unknown, hostServices: HostServices) => void | Promise<void>;
113
141
  onServerStop?: (hostServices: HostServices) => void | Promise<void>;
114
142
  onCliSetup?: (program: unknown, hostServices: HostServices) => void;
115
143
  }
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,24 +528,84 @@ var HttpClient = class {
528
528
  }
529
529
  };
530
530
 
531
+ // src/context/index.ts
532
+ var CONTEXT_PROVIDER_TYPE = "context";
533
+ var contextProviders = /* @__PURE__ */ new Map();
534
+ function registerContextProvider(provider, hostServices) {
535
+ if (!provider || typeof provider.name !== "string" || provider.name.length === 0) {
536
+ throw new Error("ContextProvider.name is required");
537
+ }
538
+ if (typeof provider.getContext !== "function") {
539
+ throw new Error("ContextProvider.getContext must be a function");
540
+ }
541
+ contextProviders.set(provider.name, provider);
542
+ hostServices?.serviceRegistry?.registerProvider?.(CONTEXT_PROVIDER_TYPE, provider, provider.name);
543
+ }
544
+ function listContextProviders() {
545
+ return Array.from(contextProviders.values());
546
+ }
547
+ function getContextProvider(name) {
548
+ return contextProviders.get(name);
549
+ }
550
+
531
551
  // src/providers/index.ts
532
552
  var ProviderRegistry = class {
533
553
  constructor(hostServices) {
534
554
  this.hostServices = hostServices;
535
555
  }
536
556
  hostServices;
557
+ /**
558
+ * Register a context provider. Convenience wrapper for the standalone
559
+ * `registerContextProvider` helper exported from `@vibecontrols/plugin-sdk/context`.
560
+ */
561
+ registerContextProvider(provider) {
562
+ registerContextProvider(provider, this.hostServices);
563
+ }
564
+ /** List every registered context provider. */
565
+ listContextProviders() {
566
+ return listContextProviders();
567
+ }
568
+ /** Resolve a context provider by name. */
569
+ getContextProvider(name) {
570
+ return getContextProvider(name);
571
+ }
537
572
  getServiceRegistry() {
538
573
  return this.hostServices?.serviceRegistry;
539
574
  }
575
+ /**
576
+ * Register a provider implementation (session / tunnel / ai) on the
577
+ * agent's per-type provider registry. Maps onto the agent's
578
+ * `registerProvider(type, provider, pluginName)` shape.
579
+ */
540
580
  registerProvider(type, name, provider) {
541
- this.hostServices?.serviceRegistry?.registerService(type, name, provider);
581
+ this.hostServices?.serviceRegistry?.registerProvider?.(type, provider, name);
542
582
  }
583
+ /**
584
+ * Resolve a provider for a given type. With one argument, returns the
585
+ * default-resolved provider (matching the agent's
586
+ * `serviceRegistry.getProvider<T>(type)` shape). With two arguments,
587
+ * resolves a *specific* provider by name — the agent's registry only
588
+ * exposes a default-resolved getter, so we list per-type entries and
589
+ * verify the name is present. The two-argument form preserves the
590
+ * original SDK signature so consumer plugins (e.g. session-manager)
591
+ * keep compiling.
592
+ */
543
593
  getProvider(type, name) {
544
- return this.hostServices?.serviceRegistry?.getService(type, name);
594
+ const reg = this.hostServices?.serviceRegistry;
595
+ if (!reg) return void 0;
596
+ if (name === void 0) return reg.getProvider?.(type);
597
+ if (!reg.listProvidersForType) return void 0;
598
+ const entries = reg.listProvidersForType(type) ?? [];
599
+ const present = entries.some(
600
+ (entry) => typeof entry === "string" ? entry === name : entry.pluginName === name
601
+ );
602
+ if (!present) return void 0;
603
+ return reg.getProvider?.(type);
545
604
  }
546
605
  listProviders(type) {
547
606
  const reg = this.hostServices?.serviceRegistry;
548
- return reg?.listProvidersForType?.(type) ?? [];
607
+ const entries = reg?.listProvidersForType?.(type) ?? [];
608
+ return entries.map((entry) => typeof entry === "string" ? entry : entry.pluginName);
549
609
  }
550
610
  /**
551
611
  * Register a CLI contribution bundle (status sections + doctor checks).
@@ -590,6 +650,6 @@ var BroadcastEmitter = class {
590
650
  }
591
651
  };
592
652
 
593
- export { AuditLogger, BoundLogger, BroadcastEmitter, CliCommandBuilder, ConfigManager, FULL_TRUST_CAPS, HttpClient, NamespaceStore, ProviderRegistry, RoutesBuilder, TelemetryEmitter, TypedStore, createLifecycleHooks, findAvailablePort, gracefulKill, isProcessAlive, maybePrintJson, pickOutputMode, redact, runMultimode, sleep };
653
+ 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 };
594
654
  //# sourceMappingURL=index.js.map
595
655
  //# 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,9 +16,33 @@ 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;
29
+ /**
30
+ * Register a provider implementation (session / tunnel / ai) on the
31
+ * agent's per-type provider registry. Maps onto the agent's
32
+ * `registerProvider(type, provider, pluginName)` shape.
33
+ */
19
34
  registerProvider<T>(type: string, name: string, provider: T): void;
20
- getProvider<T>(type: string, name: string): T | undefined;
35
+ /**
36
+ * Resolve a provider for a given type. With one argument, returns the
37
+ * default-resolved provider (matching the agent's
38
+ * `serviceRegistry.getProvider<T>(type)` shape). With two arguments,
39
+ * resolves a *specific* provider by name — the agent's registry only
40
+ * exposes a default-resolved getter, so we list per-type entries and
41
+ * verify the name is present. The two-argument form preserves the
42
+ * original SDK signature so consumer plugins (e.g. session-manager)
43
+ * keep compiling.
44
+ */
45
+ getProvider<T>(type: string, name?: string): T | undefined;
21
46
  listProviders(type: string): string[];
22
47
  /**
23
48
  * Register a CLI contribution bundle (status sections + doctor checks).
@@ -1,21 +1,81 @@
1
+ // src/context/index.ts
2
+ var CONTEXT_PROVIDER_TYPE = "context";
3
+ var contextProviders = /* @__PURE__ */ new Map();
4
+ function registerContextProvider(provider, hostServices) {
5
+ if (!provider || typeof provider.name !== "string" || provider.name.length === 0) {
6
+ throw new Error("ContextProvider.name is required");
7
+ }
8
+ if (typeof provider.getContext !== "function") {
9
+ throw new Error("ContextProvider.getContext must be a function");
10
+ }
11
+ contextProviders.set(provider.name, provider);
12
+ hostServices?.serviceRegistry?.registerProvider?.(CONTEXT_PROVIDER_TYPE, provider, provider.name);
13
+ }
14
+ function listContextProviders() {
15
+ return Array.from(contextProviders.values());
16
+ }
17
+ function getContextProvider(name) {
18
+ return contextProviders.get(name);
19
+ }
20
+
1
21
  // src/providers/index.ts
2
22
  var ProviderRegistry = class {
3
23
  constructor(hostServices) {
4
24
  this.hostServices = hostServices;
5
25
  }
6
26
  hostServices;
27
+ /**
28
+ * Register a context provider. Convenience wrapper for the standalone
29
+ * `registerContextProvider` helper exported from `@vibecontrols/plugin-sdk/context`.
30
+ */
31
+ registerContextProvider(provider) {
32
+ registerContextProvider(provider, this.hostServices);
33
+ }
34
+ /** List every registered context provider. */
35
+ listContextProviders() {
36
+ return listContextProviders();
37
+ }
38
+ /** Resolve a context provider by name. */
39
+ getContextProvider(name) {
40
+ return getContextProvider(name);
41
+ }
7
42
  getServiceRegistry() {
8
43
  return this.hostServices?.serviceRegistry;
9
44
  }
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
+ */
10
50
  registerProvider(type, name, provider) {
11
- this.hostServices?.serviceRegistry?.registerService(type, name, provider);
51
+ this.hostServices?.serviceRegistry?.registerProvider?.(type, provider, name);
12
52
  }
53
+ /**
54
+ * Resolve a provider for a given type. With one argument, returns the
55
+ * default-resolved provider (matching the agent's
56
+ * `serviceRegistry.getProvider<T>(type)` shape). With two arguments,
57
+ * resolves a *specific* provider by name — the agent's registry only
58
+ * exposes a default-resolved getter, so we list per-type entries and
59
+ * verify the name is present. The two-argument form preserves the
60
+ * original SDK signature so consumer plugins (e.g. session-manager)
61
+ * keep compiling.
62
+ */
13
63
  getProvider(type, name) {
14
- return this.hostServices?.serviceRegistry?.getService(type, name);
64
+ const reg = this.hostServices?.serviceRegistry;
65
+ if (!reg) return void 0;
66
+ if (name === void 0) return reg.getProvider?.(type);
67
+ if (!reg.listProvidersForType) return void 0;
68
+ const entries = reg.listProvidersForType(type) ?? [];
69
+ const present = entries.some(
70
+ (entry) => typeof entry === "string" ? entry === name : entry.pluginName === name
71
+ );
72
+ if (!present) return void 0;
73
+ return reg.getProvider?.(type);
15
74
  }
16
75
  listProviders(type) {
17
76
  const reg = this.hostServices?.serviceRegistry;
18
- return reg?.listProvidersForType?.(type) ?? [];
77
+ const entries = reg?.listProvidersForType?.(type) ?? [];
78
+ return entries.map((entry) => typeof entry === "string" ? entry : entry.pluginName);
19
79
  }
20
80
  /**
21
81
  * Register a CLI contribution bundle (status sections + doctor checks).
@@ -9,6 +9,8 @@ function createMockHostServices(overrides = {}) {
9
9
  list: mock(async () => [])
10
10
  };
11
11
  const serviceRegistry = {
12
+ registerProvider: mock(() => void 0),
13
+ getProvider: mock(() => void 0),
12
14
  registerService: mock(() => void 0),
13
15
  getService: mock(() => void 0),
14
16
  listProvidersForType: mock(() => [])
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@vibecontrols/plugin-sdk",
3
- "version": "2026.509.1",
3
+ "version": "2026.522.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"