@keyou007/agent-bot 0.1.25-alpha.0 → 0.1.25-alpha.2
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/CHANGELOG.md +27 -0
- package/README.md +60 -5
- package/README.zh.md +60 -5
- package/config.example.yaml +1 -3
- package/dist/cli/controlProtocol.js.map +1 -1
- package/dist/cli/help.js +14 -0
- package/dist/cli/help.js.map +1 -1
- package/dist/cli.js +32 -0
- package/dist/cli.js.map +1 -1
- package/dist/codex/CodexRuntime.js +15 -5
- package/dist/codex/CodexRuntime.js.map +1 -1
- package/dist/commands/CommandRouter.js +7 -0
- package/dist/commands/CommandRouter.js.map +1 -1
- package/dist/config/SettingsStore.js +341 -0
- package/dist/config/SettingsStore.js.map +1 -0
- package/dist/config/loadConfig.js +1 -2
- package/dist/config/loadConfig.js.map +1 -1
- package/dist/config/schema.js +0 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/console/ConsoleTurnPresenter.js +3 -0
- package/dist/console/ConsoleTurnPresenter.js.map +1 -1
- package/dist/feishu/CardRenderer.js +32 -96
- package/dist/feishu/CardRenderer.js.map +1 -1
- package/dist/feishu/FeishuConnector.js +9 -0
- package/dist/feishu/FeishuConnector.js.map +1 -1
- package/dist/feishu/FeishuMessageClient.js +35 -14
- package/dist/feishu/FeishuMessageClient.js.map +1 -1
- package/dist/feishu/FeishuTurnPresenter.js +36 -23
- package/dist/feishu/FeishuTurnPresenter.js.map +1 -1
- package/dist/feishu/LocalCardImage.js.map +1 -1
- package/dist/feishu/LocalImageMarkdown.js +59 -3
- package/dist/feishu/LocalImageMarkdown.js.map +1 -1
- package/dist/feishu/SettingsCard.js +199 -0
- package/dist/feishu/SettingsCard.js.map +1 -0
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/dist/local-files/TurnPreviewPage.js +8 -4
- package/dist/local-files/TurnPreviewPage.js.map +1 -1
- package/dist/presentation/TurnStateReducer.js +21 -2
- package/dist/presentation/TurnStateReducer.js.map +1 -1
- package/dist/presentation/turnStatus.js +34 -0
- package/dist/presentation/turnStatus.js.map +1 -0
- package/dist/proxy/ProxySessionController.js +688 -153
- package/dist/proxy/ProxySessionController.js.map +1 -1
- package/dist/runtime/submissionErrors.js +15 -0
- package/dist/runtime/submissionErrors.js.map +1 -0
- package/dist/scheduling/ScheduleCards.js +240 -0
- package/dist/scheduling/ScheduleCards.js.map +1 -0
- package/dist/scheduling/ScheduleCommand.js +67 -0
- package/dist/scheduling/ScheduleCommand.js.map +1 -0
- package/dist/scheduling/ScheduledTaskStore.js +226 -0
- package/dist/scheduling/ScheduledTaskStore.js.map +1 -0
- package/dist/scheduling/TaskScheduler.js +132 -0
- package/dist/scheduling/TaskScheduler.js.map +1 -0
- package/dist/scheduling/types.js +89 -0
- package/dist/scheduling/types.js.map +1 -0
- package/dist/state/ExecutionProvenanceStore.js +58 -0
- package/dist/state/ExecutionProvenanceStore.js.map +1 -0
- package/dist/state/StateStore.js +145 -45
- package/dist/state/StateStore.js.map +1 -1
- package/dist/state/migrations.js +37 -0
- package/dist/state/migrations.js.map +1 -1
- package/dist/supervision/SafeRestartNotifier.js +1 -1
- package/dist/supervision/SafeRestartNotifier.js.map +1 -1
- package/docs/technical-reference.md +11 -8
- package/docs/technical-reference.zh.md +11 -8
- package/npm-shrinkwrap.json +24 -2
- package/package.json +2 -1
- package/skills/agent-bot/SKILL.md +33 -3
- package/src/cli/controlProtocol.ts +1 -0
- package/src/cli/help.ts +14 -0
- package/src/cli.ts +25 -0
- package/src/codex/CodexRuntime.ts +14 -5
- package/src/commands/CommandRouter.ts +7 -0
- package/src/commands/commandTypes.ts +2 -0
- package/src/config/SettingsStore.ts +588 -0
- package/src/config/loadConfig.ts +1 -2
- package/src/config/schema.ts +0 -1
- package/src/console/ConsoleTurnPresenter.ts +2 -0
- package/src/feishu/CardRenderer.ts +33 -110
- package/src/feishu/FeishuConnector.ts +9 -0
- package/src/feishu/FeishuMessageClient.ts +39 -17
- package/src/feishu/FeishuTurnPresenter.ts +33 -22
- package/src/feishu/LocalCardImage.ts +0 -1
- package/src/feishu/LocalImageMarkdown.ts +54 -3
- package/src/feishu/SettingsCard.ts +231 -0
- package/src/index.ts +17 -6
- package/src/local-files/TurnPreviewPage.ts +8 -4
- package/src/presentation/TurnStateReducer.ts +21 -2
- package/src/presentation/turnStatus.ts +38 -0
- package/src/presentation/turnViewTypes.ts +3 -0
- package/src/proxy/ProxySessionController.ts +628 -152
- package/src/runtime/submissionErrors.ts +15 -0
- package/src/runtime/types.ts +1 -0
- package/src/scheduling/ScheduleCards.ts +317 -0
- package/src/scheduling/ScheduleCommand.ts +76 -0
- package/src/scheduling/ScheduledTaskStore.ts +332 -0
- package/src/scheduling/TaskScheduler.ts +171 -0
- package/src/scheduling/types.ts +151 -0
- package/src/state/ExecutionProvenanceStore.ts +100 -0
- package/src/state/StateStore.ts +167 -44
- package/src/state/migrations.ts +37 -0
- package/src/supervision/SafeRestartNotifier.ts +1 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { latestScheduleTime } from "./types.js";
|
|
2
|
+
export class TaskScheduler {
|
|
3
|
+
options;
|
|
4
|
+
timer;
|
|
5
|
+
work;
|
|
6
|
+
stopped = true;
|
|
7
|
+
startedAt = 0;
|
|
8
|
+
now;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.options = options;
|
|
11
|
+
this.now = options.now ?? Date.now;
|
|
12
|
+
}
|
|
13
|
+
async start() {
|
|
14
|
+
if (!this.stopped)
|
|
15
|
+
return;
|
|
16
|
+
this.stopped = false;
|
|
17
|
+
this.startedAt = this.now();
|
|
18
|
+
this.work = this.tick(true);
|
|
19
|
+
try {
|
|
20
|
+
await this.work;
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
this.work = undefined;
|
|
24
|
+
}
|
|
25
|
+
if (this.stopped)
|
|
26
|
+
return;
|
|
27
|
+
this.timer = setInterval(() => {
|
|
28
|
+
if (this.work)
|
|
29
|
+
return;
|
|
30
|
+
this.work = this.tick()
|
|
31
|
+
.catch((error) => {
|
|
32
|
+
this.options.logger.warn({ error }, "Scheduled task polling failed.");
|
|
33
|
+
})
|
|
34
|
+
.finally(() => {
|
|
35
|
+
this.work = undefined;
|
|
36
|
+
});
|
|
37
|
+
}, 5_000);
|
|
38
|
+
this.timer.unref();
|
|
39
|
+
}
|
|
40
|
+
async stop() {
|
|
41
|
+
this.stopped = true;
|
|
42
|
+
clearInterval(this.timer);
|
|
43
|
+
await this.work;
|
|
44
|
+
}
|
|
45
|
+
async tick(startup = false) {
|
|
46
|
+
const { store } = this.options;
|
|
47
|
+
const now = this.now();
|
|
48
|
+
const drain = new Set();
|
|
49
|
+
for (const run of store.schedules.pendingRuns()) {
|
|
50
|
+
const job = store.schedules.get(run.jobId);
|
|
51
|
+
if (!job)
|
|
52
|
+
continue;
|
|
53
|
+
const attempt = store.getTurnAttempt(run.id);
|
|
54
|
+
if (run.status !== "unknown" &&
|
|
55
|
+
attempt &&
|
|
56
|
+
["completed", "failed", "cancelled", "interrupted"].includes(attempt.status)) {
|
|
57
|
+
const status = attempt.status === "interrupted"
|
|
58
|
+
? "unknown"
|
|
59
|
+
: attempt.status;
|
|
60
|
+
store.schedules.saveRun({ ...run, turnId: attempt.turnId, status });
|
|
61
|
+
}
|
|
62
|
+
else if (startup &&
|
|
63
|
+
["dispatching", "submitting"].includes(run.status) &&
|
|
64
|
+
!attempt?.turnId) {
|
|
65
|
+
store.schedules.finish(run.id, "unknown", "重启后无法确认是否已提交,未自动重发。请核实执行记录。");
|
|
66
|
+
}
|
|
67
|
+
else if (run.status === "queued") {
|
|
68
|
+
if (!store.schedules.canSubmit(run.id, now)) {
|
|
69
|
+
store.cancelQueuedPrompt(run.id, job.localSessionId);
|
|
70
|
+
await this.notice(job, store.schedules.getRun(run.id)?.detail ?? "本次运行已取消。");
|
|
71
|
+
}
|
|
72
|
+
else if (!store.hasQueuedPrompt(run.id)) {
|
|
73
|
+
store.schedules.finish(run.id, "cancelled", "排队任务已取消。");
|
|
74
|
+
}
|
|
75
|
+
else
|
|
76
|
+
drain.add(job.localSessionId);
|
|
77
|
+
}
|
|
78
|
+
const session = store.getSession(job.localSessionId);
|
|
79
|
+
if (job.status === "enabled" &&
|
|
80
|
+
(!session ||
|
|
81
|
+
session.status === "closed" ||
|
|
82
|
+
job.ownerId !== this.options.ownerId())) {
|
|
83
|
+
const changed = store.schedules.change(job.id, job.revision, "pause", now);
|
|
84
|
+
await this.notice(changed, "目标任务已关闭或所有者已变化,定时计划已暂停。");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (!this.options.canDispatch() || (this.stopped && !startup))
|
|
88
|
+
return;
|
|
89
|
+
for (const job of store.schedules.due(now)) {
|
|
90
|
+
if (!this.options.canDispatch())
|
|
91
|
+
break;
|
|
92
|
+
const session = store.getSession(job.localSessionId);
|
|
93
|
+
if (!session ||
|
|
94
|
+
session.status === "closed" ||
|
|
95
|
+
job.ownerId !== this.options.ownerId()) {
|
|
96
|
+
const changed = store.schedules.change(job.id, job.revision, "pause", now);
|
|
97
|
+
await this.notice(changed, "目标任务已关闭或所有者已变化,定时计划已暂停。");
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const missed = startup ||
|
|
101
|
+
job.nextRunAt <= this.startedAt ||
|
|
102
|
+
now - job.nextRunAt > 60_000;
|
|
103
|
+
const scheduledFor = missed
|
|
104
|
+
? latestScheduleTime(job.spec, now)
|
|
105
|
+
: job.nextRunAt;
|
|
106
|
+
const skip = missed &&
|
|
107
|
+
(job.spec.catchUpMinutes === 0 ||
|
|
108
|
+
now - scheduledFor > job.spec.catchUpMinutes * 60_000)
|
|
109
|
+
? "停服、休眠或调度延迟,已跳过错过的计划。"
|
|
110
|
+
: undefined;
|
|
111
|
+
const run = store.schedules.dispatch(job, scheduledFor, now, { skip });
|
|
112
|
+
if (run?.status === "queued")
|
|
113
|
+
drain.add(job.localSessionId);
|
|
114
|
+
else if (run && skip)
|
|
115
|
+
await this.notice(store.schedules.get(job.id), run.detail);
|
|
116
|
+
}
|
|
117
|
+
for (const sessionId of drain) {
|
|
118
|
+
if (!this.options.canDispatch())
|
|
119
|
+
break;
|
|
120
|
+
await this.options.drain(sessionId);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async notice(job, text) {
|
|
124
|
+
try {
|
|
125
|
+
await this.options.notify(job, `定时任务「${job.spec.name}」:${text}`);
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
this.options.logger.warn({ error, scheduleId: job.id }, "Failed to deliver scheduled task notice.");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=TaskScheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskScheduler.js","sourceRoot":"","sources":["../../src/scheduling/TaskScheduler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,YAAY,CAAC;AAYnE,MAAM,OAAO,aAAa;IAOK,OAAO;IAN5B,KAAK,CAAkC;IACvC,IAAI,CAAiB;IACrB,OAAO,GAAG,IAAI,CAAC;IACf,SAAS,GAAG,CAAC,CAAC;IACL,GAAG,CAAe;IAEnC,YAA6B,OAAyB;uBAAzB,OAAO;QAClC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO;QAC1B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,IAAI,CAAC;QAClB,CAAC;gBAAS,CAAC;YACT,IAAI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AAC;IAEO,KAAK,CAAC,MAAM,CAAC,GAAiB,EAAE,IAAY;QAClD,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,QAAQ,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC,CAAC;QACnE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CACtB,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,EAAE,EAC7B,0CAA0C,CAC3C,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CronExpressionParser } from "cron-parser";
|
|
3
|
+
export const scheduleInputSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
name: z.string().trim().min(1).max(120).default("定时任务"),
|
|
6
|
+
prompt: z.string().trim().min(1).max(1_000),
|
|
7
|
+
cron: z.string().trim().min(1).max(120).optional(),
|
|
8
|
+
at: z.string().trim().datetime({ offset: true }).optional(),
|
|
9
|
+
timeZone: z
|
|
10
|
+
.string()
|
|
11
|
+
.trim()
|
|
12
|
+
.default(Intl.DateTimeFormat().resolvedOptions().timeZone),
|
|
13
|
+
maxDelayMinutes: z.number().int().min(1).max(10_080).default(60),
|
|
14
|
+
catchUpMinutes: z.number().int().min(0).max(10_080).default(0),
|
|
15
|
+
})
|
|
16
|
+
.strict()
|
|
17
|
+
.superRefine((value, context) => {
|
|
18
|
+
if (Boolean(value.cron) === Boolean(value.at)) {
|
|
19
|
+
context.addIssue({
|
|
20
|
+
code: "custom",
|
|
21
|
+
message: "请且仅指定 Cron 或带时区的 ISO 执行时间。",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
new Intl.DateTimeFormat("en", { timeZone: value.timeZone }).format();
|
|
26
|
+
if (value.cron) {
|
|
27
|
+
if (value.cron.split(/\s+/).length !== 5)
|
|
28
|
+
throw new Error("Cron 使用五段格式,最小间隔一分钟。");
|
|
29
|
+
CronExpressionParser.parse(value.cron, { tz: value.timeZone }).next();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
context.addIssue({
|
|
34
|
+
code: "custom",
|
|
35
|
+
message: error instanceof Error ? error.message : "时间规则无效。",
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
export const scheduleCommandSchema = z
|
|
40
|
+
.object({
|
|
41
|
+
operation: z.enum([
|
|
42
|
+
"list",
|
|
43
|
+
"add",
|
|
44
|
+
"edit",
|
|
45
|
+
"show",
|
|
46
|
+
"history",
|
|
47
|
+
"pause",
|
|
48
|
+
"resume",
|
|
49
|
+
"run",
|
|
50
|
+
"delete",
|
|
51
|
+
]),
|
|
52
|
+
id: z.string().min(1).max(100).optional(),
|
|
53
|
+
input: scheduleInputSchema.optional(),
|
|
54
|
+
page: z.number().int().min(0).max(10_000).optional(),
|
|
55
|
+
})
|
|
56
|
+
.strict();
|
|
57
|
+
export function nextScheduleTime(spec, after) {
|
|
58
|
+
if (spec.at) {
|
|
59
|
+
const time = Date.parse(spec.at);
|
|
60
|
+
return time > after ? time : undefined;
|
|
61
|
+
}
|
|
62
|
+
return CronExpressionParser.parse(spec.cron, {
|
|
63
|
+
currentDate: new Date(after),
|
|
64
|
+
tz: spec.timeZone,
|
|
65
|
+
})
|
|
66
|
+
.next()
|
|
67
|
+
.getTime();
|
|
68
|
+
}
|
|
69
|
+
export function latestScheduleTime(spec, now) {
|
|
70
|
+
if (spec.at)
|
|
71
|
+
return Date.parse(spec.at);
|
|
72
|
+
return CronExpressionParser.parse(spec.cron, {
|
|
73
|
+
currentDate: new Date(now + 1),
|
|
74
|
+
tz: spec.timeZone,
|
|
75
|
+
})
|
|
76
|
+
.prev()
|
|
77
|
+
.getTime();
|
|
78
|
+
}
|
|
79
|
+
export function scheduleTime(time, timeZone) {
|
|
80
|
+
return time === undefined
|
|
81
|
+
? "—"
|
|
82
|
+
: new Intl.DateTimeFormat("zh-CN", {
|
|
83
|
+
timeZone,
|
|
84
|
+
dateStyle: "short",
|
|
85
|
+
timeStyle: "medium",
|
|
86
|
+
hour12: false,
|
|
87
|
+
}).format(time);
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/scheduling/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACvD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;IAC3C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IAClD,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC3D,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,IAAI,EAAE;SACN,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC;IAC5D,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,C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CAAC,KAAK,CAAC,IAAI,CAAC,IAAK,EAAE;QAC5C,WAAW,EAAE,IAAI,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;QAC9B,EAAE,EAAE,IAAI,CAAC,QAAQ;KAClB,CAAC;SACC,IAAI,EAAE;SACN,OAAO,EAAE,CAAC;AACf,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,IAAwB,EACxB,QAAgB;IAEhB,OAAO,IAAI,KAAK,SAAS;QACvB,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;YAC/B,QAAQ;YACR,SAAS,EAAE,OAAO;YAClB,SAAS,EAAE,QAAQ;YACnB,MAAM,EAAE,KAAK;SACd,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createId } from "../utils/id.js";
|
|
2
|
+
export class ExecutionProvenanceStore {
|
|
3
|
+
db;
|
|
4
|
+
constructor(db) {
|
|
5
|
+
this.db = db;
|
|
6
|
+
}
|
|
7
|
+
recordSubmission(input) {
|
|
8
|
+
const previous = this.latestForAttempt(input.attemptId);
|
|
9
|
+
const parent = input.parentSourceTurnId && input.trigger !== "user" && input.trigger !== "queue" && input.trigger !== "schedule"
|
|
10
|
+
? this.forTurn(input.parentSourceTurnId, input.localSessionId) : undefined;
|
|
11
|
+
const instructionId = previous?.instructionId ?? parent?.instructionId ?? input.instructionId ?? input.attemptId;
|
|
12
|
+
const scheduledFor = input.scheduledFor ?? previous?.scheduledFor ?? parent?.scheduledFor;
|
|
13
|
+
const submissionId = createId("submission");
|
|
14
|
+
// Explicit columns are the allowlist: never serialize a runtime session or prompt here.
|
|
15
|
+
const { agentName, modelProvider, model, reasoningEffort, permissionMode, cwd } = input.settings;
|
|
16
|
+
this.db.prepare(`INSERT INTO execution_provenance (
|
|
17
|
+
submission_id, instruction_id, attempt_id, local_session_id, trigger, parent_source_turn_id,
|
|
18
|
+
scheduled_for, submitted_at, agent_name, model_provider, model, reasoning_effort, permission_mode, cwd
|
|
19
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(submissionId, instructionId, input.attemptId, input.localSessionId, input.trigger, input.parentSourceTurnId ?? null, scheduledFor ?? null, Date.now(), agentName, modelProvider ?? null, model ?? null, reasoningEffort ?? null, permissionMode, cwd);
|
|
20
|
+
return this.latestForAttempt(input.attemptId);
|
|
21
|
+
}
|
|
22
|
+
bindTurn(submissionId, turnId) {
|
|
23
|
+
this.db.prepare(`UPDATE execution_provenance SET turn_id = ? WHERE submission_id = ? AND turn_id IS NULL`)
|
|
24
|
+
.run(turnId, submissionId);
|
|
25
|
+
}
|
|
26
|
+
bindLatestTurn(attemptId, turnId) {
|
|
27
|
+
const latest = this.latestForAttempt(attemptId);
|
|
28
|
+
if (latest)
|
|
29
|
+
this.bindTurn(latest.submissionId, turnId);
|
|
30
|
+
}
|
|
31
|
+
latestForAttempt(attemptId) {
|
|
32
|
+
return this.read(this.db.prepare(`SELECT * FROM execution_provenance WHERE attempt_id = ? ORDER BY rowid DESC LIMIT 1`)
|
|
33
|
+
.get(attemptId));
|
|
34
|
+
}
|
|
35
|
+
forTurn(turnId, localSessionId) {
|
|
36
|
+
return this.read(this.db.prepare(`SELECT * FROM execution_provenance WHERE turn_id = ? AND local_session_id = ?
|
|
37
|
+
ORDER BY rowid DESC LIMIT 1`).get(turnId, localSessionId));
|
|
38
|
+
}
|
|
39
|
+
listForAttempt(attemptId) {
|
|
40
|
+
return this.db.prepare(`SELECT * FROM execution_provenance WHERE attempt_id = ? ORDER BY rowid`).all(attemptId)
|
|
41
|
+
.map((row) => this.read(row));
|
|
42
|
+
}
|
|
43
|
+
read(value) {
|
|
44
|
+
if (!value)
|
|
45
|
+
return undefined;
|
|
46
|
+
const row = value;
|
|
47
|
+
return {
|
|
48
|
+
submissionId: row.submission_id, instructionId: row.instruction_id, attemptId: row.attempt_id,
|
|
49
|
+
localSessionId: row.local_session_id, turnId: row.turn_id ?? undefined, trigger: row.trigger,
|
|
50
|
+
parentSourceTurnId: row.parent_source_turn_id ?? undefined, scheduledFor: row.scheduled_for ?? undefined,
|
|
51
|
+
submittedAt: row.submitted_at, settings: {
|
|
52
|
+
agentName: row.agent_name, modelProvider: row.model_provider ?? undefined, model: row.model ?? undefined,
|
|
53
|
+
reasoningEffort: row.reasoning_effort ?? undefined, permissionMode: row.permission_mode, cwd: row.cwd,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=ExecutionProvenanceStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExecutionProvenanceStore.js","sourceRoot":"","sources":["../../src/state/ExecutionProvenanceStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAoC1C,MAAM,OAAO,wBAAwB;IACN,EAAE;IAA/B,YAA6B,EAAqB;kBAArB,EAAE;IAAsB,CAAC;IAEtD,gBAAgB,CAAC,KACa;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACxD,MAAM,MAAM,GAAG,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,OAAO,KAAK,MAAM,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,IAAI,KAAK,CAAC,OAAO,KAAK,UAAU;YAC9H,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7E,MAAM,aAAa,GAAG,QAAQ,EAAE,aAAa,IAAI,MAAM,EAAE,aAAa,IAAI,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,SAAS,CAAC;QACjH,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,IA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/dist/state/StateStore.js
CHANGED
|
@@ -3,10 +3,24 @@ import { TurnPreviewJournal } from "./TurnPreviewJournal.js";
|
|
|
3
3
|
import { compactTurnView } from "../presentation/TurnStateReducer.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import Database from "better-sqlite3";
|
|
6
|
+
import { ScheduledTaskStore } from "../scheduling/ScheduledTaskStore.js";
|
|
6
7
|
import { migrations } from "./migrations.js";
|
|
8
|
+
import { ExecutionProvenanceStore } from "./ExecutionProvenanceStore.js";
|
|
9
|
+
// Scheduled queue entries survive a safe restart, but an in-flight submission must block it.
|
|
10
|
+
const RESTART_BLOCKING_WORK_SQL = `sessions.status = 'running'
|
|
11
|
+
OR EXISTS (
|
|
12
|
+
SELECT 1 FROM queued_prompts q WHERE q.local_session_id = sessions.local_session_id
|
|
13
|
+
AND NOT EXISTS (SELECT 1 FROM scheduled_runs r WHERE r.id = q.prompt_id)
|
|
14
|
+
)
|
|
15
|
+
OR EXISTS (
|
|
16
|
+
SELECT 1 FROM scheduled_jobs j JOIN scheduled_runs r ON r.job_id = j.id
|
|
17
|
+
WHERE j.local_session_id = sessions.local_session_id AND r.status IN ('dispatching','submitting','running')
|
|
18
|
+
)`;
|
|
7
19
|
export class StateStore {
|
|
8
20
|
db;
|
|
9
21
|
previews;
|
|
22
|
+
schedules;
|
|
23
|
+
provenance;
|
|
10
24
|
constructor(sqlitePath, onPreviewError) {
|
|
11
25
|
this.previews = new TurnPreviewJournal(path.join(path.dirname(sqlitePath), "turn-previews"), onPreviewError);
|
|
12
26
|
fs.mkdirSync(path.dirname(sqlitePath), { recursive: true });
|
|
@@ -22,6 +36,9 @@ export class StateStore {
|
|
|
22
36
|
this.ensureChatContextColumns();
|
|
23
37
|
this.ensureTurnAttemptColumns();
|
|
24
38
|
this.ensureQueuedPromptColumns();
|
|
39
|
+
this.ensureRecentContextReceiptColumns();
|
|
40
|
+
this.schedules = new ScheduledTaskStore(this.db);
|
|
41
|
+
this.provenance = new ExecutionProvenanceStore(this.db);
|
|
25
42
|
this.initializeContextSessionMappings();
|
|
26
43
|
this.db.exec("DROP INDEX IF EXISTS idx_sessions_remote_session_id_unique");
|
|
27
44
|
this.reconcileDuplicateRemoteSessions();
|
|
@@ -269,7 +286,7 @@ export class StateStore {
|
|
|
269
286
|
return linked.map((row) => row.local_session_id);
|
|
270
287
|
}
|
|
271
288
|
enqueuePrompt(input) {
|
|
272
|
-
const createdAt = new Date().toISOString();
|
|
289
|
+
const createdAt = input.createdAt ?? new Date().toISOString();
|
|
273
290
|
this.db.prepare(`
|
|
274
291
|
INSERT INTO queued_prompts (
|
|
275
292
|
prompt_id, local_session_id, context_key, prompt_text, display_prompt, local_image_paths_json,
|
|
@@ -290,6 +307,14 @@ export class StateStore {
|
|
|
290
307
|
`).all(localSessionId);
|
|
291
308
|
return rows.map(mapQueuedPrompt);
|
|
292
309
|
}
|
|
310
|
+
hasQueuedPrompt(promptId) {
|
|
311
|
+
return Boolean(this.db.prepare("SELECT 1 FROM queued_prompts WHERE prompt_id = ?").get(promptId));
|
|
312
|
+
}
|
|
313
|
+
peekQueuedPrompt(localSessionId) {
|
|
314
|
+
const row = this.db.prepare(`SELECT * FROM queued_prompts WHERE local_session_id = ?
|
|
315
|
+
ORDER BY created_at ASC, rowid ASC LIMIT 1`).get(localSessionId);
|
|
316
|
+
return row ? mapQueuedPrompt(row) : undefined;
|
|
317
|
+
}
|
|
293
318
|
listQueuedPromptSessionIds() {
|
|
294
319
|
const rows = this.db.prepare(`
|
|
295
320
|
SELECT local_session_id, min(created_at) AS first_created_at, min(rowid) AS first_rowid
|
|
@@ -307,16 +332,35 @@ export class StateStore {
|
|
|
307
332
|
}
|
|
308
333
|
takeNextQueuedPrompt(localSessionId) {
|
|
309
334
|
const take = this.db.transaction(() => {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
335
|
+
while (true) {
|
|
336
|
+
const row = this.db.prepare(`
|
|
337
|
+
SELECT * FROM queued_prompts
|
|
338
|
+
WHERE local_session_id = ?
|
|
339
|
+
ORDER BY created_at ASC, rowid ASC
|
|
340
|
+
LIMIT 1
|
|
341
|
+
`).get(localSessionId);
|
|
342
|
+
if (!row)
|
|
343
|
+
return undefined;
|
|
344
|
+
this.db.prepare("DELETE FROM queued_prompts WHERE prompt_id = ?").run(row.prompt_id);
|
|
345
|
+
if (!this.schedules.claimStart(row.prompt_id))
|
|
346
|
+
continue;
|
|
347
|
+
if (this.schedules.getRun(row.prompt_id)) {
|
|
348
|
+
const existing = this.getTurnAttempt(row.prompt_id);
|
|
349
|
+
if (existing) {
|
|
350
|
+
if (existing.submissionState !== "not_submitted" || existing.turnId) {
|
|
351
|
+
this.schedules.finish(row.prompt_id, "unknown", "存在无法安全重发的提交记录,未自动派发。");
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
this.updateTurnAttempt(row.prompt_id, { status: "accepted", pendingTurnId: null,
|
|
355
|
+
executionGeneration: this.executionGeneration(localSessionId) });
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
this.createTurnAttempt({ attemptId: row.prompt_id, localSessionId, contextKey: row.context_key,
|
|
359
|
+
promptText: row.prompt_text, replyMessageId: row.reply_message_id ?? undefined });
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return mapQueuedPrompt(row);
|
|
363
|
+
}
|
|
320
364
|
});
|
|
321
365
|
return take();
|
|
322
366
|
}
|
|
@@ -328,6 +372,9 @@ export class StateStore {
|
|
|
328
372
|
if (!row)
|
|
329
373
|
return undefined;
|
|
330
374
|
this.db.prepare("DELETE FROM queued_prompts WHERE prompt_id = ?").run(promptId);
|
|
375
|
+
const scheduled = this.schedules.getRun(promptId);
|
|
376
|
+
if (scheduled?.status === "queued")
|
|
377
|
+
this.schedules.finish(promptId, "cancelled", "已取消排队。");
|
|
331
378
|
return mapQueuedPrompt(row);
|
|
332
379
|
});
|
|
333
380
|
return cancel();
|
|
@@ -340,9 +387,9 @@ export class StateStore {
|
|
|
340
387
|
INSERT INTO turn_attempts (
|
|
341
388
|
attempt_id, local_session_id, context_key, prompt_text, local_image_paths_json,
|
|
342
389
|
message_id, reply_message_id, pending_turn_id, turn_id, recovered_from_turn_id,
|
|
343
|
-
recovery_count, retry_count, status, created_at, updated_at
|
|
344
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
345
|
-
`).run(input.attemptId, input.localSessionId, input.contextKey, input.promptText, JSON.stringify(input.localImagePaths ?? []), input.messageId ?? null, input.replyMessageId ?? null, input.pendingTurnId ?? null, input.turnId ?? null, input.recoveredFromTurnId ?? null, input.recoveryCount ?? 0, input.retryCount ?? 0, status, createdAt, updatedAt);
|
|
390
|
+
recovery_count, retry_count, submission_state, status, created_at, updated_at, execution_generation
|
|
391
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
392
|
+
`).run(input.attemptId, input.localSessionId, input.contextKey, input.promptText, JSON.stringify(input.localImagePaths ?? []), input.messageId ?? null, input.replyMessageId ?? null, input.pendingTurnId ?? null, input.turnId ?? null, input.recoveredFromTurnId ?? null, input.recoveryCount ?? 0, input.retryCount ?? 0, input.submissionState ?? (input.turnId ? "submitted" : "not_submitted"), status, createdAt, updatedAt, input.executionGeneration ?? this.executionGeneration(input.localSessionId));
|
|
346
393
|
return this.getTurnAttempt(input.attemptId);
|
|
347
394
|
}
|
|
348
395
|
getTurnAttempt(attemptId) {
|
|
@@ -388,15 +435,15 @@ export class StateStore {
|
|
|
388
435
|
this.db.prepare(`
|
|
389
436
|
UPDATE turn_attempts
|
|
390
437
|
SET message_id = ?, reply_message_id = ?, pending_turn_id = ?, turn_id = ?,
|
|
391
|
-
recovered_from_turn_id = ?, recovery_count = ?, retry_count = ?, status = ?, updated_at = ?
|
|
438
|
+
recovered_from_turn_id = ?, recovery_count = ?, retry_count = ?, submission_state = ?, execution_generation = ?, status = ?, updated_at = ?
|
|
392
439
|
WHERE attempt_id = ?
|
|
393
|
-
`).run(value(patch.messageId, existing.messageId), value(patch.replyMessageId, existing.replyMessageId), value(patch.pendingTurnId, existing.pendingTurnId), value(patch.turnId, existing.turnId), value(patch.recoveredFromTurnId, existing.recoveredFromTurnId), patch.recoveryCount ?? existing.recoveryCount, patch.retryCount ?? existing.retryCount, patch.status ?? existing.status, new Date().toISOString(), attemptId);
|
|
440
|
+
`).run(value(patch.messageId, existing.messageId), value(patch.replyMessageId, existing.replyMessageId), value(patch.pendingTurnId, existing.pendingTurnId), value(patch.turnId, existing.turnId), value(patch.recoveredFromTurnId, existing.recoveredFromTurnId), patch.recoveryCount ?? existing.recoveryCount, patch.retryCount ?? existing.retryCount, patch.submissionState ?? (patch.turnId ? "submitted" : existing.submissionState), patch.executionGeneration ?? existing.executionGeneration, patch.status ?? existing.status, new Date().toISOString(), attemptId);
|
|
394
441
|
}
|
|
395
442
|
bindTurnAttempt(localSessionId, turnId) {
|
|
396
443
|
const attempt = this.findIncompleteTurnAttemptForSession(localSessionId);
|
|
397
444
|
if (!attempt || (attempt.turnId && attempt.turnId !== turnId))
|
|
398
445
|
return undefined;
|
|
399
|
-
this.updateTurnAttempt(attempt.attemptId, { turnId, status: "running" });
|
|
446
|
+
this.updateTurnAttempt(attempt.attemptId, { turnId, status: "running", submissionState: "submitted" });
|
|
400
447
|
return this.getTurnAttempt(attempt.attemptId);
|
|
401
448
|
}
|
|
402
449
|
markTurnAttemptTerminal(turnId, status) {
|
|
@@ -405,6 +452,10 @@ export class StateStore {
|
|
|
405
452
|
SET status = ?, updated_at = ?
|
|
406
453
|
WHERE turn_id = ?
|
|
407
454
|
`).run(status, new Date().toISOString(), turnId);
|
|
455
|
+
const runs = this.db.prepare(`SELECT s.id FROM scheduled_runs s JOIN turn_attempts t ON t.attempt_id = s.id
|
|
456
|
+
WHERE t.turn_id = ?`).all(turnId);
|
|
457
|
+
for (const run of runs)
|
|
458
|
+
this.schedules.finish(run.id, status);
|
|
408
459
|
}
|
|
409
460
|
findIncompleteTurnAttemptByTurnId(turnId) {
|
|
410
461
|
const row = this.db.prepare(`
|
|
@@ -422,12 +473,6 @@ export class StateStore {
|
|
|
422
473
|
this.updateTurnAttempt(existing.attemptId, { status: "cancelling" });
|
|
423
474
|
return existing;
|
|
424
475
|
}
|
|
425
|
-
restoreTurnAttemptAfterCancellationFailure(attempt) {
|
|
426
|
-
const current = this.getTurnAttempt(attempt.attemptId);
|
|
427
|
-
if (current?.status !== "cancelling")
|
|
428
|
-
return;
|
|
429
|
-
this.updateTurnAttempt(attempt.attemptId, { status: attempt.status });
|
|
430
|
-
}
|
|
431
476
|
touchTurnAttempt(turnId, activityAt = new Date()) {
|
|
432
477
|
const timestamp = activityAt.toISOString();
|
|
433
478
|
const throttleCutoff = new Date(activityAt.getTime() - 15_000).toISOString();
|
|
@@ -439,44 +484,80 @@ export class StateStore {
|
|
|
439
484
|
AND updated_at < ?
|
|
440
485
|
`).run(timestamp, turnId, throttleCutoff);
|
|
441
486
|
}
|
|
442
|
-
|
|
487
|
+
hasUnknownTurnAttemptForSession(localSessionId) {
|
|
488
|
+
return Boolean(this.db.prepare("SELECT 1 FROM turn_attempts WHERE local_session_id = ? AND status = 'unknown' LIMIT 1")
|
|
489
|
+
.get(localSessionId));
|
|
490
|
+
}
|
|
491
|
+
hasCancellationRequestedForSession(localSessionId) {
|
|
492
|
+
return Boolean(this.db.prepare("SELECT 1 FROM turn_attempts WHERE local_session_id = ? AND status = 'cancelling' LIMIT 1")
|
|
493
|
+
.get(localSessionId));
|
|
494
|
+
}
|
|
495
|
+
beginTurnAttemptSubmission(attemptId, recordProvenance) {
|
|
496
|
+
this.db.transaction(() => {
|
|
497
|
+
const result = this.db.prepare(`
|
|
498
|
+
UPDATE turn_attempts SET submission_state = 'submission_unknown', updated_at = ?
|
|
499
|
+
WHERE attempt_id = ? AND submission_state = 'not_submitted'
|
|
500
|
+
AND status IN ('accepted', 'recovering') AND turn_id IS NULL
|
|
501
|
+
AND execution_generation = COALESCE((SELECT generation FROM task_execution_control
|
|
502
|
+
WHERE local_session_id = turn_attempts.local_session_id), 0)
|
|
503
|
+
`).run(new Date().toISOString(), attemptId);
|
|
504
|
+
if (result.changes !== 1)
|
|
505
|
+
throw new Error("Prompt submission is not provably safe; automatic replay refused.");
|
|
506
|
+
recordProvenance?.();
|
|
507
|
+
})();
|
|
508
|
+
}
|
|
509
|
+
executionGeneration(localSessionId) {
|
|
510
|
+
const row = this.db.prepare("SELECT generation FROM task_execution_control WHERE local_session_id = ?")
|
|
511
|
+
.get(localSessionId);
|
|
512
|
+
return row?.generation ?? 0;
|
|
513
|
+
}
|
|
514
|
+
requestSessionExecutionStop(localSessionId) {
|
|
515
|
+
this.db.transaction(() => {
|
|
516
|
+
this.db.prepare(`INSERT INTO task_execution_control (local_session_id, generation) VALUES (?, 1)
|
|
517
|
+
ON CONFLICT(local_session_id) DO UPDATE SET generation = generation + 1`).run(localSessionId);
|
|
518
|
+
this.db.prepare(`UPDATE turn_attempts SET status = 'cancelling', updated_at = ?
|
|
519
|
+
WHERE local_session_id = ? AND status IN ('accepted', 'running', 'recovering', 'unknown')
|
|
520
|
+
AND attempt_id NOT IN (SELECT prompt_id FROM queued_prompts)`)
|
|
521
|
+
.run(new Date().toISOString(), localSessionId);
|
|
522
|
+
})();
|
|
523
|
+
}
|
|
524
|
+
prepareUnstartedTurnAttemptRetry(attemptId) {
|
|
443
525
|
const existing = this.getTurnAttempt(attemptId);
|
|
444
|
-
if (!existing
|
|
526
|
+
if (!existing || existing.turnId || existing.submissionState !== "not_submitted"
|
|
527
|
+
|| !isIncompleteTurnAttemptStatus(existing.status))
|
|
445
528
|
return undefined;
|
|
446
529
|
this.updateTurnAttempt(attemptId, {
|
|
447
530
|
pendingTurnId: null,
|
|
448
|
-
|
|
449
|
-
recoveredFromTurnId: recoveredFromTurnId ?? existing.turnId ?? existing.recoveredFromTurnId ?? null,
|
|
450
|
-
recoveryCount: existing.recoveryCount + 1,
|
|
531
|
+
retryCount: existing.retryCount + 1,
|
|
451
532
|
status: "recovering",
|
|
452
533
|
});
|
|
453
534
|
return this.getTurnAttempt(attemptId);
|
|
454
535
|
}
|
|
455
|
-
|
|
536
|
+
prepareTurnAttemptRecovery(attemptId, recoveredFromTurnId) {
|
|
456
537
|
const existing = this.getTurnAttempt(attemptId);
|
|
457
|
-
if (!existing || existing.turnId
|
|
538
|
+
if (!existing || existing.turnId || existing.submissionState !== "not_submitted"
|
|
539
|
+
|| !isIncompleteTurnAttemptStatus(existing.status))
|
|
458
540
|
return undefined;
|
|
459
|
-
}
|
|
460
541
|
this.updateTurnAttempt(attemptId, {
|
|
461
|
-
|
|
462
|
-
turnId: null,
|
|
463
|
-
recoveredFromTurnId: failedTurnId,
|
|
464
|
-
retryCount: existing.retryCount + 1,
|
|
465
|
-
status: "recovering",
|
|
542
|
+
recoveredFromTurnId, recoveryCount: existing.recoveryCount + 1, status: "recovering",
|
|
466
543
|
});
|
|
467
544
|
return this.getTurnAttempt(attemptId);
|
|
468
545
|
}
|
|
469
|
-
|
|
546
|
+
prepareTurnAttemptRetry(attemptId, failedTurnId, verifiedContinuation = false) {
|
|
470
547
|
const existing = this.getTurnAttempt(attemptId);
|
|
471
|
-
if (!existing || existing.turnId
|
|
548
|
+
if (!verifiedContinuation || !existing || existing.turnId !== failedTurnId
|
|
549
|
+
|| !isIncompleteTurnAttemptStatus(existing.status))
|
|
472
550
|
return undefined;
|
|
473
551
|
this.updateTurnAttempt(attemptId, {
|
|
474
|
-
pendingTurnId: null,
|
|
475
|
-
retryCount: existing.retryCount + 1,
|
|
476
|
-
status: "recovering",
|
|
552
|
+
pendingTurnId: null, turnId: null, recoveredFromTurnId: failedTurnId,
|
|
553
|
+
retryCount: existing.retryCount + 1, status: "recovering", submissionState: "not_submitted",
|
|
477
554
|
});
|
|
478
555
|
return this.getTurnAttempt(attemptId);
|
|
479
556
|
}
|
|
557
|
+
acknowledgeUnknownTurnAttempts(localSessionId) {
|
|
558
|
+
this.db.prepare("UPDATE turn_attempts SET status = 'interrupted' WHERE local_session_id = ? AND status = 'unknown'")
|
|
559
|
+
.run(localSessionId);
|
|
560
|
+
}
|
|
480
561
|
rebindPendingTurnMessages(localSessionId, sourceTurnId, targetTurnId) {
|
|
481
562
|
const now = new Date().toISOString();
|
|
482
563
|
const rebind = this.db.transaction(() => {
|
|
@@ -1253,10 +1334,7 @@ export class StateStore {
|
|
|
1253
1334
|
.prepare(`
|
|
1254
1335
|
SELECT COUNT(*) AS count
|
|
1255
1336
|
FROM sessions
|
|
1256
|
-
WHERE
|
|
1257
|
-
OR EXISTS (
|
|
1258
|
-
SELECT 1 FROM queued_prompts WHERE queued_prompts.local_session_id = sessions.local_session_id
|
|
1259
|
-
)
|
|
1337
|
+
WHERE ${RESTART_BLOCKING_WORK_SQL}
|
|
1260
1338
|
`)
|
|
1261
1339
|
.get();
|
|
1262
1340
|
const pending = this.db.prepare(`
|
|
@@ -1277,6 +1355,10 @@ export class StateStore {
|
|
|
1277
1355
|
latestInboundAt: inbound.latest ?? undefined,
|
|
1278
1356
|
};
|
|
1279
1357
|
}
|
|
1358
|
+
sessionBlocksSafeRestart(localSessionId) {
|
|
1359
|
+
return Boolean(this.db.prepare(`SELECT 1 FROM sessions WHERE local_session_id = ? AND (${RESTART_BLOCKING_WORK_SQL})`)
|
|
1360
|
+
.get(localSessionId));
|
|
1361
|
+
}
|
|
1280
1362
|
findSessionByRemoteSessionId(remoteSessionId, contextKey, agentName) {
|
|
1281
1363
|
const row = contextKey
|
|
1282
1364
|
? this.db
|
|
@@ -1643,9 +1725,18 @@ export class StateStore {
|
|
|
1643
1725
|
}
|
|
1644
1726
|
ensureTurnAttemptColumns() {
|
|
1645
1727
|
const existing = new Set(this.db.pragma("table_info(turn_attempts)").map((column) => column.name));
|
|
1728
|
+
if (!existing.has("submission_state")) {
|
|
1729
|
+
this.db.transaction(() => {
|
|
1730
|
+
this.db.exec("ALTER TABLE turn_attempts ADD COLUMN submission_state TEXT NOT NULL DEFAULT 'submission_unknown'");
|
|
1731
|
+
this.db.exec("UPDATE turn_attempts SET submission_state = 'submitted' WHERE turn_id IS NOT NULL");
|
|
1732
|
+
})();
|
|
1733
|
+
}
|
|
1646
1734
|
if (!existing.has("retry_count")) {
|
|
1647
1735
|
this.db.exec("ALTER TABLE turn_attempts ADD COLUMN retry_count INTEGER NOT NULL DEFAULT 0");
|
|
1648
1736
|
}
|
|
1737
|
+
if (!existing.has("execution_generation")) {
|
|
1738
|
+
this.db.exec("ALTER TABLE turn_attempts ADD COLUMN execution_generation INTEGER NOT NULL DEFAULT 0");
|
|
1739
|
+
}
|
|
1649
1740
|
}
|
|
1650
1741
|
ensureQueuedPromptColumns() {
|
|
1651
1742
|
const existing = new Set(this.db.pragma("table_info(queued_prompts)").map((column) => column.name));
|
|
@@ -1653,6 +1744,13 @@ export class StateStore {
|
|
|
1653
1744
|
this.db.exec("ALTER TABLE queued_prompts ADD COLUMN display_prompt TEXT");
|
|
1654
1745
|
}
|
|
1655
1746
|
}
|
|
1747
|
+
ensureRecentContextReceiptColumns() {
|
|
1748
|
+
const existing = new Set(this.db.pragma("table_info(recent_context_receipts)").map((column) => column.name));
|
|
1749
|
+
if (!existing.has("prompt_message_id")) {
|
|
1750
|
+
// Old receipts have no provable source Prompt, so they cannot be stop boundaries.
|
|
1751
|
+
this.db.exec("ALTER TABLE recent_context_receipts ADD COLUMN prompt_message_id TEXT NOT NULL DEFAULT ''");
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1656
1754
|
}
|
|
1657
1755
|
const MAX_TASK_TITLE_LENGTH = 120;
|
|
1658
1756
|
const FORK_TITLE_SUFFIX = /\s*(分支\s+(\d+))$/u;
|
|
@@ -1766,6 +1864,8 @@ function mapTurnAttempt(row) {
|
|
|
1766
1864
|
recoveredFromTurnId: row.recovered_from_turn_id ?? undefined,
|
|
1767
1865
|
recoveryCount: row.recovery_count,
|
|
1768
1866
|
retryCount: row.retry_count,
|
|
1867
|
+
submissionState: row.submission_state,
|
|
1868
|
+
executionGeneration: row.execution_generation,
|
|
1769
1869
|
status: row.status,
|
|
1770
1870
|
createdAt: row.created_at,
|
|
1771
1871
|
updatedAt: row.updated_at,
|