granclaw 0.0.1-beta.56 → 0.0.1-beta.57
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.
|
@@ -1174,6 +1174,7 @@ async function runAgent(agent, message, onChunk, options) {
|
|
|
1174
1174
|
// pi emits AgentEvent (from pi-agent-core) and AgentSessionEvent
|
|
1175
1175
|
// (extended by pi-coding-agent). We translate the subset we care about
|
|
1176
1176
|
// into StreamChunk.
|
|
1177
|
+
let errorEmitted = false;
|
|
1177
1178
|
session.subscribe((event) => {
|
|
1178
1179
|
try {
|
|
1179
1180
|
switch (event.type) {
|
|
@@ -1214,6 +1215,7 @@ async function runAgent(agent, message, onChunk, options) {
|
|
|
1214
1215
|
if (Array.isArray(messages)) {
|
|
1215
1216
|
const last = messages[messages.length - 1];
|
|
1216
1217
|
if (last?.role === 'assistant' && last.errorMessage) {
|
|
1218
|
+
errorEmitted = true;
|
|
1217
1219
|
onChunk({ type: 'error', message: last.errorMessage });
|
|
1218
1220
|
(0, logs_db_js_1.logAction)(agent.id, 'error', null, { message: last.errorMessage });
|
|
1219
1221
|
}
|
|
@@ -1254,7 +1256,9 @@ async function runAgent(agent, message, onChunk, options) {
|
|
|
1254
1256
|
onChunk({ type: 'agent_ready', name });
|
|
1255
1257
|
}
|
|
1256
1258
|
}
|
|
1257
|
-
|
|
1259
|
+
if (!errorEmitted) {
|
|
1260
|
+
onChunk({ type: 'done', sessionId });
|
|
1261
|
+
}
|
|
1258
1262
|
}
|
|
1259
1263
|
catch (err) {
|
|
1260
1264
|
const msg = err instanceof Error ? err.message : String(err);
|