@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.
- package/dist/bun-environment.impl.d.ts +71 -0
- package/dist/bun-environment.impl.d.ts.map +1 -0
- package/dist/bun-environment.impl.js +130 -0
- package/dist/bun-environment.impl.js.map +1 -0
- package/dist/bun-loader.impl.d.ts +12 -0
- package/dist/bun-loader.impl.d.ts.map +1 -0
- package/dist/bun-loader.impl.js +96 -0
- package/dist/bun-loader.impl.js.map +1 -0
- package/dist/discovery/discovery.assets.consumer.d.ts +13 -0
- package/dist/discovery/discovery.assets.consumer.d.ts.map +1 -0
- package/dist/discovery/discovery.assets.consumer.js +116 -0
- package/dist/discovery/discovery.assets.consumer.js.map +1 -0
- package/dist/host/host.consumer.d.ts +12 -0
- package/dist/host/host.consumer.d.ts.map +1 -0
- package/dist/host/host.consumer.js +13 -0
- package/dist/host/host.consumer.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -0
- package/dist/loaders/fallback-loader.impl.consumer.d.ts +7 -0
- package/dist/loaders/fallback-loader.impl.consumer.d.ts.map +1 -0
- package/dist/loaders/fallback-loader.impl.consumer.js +63 -0
- package/dist/loaders/fallback-loader.impl.consumer.js.map +1 -0
- package/dist/package-plugins/candidates.consumer.d.ts +8 -0
- package/dist/package-plugins/candidates.consumer.d.ts.map +1 -0
- package/dist/package-plugins/candidates.consumer.js +133 -0
- package/dist/package-plugins/candidates.consumer.js.map +1 -0
- package/dist/package-plugins/import-module.consumer.d.ts +14 -0
- package/dist/package-plugins/import-module.consumer.d.ts.map +1 -0
- package/dist/package-plugins/import-module.consumer.js +28 -0
- package/dist/package-plugins/import-module.consumer.js.map +1 -0
- package/dist/package-plugins/index.d.ts +8 -0
- package/dist/package-plugins/index.d.ts.map +1 -0
- package/dist/package-plugins/index.js +8 -0
- package/dist/package-plugins/index.js.map +1 -0
- package/dist/package-plugins/installer.consumer.d.ts +14 -0
- package/dist/package-plugins/installer.consumer.d.ts.map +1 -0
- package/dist/package-plugins/installer.consumer.js +29 -0
- package/dist/package-plugins/installer.consumer.js.map +1 -0
- package/dist/package-plugins/loader.consumer.d.ts +12 -0
- package/dist/package-plugins/loader.consumer.d.ts.map +1 -0
- package/dist/package-plugins/loader.consumer.js +59 -0
- package/dist/package-plugins/loader.consumer.js.map +1 -0
- package/dist/package-plugins/reporting.d.ts +5 -0
- package/dist/package-plugins/reporting.d.ts.map +1 -0
- package/dist/package-plugins/reporting.js +10 -0
- package/dist/package-plugins/reporting.js.map +1 -0
- package/dist/package-plugins/resolve.consumer.d.ts +22 -0
- package/dist/package-plugins/resolve.consumer.d.ts.map +1 -0
- package/dist/package-plugins/resolve.consumer.js +265 -0
- package/dist/package-plugins/resolve.consumer.js.map +1 -0
- package/dist/process-spawn.impl.d.ts +15 -0
- package/dist/process-spawn.impl.d.ts.map +1 -0
- package/dist/process-spawn.impl.js +41 -0
- package/dist/process-spawn.impl.js.map +1 -0
- package/dist/services/runtime-path.impl.d.ts +20 -0
- package/dist/services/runtime-path.impl.d.ts.map +1 -0
- package/dist/services/runtime-path.impl.js +20 -0
- package/dist/services/runtime-path.impl.js.map +1 -0
- package/dist/services/self-spawn.consumer.d.ts +55 -0
- package/dist/services/self-spawn.consumer.d.ts.map +1 -0
- package/dist/services/self-spawn.consumer.js +85 -0
- package/dist/services/self-spawn.consumer.js.map +1 -0
- package/dist/services/workspace-resolve.d.ts +84 -0
- package/dist/services/workspace-resolve.d.ts.map +1 -0
- package/dist/services/workspace-resolve.js +107 -0
- package/dist/services/workspace-resolve.js.map +1 -0
- package/package.json +66 -0
- package/src/bun-environment.impl.ts +179 -0
- package/src/bun-loader.impl.ts +102 -0
- package/src/discovery/discovery.assets.consumer.ts +135 -0
- package/src/host/host.consumer.ts +23 -0
- package/src/index.ts +92 -0
- package/src/loaders/fallback-loader.impl.consumer.ts +57 -0
- package/src/package-plugins/candidates.consumer.ts +133 -0
- package/src/package-plugins/import-module.consumer.ts +27 -0
- package/src/package-plugins/index.ts +8 -0
- package/src/package-plugins/installer.consumer.ts +38 -0
- package/src/package-plugins/loader.consumer.ts +80 -0
- package/src/package-plugins/reporting.ts +13 -0
- package/src/package-plugins/resolve.consumer.ts +292 -0
- package/src/process-spawn.impl.ts +52 -0
- package/src/services/runtime-path.impl.ts +20 -0
- package/src/services/self-spawn.consumer.ts +91 -0
- package/src/services/workspace-resolve.ts +146 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin resolution — anchored on the project directory.
|
|
3
|
+
*
|
|
4
|
+
* For each request, we ask Bun to resolve the package's plugin entry points
|
|
5
|
+
* from `projectDir`. Bun's resolver follows the standard Node walk: it finds
|
|
6
|
+
* the package in `projectDir/node_modules`, then in parent `node_modules`,
|
|
7
|
+
* and so on. No shadow trees, no on-the-fly bundling.
|
|
8
|
+
*/
|
|
9
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
10
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
11
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
12
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return path;
|
|
16
|
+
};
|
|
17
|
+
import { dirname, join } from 'path';
|
|
18
|
+
import { existsSync, readFileSync } from 'fs';
|
|
19
|
+
import { pathToFileURL } from 'url';
|
|
20
|
+
import { exportPluginSpecifiers, getPackageName as getPluginPackageName, isBarePackageSpecifier, pluginFileCandidates } from './candidates.consumer.js';
|
|
21
|
+
function looksLikePlugin(candidate) {
|
|
22
|
+
return Boolean(candidate &&
|
|
23
|
+
typeof candidate === 'object' &&
|
|
24
|
+
'id' in candidate &&
|
|
25
|
+
!('kind' in candidate) &&
|
|
26
|
+
('name' in candidate ||
|
|
27
|
+
'description' in candidate ||
|
|
28
|
+
'dependencies' in candidate ||
|
|
29
|
+
'kinds' in candidate ||
|
|
30
|
+
'onRegister' in candidate ||
|
|
31
|
+
'onActivate' in candidate ||
|
|
32
|
+
'onDispose' in candidate));
|
|
33
|
+
}
|
|
34
|
+
function resolvePlugin(mod) {
|
|
35
|
+
const def = mod.default;
|
|
36
|
+
if (looksLikePlugin(def))
|
|
37
|
+
return def;
|
|
38
|
+
for (const [key, value] of Object.entries(mod)) {
|
|
39
|
+
if (key.toLowerCase().includes('plugin') && looksLikePlugin(value)) {
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const candidates = Object.values(mod).filter(looksLikePlugin);
|
|
44
|
+
return candidates.length === 1 ? candidates[0] : null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Specifiers we never load in consumer scope. Cloud plugins target workerd;
|
|
48
|
+
* loading them in a consumer runtime just produces unmet-dep errors because
|
|
49
|
+
* the consumer chain does not include the cloud-only plugin graph. Skip them
|
|
50
|
+
* at the specifier level.
|
|
51
|
+
*/
|
|
52
|
+
function isConsumerScopedSpecifier(specifier) {
|
|
53
|
+
return !specifier.endsWith('cloud.plugin');
|
|
54
|
+
}
|
|
55
|
+
export function getPackageName(specifier) {
|
|
56
|
+
return getPluginPackageName(specifier);
|
|
57
|
+
}
|
|
58
|
+
function isNotFoundMessage(message) {
|
|
59
|
+
return (message.includes('Cannot find') ||
|
|
60
|
+
message.includes('Could not resolve') ||
|
|
61
|
+
message.includes('Failed to resolve'));
|
|
62
|
+
}
|
|
63
|
+
async function importByPath(path) {
|
|
64
|
+
return (await import(__rewriteRelativeImportExtension(pathToFileURL(path).href)));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Walk up from a resolved file path to find the package root (the directory
|
|
68
|
+
* containing the matching `package.json`). This is how we discover a package's
|
|
69
|
+
* own filesystem root after `Bun.resolveSync` has already located it via the
|
|
70
|
+
* standard node_modules walk.
|
|
71
|
+
*/
|
|
72
|
+
function packageRootFromResolvedPath(resolvedPath, packageName) {
|
|
73
|
+
let current = dirname(resolvedPath);
|
|
74
|
+
const seen = new Set();
|
|
75
|
+
while (!seen.has(current)) {
|
|
76
|
+
seen.add(current);
|
|
77
|
+
const pkgJsonPath = join(current, 'package.json');
|
|
78
|
+
if (existsSync(pkgJsonPath)) {
|
|
79
|
+
try {
|
|
80
|
+
const pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf8'));
|
|
81
|
+
if (pkg.name === packageName)
|
|
82
|
+
return current;
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// Continue walking past unreadable package.json files.
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const parent = dirname(current);
|
|
89
|
+
if (parent === current)
|
|
90
|
+
return null;
|
|
91
|
+
current = parent;
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Locate a package's root by walking up from `projectDir` and probing each
|
|
97
|
+
* ancestor's `node_modules/<packageName>/package.json`. Used when the package
|
|
98
|
+
* declares no `.` export (so `Bun.resolveSync(packageName, …)` throws) but we
|
|
99
|
+
* still want to find its on-disk root to probe `./plugin` exports and scan
|
|
100
|
+
* for canonical plugin files.
|
|
101
|
+
*/
|
|
102
|
+
function findPackageRootByWalkUp(projectDir, packageName) {
|
|
103
|
+
const segments = packageName.split('/');
|
|
104
|
+
let current = projectDir;
|
|
105
|
+
const seen = new Set();
|
|
106
|
+
while (!seen.has(current)) {
|
|
107
|
+
seen.add(current);
|
|
108
|
+
const candidate = join(current, 'node_modules', ...segments);
|
|
109
|
+
if (existsSync(join(candidate, 'package.json')))
|
|
110
|
+
return candidate;
|
|
111
|
+
const parent = dirname(current);
|
|
112
|
+
if (parent === current)
|
|
113
|
+
return null;
|
|
114
|
+
current = parent;
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
async function trySpecifier(specifier, projectDir) {
|
|
119
|
+
let resolvedPath = null;
|
|
120
|
+
try {
|
|
121
|
+
resolvedPath = Bun.resolveSync(specifier, projectDir);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
125
|
+
return {
|
|
126
|
+
kind: 'attempt',
|
|
127
|
+
attempt: { label: specifier, message, notFound: isNotFoundMessage(message) },
|
|
128
|
+
resolvedPath: null
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
const loaded = await importByPath(resolvedPath);
|
|
133
|
+
const plugin = resolvePlugin(loaded);
|
|
134
|
+
if (plugin) {
|
|
135
|
+
return {
|
|
136
|
+
kind: 'plugin',
|
|
137
|
+
entry: { plugin, specifier, resolvedPath },
|
|
138
|
+
resolvedPath
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
kind: 'attempt',
|
|
143
|
+
attempt: {
|
|
144
|
+
label: specifier,
|
|
145
|
+
message: `Resolved ${specifier}, but it did not export a RuntimePlugin`,
|
|
146
|
+
notFound: false
|
|
147
|
+
},
|
|
148
|
+
resolvedPath
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
153
|
+
// Resolution succeeded but import failed (broken root export, syntax
|
|
154
|
+
// error, etc.). Surface the failure but keep `resolvedPath` so the
|
|
155
|
+
// caller can still discover the package root and probe other entries.
|
|
156
|
+
return {
|
|
157
|
+
kind: 'attempt',
|
|
158
|
+
attempt: { label: specifier, message, notFound: false },
|
|
159
|
+
resolvedPath
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
async function tryFile(path) {
|
|
164
|
+
try {
|
|
165
|
+
const loaded = await importByPath(path);
|
|
166
|
+
const plugin = resolvePlugin(loaded);
|
|
167
|
+
if (plugin) {
|
|
168
|
+
return { kind: 'plugin', entry: { plugin, specifier: path, resolvedPath: path } };
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
kind: 'attempt',
|
|
172
|
+
attempt: {
|
|
173
|
+
label: path,
|
|
174
|
+
message: `Resolved ${path}, but it did not export a RuntimePlugin`,
|
|
175
|
+
notFound: false
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
181
|
+
return { kind: 'attempt', attempt: { label: path, message, notFound: isNotFoundMessage(message) } };
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Resolve all plugins exported by a package — the primary plugin (`./plugin`
|
|
186
|
+
* or the bare specifier) plus any sibling surface plugins (`./<x>.plugin`,
|
|
187
|
+
* e.g. `./cli.plugin`). Cloud-scoped specifiers are excluded in consumer
|
|
188
|
+
* resolution. Plugins are deduplicated by `plugin.id` (preserving first occurrence)
|
|
189
|
+
* to handle index-barrel re-exports.
|
|
190
|
+
*/
|
|
191
|
+
export async function resolvePluginModule(request) {
|
|
192
|
+
const { id, projectDir } = request;
|
|
193
|
+
const attempts = [];
|
|
194
|
+
const packageName = getPluginPackageName(id);
|
|
195
|
+
const bareSpecifier = isBarePackageSpecifier(id);
|
|
196
|
+
const collected = new Map();
|
|
197
|
+
const addEntry = (entry) => {
|
|
198
|
+
if (!collected.has(entry.plugin.id))
|
|
199
|
+
collected.set(entry.plugin.id, entry);
|
|
200
|
+
};
|
|
201
|
+
// Try the literal request first. Even if it doesn't expose a plugin, the
|
|
202
|
+
// resolved path tells us where the package lives so we can probe its plugin
|
|
203
|
+
// entry points and on-disk plugin files.
|
|
204
|
+
const initial = await trySpecifier(id, projectDir);
|
|
205
|
+
let initialResolvedPath = null;
|
|
206
|
+
if (initial.kind === 'plugin') {
|
|
207
|
+
addEntry(initial.entry);
|
|
208
|
+
initialResolvedPath = initial.resolvedPath;
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
attempts.push(initial.attempt);
|
|
212
|
+
initialResolvedPath = initial.resolvedPath;
|
|
213
|
+
}
|
|
214
|
+
let packageRoot = null;
|
|
215
|
+
if (bareSpecifier) {
|
|
216
|
+
if (initialResolvedPath) {
|
|
217
|
+
packageRoot = packageRootFromResolvedPath(initialResolvedPath, packageName);
|
|
218
|
+
}
|
|
219
|
+
if (!packageRoot) {
|
|
220
|
+
packageRoot = findPackageRootByWalkUp(projectDir, packageName);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (bareSpecifier && packageRoot) {
|
|
224
|
+
for (const specifier of exportPluginSpecifiers(packageName, packageRoot)) {
|
|
225
|
+
if (specifier === id)
|
|
226
|
+
continue;
|
|
227
|
+
if (!isConsumerScopedSpecifier(specifier))
|
|
228
|
+
continue;
|
|
229
|
+
const candidate = await trySpecifier(specifier, projectDir);
|
|
230
|
+
if (candidate.kind === 'plugin') {
|
|
231
|
+
addEntry(candidate.entry);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
attempts.push(candidate.attempt);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
// Filesystem-discovered plugin files are only used as a fallback when no
|
|
238
|
+
// explicit plugin export resolved. They are scope-agnostic but we keep
|
|
239
|
+
// them as a last resort to preserve historic discovery behavior.
|
|
240
|
+
if (collected.size === 0) {
|
|
241
|
+
for (const file of pluginFileCandidates(packageRoot, packageName)) {
|
|
242
|
+
const candidate = await tryFile(file);
|
|
243
|
+
if (candidate.kind === 'plugin') {
|
|
244
|
+
addEntry(candidate.entry);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
attempts.push(candidate.attempt);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (collected.size > 0) {
|
|
253
|
+
return {
|
|
254
|
+
plugins: Array.from(collected.values()),
|
|
255
|
+
resolvedFrom: projectDir
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
const lastMeaningful = [...attempts].reverse().find((attempt) => !attempt.notFound);
|
|
259
|
+
const allNotFound = attempts.length > 0 && attempts.every((attempt) => attempt.notFound);
|
|
260
|
+
return {
|
|
261
|
+
error: lastMeaningful?.message ?? `Unable to resolve plugin ${id} from ${projectDir}`,
|
|
262
|
+
missing: allNotFound
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=resolve.consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.consumer.js","sourceRoot":"","sources":["../../src/package-plugins/resolve.consumer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;;;;;;;;;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAQpC,OAAO,EACN,sBAAsB,EACtB,cAAc,IAAI,oBAAoB,EACtC,sBAAsB,EACtB,oBAAoB,EACpB,MAAM,uBAAuB,CAAC;AAE/B,SAAS,eAAe,CAAC,SAAkB;IAC1C,OAAO,OAAO,CACb,SAAS;QACR,OAAO,SAAS,KAAK,QAAQ;QAC7B,IAAI,IAAI,SAAS;QACjB,CAAC,CAAC,MAAM,IAAI,SAAS,CAAC;QACtB,CAAC,MAAM,IAAI,SAAS;YACnB,aAAa,IAAI,SAAS;YAC1B,cAAc,IAAI,SAAS;YAC3B,OAAO,IAAI,SAAS;YACpB,YAAY,IAAI,SAAS;YACzB,YAAY,IAAI,SAAS;YACzB,WAAW,IAAI,SAAS,CAAC,CAC3B,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,GAA4B;IAClD,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC;IACx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AO,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpF,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACzF,OAAO;QACN,KAAK,EAAE,cAAc,EAAE,OAAO,IAAI,4BAA4B,EAAE,SAAS,UAAU,EAAE;QACrF,OAAO,EAAE,WAAW;KACpB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bun Process Spawn Implementation
|
|
3
|
+
*
|
|
4
|
+
* Consumer-only process spawning backed by Bun.spawn().
|
|
5
|
+
* Only available when hardware === 'consumer'.
|
|
6
|
+
*/
|
|
7
|
+
import type { ProcessSpawnImplementation, ProcessSpawnOptions, ProcessHandle } from '@vibesdotdev/runtime/kinds/process-spawn';
|
|
8
|
+
import type { ProcessSpawnDescriptor } from '@vibesdotdev/runtime/kinds/process-spawn';
|
|
9
|
+
export declare class BunProcessSpawn implements ProcessSpawnImplementation {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly descriptor: ProcessSpawnDescriptor;
|
|
12
|
+
constructor();
|
|
13
|
+
spawn(options: ProcessSpawnOptions): Promise<ProcessHandle>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=process-spawn.impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-spawn.impl.d.ts","sourceRoot":"","sources":["../src/process-spawn.impl.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACX,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,EACb,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAEvF,qBAAa,eAAgB,YAAW,0BAA0B;IACjE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,sBAAsB,CAAC;;IAatC,KAAK,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;CAsBjE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bun Process Spawn Implementation
|
|
3
|
+
*
|
|
4
|
+
* Consumer-only process spawning backed by Bun.spawn().
|
|
5
|
+
* Only available when hardware === 'consumer'.
|
|
6
|
+
*/
|
|
7
|
+
export class BunProcessSpawn {
|
|
8
|
+
id;
|
|
9
|
+
descriptor;
|
|
10
|
+
constructor() {
|
|
11
|
+
this.id = 'process-spawn-bun';
|
|
12
|
+
this.descriptor = {
|
|
13
|
+
id: 'process-spawn-bun',
|
|
14
|
+
kind: 'process/spawn',
|
|
15
|
+
name: 'Bun Process Spawn',
|
|
16
|
+
description: 'Consumer-only process spawning via Bun.spawn()',
|
|
17
|
+
hardware: ['consumer'],
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async spawn(options) {
|
|
21
|
+
const proc = Bun.spawn([options.command, ...(options.args ?? [])], {
|
|
22
|
+
cwd: options.cwd,
|
|
23
|
+
env: options.env ?? process.env,
|
|
24
|
+
stdout: 'pipe',
|
|
25
|
+
stderr: 'pipe',
|
|
26
|
+
});
|
|
27
|
+
const exited = proc.exited.then((code) => ({
|
|
28
|
+
code,
|
|
29
|
+
signal: null,
|
|
30
|
+
}));
|
|
31
|
+
return {
|
|
32
|
+
pid: proc.pid,
|
|
33
|
+
stdout: proc.stdout,
|
|
34
|
+
stderr: proc.stderr,
|
|
35
|
+
stdin: null,
|
|
36
|
+
exited,
|
|
37
|
+
kill: (signal) => proc.kill(signal),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=process-spawn.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-spawn.impl.js","sourceRoot":"","sources":["../src/process-spawn.impl.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,MAAM,OAAO,eAAe;IAClB,EAAE,CAAS;IACX,UAAU,CAAyB;IAE5C;QACC,IAAI,CAAC,EAAE,GAAG,mBAAmB,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG;YACjB,EAAE,EAAE,mBAAmB;YACvB,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,mBAAmB;YACzB,WAAW,EAAE,gDAAgD;YAC7D,QAAQ,EAAE,CAAC,UAAU,CAAC;SACtB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAA4B;QACvC,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,EAAE;YAClE,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,GAAG,EAAE,OAAO,CAAC,GAAG,IAAK,OAAO,CAAC,GAA8B;YAC3D,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,MAAM;SACd,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC1C,IAAI;YACJ,MAAM,EAAE,IAAqB;SAC7B,CAAC,CAAC,CAAC;QAEJ,OAAO;YACN,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,MAAM,EAAE,IAAI,CAAC,MAAiC;YAC9C,MAAM,EAAE,IAAI,CAAC,MAAiC;YAC9C,KAAK,EAAE,IAAI;YACX,MAAM;YACN,IAAI,EAAE,CAAC,MAAe,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAyC,CAAC;SAC/E,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { homedir, tmpdir } from 'node:os';
|
|
2
|
+
import { join, resolve, dirname, basename, extname, isAbsolute, normalize } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Bun / Node implementation of low-level path utilities.
|
|
5
|
+
* This is the source of truth for path operations on this host.
|
|
6
|
+
*
|
|
7
|
+
* The shape matches RuntimePath from @vibesdotdev/paths (the contract lives there).
|
|
8
|
+
*/
|
|
9
|
+
export declare const bunRuntimePath: {
|
|
10
|
+
join: typeof join;
|
|
11
|
+
resolve: typeof resolve;
|
|
12
|
+
dirname: typeof dirname;
|
|
13
|
+
basename: typeof basename;
|
|
14
|
+
extname: typeof extname;
|
|
15
|
+
isAbsolute: typeof isAbsolute;
|
|
16
|
+
normalize: typeof normalize;
|
|
17
|
+
homedir: typeof homedir;
|
|
18
|
+
tmpdir: typeof tmpdir;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=runtime-path.impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-path.impl.d.ts","sourceRoot":"","sources":["../../src/services/runtime-path.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE7F;;;;;GAKG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;CAU1B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { homedir, tmpdir } from 'node:os';
|
|
2
|
+
import { join, resolve, dirname, basename, extname, isAbsolute, normalize } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Bun / Node implementation of low-level path utilities.
|
|
5
|
+
* This is the source of truth for path operations on this host.
|
|
6
|
+
*
|
|
7
|
+
* The shape matches RuntimePath from @vibesdotdev/paths (the contract lives there).
|
|
8
|
+
*/
|
|
9
|
+
export const bunRuntimePath = {
|
|
10
|
+
join,
|
|
11
|
+
resolve,
|
|
12
|
+
dirname,
|
|
13
|
+
basename,
|
|
14
|
+
extname,
|
|
15
|
+
isAbsolute,
|
|
16
|
+
normalize,
|
|
17
|
+
homedir,
|
|
18
|
+
tmpdir,
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=runtime-path.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-path.impl.js","sourceRoot":"","sources":["../../src/services/runtime-path.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE7F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B,IAAI;IACJ,OAAO;IACP,OAAO;IACP,QAAQ;IACR,OAAO;IACP,UAAU;IACV,SAAS;IACT,OAAO;IACP,MAAM;CACN,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-spawn argv resolution.
|
|
3
|
+
*
|
|
4
|
+
* Lets a hosted process (PM daemon launcher, an autoloop child, etc.)
|
|
5
|
+
* compute the command line that re-launches the *currently running*
|
|
6
|
+
* vibes binary so a fresh subprocess can run additional commands.
|
|
7
|
+
*
|
|
8
|
+
* Two host shapes are supported, and the bin entry's `import.meta.url`
|
|
9
|
+
* is the only reliable signal for distinguishing them:
|
|
10
|
+
*
|
|
11
|
+
* - **Compiled binary** (`bun build --compile`): `import.meta.url`
|
|
12
|
+
* starts with `file:///$bunfs/` (Bun's virtual mount for the
|
|
13
|
+
* bundled root). `process.execPath` is the standalone binary
|
|
14
|
+
* itself, so the spawn argv is just `[execPath]`.
|
|
15
|
+
*
|
|
16
|
+
* - **Source mode** (`bun run vibes.ts`): `import.meta.url` is a
|
|
17
|
+
* real `file://` path to the .ts entry. `process.execPath` is bun;
|
|
18
|
+
* `process.argv[1]` is the entry script. Spawn argv is
|
|
19
|
+
* `[bun, 'run', '--bun', entry]`.
|
|
20
|
+
*
|
|
21
|
+
* Bin entries call `declareSelfSpawn(import.meta.url)` once at
|
|
22
|
+
* startup. Consumers (e.g. PM client) call `readSelfSpawnArgv()`.
|
|
23
|
+
*
|
|
24
|
+
* Embedded hosts (a SvelteKit app importing PM at runtime) never call
|
|
25
|
+
* `declareSelfSpawn`. Consumers receive `null` and decide their own
|
|
26
|
+
* fallback policy (PM, for instance, falls back to scanning the
|
|
27
|
+
* workspace for a CLI source entry — useful in monorepo dev, throws
|
|
28
|
+
* with a clear message otherwise).
|
|
29
|
+
*/
|
|
30
|
+
export type SelfSpawnSource = 'compiled-binary' | 'bun-source';
|
|
31
|
+
export interface SelfSpawnArgv {
|
|
32
|
+
argv: string[];
|
|
33
|
+
source: SelfSpawnSource;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Compute the self-spawn argv from the host's `import.meta.url`.
|
|
37
|
+
*
|
|
38
|
+
* Returns `null` when the host shape can't be determined (e.g. source
|
|
39
|
+
* mode where `process.argv[1]` is missing). Callers fall back.
|
|
40
|
+
*/
|
|
41
|
+
export declare function computeSelfSpawnArgv(binImportMetaUrl: string): SelfSpawnArgv | null;
|
|
42
|
+
/**
|
|
43
|
+
* Publish the host's self-spawn argv as a JSON env var so subprocesses
|
|
44
|
+
* and other in-process consumers can re-launch the same binary shape.
|
|
45
|
+
*
|
|
46
|
+
* Idempotent — if the env var is already set (e.g. inherited from a
|
|
47
|
+
* parent vibes process), the original launch shape is preserved.
|
|
48
|
+
*/
|
|
49
|
+
export declare function declareSelfSpawn(binImportMetaUrl: string): void;
|
|
50
|
+
/**
|
|
51
|
+
* Read the published self-spawn argv. Returns `null` when no host has
|
|
52
|
+
* declared one or the value is malformed.
|
|
53
|
+
*/
|
|
54
|
+
export declare function readSelfSpawnArgv(): string[] | null;
|
|
55
|
+
//# sourceMappingURL=self-spawn.consumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self-spawn.consumer.d.ts","sourceRoot":"","sources":["../../src/services/self-spawn.consumer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAKH,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG,YAAY,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,gBAAgB,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAYnF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAK/D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,EAAE,GAAG,IAAI,CAYnD"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-spawn argv resolution.
|
|
3
|
+
*
|
|
4
|
+
* Lets a hosted process (PM daemon launcher, an autoloop child, etc.)
|
|
5
|
+
* compute the command line that re-launches the *currently running*
|
|
6
|
+
* vibes binary so a fresh subprocess can run additional commands.
|
|
7
|
+
*
|
|
8
|
+
* Two host shapes are supported, and the bin entry's `import.meta.url`
|
|
9
|
+
* is the only reliable signal for distinguishing them:
|
|
10
|
+
*
|
|
11
|
+
* - **Compiled binary** (`bun build --compile`): `import.meta.url`
|
|
12
|
+
* starts with `file:///$bunfs/` (Bun's virtual mount for the
|
|
13
|
+
* bundled root). `process.execPath` is the standalone binary
|
|
14
|
+
* itself, so the spawn argv is just `[execPath]`.
|
|
15
|
+
*
|
|
16
|
+
* - **Source mode** (`bun run vibes.ts`): `import.meta.url` is a
|
|
17
|
+
* real `file://` path to the .ts entry. `process.execPath` is bun;
|
|
18
|
+
* `process.argv[1]` is the entry script. Spawn argv is
|
|
19
|
+
* `[bun, 'run', '--bun', entry]`.
|
|
20
|
+
*
|
|
21
|
+
* Bin entries call `declareSelfSpawn(import.meta.url)` once at
|
|
22
|
+
* startup. Consumers (e.g. PM client) call `readSelfSpawnArgv()`.
|
|
23
|
+
*
|
|
24
|
+
* Embedded hosts (a SvelteKit app importing PM at runtime) never call
|
|
25
|
+
* `declareSelfSpawn`. Consumers receive `null` and decide their own
|
|
26
|
+
* fallback policy (PM, for instance, falls back to scanning the
|
|
27
|
+
* workspace for a CLI source entry — useful in monorepo dev, throws
|
|
28
|
+
* with a clear message otherwise).
|
|
29
|
+
*/
|
|
30
|
+
const COMPILED_BINARY_URL_PREFIX = 'file:///$bunfs/';
|
|
31
|
+
const SELF_SPAWN_ENV_VAR = 'VIBES_SELF_SPAWN_ARGV';
|
|
32
|
+
/**
|
|
33
|
+
* Compute the self-spawn argv from the host's `import.meta.url`.
|
|
34
|
+
*
|
|
35
|
+
* Returns `null` when the host shape can't be determined (e.g. source
|
|
36
|
+
* mode where `process.argv[1]` is missing). Callers fall back.
|
|
37
|
+
*/
|
|
38
|
+
export function computeSelfSpawnArgv(binImportMetaUrl) {
|
|
39
|
+
if (binImportMetaUrl.startsWith(COMPILED_BINARY_URL_PREFIX)) {
|
|
40
|
+
return { argv: [process.execPath], source: 'compiled-binary' };
|
|
41
|
+
}
|
|
42
|
+
const entry = process.argv[1];
|
|
43
|
+
if (entry && entry.length > 0) {
|
|
44
|
+
return {
|
|
45
|
+
argv: [process.execPath, 'run', '--bun', entry],
|
|
46
|
+
source: 'bun-source'
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Publish the host's self-spawn argv as a JSON env var so subprocesses
|
|
53
|
+
* and other in-process consumers can re-launch the same binary shape.
|
|
54
|
+
*
|
|
55
|
+
* Idempotent — if the env var is already set (e.g. inherited from a
|
|
56
|
+
* parent vibes process), the original launch shape is preserved.
|
|
57
|
+
*/
|
|
58
|
+
export function declareSelfSpawn(binImportMetaUrl) {
|
|
59
|
+
if (process.env[SELF_SPAWN_ENV_VAR])
|
|
60
|
+
return;
|
|
61
|
+
const computed = computeSelfSpawnArgv(binImportMetaUrl);
|
|
62
|
+
if (!computed)
|
|
63
|
+
return;
|
|
64
|
+
process.env[SELF_SPAWN_ENV_VAR] = JSON.stringify(computed.argv);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Read the published self-spawn argv. Returns `null` when no host has
|
|
68
|
+
* declared one or the value is malformed.
|
|
69
|
+
*/
|
|
70
|
+
export function readSelfSpawnArgv() {
|
|
71
|
+
const raw = process.env[SELF_SPAWN_ENV_VAR];
|
|
72
|
+
if (!raw)
|
|
73
|
+
return null;
|
|
74
|
+
try {
|
|
75
|
+
const parsed = JSON.parse(raw);
|
|
76
|
+
if (Array.isArray(parsed) && parsed.every((entry) => typeof entry === 'string')) {
|
|
77
|
+
return parsed;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// malformed env value — treat as not declared
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=self-spawn.consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self-spawn.consumer.js","sourceRoot":"","sources":["../../src/services/self-spawn.consumer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,MAAM,0BAA0B,GAAG,iBAAiB,CAAC;AACrD,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AASnD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,gBAAwB;IAC5D,IAAI,gBAAgB,CAAC,UAAU,CAAC,0BAA0B,CAAC,EAAE,CAAC;QAC7D,OAAO,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE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
|
1
|
+
/**
|
|
2
|
+
* Unified Workspace Root Resolution
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for resolving the workspace root path.
|
|
5
|
+
* This consolidates the various fallback patterns used across the codebase.
|
|
6
|
+
*
|
|
7
|
+
* Priority order (highest to lowest):
|
|
8
|
+
* 1. Explicit override (e.g., MCP request header)
|
|
9
|
+
* 2. Runtime context workspacePath
|
|
10
|
+
* 3. Environment config workspacePath
|
|
11
|
+
* 4. CLI invocation cwd
|
|
12
|
+
* 5. process.cwd() fallback
|
|
13
|
+
*
|
|
14
|
+
* NOTE: This module lives in @vibesdotdev/runtime (not workspace) to avoid
|
|
15
|
+
* a circular dependency between runtime and workspace. The workspace package
|
|
16
|
+
* re-exports from here for backward compatibility.
|
|
17
|
+
*/
|
|
18
|
+
type WorkspaceSourceKey = 'override' | 'runtimeContext' | 'environment' | 'cliCwd' | 'cwd';
|
|
19
|
+
export interface WorkspaceSources {
|
|
20
|
+
override?: string;
|
|
21
|
+
runtimeContext?: string;
|
|
22
|
+
environment?: string;
|
|
23
|
+
cliCwd?: string;
|
|
24
|
+
cwd?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface WorkspaceResolutionResult {
|
|
27
|
+
path: string;
|
|
28
|
+
source: WorkspaceSourceKey | 'processCwd';
|
|
29
|
+
}
|
|
30
|
+
export interface WorkspaceResolutionContext {
|
|
31
|
+
workspacePath?: string;
|
|
32
|
+
environment?: object | null;
|
|
33
|
+
cli?: object | null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Resolve workspace root path from multiple sources with priority fallback.
|
|
37
|
+
*
|
|
38
|
+
* @param sources - Object containing potential workspace path sources
|
|
39
|
+
* @returns The resolved workspace path (never undefined)
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const workspace = resolveWorkspaceRoot({
|
|
44
|
+
* override: request.workspacePath,
|
|
45
|
+
* runtimeContext: context.workspacePath,
|
|
46
|
+
* environment: context.environment?.workspacePath,
|
|
47
|
+
* cliCwd: context.cli?.cwd
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function resolveWorkspaceRoot(sources?: WorkspaceSources): string;
|
|
52
|
+
/**
|
|
53
|
+
* Resolve workspace root path with source information for debugging.
|
|
54
|
+
*
|
|
55
|
+
* @param sources - Object containing potential workspace path sources
|
|
56
|
+
* @returns Object with resolved path and source that provided it
|
|
57
|
+
*/
|
|
58
|
+
export declare function resolveWorkspaceRootWithSource(sources?: WorkspaceSources): WorkspaceResolutionResult;
|
|
59
|
+
/**
|
|
60
|
+
* Extract workspace sources from a RuntimeContext-like object.
|
|
61
|
+
* Handles the various shapes of context objects in the codebase.
|
|
62
|
+
*
|
|
63
|
+
* @param context - Runtime context object with optional workspace-related fields
|
|
64
|
+
* @param override - Optional explicit override (e.g., from MCP request)
|
|
65
|
+
* @returns WorkspaceSources for use with resolveWorkspaceRoot
|
|
66
|
+
*/
|
|
67
|
+
export declare function extractWorkspaceSources(context: WorkspaceResolutionContext, override?: string): WorkspaceSources;
|
|
68
|
+
/**
|
|
69
|
+
* Convenience function: Extract sources and resolve in one step.
|
|
70
|
+
*
|
|
71
|
+
* @param context - Runtime context object
|
|
72
|
+
* @param override - Optional explicit override
|
|
73
|
+
* @returns Resolved workspace path
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolveWorkspaceFromContext(context: WorkspaceResolutionContext, override?: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* Resolve the current workspace as an object with rootPath.
|
|
78
|
+
* Convenience wrapper for callers that expect `{ rootPath: string }`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function resolveCurrentWorkspace(): {
|
|
81
|
+
rootPath: string;
|
|
82
|
+
};
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=workspace-resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-resolve.d.ts","sourceRoot":"","sources":["../../src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