@rallycry/conveyor-agent 10.13.56 → 10.13.58

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-7765OQU5.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-DSP4KR4B.js";
19
- import "./chunk-UAGIXPYD.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-RW7SNO6X.js.map
1319
+ //# sourceMappingURL=boot-7OPX55AO.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  loadPtySpawn,
3
3
  terminateProcessGroup
4
- } from "./chunk-UAGIXPYD.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-DSP4KR4B.js.map
299
+ //# sourceMappingURL=chunk-AXA55U4Z.js.map
@@ -3,13 +3,11 @@ import {
3
3
  DEFAULT_RETRY_DELAY_MS,
4
4
  FETCH_TIMEOUT_MS,
5
5
  GIT_PREP_MAX_RETRIES,
6
- gitCredentialHelper,
7
6
  mapChatHistory,
8
7
  readAgentVersion,
9
8
  registerBootMilestoneSocketFallback,
10
- reportBootMilestone,
11
- writeGitCredential
12
- } from "./chunk-7765OQU5.js";
9
+ reportBootMilestone
10
+ } from "./chunk-QZN6HVUY.js";
13
11
  import {
14
12
  LoopLagMonitor,
15
13
  buildConveyorSocketOptions,
@@ -32,6 +30,9 @@ import {
32
30
  buildPromptBytes,
33
31
  buildSpawnArgs,
34
32
  cleanTerminalOutput,
33
+ ghHostsExternallyOwned,
34
+ gitCredentialHelper,
35
+ githubTokenFilePath,
35
36
  inheritedEnv,
36
37
  killPtyWithEscalation,
37
38
  needsRawReadyGate,
@@ -49,9 +50,11 @@ import {
49
50
  sessionTempBase,
50
51
  sleep,
51
52
  spawnOptionsFingerprint,
53
+ syncGithubTokenFiles,
52
54
  transcriptSize,
53
- turnOptionsFrom
54
- } from "./chunk-UAGIXPYD.js";
55
+ turnOptionsFrom,
56
+ writeGitCredential
57
+ } from "./chunk-NAK6FY5U.js";
55
58
 
56
59
  // src/setup/bootstrap.ts
57
60
  var BOOTSTRAP_TIMEOUT_MS = 3e4;
@@ -1159,6 +1162,8 @@ ${q.question}${q.options.length ? "\n" + q.options.map((o) => `- ${o.label}: ${o
1159
1162
  if (!result.ok) return { refreshedClaude: false, refreshedTaskToken: false };
1160
1163
  const previousTaskToken = process.env.CONVEYOR_TASK_TOKEN;
1161
1164
  applyBootstrapToEnv(result.config);
1165
+ const env = result.config.envVars ?? {};
1166
+ syncGithubTokenFiles(env.CONVEYOR_GITHUB_TOKEN ?? env.GH_TOKEN ?? env.GITHUB_TOKEN);
1162
1167
  const refreshedTaskToken = result.config.mode !== "project" && Boolean(result.config.taskToken) && result.config.taskToken !== previousTaskToken;
1163
1168
  if (refreshedTaskToken && result.config.taskToken) {
1164
1169
  this.config.taskToken = result.config.taskToken;
@@ -1188,7 +1193,10 @@ ${q.question}${q.options.length ? "\n" + q.options.map((o) => `- ${o.label}: ${o
1188
1193
  for (const [key, value] of Object.entries(bundle.envVars ?? {})) {
1189
1194
  process.env[key] = value;
1190
1195
  }
1191
- if (bundle.githubToken) process.env.CONVEYOR_GITHUB_TOKEN = bundle.githubToken;
1196
+ if (bundle.githubToken) {
1197
+ process.env.CONVEYOR_GITHUB_TOKEN = bundle.githubToken;
1198
+ syncGithubTokenFiles(bundle.githubToken);
1199
+ }
1192
1200
  if (bundle.anthropicKey) process.env.ANTHROPIC_API_KEY = bundle.anthropicKey;
1193
1201
  if (bundle.gcpToken) process.env.CLOUDSDK_AUTH_ACCESS_TOKEN = bundle.gcpToken;
1194
1202
  const refreshedTaskToken = Boolean(bundle.sessionJwt) && bundle.sessionJwt !== previousTaskToken;
@@ -1456,23 +1464,43 @@ async function isAuthError(cwd) {
1456
1464
  return errLooksLikeAuth(err);
1457
1465
  }
1458
1466
  }
1467
+ function credentialErrorText(err) {
1468
+ const raw = err instanceof Error ? err.message : String(err);
1469
+ return raw.replace(/\/\/[^@\s]+@/g, "//***@");
1470
+ }
1459
1471
  async function updateRemoteCredential(cwd, credential) {
1472
+ const result = { ok: false, storeWritten: false, helperConfigured: false };
1460
1473
  try {
1461
1474
  const currentUrl = await git(cwd, ["remote", "get-url", "origin"]);
1462
1475
  const cloneUrl = credential.cloneUrl ?? currentUrl;
1463
- writeGitCredential(cwd, cloneUrl, credential);
1464
- if (currentUrl !== cloneUrl) {
1465
- 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]);
1466
1480
  }
1467
1481
  await git(cwd, ["config", "--local", "credential.helper", gitCredentialHelper(cwd)]);
1468
- } catch {
1482
+ result.helperConfigured = true;
1483
+ result.ok = true;
1484
+ } catch (err) {
1485
+ result.error = credentialErrorText(err);
1469
1486
  }
1487
+ return result;
1470
1488
  }
1471
1489
  async function updateRemoteToken(cwd, token) {
1472
1490
  const username = process.env.CONVEYOR_GIT_USERNAME || "x-access-token";
1473
1491
  const cloneUrl = process.env.CONVEYOR_GIT_CLONE_URL || void 0;
1474
- await updateRemoteCredential(cwd, { username, secret: token, cloneUrl });
1492
+ const credential = await updateRemoteCredential(cwd, { username, secret: token, cloneUrl });
1475
1493
  process.env.CONVEYOR_GIT_SECRET = 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
+ }
1476
1504
  }
