opencode-windows-scheduler 1.2.0 → 1.2.1

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.
Files changed (111) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/README.md +5 -5
  3. package/ROADMAP-STRATEGY.md +2 -2
  4. package/ROADMAP.md +31 -5
  5. package/dist/core/dry-run.d.ts +5 -1
  6. package/dist/core/dry-run.d.ts.map +1 -1
  7. package/dist/core/dry-run.js +20 -4
  8. package/dist/core/one-shot.d.ts +62 -0
  9. package/dist/core/one-shot.d.ts.map +1 -0
  10. package/dist/core/one-shot.js +126 -0
  11. package/dist/core/otel.d.ts +4 -0
  12. package/dist/core/otel.d.ts.map +1 -0
  13. package/dist/core/otel.js +98 -0
  14. package/dist/core/prometheus.d.ts +23 -0
  15. package/dist/core/prometheus.d.ts.map +1 -0
  16. package/dist/core/prometheus.js +146 -0
  17. package/dist/core/ps-wrapper.d.ts +6 -2
  18. package/dist/core/ps-wrapper.d.ts.map +1 -1
  19. package/dist/core/ps-wrapper.js +25 -3
  20. package/dist/core/record-history.d.ts.map +1 -1
  21. package/dist/core/record-history.js +9 -0
  22. package/dist/core/scheduler/linux.d.ts +12 -3
  23. package/dist/core/scheduler/linux.d.ts.map +1 -1
  24. package/dist/core/scheduler/linux.js +80 -3
  25. package/dist/core/scheduler/mac.d.ts.map +1 -1
  26. package/dist/core/scheduler/mac.js +17 -3
  27. package/dist/core/scheduler/posix.d.ts.map +1 -1
  28. package/dist/core/scheduler/posix.js +3 -0
  29. package/dist/core/scheduler/registry.d.ts +4 -0
  30. package/dist/core/scheduler/registry.d.ts.map +1 -1
  31. package/dist/core/scheduler/types.d.ts +5 -3
  32. package/dist/core/scheduler/types.d.ts.map +1 -1
  33. package/dist/core/scheduler/windows.d.ts.map +1 -1
  34. package/dist/core/scheduler/windows.js +10 -1
  35. package/dist/core/session.d.ts +34 -0
  36. package/dist/core/session.d.ts.map +1 -0
  37. package/dist/core/session.js +105 -0
  38. package/dist/core/structured-log.d.ts +84 -0
  39. package/dist/core/structured-log.d.ts.map +1 -0
  40. package/dist/core/structured-log.js +137 -0
  41. package/dist/core/wrappers/bash.d.ts +9 -0
  42. package/dist/core/wrappers/bash.d.ts.map +1 -1
  43. package/dist/core/wrappers/bash.js +27 -3
  44. package/dist/db/history-repo.d.ts.map +1 -1
  45. package/dist/db/history-repo.js +63 -6
  46. package/dist/db/metrics-repo.d.ts +3 -0
  47. package/dist/db/metrics-repo.d.ts.map +1 -1
  48. package/dist/db/metrics-repo.js +16 -8
  49. package/dist/db/migrate.d.ts.map +1 -1
  50. package/dist/db/migrate.js +8 -1
  51. package/dist/db/schema.d.ts +1 -1
  52. package/dist/db/schema.d.ts.map +1 -1
  53. package/dist/db/schema.js +8 -0
  54. package/dist/gui-experimental.cjs +1 -0
  55. package/dist/history.d.ts +7 -0
  56. package/dist/history.d.ts.map +1 -1
  57. package/dist/history.js +13 -0
  58. package/dist/index.d.ts +22 -3
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +330 -41
  61. package/dist/integrations.d.ts +64 -0
  62. package/dist/integrations.d.ts.map +1 -0
  63. package/dist/integrations.js +205 -0
  64. package/dist/rpc.d.ts +81 -4
  65. package/dist/rpc.d.ts.map +1 -1
  66. package/dist/rpc.js +43 -4
  67. package/dist/server.d.ts +2 -0
  68. package/dist/server.d.ts.map +1 -1
  69. package/dist/server.js +468 -56
  70. package/dist/settings.d.ts +38 -0
  71. package/dist/settings.d.ts.map +1 -1
  72. package/dist/settings.js +68 -0
  73. package/dist/shared/jobs-view.d.ts +43 -5
  74. package/dist/shared/jobs-view.d.ts.map +1 -1
  75. package/dist/shared/jobs-view.js +125 -7
  76. package/dist/task-transfer.d.ts +19 -3
  77. package/dist/task-transfer.d.ts.map +1 -1
  78. package/dist/task-transfer.js +75 -3
  79. package/docs/FEATURES.md +101 -4
  80. package/gui-experimental.cjs +4 -4
  81. package/package.json +11 -2
  82. package/scripts/demo-dashboard.mjs +12 -2
  83. package/src/core/dry-run.ts +24 -5
  84. package/src/core/one-shot.ts +173 -0
  85. package/src/core/otel.ts +128 -0
  86. package/src/core/prometheus.ts +215 -0
  87. package/src/core/ps-wrapper.ts +29 -3
  88. package/src/core/record-history.ts +13 -0
  89. package/src/core/scheduler/linux.ts +90 -3
  90. package/src/core/scheduler/mac.ts +35 -4
  91. package/src/core/scheduler/posix.ts +3 -0
  92. package/src/core/scheduler/registry.ts +4 -0
  93. package/src/core/scheduler/types.ts +5 -3
  94. package/src/core/scheduler/windows.ts +11 -1
  95. package/src/core/session.ts +115 -0
  96. package/src/core/structured-log.ts +205 -0
  97. package/src/core/wrappers/bash.ts +38 -2
  98. package/src/db/history-repo.ts +67 -7
  99. package/src/db/metrics-repo.ts +19 -7
  100. package/src/db/migrate.ts +7 -1
  101. package/src/db/schema.ts +11 -0
  102. package/src/gui.tsx +3832 -3613
  103. package/src/history.ts +17 -0
  104. package/src/index.ts +426 -47
  105. package/src/integrations.ts +253 -0
  106. package/src/rpc.ts +43 -4
  107. package/src/server.ts +501 -56
  108. package/src/settings.ts +122 -0
  109. package/src/shared/jobs-view.ts +158 -8
  110. package/src/task-transfer.ts +107 -5
  111. package/src/tui.tsx +290 -14
