@vibecontrols/plugin-sdk 2026.522.1 → 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.
@@ -8,11 +8,11 @@ import { HostServices } from '../contract/index.js';
8
8
  * in parallel, applies a per-provider timeout, and serves the merged result
9
9
  * over `/api/profiles/:profile/context*`.
10
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")`.
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
16
  *
17
17
  * Contract:
18
18
  * - One provider per `name`; re-registering replaces.
@@ -1,6 +1,14 @@
1
1
  // src/context/index.ts
2
2
  var CONTEXT_PROVIDER_TYPE = "context";
3
- var contextProviders = /* @__PURE__ */ new Map();
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
+ }
4
12
  function registerContextProvider(provider, hostServices) {
5
13
  if (!provider || typeof provider.name !== "string" || provider.name.length === 0) {
6
14
  throw new Error("ContextProvider.name is required");
@@ -8,17 +16,17 @@ function registerContextProvider(provider, hostServices) {
8
16
  if (typeof provider.getContext !== "function") {
9
17
  throw new Error("ContextProvider.getContext must be a function");
10
18
  }
11
- contextProviders.set(provider.name, provider);
19
+ getRegistry().set(provider.name, provider);
12
20
  hostServices?.serviceRegistry?.registerProvider?.(CONTEXT_PROVIDER_TYPE, provider, provider.name);
13
21
  }
14
22
  function listContextProviders() {
15
- return Array.from(contextProviders.values());
23
+ return Array.from(getRegistry().values());
16
24
  }
17
25
  function getContextProvider(name) {
18
- return contextProviders.get(name);
26
+ return getRegistry().get(name);
19
27
  }
20
28
  function __resetContextProvidersForTests() {
21
- contextProviders.clear();
29
+ getRegistry().clear();
22
30
  }
23
31
 
24
32
  export { CONTEXT_PROVIDER_TYPE, __resetContextProvidersForTests, getContextProvider, listContextProviders, registerContextProvider };
@@ -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<{
package/dist/index.js CHANGED
@@ -530,7 +530,15 @@ var HttpClient = class {
530
530
 
531
531
  // src/context/index.ts
532
532
  var CONTEXT_PROVIDER_TYPE = "context";
533
- var contextProviders = /* @__PURE__ */ new Map();
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
+ }
534
542
  function registerContextProvider(provider, hostServices) {
535
543
  if (!provider || typeof provider.name !== "string" || provider.name.length === 0) {
536
544
  throw new Error("ContextProvider.name is required");
@@ -538,14 +546,14 @@ function registerContextProvider(provider, hostServices) {
538
546
  if (typeof provider.getContext !== "function") {
539
547
  throw new Error("ContextProvider.getContext must be a function");
540
548
  }
541
- contextProviders.set(provider.name, provider);
549
+ getRegistry().set(provider.name, provider);
542
550
  hostServices?.serviceRegistry?.registerProvider?.(CONTEXT_PROVIDER_TYPE, provider, provider.name);
543
551
  }
544
552
  function listContextProviders() {
545
- return Array.from(contextProviders.values());
553
+ return Array.from(getRegistry().values());
546
554
  }
547
555
  function getContextProvider(name) {
548
- return contextProviders.get(name);
556
+ return getRegistry().get(name);
549
557
  }
550
558
 
551
559
  // src/providers/index.ts
@@ -584,16 +592,23 @@ var ProviderRegistry = class {
584
592
  * Resolve a provider for a given type. With one argument, returns the
585
593
  * default-resolved provider (matching the agent's
586
594
  * `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.
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.
592
606
  */
593
607
  getProvider(type, name) {
594
608
  const reg = this.hostServices?.serviceRegistry;
595
609
  if (!reg) return void 0;
596
610
  if (name === void 0) return reg.getProvider?.(type);
611
+ if (reg.getProviderByName) return reg.getProviderByName(type, name);
597
612
  if (!reg.listProvidersForType) return void 0;
598
613
  const entries = reg.listProvidersForType(type) ?? [];
599
614
  const present = entries.some(
@@ -36,11 +36,17 @@ declare class ProviderRegistry {
36
36
  * Resolve a provider for a given type. With one argument, returns the
37
37
  * default-resolved provider (matching the agent's
38
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.
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.
44
50
  */
45
51
  getProvider<T>(type: string, name?: string): T | undefined;
46
52
  listProviders(type: string): string[];
@@ -1,6 +1,14 @@
1
1
  // src/context/index.ts
2
2
  var CONTEXT_PROVIDER_TYPE = "context";
3
- var contextProviders = /* @__PURE__ */ new Map();
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
+ }
4
12
  function registerContextProvider(provider, hostServices) {
5
13
  if (!provider || typeof provider.name !== "string" || provider.name.length === 0) {
6
14
  throw new Error("ContextProvider.name is required");
@@ -8,14 +16,14 @@ function registerContextProvider(provider, hostServices) {
8
16
  if (typeof provider.getContext !== "function") {
9
17
  throw new Error("ContextProvider.getContext must be a function");
10
18
  }
11
- contextProviders.set(provider.name, provider);
19
+ getRegistry().set(provider.name, provider);
12
20
  hostServices?.serviceRegistry?.registerProvider?.(CONTEXT_PROVIDER_TYPE, provider, provider.name);
13
21
  }
14
22
  function listContextProviders() {
15
- return Array.from(contextProviders.values());
23
+ return Array.from(getRegistry().values());
16
24
  }
17
25
  function getContextProvider(name) {
18
- return contextProviders.get(name);
26
+ return getRegistry().get(name);
19
27
  }
20
28
 
21
29
  // src/providers/index.ts
@@ -54,16 +62,23 @@ var ProviderRegistry = class {
54
62
  * Resolve a provider for a given type. With one argument, returns the
55
63
  * default-resolved provider (matching the agent's
56
64
  * `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.
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.
62
76
  */
63
77
  getProvider(type, name) {
64
78
  const reg = this.hostServices?.serviceRegistry;
65
79
  if (!reg) return void 0;
66
80
  if (name === void 0) return reg.getProvider?.(type);
81
+ if (reg.getProviderByName) return reg.getProviderByName(type, name);
67
82
  if (!reg.listProvidersForType) return void 0;
68
83
  const entries = reg.listProvidersForType(type) ?? [];
69
84
  const present = entries.some(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibecontrols/plugin-sdk",
3
- "version": "2026.522.1",
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": {