@rallycry/conveyor-agent 7.1.7 → 7.1.8

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.
@@ -929,6 +929,9 @@ var PlanSync = class {
929
929
 
930
930
  // src/execution/query-executor.ts
931
931
  import { createHash } from "crypto";
932
+ import { existsSync } from "fs";
933
+ import { homedir } from "os";
934
+ import { join as join2 } from "path";
932
935
 
933
936
  // src/execution/pack-runner-prompt.ts
934
937
  function findLastAgentMessageIndex(history) {
@@ -5029,6 +5032,15 @@ function taskIdToSessionUuid(taskId) {
5029
5032
  const hash = createHash("sha256").update(taskId).digest("hex");
5030
5033
  return `${hash.slice(0, 8)}-${hash.slice(8, 12)}-8${hash.slice(13, 16)}-a${hash.slice(17, 20)}-${hash.slice(20, 32)}`;
5031
5034
  }
5035
+ function sessionFileExists(sessionUuid, cwd) {
5036
+ try {
5037
+ const cwdSlug = cwd.replace(/\//g, "-");
5038
+ const sessionFile = join2(homedir(), ".claude", "projects", cwdSlug, `${sessionUuid}.jsonl`);
5039
+ return existsSync(sessionFile);
5040
+ } catch {
5041
+ return false;
5042
+ }
5043
+ }
5032
5044
  function isReadOnlyMode(mode, hasExitedPlanMode) {
5033
5045
  return mode === "discovery" || mode === "help" || mode === "auto" && !hasExitedPlanMode;
5034
5046
  }
@@ -5077,7 +5089,6 @@ function buildQueryOptions(host, context) {
5077
5089
  abortController: host.abortController ?? void 0,
5078
5090
  disallowedTools: buildDisallowedTools(settings, mode, host.hasExitedPlanMode),
5079
5091
  enableFileCheckpointing: settings.enableFileCheckpointing,
5080
- sessionId: taskIdToSessionUuid(context.taskId),
5081
5092
  stderr: (data) => {
5082
5093
  logger2.warn("Claude Code stderr", { data: data.trimEnd() });
5083
5094
  }
@@ -5150,8 +5161,13 @@ async function runSdkQuery(host, context, followUpContent) {
5150
5161
  if (needsPlanSync) {
5151
5162
  host.snapshotPlanFiles();
5152
5163
  }
5153
- const options = buildQueryOptions(host, context);
5154
- const resume = taskIdToSessionUuid(context.taskId);
5164
+ const sessionUuid = taskIdToSessionUuid(context.taskId);
5165
+ const hasExistingSession = sessionFileExists(sessionUuid, host.config.workspaceDir);
5166
+ const options = {
5167
+ ...buildQueryOptions(host, context),
5168
+ ...hasExistingSession ? {} : { sessionId: sessionUuid }
5169
+ };
5170
+ const resume = hasExistingSession ? sessionUuid : void 0;
5155
5171
  if (followUpContent) {
5156
5172
  const prompt = await buildFollowUpPrompt(host, context, followUpContent);
5157
5173
  const agentQuery = host.harness.executeQuery({
@@ -5204,7 +5220,10 @@ async function buildRetryQuery(host, context, options, lastErrorWasImage) {
5204
5220
  );
5205
5221
  return host.harness.executeQuery({
5206
5222
  prompt: host.createInputStream(retryPrompt),
5207
- options: { ...options },
5223
+ // Strip sessionId on retry — if the failing query partially created a
5224
+ // session with that ID, passing it again would error. Let the SDK
5225
+ // auto-generate on retry attempts.
5226
+ options: { ...options, sessionId: void 0 },
5208
5227
  resume: void 0
5209
5228
  });
5210
5229
  }
@@ -5227,7 +5246,7 @@ async function handleAuthError(context, host, options) {
5227
5246
  );
5228
5247
  const freshQuery = host.harness.executeQuery({
5229
5248
  prompt: host.createInputStream(freshPrompt),
5230
- options: { ...options },
5249
+ options: { ...options, sessionId: void 0 },
5231
5250
  resume: void 0
5232
5251
  });
5233
5252
  return runWithRetry(freshQuery, context, host, options);
@@ -5241,7 +5260,7 @@ async function handleStaleSession(context, host, options) {
5241
5260
  );
5242
5261
  const freshQuery = host.harness.executeQuery({
5243
5262
  prompt: host.createInputStream(freshPrompt),
5244
- options: { ...options },
5263
+ options: { ...options, sessionId: void 0 },
5245
5264
  resume: void 0
5246
5265
  });
5247
5266
  return runWithRetry(freshQuery, context, host, options);
@@ -5534,7 +5553,7 @@ var QueryBridge = class {
5534
5553
 
5535
5554
  // src/runner/session-runner-helpers.ts
5536
5555
  import { readFileSync as readFileSync2 } from "fs";
5537
- import { dirname, join as join2 } from "path";
5556
+ import { dirname, join as join3 } from "path";
5538
5557
  import { fileURLToPath } from "url";
5539
5558
  function mapChatHistory(messages) {
5540
5559
  if (!messages) return [];
@@ -5562,7 +5581,7 @@ function readAgentVersion() {
5562
5581
  const here = dirname(fileURLToPath(import.meta.url));
5563
5582
  for (const rel of ["../package.json", "../../package.json"]) {
5564
5583
  try {
5565
- const pkg = JSON.parse(readFileSync2(join2(here, rel), "utf-8"));
5584
+ const pkg = JSON.parse(readFileSync2(join3(here, rel), "utf-8"));
5566
5585
  if (pkg.version) return pkg.version;
5567
5586
  } catch {
5568
5587
  }
@@ -5672,11 +5691,13 @@ var SessionRunner = class _SessionRunner {
5672
5691
  await this.shutdown("error");
5673
5692
  return;
5674
5693
  }
5675
- if (this.fullContext?.githubBranch) {
5676
- ensureOnTaskBranch(this.config.workspaceDir, this.fullContext.githubBranch);
5677
- }
5678
- if (this.fullContext?.baseBranch) {
5679
- syncWithBaseBranch(this.config.workspaceDir, this.fullContext.baseBranch);
5694
+ if (process.env.CONVEYOR_GIT_READY !== "1") {
5695
+ if (this.fullContext?.githubBranch) {
5696
+ ensureOnTaskBranch(this.config.workspaceDir, this.fullContext.githubBranch);
5697
+ }
5698
+ if (this.fullContext?.baseBranch) {
5699
+ syncWithBaseBranch(this.config.workspaceDir, this.fullContext.baseBranch);
5700
+ }
5680
5701
  }
5681
5702
  this.mode.applyServerMode(this.fullContext?.agentMode, this.fullContext?.isAuto);
5682
5703
  this.mode.resolveInitialMode(this.taskContext);
@@ -6402,15 +6423,15 @@ var CommitWatcher = class {
6402
6423
 
6403
6424
  // src/runner/worktree.ts
6404
6425
  import { execSync as execSync4 } from "child_process";
6405
- import { existsSync } from "fs";
6406
- import { join as join3 } from "path";
6426
+ import { existsSync as existsSync2 } from "fs";
6427
+ import { join as join4 } from "path";
6407
6428
  var WORKTREE_DIR = ".worktrees";
6408
6429
  function ensureWorktree(projectDir, taskId, branch) {
6409
6430
  if (projectDir.includes(`/${WORKTREE_DIR}/`)) {
6410
6431
  return projectDir;
6411
6432
  }
6412
- const worktreePath = join3(projectDir, WORKTREE_DIR, taskId);
6413
- if (existsSync(worktreePath)) {
6433
+ const worktreePath = join4(projectDir, WORKTREE_DIR, taskId);
6434
+ if (existsSync2(worktreePath)) {
6414
6435
  if (branch) {
6415
6436
  if (hasUncommittedChanges(worktreePath)) {
6416
6437
  return worktreePath;
@@ -6455,8 +6476,8 @@ function detachWorktreeBranch(projectDir, branch) {
6455
6476
  }
6456
6477
  }
6457
6478
  function removeWorktree(projectDir, taskId) {
6458
- const worktreePath = join3(projectDir, WORKTREE_DIR, taskId);
6459
- if (!existsSync(worktreePath)) return;
6479
+ const worktreePath = join4(projectDir, WORKTREE_DIR, taskId);
6480
+ if (!existsSync2(worktreePath)) return;
6460
6481
  try {
6461
6482
  execSync4(`git worktree remove "${worktreePath}" --force`, {
6462
6483
  cwd: projectDir,
@@ -7494,11 +7515,11 @@ var ProjectRunner = class {
7494
7515
 
7495
7516
  // src/setup/config.ts
7496
7517
  import { readFile as readFile2 } from "fs/promises";
7497
- import { join as join4 } from "path";
7518
+ import { join as join5 } from "path";
7498
7519
  var DEVCONTAINER_PATH = ".devcontainer/conveyor/devcontainer.json";
7499
7520
  async function loadForwardPorts(workspaceDir) {
7500
7521
  try {
7501
- const raw = await readFile2(join4(workspaceDir, DEVCONTAINER_PATH), "utf-8");
7522
+ const raw = await readFile2(join5(workspaceDir, DEVCONTAINER_PATH), "utf-8");
7502
7523
  const parsed = JSON.parse(raw);
7503
7524
  return parsed.forwardPorts ?? [];
7504
7525
  } catch {
@@ -7546,4 +7567,4 @@ export {
7546
7567
  loadForwardPorts,
7547
7568
  loadConveyorConfig
7548
7569
  };
7549
- //# sourceMappingURL=chunk-N3365TFE.js.map
7570
+ //# sourceMappingURL=chunk-WUBCS4RB.js.map