@rallycry/conveyor-agent 7.2.13 → 7.2.15

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.
@@ -253,13 +253,25 @@ var AgentConnection = class _AgentConnection {
253
253
  async emitStatus(status) {
254
254
  this.lastEmittedStatus = status;
255
255
  await this.flushEvents();
256
- void this.call("reportAgentStatus", {
257
- sessionId: this.config.sessionId,
258
- status
259
- }).then(() => {
260
- this.lastReportedStatus = status;
261
- }).catch(() => {
262
- });
256
+ const AWAIT_STATUSES = ["idle", "waiting_for_input", "connected"];
257
+ if (AWAIT_STATUSES.includes(status)) {
258
+ try {
259
+ await this.call("reportAgentStatus", {
260
+ sessionId: this.config.sessionId,
261
+ status
262
+ });
263
+ this.lastReportedStatus = status;
264
+ } catch {
265
+ }
266
+ } else {
267
+ void this.call("reportAgentStatus", {
268
+ sessionId: this.config.sessionId,
269
+ status
270
+ }).then(() => {
271
+ this.lastReportedStatus = status;
272
+ }).catch(() => {
273
+ });
274
+ }
263
275
  }
264
276
  postChatMessage(content) {
265
277
  if (!this.socket) return;
@@ -1103,6 +1115,118 @@ After addressing the feedback, resume your autonomous loop: call list_subtasks a
1103
1115
  return parts;
1104
1116
  }
1105
1117
 
1118
+ // src/execution/prompt-formatters.ts
1119
+ var PM_CHAT_HISTORY_LIMIT = 40;
1120
+ function formatFileSize(bytes) {
1121
+ if (bytes === void 0) return "";
1122
+ if (bytes < 1024) return `${bytes}B`;
1123
+ if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)}KB`;
1124
+ return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
1125
+ }
1126
+ function formatChatFile(file) {
1127
+ const sizeStr = file.fileSize ? `, ${formatFileSize(file.fileSize)}` : "";
1128
+ if (file.content && file.contentEncoding === "utf-8") {
1129
+ return [
1130
+ `[Attached: ${file.fileName} (${file.mimeType}${sizeStr})]`,
1131
+ "```",
1132
+ file.content,
1133
+ "```"
1134
+ ];
1135
+ }
1136
+ if (!file.content) {
1137
+ return [`[Attached: ${file.fileName} (${file.mimeType}${sizeStr})]: ${file.downloadUrl}`];
1138
+ }
1139
+ if (file.content && file.contentEncoding === "base64") {
1140
+ return [
1141
+ `[Attached image: ${file.fileName} (${file.mimeType}${sizeStr}) \u2014 use get_task_file("${file.fileId}") to view]`
1142
+ ];
1143
+ }
1144
+ return [`[Attached: ${file.fileName} (${file.mimeType}${sizeStr})]`];
1145
+ }
1146
+ function formatTaskFile(file) {
1147
+ if (file.content && file.contentEncoding === "utf-8") {
1148
+ return [`
1149
+ ### ${file.fileName} (${file.mimeType})`, "```", file.content, "```"];
1150
+ }
1151
+ if (file.content && file.contentEncoding === "base64") {
1152
+ const size = formatFileSize(file.fileSize);
1153
+ return [
1154
+ `- [Attached image: ${file.fileName} (${file.mimeType}${size ? `, ${size}` : ""}) \u2014 use get_task_file("${file.fileId}") to view]`
1155
+ ];
1156
+ }
1157
+ if (!file.content) {
1158
+ return [`- **${file.fileName}** (${file.mimeType}): ${file.downloadUrl}`];
1159
+ }
1160
+ return [];
1161
+ }
1162
+ function formatChatHistory(chatHistory, limit) {
1163
+ const relevant = chatHistory.slice(-(limit ?? PM_CHAT_HISTORY_LIMIT));
1164
+ const parts = [`
1165
+ ## Recent Chat Context`];
1166
+ for (const msg of relevant) {
1167
+ const sender = msg.userName ?? msg.role;
1168
+ parts.push(`[${sender}]: ${msg.content}`);
1169
+ if (msg.files?.length) {
1170
+ for (const file of msg.files) {
1171
+ parts.push(...formatChatFile(file));
1172
+ }
1173
+ }
1174
+ }
1175
+ return parts;
1176
+ }
1177
+ function formatRepoRefs(repoRefs) {
1178
+ const parts = [];
1179
+ parts.push(`
1180
+ ## Repository References`);
1181
+ for (const ref of repoRefs) {
1182
+ const icon = ref.refType === "folder" ? "folder" : "file";
1183
+ parts.push(`- [${icon}] \`${ref.path}\``);
1184
+ }
1185
+ return parts;
1186
+ }
1187
+ function formatProjectObjectives(objectives) {
1188
+ const parts = [];
1189
+ parts.push(`
1190
+ ## Project Objectives`);
1191
+ for (const obj of objectives) {
1192
+ const dates = `${obj.startDate.split("T")[0]} to ${obj.endDate.split("T")[0]}`;
1193
+ parts.push(`- **${obj.name}** (${dates})${obj.description ? ": " + obj.description : ""}`);
1194
+ }
1195
+ return parts;
1196
+ }
1197
+ function formatRecentRelatedTasks(tasks) {
1198
+ const parts = [];
1199
+ parts.push(`
1200
+ ## Recently Completed Related Tasks`);
1201
+ parts.push(
1202
+ `These tasks in the same domain were recently completed. Use them for context on recent changes and patterns.
1203
+ `
1204
+ );
1205
+ for (const task of tasks) {
1206
+ const tags = task.tagNames.length > 0 ? ` [${task.tagNames.join(", ")}]` : "";
1207
+ const pr = task.githubPRUrl ? ` \u2014 PR: ${task.githubPRUrl}` : "";
1208
+ parts.push(`- **${task.title}**${tags}${pr}`);
1209
+ }
1210
+ return parts;
1211
+ }
1212
+ function formatIncidents(incidents) {
1213
+ const parts = [];
1214
+ parts.push(`
1215
+ ## Linked Incidents`);
1216
+ parts.push(
1217
+ `This task has linked incidents. Review them for context on the problem being addressed.
1218
+ `
1219
+ );
1220
+ for (const inc of incidents) {
1221
+ const severity = inc.severity ? ` [${inc.severity}]` : "";
1222
+ const status = inc.status ? ` (${inc.status})` : "";
1223
+ parts.push(`### ${inc.title}${severity}${status}`);
1224
+ if (inc.description) parts.push(inc.description);
1225
+ if (inc.source) parts.push(`Source: ${inc.source}`);
1226
+ }
1227
+ return parts;
1228
+ }
1229
+
1106
1230
  // src/execution/tag-context-resolver.ts
