@vibecontrols/plugin-sdk 2026.531.2 → 2026.1107.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.
- package/README.md +24 -2
- package/dist/contract/index.d.ts +80 -3
- package/dist/host/os.d.ts +29 -3
- package/dist/host/os.js +11 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +34 -1
- package/dist/install/index.d.ts +54 -1
- package/dist/install/index.js +76 -1
- package/dist/providers/index.d.ts +20 -2
- package/dist/providers/index.js +23 -1
- package/package.json +54 -24
package/README.md
CHANGED
|
@@ -196,9 +196,31 @@ See `templates/plugin-scaffold.md` for the recommended layout.
|
|
|
196
196
|
|
|
197
197
|
## Contributing
|
|
198
198
|
|
|
199
|
+
The toolchain is Bun 1.4.4 (`.bun-version`) with
|
|
200
|
+
[`@burdenoff/toolchain`](https://www.npmjs.com/package/@burdenoff/toolchain)
|
|
201
|
+
(the `boff` CLI, the shared tsconfig and ESLint profiles).
|
|
202
|
+
|
|
203
|
+
Key commands:
|
|
204
|
+
|
|
205
|
+
| Command | What it does |
|
|
206
|
+
| --- | --- |
|
|
207
|
+
| `bun install` | Install dependencies (CI uses `bun install --frozen-lockfile`) |
|
|
208
|
+
| `bun run type:check` | Type check with `bun check` |
|
|
209
|
+
| `bun run lint` | ESLint (`@burdenoff/toolchain/eslint/node` profile) |
|
|
210
|
+
| `bun fmt` / `bun run format:check` | Format with `bun fmt` (reads `prettier.config.js`) / check only |
|
|
211
|
+
| `bun test` | Unit tests (`tests/**/*.test.ts`) |
|
|
212
|
+
| `bun run build` | Build `dist/` with tsup (ESM + `.d.ts`) |
|
|
213
|
+
| `bun run sanity` | `boff sanity`: format check, lint, type check, build, tests with the coverage gate, knip and `pack:check`; cached per step, so an unchanged tree re-runs in under a second (`bun run sanity:force` ignores the cache) |
|
|
214
|
+
|
|
199
215
|
1. `bun install`
|
|
200
|
-
2. `bun run sanity` must be green (0 errors, 0 warnings)
|
|
201
|
-
|
|
216
|
+
2. `bun run sanity` must be green (0 errors, 0 warnings). The lefthook
|
|
217
|
+
pre-push hook runs it too.
|
|
218
|
+
3. Trunk-based: `main` only. Every push to `main` publishes the next free
|
|
219
|
+
CalVer (`YYYY.MDD.PATCH`) to npm with provenance (`.github/workflows/release.yml`);
|
|
220
|
+
`gh workflow run release.yml -f version=YYYY.MDD.PATCH` releases an explicit
|
|
221
|
+
version. The release and PR workflows are vendored from
|
|
222
|
+
`algoshred/ci-workflows` (`.github/ci-workflows-vendor.json` lists them),
|
|
223
|
+
because a public repository cannot call private reusable workflows.
|
|
202
224
|
4. Integration docs: [`docs/integration/`](./docs/integration/) — start with [`INDEX.md`](./docs/integration/INDEX.md).
|
|
203
225
|
|
|
204
226
|
<!-- VIBECONTROLS_OSS_FOOTER_START -->
|
package/dist/contract/index.d.ts
CHANGED
|
@@ -33,10 +33,13 @@ type SupportedOS = "linux" | "darwin" | "win32";
|
|
|
33
33
|
/**
|
|
34
34
|
* Provider-registry type a META plugin's providers register under, mirroring
|
|
35
35
|
* the agent `ServiceRegistry`'s provider types. Declared on `MetaProviderRef`
|
|
36
|
-
* so
|
|
36
|
+
* so a META can ELECT a platform default (not merely install it) without
|
|
37
37
|
* having to scan every registry type to discover which one a provider owns.
|
|
38
|
+
*
|
|
39
|
+
* Kept in lockstep with the agent `ServiceRegistry` provider types
|
|
40
|
+
* (vibecontrols-agent/src/core/service-registry.ts).
|
|
38
41
|
*/
|
|
39
|
-
type ProviderType = "tunnel" | "session" | "ai" | "plan";
|
|
42
|
+
type ProviderType = "tunnel" | "session" | "ai" | "plan" | "gitops" | "security";
|
|
40
43
|
interface Prerequisite {
|
|
41
44
|
name: string;
|
|
42
45
|
kind: PrerequisiteKind;
|
|
@@ -148,6 +151,50 @@ interface SdkLogger {
|
|
|
148
151
|
error?(source: string, message: string, metadata?: Record<string, unknown>): void;
|
|
149
152
|
setLevel?(level: string): void;
|
|
150
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* The provisioning façade the agent injects into a META plugin's
|
|
156
|
+
* `provisionProviders` / `bootstrapTunnel` hooks. It lets a META install,
|
|
157
|
+
* load, prereq-install and elect ITS OWN provider plugins WITHOUT the agent
|
|
158
|
+
* enumerating providers — the agent only knows metas; metas drive providers.
|
|
159
|
+
*
|
|
160
|
+
* The agent gates this surface behind the capability proxy: only trusted/core
|
|
161
|
+
* META plugins receive a populated `plugins`. Untrusted plugins see it absent,
|
|
162
|
+
* so every member is optional and a META must defensively optional-chain.
|
|
163
|
+
*/
|
|
164
|
+
interface HostPlugins {
|
|
165
|
+
/**
|
|
166
|
+
* Install a provider package (npm) into the active install scope. Idempotent
|
|
167
|
+
* — a no-op when already installed unless `refreshLatest` forces `@latest`.
|
|
168
|
+
*/
|
|
169
|
+
install?(packageName: string, opts?: {
|
|
170
|
+
refreshLatest?: boolean;
|
|
171
|
+
}): Promise<void>;
|
|
172
|
+
/**
|
|
173
|
+
* Import + register + mount an already-installed provider, firing its
|
|
174
|
+
* `onServerStart` / `onServerReady`. After this resolves the provider's
|
|
175
|
+
* implementation is live in the agent `ServiceRegistry`.
|
|
176
|
+
*/
|
|
177
|
+
loadProvider?(packageName: string): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Drive a loaded plugin's `/prereqs/{status,install}` protocol so the
|
|
180
|
+
* provider installs its OWN binary/tool. `skipInstall` honours the
|
|
181
|
+
* operator's `--no-install-deps`. Returns whether prerequisites are satisfied.
|
|
182
|
+
*/
|
|
183
|
+
runPrereqs?(packageName: string, opts?: {
|
|
184
|
+
skipInstall?: boolean;
|
|
185
|
+
}): Promise<{
|
|
186
|
+
satisfied: boolean;
|
|
187
|
+
}>;
|
|
188
|
+
/**
|
|
189
|
+
* Elect `pluginName` as the registry default for `type`, respecting a prior
|
|
190
|
+
* user/operator override (never clobbers an explicit choice).
|
|
191
|
+
*/
|
|
192
|
+
electDefault?(type: ProviderType, pluginName: string): Promise<void>;
|
|
193
|
+
/** True if a provider of this `(type, pluginName)` is registered. */
|
|
194
|
+
isProviderRegistered?(type: ProviderType, pluginName: string): boolean;
|
|
195
|
+
/** True when the operator passed `--no-install-deps` (VIBE_SKIP_PREREQ_INSTALL=1). */
|
|
196
|
+
skipInstall?(): boolean;
|
|
197
|
+
}
|
|
151
198
|
/**
|
|
152
199
|
* The host surface a plugin can rely on. Every member is optional —
|
|
153
200
|
* downstream plugins must defensively use optional chaining or check
|
|
@@ -213,6 +260,14 @@ interface HostServices {
|
|
|
213
260
|
* Optional — older agents may not provide this; plugins must check.
|
|
214
261
|
*/
|
|
215
262
|
iframeBridge?: IframeBridge;
|
|
263
|
+
/**
|
|
264
|
+
* Provisioning façade — META plugins drive their OWN providers through this
|
|
265
|
+
* (install → loadProvider → runPrereqs → electDefault) inside their
|
|
266
|
+
* `provisionProviders` / `bootstrapTunnel` hooks. The agent injects it only
|
|
267
|
+
* for trusted/core metas (capability-gated); absent on older agents and for
|
|
268
|
+
* untrusted plugins. Optional — metas must defensively optional-chain.
|
|
269
|
+
*/
|
|
270
|
+
plugins?: HostPlugins;
|
|
216
271
|
}
|
|
217
272
|
/**
|
|
218
273
|
* Iframe-bridge primitives exposed by the agent host. Mirror the
|
|
@@ -309,6 +364,28 @@ interface VibePlugin {
|
|
|
309
364
|
* registration descriptor of the same short name.
|
|
310
365
|
*/
|
|
311
366
|
metaProviders?: ReadonlyArray<MetaProviderRef>;
|
|
367
|
+
/**
|
|
368
|
+
* META plugins ONLY. The agent calls this AFTER the meta's own
|
|
369
|
+
* `onServerStart`, in the background once the daemon reaches `ready`. The
|
|
370
|
+
* meta installs, loads, runs-prereqs-for and elects ITS OWN providers via
|
|
371
|
+
* `hostServices.plugins` — typically by delegating to the shared
|
|
372
|
+
* `provisionMetaProviders(host, this.metaProviders)` helper from
|
|
373
|
+
* `@vibecontrols/plugin-sdk/providers`. The agent enumerates NO provider
|
|
374
|
+
* here; it just fires this hook on each loaded meta. Best-effort — a throw
|
|
375
|
+
* never aborts boot.
|
|
376
|
+
*/
|
|
377
|
+
provisionProviders?: (hostServices: HostServices) => void | Promise<void>;
|
|
378
|
+
/**
|
|
379
|
+
* Tunnel META ONLY. Open a MINIMAL pre-registration tunnel and return its
|
|
380
|
+
* public URL (or null). The agent calls this BEFORE it has backend auth so
|
|
381
|
+
* it can register — breaking the chicken-and-egg (need a URL to register →
|
|
382
|
+
* need auth for the encrypted DB → need the DB for the real provider → need
|
|
383
|
+
* the provider for a URL). The meta installs+loads its platform-default
|
|
384
|
+
* tunnel provider in bootstrap mode and asks it for a quick-tunnel URL; the
|
|
385
|
+
* provider keeps the process alive for later adoption/handover. The agent
|
|
386
|
+
* never names cloudflared — the provider owns its binary + manifest.
|
|
387
|
+
*/
|
|
388
|
+
bootstrapTunnel?: (port: number, hostServices: HostServices) => Promise<string | null>;
|
|
312
389
|
/**
|
|
313
390
|
* Tunnel PROVIDER plugins only: the public DNS suffix(es) the tunnels this
|
|
314
391
|
* provider opens live under, e.g. `[".trycloudflare.com"]`. The agent adds
|
|
@@ -346,4 +423,4 @@ interface VibePlugin {
|
|
|
346
423
|
}
|
|
347
424
|
type VibePluginFactory = (ctx: ProfileContext) => VibePlugin;
|
|
348
425
|
|
|
349
|
-
export { FULL_TRUST_CAPS, type HostServices, type IframeBridge, type MetaProviderRef, type NukeResult, type PluginCapabilities, type PluginNukeContext, type PluginTag, type Prerequisite, type PrerequisiteKind, type ProfileContext, type ProviderType, type SdkLogger, type ServiceRegistry, type StorageProvider, type SupportedOS, type VibePlugin, type VibePluginFactory };
|
|
426
|
+
export { FULL_TRUST_CAPS, type HostPlugins, type HostServices, type IframeBridge, type MetaProviderRef, type NukeResult, type PluginCapabilities, type PluginNukeContext, type PluginTag, type Prerequisite, type PrerequisiteKind, type ProfileContext, type ProviderType, type SdkLogger, type ServiceRegistry, type StorageProvider, type SupportedOS, type VibePlugin, type VibePluginFactory };
|
package/dist/host/os.d.ts
CHANGED
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* HostServices follows.
|
|
13
13
|
*/
|
|
14
14
|
type SupportedPlatform = "linux" | "darwin" | "win32";
|
|
15
|
+
/** Human-readable OS label for operator-facing messages. */
|
|
16
|
+
type PlatformLabel = "macOS" | "Windows" | "Linux" | "WSL";
|
|
15
17
|
interface OsAdapter {
|
|
16
18
|
readonly platform?: SupportedPlatform;
|
|
17
19
|
readonly isWSL?: boolean;
|
|
@@ -21,12 +23,22 @@ interface OsAdapter {
|
|
|
21
23
|
readonly eol?: string;
|
|
22
24
|
/** Executable suffix ("" on POSIX, ".exe" on Windows). */
|
|
23
25
|
readonly executableSuffix?: string;
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Returns the absolute path to a command on PATH, or null when missing.
|
|
28
|
+
* The agent impl resolves against the LIVE `process.env.PATH` (not the
|
|
29
|
+
* startup snapshot Bun.which captures), so a tool installed mid-run is
|
|
30
|
+
* found. Pass `{ refreshPath: true }` to force re-reading the live PATH.
|
|
31
|
+
*/
|
|
32
|
+
which?(cmd: string, opts?: {
|
|
33
|
+
refreshPath?: boolean;
|
|
34
|
+
}): string | null;
|
|
26
35
|
isProcessAlive?(pid: number): boolean;
|
|
27
36
|
killProcessTree?(pid: number, signal: NodeJS.Signals): boolean;
|
|
28
37
|
listChildPids?(parentPid: number): number[];
|
|
38
|
+
/** npm global *bin* dir (`.../bin`) — where global executables land. */
|
|
29
39
|
npmGlobalBin?(): string | null;
|
|
40
|
+
/** npm global *root* dir (output of `npm root -g`) — where global packages install. */
|
|
41
|
+
npmGlobalRoot?(): string | null;
|
|
30
42
|
bunGlobalBin?(): string | null;
|
|
31
43
|
/** Quote a string for inclusion in a shell command on this OS. */
|
|
32
44
|
shellQuote?(value: string): string;
|
|
@@ -37,6 +49,20 @@ interface OsAdapter {
|
|
|
37
49
|
/** Build a Bun.spawn argv that runs a shell pipeline through the native shell. */
|
|
38
50
|
shellArgv?(script: string): string[];
|
|
39
51
|
processGroupSpawnOpts?(): Record<string, unknown>;
|
|
52
|
+
/** Human-readable OS label ("macOS"/"Windows"/"Linux"/"WSL") for messages. */
|
|
53
|
+
platformLabel?(): PlatformLabel;
|
|
40
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Pure helper: human-readable OS label. Use in operator-facing strings instead
|
|
57
|
+
* of inlining `process.platform === "win32" ? "Windows" : ...` ternaries.
|
|
58
|
+
*/
|
|
59
|
+
declare function platformLabel(p?: NodeJS.Platform, isWSL?: boolean): PlatformLabel;
|
|
60
|
+
/**
|
|
61
|
+
* Pure helper: pick the platform-appropriate manual-install instruction from a
|
|
62
|
+
* per-OS recipe map. Replaces the per-plugin `ttydManualInstall()` /
|
|
63
|
+
* `tmuxManualInstall()` platform switches that were copy-pasted across plugins.
|
|
64
|
+
* Falls back to the `linux` recipe when the current platform has no entry.
|
|
65
|
+
*/
|
|
66
|
+
declare function manualInstallHint(recipes: Partial<Record<SupportedPlatform, string>>, p?: NodeJS.Platform): string;
|
|
41
67
|
|
|
42
|
-
export type
|
|
68
|
+
export { type OsAdapter, type PlatformLabel, type SupportedPlatform, manualInstallHint, platformLabel };
|
package/dist/host/os.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
// src/host/os.ts
|
|
2
|
+
function platformLabel(p = process.platform, isWSL = false) {
|
|
3
|
+
if (p === "darwin") return "macOS";
|
|
4
|
+
if (p === "win32") return "Windows";
|
|
5
|
+
return isWSL ? "WSL" : "Linux";
|
|
6
|
+
}
|
|
7
|
+
function manualInstallHint(recipes, p = process.platform) {
|
|
8
|
+
const key = p === "darwin" || p === "win32" ? p : "linux";
|
|
9
|
+
return recipes[key] ?? recipes.linux ?? "";
|
|
10
|
+
}
|
|
1
11
|
|
|
12
|
+
export { manualInstallHint, platformLabel };
|
|
2
13
|
//# sourceMappingURL=os.js.map
|
|
3
14
|
//# sourceMappingURL=os.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { FULL_TRUST_CAPS, HostServices, MetaProviderRef, NukeResult, PluginCapabilities, PluginNukeContext, PluginTag, Prerequisite, PrerequisiteKind, ProfileContext, SdkLogger, ServiceRegistry, StorageProvider, SupportedOS, VibePlugin, VibePluginFactory } from './contract/index.js';
|
|
1
|
+
export { FULL_TRUST_CAPS, HostPlugins, HostServices, MetaProviderRef, NukeResult, PluginCapabilities, PluginNukeContext, PluginTag, Prerequisite, PrerequisiteKind, ProfileContext, ProviderType, SdkLogger, ServiceRegistry, StorageProvider, SupportedOS, VibePlugin, VibePluginFactory } from './contract/index.js';
|
|
2
2
|
export { LifecycleHooks, LifecycleSpec, createLifecycleHooks } from './lifecycle/index.js';
|
|
3
3
|
export { CliCommandBuilder, MultimodeOptions, OutputFlags, OutputMode, StatusCommandSpec, maybePrintJson, pickOutputMode, redact, runMultimode } from './cli/index.js';
|
|
4
4
|
export { ApiKeyResolver, RoutesBuilder } from './routes/index.js';
|
|
@@ -8,11 +8,11 @@ export { NamespaceStore, TypedStore } from './storage/index.js';
|
|
|
8
8
|
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
|
-
export { CliContribution, ProviderRegistry } from './providers/index.js';
|
|
11
|
+
export { CliContribution, ProviderRegistry, currentSupportedOS, provisionMetaProviders } from './providers/index.js';
|
|
12
12
|
export { CONTEXT_PROVIDER_TYPE, ContextContribution, ContextProvider, ContextRequest, getContextProvider, listContextProviders, registerContextProvider } from './context/index.js';
|
|
13
13
|
export { AuditLogger } from './audit/index.js';
|
|
14
14
|
export { BroadcastEmitter } from './broadcast/index.js';
|
|
15
|
-
export { OsAdapter, SupportedPlatform } from './host/os.js';
|
|
15
|
+
export { OsAdapter, PlatformLabel, SupportedPlatform, manualInstallHint, platformLabel } from './host/os.js';
|
|
16
16
|
export { PathHelpers, paths } from './host/paths.js';
|
|
17
17
|
import 'commander';
|
|
18
18
|
import 'elysia';
|
package/dist/index.js
CHANGED
|
@@ -564,6 +564,28 @@ function getContextProvider(name) {
|
|
|
564
564
|
}
|
|
565
565
|
|
|
566
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
|
+
}
|
|
567
589
|
var ProviderRegistry = class {
|
|
568
590
|
constructor(hostServices) {
|
|
569
591
|
this.hostServices = hostServices;
|
|
@@ -671,6 +693,17 @@ var BroadcastEmitter = class {
|
|
|
671
693
|
this.hostServices?.broadcast?.(type, payload);
|
|
672
694
|
}
|
|
673
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
|
+
}
|
|
674
707
|
var HOME = () => homedir();
|
|
675
708
|
var paths = {
|
|
676
709
|
homeDir: HOME,
|
|
@@ -712,6 +745,6 @@ var paths = {
|
|
|
712
745
|
}
|
|
713
746
|
};
|
|
714
747
|
|
|
715
|
-
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, paths, pickOutputMode, redact, registerContextProvider, runMultimode, sleep };
|
|
748
|
+
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 };
|
|
716
749
|
//# sourceMappingURL=index.js.map
|
|
717
750
|
//# sourceMappingURL=index.js.map
|
package/dist/install/index.d.ts
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
import { ChildProcess } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @vibecontrols/plugin-sdk/install
|
|
5
|
+
*
|
|
6
|
+
* Cross-platform binary auto-installer for provider plugins. A provider that
|
|
7
|
+
* needs an external binary (a tunnel daemon, a terminal server, …) ships a
|
|
8
|
+
* per-platform download manifest and calls `installBinary()` from its
|
|
9
|
+
* `/prereqs/install`. The binary lands in a stable per-machine cache that the
|
|
10
|
+
* provider resolves by ABSOLUTE PATH, so it is immune to the PATH snapshot
|
|
11
|
+
* `Bun.which()` takes at process start — a mid-run install is otherwise
|
|
12
|
+
* invisible to the daemon until a restart (notably on Windows, where a freshly
|
|
13
|
+
* installed tool's directory isn't on the running process's PATH at all).
|
|
14
|
+
*
|
|
15
|
+
* This keeps binary ownership inside the provider: the thin agent installs no
|
|
16
|
+
* provider tool itself; it only triggers the provider's `/prereqs` protocol.
|
|
17
|
+
*
|
|
18
|
+
* Resolution order: provider cache → $PATH (current env) → download.
|
|
19
|
+
* sha256 is OPTIONAL — when a manifest entry pins it, the download is verified
|
|
20
|
+
* before use; otherwise the HTTPS download plus an optional `--version` sanity
|
|
21
|
+
* check are the integrity gate.
|
|
22
|
+
*
|
|
23
|
+
* Cross-platform: pure node built-ins + Bun.which. Archive extraction shells
|
|
24
|
+
* out to `tar` (POSIX + Windows 10+) / `unzip` (POSIX, with a `tar.exe`
|
|
25
|
+
* fallback on Windows).
|
|
26
|
+
*/
|
|
27
|
+
|
|
1
28
|
type ToolPlatform = "linux-x64" | "linux-arm64" | "darwin-x64" | "darwin-arm64" | "win32-x64" | "win32-arm64";
|
|
2
29
|
declare function currentPlatform(): ToolPlatform;
|
|
3
30
|
interface BinaryDownload {
|
|
@@ -50,5 +77,31 @@ declare function resolveBinary(name: string, binaryName?: string, cacheRoot?: st
|
|
|
50
77
|
* exists for the current platform or the download fails.
|
|
51
78
|
*/
|
|
52
79
|
declare function installBinary(spec: InstallBinarySpec): Promise<string>;
|
|
80
|
+
/**
|
|
81
|
+
* Canonical cloudflared release-asset manifest. Imported by both the agent
|
|
82
|
+
* bootstrap and the cloudflare provider — the ONE source of truth for the
|
|
83
|
+
* binary the quick tunnel uses.
|
|
84
|
+
*/
|
|
85
|
+
declare const CLOUDFLARED_DOWNLOADS: Partial<Record<ToolPlatform, BinaryDownload>>;
|
|
86
|
+
interface QuickTunnel {
|
|
87
|
+
/** The advertised public quick-tunnel URL. */
|
|
88
|
+
url: string;
|
|
89
|
+
/** The spawned cloudflared child (caller owns its lifecycle / handover). */
|
|
90
|
+
child: ChildProcess;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Open a minimal cloudflared quick tunnel to `http://127.0.0.1:<port>` and
|
|
94
|
+
* resolve its public URL + child process. Installs cloudflared into the shared
|
|
95
|
+
* tools cache if needed (so a later provider `resolveBinary("cloudflared")`
|
|
96
|
+
* reuses it and ADOPTS this pid via `AGENT_TUNNEL_PID_*`). Storage-free and
|
|
97
|
+
* never throws — returns null on any failure so the caller can degrade and
|
|
98
|
+
* register once the provider starts. This is the agent's single deliberate
|
|
99
|
+
* pre-registration exception; the provider owns the full tunnel lifecycle
|
|
100
|
+
* post-registration.
|
|
101
|
+
*/
|
|
102
|
+
declare function openQuickTunnel(port: number, opts?: {
|
|
103
|
+
log?: InstallLogger;
|
|
104
|
+
timeoutMs?: number;
|
|
105
|
+
}): Promise<QuickTunnel | null>;
|
|
53
106
|
|
|
54
|
-
export { type BinaryDownload, type InstallBinarySpec, type InstallLogger, type ToolPlatform, cachedBinaryPath, currentPlatform, installBinary, resolveBinary, toolsCacheRoot };
|
|
107
|
+
export { type BinaryDownload, CLOUDFLARED_DOWNLOADS, type InstallBinarySpec, type InstallLogger, type QuickTunnel, type ToolPlatform, cachedBinaryPath, currentPlatform, installBinary, openQuickTunnel, resolveBinary, toolsCacheRoot };
|
package/dist/install/index.js
CHANGED
|
@@ -134,7 +134,82 @@ async function runProcess(cmd, args) {
|
|
|
134
134
|
child.on("error", reject);
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
|
+
var CLOUDFLARED_BASE = "https://github.com/cloudflare/cloudflared/releases/latest/download";
|
|
138
|
+
var CLOUDFLARED_DOWNLOADS = {
|
|
139
|
+
"linux-x64": { url: `${CLOUDFLARED_BASE}/cloudflared-linux-amd64`, archive: "raw" },
|
|
140
|
+
"linux-arm64": { url: `${CLOUDFLARED_BASE}/cloudflared-linux-arm64`, archive: "raw" },
|
|
141
|
+
"darwin-x64": {
|
|
142
|
+
url: `${CLOUDFLARED_BASE}/cloudflared-darwin-amd64.tgz`,
|
|
143
|
+
archive: "tar.gz",
|
|
144
|
+
binaryWithinArchive: "cloudflared"
|
|
145
|
+
},
|
|
146
|
+
"darwin-arm64": {
|
|
147
|
+
url: `${CLOUDFLARED_BASE}/cloudflared-darwin-arm64.tgz`,
|
|
148
|
+
archive: "tar.gz",
|
|
149
|
+
binaryWithinArchive: "cloudflared"
|
|
150
|
+
},
|
|
151
|
+
"win32-x64": { url: `${CLOUDFLARED_BASE}/cloudflared-windows-amd64.exe`, archive: "raw" },
|
|
152
|
+
"win32-arm64": { url: `${CLOUDFLARED_BASE}/cloudflared-windows-arm64.exe`, archive: "raw" }
|
|
153
|
+
};
|
|
154
|
+
var QUICK_TUNNEL_URL_RE = /(https:\/\/(?!api\.)[a-zA-Z0-9-]+\.trycloudflare\.com)/;
|
|
155
|
+
async function openQuickTunnel(port, opts) {
|
|
156
|
+
const log = opts?.log ?? {};
|
|
157
|
+
let cmd;
|
|
158
|
+
try {
|
|
159
|
+
cmd = await installBinary({
|
|
160
|
+
name: "cloudflared",
|
|
161
|
+
downloads: CLOUDFLARED_DOWNLOADS,
|
|
162
|
+
versionMatcher: "cloudflared version",
|
|
163
|
+
log
|
|
164
|
+
});
|
|
165
|
+
} catch (err) {
|
|
166
|
+
log.warn?.(`quick-tunnel: could not obtain cloudflared: ${String(err)}`);
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
let child;
|
|
170
|
+
try {
|
|
171
|
+
child = spawn(cmd, ["tunnel", "--url", `http://127.0.0.1:${port}`, "--no-autoupdate"], {
|
|
172
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
173
|
+
});
|
|
174
|
+
} catch (err) {
|
|
175
|
+
log.warn?.(`quick-tunnel: failed to spawn cloudflared: ${String(err)}`);
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
const url = await new Promise((resolve) => {
|
|
179
|
+
let settled = false;
|
|
180
|
+
const finish = (u) => {
|
|
181
|
+
if (settled) return;
|
|
182
|
+
settled = true;
|
|
183
|
+
resolve(u);
|
|
184
|
+
};
|
|
185
|
+
const timer = setTimeout(() => {
|
|
186
|
+
log.warn?.("quick-tunnel: cloudflared did not advertise a URL in time");
|
|
187
|
+
finish(null);
|
|
188
|
+
}, opts?.timeoutMs ?? 3e4);
|
|
189
|
+
const scan = (chunk) => {
|
|
190
|
+
const m = chunk.toString("utf8").match(QUICK_TUNNEL_URL_RE);
|
|
191
|
+
if (m) {
|
|
192
|
+
clearTimeout(timer);
|
|
193
|
+
finish(m[0]);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
child.stdout?.on("data", scan);
|
|
197
|
+
child.stderr?.on("data", scan);
|
|
198
|
+
child.on("error", (err) => {
|
|
199
|
+
clearTimeout(timer);
|
|
200
|
+
log.warn?.(`quick-tunnel: cloudflared failed to spawn: ${String(err)}`);
|
|
201
|
+
finish(null);
|
|
202
|
+
});
|
|
203
|
+
child.on("exit", (code) => {
|
|
204
|
+
clearTimeout(timer);
|
|
205
|
+
log.warn?.(`quick-tunnel: cloudflared exited (code=${code})`);
|
|
206
|
+
finish(null);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
if (!url) return null;
|
|
210
|
+
return { url, child };
|
|
211
|
+
}
|
|
137
212
|
|
|
138
|
-
export { cachedBinaryPath, currentPlatform, installBinary, resolveBinary, toolsCacheRoot };
|
|
213
|
+
export { CLOUDFLARED_DOWNLOADS, cachedBinaryPath, currentPlatform, installBinary, openQuickTunnel, resolveBinary, toolsCacheRoot };
|
|
139
214
|
//# sourceMappingURL=index.js.map
|
|
140
215
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HostServices, ServiceRegistry } from '../contract/index.js';
|
|
1
|
+
import { HostServices, ServiceRegistry, SupportedOS, MetaProviderRef } from '../contract/index.js';
|
|
2
2
|
import { ContextProvider } from '../context/index.js';
|
|
3
3
|
import '../host/os.js';
|
|
4
4
|
import '../host/paths.js';
|
|
@@ -15,6 +15,24 @@ interface CliContribution {
|
|
|
15
15
|
statusSections?: unknown[];
|
|
16
16
|
doctorChecks?: unknown[];
|
|
17
17
|
}
|
|
18
|
+
/** Map `process.platform` onto the SDK's `SupportedOS` union (defaults to linux). */
|
|
19
|
+
declare function currentSupportedOS(p?: NodeJS.Platform): SupportedOS;
|
|
20
|
+
/**
|
|
21
|
+
* The single, shared META→provider provisioning sequence. A META plugin calls
|
|
22
|
+
* this from its `provisionProviders` hook with its own `metaProviders`; the
|
|
23
|
+
* agent injects `host.plugins` (the provisioning façade). For each provider
|
|
24
|
+
* that is a platform default (`defaultOn` includes the current OS) this runs:
|
|
25
|
+
*
|
|
26
|
+
* install → loadProvider → runPrereqs → electDefault
|
|
27
|
+
*
|
|
28
|
+
* Opt-in providers (no `defaultOn` match) are skipped — they install on demand.
|
|
29
|
+
* Honours `host.plugins.skipInstall()` (operator `--no-install-deps`): providers
|
|
30
|
+
* are still loaded + elected, but no package/binary install is attempted.
|
|
31
|
+
* No-ops cleanly when `host.plugins` is absent (older agent / untrusted plugin).
|
|
32
|
+
* Best-effort and isolated per provider — one provider failing never aborts the
|
|
33
|
+
* others, so a META degrades gracefully rather than blocking boot.
|
|
34
|
+
*/
|
|
35
|
+
declare function provisionMetaProviders(host: HostServices, metaProviders: ReadonlyArray<MetaProviderRef> | undefined, platform?: SupportedOS): Promise<void>;
|
|
18
36
|
declare class ProviderRegistry {
|
|
19
37
|
private readonly hostServices?;
|
|
20
38
|
constructor(hostServices?: HostServices | undefined);
|
|
@@ -59,4 +77,4 @@ declare class ProviderRegistry {
|
|
|
59
77
|
withCliContribution(contribution: CliContribution): void;
|
|
60
78
|
}
|
|
61
79
|
|
|
62
|
-
export { type CliContribution, ProviderRegistry };
|
|
80
|
+
export { type CliContribution, ProviderRegistry, currentSupportedOS, provisionMetaProviders };
|
package/dist/providers/index.js
CHANGED
|
@@ -27,6 +27,28 @@ function getContextProvider(name) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// src/providers/index.ts
|
|
30
|
+
function currentSupportedOS(p = process.platform) {
|
|
31
|
+
if (p === "darwin") return "darwin";
|
|
32
|
+
if (p === "win32") return "win32";
|
|
33
|
+
return "linux";
|
|
34
|
+
}
|
|
35
|
+
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
|
+
}
|
|
51
|
+
}
|
|
30
52
|
var ProviderRegistry = class {
|
|
31
53
|
constructor(hostServices) {
|
|
32
54
|
this.hostServices = hostServices;
|
|
@@ -108,6 +130,6 @@ var ProviderRegistry = class {
|
|
|
108
130
|
}
|
|
109
131
|
};
|
|
110
132
|
|
|
111
|
-
export { ProviderRegistry };
|
|
133
|
+
export { ProviderRegistry, currentSupportedOS, provisionMetaProviders };
|
|
112
134
|
//# sourceMappingURL=index.js.map
|
|
113
135
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibecontrols/plugin-sdk",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.1107.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.
|
|
7
|
+
"bun": ">=1.4.4"
|
|
8
8
|
},
|
|
9
9
|
"author": {
|
|
10
10
|
"name": "Vignesh T.V",
|
|
@@ -100,32 +100,29 @@
|
|
|
100
100
|
"scripts": {
|
|
101
101
|
"dev": "tsup --watch",
|
|
102
102
|
"build": "tsup",
|
|
103
|
-
"lint": "eslint ./src ./tests",
|
|
104
|
-
"lint:sanity": "if [ \"${CI:-}\" = \"true\" ]; then bun run lint -- --max-warnings 0; else bun run lint -- --max-warnings 0 --cache --cache-location .eslintcache; fi",
|
|
105
|
-
"format": "prettier . --write",
|
|
106
|
-
"format:check": "prettier . --check",
|
|
107
|
-
"type:check": "tsc --noEmit",
|
|
108
|
-
"test": "bun test tests/**/*.test.ts",
|
|
109
103
|
"knip": "knip --reporter compact",
|
|
110
|
-
"clean": "
|
|
104
|
+
"clean": "rm -rf dist coverage .eslintcache",
|
|
111
105
|
"prebuild": "bun run clean",
|
|
112
106
|
"pack:check": "npm pack --dry-run",
|
|
113
|
-
"
|
|
107
|
+
"type:check": "boff gate -- bun check --no-pretty",
|
|
108
|
+
"format": "bun fmt src tests tsup.config.ts eslint.config.js prettier.config.js",
|
|
109
|
+
"format:check": "bun fmt --check src tests tsup.config.ts eslint.config.js prettier.config.js",
|
|
110
|
+
"lint": "eslint .",
|
|
111
|
+
"test": "bun test",
|
|
112
|
+
"sanity": "boff sanity",
|
|
113
|
+
"sanity:force": "boff sanity --force",
|
|
114
|
+
"audit": "bun audit --audit-level=high"
|
|
114
115
|
},
|
|
115
116
|
"devDependencies": {
|
|
116
|
-
"@
|
|
117
|
-
"@types/bun": "^1.
|
|
117
|
+
"@burdenoff/toolchain": "2026.1107.14",
|
|
118
|
+
"@types/bun": "^1.4.4",
|
|
118
119
|
"commander": "^14.0.3",
|
|
119
|
-
"elysia": "
|
|
120
|
-
"eslint": "^
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"
|
|
125
|
-
"rimraf": "^6.1.3",
|
|
126
|
-
"tsup": "^8.5.0",
|
|
127
|
-
"typescript": "^5.9.3",
|
|
128
|
-
"typescript-eslint": "^8.56.0"
|
|
120
|
+
"elysia": "~1.4.31",
|
|
121
|
+
"eslint": "^9.39.5",
|
|
122
|
+
"knip": "^6.44.2",
|
|
123
|
+
"lefthook": "^2.2.2",
|
|
124
|
+
"tsup": "^8.5.1",
|
|
125
|
+
"typescript": "^5.9.3"
|
|
129
126
|
},
|
|
130
127
|
"peerDependencies": {
|
|
131
128
|
"commander": ">=14.0.0",
|
|
@@ -147,7 +144,7 @@
|
|
|
147
144
|
],
|
|
148
145
|
"repository": {
|
|
149
146
|
"type": "git",
|
|
150
|
-
"url": "git+https://github.com/
|
|
147
|
+
"url": "git+https://github.com/Algoshred/vibecontrols-plugin-sdk.git"
|
|
151
148
|
},
|
|
152
149
|
"bugs": {
|
|
153
150
|
"url": "https://github.com/algoshred/vibecontrols-plugin-sdk/issues"
|
|
@@ -178,5 +175,38 @@
|
|
|
178
175
|
"yaml": ">=2.8.3",
|
|
179
176
|
"picomatch": ">=2.3.2",
|
|
180
177
|
"minimatch": ">=3.1.3"
|
|
181
|
-
}
|
|
178
|
+
},
|
|
179
|
+
"packageManager": "bun@1.4.4",
|
|
180
|
+
"boff": {
|
|
181
|
+
"type": "lib",
|
|
182
|
+
"sanity": {
|
|
183
|
+
"steps": [
|
|
184
|
+
"format",
|
|
185
|
+
"lint",
|
|
186
|
+
"typecheck",
|
|
187
|
+
"build",
|
|
188
|
+
"test",
|
|
189
|
+
"knip"
|
|
190
|
+
],
|
|
191
|
+
"extra": [
|
|
192
|
+
"pack:check"
|
|
193
|
+
],
|
|
194
|
+
"formatPaths": [
|
|
195
|
+
"src",
|
|
196
|
+
"tests",
|
|
197
|
+
"tsup.config.ts",
|
|
198
|
+
"eslint.config.js",
|
|
199
|
+
"prettier.config.js"
|
|
200
|
+
]
|
|
201
|
+
},
|
|
202
|
+
"coverage": {
|
|
203
|
+
"lines": 92,
|
|
204
|
+
"functions": 72,
|
|
205
|
+
"diff": 80
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
"trustedDependencies": [
|
|
209
|
+
"esbuild",
|
|
210
|
+
"lefthook"
|
|
211
|
+
]
|
|
182
212
|
}
|