@rallycry/conveyor-agent 10.2.1 → 10.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.
@@ -188,6 +188,8 @@ var AgentConnection = class _AgentConnection {
188
188
  finalizeSnapshotCallback = null;
189
189
  runStartCommandCallback = null;
190
190
  earlyPullBranches = [];
191
+ spawnReviewCallback = null;
192
+ earlySpawnReviews = [];
191
193
  // PTY relay (S5 terminal). Single-slot callbacks, set per PtySession run.
192
194
  ptyInputCallback = null;
193
195
  ptyResizeCallback = null;
@@ -391,6 +393,10 @@ var AgentConnection = class _AgentConnection {
391
393
  if (this.pullBranchCallback) this.pullBranchCallback(data);
392
394
  else this.earlyPullBranches.push(data);
393
395
  });
396
+ this.socket.on("session:spawnReview", (data) => {
397
+ if (this.spawnReviewCallback) this.spawnReviewCallback(data);
398
+ else this.earlySpawnReviews.push(data);
399
+ });
394
400
  this.socket.on("session:finalizeSnapshot", () => {
395
401
  this.finalizeSnapshotCallback?.();
396
402
  });
@@ -621,6 +627,26 @@ var AgentConnection = class _AgentConnection {
621
627
  for (const data of this.earlyPullBranches) callback(data);
622
628
  this.earlyPullBranches = [];
623
629
  }
630
+ onSpawnReview(callback) {
631
+ this.spawnReviewCallback = callback;
632
+ for (const data of this.earlySpawnReviews) callback(data);
633
+ this.earlySpawnReviews = [];
634
+ }
635
+ /**
636
+ * Report that a same-pod review child failed to spawn (fire-and-forget).
637
+ * The server Ends the orphaned review session and falls back to a dedicated
638
+ * review pod. sessionId is OUR (builder) session — the SEC-9 guard runs on
639
+ * it; the review session is identified separately.
640
+ */
641
+ reportReviewSpawnFailure(reviewSessionId, error) {
642
+ if (!this.socket) return;
643
+ void this.call("reportReviewSpawnFailure", {
644
+ sessionId: this.config.sessionId,
645
+ reviewSessionId,
646
+ ...error ? { error: error.slice(0, 2e3) } : {}
647
+ }).catch(() => {
648
+ });
649
+ }
624
650
  onFinalizeSnapshot(callback) {
625
651
  this.finalizeSnapshotCallback = callback;
626
652
  }
