@tablation/crew 0.169.5 → 0.169.6

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 +42 -6
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -5164,6 +5164,24 @@ function credentialSource(r) {
5164
5164
  }
5165
5165
  return process.env.CREW_API_KEY?.trim() ? "CREW_API_KEY" : "none";
5166
5166
  }
5167
+ function siblingRouteKey(routes, host, sameWorkspace, hostOf) {
5168
+ for (const r of routes) {
5169
+ const [workspace] = splitRoute(r.route);
5170
+ if (hostOf(r.baseUrl) !== host || !sameWorkspace(workspace)) continue;
5171
+ const source = credentialSource(r);
5172
+ if (source === "none") continue;
5173
+ try {
5174
+ return {
5175
+ apiKey: resolveApiKey(r),
5176
+ source,
5177
+ workspace,
5178
+ ...source === "apiKeyFile" ? { apiKeyFile: r.apiKeyFile, apiKeyVar: r.apiKeyVar } : {}
5179
+ };
5180
+ } catch {
5181
+ }
5182
+ }
5183
+ return void 0;
5184
+ }
5167
5185
  var KEYCHAIN_ELIGIBLE_ROUTES = /* @__PURE__ */ new WeakSet();
5168
5186
  async function hydrateApiKeys(routes, getStore = getSessionStore) {
5169
5187
  let store;
@@ -28315,7 +28333,8 @@ function renderConnection(d, route2, dir, opts = {}) {
28315
28333
  apiKeyVar: ${opts.apiKeyVar}` : "";
28316
28334
  const baseUrlLine = opts.baseUrl && opts.baseUrl.replace(/\/+$/, "") !== DEFAULT_BASE_URL ? ` baseUrl: "${opts.baseUrl}"
28317
28335
  ` : "";
28318
- const keyLines = [apiKeyFileLine, apiKeyVarLine.replace(/^\n/, "")].filter(Boolean).join("\n");
28336
+ const inlineKeyLine = !opts.keychainBacked && opts.inlineApiKey ? ` apiKey: "${opts.inlineApiKey}"` : "";
28337
+ const keyLines = [apiKeyFileLine, apiKeyVarLine.replace(/^\n/, ""), inlineKeyLine].filter(Boolean).join("\n");
28319
28338
  return ` - route: ${route2}
28320
28339
  enabled: false # set to true once \`crew doctor\` is green
28321
28340
  ${opts.area ? ` area: "${opts.area}"
@@ -29948,7 +29967,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
29948
29967
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
29949
29968
  import { join as join61 } from "path";
29950
29969
  function builtVersion() {
29951
- return true ? "0.169.5" : null;
29970
+ return true ? "0.169.6" : null;
29952
29971
  }
29953
29972
  var REBUILD_HINT = "rebuild with npm run build";
29954
29973
  function newestMtime(path) {
@@ -35803,8 +35822,9 @@ ${reconstruction.prompt}
35803
35822
  let workspace = argWorkspace ?? value("workspace-id") ?? value("workspace") ?? connectChoices.workspace;
35804
35823
  const project = argProject ?? value("project") ?? connectChoices.project;
35805
35824
  const baseUrl = value("base-url") ?? cfg.routes[0]?.baseUrl ?? DEFAULT_BASE_URL;
35806
- let apiKey = value("key") ?? process.env.CREW_CONNECT_KEY ?? cfg.routes.find((c) => c.apiKey)?.apiKey;
35825
+ let apiKey = value("key") ?? process.env.CREW_CONNECT_KEY ?? (workspace ? void 0 : cfg.routes.find((c) => c.apiKey)?.apiKey);
35807
35826
  const givenKeySource = value("key") ?? process.env.CREW_CONNECT_KEY ? "flag" : "config";
35827
+ let siblingKey;
35808
35828
  let store;
35809
35829
  try {
35810
35830
  store = getSessionStore();
@@ -35833,6 +35853,19 @@ ${reconstruction.prompt}
35833
35853
  } catch {
35834
35854
  }
35835
35855
  }
35856
+ if (!apiKey && workspace) {
35857
+ const host = hostFromUrl4(baseUrl);
35858
+ const full = rememberedAddressFor(cfg.ship.stateDir, host, workspace);
35859
+ siblingKey = siblingRouteKey(cfg.routes, host, (w) => w === workspace || w === full, hostFromUrl4);
35860
+ if (siblingKey) {
35861
+ apiKey = siblingKey.apiKey;
35862
+ if (siblingKey.source === "keychain") {
35863
+ keychainBacked = true;
35864
+ sessionAddress = siblingKey.workspace;
35865
+ }
35866
+ routineLine(`Reusing the key of the existing route in ${host}/${workspace}.`);
35867
+ }
35868
+ }
35836
35869
  let signInSource = apiKey ? "key" : "device";
35837
35870
  if (!apiKey && !workspace && store) {
35838
35871
  const resumable = await resumableSessions({
@@ -36274,7 +36307,9 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
36274
36307
  }
36275
36308
  }
36276
36309
  }
36277
- if ((mintedFromDevice || firstRunFromFlags || keyFromFlag) && !keychainBacked) {
36310
+ if (siblingKey?.source === "apiKeyFile") {
36311
+ apiKeyFile = siblingKey.apiKeyFile;
36312
+ } else if (!siblingKey && (mintedFromDevice || firstRunFromFlags || keyFromFlag) && !keychainBacked) {
36278
36313
  apiKeyFile = apiKeyPathFor(cfg.ship.stateDir, route3);
36279
36314
  if (dryRun) {
36280
36315
  process.stderr.write(`(dry run) would write the API key to ${apiKeyFile}
@@ -36286,7 +36321,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
36286
36321
  routineLine(`API key written to ${apiKeyFile}`);
36287
36322
  }
36288
36323
  }
36289
- const keyPersisted = keychainBacked || apiKeyFile !== void 0;
36324
+ const keyPersisted = keychainBacked || apiKeyFile !== void 0 || siblingKey !== void 0;
36290
36325
  const wizard = firstRun;
36291
36326
  const writeFirstRun = wizard !== void 0 && !dryRun && keyPersisted;
36292
36327
  const routeDir = value("dir");
@@ -36297,9 +36332,10 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
36297
36332
  {
36298
36333
  area: value("area"),
36299
36334
  apiKeyFile,
36300
- apiKeyVar: apiKeyFile ? apiKeyVar : void 0,
36335
+ apiKeyVar: apiKeyFile ? siblingKey?.apiKeyVar ?? apiKeyVar : void 0,
36301
36336
  keychainBacked,
36302
36337
  baseUrl,
36338
+ ...siblingKey?.source === "inline" ? { inlineApiKey: siblingKey.apiKey } : {},
36303
36339
  ...writeFirstRun ? { hostPassengers: wizard.answers.hostPassengers } : {}
36304
36340
  }
36305
36341
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.169.5",
3
+ "version": "0.169.6",
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",