@buda-ai/connector 0.1.14 → 0.1.16
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/cli.js +37 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -517,7 +517,7 @@ import path2 from "path";
|
|
|
517
517
|
// package.json
|
|
518
518
|
var package_default = {
|
|
519
519
|
name: "@buda-ai/connector",
|
|
520
|
-
version: "0.1.
|
|
520
|
+
version: "0.1.16",
|
|
521
521
|
private: false,
|
|
522
522
|
type: "module",
|
|
523
523
|
publishConfig: {
|
|
@@ -2411,6 +2411,31 @@ import path6 from "path";
|
|
|
2411
2411
|
import { promisify } from "util";
|
|
2412
2412
|
var execFileAsync = promisify(execFile);
|
|
2413
2413
|
var RUNTIME_INSTALL_TIMEOUT_MS = 5 * 6e4;
|
|
2414
|
+
var WINDOWS_RENAME_RETRY_DELAYS_MS = [50, 100, 200, 400, 500, 500, 500, 500, 500];
|
|
2415
|
+
var resolveBundledNodePlacement = (sourceRoot, sourceNode, pathApi = path6) => {
|
|
2416
|
+
const relativeNode = pathApi.relative(sourceRoot, sourceNode);
|
|
2417
|
+
return {
|
|
2418
|
+
copyNode: relativeNode.startsWith("..") || pathApi.isAbsolute(relativeNode),
|
|
2419
|
+
relativeNode
|
|
2420
|
+
};
|
|
2421
|
+
};
|
|
2422
|
+
var isWindowsRenameContention = (error) => error instanceof Error && "code" in error && ["EACCES", "EBUSY", "EPERM"].includes(String(error.code));
|
|
2423
|
+
var renameStagedRuntime = async (source, destination, options = {}) => {
|
|
2424
|
+
const platform4 = options.platform ?? process.platform;
|
|
2425
|
+
const renamePath = options.renamePath ?? rename4;
|
|
2426
|
+
const wait4 = options.wait ?? ((milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)));
|
|
2427
|
+
const delays = platform4 === "win32" ? WINDOWS_RENAME_RETRY_DELAYS_MS : [];
|
|
2428
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
2429
|
+
try {
|
|
2430
|
+
await renamePath(source, destination);
|
|
2431
|
+
return;
|
|
2432
|
+
} catch (error) {
|
|
2433
|
+
const delay = delays[attempt];
|
|
2434
|
+
if (delay === void 0 || !isWindowsRenameContention(error)) throw error;
|
|
2435
|
+
await wait4(delay);
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
};
|
|
2414
2439
|
var exists = async (filePath) => access(filePath).then(() => true).catch(() => false);
|
|
2415
2440
|
var runtimeRoot = () => process.env.BUDA_CONNECTOR_RUNTIME_ROOT || path6.join(homedir3(), ".buda", "runtime");
|
|
2416
2441
|
var runtimePlatformKey = `${process.platform}-${process.arch}-node${process.versions.modules}`;
|
|
@@ -2482,10 +2507,10 @@ var installFromBundledRuntime = async (directory, sourceRoot) => {
|
|
|
2482
2507
|
if (relativeEntrypoint.startsWith("..") || path6.isAbsolute(relativeEntrypoint)) {
|
|
2483
2508
|
throw new Error("Bundled Connector entrypoint must be inside its runtime root");
|
|
2484
2509
|
}
|
|
2485
|
-
const relativeNode =
|
|
2510
|
+
const { copyNode, relativeNode } = resolveBundledNodePlacement(sourceRoot, sourceNode);
|
|
2486
2511
|
const entrypoint = path6.join(directory, relativeEntrypoint);
|
|
2487
|
-
const nodeExecutable =
|
|
2488
|
-
if (
|
|
2512
|
+
const nodeExecutable = copyNode ? path6.join(directory, "node", path6.basename(sourceNode)) : path6.join(directory, relativeNode);
|
|
2513
|
+
if (copyNode) {
|
|
2489
2514
|
await mkdir5(path6.dirname(nodeExecutable), { recursive: true });
|
|
2490
2515
|
await cp(sourceNode, nodeExecutable, { force: true });
|
|
2491
2516
|
}
|
|
@@ -2533,7 +2558,7 @@ async function ensureStableConnectorRuntime() {
|
|
|
2533
2558
|
};
|
|
2534
2559
|
await writeManifest(temporary, rebased);
|
|
2535
2560
|
await rm(finalDirectory, { recursive: true, force: true });
|
|
2536
|
-
await
|
|
2561
|
+
await renameStagedRuntime(temporary, finalDirectory);
|
|
2537
2562
|
return rebased;
|
|
2538
2563
|
} catch (error) {
|
|
2539
2564
|
await rm(temporary, { recursive: true, force: true });
|
|
@@ -2595,15 +2620,20 @@ var waitForDaemon = async (launchConfig, deadline) => {
|
|
|
2595
2620
|
};
|
|
2596
2621
|
var spawnInternalDaemon = async (launchConfig, mode, preparedRuntime, options = {}) => {
|
|
2597
2622
|
const runtime = preparedRuntime ?? await ensureStableConnectorRuntime();
|
|
2623
|
+
const debugDaemonStdio = process.env.BUDA_CONNECTOR_DEBUG_DAEMON_STDIO === "1";
|
|
2598
2624
|
const child = spawn(runtime.nodeExecutable, getRuntimeCommandArgs(runtime, mode, options), {
|
|
2599
2625
|
detached: true,
|
|
2600
2626
|
env: {
|
|
2601
2627
|
...process.env,
|
|
2602
2628
|
BUDA_CONNECTOR_INTERNAL_LAUNCH_CONFIG: JSON.stringify(launchConfig ?? {})
|
|
2603
2629
|
},
|
|
2604
|
-
stdio: "ignore",
|
|
2630
|
+
stdio: debugDaemonStdio ? ["ignore", "inherit", "inherit"] : "ignore",
|
|
2605
2631
|
windowsHide: true
|
|
2606
2632
|
});
|
|
2633
|
+
await new Promise((resolve, reject) => {
|
|
2634
|
+
child.once("error", reject);
|
|
2635
|
+
child.once("spawn", resolve);
|
|
2636
|
+
});
|
|
2607
2637
|
child.unref();
|
|
2608
2638
|
};
|
|
2609
2639
|
var stopOlderIdleDaemon = async (config, status) => {
|
|
@@ -3725,6 +3755,7 @@ var writeJournal = async (journalPath, journal) => {
|
|
|
3725
3755
|
}
|
|
3726
3756
|
};
|
|
3727
3757
|
var syncDirectory2 = async (directory) => {
|
|
3758
|
+
if (process.platform === "win32") return;
|
|
3728
3759
|
const handle = await open2(directory, constants2.O_RDONLY);
|
|
3729
3760
|
try {
|
|
3730
3761
|
await handle.sync();
|