1107
1231
  import { readFile, readdir } from "fs/promises";
1108
1232
  var TYPE_PRIORITY = { rule: 0, file: 1, folder: 2, doc: 3 };
@@ -1729,14 +1853,7 @@ Your responses are sent directly to the task chat \u2014 the team sees everythin
1729
1853
  }
1730
1854
 
1731
1855
  // src/execution/prompt-builder.ts
1732
- var PM_CHAT_HISTORY_LIMIT = 40;
1733
1856
  var TASK_CHAT_HISTORY_LIMIT = 20;
1734
- function formatFileSize(bytes) {
1735
- if (bytes === void 0) return "";
1736
- if (bytes < 1024) return `${bytes}B`;
1737
- if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)}KB`;
1738
- return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
1739
- }
1740
1857
  function findLastAgentMessageIndex2(history) {
1741
1858
  for (let i = history.length - 1; i >= 0; i--) {
1742
1859
  if (history[i].role === "assistant") return i;
@@ -1856,57 +1973,6 @@ Address the requested changes. Do NOT re-investigate the codebase from scratch o
1856
1973
  }
1857
1974
  return parts.join("\n");
1858
1975
  }
1859
- function formatChatFile(file) {
1860
- const sizeStr = file.fileSize ? `, ${formatFileSize(file.fileSize)}` : "";
1861
- if (file.content && file.contentEncoding === "utf-8") {
1862
- return [
1863
- `[Attached: ${file.fileName} (${file.mimeType}${sizeStr})]`,
1864
- "```",
1865
- file.content,
1866
- "```"
1867
- ];
1868
- }
1869
- if (!file.content) {
1870
- return [`[Attached: ${file.fileName} (${file.mimeType}${sizeStr})]: ${file.downloadUrl}`];
1871
- }
1872
- if (file.content && file.contentEncoding === "base64") {
1873
- return [
1874
- `[Attached image: ${file.fileName} (${file.mimeType}${sizeStr}) \u2014 use get_task_file("${file.fileId}") to view]`
1875
- ];
1876
- }
1877
- return [`[Attached: ${file.fileName} (${file.mimeType}${sizeStr})]`];
1878
- }
1879
- function formatTaskFile(file) {
1880
- if (file.content && file.contentEncoding === "utf-8") {
1881
- return [`
1882
- ### ${file.fileName} (${file.mimeType})`, "```", file.content, "```"];
1883
- }
1884
- if (file.content && file.contentEncoding === "base64") {
1885
- const size = formatFileSize(file.fileSize);
1886
- return [
1887
- `- [Attached image: ${file.fileName} (${file.mimeType}${size ? `, ${size}` : ""}) \u2014 use get_task_file("${file.fileId}") to view]`
1888
- ];
1889
- }
1890
- if (!file.content) {
1891
- return [`- **${file.fileName}** (${file.mimeType}): ${file.downloadUrl}`];
1892
- }
1893
- return [];
1894
- }
1895
- function formatChatHistory(chatHistory, limit) {
1896
- const relevant = chatHistory.slice(-(limit ?? PM_CHAT_HISTORY_LIMIT));
1897
- const parts = [`
1898
- ## Recent Chat Context`];
1899
- for (const msg of relevant) {
1900
- const sender = msg.userName ?? msg.role;
1901
- parts.push(`[${sender}]: ${msg.content}`);
1902
- if (msg.files?.length) {
1903
- for (const file of msg.files) {
1904
- parts.push(...formatChatFile(file));
1905
- }
1906
- }
1907
- }
1908
- return parts;
1909
- }
1910
1976
  async function resolveTaskTagContext(context, runnerMode) {
1911
1977
  if (!context.projectTags?.length || !context.taskTagIds?.length) return null;
1912
1978
  const { injectedSection } = await resolveTagContext(
@@ -1918,58 +1984,6 @@ async function resolveTaskTagContext(context, runnerMode) {
1918
1984
  );
1919
1985
  return injectedSection || null;
1920
1986
  }
1921
- function formatRepoRefs(repoRefs) {
1922
- const parts = [];
1923
- parts.push(`
1924
- ## Repository References`);
1925
- for (const ref of repoRefs) {
1926
- const icon = ref.refType === "folder" ? "folder" : "file";
1927
- parts.push(`- [${icon}] \`${ref.path}\``);
1928
- }
1929
- return parts;
1930
- }
1931
- function formatProjectObjectives(objectives) {
1932
- const parts = [];
1933
- parts.push(`
1934
- ## Project Objectives`);
1935
- for (const obj of objectives) {
1936
- const dates = `${obj.startDate.split("T")[0]} to ${obj.endDate.split("T")[0]}`;
1937
- parts.push(`- **${obj.name}** (${dates})${obj.description ? ": " + obj.description : ""}`);
1938
- }
1939
- return parts;
1940
- }
1941
- function formatRecentRelatedTasks(tasks) {
1942
- const parts = [];
1943
- parts.push(`
1944
- ## Recently Completed Related Tasks`);
1945
- parts.push(
1946
- `These tasks in the same domain were recently completed. Use them for context on recent changes and patterns.
1947
- `
1948
- );
1949
- for (const task of tasks) {
1950
- const tags = task.tagNames.length > 0 ? ` [${task.tagNames.join(", ")}]` : "";
1951
- const pr = task.githubPRUrl ? ` \u2014 PR: ${task.githubPRUrl}` : "";
1952
- parts.push(`- **${task.title}**${tags}${pr}`);
1953
- }
1954
- return parts;
1955
- }
1956
- function formatIncidents(incidents) {
1957
- const parts = [];
1958
- parts.push(`
1959
- ## Linked Incidents`);
1960
- parts.push(
1961
- `This task has linked incidents. Review them for context on the problem being addressed.
1962
- `
1963
- );
1964
- for (const inc of incidents) {
1965
- const severity = inc.severity ? ` [${inc.severity}]` : "";
1966
- const status = inc.status ? ` (${inc.status})` : "";
1967
- parts.push(`### ${inc.title}${severity}${status}`);
1968
- if (inc.description) parts.push(inc.description);
1969
- if (inc.source) parts.push(`Source: ${inc.source}`);
1970
- }
1971
- return parts;
1972
- }
1973
1987
  async function buildTaskBody(context, runnerMode) {
1974
1988
  const parts = [];
1975
1989
  parts.push(`# Task: ${context.title}`);
@@ -2085,19 +2099,39 @@ CRITICAL: You are in Auto mode. Do NOT report status, ask for confirmation, or g
2085
2099
  }
2086
2100
  return parts;
2087
2101
  }