@@ -2612,6 +2638,11 @@ var EmitAgentEventRequestSchema = z.object({
2612
2638
  var RefreshGithubTokenRequestSchema = z.object({
2613
2639
  sessionId: z.string()
2614
2640
  });
2641
+ var ReportReviewSpawnFailureRequestSchema = z.object({
2642
+ sessionId: z.string(),
2643
+ reviewSessionId: z.string(),
2644
+ error: z.string().max(2e3).optional()
2645
+ });
2615
2646
  var RefreshGithubTokenResponseSchema = z.object({
2616
2647
  token: z.string()
2617
2648
  });
@@ -3978,6 +4009,18 @@ var PLAN_DIALOG_INTERVAL_MS = 1500;
3978
4009
  var PLAN_DIALOG_SLOW_INTERVAL_MS = 5e3;
3979
4010
  var PLAN_DIALOG_FAST_WINDOW_MS = 1e4;
3980
4011
  var PLAN_DIALOG_WINDOW_MS = 9e4;
4012
+ function resolveSubmitNudgeTiming() {
4013
+ const envMs = (name, fallback) => {
4014
+ const raw = Number(process.env[name]);
4015
+ return Number.isFinite(raw) && raw > 0 ? raw : fallback;
4016
+ };
4017
+ return {
4018
+ intervalMs: envMs("CONVEYOR_PTY_NUDGE_INTERVAL_MS", SUBMIT_NUDGE_INTERVAL_MS),
4019
+ slowIntervalMs: envMs("CONVEYOR_PTY_NUDGE_SLOW_INTERVAL_MS", SUBMIT_NUDGE_SLOW_INTERVAL_MS),
4020
+ maxPresses: SUBMIT_NUDGE_MAX_PRESSES,
4021
+ windowMs: envMs("CONVEYOR_PTY_NUDGE_WINDOW_MS", SUBMIT_NUDGE_WINDOW_MS)
4022
+ };
4023
+ }
3981
4024
  function turnOptionsFrom(options) {
3982
4025
  return {
3983
4026
  canUseTool: options.canUseTool,
@@ -4477,20 +4520,21 @@ var PtySession = class {
4477
4520
  if (this.submitNudgeTimer) return;
4478
4521
  this.pendingSubmitNudge = true;
4479
4522
  const startedAt = Date.now();
4523
+ const { intervalMs, slowIntervalMs, maxPresses, windowMs } = resolveSubmitNudgeTiming();
4480
4524
  let presses = 0;
4481
4525
  const press = () => {
4482
- if (this._toreDown || !this.pendingSubmitNudge || Date.now() - startedAt >= SUBMIT_NUDGE_WINDOW_MS) {
4526
+ if (this._toreDown || !this.pendingSubmitNudge || Date.now() - startedAt >= windowMs) {
4483
4527
  this.disarmSubmitNudge();
4484
4528
  return;
4485
4529
  }
4486
4530
  presses++;
4487
4531
  this.writeStdin("\r");
4488
- if (presses === SUBMIT_NUDGE_MAX_PRESSES && this.submitNudgeTimer) {
4532
+ if (presses === maxPresses && this.submitNudgeTimer) {
4489
4533
  clearInterval(this.submitNudgeTimer);
4490
- this.submitNudgeTimer = setInterval(press, SUBMIT_NUDGE_SLOW_INTERVAL_MS);
4534
+ this.submitNudgeTimer = setInterval(press, slowIntervalMs);
4491
4535
  }
4492
4536
  };
4493
- this.submitNudgeTimer = setInterval(press, SUBMIT_NUDGE_INTERVAL_MS);
4537
+ this.submitNudgeTimer = setInterval(press, intervalMs);
4494
4538
  }
4495
4539
  disarmSubmitNudge() {
4496
4540
  this.pendingSubmitNudge = false;
@@ -8327,6 +8371,14 @@ function hasExistingSessionFile(taskId, cwd, lineage) {
8327
8371
  const key = sessionLineageKey(taskId, lineage.agentMode, lineage.runnerMode);
8328
8372
  return sessionFileExists(taskIdToSessionUuid(key), cwd);
8329
8373
  }
8374
+ function resolveSessionStart(lineageKey, cwd) {
8375
+ const sessionUuid = taskIdToSessionUuid(lineageKey);
8376
+ if (sessionFileExists(sessionUuid, cwd)) {
8377
+ repairTornSessionFile(sessionTranscriptPath(cwd, sessionUuid));
8378
+ return { resume: sessionUuid };
8379
+ }
8380
+ return { sessionId: sessionUuid };
8381
+ }
8330
8382
  function repairTornSessionFile(path4) {
8331
8383
  try {
8332
8384
  if (!existsSync(path4)) return false;
@@ -8526,13 +8578,11 @@ async function runSdkQuery(host, context, followUpContent, promptDeliveryOverrid
8526
8578
  if (needsPlanSync) {
8527
8579
  host.snapshotPlanFiles();
8528
8580
  }
8529
- const sessionUuid = taskIdToSessionUuid(
8530
- sessionLineageKey(context.taskId, mode, host.config.mode)
8581
+ const sessionStart = resolveSessionStart(
8582
+ sessionLineageKey(context.taskId, mode, host.config.mode),
8583
+ host.config.workspaceDir
8531
8584
  );
8532
- const hasExistingSession = sessionFileExists(sessionUuid, host.config.workspaceDir);
8533
- if (hasExistingSession) {
8534
- repairTornSessionFile(sessionTranscriptPath(host.config.workspaceDir, sessionUuid));
8535
- }
8585
+ const hasExistingSession = !!sessionStart.resume;
8536
8586
  const promptDelivery = promptDeliveryOverride ?? resolvePromptDelivery({
8537
8587
  harnessKind: host.harnessKind,
8538
8588
  runnerMode: host.config.mode,
@@ -8544,9 +8594,9 @@ async function runSdkQuery(host, context, followUpContent, promptDeliveryOverrid
8544
8594
  const options = {
8545
8595
  ...buildQueryOptions(host, context),
8546
8596
  promptDelivery,
8547
- ...hasExistingSession ? {} : { sessionId: sessionUuid }
8597
+ ...sessionStart.sessionId ? { sessionId: sessionStart.sessionId } : {}
8548
8598
  };
8549
- const resume = hasExistingSession ? sessionUuid : void 0;
8599
+ const resume = sessionStart.resume;
8550
8600
  if (followUpContent) {
8551
8601
  await runFollowUpQuery(host, context, options, resume, followUpContent);
8552
8602
  } else if (isDiscoveryLike && promptDelivery !== "prefill") {
@@ -10637,6 +10687,7 @@ export {
10637
10687
  updateRemoteToken,
10638
10688
  flushPendingChanges,
10639
10689
  pushToOrigin,
10690
+ resolveSessionStart,
10640
10691
  PlanSync,
10641
10692
  sampleKeyUsage,
10642
10693
  awaitGitReady,
@@ -10655,4 +10706,4 @@ export {
10655
10706
  runStartCommand,
10656
10707
  unshallowRepo
10657
10708
  };
10658
- //# sourceMappingURL=chunk-YGLTLUGA.js.map
10709
+ //# sourceMappingURL=chunk-53ZLFIAI.js.map