@rallycry/conveyor-agent 7.2.2 → 7.2.4

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.
@@ -628,6 +628,7 @@ var Lifecycle = class {
628
628
  // ── Token refresh ─────────────────────────────────────────────────
629
629
  startTokenRefresh() {
630
630
  this.stopTokenRefresh();
631
+ this.callbacks.onTokenRefresh();
631
632
  this.tokenRefreshTimer = setInterval(() => {
632
633
  this.callbacks.onTokenRefresh();
633
634
  }, this.config.tokenRefreshIntervalMs);
@@ -782,13 +783,18 @@ function stageAndCommit(cwd, message) {
782
783
  }
783
784
  function tryPush(cwd, branch) {
784
785
  try {
785
- execSync(`git push origin ${branch}`, { cwd, stdio: ["ignore", "pipe", "pipe"] });
786
+ execSync(`git push origin ${branch}`, {
787
+ cwd,
788
+ stdio: ["ignore", "pipe", "pipe"],
789
+ timeout: 3e4
790
+ });
786
791
  return true;
787
792
  } catch {
788
793
  try {
789
794
  execSync(`git push --force-with-lease origin ${branch}`, {
790
795
  cwd,
791
- stdio: ["ignore", "pipe", "pipe"]
796
+ stdio: ["ignore", "pipe", "pipe"],
797
+ timeout: 3e4
792
798
  });
793
799
  return true;
794
800
  } catch {
@@ -798,9 +804,10 @@ function tryPush(cwd, branch) {
798
804
  }
799
805
  function isAuthError(cwd) {
800
806
  try {
801
- execSync("git push --dry-run", { cwd, stdio: ["ignore", "pipe", "pipe"] });
807
+ execSync("git push --dry-run", { cwd, stdio: ["ignore", "pipe", "pipe"], timeout: 3e4 });
802
808
  return false;
803
809
  } catch (err) {
810
+ if (err.killed) return true;
804
811
  const stderr = err.stderr?.toString() ?? "";
805
812
  const stdout = err.stdout?.toString() ?? "";
806
813
  const msg = stderr || stdout || (err instanceof Error ? err.message : "");
@@ -847,6 +854,17 @@ async function pushToOrigin(cwd, refreshToken) {
847
854
  try {
848
855
  const currentBranch = getCurrentBranch(cwd);
849
856
  if (!currentBranch) return false;
857
+ if (refreshToken) {
858
+ try {
859
+ const token = await refreshToken();
860
+ if (token) {
861
+ updateRemoteToken(cwd, token);
862
+ process.env.GITHUB_TOKEN = token;
863
+ process.env.GH_TOKEN = token;
864
+ }
865
+ } catch {
866
+ }
867
+ }
850
868
  if (tryPush(cwd, currentBranch)) return true;
851
869
  if (refreshToken && isAuthError(cwd)) {
852
870
  const token = await refreshToken();
@@ -1124,9 +1142,10 @@ function isBinaryPath(filePath) {
1124
1142
  const ext = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
1125
1143
  return BINARY_EXTENSIONS.has(ext);
1126
1144
  }
1127
- function getContextBudgetChars(_model, betas) {
1145
+ function getContextBudgetChars(_model, betas, runnerMode) {
1128
1146
  const contextWindow = betas?.some((b) => b.includes("context-1m")) ? 1e6 : 2e5;
1129
- return contextWindow * 0.25 * 4;
1147
+ const budgetPct = runnerMode === "task" ? 0.15 : 0.25;
1148
+ return contextWindow * budgetPct * 4;
1130
1149
  }
1131
1150
  async function readFileContent(filePath, maxChars) {
1132
1151
  try {
@@ -1219,7 +1238,7 @@ ${formatEntry(entry)}`);
1219
1238
  }
1220
1239
  return parts.join("\n");
1221
1240
  }
1222
- async function resolveTagContext(projectTags, taskTagIds, model, betas) {
1241
+ async function resolveTagContext(projectTags, taskTagIds, model, betas, runnerMode) {
1223
1242
  if (!projectTags?.length || !taskTagIds.length) {
1224
1243
  return { injectedSection: "", stats: { injected: 0, skipped: 0 } };
1225
1244
  }
@@ -1242,7 +1261,7 @@ async function resolveTagContext(projectTags, taskTagIds, model, betas) {
1242
1261
  if (allEntries.length === 0) {
1243
1262
  return { injectedSection: "", stats: { injected: 0, skipped: 0 } };
1244
1263
  }
1245
- const budgetChars = getContextBudgetChars(model, betas);
1264
+ const budgetChars = getContextBudgetChars(model, betas, runnerMode);
1246
1265
  const budget = { remaining: budgetChars };
1247
1266
  let injected = 0;
1248
1267
  let skipped = 0;
@@ -1267,7 +1286,26 @@ async function resolveTagContext(projectTags, taskTagIds, model, betas) {
1267
1286
  }
1268
1287
 
1269
1288
  // src/execution/mode-prompt.ts
1270
- function buildPropertyInstructions(context) {
1289
+ var SP_DESC_MAX_CHARS = 80;
1290
+ function truncateDescription(desc, maxChars) {
1291
+ if (desc.length <= maxChars) return desc;
1292
+ return desc.slice(0, maxChars) + "\u2026";
1293
+ }
1294
+ function formatTagWithContextPaths(tag) {
1295
+ const desc = tag.description ? ` \u2014 ${tag.description}` : "";
1296
+ const lines = [`- ID: "${tag.id}", Name: "${tag.name}"${desc}`];
1297
+ for (const link of tag.contextPaths ?? []) {
1298
+ const label = link.label ? ` (${link.label})` : "";
1299
+ lines.push(` \u2192 ${link.type}: ${link.path}${label}`);
1300
+ }
1301
+ return lines;
1302
+ }
1303
+ function formatTagNameOnly(tag) {
1304
+ const desc = tag.description ? ` \u2014 ${tag.description}` : "";
1305
+ return `- Name: "${tag.name}"${desc}`;
1306
+ }
1307
+ function buildPropertyInstructions(context, runnerMode) {
1308
+ const isTask = runnerMode === "task";
1271
1309
  const parts = [];
1272
1310
  parts.push(
1273
1311
  ``,
@@ -1280,29 +1318,29 @@ function buildPropertyInstructions(context) {
1280
1318
  `Don't wait for the user to ask \u2014 fill these in naturally as the plan takes shape.`,
1281
1319
  `If the user adjusts the plan significantly, update the properties to match.`
1282
1320
  );
1283
- if (context.storyPoints && context.storyPoints.length > 0) {
1321
+ if (!isTask && context.storyPoints && context.storyPoints.length > 0) {
1284
1322
  parts.push(``, `Available story point tiers:`);
1285
1323
  for (const sp of context.storyPoints) {
1286
- const desc = sp.description ? ` \u2014 ${sp.description}` : "";
1324
+ const desc = sp.description ? ` \u2014 ${truncateDescription(sp.description, SP_DESC_MAX_CHARS)}` : "";
1287
1325
  parts.push(`- Value ${sp.value}: "${sp.name}"${desc}`);
1288
1326
  }
1289
1327
  }
1290
1328
  if (context.projectTags && context.projectTags.length > 0) {
1291
- parts.push(``, `Available project tags:`);
1292
- for (const tag of context.projectTags) {
1293
- const desc = tag.description ? ` \u2014 ${tag.description}` : "";
1294
- parts.push(`- ID: "${tag.id}", Name: "${tag.name}"${desc}`);
1295
- if (tag.contextPaths?.length) {
1296
- for (const link of tag.contextPaths) {
1297
- const label = link.label ? ` (${link.label})` : "";
1298
- parts.push(` \u2192 ${link.type}: ${link.path}${label}`);
1299
- }
1300
- }
1329
+ const assignedIds = new Set(context.taskTagIds ?? []);
1330
+ const assigned = context.projectTags.filter((t) => assignedIds.has(t.id));
1331
+ const unassigned = context.projectTags.filter((t) => !assignedIds.has(t.id));
1332
+ if (assigned.length > 0) {
1333
+ parts.push(``, `Assigned tags:`);
1334
+ for (const tag of assigned) parts.push(...formatTagWithContextPaths(tag));
1335
+ }
1336
+ if (!isTask && unassigned.length > 0) {
1337
+ parts.push(``, `Available project tags:`);
1338
+ for (const tag of unassigned) parts.push(formatTagNameOnly(tag));
1301
1339
  }
1302
1340
  }
1303
1341
  return parts;
1304
1342
  }
1305
- function buildDiscoveryPrompt(context) {
1343
+ function buildDiscoveryPrompt(context, runnerMode) {
1306
1344
  const parts = [
1307
1345
  `
1308
1346
  ## Mode: Discovery`,
@@ -1361,10 +1399,10 @@ function buildDiscoveryPrompt(context) {
1361
1399
  `- It does NOT start building \u2014 the team controls when to switch to Build mode`,
1362
1400
  `- Do NOT call ExitPlanMode until you have thoroughly explored the codebase and saved a detailed plan`
1363
1401
  ];
1364
- if (context) parts.push(...buildPropertyInstructions(context));
1402
+ if (context) parts.push(...buildPropertyInstructions(context, runnerMode));
1365
1403
  return parts.join("\n");
1366
1404
  }
1367
- function buildAutoPrompt(context) {
1405
+ function buildAutoPrompt(context, runnerMode) {
1368
1406
  const parts = [
1369
1407
  `
1370
1408
  ## Mode: Auto`,
@@ -1407,13 +1445,13 @@ function buildAutoPrompt(context) {
1407
1445
  `- Only escalate when genuinely blocked (ambiguous requirements, missing access, conflicting instructions)`,
1408
1446
  `- Be thorough in discovery: read relevant files, understand the codebase architecture, then plan`
1409
1447
  ];
1410
- if (context) parts.push(...buildPropertyInstructions(context));
1448
+ if (context) parts.push(...buildPropertyInstructions(context, runnerMode));
1411
1449
  return parts.join("\n");
1412
1450
  }
1413
- function buildModePrompt(agentMode, context) {
1451
+ function buildModePrompt(agentMode, context, runnerMode) {
1414
1452
  switch (agentMode) {
1415
1453
  case "discovery":
1416
- return buildDiscoveryPrompt(context);
1454
+ return buildDiscoveryPrompt(context, runnerMode);
1417
1455
  case "building": {
1418
1456
  const parts = [
1419
1457
  `
@@ -1447,7 +1485,7 @@ function buildModePrompt(agentMode, context) {
1447
1485
  case "review":
1448
1486
  return buildReviewPrompt(context);
1449
1487
  case "auto":
1450
- return buildAutoPrompt(context);
1488
+ return buildAutoPrompt(context, runnerMode);
1451
1489
  default:
1452
1490
  return null;
1453
1491
  }
@@ -1569,14 +1607,6 @@ You are the Project Manager for this set of tasks.`,
1569
1607
  `Use the subtask tools (create_subtask, update_subtask, list_subtasks) to manage work breakdown.`
1570
1608
  );
1571
1609
  }
1572
- if (context.storyPoints && context.storyPoints.length > 0) {
1573
- parts.push(`
1574
- Story Point Tiers:`);
1575
- for (const sp of context.storyPoints) {
1576
- const desc = sp.description ? ` \u2014 ${sp.description}` : "";
1577
- parts.push(`- Value ${sp.value}: "${sp.name}"${desc}`);
1578
- }
1579
- }
1580
1610
  if (context.projectAgents && context.projectAgents.length > 0) {
1581
1611
  parts.push(`
1582
1612
  Project Agents:`);
@@ -1584,14 +1614,6 @@ Project Agents:`);
1584
1614
  parts.push(formatProjectAgentLine(pa));
1585
1615
  }
1586
1616
  }
1587
- if (context.projectObjectives && context.projectObjectives.length > 0) {
1588
- parts.push(`
1589
- Project Objectives:`);
1590
- for (const obj of context.projectObjectives) {
1591
- const dates = `${obj.startDate.split("T")[0]} to ${obj.endDate.split("T")[0]}`;
1592
- parts.push(`- **${obj.name}** (${dates})${obj.description ? ": " + obj.description : ""}`);
1593
- }
1594
- }
1595
1617
  return parts;
1596
1618
  }
1597
1619
  function buildActivePreamble(context, workspaceDir) {
@@ -1718,7 +1740,7 @@ Your responses are sent directly to the task chat \u2014 the team sees everythin
1718
1740
  if (options?.hasDebugTools) {
1719
1741
  parts.push(buildDebugModeSection(options.hypothesisTracker));
1720
1742
  }
1721
- const modePrompt = buildModePrompt(agentMode, context);
1743
+ const modePrompt = buildModePrompt(agentMode, context, mode);
1722
1744
  if (modePrompt) {
1723
1745
  parts.push(modePrompt);
1724
1746
  }
@@ -1726,7 +1748,8 @@ Your responses are sent directly to the task chat \u2014 the team sees everythin
1726
1748
  }
1727
1749
 
1728
1750
  // src/execution/prompt-builder.ts
1729
- var CHAT_HISTORY_LIMIT = 40;
1751
+ var PM_CHAT_HISTORY_LIMIT = 40;
1752
+ var TASK_CHAT_HISTORY_LIMIT = 20;
1730
1753
  function formatFileSize(bytes) {
1731
1754
  if (bytes === void 0) return "";
1732
1755
  if (bytes < 1024) return `${bytes}B`;
@@ -1871,8 +1894,8 @@ function formatTaskFile(file) {
1871
1894
  }
1872
1895
  return [];
1873
1896
  }
1874
- function formatChatHistory(chatHistory) {
1875
- const relevant = chatHistory.slice(-CHAT_HISTORY_LIMIT);
1897
+ function formatChatHistory(chatHistory, limit) {
1898
+ const relevant = chatHistory.slice(-(limit ?? PM_CHAT_HISTORY_LIMIT));
1876
1899
  const parts = [`
1877
1900
  ## Recent Chat Context`];
1878
1901
  for (const msg of relevant) {
@@ -1886,13 +1909,14 @@ function formatChatHistory(chatHistory) {
1886
1909
  }
1887
1910
  return parts;
1888
1911
  }
1889
- async function resolveTaskTagContext(context) {
1912
+ async function resolveTaskTagContext(context, runnerMode) {
1890
1913
  if (!context.projectTags?.length || !context.taskTagIds?.length) return null;
1891
1914
  const { injectedSection } = await resolveTagContext(
1892
1915
  context.projectTags,
1893
1916
  context.taskTagIds,
1894
1917
  context.model,
1895
- context.agentSettings?.betas
1918
+ context.agentSettings?.betas,
1919
+ runnerMode
1896
1920
  );
1897
1921
  return injectedSection || null;
1898
1922
  }
@@ -1948,7 +1972,7 @@ function formatIncidents(incidents) {
1948
1972
  }
1949
1973
  return parts;
1950
1974
  }
1951
- async function buildTaskBody(context) {
1975
+ async function buildTaskBody(context, runnerMode) {
1952
1976
  const parts = [];
1953
1977
  parts.push(`# Task: ${context.title}`);
1954
1978
  if (context.projectName) {
@@ -1977,19 +2001,22 @@ ${context.plan}`);
1977
2001
  if (context.repoRefs && context.repoRefs.length > 0) {
1978
2002
  parts.push(...formatRepoRefs(context.repoRefs));
1979
2003
  }
1980
- const tagSection = await resolveTaskTagContext(context);
2004
+ const tagSection = await resolveTaskTagContext(context, runnerMode);
1981
2005
  if (tagSection) parts.push(tagSection);
1982
- if (context.projectObjectives && context.projectObjectives.length > 0) {
1983
- parts.push(...formatProjectObjectives(context.projectObjectives));
1984
- }
1985
- if (context.recentRelatedTasks && context.recentRelatedTasks.length > 0) {
1986
- parts.push(...formatRecentRelatedTasks(context.recentRelatedTasks));
2006
+ if (runnerMode !== "task") {
2007
+ if (context.projectObjectives && context.projectObjectives.length > 0) {
2008
+ parts.push(...formatProjectObjectives(context.projectObjectives));
2009
+ }
2010
+ if (context.recentRelatedTasks && context.recentRelatedTasks.length > 0) {
2011
+ parts.push(...formatRecentRelatedTasks(context.recentRelatedTasks));
2012
+ }
1987
2013
  }
1988
2014
  if (context.incidents && context.incidents.length > 0) {
1989
2015
  parts.push(...formatIncidents(context.incidents));
1990
2016
  }
1991
2017
  if (context.chatHistory.length > 0) {
1992
- parts.push(...formatChatHistory(context.chatHistory));
2018
+ const chatLimit = runnerMode === "task" ? TASK_CHAT_HISTORY_LIMIT : PM_CHAT_HISTORY_LIMIT;
2019
+ parts.push(...formatChatHistory(context.chatHistory, chatLimit));
1993
2020
  }
1994
2021
  return parts;
1995
2022
  }
@@ -2166,7 +2193,7 @@ async function buildInitialPrompt(mode, context, isAuto, agentMode) {
2166
2193
  if (isPm && agentMode === "building" && isAuto && !context.claudeSessionId && !context.githubPRUrl && scenario === "idle_relaunch") {
2167
2194
  scenario = "fresh";
2168
2195
  }
2169
- const body = await buildTaskBody(context);
2196
+ const body = await buildTaskBody(context, mode);
2170
2197
  const instructions = isPackRunner ? buildPackRunnerInstructions(context, scenario) : buildInstructions(mode, context, scenario, agentMode, isAuto);
2171
2198
  return [...body, ...instructions].join("\n");
2172
2199
  }
@@ -4943,7 +4970,13 @@ async function handleExitPlanMode(host, input) {
4943
4970
  );
4944
4971
  return { behavior: "allow", updatedInput: input };
4945
4972
  }
4946
- await host.connection.triggerIdentification();
4973
+ try {
4974
+ await host.connection.triggerIdentification();
4975
+ } catch (triggerErr) {
4976
+ host.connection.postChatMessage(
4977
+ `Identification trigger encountered an issue (${triggerErr instanceof Error ? triggerErr.message : "unknown error"}). Proceeding to build phase \u2014 identification will use fallbacks.`
4978
+ );
4979
+ }
4947
4980
  host.hasExitedPlanMode = true;
4948
4981
  const newMode = host.isParentTask ? "review" : "building";
4949
4982
  host.connection.sendEvent({ type: "mode_transition", from: "auto", to: newMode });
@@ -5779,6 +5812,10 @@ var SessionRunner = class _SessionRunner {
5779
5812
  }
5780
5813
  this.mode.applyServerMode(this.fullContext?.agentMode, this.fullContext?.isAuto);
5781
5814
  this.mode.resolveInitialMode(this.taskContext);
5815
+ if (this.fullContext?.isAuto && this.taskContext.status === "Open" && this.mode.isBuildCapable) {
5816
+ void this.connection.triggerIdentification().catch(() => {
5817
+ });
5818
+ }
5782
5819
  this.queryBridge = this.createQueryBridge();
5783
5820
  this.logInitialization();
5784
5821
  const staleMessageCount = this.pendingMessages.length;
@@ -5971,7 +6008,7 @@ var SessionRunner = class _SessionRunner {
5971
6008
  softStop() {
5972
6009
  this.interrupted = true;
5973
6010
  this.queryBridge?.stop();
5974
- if (this.inputResolver) {
6011
+ if (this.inputResolver && this.pendingMessages.length === 0) {
5975
6012
  const resolver = this.inputResolver;
5976
6013
  this.inputResolver = null;
5977
6014
  resolver(null);
@@ -6123,9 +6160,10 @@ var SessionRunner = class _SessionRunner {
6123
6160
  if (this.fullContext && action.newMode === "review") {
6124
6161
  this.fullContext.claudeSessionId = null;
6125
6162
  }
6126
- if (this.fullContext && action.newMode === "building") {
6163
+ if (this.fullContext && (action.newMode === "building" || action.newMode === "auto" && this.mode.hasExitedPlanMode)) {
6127
6164
  void this.refreshBranchForBuilding();
6128
6165
  }
6166
+ this.completedThisTurn = false;
6129
6167
  this.connection.emitModeChanged(action.newMode);
6130
6168
  this.softStop();
6131
6169
  }
@@ -7257,7 +7295,7 @@ var ProjectRunner = class {
7257
7295
  async handleAuditTasks(request) {
7258
7296
  this.connection.emitStatus("busy");
7259
7297
  try {
7260
- const { handleTaskAudit } = await import("./task-audit-handler-UL4HXCE4.js");
7298
+ const { handleTaskAudit } = await import("./task-audit-handler-LH35J3TX.js");
7261
7299
  await handleTaskAudit(request, this.connection, this.projectDir);
7262
7300
  } catch (error) {
7263
7301
  const msg = error instanceof Error ? error.message : String(error);
@@ -7702,4 +7740,4 @@ export {
7702
7740
  loadForwardPorts,
7703
7741
  loadConveyorConfig
7704
7742
  };
7705
- //# sourceMappingURL=chunk-5HTCDNOK.js.map
7743
+ //# sourceMappingURL=chunk-AS3FYEBJ.js.map