@buda-ai/connector 0.1.22 → 0.1.24
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 +24 -10
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -25,8 +25,8 @@ async function acquireExclusiveFileLock(targetPath, options = {}) {
|
|
|
25
25
|
} catch (error) {
|
|
26
26
|
if (!isAlreadyExists(error)) throw error;
|
|
27
27
|
if (await shouldRecoverLock(lockPath, staleMs)) {
|
|
28
|
-
await unlink(lockPath).catch(() =>
|
|
29
|
-
continue;
|
|
28
|
+
const recovered = await unlink(lockPath).then(() => true).catch(() => false);
|
|
29
|
+
if (recovered) continue;
|
|
30
30
|
}
|
|
31
31
|
if (Date.now() >= deadline) {
|
|
32
32
|
throw new Error(`Timed out waiting for exclusive access to ${targetPath}`);
|
|
@@ -35,17 +35,23 @@ async function acquireExclusiveFileLock(targetPath, options = {}) {
|
|
|
35
35
|
continue;
|
|
36
36
|
}
|
|
37
37
|
const ownerToken = randomUUID();
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
try {
|
|
39
|
+
await handle.writeFile(
|
|
40
|
+
`${JSON.stringify({ pid: process.pid, ownerToken, createdAt: Date.now() })}
|
|
40
41
|
`
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
);
|
|
43
|
+
await handle.sync();
|
|
44
|
+
} catch (error) {
|
|
45
|
+
await handle.close().catch(() => void 0);
|
|
46
|
+
await unlink(lockPath).catch(() => void 0);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
await handle.close();
|
|
43
50
|
let released = false;
|
|
44
51
|
return {
|
|
45
52
|
release: async () => {
|
|
46
53
|
if (released) return;
|
|
47
54
|
released = true;
|
|
48
|
-
await handle.close();
|
|
49
55
|
const currentOwner = await readFile(lockPath, "utf8").then((raw) => JSON.parse(raw).ownerToken).catch(() => void 0);
|
|
50
56
|
if (currentOwner === ownerToken) await unlink(lockPath).catch(() => void 0);
|
|
51
57
|
}
|
|
@@ -517,7 +523,7 @@ import path2 from "path";
|
|
|
517
523
|
// package.json
|
|
518
524
|
var package_default = {
|
|
519
525
|
name: "@buda-ai/connector",
|
|
520
|
-
version: "0.1.
|
|
526
|
+
version: "0.1.24",
|
|
521
527
|
private: false,
|
|
522
528
|
type: "module",
|
|
523
529
|
publishConfig: {
|
|
@@ -2627,6 +2633,10 @@ var compareVersions = (left, right) => {
|
|
|
2627
2633
|
return 0;
|
|
2628
2634
|
};
|
|
2629
2635
|
var shouldReplaceDaemonVersion = (runningVersion, candidateVersion) => compareVersions(candidateVersion, runningVersion) > 0;
|
|
2636
|
+
var shouldDisplayConnectorLogEntry = (createdAt, startedAt) => {
|
|
2637
|
+
const timestamp = Date.parse(createdAt);
|
|
2638
|
+
return Number.isNaN(timestamp) || timestamp >= startedAt;
|
|
2639
|
+
};
|
|
2630
2640
|
var getErrorCode = (error) => typeof error === "object" && error !== null && "code" in error ? String(error.code) : "UNKNOWN";
|
|
2631
2641
|
var waitForChildSpawn = (child) => new Promise((resolve, reject) => {
|
|
2632
2642
|
const onError = (error) => {
|
|
@@ -2773,6 +2783,7 @@ var streamDaemonLogs = (options) => {
|
|
|
2773
2783
|
for (const line of lines.slice(seenLines)) {
|
|
2774
2784
|
try {
|
|
2775
2785
|
const entry = JSON.parse(line);
|
|
2786
|
+
if (!shouldDisplayConnectorLogEntry(entry.createdAt, options.startedAt)) continue;
|
|
2776
2787
|
const connectorId = entry.metadata?.connectorId;
|
|
2777
2788
|
if (options.dashboardActive && typeof connectorId === "string") {
|
|
2778
2789
|
const output2 = entry.metadata?.source === "daemon-console" ? entry.message : `[buda-connector] ${entry.message}`;
|
|
@@ -2883,6 +2894,7 @@ var waitForConnectorViewerExit = async (dashboardClosed) => {
|
|
|
2883
2894
|
process.off("SIGTERM", finishSignal);
|
|
2884
2895
|
};
|
|
2885
2896
|
async function runConnectorDashboard(launchConfig, options = {}) {
|
|
2897
|
+
const startedAt = Date.now();
|
|
2886
2898
|
let finishDashboard = () => void 0;
|
|
2887
2899
|
const dashboardClosed = new Promise((resolve) => {
|
|
2888
2900
|
finishDashboard = resolve;
|
|
@@ -2903,7 +2915,8 @@ async function runConnectorDashboard(launchConfig, options = {}) {
|
|
|
2903
2915
|
connectorId: config.connectorId,
|
|
2904
2916
|
dashboardActive: false,
|
|
2905
2917
|
plain: Boolean(options.plain),
|
|
2906
|
-
serverUrl: config.serverUrl
|
|
2918
|
+
serverUrl: config.serverUrl,
|
|
2919
|
+
startedAt
|
|
2907
2920
|
});
|
|
2908
2921
|
if (!process.stdin.isTTY) {
|
|
2909
2922
|
stopLogs2();
|
|
@@ -2930,7 +2943,8 @@ async function runConnectorDashboard(launchConfig, options = {}) {
|
|
|
2930
2943
|
const stopLogs = streamDaemonLogs({
|
|
2931
2944
|
dashboardActive: true,
|
|
2932
2945
|
plain: false,
|
|
2933
|
-
serverUrl: getServerUrl(launchConfig)
|
|
2946
|
+
serverUrl: getServerUrl(launchConfig),
|
|
2947
|
+
startedAt
|
|
2934
2948
|
});
|
|
2935
2949
|
let refreshing = false;
|
|
2936
2950
|
const refresh = async () => {
|