@rallycry/conveyor-agent 10.13.57 → 10.13.59

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.
@@ -9,14 +9,14 @@ import {
9
9
  readAgentVersion,
10
10
  redactToken,
11
11
  reportBootMilestone
12
- } from "./chunk-WVUQ5CH5.js";
12
+ } from "./chunk-QZN6HVUY.js";
13
13
  import {
14
14
  workbenchPort
15
15
  } from "./chunk-4VUQ2NPF.js";
16
16
  import {
17
17
  startWorkbenchServer
18
- } from "./chunk-MS43QSHO.js";
19
- import "./chunk-PWYJZY3P.js";
18
+ } from "./chunk-AXA55U4Z.js";
19
+ import "./chunk-NAK6FY5U.js";
20
20
  import {
21
21
  DEFAULT_WORKBENCH_PORT
22
22
  } from "./chunk-JIGG755T.js";
@@ -1316,4 +1316,4 @@ export {
1316
1316
  runBoot,
1317
1317
  workbenchBootSteps
1318
1318
  };
1319
- //# sourceMappingURL=boot-37ZX7POR.js.map
1319
+ //# sourceMappingURL=boot-7OPX55AO.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  loadPtySpawn,
3
3
  terminateProcessGroup
4
- } from "./chunk-PWYJZY3P.js";
4
+ } from "./chunk-NAK6FY5U.js";
5
5
  import {
6
6
  FrameReader,
7
7
  timingSafeTokenEqual,
@@ -296,4 +296,4 @@ async function runReaddir(socket, req) {
296
296
  export {
297
297
  startWorkbenchServer
298
298
  };
299
- //# sourceMappingURL=chunk-MS43QSHO.js.map
299
+ //# sourceMappingURL=chunk-AXA55U4Z.js.map
@@ -7,7 +7,7 @@ import {
7
7
  readAgentVersion,
8
8
  registerBootMilestoneSocketFallback,
9
9
  reportBootMilestone
10
- } from "./chunk-WVUQ5CH5.js";
10
+ } from "./chunk-QZN6HVUY.js";
11
11
  import {
12
12
  LoopLagMonitor,
13
13
  buildConveyorSocketOptions,
@@ -30,6 +30,7 @@ import {
30
30
  buildPromptBytes,
31
31
  buildSpawnArgs,
32
32
  cleanTerminalOutput,
33
+ ghHostsExternallyOwned,
33
34
  gitCredentialHelper,
34
35
  githubTokenFilePath,
35
36
  inheritedEnv,
@@ -53,7 +54,7 @@ import {
53
54
  transcriptSize,
54
55
  turnOptionsFrom,
55
56
  writeGitCredential
56
- } from "./chunk-PWYJZY3P.js";
57
+ } from "./chunk-NAK6FY5U.js";
57
58
 
58
59
  // src/setup/bootstrap.ts
59
60
  var BOOTSTRAP_TIMEOUT_MS = 3e4;
@@ -1463,24 +1464,43 @@ async function isAuthError(cwd) {
1463
1464
  return errLooksLikeAuth(err);
1464
1465
  }
1465
1466
  }
1467
+ function credentialErrorText(err) {
1468
+ const raw = err instanceof Error ? err.message : String(err);
1469
+ return raw.replace(/\/\/[^@\s]+@/g, "//***@");
1470
+ }
1466
1471
  async function updateRemoteCredential(cwd, credential) {
1472
+ const result = { ok: false, storeWritten: false, helperConfigured: false };
1467
1473
  try {
1468
1474
  const currentUrl = await git(cwd, ["remote", "get-url", "origin"]);
1469
1475
  const cloneUrl = credential.cloneUrl ?? currentUrl;
1470
- writeGitCredential(cwd, cloneUrl, credential);
1471
- if (currentUrl !== cloneUrl) {
1472
- await git(cwd, ["remote", "set-url", "origin", cloneUrl]);
1476
+ const normalizedUrl = writeGitCredential(cwd, cloneUrl, credential);
1477
+ result.storeWritten = true;
1478
+ if (currentUrl !== normalizedUrl) {
1479
+ await git(cwd, ["remote", "set-url", "origin", normalizedUrl]);
1473
1480
  }
1474
1481
  await git(cwd, ["config", "--local", "credential.helper", gitCredentialHelper(cwd)]);
1475
- } catch {
1482
+ result.helperConfigured = true;
1483
+ result.ok = true;
1484
+ } catch (err) {
1485
+ result.error = credentialErrorText(err);
1476
1486
  }
1487
+ return result;
1477
1488
  }
1478
1489
  async function updateRemoteToken(cwd, token) {
1479
1490
  const username = process.env.CONVEYOR_GIT_USERNAME || "x-access-token";
1480
1491
  const cloneUrl = process.env.CONVEYOR_GIT_CLONE_URL || void 0;
1481
- await updateRemoteCredential(cwd, { username, secret: token, cloneUrl });
1492
+ const credential = await updateRemoteCredential(cwd, { username, secret: token, cloneUrl });
1482
1493
  process.env.CONVEYOR_GIT_SECRET = token;
1483
- syncGithubTokenFiles(token);
1494
+ const files = syncGithubTokenFiles(token);
1495
+ return { credential, files };
1496
+ }
1497
+ async function verifyGitCredential(cwd) {
1498
+ try {
1499
+ await git(cwd, ["ls-remote", "--heads", "origin"], 3e4);
1500
+ return { ok: true };
1501
+ } catch (err) {
1502
+ return { ok: false, error: credentialErrorText(err) };
1503
+ }
1484
1504
  }
1485
1505
  function wipRefForBranch(branch) {
1486
1506
  return `conveyor-wip/${branch}`;
@@ -3281,6 +3301,10 @@ var FIREBASE_EMULATOR_COMMAND = [
3281
3301
  EOF
3282
3302
  exec firebase emulators:start --only=auth --project=rally-cry-dev`
3283
3303
  ];
3304
+ var FIREBASE_EMULATOR_ENV = {
3305
+ METADATA_SERVER_DETECTION: "none",
3306
+ GOOGLE_APPLICATION_CREDENTIALS: "/dev/null"
3307
+ };
3284
3308
  var CATALOG = {
3285
3309
  postgresql: {
3286
3310
  name: "postgresql",
@@ -3366,6 +3390,10 @@ var CATALOG = {
3366
3390
  requests: { cpuMillicores: 25, memoryMi: 32, ephemeralMi: 256 },
3367
3391
  limits: { cpuMillicores: 50, memoryMi: 64, ephemeralMi: 256 }
3368
3392
  },
3393
+ connectionEnv: {
3394
+ REDIS_URL: "redis://redis:6379",
3395
+ AUTH_REDIS_URL: "redis://redis:6379"
3396
+ },
3369
3397
  statefulBake: false,
3370
3398
  // Redis holds no baked state, so the bake runs the stock image CMD.
3371
3399
  bake: {},
@@ -3411,6 +3439,9 @@ var CATALOG = {
3411
3439
  requests: { cpuMillicores: 500, memoryMi: 1024, ephemeralMi: 256 },
3412
3440
  limits: { cpuMillicores: 2e3, memoryMi: 1024, ephemeralMi: 256 }
3413
3441
  },
3442
+ connectionEnv: {
3443
+ ELASTICSEARCH_URL: "http://elasticsearch:9200"
3444
+ },
3414
3445
  statefulBake: true,
3415
3446
  bake: {
3416
3447
  // No lock-clearing command at bake time: the bake starts from the stock
@@ -3480,8 +3511,7 @@ var CATALOG = {
3480
3511
  // for this container only: google-auth-library skips metadata detection
3481
3512
  // and finds no key file, firebase-tools logs "not authenticated" and
3482
3513
  // starts the emulator immediately. The agent container keeps its WI.
3483
- METADATA_SERVER_DETECTION: "none",
3484
- GOOGLE_APPLICATION_CREDENTIALS: "/dev/null"
3514
+ ...FIREBASE_EMULATOR_ENV
3485
3515
  },
3486
3516
  resources: {
3487
3517
  requests: { cpuMillicores: 100, memoryMi: 256, ephemeralMi: 256 },
@@ -3503,8 +3533,12 @@ var CATALOG = {
3503
3533
  // The emulator writes its config at startup, so the bake needs the same
3504
3534
  // inline command the runtime uses.
3505
3535
  command: FIREBASE_EMULATOR_COMMAND,
3536
+ environment: FIREBASE_EMULATOR_ENV,
3506
3537
  healthcheck: {
3507
- test: ["CMD-SHELL", "wget -qO- http://localhost:9099/ >/dev/null 2>&1 || exit 1"],
3538
+ test: [
3539
+ "CMD-SHELL",
3540
+ `node -e "fetch('http://localhost:9099/').then((response) => process.exit(response.ok ? 0 : 1)).catch(() => process.exit(1))"`
3541
+ ],
3508
3542
  intervalSec: 3,
3509
3543
  timeoutSec: 5,
3510
3544
  retries: 20
@@ -11169,18 +11203,48 @@ function buildRefreshGithubTokenTool(connection, config) {
11169
11203
  const result = await connection.call("refreshGithubToken", {
11170
11204
  sessionId: connection.sessionId
11171
11205
  });
11172
- await updateRemoteToken(config.workspaceDir, result.token);
11206
+ const written = await updateRemoteToken(config.workspaceDir, result.token);
11173
11207
  process.env.GITHUB_TOKEN = result.token;
11174
11208
  process.env.GH_TOKEN = result.token;
11175
11209
  const tokenFile = githubTokenFilePath();
11210
+ const failures = [];
11211
+ if (!written.credential.storeWritten) {
11212
+ failures.push(
11213
+ `- git credential store NOT written${written.credential.error ? `: ${written.credential.error}` : ""}`
11214
+ );
11215
+ } else if (!written.credential.helperConfigured) {
11216
+ failures.push(
11217
+ `- git credential helper NOT configured${written.credential.error ? `: ${written.credential.error}` : ""}`
11218
+ );
11219
+ }
11220
+ if (!written.files.tokenFile) failures.push(`- token file ${tokenFile} NOT written`);
11221
+ if (!written.files.ghHosts && !ghHostsExternallyOwned()) {
11222
+ failures.push("- gh CLI config NOT written");
11223
+ }
11224
+ const probe = await verifyGitCredential(config.workspaceDir);
11225
+ if (!probe.ok) {
11226
+ failures.push(
11227
+ `- git could not authenticate to origin: ${probe.error ?? "unknown error"}`
11228
+ );
11229
+ }
11230
+ if (failures.length > 0) {
11231
+ return textResult(
11232
+ [
11233
+ probe.ok ? "GitHub token refreshed, but some credential copies did not update." : "GitHub token refresh did NOT produce a working git credential.",
11234
+ ...failures,
11235
+ `A current token is available at ${tokenFile} when that file was written.`,
11236
+ "Do not retry this tool more than once. Report the failing lines above to the team \u2014 the GitHub App install may be missing for this project, or the pod's credential directory may not be writable."
11237
+ ].join("\n")
11238
+ );
11239
+ }
11176
11240
  return textResult(
11177
11241
  [
11178
- "GitHub token refreshed.",
11179
- "- git: the credential store is updated, so `git push` works now with no extra step.",
11242
+ "GitHub token refreshed and verified against origin.",
11243
+ "- git: the credential store and helper are updated, so `git push` works now with no extra step.",
11180
11244
  "- gh: the CLI config is updated, so `gh` works now with no extra step.",
11181
11245
  `- shell/scripts: read the current token from ${tokenFile}.`,
11182
11246
  ` For a command that needs it in the environment: GITHUB_TOKEN=$(cat ${tokenFile}) <command>`,
11183
- "Retry the failed command. If it still returns 401, the GitHub App install may be missing for this project \u2014 report that instead of retrying."
11247
+ "Retry the failed command."
11184
11248
  ].join("\n")
11185
11249
  );
11186
11250
  } catch (error) {
@@ -16148,10 +16212,17 @@ var SessionRunner = class _SessionRunner {
16148
16212
  const res = await this.connection.call("refreshGithubToken", {
16149
16213
  sessionId: this.connection.sessionId
16150
16214
  });
16151
- await updateRemoteToken(this.config.workspaceDir, res.token);
16215
+ const written = await updateRemoteToken(this.config.workspaceDir, res.token);
16152
16216
  process.env.GITHUB_TOKEN = res.token;
16153
16217
  process.env.GH_TOKEN = res.token;
16154
- process.stderr.write("[conveyor-agent] Proactively refreshed GitHub token\n");
16218
+ if (written.credential.ok) {
16219
+ process.stderr.write("[conveyor-agent] Proactively refreshed GitHub token\n");
16220
+ } else {
16221
+ process.stderr.write(
16222
+ `[conveyor-agent] Warning: refreshed GitHub token but the git credential did not update: ${written.credential.error ?? "unknown error"}
16223
+ `
16224
+ );
16225
+ }
16155
16226
  } catch (err) {
16156
16227
  const msg = err instanceof Error ? err.message : String(err);
16157
16228
  process.stderr.write(`[conveyor-agent] Warning: proactive token refresh failed: ${msg}
@@ -16341,6 +16412,8 @@ export {
16341
16412
  PtyHarness,
16342
16413
  resolveTuiKindFromEnv,
16343
16414
  resolveTuiAdapter,
16415
+ readWorkspaceBytes,
16416
+ statWorkspacePath,
16344
16417
  workspacePathExists,
16345
16418
  GIT_TIMEOUT_MS,
16346
16419
  hasUncommittedChanges,
@@ -16365,4 +16438,4 @@ export {
16365
16438
  loadConveyorConfig,
16366
16439
  unshallowRepo
16367
16440
  };
16368
- //# sourceMappingURL=chunk-VIEBOAJ7.js.map
16441
+ //# sourceMappingURL=chunk-JCRP6K6T.js.map