@vibesdotdev/runtime-environment-bun 0.0.0

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 (86) hide show
  1. package/dist/bun-environment.impl.d.ts +71 -0
  2. package/dist/bun-environment.impl.d.ts.map +1 -0
  3. package/dist/bun-environment.impl.js +130 -0
  4. package/dist/bun-environment.impl.js.map +1 -0
  5. package/dist/bun-loader.impl.d.ts +12 -0
  6. package/dist/bun-loader.impl.d.ts.map +1 -0
  7. package/dist/bun-loader.impl.js +96 -0
  8. package/dist/bun-loader.impl.js.map +1 -0
  9. package/dist/discovery/discovery.assets.consumer.d.ts +13 -0
  10. package/dist/discovery/discovery.assets.consumer.d.ts.map +1 -0
  11. package/dist/discovery/discovery.assets.consumer.js +116 -0
  12. package/dist/discovery/discovery.assets.consumer.js.map +1 -0
  13. package/dist/host/host.consumer.d.ts +12 -0
  14. package/dist/host/host.consumer.d.ts.map +1 -0
  15. package/dist/host/host.consumer.js +13 -0
  16. package/dist/host/host.consumer.js.map +1 -0
  17. package/dist/index.d.ts +49 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +77 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/loaders/fallback-loader.impl.consumer.d.ts +7 -0
  22. package/dist/loaders/fallback-loader.impl.consumer.d.ts.map +1 -0
  23. package/dist/loaders/fallback-loader.impl.consumer.js +63 -0
  24. package/dist/loaders/fallback-loader.impl.consumer.js.map +1 -0
  25. package/dist/package-plugins/candidates.consumer.d.ts +8 -0
  26. package/dist/package-plugins/candidates.consumer.d.ts.map +1 -0
  27. package/dist/package-plugins/candidates.consumer.js +133 -0
  28. package/dist/package-plugins/candidates.consumer.js.map +1 -0
  29. package/dist/package-plugins/import-module.consumer.d.ts +14 -0
  30. package/dist/package-plugins/import-module.consumer.d.ts.map +1 -0
  31. package/dist/package-plugins/import-module.consumer.js +28 -0
  32. package/dist/package-plugins/import-module.consumer.js.map +1 -0
  33. package/dist/package-plugins/index.d.ts +8 -0
  34. package/dist/package-plugins/index.d.ts.map +1 -0
  35. package/dist/package-plugins/index.js +8 -0
  36. package/dist/package-plugins/index.js.map +1 -0
  37. package/dist/package-plugins/installer.consumer.d.ts +14 -0
  38. package/dist/package-plugins/installer.consumer.d.ts.map +1 -0
  39. package/dist/package-plugins/installer.consumer.js +29 -0
  40. package/dist/package-plugins/installer.consumer.js.map +1 -0
  41. package/dist/package-plugins/loader.consumer.d.ts +12 -0
  42. package/dist/package-plugins/loader.consumer.d.ts.map +1 -0
  43. package/dist/package-plugins/loader.consumer.js +59 -0
  44. package/dist/package-plugins/loader.consumer.js.map +1 -0
  45. package/dist/package-plugins/reporting.d.ts +5 -0
  46. package/dist/package-plugins/reporting.d.ts.map +1 -0
  47. package/dist/package-plugins/reporting.js +10 -0
  48. package/dist/package-plugins/reporting.js.map +1 -0
  49. package/dist/package-plugins/resolve.consumer.d.ts +22 -0
  50. package/dist/package-plugins/resolve.consumer.d.ts.map +1 -0
  51. package/dist/package-plugins/resolve.consumer.js +265 -0
  52. package/dist/package-plugins/resolve.consumer.js.map +1 -0
  53. package/dist/process-spawn.impl.d.ts +15 -0
  54. package/dist/process-spawn.impl.d.ts.map +1 -0
  55. package/dist/process-spawn.impl.js +41 -0
  56. package/dist/process-spawn.impl.js.map +1 -0
  57. package/dist/services/runtime-path.impl.d.ts +20 -0
  58. package/dist/services/runtime-path.impl.d.ts.map +1 -0
  59. package/dist/services/runtime-path.impl.js +20 -0
  60. package/dist/services/runtime-path.impl.js.map +1 -0
  61. package/dist/services/self-spawn.consumer.d.ts +55 -0
  62. package/dist/services/self-spawn.consumer.d.ts.map +1 -0
  63. package/dist/services/self-spawn.consumer.js +85 -0
  64. package/dist/services/self-spawn.consumer.js.map +1 -0
  65. package/dist/services/workspace-resolve.d.ts +84 -0
  66. package/dist/services/workspace-resolve.d.ts.map +1 -0
  67. package/dist/services/workspace-resolve.js +107 -0
  68. package/dist/services/workspace-resolve.js.map +1 -0
  69. package/package.json +66 -0
  70. package/src/bun-environment.impl.ts +179 -0
  71. package/src/bun-loader.impl.ts +102 -0
  72. package/src/discovery/discovery.assets.consumer.ts +135 -0
  73. package/src/host/host.consumer.ts +23 -0
  74. package/src/index.ts +92 -0
  75. package/src/loaders/fallback-loader.impl.consumer.ts +57 -0
  76. package/src/package-plugins/candidates.consumer.ts +133 -0
  77. package/src/package-plugins/import-module.consumer.ts +27 -0
  78. package/src/package-plugins/index.ts +8 -0
  79. package/src/package-plugins/installer.consumer.ts +38 -0
  80. package/src/package-plugins/loader.consumer.ts +80 -0
  81. package/src/package-plugins/reporting.ts +13 -0
  82. package/src/package-plugins/resolve.consumer.ts +292 -0
  83. package/src/process-spawn.impl.ts +52 -0
  84. package/src/services/runtime-path.impl.ts +20 -0
  85. package/src/services/self-spawn.consumer.ts +91 -0
  86. package/src/services/workspace-resolve.ts +146 -0
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Bun Runtime Environment Implementation
3
+ *
4
+ * Captures environment at construction and provides Bun-specific
5
+ * implementations for scope, env access, secrets, and module loading.
6
+ */
7
+ import type { RuntimeDiscoveryConfig, RuntimeDiscoveryProvider, RuntimeEnvironmentImplementation, RuntimeLoaderImplementation } from '@vibesdotdev/runtime';
8
+ import type { RuntimeScope, TenancyConfig } from '@vibesdotdev/runtime';
9
+ export interface BunEnvironmentOptions {
10
+ /** Surface override (default: detected from env) */
11
+ surface?: string;
12
+ /** Hardware override (default: detected from env) */
13
+ hardware?: string;
14
+ /** Purpose override (default: detected from env) */
15
+ purpose?: string;
16
+ /** Tenancy configuration */
17
+ tenancy?: TenancyConfig;
18
+ /** Dev mode flag */
19
+ dev?: boolean;
20
+ /** Whether daemon endpoints/process features should be enabled for this runtime */
21
+ daemon?: boolean;
22
+ /** Optional discovery defaults for this environment capability */
23
+ discoveryDefaults?: RuntimeDiscoveryConfig;
24
+ /** Optional discovery provider override for this environment capability */
25
+ discoveryProvider?: RuntimeDiscoveryProvider;
26
+ }
27
+ export declare class BunEnvironment implements RuntimeEnvironmentImplementation {
28
+ readonly id: string;
29
+ readonly description: string;
30
+ readonly capabilities: Record<string, boolean>;
31
+ readonly scope: RuntimeScope;
32
+ readonly loader: RuntimeLoaderImplementation;
33
+ readonly discovery: {
34
+ readonly defaults: RuntimeDiscoveryConfig;
35
+ readonly provider?: RuntimeDiscoveryProvider;
36
+ };
37
+ private _envSnapshot;
38
+ constructor(options?: BunEnvironmentOptions);
39
+ /**
40
+ * Capture environment variables at construction time.
41
+ * This is the ONLY place process.env is accessed.
42
+ */
43
+ private _captureEnv;
44
+ /**
45
+ * Return the env snapshot, healing it if a cross-module or partially
46
+ * initialized BunEnvironment instance was attached to the runtime.
47
+ * This makes `dev mcp serve` (and other heavy CLI commands) robust when
48
+ * reusing the runtime created by createVibesCliApp.
49
+ */
50
+ private _getSnapshot;
51
+ /**
52
+ * Build runtime scope from captured environment.
53
+ */
54
+ private _buildScope;
55
+ private _detectDaemonCapability;
56
+ private _detectSurface;
57
+ private _detectHardware;
58
+ private _detectPurpose;
59
+ /**
60
+ * Get environment variable from captured snapshot.
61
+ * No direct process.env access.
62
+ */
63
+ getEnv(key: string): string | undefined;
64
+ /**
65
+ * Get secret value.
66
+ * Bun doesn't have a secrets API, so this falls back to env.
67
+ * Cloudflare environment will use CF Secrets Store.
68
+ */
69
+ getSecret(key: string): Promise<string | undefined>;
70
+ }
71
+ //# sourceMappingURL=bun-environment.impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bun-environment.impl.d.ts","sourceRoot":"","sources":["../src/bun-environment.impl.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACX,sBAAsB,EACtB,wBAAwB,EACxB,gCAAgC,EAChC,2BAA2B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIxE,MAAM,WAAW,qBAAqB;IACrC,oDAAoD;IACpD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EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CAGzD"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Bun Runtime Environment Implementation
3
+ *
4
+ * Captures environment at construction and provides Bun-specific
5
+ * implementations for scope, env access, secrets, and module loading.
6
+ */
7
+ import { BunLoader } from './bun-loader.impl';
8
+ import { bunRuntimePath } from './services/runtime-path.impl';
9
+ export class BunEnvironment {
10
+ id;
11
+ description;
12
+ capabilities;
13
+ scope;
14
+ loader;
15
+ discovery;
16
+ _envSnapshot;
17
+ constructor(options = {}) {
18
+ this.id = 'bun';
19
+ this.description = 'Bun runtime environment';
20
+ // Capture env snapshot FIRST - required for any _detect* methods below
21
+ this._envSnapshot = this._captureEnv();
22
+ const daemon = this._detectDaemonCapability(options);
23
+ this.capabilities = {
24
+ esm: true,
25
+ typescript: true,
26
+ nativeLoader: true,
27
+ secrets: false,
28
+ daemon
29
+ };
30
+ // Build scope from captured env + options
31
+ this.scope = this._buildScope(options);
32
+ // Create Bun-specific loader
33
+ this.loader = new BunLoader();
34
+ this.discovery = {
35
+ defaults: options.discoveryDefaults ?? {
36
+ basePaths: [process.cwd()],
37
+ skipPlugins: false,
38
+ respectGitignore: true
39
+ },
40
+ ...(options.discoveryProvider ? { provider: options.discoveryProvider } : {})
41
+ };
42
+ }
43
+ /**
44
+ * Capture environment variables at construction time.
45
+ * This is the ONLY place process.env is accessed.
46
+ */
47
+ _captureEnv() {
48
+ const captured = {};
49
+ if (typeof process !== 'undefined' && process.env) {
50
+ for (const [key, value] of Object.entries(process.env)) {
51
+ if (typeof value === 'string') {
52
+ captured[key] = value;
53
+ }
54
+ }
55
+ }
56
+ return captured;
57
+ }
58
+ /**
59
+ * Return the env snapshot, healing it if a cross-module or partially
60
+ * initialized BunEnvironment instance was attached to the runtime.
61
+ * This makes `dev mcp serve` (and other heavy CLI commands) robust when
62
+ * reusing the runtime created by createVibesCliApp.
63
+ */
64
+ _getSnapshot() {
65
+ if (!this._envSnapshot) {
66
+ this._envSnapshot = this._captureEnv();
67
+ }
68
+ return this._envSnapshot;
69
+ }
70
+ /**
71
+ * Build runtime scope from captured environment.
72
+ */
73
+ _buildScope(options) {
74
+ const surface = options.surface ?? this._detectSurface();
75
+ const hardware = options.hardware ?? this._detectHardware();
76
+ const purpose = options.purpose ?? this._detectPurpose();
77
+ const snap = this._getSnapshot();
78
+ const dev = options.dev ?? (snap.NODE_ENV !== 'production');
79
+ const daemon = this._detectDaemonCapability(options, surface, hardware);
80
+ return {
81
+ surface,
82
+ hardware,
83
+ purpose,
84
+ capabilities: {
85
+ daemon
86
+ },
87
+ qualifiers: {
88
+ dev,
89
+ ...(options.tenancy?.teamId && { teamId: options.tenancy.teamId })
90
+ },
91
+ tenancy: options.tenancy
92
+ };
93
+ }
94
+ _detectDaemonCapability(options, surface, hardware) {
95
+ if (typeof options.daemon === 'boolean')
96
+ return options.daemon;
97
+ const snap = this._getSnapshot();
98
+ if (snap.VIBES_RUNTIME_DAEMON === '1' || snap.VIBES_DAEMON === '1') {
99
+ return true;
100
+ }
101
+ const resolvedSurface = surface ?? options.surface ?? this._detectSurface();
102
+ const resolvedHardware = hardware ?? options.hardware ?? this._detectHardware();
103
+ return resolvedSurface === 'daemon' || resolvedHardware === 'consumer';
104
+ }
105
+ _detectSurface() {
106
+ return this._getSnapshot().VIBES_SURFACE ?? 'ssr';
107
+ }
108
+ _detectHardware() {
109
+ return this._getSnapshot().VIBES_HARDWARE ?? 'consumer';
110
+ }
111
+ _detectPurpose() {
112
+ return this._getSnapshot().VIBES_PURPOSE ?? 'direct';
113
+ }
114
+ /**
115
+ * Get environment variable from captured snapshot.
116
+ * No direct process.env access.
117
+ */
118
+ getEnv(key) {
119
+ return this._getSnapshot()[key];
120
+ }
121
+ /**
122
+ * Get secret value.
123
+ * Bun doesn't have a secrets API, so this falls back to env.
124
+ * Cloudflare environment will use CF Secrets Store.
125
+ */
126
+ async getSecret(key) {
127
+ return this._getSnapshot()[key];
128
+ }
129
+ }
130
+ //# sourceMappingURL=bun-environment.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bun-environment.impl.js","sourceRoot":"","sources":["../src/bun-environment.impl.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAqB9D,MAAM,OAAO,cAAc;IACjB,EAAE,CAAS;IACX,WAAW,CAAS;IACpB,YAAY,CAA0B;IACtC,KAAK,CAAe;IACpB,MAAM,CAA8B;IACpC,SAAS,CAGhB;IAEM,YAAY,CAAqC;IAEzD,YAAY,UAAiC,EAAE;QAC9C,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC;QAChB,IAAI,CAAC,WAAW,GAAG,yBAAyB,CAAC;QAE7C,uEAAuE;QACvE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEvC,MAAM,MAAM,GAAG,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;QACrD,IAAI,CAAC,YAAY,GAAG;YACnB,GAAG,EAAE,IAAI;YACT,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;YAClB,OAAO,EAAE,KAAK;YACd,MAAM;SACN,CAAC;QAEF,0CAA0C;QAC1C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAEvC,6BAA6B;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG;YAChB,QAAQ,EAAE,OAAO,CAAC,iBAAiB,IAAI;gBACtC,SAAS,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;gBAC1B,WAAW,EAAE,KAAK;gBAClB,gBAAgB,EAAE,IAAI;aACtB;YACD,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,QA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,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,SAAS,CAAC,GAAW;QAC1B,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;CACD"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Bun Loader Implementation
3
+ *
4
+ * Uses Bun.import() for module loading with native ESM support.
5
+ */
6
+ import type { RuntimeLoaderImplementation, RuntimeLoaderModuleMaps, RuntimeLoaderOptions, RuntimeLoaderKindDiscoveryOptions } from '@vibesdotdev/runtime';
7
+ import type { RuntimeDescriptor } from '@vibesdotdev/runtime';
8
+ export declare class BunLoader implements RuntimeLoaderImplementation {
9
+ loadModules(options: RuntimeLoaderOptions): Promise<RuntimeLoaderModuleMaps>;
10
+ discoverKindDescriptors(options: RuntimeLoaderKindDiscoveryOptions): Promise<RuntimeDescriptor[]>;
11
+ }
12
+ //# sourceMappingURL=bun-loader.impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bun-loader.impl.d.ts","sourceRoot":"","sources":["../src/bun-loader.impl.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACX,2BAA2B,EAC3B,uBAAuB,EACvB,oBAAoB,EACpB,iCAAiC,EACjC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAI9D,qBAAa,SAAU,YAAW,2BAA2B;IACtD,WAAW,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAqD5E,uBAAuB,CAC5B,OAAO,EAAE,iCAAiC,GACxC,OAAO,CAAC,iBAAiB,EAAE,CAAC;CA6B/B"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Bun Loader Implementation
3
+ *
4
+ * Uses Bun.import() for module loading with native ESM support.
5
+ */
6
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
7
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
8
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
9
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
10
+ });
11
+ }
12
+ return path;
13
+ };
14
+ import { Glob } from 'bun';
15
+ import { join, basename } from 'path';
16
+ export class BunLoader {
17
+ async loadModules(options) {
18
+ const { scope, discovery } = options;
19
+ const basePaths = discovery?.basePaths ?? [process.cwd()];
20
+ const patterns = discovery?.patterns ?? {
21
+ plugin: '**/*.plugin.ts',
22
+ descriptor: '**/*.descriptor*.ts',
23
+ implementation: '**/*.impl*.ts*'
24
+ };
25
+ const result = {
26
+ plugins: {},
27
+ descriptors: {},
28
+ implementations: {}
29
+ };
30
+ for (const basePath of basePaths) {
31
+ // Load plugins
32
+ const pluginGlob = new Glob(patterns.plugin ?? '**/*.plugin.ts');
33
+ const pluginFiles = [];
34
+ for await (const file of pluginGlob.scan({ cwd: basePath, absolute: true })) {
35
+ if (file)
36
+ pluginFiles.push(file);
37
+ }
38
+ for (const file of pluginFiles) {
39
+ const fullPath = join(basePath, file);
40
+ result.plugins[fullPath] = () => import(__rewriteRelativeImportExtension(fullPath));
41
+ }
42
+ // Load descriptors
43
+ const descriptorGlob = new Glob(patterns.descriptor ?? '**/*.descriptor*.ts');
44
+ const descriptorFiles = [];
45
+ for await (const file of descriptorGlob.scan({ cwd: basePath, absolute: true })) {
46
+ if (file)
47
+ descriptorFiles.push(file);
48
+ }
49
+ for (const file of descriptorFiles) {
50
+ const fullPath = join(basePath, file);
51
+ result.descriptors[fullPath] = () => import(__rewriteRelativeImportExtension(fullPath));
52
+ }
53
+ // Load implementations
54
+ const implGlob = new Glob(patterns.implementation ?? '**/*.impl*.ts*');
55
+ const implFiles = [];
56
+ for await (const file of implGlob.scan({ cwd: basePath, absolute: true })) {
57
+ if (file)
58
+ implFiles.push(file);
59
+ }
60
+ for (const file of implFiles) {
61
+ const fullPath = join(basePath, file);
62
+ result.implementations[fullPath] = () => import(__rewriteRelativeImportExtension(fullPath));
63
+ }
64
+ }
65
+ return result;
66
+ }
67
+ async discoverKindDescriptors(options) {
68
+ const { scope, discovery, kindPatterns } = options;
69
+ const basePaths = discovery?.basePaths ?? [process.cwd()];
70
+ const descriptors = [];
71
+ for (const kindPattern of kindPatterns) {
72
+ const glob = new Glob(kindPattern.pattern);
73
+ for (const basePath of basePaths) {
74
+ for await (const file of glob.scan({ cwd: basePath, absolute: true })) {
75
+ const fullPath = join(basePath, file);
76
+ try {
77
+ const module = await import(__rewriteRelativeImportExtension(fullPath));
78
+ if (module.default) {
79
+ const descriptor = module.default;
80
+ if (descriptor.kind === kindPattern.kindId) {
81
+ descriptors.push(descriptor);
82
+ }
83
+ }
84
+ }
85
+ catch (error) {
86
+ if (discovery?.debug) {
87
+ console.warn(`Failed to load descriptor ${fullPath}:`, error);
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ return descriptors;
94
+ }
95
+ }
96
+ //# sourceMappingURL=bun-loader.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bun-loader.impl.js","sourceRoot":"","sources":["../src/bun-loader.impl.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;;;AASH,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEtC,MAAM,OAAO,SAAS;IACrB,KAAK,CAAC,WAAW,CAAC,OAA6B;QAC9C,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;QACrC,MAAM,SAAS,GAAG,SAAS,EAAE,SAAS,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC1D,MAAM,QAAQ,GAAG,SAAS,EAAE,QAAQ,IAAI;YACvC,MAAM,EAAE,gBAA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AI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAW,CAAC,EAAE,CAAC;oBAChF,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAK,CAAC,CAAC;oBACvC,IAAI,CAAC;wBACJ,MAAM,MAAM,GAAG,MAAM,MAAM,kCAAC,QAAQ,EAAC,CAAC;wBACtC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;4BACpB,MAAM,UAAU,GAAG,MAAM,CAAC,OAA4B,CAAC;4BACvD,IAAI,UAAU,CAAC,IAAI,KAAK,WAAW,CAAC,MAAM,EAAE,CAAC;gCAC5C,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;4BAC9B,CAAC;wBACF,CAAC;oBACF,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBAChB,IAAI,SAAS,EAAE,KAAK,EAAE,CAAC;4BACtB,OAAO,CAAC,IAAI,CAAC,6BAA6B,QAAQ,GAAG,EAAE,KAAK,CAAC,CAAC;wBAC/D,CAAC;oBACF,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO,WAAW,CAAC;IACpB,CAAC;CACD"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Plugin Asset Discovery
3
+ *
4
+ * Scans the filesystem for descriptor and implementation files,
5
+ * registers descriptors eagerly, and implementations as lazy loaders.
6
+ * Consumer/Bun-only helper for plugin-local asset discovery.
7
+ */
8
+ import type { RuntimeRef } from '@vibesdotdev/runtime/factory/plugin';
9
+ export declare function discoverAssets(runtime: RuntimeRef, baseUrl: string | undefined, kindPatterns: Record<string, string | string[]>): Promise<{
10
+ descriptors: number;
11
+ loaders: number;
12
+ }>;
13
+ //# sourceMappingURL=discovery.assets.consumer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.assets.consumer.d.ts","sourceRoot":"","sources":["../../src/discovery/discovery.assets.consumer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAWtE,wBAAsB,cAAc,CACnC,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,GAC7C,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAwEnD"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Plugin Asset Discovery
3
+ *
4
+ * Scans the filesystem for descriptor and implementation files,
5
+ * registers descriptors eagerly, and implementations as lazy loaders.
6
+ * Consumer/Bun-only helper for plugin-local asset discovery.
7
+ */
8
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
9
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
10
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
11
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
12
+ });
13
+ }
14
+ return path;
15
+ };
16
+ import { fileURLToPath } from 'node:url';
17
+ import { dirname, resolve } from 'node:path';
18
+ import { extractDescriptorStem, parseImplFilename } from '@vibesdotdev/runtime/discovery/scope-parser';
19
+ export async function discoverAssets(runtime, baseUrl, kindPatterns) {
20
+ // Filesystem asset discovery requires a real `file://` base URL. In workerd
21
+ // and other non-filesystem runtimes `import.meta.url` is undefined, so
22
+ // the caller can't give us a baseUrl. Short-circuit instead of throwing.
23
+ if (typeof baseUrl !== 'string' || baseUrl.length === 0) {
24
+ return { descriptors: 0, loaders: 0 };
25
+ }
26
+ if (baseUrl.includes('/$bunfs/') || baseUrl.includes('/$bun/')) {
27
+ return { descriptors: 0, loaders: 0 };
28
+ }
29
+ const baseDir = dirname(fileURLToPath(baseUrl));
30
+ let descriptors = 0;
31
+ let loaders = 0;
32
+ for (const [kind, rawPatterns] of Object.entries(kindPatterns)) {
33
+ const patterns = Array.isArray(rawPatterns) ? rawPatterns : [rawPatterns];
34
+ const files = scanPatterns(patterns, baseDir);
35
+ const descriptorFiles = files.filter((f) => f.includes('.descriptor.'));
36
+ const implFiles = files.filter((f) => f.includes('.impl.'));
37
+ for (const file of descriptorFiles) {
38
+ try {
39
+ const absPath = resolve(baseDir, file);
40
+ const mod = await import(__rewriteRelativeImportExtension(absPath));
41
+ const desc = mod.default;
42
+ if (!desc || !desc.id)
43
+ continue;
44
+ const descKind = desc.kind ?? kind;
45
+ runtime.registerDescriptor(descKind, desc);
46
+ descriptors++;
47
+ const stem = extractDescriptorStem(file)?.stem;
48
+ if (!stem)
49
+ continue;
50
+ const matchingImpl = implFiles.find((candidate) => {
51
+ try {
52
+ return parseImplFilename(candidate).stem === stem;
53
+ }
54
+ catch {
55
+ return false;
56
+ }
57
+ });
58
+ if (!matchingImpl)
59
+ continue;
60
+ const implPath = resolve(baseDir, matchingImpl);
61
+ runtime.registerLoader(descKind, desc.id, async () => {
62
+ const exported = (await import(__rewriteRelativeImportExtension(implPath))).default;
63
+ if (exported &&
64
+ typeof exported === 'object' &&
65
+ 'impl' in exported &&
66
+ 'meta' in exported) {
67
+ return exported;
68
+ }
69
+ return {
70
+ meta: {
71
+ id: desc.id,
72
+ kind: descKind,
73
+ priority: 0
74
+ },
75
+ impl: exported
76
+ };
77
+ });
78
+ loaders++;
79
+ }
80
+ catch {
81
+ // Descriptor may have unresolvable imports in this environment — skip
82
+ }
83
+ }
84
+ }
85
+ return { descriptors, loaders };
86
+ }
87
+ function scanPatterns(patterns, cwd) {
88
+ const results = [];
89
+ for (const pattern of patterns) {
90
+ for (const expanded of expandScopedPattern(pattern)) {
91
+ results.push(...scanGlob(expanded, cwd));
92
+ }
93
+ }
94
+ return results;
95
+ }
96
+ function expandScopedPattern(pattern) {
97
+ if (!pattern.includes('{descriptor,impl}'))
98
+ return [pattern];
99
+ return [
100
+ pattern.replace('{descriptor,impl}', 'descriptor*'),
101
+ pattern.replace('{descriptor,impl}', 'impl*')
102
+ ];
103
+ }
104
+ function scanGlob(pattern, cwd) {
105
+ if (typeof globalThis !== 'undefined' && 'Bun' in globalThis) {
106
+ const BunGlob = globalThis.Bun;
107
+ return [...new BunGlob.Glob(pattern).scanSync({ cwd, onlyFiles: true })];
108
+ }
109
+ const builtinProcess = process;
110
+ const fsModule = builtinProcess.getBuiltinModule?.('node:fs');
111
+ if (typeof fsModule?.globSync === 'function') {
112
+ return fsModule.globSync(pattern, { cwd });
113
+ }
114
+ return [];
115
+ }
116
+ //# sourceMappingURL=discovery.assets.consumer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.assets.consumer.js","sourceRoot":"","sources":["../../src/discovery/discovery.assets.consumer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAUvG,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,OAAmB,EACnB,OAA2B,EAC3B,YAA+C;IAE/C,4EAA4E;IAC5E,uEAAuE;IACvE,yEAAyE;IACzE,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzD,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACvC,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChE,OAAO,E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ated here to avoid export map changes in runtime core).
3
+ * Matches the contract in packages/runtime/src/env/host.contracts.ts.
4
+ */
5
+ interface RuntimeHost {
6
+ kind: 'browser' | 'node' | 'cloud';
7
+ cwd(): string | null;
8
+ readTextFile(path: string): Promise<string>;
9
+ }
10
+ export declare const host: RuntimeHost;
11
+ export {};
12
+ //# sourceMappingURL=host.consumer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.consumer.d.ts","sourceRoot":"","sources":["../../src/host/host.consumer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,UAAU,WAAW;IACpB,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;IACnC,GAAG,IAAI,MAAM,GAAG,IAAI,CAAC;IACrB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5C;AAKD,eAAO,MAAM,IAAI,EAAE,WASlB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { resolve } from 'node:path';
3
+ export const host = {
4
+ kind: 'node',
5
+ cwd() {
6
+ return process.cwd();
7
+ },
8
+ async readTextFile(path) {
9
+ const absolute = resolve(process.cwd(), path);
10
+ return await readFile(absolute, 'utf8');
11
+ }
12
+ };
13
+ //# sourceMappingURL=host.consumer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.consumer.js","sourceRoot":"","sources":["../../src/host/host.consumer.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,MAAM,IAAI,GAAgB;IAChC,IAAI,EAAE,MAAM;IACZ,GAAG;QACF,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;IACtB,CAAC;IACD,KAAK,CAAC,YAAY,CAAC,IAAY;QAC9B,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;QAC9C,OAAO,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;CACD,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Bun Runtime Environment Package
3
+ *
4
+ * Provides Bun-specific implementations for:
5
+ * - runtime/environment: BunEnvironment
6
+ * - runtime/loader: BunLoader
7
+ * - runtime/scope: Built from captured env
8
+ * - runtime/env: Env + secrets access
9
+ */
10
+ import type { VibesRuntime } from '@vibesdotdev/runtime';
11
+ import { BunEnvironment, type BunEnvironmentOptions } from './bun-environment.impl';
12
+ import { BunLoader } from './bun-loader.impl';
13
+ /**
14
+ * Register the Bun environment with the runtime.
15
+ * Call this at bootstrap before any plugins are loaded.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * // apps/my-app/src/hooks.server.ts
20
+ * import { registerBunEnvironment } from '@vibesdotdev/runtime-environment-bun';
21
+ * import { getVibesRuntime } from '@vibesdotdev/runtime';
22
+ *
23
+ * export async function handle({ event, resolve }) {
24
+ * registerBunEnvironment(getVibesRuntime(), {
25
+ * tenancy: {
26
+ * ownerType: 'organization',
27
+ * ownerId: event.locals.activeOrgId
28
+ * }
29
+ * });
30
+ * // ... rest of handle
31
+ * }
32
+ * ```
33
+ */
34
+ export declare function registerBunEnvironment(runtime: VibesRuntime, options?: BunEnvironmentOptions): BunEnvironment;
35
+ /**
36
+ * Get the Bun environment implementation.
37
+ * Throws if Bun environment wasn't registered.
38
+ */
39
+ export declare function getBunEnvironment(runtime: VibesRuntime): BunEnvironment;
40
+ export { BunEnvironment, BunLoader };
41
+ export { BunProcessSpawn } from './process-spawn.impl';
42
+ export { bunRuntimePath } from './services/runtime-path.impl';
43
+ export type { BunEnvironmentOptions };
44
+ export { loadPlugins } from './package-plugins/loader.consumer';
45
+ export { reportMissingPlugins } from './package-plugins/installer.consumer';
46
+ export { resolvePluginModule, getPackageName } from './package-plugins/resolve.consumer';
47
+ export { fallbackLoader } from './loaders/fallback-loader.impl.consumer';
48
+ export { discoverAssets } from './discovery/discovery.assets.consumer';
49
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,sBAAsB,CACrC,OAAO,EAAE,YAAY,EACrB,OAAO,GAAE,qBAA0B,GACjC,cAAc,CAoBhB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,cAAc,CASvE;AAED,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,YAAY,EAAE,qBAAqB,EAAE,CAAC;AAItC,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzF,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAGzE,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Bun Runtime Environment Package
3
+ *
4
+ * Provides Bun-specific implementations for:
5
+ * - runtime/environment: BunEnvironment
6
+ * - runtime/loader: BunLoader
7
+ * - runtime/scope: Built from captured env
8
+ * - runtime/env: Env + secrets access
9
+ */
10
+ import { BunEnvironment } from './bun-environment.impl';
11
+ import { BunLoader } from './bun-loader.impl';
12
+ import { bunRuntimePath } from './services/runtime-path.impl';
13
+ /**
14
+ * Register the Bun environment with the runtime.
15
+ * Call this at bootstrap before any plugins are loaded.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * // apps/my-app/src/hooks.server.ts
20
+ * import { registerBunEnvironment } from '@vibesdotdev/runtime-environment-bun';
21
+ * import { getVibesRuntime } from '@vibesdotdev/runtime';
22
+ *
23
+ * export async function handle({ event, resolve }) {
24
+ * registerBunEnvironment(getVibesRuntime(), {
25
+ * tenancy: {
26
+ * ownerType: 'organization',
27
+ * ownerId: event.locals.activeOrgId
28
+ * }
29
+ * });
30
+ * // ... rest of handle
31
+ * }
32
+ * ```
33
+ */
34
+ export function registerBunEnvironment(runtime, options = {}) {
35
+ const environment = new BunEnvironment(options);
36
+ runtime.registerEnvironment(environment);
37
+ // Constitutional registration: the low-level path operations (owned by the host)
38
+ // are provided under the kind id defined by @vibesdotdev/paths.
39
+ // packages/paths queries this kind and stays completely agnostic to which
40
+ // runtime-environment-* package is active or what its classes look like.
41
+ //
42
+ // Register both the descriptor (so `query.withId('bun').resolve()` works)
43
+ // and the loader (so the impl is lazily produced when resolved).
44
+ runtime.registerDescriptor('paths/runtime-path', {
45
+ id: 'bun',
46
+ kind: 'paths/runtime-path',
47
+ name: 'Bun Runtime Path',
48
+ description: 'Bun host implementation of low-level path operations'
49
+ });
50
+ runtime.registerLoader('paths/runtime-path', 'bun', () => Promise.resolve({ impl: bunRuntimePath }));
51
+ return environment;
52
+ }
53
+ /**
54
+ * Get the Bun environment implementation.
55
+ * Throws if Bun environment wasn't registered.
56
+ */
57
+ export function getBunEnvironment(runtime) {
58
+ const env = runtime.environment;
59
+ if (!(env instanceof BunEnvironment)) {
60
+ throw new Error(`Expected BunEnvironment but got ${env.constructor.name}. ` +
61
+ 'Did you call registerBunEnvironment() at bootstrap?');
62
+ }
63
+ return env;
64
+ }
65
+ export { BunEnvironment, BunLoader };
66
+ export { BunProcessSpawn } from './process-spawn.impl';
67
+ export { bunRuntimePath } from './services/runtime-path.impl';
68
+ // Package import policy / dynamic plugin loading from the filesystem
69
+ // (owned by the environment per RUNTIME-ENVIRONMENT-SURFACE-SPEC.md)
70
+ export { loadPlugins } from './package-plugins/loader.consumer';
71
+ export { reportMissingPlugins } from './package-plugins/installer.consumer';
72
+ export { resolvePluginModule, getPackageName } from './package-plugins/resolve.consumer';
73
+ // Fallback loader for test/dev when no surface loader is provided
74
+ export { fallbackLoader } from './loaders/fallback-loader.impl.consumer';
75
+ // Consumer asset discovery helper (filesystem scanning for .descriptor / .impl / .plugin files)
76
+ export { discoverAssets } from './discovery/discovery.assets.consumer';
77
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,cAAc,EAA8B,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,sBAAsB,CACrC,OAAqB,EACrB,UAAiC,EAAE;IAEnC,MAAM,WAAW,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;IAChD,OAAO,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;IAEzC,iFAAiF;IACjF,gEAAgE;IAChE,0EAA0E;IAC1E,yEAAyE;IACzE,EAAE;IACF,0EAA0E;IAC1E,iEAAiE;IACjE,OAAO,CAAC,kBAAkB,CAAC,oBAAoB,EAAE;QAChD,EAAE,EAAE,KAAK;QACT,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,sDAAsD;KACnE,CAAC,CAAC;IACH,OAAO,C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