@buda-ai/connector 0.1.17 → 0.1.19
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 +64 -15
- package/package.json +2 -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.19",
|
|
521
521
|
private: false,
|
|
522
522
|
type: "module",
|
|
523
523
|
publishConfig: {
|
|
@@ -535,6 +535,7 @@ var package_default = {
|
|
|
535
535
|
dev: "tsx src/cli.ts dev",
|
|
536
536
|
daemon: "tsx src/cli.ts daemon",
|
|
537
537
|
new: "tsx src/cli.ts new",
|
|
538
|
+
prepack: "tsup --silent",
|
|
538
539
|
start: "node dist/cli.js daemon",
|
|
539
540
|
build: "tsup",
|
|
540
541
|
test: "vitest run",
|
|
@@ -2604,6 +2605,57 @@ var compareVersions = (left, right) => {
|
|
|
2604
2605
|
return 0;
|
|
2605
2606
|
};
|
|
2606
2607
|
var shouldReplaceDaemonVersion = (runningVersion, candidateVersion) => compareVersions(candidateVersion, runningVersion) > 0;
|
|
2608
|
+
var getErrorCode = (error) => typeof error === "object" && error !== null && "code" in error ? String(error.code) : "UNKNOWN";
|
|
2609
|
+
var waitForChildSpawn = (child) => new Promise((resolve, reject) => {
|
|
2610
|
+
const onError = (error) => {
|
|
2611
|
+
child.off("spawn", onSpawn);
|
|
2612
|
+
reject(error);
|
|
2613
|
+
};
|
|
2614
|
+
const onSpawn = () => {
|
|
2615
|
+
child.off("error", onError);
|
|
2616
|
+
resolve();
|
|
2617
|
+
};
|
|
2618
|
+
child.once("error", onError);
|
|
2619
|
+
child.once("spawn", onSpawn);
|
|
2620
|
+
});
|
|
2621
|
+
async function spawnDetachedDaemonProcess(command, args, options, dependencies = {}) {
|
|
2622
|
+
const platform4 = dependencies.platform ?? process.platform;
|
|
2623
|
+
const spawnProcess = dependencies.spawnProcess ?? ((file, fileArgs, spawnOptions) => spawn(file, fileArgs, spawnOptions));
|
|
2624
|
+
const strategies = platform4 === "win32" ? [
|
|
2625
|
+
{ name: "detached-hidden", windowsHide: true },
|
|
2626
|
+
{ name: "detached-unhidden", windowsHide: false }
|
|
2627
|
+
] : [{ name: "detached-hidden", windowsHide: true }];
|
|
2628
|
+
const attempted = [];
|
|
2629
|
+
for (const [index, strategy] of strategies.entries()) {
|
|
2630
|
+
attempted.push(strategy.name);
|
|
2631
|
+
const child = spawnProcess(command, args, {
|
|
2632
|
+
detached: true,
|
|
2633
|
+
env: options.env,
|
|
2634
|
+
stdio: options.stdio,
|
|
2635
|
+
windowsHide: strategy.windowsHide
|
|
2636
|
+
});
|
|
2637
|
+
try {
|
|
2638
|
+
await waitForChildSpawn(child);
|
|
2639
|
+
child.unref();
|
|
2640
|
+
return strategy.name;
|
|
2641
|
+
} catch (error) {
|
|
2642
|
+
const code = getErrorCode(error);
|
|
2643
|
+
const shouldRetry = platform4 === "win32" && index === 0 && code === "EINVAL";
|
|
2644
|
+
if (shouldRetry) continue;
|
|
2645
|
+
const diagnostics = [
|
|
2646
|
+
`code=${code}`,
|
|
2647
|
+
`strategies=${attempted.join(",")}`,
|
|
2648
|
+
`platform=${platform4}`,
|
|
2649
|
+
`node=${dependencies.nodeVersion ?? process.version}`,
|
|
2650
|
+
`executable=${JSON.stringify(command)}`,
|
|
2651
|
+
`entrypoint=${JSON.stringify(args[0] ?? "")}`,
|
|
2652
|
+
`cwd=${JSON.stringify(dependencies.cwd ?? process.cwd())}`
|
|
2653
|
+
].join(" ");
|
|
2654
|
+
throw new Error(`Connector daemon process creation failed: ${diagnostics}`, { cause: error });
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
throw new Error("Connector daemon process creation failed without a spawn attempt");
|
|
2658
|
+
}
|
|
2607
2659
|
var waitForDaemon = async (launchConfig, deadline) => {
|
|
2608
2660
|
let lastConfig = null;
|
|
2609
2661
|
while (Date.now() < deadline) {
|
|
@@ -2621,20 +2673,17 @@ var waitForDaemon = async (launchConfig, deadline) => {
|
|
|
2621
2673
|
var spawnInternalDaemon = async (launchConfig, mode, preparedRuntime, options = {}) => {
|
|
2622
2674
|
const runtime = preparedRuntime ?? await ensureStableConnectorRuntime();
|
|
2623
2675
|
const debugDaemonStdio = process.env.BUDA_CONNECTOR_DEBUG_DAEMON_STDIO === "1";
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
child.once("spawn", resolve);
|
|
2636
|
-
});
|
|
2637
|
-
child.unref();
|
|
2676
|
+
await spawnDetachedDaemonProcess(
|
|
2677
|
+
runtime.nodeExecutable,
|
|
2678
|
+
getRuntimeCommandArgs(runtime, mode, options),
|
|
2679
|
+
{
|
|
2680
|
+
env: {
|
|
2681
|
+
...process.env,
|
|
2682
|
+
BUDA_CONNECTOR_INTERNAL_LAUNCH_CONFIG: JSON.stringify(launchConfig ?? {})
|
|
2683
|
+
},
|
|
2684
|
+
stdio: debugDaemonStdio ? ["ignore", "inherit", "inherit"] : "ignore"
|
|
2685
|
+
}
|
|
2686
|
+
);
|
|
2638
2687
|
};
|
|
2639
2688
|
var stopOlderIdleDaemon = async (config, status) => {
|
|
2640
2689
|
if (!shouldReplaceDaemonVersion(status.version, CONNECTOR_RUNTIME_VERSION)) return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buda-ai/connector",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"dev": "tsx src/cli.ts dev",
|
|
19
19
|
"daemon": "tsx src/cli.ts daemon",
|
|
20
20
|
"new": "tsx src/cli.ts new",
|
|
21
|
+
"prepack": "tsup --silent",
|
|
21
22
|
"start": "node dist/cli.js daemon",
|
|
22
23
|
"build": "tsup",
|
|
23
24
|
"test": "vitest run",
|