@rallycry/conveyor-agent 7.0.8 → 7.0.10

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.
@@ -92,8 +92,14 @@ var AgentConnection = class _AgentConnection {
92
92
  extraHeaders: { "ngrok-skip-browser-warning": "true" }
93
93
  });
94
94
  this.socket.on("session:message", (msg) => {
95
- if (this.messageCallback) this.messageCallback(msg);
96
- else this.earlyMessages.push(msg);
95
+ const incoming = {
96
+ content: msg.content,
97
+ userId: msg.userId,
98
+ ...msg.source && { source: msg.source },
99
+ ...msg.files && { files: msg.files }
100
+ };
101
+ if (this.messageCallback) this.messageCallback(incoming);
102
+ else this.earlyMessages.push(incoming);
97
103
  });
98
104
  this.socket.on("session:stop", () => {
99
105
  if (this.stopCallback) this.stopCallback();
@@ -161,7 +167,7 @@ var AgentConnection = class _AgentConnection {
161
167
  });
162
168
  }
163
169
  disconnect() {
164
- this.flushEvents();
170
+ void this.flushEvents();
165
171
  if (this.socket) {
166
172
  this.socket.io.reconnection(false);
167
173
  this.socket.removeAllListeners();
@@ -248,9 +254,9 @@ var AgentConnection = class _AgentConnection {
248
254
  this.apiKeyUpdateCallback = callback;
249
255
  }
250
256
  // ── Convenience methods (thin wrappers around call / emit) ─────────
251
- emitStatus(status) {
257
+ async emitStatus(status) {
252
258
  this.lastEmittedStatus = status;
253
- this.flushEvents();
259
+ await this.flushEvents();
254
260
  void this.call("reportAgentStatus", {
255
261
  sessionId: this.config.sessionId,
256
262
  status
@@ -424,10 +430,10 @@ ${q.question}${q.options.length ? "\n" + q.options.map((o) => `- ${o.label}: ${o
424
430
  if (!this.socket) return;
425
431
  this.eventBuffer.push({ event });
426
432
  if (!this.flushTimer) {
427
- this.flushTimer = setTimeout(() => this.flushEvents(), EVENT_BATCH_MS);
433
+ this.flushTimer = setTimeout(() => void this.flushEvents(), EVENT_BATCH_MS);
428
434
  }
429
435
  }
430
- flushEvents() {
436
+ async flushEvents() {
431
437
  if (this.flushTimer) {
432
438
  clearTimeout(this.flushTimer);
433
439
  this.flushTimer = null;
@@ -435,7 +441,7 @@ ${q.question}${q.options.length ? "\n" + q.options.map((o) => `- ${o.label}: ${o
435
441
  if (!this.socket || this.eventBuffer.length === 0) return;
436
442
  const events = this.eventBuffer.map((entry) => entry.event);
437
443
  this.eventBuffer = [];
438
- this.call("emitAgentEvent", { sessionId: this.config.sessionId, events }).catch(() => {
444
+ await this.call("emitAgentEvent", { sessionId: this.config.sessionId, events }).catch(() => {
439
445
  });
440
446
  }
441
447
  };
@@ -672,6 +678,28 @@ function syncWithBaseBranch(cwd, baseBranch) {
672
678
  `);
673
679
  return true;
674
680
  }
681
+ function ensureOnTaskBranch(cwd, taskBranch) {
682
+ if (!taskBranch) return true;
683
+ const current = getCurrentBranch(cwd);
684
+ if (current === taskBranch) return true;
685
+ try {
686
+ execSync(`git fetch origin ${taskBranch}`, { cwd, stdio: "ignore", timeout: 6e4 });
687
+ } catch {
688
+ process.stderr.write(`[conveyor-agent] Warning: git fetch origin ${taskBranch} failed
689
+ `);
690
+ return false;
691
+ }
692
+ try {
693
+ execSync(`git checkout ${taskBranch}`, { cwd, stdio: "ignore", timeout: 3e4 });
694
+ } catch {
695
+ process.stderr.write(`[conveyor-agent] Warning: git checkout ${taskBranch} failed
696
+ `);
697
+ return false;
698
+ }
699
+ process.stderr.write(`[conveyor-agent] Checked out task branch ${taskBranch}
700
+ `);
701
+ return true;
702
+ }
675
703
  function hasUncommittedChanges(cwd) {
676
704
  const status = execSync("git status --porcelain", {
677
705
  cwd,
@@ -879,6 +907,472 @@ var PlanSync = class {
879
907
  }
880
908
  };
881
909
 
910
+ // ../shared/dist/index.js
911
+ import { z } from "zod";
912
+ var MAX_FILE_SIZE_BYTES = 25 * 1024 * 1024;
913
+ var EMBED_THRESHOLD_IMAGES = 5 * 1024 * 1024;
914
+ var EMBED_THRESHOLD_TEXT = 2 * 1024 * 1024;
915
+ var AgentHeartbeatSchema = z.object({
916
+ sessionId: z.string().optional(),
917
+ timestamp: z.string(),
918
+ status: z.enum(["active", "idle", "building"]),
919
+ currentAction: z.string().optional()
920
+ });
921
+ var CreatePRInputSchema = z.object({
922
+ title: z.string().min(1),
923
+ body: z.string(),
924
+ head: z.string().optional(),
925
+ base: z.string().optional()
926
+ });
927
+ var PostToChatInputSchema = z.object({
928
+ message: z.string().min(1),
929
+ type: z.enum(["message", "question", "update"]).optional().default("message")
930
+ });
931
+ var GetTaskContextRequestSchema = z.object({
932
+ sessionId: z.string(),
933
+ includeHistory: z.boolean().optional().default(false)
934
+ });
935
+ var GetChatMessagesRequestSchema = z.object({
936
+ sessionId: z.string(),
937
+ limit: z.number().int().positive().optional().default(50),
938
+ offset: z.number().int().nonnegative().optional().default(0)
939
+ });
940
+ var GetTaskFilesRequestSchema = z.object({
941
+ sessionId: z.string()
942
+ });
943
+ var GetTaskFileRequestSchema = z.object({
944
+ sessionId: z.string(),
945
+ fileId: z.string()
946
+ });
947
+ var GetTaskRequestSchema = z.object({
948
+ sessionId: z.string(),
949
+ taskSlugOrId: z.string()
950
+ });
951
+ var GetCliHistoryRequestSchema = z.object({
952
+ sessionId: z.string(),
953
+ limit: z.number().int().positive().optional().default(100),
954
+ source: z.enum(["agent", "application"]).optional()
955
+ });
956
+ var ListSubtasksRequestSchema = z.object({
957
+ sessionId: z.string()
958
+ });
959
+ var GetDependenciesRequestSchema = z.object({
960
+ sessionId: z.string()
961
+ });
962
+ var GetSuggestionsRequestSchema = z.object({
963
+ sessionId: z.string()
964
+ });
965
+ var GetTaskIncidentsRequestSchema = z.object({
966
+ sessionId: z.string()
967
+ });
968
+ var CreatePullRequestRequestSchema = CreatePRInputSchema.extend({ sessionId: z.string() });
969
+ var UpdateTaskStatusRequestSchema = z.object({
970
+ sessionId: z.string(),
971
+ status: z.string(),
972
+ force: z.boolean().optional().default(false)
973
+ });
974
+ var StoreSessionIdRequestSchema = z.object({
975
+ sessionId: z.string(),
976
+ sdkSessionId: z.string()
977
+ });
978
+ var TrackSpendingRequestSchema = z.object({
979
+ sessionId: z.string(),
980
+ inputTokens: z.number().int().nonnegative(),
981
+ outputTokens: z.number().int().nonnegative(),
982
+ costUsd: z.number().nonnegative(),
983
+ model: z.string()
984
+ });
985
+ var SessionStartRequestSchema = z.object({
986
+ sessionId: z.string(),
987
+ agentVersion: z.string(),
988
+ capabilities: z.array(z.string())
989
+ });
990
+ var SessionStopRequestSchema = z.object({
991
+ sessionId: z.string(),
992
+ reason: z.string().optional()
993
+ });
994
+ var ConnectAgentRequestSchema = z.object({
995
+ sessionId: z.string()
996
+ });
997
+ var ReportAgentStatusRequestSchema = z.object({
998
+ sessionId: z.string(),
999
+ status: z.string()
1000
+ });
1001
+ var CreateSubtaskRequestSchema = z.object({
1002
+ sessionId: z.string(),
1003
+ title: z.string().min(1),
1004
+ description: z.string().optional(),
1005
+ plan: z.string().optional(),
1006
+ storyPointValue: z.number().int().positive().optional(),
1007
+ ordinal: z.number().int().nonnegative().optional()
1008
+ });
1009
+ var UpdateSubtaskRequestSchema = z.object({
1010
+ sessionId: z.string(),
1011
+ subtaskId: z.string(),
1012
+ title: z.string().min(1).optional(),
1013
+ description: z.string().optional(),
1014
+ plan: z.string().optional(),
1015
+ status: z.string().optional(),
1016
+ storyPointValue: z.number().int().positive().optional()
1017
+ });
1018
+ var DeleteSubtaskRequestSchema = z.object({
1019
+ sessionId: z.string(),
1020
+ subtaskId: z.string()
1021
+ });
1022
+ var SearchIncidentsRequestSchema = z.object({
1023
+ sessionId: z.string(),
1024
+ status: z.string().optional(),
1025
+ source: z.string().optional()
1026
+ });
1027
+ var QueryGcpLogsRequestSchema = z.object({
1028
+ sessionId: z.string(),
1029
+ filter: z.string().optional(),
1030
+ startTime: z.string().optional(),
1031
+ endTime: z.string().optional(),
1032
+ severity: z.string().optional(),
1033
+ pageSize: z.number().int().positive().optional().default(100)
1034
+ });
1035
+ var GetTaskPropertiesRequestSchema = z.object({
1036
+ sessionId: z.string()
1037
+ });
1038
+ var UpdateTaskFieldsRequestSchema = z.object({
1039
+ sessionId: z.string(),
1040
+ plan: z.string().optional(),
1041
+ description: z.string().optional()
1042
+ });
1043
+ var UpdateTaskPropertiesRequestSchema = z.object({
1044
+ sessionId: z.string(),
1045
+ title: z.string().optional(),
1046
+ storyPointValue: z.number().int().positive().optional(),
1047
+ tagIds: z.array(z.string()).optional()
1048
+ });
1049
+ var ListIconsRequestSchema = z.object({
1050
+ sessionId: z.string()
1051
+ });
1052
+ var GenerateTaskIconRequestSchema = z.object({
1053
+ sessionId: z.string(),
1054
+ prompt: z.string().min(1),
1055
+ aspectRatio: z.string().optional()
1056
+ });
1057
+ var SearchFaIconsRequestSchema = z.object({
1058
+ sessionId: z.string(),
1059
+ query: z.string().min(1),
1060
+ first: z.number().int().positive().optional()
1061
+ });
1062
+ var PickFaIconRequestSchema = z.object({
1063
+ sessionId: z.string(),
1064
+ fontAwesomeId: z.string().min(1),
1065
+ fontAwesomeStyle: z.string().optional()
1066
+ });
1067
+ var CreateFollowUpTaskRequestSchema = z.object({
1068
+ sessionId: z.string(),
1069
+ title: z.string().min(1),
1070
+ description: z.string().optional(),
1071
+ plan: z.string().optional(),
1072
+ storyPointValue: z.number().int().positive().optional()
1073
+ });
1074
+ var AddDependencyRequestSchema = z.object({
1075
+ sessionId: z.string(),
1076
+ dependsOnSlugOrId: z.string()
1077
+ });
1078
+ var RemoveDependencyRequestSchema = z.object({
1079
+ sessionId: z.string(),
1080
+ dependsOnSlugOrId: z.string()
1081
+ });
1082
+ var CreateSuggestionRequestSchema = z.object({
1083
+ sessionId: z.string(),
1084
+ title: z.string().min(1),
1085
+ description: z.string().optional(),
1086
+ tagNames: z.array(z.string()).optional()
1087
+ });
1088
+ var VoteSuggestionRequestSchema = z.object({
1089
+ sessionId: z.string(),
1090
+ suggestionId: z.string(),
1091
+ value: z.union([z.literal(1), z.literal(-1)])
1092
+ });
1093
+ var ScaleUpResourcesRequestSchema = z.object({
1094
+ sessionId: z.string(),
1095
+ tier: z.string(),
1096
+ reason: z.string().optional()
1097
+ });
1098
+ var TriggerIdentificationRequestSchema = z.object({
1099
+ sessionId: z.string()
1100
+ });
1101
+ var SubmitCodeReviewResultRequestSchema = z.object({
1102
+ sessionId: z.string(),
1103
+ approved: z.boolean(),
1104
+ content: z.string()
1105
+ });
1106
+ var StartChildCloudBuildRequestSchema = z.object({
1107
+ sessionId: z.string(),
1108
+ childTaskId: z.string()
1109
+ });
1110
+ var StopChildBuildRequestSchema = z.object({
1111
+ sessionId: z.string(),
1112
+ childTaskId: z.string()
1113
+ });
1114
+ var ApproveAndMergePRRequestSchema = z.object({
1115
+ sessionId: z.string(),
1116
+ childTaskId: z.string()
1117
+ });
1118
+ var PostChildChatMessageRequestSchema = z.object({
1119
+ sessionId: z.string(),
1120
+ childTaskId: z.string(),
1121
+ message: z.string().min(1)
1122
+ });
1123
+ var UpdateChildStatusRequestSchema = z.object({
1124
+ sessionId: z.string(),
1125
+ childTaskId: z.string(),
1126
+ status: z.string()
1127
+ });
1128
+ var RegisterProjectAgentRequestSchema = z.object({
1129
+ projectId: z.string(),
1130
+ capabilities: z.array(z.string())
1131
+ });
1132
+ var ProjectRunnerHeartbeatRequestSchema = z.object({
1133
+ projectId: z.string()
1134
+ });
1135
+ var ReportProjectAgentStatusRequestSchema = z.object({
1136
+ projectId: z.string(),
1137
+ status: z.enum(["busy", "idle"]),
1138
+ activeChatId: z.string().nullish(),
1139
+ activeTaskId: z.string().nullish(),
1140
+ activeBranch: z.string().nullish()
1141
+ });
1142
+ var DisconnectProjectRunnerRequestSchema = z.object({
1143
+ projectId: z.string()
1144
+ });
1145
+ var GetProjectAgentContextRequestSchema = z.object({
1146
+ projectId: z.string()
1147
+ });
1148
+ var GetProjectChatHistoryRequestSchema = z.object({
1149
+ projectId: z.string(),
1150
+ limit: z.number().int().positive().optional().default(50),
1151
+ chatId: z.string().optional()
1152
+ });
1153
+ var PostProjectAgentMessageRequestSchema = z.object({
1154
+ projectId: z.string(),
1155
+ content: z.string().min(1),
1156
+ chatId: z.string().optional()
1157
+ });
1158
+ var ListProjectTasksRequestSchema = z.object({
1159
+ projectId: z.string(),
1160
+ status: z.string().optional(),
1161
+ assigneeId: z.string().optional(),
1162
+ limit: z.number().int().positive().optional().default(50)
1163
+ });
1164
+ var GetProjectTaskRequestSchema = z.object({
1165
+ projectId: z.string(),
1166
+ taskId: z.string()
1167
+ });
1168
+ var SearchProjectTasksRequestSchema = z.object({
1169
+ projectId: z.string(),
1170
+ tagNames: z.array(z.string()).optional(),
1171
+ searchQuery: z.string().optional(),
1172
+ statusFilters: z.array(z.string()).optional(),
1173
+ limit: z.number().int().positive().optional().default(20)
1174
+ });
1175
+ var ListProjectTagsRequestSchema = z.object({
1176
+ projectId: z.string()
1177
+ });
1178
+ var GetProjectSummaryRequestSchema = z.object({
1179
+ projectId: z.string()
1180
+ });
1181
+ var CreateProjectTaskRequestSchema = z.object({
1182
+ projectId: z.string(),
1183
+ title: z.string().min(1),
1184
+ description: z.string().optional(),
1185
+ plan: z.string().optional(),
1186
+ status: z.string().optional(),
1187
+ isBug: z.boolean().optional()
1188
+ });
1189
+ var UpdateProjectTaskRequestSchema = z.object({
1190
+ projectId: z.string(),
1191
+ taskId: z.string(),
1192
+ title: z.string().optional(),
1193
+ description: z.string().optional(),
1194
+ plan: z.string().optional(),
1195
+ status: z.string().optional(),
1196
+ assignedUserId: z.string().nullish()
1197
+ });
1198
+ var ReportProjectAgentEventRequestSchema = z.object({
1199
+ projectId: z.string(),
1200
+ event: z.record(z.string(), z.unknown())
1201
+ });
1202
+ var ReportTagAuditProgressRequestSchema = z.object({
1203
+ projectId: z.string(),
1204
+ requestId: z.string(),
1205
+ activity: z.object({
1206
+ tool: z.string(),
1207
+ input: z.string().optional(),
1208
+ timestamp: z.string()
1209
+ })
1210
+ });
1211
+ var ReportTagAuditResultRequestSchema = z.object({
1212
+ projectId: z.string(),
1213
+ requestId: z.string(),
1214
+ recommendations: z.array(z.record(z.string(), z.unknown())),
1215
+ summary: z.string(),
1216
+ complete: z.boolean()
1217
+ });
1218
+ var ReportNewCommitsDetectedRequestSchema = z.object({
1219
+ projectId: z.string(),
1220
+ commits: z.array(
1221
+ z.object({
1222
+ sha: z.string(),
1223
+ message: z.string(),
1224
+ author: z.string()
1225
+ })
1226
+ ),
1227
+ branch: z.string()
1228
+ });
1229
+ var ReportEnvironmentReadyRequestSchema = z.object({
1230
+ projectId: z.string(),
1231
+ branch: z.string(),
1232
+ setupComplete: z.boolean(),
1233
+ startCommandRunning: z.boolean()
1234
+ });
1235
+ var ReportEnvSwitchProgressRequestSchema = z.object({
1236
+ projectId: z.string(),
1237
+ step: z.string(),
1238
+ progress: z.number(),
1239
+ message: z.string().optional()
1240
+ });
1241
+ var ForwardProjectChatMessageRequestSchema = z.object({
1242
+ projectId: z.string(),
1243
+ chatId: z.string(),
1244
+ content: z.string().min(1),
1245
+ targetUserId: z.string().optional()
1246
+ });
1247
+ var CancelQueuedProjectMessageRequestSchema = z.object({
1248
+ projectId: z.string(),
1249
+ index: z.number().int().nonnegative()
1250
+ });
1251
+ var GetProjectCliHistoryRequestSchema = z.object({
1252
+ projectId: z.string(),
1253
+ limit: z.number().int().positive().optional().default(50),
1254
+ source: z.string().optional()
1255
+ });
1256
+ var PostToProjectTaskChatRequestSchema = z.object({
1257
+ projectId: z.string(),
1258
+ taskId: z.string(),
1259
+ content: z.string()
1260
+ });
1261
+ var GetProjectTaskCliRequestSchema = z.object({
1262
+ projectId: z.string(),
1263
+ taskId: z.string(),
1264
+ limit: z.number().int().positive().optional().default(50),
1265
+ source: z.string().optional()
1266
+ });
1267
+ var StartProjectBuildRequestSchema = z.object({
1268
+ projectId: z.string(),
1269
+ taskId: z.string()
1270
+ });
1271
+ var StopProjectBuildRequestSchema = z.object({
1272
+ projectId: z.string(),
1273
+ taskId: z.string()
1274
+ });
1275
+ var ApproveProjectMergePRRequestSchema = z.object({
1276
+ projectId: z.string(),
1277
+ childTaskId: z.string()
1278
+ });
1279
+ var GetAgentStatusRequestSchema = z.object({
1280
+ taskId: z.string()
1281
+ });
1282
+ var GetUiCliHistoryRequestSchema = z.object({
1283
+ taskId: z.string()
1284
+ });
1285
+ var SendSoftStopRequestSchema = z.object({
1286
+ taskId: z.string().optional(),
1287
+ projectId: z.string().optional()
1288
+ });
1289
+ var FlushTaskQueueRequestSchema = z.object({
1290
+ taskId: z.string()
1291
+ });
1292
+ var FlushProjectQueueRequestSchema = z.object({
1293
+ projectId: z.string()
1294
+ });
1295
+ var CancelTaskQueuedMessageRequestSchema = z.object({
1296
+ taskId: z.string(),
1297
+ messageId: z.string()
1298
+ });
1299
+ var FlushSingleQueuedMessageRequestSchema = z.object({
1300
+ taskId: z.string(),
1301
+ messageId: z.string()
1302
+ });
1303
+ var FlushSingleProjectQueuedMessageRequestSchema = z.object({
1304
+ projectId: z.string(),
1305
+ index: z.number().int().nonnegative()
1306
+ });
1307
+ var AnswerAgentQuestionRequestSchema = z.object({
1308
+ taskId: z.string(),
1309
+ requestId: z.string(),
1310
+ answers: z.record(z.string(), z.string())
1311
+ });
1312
+ var ClearAgentTodosRequestSchema = z.object({
1313
+ taskId: z.string()
1314
+ });
1315
+ var AgentQuestionOptionSchema = z.object({
1316
+ label: z.string(),
1317
+ description: z.string(),
1318
+ preview: z.string().optional()
1319
+ });
1320
+ var AgentQuestionSchema = z.object({
1321
+ question: z.string(),
1322
+ header: z.string(),
1323
+ options: z.array(AgentQuestionOptionSchema),
1324
+ multiSelect: z.boolean().optional()
1325
+ });
1326
+ var AskUserQuestionRequestSchema = z.object({
1327
+ sessionId: z.string(),
1328
+ question: z.string().min(1),
1329
+ requestId: z.string().min(1),
1330
+ questions: z.array(AgentQuestionSchema).min(1)
1331
+ });
1332
+ var RefreshGithubTokenRequestSchema = z.object({
1333
+ sessionId: z.string()
1334
+ });
1335
+ var RefreshGithubTokenResponseSchema = z.object({
1336
+ token: z.string()
1337
+ });
1338
+ var CreatePRResponseSchema = z.object({
1339
+ prNumber: z.number().int().positive(),
1340
+ prUrl: z.string().url()
1341
+ });
1342
+ var PostToChatResponseSchema = z.object({
1343
+ messageId: z.string()
1344
+ });
1345
+ var UpdateTaskStatusResponseSchema = z.object({
1346
+ taskId: z.string(),
1347
+ status: z.string()
1348
+ });
1349
+ var StoreSessionIdResponseSchema = z.object({
1350
+ success: z.boolean()
1351
+ });
1352
+ var HeartbeatResponseSchema = z.object({
1353
+ acknowledged: z.boolean()
1354
+ });
1355
+ var SessionStartResponseSchema = z.object({
1356
+ sessionId: z.string(),
1357
+ startedAt: z.string()
1358
+ });
1359
+ var SessionStopResponseSchema = z.object({
1360
+ sessionId: z.string(),
1361
+ stoppedAt: z.string()
1362
+ });
1363
+ var DeleteSubtaskResponseSchema = z.object({
1364
+ deleted: z.boolean()
1365
+ });
1366
+ var RegisterProjectAgentResponseSchema = z.object({
1367
+ registered: z.boolean(),
1368
+ agentName: z.string(),
1369
+ agentInstructions: z.string(),
1370
+ model: z.string(),
1371
+ agentSettings: z.record(z.string(), z.unknown()).nullable(),
1372
+ branchSwitchCommand: z.string().nullable()
1373
+ });
1374
+ var CRITICAL_AUTOMATED_SOURCES = /* @__PURE__ */ new Set(["ci_failure"]);
1375
+
882
1376
  // src/execution/pack-runner-prompt.ts
883
1377
  function findLastAgentMessageIndex(history) {
884
1378
  for (let i = history.length - 1; i >= 0; i--) {
@@ -1194,10 +1688,9 @@ function buildPropertyInstructions(context) {
1194
1688
  ``,
1195
1689
  `### Proactive Property Management`,
1196
1690
  `As you plan this task, proactively fill in task properties when you have enough context:`,
1197
- `- Use update_task_properties to set any combination of: title, story points, tags, and icon`,
1691
+ `- Use update_task_properties to set any combination of: title, story points, and tags`,
1198
1692
  `- You can update all properties at once or just one at a time as needed`,
1199
- `- For icons: FIRST call list_icons to check for existing matches, then use update_task_properties with iconId.`,
1200
- ` Only call generate_task_icon if no existing icon is a good fit.`,
1693
+ `- Icons are assigned automatically during identification \u2014 do not set icons manually`,
1201
1694
  ``,
1202
1695
  `Don't wait for the user to ask \u2014 fill these in naturally as the plan takes shape.`,
1203
1696
  `If the user adjusts the plan significantly, update the properties to match.`
@@ -1235,22 +1728,22 @@ function buildDiscoveryPrompt(context) {
1235
1728
  `- If you identify code changes needed, describe them in the plan instead of implementing them`,
1236
1729
  `- You can create and manage subtasks`,
1237
1730
  `- Goal: collaborate with the user to create a clear plan`,
1238
- `- Proactively fill task properties (SP, tags, icon) as the plan takes shape`,
1731
+ `- Proactively fill task properties (SP, tags) as the plan takes shape`,
1239
1732
  ``,
1240
1733
  `### Planning Checklist (complete ALL before calling ExitPlanMode)`,
1241
1734
  `Your PRIMARY goal is to create a thorough plan. Complete these steps in order:`,
1242
1735
  `1. Read the task description and chat history \u2014 respond to what's been discussed`,
1243
1736
  `2. Explore the codebase to understand relevant files and patterns`,
1244
1737
  `3. Save a detailed plan via \`update_task\``,
1245
- `4. Set story points, tags, and title via \`update_task_properties\``,
1738
+ `4. Set story points, tags, and title via \`update_task_properties\` (icon is set automatically)`,
1246
1739
  `5. Discuss the plan with the team if they're engaged, incorporate feedback`,
1247
1740
  `6. THEN call ExitPlanMode \u2014 it is the LAST step, not the first`,
1248
1741
  ``,
1249
1742
  `### Self-Identification Tools`,
1250
1743
  `Use these MCP tools to set your own task properties:`,
1251
1744
  `- \`update_task\` \u2014 save your plan and description`,
1252
- `- \`update_task_properties\` \u2014 set title, story points, tags, and icon (any combination)`,
1253
- `- \`generate_task_icon\` \u2014 generate a new icon if needed (call \`list_icons\` first)`,
1745
+ `- \`update_task_properties\` \u2014 set title, story points, and tags (any combination)`,
1746
+ `Note: Icons are assigned automatically during identification after planning is complete.`,
1254
1747
  ``,
1255
1748
  `### Tags & Context`,
1256
1749
  `- Early in discovery, identify relevant project tags that match this task's domain`,
@@ -1467,6 +1960,9 @@ function buildCodeReviewPrompt() {
1467
1960
  `- Explain what's wrong and suggest fixes`,
1468
1961
  `- Focus on substantive issues, not style nitpicks (linting handles that)`,
1469
1962
  ``,
1963
+ `## Previous Review Feedback`,
1964
+ `If previous review feedback is present in the chat history, verify those specific issues were addressed before raising new concerns. Focus on whether the requested changes were implemented correctly.`,
1965
+ ``,
1470
1966
  `## Rules`,
1471
1967
  `- You are READ-ONLY. Do NOT modify any files.`,
1472
1968
  `- Do NOT re-review things CI already validates (formatting, lint rules).`,
@@ -2070,7 +2566,7 @@ async function buildInitialPrompt(mode, context, isAuto, agentMode) {
2070
2566
  }
2071
2567
 
2072
2568
  // src/tools/common-tools.ts
2073
- import { z } from "zod";
2569
+ import { z as z2 } from "zod";
2074
2570
 
2075
2571
  // src/tools/helpers.ts
2076
2572
  function textResult(text) {
@@ -2104,8 +2600,8 @@ function buildReadTaskChatTool(connection) {
2104
2600
  "read_task_chat",
2105
2601
  "Read recent messages from a task chat. Omit task_id to read the current task's chat, or provide a child task ID to read a child's chat.",
2106
2602
  {
2107
- limit: z.number().optional().describe("Number of recent messages to fetch (default 20)"),
2108
- task_id: z.string().optional().describe("Child task ID to read chat from. Omit to read the current task's chat.")
2603
+ limit: z2.number().optional().describe("Number of recent messages to fetch (default 20)"),
2604
+ task_id: z2.string().optional().describe("Child task ID to read chat from. Omit to read the current task's chat.")
2109
2605
  },
2110
2606
  async ({ limit, task_id }) => {
2111
2607
  try {
@@ -2149,7 +2645,7 @@ function buildGetTaskTool(connection) {
2149
2645
  "get_task",
2150
2646
  "Look up a task by slug or ID to get its title, description, plan, and status",
2151
2647
  {
2152
- slug_or_id: z.string().describe("The task slug (e.g. 'my-task') or CUID")
2648
+ slug_or_id: z2.string().describe("The task slug (e.g. 'my-task') or CUID")
2153
2649
  },
2154
2650
  async ({ slug_or_id }) => {
2155
2651
  try {
@@ -2172,9 +2668,9 @@ function buildGetTaskCliTool(connection) {
2172
2668
  "get_task_cli",
2173
2669
  "Read CLI execution logs from a task. Returns agent reasoning, tool calls, setup output, and other execution events. Use 'source' to filter: 'agent' for agent reasoning/tool calls only, 'application' for setup/dev-server output only.",
2174
2670
  {
2175
- task_id: z.string().optional().describe("Task ID or slug. Omit to read logs from the current task."),
2176
- source: z.enum(["agent", "application"]).optional().describe("Filter by log source. Omit for all logs."),
2177
- limit: z.number().optional().describe("Max number of log entries to return (default 50, max 500).")
2671
+ task_id: z2.string().optional().describe("Task ID or slug. Omit to read logs from the current task."),
2672
+ source: z2.enum(["agent", "application"]).optional().describe("Filter by log source. Omit for all logs."),
2673
+ limit: z2.number().optional().describe("Max number of log entries to return (default 50, max 500).")
2178
2674
  },
2179
2675
  async ({ task_id, source, limit }) => {
2180
2676
  try {
@@ -2234,7 +2730,7 @@ function buildGetTaskFileTool(connection) {
2234
2730
  return defineTool(
2235
2731
  "get_task_file",
2236
2732
  "Get a specific task file's content and download URL by file ID",
2237
- { fileId: z.string().describe("The file ID to retrieve") },
2733
+ { fileId: z2.string().describe("The file ID to retrieve") },
2238
2734
  async ({ fileId }) => {
2239
2735
  try {
2240
2736
  const file = await connection.call("getTaskFile", {
@@ -2265,8 +2761,8 @@ function buildSearchIncidentsTool(connection) {
2265
2761
  "search_incidents",
2266
2762
  "Search incidents in the current project. Optionally filter by status (Open, Acknowledged, Investigating, Resolved, Closed) or source.",
2267
2763
  {
2268
- status: z.string().optional().describe("Filter by incident status"),
2269
- source: z.string().optional().describe("Filter by source (e.g., 'conveyor', 'agent', 'build')")
2764
+ status: z2.string().optional().describe("Filter by incident status"),
2765
+ source: z2.string().optional().describe("Filter by source (e.g., 'conveyor', 'agent', 'build')")
2270
2766
  },
2271
2767
  async ({ status, source }) => {
2272
2768
  try {
@@ -2290,7 +2786,7 @@ function buildGetTaskIncidentsTool(connection) {
2290
2786
  "get_task_incidents",
2291
2787
  "Get all incidents linked to the current task (or a specified task). Returns full incident details including title, description, severity, status, and source.",
2292
2788
  {
2293
- task_id: z.string().optional().describe("Task ID (defaults to current task)")
2789
+ task_id: z2.string().optional().describe("Task ID (defaults to current task)")
2294
2790
  },
2295
2791
  async ({ task_id }) => {
2296
2792
  try {
@@ -2313,12 +2809,12 @@ function buildQueryGcpLogsTool(connection) {
2313
2809
  "query_gcp_logs",
2314
2810
  "Query GCP Cloud Logging for the current project. Returns log entries matching the given filters. Use severity to filter by minimum log level. The project's GCP credentials are used automatically.",
2315
2811
  {
2316
- filter: z.string().optional().describe(
2812
+ filter: z2.string().optional().describe(
2317
2813
  `Cloud Logging filter expression (e.g., 'resource.type="gce_instance"'). Max 1000 chars.`
2318
2814
  ),
2319
- start_time: z.string().optional().describe("Start time in ISO 8601 format (e.g., '2024-01-01T00:00:00Z')"),
2320
- end_time: z.string().optional().describe("End time in ISO 8601 format (e.g., '2024-01-02T00:00:00Z')"),
2321
- severity: z.enum([
2815
+ start_time: z2.string().optional().describe("Start time in ISO 8601 format (e.g., '2024-01-01T00:00:00Z')"),
2816
+ end_time: z2.string().optional().describe("End time in ISO 8601 format (e.g., '2024-01-02T00:00:00Z')"),
2817
+ severity: z2.enum([
2322
2818
  "DEFAULT",
2323
2819
  "DEBUG",
2324
2820
  "INFO",
@@ -2329,7 +2825,7 @@ function buildQueryGcpLogsTool(connection) {
2329
2825
  "ALERT",
2330
2826
  "EMERGENCY"
2331
2827
  ]).optional().describe("Minimum severity level to filter by (default: all levels)"),
2332
- page_size: z.number().optional().describe("Number of log entries to return (default 100, max 500)")
2828
+ page_size: z2.number().optional().describe("Number of log entries to return (default 100, max 500)")
2333
2829
  },
2334
2830
  async ({ filter, start_time, end_time, severity, page_size }) => {
2335
2831
  try {
@@ -2383,8 +2879,8 @@ function buildGetSuggestionsTool(connection) {
2383
2879
  "get_suggestions",
2384
2880
  "List project suggestions sorted by vote score. Use this to see what the team thinks is important.",
2385
2881
  {
2386
- status: z.string().optional().describe("Filter by status: Open, Accepted, Rejected, Implemented"),
2387
- limit: z.number().optional().describe("Max results (default 20)")
2882
+ status: z2.string().optional().describe("Filter by status: Open, Accepted, Rejected, Implemented"),
2883
+ limit: z2.number().optional().describe("Max results (default 20)")
2388
2884
  },
2389
2885
  async ({ status: _status, limit: _limit }) => {
2390
2886
  try {
@@ -2409,8 +2905,8 @@ function buildPostToChatTool(connection) {
2409
2905
  "post_to_chat",
2410
2906
  "Post a message to a task chat. Your normal replies already appear in chat \u2014 only use this for explicit out-of-band updates or posting to a child task's chat.",
2411
2907
  {
2412
- message: z.string().describe("The message to post to the team"),
2413
- task_id: z.string().optional().describe("Child task ID to post to. Omit to post to the current task's chat.")
2908
+ message: z2.string().describe("The message to post to the team"),
2909
+ task_id: z2.string().optional().describe("Child task ID to post to. Omit to post to the current task's chat.")
2414
2910
  },
2415
2911
  async ({ message, task_id }) => {
2416
2912
  try {
@@ -2437,8 +2933,8 @@ function buildForceUpdateTaskStatusTool(connection) {
2437
2933
  "force_update_task_status",
2438
2934
  "EMERGENCY ONLY: Force-override a task's Kanban status. Status transitions happen automatically (building sets InProgress, PR creation sets ReviewPR, merge sets ReviewDev). Only use this if an automatic transition failed or a task is stuck in the wrong status. Omit task_id to update the current task, or provide a child task ID.",
2439
2935
  {
2440
- status: z.enum(["InProgress", "ReviewPR", "ReviewDev", "Complete"]).describe("The new status for the task"),
2441
- task_id: z.string().optional().describe("Child task ID to update. Omit to update the current task.")
2936
+ status: z2.enum(["InProgress", "ReviewPR", "ReviewDev", "Complete"]).describe("The new status for the task"),
2937
+ task_id: z2.string().optional().describe("Child task ID to update. Omit to update the current task.")
2442
2938
  },
2443
2939
  async ({ status, task_id }) => {
2444
2940
  try {
@@ -2469,15 +2965,15 @@ function buildCreatePullRequestTool(connection, config) {
2469
2965
  "create_pull_request",
2470
2966
  "Create a GitHub pull request for this task. Automatically stages uncommitted changes, commits them, and pushes before creating the PR. Use this instead of gh CLI or git commands to create PRs.",
2471
2967
  {
2472
- title: z.string().describe("The PR title"),
2473
- body: z.string().describe("The PR description/body in markdown"),
2474
- branch: z.string().optional().describe(
2968
+ title: z2.string().describe("The PR title"),
2969
+ body: z2.string().describe("The PR description/body in markdown"),
2970
+ branch: z2.string().optional().describe(
2475
2971
  "The head branch name for the PR. If the task doesn't have a branch set, this will be used. Defaults to the task's existing branch."
2476
2972
  ),
2477
- baseBranch: z.string().optional().describe(
2973
+ baseBranch: z2.string().optional().describe(
2478
2974
  "The base branch to target for the PR (e.g. 'main', 'develop'). Defaults to the project's configured dev branch."
2479
2975
  ),
2480
- commitMessage: z.string().optional().describe(
2976
+ commitMessage: z2.string().optional().describe(
2481
2977
  "Commit message for staging uncommitted changes. If not provided, a default message based on the PR title will be used."
2482
2978
  )
2483
2979
  },
@@ -2555,7 +3051,7 @@ function buildAddDependencyTool(connection) {
2555
3051
  "add_dependency",
2556
3052
  "Add a dependency \u2014 this task cannot start until the specified task is merged to dev",
2557
3053
  {
2558
- depends_on_slug_or_id: z.string().describe("Slug or ID of the task this task depends on")
3054
+ depends_on_slug_or_id: z2.string().describe("Slug or ID of the task this task depends on")
2559
3055
  },
2560
3056
  async ({ depends_on_slug_or_id }) => {
2561
3057
  try {
@@ -2577,7 +3073,7 @@ function buildRemoveDependencyTool(connection) {
2577
3073
  "remove_dependency",
2578
3074
  "Remove a dependency from this task",
2579
3075
  {
2580
- depends_on_slug_or_id: z.string().describe("Slug or ID of the task to remove as dependency")
3076
+ depends_on_slug_or_id: z2.string().describe("Slug or ID of the task to remove as dependency")
2581
3077
  },
2582
3078
  async ({ depends_on_slug_or_id }) => {
2583
3079
  try {
@@ -2599,10 +3095,10 @@ function buildCreateFollowUpTaskTool(connection) {
2599
3095
  "create_follow_up_task",
2600
3096
  "Create a follow-up task in this project that depends on the current task. Use for out-of-scope work, v1.1 features, or cleanup that should happen after this task merges.",
2601
3097
  {
2602
- title: z.string().describe("Follow-up task title"),
2603
- description: z.string().optional().describe("Brief description of the follow-up work"),
2604
- plan: z.string().optional().describe("Implementation plan if known"),
2605
- story_point_value: z.number().optional().describe("Story point estimate (1=Common, 2=Magic, 3=Rare, 5=Unique)")
3098
+ title: z2.string().describe("Follow-up task title"),
3099
+ description: z2.string().optional().describe("Brief description of the follow-up work"),
3100
+ plan: z2.string().optional().describe("Implementation plan if known"),
3101
+ story_point_value: z2.number().optional().describe("Story point estimate (1=Common, 2=Magic, 3=Rare, 5=Unique)")
2606
3102
  },
2607
3103
  async ({ title, description, plan, story_point_value }) => {
2608
3104
  try {
@@ -2629,9 +3125,9 @@ function buildCreateSuggestionTool(connection) {
2629
3125
  "create_suggestion",
2630
3126
  "Suggest a feature, improvement, or idea for the project. If you want to recommend something \u2014 a document, a rule, a feature, a task, an optimization \u2014 use this tool. If a similar suggestion already exists, your vote will be added to it instead of creating a duplicate.",
2631
3127
  {
2632
- title: z.string().describe("Short title for the suggestion"),
2633
- description: z.string().optional().describe("Details about the suggestion"),
2634
- tag_names: z.array(z.string()).optional().describe("Tag names to categorize the suggestion")
3128
+ title: z2.string().describe("Short title for the suggestion"),
3129
+ description: z2.string().optional().describe("Details about the suggestion"),
3130
+ tag_names: z2.array(z2.string()).optional().describe("Tag names to categorize the suggestion")
2635
3131
  },
2636
3132
  async ({ title, description, tag_names }) => {
2637
3133
  try {
@@ -2660,8 +3156,8 @@ function buildVoteSuggestionTool(connection) {
2660
3156
  "vote_suggestion",
2661
3157
  "Vote on a project suggestion. Use +1 to upvote or -1 to downvote.",
2662
3158
  {
2663
- suggestion_id: z.string().describe("The suggestion ID to vote on"),
2664
- value: z.number().refine((v) => v === 1 || v === -1, { message: "Value must be 1 or -1" }).describe("+1 to upvote, -1 to downvote")
3159
+ suggestion_id: z2.string().describe("The suggestion ID to vote on"),
3160
+ value: z2.number().refine((v) => v === 1 || v === -1, { message: "Value must be 1 or -1" }).describe("+1 to upvote, -1 to downvote")
2665
3161
  },
2666
3162
  async ({ suggestion_id, value }) => {
2667
3163
  try {
@@ -2684,8 +3180,8 @@ function buildScaleUpResourcesTool(connection) {
2684
3180
  "scale_up_resources",
2685
3181
  "Scale up the pod's CPU and memory resources. Use before running dev servers, tests, builds, or other resource-intensive operations. Phases: 'setup' (installs, basic dev servers), 'build' (full dev servers, test suites, typecheck, builds). Actual CPU/memory values are configured per-project. Scaling is one-way (up only).",
2686
3182
  {
2687
- tier: z.enum(["initial", "setup", "build"]).describe("The resource phase to scale up to"),
2688
- reason: z.string().optional().describe("Brief reason for scaling (e.g., 'running test suite')")
3183
+ tier: z2.enum(["initial", "setup", "build"]).describe("The resource phase to scale up to"),
3184
+ reason: z2.string().optional().describe("Brief reason for scaling (e.g., 'running test suite')")
2689
3185
  },
2690
3186
  async ({ tier, reason }) => {
2691
3187
  try {
@@ -2738,15 +3234,15 @@ function buildCommonTools(connection, config) {
2738
3234
  }
2739
3235
 
2740
3236
  // src/tools/pm-tools.ts
2741
- import { z as z2 } from "zod";
3237
+ import { z as z3 } from "zod";
2742
3238
  var SP_DESCRIPTION = "Story point value (1=Common, 2=Magic, 3=Rare, 5=Unique)";
2743
3239
  function buildUpdateTaskTool(connection) {
2744
3240
  return defineTool(
2745
3241
  "update_task",
2746
3242
  "Save the finalized task plan and/or description",
2747
3243
  {
2748
- plan: z2.string().optional().describe("The task plan in markdown"),
2749
- description: z2.string().optional().describe("Updated task description")
3244
+ plan: z3.string().optional().describe("The task plan in markdown"),
3245
+ description: z3.string().optional().describe("Updated task description")
2750
3246
  },
2751
3247
  async ({ plan, description }) => {
2752
3248
  try {
@@ -2767,11 +3263,11 @@ function buildCreateSubtaskTool(connection) {
2767
3263
  "create_subtask",
2768
3264
  "Create a subtask under the current parent task. Use for breaking complex tasks into smaller pieces.",
2769
3265
  {
2770
- title: z2.string().describe("Subtask title"),
2771
- description: z2.string().optional().describe("Brief description"),
2772
- plan: z2.string().optional().describe("Implementation plan in markdown"),
2773
- ordinal: z2.number().optional().describe("Step/order number (0-based)"),
2774
- storyPointValue: z2.number().optional().describe(SP_DESCRIPTION)
3266
+ title: z3.string().describe("Subtask title"),
3267
+ description: z3.string().optional().describe("Brief description"),
3268
+ plan: z3.string().optional().describe("Implementation plan in markdown"),
3269
+ ordinal: z3.number().optional().describe("Step/order number (0-based)"),
3270
+ storyPointValue: z3.number().optional().describe(SP_DESCRIPTION)
2775
3271
  },
2776
3272
  async ({ title, description, plan, ordinal, storyPointValue }) => {
2777
3273
  try {
@@ -2797,12 +3293,12 @@ function buildUpdateSubtaskTool(connection) {
2797
3293
  "update_subtask",
2798
3294
  "Update an existing subtask's fields",
2799
3295
  {
2800
- subtaskId: z2.string().describe("The subtask ID to update"),
2801
- title: z2.string().optional(),
2802
- description: z2.string().optional(),
2803
- plan: z2.string().optional(),
2804
- ordinal: z2.number().optional(),
2805
- storyPointValue: z2.number().optional().describe(SP_DESCRIPTION)
3296
+ subtaskId: z3.string().describe("The subtask ID to update"),
3297
+ title: z3.string().optional(),
3298
+ description: z3.string().optional(),
3299
+ plan: z3.string().optional(),
3300
+ ordinal: z3.number().optional(),
3301
+ storyPointValue: z3.number().optional().describe(SP_DESCRIPTION)
2806
3302
  },
2807
3303
  async ({ subtaskId, title, description, plan, storyPointValue }) => {
2808
3304
  try {
@@ -2825,7 +3321,7 @@ function buildDeleteSubtaskTool(connection) {
2825
3321
  return defineTool(
2826
3322
  "delete_subtask",
2827
3323
  "Delete a subtask",
2828
- { subtaskId: z2.string().describe("The subtask ID to delete") },
3324
+ { subtaskId: z3.string().describe("The subtask ID to delete") },
2829
3325
  async ({ subtaskId }) => {
2830
3326
  try {
2831
3327
  await connection.call("deleteSubtask", {
@@ -2863,7 +3359,7 @@ function buildPackTools(connection) {
2863
3359
  "start_child_cloud_build",
2864
3360
  "Start a cloud build for a child task. The child must be in Open status with story points and an agent assigned.",
2865
3361
  {
2866
- childTaskId: z2.string().describe("The child task ID to start a cloud build for")
3362
+ childTaskId: z3.string().describe("The child task ID to start a cloud build for")
2867
3363
  },
2868
3364
  async ({ childTaskId }) => {
2869
3365
  try {
@@ -2883,7 +3379,7 @@ function buildPackTools(connection) {
2883
3379
  "stop_child_build",
2884
3380
  "Stop a running cloud build for a child task. Sends a stop signal to the child agent.",
2885
3381
  {
2886
- childTaskId: z2.string().describe("The child task ID whose build should be stopped")
3382
+ childTaskId: z3.string().describe("The child task ID whose build should be stopped")
2887
3383
  },
2888
3384
  async ({ childTaskId }) => {
2889
3385
  try {
@@ -2903,7 +3399,7 @@ function buildPackTools(connection) {
2903
3399
  "approve_and_merge_pr",
2904
3400
  "Approve and merge a child task's pull request. Only succeeds if all CI/CD checks are passing. Returns an error if checks are pending (retry after waiting) or failed (investigate). The child task must be in ReviewPR status.",
2905
3401
  {
2906
- childTaskId: z2.string().describe("The child task ID whose PR should be approved and merged")
3402
+ childTaskId: z3.string().describe("The child task ID whose PR should be approved and merged")
2907
3403
  },
2908
3404
  async ({ childTaskId }) => {
2909
3405
  try {
@@ -2941,119 +3437,31 @@ function buildPmTools(connection, options) {
2941
3437
  }
2942
3438
 
2943
3439
  // src/tools/discovery-tools.ts
2944
- import { z as z3 } from "zod";
3440
+ import { z as z4 } from "zod";
2945
3441
  var SP_DESCRIPTION2 = "Story point value (1=Common, 2=Magic, 3=Rare, 5=Unique)";
2946
- function buildSearchIconsTool(connection) {
2947
- return defineTool(
2948
- "search_icons",
2949
- "Search for icons by keyword. Searches both the Conveyor database (existing icons) and FontAwesome library (~2200 icons). Returns matching icons with IDs and preview info. Use this to find an icon before generating one.",
2950
- {
2951
- query: z3.string().describe("Search query for icon name or keyword (e.g. 'bug', 'gear', 'star')")
2952
- },
2953
- async ({ query }) => {
2954
- try {
2955
- const [dbIcons, faIcons] = await Promise.all([
2956
- connection.call("listIcons", { sessionId: connection.sessionId }),
2957
- connection.call("searchFaIcons", { sessionId: connection.sessionId, query })
2958
- ]);
2959
- const q = query.toLowerCase();
2960
- const matchingDbIcons = dbIcons.filter((icon) => icon.name.toLowerCase().includes(q));
2961
- const dbFaIds = new Set(matchingDbIcons.map((i) => i.name));
2962
- const uniqueFaIcons = faIcons.filter((fa) => !dbFaIds.has(fa.fontAwesomeId));
2963
- const results = {
2964
- existingIcons: matchingDbIcons.map((i) => ({
2965
- id: i.id,
2966
- name: i.name,
2967
- source: "database"
2968
- })),
2969
- fontAwesomeIcons: uniqueFaIcons.map((fa) => ({
2970
- fontAwesomeId: fa.fontAwesomeId,
2971
- label: fa.label,
2972
- styles: fa.styles,
2973
- source: "fontawesome"
2974
- }))
2975
- };
2976
- return textResult(JSON.stringify(results, null, 2));
2977
- } catch (error) {
2978
- const message = error instanceof Error ? error.message : "Unknown error";
2979
- return textResult(`Failed to search icons: ${message}`);
2980
- }
2981
- },
2982
- { annotations: { readOnlyHint: true } }
2983
- );
2984
- }
2985
- function buildIconTools(connection) {
2986
- return [
2987
- defineTool(
2988
- "list_icons",
2989
- "List available icons (default library + user-created). Returns icon IDs, names, and whether they're defaults. Call this FIRST before update_task_properties to check for existing matches.",
2990
- {},
2991
- async () => {
2992
- try {
2993
- const icons = await connection.call("listIcons", {
2994
- sessionId: connection.sessionId
2995
- });
2996
- return textResult(JSON.stringify(icons, null, 2));
2997
- } catch (error) {
2998
- return textResult(
2999
- `Failed to list icons: ${error instanceof Error ? error.message : "Unknown error"}`
3000
- );
3001
- }
3002
- },
3003
- { annotations: { readOnlyHint: true } }
3004
- ),
3005
- defineTool(
3006
- "generate_task_icon",
3007
- "Find a FontAwesome icon matching the description and assign it to this task. Falls back to a placeholder if no match is found. Provide a concise keyword or description.",
3008
- {
3009
- prompt: z3.string().describe(
3010
- "Keyword or description to search FontAwesome icons (e.g. 'bug', 'gear', 'rocket')"
3011
- ),
3012
- aspectRatio: z3.enum(["auto", "portrait", "landscape", "square"]).optional().describe("Icon aspect ratio, defaults to square")
3013
- },
3014
- async ({ prompt, aspectRatio }) => {
3015
- try {
3016
- const result = await connection.call("generateTaskIcon", {
3017
- sessionId: connection.sessionId,
3018
- prompt,
3019
- aspectRatio: aspectRatio ?? "square"
3020
- });
3021
- return textResult(`Icon generated and assigned: ${result.iconId}`);
3022
- } catch (error) {
3023
- return textResult(
3024
- `Failed to generate icon: ${error instanceof Error ? error.message : "Unknown error"}`
3025
- );
3026
- }
3027
- }
3028
- )
3029
- ];
3030
- }
3031
3442
  function buildDiscoveryTools(connection) {
3032
3443
  return [
3033
3444
  defineTool(
3034
3445
  "update_task_properties",
3035
3446
  "Set one or more task properties in a single call. All fields are optional \u2014 only include the fields you want to update.",
3036
3447
  {
3037
- title: z3.string().optional().describe("The new task title"),
3038
- storyPointValue: z3.number().optional().describe(SP_DESCRIPTION2),
3039
- tagIds: z3.array(z3.string()).optional().describe("Array of tag IDs to assign"),
3040
- iconId: z3.string().optional().describe("Icon ID to assign (use list_icons first)")
3448
+ title: z4.string().optional().describe("The new task title"),
3449
+ storyPointValue: z4.number().optional().describe(SP_DESCRIPTION2),
3450
+ tagIds: z4.array(z4.string()).optional().describe("Array of tag IDs to assign")
3041
3451
  },
3042
- async ({ title, storyPointValue, tagIds, iconId }) => {
3452
+ async ({ title, storyPointValue, tagIds }) => {
3043
3453
  try {
3044
3454
  await connection.call("updateTaskProperties", {
3045
3455
  sessionId: connection.sessionId,
3046
3456
  title,
3047
3457
  storyPointValue,
3048
- tagIds,
3049
- iconId
3458
+ tagIds
3050
3459
  });
3051
3460
  const updatedFields = [];
3052
3461
  if (title !== void 0) updatedFields.push(`title to "${title}"`);
3053
3462
  if (storyPointValue !== void 0)
3054
3463
  updatedFields.push(`story points to ${storyPointValue}`);
3055
3464
  if (tagIds !== void 0) updatedFields.push(`tags (${tagIds.length} tag(s))`);
3056
- if (iconId !== void 0) updatedFields.push(`icon`);
3057
3465
  return textResult(`Task properties updated: ${updatedFields.join(", ")}`);
3058
3466
  } catch (error) {
3059
3467
  return textResult(
@@ -3061,21 +3469,19 @@ function buildDiscoveryTools(connection) {
3061
3469
  );
3062
3470
  }
3063
3471
  }
3064
- ),
3065
- buildSearchIconsTool(connection),
3066
- ...buildIconTools(connection)
3472
+ )
3067
3473
  ];
3068
3474
  }
3069
3475
 
3070
3476
  // src/tools/code-review-tools.ts
3071
- import { z as z4 } from "zod";
3477
+ import { z as z5 } from "zod";
3072
3478
  function buildCodeReviewTools(connection) {
3073
3479
  return [
3074
3480
  defineTool(
3075
3481
  "approve_code_review",
3076
3482
  "Approve the code review. Use this when the code passes all review criteria and is ready to merge.",
3077
3483
  {
3078
- summary: z4.string().describe("Brief summary of what was reviewed and why it looks good")
3484
+ summary: z5.string().describe("Brief summary of what was reviewed and why it looks good")
3079
3485
  },
3080
3486
  async ({ summary }) => {
3081
3487
  const content = `**Code Review: Approved** :white_check_mark:
@@ -3098,15 +3504,15 @@ ${summary}`;
3098
3504
  "request_code_changes",
3099
3505
  "Request changes during code review. Use this when substantive issues are found that need to be fixed before merge.",
3100
3506
  {
3101
- issues: z4.array(
3102
- z4.object({
3103
- file: z4.string().describe("File path where the issue was found"),
3104
- line: z4.number().optional().describe("Line number (if applicable)"),
3105
- severity: z4.enum(["critical", "major", "minor"]).describe("Issue severity"),
3106
- description: z4.string().describe("What is wrong and how to fix it")
3507
+ issues: z5.array(
3508
+ z5.object({
3509
+ file: z5.string().describe("File path where the issue was found"),
3510
+ line: z5.number().optional().describe("Line number (if applicable)"),
3511
+ severity: z5.enum(["critical", "major", "minor"]).describe("Issue severity"),
3512
+ description: z5.string().describe("What is wrong and how to fix it")
3107
3513
  })
3108
3514
  ).describe("List of issues found during review"),
3109
- summary: z4.string().describe("Brief overall summary of the review findings")
3515
+ summary: z5.string().describe("Brief overall summary of the review findings")
3110
3516
  },
3111
3517
  async ({ issues, summary }) => {
3112
3518
  const issueLines = issues.map((issue) => {
@@ -3136,10 +3542,10 @@ ${issueLines}`;
3136
3542
  }
3137
3543
 
3138
3544
  // src/tools/debug-tools.ts
3139
- import { z as z7 } from "zod";
3545
+ import { z as z8 } from "zod";
3140
3546
 
3141
3547
  // src/tools/telemetry-tools.ts
3142
- import { z as z5 } from "zod";
3548
+ import { z as z6 } from "zod";
3143
3549
 
3144
3550
  // src/debug/telemetry-injector.ts
3145
3551
  var BUFFER_SIZE = 200;
@@ -3534,12 +3940,12 @@ function buildGetTelemetryTool(manager) {
3534
3940
  "debug_get_telemetry",
3535
3941
  "Query structured telemetry events (HTTP requests, database queries, Socket.IO events, errors) captured from the running dev server. Returns filtered, structured data instead of raw logs.",
3536
3942
  {
3537
- type: z5.enum(["http", "db", "socket", "error"]).optional().describe("Filter by event type"),
3538
- urlPattern: z5.string().optional().describe("Regex pattern to filter HTTP events by URL"),
3539
- minDuration: z5.number().optional().describe("Minimum duration in ms \u2014 only return events slower than this"),
3540
- errorOnly: z5.boolean().optional().describe("Only return error events and HTTP 4xx/5xx responses"),
3541
- since: z5.number().optional().describe("Only return events after this timestamp (ms since epoch)"),
3542
- limit: z5.number().optional().describe("Max events to return (default: 20, from most recent)")
3943
+ type: z6.enum(["http", "db", "socket", "error"]).optional().describe("Filter by event type"),
3944
+ urlPattern: z6.string().optional().describe("Regex pattern to filter HTTP events by URL"),
3945
+ minDuration: z6.number().optional().describe("Minimum duration in ms \u2014 only return events slower than this"),
3946
+ errorOnly: z6.boolean().optional().describe("Only return error events and HTTP 4xx/5xx responses"),
3947
+ since: z6.number().optional().describe("Only return events after this timestamp (ms since epoch)"),
3948
+ limit: z6.number().optional().describe("Max events to return (default: 20, from most recent)")
3543
3949
  },
3544
3950
  async ({ type, urlPattern, minDuration, errorOnly, since, limit }) => {
3545
3951
  const clientOrErr = requireDebugClient(manager);
@@ -3609,7 +4015,7 @@ function buildTelemetryTools(manager) {
3609
4015
  }
3610
4016
 
3611
4017
  // src/tools/client-debug-tools.ts
3612
- import { z as z6 } from "zod";
4018
+ import { z as z7 } from "zod";
3613
4019
  function requirePlaywrightClient(manager) {
3614
4020
  if (!manager.isClientDebugMode()) {
3615
4021
  return "Client debug mode is not active. Use debug_enter_mode with clientSide: true first.";
@@ -3629,11 +4035,11 @@ function buildClientBreakpointTools(manager) {
3629
4035
  "debug_set_client_breakpoint",
3630
4036
  "Set a breakpoint in client-side code running in the headless Chromium browser. V8 resolves source maps automatically, so original .tsx/.ts file paths work. Use this for React components, client utilities, and browser-side code.",
3631
4037
  {
3632
- file: z6.string().describe(
4038
+ file: z7.string().describe(
3633
4039
  "Original source file path (e.g., src/components/App.tsx) \u2014 source maps resolve automatically"
3634
4040
  ),
3635
- line: z6.number().describe("Line number (1-based) in the original source file"),
3636
- condition: z6.string().optional().describe("JavaScript condition expression \u2014 breakpoint only triggers when truthy")
4041
+ line: z7.number().describe("Line number (1-based) in the original source file"),
4042
+ condition: z7.string().optional().describe("JavaScript condition expression \u2014 breakpoint only triggers when truthy")
3637
4043
  },
3638
4044
  async ({ file, line, condition }) => {
3639
4045
  const clientOrErr = requirePlaywrightClient(manager);
@@ -3655,7 +4061,7 @@ Breakpoint ID: ${breakpointId}${sourceMapNote}`
3655
4061
  "debug_remove_client_breakpoint",
3656
4062
  "Remove a previously set client-side breakpoint by its ID.",
3657
4063
  {
3658
- breakpointId: z6.string().describe("The breakpoint ID returned by debug_set_client_breakpoint")
4064
+ breakpointId: z7.string().describe("The breakpoint ID returned by debug_set_client_breakpoint")
3659
4065
  },
3660
4066
  async ({ breakpointId }) => {
3661
4067
  const clientOrErr = requirePlaywrightClient(manager);
@@ -3735,8 +4141,8 @@ ${JSON.stringify(queuedHits, null, 2)}`
3735
4141
  "debug_evaluate_client",
3736
4142
  "Evaluate a JavaScript expression in the client-side browser context. When paused at a client breakpoint, evaluates in the paused scope. Can access DOM, window, React internals, etc.",
3737
4143
  {
3738
- expression: z6.string().describe("JavaScript expression to evaluate in the browser context"),
3739
- frameIndex: z6.number().optional().describe("Call stack frame index (0 = top frame). Defaults to the top frame.")
4144
+ expression: z7.string().describe("JavaScript expression to evaluate in the browser context"),
4145
+ frameIndex: z7.number().optional().describe("Call stack frame index (0 = top frame). Defaults to the top frame.")
3740
4146
  },
3741
4147
  async ({ expression, frameIndex }) => {
3742
4148
  const clientOrErr = requirePlaywrightClient(manager);
@@ -3809,7 +4215,7 @@ function buildClientInteractionTools(manager) {
3809
4215
  "debug_navigate_client",
3810
4216
  "Navigate the headless browser to a specific URL. Use this to reproduce specific flows or visit different pages.",
3811
4217
  {
3812
- url: z6.string().describe("URL to navigate to (e.g., http://localhost:3000/dashboard)")
4218
+ url: z7.string().describe("URL to navigate to (e.g., http://localhost:3000/dashboard)")
3813
4219
  },
3814
4220
  async ({ url }) => {
3815
4221
  const clientOrErr = requirePlaywrightClient(manager);
@@ -3826,7 +4232,7 @@ function buildClientInteractionTools(manager) {
3826
4232
  "debug_click_client",
3827
4233
  "Click an element on the page in the headless browser. Use CSS selectors to target elements. Useful for reproducing bugs by interacting with the UI programmatically.",
3828
4234
  {
3829
- selector: z6.string().describe(
4235
+ selector: z7.string().describe(
3830
4236
  "CSS selector of the element to click (e.g., 'button.submit', '#login-form input[type=submit]')"
3831
4237
  )
3832
4238
  },
@@ -3848,8 +4254,8 @@ function buildClientConsoleTool(manager) {
3848
4254
  "debug_get_client_console",
3849
4255
  "Get console messages captured from the headless browser. Includes console.log, warn, error, etc.",
3850
4256
  {
3851
- level: z6.string().optional().describe("Filter by console level: log, warn, error, info, debug"),
3852
- limit: z6.number().optional().describe("Maximum number of recent messages to return (default: all)")
4257
+ level: z7.string().optional().describe("Filter by console level: log, warn, error, info, debug"),
4258
+ limit: z7.number().optional().describe("Maximum number of recent messages to return (default: all)")
3853
4259
  },
3854
4260
  // oxlint-disable-next-line require-await
3855
4261
  async ({ level, limit }) => {
@@ -3876,8 +4282,8 @@ function buildClientNetworkTool(manager) {
3876
4282
  "debug_get_client_network",
3877
4283
  "Get network requests captured from the headless browser. Shows URLs, methods, status codes, and timing.",
3878
4284
  {
3879
- filter: z6.string().optional().describe("Regex pattern to filter requests by URL"),
3880
- limit: z6.number().optional().describe("Maximum number of recent requests to return (default: all)")
4285
+ filter: z7.string().optional().describe("Regex pattern to filter requests by URL"),
4286
+ limit: z7.number().optional().describe("Maximum number of recent requests to return (default: all)")
3881
4287
  },
3882
4288
  // oxlint-disable-next-line require-await
3883
4289
  async ({ filter, limit }) => {
@@ -3905,7 +4311,7 @@ function buildClientErrorsTool(manager) {
3905
4311
  "debug_get_client_errors",
3906
4312
  "Get uncaught errors captured from the headless browser. Includes error messages and source-mapped stack traces.",
3907
4313
  {
3908
- limit: z6.number().optional().describe("Maximum number of recent errors to return (default: all)")
4314
+ limit: z7.number().optional().describe("Maximum number of recent errors to return (default: all)")
3909
4315
  },
3910
4316
  // oxlint-disable-next-line require-await
3911
4317
  async ({ limit }) => {
@@ -3999,12 +4405,12 @@ function buildDebugLifecycleTools(manager) {
3999
4405
  "debug_enter_mode",
4000
4406
  "Activate debug mode: restarts the dev server with Node.js --inspect flag and connects the CDP debugger. Optionally launch a headless Chromium browser for client-side debugging. Use serverSide for backend breakpoints, clientSide for frontend breakpoints, or both for full-stack.",
4001
4407
  {
4002
- hypothesis: z7.string().optional().describe("Your hypothesis about the bug \u2014 helps track debugging intent"),
4003
- serverSide: z7.boolean().optional().describe(
4408
+ hypothesis: z8.string().optional().describe("Your hypothesis about the bug \u2014 helps track debugging intent"),
4409
+ serverSide: z8.boolean().optional().describe(
4004
4410
  "Enable server-side Node.js debugging (default: true if clientSide is not set)"
4005
4411
  ),
4006
- clientSide: z7.boolean().optional().describe("Enable client-side browser debugging via headless Chromium + Playwright"),
4007
- previewUrl: z7.string().optional().describe(
4412
+ clientSide: z8.boolean().optional().describe("Enable client-side browser debugging via headless Chromium + Playwright"),
4413
+ previewUrl: z8.string().optional().describe(
4008
4414
  "Preview URL for client-side debugging (e.g., http://localhost:3000). Required when clientSide is true."
4009
4415
  )
4010
4416
  },
@@ -4040,9 +4446,9 @@ function buildBreakpointTools(manager) {
4040
4446
  "debug_set_breakpoint",
4041
4447
  "Set a breakpoint at the specified file and line number. Optionally provide a condition expression that must evaluate to true for the breakpoint to pause execution.",
4042
4448
  {
4043
- file: z7.string().describe("Absolute or relative file path to set the breakpoint in"),
4044
- line: z7.number().describe("Line number (1-based) to set the breakpoint on"),
4045
- condition: z7.string().optional().describe("JavaScript condition expression \u2014 breakpoint only triggers when truthy")
4449
+ file: z8.string().describe("Absolute or relative file path to set the breakpoint in"),
4450
+ line: z8.number().describe("Line number (1-based) to set the breakpoint on"),
4451
+ condition: z8.string().optional().describe("JavaScript condition expression \u2014 breakpoint only triggers when truthy")
4046
4452
  },
4047
4453
  async ({ file, line, condition }) => {
4048
4454
  const clientOrErr = requireDebugClient2(manager);
@@ -4064,7 +4470,7 @@ Breakpoint ID: ${breakpointId}`
4064
4470
  "debug_remove_breakpoint",
4065
4471
  "Remove a previously set breakpoint by its ID.",
4066
4472
  {
4067
- breakpointId: z7.string().describe("The breakpoint ID returned by debug_set_breakpoint")
4473
+ breakpointId: z8.string().describe("The breakpoint ID returned by debug_set_breakpoint")
4068
4474
  },
4069
4475
  async ({ breakpointId }) => {
4070
4476
  const clientOrErr = requireDebugClient2(manager);
@@ -4145,8 +4551,8 @@ ${JSON.stringify(queuedHits, null, 2)}`
4145
4551
  "debug_evaluate",
4146
4552
  "Evaluate a JavaScript expression in the current paused scope (or globally if not paused). When paused, use frameIndex to evaluate in a specific call frame.",
4147
4553
  {
4148
- expression: z7.string().describe("The JavaScript expression to evaluate"),
4149
- frameIndex: z7.number().optional().describe("Call stack frame index (0 = top frame). Defaults to the top frame.")
4554
+ expression: z8.string().describe("The JavaScript expression to evaluate"),
4555
+ frameIndex: z8.number().optional().describe("Call stack frame index (0 = top frame). Defaults to the top frame.")
4150
4556
  },
4151
4557
  async ({ expression, frameIndex }) => {
4152
4558
  const clientOrErr = requireDebugClient2(manager);
@@ -4174,12 +4580,12 @@ function buildProbeManagementTools(manager) {
4174
4580
  "debug_add_probe",
4175
4581
  "Add a debug probe at a specific code location. Captures expression values each time the line executes \u2014 without pausing or modifying source files. Like console.log but better: structured, no diff pollution, auto-cleaned on debug exit.",
4176
4582
  {
4177
- file: z7.string().describe("File path to probe"),
4178
- line: z7.number().describe("Line number (1-based) to probe"),
4179
- expressions: z7.array(z7.string()).describe(
4583
+ file: z8.string().describe("File path to probe"),
4584
+ line: z8.number().describe("Line number (1-based) to probe"),
4585
+ expressions: z8.array(z8.string()).describe(
4180
4586
  'JavaScript expressions to capture when the line executes (e.g., ["req.params.id", "user.role"])'
4181
4587
  ),
4182
- label: z7.string().optional().describe("Optional label for this probe (defaults to file:line)")
4588
+ label: z8.string().optional().describe("Optional label for this probe (defaults to file:line)")
4183
4589
  },
4184
4590
  async ({ file, line, expressions, label }) => {
4185
4591
  const clientOrErr = requireDebugClient2(manager);
@@ -4204,7 +4610,7 @@ Trigger the code path, then use debug_get_probe_results to see captured values.`
4204
4610
  "debug_remove_probe",
4205
4611
  "Remove a previously set debug probe by its ID.",
4206
4612
  {
4207
- probeId: z7.string().describe("The probe ID returned by debug_add_probe")
4613
+ probeId: z8.string().describe("The probe ID returned by debug_add_probe")
4208
4614
  },
4209
4615
  async ({ probeId }) => {
4210
4616
  const clientOrErr = requireDebugClient2(manager);
@@ -4244,9 +4650,9 @@ function buildProbeResultTools(manager) {
4244
4650
  "debug_get_probe_results",
4245
4651
  "Fetch captured probe hit data. Returns expression values from each time a probed line executed.",
4246
4652
  {
4247
- probeId: z7.string().optional().describe("Filter results by probe ID (resolves to its label)"),
4248
- label: z7.string().optional().describe("Filter results by probe label"),
4249
- limit: z7.number().optional().describe("Maximum number of recent hits to return (default: all)")
4653
+ probeId: z8.string().optional().describe("Filter results by probe ID (resolves to its label)"),
4654
+ label: z8.string().optional().describe("Filter results by probe label"),
4655
+ limit: z8.number().optional().describe("Maximum number of recent hits to return (default: all)")
4250
4656
  },
4251
4657
  async ({ probeId, label, limit }) => {
4252
4658
  const clientOrErr = requireDebugClient2(manager);
@@ -4970,14 +5376,14 @@ async function handleExitPlanMode(host, input) {
4970
5376
  }
4971
5377
  if (host.agentMode === "discovery") {
4972
5378
  host.hasExitedPlanMode = true;
5379
+ void host.connection.triggerIdentification();
4973
5380
  host.connection.postChatMessage(
4974
- "Plan complete. The task stays in Planning \u2014 identify it or switch to Build mode when ready."
5381
+ "Plan complete. Running identification \u2014 icon and agent assignment will be set automatically."
4975
5382
  );
4976
5383
  host.requestSoftStop();
4977
5384
  return { behavior: "allow", updatedInput: input };
4978
5385
  }
4979
5386
  await host.connection.triggerIdentification();
4980
- host.connection.updateStatus("InProgress");
4981
5387
  host.hasExitedPlanMode = true;
4982
5388
  const newMode = host.isParentTask ? "review" : "building";
4983
5389
  host.pendingModeRestart = true;
@@ -5385,6 +5791,7 @@ async function emitRetryStatus(host, attempt, delayMs) {
5385
5791
  await host.callbacks.onStatusChange("running");
5386
5792
  }
5387
5793
  function handleRateLimitPause(host, rateLimitResetsAt) {
5794
+ host.wasRateLimited = true;
5388
5795
  host.connection.emitRateLimitPause(rateLimitResetsAt);
5389
5796
  host.connection.postChatMessage(
5390
5797
  `Rate limited. The task will be automatically re-queued and resume after ${new Date(rateLimitResetsAt).toLocaleString()}.`
@@ -5505,6 +5912,7 @@ var QueryBridge = class {
5505
5912
  pendingToolOutputs = [];
5506
5913
  _stopped = false;
5507
5914
  _isParentTask = false;
5915
+ _wasRateLimited = false;
5508
5916
  _abortController = null;
5509
5917
  /** Called by SessionRunner when ExitPlanMode triggers a mode transition. */
5510
5918
  onModeTransition;
@@ -5519,6 +5927,9 @@ var QueryBridge = class {
5519
5927
  set isParentTask(val) {
5520
5928
  this._isParentTask = val;
5521
5929
  }
5930
+ get wasRateLimited() {
5931
+ return this._wasRateLimited;
5932
+ }
5522
5933
  stop() {
5523
5934
  this._stopped = true;
5524
5935
  this._abortController?.abort();
@@ -5533,6 +5944,7 @@ var QueryBridge = class {
5533
5944
  */
5534
5945
  async execute(context, followUpContent) {
5535
5946
  this._stopped = false;
5947
+ this._wasRateLimited = false;
5536
5948
  this._abortController = new AbortController();
5537
5949
  const host = this.buildHost();
5538
5950
  try {
@@ -5582,6 +5994,12 @@ var QueryBridge = class {
5582
5994
  set pendingModeRestart(val) {
5583
5995
  bridge.mode.pendingModeRestart = val;
5584
5996
  },
5997
+ get wasRateLimited() {
5998
+ return bridge._wasRateLimited;
5999
+ },
6000
+ set wasRateLimited(val) {
6001
+ bridge._wasRateLimited = val;
6002
+ },
5585
6003
  get activeQuery() {
5586
6004
  return bridge.activeQuery;
5587
6005
  },
@@ -5720,13 +6138,20 @@ var SessionRunner = class _SessionRunner {
5720
6138
  await this.shutdown("error");
5721
6139
  return;
5722
6140
  }
6141
+ if (this.fullContext?.githubBranch) {
6142
+ ensureOnTaskBranch(this.config.workspaceDir, this.fullContext.githubBranch);
6143
+ }
5723
6144
  if (this.fullContext?.baseBranch) {
5724
6145
  syncWithBaseBranch(this.config.workspaceDir, this.fullContext.baseBranch);
5725
6146
  }
5726
6147
  this.mode.resolveInitialMode(this.taskContext);
5727
6148
  this.queryBridge = this.createQueryBridge();
5728
6149
  this.logInitialization();
6150
+ const staleMessageCount = this.pendingMessages.length;
5729
6151
  await this.executeInitialMode();
6152
+ if (staleMessageCount > 0) {
6153
+ this.pendingMessages.splice(0, staleMessageCount);
6154
+ }
5730
6155
  if (!this.stopped && this._state !== "error") {
5731
6156
  this.hasCompleted = true;
5732
6157
  }
@@ -5750,6 +6175,34 @@ var SessionRunner = class _SessionRunner {
5750
6175
  await this.connect();
5751
6176
  await this.run();
5752
6177
  }
6178
+ // ── Message filtering ──────────────────────────────────────────────
6179
+ /**
6180
+ * Returns true if the message should be skipped (not processed).
6181
+ *
6182
+ * After the agent has completed, we only process:
6183
+ * 1. Critical automated sources (e.g. CI failure) — always process
6184
+ * 2. Messages with source: "user" — real user typed in chat
6185
+ * 3. Messages from flushAllCombined — have a real userId but no source
6186
+ *
6187
+ * Everything else (system messages, stale history replays) is skipped.
6188
+ */
6189
+ shouldSkipMessage(msg) {
6190
+ if (!this.hasCompleted) return false;
6191
+ const isCritical = !!msg.source && CRITICAL_AUTOMATED_SOURCES.has(msg.source);
6192
+ if (isCritical) {
6193
+ this.hasCompleted = false;
6194
+ return false;
6195
+ }
6196
+ if (msg.source === "user") {
6197
+ this.hasCompleted = false;
6198
+ return false;
6199
+ }
6200
+ if (!msg.source && msg.userId !== "system") {
6201
+ this.hasCompleted = false;
6202
+ return false;
6203
+ }
6204
+ return true;
6205
+ }
5753
6206
  // ── Core loop ──────────────────────────────────────────────────────
5754
6207
  async coreLoop() {
5755
6208
  while (!this.stopped) {
@@ -5764,12 +6217,7 @@ var SessionRunner = class _SessionRunner {
5764
6217
  }
5765
6218
  break;
5766
6219
  }
5767
- if (this.hasCompleted && msg.userId === "system") {
5768
- continue;
5769
- }
5770
- if (msg.userId !== "system") {
5771
- this.hasCompleted = false;
5772
- }
6220
+ if (this.shouldSkipMessage(msg)) continue;
5773
6221
  await this.setState("running");
5774
6222
  this.interrupted = false;
5775
6223
  await this.callbacks.onEvent({
@@ -5878,6 +6326,7 @@ var SessionRunner = class _SessionRunner {
5878
6326
  static MAX_PR_NUDGES = 3;
5879
6327
  needsPRNudge() {
5880
6328
  if (!this.config.isAuto || this.stopped) return false;
6329
+ if (this.queryBridge?.wasRateLimited) return false;
5881
6330
  if (this.prNudgeCount > _SessionRunner.MAX_PR_NUDGES) return false;
5882
6331
  if (!this.taskContext) return false;
5883
6332
  return this.taskContext.status === "InProgress" && !this.taskContext.githubPRUrl;
@@ -6035,7 +6484,7 @@ var SessionRunner = class _SessionRunner {
6035
6484
  }
6036
6485
  async setState(status) {
6037
6486
  this._state = status;
6038
- this.connection.emitStatus(status);
6487
+ await this.connection.emitStatus(status);
6039
6488
  await this.callbacks.onStatusChange(status);
6040
6489
  }
6041
6490
  async shutdown(finalState) {
@@ -6475,7 +6924,7 @@ import * as path from "path";
6475
6924
  import { fileURLToPath } from "url";
6476
6925
 
6477
6926
  // src/tools/project-tools.ts
6478
- import { z as z8 } from "zod";
6927
+ import { z as z9 } from "zod";
6479
6928
  function buildTaskListTools(connection) {
6480
6929
  const projectId = connection.projectId;
6481
6930
  return [
@@ -6483,9 +6932,9 @@ function buildTaskListTools(connection) {
6483
6932
  "list_tasks",
6484
6933
  "List tasks in the project. Optionally filter by status or assignee.",
6485
6934
  {
6486
- status: z8.string().optional().describe("Filter by task status"),
6487
- assigneeId: z8.string().optional().describe("Filter by assigned user ID"),
6488
- limit: z8.number().optional().describe("Max number of tasks to return (default 50)")
6935
+ status: z9.string().optional().describe("Filter by task status"),
6936
+ assigneeId: z9.string().optional().describe("Filter by assigned user ID"),
6937
+ limit: z9.number().optional().describe("Max number of tasks to return (default 50)")
6489
6938
  },
6490
6939
  async (params) => {
6491
6940
  try {
@@ -6502,7 +6951,7 @@ function buildTaskListTools(connection) {
6502
6951
  defineTool(
6503
6952
  "get_task",
6504
6953
  "Get detailed information about a task including chat messages, child tasks, and session.",
6505
- { task_id: z8.string().describe("The task ID to look up") },
6954
+ { task_id: z9.string().describe("The task ID to look up") },
6506
6955
  async ({ task_id }) => {
6507
6956
  try {
6508
6957
  const task = await connection.call("getProjectTask", { projectId, taskId: task_id });
@@ -6519,10 +6968,10 @@ function buildTaskListTools(connection) {
6519
6968
  "search_tasks",
6520
6969
  "Search tasks by tags, text query, or status filters.",
6521
6970
  {
6522
- tagNames: z8.array(z8.string()).optional().describe("Filter by tag names"),
6523
- searchQuery: z8.string().optional().describe("Text search in title/description"),
6524
- statusFilters: z8.array(z8.string()).optional().describe("Filter by statuses"),
6525
- limit: z8.number().optional().describe("Max results (default 20)")
6971
+ tagNames: z9.array(z9.string()).optional().describe("Filter by tag names"),
6972
+ searchQuery: z9.string().optional().describe("Text search in title/description"),
6973
+ statusFilters: z9.array(z9.string()).optional().describe("Filter by statuses"),
6974
+ limit: z9.number().optional().describe("Max results (default 20)")
6526
6975
  },
6527
6976
  async (params) => {
6528
6977
  try {
@@ -6582,11 +7031,11 @@ function buildMutationTools(connection) {
6582
7031
  "create_task",
6583
7032
  "Create a new task in the project.",
6584
7033
  {
6585
- title: z8.string().describe("Task title"),
6586
- description: z8.string().optional().describe("Task description"),
6587
- plan: z8.string().optional().describe("Implementation plan in markdown"),
6588
- status: z8.string().optional().describe("Initial status (default: Planning)"),
6589
- isBug: z8.boolean().optional().describe("Whether this is a bug report")
7034
+ title: z9.string().describe("Task title"),
7035
+ description: z9.string().optional().describe("Task description"),
7036
+ plan: z9.string().optional().describe("Implementation plan in markdown"),
7037
+ status: z9.string().optional().describe("Initial status (default: Planning)"),
7038
+ isBug: z9.boolean().optional().describe("Whether this is a bug report")
6590
7039
  },
6591
7040
  async (params) => {
6592
7041
  try {
@@ -6603,12 +7052,12 @@ function buildMutationTools(connection) {
6603
7052
  "update_task",
6604
7053
  "Update an existing task's title, description, plan, status, or assignee.",
6605
7054
  {
6606
- task_id: z8.string().describe("The task ID to update"),
6607
- title: z8.string().optional().describe("New title"),
6608
- description: z8.string().optional().describe("New description"),
6609
- plan: z8.string().optional().describe("New plan in markdown"),
6610
- status: z8.string().optional().describe("New status"),
6611
- assignedUserId: z8.string().nullable().optional().describe("Assign to user ID, or null to unassign")
7055
+ task_id: z9.string().describe("The task ID to update"),
7056
+ title: z9.string().optional().describe("New title"),
7057
+ description: z9.string().optional().describe("New description"),
7058
+ plan: z9.string().optional().describe("New plan in markdown"),
7059
+ status: z9.string().optional().describe("New status"),
7060
+ assignedUserId: z9.string().nullable().optional().describe("Assign to user ID, or null to unassign")
6612
7061
  },
6613
7062
  async ({ task_id, ...fields }) => {
6614
7063
  try {
@@ -7057,7 +7506,7 @@ var ProjectRunner = class {
7057
7506
  async handleAuditTags(request) {
7058
7507
  this.connection.emitStatus("busy");
7059
7508
  try {
7060
- const { handleTagAudit } = await import("./tag-audit-handler-4RRGIHVB.js");
7509
+ const { handleTagAudit } = await import("./tag-audit-handler-L7YPDXTA.js");
7061
7510
  await handleTagAudit(request, this.connection, this.projectDir);
7062
7511
  } catch (error) {
7063
7512
  const msg = error instanceof Error ? error.message : String(error);
@@ -7478,4 +7927,4 @@ export {
7478
7927
  loadForwardPorts,
7479
7928
  loadConveyorConfig
7480
7929
  };
7481
- //# sourceMappingURL=chunk-PMDVB2EU.js.map
7930
+ //# sourceMappingURL=chunk-BOFWZIL6.js.map