braintrust 3.16.0 → 3.17.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/bin/bt +41 -0
- package/dist/cli.js +17 -3
- package/package.json +17 -3
- package/scripts/bt-helper.js +139 -0
- package/scripts/install.js +153 -0
package/bin/bt
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// Runtime launcher for the `bt` CLI. Resolves the platform-specific binary
|
|
5
|
+
// (installed via the matching `@braintrust/bt-*` optionalDependency, or
|
|
6
|
+
// downloaded by `scripts/install.js` as a fallback) and forwards argv,
|
|
7
|
+
// stdio, signals, and the exit code.
|
|
8
|
+
|
|
9
|
+
const childProcess = require("node:child_process");
|
|
10
|
+
const { getBinaryPath } = require("../scripts/bt-helper");
|
|
11
|
+
|
|
12
|
+
let binaryPath;
|
|
13
|
+
try {
|
|
14
|
+
binaryPath = getBinaryPath();
|
|
15
|
+
} catch (err) {
|
|
16
|
+
console.error(err.message);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const child = childProcess
|
|
21
|
+
.spawn(binaryPath, process.argv.slice(2), {
|
|
22
|
+
stdio: "inherit",
|
|
23
|
+
windowsHide: true,
|
|
24
|
+
})
|
|
25
|
+
.on("error", (err) => {
|
|
26
|
+
console.error(err);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
})
|
|
29
|
+
.on("exit", (code, signal) => {
|
|
30
|
+
if (signal) {
|
|
31
|
+
// Detach our forwarding listener so the re-raised signal hits Node's
|
|
32
|
+
// default handler; otherwise we'd intercept it again and exit 0.
|
|
33
|
+
process.removeAllListeners(signal);
|
|
34
|
+
process.kill(process.pid, signal);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
process.exit(code ?? 1);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
process.on("SIGTERM", () => child.kill("SIGTERM"));
|
|
41
|
+
process.on("SIGINT", () => child.kill("SIGINT"));
|
package/dist/cli.js
CHANGED
|
@@ -1232,7 +1232,7 @@ var require_package = __commonJS({
|
|
|
1232
1232
|
"package.json"(exports2, module2) {
|
|
1233
1233
|
module2.exports = {
|
|
1234
1234
|
name: "braintrust",
|
|
1235
|
-
version: "3.
|
|
1235
|
+
version: "3.17.0",
|
|
1236
1236
|
description: "SDK for integrating Braintrust",
|
|
1237
1237
|
repository: {
|
|
1238
1238
|
type: "git",
|
|
@@ -1251,7 +1251,8 @@ var require_package = __commonJS({
|
|
|
1251
1251
|
"./dist/index.d.mts": "./dist/browser.d.mts"
|
|
1252
1252
|
},
|
|
1253
1253
|
bin: {
|
|
1254
|
-
braintrust: "./dist/cli.js"
|
|
1254
|
+
braintrust: "./dist/cli.js",
|
|
1255
|
+
bt: "./bin/bt"
|
|
1255
1256
|
},
|
|
1256
1257
|
exports: {
|
|
1257
1258
|
"./package.json": "./package.json",
|
|
@@ -1359,9 +1360,13 @@ var require_package = __commonJS({
|
|
|
1359
1360
|
files: [
|
|
1360
1361
|
"dist/**/*",
|
|
1361
1362
|
"dev/dist/**/*",
|
|
1362
|
-
"util/dist/**/*"
|
|
1363
|
+
"util/dist/**/*",
|
|
1364
|
+
"bin/bt",
|
|
1365
|
+
"scripts/bt-helper.js",
|
|
1366
|
+
"scripts/install.js"
|
|
1363
1367
|
],
|
|
1364
1368
|
scripts: {
|
|
1369
|
+
postinstall: "node ./scripts/install.js",
|
|
1365
1370
|
build: 'cross-env NODE_OPTIONS="--max-old-space-size=8192" tsup',
|
|
1366
1371
|
"check:typings": "tsc --noEmit",
|
|
1367
1372
|
watch: "tsup --watch",
|
|
@@ -1456,6 +1461,15 @@ var require_package = __commonJS({
|
|
|
1456
1461
|
peerDependencies: {
|
|
1457
1462
|
zod: "^3.25.34 || ^4.0"
|
|
1458
1463
|
},
|
|
1464
|
+
optionalDependencies: {
|
|
1465
|
+
"@braintrust/bt-darwin-arm64": "0.11.1",
|
|
1466
|
+
"@braintrust/bt-darwin-x64": "0.11.1",
|
|
1467
|
+
"@braintrust/bt-linux-arm64": "0.11.1",
|
|
1468
|
+
"@braintrust/bt-linux-x64": "0.11.1",
|
|
1469
|
+
"@braintrust/bt-linux-x64-musl": "0.11.1",
|
|
1470
|
+
"@braintrust/bt-win32-arm64": "0.11.1",
|
|
1471
|
+
"@braintrust/bt-win32-x64": "0.11.1"
|
|
1472
|
+
},
|
|
1459
1473
|
publishConfig: {
|
|
1460
1474
|
access: "public",
|
|
1461
1475
|
registry: "https://registry.npmjs.org/",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "braintrust",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.0",
|
|
4
4
|
"description": "SDK for integrating Braintrust",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"./dist/index.d.mts": "./dist/browser.d.mts"
|
|
20
20
|
},
|
|
21
21
|
"bin": {
|
|
22
|
-
"braintrust": "./dist/cli.js"
|
|
22
|
+
"braintrust": "./dist/cli.js",
|
|
23
|
+
"bt": "./bin/bt"
|
|
23
24
|
},
|
|
24
25
|
"exports": {
|
|
25
26
|
"./package.json": "./package.json",
|
|
@@ -127,9 +128,13 @@
|
|
|
127
128
|
"files": [
|
|
128
129
|
"dist/**/*",
|
|
129
130
|
"dev/dist/**/*",
|
|
130
|
-
"util/dist/**/*"
|
|
131
|
+
"util/dist/**/*",
|
|
132
|
+
"bin/bt",
|
|
133
|
+
"scripts/bt-helper.js",
|
|
134
|
+
"scripts/install.js"
|
|
131
135
|
],
|
|
132
136
|
"scripts": {
|
|
137
|
+
"postinstall": "node ./scripts/install.js",
|
|
133
138
|
"build": "cross-env NODE_OPTIONS=\"--max-old-space-size=8192\" tsup",
|
|
134
139
|
"check:typings": "tsc --noEmit",
|
|
135
140
|
"watch": "tsup --watch",
|
|
@@ -224,6 +229,15 @@
|
|
|
224
229
|
"peerDependencies": {
|
|
225
230
|
"zod": "^3.25.34 || ^4.0"
|
|
226
231
|
},
|
|
232
|
+
"optionalDependencies": {
|
|
233
|
+
"@braintrust/bt-darwin-arm64": "0.11.1",
|
|
234
|
+
"@braintrust/bt-darwin-x64": "0.11.1",
|
|
235
|
+
"@braintrust/bt-linux-arm64": "0.11.1",
|
|
236
|
+
"@braintrust/bt-linux-x64": "0.11.1",
|
|
237
|
+
"@braintrust/bt-linux-x64-musl": "0.11.1",
|
|
238
|
+
"@braintrust/bt-win32-arm64": "0.11.1",
|
|
239
|
+
"@braintrust/bt-win32-x64": "0.11.1"
|
|
240
|
+
},
|
|
227
241
|
"publishConfig": {
|
|
228
242
|
"access": "public",
|
|
229
243
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Shared helpers for locating the `bt` binary. Used by both `bin/bt`
|
|
4
|
+
// (the runtime launcher) and `scripts/install.js` (the postinstall
|
|
5
|
+
// fallback downloader).
|
|
6
|
+
|
|
7
|
+
const fs = require("node:fs");
|
|
8
|
+
const os = require("node:os");
|
|
9
|
+
const path = require("node:path");
|
|
10
|
+
|
|
11
|
+
const BINARY_DISTRIBUTIONS = [
|
|
12
|
+
{ packageName: "@braintrust/bt-darwin-arm64", subpath: "bin/bt" },
|
|
13
|
+
{ packageName: "@braintrust/bt-darwin-x64", subpath: "bin/bt" },
|
|
14
|
+
{ packageName: "@braintrust/bt-linux-arm64", subpath: "bin/bt" },
|
|
15
|
+
{ packageName: "@braintrust/bt-linux-x64", subpath: "bin/bt" },
|
|
16
|
+
{ packageName: "@braintrust/bt-linux-x64-musl", subpath: "bin/bt" },
|
|
17
|
+
{ packageName: "@braintrust/bt-win32-arm64", subpath: "bin/bt.exe" },
|
|
18
|
+
{ packageName: "@braintrust/bt-win32-x64", subpath: "bin/bt.exe" },
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
function detectLibc() {
|
|
22
|
+
if (process.platform !== "linux") return null;
|
|
23
|
+
try {
|
|
24
|
+
const report = process.report && process.report.getReport();
|
|
25
|
+
if (report && report.header && report.header.glibcVersionRuntime) {
|
|
26
|
+
return "glibc";
|
|
27
|
+
}
|
|
28
|
+
return "musl";
|
|
29
|
+
} catch {
|
|
30
|
+
return "glibc";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function binaryName() {
|
|
35
|
+
return process.platform === "win32" ? "bt.exe" : "bt";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function getDistributionForThisPlatform() {
|
|
39
|
+
const arch = os.arch();
|
|
40
|
+
const platform = os.platform();
|
|
41
|
+
const subpath = `bin/${binaryName()}`;
|
|
42
|
+
|
|
43
|
+
let packageName;
|
|
44
|
+
if (platform === "darwin") {
|
|
45
|
+
if (arch === "arm64") packageName = "@braintrust/bt-darwin-arm64";
|
|
46
|
+
else if (arch === "x64") packageName = "@braintrust/bt-darwin-x64";
|
|
47
|
+
} else if (platform === "linux") {
|
|
48
|
+
if (arch === "arm64") {
|
|
49
|
+
packageName = "@braintrust/bt-linux-arm64";
|
|
50
|
+
} else if (arch === "x64") {
|
|
51
|
+
packageName =
|
|
52
|
+
detectLibc() === "musl"
|
|
53
|
+
? "@braintrust/bt-linux-x64-musl"
|
|
54
|
+
: "@braintrust/bt-linux-x64";
|
|
55
|
+
}
|
|
56
|
+
} else if (platform === "win32") {
|
|
57
|
+
if (arch === "arm64") packageName = "@braintrust/bt-win32-arm64";
|
|
58
|
+
else if (arch === "x64") packageName = "@braintrust/bt-win32-x64";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return { packageName, subpath };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function throwUnsupportedPlatformError() {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`Unsupported operating system or architecture! The bt CLI does not work on ${process.platform}-${process.arch}.
|
|
67
|
+
|
|
68
|
+
bt supports:
|
|
69
|
+
- macOS (darwin) on arm64 and x64
|
|
70
|
+
- Linux on arm64 and x64 (glibc and musl)
|
|
71
|
+
- Windows on arm64 and x64`,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Constructed indirectly so bundlers (e.g. @vercel/nft) don't statically
|
|
76
|
+
// detect the fallback binary path as an asset to trace.
|
|
77
|
+
function getFallbackBinaryPath() {
|
|
78
|
+
const parts = [__dirname, binaryName()];
|
|
79
|
+
return path.resolve(...parts);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function getBinaryPath() {
|
|
83
|
+
if (process.env.BT_BINARY_PATH) {
|
|
84
|
+
return process.env.BT_BINARY_PATH;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const { packageName, subpath } = getDistributionForThisPlatform();
|
|
88
|
+
|
|
89
|
+
if (packageName === undefined) {
|
|
90
|
+
throwUnsupportedPlatformError();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Prefer the optional dep so a stale fallback from a prior
|
|
94
|
+
// `--omit=optional` install can't shadow a newer optional dep on upgrade.
|
|
95
|
+
try {
|
|
96
|
+
return require.resolve(`${packageName}/${subpath}`);
|
|
97
|
+
} catch (e) {
|
|
98
|
+
const fallbackBinaryPath = getFallbackBinaryPath();
|
|
99
|
+
if (fs.existsSync(fallbackBinaryPath)) {
|
|
100
|
+
return fallbackBinaryPath;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const otherInstalled = BINARY_DISTRIBUTIONS.find((dist) => {
|
|
104
|
+
try {
|
|
105
|
+
require.resolve(`${dist.packageName}/${dist.subpath}`);
|
|
106
|
+
return true;
|
|
107
|
+
} catch {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Error messages inspired by esbuild:
|
|
113
|
+
// https://github.com/evanw/esbuild/blob/f3d535262e3998d845d0f102b944ecd5a9efda57/lib/npm/node-platform.ts#L150
|
|
114
|
+
if (otherInstalled) {
|
|
115
|
+
throw new Error(
|
|
116
|
+
`bt binary for this platform/architecture not found!
|
|
117
|
+
|
|
118
|
+
The "${otherInstalled.packageName}" package is installed, but for the current platform you should have the "${packageName}" package installed instead. This usually happens if "braintrust" is installed on one platform (for example macOS or Windows) and the "node_modules" folder is then reused on another (for example Linux in Docker).
|
|
119
|
+
|
|
120
|
+
To fix this, avoid copying the "node_modules" folder, and instead freshly install your dependencies on the target system. You can also configure your package manager to install the right package. For example, yarn has the "supportedArchitectures" feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitecture.`,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
throw new Error(
|
|
125
|
+
`bt binary for this platform/architecture not found!
|
|
126
|
+
|
|
127
|
+
It seems like none of the "braintrust" package's optional dependencies got installed. Please make sure your package manager is configured to install optional dependencies. If you are using npm, don't set the "--no-optional", "--ignore-optional", or "--omit=optional" flags. The "braintrust" package needs the "optionalDependencies" feature in order to install the bt binary.`,
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
module.exports = {
|
|
133
|
+
BINARY_DISTRIBUTIONS,
|
|
134
|
+
binaryName,
|
|
135
|
+
getBinaryPath,
|
|
136
|
+
getDistributionForThisPlatform,
|
|
137
|
+
getFallbackBinaryPath,
|
|
138
|
+
throwUnsupportedPlatformError,
|
|
139
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Postinstall script for the `bt` CLI binary.
|
|
4
|
+
//
|
|
5
|
+
// The native binary ships in a per-platform `@braintrust/bt-*` package listed
|
|
6
|
+
// in `optionalDependencies`; npm/pnpm install only the one matching the host.
|
|
7
|
+
// If a package manager is run with `--no-optional`, `--ignore-optional`, or
|
|
8
|
+
// `--omit=optional`, none of those packages get installed and `bt` would be
|
|
9
|
+
// unusable. As a workaround, we manually fetch the matching tarball from the
|
|
10
|
+
// npm registry and extract the binary so the launcher can find it.
|
|
11
|
+
|
|
12
|
+
const fs = require("node:fs");
|
|
13
|
+
const https = require("node:https");
|
|
14
|
+
const path = require("node:path");
|
|
15
|
+
const zlib = require("node:zlib");
|
|
16
|
+
|
|
17
|
+
const helper = require("./bt-helper");
|
|
18
|
+
const pkg = require("../package.json");
|
|
19
|
+
|
|
20
|
+
if (process.env.BT_SKIP_DOWNLOAD === "1") {
|
|
21
|
+
console.log(
|
|
22
|
+
"bt: skipping post-install binary download because BT_SKIP_DOWNLOAD=1 is set.",
|
|
23
|
+
);
|
|
24
|
+
process.exit(0);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const { packageName, subpath } = helper.getDistributionForThisPlatform();
|
|
28
|
+
|
|
29
|
+
if (packageName === undefined) {
|
|
30
|
+
// Don't fail the install; the launcher will surface the unsupported-platform
|
|
31
|
+
// error if/when the user actually tries to run `bt`.
|
|
32
|
+
console.error(
|
|
33
|
+
`bt: no prebuilt binary available for ${process.platform}-${process.arch}; the bt CLI will not be available.`,
|
|
34
|
+
);
|
|
35
|
+
process.exit(0);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
require.resolve(`${packageName}/${subpath}`);
|
|
40
|
+
// Optional dependency was installed successfully. Nothing to do.
|
|
41
|
+
process.exit(0);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
// Fall through to the manual download path below.
|
|
44
|
+
console.log(
|
|
45
|
+
`bt: failed to locate the "${packageName}" package after installation.
|
|
46
|
+
|
|
47
|
+
This can happen if you use an option to disable optional dependencies during installation, like "--no-optional", "--ignore-optional", or "--omit=optional". The "braintrust" package uses the "optionalDependencies" package.json feature to install the correct bt binary for your platform and operating system. This post-install script will now try to work around that by manually downloading the bt binary from the npm registry. If this fails, you need to remove the "--no-optional", "--ignore-optional", and "--omit=optional" flags for bt to work.`,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const version = (pkg.optionalDependencies || {})[packageName];
|
|
52
|
+
if (!version) {
|
|
53
|
+
// Don't fail the parent install: the SDK works without `bt`, and the
|
|
54
|
+
// launcher errors clearly if it's actually invoked.
|
|
55
|
+
console.error(
|
|
56
|
+
`bt: cannot determine which version of "${packageName}" to download — it is not listed in the "braintrust" package's optionalDependencies. The bt CLI will not be available; the rest of the braintrust SDK is unaffected.`,
|
|
57
|
+
);
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function fetchBuffer(url, redirectsRemaining = 5) {
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
https
|
|
64
|
+
.get(url, (response) => {
|
|
65
|
+
const { statusCode = 0, headers } = response;
|
|
66
|
+
if (statusCode >= 200 && statusCode < 300) {
|
|
67
|
+
const chunks = [];
|
|
68
|
+
response.on("data", (chunk) => chunks.push(chunk));
|
|
69
|
+
response.on("end", () => resolve(Buffer.concat(chunks)));
|
|
70
|
+
response.on("error", reject);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (
|
|
74
|
+
statusCode >= 300 &&
|
|
75
|
+
statusCode < 400 &&
|
|
76
|
+
headers.location &&
|
|
77
|
+
redirectsRemaining > 0
|
|
78
|
+
) {
|
|
79
|
+
response.resume();
|
|
80
|
+
fetchBuffer(headers.location, redirectsRemaining - 1).then(
|
|
81
|
+
resolve,
|
|
82
|
+
reject,
|
|
83
|
+
);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
response.resume();
|
|
87
|
+
reject(
|
|
88
|
+
new Error(
|
|
89
|
+
`npm registry responded with status code ${statusCode} when downloading ${url}`,
|
|
90
|
+
),
|
|
91
|
+
);
|
|
92
|
+
})
|
|
93
|
+
.on("error", reject);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Extracts a single file from an uncompressed tar archive. Tar archives are
|
|
98
|
+
// organized in 512-byte blocks: a header block (file name in bytes 0-99,
|
|
99
|
+
// file size in bytes 124-135 as an octal string) followed by data blocks
|
|
100
|
+
// padded out to the next multiple of 512.
|
|
101
|
+
function extractFileFromTarball(tarball, target) {
|
|
102
|
+
let offset = 0;
|
|
103
|
+
while (offset + 512 <= tarball.length) {
|
|
104
|
+
const header = tarball.subarray(offset, offset + 512);
|
|
105
|
+
offset += 512;
|
|
106
|
+
const fileName = header.toString("utf-8", 0, 100).replace(/\0.*/g, "");
|
|
107
|
+
if (!fileName) break;
|
|
108
|
+
const fileSize = parseInt(
|
|
109
|
+
header.toString("utf-8", 124, 136).replace(/\0.*/g, ""),
|
|
110
|
+
8,
|
|
111
|
+
);
|
|
112
|
+
if (fileName === target) {
|
|
113
|
+
return tarball.subarray(offset, offset + fileSize);
|
|
114
|
+
}
|
|
115
|
+
offset = (offset + fileSize + 511) & ~511;
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function downloadFallback() {
|
|
121
|
+
// npm tarball URLs look like:
|
|
122
|
+
// https://registry.npmjs.org/<scope>/<name>/-/<name>-<version>.tgz
|
|
123
|
+
// where <name> is the unscoped package name.
|
|
124
|
+
const tarballName = packageName.split("/").pop();
|
|
125
|
+
const url = `https://registry.npmjs.org/${packageName}/-/${tarballName}-${version}.tgz`;
|
|
126
|
+
console.log(`bt: downloading ${packageName}@${version} from ${url}`);
|
|
127
|
+
|
|
128
|
+
const gzipped = await fetchBuffer(url);
|
|
129
|
+
const tarball = zlib.gunzipSync(gzipped);
|
|
130
|
+
const binary = extractFileFromTarball(tarball, `package/${subpath}`);
|
|
131
|
+
|
|
132
|
+
if (!binary) {
|
|
133
|
+
throw new Error(
|
|
134
|
+
`could not find "package/${subpath}" inside ${packageName}@${version} tarball`,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const fallbackBinaryPath = helper.getFallbackBinaryPath();
|
|
139
|
+
fs.mkdirSync(path.dirname(fallbackBinaryPath), { recursive: true });
|
|
140
|
+
fs.writeFileSync(fallbackBinaryPath, binary);
|
|
141
|
+
fs.chmodSync(fallbackBinaryPath, 0o755);
|
|
142
|
+
console.log(`bt: installed fallback binary at ${fallbackBinaryPath}`);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
downloadFallback().catch((err) => {
|
|
146
|
+
// Don't fail the parent install: airgapped/proxied CI may not reach the
|
|
147
|
+
// npm registry, and the SDK works without `bt`.
|
|
148
|
+
console.error(
|
|
149
|
+
`bt: failed to download fallback binary for ${packageName}@${version}: ${err.message}
|
|
150
|
+
The bt CLI will not be available; the rest of the braintrust SDK is unaffected.`,
|
|
151
|
+
);
|
|
152
|
+
process.exit(0);
|
|
153
|
+
});
|