1477
1505
  function wipRefForBranch(branch) {
1478
1506
  return `conveyor-wip/${branch}`;
@@ -2625,6 +2653,20 @@ var GetProjectTagRequestSchema = z5.object({
2625
2653
  /** Tag id or exact (case-insensitive) tag name. */
2626
2654
  tag: z5.string().min(1).max(100)
2627
2655
  });
2656
+ var ListProjectTagAttachmentsRequestSchema = z5.object({
2657
+ projectId: z5.string(),
2658
+ /** Tag id or exact (case-insensitive) tag name. */
2659
+ tag: z5.string().min(1).max(100),
2660
+ limit: z5.number().int().min(1).max(60).optional(),
2661
+ offset: z5.number().int().min(0).optional()
2662
+ });
2663
+ var SetProjectFileTagsRequestSchema = z5.object({
2664
+ projectId: z5.string(),
2665
+ taskId: z5.string(),
2666
+ fileId: z5.string(),
2667
+ tags: z5.array(z5.string().min(1).max(MAX_FILE_TAG_LENGTH)).max(MAX_FILE_TAGS),
2668
+ requestingUserId: z5.string().optional()
2669
+ });
2628
2670
  var GetProjectSummaryRequestSchema = z5.object({
2629
2671
  projectId: z5.string()
2630
2672
  });
@@ -9936,11 +9978,11 @@ var readTaskChatContract = defineToolContract({
9936
9978
  var listTagsContract = defineToolContract({
9937
9979
  name: "list_tags",
9938
9980
  agent: {
9939
- description: "List the project glossary: every tag's id, name, color, description, parent/child tag ids, its contextPaths (the rule/doc/file/folder links it wires into agent context \u2014 `[]` means none), and whether it carries a full overview (fetch that with get_tag). The context links ship inline, so you only need get_tag for a term's full overview. Use the ids with get_tag / update_tag.",
9981
+ description: "List the project glossary: every tag's id, name, color, description, parent/child tag ids, its contextPaths (the rule/doc/file/folder links it wires into agent context \u2014 `[]` means none), whether it carries a full overview (fetch that with get_tag), and its attachmentCount (files labelled as examples of the term). The context links ship inline, so you only need get_tag for a term's full overview. Use the ids with get_tag / update_tag.",
9940
9982
  fields: {}
9941
9983
  },
9942
9984
  mcp: {
9943
- description: "List all project tags with names, IDs, colors, descriptions, hierarchy (parent/child ids), contextPaths (the rule/doc/file/folder links each tag wires into agent context \u2014 `[]` means none), and a hasOverview flag. Context links ship inline; call get_tag only for a term's full overview. Pass projectId to target a specific project; otherwise the configured default project is used.",
9985
+ description: "List all project tags with names, IDs, colors, descriptions, hierarchy (parent/child ids), contextPaths (the rule/doc/file/folder links each tag wires into agent context \u2014 `[]` means none), a hasOverview flag, and an attachmentCount (files labelled as examples of the term \u2014 read the tiles with list_tag_attachments). Context links ship inline; call get_tag only for a term's full overview. Pass projectId to target a specific project; otherwise the configured default project is used.",
9944
9986
  fields: {
9945
9987
  projectId: mcpProjectId
9946
9988
  }
@@ -10047,13 +10089,13 @@ var tagRef = f.string({
10047
10089
  var getTagContract = defineToolContract({
10048
10090
  name: "get_tag",
10049
10091
  agent: {
10050
- description: "Read one tag's full glossary entry: description, the full markdown overview (the term's spec \u2014 philosophy, mechanics, invariants), linked files/rules (each with its verified-link status \u2014 ok/stale/unchecked \u2014 from the periodic repo check), parent/child tags, active-card count, and recent revisions with their reasons. Call this whenever a chat message, plan, or tag list points at a term you need the full context for. A response with `overviewPath` set means the overview is sourced from that repo file \u2014 prefer Reading the path from your checkout (branch-correct); the served overview is the base-branch materialization (`overviewSource.state`: ok/pending/stale).",
10092
+ description: "Read one tag's full glossary entry: description, the full markdown overview (the term's spec \u2014 philosophy, mechanics, invariants), linked files/rules (each with its verified-link status \u2014 ok/stale/unchecked \u2014 from the periodic repo check), parent/child tags, active-card count, attachment count (files labelled as examples of the term), and recent revisions with their reasons. Call this whenever a chat message, plan, or tag list points at a term you need the full context for. A response with `overviewPath` set means the overview is sourced from that repo file \u2014 prefer Reading the path from your checkout (branch-correct); the served overview is the base-branch materialization (`overviewSource.state`: ok/pending/stale).",
10051
10093
  fields: {
10052
10094
  tag: tagRef
10053
10095
  }
10054
10096
  },
10055
10097
  mcp: {
10056
- description: "Read one tag's full glossary entry \u2014 description, markdown overview, context links (each with its verified-link status: ok/stale/unchecked plus last-checked provenance), parent/child tags, active-card count, and recent revisions with provenance. A response with `overviewPath` set means the overview is sourced from that repo file at the base branch (`overviewSource.state`: ok/pending/stale) \u2014 clients with a checkout can read the path directly for the branch-correct copy. Pass projectId to target a specific project; otherwise the configured default project is used.",
10098
+ description: "Read one tag's full glossary entry \u2014 description, markdown overview, context links (each with its verified-link status: ok/stale/unchecked plus last-checked provenance), parent/child tags, active-card count, attachment count (files labelled as examples of the term \u2014 read the tiles with list_tag_attachments), and recent revisions with provenance. A response with `overviewPath` set means the overview is sourced from that repo file at the base branch (`overviewSource.state`: ok/pending/stale) \u2014 clients with a checkout can read the path directly for the branch-correct copy. Pass projectId to target a specific project; otherwise the configured default project is used.",
10057
10099
  fields: {
10058
10100
  projectId: mcpProjectId,
10059
10101
  tag: tagRef
@@ -11137,10 +11179,75 @@ function buildVoteSuggestionTool(connection) {
11137
11179
  }
11138
11180
  );
11139
11181
  }
11182
+ function buildRefreshGithubTokenTool(connection, config) {
11183
+ return defineTool(
11184
+ "refresh_github_token",
11185
+ "Mint a fresh GitHub token for this pod when git or gh fails with a 401 / 'Bad credentials'. The pod's token expires about every hour. This updates the git credential store and the gh CLI config, and returns the shell command that puts a current token in your environment.",
11186
+ {},
11187
+ async () => {
11188
+ try {
11189
+ const result = await connection.call("refreshGithubToken", {
11190
+ sessionId: connection.sessionId
11191
+ });
11192
+ const written = await updateRemoteToken(config.workspaceDir, result.token);
11193
+ process.env.GITHUB_TOKEN = result.token;
11194
+ process.env.GH_TOKEN = result.token;
11195
+ const tokenFile = githubTokenFilePath();
11196
+ const failures = [];
11197
+ if (!written.credential.storeWritten) {
11198
+ failures.push(
11199
+ `- git credential store NOT written${written.credential.error ? `: ${written.credential.error}` : ""}`
11200
+ );
11201
+ } else if (!written.credential.helperConfigured) {
11202
+ failures.push(
11203
+ `- git credential helper NOT configured${written.credential.error ? `: ${written.credential.error}` : ""}`
11204
+ );
11205
+ }
11206
+ if (!written.files.tokenFile) failures.push(`- token file ${tokenFile} NOT written`);
11207
+ if (!written.files.ghHosts && !ghHostsExternallyOwned()) {
11208
+ failures.push("- gh CLI config NOT written");
11209
+ }
11210
+ const probe = await verifyGitCredential(config.workspaceDir);
11211
+ if (!probe.ok) {
11212
+ failures.push(
11213
+ `- git could not authenticate to origin: ${probe.error ?? "unknown error"}`
11214
+ );
11215
+ }
11216
+ if (failures.length > 0) {
11217
+ return textResult(
11218
+ [
11219
+ probe.ok ? "GitHub token refreshed, but some credential copies did not update." : "GitHub token refresh did NOT produce a working git credential.",
11220
+ ...failures,
11221
+ `A current token is available at ${tokenFile} when that file was written.`,
11222
+ "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."
11223
+ ].join("\n")
11224
+ );
11225
+ }
11226
+ return textResult(
11227
+ [
11228
+ "GitHub token refreshed and verified against origin.",
11229
+ "- git: the credential store and helper are updated, so `git push` works now with no extra step.",
11230
+ "- gh: the CLI config is updated, so `gh` works now with no extra step.",
11231
+ `- shell/scripts: read the current token from ${tokenFile}.`,
11232
+ ` For a command that needs it in the environment: GITHUB_TOKEN=$(cat ${tokenFile}) <command>`,
11233
+ "Retry the failed command."
11234
+ ].join("\n")
11235
+ );
11236
+ } catch (error) {
11237
+ return textResult(
11238
+ `Failed to refresh the GitHub token: ${error instanceof Error ? error.message : "Unknown error"}
11239
+
11240
+ The agent's connection to the API may be down. Wait for it to reconnect and try again.`
11241
+ );
11242
+ }
11243
+ }
11244
+ );
11245
+ }
11140
11246
  function buildMutationTools(connection, config) {
11141
11247
  return [
11142
11248
  buildPostToChatTool(connection),
11143
11249
  buildCreatePullRequestTool(connection, config),
11250
+ buildRefreshGithubTokenTool(connection, config),
11144
11251
  buildAddDependencyTool(connection),
11145
11252
  buildRemoveDependencyTool(connection),
11146
11253
  buildCreateFollowUpTaskTool(connection),
@@ -16091,10 +16198,17 @@ var SessionRunner = class _SessionRunner {
16091
16198
  const res = await this.connection.call("refreshGithubToken", {
16092
16199
  sessionId: this.connection.sessionId
16093
16200
  });
16094
- await updateRemoteToken(this.config.workspaceDir, res.token);
16201
+ const written = await updateRemoteToken(this.config.workspaceDir, res.token);
16095
16202
  process.env.GITHUB_TOKEN = res.token;
16096
16203
  process.env.GH_TOKEN = res.token;
16097
- process.stderr.write("[conveyor-agent] Proactively refreshed GitHub token\n");
16204
+ if (written.credential.ok) {
16205
+ process.stderr.write("[conveyor-agent] Proactively refreshed GitHub token\n");
16206
+ } else {
16207
+ process.stderr.write(
16208
+ `[conveyor-agent] Warning: refreshed GitHub token but the git credential did not update: ${written.credential.error ?? "unknown error"}
16209
+ `
16210
+ );
16211
+ }
16098
16212
  } catch (err) {
16099
16213
  const msg = err instanceof Error ? err.message : String(err);
16100
16214
  process.stderr.write(`[conveyor-agent] Warning: proactive token refresh failed: ${msg}
@@ -16308,4 +16422,4 @@ export {
16308
16422
  loadConveyorConfig,
16309
16423
  unshallowRepo
16310
16424
  };
16311
- //# sourceMappingURL=chunk-PG3Z6RIC.js.map
16425
+ //# sourceMappingURL=chunk-HYP7BK2B.js.map