@tablation/crew 0.126.9 → 0.126.11

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/cli.js CHANGED
@@ -2747,11 +2747,12 @@ function tablationEndpoint(url) {
2747
2747
  }
2748
2748
  return { host, port };
2749
2749
  }
2750
- var TOOL_BINARIES = ["/usr/bin/curl", "/usr/bin/node", "/usr/local/bin/node", "/usr/bin/npm", "/usr/local/bin/npm", "/usr/local/bin/pnpm", "/usr/bin/corepack", "/usr/local/bin/corepack"];
2750
+ var CREW_BIN = "/opt/crew/bin";
2751
+ var TOOL_BINARIES = ["/usr/bin/curl", `${CREW_BIN}/node`, "/usr/bin/node", "/usr/local/bin/node", "/usr/bin/npm", "/usr/local/bin/npm", "/usr/local/bin/pnpm", "/usr/bin/corepack", "/usr/local/bin/corepack"];
2751
2752
  var GIT_BINARIES = ["/usr/bin/git", "/usr/lib/git-core/git-remote-http", "/usr/lib/git-core/git-remote-https"];
2752
2753
  function policyGroups(input) {
2753
2754
  const harness = `/usr/local/bin/${basename2(input.harnessBin)}`;
2754
- const harnessBins = [.../* @__PURE__ */ new Set([harness, `/usr/bin/${basename2(input.harnessBin)}`, "/usr/bin/node", "/usr/local/bin/node"])];
2755
+ const harnessBins = [.../* @__PURE__ */ new Set([`${CREW_BIN}/${basename2(input.harnessBin)}`, harness, `/usr/bin/${basename2(input.harnessBin)}`, `${CREW_BIN}/node`, "/usr/bin/node", "/usr/local/bin/node"])];
2755
2756
  const groups = [];
2756
2757
  const tablation = tablationEndpoint(input.tablationUrl);
2757
2758
  groups.push({
@@ -6352,7 +6353,7 @@ function attentionProblems(items, already) {
6352
6353
  }
6353
6354
 
6354
6355
  // src/sandbox-image.ts
6355
- import { createHash as createHash6 } from "crypto";
6356
+ import { createHash as createHash7 } from "crypto";
6356
6357
  import { spawn as spawn5 } from "child_process";
6357
6358
  import { execFileSync as execFileSync8 } from "child_process";
6358
6359
  import { existsSync as existsSync30, mkdirSync as mkdirSync19, readFileSync as readFileSync27, renameSync as renameSync3, writeFileSync as writeFileSync20, rmSync as rmSync15 } from "fs";
@@ -6362,7 +6363,7 @@ import { tmpdir as tmpdir3 } from "os";
6362
6363
 
6363
6364
  // src/passenger-containers.ts
6364
6365
  import { execFileSync as execFileSync7 } from "child_process";
6365
- import { createHash as createHash5 } from "crypto";
6366
+ import { createHash as createHash6 } from "crypto";
6366
6367
 
6367
6368
  // src/sandbox-cache.ts
6368
6369
  import { execFile as execFile2 } from "child_process";
@@ -6382,7 +6383,7 @@ import { readFileSync as readFileSync25, existsSync as existsSync26, statSync as
6382
6383
  import { StringDecoder } from "string_decoder";
6383
6384
  import { finished } from "stream/promises";
6384
6385
  import { join as join29, dirname as dirname14, basename as basename9 } from "path";
6385
- import { createHash as createHash4 } from "crypto";
6386
+ import { createHash as createHash5 } from "crypto";
6386
6387
 
6387
6388
  // src/state.ts
6388
6389
  import { readFileSync as readFileSync19, writeFileSync as writeFileSync14, existsSync as existsSync19, mkdirSync as mkdirSync13, rmSync as rmSync10, statSync as statSync7, readdirSync as readdirSync5 } from "fs";
@@ -10681,6 +10682,7 @@ function skillMarkerWarnings(promptsDir, personaPrompts) {
10681
10682
  // src/runner.ts
10682
10683
  import { spawn as spawn3, execFile, execFileSync as execFileSync6 } from "child_process";
10683
10684
  import { mkdtempSync, mkdirSync as mkdirSync17, writeFileSync as writeFileSync18, rmSync as rmSync14 } from "fs";
10685
+ import { createHash as createHash4 } from "crypto";
10684
10686
  import { tmpdir as tmpdir2 } from "os";
10685
10687
  import { basename as basename8, dirname as dirname13, join as join28 } from "path";
10686
10688
  import { promisify } from "util";
@@ -10776,8 +10778,9 @@ function shQuote2(s) {
10776
10778
  return `'${s.replace(/'/g, `'\\''`)}'`;
10777
10779
  }
10778
10780
  function sandboxName(plan, now = Date.now()) {
10779
- const base = [plan.route, plan.role, plan.ticket ?? ""].join("-").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
10780
- return `crew-${base.slice(0, 36)}-${now.toString(36)}`.replace(/-+/g, "-");
10781
+ const h = createHash4("sha256").update([plan.route, plan.role, plan.ticket ?? ""].join("\0")).digest();
10782
+ const tag = (h.readUInt32BE(0) % 36 ** 6).toString(36).padStart(6, "0");
10783
+ return `crew-${tag}${now.toString(36).slice(-8).padStart(8, "0")}`;
10781
10784
  }
10782
10785
  var SandboxRunner = class {
10783
10786
  kind = "sandbox";
@@ -10792,8 +10795,10 @@ var SandboxRunner = class {
10792
10795
  return execFileP(this.cfg.bin, args, { env: o.env ?? process.env, maxBuffer: 16 * 1024 * 1024 });
10793
10796
  }
10794
10797
  async start(plan, o) {
10795
- const origin = this.originOf(plan.cwd);
10796
- if (!origin) throw new Error(`cannot find the origin remote of ${plan.cwd}, so there is nothing to clone into the sandbox`);
10798
+ const origin = plan.sandboxOrigin ?? (plan.repo ? null : this.originOf(plan.cwd));
10799
+ if (!origin) {
10800
+ throw new Error(plan.repo ? `cannot place the repository ${plan.repo} of ${plan.ticket ?? "this run"} on route ${plan.route}, so there is nothing to clone into the sandbox` : `cannot find the origin remote of ${plan.cwd}, so there is nothing to clone into the sandbox`);
10801
+ }
10797
10802
  const repo = parseRemote(origin);
10798
10803
  if (!repo) throw new Error(`cannot read a forge host and path from the origin remote ${origin}`);
10799
10804
  const name = sandboxName(plan);
@@ -10938,7 +10943,8 @@ function runnerFor(kind, sandbox) {
10938
10943
  function runnerOfSidecar(sc) {
10939
10944
  return sc.runner === "sandbox" ? new SandboxRunner(sc.sandboxBin ? { bin: sc.sandboxBin } : {}) : new HostRunner();
10940
10945
  }
10941
- function checkSandboxRunner(cfg = {}, run3 = (b, a) => execFileSync6(b, a, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: 15e3 })) {
10946
+ var PROBE_CREATE_TIMEOUT_MS = 12e4;
10947
+ function checkSandboxRunner(cfg = {}, run3 = (b, a, t) => execFileSync6(b, a, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: t ?? 15e3 })) {
10942
10948
  const bin = cfg.bin ?? DEFAULT_SANDBOX_CONFIG.bin;
10943
10949
  let version;
10944
10950
  try {
@@ -10955,6 +10961,21 @@ function checkSandboxRunner(cfg = {}, run3 = (b, a) => execFileSync6(b, a, { enc
10955
10961
  detail: `${version}: the gateway does not answer (${(err3.stderr || err3.message).trim().split("\n").filter(Boolean).slice(0, 2).join(" / ")}). Start it; on Docker Desktop its docker section needs supervisor_network_mode = "bridge", and allow_driver_config = true for the cache volume mount.`
10956
10962
  };
10957
10963
  }
10964
+ const probe = sandboxName({ route: "doctor", role: "dev", ticket: void 0 });
10965
+ try {
10966
+ run3(bin, ["sandbox", "create", "--name", probe, "--detach", "--", "sleep", "60"], PROBE_CREATE_TIMEOUT_MS);
10967
+ } catch (e) {
10968
+ const err3 = e;
10969
+ if (err3.code === "ETIMEDOUT" || err3.killed) {
10970
+ return { ok: false, detail: `${version}: creating a probe sandbox named ${probe} timed out after ${PROBE_CREATE_TIMEOUT_MS / 1e3} s; the gateway may still be pulling its images on a first create, so run crew doctor again` };
10971
+ }
10972
+ return { ok: false, detail: `${version}: the gateway refused a probe sandbox named ${probe} (${(err3.stderr || err3.message).trim().split("\n").filter(Boolean).slice(0, 2).join(" / ")})` };
10973
+ } finally {
10974
+ try {
10975
+ run3(bin, ["sandbox", "delete", probe]);
10976
+ } catch {
10977
+ }
10978
+ }
10958
10979
  return { ok: true, detail: version };
10959
10980
  }
10960
10981
 
@@ -10975,6 +10996,13 @@ function assemblePrompt(p) {
10975
10996
  }
10976
10997
  var AgentError = class extends Error {
10977
10998
  };
10999
+ function sandboxOriginFor(route2, repo) {
11000
+ if (!repo) return void 0;
11001
+ const repos = reposOf(route2);
11002
+ const target = repos.find((r) => r.name === repo) ?? (repos.length === 1 ? repos[0] : void 0);
11003
+ if (!target) return void 0;
11004
+ return originUrlOf(target.dir, "origin") ?? (target.remote ? cloneUrlFor(target.remote, { host: target.forgeHost }) : void 0);
11005
+ }
10978
11006
  function sandboxPolicyInputFor(route2, toolchain, o) {
10979
11007
  const repos = reposOf(route2);
10980
11008
  const forgeHosts = [...new Set(repos.map((r) => r.forgeHost ?? "github.com"))];
@@ -11134,7 +11162,7 @@ function planAgentRun(o) {
11134
11162
  brief: expanded.text,
11135
11163
  digest
11136
11164
  });
11137
- const promptSha = createHash4("sha256").update(expanded.text).digest("hex");
11165
+ const promptSha = createHash5("sha256").update(expanded.text).digest("hex");
11138
11166
  const streamsDir = join29(o.stateDir, "streams");
11139
11167
  const base = `${routeLabel}-${o.role}-${o.cycle}${o.runId ? `-${o.runId}` : ""}`;
11140
11168
  const seat = resolveSeat(o.ship, o.route, o.role, o.agentPersona ?? (o.agentModel ? { model: o.agentModel } : {}), o.repo);
@@ -11152,6 +11180,7 @@ function planAgentRun(o) {
11152
11180
  const adapter = adapterFor(toolchain.harness);
11153
11181
  const code = codeBridgeFor(o, adapter.harness);
11154
11182
  const sandboxLsp = o.ship.runner === "sandbox" && adapter.harness === "claude" ? sandboxLspPluginFor(o.route, o.repo) : void 0;
11183
+ const sandboxOrigin = o.ship.runner === "sandbox" ? sandboxOriginFor(o.route, o.repo) : void 0;
11155
11184
  const sandboxFiles = [...code?.files ?? [], ...sandboxLsp?.files ?? []];
11156
11185
  const invocation = adapter.invocation(toolchain, {
11157
11186
  code,
@@ -11204,6 +11233,7 @@ function planAgentRun(o) {
11204
11233
  ...o.ship.runner === "sandbox" ? {
11205
11234
  runner: "sandbox",
11206
11235
  ...o.ship.sandbox ? { sandboxConfig: o.ship.sandbox } : {},
11236
+ ...sandboxOrigin ? { sandboxOrigin } : {},
11207
11237
  sandboxPolicy: sandboxPolicyInputFor(o.route, toolchain, { harnessBin: invocation.bin, repo: o.repo, sandbox: o.ship.sandbox }),
11208
11238
  ...sandboxFiles.length ? { sandboxFiles } : {}
11209
11239
  } : {},
@@ -12085,8 +12115,8 @@ async function mintMissingSeatKeys(route2, o) {
12085
12115
  const resolved = route2.resolved;
12086
12116
  const doFetch = o.fetchImpl ?? fetch;
12087
12117
  const targets = [
12088
- ...SEAT_KEY_ROLES.filter((r) => resolved.seats[r]).map((role) => ({ role, agentId: seatAgentId(route2, role) })),
12089
- ...resolved.releaseSeat ? [{ role: "release", agentId: resolved.releaseAgentId }] : []
12118
+ ...SEAT_KEY_ROLES.filter((r) => resolved.seats[r]).map((role) => ({ role, agentId: seatAgentId(route2, role), actorRecordId: resolved.seats[role] })),
12119
+ ...resolved.releaseSeat ? [{ role: "release", agentId: resolved.releaseAgentId, actorRecordId: resolved.releaseSeat }] : []
12090
12120
  ];
12091
12121
  let store;
12092
12122
  try {
@@ -12115,7 +12145,7 @@ async function mintMissingSeatKeys(route2, o) {
12115
12145
  return targets.map(({ role, agentId }) => agentId ? { role, action: "failed", detail } : { role, action: "no_agent" });
12116
12146
  }
12117
12147
  }
12118
- for (const { role, agentId } of targets) {
12148
+ for (const { role, agentId, actorRecordId } of targets) {
12119
12149
  if (!agentId) {
12120
12150
  out.push({ role, action: "no_agent" });
12121
12151
  continue;
@@ -12137,7 +12167,7 @@ async function mintMissingSeatKeys(route2, o) {
12137
12167
  "Content-Type": "application/json",
12138
12168
  "User-Agent": o.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0"
12139
12169
  },
12140
- body: JSON.stringify({ name: `crew ${o.shipName ?? "ship"} ${role}` })
12170
+ body: JSON.stringify({ name: `crew ${o.shipName ?? "ship"} ${role}`, ...actorRecordId ? { actorRecordId } : {} })
12141
12171
  });
12142
12172
  if (res.status === 403) {
12143
12173
  out.push({ role, action: "forbidden" });
@@ -12208,8 +12238,8 @@ async function revokeSeatKeys(route2, o) {
12208
12238
  const resolved = route2.resolved;
12209
12239
  const doFetch = o.fetchImpl ?? fetch;
12210
12240
  const targets = [
12211
- ...SEAT_KEY_ROLES.filter((r) => resolved.seats[r]).map((role) => ({ role, agentId: seatAgentId(route2, role) })),
12212
- ...resolved.releaseSeat ? [{ role: "release", agentId: resolved.releaseAgentId }] : []
12241
+ ...SEAT_KEY_ROLES.filter((r) => resolved.seats[r]).map((role) => ({ role, agentId: seatAgentId(route2, role), actorRecordId: resolved.seats[role] })),
12242
+ ...resolved.releaseSeat ? [{ role: "release", agentId: resolved.releaseAgentId, actorRecordId: resolved.releaseSeat }] : []
12213
12243
  ];
12214
12244
  let store;
12215
12245
  try {
@@ -12739,12 +12769,12 @@ function containerNameFor(workspaceId) {
12739
12769
  return `crew-passenger-${workspaceId}`;
12740
12770
  }
12741
12771
  function portFor(workspaceId, base = 28765, span = 1e3) {
12742
- const digest = createHash5("sha256").update(workspaceId).digest();
12772
+ const digest = createHash6("sha256").update(workspaceId).digest();
12743
12773
  return base + digest.readUInt32BE(0) % span;
12744
12774
  }
12745
12775
  function mountsDigest(mounts, image) {
12746
12776
  const sorted2 = [...mounts].sort((a, b) => a.containerPath.localeCompare(b.containerPath));
12747
- return createHash5("sha256").update(JSON.stringify({ mounts: sorted2, image })).digest("hex").slice(0, 16);
12777
+ return createHash6("sha256").update(JSON.stringify({ mounts: sorted2, image })).digest("hex").slice(0, 16);
12748
12778
  }
12749
12779
  function planContainers(cfg) {
12750
12780
  const byWorkspace = /* @__PURE__ */ new Map();
@@ -12947,7 +12977,7 @@ echo "password=$CREW_FORGE_TOKEN"
12947
12977
  `;
12948
12978
  var MCP_CONFIG = `${JSON.stringify({ mcpServers: {} }, null, 2)}
12949
12979
  `;
12950
- var hash = (parts) => createHash6("sha256").update(JSON.stringify(parts)).digest("hex").slice(0, 12);
12980
+ var hash = (parts) => createHash7("sha256").update(JSON.stringify(parts)).digest("hex").slice(0, 12);
12951
12981
  var slug = (s) => s.toLowerCase().replace(/[^a-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "") || "repo";
12952
12982
  var run2 = (cmd) => `RUN ["/bin/bash", "-c", ${JSON.stringify(`set -euo pipefail; ${cmd}`)}]`;
12953
12983
  var CREW_ENV = {
@@ -14372,13 +14402,13 @@ import { hostname as hostname3 } from "os";
14372
14402
 
14373
14403
  // src/machine-id.ts
14374
14404
  import { execFileSync as execFileSync10 } from "child_process";
14375
- import { createHash as createHash7 } from "crypto";
14405
+ import { createHash as createHash8 } from "crypto";
14376
14406
  import { existsSync as existsSync33, mkdirSync as mkdirSync24, readFileSync as readFileSync32, writeFileSync as writeFileSync25 } from "fs";
14377
14407
  import { dirname as dirname19, join as join37 } from "path";
14378
14408
  function machineIdPathFor(stateDir) {
14379
14409
  return join37(stateDir, "machine-id");
14380
14410
  }
14381
- var sha256 = (s) => createHash7("sha256").update(s).digest("hex");
14411
+ var sha256 = (s) => createHash8("sha256").update(s).digest("hex");
14382
14412
  function readRawMachineId(platform2 = process.platform) {
14383
14413
  try {
14384
14414
  if (platform2 === "darwin") {
@@ -20560,7 +20590,7 @@ async function runAgentsSync(target, o) {
20560
20590
  }
20561
20591
 
20562
20592
  // src/logbook.ts
20563
- import { createHash as createHash8 } from "crypto";
20593
+ import { createHash as createHash9 } from "crypto";
20564
20594
  import { TablationClient as TablationClient4 } from "@tablation/client";
20565
20595
  var LogbookError = class extends Error {
20566
20596
  };
@@ -20646,7 +20676,7 @@ async function showLogEntry(route2, entryId, opts = {}) {
20646
20676
  };
20647
20677
  }
20648
20678
  const prompt = appendAdditions(match.prompt ?? "", match.prompt_additions);
20649
- const actualSha = createHash8("sha256").update(prompt).digest("hex");
20679
+ const actualSha = createHash9("sha256").update(prompt).digest("hex");
20650
20680
  const exact = !!entry.prompt_sha && actualSha === entry.prompt_sha;
20651
20681
  return {
20652
20682
  entry,
@@ -22228,7 +22258,7 @@ function shipIdentityJson(s) {
22228
22258
  }
22229
22259
 
22230
22260
  // src/mcp-endpoint-registry.ts
22231
- import { createHash as createHash9 } from "crypto";
22261
+ import { createHash as createHash10 } from "crypto";
22232
22262
  function endpointsUrl(api, workspaceId, id) {
22233
22263
  const base = `${api.baseUrl.replace(/\/+$/, "")}/api/workspaces/${workspaceId}/mcp-endpoints`;
22234
22264
  return id ? `${base}/${id}` : base;
@@ -22298,7 +22328,7 @@ async function probeEndpointAccess(api, workspaceId) {
22298
22328
  }
22299
22329
  var REGISTER_MCP_ENDPOINTS_HINT = "give this key's role the REGISTER_MCP_ENDPOINTS capability, e.g. via the group that holds the Crew project role";
22300
22330
  function registrationKey(url, mcpSecret, controlUrl) {
22301
- return createHash9("sha256").update(`${url}
22331
+ return createHash10("sha256").update(`${url}
22302
22332
  ${mcpSecret ?? ""}
22303
22333
  ${controlUrl ?? ""}`).digest("hex").slice(0, 16);
22304
22334
  }
@@ -23681,7 +23711,7 @@ async function buildEnvironment(route2, ship, ticket) {
23681
23711
  }
23682
23712
 
23683
23713
  // src/control-api.ts
23684
- import { createHash as createHash10 } from "crypto";
23714
+ import { createHash as createHash11 } from "crypto";
23685
23715
  import {
23686
23716
  chmodSync as chmodSync4,
23687
23717
  closeSync as closeSync6,
@@ -23941,7 +23971,7 @@ var ControlAuth = class {
23941
23971
  if (!token) return "unauthorized";
23942
23972
  for (const k of this.o.shipKeys()) if (k && secretsMatch(token, k)) return "ok";
23943
23973
  const now = (this.o.now ?? Date.now)();
23944
- const id = createHash10("sha256").update(token).digest("hex");
23974
+ const id = createHash11("sha256").update(token).digest("hex");
23945
23975
  const hit = this.cache.get(id);
23946
23976
  if (hit && now - hit.at < (this.o.cacheMs ?? 6e4)) return hit.verdict;
23947
23977
  const verdict = await this.ask(token);
@@ -23962,7 +23992,7 @@ var ControlAuth = class {
23962
23992
  for (const k of this.o.shipKeys()) if (k && secretsMatch(token, k)) return "ok";
23963
23993
  for (const k of this.o.workspaceSecrets?.(workspaceId) ?? []) if (k && secretsMatch(token, k)) return "ok";
23964
23994
  const now = (this.o.now ?? Date.now)();
23965
- const id = `${workspaceId}:${createHash10("sha256").update(token).digest("hex")}`;
23995
+ const id = `${workspaceId}:${createHash11("sha256").update(token).digest("hex")}`;
23966
23996
  const hit = this.cache.get(id);
23967
23997
  if (hit && now - hit.at < (this.o.cacheMs ?? 6e4)) return hit.verdict;
23968
23998
  const verdict = await this.ask(token, [workspaceId]);
@@ -24646,6 +24646,8 @@ function parseEndpoint(raw, defaultPort = 443) {
24646
24646
  if (!IPV4.test(host) && !HOST.test(host)) throw new SandboxPolicyError(`"${raw}" is not a valid host name`);
24647
24647
  return { host, port };
24648
24648
  }
24649
+ var CREW_BIN = "/opt/crew/bin";
24650
+ var TOOL_BINARIES = ["/usr/bin/curl", `${CREW_BIN}/node`, "/usr/bin/node", "/usr/local/bin/node", "/usr/bin/npm", "/usr/local/bin/npm", "/usr/local/bin/pnpm", "/usr/bin/corepack", "/usr/local/bin/corepack"];
24649
24651
  function parseSandboxNetwork(raw, file, fail2) {
24650
24652
  if (raw === void 0 || raw === null) return void 0;
24651
24653
  if (typeof raw !== "object" || Array.isArray(raw)) throw fail2(`${file}: sandbox must be a mapping`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.126.9",
3
+ "version": "0.126.11",
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",