@vibecontrols/plugin-sdk 2026.1108.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 +8 -8
package/dist/index.js CHANGED
@@ -1,750 +1,17 @@
1
- import { Elysia } from 'elysia';
2
- import { createServer } from 'net';
3
- import { homedir, platform, tmpdir } from 'os';
4
- import { join } from 'path';
5
-
6
- // src/contract/index.ts
7
- var FULL_TRUST_CAPS = {
8
- storage: "rw",
9
- secrets: "rw",
10
- gateway: true,
11
- broadcast: true,
12
- subprocess: true,
13
- audit: true,
14
- telemetry: true,
15
- singletonOnly: false,
16
- requiresIsolation: false
17
- };
18
-
19
- // src/lifecycle/index.ts
20
- function createLifecycleHooks(spec) {
21
- const { name, onInit, onShutdown, onNuke, telemetryEventName, skipPlatforms } = spec;
22
- return {
23
- onServerStart: async (_app, hostServices) => {
24
- if (skipPlatforms && skipPlatforms.includes(process.platform)) {
25
- process.stderr.write(
26
- `[${name}] skipping init on unsupported platform '${process.platform}'
27
- `
28
- );
29
- return;
30
- }
31
- if (onInit) {
32
- await onInit(hostServices);
33
- }
34
- if (telemetryEventName) {
35
- hostServices.telemetry?.emit(telemetryEventName, { plugin: name });
36
- }
37
- },
38
- onServerStop: async (hostServices) => {
39
- if (onShutdown) {
40
- await onShutdown(hostServices);
41
- }
42
- },
43
- onNuke: async (hostServices, ctx) => {
44
- if (onNuke) {
45
- return onNuke(hostServices, ctx);
46
- }
47
- }
48
- };
49
- }
50
-
51
- // src/cli/multimode.ts
52
- function pickOutputMode(flags) {
53
- if (flags.json) return "json";
54
- if (flags.plain) return "plain";
55
- if (flags.interactive) return "interactive";
56
- return "auto";
57
- }
58
- function isCi() {
59
- return !!process.env.CI || !!process.env.NO_COLOR || process.env.TERM === "dumb";
60
- }
61
- function stdoutIsTty() {
62
- return Boolean(process.stdout.isTTY);
63
- }
64
- async function runMultimode(opts) {
65
- const data = await opts.fetchData();
66
- const mode = opts.mode ?? "auto";
67
- if (mode === "json") {
68
- const shaped = opts.json ? opts.json(data) : data;
69
- process.stdout.write(`${JSON.stringify(shaped, null, 2)}
70
- `);
71
- return;
72
- }
73
- if (mode === "plain") {
74
- await opts.plain(data);
75
- return;
76
- }
77
- const wantInteractive = (mode === "interactive" || stdoutIsTty() && !isCi()) && !!opts.interactive;
78
- if (wantInteractive && opts.interactive) {
79
- try {
80
- await opts.interactive(data);
81
- return;
82
- } catch {
83
- }
84
- }
85
- await opts.plain(data);
86
- }
87
- function maybePrintJson(flags, data) {
88
- if (!flags.json) return false;
89
- process.stdout.write(`${JSON.stringify(data, null, 2)}
90
- `);
91
- return true;
92
- }
93
-
94
- // src/cli/redaction.ts
95
- var SENSITIVE_KEY_RE = /(token|secret|password|apikey|api_key|key|auth|credential|email)/i;
96
- function redact(value) {
97
- return redactInner(value);
98
- }
99
- function redactInner(value) {
100
- if (value === null || value === void 0) return value;
101
- if (Array.isArray(value)) return value.map(redactInner);
102
- if (typeof value === "object") {
103
- const out = {};
104
- for (const [k, v] of Object.entries(value)) {
105
- if (SENSITIVE_KEY_RE.test(k)) {
106
- out[k] = "[redacted]";
107
- continue;
108
- }
109
- out[k] = redactInner(v);
110
- }
111
- return out;
112
- }
113
- return value;
114
- }
115
-
116
- // src/cli/command-builder.ts
117
- var CliCommandBuilder = class {
118
- constructor(program) {
119
- this.program = program;
120
- }
121
- program;
122
- /**
123
- * Register a `<name>` sub-command that fetches once and renders via
124
- * `--json` / `--plain` / interactive (when stdout is a TTY).
125
- */
126
- addStatusCommand(name, spec) {
127
- this.program.command(name).description(spec.description).option("--json", "emit JSON for scripting").option("--plain", "force plain text (no opentui)").action(async (opts) => {
128
- const mode = pickOutputMode(opts);
129
- await runMultimode({
130
- mode,
131
- fetchData: spec.fetchData,
132
- plain: async (data) => {
133
- const view = spec.redact ? redact(data) : data;
134
- if (spec.format) {
135
- await spec.format(view);
136
- return;
137
- }
138
- process.stdout.write(`${JSON.stringify(view, null, 2)}
139
- `);
140
- },
141
- json: (data) => spec.redact ? redact(data) : data
142
- });
143
- });
144
- return this;
145
- }
146
- /** Escape hatch: hand back the underlying commander Command. */
147
- command() {
148
- return this.program;
149
- }
150
- };
151
- var RoutesBuilder = class {
152
- constructor(pluginName, hostServices) {
153
- this.pluginName = pluginName;
154
- this.hostServices = hostServices;
155
- }
156
- pluginName;
157
- hostServices;
158
- prefix;
159
- apiKeyResolver;
160
- errorHandlerEnabled = false;
161
- loggingEnabled = false;
162
- withPrefix(prefix) {
163
- this.prefix = prefix;
164
- return this;
165
- }
166
- withAuth(getApiKey) {
167
- this.apiKeyResolver = getApiKey;
168
- return this;
169
- }
170
- withErrorHandler() {
171
- this.errorHandlerEnabled = true;
172
- return this;
173
- }
174
- withLogging() {
175
- this.loggingEnabled = true;
176
- return this;
177
- }
178
- /**
179
- * Build the configured Elysia instance. Plugins typically call
180
- * `.derive` / `.get` / `.post` on the result before returning it from
181
- * `createRoutes()`.
182
- */
183
- build() {
184
- const opts = this.prefix ? { prefix: this.prefix } : void 0;
185
- const app = new Elysia(opts);
186
- if (this.apiKeyResolver) {
187
- const resolver = this.apiKeyResolver;
188
- app.onBeforeHandle(async ({ request, set }) => {
189
- const supplied = request.headers.get("x-api-key");
190
- const expected = await resolver();
191
- if (!supplied || supplied !== expected) {
192
- set.status = 401;
193
- return { error: "unauthorized" };
194
- }
195
- return;
196
- });
197
- }
198
- if (this.errorHandlerEnabled) {
199
- const pluginName = this.pluginName;
200
- const logger = this.hostServices?.logger;
201
- app.onError(({ error, set }) => {
202
- const message = error instanceof Error ? error.message : String(error);
203
- logger?.error?.(pluginName, "route error", { message });
204
- set.status = 500;
205
- return { error: message };
206
- });
207
- }
208
- if (this.loggingEnabled) {
209
- const pluginName = this.pluginName;
210
- const logger = this.hostServices?.logger;
211
- app.onRequest(({ request }) => {
212
- logger?.debug?.(pluginName, "request", {
213
- method: request.method,
214
- url: request.url
215
- });
216
- });
217
- }
218
- return app;
219
- }
220
- };
221
-
222
- // src/telemetry/index.ts
223
- var TelemetryEmitter = class {
224
- constructor(pluginName, pluginVersion, hostServices) {
225
- this.pluginName = pluginName;
226
- this.pluginVersion = pluginVersion;
227
- this.hostServices = hostServices;
228
- }
229
- pluginName;
230
- pluginVersion;
231
- hostServices;
232
- /** Emit `eventName` with auto-tagged plugin/version/timestamp. */
233
- emit(eventName, payload) {
234
- const target = this.hostServices?.telemetry;
235
- if (!target) return;
236
- target.emit(eventName, {
237
- plugin: this.pluginName,
238
- version: this.pluginVersion,
239
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
240
- ...payload ?? {}
241
- });
242
- }
243
- /** `<pluginName>.ready` shorthand. */
244
- emitReady(context) {
245
- this.emit(`${this.pluginName}.ready`, context);
246
- }
247
- /** `<pluginName>.error` shorthand — extracts message from Error. */
248
- emitError(error, context) {
249
- this.emit(`${this.pluginName}.error`, {
250
- message: error.message,
251
- ...context ?? {}
252
- });
253
- }
254
- /** Generic event-type emit (alias of emit). */
255
- emitEvent(type, payload) {
256
- this.emit(type, payload);
257
- }
258
- };
259
-
260
- // src/log/index.ts
261
- var BoundLogger = class {
262
- constructor(logger, source) {
263
- this.logger = logger;
264
- this.source = source;
265
- }
266
- logger;
267
- source;
268
- info(message, meta) {
269
- this.logger?.info?.(this.source, message, meta);
270
- }
271
- warn(message, meta) {
272
- this.logger?.warn?.(this.source, message, meta);
273
- }
274
- error(message, meta) {
275
- this.logger?.error?.(this.source, message, meta);
276
- }
277
- debug(message, meta) {
278
- this.logger?.debug?.(this.source, message, meta);
279
- }
280
- };
281
-
282
- // src/storage/typed-store.ts
283
- var TypedStore = class {
284
- constructor(storage, namespace, key, logger, pluginName = "plugin") {
285
- this.storage = storage;
286
- this.namespace = namespace;
287
- this.key = key;
288
- this.logger = logger;
289
- this.pluginName = pluginName;
290
- }
291
- storage;
292
- namespace;
293
- key;
294
- logger;
295
- pluginName;
296
- async get() {
297
- const raw = await this.storage.get(this.namespace, this.key);
298
- if (raw === null || raw === void 0) return null;
299
- if (typeof raw !== "string") {
300
- return raw;
301
- }
302
- try {
303
- return JSON.parse(raw);
304
- } catch (err) {
305
- this.logger?.error?.(this.pluginName, "TypedStore: corrupt JSON", {
306
- namespace: this.namespace,
307
- key: this.key,
308
- message: err instanceof Error ? err.message : String(err)
309
- });
310
- return null;
311
- }
312
- }
313
- async set(value) {
314
- await this.storage.set(this.namespace, this.key, JSON.stringify(value));
315
- }
316
- async delete() {
317
- return this.storage.delete(this.namespace, this.key);
318
- }
319
- };
320
- var NamespaceStore = class {
321
- constructor(storage, namespace, logger, pluginName = "plugin") {
322
- this.storage = storage;
323
- this.namespace = namespace;
324
- this.logger = logger;
325
- this.pluginName = pluginName;
326
- }
327
- storage;
328
- namespace;
329
- logger;
330
- pluginName;
331
- /** Get a typed handle for `(this.namespace, key)`. */
332
- typed(key) {
333
- return new TypedStore(this.storage, this.namespace, key, this.logger, this.pluginName);
334
- }
335
- async get(key) {
336
- return this.storage.get(this.namespace, key);
337
- }
338
- async set(key, value) {
339
- return this.storage.set(this.namespace, key, value);
340
- }
341
- async delete(key) {
342
- return this.storage.delete(this.namespace, key);
343
- }
344
- };
345
-
346
- // src/config/index.ts
347
- var ConfigManager = class {
348
- constructor(pluginName, hostServices, logger) {
349
- this.pluginName = pluginName;
350
- this.hostServices = hostServices;
351
- this.logger = logger;
352
- this.envPrefix = `VIBE_${pluginName.toUpperCase().replace(/-/g, "_")}_`;
353
- }
354
- pluginName;
355
- hostServices;
356
- logger;
357
- envPrefix;
358
- envName(key) {
359
- return `${this.envPrefix}${key.toUpperCase().replace(/-/g, "_")}`;
360
- }
361
- /**
362
- * Resolve a string config value. Returns `defaultValue` (or undefined)
363
- * when neither env nor host config has it.
364
- */
365
- async get(key, defaultValue) {
366
- const fromEnv = process.env[this.envName(key)];
367
- if (fromEnv !== void 0 && fromEnv !== "") return fromEnv;
368
- const fromHost = await this.hostServices?.getConfig?.(`${this.pluginName}.${key}`);
369
- if (fromHost !== void 0 && fromHost !== "") return fromHost;
370
- return defaultValue;
371
- }
372
- /** Like `get`, but throw if the key resolves to undefined / empty. */
373
- async getRequired(key) {
374
- const v = await this.get(key);
375
- if (v === void 0 || v === "") {
376
- throw new Error(
377
- `[${this.pluginName}] required config '${key}' is missing (env ${this.envName(key)} or host config '${this.pluginName}.${key}')`
378
- );
379
- }
380
- return v;
381
- }
382
- async getInt(key, defaultValue) {
383
- const raw = await this.get(key);
384
- if (raw === void 0) return defaultValue;
385
- const parsed = Number.parseInt(raw, 10);
386
- if (Number.isNaN(parsed)) {
387
- this.logger?.warn?.(this.pluginName, "ConfigManager: invalid int", {
388
- key,
389
- raw
390
- });
391
- return defaultValue;
392
- }
393
- return parsed;
394
- }
395
- async getBoolean(key, defaultValue) {
396
- const raw = await this.get(key);
397
- if (raw === void 0) return defaultValue;
398
- const v = raw.toLowerCase();
399
- if (v === "true" || v === "1" || v === "yes" || v === "on") return true;
400
- if (v === "false" || v === "0" || v === "no" || v === "off") return false;
401
- this.logger?.warn?.(this.pluginName, "ConfigManager: invalid bool", {
402
- key,
403
- raw
404
- });
405
- return defaultValue;
406
- }
407
- };
408
- function sleep(ms) {
409
- return new Promise((resolve) => setTimeout(resolve, ms));
410
- }
411
- function isProcessAlive(pid) {
412
- try {
413
- process.kill(pid, 0);
414
- return true;
415
- } catch {
416
- return false;
417
- }
418
- }
419
- async function gracefulKill(pid, timeoutMs = 3e3, logger) {
420
- const source = "subprocess";
421
- if (!isProcessAlive(pid)) return;
422
- try {
423
- process.kill(pid, "SIGTERM");
424
- } catch (err) {
425
- logger?.warn?.(source, "SIGTERM failed", {
426
- pid,
427
- message: err instanceof Error ? err.message : String(err)
428
- });
429
- return;
430
- }
431
- const pollMs = 50;
432
- let elapsed = 0;
433
- while (elapsed < timeoutMs) {
434
- await sleep(pollMs);
435
- elapsed += pollMs;
436
- if (!isProcessAlive(pid)) return;
437
- }
438
- try {
439
- process.kill(pid, "SIGKILL");
440
- } catch (err) {
441
- logger?.warn?.(source, "SIGKILL failed", {
442
- pid,
443
- message: err instanceof Error ? err.message : String(err)
444
- });
445
- }
446
- }
447
- async function findAvailablePort(start, range = 200) {
448
- for (let i = 0; i < range; i++) {
449
- const port = start + i;
450
- if (await isPortFree(port)) return port;
451
- }
452
- throw new Error(`findAvailablePort: no port free in [${start}, ${start + range - 1}]`);
453
- }
454
- function isPortFree(port) {
455
- return new Promise((resolve) => {
456
- const server = createServer();
457
- server.once("error", () => {
458
- resolve(false);
459
- });
460
- server.once("listening", () => {
461
- server.close(() => resolve(true));
462
- });
463
- try {
464
- server.listen({ port, host: "0.0.0.0" });
465
- } catch {
466
- resolve(false);
467
- }
468
- });
469
- }
470
-
471
- // src/http/index.ts
472
- var HttpClient = class {
473
- constructor(baseUrl, options = {}) {
474
- this.baseUrl = baseUrl;
475
- this.timeoutMs = options.timeoutMs ?? 1e4;
476
- this.maxAttempts = options.maxAttempts ?? 3;
477
- this.defaultHeaders = options.defaultHeaders ?? {};
478
- this.fetchImpl = options.fetchImpl ?? fetch;
479
- }
480
- baseUrl;
481
- timeoutMs;
482
- maxAttempts;
483
- defaultHeaders;
484
- fetchImpl;
485
- async get(path, options) {
486
- return this.request("GET", path, void 0, options);
487
- }
488
- async post(path, body, options) {
489
- return this.request("POST", path, body, options);
490
- }
491
- async request(method, path, body, options) {
492
- const url = `${this.baseUrl.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
493
- const headers = {
494
- ...this.defaultHeaders,
495
- ...options?.headers ?? {}
496
- };
497
- if (body !== void 0 && headers["content-type"] === void 0) {
498
- headers["content-type"] = "application/json";
499
- }
500
- let lastError;
501
- for (let attempt = 1; attempt <= this.maxAttempts; attempt++) {
502
- const controller = new AbortController();
503
- const timer = setTimeout(() => controller.abort(), this.timeoutMs);
504
- const callerSignal = options?.signal;
505
- const onCallerAbort = () => controller.abort();
506
- callerSignal?.addEventListener("abort", onCallerAbort, { once: true });
507
- try {
508
- const res = await this.fetchImpl(url, {
509
- method,
510
- headers,
511
- body: body === void 0 ? void 0 : JSON.stringify(body),
512
- signal: controller.signal
513
- });
514
- if (!res.ok) {
515
- throw new Error(`HTTP ${res.status} ${res.statusText} for ${method} ${url}`);
516
- }
517
- const text = await res.text();
518
- if (!text) return void 0;
519
- try {
520
- return JSON.parse(text);
521
- } catch {
522
- return text;
523
- }
524
- } catch (err) {
525
- lastError = err;
526
- if (attempt >= this.maxAttempts) break;
527
- const backoff = 100 * 2 ** (attempt - 1);
528
- await new Promise((r) => setTimeout(r, backoff));
529
- } finally {
530
- clearTimeout(timer);
531
- callerSignal?.removeEventListener("abort", onCallerAbort);
532
- }
533
- }
534
- throw lastError instanceof Error ? lastError : new Error(`HttpClient: request failed for ${method} ${url}`);
535
- }
536
- };
537
-
538
- // src/context/index.ts
539
- var CONTEXT_PROVIDER_TYPE = "context";
540
- var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@vibecontrols/plugin-sdk:contextProviders@1");
541
- function getRegistry() {
542
- const slots = globalThis;
543
- const existing = slots[REGISTRY_KEY];
544
- if (existing) return existing;
545
- const created = /* @__PURE__ */ new Map();
546
- slots[REGISTRY_KEY] = created;
547
- return created;
548
- }
549
- function registerContextProvider(provider, hostServices) {
550
- if (!provider || typeof provider.name !== "string" || provider.name.length === 0) {
551
- throw new Error("ContextProvider.name is required");
552
- }
553
- if (typeof provider.getContext !== "function") {
554
- throw new Error("ContextProvider.getContext must be a function");
555
- }
556
- getRegistry().set(provider.name, provider);
557
- hostServices?.serviceRegistry?.registerProvider?.(CONTEXT_PROVIDER_TYPE, provider, provider.name);
558
- }
559
- function listContextProviders() {
560
- return Array.from(getRegistry().values());
561
- }
562
- function getContextProvider(name) {
563
- return getRegistry().get(name);
564
- }
565
-
566
- // src/providers/index.ts
567
- function currentSupportedOS(p = process.platform) {
568
- if (p === "darwin") return "darwin";
569
- if (p === "win32") return "win32";
570
- return "linux";
571
- }
572
- async function provisionMetaProviders(host, metaProviders, platform2 = currentSupportedOS()) {
573
- const plugins = host.plugins;
574
- if (!plugins || !metaProviders?.length) return;
575
- const skip = plugins.skipInstall?.() ?? false;
576
- for (const ref of metaProviders) {
577
- if (!ref.defaultOn?.includes(platform2)) continue;
578
- try {
579
- if (!skip) await plugins.install?.(ref.packageName, { refreshLatest: true });
580
- await plugins.loadProvider?.(ref.packageName);
581
- await plugins.runPrereqs?.(ref.packageName, { skipInstall: skip });
582
- if (ref.providerType && ref.pluginName) {
583
- await plugins.electDefault?.(ref.providerType, ref.pluginName);
584
- }
585
- } catch {
586
- }
587
- }
588
- }
589
- var ProviderRegistry = class {
590
- constructor(hostServices) {
591
- this.hostServices = hostServices;
592
- }
593
- hostServices;
594
- /**
595
- * Register a context provider. Convenience wrapper for the standalone
596
- * `registerContextProvider` helper exported from `@vibecontrols/plugin-sdk/context`.
597
- */
598
- registerContextProvider(provider) {
599
- registerContextProvider(provider, this.hostServices);
600
- }
601
- /** List every registered context provider. */
602
- listContextProviders() {
603
- return listContextProviders();
604
- }
605
- /** Resolve a context provider by name. */
606
- getContextProvider(name) {
607
- return getContextProvider(name);
608
- }
609
- getServiceRegistry() {
610
- return this.hostServices?.serviceRegistry;
611
- }
612
- /**
613
- * Register a provider implementation (session / tunnel / ai) on the
614
- * agent's per-type provider registry. Maps onto the agent's
615
- * `registerProvider(type, provider, pluginName)` shape.
616
- */
617
- registerProvider(type, name, provider) {
618
- this.hostServices?.serviceRegistry?.registerProvider?.(type, provider, name);
619
- }
620
- /**
621
- * Resolve a provider for a given type. With one argument, returns the
622
- * default-resolved provider (matching the agent's
623
- * `serviceRegistry.getProvider<T>(type)` shape). With two arguments,
624
- * resolves a *specific* provider by `(type, name)` via the agent's
625
- * `getProviderByName` — which is what consumers like session-manager
626
- * actually want when iterating registered providers.
627
- *
628
- * Previously the two-argument form bug-existed: it
629
- * verified the name was present in `listProvidersForType` but then
630
- * returned the type's *default* provider regardless, so every
631
- * per-name lookup yielded the same object. We now call
632
- * `getProviderByName` when the host exposes it, and only fall back
633
- * to the default-resolved getter for hosts that pre-date that
634
- * method.
635
- */
636
- getProvider(type, name) {
637
- const reg = this.hostServices?.serviceRegistry;
638
- if (!reg) return void 0;
639
- if (name === void 0) return reg.getProvider?.(type);
640
- if (reg.getProviderByName) return reg.getProviderByName(type, name);
641
- if (!reg.listProvidersForType) return void 0;
642
- const entries = reg.listProvidersForType(type) ?? [];
643
- const present = entries.some(
644
- (entry) => typeof entry === "string" ? entry === name : entry.pluginName === name
645
- );
646
- if (!present) return void 0;
647
- return reg.getProvider?.(type);
648
- }
649
- listProviders(type) {
650
- const reg = this.hostServices?.serviceRegistry;
651
- const entries = reg?.listProvidersForType?.(type) ?? [];
652
- return entries.map((entry) => typeof entry === "string" ? entry : entry.pluginName);
653
- }
654
- /**
655
- * Register a CLI contribution bundle (status sections + doctor checks).
656
- * No-op when the host doesn't expose `cliContributors`.
657
- */
658
- withCliContribution(contribution) {
659
- const contributors = this.hostServices?.cliContributors;
660
- if (!contributors) return;
661
- for (const section of contribution.statusSections ?? []) {
662
- contributors.addStatusSection?.(section);
663
- }
664
- for (const check of contribution.doctorChecks ?? []) {
665
- contributors.addDoctorCheck?.(check);
666
- }
667
- }
668
- };
669
-
670
- // src/audit/index.ts
671
- var AuditLogger = class {
672
- constructor(source, hostServices) {
673
- this.source = source;
674
- this.hostServices = hostServices;
675
- }
676
- source;
677
- hostServices;
678
- emit(event, payload) {
679
- this.hostServices?.audit?.emit(event, {
680
- source: this.source,
681
- ...payload ?? {}
682
- });
683
- }
684
- };
685
-
686
- // src/broadcast/index.ts
687
- var BroadcastEmitter = class {
688
- constructor(hostServices) {
689
- this.hostServices = hostServices;
690
- }
691
- hostServices;
692
- broadcast(type, payload) {
693
- this.hostServices?.broadcast?.(type, payload);
694
- }
695
- };
696
-
697
- // src/host/os.ts
698
- function platformLabel(p = process.platform, isWSL = false) {
699
- if (p === "darwin") return "macOS";
700
- if (p === "win32") return "Windows";
701
- return isWSL ? "WSL" : "Linux";
702
- }
703
- function manualInstallHint(recipes, p = process.platform) {
704
- const key = p === "darwin" || p === "win32" ? p : "linux";
705
- return recipes[key] ?? recipes.linux ?? "";
706
- }
707
- var HOME = () => homedir();
708
- var paths = {
709
- homeDir: HOME,
710
- configDir(scope) {
711
- const p = platform();
712
- if (p === "win32") {
713
- return join(process.env.APPDATA ?? join(HOME(), "AppData", "Roaming"), scope);
714
- }
715
- if (p === "darwin") {
716
- return join(HOME(), "Library", "Application Support", scope);
717
- }
718
- return join(process.env.XDG_CONFIG_HOME ?? join(HOME(), ".config"), scope);
719
- },
720
- cacheDir(scope) {
721
- const p = platform();
722
- if (p === "win32") {
723
- return join(process.env.LOCALAPPDATA ?? join(HOME(), "AppData", "Local"), scope, "Cache");
724
- }
725
- if (p === "darwin") {
726
- return join(HOME(), "Library", "Caches", scope);
727
- }
728
- return join(process.env.XDG_CACHE_HOME ?? join(HOME(), ".cache"), scope);
729
- },
730
- dataDir(scope) {
731
- const p = platform();
732
- if (p === "win32") {
733
- return join(process.env.LOCALAPPDATA ?? join(HOME(), "AppData", "Local"), scope);
734
- }
735
- if (p === "darwin") {
736
- return join(HOME(), "Library", "Application Support", scope);
737
- }
738
- return join(process.env.XDG_DATA_HOME ?? join(HOME(), ".local", "share"), scope);
739
- },
740
- tmpDir() {
741
- return tmpdir();
742
- },
743
- exeName(base) {
744
- return platform() === "win32" ? `${base}.exe` : base;
745
- }
746
- };
747
-
1
+ import { FULL_TRUST_CAPS } from "./contract/index.js";
2
+ import { createLifecycleHooks } from "./lifecycle/index.js";
3
+ import { a as runMultimode, i as pickOutputMode, n as redact, r as maybePrintJson, t as CliCommandBuilder } from "./cli-CGyu31Cn.js";
4
+ import { RoutesBuilder } from "./routes/index.js";
5
+ import { TelemetryEmitter } from "./telemetry/index.js";
6
+ import { BoundLogger } from "./log/index.js";
7
+ import { n as TypedStore, t as NamespaceStore } from "./storage-DkNBaJHC.js";
8
+ import { ConfigManager } from "./config/index.js";
9
+ import { findAvailablePort, gracefulKill, isProcessAlive, sleep } from "./subprocess/index.js";
10
+ import { HttpClient } from "./http/index.js";
11
+ import { ProviderRegistry, currentSupportedOS, provisionMetaProviders } from "./providers/index.js";
12
+ import { CONTEXT_PROVIDER_TYPE, getContextProvider, listContextProviders, registerContextProvider } from "./context/index.js";
13
+ import { AuditLogger } from "./audit/index.js";
14
+ import { BroadcastEmitter } from "./broadcast/index.js";
15
+ import { manualInstallHint, platformLabel } from "./host/os.js";
16
+ import { paths } from "./host/paths.js";
748
17
  export { AuditLogger, BoundLogger, BroadcastEmitter, CONTEXT_PROVIDER_TYPE, CliCommandBuilder, ConfigManager, FULL_TRUST_CAPS, HttpClient, NamespaceStore, ProviderRegistry, RoutesBuilder, TelemetryEmitter, TypedStore, createLifecycleHooks, currentSupportedOS, findAvailablePort, getContextProvider, gracefulKill, isProcessAlive, listContextProviders, manualInstallHint, maybePrintJson, paths, pickOutputMode, platformLabel, provisionMetaProviders, redact, registerContextProvider, runMultimode, sleep };
749
- //# sourceMappingURL=index.js.map
750
- //# sourceMappingURL=index.js.map