@rallycry/conveyor-agent 7.2.14 → 7.2.16

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.
@@ -1115,6 +1115,118 @@ After addressing the feedback, resume your autonomous loop: call list_subtasks a
1115
1115
  return parts;
1116
1116
  }
1117
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
+
1118
1230
  // src/execution/tag-context-resolver.ts
1119
1231
  import { readFile, readdir } from "fs/promises";
1120
1232
  var TYPE_PRIORITY = { rule: 0, file: 1, folder: 2, doc: 3 };
@@ -1741,14 +1853,7 @@ Your responses are sent directly to the task chat \u2014 the team sees everythin
1741
1853
  }
1742
1854
 
1743
1855
  // src/execution/prompt-builder.ts
1744
- var PM_CHAT_HISTORY_LIMIT = 40;
1745
1856
  var TASK_CHAT_HISTORY_LIMIT = 20;
1746
- function formatFileSize(bytes) {
1747
- if (bytes === void 0) return "";
1748
- if (bytes < 1024) return `${bytes}B`;
1749
- if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)}KB`;
1750
- return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
1751
- }
1752
1857
  function findLastAgentMessageIndex2(history) {
1753
1858
  for (let i = history.length - 1; i >= 0; i--) {
1754
1859
  if (history[i].role === "assistant") return i;
@@ -1868,57 +1973,6 @@ Address the requested changes. Do NOT re-investigate the codebase from scratch o
1868
1973
  }
1869
1974
  return parts.join("\n");
1870
1975
  }
1871
- function formatChatFile(file) {
1872
- const sizeStr = file.fileSize ? `, ${formatFileSize(file.fileSize)}` : "";
1873
- if (file.content && file.contentEncoding === "utf-8") {
1874
- return [
1875
- `[Attached: ${file.fileName} (${file.mimeType}${sizeStr})]`,
1876
- "```",
1877
- file.content,
1878
- "```"
1879
- ];
1880
- }
1881
- if (!file.content) {
1882
- return [`[Attached: ${file.fileName} (${file.mimeType}${sizeStr})]: ${file.downloadUrl}`];
1883
- }
1884
- if (file.content && file.contentEncoding === "base64") {
1885
- return [
1886
- `[Attached image: ${file.fileName} (${file.mimeType}${sizeStr}) \u2014 use get_task_file("${file.fileId}") to view]`
1887
- ];
1888
- }
1889
- return [`[Attached: ${file.fileName} (${file.mimeType}${sizeStr})]`];
1890
- }
1891
- function formatTaskFile(file) {
1892
- if (file.content && file.contentEncoding === "utf-8") {
1893
- return [`
1894
- ### ${file.fileName} (${file.mimeType})`, "```", file.content, "```"];
1895
- }
1896
- if (file.content && file.contentEncoding === "base64") {
1897
- const size = formatFileSize(file.fileSize);
1898
- return [
1899
- `- [Attached image: ${file.fileName} (${file.mimeType}${size ? `, ${size}` : ""}) \u2014 use get_task_file("${file.fileId}") to view]`
1900
- ];
1901
- }
1902
- if (!file.content) {
1903
- return [`- **${file.fileName}** (${file.mimeType}): ${file.downloadUrl}`];
1904
- }
1905
- return [];
1906
- }
1907
- function formatChatHistory(chatHistory, limit) {
1908
- const relevant = chatHistory.slice(-(limit ?? PM_CHAT_HISTORY_LIMIT));
1909
- const parts = [`
1910
- ## Recent Chat Context`];
1911
- for (const msg of relevant) {
1912
- const sender = msg.userName ?? msg.role;
1913
- parts.push(`[${sender}]: ${msg.content}`);
1914
- if (msg.files?.length) {
1915
- for (const file of msg.files) {
1916
- parts.push(...formatChatFile(file));
1917
- }
1918
- }
1919
- }
1920
- return parts;
1921
- }
1922
1976
  async function resolveTaskTagContext(context, runnerMode) {
1923
1977
  if (!context.projectTags?.length || !context.taskTagIds?.length) return null;
1924
1978
  const { injectedSection } = await resolveTagContext(
@@ -1930,58 +1984,6 @@ async function resolveTaskTagContext(context, runnerMode) {
1930
1984
  );
1931
1985
  return injectedSection || null;
1932
1986
  }
1933
- function formatRepoRefs(repoRefs) {
1934
- const parts = [];
1935
- parts.push(`
1936
- ## Repository References`);
1937
- for (const ref of repoRefs) {
1938
- const icon = ref.refType === "folder" ? "folder" : "file";
1939
- parts.push(`- [${icon}] \`${ref.path}\``);
1940
- }
1941
- return parts;
1942
- }
1943
- function formatProjectObjectives(objectives) {
1944
- const parts = [];
1945
- parts.push(`
1946
- ## Project Objectives`);
1947
- for (const obj of objectives) {
1948
- const dates = `${obj.startDate.split("T")[0]} to ${obj.endDate.split("T")[0]}`;
1949
- parts.push(`- **${obj.name}** (${dates})${obj.description ? ": " + obj.description : ""}`);
1950
- }
1951
- return parts;
1952
- }
1953
- function formatRecentRelatedTasks(tasks) {
1954
- const parts = [];
1955
- parts.push(`
1956
- ## Recently Completed Related Tasks`);
1957
- parts.push(
1958
- `These tasks in the same domain were recently completed. Use them for context on recent changes and patterns.
1959
- `
1960
- );
1961
- for (const task of tasks) {
1962
- const tags = task.tagNames.length > 0 ? ` [${task.tagNames.join(", ")}]` : "";
1963
- const pr = task.githubPRUrl ? ` \u2014 PR: ${task.githubPRUrl}` : "";
1964
- parts.push(`- **${task.title}**${tags}${pr}`);
1965
- }
1966
- return parts;
1967
- }
1968
- function formatIncidents(incidents) {
1969
- const parts = [];
1970
- parts.push(`
1971
- ## Linked Incidents`);
1972
- parts.push(
1973
- `This task has linked incidents. Review them for context on the problem being addressed.
1974
- `
1975
- );
1976
- for (const inc of incidents) {
1977
- const severity = inc.severity ? ` [${inc.severity}]` : "";
1978
- const status = inc.status ? ` (${inc.status})` : "";
1979
- parts.push(`### ${inc.title}${severity}${status}`);
1980
- if (inc.description) parts.push(inc.description);
1981
- if (inc.source) parts.push(`Source: ${inc.source}`);
1982
- }
1983
- return parts;
1984
- }
1985
1987
  async function buildTaskBody(context, runnerMode) {
1986
1988
  const parts = [];
1987
1989
  parts.push(`# Task: ${context.title}`);
@@ -2097,19 +2099,39 @@ CRITICAL: You are in Auto mode. Do NOT report status, ask for confirmation, or g
2097
2099
  }
2098
2100
  return parts;
2099
2101
  }
