@tablation/crew 0.128.3 → 0.129.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.
@@ -24593,11 +24593,52 @@ function realSerenaDeps(onPath2, extraEnv = process.env) {
24593
24593
 
24594
24594
  // src/repo-config.ts
24595
24595
  var import_node_fs5 = require("fs");
24596
- var import_node_path6 = require("path");
24596
+
24597
+ // src/remote-dir.ts
24598
+ var import_node_child_process3 = require("child_process");
24599
+ var import_node_path5 = require("path");
24600
+ var REMOTE_ROOT = "/.crew-sandbox";
24601
+ var registry2 = /* @__PURE__ */ new Map();
24602
+ function remoteOf(path) {
24603
+ if (!path.startsWith(`${REMOTE_ROOT}/`)) return null;
24604
+ for (const [dir, remote] of registry2) {
24605
+ if (path === dir) return { remote, path: remote.workDir };
24606
+ if (path.startsWith(`${dir}/`)) return { remote, path: import_node_path5.posix.join(remote.workDir, path.slice(dir.length + 1)) };
24607
+ }
24608
+ return null;
24609
+ }
24610
+ function sandboxExecArgs(r, cwd, argv) {
24611
+ return ["sandbox", "exec", "-n", r.sandbox, "--no-login-shell", "--workdir", cwd, "--", ...argv];
24612
+ }
24613
+ function execRemoteSync(hit, argv, o = {}) {
24614
+ return (0, import_node_child_process3.execFileSync)(hit.remote.bin, sandboxExecArgs(hit.remote, o.cwd ?? hit.path, argv), {
24615
+ encoding: "utf8",
24616
+ stdio: [o.input === void 0 ? "ignore" : "pipe", "pipe", "pipe"],
24617
+ maxBuffer: 256 * 1024 * 1024,
24618
+ ...o.input === void 0 ? {} : { input: o.input }
24619
+ });
24620
+ }
24621
+ function existsAt(path, hostExists2) {
24622
+ const hit = remoteOf(path);
24623
+ if (!hit) return hostExists2(path);
24624
+ try {
24625
+ execRemoteSync(hit, ["test", "-e", hit.path], { cwd: hit.remote.workDir });
24626
+ return true;
24627
+ } catch {
24628
+ return false;
24629
+ }
24630
+ }
24631
+ function readTextAt(path, hostRead) {
24632
+ const hit = remoteOf(path);
24633
+ return hit ? execRemoteSync(hit, ["cat", "--", hit.path], { cwd: hit.remote.workDir }) : hostRead(path);
24634
+ }
24635
+
24636
+ // src/repo-config.ts
24637
+ var import_node_path7 = require("path");
24597
24638
  var import_yaml2 = __toESM(require_dist2(), 1);
24598
24639
 
24599
24640
  // src/sandbox-policy.ts
24600
- var import_node_path5 = require("path");
24641
+ var import_node_path6 = require("path");
24601
24642
  var import_yaml = __toESM(require_dist2(), 1);
24602
24643
  var SandboxPolicyError = class extends Error {
24603
24644
  };
@@ -24778,8 +24819,8 @@ var MODES = ["local", "integrate", "ci_manual", "ci_auto", "external"];
24778
24819
  var PROVIDERS = ["github", "buildkite", "other", "none"];
24779
24820
  function findRepoConfig(dir) {
24780
24821
  for (const name of REPO_CONFIG_FILENAMES) {
24781
- const p = (0, import_node_path6.join)(dir, name);
24782
- if ((0, import_node_fs5.existsSync)(p)) return p;
24822
+ const p = (0, import_node_path7.join)(dir, name);
24823
+ if (existsAt(p, import_node_fs5.existsSync)) return p;
24783
24824
  }
24784
24825
  return null;
24785
24826
  }
@@ -25032,11 +25073,11 @@ function parseRepoConfig(text, file) {
25032
25073
  }
25033
25074
  if (versionFilesGiven) {
25034
25075
  for (const name of versionFiles) {
25035
- const path = (0, import_node_path6.join)((0, import_node_path6.dirname)(file), name);
25036
- if (!(0, import_node_fs5.existsSync)(path)) continue;
25076
+ const path = (0, import_node_path7.join)((0, import_node_path7.dirname)(file), name);
25077
+ if (!existsAt(path, import_node_fs5.existsSync)) continue;
25037
25078
  let text2;
25038
25079
  try {
25039
- text2 = (0, import_node_fs5.readFileSync)(path, "utf8");
25080
+ text2 = readTextAt(path, (p) => (0, import_node_fs5.readFileSync)(p, "utf8"));
25040
25081
  } catch (e) {
25041
25082
  throw new RepoConfigError(
25042
25083
  `${file}: release.versionFiles entry "${name}" cannot be read (${e.code ?? "read error"})`
@@ -25081,7 +25122,7 @@ function parseRepoConfig(text, file) {
25081
25122
  function loadRepoConfig(dir) {
25082
25123
  const file = findRepoConfig(dir);
25083
25124
  if (!file) return null;
25084
- return parseRepoConfig((0, import_node_fs5.readFileSync)(file, "utf8"), file);
25125
+ return parseRepoConfig(readTextAt(file, (p) => (0, import_node_fs5.readFileSync)(p, "utf8")), file);
25085
25126
  }
25086
25127
  function parseLowercase(v, where) {
25087
25128
  if (typeof v !== "boolean") throw new RepoConfigError(`${where}: branch.lowercase must be true or false`);
@@ -25089,16 +25130,23 @@ function parseLowercase(v, where) {
25089
25130
  }
25090
25131
 
25091
25132
  // src/shell.ts
25092
- var import_node_child_process3 = require("child_process");
25133
+ var import_node_child_process4 = require("child_process");
25093
25134
  var import_node_process2 = require("process");
25094
25135
  function defaultShell() {
25095
25136
  return import_node_process2.platform === "win32" ? { bin: "powershell", args: ["-NoProfile", "-NonInteractive", "-Command"] } : { bin: "bash", args: ["-c"] };
25096
25137
  }
25138
+ function remoteScript(script, prelude, env) {
25139
+ const q = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
25140
+ const exports2 = Object.entries(env ?? {}).filter(([, v]) => v !== void 0).map(([k, v]) => `${k}=${q(String(v))}; export ${k}; `).join("");
25141
+ return `${prelude ?? ""}${exports2}${script}`;
25142
+ }
25097
25143
  function runScript(script, opts) {
25098
25144
  const shell = opts.shell ?? defaultShell();
25145
+ const hit = remoteOf(opts.cwd);
25146
+ const [bin, args, cwd] = hit ? [hit.remote.bin, sandboxExecArgs(hit.remote, hit.path, [shell.bin, ...shell.args, remoteScript(script, hit.remote.prelude, opts.env)]), void 0] : [shell.bin, [...shell.args, script], opts.cwd];
25099
25147
  return new Promise((resolvePromise) => {
25100
- const child = (0, import_node_child_process3.spawn)(shell.bin, [...shell.args, script], {
25101
- cwd: opts.cwd,
25148
+ const child = (0, import_node_child_process4.spawn)(bin, args, {
25149
+ cwd,
25102
25150
  env: { ...process.env, ...opts.env },
25103
25151
  stdio: ["ignore", "pipe", "pipe"]
25104
25152
  });
@@ -25135,7 +25183,7 @@ crew: cannot run ${shell.bin}: ${err.message}`, stdout });
25135
25183
 
25136
25184
  // src/sandbox-intel-bridge.ts
25137
25185
  var import_node_fs6 = require("fs");
25138
- var import_node_path7 = require("path");
25186
+ var import_node_path8 = require("path");
25139
25187
  function parseSandboxBridgeArgs(argv) {
25140
25188
  const get = (flag) => {
25141
25189
  const i = argv.indexOf(flag);
@@ -25163,7 +25211,7 @@ function envFromHookOutput(output) {
25163
25211
  }
25164
25212
  return env;
25165
25213
  }
25166
- var onPath = (bin) => (process.env.PATH ?? "").split(import_node_path7.delimiter).some((d) => d && (0, import_node_fs6.existsSync)((0, import_node_path7.join)(d, bin)));
25214
+ var onPath = (bin) => (process.env.PATH ?? "").split(import_node_path8.delimiter).some((d) => d && (0, import_node_fs6.existsSync)((0, import_node_path8.join)(d, bin)));
25167
25215
  function sandboxStarter(a, run = runScript) {
25168
25216
  return async () => {
25169
25217
  const env = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.128.3",
3
+ "version": "0.129.1",
4
4
  "description": "A standing team of headless agents that picks work off a Tablation board, does it on a machine you control, and reports back.",
5
5
  "type": "module",
6
6
  "license": "MIT",