codekin 0.6.3 → 0.6.5

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 (113) hide show
  1. package/README.md +1 -0
  2. package/bin/codekin.mjs +69 -6
  3. package/dist/assets/index-B0xIzdCK.js +187 -0
  4. package/dist/assets/index-Q2WSVlHo.css +1 -0
  5. package/dist/index.html +2 -2
  6. package/package.json +5 -5
  7. package/server/dist/auth-routes.js +6 -0
  8. package/server/dist/auth-routes.js.map +1 -1
  9. package/server/dist/claude-process.d.ts +1 -0
  10. package/server/dist/claude-process.js +7 -3
  11. package/server/dist/claude-process.js.map +1 -1
  12. package/server/dist/commit-event-handler.d.ts +16 -2
  13. package/server/dist/commit-event-handler.js +43 -10
  14. package/server/dist/commit-event-handler.js.map +1 -1
  15. package/server/dist/commit-event-hooks.d.ts +11 -0
  16. package/server/dist/commit-event-hooks.js +61 -11
  17. package/server/dist/commit-event-hooks.js.map +1 -1
  18. package/server/dist/config.d.ts +19 -0
  19. package/server/dist/config.js +43 -1
  20. package/server/dist/config.js.map +1 -1
  21. package/server/dist/docs-routes.js +4 -7
  22. package/server/dist/docs-routes.js.map +1 -1
  23. package/server/dist/json-parse.d.ts +8 -0
  24. package/server/dist/json-parse.js +9 -0
  25. package/server/dist/json-parse.js.map +1 -0
  26. package/server/dist/opencode-process.js +8 -1
  27. package/server/dist/opencode-process.js.map +1 -1
  28. package/server/dist/orchestrator-children.d.ts +41 -1
  29. package/server/dist/orchestrator-children.js +87 -1
  30. package/server/dist/orchestrator-children.js.map +1 -1
  31. package/server/dist/orchestrator-learning-router.d.ts +8 -0
  32. package/server/dist/orchestrator-learning-router.js +126 -0
  33. package/server/dist/orchestrator-learning-router.js.map +1 -0
  34. package/server/dist/orchestrator-learning.d.ts +0 -5
  35. package/server/dist/orchestrator-learning.js +2 -9
  36. package/server/dist/orchestrator-learning.js.map +1 -1
  37. package/server/dist/orchestrator-memory-router.d.ts +10 -0
  38. package/server/dist/orchestrator-memory-router.js +148 -0
  39. package/server/dist/orchestrator-memory-router.js.map +1 -0
  40. package/server/dist/orchestrator-memory.js +2 -1
  41. package/server/dist/orchestrator-memory.js.map +1 -1
  42. package/server/dist/orchestrator-monitor.d.ts +6 -0
  43. package/server/dist/orchestrator-monitor.js +27 -0
  44. package/server/dist/orchestrator-monitor.js.map +1 -1
  45. package/server/dist/orchestrator-notify.d.ts +29 -0
  46. package/server/dist/orchestrator-notify.js +27 -0
  47. package/server/dist/orchestrator-notify.js.map +1 -0
  48. package/server/dist/orchestrator-reports.d.ts +0 -4
  49. package/server/dist/orchestrator-reports.js +8 -10
  50. package/server/dist/orchestrator-reports.js.map +1 -1
  51. package/server/dist/orchestrator-routes.d.ts +2 -2
  52. package/server/dist/orchestrator-routes.js +11 -506
  53. package/server/dist/orchestrator-routes.js.map +1 -1
  54. package/server/dist/orchestrator-session-router.d.ts +13 -0
  55. package/server/dist/orchestrator-session-router.js +315 -0
  56. package/server/dist/orchestrator-session-router.js.map +1 -0
  57. package/server/dist/process-coordinator.d.ts +83 -0
  58. package/server/dist/process-coordinator.js +167 -0
  59. package/server/dist/process-coordinator.js.map +1 -0
  60. package/server/dist/prompt-router.js +2 -1
  61. package/server/dist/prompt-router.js.map +1 -1
  62. package/server/dist/session-archive.js +2 -1
  63. package/server/dist/session-archive.js.map +1 -1
  64. package/server/dist/session-lifecycle.d.ts +1 -0
  65. package/server/dist/session-lifecycle.js +15 -36
  66. package/server/dist/session-lifecycle.js.map +1 -1
  67. package/server/dist/session-manager.d.ts +34 -0
  68. package/server/dist/session-manager.js +161 -79
  69. package/server/dist/session-manager.js.map +1 -1
  70. package/server/dist/session-persistence.js +3 -1
  71. package/server/dist/session-persistence.js.map +1 -1
  72. package/server/dist/session-routes.d.ts +18 -0
  73. package/server/dist/session-routes.js +60 -12
  74. package/server/dist/session-routes.js.map +1 -1
  75. package/server/dist/stepflow-handler.js +5 -1
  76. package/server/dist/stepflow-handler.js.map +1 -1
  77. package/server/dist/stepflow-prompt.js +16 -12
  78. package/server/dist/stepflow-prompt.js.map +1 -1
  79. package/server/dist/tsconfig.tsbuildinfo +1 -1
  80. package/server/dist/types.d.ts +4 -0
  81. package/server/dist/types.js +1 -0
  82. package/server/dist/types.js.map +1 -1
  83. package/server/dist/upload-routes.d.ts +5 -0
  84. package/server/dist/upload-routes.js +81 -16
  85. package/server/dist/upload-routes.js.map +1 -1
  86. package/server/dist/version-check.js +3 -2
  87. package/server/dist/version-check.js.map +1 -1
  88. package/server/dist/webhook-rate-limiter.js +9 -1
  89. package/server/dist/webhook-rate-limiter.js.map +1 -1
  90. package/server/dist/webhook-workspace.d.ts +12 -0
  91. package/server/dist/webhook-workspace.js +126 -3
  92. package/server/dist/webhook-workspace.js.map +1 -1
  93. package/server/dist/workflow-engine.d.ts +81 -7
  94. package/server/dist/workflow-engine.js +234 -40
  95. package/server/dist/workflow-engine.js.map +1 -1
  96. package/server/dist/workflow-loader.d.ts +6 -1
  97. package/server/dist/workflow-loader.js +189 -35
  98. package/server/dist/workflow-loader.js.map +1 -1
  99. package/server/dist/workflow-routes.d.ts +13 -0
  100. package/server/dist/workflow-routes.js +140 -4
  101. package/server/dist/workflow-routes.js.map +1 -1
  102. package/server/dist/ws-message-handler.js +5 -1
  103. package/server/dist/ws-message-handler.js.map +1 -1
  104. package/server/dist/ws-origin-check.d.ts +11 -0
  105. package/server/dist/ws-origin-check.js +20 -0
  106. package/server/dist/ws-origin-check.js.map +1 -0
  107. package/server/dist/ws-rate-limit.d.ts +19 -0
  108. package/server/dist/ws-rate-limit.js +30 -0
  109. package/server/dist/ws-rate-limit.js.map +1 -0
  110. package/server/dist/ws-server.js +69 -32
  111. package/server/dist/ws-server.js.map +1 -1
  112. package/dist/assets/index-CxlBrS5y.js +0 -182
  113. package/dist/assets/index-DgeUVGjz.css +0 -1
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import { readFileSync } from 'fs';
9
9
  import { join } from 'path';
