@actiondock/core 2.9.1 → 2.11.0

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 (256) hide show
  1. package/README.md +1 -2
  2. package/dist/catalog/action-catalog.js +3 -33
  3. package/dist/catalog/discovery.d.ts +0 -3
  4. package/dist/catalog/discovery.js +4 -4
  5. package/dist/catalog/graph.d.ts +0 -4
  6. package/dist/catalog/graph.js +12 -15
  7. package/dist/{profile/client-actions.d.ts → client/actions.d.ts} +1 -1
  8. package/dist/{profile/client-actions.js → client/actions.js} +2 -8
  9. package/dist/{profile/client-config.d.ts → client/config.d.ts} +1 -1
  10. package/dist/{profile/client-config.js → client/config.js} +1 -1
  11. package/dist/client/dispatcher.d.ts +4 -0
  12. package/dist/client/dispatcher.js +21 -0
  13. package/dist/client/health.d.ts +38 -0
  14. package/dist/{profile/client-health.js → client/health.js} +9 -6
  15. package/dist/client/index.d.ts +16 -0
  16. package/dist/client/index.js +20 -0
  17. package/dist/{profile/client-playbooks.d.ts → client/playbooks.d.ts} +1 -1
  18. package/dist/{profile/client-playbooks.js → client/playbooks.js} +1 -1
  19. package/dist/{profile/client-runs.d.ts → client/runs.d.ts} +4 -2
  20. package/dist/{profile/client-runs.js → client/runs.js} +7 -1
  21. package/dist/{profile/client-state.d.ts → client/state.d.ts} +1 -1
  22. package/dist/{profile/client-state.js → client/state.js} +1 -1
  23. package/dist/{profile/client-transport.d.ts → client/transport.d.ts} +29 -10
  24. package/dist/{profile/client-transport.js → client/transport.js} +125 -35
  25. package/dist/doctor/checks/index.d.ts +1 -1
  26. package/dist/doctor/checks/index.js +1 -1
  27. package/dist/doctor/checks/project.js +24 -92
  28. package/dist/doctor/checks/registry.js +1 -1
  29. package/dist/doctor/checks/runtime.d.ts +0 -4
  30. package/dist/doctor/checks/runtime.js +0 -28
  31. package/dist/doctor/doctor.js +1 -2
  32. package/dist/errors.d.ts +85 -4
  33. package/dist/errors.js +114 -4
  34. package/dist/execution/service.d.ts +55 -37
  35. package/dist/execution/service.js +601 -212
  36. package/dist/execution/types.d.ts +24 -5
  37. package/dist/host/host.d.ts +42 -22
  38. package/dist/host/host.js +565 -150
  39. package/dist/host/routing.js +6 -6
  40. package/dist/host/types.d.ts +25 -13
  41. package/dist/index.d.ts +9 -4
  42. package/dist/index.js +5 -2
  43. package/dist/input/advice.d.ts +0 -44
  44. package/dist/input/advice.js +7 -141
  45. package/dist/input/describe.d.ts +6 -0
  46. package/dist/input/describe.js +26 -1
  47. package/dist/input/flat-materializer.js +1 -1
  48. package/dist/input/flat-parser.js +1 -1
  49. package/dist/input/index.d.ts +0 -1
  50. package/dist/input/index.js +0 -1
  51. package/dist/input/input-resolver.js +2 -2
  52. package/dist/input/validation-mapper.d.ts +1 -1
  53. package/dist/invocation/policy.js +2 -0
  54. package/dist/ipc/diagnostic.d.ts +8 -21
  55. package/dist/ipc/diagnostic.js +24 -57
  56. package/dist/ipc/host.js +21 -7
  57. package/dist/ipc/service.d.ts +14 -0
  58. package/dist/ipc/service.js +132 -26
  59. package/dist/ipc/types.d.ts +0 -4
  60. package/dist/package/index.d.ts +4 -5
  61. package/dist/package/index.js +1 -2
  62. package/dist/package/runtime.d.ts +94 -23
  63. package/dist/package/runtime.js +628 -274
  64. package/dist/package/static-index.d.ts +3 -6
  65. package/dist/package/static-index.js +11 -40
  66. package/dist/package/types.d.ts +19 -4
  67. package/dist/platform/index.d.ts +2 -1
  68. package/dist/platform/index.js +2 -1
  69. package/dist/platform/loader-hook.d.ts +32 -0
  70. package/dist/platform/loader-hook.js +90 -0
  71. package/dist/{node → platform}/module-loader.d.ts +13 -0
  72. package/dist/{node → platform}/module-loader.js +51 -4
  73. package/dist/platform/node.d.ts +19 -8
  74. package/dist/platform/node.js +50 -20
  75. package/dist/platform/types.d.ts +7 -47
  76. package/dist/process/context-process.d.ts +3 -18
  77. package/dist/process/context-process.js +3 -44
  78. package/dist/process/control.d.ts +21 -0
  79. package/dist/process/control.js +34 -0
  80. package/dist/process/converters.d.ts +23 -0
  81. package/dist/process/converters.js +92 -0
  82. package/dist/process/cursor.js +2 -22
  83. package/dist/process/{diagnostics-sink.d.ts → diagnostics.d.ts} +0 -7
  84. package/dist/process/{diagnostics-sink.js → diagnostics.js} +6 -8
  85. package/dist/process/index.d.ts +1 -3
  86. package/dist/process/index.js +1 -3
  87. package/dist/process/input-dispatcher.d.ts +4 -13
  88. package/dist/process/input-dispatcher.js +48 -69
  89. package/dist/process/managed-record.d.ts +3 -31
  90. package/dist/process/metadata-store.d.ts +0 -41
  91. package/dist/process/metadata-store.js +2 -341
  92. package/dist/process/process-driver.js +2 -2
  93. package/dist/process/process-manager.d.ts +8 -50
  94. package/dist/process/process-manager.js +28 -417
  95. package/dist/process/quotas.d.ts +14 -0
  96. package/dist/process/quotas.js +29 -0
  97. package/dist/process/run-executor.js +0 -1
  98. package/dist/process/terminal-output-cache.d.ts +20 -34
  99. package/dist/process/terminal-output-cache.js +43 -64
  100. package/dist/profile/index.d.ts +1 -2
  101. package/dist/profile/index.js +1 -2
  102. package/dist/profile/manager.d.ts +2 -4
  103. package/dist/profile/manager.js +10 -40
  104. package/dist/profile/types.d.ts +1 -17
  105. package/dist/project/digest.d.ts +5 -1
  106. package/dist/project/digest.js +81 -219
  107. package/dist/project/index.d.ts +4 -5
  108. package/dist/project/index.js +4 -5
  109. package/dist/project/init.js +2 -2
  110. package/dist/project/loader.d.ts +3 -3
  111. package/dist/project/loader.js +72 -50
  112. package/dist/project/lockfile.js +6 -5
  113. package/dist/project/manifest.js +5 -4
  114. package/dist/project/transactions.d.ts +4 -42
  115. package/dist/project/transactions.js +83 -138
  116. package/dist/project/types-generator.js +2 -1
  117. package/dist/project/types.d.ts +2 -0
  118. package/dist/registry/index.d.ts +0 -1
  119. package/dist/registry/index.js +0 -1
  120. package/dist/registry/lock.d.ts +2 -11
  121. package/dist/registry/lock.js +14 -183
  122. package/dist/registry/registry.d.ts +1 -6
  123. package/dist/registry/registry.js +5 -17
  124. package/dist/runtime/action-registry.d.ts +1 -5
  125. package/dist/runtime/action-registry.js +0 -12
  126. package/dist/runtime/context.js +2 -2
  127. package/dist/runtime/events.d.ts +11 -50
  128. package/dist/runtime/events.js +88 -368
  129. package/dist/runtime/index.d.ts +0 -4
  130. package/dist/runtime/index.js +0 -4
  131. package/dist/runtime/run-persistence.d.ts +2 -0
  132. package/dist/runtime/run-persistence.js +2 -1
  133. package/dist/runtime/standalone-commands.d.ts +18 -0
  134. package/dist/runtime/standalone-commands.js +466 -0
  135. package/dist/runtime/standalone-help.d.ts +20 -0
  136. package/dist/runtime/standalone-help.js +72 -0
  137. package/dist/runtime/standalone.d.ts +1 -44
  138. package/dist/runtime/standalone.js +31 -526
  139. package/dist/schema/validator.d.ts +2 -2
  140. package/dist/schema/validator.js +2 -9
  141. package/dist/server/index.d.ts +0 -2
  142. package/dist/server/index.js +0 -2
  143. package/dist/server/routes/actions.js +1 -1
  144. package/dist/server/routes/info.js +1 -1
  145. package/dist/server/routes/playbooks.js +1 -1
  146. package/dist/server/routes/runs.js +123 -16
  147. package/dist/server/routes/state.js +43 -18
  148. package/dist/server/security.d.ts +1 -1
  149. package/dist/server/security.js +2 -2
  150. package/dist/server/server.js +3 -7
  151. package/dist/service/factory.js +4 -3
  152. package/dist/service/index.d.ts +1 -1
  153. package/dist/service/index.js +1 -1
  154. package/dist/service/remote-errors.d.ts +1 -1
  155. package/dist/service/remote-errors.js +6 -6
  156. package/dist/service/remote-polling.d.ts +3 -0
  157. package/dist/service/remote-polling.js +10 -5
  158. package/dist/service/remote.d.ts +5 -1
  159. package/dist/service/remote.js +108 -17
  160. package/dist/service/sse-stream.js +2 -2
  161. package/dist/service/types.d.ts +22 -19
  162. package/dist/service/types.js +1 -24
  163. package/dist/storage/clock.d.ts +1 -1
  164. package/dist/storage/clock.js +1 -1
  165. package/dist/storage/data-dir-lock.d.ts +10 -22
  166. package/dist/storage/data-dir-lock.js +28 -56
  167. package/dist/storage/file-lock.d.ts +64 -0
  168. package/dist/storage/file-lock.js +447 -0
  169. package/dist/storage/index.d.ts +2 -2
  170. package/dist/storage/index.js +5 -4
  171. package/dist/storage/run-liveness.d.ts +48 -0
  172. package/dist/storage/run-liveness.js +44 -0
  173. package/dist/storage/sqlite-config.d.ts +16 -0
  174. package/dist/storage/sqlite-config.js +59 -0
  175. package/dist/storage/sqlite-driver.d.ts +3 -1
  176. package/dist/storage/sqlite-driver.js +14 -4
  177. package/dist/storage/sqlite-events.d.ts +13 -0
  178. package/dist/storage/sqlite-events.js +48 -0
  179. package/dist/storage/sqlite-runs.d.ts +107 -0
  180. package/dist/storage/sqlite-runs.js +622 -0
  181. package/dist/storage/sqlite-schema.d.ts +5 -0
  182. package/dist/storage/sqlite-schema.js +143 -0
  183. package/dist/storage/sqlite-state.d.ts +33 -0
  184. package/dist/storage/sqlite-state.js +270 -0
  185. package/dist/storage/sqlite.d.ts +30 -57
  186. package/dist/storage/sqlite.js +84 -741
  187. package/dist/storage/types.d.ts +35 -2
  188. package/dist/utils/index.d.ts +18 -14
  189. package/dist/utils/index.js +37 -29
  190. package/dist/utils/semver.d.ts +18 -0
  191. package/dist/utils/semver.js +19 -0
  192. package/dist/utils/warning.d.ts +1 -0
  193. package/dist/utils/warning.js +52 -0
  194. package/dist/{json/value-validator.d.ts → value-validator.d.ts} +9 -0
  195. package/dist/value-validator.js +330 -0
  196. package/dist/version.d.ts +1 -1
  197. package/dist/version.js +1 -1
  198. package/package.json +10 -12
  199. package/dist/execution/index.d.ts +0 -2
  200. package/dist/execution/index.js +0 -2
  201. package/dist/filter/index.d.ts +0 -1
  202. package/dist/filter/index.js +0 -1
  203. package/dist/graph/index.d.ts +0 -4
  204. package/dist/graph/index.js +0 -4
  205. package/dist/input/metadata.d.ts +0 -99
  206. package/dist/input/metadata.js +0 -99
  207. package/dist/invocation/index.d.ts +0 -2
  208. package/dist/invocation/index.js +0 -2
  209. package/dist/ipc/index.d.ts +0 -4
  210. package/dist/ipc/index.js +0 -4
  211. package/dist/json/index.d.ts +0 -1
  212. package/dist/json/index.js +0 -1
  213. package/dist/json/value-validator.js +0 -330
  214. package/dist/node/index.d.ts +0 -1
  215. package/dist/node/index.js +0 -1
  216. package/dist/platform/node-fs.d.ts +0 -37
  217. package/dist/platform/node-fs.js +0 -81
  218. package/dist/process/control-arbiter.d.ts +0 -108
  219. package/dist/process/control-arbiter.js +0 -250
  220. package/dist/process/process-executor.d.ts +0 -47
  221. package/dist/process/process-executor.js +0 -296
  222. package/dist/profile/client-health.d.ts +0 -14
  223. package/dist/profile/client-query.d.ts +0 -30
  224. package/dist/profile/client-query.js +0 -69
  225. package/dist/profile/client.d.ts +0 -26
  226. package/dist/profile/client.js +0 -31
  227. package/dist/project/closure.d.ts +0 -25
  228. package/dist/project/closure.js +0 -74
  229. package/dist/registry/store.d.ts +0 -42
  230. package/dist/registry/store.js +0 -43
  231. package/dist/runtime/clock.d.ts +0 -7
  232. package/dist/runtime/clock.js +0 -7
  233. package/dist/runtime/module-loader.d.ts +0 -2
  234. package/dist/runtime/module-loader.js +0 -1
  235. package/dist/runtime/process.d.ts +0 -8
  236. package/dist/runtime/process.js +0 -1
  237. package/dist/runtime/runner.d.ts +0 -234
  238. package/dist/runtime/runner.js +0 -609
  239. package/dist/schema/index.d.ts +0 -1
  240. package/dist/schema/index.js +0 -1
  241. package/dist/server/dispatcher.d.ts +0 -25
  242. package/dist/server/dispatcher.js +0 -54
  243. package/dist/service/local.d.ts +0 -27
  244. package/dist/service/local.js +0 -141
  245. package/dist/storage/driver.d.ts +0 -10
  246. package/dist/storage/driver.js +0 -10
  247. package/dist/storage/lazy.d.ts +0 -8
  248. package/dist/storage/lazy.js +0 -45
  249. package/dist/storage/lock-core.d.ts +0 -158
  250. package/dist/storage/lock-core.js +0 -872
  251. package/dist/utils/net.d.ts +0 -10
  252. package/dist/utils/net.js +0 -16
  253. package/dist/utils/process.d.ts +0 -10
  254. package/dist/utils/process.js +0 -21
  255. /package/dist/{filter → utils}/intent.d.ts +0 -0
  256. /package/dist/{filter → utils}/intent.js +0 -0
