@tablation/crew 0.169.6 → 0.170.0

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 +113 -4
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -26861,6 +26861,98 @@ function fallbackStateDir(configFile) {
26861
26861
  return join55(dirname30(configFile), "state");
26862
26862
  }
26863
26863
 
26864
+ // src/routes-available.ts
26865
+ var lower = (s) => s.trim().toLowerCase();
26866
+ async function buildRoutesAvailable(routes, deps) {
26867
+ const doFetch = deps.fetch ?? fetch;
26868
+ const hosts = /* @__PURE__ */ new Map();
26869
+ for (const r of routes) {
26870
+ const h = deps.hostOf(r.baseUrl);
26871
+ hosts.set(h, [...hosts.get(h) ?? [], r]);
26872
+ }
26873
+ const existing = new Set(routes.map((r) => {
26874
+ const [ws, proj] = splitRoute(r.route);
26875
+ return `${deps.hostOf(r.baseUrl)}|${lower(ws)}|${lower(proj)}`;
26876
+ }));
26877
+ const get2 = (r, key, path) => doFetch(`${r.baseUrl.replace(/\/+$/, "")}/api${path}`, {
26878
+ headers: { Authorization: `Bearer ${key}`, "User-Agent": deps.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0" }
26879
+ });
26880
+ return Promise.all([...hosts].map(async ([host, hostRoutes]) => {
26881
+ let keyed = 0;
26882
+ for (const r of hostRoutes) {
26883
+ let key;
26884
+ try {
26885
+ key = resolveApiKey(r);
26886
+ } catch {
26887
+ continue;
26888
+ }
26889
+ keyed++;
26890
+ let res;
26891
+ try {
26892
+ res = await get2(r, key, "/auth/my-tracker-apps");
26893
+ } catch (e) {
26894
+ return { host, error: e.message, reason: "failed" };
26895
+ }
26896
+ if (res.status === 401 || res.status === 403) continue;
26897
+ if (res.status === 404) return { host, error: "this Tablation host does not offer the tracker app list yet", reason: "unsupported" };
26898
+ if (!res.ok) return { host, error: `/auth/my-tracker-apps answered HTTP ${res.status}`, reason: "failed" };
26899
+ const apps = await res.json();
26900
+ const list = Array.isArray(apps) ? apps : apps.apps ?? [];
26901
+ let email = null;
26902
+ try {
26903
+ const me = await get2(r, key, "/auth/me");
26904
+ if (me.ok) email = (await me.json()).email ?? null;
26905
+ } catch {
26906
+ }
26907
+ const signIn = /* @__PURE__ */ new Map();
26908
+ const out = [];
26909
+ for (const a of list) {
26910
+ const address = a.workspace.path || a.workspace.slug;
26911
+ if (existing.has(`${host}|${lower(address)}|${lower(a.project.slug)}`)) continue;
26912
+ if (!signIn.has(address)) {
26913
+ const sibling = siblingRouteKey(hostRoutes, host, (w) => lower(w) === lower(address), deps.hostOf);
26914
+ signIn.set(address, !sibling && !await deps.holdsCredential(host, address).catch(() => false));
26915
+ }
26916
+ out.push({
26917
+ route: `${address}/${a.project.slug}`,
26918
+ workspace: { address, name: a.workspace.name, role: a.workspace.role },
26919
+ project: { slug: a.project.slug, name: a.project.name },
26920
+ accepted: a.interfaceVersion === null || versionAccepted(a.interfaceVersion),
26921
+ needsSignIn: signIn.get(address)
26922
+ });
26923
+ }
26924
+ return { host, identity: { email }, routes: out };
26925
+ }
26926
+ return keyed === 0 ? { host, error: "no route on this host has a usable key", reason: "no_key" } : { host, error: "every key on this host was rejected", reason: "rejected" };
26927
+ }));
26928
+ }
26929
+ function formatRoutesAvailable(report, hadRoutes) {
26930
+ if (!hadRoutes) return "No routes are configured, so there is nothing to list from. `crew connect` is the first-run path.\n";
26931
+ const lines2 = [];
26932
+ let any = false;
26933
+ for (const h of report) {
26934
+ if ("error" in h) {
26935
+ lines2.push(`${h.host}: ${h.error}`);
26936
+ continue;
26937
+ }
26938
+ if (report.length > 1) lines2.push(`${h.host}${h.identity.email ? ` (${h.identity.email})` : ""}`);
26939
+ const byWs = /* @__PURE__ */ new Map();
26940
+ for (const r of h.routes) byWs.set(r.workspace.address, [...byWs.get(r.workspace.address) ?? [], r]);
26941
+ for (const [, rs] of [...byWs].sort((a, b) => a[1][0].workspace.name.localeCompare(b[1][0].workspace.name))) {
26942
+ any = true;
26943
+ lines2.push(rs[0].workspace.name);
26944
+ for (const r of rs.sort((a, b) => a.project.name.localeCompare(b.project.name))) {
26945
+ const marks = [!r.accepted ? `needs a newer crew (accepts ${acceptedLabel()})` : "", r.needsSignIn ? "sign-in needed" : ""].filter(Boolean);
26946
+ lines2.push(` ${r.project.name} ${r.route}${marks.length ? ` [${marks.join("; ")}]` : ""}`);
26947
+ }
26948
+ }
26949
+ }
26950
+ if (!any && report.some((h) => !("error" in h))) lines2.push("Every tracker app you can reach is already routed on this machine.");
26951
+ if (any) lines2.push("", "Add one with `crew connect <route>`.");
26952
+ return `${lines2.join("\n")}
26953
+ `;
26954
+ }
26955
+
26864
26956
  // src/projects-cmd.ts
26865
26957
  async function buildProjectsReport(routes, open2) {
26866
26958
  return Promise.all(routes.map(async (r) => {
@@ -29967,7 +30059,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
29967
30059
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
29968
30060
  import { join as join61 } from "path";
29969
30061
  function builtVersion() {
29970
- return true ? "0.169.6" : null;
30062
+ return true ? "0.170.0" : null;
29971
30063
  }
29972
30064
  var REBUILD_HINT = "rebuild with npm run build";
29973
30065
  function newestMtime(path) {
@@ -32168,6 +32260,7 @@ function usage(problem, requested = false) {
32168
32260
  crew --version [--json] print the crew version on one line (also: crew version); --json adds home and compiled
32169
32261
  crew status [route] [--json] [--verbose] what is running and what needs a person; --verbose adds configuration and full lists; --json for a machine reader
32170
32262
  crew projects [--route R] [--json] the Projects rows each route can read (id, name, prefix, work mode)
32263
+ crew routes available [--json] the tracker apps you can reach that this machine has no route for (read-only; starts no sign-in)
32171
32264
  crew projects add [route] NAME --prefix P [--work-mode automatic|hybrid|manual] [--json] [--dry-run] create a Projects row
32172
32265
  crew provision --key K --route WS[/PROJECT] [--forge-host H] [--ship-name N] [--json] one non-interactive run: connect, forge tokens,
32173
32266
  enable routes, install units with lingering, start the daemon; safe to re-run (CREW_CONNECT_KEY,
@@ -32322,6 +32415,7 @@ var KNOWN_COMMANDS = /* @__PURE__ */ new Set([
32322
32415
  "projects",
32323
32416
  "reap",
32324
32417
  "release",
32418
+ "routes",
32325
32419
  "reload",
32326
32420
  "repos",
32327
32421
  "resume",
@@ -32760,8 +32854,8 @@ if (command === "passenger-sync-daemon") {
32760
32854
  firstRun = { answers, configPath };
32761
32855
  cfg = loadConfig(CREW_HOME, configPath, { text: renderShipBlock(answers), allowNoRoutes: true });
32762
32856
  } else {
32763
- const toleratesNoRoutes = command === "credential" || command === "forge" || command === "repos" || command === "ship" || command === "disconnect" && flag("reset") || command === "deprovision" || command === "connect" && flag("sign-out");
32764
- const configless = command === "connect" && flag("sign-out") || command === "disconnect" && flag("reset") || command === "deprovision";
32857
+ const toleratesNoRoutes = command === "routes" || command === "credential" || command === "forge" || command === "repos" || command === "ship" || command === "disconnect" && flag("reset") || command === "deprovision" || command === "connect" && flag("sign-out");
32858
+ const configless = command === "routes" || command === "connect" && flag("sign-out") || command === "disconnect" && flag("reset") || command === "deprovision";
32765
32859
  if (configless && !existsSync60(findConfigFile(CREW_HOME))) {
32766
32860
  cfg = loadConfig(CREW_HOME, firstRunConfigPath(), { text: "ship: {}\n", allowNoRoutes: true });
32767
32861
  } else {
@@ -32819,7 +32913,7 @@ if (command === "passenger-sync-daemon") {
32819
32913
  const DAEMON_SUBCOMMANDS = /* @__PURE__ */ new Set(["start", "stop", "status", "restart"]);
32820
32914
  const worktreeArgs = command === "worktree" ? splitWorktreeArgs(positional, cfg.routes.map((r) => r.route)) : void 0;
32821
32915
  const named = worktreeArgs ? worktreeArgs.route : command === "daemon" && DAEMON_SUBCOMMANDS.has(positional[1] ?? "") ? positional[2] : positional[1];
32822
- const fleetWide = command === "inbox" || command === "connect" || command === "disconnect" || command === "deprovision" || command === "agents" || command === "skills" || command === "logbook" || command === "repos" || command === "ship" || command === "projects" || command === "periscope" || command === "whoami" || command === "sandbox" || releaseFleetWide || // CREW-3875: the scheduler units are per ship and name no route, so a route given is ignored.
32916
+ const fleetWide = command === "inbox" || command === "connect" || command === "disconnect" || command === "deprovision" || command === "agents" || command === "skills" || command === "logbook" || command === "repos" || command === "ship" || command === "projects" || command === "routes" || command === "periscope" || command === "whoami" || command === "sandbox" || releaseFleetWide || // CREW-3875: the scheduler units are per ship and name no route, so a route given is ignored.
32823
32917
  command === "install" || command === "uninstall" || command === "pause" || command === "resume" || command === "reload" || FLEET_CAPABLE.has(command) && !named && cfg.routes.length > 1 || worktreeArgs !== void 0 && !named && cfg.routes.length > 1;
32824
32918
  let route2;
32825
32919
  try {
@@ -38030,6 +38124,21 @@ ${where.join("\n")}`);
38030
38124
  if (report.some((r) => !r.ok)) process.exitCode = 1;
38031
38125
  break;
38032
38126
  }
38127
+ case "routes": {
38128
+ if (positional[1] !== "available") die("crew routes", "unknown subcommand", "`crew routes available [--json]`", 2);
38129
+ const report = await buildRoutesAvailable(cfg.routes, {
38130
+ userAgent: cfg.ship.userAgent,
38131
+ hostOf: hostFromUrl4,
38132
+ holdsCredential: async (host, address) => {
38133
+ const s = getSessionStore();
38134
+ return !!(await s.get(host, address))?.apiKey;
38135
+ }
38136
+ });
38137
+ process.stdout.write(flag("json") ? `${JSON.stringify({ hosts: report }, null, 2)}
38138
+ ` : formatRoutesAvailable(report, cfg.routes.length > 0));
38139
+ if (report.length > 0 && report.every((h) => "error" in h)) process.exitCode = 1;
38140
+ break;
38141
+ }
38033
38142
  case "projects": {
38034
38143
  if (positional[1] === "add") {
38035
38144
  const rest = positional.slice(2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.169.6",
3
+ "version": "0.170.0",
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",