@rallycry/conveyor-agent 7.2.0 → 7.2.2

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.
@@ -4935,7 +4935,8 @@ async function handleExitPlanMode(host, input) {
4935
4935
  }
4936
4936
  if (host.agentMode === "discovery") {
4937
4937
  host.hasExitedPlanMode = true;
4938
- host.pendingModeRestart = true;
4938
+ host.discoveryCompleted = true;
4939
+ host.requestStop();
4939
4940
  void host.connection.triggerIdentification();
4940
4941
  host.connection.postChatMessage(
4941
4942
  "Plan complete. Running identification \u2014 icon and agent assignment will be set automatically."
@@ -5490,6 +5491,7 @@ var QueryBridge = class {
5490
5491
  activeQuery = null;
5491
5492
  pendingToolOutputs = [];
5492
5493
  _stopped = false;
5494
+ _discoveryCompleted = false;
5493
5495
  _isParentTask = false;
5494
5496
  _wasRateLimited = false;
5495
5497
  _abortController = null;
@@ -5500,6 +5502,12 @@ var QueryBridge = class {
5500
5502
  get isStopped() {
5501
5503
  return this._stopped;
5502
5504
  }
5505
+ get isDiscoveryCompleted() {
5506
+ return this._discoveryCompleted;
5507
+ }
5508
+ set isDiscoveryCompleted(val) {
5509
+ this._discoveryCompleted = val;
5510
+ }
5503
5511
  get isParentTask() {
5504
5512
  return this._isParentTask;
5505
5513
  }
@@ -5573,6 +5581,12 @@ var QueryBridge = class {
5573
5581
  set pendingModeRestart(val) {
5574
5582
  bridge.mode.pendingModeRestart = val;
5575
5583
  },
5584
+ get discoveryCompleted() {
5585
+ return bridge._discoveryCompleted;
5586
+ },
5587
+ set discoveryCompleted(val) {
5588
+ bridge._discoveryCompleted = val;
5589
+ },
5576
5590
  get wasRateLimited() {
5577
5591
  return bridge._wasRateLimited;
5578
5592
  },
@@ -5660,6 +5674,9 @@ var SessionRunner = class _SessionRunner {
5660
5674
  _state = "connecting";
5661
5675
  stopped = false;
5662
5676
  interrupted = false;
5677
+ /** Defense-in-depth: set when the agent emits a "completed" event.
5678
+ * Prevents the core loop from processing any further messages. */
5679
+ completedThisTurn = false;
5663
5680
  taskContext = null;
5664
5681
  fullContext = null;
5665
5682
  queryBridge = null;
@@ -5790,8 +5807,22 @@ var SessionRunner = class _SessionRunner {
5790
5807
  await this.run();
5791
5808
  }
5792
5809
  // ── Core loop ──────────────────────────────────────────────────────
5810
+ // oxlint-disable-next-line complexity -- dormant idle paths add branches but are tightly coupled to the loop
5793
5811
  async coreLoop() {
5794
5812
  while (!this.stopped) {
5813
+ if (this.completedThisTurn) {
5814
+ process.stderr.write(
5815
+ "[conveyor-agent] Completed \u2014 entering dormant idle (staying connected)\n"
5816
+ );
5817
+ this.pendingMessages.length = 0;
5818
+ if (this._state !== "idle") await this.setState("idle");
5819
+ const dormantMsg = await this.waitForMessage();
5820
+ if (!dormantMsg) break;
5821
+ process.stderr.write("[conveyor-agent] Received message while dormant, resuming\n");
5822
+ this.completedThisTurn = false;
5823
+ this.pendingMessages.unshift(dormantMsg);
5824
+ continue;
5825
+ }
5795
5826
  if (this._state === "idle") {
5796
5827
  this.lifecycle.startIdleTimer();
5797
5828
  const msg = await this.waitForMessage();
@@ -5811,6 +5842,22 @@ var SessionRunner = class _SessionRunner {
5811
5842
  userId: msg.userId
5812
5843
  });
5813
5844
  await this.executeQuery(msg.content);
5845
+ if (this.queryBridge?.isDiscoveryCompleted) {
5846
+ process.stderr.write(
5847
+ "[conveyor-agent] Discovery completed \u2014 entering dormant idle (staying connected)\n"
5848
+ );
5849
+ this.pendingMessages.length = 0;
5850
+ if (this._state !== "idle") await this.setState("idle");
5851
+ const discoveryMsg = await this.waitForMessage();
5852
+ if (!discoveryMsg) break;
5853
+ process.stderr.write(
5854
+ "[conveyor-agent] Received message while discovery-dormant, resuming\n"
5855
+ );
5856
+ this.queryBridge.isDiscoveryCompleted = false;
5857
+ this.completedThisTurn = false;
5858
+ this.pendingMessages.unshift(discoveryMsg);
5859
+ continue;
5860
+ }
5814
5861
  if (this.stopped) break;
5815
5862
  if (this.interrupted) {
5816
5863
  this.interrupted = false;
@@ -6037,7 +6084,12 @@ var SessionRunner = class _SessionRunner {
6037
6084
  runnerConfig,
6038
6085
  {
6039
6086
  onStatusChange: (status) => this.callbacks.onStatusChange(status),
6040
- onEvent: (event) => this.callbacks.onEvent(event)
6087
+ onEvent: (event) => {
6088
+ if (event.type === "completed") {
6089
+ this.completedThisTurn = true;
6090
+ }
6091
+ return this.callbacks.onEvent(event);
6092
+ }
6041
6093
  },
6042
6094
  this.config.workspaceDir
6043
6095
  );
@@ -7650,4 +7702,4 @@ export {
7650
7702
  loadForwardPorts,
7651
7703
  loadConveyorConfig
7652
7704
  };
7653
- //# sourceMappingURL=chunk-LEZ6E6OZ.js.map
7705
+ //# sourceMappingURL=chunk-5HTCDNOK.js.map