@@ -0,0 +1,59 @@
1
+ import { safeParseStoredJson } from "./utils.js";
2
+ export class SqliteConfigStore {
3
+ statementCache = new Map();
4
+ driver;
5
+ packageId;
6
+ dbPath;
7
+ clock;
8
+ constructor(driver, packageId, dbPath, clock) {
9
+ this.driver = driver;
10
+ this.packageId = packageId;
11
+ this.dbPath = dbPath;
12
+ this.clock = clock;
13
+ }
14
+ getStatement(sql) {
15
+ let stmt = this.statementCache.get(sql);
16
+ if (!stmt) {
17
+ stmt = this.driver.prepare(sql);
18
+ this.statementCache.set(sql, stmt);
19
+ }
20
+ return stmt;
21
+ }
22
+ getConfig(key) {
23
+ const stmt = this.getStatement("SELECT value_json FROM config WHERE package_id = ? AND key = ?");
24
+ const row = stmt.get(this.packageId, key);
25
+ if (!row || row.value_json === undefined || row.value_json === null) {
26
+ return undefined;
27
+ }
28
+ return safeParseStoredJson(row.value_json, `config db=${this.dbPath} package=${this.packageId} key=${key}`);
29
+ }
30
+ listConfig() {
31
+ const stmt = this.getStatement("SELECT key, value_json FROM config WHERE package_id = ?");
32
+ const rows = stmt.all(this.packageId);
33
+ const result = {};
34
+ for (const row of rows) {
35
+ result[row.key] = safeParseStoredJson(row.value_json, `config db=${this.dbPath} package=${this.packageId} key=${row.key}`);
36
+ }
37
+ return result;
38
+ }
39
+ setConfig(key, value) {
40
+ const stmt = this.getStatement(`
41
+ INSERT INTO config (package_id, key, value_json, updated_at)
42
+ VALUES (?, ?, ?, ?)
43
+ ON CONFLICT(package_id, key) DO UPDATE SET
44
+ value_json = excluded.value_json,
45
+ updated_at = excluded.updated_at
46
+ `);
47
+ const valJson = JSON.stringify(value);
48
+ const now = this.clock.now().toISOString();
49
+ stmt.run(this.packageId, key, valJson, now);
50
+ }
51
+ deleteConfig(key) {
52
+ const stmt = this.getStatement("DELETE FROM config WHERE package_id = ? AND key = ?");
53
+ const res = stmt.run(this.packageId, key);
54
+ return res.changes > 0;
55
+ }
56
+ close() {
57
+ this.statementCache.clear();
58
+ }
59
+ }
@@ -1,8 +1,10 @@
1
- import { DatabaseSync } from "node:sqlite";
1
+ import "../utils/warning.js";
2
+ import type { DatabaseSync } from "node:sqlite";
2
3
  import { normalizeSqliteParams } from "./params.js";