2088
- function buildFeedbackInstructions(context, isPm) {
2102
+ function buildFeedbackInstructions(context, isPm, agentMode, isAuto) {
2089
2103
  const lastAgentIdx = findLastAgentMessageIndex2(context.chatHistory);
2090
2104
  const newMessages = context.chatHistory.slice(lastAgentIdx + 1).filter((m) => m.role === "user");
2091
2105
  if (isPm) {
2092
- return [
2106
+ const parts2 = [
2093
2107
  `You were relaunched with new feedback since your last run.`,
2094
2108
  `You are the project manager for this task.`,
2095
2109
  `
2096
2110
  New messages since your last run:`,
2097
- ...newMessages.map((m) => `[${m.userName ?? "user"}]: ${m.content}`),
2098
- `
2099
- Review these messages and wait for the team to provide instructions before taking action.`
2111
+ ...newMessages.map((m) => `[${m.userName ?? "user"}]: ${m.content}`)
2100
2112
  ];
2113
+ if (isAuto && (agentMode === "building" || agentMode === "review")) {
2114
+ parts2.push(
2115
+ `
2116
+ Your plan has been approved. Address the feedback above, then begin implementing.`,
2117
+ `Work on the git branch "${context.githubBranch}". Stay on this branch \u2014 do not checkout or create other branches.`,
2118
+ `Start by reading the relevant source files mentioned in the plan, then write code.`,
2119
+ `When finished, use the mcp__conveyor__create_pull_request tool to open a PR. Do NOT use gh CLI.`
2120
+ );
2121
+ } else if (isAuto) {
2122
+ parts2.push(
2123
+ `
2124
+ You are in auto mode. Address the feedback above \u2014 update the plan accordingly using update_task.`,
2125
+ `When the plan and all required properties are set, call ExitPlanMode to transition to building.`,
2126
+ `Do NOT wait for additional team input \u2014 the messages above ARE the team's input. Proceed autonomously.`
2127
+ );
2128
+ } else {
2129
+ parts2.push(
2130
+ `
2131
+ Review these messages and wait for the team to provide instructions before taking action.`
2132
+ );
2133
+ }
2134
+ return parts2;
2101
2135
  }
2102
2136
  const parts = [
2103
2137
  `You have been relaunched to address feedback on your previous work.`,
@@ -2177,7 +2211,7 @@ function buildInstructions(mode, context, scenario, agentMode, isAuto) {
2177
2211
  parts.push(...buildIdleRelaunchInstructions(context, isPm, agentMode, isAuto));
2178
2212
  return parts;
2179
2213
  }
2180
- parts.push(...buildFeedbackInstructions(context, isPm));
2214
+ parts.push(...buildFeedbackInstructions(context, isPm, agentMode, isAuto));
2181
2215
  return parts;
2182
2216
  }
2183
2217
  async function buildInitialPrompt(mode, context, isAuto, agentMode) {
@@ -2402,7 +2436,7 @@ function buildSearchIncidentsTool(connection) {
2402
2436
  function buildGetTaskIncidentsTool(connection) {
2403
2437
  return defineTool(
2404
2438
  "get_task_incidents",
2405
- "Get all incidents linked to the current task (or a specified task). Returns full incident details including title, description, severity, status, and source.",
2439
+ "Get incidents linked to the current task. Returns a summary of each incident with available sections. Use get_incident_detail to drill into specific sections (messages, logs, task details).",
2406
2440
  {
2407
2441
  task_id: z.string().optional().describe("Task ID (defaults to current task)")
2408
2442
  },
@@ -2422,6 +2456,51 @@ function buildGetTaskIncidentsTool(connection) {
2422
2456
  { annotations: { readOnlyHint: true } }
2423
2457
  );
2424
2458
  }
2459
+ function buildGetIncidentDetailTool(connection) {
2460
+ return defineTool(
2461
+ "get_incident_detail",
2462
+ "Get detailed incident data by section. Use after get_task_incidents to drill into specific sections of an incident. Supports pagination and text search within sections.",
2463
+ {
2464
+ incident_id: z.string().describe("The incident ID to get details for"),
2465
+ section: z.enum(["all", "user_report", "task_details", "subtasks", "messages", "logs"]).optional().default("all").describe("Which section to retrieve (default: all)"),
2466
+ search: z.string().optional().describe("Search for specific text within the section (case-insensitive)"),
2467
+ offset: z.number().optional().describe("Line offset for pagination (default 0)"),
2468
+ limit: z.number().optional().describe("Max lines to return (default 100, max 500)")
2469
+ },
2470
+ async ({ incident_id, section, search, offset, limit }) => {
2471
+ try {
2472
+ const result = await connection.call("getIncidentDetail", {
2473
+ sessionId: connection.sessionId,
2474
+ incidentId: incident_id,
2475
+ section,
2476
+ search,
2477
+ offset,
2478
+ limit
2479
+ });
2480
+ if (result.matchCount !== void 0) {
2481
+ return textResult(
2482
+ `${result.content}
2483
+
2484
+ --- ${result.matchCount} matches found (${result.totalLines} total lines in section) ---`
2485
+ );
2486
+ }
2487
+ if (result.hasMore) {
2488
+ return textResult(
2489
+ `${result.content}
2490
+
2491
+ --- Showing lines ${result.offset ?? 0}-${(result.offset ?? 0) + (limit ?? 100)} of ${result.totalLines} (more available \u2014 increase offset) ---`
2492
+ );
2493
+ }
2494
+ return textResult(result.content);
2495
+ } catch (error) {
2496
+ return textResult(
2497
+ `Failed to get incident detail: ${error instanceof Error ? error.message : "Unknown error"}`
2498
+ );
2499
+ }
2500
+ },
2501
+ { annotations: { readOnlyHint: true } }
2502
+ );
2503
+ }
2425
2504
  function buildQueryGcpLogsTool(connection) {
2426
2505
  return defineTool(
2427
2506
  "query_gcp_logs",
@@ -2806,6 +2885,7 @@ function buildCommonTools(connection, config) {
2806
2885
  buildGetTaskFileTool(connection),
2807
2886
  buildSearchIncidentsTool(connection),
2808
2887
  buildGetTaskIncidentsTool(connection),
2888
+ buildGetIncidentDetailTool(connection),
2809
2889
  buildQueryGcpLogsTool(connection),
2810
2890
  buildCreatePullRequestTool(connection, config),
2811
2891
  buildAddDependencyTool(connection),
@@ -4471,7 +4551,7 @@ async function processAssistantEvent(event, host, turnToolCalls) {
4471
4551
  host.connection.postChatMessage(turnTextParts.join("\n\n"));
4472
4552
  }
4473
4553
  }
4474
- var API_ERROR_PATTERN = /API Error: [45]\d\d/;
4554
+ var API_ERROR_PATTERN = /API Error: (?:[45]\d\d|terminated)/;
4475
4555
  var IMAGE_ERROR_PATTERN = /Could not process image/i;
4476
4556
  var AUTH_ERROR_PATTERN = /Not logged in|Please run \/login|authentication failed|invalid.*token|unauthorized/i;
4477
4557
  function isAuthError2(msg) {
@@ -4711,7 +4791,6 @@ async function handleResultCase(event, host, context, startTime, isTyping, lastA
4711
4791
  }
4712
4792
 
4713
4793
  // src/execution/event-processor.ts
4714
- var API_ERROR_PATTERN2 = /API Error: [45]\d\d/;
4715
4794
  function stopTypingIfNeeded(host, isTyping) {
4716
4795
  if (isTyping) host.connection.sendTypingStop();
4717
4796
  }
@@ -4746,7 +4825,7 @@ async function processAssistantCase(event, host, state) {
4746
4825
  if (usage) state.lastAssistantUsage = usage;
4747
4826
  if (!state.sawApiError) {
4748
4827
  const fullText = event.message.content.filter((b) => b.type === "text").map((b) => b.text).join(" ");
4749
- if (API_ERROR_PATTERN2.test(fullText)) {
4828
+ if (API_ERROR_PATTERN.test(fullText)) {
4750
4829
  state.sawApiError = true;
4751
4830
  }
4752
4831
  }
@@ -5024,7 +5103,6 @@ function buildCanUseTool(host) {
5024
5103
 
5025
5104
  // src/execution/query-executor.ts
5026
5105
  var logger2 = createServiceLogger("QueryExecutor");
5027
- var API_ERROR_PATTERN3 = /API Error: [45]\d\d/;
5028
5106
  var IMAGE_ERROR_PATTERN2 = /Could not process image/i;
5029
5107
  var RETRY_DELAYS_MS = [6e4, 12e4, 18e4, 3e5];
5030
5108
  function buildHooks(host) {
@@ -5321,7 +5399,7 @@ function getErrorMessage(error) {
5321
5399
  }
5322
5400
  function isRetriableError(error) {
5323
5401
  const message = getErrorMessage(error);
5324
- return API_ERROR_PATTERN3.test(message) || IMAGE_ERROR_PATTERN2.test(message);
5402
+ return API_ERROR_PATTERN.test(message) || IMAGE_ERROR_PATTERN2.test(message);
5325
5403
  }
5326
5404
  function classifyImageError(error) {
5327
5405
  return IMAGE_ERROR_PATTERN2.test(getErrorMessage(error));
@@ -7681,4 +7759,4 @@ export {
7681
7759
  loadForwardPorts,
7682
7760
  loadConveyorConfig
7683
7761
  };
7684
- //# sourceMappingURL=chunk-HXDVU6IH.js.map
7762
+ //# sourceMappingURL=chunk-TN24QXF5.js.map