2100
- function buildFeedbackInstructions(context, isPm) {
2102
+ function buildFeedbackInstructions(context, isPm, agentMode, isAuto) {
2101
2103
  const lastAgentIdx = findLastAgentMessageIndex2(context.chatHistory);
2102
2104
  const newMessages = context.chatHistory.slice(lastAgentIdx + 1).filter((m) => m.role === "user");
2103
2105
  if (isPm) {
2104
- return [
2106
+ const parts2 = [
2105
2107
  `You were relaunched with new feedback since your last run.`,
2106
2108
  `You are the project manager for this task.`,
2107
2109
  `
2108
2110
  New messages since your last run:`,
2109
- ...newMessages.map((m) => `[${m.userName ?? "user"}]: ${m.content}`),
2110
- `
2111
- Review these messages and wait for the team to provide instructions before taking action.`
2111
+ ...newMessages.map((m) => `[${m.userName ?? "user"}]: ${m.content}`)
2112
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;
2113
2135
  }
2114
2136
  const parts = [
2115
2137
  `You have been relaunched to address feedback on your previous work.`,
@@ -2189,7 +2211,7 @@ function buildInstructions(mode, context, scenario, agentMode, isAuto) {
2189
2211
  parts.push(...buildIdleRelaunchInstructions(context, isPm, agentMode, isAuto));
2190
2212
  return parts;
2191
2213
  }
2192
- parts.push(...buildFeedbackInstructions(context, isPm));
2214
+ parts.push(...buildFeedbackInstructions(context, isPm, agentMode, isAuto));
2193
2215
  return parts;
2194
2216
  }
2195
2217
  async function buildInitialPrompt(mode, context, isAuto, agentMode) {
@@ -2414,7 +2436,7 @@ function buildSearchIncidentsTool(connection) {
2414
2436
  function buildGetTaskIncidentsTool(connection) {
2415
2437
  return defineTool(
2416
2438
  "get_task_incidents",
2417
- "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).",
2418
2440
  {
2419
2441
  task_id: z.string().optional().describe("Task ID (defaults to current task)")
2420
2442
  },
@@ -2434,6 +2456,51 @@ function buildGetTaskIncidentsTool(connection) {
2434
2456
  { annotations: { readOnlyHint: true } }
2435
2457
  );
2436
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
+ }
2437
2504
  function buildQueryGcpLogsTool(connection) {
2438
2505
  return defineTool(
2439
2506
  "query_gcp_logs",
@@ -2818,6 +2885,7 @@ function buildCommonTools(connection, config) {
2818
2885
  buildGetTaskFileTool(connection),
2819
2886
  buildSearchIncidentsTool(connection),
2820
2887
  buildGetTaskIncidentsTool(connection),
2888
+ buildGetIncidentDetailTool(connection),
2821
2889
  buildQueryGcpLogsTool(connection),
2822
2890
  buildCreatePullRequestTool(connection, config),
2823
2891
  buildAddDependencyTool(connection),
@@ -4483,7 +4551,7 @@ async function processAssistantEvent(event, host, turnToolCalls) {
4483
4551
  host.connection.postChatMessage(turnTextParts.join("\n\n"));
4484
4552
  }
4485
4553
  }
4486
- var API_ERROR_PATTERN = /API Error: [45]\d\d/;
4554
+ var API_ERROR_PATTERN = /API Error: (?:[45]\d\d|terminated)/;
4487
4555
  var IMAGE_ERROR_PATTERN = /Could not process image/i;
4488
4556
  var AUTH_ERROR_PATTERN = /Not logged in|Please run \/login|authentication failed|invalid.*token|unauthorized/i;
4489
4557
  function isAuthError2(msg) {
@@ -4723,7 +4791,6 @@ async function handleResultCase(event, host, context, startTime, isTyping, lastA
4723
4791
  }
4724
4792
 
4725
4793
  // src/execution/event-processor.ts
4726
- var API_ERROR_PATTERN2 = /API Error: [45]\d\d/;
4727
4794
  function stopTypingIfNeeded(host, isTyping) {
4728
4795
  if (isTyping) host.connection.sendTypingStop();
4729
4796
  }
@@ -4758,7 +4825,7 @@ async function processAssistantCase(event, host, state) {
4758
4825
  if (usage) state.lastAssistantUsage = usage;
4759
4826
  if (!state.sawApiError) {
4760
4827
  const fullText = event.message.content.filter((b) => b.type === "text").map((b) => b.text).join(" ");
4761
- if (API_ERROR_PATTERN2.test(fullText)) {
4828
+ if (API_ERROR_PATTERN.test(fullText)) {
4762
4829
  state.sawApiError = true;
4763
4830
  }
4764
4831
  }
@@ -5036,7 +5103,6 @@ function buildCanUseTool(host) {
5036
5103
 
5037
5104
  // src/execution/query-executor.ts
5038
5105
  var logger2 = createServiceLogger("QueryExecutor");
5039
- var API_ERROR_PATTERN3 = /API Error: [45]\d\d/;
5040
5106
  var IMAGE_ERROR_PATTERN2 = /Could not process image/i;
5041
5107
  var RETRY_DELAYS_MS = [6e4, 12e4, 18e4, 3e5];
5042
5108
  function buildHooks(host) {
@@ -5333,7 +5399,7 @@ function getErrorMessage(error) {
5333
5399
  }
5334
5400
  function isRetriableError(error) {
5335
5401
  const message = getErrorMessage(error);
5336
- return API_ERROR_PATTERN3.test(message) || IMAGE_ERROR_PATTERN2.test(message);
5402
+ return API_ERROR_PATTERN.test(message) || IMAGE_ERROR_PATTERN2.test(message);
5337
5403
  }
5338
5404
  function classifyImageError(error) {
5339
5405
  return IMAGE_ERROR_PATTERN2.test(getErrorMessage(error));
@@ -6725,8 +6791,7 @@ function buildMutationTools(connection) {
6725
6791
  title: z8.string().describe("Task title"),
6726
6792
  description: z8.string().optional().describe("Task description"),
6727
6793
  plan: z8.string().optional().describe("Implementation plan in markdown"),
6728
- status: z8.string().optional().describe("Initial status (default: Planning)"),
6729
- isBug: z8.boolean().optional().describe("Whether this is a bug report")
6794
+ status: z8.string().optional().describe("Initial status (default: Planning)")
6730
6795
  },
6731
6796
  async (params) => {
6732
6797
  try {
@@ -7693,4 +7758,4 @@ export {
7693
7758
  loadForwardPorts,
7694
7759
  loadConveyorConfig
7695
7760
  };
7696
- //# sourceMappingURL=chunk-FDYL6LO7.js.map
7761
+ //# sourceMappingURL=chunk-4XJPZGXU.js.map