@nowcrew/daemon 0.5.6 → 0.5.8
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/runner.js +6 -2
- package/dist/session.js +5 -0
- package/package.json +1 -1
package/dist/runner.js
CHANGED
|
@@ -69,9 +69,11 @@ onConsole = () => { }) {
|
|
|
69
69
|
: !config.resume ? "resume_disabled"
|
|
70
70
|
: !ws.sessionResume ? "first_run"
|
|
71
71
|
: resuming ? (nearBudget ? "warm_resume_near_budget" : "warm_resume")
|
|
72
|
-
:
|
|
73
|
-
: "
|
|
72
|
+
: prior?.lastExitOk === false ? "prior_run_crashed"
|
|
73
|
+
: rotatedForBudget ? "rotated_for_budget"
|
|
74
|
+
: "warm_window_expired_or_model_changed",
|
|
74
75
|
prior_context_tokens: prior?.contextTokens ?? null,
|
|
76
|
+
prior_last_exit_ok: prior?.lastExitOk ?? null,
|
|
75
77
|
budget_tokens: config.sessionBudgetTokens,
|
|
76
78
|
});
|
|
77
79
|
const systemPrompt = buildSystemPrompt({
|
|
@@ -269,6 +271,8 @@ onConsole = () => { }) {
|
|
|
269
271
|
turns: resuming ? (prior?.turns ?? 0) + 1 : 1,
|
|
270
272
|
model: currentModel,
|
|
271
273
|
providerFingerprint: providerFp,
|
|
274
|
+
// 非零退出(崩溃/超窗/被杀)标记本会话不健康 → 下轮 pickResumeId 强制冷启动,不再续这个坏会话。
|
|
275
|
+
lastExitOk: exitCode === 0,
|
|
272
276
|
...(contextTokens != null ? { contextTokens } : {}),
|
|
273
277
|
});
|
|
274
278
|
}
|
package/dist/session.js
CHANGED
|
@@ -30,6 +30,7 @@ export async function readSession(runDir) {
|
|
|
30
30
|
model: typeof o.model === "string" ? o.model : null,
|
|
31
31
|
providerFingerprint: typeof o.providerFingerprint === "string" ? o.providerFingerprint : null,
|
|
32
32
|
...(typeof o.contextTokens === "number" && o.contextTokens >= 0 ? { contextTokens: o.contextTokens } : {}),
|
|
33
|
+
...(typeof o.lastExitOk === "boolean" ? { lastExitOk: o.lastExitOk } : {}),
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
catch {
|
|
@@ -60,6 +61,10 @@ export function pickResumeId(prior, now, warmMs, currentModel = null, budgetToke
|
|
|
60
61
|
// 下,--resume 会直接报错,必须冷启动。
|
|
61
62
|
if ((prior.providerFingerprint ?? null) !== currentProviderFingerprint)
|
|
62
63
|
return null;
|
|
64
|
+
// 上轮崩溃/超窗/被杀:会话大概率已污染(或就是太大),续用几乎必再崩。强制冷启动斩断循环——
|
|
65
|
+
// 这条不依赖 token 记账是否准确(OOM/SIGKILL 时没有 usage,预算判断会漏,此条兜底)。
|
|
66
|
+
if (prior.lastExitOk === false)
|
|
67
|
+
return null;
|
|
63
68
|
if (warmMs > 0 && now - prior.lastRunAt > warmMs)
|
|
64
69
|
return null;
|
|
65
70
|
if (budgetTokens > 0 && (prior.contextTokens ?? 0) >= budgetTokens)
|