10
+ import { jsonParse } from './json-parse.js';
10
11
  /** How long to cache the npm lookup result (6 hours). */
11
12
  const CACHE_TTL_MS = 6 * 60 * 60 * 1000;
12
13
  /** npm registry endpoint for the package. */
@@ -21,8 +22,8 @@ const state = {
21
22
  function getCurrentVersion() {
22
23
  if (!state.currentVersion) {
23
24
  const pkgPath = join(import.meta.dirname, '..', 'package.json');
24
- const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
25
- state.currentVersion = pkg.version;
25
+ const pkg = jsonParse(readFileSync(pkgPath, 'utf-8'));
26
+ state.currentVersion = String(pkg.version);
26
27
  }
27
28
  return state.currentVersion;
28
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"version-check.js","sourceRoot":"","sources":["../version-check.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,yDAAyD;AACzD,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAEvC,6CAA6C;AAC7C,MAAM,YAAY,GAAG,2CAA2C,CAAA;AAShE,MAAM,KAAK,GAAiB;IAC1B,cAAc,EAAE,EAAE;IAClB,aAAa,EAAE,IAAI;IACnB,eAAe,EAAE,KAAK;IACtB,SAAS,EAAE,CAAC;CACb,CAAA;AAED,yDAAyD;AACzD,SAAS,iBAAiB;IACxB,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,cAAc,CAAC,CAAA;QAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;QACtD,KAAK,CAAC,cAAc,GAAG,GAAG,CAAC,OAAO,CAAA;IACpC,CAAC;IACD,OAAO,KAAK,CAAC,cAAc,CAAA;A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,KAAK,CAAC,aAAa,GAAG,MAAM,CAAA;QAC5B,KAAK,CAAC,eAAe,GAAG,KAAK,CAAA;QAC7B,OAAO,CAAC,GAAG,CAAC,oBAAoB,OAAO,gBAAgB,CAAC,CAAA;IAC1D,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,SAAS,GAAG,YAAY,EAAE,CAAC;QAChD,MAAM,eAAe,EAAE,CAAA;IACzB,CAAC;IACD,IAAI,KAAK,CAAC,eAAe,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;QACjD,OAAO,YAAY,KAAK,CAAC,aAAa,4BAA4B,KAAK,CAAC,cAAc,qCAAqC,CAAA;IAC7H,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { jsonParse } from './json-parse.js';
1
2
  /**
2
3
  * Creates a per-key sliding window rate limiter for webhook requests.
3
4
  *
@@ -27,6 +28,8 @@
27
28
  export function createWebhookRateLimiter(maxPerMinute = 30,
28
29
  /** Extract a rate-limit key from the parsed body. Return `undefined` to skip limiting. */
29
30
  keyExtractor = (body) => body?.repository?.full_name) {
31
+ /** Maximum number of tracked keys to prevent unbounded memory growth. */
32
+ const WEBHOOK_RATE_MAP_MAX_SIZE = 10_000;
30
33
  const keyTimestamps = new Map();
31
34
  // Periodic cleanup: every 5 minutes, remove keys with no recent timestamps
32
35
  const cleanupInterval = setInterval(() => {
@@ -50,7 +53,7 @@ keyExtractor = (body) => body?.repository?.full_name) {
50
53
  try {
51
54
  const body = req.body;
52
55
  if (Buffer.isBuffer(body)) {
53
- const parsed = JSON.parse(body.toString('utf-8'));
56
+ const parsed = jsonParse(body.toString('utf-8'));
54
57
  key = keyExtractor(parsed);
55
58
  }
56
59
  }
@@ -70,6 +73,11 @@ keyExtractor = (body) => body?.repository?.full_name) {
70
73
  res.status(429).json({ error: 'Too Many Requests', repo: key, retryAfter: 60 });
71
74
  return;
72
75
  }
76
+ // Reject new keys if the map has grown too large (DoS protection)
77
+ if (recent.length === 0 && keyTimestamps.size >= WEBHOOK_RATE_MAP_MAX_SIZE) {
78
+ res.status(429).json({ error: 'Too Many Requests', retryAfter: 60 });
79
+ return;
80
+ }
73
81
  recent.push(now);
74
82
  keyTimestamps.set(key, recent);
75
83
  next();
@@ -1 +1 @@
1
- {"version":3,"file":"webhook-rate-limiter.js","sourceRoot":"","sources":["../webhook-rate-limiter.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,wBAAwB,CACtC,YAAY,GAAG,EAAE;AACjB,2FAA2F;AAC3F,eAAsD,CAAC,IAAI,EAAE,EAAE,CAC5D,IAA4D,EAAE,UAAU,EAAE,SAAS;IAEtF,MAAM,aAAa,GAAG,IAAI,GAAG,EAAoB,CAAA;IAEjD,2EAA2E;IAC3E,MAAM,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE;QACvC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACtB,KAAK,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,aAAa,EAAE,CAAC;YAC9C,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,CAAA;YACvD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACxB,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YAC3B,CAAC;iBAAM,CAAC;gBACN,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;YAChC,CAAC;QACH,CAAC;IACH,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAA;IAEjB,6DAA6D;IAC7D,IAAI,eAAe,CAAC,KAAK,EAAE,CAAC;QAC1B,eAAe,CAA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AAC,GAAG,CAAC,CAAA;QAChB,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAC9B,IAAI,EAAE,CAAA;IACR,CAAC,CAAA;AACH,CAAC"}
@@ -10,6 +10,18 @@
10
10
  * @returns The absolute path to the created workspace directory.
11
11
  */
12
12
  export declare function createWorkspace(sessionId: string, repo: string, cloneUrl: string, branch: string, headSha: string): Promise<string>;
13
+ /**
14
+ * Scan a workspace for report files under `.codekin/reports/` and commit them
15
+ * to the `codekin/reports` branch of origin.
16
+ *
17
+ * Uses the same worktree-based approach as the MD workflow engine's save_report
18
+ * step so that reports from both systems end up in the same place. This must
19
+ * be called BEFORE cleanupWorkspace() so the workspace still exists.
20
+ *
21
+ * @param sessionId - Session ID (used for log context and temp worktree naming).
22
+ * @param commitPrefix - Commit message prefix (e.g. "chore: code review").
23
+ */
24
+ export declare function commitReportsFromWorkspace(sessionId: string, commitPrefix: string): void;
13
25
  /**
14
26
  * Remove a workspace directory when a session closes.
15
27
  *
@@ -1,7 +1,7 @@
1
- import { execFile } from 'child_process';
2
- import { existsSync, mkdirSync, rmSync } from 'fs';
1
+ import { execFile, execFileSync } from 'child_process';
2
+ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'fs';
3
3
  import { homedir } from 'os';
4
- import { join, resolve } from 'path';
4
+ import { dirname, join, resolve } from 'path';
5
5
  import { promisify } from 'util';
6
6
  const execFileAsync = promisify(execFile);
7
7
  const GIT_TIMEOUT_MS = 120_000;
@@ -158,6 +158,129 @@ export async function createWorkspace(sessionId, repo, cloneUrl, branch, headSha
158
158
  }
159
159
  }
160
160
  }
161
+ /**
162
+ * Scan a workspace for report files under `.codekin/reports/` and commit them
163
+ * to the `codekin/reports` branch of origin.
164
+ *
165
+ * Uses the same worktree-based approach as the MD workflow engine's save_report
166
+ * step so that reports from both systems end up in the same place. This must
167
+ * be called BEFORE cleanupWorkspace() so the workspace still exists.
168
+ *
169
+ * @param sessionId - Session ID (used for log context and temp worktree naming).
170
+ * @param commitPrefix - Commit message prefix (e.g. "chore: code review").
171
+ */
172
+ export function commitReportsFromWorkspace(sessionId, commitPrefix) {
173
+ const workspacePath = join(WORKSPACES_DIR, sessionId);
174
+ const reportsDir = join(workspacePath, '.codekin', 'reports');
175
+ if (!existsSync(reportsDir))
176
+ return;
177
+ // Collect all .md report files
178
+ const reportFiles = [];
179
+ try {
180
+ for (const category of readdirSync(reportsDir)) {
181
+ const categoryDir = join(reportsDir, category);
182
+ let entries;
183
+ try {
184
+ entries = readdirSync(categoryDir);
185
+ }
186
+ catch {
187
+ continue;
188
+ }
189
+ for (const file of entries) {
190
+ if (!file.endsWith('.md'))
191
+ continue;
192
+ const fullPath = join(categoryDir, file);
193
+ reportFiles.push({
194
+ relativePath: `.codekin/reports/${category}/${file}`,
195
+ content: readFileSync(fullPath, 'utf-8'),
196
+ });
197
+ }
198
+ }
199
+ }
200
+ catch (err) {
201
+ console.warn(`[webhook-workspace] Failed to scan reports in ${workspacePath}:`, err);
202
+ return;
203
+ }
204
+ if (reportFiles.length === 0)
205
+ return;
206
+ const REPORTS_BRANCH = 'codekin/reports';
207
+ const dateStr = new Date().toISOString().slice(0, 10);
208
+ try {
209
+ // Ensure the reports branch exists on origin (create from HEAD if needed)
210
+ try {
211
+ execFileSync('git', ['rev-parse', '--verify', `origin/${REPORTS_BRANCH}`], {
212
+ cwd: workspacePath, timeout: 5_000, stdio: 'pipe',
213
+ });
214
+ }
215
+ catch {
216
+ // Remote branch doesn't exist — create it locally first
217
+ try {
218
+ execFileSync('git', ['branch', REPORTS_BRANCH], {
219
+ cwd: workspacePath, timeout: 5_000,
220
+ });
221
+ }
222
+ catch {
223
+ // May already exist locally
224
+ }
225
+ }
226
+ // Fetch the reports branch so we have the latest
227
+ try {
228
+ execFileSync('git', ['fetch', 'origin', `${REPORTS_BRANCH}:${REPORTS_BRANCH}`], { cwd: workspacePath, timeout: 30_000, stdio: 'pipe', env: GIT_AUTH_ENV });
229
+ }
230
+ catch {
231
+ // Branch may not exist on remote yet — that's OK
232
+ }
233
+ // Create a temporary worktree on the reports branch
234
+ const wtDir = join(WORKSPACES_DIR, `.report-wt-${sessionId.slice(0, 12)}`);
235
+ try {
236
+ execFileSync('git', ['worktree', 'add', wtDir, REPORTS_BRANCH], {
237
+ cwd: workspacePath, timeout: 10_000,
238
+ });
239
+ // Copy each report file into the worktree
240
+ for (const report of reportFiles) {
241
+ const destPath = join(wtDir, report.relativePath);
242
+ const destDir = dirname(destPath);
243
+ if (!existsSync(destDir))
244
+ mkdirSync(destDir, { recursive: true });
245
+ writeFileSync(destPath, report.content, 'utf-8');
246
+ }
247
+ // Stage and check if there's anything to commit
248
+ execFileSync('git', ['add', '.codekin/reports'], { cwd: wtDir, timeout: 10_000 });
249
+ try {
250
+ execFileSync('git', ['diff', '--cached', '--quiet'], { cwd: wtDir, timeout: 5_000 });
251
+ // Exit code 0 means no staged changes — nothing to commit
252
+ console.log(`[webhook-workspace] Reports already up to date on ${REPORTS_BRANCH}, skipping commit`);
253
+ return;
254
+ }
255
+ catch {
256
+ // Exit code 1 means there are staged changes — proceed with commit
257
+ }
258
+ // Set git identity in the worktree to avoid "Author identity unknown"
259
+ execFileSync('git', ['config', 'user.name', 'Codekin Workflow'], { cwd: wtDir, timeout: 5_000 });
260
+ execFileSync('git', ['config', 'user.email', 'workflow@codekin.local'], { cwd: wtDir, timeout: 5_000 });
261
+ execFileSync('git', ['commit', '-m', `${commitPrefix} ${dateStr}`], { cwd: wtDir, timeout: 15_000 });
262
+ console.log(`[webhook-workspace] Committed ${reportFiles.length} report(s) on ${REPORTS_BRANCH}`);
263
+ try {
264
+ execFileSync('git', ['push', 'origin', REPORTS_BRANCH], { cwd: wtDir, timeout: 30_000, stdio: 'pipe', env: GIT_AUTH_ENV });
265
+ console.log(`[webhook-workspace] Pushed ${REPORTS_BRANCH} to origin`);
266
+ }
267
+ catch (pushErr) {
268
+ console.warn(`[webhook-workspace] Could not push ${REPORTS_BRANCH}: ${pushErr}`);
269
+ }
270
+ }
271
+ finally {
272
+ try {
273
+ execFileSync('git', ['worktree', 'remove', '--force', wtDir], {
274
+ cwd: workspacePath, timeout: 10_000,
275
+ });
276
+ }
277
+ catch { /* best-effort cleanup */ }
278
+ }
279
+ }
280
+ catch (err) {
281
+ console.warn(`[webhook-workspace] Could not commit reports from workspace ${sessionId}: ${err}`);
282
+ }
283
+ }
161
284
  /**
162
285
  * Remove a workspace directory when a session closes.
163
286
  *
@@ -1 +1 @@
1
- {"version":3,"file":"webhook-workspace.js","sourceRoot":"","sources":["../webhook-workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,IAAI,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAEhC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;AACzC,MAAM,cAAc,GAAG,OAAO,CAAA;AAE9B;;;;;;;GAOG;AACH,MAAM,YAAY,GAAG;IACnB,GAAG,OAAO,CAAC,GAAG;IACd,gBAAgB,EAAE,GAAG;IACrB,gBAAgB,EAAE,sCAAsC;IACxD,kBAAkB,EAAE,kCAAkC;CACvD,CAAA;AAED,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAA;AAC5C,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;AACzC,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;AAEnD,iFAAiF;AACjF,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2B,CAAA;AAEtD;;;;;;GAMG;AACH,KAAK,U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Skipped extends Error {
24
24
  constructor(message: string);
25
25
  }
26
+ /**
27
+ * Thrown when a step references a session that no longer exists in the session manager —
28
+ * either because it was deleted, expired, or never persisted across a server restart.
29
+ * Carries enough context (run id, step key, session id, last heartbeat) for diagnostics.
30
+ */
31
+ export declare class SessionGoneError extends Error {
32
+ readonly runId: string;
33
+ readonly stepKey: string;
34
+ readonly sessionId: string;
35
+ readonly lastSeen: string | null;
36
+ constructor(runId: string, stepKey: string, sessionId: string, lastSeen: string | null);
37
+ }
26
38
  /**
27
39
  * Lifecycle status of an individual workflow step.
28
40
  * - `pending` — not yet reached by the executor
@@ -52,6 +64,12 @@ export interface WorkflowRun {
52
64
  startedAt: string | null;
53
65
  /** ISO timestamp when execution finished (success, failure, or skip). */
54
66
  completedAt: string | null;
67
+ /** Codekin session id owned by this run, recorded by `create_session`. Null until that step records it. */
68
+ sessionId?: string | null;
69
+ /** ISO timestamp updated whenever a step starts; serves as a liveness heartbeat for resume. */
70
+ lastStepAt?: string | null;
71
+ /** Key of the step that was most recently marked running. Used to resume from the right place. */
72
+ currentStepKey?: string | null;
55
73
  }
56
74
  /** A single step within a workflow run. Insertion order (rowid) preserves definition order. */
57
75
  export interface WorkflowStep {
@@ -111,15 +129,33 @@ export interface WorkflowEvent {
111
129
  /**
112
130
  * Step handler function — receives step input + run context, returns step output.
113
131
  * @param input Merged output of all preceding steps (plus the run's original input).
114
- * @param context.runId UUID of the current run.
115
- * @param context.run Full WorkflowRun object (mutable — reflects current status).
116
- * @param context.abortSignal Fires when `cancelRun()` is called; handlers should check or listen on it.
132
+ * @param context.runId UUID of the current run.
133
+ * @param context.run Full WorkflowRun object (mutable — reflects current status).
134
+ * @param context.abortSignal Fires when `cancelRun()` is called; handlers should check or listen on it.
135
+ * @param context.resumed True when this step is being re-executed after a server restart.
136
+ * Handlers can use this to skip side effects already performed
137
+ * (e.g. don't re-send a Claude prompt — just await the result).
138
+ * @param context.recordSessionId Persist the session id atomically with `create_session`, so that
139
+ * a later `resumeInterrupted()` scan can reattach to the session
140
+ * even if the server crashed before the step's output row was written.
117
141
  */
118
142
  export type StepHandler = (input: Record<string, unknown>, context: {
119
143
  runId: string;
120
144
  run: WorkflowRun;
121
145
  abortSignal: AbortSignal;
146
+ resumed?: boolean;
147
+ recordSessionId?: (sessionId: string) => void;
122
148
  }) => Promise<Record<string, unknown>>;
149
+ /**
150
+ * Result of resolving a workflow's session at resume time.
151
+ * `null` means the session is gone (deleted, expired, never persisted) and the run cannot resume.
152
+ */
153
+ export interface SessionLiveness {
154
+ /** ISO timestamp of the most recent activity on the session, if known. */
155
+ lastActivityAt?: string | null;
156
+ }
157
+ /** Lookup function used by `resumeInterrupted()` to decide whether a session is still resumable. */
158
+ export type SessionResolver = (sessionId: string) => SessionLiveness | null;
123
159
  interface StepDefinition {
124
160
  key: string;
125
161
  handler: StepHandler;
@@ -130,13 +166,29 @@ interface WorkflowDefinition {
130
166
  /** Called after run completes (success or failure) for cleanup. */
131
167
  afterRun?: (run: WorkflowRun) => Promise<void>;
132
168
  }
169
+ export declare function cronMatchesDate(expression: string, date: Date): boolean;
133
170
  export declare class WorkflowEngine extends EventEmitter {
134
171
  private db;
135
172
  private workflows;
136
173
  private activeAbortControllers;
137
174
  private cronTimer;
175
+ private sessionResolver;
138
176
  constructor(dbPath?: string);
139
177
  private createTables;
178
+ /**
179
+ * Apply additive (backwards-compatible) schema migrations.
180
+ * Each ALTER TABLE is wrapped in try/catch so a re-run on a migrated DB is a no-op
181
+ * (SQLite has no `ADD COLUMN IF NOT EXISTS`). New columns are nullable so older rows
182
+ * keep working without backfill.
183
+ */
184
+ private migrateSchema;
185
+ /**
186
+ * Register a callback used by `resumeInterrupted()` to decide whether a workflow's
187
+ * session is still alive. Pass `null` to clear. Without a resolver, all interrupted
188
+ * runs whose session_id is set are conservatively treated as resumable — but the
189
+ * step handler will still surface a typed error if the session has actually gone.
190
+ */
191
+ setSessionResolver(resolver: SessionResolver | null): void;
140
192
  /** Register a workflow kind with its step definitions. Must be called before `startRun()`. */
141
193
  registerWorkflow(definition: WorkflowDefinition): void;
142
194
  /** Check whether a workflow kind has been registered. */
@@ -155,10 +207,21 @@ export declare class WorkflowEngine extends EventEmitter {
155
207
  *
156
208
  * Cancellation: `cancelRun()` calls controller.abort(); the AbortSignal is
157
209
  * passed to each handler so long-running async work can exit cooperatively.
210
+ *
211
+ * Resume: when `opts.resumeFromKey` is set, steps before that key are skipped
212
+ * (their outputs come from `opts.priorOutput`) and the resumed step receives
213
+ * `resumed: true` in its context so the handler can avoid double side effects.
158
214
  */
159
215
  private executeRun;
160
216
  /** Signal an active run to abort. Returns true if the run was in-flight and the signal was sent. */
161
217
  cancelRun(runId: string): boolean;
218
+ /**
219
+ * Persist a session id on a run so that `resumeInterrupted()` can locate the
220
+ * still-alive session even if the server crashes before the `create_session`
221
+ * step's output row is committed. Called from inside the step handler via
222
+ * `ctx.recordSessionId(...)`.
223
+ */
224
+ recordSessionId(runId: string, sessionId: string): void;
162
225
  /** Fetch a single run with all its steps (ordered by definition order). Returns `null` if not found. */
163
226
  getRun(runId: string): (WorkflowRun & {
164
227
  steps: WorkflowStep[];
@@ -185,12 +248,23 @@ export declare class WorkflowEngine extends EventEmitter {
185
248
  /** Stop the cron polling loop. Safe to call multiple times. */
186
249
  stopCronScheduler(): void;
187
250
  /**
188
- * Mark any runs that were in-flight when the server last shut down as failed.
189
- * Called once at startup — a run left in 'running' state means the Node process
190
- * died mid-execution and the AbortController / step callbacks are gone, so there
191
- * is no safe way to resume; failing fast is cleaner than leaving them stuck.
251
+ * Resume runs that were in-flight when the server last shut down.
252
+ *
253
+ * Strategy:
254
+ * 1. Find all runs still marked `running` (no graceful completion happened).
255
+ * 2. For each, look at `session_id` + `current_step_key` — captured before the crash.
256
+ * 3. If the session is still alive (per `sessionResolver`) and the step is one we know how
257
+ * to resume (`run_prompt`, `save_report`), re-execute from there with `resumed: true`.
258
+ * 4. Otherwise mark the run failed with a clear, typed reason. We do NOT silently mark
259
+ * remaining steps `skipped` — the failure surface is loud so reports don't go missing.
260
+ *
261
+ * Earlier steps (`validate_repo`, `create_session`) are not resumed: by the time they were
262
+ * running, the workflow had no usable session yet, and re-creating one mid-way would risk
263
+ * spawning duplicate sessions or sending the prompt twice.
192
264
  */
193
265
  resumeInterrupted(): Promise<void>;
266
+ /** Mark a run as failed during the resume scan (no AbortController, no in-memory run object). */
267
+ private failInterrupted;
194
268
  private emitEvent;
195
269
  /** Gracefully shut down: stop cron, cancel active runs, close the database. */
196
270
  shutdown(): void;