3
4
  import type { SqliteDriver, SqliteStatement } from "./types.js";
4
5
  export { normalizeSqliteParams };
5
6
  /**
7
+
6
8
  * 基于 Node.js 内置 node:sqlite 实现的 SQLite 驱动适配器。
7
9
  */
8
10
  export declare class NodeSqliteDriver implements SqliteDriver {
@@ -1,7 +1,11 @@
1
- import { DatabaseSync } from "node:sqlite";
1
+ import "../utils/warning.js";
2
2
  import { normalizeSqliteParams } from "./params.js";
3
+ import { ActionDockError, ASYNC_TRANSACTION_UNSUPPORTED, STORAGE_CLOSED } from "../errors.js";
4
+ // 基于原生 ESM Top-Level Await 在模块评估期动态加载,确保警告静默拦截器优先就绪且保持纯正 ESM 架构
5
+ const { DatabaseSync: DatabaseSyncConstructor } = (await import("node:sqlite"));
3
6
  export { normalizeSqliteParams };
4
7
  /**
8
+
5
9
  * 基于 Node.js 内置 node:sqlite 实现的 SQLite 驱动适配器。
6
10
  */
7
11
  export class NodeSqliteDriver {
@@ -9,11 +13,17 @@ export class NodeSqliteDriver {
9
13
  closed = false;
10
14
  constructor(dbPath = ":memory:", options) {
11
15
  if (typeof dbPath === "string") {
12
- this.db = options !== undefined ? new DatabaseSync(dbPath, options) : new DatabaseSync(dbPath);
16
+ this.db = options !== undefined ? new DatabaseSyncConstructor(dbPath, options) : new DatabaseSyncConstructor(dbPath);
13
17
  }
14
18
  else {
15
19
  this.db = dbPath;
16
20
  }
21
+ try {
22
+ this.db.exec("PRAGMA busy_timeout = 5000;");
23
+ }
24
+ catch {
25
+ // 忽略已关闭或不支持的只读连接异常
26
+ }
17
27
  }
18
28
  /**
19
29
  * 检查底层连接是否处于开启状态。
@@ -91,7 +101,7 @@ export class NodeSqliteDriver {
91
101
  catch {
92
102
  // 忽略回滚阶段发生的级联异常
93
103
  }
94
- throw new Error("Async transactions are not allowed in SQLite");
104
+ throw new ActionDockError(ASYNC_TRANSACTION_UNSUPPORTED, "Async transactions are not allowed in SQLite");
95
105
  }
96
106
  this.db.exec("COMMIT");
97
107
  return result;
@@ -110,7 +120,7 @@ export class NodeSqliteDriver {
110
120
  */
111
121
  assertOpen() {
112
122
  if (this.closed) {
113
- throw new Error("Database connection is closed");
123
+ throw new ActionDockError(STORAGE_CLOSED, "Database connection is closed");
114
124
  }
115
125
  }
116
126
  }
@@ -0,0 +1,13 @@
1
+ import type { SqliteDriver } from "./types.js";
2
+ import type { Clock } from "./clock.js";
3
+ export declare class SqliteEventsStore {
4
+ private statementCache;
5
+ private driver;
6
+ private packageId;
7
+ private clock;
8
+ constructor(driver: SqliteDriver, packageId: string, clock: Clock);
9
+ private getStatement;
10
+ appendEvent(eventType: string, payload: unknown): void;
11
+ queryEvents(eventType?: string): any[];
12
+ close(): void;
13
+ }
@@ -0,0 +1,48 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { safeParseStoredJson } from "./utils.js";
3
+ export class SqliteEventsStore {
4
+ statementCache = new Map();
5
+ driver;
6
+ packageId;
7
+ clock;
8
+ constructor(driver, packageId, clock) {
9
+ this.driver = driver;
10
+ this.packageId = packageId;
11
+ this.clock = clock;
12
+ }
13
+ getStatement(sql) {
14
+ let stmt = this.statementCache.get(sql);
15
+ if (!stmt) {
16
+ stmt = this.driver.prepare(sql);
17
+ this.statementCache.set(sql, stmt);
18
+ }
19
+ return stmt;
20
+ }
21
+ appendEvent(eventType, payload) {
22
+ const stmt = this.getStatement(`
23
+ INSERT INTO events (id, package_id, event_type, payload_json, created_at)
24
+ VALUES (?, ?, ?, ?, ?)
25
+ `);
26
+ const id = randomUUID();
27
+ const payloadJson = payload !== undefined ? JSON.stringify(payload) : null;
28
+ stmt.run(id, this.packageId, eventType, payloadJson, this.clock.now().toISOString());
29
+ }
30
+ queryEvents(eventType) {
31
+ const sql = eventType
32
+ ? "SELECT * FROM events WHERE package_id = ? AND event_type = ? ORDER BY created_at ASC"
33
+ : "SELECT * FROM events WHERE package_id = ? ORDER BY created_at ASC";
34
+ const params = eventType ? [this.packageId, eventType] : [this.packageId];
35
+ const stmt = this.getStatement(sql);
36
+ const rows = stmt.all(...params);
37
+ return rows.map((r) => ({
38
+ id: r.id,
39
+ packageId: r.package_id,
40
+ eventType: r.event_type,
41
+ payload: safeParseStoredJson(r.payload_json, `events.payload id=${r.id}`),
42
+ createdAt: r.created_at,
43
+ }));
44
+ }
45
+ close() {
46
+ this.statementCache.clear();
47
+ }
48
+ }
@@ -0,0 +1,107 @@
1
+ import type { Logger, RuntimeError, RunRecord } from "@actiondock/sdk";
2
+ import type { SqliteDriver, TerminalRunStatus, RunsRetentionPolicy, IdempotencyRecord, IdempotencyCheckResult } from "./types.js";
3
+ import type { Clock } from "./clock.js";
4
+ import { type ProcessLivenessProbe } from "./run-liveness.js";
5
+ export declare class SqliteRunsStore {
6
+ private statementCache;
7
+ private runInsertCount;
8
+ private lastRunsCleanupAt;
9
+ private static readonly RUNS_CLEANUP_INTERVAL_MS;
10
+ private static readonly RUNS_CLEANUP_BATCH_THRESHOLD;
11
+ private driver;
12
+ private packageId;
13
+ private dbPath;
14
+ private clock;
15
+ private retentionPolicy?;
16
+ private getConfigFn?;
17
+ private logger?;
18
+ private logWarnFn?;
19
+ constructor(driver: SqliteDriver, packageId: string, dbPath: string, clock: Clock, retentionPolicy?: RunsRetentionPolicy, getConfigFn?: <T>(key: string) => T | undefined, logger?: Logger, logWarnFn?: (msg: string) => void);
20
+ private logWarn;
21
+ private getStatement;
22
+ /**
23
+ * 收敛死亡宿主遗留的非终态运行记录(保守收割)。
24
+ *
25
+ * 判定依据是宿主存活而不是会话归属:会话归属只区分「不是当前会话」,
26
+ * 无法区分「持有进程已死」与「另一活跃进程仍在执行」。
27
+ * 先选取非当前会话的非终态候选,再逐条做存活校验,仅收割确认死亡的记录:
28
+ * - 携带宿主进程标识的记录:进程探测失败(明确不存在)才收割;
29
+ * - 遗留记录(无进程标识):心跳(缺省回退开始时间)超过宽限期才收割。
30
+ *
31
+ * 无法确认死亡时一律保留,宁司不动也不误杀活跃任务。
32
+ */
33
+ recoverDeadSessionRuns(isClosed: boolean, currentHostSessionId?: string, options?: {
34
+ probe?: ProcessLivenessProbe;
35
+ }): number;
36
+ /** 选取非当前会话的非终态候选记录(仅判定所需列) */
37
+ private selectOrphanCandidates;
38
+ /** 将确认死亡的记录收敛为 interrupted(单条 SQL 批量执行,不误伤其他在途记录) */
39
+ private interruptRunsByIds;
40
+ /**
41
+ * 刷新在途运行记录的心跳时间戳。
42
+ *
43
+ * 执行宿主周期性调用,使无进程标识判定路径(遗留记录兜底)以及其他
44
+ * 协作方能够区分「在途执行中」与「宿主崩溃后的遗留」。
45
+ * 仅更新非终态记录,终态记录心跳无意义不更新。
46
+ */
47
+ touchRunHeartbeat(isClosed: boolean, runIds: string[]): number;
48
+ createRun(record: RunRecord | any): void;
49
+ updateRun(id: string, status: TerminalRunStatus, isClosed: boolean, output?: unknown, error?: RuntimeError, finishedAt?: string): void;
50
+ getRun(id: string): RunRecord | null;
51
+ /**
52
+ * 查询单条运行记录并补齐幂等请求标识关联(详情路径专用)。
53
+ */
54
+ getRunWithRequestId(id: string, isClosed: boolean): RunRecord | null;
55
+ listRuns(options?: {
56
+ actionId?: string;
57
+ status?: string;
58
+ limit?: number;
59
+ offset?: number;
60
+ }): RunRecord[];
61
+ /**
62
+ * 统计符合过滤条件的真实运行记录总数。
63
+ * 支持按 actionId、status 以及包含 requestIds 的反查场景统计总数。
64
+ */
65
+ countRuns(options?: {
66
+ actionId?: string;
67
+ status?: string;
68
+ requestIds?: string[];
69
+ }, isClosed?: boolean): number;
70
+ /**
71
+ * 按客户端幂等请求标识反查关联运行记录总数。
72
+ */
73
+ countRunsByRequestIds(isClosed: boolean, requestIds: string[], options?: {
74
+ actionId?: string;
75
+ status?: string;
76
+ }): number;
77
+ /**
78
+ * 构造 IN (…) 占位符列表。
79
+ */
80
+ private static placeholders;
81
+ /**
82
+ * 批量反查当前包范围内、由指定幂等请求标识登记的运行记录。
83
+ *
84
+ * 关联链为 idempotency_keys.run_id -> runs.id,且强制 runs.package_id 等于
85
+ * 当前包,保证多包共库(全局库)时不越界读取其他包的运行记录。
86
+ * 不按 owner_id 过滤:写入方与查询方分属不同宿主进程,ownerId 必然不同。
87
+ */
88
+ listRunsByRequestIds(isClosed: boolean, requestIds: string[]): RunRecord[];
89
+ /**
90
+ * 反查当前包范围内运行记录关联的幂等请求标识。
91
+ *
92
+ * 仅返回存在关联的键值对;未登记幂等键的运行记录不产生对应键。
93
+ */
94
+ getRunRequestIds(isClosed: boolean, runIds: string[]): Record<string, string>;
95
+ clearRuns(options?: {
96
+ actionId?: string;
97
+ status?: string;
98
+ olderThanMs?: number;
99
+ keep?: number;
100
+ }): number;
101
+ cleanExpiredRuns(isClosed: boolean, policy?: RunsRetentionPolicy): number;
102
+ private resolveRetentionPolicy;
103
+ checkAndRecordIdempotency(isClosed: boolean, record: IdempotencyRecord): IdempotencyCheckResult;
104
+ getIdempotencyRecord(isClosed: boolean, ownerId: string, actionRef: string, requestId: string): IdempotencyRecord | undefined;
105
+ private mapRunRecord;
106
+ close(): void;
107
+ }