baro-ai 0.58.1 → 0.59.1
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/runner.mjs +31 -6
- package/dist/runner.mjs.map +1 -1
- package/package.json +1 -1
package/dist/runner.mjs
CHANGED
|
@@ -3713,7 +3713,7 @@ var require_websocket_server = __commonJS({
|
|
|
3713
3713
|
});
|
|
3714
3714
|
|
|
3715
3715
|
// ../baro-orchestrator/scripts/runner.ts
|
|
3716
|
-
import { spawn } from "child_process";
|
|
3716
|
+
import { execFileSync, spawn } from "child_process";
|
|
3717
3717
|
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
3718
3718
|
import { hostname, homedir, tmpdir } from "os";
|
|
3719
3719
|
import { join } from "path";
|
|
@@ -3734,7 +3734,7 @@ var url = process.env.CONTROL_URL ?? "wss://api.baro.jigjoy.ai";
|
|
|
3734
3734
|
var token = process.env.RUNNER_TOKEN;
|
|
3735
3735
|
var httpBase = url.replace(/^ws/, "http").replace(/\/+$/, "");
|
|
3736
3736
|
var credsPath = join(homedir(), ".baro", "credentials.json");
|
|
3737
|
-
var VERSION = "0.
|
|
3737
|
+
var VERSION = "0.59.1";
|
|
3738
3738
|
var updateCachePath = join(homedir(), ".baro", "update-check.json");
|
|
3739
3739
|
function semverLt(a, b) {
|
|
3740
3740
|
const pa = a.split(".").map(Number);
|
|
@@ -3821,26 +3821,48 @@ var runOnce = process.env.BARO_RUN_ONCE === "1";
|
|
|
3821
3821
|
function cloneRepo(fullName, token2, emit) {
|
|
3822
3822
|
return new Promise((resolve, reject) => {
|
|
3823
3823
|
const dir = mkdtempSync(join(tmpdir(), "baro-clone-"));
|
|
3824
|
-
const url2 = `https://x-access-token:${token2}@github.com/${fullName}.git`;
|
|
3824
|
+
const url2 = token2 ? `https://x-access-token:${token2}@github.com/${fullName}.git` : `https://github.com/${fullName}.git`;
|
|
3825
3825
|
emit({ type: "story_log", agentId: "_git", data: { type: "story_log", id: "_git", line: `cloning ${fullName}\u2026` } });
|
|
3826
3826
|
const ch = spawn("git", ["clone", "--quiet", url2, dir], { stdio: "ignore" });
|
|
3827
3827
|
ch.on("close", (code) => code === 0 ? resolve(dir) : reject(new Error(`git clone exit ${code}`)));
|
|
3828
3828
|
ch.on("error", reject);
|
|
3829
3829
|
});
|
|
3830
3830
|
}
|
|
3831
|
+
function captureDiff(cwd, base) {
|
|
3832
|
+
try {
|
|
3833
|
+
execFileSync("git", ["add", "-A"], { cwd });
|
|
3834
|
+
const out = execFileSync("git", ["diff", "--cached", base], { cwd, maxBuffer: 8 * 1024 * 1024 }).toString();
|
|
3835
|
+
return out.length > 2e5 ? out.slice(0, 2e5) + "\n\u2026 (diff truncated)" : out;
|
|
3836
|
+
} catch {
|
|
3837
|
+
return "";
|
|
3838
|
+
}
|
|
3839
|
+
}
|
|
3831
3840
|
async function runGoal(d, emit, signal) {
|
|
3832
3841
|
const env = { ...process.env };
|
|
3833
3842
|
delete env.ANTHROPIC_API_KEY;
|
|
3834
3843
|
let cwd = workspaceDir;
|
|
3835
3844
|
let cleanup;
|
|
3836
|
-
|
|
3845
|
+
let diffBase;
|
|
3846
|
+
if (d.repo && (d.githubToken || d.diffOnly)) {
|
|
3837
3847
|
try {
|
|
3838
3848
|
cwd = await cloneRepo(d.repo.fullName, d.githubToken, emit);
|
|
3839
3849
|
} catch (e) {
|
|
3840
3850
|
return { success: false, durationSecs: 1, error: `clone failed: ${e.message}` };
|
|
3841
3851
|
}
|
|
3842
|
-
|
|
3843
|
-
|
|
3852
|
+
if (d.diffOnly) {
|
|
3853
|
+
try {
|
|
3854
|
+
diffBase = execFileSync("git", ["rev-parse", "HEAD"], { cwd }).toString().trim();
|
|
3855
|
+
} catch {
|
|
3856
|
+
diffBase = void 0;
|
|
3857
|
+
}
|
|
3858
|
+
try {
|
|
3859
|
+
execFileSync("git", ["remote", "remove", "origin"], { cwd });
|
|
3860
|
+
} catch {
|
|
3861
|
+
}
|
|
3862
|
+
} else {
|
|
3863
|
+
env.GH_TOKEN = d.githubToken;
|
|
3864
|
+
env.GITHUB_TOKEN = d.githubToken;
|
|
3865
|
+
}
|
|
3844
3866
|
cleanup = () => {
|
|
3845
3867
|
try {
|
|
3846
3868
|
rmSync(cwd, { recursive: true, force: true });
|
|
@@ -3900,6 +3922,9 @@ async function runGoal(d, emit, signal) {
|
|
|
3900
3922
|
});
|
|
3901
3923
|
child.on("error", (e) => resolve({ success: false, durationSecs: secs(), error: e.message }));
|
|
3902
3924
|
});
|
|
3925
|
+
if (d.diffOnly && diffBase) {
|
|
3926
|
+
outcome.diff = captureDiff(cwd, diffBase);
|
|
3927
|
+
}
|
|
3903
3928
|
cleanup?.();
|
|
3904
3929
|
return outcome;
|
|
3905
3930
|
}
|