@blaxel/core 0.2.67 → 0.2.68-dev.94

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.
@@ -198,23 +198,16 @@ export function initSentry() {
198
198
  process.exit(signal === "SIGTERM" ? 143 : 130);
199
199
  });
200
200
  };
201
- // Uncaught exception handler - only capture SDK errors
202
- const uncaughtExceptionHandler = (error) => {
203
- if (isFromSDK(error)) {
204
- captureException(error);
205
- }
206
- };
207
- // Unhandled rejection handler - only capture SDK errors
208
- const unhandledRejectionHandler = (reason) => {
209
- const error = reason instanceof Error ? reason : new Error(String(reason));
201
+ // Monitor uncaught exceptions to capture SDK errors without
202
+ // preventing Node.js default crash behavior (print + exit).
203
+ const uncaughtExceptionMonitorHandler = (error) => {
210
204
  if (isFromSDK(error)) {
211
205
  captureException(error);
212
206
  }
213
207
  };
214
208
  process.on("SIGTERM", () => signalHandler("SIGTERM"));
215
209
  process.on("SIGINT", () => signalHandler("SIGINT"));
216
- process.on("uncaughtException", uncaughtExceptionHandler);
217
- process.on("unhandledRejection", unhandledRejectionHandler);
210
+ process.on("uncaughtExceptionMonitor", uncaughtExceptionMonitorHandler);
218
211
  // Intercept console.error to capture SDK errors that are caught and logged
219
212
  const originalConsoleError = console.error;
220
213
  console.error = function (...args) {
@@ -3,8 +3,8 @@ import { authentication } from "../authentication/index.js";
3
3
  import { env } from "../common/env.js";
4
4
  import { fs, os, path } from "../common/node.js";
5
5
  // Build info - these placeholders are replaced at build time by build:replace-imports
6
- const BUILD_VERSION = "0.2.67";
7
- const BUILD_COMMIT = "3a64eedabba6c905c7dbba66fd6e8c036afdc3dd";
6
+ const BUILD_VERSION = "0.2.68-dev.94";
7
+ const BUILD_COMMIT = "14ccbafeb7ce8418b80f9cf18cc629ce055e6151";
8
8
  const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
9
9
  // Cache for config.yaml tracking value
10
10
  let configTrackingValue = null;
@@ -115,6 +115,206 @@ export class ImageInstance {
115
115
  }
116
116
  return new ImageInstance(newContext);
117
117
  }
118
+ pipInstall(...args) {
119
+ let options = {};
120
+ let packages;
121
+ if (args.length > 0 && typeof args[0] === "object") {
122
+ options = args[0];
123
+ packages = args.slice(1);
124
+ }
125
+ else {
126
+ packages = args;
127
+ }
128
+ if (packages.length === 0)
129
+ return this;
130
+ const opts = [];
131
+ if (options.findLinks)
132
+ opts.push(`--find-links ${options.findLinks}`);
133
+ if (options.indexUrl)
134
+ opts.push(`--index-url ${options.indexUrl}`);
135
+ if (options.extraIndexUrl)
136
+ opts.push(`--extra-index-url ${options.extraIndexUrl}`);
137
+ if (options.pre)
138
+ opts.push("--pre");
139
+ if (options.extraOptions)
140
+ opts.push(options.extraOptions);
141
+ const cmd = ["pip install", ...opts, ...packages].join(" ").replace(/\s+/g, " ").trim();
142
+ return this.runCommands(cmd);
143
+ }
144
+ aptInstall(...args) {
145
+ let options = {};
146
+ let packages;
147
+ if (args.length > 0 && typeof args[0] === "object") {
148
+ options = args[0];
149
+ packages = args.slice(1);
150
+ }
151
+ else {
152
+ packages = args;
153
+ }
154
+ if (packages.length === 0)
155
+ return this;
156
+ const update = options.update ?? true;
157
+ const clean = options.clean ?? true;
158
+ const parts = [];
159
+ if (update)
160
+ parts.push("apt-get update");
161
+ parts.push(`apt-get install -y --no-install-recommends ${packages.join(" ")}`);
162
+ if (clean)
163
+ parts.push("rm -rf /var/lib/apt/lists/*");
164
+ return this.runCommands(parts.join(" && "));
165
+ }
166
+ apkAdd(...args) {
167
+ let options = {};
168
+ let packages;
169
+ if (args.length > 0 && typeof args[0] === "object") {
170
+ options = args[0];
171
+ packages = args.slice(1);
172
+ }
173
+ else {
174
+ packages = args;
175
+ }
176
+ if (packages.length === 0)
177
+ return this;
178
+ const noCache = options.noCache ?? true;
179
+ const update = options.update ?? true;
180
+ const clean = options.clean ?? true;
181
+ const pkgs = packages.join(" ");
182
+ if (noCache) {
183
+ return this.runCommands(`apk add --no-cache ${pkgs}`);
184
+ }
185
+ const parts = [];
186
+ if (update)
187
+ parts.push("apk update");
188
+ parts.push(`apk add ${pkgs}`);
189
+ if (clean)
190
+ parts.push("rm -rf /var/cache/apk/*");
191
+ return this.runCommands(parts.join(" && "));
192
+ }
193
+ npmInstall(...args) {
194
+ let options = {};
195
+ let packages;
196
+ if (args.length > 0 && typeof args[0] === "object") {
197
+ options = args[0];
198
+ packages = args.slice(1);
199
+ }
200
+ else {
201
+ packages = args;
202
+ }
203
+ const pm = (options.packageManager ?? "npm").toLowerCase();
204
+ const g = options.globalInstall ?? false;
205
+ const d = options.saveDev ?? false;
206
+ const pkgs = packages.join(" ");
207
+ let cmd;
208
+ if (!packages.length) {
209
+ // Install from lockfile/package.json
210
+ const installCmds = {
211
+ npm: "npm install",
212
+ yarn: "yarn install",
213
+ pnpm: "pnpm install",
214
+ bun: "bun install",
215
+ };
216
+ cmd = installCmds[pm];
217
+ if (!cmd)
218
+ throw new Error(`Invalid package manager: ${pm}. Must be one of npm, yarn, pnpm, bun`);
219
+ }
220
+ else {
221
+ const addCmds = {
222
+ npm: `npm install ${g ? "-g " : ""}${d ? "--save-dev " : ""}${pkgs}`,
223
+ yarn: `yarn ${g ? "global add" : "add"} ${d && !g ? "--dev " : ""}${pkgs}`,
224
+ pnpm: `pnpm add ${g ? "-g " : ""}${d ? "-D " : ""}${pkgs}`,
225
+ bun: `bun add ${g ? "-g " : ""}${d ? "-d " : ""}${pkgs}`,
226
+ };
227
+ cmd = addCmds[pm];
228
+ if (!cmd)
229
+ throw new Error(`Invalid package manager: ${pm}. Must be one of npm, yarn, pnpm, bun`);
230
+ }
231
+ return this.runCommands(cmd.replace(/\s+/g, " ").trim());
232
+ }
233
+ gemInstall(...args) {
234
+ let options = {};
235
+ let packages;
236
+ if (args.length > 0 && typeof args[0] === "object") {
237
+ options = args[0];
238
+ packages = args.slice(1);
239
+ }
240
+ else {
241
+ packages = args;
242
+ }
243
+ if (packages.length === 0)
244
+ return this;
245
+ const noDoc = options.noDocument ?? true;
246
+ const cmd = `gem install ${noDoc ? "--no-document " : ""}${packages.join(" ")}`.replace(/\s+/g, " ").trim();
247
+ return this.runCommands(cmd);
248
+ }
249
+ cargoInstall(...args) {
250
+ let options = {};
251
+ let packages;
252
+ if (args.length > 0 && typeof args[0] === "object") {
253
+ options = args[0];
254
+ packages = args.slice(1);
255
+ }
256
+ else {
257
+ packages = args;
258
+ }
259
+ if (packages.length === 0)
260
+ return this;
261
+ const cmd = `cargo install ${options.locked ? "--locked " : ""}${packages.join(" ")}`.replace(/\s+/g, " ").trim();
262
+ return this.runCommands(cmd);
263
+ }
264
+ /**
265
+ * Install Go packages.
266
+ */
267
+ goInstall(...packages) {
268
+ if (packages.length === 0)
269
+ return this;
270
+ const commands = packages.map((pkg) => `go install ${pkg}`);
271
+ return this.runCommands(commands.join(" && "));
272
+ }
273
+ composerInstall(...args) {
274
+ let options = {};
275
+ let packages;
276
+ if (args.length > 0 && typeof args[0] === "object") {
277
+ options = args[0];
278
+ packages = args.slice(1);
279
+ }
280
+ else {
281
+ packages = args;
282
+ }
283
+ const flags = `${options.noDev ? "--no-dev " : ""}${options.optimizeAutoloader ? "--optimize-autoloader " : ""}`;
284
+ let cmd;
285
+ if (packages.length > 0) {
286
+ cmd = `composer require ${flags}${packages.join(" ")}`;
287
+ }
288
+ else {
289
+ cmd = `composer install ${flags}`;
290
+ }
291
+ return this.runCommands(cmd.replace(/\s+/g, " ").trim());
292
+ }
293
+ uvInstall(...args) {
294
+ let options = {};
295
+ let packages;
296
+ if (args.length > 0 && typeof args[0] === "object") {
297
+ options = args[0];
298
+ packages = args.slice(1);
299
+ }
300
+ else {
301
+ packages = args;
302
+ }
303
+ if (packages.length === 0)
304
+ return this;
305
+ const system = options.system ?? true;
306
+ const cmd = `uv pip install ${system ? "--system " : ""}${options.upgrade ? "--upgrade " : ""}${packages.join(" ")}`.replace(/\s+/g, " ").trim();
307
+ return this.runCommands(cmd);
308
+ }
309
+ /**
310
+ * Install Python CLI applications using pipx.
311
+ */
312
+ pipxInstall(...packages) {
313
+ if (packages.length === 0)
314
+ return this;
315
+ const commands = packages.map((pkg) => `pipx install ${pkg}`);
316
+ return this.runCommands(commands.join(" && "));
317
+ }
118
318
  /**
119
319
  * Set environment variables.
120
320
  *
@@ -99,6 +99,7 @@ export class McpTool {
99
99
  throw err;
100
100
  }
101
101
  logger.debug(`MCP:${this.name}:Connecting to fallback`);
102
+ this.transportName = undefined;
102
103
  this.transport = await this.getTransport(this.fallbackUrl);
103
104
  await this.client.connect(this.transport);
104
105
  logger.debug(`MCP:${this.name}:Connected to fallback`);