@rallycry/conveyor-agent 7.1.3 → 7.1.5

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.
@@ -1,3 +1,8 @@
1
+ import {
2
+ imageBlock,
3
+ isImageMimeType,
4
+ textResult
5
+ } from "./chunk-C5YAMQJ2.js";
1
6
  import {
2
7
  createHarness,
3
8
  createServiceLogger,
@@ -32,7 +37,6 @@ var AgentConnection = class _AgentConnection {
32
37
  stopCallback = null;
33
38
  softStopCallback = null;
34
39
  modeChangeCallback = null;
35
- wakeCallback = null;
36
40
  apiKeyUpdateCallback = null;
37
41
  constructor(config) {
38
42
  this.config = config;
@@ -114,15 +118,6 @@ var AgentConnection = class _AgentConnection {
114
118
  if (this.modeChangeCallback) this.modeChangeCallback(data);
115
119
  else this.earlyModeChanges.push(data);
116
120
  });
117
- this.socket.on("session:wake", () => {
118
- if (this.wakeCallback) {
119
- this.wakeCallback();
120
- } else if (this.messageCallback) {
121
- this.messageCallback({ content: "", userId: "system" });
122
- } else {
123
- this.earlyMessages.push({ content: "", userId: "system" });
124
- }
125
- });
126
121
  this.socket.on(
127
122
  "session:answerQuestion",
128
123
  (data) => {
@@ -251,9 +246,6 @@ var AgentConnection = class _AgentConnection {
251
246
  for (const data of this.earlyModeChanges) callback(data);
252
247
  this.earlyModeChanges = [];
253
248
  }
254
- onWake(callback) {
255
- this.wakeCallback = callback;
256
- }
257
249
  onApiKeyUpdate(callback) {
258
250
  this.apiKeyUpdateCallback = callback;
259
251
  }
@@ -314,8 +306,7 @@ var AgentConnection = class _AgentConnection {
314
306
  fetching_context: "active",
315
307
  connected: "active",
316
308
  connecting: "active",
317
- idle: "idle",
318
- sleeping: "idle"
309
+ idle: "idle"
319
310
  };
320
311
  const heartbeatStatus = statusMap[this.lastEmittedStatus ?? "idle"] ?? "active";
321
312
  void this.call("heartbeat", {
@@ -511,6 +502,26 @@ var ModeController = class {
511
502
  const m = this.effectiveMode;
512
503
  return m === "building" || m === "review" || m === "auto" && this._hasExitedPlanMode;
513
504
  }
505
+ /**
506
+ * Apply authoritative mode from the server's task context.
507
+ * Called after getTaskContext to override env-var defaults with the
508
+ * actual task state — ensures pods that launch without CONVEYOR_AGENT_MODE
509
+ * still get the correct mode.
510
+ */
511
+ applyServerMode(agentMode, isAuto) {
512
+ if (agentMode) {
513
+ this._mode = agentMode;
514
+ this._isAuto = agentMode === "auto" || !!isAuto;
515
+ } else if (isAuto !== void 0) {
516
+ this._isAuto = isAuto;
517
+ if (isAuto && this._runnerMode === "pm" && !this._mode) {
518
+ this._mode = "auto";
519
+ }
520
+ }
521
+ if (this._isAuto && this._mode === "discovery") {
522
+ this._mode = "auto";
523
+ }
524
+ }
514
525
  // ── Mode resolution ────────────────────────────────────────────────
515
526
  /** Resolve the initial mode based on task context */
516
527
  resolveInitialMode(context) {
@@ -539,6 +550,11 @@ var ModeController = class {
539
550
  this._mode = newMode;
540
551
  return { type: "restart_query", newMode: "review" };
541
552
  }
553
+ if (this._runnerMode === "task" && newMode === "building") {
554
+ this._mode = newMode;
555
+ this._hasExitedPlanMode = true;
556
+ return { type: "restart_query", newMode: "building" };
557
+ }
542
558
  if (this._runnerMode !== "pm") return { type: "noop" };
543
559
  this._mode = newMode;
544
560
  this.updateExitedPlanModeFlag(newMode);
@@ -573,7 +589,6 @@ var ModeController = class {
573
589
  // src/runner/lifecycle.ts
574
590
  var DEFAULT_LIFECYCLE_CONFIG = {
575
591
  idleTimeoutMs: 30 * 60 * 1e3,
576
- sleepGracePeriodMs: 5e3,
577
592
  heartbeatIntervalMs: 3e4
578
593
  };
579
594
  var Lifecycle = class {
@@ -582,15 +597,10 @@ var Lifecycle = class {
582
597
  heartbeatTimer = null;
583
598
  idleTimer = null;
584
599
  idleCheckInterval = null;
585
- sleepShutdownTimer = null;
586
- _isSleeping = false;
587
600
  constructor(config, callbacks) {
588
601
  this.config = config;
589
602
  this.callbacks = callbacks;
590
603
  }
591
- get isSleeping() {
592
- return this._isSleeping;
593
- }
594
604
  // ── Heartbeat ──────────────────────────────────────────────────────
595
605
  startHeartbeat() {
596
606
  this.stopHeartbeat();
@@ -609,37 +619,11 @@ var Lifecycle = class {
609
619
  this.clearIdleTimers();
610
620
  this.idleTimer = setTimeout(() => {
611
621
  this.callbacks.onIdleTimeout();
612
- this.enterSleepMode();
613
622
  }, this.config.idleTimeoutMs);
614
623
  }
615
624
  cancelIdleTimer() {
616
625
  this.clearIdleTimers();
617
626
  }
618
- // ── Sleep mode ─────────────────────────────────────────────────────
619
- enterSleepMode() {
620
- this._isSleeping = true;
621
- this.callbacks.onSleep();
622
- this.sleepShutdownTimer = setTimeout(() => {
623
- this.callbacks.onSleepGraceExpired();
624
- }, this.config.sleepGracePeriodMs);
625
- }
626
- /** Wake from sleep — cancels shutdown timer, resets idle */
627
- wake() {
628
- if (this.sleepShutdownTimer) {
629
- clearTimeout(this.sleepShutdownTimer);
630
- this.sleepShutdownTimer = null;
631
- }
632
- this._isSleeping = false;
633
- this.callbacks.onWake();
634
- }
635
- /** Cancel the sleep shutdown timer (e.g. when a message arrives) */
636
- cancelSleepShutdown() {
637
- if (this.sleepShutdownTimer) {
638
- clearTimeout(this.sleepShutdownTimer);
639
- this.sleepShutdownTimer = null;
640
- }
641
- this._isSleeping = false;
642
- }
643
627
  // ── Cleanup ────────────────────────────────────────────────────────
644
628
  destroy() {
645
629
  this.stopHeartbeat();
@@ -655,11 +639,6 @@ var Lifecycle = class {
655
639
  clearInterval(this.idleCheckInterval);
656
640
  this.idleCheckInterval = null;
657
641
  }
658
- if (this.sleepShutdownTimer) {
659
- clearTimeout(this.sleepShutdownTimer);
660
- this.sleepShutdownTimer = null;
661
- }
662
- this._isSleeping = false;
663
642
  }
664
643
  };
665
644
 
@@ -944,522 +923,6 @@ var PlanSync = class {
944
923
  }
945
924
  };
946
925
 
947
- // ../shared/dist/index.js
948
- import { z } from "zod";
949
- import { z as z2 } from "zod";
950
- import { z as z3 } from "zod";
951
- var MAX_FILE_SIZE_BYTES = 25 * 1024 * 1024;
952
- var EMBED_THRESHOLD_IMAGES = 5 * 1024 * 1024;
953
- var EMBED_THRESHOLD_TEXT = 2 * 1024 * 1024;
954
- var AgentHeartbeatSchema = z.object({
955
- sessionId: z.string().optional(),
956
- timestamp: z.string(),
957
- status: z.enum(["active", "idle", "building"]),
958
- currentAction: z.string().optional()
959
- });
960
- var CreatePRInputSchema = z.object({
961
- title: z.string().min(1),
962
- body: z.string(),
963
- head: z.string().optional(),
964
- base: z.string().optional()
965
- });
966
- var PostToChatInputSchema = z.object({
967
- message: z.string().min(1),
968
- type: z.enum(["message", "question", "update"]).optional().default("message")
969
- });
970
- var GetTaskContextRequestSchema = z.object({
971
- sessionId: z.string(),
972
- includeHistory: z.boolean().optional().default(false)
973
- });
974
- var GetChatMessagesRequestSchema = z.object({
975
- sessionId: z.string(),
976
- limit: z.number().int().positive().optional().default(50),
977
- offset: z.number().int().nonnegative().optional().default(0)
978
- });
979
- var GetTaskFilesRequestSchema = z.object({
980
- sessionId: z.string()
981
- });
982
- var GetTaskFileRequestSchema = z.object({
983
- sessionId: z.string(),
984
- fileId: z.string()
985
- });
986
- var GetTaskRequestSchema = z.object({
987
- sessionId: z.string(),
988
- taskSlugOrId: z.string()
989
- });
990
- var GetCliHistoryRequestSchema = z.object({
991
- sessionId: z.string(),
992
- limit: z.number().int().positive().optional().default(100),
993
- source: z.enum(["agent", "application"]).optional()
994
- });
995
- var ListSubtasksRequestSchema = z.object({
996
- sessionId: z.string()
997
- });
998
- var GetDependenciesRequestSchema = z.object({
999
- sessionId: z.string()
1000
- });
1001
- var GetSuggestionsRequestSchema = z.object({
1002
- sessionId: z.string()
1003
- });
1004
- var GetTaskIncidentsRequestSchema = z.object({
1005
- sessionId: z.string(),
1006
- taskId: z.string().optional()
1007
- });
1008
- var CreatePullRequestRequestSchema = CreatePRInputSchema.extend({ sessionId: z.string() });
1009
- var UpdateTaskStatusRequestSchema = z.object({
1010
- sessionId: z.string(),
1011
- status: z.string(),
1012
- force: z.boolean().optional().default(false)
1013
- });
1014
- var StoreSessionIdRequestSchema = z.object({
1015
- sessionId: z.string(),
1016
- sdkSessionId: z.string()
1017
- });
1018
- var TrackSpendingRequestSchema = z.object({
1019
- sessionId: z.string(),
1020
- inputTokens: z.number().int().nonnegative(),
1021
- outputTokens: z.number().int().nonnegative(),
1022
- costUsd: z.number().nonnegative(),
1023
- model: z.string()
1024
- });
1025
- var SessionStartRequestSchema = z.object({
1026
- sessionId: z.string(),
1027
- agentVersion: z.string(),
1028
- capabilities: z.array(z.string())
1029
- });
1030
- var SessionStopRequestSchema = z.object({
1031
- sessionId: z.string(),
1032
- reason: z.string().optional()
1033
- });
1034
- var ConnectAgentRequestSchema = z.object({
1035
- sessionId: z.string()
1036
- });
1037
- var ReportAgentStatusRequestSchema = z.object({
1038
- sessionId: z.string(),
1039
- status: z.string()
1040
- });
1041
- var NotifyAgentVersionRequestSchema = z.object({
1042
- sessionId: z.string(),
1043
- agentVersion: z.string()
1044
- });
1045
- var CreateSubtaskRequestSchema = z.object({
1046
- sessionId: z.string(),
1047
- title: z.string().min(1),
1048
- description: z.string().optional(),
1049
- plan: z.string().optional(),
1050
- storyPointValue: z.number().int().positive().optional(),
1051
- ordinal: z.number().int().nonnegative().optional()
1052
- });
1053
- var UpdateSubtaskRequestSchema = z.object({
1054
- sessionId: z.string(),
1055
- subtaskId: z.string(),
1056
- title: z.string().min(1).optional(),
1057
- description: z.string().optional(),
1058
- plan: z.string().optional(),
1059
- status: z.string().optional(),
1060
- storyPointValue: z.number().int().positive().optional()
1061
- });
1062
- var DeleteSubtaskRequestSchema = z.object({
1063
- sessionId: z.string(),
1064
- subtaskId: z.string()
1065
- });
1066
- var SearchIncidentsRequestSchema = z.object({
1067
- sessionId: z.string(),
1068
- status: z.string().optional(),
1069
- source: z.string().optional()
1070
- });
1071
- var QueryGcpLogsRequestSchema = z.object({
1072
- sessionId: z.string(),
1073
- filter: z.string().optional(),
1074
- startTime: z.string().optional(),
1075
- endTime: z.string().optional(),
1076
- severity: z.string().optional(),
1077
- pageSize: z.number().int().positive().optional().default(100)
1078
- });
1079
- var GetTaskPropertiesRequestSchema = z.object({
1080
- sessionId: z.string()
1081
- });
1082
- var UpdateTaskFieldsRequestSchema = z.object({
1083
- sessionId: z.string(),
1084
- plan: z.string().optional(),
1085
- description: z.string().optional()
1086
- });
1087
- var UpdateTaskPropertiesRequestSchema = z.object({
1088
- sessionId: z.string(),
1089
- title: z.string().optional(),
1090
- storyPointValue: z.number().int().positive().optional(),
1091
- tagIds: z.array(z.string()).optional(),
1092
- githubPRUrl: z.string().url().optional()
1093
- });
1094
- var ListIconsRequestSchema = z.object({
1095
- sessionId: z.string()
1096
- });
1097
- var GenerateTaskIconRequestSchema = z.object({
1098
- sessionId: z.string(),
1099
- prompt: z.string().min(1),
1100
- aspectRatio: z.string().optional()
1101
- });
1102
- var SearchFaIconsRequestSchema = z.object({
1103
- sessionId: z.string(),
1104
- query: z.string().min(1),
1105
- first: z.number().int().positive().optional()
1106
- });
1107
- var PickFaIconRequestSchema = z.object({
1108
- sessionId: z.string(),
1109
- fontAwesomeId: z.string().min(1),
1110
- fontAwesomeStyle: z.string().optional()
1111
- });
1112
- var CreateFollowUpTaskRequestSchema = z.object({
1113
- sessionId: z.string(),
1114
- title: z.string().min(1),
1115
- description: z.string().optional(),
1116
- plan: z.string().optional(),
1117
- storyPointValue: z.number().int().positive().optional()
1118
- });
1119
- var AddDependencyRequestSchema = z.object({
1120
- sessionId: z.string(),
1121
- dependsOnSlugOrId: z.string()
1122
- });
1123
- var RemoveDependencyRequestSchema = z.object({
1124
- sessionId: z.string(),
1125
- dependsOnSlugOrId: z.string()
1126
- });
1127
- var CreateSuggestionRequestSchema = z.object({
1128
- sessionId: z.string(),
1129
- title: z.string().min(1),
1130
- description: z.string().optional(),
1131
- tagNames: z.array(z.string()).optional()
1132
- });
1133
- var VoteSuggestionRequestSchema = z.object({
1134
- sessionId: z.string(),
1135
- suggestionId: z.string(),
1136
- value: z.union([z.literal(1), z.literal(-1)])
1137
- });
1138
- var ScaleUpResourcesRequestSchema = z.object({
1139
- sessionId: z.string(),
1140
- tier: z.string(),
1141
- reason: z.string().optional()
1142
- });
1143
- var TriggerIdentificationRequestSchema = z.object({
1144
- sessionId: z.string()
1145
- });
1146
- var SubmitCodeReviewResultRequestSchema = z.object({
1147
- sessionId: z.string(),
1148
- approved: z.boolean(),
1149
- content: z.string()
1150
- });
1151
- var StartChildCloudBuildRequestSchema = z.object({
1152
- sessionId: z.string(),
1153
- childTaskId: z.string()
1154
- });
1155
- var StopChildBuildRequestSchema = z.object({
1156
- sessionId: z.string(),
1157
- childTaskId: z.string()
1158
- });
1159
- var ApproveAndMergePRRequestSchema = z.object({
1160
- sessionId: z.string(),
1161
- childTaskId: z.string()
1162
- });
1163
- var PostChildChatMessageRequestSchema = z.object({
1164
- sessionId: z.string(),
1165
- childTaskId: z.string(),
1166
- message: z.string().min(1)
1167
- });
1168
- var UpdateChildStatusRequestSchema = z.object({
1169
- sessionId: z.string(),
1170
- childTaskId: z.string(),
1171
- status: z.string()
1172
- });
1173
- var GetAgentStatusRequestSchema = z.object({
1174
- taskId: z.string()
1175
- });
1176
- var GetUiCliHistoryRequestSchema = z.object({
1177
- taskId: z.string()
1178
- });
1179
- var SendSoftStopRequestSchema = z.object({
1180
- taskId: z.string().optional(),
1181
- projectId: z.string().optional()
1182
- });
1183
- var FlushTaskQueueRequestSchema = z.object({
1184
- taskId: z.string()
1185
- });
1186
- var FlushProjectQueueRequestSchema = z.object({
1187
- projectId: z.string()
1188
- });
1189
- var CancelTaskQueuedMessageRequestSchema = z.object({
1190
- taskId: z.string(),
1191
- messageId: z.string()
1192
- });
1193
- var FlushSingleQueuedMessageRequestSchema = z.object({
1194
- taskId: z.string(),
1195
- messageId: z.string()
1196
- });
1197
- var FlushSingleProjectQueuedMessageRequestSchema = z.object({
1198
- projectId: z.string(),
1199
- index: z.number().int().nonnegative()
1200
- });
1201
- var AnswerAgentQuestionRequestSchema = z.object({
1202
- taskId: z.string(),
1203
- requestId: z.string(),
1204
- answers: z.record(z.string(), z.string())
1205
- });
1206
- var ClearAgentTodosRequestSchema = z.object({
1207
- taskId: z.string()
1208
- });
1209
- var AgentQuestionOptionSchema = z.object({
1210
- label: z.string(),
1211
- description: z.string(),
1212
- preview: z.string().optional()
1213
- });
1214
- var AgentQuestionSchema = z.object({
1215
- question: z.string(),
1216
- header: z.string(),
1217
- options: z.array(AgentQuestionOptionSchema),
1218
- multiSelect: z.boolean().optional()
1219
- });
1220
- var AskUserQuestionRequestSchema = z.object({
1221
- sessionId: z.string(),
1222
- question: z.string().min(1),
1223
- requestId: z.string().min(1),
1224
- questions: z.array(AgentQuestionSchema).min(1)
1225
- });
1226
- var RefreshGithubTokenRequestSchema = z.object({
1227
- sessionId: z.string()
1228
- });
1229
- var RefreshGithubTokenResponseSchema = z.object({
1230
- token: z.string()
1231
- });
1232
- var CreatePRResponseSchema = z.object({
1233
- prNumber: z.number().int().positive(),
1234
- prUrl: z.string().url()
1235
- });
1236
- var PostToChatResponseSchema = z.object({
1237
- messageId: z.string()
1238
- });
1239
- var UpdateTaskStatusResponseSchema = z.object({
1240
- taskId: z.string(),
1241
- status: z.string()
1242
- });
1243
- var StoreSessionIdResponseSchema = z.object({
1244
- success: z.boolean()
1245
- });
1246
- var HeartbeatResponseSchema = z.object({
1247
- acknowledged: z.boolean()
1248
- });
1249
- var SessionStartResponseSchema = z.object({
1250
- sessionId: z.string(),
1251
- startedAt: z.string()
1252
- });
1253
- var SessionStopResponseSchema = z.object({
1254
- sessionId: z.string(),
1255
- stoppedAt: z.string()
1256
- });
1257
- var DeleteSubtaskResponseSchema = z.object({
1258
- deleted: z.boolean()
1259
- });
1260
- var RegisterProjectAgentResponseSchema = z.object({
1261
- registered: z.boolean(),
1262
- agentName: z.string(),
1263
- agentInstructions: z.string(),
1264
- model: z.string(),
1265
- agentSettings: z.record(z.string(), z.unknown()).nullable(),
1266
- branchSwitchCommand: z.string().nullable()
1267
- });
1268
- var RegisterProjectAgentRequestSchema = z2.object({
1269
- projectId: z2.string(),
1270
- capabilities: z2.array(z2.string())
1271
- });
1272
- var ProjectRunnerHeartbeatRequestSchema = z2.object({
1273
- projectId: z2.string()
1274
- });
1275
- var ReportProjectAgentStatusRequestSchema = z2.object({
1276
- projectId: z2.string(),
1277
- status: z2.enum(["busy", "idle"]),
1278
- activeChatId: z2.string().nullish(),
1279
- activeTaskId: z2.string().nullish(),
1280
- activeBranch: z2.string().nullish()
1281
- });
1282
- var DisconnectProjectRunnerRequestSchema = z2.object({
1283
- projectId: z2.string()
1284
- });
1285
- var GetProjectAgentContextRequestSchema = z2.object({
1286
- projectId: z2.string()
1287
- });
1288
- var GetProjectChatHistoryRequestSchema = z2.object({
1289
- projectId: z2.string(),
1290
- limit: z2.number().int().positive().optional().default(50),
1291
- chatId: z2.string().optional()
1292
- });
1293
- var PostProjectAgentMessageRequestSchema = z2.object({
1294
- projectId: z2.string(),
1295
- content: z2.string().min(1),
1296
- chatId: z2.string().optional()
1297
- });
1298
- var ListProjectTasksRequestSchema = z2.object({
1299
- projectId: z2.string(),
1300
- status: z2.string().optional(),
1301
- assigneeId: z2.string().optional(),
1302
- limit: z2.number().int().positive().optional().default(50)
1303
- });
1304
- var GetProjectTaskRequestSchema = z2.object({
1305
- projectId: z2.string(),
1306
- taskId: z2.string()
1307
- });
1308
- var SearchProjectTasksRequestSchema = z2.object({
1309
- projectId: z2.string(),
1310
- tagNames: z2.array(z2.string()).optional(),
1311
- searchQuery: z2.string().optional(),
1312
- statusFilters: z2.array(z2.string()).optional(),
1313
- limit: z2.number().int().positive().optional().default(20)
1314
- });
1315
- var ListProjectTagsRequestSchema = z2.object({
1316
- projectId: z2.string()
1317
- });
1318
- var GetProjectSummaryRequestSchema = z2.object({
1319
- projectId: z2.string()
1320
- });
1321
- var CreateProjectTaskRequestSchema = z2.object({
1322
- projectId: z2.string(),
1323
- title: z2.string().min(1),
1324
- description: z2.string().optional(),
1325
- plan: z2.string().optional(),
1326
- status: z2.string().optional(),
1327
- isBug: z2.boolean().optional()
1328
- });
1329
- var UpdateProjectTaskRequestSchema = z2.object({
1330
- projectId: z2.string(),
1331
- taskId: z2.string(),
1332
- title: z2.string().optional(),
1333
- description: z2.string().optional(),
1334
- plan: z2.string().optional(),
1335
- status: z2.string().optional(),
1336
- assignedUserId: z2.string().nullish()
1337
- });
1338
- var ReportProjectAgentEventRequestSchema = z2.object({
1339
- projectId: z2.string(),
1340
- event: z2.record(z2.string(), z2.unknown())
1341
- });
1342
- var ReportTagAuditProgressRequestSchema = z2.object({
1343
- projectId: z2.string(),
1344
- requestId: z2.string(),
1345
- activity: z2.object({
1346
- tool: z2.string(),
1347
- input: z2.string().optional(),
1348
- timestamp: z2.string()
1349
- })
1350
- });
1351
- var ReportTagAuditResultRequestSchema = z2.object({
1352
- projectId: z2.string(),
1353
- requestId: z2.string(),
1354
- recommendations: z2.array(z2.record(z2.string(), z2.unknown())),
1355
- summary: z2.string(),
1356
- complete: z2.boolean()
1357
- });
1358
- var ReportNewCommitsDetectedRequestSchema = z2.object({
1359
- projectId: z2.string(),
1360
- commits: z2.array(
1361
- z2.object({
1362
- sha: z2.string(),
1363
- message: z2.string(),
1364
- author: z2.string()
1365
- })
1366
- ),
1367
- branch: z2.string()
1368
- });
1369
- var ReportEnvironmentReadyRequestSchema = z2.object({
1370
- projectId: z2.string(),
1371
- branch: z2.string(),
1372
- setupComplete: z2.boolean(),
1373
- startCommandRunning: z2.boolean()
1374
- });
1375
- var ReportEnvSwitchProgressRequestSchema = z2.object({
1376
- projectId: z2.string(),
1377
- step: z2.string(),
1378
- progress: z2.number(),
1379
- message: z2.string().optional()
1380
- });
1381
- var ForwardProjectChatMessageRequestSchema = z2.object({
1382
- projectId: z2.string(),
1383
- chatId: z2.string(),
1384
- content: z2.string().min(1),
1385
- targetUserId: z2.string().optional()
1386
- });
1387
- var CancelQueuedProjectMessageRequestSchema = z2.object({
1388
- projectId: z2.string(),
1389
- index: z2.number().int().nonnegative()
1390
- });
1391
- var GetProjectCliHistoryRequestSchema = z2.object({
1392
- projectId: z2.string(),
1393
- limit: z2.number().int().positive().optional().default(50),
1394
- source: z2.string().optional()
1395
- });
1396
- var PostToProjectTaskChatRequestSchema = z2.object({
1397
- projectId: z2.string(),
1398
- taskId: z2.string(),
1399
- content: z2.string()
1400
- });
1401
- var GetProjectTaskCliRequestSchema = z2.object({
1402
- projectId: z2.string(),
1403
- taskId: z2.string(),
1404
- limit: z2.number().int().positive().optional().default(50),
1405
- source: z2.string().optional()
1406
- });
1407
- var StartProjectBuildRequestSchema = z2.object({
1408
- projectId: z2.string(),
1409
- taskId: z2.string()
1410
- });
1411
- var StopProjectBuildRequestSchema = z2.object({
1412
- projectId: z2.string(),
1413
- taskId: z2.string()
1414
- });
1415
- var ApproveProjectMergePRRequestSchema = z2.object({
1416
- projectId: z2.string(),
1417
- childTaskId: z2.string()
1418
- });
1419
- var CRITICAL_AUTOMATED_SOURCES = /* @__PURE__ */ new Set(["ci_failure", "review_trigger"]);
1420
- var StartTaskAuditRequestSchema = z3.object({
1421
- projectId: z3.string(),
1422
- taskIds: z3.array(z3.string()).min(1)
1423
- });
1424
- var ReportTaskAuditProgressRequestSchema = z3.object({
1425
- projectId: z3.string(),
1426
- requestId: z3.string(),
1427
- taskId: z3.string(),
1428
- activity: z3.string()
1429
- });
1430
- var ReportTaskAuditResultRequestSchema = z3.object({
1431
- projectId: z3.string(),
1432
- requestId: z3.string(),
1433
- taskId: z3.string(),
1434
- summary: z3.string(),
1435
- turnGrades: z3.array(
1436
- z3.object({
1437
- turnIndex: z3.number(),
1438
- phase: z3.enum(["planning", "building", "human"]),
1439
- grade: z3.enum(["correct", "neutral", "blunder"]),
1440
- reasoning: z3.string(),
1441
- eventType: z3.string(),
1442
- eventSummary: z3.string()
1443
- })
1444
- ),
1445
- planningAccuracy: z3.number().nullable(),
1446
- buildingAccuracy: z3.number().nullable(),
1447
- humanAccuracy: z3.number().nullable(),
1448
- planningCorrect: z3.number(),
1449
- planningNeutral: z3.number(),
1450
- planningBlunder: z3.number(),
1451
- buildingCorrect: z3.number(),
1452
- buildingNeutral: z3.number(),
1453
- buildingBlunder: z3.number(),
1454
- humanCorrect: z3.number(),
1455
- humanNeutral: z3.number(),
1456
- humanBlunder: z3.number(),
1457
- suggestionIds: z3.array(z3.string()),
1458
- auditCostUsd: z3.number().nullable(),
1459
- model: z3.string().nullable(),
1460
- error: z3.string().optional()
1461
- });
1462
-
1463
926
  // src/execution/pack-runner-prompt.ts
1464
927
  function findLastAgentMessageIndex(history) {
1465
928
  for (let i = history.length - 1; i >= 0; i--) {
@@ -2643,20 +2106,7 @@ async function buildInitialPrompt(mode, context, isAuto, agentMode) {
2643
2106
  }
2644
2107
 
2645
2108
  // src/tools/common-tools.ts
2646
- import { z as z4 } from "zod";
2647
-
2648
- // src/tools/helpers.ts
2649
- function textResult(text) {
2650
- return { content: [{ type: "text", text }] };
2651
- }
2652
- function imageBlock(data, mimeType) {
2653
- return { type: "image", data, mimeType };
2654
- }
2655
- function isImageMimeType(mimeType) {
2656
- return mimeType.startsWith("image/");
2657
- }
2658
-
2659
- // src/tools/common-tools.ts
2109
+ import { z } from "zod";
2660
2110
  var cliEventFormatters = {
2661
2111
  thinking: (e) => e.message ?? "",
2662
2112
  tool_use: (e) => `${e.tool}: ${e.input?.slice(0, 1e3) ?? ""}`,
@@ -2677,8 +2127,8 @@ function buildReadTaskChatTool(connection) {
2677
2127
  "read_task_chat",
2678
2128
  "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.",
2679
2129
  {
2680
- limit: z4.number().optional().describe("Number of recent messages to fetch (default 20)"),
2681
- task_id: z4.string().optional().describe("Child task ID to read chat from. Omit to read the current task's chat.")
2130
+ limit: z.number().optional().describe("Number of recent messages to fetch (default 20)"),
2131
+ task_id: z.string().optional().describe("Child task ID to read chat from. Omit to read the current task's chat.")
2682
2132
  },
2683
2133
  async ({ limit, task_id }) => {
2684
2134
  try {
@@ -2722,7 +2172,7 @@ function buildGetTaskTool(connection) {
2722
2172
  "get_task",
2723
2173
  "Look up a task by slug or ID to get its title, description, plan, and status",
2724
2174
  {
2725
- slug_or_id: z4.string().describe("The task slug (e.g. 'my-task') or CUID")
2175
+ slug_or_id: z.string().describe("The task slug (e.g. 'my-task') or CUID")
2726
2176
  },
2727
2177
  async ({ slug_or_id }) => {
2728
2178
  try {
@@ -2745,9 +2195,9 @@ function buildGetTaskCliTool(connection) {
2745
2195
  "get_task_cli",
2746
2196
  "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.",
2747
2197
  {
2748
- task_id: z4.string().optional().describe("Task ID or slug. Omit to read logs from the current task."),
2749
- source: z4.enum(["agent", "application"]).optional().describe("Filter by log source. Omit for all logs."),
2750
- limit: z4.number().optional().describe("Max number of log entries to return (default 50, max 500).")
2198
+ task_id: z.string().optional().describe("Task ID or slug. Omit to read logs from the current task."),
2199
+ source: z.enum(["agent", "application"]).optional().describe("Filter by log source. Omit for all logs."),
2200
+ limit: z.number().optional().describe("Max number of log entries to return (default 50, max 500).")
2751
2201
  },
2752
2202
  async ({ task_id, source, limit }) => {
2753
2203
  try {
@@ -2807,7 +2257,7 @@ function buildGetTaskFileTool(connection) {
2807
2257
  return defineTool(
2808
2258
  "get_task_file",
2809
2259
  "Get a specific task file's content and download URL by file ID",
2810
- { fileId: z4.string().describe("The file ID to retrieve") },
2260
+ { fileId: z.string().describe("The file ID to retrieve") },
2811
2261
  async ({ fileId }) => {
2812
2262
  try {
2813
2263
  const file = await connection.call("getTaskFile", {
@@ -2838,8 +2288,8 @@ function buildSearchIncidentsTool(connection) {
2838
2288
  "search_incidents",
2839
2289
  "Search incidents in the current project. Optionally filter by status (Open, Acknowledged, Investigating, Resolved, Closed) or source.",
2840
2290
  {
2841
- status: z4.string().optional().describe("Filter by incident status"),
2842
- source: z4.string().optional().describe("Filter by source (e.g., 'conveyor', 'agent', 'build')")
2291
+ status: z.string().optional().describe("Filter by incident status"),
2292
+ source: z.string().optional().describe("Filter by source (e.g., 'conveyor', 'agent', 'build')")
2843
2293
  },
2844
2294
  async ({ status, source }) => {
2845
2295
  try {
@@ -2863,7 +2313,7 @@ function buildGetTaskIncidentsTool(connection) {
2863
2313
  "get_task_incidents",
2864
2314
  "Get all incidents linked to the current task (or a specified task). Returns full incident details including title, description, severity, status, and source.",
2865
2315
  {
2866
- task_id: z4.string().optional().describe("Task ID (defaults to current task)")
2316
+ task_id: z.string().optional().describe("Task ID (defaults to current task)")
2867
2317
  },
2868
2318
  async ({ task_id }) => {
2869
2319
  try {
@@ -2886,12 +2336,12 @@ function buildQueryGcpLogsTool(connection) {
2886
2336
  "query_gcp_logs",
2887
2337
  "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.",
2888
2338
  {
2889
- filter: z4.string().optional().describe(
2339
+ filter: z.string().optional().describe(
2890
2340
  `Cloud Logging filter expression (e.g., 'resource.type="gce_instance"'). Max 1000 chars.`
2891
2341
  ),
2892
- start_time: z4.string().optional().describe("Start time in ISO 8601 format (e.g., '2024-01-01T00:00:00Z')"),
2893
- end_time: z4.string().optional().describe("End time in ISO 8601 format (e.g., '2024-01-02T00:00:00Z')"),
2894
- severity: z4.enum([
2342
+ start_time: z.string().optional().describe("Start time in ISO 8601 format (e.g., '2024-01-01T00:00:00Z')"),
2343
+ end_time: z.string().optional().describe("End time in ISO 8601 format (e.g., '2024-01-02T00:00:00Z')"),
2344
+ severity: z.enum([
2895
2345
  "DEFAULT",
2896
2346
  "DEBUG",
2897
2347
  "INFO",
@@ -2902,7 +2352,7 @@ function buildQueryGcpLogsTool(connection) {
2902
2352
  "ALERT",
2903
2353
  "EMERGENCY"
2904
2354
  ]).optional().describe("Minimum severity level to filter by (default: all levels)"),
2905
- page_size: z4.number().optional().describe("Number of log entries to return (default 100, max 500)")
2355
+ page_size: z.number().optional().describe("Number of log entries to return (default 100, max 500)")
2906
2356
  },
2907
2357
  async ({ filter, start_time, end_time, severity, page_size }) => {
2908
2358
  try {
@@ -2956,8 +2406,8 @@ function buildGetSuggestionsTool(connection) {
2956
2406
  "get_suggestions",
2957
2407
  "List project suggestions sorted by vote score. Use this to see what the team thinks is important.",
2958
2408
  {
2959
- status: z4.string().optional().describe("Filter by status: Open, Accepted, Rejected, Implemented"),
2960
- limit: z4.number().optional().describe("Max results (default 20)")
2409
+ status: z.string().optional().describe("Filter by status: Open, Accepted, Rejected, Implemented"),
2410
+ limit: z.number().optional().describe("Max results (default 20)")
2961
2411
  },
2962
2412
  async ({ status: _status, limit: _limit }) => {
2963
2413
  try {
@@ -2982,8 +2432,8 @@ function buildPostToChatTool(connection) {
2982
2432
  "post_to_chat",
2983
2433
  "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.",
2984
2434
  {
2985
- message: z4.string().describe("The message to post to the team"),
2986
- task_id: z4.string().optional().describe("Child task ID to post to. Omit to post to the current task's chat.")
2435
+ message: z.string().describe("The message to post to the team"),
2436
+ task_id: z.string().optional().describe("Child task ID to post to. Omit to post to the current task's chat.")
2987
2437
  },
2988
2438
  async ({ message, task_id }) => {
2989
2439
  try {
@@ -3010,8 +2460,8 @@ function buildForceUpdateTaskStatusTool(connection) {
3010
2460
  "force_update_task_status",
3011
2461
  "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.",
3012
2462
  {
3013
- status: z4.enum(["InProgress", "ReviewPR", "ReviewDev", "Complete"]).describe("The new status for the task"),
3014
- task_id: z4.string().optional().describe("Child task ID to update. Omit to update the current task.")
2463
+ status: z.enum(["InProgress", "ReviewPR", "ReviewDev", "Complete"]).describe("The new status for the task"),
2464
+ task_id: z.string().optional().describe("Child task ID to update. Omit to update the current task.")
3015
2465
  },
3016
2466
  async ({ status, task_id }) => {
3017
2467
  try {
@@ -3042,15 +2492,15 @@ function buildCreatePullRequestTool(connection, config) {
3042
2492
  "create_pull_request",
3043
2493
  "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.",
3044
2494
  {
3045
- title: z4.string().describe("The PR title"),
3046
- body: z4.string().describe("The PR description/body in markdown"),
3047
- branch: z4.string().optional().describe(
2495
+ title: z.string().describe("The PR title"),
2496
+ body: z.string().describe("The PR description/body in markdown"),
2497
+ branch: z.string().optional().describe(
3048
2498
  "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."
3049
2499
  ),
3050
- baseBranch: z4.string().optional().describe(
2500
+ baseBranch: z.string().optional().describe(
3051
2501
  "The base branch to target for the PR (e.g. 'main', 'develop'). Defaults to the project's configured dev branch."
3052
2502
  ),
3053
- commitMessage: z4.string().optional().describe(
2503
+ commitMessage: z.string().optional().describe(
3054
2504
  "Commit message for staging uncommitted changes. If not provided, a default message based on the PR title will be used."
3055
2505
  )
3056
2506
  },
@@ -3128,7 +2578,7 @@ function buildAddDependencyTool(connection) {
3128
2578
  "add_dependency",
3129
2579
  "Add a dependency \u2014 this task cannot start until the specified task is merged to dev",
3130
2580
  {
3131
- depends_on_slug_or_id: z4.string().describe("Slug or ID of the task this task depends on")
2581
+ depends_on_slug_or_id: z.string().describe("Slug or ID of the task this task depends on")
3132
2582
  },
3133
2583
  async ({ depends_on_slug_or_id }) => {
3134
2584
  try {
@@ -3150,7 +2600,7 @@ function buildRemoveDependencyTool(connection) {
3150
2600
  "remove_dependency",
3151
2601
  "Remove a dependency from this task",
3152
2602
  {
3153
- depends_on_slug_or_id: z4.string().describe("Slug or ID of the task to remove as dependency")
2603
+ depends_on_slug_or_id: z.string().describe("Slug or ID of the task to remove as dependency")
3154
2604
  },
3155
2605
  async ({ depends_on_slug_or_id }) => {
3156
2606
  try {
@@ -3172,10 +2622,10 @@ function buildCreateFollowUpTaskTool(connection) {
3172
2622
  "create_follow_up_task",
3173
2623
  "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.",
3174
2624
  {
3175
- title: z4.string().describe("Follow-up task title"),
3176
- description: z4.string().optional().describe("Brief description of the follow-up work"),
3177
- plan: z4.string().optional().describe("Implementation plan if known"),
3178
- story_point_value: z4.number().optional().describe("Story point estimate (1=Common, 2=Magic, 3=Rare, 5=Unique)")
2625
+ title: z.string().describe("Follow-up task title"),
2626
+ description: z.string().optional().describe("Brief description of the follow-up work"),
2627
+ plan: z.string().optional().describe("Implementation plan if known"),
2628
+ story_point_value: z.number().optional().describe("Story point estimate (1=Common, 2=Magic, 3=Rare, 5=Unique)")
3179
2629
  },
3180
2630
  async ({ title, description, plan, story_point_value }) => {
3181
2631
  try {
@@ -3202,9 +2652,9 @@ function buildCreateSuggestionTool(connection) {
3202
2652
  "create_suggestion",
3203
2653
  "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.",
3204
2654
  {
3205
- title: z4.string().describe("Short title for the suggestion"),
3206
- description: z4.string().optional().describe("Details about the suggestion"),
3207
- tag_names: z4.array(z4.string()).optional().describe("Tag names to categorize the suggestion")
2655
+ title: z.string().describe("Short title for the suggestion"),
2656
+ description: z.string().optional().describe("Details about the suggestion"),
2657
+ tag_names: z.array(z.string()).optional().describe("Tag names to categorize the suggestion")
3208
2658
  },
3209
2659
  async ({ title, description, tag_names }) => {
3210
2660
  try {
@@ -3233,8 +2683,8 @@ function buildVoteSuggestionTool(connection) {
3233
2683
  "vote_suggestion",
3234
2684
  "Vote on a project suggestion. Use +1 to upvote or -1 to downvote.",
3235
2685
  {
3236
- suggestion_id: z4.string().describe("The suggestion ID to vote on"),
3237
- value: z4.number().refine((v) => v === 1 || v === -1, { message: "Value must be 1 or -1" }).describe("+1 to upvote, -1 to downvote")
2686
+ suggestion_id: z.string().describe("The suggestion ID to vote on"),
2687
+ value: z.number().refine((v) => v === 1 || v === -1, { message: "Value must be 1 or -1" }).describe("+1 to upvote, -1 to downvote")
3238
2688
  },
3239
2689
  async ({ suggestion_id, value }) => {
3240
2690
  try {
@@ -3257,8 +2707,8 @@ function buildScaleUpResourcesTool(connection) {
3257
2707
  "scale_up_resources",
3258
2708
  "Scale up the pod's CPU and memory resources to the 'build' tier. Use before running heavy operations like full test suites, integration tests, typechecks, or production builds. Pods start at the 'setup' tier by default \u2014 only call this when you actually need more. Scaling is one-way (up only).",
3259
2709
  {
3260
- tier: z4.literal("build").describe("The resource phase to scale up to"),
3261
- reason: z4.string().optional().describe("Brief reason for scaling (e.g., 'running test suite')")
2710
+ tier: z.literal("build").describe("The resource phase to scale up to"),
2711
+ reason: z.string().optional().describe("Brief reason for scaling (e.g., 'running test suite')")
3262
2712
  },
3263
2713
  async ({ tier, reason }) => {
3264
2714
  try {
@@ -3311,15 +2761,15 @@ function buildCommonTools(connection, config) {
3311
2761
  }
3312
2762
 
3313
2763
  // src/tools/pm-tools.ts
3314
- import { z as z5 } from "zod";
2764
+ import { z as z2 } from "zod";
3315
2765
  var SP_DESCRIPTION = "Story point value (1=Common, 2=Magic, 3=Rare, 5=Unique)";
3316
2766
  function buildUpdateTaskTool(connection) {
3317
2767
  return defineTool(
3318
2768
  "update_task",
3319
2769
  "Save the finalized task plan and/or description",
3320
2770
  {
3321
- plan: z5.string().optional().describe("The task plan in markdown"),
3322
- description: z5.string().optional().describe("Updated task description")
2771
+ plan: z2.string().optional().describe("The task plan in markdown"),
2772
+ description: z2.string().optional().describe("Updated task description")
3323
2773
  },
3324
2774
  async ({ plan, description }) => {
3325
2775
  try {
@@ -3340,11 +2790,11 @@ function buildCreateSubtaskTool(connection) {
3340
2790
  "create_subtask",
3341
2791
  "Create a subtask under the current parent task. Use for breaking complex tasks into smaller pieces.",
3342
2792
  {
3343
- title: z5.string().describe("Subtask title"),
3344
- description: z5.string().optional().describe("Brief description"),
3345
- plan: z5.string().optional().describe("Implementation plan in markdown"),
3346
- ordinal: z5.number().optional().describe("Step/order number (0-based)"),
3347
- storyPointValue: z5.number().optional().describe(SP_DESCRIPTION)
2793
+ title: z2.string().describe("Subtask title"),
2794
+ description: z2.string().optional().describe("Brief description"),
2795
+ plan: z2.string().optional().describe("Implementation plan in markdown"),
2796
+ ordinal: z2.number().optional().describe("Step/order number (0-based)"),
2797
+ storyPointValue: z2.number().optional().describe(SP_DESCRIPTION)
3348
2798
  },
3349
2799
  async ({ title, description, plan, ordinal, storyPointValue }) => {
3350
2800
  try {
@@ -3370,12 +2820,12 @@ function buildUpdateSubtaskTool(connection) {
3370
2820
  "update_subtask",
3371
2821
  "Update an existing subtask's fields",
3372
2822
  {
3373
- subtaskId: z5.string().describe("The subtask ID to update"),
3374
- title: z5.string().optional(),
3375
- description: z5.string().optional(),
3376
- plan: z5.string().optional(),
3377
- ordinal: z5.number().optional(),
3378
- storyPointValue: z5.number().optional().describe(SP_DESCRIPTION)
2823
+ subtaskId: z2.string().describe("The subtask ID to update"),
2824
+ title: z2.string().optional(),
2825
+ description: z2.string().optional(),
2826
+ plan: z2.string().optional(),
2827
+ ordinal: z2.number().optional(),
2828
+ storyPointValue: z2.number().optional().describe(SP_DESCRIPTION)
3379
2829
  },
3380
2830
  async ({ subtaskId, title, description, plan, storyPointValue }) => {
3381
2831
  try {
@@ -3398,7 +2848,7 @@ function buildDeleteSubtaskTool(connection) {
3398
2848
  return defineTool(
3399
2849
  "delete_subtask",
3400
2850
  "Delete a subtask",
3401
- { subtaskId: z5.string().describe("The subtask ID to delete") },
2851
+ { subtaskId: z2.string().describe("The subtask ID to delete") },
3402
2852
  async ({ subtaskId }) => {
3403
2853
  try {
3404
2854
  await connection.call("deleteSubtask", {
@@ -3436,7 +2886,7 @@ function buildPackTools(connection) {
3436
2886
  "start_child_cloud_build",
3437
2887
  "Start a cloud build for a child task. The child must be in Open status with story points and an agent assigned.",
3438
2888
  {
3439
- childTaskId: z5.string().describe("The child task ID to start a cloud build for")
2889
+ childTaskId: z2.string().describe("The child task ID to start a cloud build for")
3440
2890
  },
3441
2891
  async ({ childTaskId }) => {
3442
2892
  try {
@@ -3456,7 +2906,7 @@ function buildPackTools(connection) {
3456
2906
  "stop_child_build",
3457
2907
  "Stop a running cloud build for a child task. Sends a stop signal to the child agent.",
3458
2908
  {
3459
- childTaskId: z5.string().describe("The child task ID whose build should be stopped")
2909
+ childTaskId: z2.string().describe("The child task ID whose build should be stopped")
3460
2910
  },
3461
2911
  async ({ childTaskId }) => {
3462
2912
  try {
@@ -3476,7 +2926,7 @@ function buildPackTools(connection) {
3476
2926
  "approve_and_merge_pr",
3477
2927
  "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.",
3478
2928
  {
3479
- childTaskId: z5.string().describe("The child task ID whose PR should be approved and merged")
2929
+ childTaskId: z2.string().describe("The child task ID whose PR should be approved and merged")
3480
2930
  },
3481
2931
  async ({ childTaskId }) => {
3482
2932
  try {
@@ -3514,7 +2964,7 @@ function buildPmTools(connection, options) {
3514
2964
  }
3515
2965
 
3516
2966
  // src/tools/discovery-tools.ts
3517
- import { z as z6 } from "zod";
2967
+ import { z as z3 } from "zod";
3518
2968
  var SP_DESCRIPTION2 = "Story point value (1=Common, 2=Magic, 3=Rare, 5=Unique)";
3519
2969
  function buildDiscoveryTools(connection) {
3520
2970
  return [
@@ -3522,10 +2972,10 @@ function buildDiscoveryTools(connection) {
3522
2972
  "update_task_properties",
3523
2973
  "Set one or more task properties in a single call. All fields are optional \u2014 only include the fields you want to update.",
3524
2974
  {
3525
- title: z6.string().optional().describe("The new task title"),
3526
- storyPointValue: z6.number().optional().describe(SP_DESCRIPTION2),
3527
- tagIds: z6.array(z6.string()).optional().describe("Array of tag IDs to assign"),
3528
- githubPRUrl: z6.string().url().optional().describe("GitHub pull request URL to link to this task")
2975
+ title: z3.string().optional().describe("The new task title"),
2976
+ storyPointValue: z3.number().optional().describe(SP_DESCRIPTION2),
2977
+ tagIds: z3.array(z3.string()).optional().describe("Array of tag IDs to assign"),
2978
+ githubPRUrl: z3.string().url().optional().describe("GitHub pull request URL to link to this task")
3529
2979
  },
3530
2980
  async ({ title, storyPointValue, tagIds, githubPRUrl }) => {
3531
2981
  try {
@@ -3554,14 +3004,14 @@ function buildDiscoveryTools(connection) {
3554
3004
  }
3555
3005
 
3556
3006
  // src/tools/code-review-tools.ts
3557
- import { z as z7 } from "zod";
3007
+ import { z as z4 } from "zod";
3558
3008
  function buildCodeReviewTools(connection) {
3559
3009
  return [
3560
3010
  defineTool(
3561
3011
  "approve_code_review",
3562
3012
  "Approve the code review. Use this when the code passes all review criteria and is ready to merge.",
3563
3013
  {
3564
- summary: z7.string().describe("Brief summary of what was reviewed and why it looks good")
3014
+ summary: z4.string().describe("Brief summary of what was reviewed and why it looks good")
3565
3015
  },
3566
3016
  async ({ summary }) => {
3567
3017
  const content = `**Code Review: Approved** :white_check_mark:
@@ -3584,15 +3034,15 @@ ${summary}`;
3584
3034
  "request_code_changes",
3585
3035
  "Request changes during code review. Use this when substantive issues are found that need to be fixed before merge.",
3586
3036
  {
3587
- issues: z7.array(
3588
- z7.object({
3589
- file: z7.string().describe("File path where the issue was found"),
3590
- line: z7.number().optional().describe("Line number (if applicable)"),
3591
- severity: z7.enum(["critical", "major", "minor"]).describe("Issue severity"),
3592
- description: z7.string().describe("What is wrong and how to fix it")
3037
+ issues: z4.array(
3038
+ z4.object({
3039
+ file: z4.string().describe("File path where the issue was found"),
3040
+ line: z4.number().optional().describe("Line number (if applicable)"),
3041
+ severity: z4.enum(["critical", "major", "minor"]).describe("Issue severity"),
3042
+ description: z4.string().describe("What is wrong and how to fix it")
3593
3043
  })
3594
3044
  ).describe("List of issues found during review"),
3595
- summary: z7.string().describe("Brief overall summary of the review findings")
3045
+ summary: z4.string().describe("Brief overall summary of the review findings")
3596
3046
  },
3597
3047
  async ({ issues, summary }) => {
3598
3048
  const issueLines = issues.map((issue) => {
@@ -3622,10 +3072,10 @@ ${issueLines}`;
3622
3072
  }
3623
3073
 
3624
3074
  // src/tools/debug-tools.ts
3625
- import { z as z10 } from "zod";
3075
+ import { z as z7 } from "zod";
3626
3076
 
3627
3077
  // src/tools/telemetry-tools.ts
3628
- import { z as z8 } from "zod";
3078
+ import { z as z5 } from "zod";
3629
3079
 
3630
3080
  // src/debug/telemetry-injector.ts
3631
3081
  var BUFFER_SIZE = 200;
@@ -4020,12 +3470,12 @@ function buildGetTelemetryTool(manager) {
4020
3470
  "debug_get_telemetry",
4021
3471
  "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.",
4022
3472
  {
4023
- type: z8.enum(["http", "db", "socket", "error"]).optional().describe("Filter by event type"),
4024
- urlPattern: z8.string().optional().describe("Regex pattern to filter HTTP events by URL"),
4025
- minDuration: z8.number().optional().describe("Minimum duration in ms \u2014 only return events slower than this"),
4026
- errorOnly: z8.boolean().optional().describe("Only return error events and HTTP 4xx/5xx responses"),
4027
- since: z8.number().optional().describe("Only return events after this timestamp (ms since epoch)"),
4028
- limit: z8.number().optional().describe("Max events to return (default: 20, from most recent)")
3473
+ type: z5.enum(["http", "db", "socket", "error"]).optional().describe("Filter by event type"),
3474
+ urlPattern: z5.string().optional().describe("Regex pattern to filter HTTP events by URL"),
3475
+ minDuration: z5.number().optional().describe("Minimum duration in ms \u2014 only return events slower than this"),
3476
+ errorOnly: z5.boolean().optional().describe("Only return error events and HTTP 4xx/5xx responses"),
3477
+ since: z5.number().optional().describe("Only return events after this timestamp (ms since epoch)"),
3478
+ limit: z5.number().optional().describe("Max events to return (default: 20, from most recent)")
4029
3479
  },
4030
3480
  async ({ type, urlPattern, minDuration, errorOnly, since, limit }) => {
4031
3481
  const clientOrErr = requireDebugClient(manager);
@@ -4095,7 +3545,7 @@ function buildTelemetryTools(manager) {
4095
3545
  }
4096
3546
 
4097
3547
  // src/tools/client-debug-tools.ts
4098
- import { z as z9 } from "zod";
3548
+ import { z as z6 } from "zod";
4099
3549
  function requirePlaywrightClient(manager) {
4100
3550
  if (!manager.isClientDebugMode()) {
4101
3551
  return "Client debug mode is not active. Use debug_enter_mode with clientSide: true first.";
@@ -4115,11 +3565,11 @@ function buildClientBreakpointTools(manager) {
4115
3565
  "debug_set_client_breakpoint",
4116
3566
  "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.",
4117
3567
  {
4118
- file: z9.string().describe(
3568
+ file: z6.string().describe(
4119
3569
  "Original source file path (e.g., src/components/App.tsx) \u2014 source maps resolve automatically"
4120
3570
  ),
4121
- line: z9.number().describe("Line number (1-based) in the original source file"),
4122
- condition: z9.string().optional().describe("JavaScript condition expression \u2014 breakpoint only triggers when truthy")
3571
+ line: z6.number().describe("Line number (1-based) in the original source file"),
3572
+ condition: z6.string().optional().describe("JavaScript condition expression \u2014 breakpoint only triggers when truthy")
4123
3573
  },
4124
3574
  async ({ file, line, condition }) => {
4125
3575
  const clientOrErr = requirePlaywrightClient(manager);
@@ -4141,7 +3591,7 @@ Breakpoint ID: ${breakpointId}${sourceMapNote}`
4141
3591
  "debug_remove_client_breakpoint",
4142
3592
  "Remove a previously set client-side breakpoint by its ID.",
4143
3593
  {
4144
- breakpointId: z9.string().describe("The breakpoint ID returned by debug_set_client_breakpoint")
3594
+ breakpointId: z6.string().describe("The breakpoint ID returned by debug_set_client_breakpoint")
4145
3595
  },
4146
3596
  async ({ breakpointId }) => {
4147
3597
  const clientOrErr = requirePlaywrightClient(manager);
@@ -4221,8 +3671,8 @@ ${JSON.stringify(queuedHits, null, 2)}`
4221
3671
  "debug_evaluate_client",
4222
3672
  "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.",
4223
3673
  {
4224
- expression: z9.string().describe("JavaScript expression to evaluate in the browser context"),
4225
- frameIndex: z9.number().optional().describe("Call stack frame index (0 = top frame). Defaults to the top frame.")
3674
+ expression: z6.string().describe("JavaScript expression to evaluate in the browser context"),
3675
+ frameIndex: z6.number().optional().describe("Call stack frame index (0 = top frame). Defaults to the top frame.")
4226
3676
  },
4227
3677
  async ({ expression, frameIndex }) => {
4228
3678
  const clientOrErr = requirePlaywrightClient(manager);
@@ -4295,7 +3745,7 @@ function buildClientInteractionTools(manager) {
4295
3745
  "debug_navigate_client",
4296
3746
  "Navigate the headless browser to a specific URL. Use this to reproduce specific flows or visit different pages.",
4297
3747
  {
4298
- url: z9.string().describe("URL to navigate to (e.g., http://localhost:3000/dashboard)")
3748
+ url: z6.string().describe("URL to navigate to (e.g., http://localhost:3000/dashboard)")
4299
3749
  },
4300
3750
  async ({ url }) => {
4301
3751
  const clientOrErr = requirePlaywrightClient(manager);
@@ -4312,7 +3762,7 @@ function buildClientInteractionTools(manager) {
4312
3762
  "debug_click_client",
4313
3763
  "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.",
4314
3764
  {
4315
- selector: z9.string().describe(
3765
+ selector: z6.string().describe(
4316
3766
  "CSS selector of the element to click (e.g., 'button.submit', '#login-form input[type=submit]')"
4317
3767
  )
4318
3768
  },
@@ -4334,8 +3784,8 @@ function buildClientConsoleTool(manager) {
4334
3784
  "debug_get_client_console",
4335
3785
  "Get console messages captured from the headless browser. Includes console.log, warn, error, etc.",
4336
3786
  {
4337
- level: z9.string().optional().describe("Filter by console level: log, warn, error, info, debug"),
4338
- limit: z9.number().optional().describe("Maximum number of recent messages to return (default: all)")
3787
+ level: z6.string().optional().describe("Filter by console level: log, warn, error, info, debug"),
3788
+ limit: z6.number().optional().describe("Maximum number of recent messages to return (default: all)")
4339
3789
  },
4340
3790
  // oxlint-disable-next-line require-await
4341
3791
  async ({ level, limit }) => {
@@ -4362,8 +3812,8 @@ function buildClientNetworkTool(manager) {
4362
3812
  "debug_get_client_network",
4363
3813
  "Get network requests captured from the headless browser. Shows URLs, methods, status codes, and timing.",
4364
3814
  {
4365
- filter: z9.string().optional().describe("Regex pattern to filter requests by URL"),
4366
- limit: z9.number().optional().describe("Maximum number of recent requests to return (default: all)")
3815
+ filter: z6.string().optional().describe("Regex pattern to filter requests by URL"),
3816
+ limit: z6.number().optional().describe("Maximum number of recent requests to return (default: all)")
4367
3817
  },
4368
3818
  // oxlint-disable-next-line require-await
4369
3819
  async ({ filter, limit }) => {
@@ -4391,7 +3841,7 @@ function buildClientErrorsTool(manager) {
4391
3841
  "debug_get_client_errors",
4392
3842
  "Get uncaught errors captured from the headless browser. Includes error messages and source-mapped stack traces.",
4393
3843
  {
4394
- limit: z9.number().optional().describe("Maximum number of recent errors to return (default: all)")
3844
+ limit: z6.number().optional().describe("Maximum number of recent errors to return (default: all)")
4395
3845
  },
4396
3846
  // oxlint-disable-next-line require-await
4397
3847
  async ({ limit }) => {
@@ -4485,12 +3935,12 @@ function buildDebugLifecycleTools(manager) {
4485
3935
  "debug_enter_mode",
4486
3936
  "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.",
4487
3937
  {
4488
- hypothesis: z10.string().optional().describe("Your hypothesis about the bug \u2014 helps track debugging intent"),
4489
- serverSide: z10.boolean().optional().describe(
3938
+ hypothesis: z7.string().optional().describe("Your hypothesis about the bug \u2014 helps track debugging intent"),
3939
+ serverSide: z7.boolean().optional().describe(
4490
3940
  "Enable server-side Node.js debugging (default: true if clientSide is not set)"
4491
3941
  ),
4492
- clientSide: z10.boolean().optional().describe("Enable client-side browser debugging via headless Chromium + Playwright"),
4493
- previewUrl: z10.string().optional().describe(
3942
+ clientSide: z7.boolean().optional().describe("Enable client-side browser debugging via headless Chromium + Playwright"),
3943
+ previewUrl: z7.string().optional().describe(
4494
3944
  "Preview URL for client-side debugging (e.g., http://localhost:3000). Required when clientSide is true."
4495
3945
  )
4496
3946
  },
@@ -4526,9 +3976,9 @@ function buildBreakpointTools(manager) {
4526
3976
  "debug_set_breakpoint",
4527
3977
  "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.",
4528
3978
  {
4529
- file: z10.string().describe("Absolute or relative file path to set the breakpoint in"),
4530
- line: z10.number().describe("Line number (1-based) to set the breakpoint on"),
4531
- condition: z10.string().optional().describe("JavaScript condition expression \u2014 breakpoint only triggers when truthy")
3979
+ file: z7.string().describe("Absolute or relative file path to set the breakpoint in"),
3980
+ line: z7.number().describe("Line number (1-based) to set the breakpoint on"),
3981
+ condition: z7.string().optional().describe("JavaScript condition expression \u2014 breakpoint only triggers when truthy")
4532
3982
  },
4533
3983
  async ({ file, line, condition }) => {
4534
3984
  const clientOrErr = requireDebugClient2(manager);
@@ -4550,7 +4000,7 @@ Breakpoint ID: ${breakpointId}`
4550
4000
  "debug_remove_breakpoint",
4551
4001
  "Remove a previously set breakpoint by its ID.",
4552
4002
  {
4553
- breakpointId: z10.string().describe("The breakpoint ID returned by debug_set_breakpoint")
4003
+ breakpointId: z7.string().describe("The breakpoint ID returned by debug_set_breakpoint")
4554
4004
  },
4555
4005
  async ({ breakpointId }) => {
4556
4006
  const clientOrErr = requireDebugClient2(manager);
@@ -4631,8 +4081,8 @@ ${JSON.stringify(queuedHits, null, 2)}`
4631
4081
  "debug_evaluate",
4632
4082
  "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.",
4633
4083
  {
4634
- expression: z10.string().describe("The JavaScript expression to evaluate"),
4635
- frameIndex: z10.number().optional().describe("Call stack frame index (0 = top frame). Defaults to the top frame.")
4084
+ expression: z7.string().describe("The JavaScript expression to evaluate"),
4085
+ frameIndex: z7.number().optional().describe("Call stack frame index (0 = top frame). Defaults to the top frame.")
4636
4086
  },
4637
4087
  async ({ expression, frameIndex }) => {
4638
4088
  const clientOrErr = requireDebugClient2(manager);
@@ -4660,12 +4110,12 @@ function buildProbeManagementTools(manager) {
4660
4110
  "debug_add_probe",
4661
4111
  "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.",
4662
4112
  {
4663
- file: z10.string().describe("File path to probe"),
4664
- line: z10.number().describe("Line number (1-based) to probe"),
4665
- expressions: z10.array(z10.string()).describe(
4113
+ file: z7.string().describe("File path to probe"),
4114
+ line: z7.number().describe("Line number (1-based) to probe"),
4115
+ expressions: z7.array(z7.string()).describe(
4666
4116
  'JavaScript expressions to capture when the line executes (e.g., ["req.params.id", "user.role"])'
4667
4117
  ),
4668
- label: z10.string().optional().describe("Optional label for this probe (defaults to file:line)")
4118
+ label: z7.string().optional().describe("Optional label for this probe (defaults to file:line)")
4669
4119
  },
4670
4120
  async ({ file, line, expressions, label }) => {
4671
4121
  const clientOrErr = requireDebugClient2(manager);
@@ -4690,7 +4140,7 @@ Trigger the code path, then use debug_get_probe_results to see captured values.`
4690
4140
  "debug_remove_probe",
4691
4141
  "Remove a previously set debug probe by its ID.",
4692
4142
  {
4693
- probeId: z10.string().describe("The probe ID returned by debug_add_probe")
4143
+ probeId: z7.string().describe("The probe ID returned by debug_add_probe")
4694
4144
  },
4695
4145
  async ({ probeId }) => {
4696
4146
  const clientOrErr = requireDebugClient2(manager);
@@ -4730,9 +4180,9 @@ function buildProbeResultTools(manager) {
4730
4180
  "debug_get_probe_results",
4731
4181
  "Fetch captured probe hit data. Returns expression values from each time a probed line executed.",
4732
4182
  {
4733
- probeId: z10.string().optional().describe("Filter results by probe ID (resolves to its label)"),
4734
- label: z10.string().optional().describe("Filter results by probe label"),
4735
- limit: z10.number().optional().describe("Maximum number of recent hits to return (default: all)")
4183
+ probeId: z7.string().optional().describe("Filter results by probe ID (resolves to its label)"),
4184
+ label: z7.string().optional().describe("Filter results by probe label"),
4185
+ limit: z7.number().optional().describe("Maximum number of recent hits to return (default: all)")
4736
4186
  },
4737
4187
  async ({ probeId, label, limit }) => {
4738
4188
  const clientOrErr = requireDebugClient2(manager);
@@ -5496,6 +4946,12 @@ function buildCanUseTool(host) {
5496
4946
  if (toolName === "ExitPlanMode" && (host.agentMode === "auto" || host.agentMode === "discovery") && !host.hasExitedPlanMode) {
5497
4947
  return await handleExitPlanMode(host, input);
5498
4948
  }
4949
+ if (toolName === "ExitPlanMode" && host.agentMode === "discovery" && host.hasExitedPlanMode) {
4950
+ return {
4951
+ behavior: "deny",
4952
+ message: "Plan mode has already been exited. The team will transition you to Building mode when ready."
4953
+ };
4954
+ }
5499
4955
  if (toolName === "AskUserQuestion") {
5500
4956
  return await handleAskUserQuestion(host, input);
5501
4957
  }
@@ -6113,7 +5569,6 @@ var SessionRunner = class _SessionRunner {
6113
5569
  callbacks;
6114
5570
  _state = "connecting";
6115
5571
  stopped = false;
6116
- hasCompleted = false;
6117
5572
  interrupted = false;
6118
5573
  taskContext = null;
6119
5574
  fullContext = null;
@@ -6131,24 +5586,13 @@ var SessionRunner = class _SessionRunner {
6131
5586
  this.lifecycle = new Lifecycle(lifecycleConfig, {
6132
5587
  onHeartbeat: () => this.connection.sendHeartbeat(),
6133
5588
  onIdleTimeout: () => {
6134
- process.stderr.write("[conveyor-agent] Idle timeout reached, entering sleep\n");
6135
- this.connection.emitStatus("sleeping");
6136
- },
6137
- onSleep: () => {
6138
- process.stderr.write("[conveyor-agent] Sleep mode active\n");
6139
- this.connection.postChatMessage("Agent sleeping \u2014 send a message or click Resume to wake.");
6140
- },
6141
- onSleepGraceExpired: () => {
5589
+ process.stderr.write("[conveyor-agent] Idle timeout reached, stopping agent\n");
6142
5590
  this.stopped = true;
6143
5591
  if (this.inputResolver) {
6144
5592
  const resolver = this.inputResolver;
6145
5593
  this.inputResolver = null;
6146
5594
  resolver(null);
6147
5595
  }
6148
- },
6149
- onWake: () => {
6150
- process.stderr.write("[conveyor-agent] Woken from sleep\n");
6151
- this.lifecycle.cancelSleepShutdown();
6152
5596
  }
6153
5597
  });
6154
5598
  }
@@ -6222,6 +5666,7 @@ var SessionRunner = class _SessionRunner {
6222
5666
  if (this.fullContext?.baseBranch) {
6223
5667
  syncWithBaseBranch(this.config.workspaceDir, this.fullContext.baseBranch);
6224
5668
  }
5669
+ this.mode.applyServerMode(this.fullContext?.agentMode, this.fullContext?.isAuto);
6225
5670
  this.mode.resolveInitialMode(this.taskContext);
6226
5671
  this.queryBridge = this.createQueryBridge();
6227
5672
  this.logInitialization();
@@ -6230,9 +5675,6 @@ var SessionRunner = class _SessionRunner {
6230
5675
  if (staleMessageCount > 0 && didExecuteInitialQuery) {
6231
5676
  this.pendingMessages.splice(0, staleMessageCount);
6232
5677
  }
6233
- if (!this.stopped && this._state !== "error") {
6234
- this.hasCompleted = true;
6235
- }
6236
5678
  if (!this.stopped && this.pendingMessages.length === 0) {
6237
5679
  await this.maybeSendPRNudge();
6238
5680
  }
@@ -6253,34 +5695,6 @@ var SessionRunner = class _SessionRunner {
6253
5695
  await this.connect();
6254
5696
  await this.run();
6255
5697
  }
6256
- // ── Message filtering ──────────────────────────────────────────────
6257
- /**
6258
- * Returns true if the message should be skipped (not processed).
6259
- *
6260
- * After the agent has completed, we only process:
6261
- * 1. Critical automated sources (e.g. CI failure) — always process
6262
- * 2. Messages with source: "user" — real user typed in chat
6263
- * 3. Messages from flushAllCombined — have a real userId but no source
6264
- *
6265
- * Everything else (system messages, stale history replays) is skipped.
6266
- */
6267
- shouldSkipMessage(msg) {
6268
- if (!this.hasCompleted) return false;
6269
- const isCritical = !!msg.source && CRITICAL_AUTOMATED_SOURCES.has(msg.source);
6270
- if (isCritical) {
6271
- this.hasCompleted = false;
6272
- return false;
6273
- }
6274
- if (msg.source === "user") {
6275
- this.hasCompleted = false;
6276
- return false;
6277
- }
6278
- if (!msg.source && msg.userId !== "system") {
6279
- this.hasCompleted = false;
6280
- return false;
6281
- }
6282
- return true;
6283
- }
6284
5698
  // ── Core loop ──────────────────────────────────────────────────────
6285
5699
  async coreLoop() {
6286
5700
  while (!this.stopped) {
@@ -6295,7 +5709,6 @@ var SessionRunner = class _SessionRunner {
6295
5709
  }
6296
5710
  break;
6297
5711
  }
6298
- if (this.shouldSkipMessage(msg)) continue;
6299
5712
  await this.setState("running");
6300
5713
  this.interrupted = false;
6301
5714
  await this.callbacks.onEvent({
@@ -6312,7 +5725,6 @@ var SessionRunner = class _SessionRunner {
6312
5725
  if (!this.stopped && this.pendingMessages.length === 0) {
6313
5726
  await this.maybeSendPRNudge();
6314
5727
  }
6315
- this.hasCompleted = true;
6316
5728
  if (!this.stopped) await this.setState("idle");
6317
5729
  } else if (this._state === "error") {
6318
5730
  await this.setState("idle");
@@ -6348,7 +5760,6 @@ var SessionRunner = class _SessionRunner {
6348
5760
  }
6349
5761
  /** Inject a message (from connection callback or external source) */
6350
5762
  injectMessage(msg) {
6351
- this.lifecycle.cancelSleepShutdown();
6352
5763
  if (this.inputResolver) {
6353
5764
  const resolve2 = this.inputResolver;
6354
5765
  this.inputResolver = null;
@@ -6509,7 +5920,9 @@ var SessionRunner = class _SessionRunner {
6509
5920
  taskTagIds: ctx.taskTagIds ?? void 0,
6510
5921
  projectObjectives: ctx.projectObjectives ?? void 0,
6511
5922
  incidents: ctx.incidents ?? void 0,
6512
- agentSettings: ctx.agentSettings ?? null
5923
+ agentSettings: ctx.agentSettings ?? null,
5924
+ agentMode: ctx.agentMode ?? void 0,
5925
+ isAuto: ctx.isAuto
6513
5926
  };
6514
5927
  }
6515
5928
  createQueryBridge() {
@@ -6567,7 +5980,6 @@ var SessionRunner = class _SessionRunner {
6567
5980
  this.softStop();
6568
5981
  }
6569
5982
  });
6570
- this.connection.onWake(() => this.lifecycle.wake());
6571
5983
  this.connection.onApiKeyUpdate((data) => {
6572
5984
  if (data.isSubscription) {
6573
5985
  process.env.CLAUDE_CODE_OAUTH_TOKEN = data.apiKey;
@@ -6590,6 +6002,12 @@ var SessionRunner = class _SessionRunner {
6590
6002
  this.lifecycle.destroy();
6591
6003
  await this.setState(finalState);
6592
6004
  this.connection.disconnect();
6005
+ this._finalState = finalState;
6006
+ }
6007
+ _finalState = null;
6008
+ /** The final status after run() completes. Use to determine exit code. */
6009
+ get finalState() {
6010
+ return this._finalState;
6593
6011
  }
6594
6012
  logInitialization() {
6595
6013
  const context = {
@@ -6736,6 +6154,9 @@ var ProjectConnection = class {
6736
6154
  onAuditTags(callback) {
6737
6155
  this.requireSocket().on("projectRunner:auditTags", callback);
6738
6156
  }
6157
+ onAuditTasks(callback) {
6158
+ this.requireSocket().on("projectRunner:auditTasks", callback);
6159
+ }
6739
6160
  // ── Outgoing helpers ───────────────────────────────────────────────────
6740
6161
  sendHeartbeat() {
6741
6162
  void this.call("projectRunnerHeartbeat", { projectId: this.config.projectId }).catch(() => {
@@ -7020,7 +6441,7 @@ import * as path from "path";
7020
6441
  import { fileURLToPath as fileURLToPath2 } from "url";
7021
6442
 
7022
6443
  // src/tools/project-tools.ts
7023
- import { z as z11 } from "zod";
6444
+ import { z as z8 } from "zod";
7024
6445
  function buildTaskListTools(connection) {
7025
6446
  const projectId = connection.projectId;
7026
6447
  return [
@@ -7028,9 +6449,9 @@ function buildTaskListTools(connection) {
7028
6449
  "list_tasks",
7029
6450
  "List tasks in the project. Optionally filter by status or assignee.",
7030
6451
  {
7031
- status: z11.string().optional().describe("Filter by task status"),
7032
- assigneeId: z11.string().optional().describe("Filter by assigned user ID"),
7033
- limit: z11.number().optional().describe("Max number of tasks to return (default 50)")
6452
+ status: z8.string().optional().describe("Filter by task status"),
6453
+ assigneeId: z8.string().optional().describe("Filter by assigned user ID"),
6454
+ limit: z8.number().optional().describe("Max number of tasks to return (default 50)")
7034
6455
  },
7035
6456
  async (params) => {
7036
6457
  try {
@@ -7047,7 +6468,7 @@ function buildTaskListTools(connection) {
7047
6468
  defineTool(
7048
6469
  "get_task",
7049
6470
  "Get detailed information about a task including chat messages, child tasks, and session.",
7050
- { task_id: z11.string().describe("The task ID to look up") },
6471
+ { task_id: z8.string().describe("The task ID to look up") },
7051
6472
  async ({ task_id }) => {
7052
6473
  try {
7053
6474
  const task = await connection.call("getProjectTask", { projectId, taskId: task_id });
@@ -7064,10 +6485,10 @@ function buildTaskListTools(connection) {
7064
6485
  "search_tasks",
7065
6486
  "Search tasks by tags, text query, or status filters.",
7066
6487
  {
7067
- tagNames: z11.array(z11.string()).optional().describe("Filter by tag names"),
7068
- searchQuery: z11.string().optional().describe("Text search in title/description"),
7069
- statusFilters: z11.array(z11.string()).optional().describe("Filter by statuses"),
7070
- limit: z11.number().optional().describe("Max results (default 20)")
6488
+ tagNames: z8.array(z8.string()).optional().describe("Filter by tag names"),
6489
+ searchQuery: z8.string().optional().describe("Text search in title/description"),
6490
+ statusFilters: z8.array(z8.string()).optional().describe("Filter by statuses"),
6491
+ limit: z8.number().optional().describe("Max results (default 20)")
7071
6492
  },
7072
6493
  async (params) => {
7073
6494
  try {
@@ -7127,11 +6548,11 @@ function buildMutationTools(connection) {
7127
6548
  "create_task",
7128
6549
  "Create a new task in the project.",
7129
6550
  {
7130
- title: z11.string().describe("Task title"),
7131
- description: z11.string().optional().describe("Task description"),
7132
- plan: z11.string().optional().describe("Implementation plan in markdown"),
7133
- status: z11.string().optional().describe("Initial status (default: Planning)"),
7134
- isBug: z11.boolean().optional().describe("Whether this is a bug report")
6551
+ title: z8.string().describe("Task title"),
6552
+ description: z8.string().optional().describe("Task description"),
6553
+ plan: z8.string().optional().describe("Implementation plan in markdown"),
6554
+ status: z8.string().optional().describe("Initial status (default: Planning)"),
6555
+ isBug: z8.boolean().optional().describe("Whether this is a bug report")
7135
6556
  },
7136
6557
  async (params) => {
7137
6558
  try {
@@ -7148,12 +6569,12 @@ function buildMutationTools(connection) {
7148
6569
  "update_task",
7149
6570
  "Update an existing task's title, description, plan, status, or assignee.",
7150
6571
  {
7151
- task_id: z11.string().describe("The task ID to update"),
7152
- title: z11.string().optional().describe("New title"),
7153
- description: z11.string().optional().describe("New description"),
7154
- plan: z11.string().optional().describe("New plan in markdown"),
7155
- status: z11.string().optional().describe("New status"),
7156
- assignedUserId: z11.string().nullable().optional().describe("Assign to user ID, or null to unassign")
6572
+ task_id: z8.string().describe("The task ID to update"),
6573
+ title: z8.string().optional().describe("New title"),
6574
+ description: z8.string().optional().describe("New description"),
6575
+ plan: z8.string().optional().describe("New plan in markdown"),
6576
+ status: z8.string().optional().describe("New status"),
6577
+ assignedUserId: z8.string().nullable().optional().describe("Assign to user ID, or null to unassign")
7157
6578
  },
7158
6579
  async ({ task_id, ...fields }) => {
7159
6580
  try {
@@ -7604,6 +7025,7 @@ var ProjectRunner = class {
7604
7025
  );
7605
7026
  });
7606
7027
  this.connection.onAuditTags((request) => void this.handleAuditTags(request));
7028
+ this.connection.onAuditTasks((request) => void this.handleAuditTasks(request));
7607
7029
  this.connection.onSwitchBranch((data, cb) => void this.handleSwitchBranch(data, cb));
7608
7030
  this.connection.onSyncEnvironment((cb) => void this.handleSyncEnvironment(cb));
7609
7031
  this.connection.onRestartStartCommand((cb) => {
@@ -7648,6 +7070,47 @@ var ProjectRunner = class {
7648
7070
  this.connection.emitStatus("idle");
7649
7071
  }
7650
7072
  }
7073
+ // ── Task audit ─────────────────────────────────────────────────────────
7074
+ async handleAuditTasks(request) {
7075
+ this.connection.emitStatus("busy");
7076
+ try {
7077
+ const { handleTaskAudit } = await import("./task-audit-handler-URD2BOC4.js");
7078
+ await handleTaskAudit(request, this.connection, this.projectDir);
7079
+ } catch (error) {
7080
+ const msg = error instanceof Error ? error.message : String(error);
7081
+ logger7.error("Task audit failed", { error: msg, requestId: request.requestId });
7082
+ for (const task of request.tasks) {
7083
+ try {
7084
+ await this.connection.call("reportTaskAuditResult", {
7085
+ projectId: this.connection.projectId,
7086
+ requestId: request.requestId,
7087
+ taskId: task.taskId,
7088
+ summary: "",
7089
+ turnGrades: [],
7090
+ planningAccuracy: null,
7091
+ buildingAccuracy: null,
7092
+ humanAccuracy: null,
7093
+ planningCorrect: 0,
7094
+ planningNeutral: 0,
7095
+ planningBlunder: 0,
7096
+ buildingCorrect: 0,
7097
+ buildingNeutral: 0,
7098
+ buildingBlunder: 0,
7099
+ humanCorrect: 0,
7100
+ humanNeutral: 0,
7101
+ humanBlunder: 0,
7102
+ suggestionIds: [],
7103
+ auditCostUsd: null,
7104
+ model: null,
7105
+ error: `Audit failed: ${msg}`
7106
+ });
7107
+ } catch {
7108
+ }
7109
+ }
7110
+ } finally {
7111
+ this.connection.emitStatus("idle");
7112
+ }
7113
+ }
7651
7114
  // ── Task management ────────────────────────────────────────────────────
7652
7115
  async killAgent(agent, taskId) {
7653
7116
  const shortId = taskId.slice(0, 8);
@@ -8051,4 +7514,4 @@ export {
8051
7514
  loadForwardPorts,
8052
7515
  loadConveyorConfig
8053
7516
  };
8054
- //# sourceMappingURL=chunk-AZ6CRVYN.js.map
7517
+ //# sourceMappingURL=chunk-36TKGT6T.js.map