@groupchatai/claude-runner 0.4.9 → 0.4.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.
- package/dist/index.js +67 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -127,6 +127,14 @@ ${comment.body}`
|
|
|
127
127
|
);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
+
if (detail.lastFollowUpMessage) {
|
|
131
|
+
parts.push(
|
|
132
|
+
`
|
|
133
|
+
## Latest Follow-up Request
|
|
134
|
+
The user has sent a follow-up message. Address this:
|
|
135
|
+
${detail.lastFollowUpMessage}`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
130
138
|
const existingPrUrl = detail.pullRequestUrl ?? detail.task.pullRequestUrl;
|
|
131
139
|
if (existingPrUrl) {
|
|
132
140
|
parts.push(`
|
|
@@ -932,6 +940,23 @@ async function processRun(client, run, config, worktreeDir, detail, runBaseDir,
|
|
|
932
940
|
const logGreen = (msg) => console.log(`${runTag} ${C.green}${msg}${C.reset}`);
|
|
933
941
|
const ownerName = run.owner?.name ?? detail.owner?.name ?? "unknown";
|
|
934
942
|
log(`\u{1F4CB} "${run.taskTitle}" \u2014 delegated by ${ownerName}`);
|
|
943
|
+
if (config.verbose) {
|
|
944
|
+
log(`\u{1F4CE} Run ID: ${run.id} | Task ID: ${run.taskId}`);
|
|
945
|
+
log(
|
|
946
|
+
`\u{1F4CE} Detail status: ${detail.status} | Has lastFollowUpMessage: ${!!detail.lastFollowUpMessage} | Has lastSessionId: ${!!detail.lastSessionId}`
|
|
947
|
+
);
|
|
948
|
+
log(
|
|
949
|
+
`\u{1F4CE} In-memory session cache hit: ${sessionCache.has(run.taskId)} | Activity items: ${detail.activity.length}`
|
|
950
|
+
);
|
|
951
|
+
if (detail.lastFollowUpMessage) {
|
|
952
|
+
log(
|
|
953
|
+
`\u{1F4CE} lastFollowUpMessage: "${detail.lastFollowUpMessage.slice(0, 150)}${detail.lastFollowUpMessage.length > 150 ? "\u2026" : ""}"`
|
|
954
|
+
);
|
|
955
|
+
}
|
|
956
|
+
if (detail.lastSessionId) {
|
|
957
|
+
log(`\u{1F4CE} Server lastSessionId: ${detail.lastSessionId.slice(0, 12)}\u2026`);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
935
960
|
if (detail.status !== "PENDING") {
|
|
936
961
|
log(`\u23ED Run is no longer PENDING (now ${detail.status}), skipping.`);
|
|
937
962
|
return;
|
|
@@ -975,16 +1000,43 @@ async function processRun(client, run, config, worktreeDir, detail, runBaseDir,
|
|
|
975
1000
|
});
|
|
976
1001
|
await new Promise((resolve) => git.on("close", () => resolve()));
|
|
977
1002
|
}
|
|
978
|
-
const cachedSessionId = sessionCache.get(run.taskId);
|
|
1003
|
+
const cachedSessionId = sessionCache.get(run.taskId) ?? detail.lastSessionId;
|
|
979
1004
|
const isFollowUp = cachedSessionId !== void 0;
|
|
980
|
-
|
|
1005
|
+
let effectivePrompt;
|
|
1006
|
+
if (isFollowUp && detail.lastFollowUpMessage) {
|
|
1007
|
+
effectivePrompt = detail.lastFollowUpMessage;
|
|
1008
|
+
} else if (isFollowUp) {
|
|
1009
|
+
effectivePrompt = prompt;
|
|
1010
|
+
} else {
|
|
1011
|
+
effectivePrompt = prompt;
|
|
1012
|
+
}
|
|
981
1013
|
const resumeSession = isFollowUp ? cachedSessionId : void 0;
|
|
982
1014
|
if (config.verbose) {
|
|
983
1015
|
if (isFollowUp) {
|
|
984
|
-
|
|
1016
|
+
const sessionSource = sessionCache.has(run.taskId) ? "in-memory cache" : "server (lastSessionId)";
|
|
1017
|
+
log(`\u{1F504} Resuming session ${cachedSessionId.slice(0, 12)}\u2026 (source: ${sessionSource})`);
|
|
1018
|
+
if (detail.lastFollowUpMessage) {
|
|
1019
|
+
log(
|
|
1020
|
+
`\u{1F4AC} Follow-up message: "${detail.lastFollowUpMessage.slice(0, 200)}${detail.lastFollowUpMessage.length > 200 ? "\u2026" : ""}"`
|
|
1021
|
+
);
|
|
1022
|
+
} else {
|
|
1023
|
+
log(`\u26A0 No lastFollowUpMessage found \u2014 using full prompt for resumed session`);
|
|
1024
|
+
}
|
|
1025
|
+
} else {
|
|
1026
|
+
log(`\u{1F195} Initial run (no session to resume)`);
|
|
985
1027
|
}
|
|
986
|
-
log(
|
|
1028
|
+
log(
|
|
1029
|
+
`\u{1F4DD} Prompt (${effectivePrompt.length} chars)${isFollowUp ? " [follow-up]" : " [initial]"}`
|
|
1030
|
+
);
|
|
1031
|
+
const previewLen = 500;
|
|
1032
|
+
log(
|
|
1033
|
+
`\u{1F4DD} Prompt preview:
|
|
1034
|
+
${effectivePrompt.slice(0, previewLen)}${effectivePrompt.length > previewLen ? "\n... (truncated)" : ""}`
|
|
1035
|
+
);
|
|
987
1036
|
if (effectiveModel) log(`\u{1F9E0} Model: ${effectiveModel}`);
|
|
1037
|
+
log(
|
|
1038
|
+
`\u{1F4CA} Activity items: ${detail.activity.length}, Comments: ${detail.activity.filter((a) => a.type === "comment").length}`
|
|
1039
|
+
);
|
|
988
1040
|
}
|
|
989
1041
|
const { process: child, output } = spawnClaudeCode(
|
|
990
1042
|
effectivePrompt,
|
|
@@ -1017,6 +1069,9 @@ async function processRun(client, run, config, worktreeDir, detail, runBaseDir,
|
|
|
1017
1069
|
}
|
|
1018
1070
|
if (sessionId) {
|
|
1019
1071
|
sessionCache.set(run.taskId, sessionId);
|
|
1072
|
+
if (config.verbose) {
|
|
1073
|
+
log(`\u{1F4BE} Session ${sessionId.slice(0, 12)}\u2026 cached for task ${run.taskId}`);
|
|
1074
|
+
}
|
|
1020
1075
|
}
|
|
1021
1076
|
const pullRequestUrl = streamPrUrl ?? await detectPullRequestUrl(effectiveCwd) ?? extractPullRequestUrlFromOutput(stdout) ?? extractPullRequestUrlFromOutput(rawOutput);
|
|
1022
1077
|
const streamEvents = parseClaudeNdjsonEvents(rawOutput);
|
|
@@ -1051,7 +1106,8 @@ async function processRun(client, run, config, worktreeDir, detail, runBaseDir,
|
|
|
1051
1106
|
await client.errorRun(run.id, errorMsg, {
|
|
1052
1107
|
pullRequestUrl,
|
|
1053
1108
|
errorType: retryInfo?.errorType,
|
|
1054
|
-
retryAfter: retryInfo?.retryAfterMs
|
|
1109
|
+
retryAfter: retryInfo?.retryAfterMs,
|
|
1110
|
+
sessionId: lastClaude.sessionId
|
|
1055
1111
|
});
|
|
1056
1112
|
if (retryInfo) {
|
|
1057
1113
|
const retryAt = new Date(retryInfo.retryAfterMs).toLocaleString(void 0, {
|
|
@@ -1082,7 +1138,11 @@ async function processRun(client, run, config, worktreeDir, detail, runBaseDir,
|
|
|
1082
1138
|
}
|
|
1083
1139
|
const resultText = extractResultText(stdout);
|
|
1084
1140
|
const cost = extractCost(stdout);
|
|
1085
|
-
await client.completeRun(run.id, resultText, {
|
|
1141
|
+
await client.completeRun(run.id, resultText, {
|
|
1142
|
+
...cost,
|
|
1143
|
+
pullRequestUrl,
|
|
1144
|
+
sessionId: lastClaude.sessionId
|
|
1145
|
+
});
|
|
1086
1146
|
if (pullRequestUrl) logGreen(`\u{1F517} PR: ${pullRequestUrl}`);
|
|
1087
1147
|
logGreen(`\u2705 Run completed`);
|
|
1088
1148
|
} catch (err) {
|
|
@@ -1114,7 +1174,7 @@ async function processRun(client, run, config, worktreeDir, detail, runBaseDir,
|
|
|
1114
1174
|
${message.slice(0, 2e3)}
|
|
1115
1175
|
\`\`\``;
|
|
1116
1176
|
try {
|
|
1117
|
-
await client.errorRun(run.id, errorBody);
|
|
1177
|
+
await client.errorRun(run.id, errorBody, { sessionId: lastClaude.sessionId });
|
|
1118
1178
|
} catch {
|
|
1119
1179
|
log(`${C.dim}\u26A0 Failed to report error to API${C.reset}`);
|
|
1120
1180
|
}
|