@@ -32,10 +32,19 @@ export interface BashWrapperOptions {
32
32
  qualityGate?: string;
33
33
  /** LLM-модель для `opencode run --model` (если не задана — модель по умолчанию). */
34
34
  model?: string;
35
+ /** Спринт 24: режим сессии — "new" | "reuse" | "last". */
36
+ sessionMode?: import("../session.js").SessionMode;
37
+ /** Спринт 24: id сессии для режима "reuse". */
38
+ sessionId?: string;
35
39
  /** Pre-flight команда: ненулевой код отменяет запуск задачи. */
36
40
  beforeScript?: string;
37
41
  /** Post-flight команда: выполняется даже при ошибке основной задачи. */
38
42
  afterScript?: string;
43
+ /**
44
+ * Команда самоочистки one-shot (например, выгрузка launchd-агента).
45
+ * Запускается в фоне после записи истории и не влияет на код возврата.
46
+ */
47
+ oneShotCleanupCommand?: string;
39
48
  /**
40
49
  * Гейт расписания (спринт 19): проверка cron в таймзоне задачи и окна
41
50
  * запуска выполняется до lock и запуска opencode.
@@ -82,6 +91,9 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
82
91
  model,
83
92
  beforeScript,
84
93
  afterScript,
94
+ sessionMode,
95
+ sessionId,
96
+ oneShotCleanupCommand,
85
97
  allowedTools,
86
98
  deniedTools,
87
99
  scheduleGate,
@@ -104,6 +116,9 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
104
116
  `RECORDER_FILE=${shellQuote(recorderFile ?? "")}`,
105
117
  `QUALITY_GATE=${shellQuote(qualityGate ?? "")}`,
106
118
  `MODEL=${shellQuote(model ?? "")}`,
119
+ // Спринт 24: режим сессии — "new" (по умолчанию), "reuse" (--session <id>), "last" (--continue).
120
+ `SESSION_MODE=${shellQuote(sessionMode ?? "new")}`,
121
+ `SESSION_ID=${shellQuote(sessionId ?? "")}`,
107
122
  `BEFORE_SCRIPT=${shellQuote(beforeScript ?? "")}`,
108
123
  `AFTER_SCRIPT=${shellQuote(afterScript ?? "")}`,
109
124
  `ALLOWED_TOOLS=${shellQuote((allowedTools ?? []).join(","))}`,
@@ -237,10 +252,23 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
237
252
  "",
238
253
  "# Модель указывается только если задана — иначе OpenCode берёт свою по умолчанию.",
239
254
  "run_opencode() {",
255
+ ' SESSION_ARGS=()',
256
+ ' case "$SESSION_MODE" in',
257
+ ' reuse)',
258
+ ' if [ -n "$SESSION_ID" ]; then',
259
+ ' SESSION_ARGS+=(--session "$SESSION_ID")',
260
+ ' fi',
261
+ ' ;;',
262
+ ' last)',
263
+ ' SESSION_ARGS+=(--continue)',
264
+ ' ;;',
265
+ ' *)',
266
+ ' ;;',
267
+ ' esac',
240
268
  ' if [ -n "$MODEL" ]; then',
241
- ' opencode run --model "$MODEL" "$PROMPT"',
269
+ ' opencode run "${SESSION_ARGS[@]}" --model "$MODEL" "$PROMPT"',
242
270
  " else",
243
- ' opencode run "$PROMPT"',
271
+ ' opencode run "${SESSION_ARGS[@]}" "$PROMPT"',
244
272
  " fi",
245
273
  "}",
246
274
  "",
@@ -311,6 +339,14 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
311
339
  " fi",
312
340
  "fi",
313
341
  "",
342
+ // One-shot: снимаем задание с расписания после единственного запуска.
343
+ // История уже записана, поэтому фоновая очистка не влияет на результат.
344
+ ...(oneShotCleanupCommand
345
+ ? [
346
+ `(sleep 2; ${oneShotCleanupCommand}) >/dev/null 2>&1 &`,
347
+ "",
348
+ ]
349
+ : []),
314
350
  'exit "$EXIT_CODE"',
315
351
  "",
316
352
  ];
@@ -1,5 +1,6 @@
1
1
  import { getDb, withTransaction } from "./index.js";
2
2
  import { incrementMetricsUnsafe } from "./metrics-repo.js";
3
+ import { appendStructuredLog } from "../core/structured-log.js";
3
4
  import type { TaskStatus } from "../history.js";
4
5
 
5
6
  /**
@@ -117,7 +118,7 @@ export function startRun(
117
118
  allowedTools?: string[] | null,
118
119
  deniedTools?: string[] | null
119
120
  ): number {
120
- return insertHistory({
121
+ const id = insertHistory({
121
122
  taskName,
122
123
  status: "running",
123
124
  startedAt,
@@ -126,6 +127,16 @@ export function startRun(
126
127
  allowedTools,
127
128
  deniedTools,
128
129
  });
130
+ appendStructuredLog({
131
+ event: "run.started",
132
+ runId: id,
133
+ task: taskName,
134
+ status: "running",
135
+ startedAt,
136
+ workspaceId: workspaceId ?? null,
137
+ source: "startRun",
138
+ });
139
+ return id;
129
140
  }
130
141
 
131
142
  /**
@@ -144,7 +155,11 @@ export function finishRun(
144
155
  preFlightStatus?: "success" | "error" | "skipped",
145
156
  postFlightStatus?: "success" | "error" | "skipped"
146
157
  ): boolean {
147
- return withTransaction(() => {
158
+ const safeDuration = Number.isFinite(durationMs) ? Math.max(0, Math.floor(durationMs)) : 0;
159
+ const finishedAt = new Date().toISOString();
160
+ let completed: { taskName: string; startedAt: string } | null = null;
161
+
162
+ const ok = withTransaction(() => {
148
163
  const instance = getDb();
149
164
  const row = instance
150
165
  .prepare("SELECT finished_at FROM history WHERE id = ?")
@@ -161,8 +176,8 @@ export function finishRun(
161
176
  )
162
177
  .run(
163
178
  status,
164
- new Date().toISOString(),
165
- Number.isFinite(durationMs) ? Math.max(0, Math.floor(durationMs)) : 0,
179
+ finishedAt,
180
+ safeDuration,
166
181
  error ?? null,
167
182
  nextTask ?? null,
168
183
  tokens ?? null,
@@ -174,11 +189,36 @@ export function finishRun(
174
189
  );
175
190
 
176
191
  const taskRow = instance
177
- .prepare("SELECT task_name FROM history WHERE id = ?")
192
+ .prepare("SELECT task_name, started_at FROM history WHERE id = ?")
178
193
  .get(id) as any;
179
194
  incrementMetricsUnsafe(String(taskRow.task_name), status, tokens, costUsd);
195
+ completed = {
196
+ taskName: String(taskRow.task_name),
197
+ startedAt: String(taskRow.started_at),
198
+ };
180
199
  return true;
181
200
  });
201
+
202
+ if (ok && completed) {
203
+ const done = completed as { taskName: string; startedAt: string };
204
+ appendStructuredLog({
205
+ event: "run.finished",
206
+ runId: id,
207
+ task: done.taskName,
208
+ status,
209
+ startedAt: done.startedAt,
210
+ finishedAt,
211
+ durationMs: safeDuration,
212
+ error: error ?? null,
213
+ nextTask: nextTask ?? null,
214
+ tokens,
215
+ costUsd,
216
+ model,
217
+ preFlightStatus,
218
+ postFlightStatus,
219
+ });
220
+ }
221
+ return ok;
182
222
  }
183
223
 
184
224
  /**
@@ -202,7 +242,8 @@ export function recordRun(
202
242
  allowedTools?: string[] | null,
203
243
  deniedTools?: string[] | null
204
244
  ): number {
205
- return withTransaction(() => {
245
+ const safeDuration = Math.max(0, Math.floor(Number(durationMs) || 0));
246
+ const id = withTransaction(() => {
206
247
  const result = getDb()
207
248
  .prepare(INSERT_SQL)
208
249
  .run(
@@ -210,7 +251,7 @@ export function recordRun(
210
251
  status,
211
252
  startedAt,
212
253
  finishedAt,
213
- Math.max(0, Math.floor(Number(durationMs) || 0)),
254
+ safeDuration,
214
255
  error ?? null,
215
256
  tokens ?? null,
216
257
  costUsd ?? null,
@@ -225,6 +266,25 @@ export function recordRun(
225
266
  incrementMetricsUnsafe(taskName, status, tokens, costUsd);
226
267
  return lastId(result);
227
268
  });
269
+
270
+ appendStructuredLog({
271
+ event: "run.finished",
272
+ runId: id,
273
+ task: taskName,
274
+ status,
275
+ startedAt,
276
+ finishedAt,
277
+ durationMs: safeDuration,
278
+ error: error ?? null,
279
+ nextTask: nextTask ?? null,
280
+ tokens,
281
+ costUsd,
282
+ model,
283
+ workspaceId: workspaceId ?? null,
284
+ preFlightStatus,
285
+ postFlightStatus,
286
+ });
287
+ return id;
228
288
  }
229
289
 
230
290
  /** История запусков (новые сверху). Без taskName — по всем задачам. */
@@ -16,6 +16,8 @@ export interface TaskMetricsRow {
16
16
  total: number;
17
17
  success: number;
18
18
  error: number;
19
+ /** Частичные выполнения: ответ получен, но post-flight/quality gate не прошёл. */
20
+ partial: number;
19
21
  tokens: number;
20
22
  costUsd: number;
21
23
  }
@@ -24,6 +26,7 @@ export interface MetricsTotals {
24
26
  total: number;
25
27
  success: number;
26
28
  error: number;
29
+ partial: number;
27
30
  tokens: number;
28
31
  costUsd: number;
29
32
  }
@@ -41,6 +44,7 @@ function rowToMetrics(row: any): TaskMetricsRow {
41
44
  total: Number(row.total) || 0,
42
45
  success: Number(row.success) || 0,
43
46
  error: Number(row.error) || 0,
47
+ partial: Number(row.partial) || 0,
44
48
  tokens: Number(row.total_tokens) || 0,
45
49
  costUsd: Number(row.total_cost) || 0,
46
50
  };
@@ -53,23 +57,27 @@ export function incrementMetricsUnsafe(
53
57
  tokens = 0,
54
58
  costUsd = 0
55
59
  ): void {
60
+ // error — только ошибки и таймауты; partial хранится отдельным счётчиком,
61
+ // иначе дашборд показывал частичный запуск как обычную ошибку.
56
62
  const success = status === "success" ? 1 : 0;
57
- const error = status === "success" ? 0 : 1;
63
+ const partial = status === "partial" ? 1 : 0;
64
+ const error = status === "error" || status === "timeout" ? 1 : 0;
58
65
  const safeTokens = Number.isFinite(tokens) && tokens > 0 ? Math.floor(tokens) : 0;
59
66
  const safeCost = Number.isFinite(costUsd) && costUsd > 0 ? costUsd : 0;
60
67
 
61
68
  getDb()
62
69
  .prepare(
63
- `INSERT INTO metrics (task_name, total, success, error, total_tokens, total_cost)
64
- VALUES (?, 1, ?, ?, ?, ?)
70
+ `INSERT INTO metrics (task_name, total, success, error, partial, total_tokens, total_cost)
71
+ VALUES (?, 1, ?, ?, ?, ?, ?)
65
72
  ON CONFLICT(task_name) DO UPDATE SET
66
73
  total = total + 1,
67
74
  success = success + excluded.success,
68
75
  error = error + excluded.error,
76
+ partial = partial + excluded.partial,
69
77
  total_tokens = total_tokens + excluded.total_tokens,
70
78
  total_cost = total_cost + excluded.total_cost`
71
79
  )
72
- .run(taskName, success, error, safeTokens, safeCost);
80
+ .run(taskName, success, error, partial, safeTokens, safeCost);
73
81
  }
74
82
 
75
83
  /** Атомарно увеличивает счётчики задачи: +1 запуск, +1 success/error, токены, стоимость. */
@@ -88,7 +96,7 @@ export function getMetrics(taskName: string): TaskMetricsRow {
88
96
  .prepare("SELECT * FROM metrics WHERE lower(task_name) = lower(?) LIMIT 1")
89
97
  .get(taskName) as any;
90
98
  if (!row) {
91
- return { taskName, total: 0, success: 0, error: 0, tokens: 0, costUsd: 0 };
99
+ return { taskName, total: 0, success: 0, error: 0, partial: 0, tokens: 0, costUsd: 0 };
92
100
  }
93
101
  return rowToMetrics(row);
94
102
  }
@@ -109,6 +117,7 @@ export function getTotals(): MetricsTotals {
109
117
  COALESCE(SUM(total), 0) AS total,
110
118
  COALESCE(SUM(success), 0) AS success,
111
119
  COALESCE(SUM(error), 0) AS error,
120
+ COALESCE(SUM(partial), 0) AS partial,
112
121
  COALESCE(SUM(total_tokens), 0) AS tokens,
113
122
  COALESCE(SUM(total_cost), 0) AS cost_usd
114
123
  FROM metrics`
@@ -118,6 +127,7 @@ export function getTotals(): MetricsTotals {
118
127
  total: Number(row?.total) || 0,
119
128
  success: Number(row?.success) || 0,
120
129
  error: Number(row?.error) || 0,
130
+ partial: Number(row?.partial) || 0,
121
131
  tokens: Number(row?.tokens) || 0,
122
132
  costUsd: Number(row?.cost_usd) || 0,
123
133
  };
@@ -132,12 +142,13 @@ export function incrementGlobalMetrics(status: TaskStatus): void {
132
142
  export function upsertMetricsRow(row: TaskMetricsRow): void {
133
143
  getDb()
134
144
  .prepare(
135
- `INSERT INTO metrics (task_name, total, success, error, total_tokens, total_cost)
136
- VALUES (?, ?, ?, ?, ?, ?)
145
+ `INSERT INTO metrics (task_name, total, success, error, partial, total_tokens, total_cost)
146
+ VALUES (?, ?, ?, ?, ?, ?, ?)
137
147
  ON CONFLICT(task_name) DO UPDATE SET
138
148
  total = excluded.total,
139
149
  success = excluded.success,
140
150
  error = excluded.error,
151
+ partial = excluded.partial,
141
152
  total_tokens = excluded.total_tokens,
142
153
  total_cost = excluded.total_cost`
143
154
  )
@@ -146,6 +157,7 @@ export function upsertMetricsRow(row: TaskMetricsRow): void {
146
157
  Math.max(0, Math.floor(row.total)),
147
158
  Math.max(0, Math.floor(row.success)),
148
159
  Math.max(0, Math.floor(row.error)),
160
+ Math.max(0, Math.floor(row.partial)),
149
161
  Math.max(0, Math.floor(row.tokens)),
150
162
  Math.max(0, row.costUsd)
151
163
  );
package/src/db/migrate.ts CHANGED
@@ -236,11 +236,13 @@ export async function migrateJsonToDb(
236
236
  total: 0,
237
237
  success: 0,
238
238
  error: 0,
239
+ partial: 0,
239
240
  tokens: 0,
240
241
  costUsd: 0,
241
242
  } satisfies TaskMetricsRow);
242
243
  current.total += 1;
243
244
  if (row.status === "success") current.success += 1;
245
+ else if (row.status === "partial") current.partial += 1;
244
246
  else current.error += 1;
245
247
  current.tokens += Math.max(0, row.tokens ?? 0);
246
248
  current.costUsd += Math.max(0, row.costUsd ?? 0);
@@ -253,16 +255,19 @@ export async function migrateJsonToDb(
253
255
  total: acc.total + row.total,
254
256
  success: acc.success + row.success,
255
257
  error: acc.error + row.error,
258
+ partial: acc.partial + row.partial,
256
259
  tokens: acc.tokens + row.tokens,
257
260
  costUsd: acc.costUsd + row.costUsd,
258
261
  }),
259
- { total: 0, success: 0, error: 0, tokens: 0, costUsd: 0 }
262
+ { total: 0, success: 0, error: 0, partial: 0, tokens: 0, costUsd: 0 }
260
263
  );
261
264
 
262
265
  const extra = {
263
266
  total: Math.max(0, (toNumber(legacyMetrics.total) ?? 0) - migrated.total),
264
267
  success: Math.max(0, (toNumber(legacyMetrics.success) ?? 0) - migrated.success),
265
268
  error: Math.max(0, (toNumber(legacyMetrics.error) ?? 0) - migrated.error),
269
+ // В старом metrics.json не было отдельного счётчика partial.
270
+ partial: 0,
266
271
  tokens: Math.max(0, (toNumber(legacyMetrics.tokens) ?? 0) - migrated.tokens),
267
272
  costUsd: Math.max(0, (toNumber(legacyMetrics.costUsd) ?? 0) - migrated.costUsd),
268
273
  };
@@ -277,6 +282,7 @@ export async function migrateJsonToDb(
277
282
  total: extra.total,
278
283
  success: extra.success,
279
284
  error: extra.error,
285
+ partial: extra.partial,
280
286
  tokens: extra.tokens,
281
287
  costUsd: extra.costUsd,
282
288
  });
package/src/db/schema.ts CHANGED
@@ -41,6 +41,7 @@ CREATE TABLE IF NOT EXISTS metrics (
41
41
  total INTEGER DEFAULT 0,
42
42
  success INTEGER DEFAULT 0,
43
43
  error INTEGER DEFAULT 0,
44
+ partial INTEGER DEFAULT 0,
44
45
  total_tokens INTEGER DEFAULT 0,
45
46
  total_cost REAL DEFAULT 0
46
47
  );
@@ -120,4 +121,14 @@ export function applySchema(db: SchemaDb): void {
120
121
  if (!workspaceColumnNames.includes("env_file")) {
121
122
  db.exec("ALTER TABLE workspaces ADD COLUMN env_file TEXT");
122
123
  }
124
+
125
+ // Спринт 25: partial вынесен из error, чтобы дашборд не смешивал
126
+ // частичные выполнения с ошибками и таймаутами.
127
+ const metricsColumns = db.prepare("PRAGMA table_info(metrics)").all() as Array<{
128
+ name?: string;
129
+ }>;
130
+ const metricsColumnNames = metricsColumns.map((c) => c.name).filter(Boolean);
131
+ if (!metricsColumnNames.includes("partial")) {
132
+ db.exec("ALTER TABLE metrics ADD COLUMN partial INTEGER DEFAULT 0");
133
+ }
123
134
  }