@buda-ai/connector 0.1.31 → 0.1.32
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 -23
- 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.32",
|
|
521
521
|
private: false,
|
|
522
522
|
type: "module",
|
|
523
523
|
publishConfig: {
|
|
@@ -2405,25 +2405,66 @@ async function unregisterConnector(config, launchConfig) {
|
|
|
2405
2405
|
// src/runtime-install.ts
|
|
2406
2406
|
import { execFile } from "child_process";
|
|
2407
2407
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
2408
|
-
import {
|
|
2408
|
+
import {
|
|
2409
|
+
access,
|
|
2410
|
+
cp,
|
|
2411
|
+
mkdir as mkdir5,
|
|
2412
|
+
readdir as readdir4,
|
|
2413
|
+
readFile as readFile5,
|
|
2414
|
+
realpath,
|
|
2415
|
+
rename as rename4,
|
|
2416
|
+
rm,
|
|
2417
|
+
writeFile as writeFile3
|
|
2418
|
+
} from "fs/promises";
|
|
2409
2419
|
import { homedir as homedir3 } from "os";
|
|
2410
2420
|
import path6 from "path";
|
|
2411
2421
|
import { promisify } from "util";
|
|
2412
2422
|
var execFileAsync = promisify(execFile);
|
|
2413
2423
|
var RUNTIME_INSTALL_TIMEOUT_MS = 5 * 6e4;
|
|
2414
2424
|
var MACOS_NODE_LIBRARY_PATTERN = /^libnode(?:\.\d+)*\.dylib$/;
|
|
2425
|
+
var getLoadedSharedObjects = () => {
|
|
2426
|
+
const report = process.report?.getReport();
|
|
2427
|
+
return Array.isArray(report?.sharedObjects) ? report.sharedObjects.filter((value) => typeof value === "string") : [];
|
|
2428
|
+
};
|
|
2415
2429
|
var copyNodeRuntime = async (sourceNode, destinationNode, options = {}) => {
|
|
2416
|
-
const
|
|
2430
|
+
const resolvedSourceNode = await realpath(sourceNode);
|
|
2431
|
+
const sourceDirectory = path6.dirname(resolvedSourceNode);
|
|
2417
2432
|
const destinationDirectory = path6.dirname(destinationNode);
|
|
2418
2433
|
await mkdir5(destinationDirectory, { recursive: true });
|
|
2419
|
-
await cp(
|
|
2434
|
+
await cp(resolvedSourceNode, destinationNode, { dereference: true, force: true });
|
|
2420
2435
|
if ((options.platform ?? process.platform) !== "darwin") return;
|
|
2421
|
-
const
|
|
2436
|
+
const launcherDirectory = path6.resolve(path6.dirname(sourceNode));
|
|
2437
|
+
const companionDirectories = [
|
|
2438
|
+
.../* @__PURE__ */ new Set([
|
|
2439
|
+
launcherDirectory,
|
|
2440
|
+
path6.resolve(launcherDirectory, "..", "lib"),
|
|
2441
|
+
sourceDirectory,
|
|
2442
|
+
path6.resolve(sourceDirectory, "..", "lib")
|
|
2443
|
+
])
|
|
2444
|
+
];
|
|
2445
|
+
const companions = (await Promise.all(
|
|
2446
|
+
companionDirectories.map(async (directory) => ({
|
|
2447
|
+
directory,
|
|
2448
|
+
entries: await readdir4(directory, { withFileTypes: true }).catch((error) => {
|
|
2449
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return [];
|
|
2450
|
+
throw error;
|
|
2451
|
+
})
|
|
2452
|
+
}))
|
|
2453
|
+
)).flatMap(({ directory, entries }) => entries.map((entry) => ({ directory, entry })));
|
|
2454
|
+
const companionFiles = /* @__PURE__ */ new Map();
|
|
2455
|
+
const loadedLibraries = options.loadedLibraries ?? getLoadedSharedObjects();
|
|
2456
|
+
for (const library of loadedLibraries) {
|
|
2457
|
+
const name = path6.basename(library);
|
|
2458
|
+
if (MACOS_NODE_LIBRARY_PATTERN.test(name)) companionFiles.set(name, library);
|
|
2459
|
+
}
|
|
2460
|
+
for (const { directory, entry } of companions) {
|
|
2461
|
+
if ((entry.isFile() || entry.isSymbolicLink()) && MACOS_NODE_LIBRARY_PATTERN.test(entry.name) && !companionFiles.has(entry.name)) {
|
|
2462
|
+
companionFiles.set(entry.name, path6.join(directory, entry.name));
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2422
2465
|
await Promise.all(
|
|
2423
|
-
|
|
2424
|
-
(
|
|
2425
|
-
).map(
|
|
2426
|
-
(entry) => cp(path6.join(sourceDirectory, entry.name), path6.join(destinationDirectory, entry.name), {
|
|
2466
|
+
[...companionFiles].map(
|
|
2467
|
+
([name, source]) => cp(source, path6.join(destinationDirectory, name), {
|
|
2427
2468
|
dereference: true,
|
|
2428
2469
|
force: true
|
|
2429
2470
|
})
|
|
@@ -3394,7 +3435,7 @@ import {
|
|
|
3394
3435
|
readdir as readdir5,
|
|
3395
3436
|
readFile as readFile7,
|
|
3396
3437
|
readlink,
|
|
3397
|
-
realpath,
|
|
3438
|
+
realpath as realpath2,
|
|
3398
3439
|
rename as rename5,
|
|
3399
3440
|
rm as rm2,
|
|
3400
3441
|
symlink,
|
|
@@ -3446,7 +3487,7 @@ var migrateLegacyWorkspaceRoot = async (storageRoot, options = {}) => {
|
|
|
3446
3487
|
"Legacy migration storage root must be a real directory"
|
|
3447
3488
|
);
|
|
3448
3489
|
}
|
|
3449
|
-
const canonicalRoot = await
|
|
3490
|
+
const canonicalRoot = await realpath2(storageRoot);
|
|
3450
3491
|
const migrationDirectory = path9.join(canonicalRoot, MIGRATION_DIRECTORY);
|
|
3451
3492
|
await ensurePrivateDirectoryWithin(canonicalRoot, migrationDirectory);
|
|
3452
3493
|
const journalPath = path9.join(migrationDirectory, JOURNAL_FILENAME);
|
|
@@ -4089,7 +4130,7 @@ function isNonEmptyString(value) {
|
|
|
4089
4130
|
}
|
|
4090
4131
|
|
|
4091
4132
|
// src/html-preview.ts
|
|
4092
|
-
import { readFile as readFile8, realpath as
|
|
4133
|
+
import { readFile as readFile8, realpath as realpath3, stat as stat4 } from "fs/promises";
|
|
4093
4134
|
import { createServer as createServer2 } from "http";
|
|
4094
4135
|
import path10 from "path";
|
|
4095
4136
|
var PREVIEW_HOST = "127.0.0.1";
|
|
@@ -4179,7 +4220,7 @@ var resolveWorkspaceFile = async (input) => {
|
|
|
4179
4220
|
const virtualPath = input.filePath.replaceAll("\\", "/");
|
|
4180
4221
|
if (virtualPath.includes("\0")) throw new Error("HTML preview path contains invalid data.");
|
|
4181
4222
|
const mountPath = path10.resolve(input.mounts[input.rootVolume]);
|
|
4182
|
-
const root = await
|
|
4223
|
+
const root = await realpath3(mountPath);
|
|
4183
4224
|
let relativePath = virtualPath;
|
|
4184
4225
|
let explicitVolume;
|
|
4185
4226
|
for (const volume of ["agent", "space"]) {
|
|
@@ -4209,7 +4250,7 @@ var resolveWorkspaceFile = async (input) => {
|
|
|
4209
4250
|
}
|
|
4210
4251
|
const candidate = path10.resolve(root, ...segments);
|
|
4211
4252
|
assertContained(root, candidate);
|
|
4212
|
-
const canonicalFile = await
|
|
4253
|
+
const canonicalFile = await realpath3(candidate);
|
|
4213
4254
|
assertContained(root, canonicalFile);
|
|
4214
4255
|
const fileStat = await stat4(canonicalFile);
|
|
4215
4256
|
if (!fileStat.isFile()) throw new Error("HTML preview path must identify a file.");
|
|
@@ -4271,10 +4312,10 @@ var serveStaticFile = async (folder, method, requestUrl) => {
|
|
|
4271
4312
|
try {
|
|
4272
4313
|
const candidate = path10.resolve(folder, ...segments);
|
|
4273
4314
|
assertContained(folder, candidate);
|
|
4274
|
-
let canonicalFile = await
|
|
4315
|
+
let canonicalFile = await realpath3(candidate);
|
|
4275
4316
|
assertContained(folder, canonicalFile);
|
|
4276
4317
|
if ((await stat4(canonicalFile)).isDirectory()) {
|
|
4277
|
-
canonicalFile = await
|
|
4318
|
+
canonicalFile = await realpath3(path10.join(canonicalFile, "index.html"));
|
|
4278
4319
|
assertContained(folder, canonicalFile);
|
|
4279
4320
|
}
|
|
4280
4321
|
if (!(await stat4(canonicalFile)).isFile()) throw new Error("Not a file");
|
|
@@ -4309,7 +4350,7 @@ import {
|
|
|
4309
4350
|
mkdir as mkdir9,
|
|
4310
4351
|
readdir as readdir6,
|
|
4311
4352
|
readFile as readFile9,
|
|
4312
|
-
realpath as
|
|
4353
|
+
realpath as realpath4,
|
|
4313
4354
|
rm as rm3,
|
|
4314
4355
|
symlink as symlink2,
|
|
4315
4356
|
writeFile as writeFile4
|
|
@@ -4447,7 +4488,7 @@ var WorkspaceVolumeLifecycle = class {
|
|
|
4447
4488
|
]) {
|
|
4448
4489
|
await mkdir9(volume, { recursive: true, mode: 448 });
|
|
4449
4490
|
const info = await lstat2(volume);
|
|
4450
|
-
if (info.isSymbolicLink() || !info.isDirectory() || await
|
|
4491
|
+
if (info.isSymbolicLink() || !info.isDirectory() || await realpath4(volume) !== volume) {
|
|
4451
4492
|
throw new Error("Workspace volume must be a canonical real directory");
|
|
4452
4493
|
}
|
|
4453
4494
|
}
|
|
@@ -4460,7 +4501,7 @@ var isMissingFile = (error) => error instanceof Error && "code" in error && erro
|
|
|
4460
4501
|
var ensureVolumeLink = async (target, linkPath) => {
|
|
4461
4502
|
try {
|
|
4462
4503
|
const info = await lstat2(linkPath);
|
|
4463
|
-
if (!info.isSymbolicLink() || await
|
|
4504
|
+
if (!info.isSymbolicLink() || await realpath4(linkPath) !== target) {
|
|
4464
4505
|
throw new Error("Workspace mount link does not match its canonical volume");
|
|
4465
4506
|
}
|
|
4466
4507
|
} catch (error) {
|
|
@@ -4470,7 +4511,7 @@ var ensureVolumeLink = async (target, linkPath) => {
|
|
|
4470
4511
|
} catch (createError) {
|
|
4471
4512
|
if (!isAlreadyExists3(createError)) throw createError;
|
|
4472
4513
|
const info = await lstat2(linkPath);
|
|
4473
|
-
if (!info.isSymbolicLink() || await
|
|
4514
|
+
if (!info.isSymbolicLink() || await realpath4(linkPath) !== target) {
|
|
4474
4515
|
throw new Error("Workspace mount link raced with an invalid target");
|
|
4475
4516
|
}
|
|
4476
4517
|
}
|
|
@@ -5117,7 +5158,7 @@ import {
|
|
|
5117
5158
|
mkdir as mkdir11,
|
|
5118
5159
|
open as open3,
|
|
5119
5160
|
readFile as readFile10,
|
|
5120
|
-
realpath as
|
|
5161
|
+
realpath as realpath5,
|
|
5121
5162
|
rename as rename6,
|
|
5122
5163
|
statfs,
|
|
5123
5164
|
unlink as unlink7
|
|
@@ -5281,7 +5322,7 @@ var reconcileWorkspace = async (workspace, storageRoot) => {
|
|
|
5281
5322
|
for (const volume of volumes) {
|
|
5282
5323
|
assertContained2(storageRoot, volume);
|
|
5283
5324
|
await ensurePrivateDirectory2(volume);
|
|
5284
|
-
const canonical = await
|
|
5325
|
+
const canonical = await realpath5(volume);
|
|
5285
5326
|
if (canonical !== volume) throw corrupt2("Workspace path resolves through a symbolic link");
|
|
5286
5327
|
}
|
|
5287
5328
|
};
|
|
@@ -5327,7 +5368,7 @@ var canonicalDirectory = async (directory, label) => {
|
|
|
5327
5368
|
if (info.isSymbolicLink() || !info.isDirectory()) {
|
|
5328
5369
|
throw new WorkspaceRegistryError("STORAGE_UNSAFE", `${label} must be a real directory`);
|
|
5329
5370
|
}
|
|
5330
|
-
return
|
|
5371
|
+
return realpath5(directory);
|
|
5331
5372
|
};
|
|
5332
5373
|
var rejectUnsafeFilesystem = async (storageRoot) => {
|
|
5333
5374
|
const stats = await statfs(storageRoot, { bigint: true });
|