@rallycry/conveyor-agent 11.0.25 → 11.0.26

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.
@@ -5312,7 +5312,16 @@ function wrapBridgeWithDirectStream(inner, reporter, options = {}) {
5312
5312
 
5313
5313
  // src/execution/query-executor.ts
5314
5314
  import { createHash as createHash4, randomUUID as randomUUID2 } from "crypto";
5315
- import { existsSync, readFileSync as readFileSync3, renameSync as renameSync2, truncateSync } from "fs";
5315
+ import {
5316
+ closeSync,
5317
+ existsSync,
5318
+ openSync,
5319
+ readFileSync as readFileSync3,
5320
+ readSync,
5321
+ renameSync as renameSync2,
5322
+ statSync as statSync2,
5323
+ truncateSync
5324
+ } from "fs";
5316
5325
 
5317
5326
  // src/execution/chat-instructions.ts
5318
5327
  function buildChatInstructions(context, scenario, newMessages) {
@@ -12325,7 +12334,15 @@ function hasExistingSessionFile(taskId, cwd, lineage) {
12325
12334
  if (process.env.CONVEYOR_TUI === "codex") {
12326
12335
  return !!readCodexLineage(taskIdToSessionUuid(key), cwd);
12327
12336
  }
12328
- return sessionFileExists(taskIdToSessionUuid(key), cwd);
12337
+ const uuid = taskIdToSessionUuid(key);
12338
+ return sessionFileExists(uuid, cwd) && isResumableTranscript(sessionTranscriptPath(cwd, uuid));
12339
+ }
12340
+ var spawnedTranscripts = /* @__PURE__ */ new Set();
12341
+ function markSpawnedTranscript(cwd, sessionUuid) {
12342
+ spawnedTranscripts.add(sessionTranscriptPath(cwd, sessionUuid));
12343
+ }
12344
+ function isResumableTranscript(path) {
12345
+ return spawnedTranscripts.has(path) || transcriptHasConversation(path);
12329
12346
  }
12330
12347
  function resolveSessionStart(lineageKey, cwd, tui = process.env.CONVEYOR_TUI) {
12331
12348
  const sessionUuid = taskIdToSessionUuid(lineageKey);
@@ -12334,11 +12351,46 @@ function resolveSessionStart(lineageKey, cwd, tui = process.env.CONVEYOR_TUI) {
12334
12351
  return { sessionId: sessionUuid, ...resume ? { resume } : {} };
12335
12352
  }
12336
12353
  if (sessionFileExists(sessionUuid, cwd)) {
12337
- repairTornSessionFile(sessionTranscriptPath(cwd, sessionUuid));
12338
- return { resume: sessionUuid };
12354
+ const path = sessionTranscriptPath(cwd, sessionUuid);
12355
+ repairTornSessionFile(path);
12356
+ if (isResumableTranscript(path)) return { resume: sessionUuid };
12357
+ rotateSessionFile(cwd, sessionUuid);
12358
+ logger5.warn("Rotated a transcript with no conversation aside before resume", { path });
12339
12359
  }
12360
+ markSpawnedTranscript(cwd, sessionUuid);
12340
12361
  return { sessionId: sessionUuid };
12341
12362
  }
12363
+ var CONVERSATION_PROBE_BYTES = 256 * 1024;
12364
+ function transcriptHasConversation(path) {
12365
+ let fd;
12366
+ try {
12367
+ const size = statSync2(path).size;
12368
+ const length = Math.min(size, CONVERSATION_PROBE_BYTES);
12369
+ const buffer = Buffer.alloc(length);
12370
+ fd = openSync(path, "r");
12371
+ const read = readSync(fd, buffer, 0, length, 0);
12372
+ const text = buffer.subarray(0, read).toString("utf8");
12373
+ const complete = text.slice(0, text.lastIndexOf("\n") + 1);
12374
+ for (const line of complete.split("\n")) {
12375
+ if (!line.trim()) continue;
12376
+ try {
12377
+ const type = JSON.parse(line).type;
12378
+ if (type === "user" || type === "assistant") return true;
12379
+ } catch {
12380
+ }
12381
+ }
12382
+ return size > CONVERSATION_PROBE_BYTES;
12383
+ } catch {
12384
+ return true;
12385
+ } finally {
12386
+ if (fd !== void 0) {
12387
+ try {
12388
+ closeSync(fd);
12389
+ } catch {
12390
+ }
12391
+ }
12392
+ }
12393
+ }
12342
12394
  function repairTornSessionFile(path) {
12343
12395
  try {
12344
12396
  if (!existsSync(path)) return false;
@@ -12867,6 +12919,7 @@ function freshSessionOptions(host, context, options) {
12867
12919
  sessionLineageKey(context.taskId, host.agentMode, host.config.mode)
12868
12920
  );
12869
12921
  if (rotateSessionFile(host.config.workspaceDir, lineageUuid)) {
12922
+ markSpawnedTranscript(host.config.workspaceDir, lineageUuid);
12870
12923
  return { ...options, sessionId: lineageUuid };
12871
12924
  }
12872
12925
  return { ...options, sessionId: randomUUID2() };
@@ -12918,6 +12971,11 @@ async function handleAuthError(context, host, options) {
12918
12971
  async function handleStaleSession(context, host, options) {
12919
12972
  context.claudeSessionId = null;
12920
12973
  host.connection.storeSessionId("");
12974
+ logger5.warn("Resume target had no resumable conversation; rotating it aside and starting fresh", {
12975
+ taskId: context.taskId,
12976
+ runnerMode: host.config.mode,
12977
+ agentMode: host.agentMode
12978
+ });
12921
12979
  const freshPrompt = buildMultimodalPrompt(
12922
12980
  await buildInitialPrompt(host.config.mode, context, host.isAuto, host.agentMode),
12923
12981
  context,
@@ -13025,7 +13083,7 @@ async function handleUsageCapRejection(context, host, options, rateLimitType, re
13025
13083
  return runWithRetry(freshQuery, context, host, options);
13026
13084
  }
13027
13085
  function handleRetryError(error, context, host, options, prevImageError) {
13028
- if (isStaleOrExitedSession(error, context) && context.claudeSessionId) {
13086
+ if (isStaleOrExitedSession(error, context)) {
13029
13087
  return handleStaleSession(context, host, options);
13030
13088
  }
13031
13089
  if (isAuthError(getErrorMessage(error))) {
@@ -13051,7 +13109,7 @@ function handleProcessResult(result, context, host, options) {
13051
13109
  )
13052
13110
  };
13053
13111
  }
13054
- if (result.staleSession && context.claudeSessionId) {
13112
+ if (result.staleSession) {
13055
13113
  return {
13056
13114
  action: "return_promise",
13057
13115
  promise: handleStaleSession(context, host, options)
package/dist/cli.js CHANGED
@@ -25,7 +25,7 @@ import {
25
25
  runUsageProbe,
26
26
  sampleKeyUsage,
27
27
  usesNativeUsageReporting
28
- } from "./chunk-RLROQPPT.js";
28
+ } from "./chunk-4L22UNZD.js";
29
29
  import "./chunk-37J5MMQT.js";
30
30
  import {
31
31
  inheritedEnv,
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SessionRunner,
3
3
  unshallowRepo
4
- } from "./chunk-RLROQPPT.js";
4
+ } from "./chunk-4L22UNZD.js";
5
5
  import "./chunk-37J5MMQT.js";
6
6
  import "./chunk-WCJ6HRVU.js";
7
7
  import {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rallycry/conveyor-agent",
3
- "version": "11.0.25",
3
+ "version": "11.0.26",
4
4
  "description": "Conveyor Agent Runner v10 - PTY harness for the task chat (SDK harness for audit/project-chat). Agent-as-User architecture with BaseService patterns. Works locally too.",
5
5
  "keywords": [
6
6
  "agent",