@rallycry/conveyor-agent 7.2.0 → 7.2.1

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,9 @@ var QueryBridge = class {
5500
5502
  get isStopped() {
5501
5503
  return this._stopped;
5502
5504
  }
5505
+ get isDiscoveryCompleted() {
5506
+ return this._discoveryCompleted;
5507
+ }
5503
5508
  get isParentTask() {
5504
5509
  return this._isParentTask;
5505
5510
  }
@@ -5573,6 +5578,12 @@ var QueryBridge = class {
5573
5578
  set pendingModeRestart(val) {
5574
5579
  bridge.mode.pendingModeRestart = val;
5575
5580
  },
5581
+ get discoveryCompleted() {
5582
+ return bridge._discoveryCompleted;
5583
+ },
5584
+ set discoveryCompleted(val) {
5585
+ bridge._discoveryCompleted = val;
5586
+ },
5576
5587
  get wasRateLimited() {
5577
5588
  return bridge._wasRateLimited;
5578
5589
  },
@@ -5660,6 +5671,9 @@ var SessionRunner = class _SessionRunner {
5660
5671
  _state = "connecting";
5661
5672
  stopped = false;
5662
5673
  interrupted = false;
5674
+ /** Defense-in-depth: set when the agent emits a "completed" event.
5675
+ * Prevents the core loop from processing any further messages. */
5676
+ completedThisTurn = false;
5663
5677
  taskContext = null;
5664
5678
  fullContext = null;
5665
5679
  queryBridge = null;
@@ -5792,6 +5806,13 @@ var SessionRunner = class _SessionRunner {
5792
5806
  // ── Core loop ──────────────────────────────────────────────────────
5793
5807
  async coreLoop() {
5794
5808
  while (!this.stopped) {
5809
+ if (this.completedThisTurn) {
5810
+ process.stderr.write(
5811
+ "[conveyor-agent] Completed \u2014 ignoring further messages (agent-side guard)\n"
5812
+ );
5813
+ this.stopped = true;
5814
+ break;
5815
+ }
5795
5816
  if (this._state === "idle") {
5796
5817
  this.lifecycle.startIdleTimer();
5797
5818
  const msg = await this.waitForMessage();
@@ -5811,6 +5832,13 @@ var SessionRunner = class _SessionRunner {
5811
5832
  userId: msg.userId
5812
5833
  });
5813
5834
  await this.executeQuery(msg.content);
5835
+ if (this.queryBridge?.isDiscoveryCompleted) {
5836
+ process.stderr.write(
5837
+ "[conveyor-agent] Discovery completed via ExitPlanMode, shutting down\n"
5838
+ );
5839
+ this.stopped = true;
5840
+ break;
5841
+ }
5814
5842
  if (this.stopped) break;
5815
5843
  if (this.interrupted) {
5816
5844
  this.interrupted = false;
@@ -6037,7 +6065,12 @@ var SessionRunner = class _SessionRunner {
6037
6065
  runnerConfig,
6038
6066
  {
6039
6067
  onStatusChange: (status) => this.callbacks.onStatusChange(status),
6040
- onEvent: (event) => this.callbacks.onEvent(event)
6068
+ onEvent: (event) => {
6069
+ if (event.type === "completed") {
6070
+ this.completedThisTurn = true;
6071
+ }
6072
+ return this.callbacks.onEvent(event);
6073
+ }
6041
6074
  },
6042
6075
  this.config.workspaceDir
6043
6076
  );
@@ -7650,4 +7683,4 @@ export {
7650
7683
  loadForwardPorts,
7651
7684
  loadConveyorConfig
7652
7685
  };
7653
- //# sourceMappingURL=chunk-LEZ6E6OZ.js.map
7686
+ //# sourceMappingURL=chunk-2JONMCGY.js.map