@rallycry/conveyor-agent 4.7.1 → 4.9.0

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.
@@ -93,6 +93,12 @@ function getTaskProperties(socket) {
93
93
  function triggerIdentification(socket) {
94
94
  return emitRpc(requireSocket(socket), "agentRunner:triggerIdentification", {});
95
95
  }
96
+ function searchIncidents(socket, status, source) {
97
+ return emitRpc(requireSocket(socket), "agentRunner:searchIncidents", { status, source });
98
+ }
99
+ function getTaskIncidents(socket, taskId) {
100
+ return emitRpc(requireSocket(socket), "agentRunner:getTaskIncidents", { taskId });
101
+ }
96
102
 
97
103
  // src/connection/task-connection.ts
98
104
  var ConveyorConnection = class _ConveyorConnection {
@@ -335,6 +341,12 @@ var ConveyorConnection = class _ConveyorConnection {
335
341
  if (!this.socket) return;
336
342
  this.socket.emit("agentRunner:modeTransition", payload);
337
343
  }
344
+ searchIncidents(status, source) {
345
+ return searchIncidents(this.socket, status, source);
346
+ }
347
+ getTaskIncidents(taskId) {
348
+ return getTaskIncidents(this.socket, taskId);
349
+ }
338
350
  disconnect() {
339
351
  this.flushEvents();
340
352
  this.socket?.disconnect();
@@ -658,15 +670,15 @@ async function processAssistantEvent(event, host, turnToolCalls) {
658
670
  }
659
671
  var API_ERROR_PATTERN = /API Error: [45]\d\d/;
660
672
  var IMAGE_ERROR_PATTERN = /Could not process image/i;
661
- function isRetriableMessage(msg, durationMs) {
673
+ function isRetriableMessage(msg) {
662
674
  if (IMAGE_ERROR_PATTERN.test(msg)) return true;
663
- if (API_ERROR_PATTERN.test(msg) && (durationMs === void 0 || durationMs < 3e4)) return true;
675
+ if (API_ERROR_PATTERN.test(msg)) return true;
664
676
  return false;
665
677
  }
666
678
  function handleSuccessResult(event, host, context, startTime) {
667
679
  const durationMs = Date.now() - startTime;
668
680
  const summary = event.result || "Task completed.";
669
- const retriable = isRetriableMessage(summary, durationMs);
681
+ const retriable = isRetriableMessage(summary);
670
682
  const cumulativeTotal = host.costTracker.addQueryCost(event.total_cost_usd);
671
683
  const { modelUsage } = event;
672
684
  if (modelUsage && typeof modelUsage === "object") {
@@ -676,17 +688,34 @@ function handleSuccessResult(event, host, context, startTime) {
676
688
  if (modelUsage && typeof modelUsage === "object") {
677
689
  let queryInputTokens = 0;
678
690
  let contextWindow = 0;
691
+ let totalInputTokens = 0;
692
+ let totalCacheRead = 0;
693
+ let totalCacheCreation = 0;
679
694
  for (const data of Object.values(modelUsage)) {
680
695
  const d = data;
681
- queryInputTokens += (d.inputTokens ?? 0) + (d.cacheReadInputTokens ?? 0) + (d.cacheCreationInputTokens ?? 0);
696
+ const input = d.inputTokens ?? 0;
697
+ const cacheRead = d.cacheReadInputTokens ?? 0;
698
+ const cacheCreation = d.cacheCreationInputTokens ?? 0;
699
+ totalInputTokens += input;
700
+ totalCacheRead += cacheRead;
701
+ totalCacheCreation += cacheCreation;
702
+ queryInputTokens += input + cacheRead + cacheCreation;
682
703
  const cw = data.contextWindow ?? 0;
683
704
  if (cw > contextWindow) contextWindow = cw;
684
705
  }
706
+ const settings = context.agentSettings ?? host.config.agentSettings ?? {};
707
+ const has1mBeta = settings.betas?.includes("context-1m-2025-08-07");
708
+ if (has1mBeta && contextWindow > 0 && contextWindow <= 2e5) {
709
+ contextWindow = 1e6;
710
+ }
685
711
  if (contextWindow > 0) {
686
712
  host.connection.sendEvent({
687
713
  type: "context_update",
688
714
  contextTokens: queryInputTokens,
689
- contextWindow
715
+ contextWindow,
716
+ inputTokens: totalInputTokens,
717
+ cacheReadInputTokens: totalCacheRead,
718
+ cacheCreationInputTokens: totalCacheCreation
690
719
  });
691
720
  }
692
721
  }
@@ -739,6 +768,14 @@ async function emitResultEvent(event, host, context, startTime) {
739
768
  function handleRateLimitEvent(event, host) {
740
769
  const { rate_limit_info } = event;
741
770
  const status = rate_limit_info.status;
771
+ if (rate_limit_info.utilization != null && rate_limit_info.rateLimitType) {
772
+ host.connection.sendEvent({
773
+ type: "rate_limit_update",
774
+ rateLimitType: rate_limit_info.rateLimitType,
775
+ utilization: rate_limit_info.utilization,
776
+ status
777
+ });
778
+ }
742
779
  if (status === "rejected") {
743
780
  const resetsAt = rate_limit_info.resetsAt ? new Date(rate_limit_info.resetsAt).toISOString() : void 0;
744
781
  const resetsAtDisplay = resetsAt ?? "unknown";
@@ -1393,7 +1430,11 @@ function buildFreshInstructions(isPm, isAutoMode, context, agentMode) {
1393
1430
  `Your plan has been approved. Begin implementing it now.`,
1394
1431
  `Work on the git branch "${context.githubBranch}". Stay on this branch \u2014 do not checkout or create other branches.`,
1395
1432
  `Start by reading the relevant source files mentioned in the plan, then write code.`,
1396
- `When finished, commit and push your changes, then use the create_pull_request tool to open a PR. Do NOT use gh CLI.`
1433
+ `When finished, commit and push your changes, then use the create_pull_request tool to open a PR. Do NOT use gh CLI.`,
1434
+ ...isAutoMode ? [
1435
+ `
1436
+ IMPORTANT: You are in Auto mode. You MUST create a pull request using create_pull_request before finishing. Do NOT declare the task complete or go idle without opening a PR. If you are blocked from creating a PR, explain what is blocking you.`
1437
+ ] : []
1397
1438
  ];
1398
1439
  }
1399
1440
  if (isAutoMode && isPm) {
@@ -1731,6 +1772,47 @@ function buildGetTaskFileTool(connection) {
1731
1772
  { annotations: { readOnlyHint: true } }
1732
1773
  );
1733
1774
  }
1775
+ function buildSearchIncidentsTool(connection) {
1776
+ return tool(
1777
+ "search_incidents",
1778
+ "Search incidents in the current project. Optionally filter by status (Open, Acknowledged, Investigating, Resolved, Closed) or source.",
1779
+ {
1780
+ status: z.string().optional().describe("Filter by incident status"),
1781
+ source: z.string().optional().describe("Filter by source (e.g., 'conveyor', 'agent', 'build')")
1782
+ },
1783
+ async ({ status, source }) => {
1784
+ try {
1785
+ const incidents = await connection.searchIncidents(status, source);
1786
+ return textResult(JSON.stringify(incidents, null, 2));
1787
+ } catch (error) {
1788
+ return textResult(
1789
+ `Failed to search incidents: ${error instanceof Error ? error.message : "Unknown error"}`
1790
+ );
1791
+ }
1792
+ },
1793
+ { annotations: { readOnlyHint: true } }
1794
+ );
1795
+ }
1796
+ function buildGetTaskIncidentsTool(connection) {
1797
+ return tool(
1798
+ "get_task_incidents",
1799
+ "Get all incidents linked to the current task (or a specified task). Returns full incident details including title, description, severity, status, and source.",
1800
+ {
1801
+ task_id: z.string().optional().describe("Task ID (defaults to current task)")
1802
+ },
1803
+ async ({ task_id }) => {
1804
+ try {
1805
+ const incidents = await connection.getTaskIncidents(task_id);
1806
+ return textResult(JSON.stringify(incidents, null, 2));
1807
+ } catch (error) {
1808
+ return textResult(
1809
+ `Failed to get task incidents: ${error instanceof Error ? error.message : "Unknown error"}`
1810
+ );
1811
+ }
1812
+ },
1813
+ { annotations: { readOnlyHint: true } }
1814
+ );
1815
+ }
1734
1816
  function buildCommonTools(connection, config) {
1735
1817
  return [
1736
1818
  buildReadTaskChatTool(connection),
@@ -1740,7 +1822,9 @@ function buildCommonTools(connection, config) {
1740
1822
  buildGetTaskTool(connection),
1741
1823
  buildGetTaskCliTool(connection),
1742
1824
  buildListTaskFilesTool(connection),
1743
- buildGetTaskFileTool(connection)
1825
+ buildGetTaskFileTool(connection),
1826
+ buildSearchIncidentsTool(connection),
1827
+ buildGetTaskIncidentsTool(connection)
1744
1828
  ];
1745
1829
  }
1746
1830
 
@@ -2935,6 +3019,7 @@ var AgentRunner = class {
2935
3019
  sessionIds = /* @__PURE__ */ new Map();
2936
3020
  lastQueryModeRestart = false;
2937
3021
  startCommandStarted = false;
3022
+ nudgedForPR = false;
2938
3023
  idleTimer = null;
2939
3024
  idleCheckInterval = null;
2940
3025
  deferredStartConfig = null;
@@ -3077,6 +3162,26 @@ var AgentRunner = class {
3077
3162
  } catch {
3078
3163
  }
3079
3164
  }
3165
+ async maybeSendPRNudge() {
3166
+ if (!this.config.isAuto || this.nudgedForPR || this.stopped) return false;
3167
+ const fresh = await this.connection.fetchTaskContext().catch(() => null);
3168
+ if (fresh) this.taskContext = fresh;
3169
+ const status = this.taskContext?.status;
3170
+ const hasPR = !!this.taskContext?.githubPRUrl;
3171
+ if (status === "InProgress" && !hasPR) {
3172
+ this.nudgedForPR = true;
3173
+ this.connection.postChatMessage(
3174
+ "Auto-nudge: Task is still In Progress with no PR. Prompting agent to continue..."
3175
+ );
3176
+ await this.setState("running");
3177
+ await this.runQuerySafe(
3178
+ this.taskContext,
3179
+ "You are in Auto mode and your task is still In Progress with no pull request. You MUST create a pull request before finishing. Use the create_pull_request tool now to open a PR for your changes. If you are blocked, explain what is preventing you from creating a PR."
3180
+ );
3181
+ return true;
3182
+ }
3183
+ return false;
3184
+ }
3080
3185
  async executeInitialMode() {
3081
3186
  if (!this.taskContext) return;
3082
3187
  const mode = this.effectiveAgentMode;
@@ -3084,7 +3189,10 @@ var AgentRunner = class {
3084
3189
  if (shouldRun) {
3085
3190
  await this.setState("running");
3086
3191
  await this.runQuerySafe(this.taskContext);
3087
- if (!this.stopped) await this.setState("idle");
3192
+ if (!this.stopped && this._state !== "error") {
3193
+ const nudged = await this.maybeSendPRNudge();
3194
+ if (!nudged) await this.setState("idle");
3195
+ }
3088
3196
  } else {
3089
3197
  await this.setState("idle");
3090
3198
  }
@@ -3123,7 +3231,10 @@ var AgentRunner = class {
3123
3231
  }
3124
3232
  );
3125
3233
  this.taskContext = await this.connection.fetchTaskContext().catch(() => null) ?? this.taskContext;
3126
- if (!this.stopped && this._state !== "error") await this.setState("idle");
3234
+ if (!this.stopped && this._state !== "error") {
3235
+ const nudged = await this.maybeSendPRNudge();
3236
+ if (!nudged) await this.setState("idle");
3237
+ }
3127
3238
  continue;
3128
3239
  }
3129
3240
  if (this._state === "idle") {
@@ -3777,4 +3888,4 @@ export {
3777
3888
  ProjectRunner,
3778
3889
  FileCache
3779
3890
  };
3780
- //# sourceMappingURL=chunk-EBCQISOA.js.map
3891
+ //# sourceMappingURL=chunk-ACPWJ2SL.js.map