@rallycry/conveyor-agent 7.2.1 → 7.2.3

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();
@@ -4943,7 +4961,13 @@ async function handleExitPlanMode(host, input) {
4943
4961
  );
4944
4962
  return { behavior: "allow", updatedInput: input };
4945
4963
  }
4946
- await host.connection.triggerIdentification();
4964
+ try {
4965
+ await host.connection.triggerIdentification();
4966
+ } catch (triggerErr) {
4967
+ host.connection.postChatMessage(
4968
+ `Identification trigger encountered an issue (${triggerErr instanceof Error ? triggerErr.message : "unknown error"}). Proceeding to build phase \u2014 identification will use fallbacks.`
4969
+ );
4970
+ }
4947
4971
  host.hasExitedPlanMode = true;
4948
4972
  const newMode = host.isParentTask ? "review" : "building";
4949
4973
  host.connection.sendEvent({ type: "mode_transition", from: "auto", to: newMode });
@@ -5505,6 +5529,9 @@ var QueryBridge = class {
5505
5529
  get isDiscoveryCompleted() {
5506
5530
  return this._discoveryCompleted;
5507
5531
  }
5532
+ set isDiscoveryCompleted(val) {
5533
+ this._discoveryCompleted = val;
5534
+ }
5508
5535
  get isParentTask() {
5509
5536
  return this._isParentTask;
5510
5537
  }
@@ -5804,14 +5831,21 @@ var SessionRunner = class _SessionRunner {
5804
5831
  await this.run();
5805
5832
  }
5806
5833
  // ── Core loop ──────────────────────────────────────────────────────
5834
+ // oxlint-disable-next-line complexity -- dormant idle paths add branches but are tightly coupled to the loop
5807
5835
  async coreLoop() {
5808
5836
  while (!this.stopped) {
5809
5837
  if (this.completedThisTurn) {
5810
5838
  process.stderr.write(
5811
- "[conveyor-agent] Completed \u2014 ignoring further messages (agent-side guard)\n"
5839
+ "[conveyor-agent] Completed \u2014 entering dormant idle (staying connected)\n"
5812
5840
  );
5813
- this.stopped = true;
5814
- break;
5841
+ this.pendingMessages.length = 0;
5842
+ if (this._state !== "idle") await this.setState("idle");
5843
+ const dormantMsg = await this.waitForMessage();
5844
+ if (!dormantMsg) break;
5845
+ process.stderr.write("[conveyor-agent] Received message while dormant, resuming\n");
5846
+ this.completedThisTurn = false;
5847
+ this.pendingMessages.unshift(dormantMsg);
5848
+ continue;
5815
5849
  }
5816
5850
  if (this._state === "idle") {
5817
5851
  this.lifecycle.startIdleTimer();
@@ -5834,10 +5868,19 @@ var SessionRunner = class _SessionRunner {
5834
5868
  await this.executeQuery(msg.content);
5835
5869
  if (this.queryBridge?.isDiscoveryCompleted) {
5836
5870
  process.stderr.write(
5837
- "[conveyor-agent] Discovery completed via ExitPlanMode, shutting down\n"
5871
+ "[conveyor-agent] Discovery completed \u2014 entering dormant idle (staying connected)\n"
5838
5872
  );
5839
- this.stopped = true;
5840
- break;
5873
+ this.pendingMessages.length = 0;
5874
+ if (this._state !== "idle") await this.setState("idle");
5875
+ const discoveryMsg = await this.waitForMessage();
5876
+ if (!discoveryMsg) break;
5877
+ process.stderr.write(
5878
+ "[conveyor-agent] Received message while discovery-dormant, resuming\n"
5879
+ );
5880
+ this.queryBridge.isDiscoveryCompleted = false;
5881
+ this.completedThisTurn = false;
5882
+ this.pendingMessages.unshift(discoveryMsg);
5883
+ continue;
5841
5884
  }
5842
5885
  if (this.stopped) break;
5843
5886
  if (this.interrupted) {
@@ -7683,4 +7726,4 @@ export {
7683
7726
  loadForwardPorts,
7684
7727
  loadConveyorConfig
7685
7728
  };
7686
- //# sourceMappingURL=chunk-2JONMCGY.js.map
7729
+ //# sourceMappingURL=chunk-N66QQFXY.js.map