@tablation/crew 0.157.1 → 0.157.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 +122 -18
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -7148,7 +7148,7 @@ function visibleAttention(items, dockerFindingPresent) {
7148
7148
  function attentionProblems(items, already) {
7149
7149
  const seen = new Set(already.filter((p) => p.kind === "hook_missing").map((p) => `hook_missing:${p.route}/${p.repo}/${p.hook}`));
7150
7150
  if (already.some((p) => p.kind === "docker_daemon_down")) seen.add(DOCKER_DAEMON_KEY);
7151
- return items.filter((i) => !seen.has(i.key)).map((i) => ({ severity: "attention", kind: i.kind, message: i.message }));
7151
+ return items.filter((i) => !seen.has(i.key) && i.kind !== "seat_missing").map((i) => ({ severity: "attention", kind: i.kind, message: i.message }));
7152
7152
  }
7153
7153
  var NO_PROJECTS_REMEDY = "run `crew projects add NAME --prefix PREFIX` (or add a row to the Projects table)";
7154
7154
  function noProjectsFinding(route2, projectCount) {
@@ -9229,7 +9229,7 @@ import { basename as basename7 } from "path";
9229
9229
 
9230
9230
  // src/tracker.ts
9231
9231
  import { hostname } from "os";
9232
- import { TablationClient } from "@tablation/client";
9232
+ import { TablationApiError, TablationClient } from "@tablation/client";
9233
9233
 
9234
9234
  // src/work-mode.ts
9235
9235
  function projectWorkModes(rows, contract) {
@@ -9528,6 +9528,15 @@ var Tracker = class {
9528
9528
  async comments(limit = 500) {
9529
9529
  return this.client.records.list(this.models.comments, { limit });
9530
9530
  }
9531
+ /** One Crew row, or null when the tracker answers 404 (CREW-3449). Any other failure throws. */
9532
+ async crewRow(id) {
9533
+ try {
9534
+ return await this.client.records.get(this.models.crew, id);
9535
+ } catch (e) {
9536
+ if (e instanceof TablationApiError && e.status === 404) return null;
9537
+ throw e;
9538
+ }
9539
+ }
9531
9540
  async crewRows() {
9532
9541
  return this.client.records.list(this.models.crew, { limit: 200 });
9533
9542
  }
@@ -12866,7 +12875,7 @@ function expandSkillMarkers(text2, lookup2, opts = {}) {
12866
12875
  import { readFileSync as readFileSync30, readdirSync as readdirSync9, existsSync as existsSync28 } from "fs";
12867
12876
  import { join as join32 } from "path";
12868
12877
  import { parse as parseYaml2 } from "yaml";
12869
- import { TablationClient as TablationClient3, StaleWriteError as StaleWriteError3, TablationApiError as TablationApiError2 } from "@tablation/client";
12878
+ import { TablationClient as TablationClient3, StaleWriteError as StaleWriteError3, TablationApiError as TablationApiError3 } from "@tablation/client";
12870
12879
 
12871
12880
  // src/prompt-additions.ts
12872
12881
  var PROMPT_ADDITIONS_SEPARATOR = "---\n\nAdditional instructions from this workspace. Where they conflict with anything above, these take precedence.";
@@ -12898,7 +12907,7 @@ function readPersonaFile(path) {
12898
12907
  // src/agents.ts
12899
12908
  import { readFileSync as readFileSync29, existsSync as existsSync27 } from "fs";
12900
12909
  import { join as join31 } from "path";
12901
- import { TablationClient as TablationClient2, StaleWriteError as StaleWriteError2, TablationApiError } from "@tablation/client";
12910
+ import { TablationClient as TablationClient2, StaleWriteError as StaleWriteError2, TablationApiError as TablationApiError2 } from "@tablation/client";
12902
12911
  var PERSONA_NAME = {
12903
12912
  dev: "Developer",
12904
12913
  design: "Design",
@@ -13050,7 +13059,7 @@ async function fetchKeyRole(route2, userAgent) {
13050
13059
  }
13051
13060
  }
13052
13061
  function isForbidden(e) {
13053
- return e instanceof TablationApiError && e.status === 403;
13062
+ return e instanceof TablationApiError2 && e.status === 403;
13054
13063
  }
13055
13064
  function promptSourceFields(model, prompt) {
13056
13065
  return model.fields?.some((f) => f.columnName === "prompt_baseline") ? { prompt_source: "crew", prompt_baseline: prompt } : {};
@@ -13062,7 +13071,7 @@ function needsBaselineBackfill(model, row) {
13062
13071
  return hasPromptBaselineColumn(model) && row.prompt_customized !== true && (typeof row.prompt_baseline !== "string" || !row.prompt_source);
13063
13072
  }
13064
13073
  function isPromptGateRejection(e) {
13065
- return e instanceof TablationApiError && e.status === 422;
13074
+ return e instanceof TablationApiError2 && e.status === 422;
13066
13075
  }
13067
13076
  var RELEASE_AGENT_NAME = "Release agent";
13068
13077
  var RELEASE_AGENT_PROMPT = "Principal for the crew release phase (merge, deploy, release comments). It runs no model; this row only gives those tracker writes an agent identity.";
@@ -13080,7 +13089,7 @@ async function syncPersonas(route2, opts) {
13080
13089
  try {
13081
13090
  agentsModel = await client2.dataModels.get("agents", workspaceId);
13082
13091
  } catch (e) {
13083
- if (e instanceof TablationApiError && e.status === 404) {
13092
+ if (e instanceof TablationApiError2 && e.status === 404) {
13084
13093
  throw new AgentsSyncError(
13085
13094
  `workspace ${workspaceId} has no Agents table yet \u2014 every workspace auto-provisions one (ISSUE-465); an older workspace may still need its one-time backfill`
13086
13095
  );
@@ -13277,7 +13286,7 @@ async function getSeatRow(client2, crewModelId, seatId) {
13277
13286
  try {
13278
13287
  return await client2.records.get(crewModelId, seatId);
13279
13288
  } catch (e) {
13280
- if (e instanceof TablationApiError && e.status === 404) return null;
13289
+ if (e instanceof TablationApiError2 && e.status === 404) return null;
13281
13290
  throw e;
13282
13291
  }
13283
13292
  }
@@ -13457,7 +13466,7 @@ async function syncSkills(route2, opts) {
13457
13466
  try {
13458
13467
  skillsModel = await client2.dataModels.get("agent_skills", workspaceId);
13459
13468
  } catch (e) {
13460
- if (e instanceof TablationApiError2 && e.status === 404) {
13469
+ if (e instanceof TablationApiError3 && e.status === 404) {
13461
13470
  throw new SkillSyncError(
13462
13471
  `workspace ${workspaceId} has no Agent Skills table yet \u2014 every workspace auto-provisions one; an older workspace may still need its one-time backfill`
13463
13472
  );
@@ -13499,7 +13508,7 @@ async function syncSkills(route2, opts) {
13499
13508
  const agentsModel = await client2.dataModels.get("agents", workspaceId);
13500
13509
  agentRows = await client2.records.list(agentsModel.id, { limit: 200 });
13501
13510
  } catch (e) {
13502
- if (!(e instanceof TablationApiError2)) throw e;
13511
+ if (!(e instanceof TablationApiError3)) throw e;
13503
13512
  agentRows = [];
13504
13513
  }
13505
13514
  }
@@ -18327,7 +18336,7 @@ function realPoolMemberDeps(o) {
18327
18336
  }
18328
18337
 
18329
18338
  // src/crew-floor.ts
18330
- import { TablationApiError as TablationApiError3 } from "@tablation/client";
18339
+ import { TablationApiError as TablationApiError4 } from "@tablation/client";
18331
18340
  var CREW_OUTDATED_KEY = "crew_outdated";
18332
18341
  function parseVersion(v) {
18333
18342
  const m = /^v?(\d+)\.(\d+)\.(\d+)/.exec(v.trim());
@@ -18387,7 +18396,7 @@ function openOutdated(state) {
18387
18396
  return state.shipAttention().previous().find((i) => i.key === CREW_OUTDATED_KEY)?.message ?? null;
18388
18397
  }
18389
18398
  function isUpgradeRequired(err3) {
18390
- return err3 instanceof TablationApiError3 && err3.status === 426;
18399
+ return err3 instanceof TablationApiError4 && err3.status === 426;
18391
18400
  }
18392
18401
  async function raiseFromUpgradeRequired(o, err3) {
18393
18402
  const have = sentVersion(o.ship) ?? "unknown";
@@ -23467,6 +23476,60 @@ function explainRefusal(readable, unreadable) {
23467
23476
  return parts.join(", ");
23468
23477
  }
23469
23478
 
23479
+ // src/seat-missing.ts
23480
+ import { TablationApiError as TablationApiError5 } from "@tablation/client";
23481
+ var SEAT_MISSING_REMEDY = "run `crew connect` to pick a seat";
23482
+ async function probeSeats(route2, read) {
23483
+ const r = route2.resolved;
23484
+ if (!r) return [];
23485
+ const wanted = [];
23486
+ for (const role of ROLE_NAMES) if (r.seats[role]) wanted.push({ role, seatId: r.seats[role] });
23487
+ if (r.releaseSeat) wanted.push({ role: "release", seatId: r.releaseSeat });
23488
+ const byId = /* @__PURE__ */ new Map();
23489
+ const probeOne = async (id) => {
23490
+ try {
23491
+ return { state: await read(id) === null ? "missing" : "present" };
23492
+ } catch (e) {
23493
+ if (e instanceof TablationApiError5 && e.status === 404) return { state: "missing" };
23494
+ return { state: "unknown", detail: e.message };
23495
+ }
23496
+ };
23497
+ for (const w of wanted) if (!byId.has(w.seatId)) byId.set(w.seatId, probeOne(w.seatId));
23498
+ return Promise.all(wanted.map(async (w) => ({ ...w, ...await byId.get(w.seatId) })));
23499
+ }
23500
+ var seatMissingKey = (route2, role) => `seat_missing:${route2}:${role}`;
23501
+ function seatMissingMessage(route2, role) {
23502
+ return `${route2}: the ${role} seat's Crew row no longer exists, so that role is skipped \u2014 ${SEAT_MISSING_REMEDY}. Clears automatically once the seat resolves`;
23503
+ }
23504
+ function seatMissingItem(route2, role, nowIso = (/* @__PURE__ */ new Date()).toISOString()) {
23505
+ return { kind: "seat_missing", key: seatMissingKey(route2, role), since: nowIso, message: seatMissingMessage(route2, role) };
23506
+ }
23507
+ async function reconcileSeatAttention(route2, probes, io) {
23508
+ const slug2 = routeSlug(route2.route);
23509
+ for (const p of probes) {
23510
+ if (p.state === "missing") await io.raise(seatMissingItem(slug2, p.role));
23511
+ else if (p.state === "present") io.clear(seatMissingKey(slug2, p.role));
23512
+ }
23513
+ }
23514
+ var missingRoles = (probes) => probes.filter((p) => p.state === "missing").map((p) => p.role);
23515
+ function mergeSeatAttention(open, route2, probes, nowIso = (/* @__PURE__ */ new Date()).toISOString()) {
23516
+ const slug2 = routeSlug(route2.route);
23517
+ const settled = new Map(probes.filter((p) => p.state !== "unknown").map((p) => [seatMissingKey(slug2, p.role), p.state]));
23518
+ const kept = open.filter((i) => i.kind !== "seat_missing" || !settled.has(i.key) || settled.get(i.key) === "missing");
23519
+ const have = new Set(kept.map((i) => i.key));
23520
+ const added = probes.filter((p) => p.state === "missing" && !have.has(seatMissingKey(slug2, p.role))).map((p) => seatMissingItem(slug2, p.role, nowIso));
23521
+ return [...kept, ...added];
23522
+ }
23523
+ function seatMissingProblems(route2, probes) {
23524
+ return probes.filter((p) => p.state === "missing").map((p) => ({
23525
+ severity: "blocker",
23526
+ kind: "seat_missing",
23527
+ route: route2.route,
23528
+ message: `route ${route2.route}: the ${p.role} seat's Crew row (${p.seatId}) no longer exists, so that role is skipped`,
23529
+ remedy: SEAT_MISSING_REMEDY
23530
+ }));
23531
+ }
23532
+
23470
23533
  // src/ssh-keys.ts
23471
23534
  import { execFileSync as execFileSync13 } from "child_process";
23472
23535
  import { existsSync as existsSync46, mkdirSync as mkdirSync34, readFileSync as readFileSync44, chmodSync as chmodSync3 } from "fs";
@@ -24279,9 +24342,29 @@ async function runOnePassUnguarded(o) {
24279
24342
  const { ctx } = await prepareRoutePass(o);
24280
24343
  const decision = await (o.decide ?? decideCycle)(ctx);
24281
24344
  await applyRouteDecision(o, ctx, decision);
24282
- const { started, skipped } = await fillSlots(o, [{ ctx, decision, roles: decision.selection.pending }]);
24345
+ const pending = await dropRolesWithMissingSeat(o, ctx, decision.selection.pending);
24346
+ const { started, skipped } = await fillSlots(o, [{ ctx, decision, roles: pending }]);
24283
24347
  await publishShipAttention(o.state, o.route, o.ship);
24284
- return { pending: decision.selection.pending, started, skipped };
24348
+ return { pending, started, skipped };
24349
+ }
24350
+ async function dropRolesWithMissingSeat(o, ctx, pending) {
24351
+ if (!o.route.resolved) return pending;
24352
+ try {
24353
+ const tracker = new Tracker(o.route, o.ship);
24354
+ const probes = await probeSeats(o.route, (id) => tracker.crewRow(id));
24355
+ await reconcileSeatAttention(o.route, probes, {
24356
+ raise: (item) => raiseShipAttention({ state: o.state, emit: ctx.emit, route: o.route, ship: o.ship }, item),
24357
+ clear: (key) => clearShipAttention(o.state, key)
24358
+ });
24359
+ const missing = new Set(missingRoles(probes));
24360
+ for (const role of missing) {
24361
+ ctx.emit.warn(`${role} skipped this cycle: its configured seat's Crew row no longer exists (${SEAT_MISSING_REMEDY})`, { step: "select", role: role === "release" ? void 0 : role });
24362
+ }
24363
+ return pending.filter((r) => !missing.has(r));
24364
+ } catch (e) {
24365
+ ctx.emit.warn(`could not check the configured seats: ${e.message}`, { step: "select" });
24366
+ return pending;
24367
+ }
24285
24368
  }
24286
24369
  async function prepareRoutePass(o) {
24287
24370
  await hydrateApiKeys([o.route], o.getSessionStore);
@@ -28283,7 +28366,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
28283
28366
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
28284
28367
  import { join as join60 } from "path";
28285
28368
  function builtVersion() {
28286
- return true ? "0.157.1" : null;
28369
+ return true ? "0.157.2" : null;
28287
28370
  }
28288
28371
  var REBUILD_HINT = "rebuild with npm run build";
28289
28372
  function newestMtime(path) {
@@ -36145,6 +36228,8 @@ ${where.join("\n")}`);
36145
36228
  const repos = await resolvedRepos(route2);
36146
36229
  const seatIds = route2.resolved?.seats ?? {};
36147
36230
  const crewRows = Object.keys(seatIds).length ? await statusTracker.crewRows() : [];
36231
+ const seatProbes = await probeSeats(route2, (id) => statusTracker.crewRow(id));
36232
+ const seatProbeOf = (role) => seatProbes.find((p) => p.role === role);
36148
36233
  const crewRowById = new Map(crewRows.map((c) => [c.id, c]));
36149
36234
  const agentPersonas = route2.resolved?.agentPersonas ?? {};
36150
36235
  const seats2 = ROLE_NAMES.filter((r) => r !== "pair").map((r) => {
@@ -36156,6 +36241,8 @@ ${where.join("\n")}`);
36156
36241
  role: r,
36157
36242
  label: ROLE_LABEL[r],
36158
36243
  crewId: seatId ?? null,
36244
+ // Additive (CREW-3449): true only when the tracker answered 404 for this seat's Crew row.
36245
+ missing: seatProbeOf(r)?.state === "missing",
36159
36246
  name: crewRow?.name ?? null,
36160
36247
  personaName,
36161
36248
  // Additive (CREW-2822): how many runs this seat has live right now.
@@ -36191,7 +36278,7 @@ ${where.join("\n")}`);
36191
36278
  eventFile: eventFileFor(cfg.ship.stateDir),
36192
36279
  // Additive (CREW-1373): open ship-level items, including the
36193
36280
  // derived `release_stale`. `version` stays 1.
36194
- attention: openShipAttention(state),
36281
+ attention: mergeSeatAttention(openShipAttention(state), route2, seatProbes),
36195
36282
  // Additive (CREW-2495): this ship's Ships-row name and whether it has drifted from `name`.
36196
36283
  rowName: nameSync.rowName ?? null,
36197
36284
  nameDrift: nameSync.drift,
@@ -36275,7 +36362,7 @@ ${where.join("\n")}`);
36275
36362
  `);
36276
36363
  break;
36277
36364
  }
36278
- const shipAttention = openShipAttention(state);
36365
+ const shipAttention = mergeSeatAttention(openShipAttention(state), route2, await probeSeats(route2, (id) => statusTracker.crewRow(id)));
36279
36366
  let heldReleases = [];
36280
36367
  let waitViews = [];
36281
36368
  let deferredReleases = [];
@@ -36509,6 +36596,9 @@ ${where.join("\n")}`);
36509
36596
  if (jsonGit && !jsonGit.ok) {
36510
36597
  problems.push({ severity: "blocker", kind: "git_unrunnable", message: `git failed to run: ${jsonGit.detail}`, remedy: "fix the git on the scheduler PATH (on macOS, install the Xcode command line tools), then re-run `crew doctor`" });
36511
36598
  }
36599
+ if (!flag("offline") && route2.resolved) {
36600
+ problems.push(...seatMissingProblems(route2, await probeSeats(route2, (id) => new Tracker(route2, cfg.ship).crewRow(id))));
36601
+ }
36512
36602
  problems.push(...attentionProblems(openShipAttention(state), problems));
36513
36603
  if (problems.some((p) => p.severity === "blocker")) process.exitCode = 1;
36514
36604
  process.stdout.write(`${JSON.stringify({ offline: flag("offline"), pushAuth, tools: toolRows, daemon: daemonLiveness, problems, passed }, null, 2)}
@@ -37027,7 +37117,21 @@ crew manifest: ${seats2.length ? seats2.map((c) => c.name).join(", ") : "non
37027
37117
  }
37028
37118
  }
37029
37119
  }
37030
- for (const i of visibleAttention(openShipAttention(state), Boolean(dockerFinding))) {
37120
+ if (!flag("offline")) {
37121
+ for (const r of cfg.routes) {
37122
+ if (!r.resolved) continue;
37123
+ try {
37124
+ const tracker2 = new Tracker(r, cfg.ship);
37125
+ for (const p of seatMissingProblems(r, await probeSeats(r, (id) => tracker2.crewRow(id)))) {
37126
+ R.line(`seat: BLOCKER ${p.message} \u2014 ${p.remedy}
37127
+ `);
37128
+ process.exitCode = 1;
37129
+ }
37130
+ } catch {
37131
+ }
37132
+ }
37133
+ }
37134
+ for (const i of visibleAttention(openShipAttention(state), Boolean(dockerFinding)).filter((x) => x.kind !== "seat_missing")) {
37031
37135
  R.line(`attention: ${i.kind} \u2014 ${i.message} (since ${i.since})
37032
37136
  `);
37033
37137
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.157.1",
3
+ "version": "0.157.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",