agent-neckbeard 1.0.7 → 1.0.9
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.
Potentially problematic release.
This version of agent-neckbeard might be problematic. Click here for more details.
- package/dist/index.cjs +43 -3
- package/dist/index.js +51 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -348,7 +348,13 @@ try {
|
|
|
348
348
|
if (collectedExternals.size > 0) {
|
|
349
349
|
const dependencies = {};
|
|
350
350
|
for (const pkg of collectedExternals) {
|
|
351
|
-
|
|
351
|
+
try {
|
|
352
|
+
const pkgJsonPath = require.resolve(`${pkg}/package.json`, { paths: [(0, import_node_path.dirname)(this._sourceFile)] });
|
|
353
|
+
const pkgJson2 = JSON.parse((0, import_node_fs.readFileSync)(pkgJsonPath, "utf-8"));
|
|
354
|
+
dependencies[pkg] = pkgJson2.version;
|
|
355
|
+
} catch {
|
|
356
|
+
dependencies[pkg] = "*";
|
|
357
|
+
}
|
|
352
358
|
}
|
|
353
359
|
const pkgJson = JSON.stringify({
|
|
354
360
|
name: "agent-sandbox",
|
|
@@ -401,18 +407,52 @@ try {
|
|
|
401
407
|
apiKey: e2bApiKey
|
|
402
408
|
});
|
|
403
409
|
await sandbox.files.write(SANDBOX_PATHS.taskJson, JSON.stringify({ input: validatedInput, executionId }));
|
|
410
|
+
let capturedStdout = "";
|
|
411
|
+
let capturedStderr = "";
|
|
404
412
|
const result = await sandbox.commands.run(`node ${SANDBOX_PATHS.runnerModule}`, {
|
|
405
413
|
timeoutMs: this.maxDuration * 1e3,
|
|
406
414
|
envs: {
|
|
407
415
|
ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY ?? ""
|
|
416
|
+
},
|
|
417
|
+
onStdout: (data) => {
|
|
418
|
+
capturedStdout += data;
|
|
419
|
+
},
|
|
420
|
+
onStderr: (data) => {
|
|
421
|
+
capturedStderr += data;
|
|
408
422
|
}
|
|
409
423
|
});
|
|
410
424
|
if (result.exitCode !== 0) {
|
|
411
|
-
|
|
425
|
+
let resultError = "";
|
|
426
|
+
try {
|
|
427
|
+
const resultJson = await sandbox.files.read(SANDBOX_PATHS.resultJson);
|
|
428
|
+
const parsed = JSON.parse(resultJson);
|
|
429
|
+
if (!parsed.success && parsed.error) {
|
|
430
|
+
resultError = `
|
|
431
|
+
Result: ${parsed.error.message}`;
|
|
432
|
+
if (parsed.error.stack) resultError += `
|
|
433
|
+
Stack: ${parsed.error.stack}`;
|
|
434
|
+
}
|
|
435
|
+
} catch {
|
|
436
|
+
}
|
|
437
|
+
const errorDetails = [
|
|
438
|
+
`Agent failed with exit code ${result.exitCode}`,
|
|
439
|
+
result.stderr ? `Stderr: ${result.stderr}` : "",
|
|
440
|
+
capturedStderr ? `Captured stderr: ${capturedStderr}` : "",
|
|
441
|
+
capturedStdout ? `Stdout: ${capturedStdout}` : "",
|
|
442
|
+
resultError
|
|
443
|
+
].filter(Boolean).join("\n");
|
|
444
|
+
return { ok: false, executionId, error: new ExecutionError(errorDetails) };
|
|
412
445
|
}
|
|
413
446
|
const output = JSON.parse(await sandbox.files.read(SANDBOX_PATHS.resultJson));
|
|
414
447
|
if (!output.success) {
|
|
415
|
-
const
|
|
448
|
+
const errorDetails = [
|
|
449
|
+
output.error.message,
|
|
450
|
+
capturedStderr ? `
|
|
451
|
+
Captured stderr: ${capturedStderr}` : "",
|
|
452
|
+
capturedStdout ? `
|
|
453
|
+
Stdout: ${capturedStdout}` : ""
|
|
454
|
+
].filter(Boolean).join("");
|
|
455
|
+
const err = new ExecutionError(errorDetails);
|
|
416
456
|
err.stack = output.error.stack;
|
|
417
457
|
return { ok: false, executionId, error: err };
|
|
418
458
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
1
8
|
// src/index.ts
|
|
2
9
|
import { fileURLToPath } from "url";
|
|
3
10
|
import { readdirSync, readFileSync, statSync } from "fs";
|
|
4
|
-
import { join, relative } from "path";
|
|
11
|
+
import { join, relative, dirname } from "path";
|
|
5
12
|
var getEsbuild = () => import("esbuild");
|
|
6
13
|
var getE2b = () => import("e2b");
|
|
7
14
|
var DEFAULT_MAX_DURATION = 300;
|
|
@@ -308,7 +315,13 @@ try {
|
|
|
308
315
|
if (collectedExternals.size > 0) {
|
|
309
316
|
const dependencies = {};
|
|
310
317
|
for (const pkg of collectedExternals) {
|
|
311
|
-
|
|
318
|
+
try {
|
|
319
|
+
const pkgJsonPath = __require.resolve(`${pkg}/package.json`, { paths: [dirname(this._sourceFile)] });
|
|
320
|
+
const pkgJson2 = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
|
|
321
|
+
dependencies[pkg] = pkgJson2.version;
|
|
322
|
+
} catch {
|
|
323
|
+
dependencies[pkg] = "*";
|
|
324
|
+
}
|
|
312
325
|
}
|
|
313
326
|
const pkgJson = JSON.stringify({
|
|
314
327
|
name: "agent-sandbox",
|
|
@@ -361,18 +374,52 @@ try {
|
|
|
361
374
|
apiKey: e2bApiKey
|
|
362
375
|
});
|
|
363
376
|
await sandbox.files.write(SANDBOX_PATHS.taskJson, JSON.stringify({ input: validatedInput, executionId }));
|
|
377
|
+
let capturedStdout = "";
|
|
378
|
+
let capturedStderr = "";
|
|
364
379
|
const result = await sandbox.commands.run(`node ${SANDBOX_PATHS.runnerModule}`, {
|
|
365
380
|
timeoutMs: this.maxDuration * 1e3,
|
|
366
381
|
envs: {
|
|
367
382
|
ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY ?? ""
|
|
383
|
+
},
|
|
384
|
+
onStdout: (data) => {
|
|
385
|
+
capturedStdout += data;
|
|
386
|
+
},
|
|
387
|
+
onStderr: (data) => {
|
|
388
|
+
capturedStderr += data;
|
|
368
389
|
}
|
|
369
390
|
});
|
|
370
391
|
if (result.exitCode !== 0) {
|
|
371
|
-
|
|
392
|
+
let resultError = "";
|
|
393
|
+
try {
|
|
394
|
+
const resultJson = await sandbox.files.read(SANDBOX_PATHS.resultJson);
|
|
395
|
+
const parsed = JSON.parse(resultJson);
|
|
396
|
+
if (!parsed.success && parsed.error) {
|
|
397
|
+
resultError = `
|
|
398
|
+
Result: ${parsed.error.message}`;
|
|
399
|
+
if (parsed.error.stack) resultError += `
|
|
400
|
+
Stack: ${parsed.error.stack}`;
|
|
401
|
+
}
|
|
402
|
+
} catch {
|
|
403
|
+
}
|
|
404
|
+
const errorDetails = [
|
|
405
|
+
`Agent failed with exit code ${result.exitCode}`,
|
|
406
|
+
result.stderr ? `Stderr: ${result.stderr}` : "",
|
|
407
|
+
capturedStderr ? `Captured stderr: ${capturedStderr}` : "",
|
|
408
|
+
capturedStdout ? `Stdout: ${capturedStdout}` : "",
|
|
409
|
+
resultError
|
|
410
|
+
].filter(Boolean).join("\n");
|
|
411
|
+
return { ok: false, executionId, error: new ExecutionError(errorDetails) };
|
|
372
412
|
}
|
|
373
413
|
const output = JSON.parse(await sandbox.files.read(SANDBOX_PATHS.resultJson));
|
|
374
414
|
if (!output.success) {
|
|
375
|
-
const
|
|
415
|
+
const errorDetails = [
|
|
416
|
+
output.error.message,
|
|
417
|
+
capturedStderr ? `
|
|
418
|
+
Captured stderr: ${capturedStderr}` : "",
|
|
419
|
+
capturedStdout ? `
|
|
420
|
+
Stdout: ${capturedStdout}` : ""
|
|
421
|
+
].filter(Boolean).join("");
|
|
422
|
+
const err = new ExecutionError(errorDetails);
|
|
376
423
|
err.stack = output.error.stack;
|
|
377
424
|
return { ok: false, executionId, error: err };
|
|
378
425
|
}
|