@tablation/crew 0.130.0 → 0.130.2

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.
Files changed (2) hide show
  1. package/dist/cli.js +36 -7
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2353,6 +2353,7 @@ function storeForgeToken(forges, host, token, stateDir, env = process.env) {
2353
2353
  if (!i.write) throw new ForgeError(`forges.${host} reads its token from ${i.describe(f.entry.token, { host: f.host, stateDir, env })}, which crew cannot write`);
2354
2354
  if (!token.trim()) throw new ForgeError("empty token");
2355
2355
  i.write(f.entry.token, token.trim(), { host: f.host, stateDir, env });
2356
+ noteForgeMiss(stateDir, f.host, null);
2356
2357
  }
2357
2358
  function eraseForgeToken(forges, host, stateDir, env = process.env) {
2358
2359
  const f = forgeFor(forges, host);
@@ -7314,6 +7315,27 @@ async function revokeSeatKeys(route2, o) {
7314
7315
  }
7315
7316
  const host = hostFromUrl2(route2.baseUrl);
7316
7317
  const base = route2.baseUrl.replace(/\/+$/, "");
7318
+ const headers = { Authorization: `Bearer ${resolveApiKey(route2)}`, "User-Agent": o.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0" };
7319
+ const sweepNamedKeys = async (role, agentId) => {
7320
+ const prefix = `crew ${o.shipName} `;
7321
+ try {
7322
+ const res = await doFetch(`${base}/api/workspaces/${resolved.workspaceId}/agents/${agentId}/api-keys`, { headers });
7323
+ if (!res.ok) return;
7324
+ const keys = await res.json();
7325
+ for (const k of Array.isArray(keys) ? keys : []) {
7326
+ if (!k.id || k.revokedAt || !k.name?.startsWith(prefix)) continue;
7327
+ if (o.dryRun) {
7328
+ out.push({ role, action: "revoked", detail: `dry run; key "${k.name}" found on the server` });
7329
+ continue;
7330
+ }
7331
+ const del2 = await doFetch(`${base}/api/workspaces/${resolved.workspaceId}/agents/${agentId}/api-keys/${k.id}`, { method: "DELETE", headers });
7332
+ if (del2.ok || del2.status === 404) out.push({ role, action: "revoked", detail: `key "${k.name}" found on the server, not in the keychain` });
7333
+ else out.push({ role, action: "failed", detail: `key "${k.name}": ${del2.status} ${del2.statusText}` });
7334
+ }
7335
+ } catch (e) {
7336
+ out.push({ role, action: "failed", detail: `could not sweep keys named for this ship (${e.message})` });
7337
+ }
7338
+ };
7317
7339
  for (const { role, agentId } of targets) {
7318
7340
  if (!agentId) {
7319
7341
  out.push({ role, action: "no_agent" });
@@ -7324,6 +7346,7 @@ async function revokeSeatKeys(route2, o) {
7324
7346
  const session = await store.get(host, slug2);
7325
7347
  if (!session?.apiKey) {
7326
7348
  out.push({ role, action: "not_stored" });
7349
+ if (o.shipName) await sweepNamedKeys(role, agentId);
7327
7350
  continue;
7328
7351
  }
7329
7352
  if (!session.keyId) {
@@ -7344,6 +7367,7 @@ async function revokeSeatKeys(route2, o) {
7344
7367
  }
7345
7368
  await store.clear(host, slug2);
7346
7369
  out.push({ role, action: "revoked", detail: del2.ok ? void 0 : "server already had no such key" });
7370
+ if (o.shipName) await sweepNamedKeys(role, agentId);
7347
7371
  } catch (e) {
7348
7372
  out.push({ role, action: "failed", detail: /Command failed|security|sk_|-w /i.test(e.message) ? describeStoreError(e) : e.message });
7349
7373
  }
@@ -12904,7 +12928,12 @@ function labeledDocker() {
12904
12928
  if (!dockerAvailable()) return { volumes: [], images: [] };
12905
12929
  return {
12906
12930
  volumes: lines(docker(["volume", "ls", "-q", "--filter", `label=${DOCKER_LABEL_OWNER}`, "--filter", `label=${DOCKER_LABEL_CACHE}`])),
12907
- images: lines(docker(["image", "ls", "-q", "--filter", `label=${DOCKER_LABEL_OWNER}`, "--filter", `label=${DOCKER_LABEL_REPO_LAYER}`]))
12931
+ // CREW-2984: the repository and ship layers are tagged `crew-sandbox/<name>:<hash>` but carry only an `io.crew.sandbox.*` label,
12932
+ // so the label filter alone missed them. The tag namespace is crew's own; the base and crew layers are `crew-sandbox-base`/`-crew`.
12933
+ images: [.../* @__PURE__ */ new Set([
12934
+ ...lines(docker(["image", "ls", "--format", "{{.Repository}}:{{.Tag}}", "--filter", "reference=crew-sandbox/*"])),
12935
+ ...lines(docker(["image", "ls", "-q", "--filter", `label=${DOCKER_LABEL_OWNER}`, "--filter", `label=${DOCKER_LABEL_REPO_LAYER}`]))
12936
+ ])]
12908
12937
  };
12909
12938
  }
12910
12939
  function realDeprovisionDeps(cfg, emit, crewHome, getStore) {
@@ -15798,7 +15827,7 @@ function realProvisionDeps(crewHome) {
15798
15827
  return wrote ? "set" : "kept";
15799
15828
  },
15800
15829
  storedToken(host) {
15801
- const res = spawnCrew(["credential", "get"], { input: `protocol=https
15830
+ const res = spawnCrew(["credential", "get", "--no-miss"], { input: `protocol=https
15802
15831
  host=${host}
15803
15832
 
15804
15833
  ` });
@@ -19836,11 +19865,11 @@ function formatProjectsReport(report) {
19836
19865
 
19837
19866
  // src/forge-cmd.ts
19838
19867
  import { parseDocument as parseDocument4 } from "yaml";
19839
- function runCredential(action, stdin, forges, stateDir, env = process.env) {
19868
+ function runCredential(action, stdin, forges, stateDir, env = process.env, recordMisses = true) {
19840
19869
  try {
19841
19870
  const input = parseCredentialInput(stdin);
19842
19871
  const out = answerCredential(action ?? "", input, forges, stateDir, env);
19843
- if (action === "get" && input.host && (!input.protocol || input.protocol === "https")) {
19872
+ if (recordMisses && action === "get" && input.host && (!input.protocol || input.protocol === "https")) {
19844
19873
  noteForgeMiss(stateDir, input.host, out ? null : (/* @__PURE__ */ new Date()).toISOString());
19845
19874
  }
19846
19875
  return { code: 0, out, err: "" };
@@ -26287,7 +26316,7 @@ if (command === "passenger-sync-daemon") {
26287
26316
  throw e;
26288
26317
  }
26289
26318
  if (command === "credential") {
26290
- const r = runCredential(positional[1], readFileSync47(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir);
26319
+ const r = runCredential(positional[1], readFileSync47(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
26291
26320
  process.stdout.write(r.out);
26292
26321
  process.stderr.write(r.err);
26293
26322
  process.exit(r.code);
@@ -28212,7 +28241,7 @@ ${cu.tail.trimEnd()}
28212
28241
  }
28213
28242
  const { personaResult, skillResult } = run3;
28214
28243
  if (flag("revoke-seat-keys")) {
28215
- for (const o of await revokeSeatKeys(target, { userAgent: cfg.ship.userAgent, dryRun })) {
28244
+ for (const o of await revokeSeatKeys(target, { userAgent: cfg.ship.userAgent, dryRun, shipName: cfg.ship.name })) {
28216
28245
  process.stdout.write(`${describeRevokeOutcome(o)}
28217
28246
  `);
28218
28247
  }
@@ -30585,7 +30614,7 @@ ${where.join("\n")}`);
30585
30614
  },
30586
30615
  removePair: removePairEntries,
30587
30616
  async revokeSeatKeys(r, dry) {
30588
- const outcomes = await revokeSeatKeys(r, { userAgent: cfg.ship.userAgent, dryRun: dry });
30617
+ const outcomes = await revokeSeatKeys(r, { userAgent: cfg.ship.userAgent, dryRun: dry, shipName: cfg.ship.name });
30589
30618
  return outcomes.map((o) => ({ line: describeRevokeOutcome(o), ok: o.action !== "failed" }));
30590
30619
  },
30591
30620
  async credential(r) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.130.0",
3
+ "version": "0.130.2",
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",