oh-pi 0.1.63 → 0.1.65
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/package.json
CHANGED
|
@@ -191,9 +191,21 @@ export default function antColonyExtension(pi: ExtensionAPI) {
|
|
|
191
191
|
promise: null as any, // set below
|
|
192
192
|
};
|
|
193
193
|
|
|
194
|
+
let lastPhase = "";
|
|
195
|
+
|
|
194
196
|
const callbacks: QueenCallbacks = {
|
|
195
197
|
onSignal(signal) {
|
|
196
198
|
colony.phase = signal.message;
|
|
199
|
+
// 阶段切换时注入消息到主进程对话流
|
|
200
|
+
if (signal.phase !== lastPhase) {
|
|
201
|
+
lastPhase = signal.phase;
|
|
202
|
+
const pct = Math.round(signal.progress * 100);
|
|
203
|
+
pi.sendMessage({
|
|
204
|
+
customType: "ant-colony-progress",
|
|
205
|
+
content: `[COLONY_SIGNAL:${signal.phase.toUpperCase()}] 🐜 ${signal.message} (${pct}%, ${formatCost(signal.cost)})`,
|
|
206
|
+
display: false,
|
|
207
|
+
}, { triggerTurn: false, deliverAs: "followUp" });
|
|
208
|
+
}
|
|
197
209
|
throttledRender();
|
|
198
210
|
},
|
|
199
211
|
onPhase(phase, detail) {
|
|
@@ -206,8 +218,18 @@ export default function antColonyExtension(pi: ExtensionAPI) {
|
|
|
206
218
|
});
|
|
207
219
|
throttledRender();
|
|
208
220
|
},
|
|
209
|
-
onAntDone(ant) {
|
|
221
|
+
onAntDone(ant, task) {
|
|
210
222
|
colony.antStreams.delete(ant.id);
|
|
223
|
+
// 每个任务完成时注入一句话到主进程
|
|
224
|
+
const m = colony.state?.metrics;
|
|
225
|
+
const icon = ant.status === "done" ? "✓" : "✗";
|
|
226
|
+
const progress = m ? `${m.tasksDone}/${m.tasksTotal}` : "";
|
|
227
|
+
const cost = m ? formatCost(m.totalCost) : "";
|
|
228
|
+
pi.sendMessage({
|
|
229
|
+
customType: "ant-colony-progress",
|
|
230
|
+
content: `[COLONY_SIGNAL:TASK_DONE] 🐜 ${icon} ${task.title.slice(0, 60)} (${progress}, ${cost})`,
|
|
231
|
+
display: false,
|
|
232
|
+
}, { triggerTurn: false, deliverAs: "followUp" });
|
|
211
233
|
throttledRender();
|
|
212
234
|
},
|
|
213
235
|
onAntStream(event: AntStreamEvent) {
|