@rallycry/conveyor-agent 7.0.9 → 7.0.10

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.
@@ -678,6 +678,28 @@ function syncWithBaseBranch(cwd, baseBranch) {
678
678
  `);
679
679
  return true;
680
680
  }
681
+ function ensureOnTaskBranch(cwd, taskBranch) {
682
+ if (!taskBranch) return true;
683
+ const current = getCurrentBranch(cwd);
684
+ if (current === taskBranch) return true;
685
+ try {
686
+ execSync(`git fetch origin ${taskBranch}`, { cwd, stdio: "ignore", timeout: 6e4 });
687
+ } catch {
688
+ process.stderr.write(`[conveyor-agent] Warning: git fetch origin ${taskBranch} failed
689
+ `);
690
+ return false;
691
+ }
692
+ try {
693
+ execSync(`git checkout ${taskBranch}`, { cwd, stdio: "ignore", timeout: 3e4 });
694
+ } catch {
695
+ process.stderr.write(`[conveyor-agent] Warning: git checkout ${taskBranch} failed
696
+ `);
697
+ return false;
698
+ }
699
+ process.stderr.write(`[conveyor-agent] Checked out task branch ${taskBranch}
700
+ `);
701
+ return true;
702
+ }
681
703
  function hasUncommittedChanges(cwd) {
682
704
  const status = execSync("git status --porcelain", {
683
705
  cwd,
@@ -5769,6 +5791,7 @@ async function emitRetryStatus(host, attempt, delayMs) {
5769
5791
  await host.callbacks.onStatusChange("running");
5770
5792
  }
5771
5793
  function handleRateLimitPause(host, rateLimitResetsAt) {
5794
+ host.wasRateLimited = true;
5772
5795
  host.connection.emitRateLimitPause(rateLimitResetsAt);
5773
5796
  host.connection.postChatMessage(
5774
5797
  `Rate limited. The task will be automatically re-queued and resume after ${new Date(rateLimitResetsAt).toLocaleString()}.`
@@ -5889,6 +5912,7 @@ var QueryBridge = class {
5889
5912
  pendingToolOutputs = [];
5890
5913
  _stopped = false;
5891
5914
  _isParentTask = false;
5915
+ _wasRateLimited = false;
5892
5916
  _abortController = null;
5893
5917
  /** Called by SessionRunner when ExitPlanMode triggers a mode transition. */
5894
5918
  onModeTransition;
@@ -5903,6 +5927,9 @@ var QueryBridge = class {
5903
5927
  set isParentTask(val) {
5904
5928
  this._isParentTask = val;
5905
5929
  }
5930
+ get wasRateLimited() {
5931
+ return this._wasRateLimited;
5932
+ }
5906
5933
  stop() {
5907
5934
  this._stopped = true;
5908
5935
  this._abortController?.abort();
@@ -5917,6 +5944,7 @@ var QueryBridge = class {
5917
5944
  */
5918
5945
  async execute(context, followUpContent) {
5919
5946
  this._stopped = false;
5947
+ this._wasRateLimited = false;
5920
5948
  this._abortController = new AbortController();
5921
5949
  const host = this.buildHost();
5922
5950
  try {
@@ -5966,6 +5994,12 @@ var QueryBridge = class {
5966
5994
  set pendingModeRestart(val) {
5967
5995
  bridge.mode.pendingModeRestart = val;
5968
5996
  },
5997
+ get wasRateLimited() {
5998
+ return bridge._wasRateLimited;
5999
+ },
6000
+ set wasRateLimited(val) {
6001
+ bridge._wasRateLimited = val;
6002
+ },
5969
6003
  get activeQuery() {
5970
6004
  return bridge.activeQuery;
5971
6005
  },
@@ -6104,13 +6138,20 @@ var SessionRunner = class _SessionRunner {
6104
6138
  await this.shutdown("error");
6105
6139
  return;
6106
6140
  }
6141
+ if (this.fullContext?.githubBranch) {
6142
+ ensureOnTaskBranch(this.config.workspaceDir, this.fullContext.githubBranch);
6143
+ }
6107
6144
  if (this.fullContext?.baseBranch) {
6108
6145
  syncWithBaseBranch(this.config.workspaceDir, this.fullContext.baseBranch);
6109
6146
  }
6110
6147
  this.mode.resolveInitialMode(this.taskContext);
6111
6148
  this.queryBridge = this.createQueryBridge();
6112
6149
  this.logInitialization();
6150
+ const staleMessageCount = this.pendingMessages.length;
6113
6151
  await this.executeInitialMode();
6152
+ if (staleMessageCount > 0) {
6153
+ this.pendingMessages.splice(0, staleMessageCount);
6154
+ }
6114
6155
  if (!this.stopped && this._state !== "error") {
6115
6156
  this.hasCompleted = true;
6116
6157
  }
@@ -6135,14 +6176,31 @@ var SessionRunner = class _SessionRunner {
6135
6176
  await this.run();
6136
6177
  }
6137
6178
  // ── Message filtering ──────────────────────────────────────────────
6138
- /** Returns true if the message should be skipped (not processed). */
6179
+ /**
6180
+ * Returns true if the message should be skipped (not processed).
6181
+ *
6182
+ * After the agent has completed, we only process:
6183
+ * 1. Critical automated sources (e.g. CI failure) — always process
6184
+ * 2. Messages with source: "user" — real user typed in chat
6185
+ * 3. Messages from flushAllCombined — have a real userId but no source
6186
+ *
6187
+ * Everything else (system messages, stale history replays) is skipped.
6188
+ */
6139
6189
  shouldSkipMessage(msg) {
6140
- if (!this.hasCompleted || msg.userId !== "system") return false;
6190
+ if (!this.hasCompleted) return false;
6141
6191
  const isCritical = !!msg.source && CRITICAL_AUTOMATED_SOURCES.has(msg.source);
6142
6192
  if (isCritical) {
6143
6193
  this.hasCompleted = false;
6144
6194
  return false;
6145
6195
  }
6196
+ if (msg.source === "user") {
6197
+ this.hasCompleted = false;
6198
+ return false;
6199
+ }
6200
+ if (!msg.source && msg.userId !== "system") {
6201
+ this.hasCompleted = false;
6202
+ return false;
6203
+ }
6146
6204
  return true;
6147
6205
  }
6148
6206
  // ── Core loop ──────────────────────────────────────────────────────
@@ -6160,9 +6218,6 @@ var SessionRunner = class _SessionRunner {
6160
6218
  break;
6161
6219
  }
6162
6220
  if (this.shouldSkipMessage(msg)) continue;
6163
- if (msg.userId !== "system") {
6164
- this.hasCompleted = false;
6165
- }
6166
6221
  await this.setState("running");
6167
6222
  this.interrupted = false;
6168
6223
  await this.callbacks.onEvent({
@@ -6271,6 +6326,7 @@ var SessionRunner = class _SessionRunner {
6271
6326
  static MAX_PR_NUDGES = 3;
6272
6327
  needsPRNudge() {
6273
6328
  if (!this.config.isAuto || this.stopped) return false;
6329
+ if (this.queryBridge?.wasRateLimited) return false;
6274
6330
  if (this.prNudgeCount > _SessionRunner.MAX_PR_NUDGES) return false;
6275
6331
  if (!this.taskContext) return false;
6276
6332
  return this.taskContext.status === "InProgress" && !this.taskContext.githubPRUrl;
@@ -7450,7 +7506,7 @@ var ProjectRunner = class {
7450
7506
  async handleAuditTags(request) {
7451
7507
  this.connection.emitStatus("busy");
7452
7508
  try {
7453
- const { handleTagAudit } = await import("./tag-audit-handler-4RRGIHVB.js");
7509
+ const { handleTagAudit } = await import("./tag-audit-handler-L7YPDXTA.js");
7454
7510
  await handleTagAudit(request, this.connection, this.projectDir);
7455
7511
  } catch (error) {
7456
7512
  const msg = error instanceof Error ? error.message : String(error);
@@ -7871,4 +7927,4 @@ export {
7871
7927
  loadForwardPorts,
7872
7928
  loadConveyorConfig
7873
7929
  };
7874
- //# sourceMappingURL=chunk-LKO3CBJU.js.map
7930
+ //# sourceMappingURL=chunk-BOFWZIL6.js.map