ai-project-manage-cli 8.1.17 → 8.1.18
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/worker-script.js +46 -15
- package/package.json +1 -1
package/dist/worker-script.js
CHANGED
|
@@ -2692,27 +2692,57 @@ async function openSqliteLocalAgentStore(workspaceRef) {
|
|
|
2692
2692
|
sqliteByKey.set(cwd, pending2);
|
|
2693
2693
|
return pending2;
|
|
2694
2694
|
}
|
|
2695
|
+
function jsonSafePayload(value) {
|
|
2696
|
+
if (value == null) return null;
|
|
2697
|
+
try {
|
|
2698
|
+
return JSON.parse(JSON.stringify(value));
|
|
2699
|
+
} catch {
|
|
2700
|
+
return null;
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2695
2703
|
function mirrorRunEventsForVisualization(cfg2, local) {
|
|
2696
2704
|
const api = createApmApiClient(cfg2);
|
|
2705
|
+
const queues = /* @__PURE__ */ new Map();
|
|
2706
|
+
const draining = /* @__PURE__ */ new Set();
|
|
2707
|
+
const drain = async (runId) => {
|
|
2708
|
+
if (draining.has(runId)) return;
|
|
2709
|
+
draining.add(runId);
|
|
2710
|
+
try {
|
|
2711
|
+
for (; ; ) {
|
|
2712
|
+
const pending2 = queues.get(runId);
|
|
2713
|
+
if (!pending2 || pending2.length === 0) {
|
|
2714
|
+
queues.delete(runId);
|
|
2715
|
+
return;
|
|
2716
|
+
}
|
|
2717
|
+
const batch = pending2.splice(0, 200);
|
|
2718
|
+
try {
|
|
2719
|
+
await api.cli.cursorStoreAppendRunEvents({ events: batch });
|
|
2720
|
+
} catch (err) {
|
|
2721
|
+
console.warn(
|
|
2722
|
+
`[apm] runEvents \u53EF\u89C6\u5316\u540C\u6B65\u5931\u8D25 runId=${runId} n=${batch.length}:`,
|
|
2723
|
+
err instanceof Error ? err.message : err
|
|
2724
|
+
);
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
} finally {
|
|
2728
|
+
draining.delete(runId);
|
|
2729
|
+
if ((queues.get(runId)?.length ?? 0) > 0) void drain(runId);
|
|
2730
|
+
}
|
|
2731
|
+
};
|
|
2697
2732
|
return {
|
|
2698
2733
|
async append(input) {
|
|
2699
2734
|
const row = await local.append(input);
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
}
|
|
2709
|
-
]
|
|
2710
|
-
}).catch((err) => {
|
|
2711
|
-
console.warn(
|
|
2712
|
-
`[apm] runEvents \u53EF\u89C6\u5316\u540C\u6B65\u5931\u8D25 runId=${input.runId}:`,
|
|
2713
|
-
err instanceof Error ? err.message : err
|
|
2714
|
-
);
|
|
2735
|
+
const queued = queues.get(input.runId) ?? [];
|
|
2736
|
+
queued.push({
|
|
2737
|
+
runId: input.runId,
|
|
2738
|
+
eventType: input.eventType,
|
|
2739
|
+
payload: jsonSafePayload(input.payload),
|
|
2740
|
+
payloadRef: input.payloadRef ?? null,
|
|
2741
|
+
idempotencyKey: input.idempotencyKey ?? `${input.runId}:${row.seq}`,
|
|
2742
|
+
createdAt: row.createdAt
|
|
2715
2743
|
});
|
|
2744
|
+
queues.set(input.runId, queued);
|
|
2745
|
+
void drain(input.runId);
|
|
2716
2746
|
return row;
|
|
2717
2747
|
},
|
|
2718
2748
|
list: (input) => local.list(input),
|
|
@@ -2720,6 +2750,7 @@ function mirrorRunEventsForVisualization(cfg2, local) {
|
|
|
2720
2750
|
await local.delete(input);
|
|
2721
2751
|
const runIds = input.filter.runIds?.map((id) => id.trim()).filter(Boolean);
|
|
2722
2752
|
if (!runIds?.length) return;
|
|
2753
|
+
for (const runId of runIds) queues.delete(runId);
|
|
2723
2754
|
void api.cli.cursorStoreDeleteRunEvents({ runIds }).catch((err) => {
|
|
2724
2755
|
console.warn(
|
|
2725
2756
|
`[apm] runEvents \u53EF\u89C6\u5316\u6E05\u7406\u5931\u8D25:`,
|