@actiondock/core 2.5.0 → 2.6.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 (134) hide show
  1. package/dist/app/app.d.ts +14 -1
  2. package/dist/app/app.js +88 -215
  3. package/dist/app/static-index.d.ts +39 -0
  4. package/dist/app/static-index.js +164 -0
  5. package/dist/app/types.d.ts +5 -0
  6. package/dist/catalog/action-index.js +6 -4
  7. package/dist/catalog/package-catalog.js +2 -1
  8. package/dist/doctor/checks/index.d.ts +5 -0
  9. package/dist/doctor/checks/index.js +5 -0
  10. package/dist/doctor/checks/project-locate.d.ts +6 -0
  11. package/dist/doctor/checks/project-locate.js +36 -0
  12. package/dist/doctor/checks/project.d.ts +6 -0
  13. package/dist/doctor/checks/project.js +383 -0
  14. package/dist/doctor/checks/registry.d.ts +13 -0
  15. package/dist/doctor/checks/registry.js +207 -0
  16. package/dist/doctor/checks/runtime.d.ts +13 -0
  17. package/dist/doctor/checks/runtime.js +90 -0
  18. package/dist/doctor/checks/storage.d.ts +5 -0
  19. package/dist/doctor/checks/storage.js +34 -0
  20. package/dist/doctor/context.d.ts +35 -0
  21. package/dist/doctor/context.js +11 -0
  22. package/dist/doctor/doctor.d.ts +5 -0
  23. package/dist/doctor/doctor.js +33 -602
  24. package/dist/errors.d.ts +2 -0
  25. package/dist/errors.js +2 -0
  26. package/dist/execution/service.js +14 -9
  27. package/dist/host/host.d.ts +33 -0
  28. package/dist/host/host.js +222 -362
  29. package/dist/host/routing.d.ts +92 -0
  30. package/dist/host/routing.js +238 -0
  31. package/dist/host/types.d.ts +8 -0
  32. package/dist/ipc/host.js +38 -0
  33. package/dist/platform/types.d.ts +7 -0
  34. package/dist/process/control-arbiter.d.ts +107 -0
  35. package/dist/process/control-arbiter.js +251 -0
  36. package/dist/process/diagnostics-sink.d.ts +26 -0
  37. package/dist/process/diagnostics-sink.js +35 -0
  38. package/dist/process/index.d.ts +7 -0
  39. package/dist/process/index.js +7 -0
  40. package/dist/process/input-dispatcher.d.ts +88 -0
  41. package/dist/process/input-dispatcher.js +240 -0
  42. package/dist/process/managed-record.d.ts +78 -0
  43. package/dist/process/managed-record.js +1 -0
  44. package/dist/process/process-manager.d.ts +15 -56
  45. package/dist/process/process-manager.js +119 -707
  46. package/dist/process/reservation-table.d.ts +39 -0
  47. package/dist/process/reservation-table.js +80 -0
  48. package/dist/process/run-executor.d.ts +16 -0
  49. package/dist/process/run-executor.js +155 -0
  50. package/dist/process/terminal-output-cache.d.ts +66 -0
  51. package/dist/process/terminal-output-cache.js +132 -0
  52. package/dist/profile/client-actions.d.ts +56 -0
  53. package/dist/profile/client-actions.js +215 -0
  54. package/dist/profile/client-config.d.ts +20 -0
  55. package/dist/profile/client-config.js +51 -0
  56. package/dist/profile/client-health.d.ts +14 -0
  57. package/dist/profile/client-health.js +68 -0
  58. package/dist/profile/client-playbooks.d.ts +19 -0
  59. package/dist/profile/client-playbooks.js +36 -0
  60. package/dist/profile/client-query.d.ts +30 -0
  61. package/dist/profile/client-query.js +70 -0
  62. package/dist/profile/client-runs.d.ts +42 -0
  63. package/dist/profile/client-runs.js +58 -0
  64. package/dist/profile/client-state.d.ts +56 -0
  65. package/dist/profile/client-state.js +83 -0
  66. package/dist/profile/client-transport.d.ts +61 -0
  67. package/dist/profile/client-transport.js +155 -0
  68. package/dist/profile/client.d.ts +23 -142
  69. package/dist/profile/client.js +28 -588
  70. package/dist/profile/manager.js +1 -1
  71. package/dist/project/closure.d.ts +4 -4
  72. package/dist/project/closure.js +11 -5
  73. package/dist/project/init.js +2 -2
  74. package/dist/project/loader.d.ts +0 -25
  75. package/dist/project/loader.js +1 -154
  76. package/dist/project/transactions.d.ts +12 -14
  77. package/dist/project/transactions.js +60 -836
  78. package/dist/registry/registry.js +6 -4
  79. package/dist/registry/resolve.js +1 -1
  80. package/dist/runtime/action-registry.d.ts +45 -0
  81. package/dist/runtime/action-registry.js +108 -0
  82. package/dist/runtime/clock.d.ts +5 -17
  83. package/dist/runtime/clock.js +5 -15
  84. package/dist/runtime/context.d.ts +3 -0
  85. package/dist/runtime/context.js +17 -56
  86. package/dist/runtime/index.d.ts +3 -0
  87. package/dist/runtime/index.js +3 -0
  88. package/dist/runtime/package-runner-factory.d.ts +82 -0
  89. package/dist/runtime/package-runner-factory.js +186 -0
  90. package/dist/runtime/run-persistence.d.ts +85 -0
  91. package/dist/runtime/run-persistence.js +111 -0
  92. package/dist/runtime/runner.d.ts +23 -33
  93. package/dist/runtime/runner.js +92 -286
  94. package/dist/runtime/standalone.d.ts +11 -1
  95. package/dist/runtime/standalone.js +137 -25
  96. package/dist/server/dispatcher.d.ts +8 -3
  97. package/dist/server/dispatcher.js +16 -40
  98. package/dist/server/routes/runs.js +6 -4
  99. package/dist/server/security.d.ts +1 -7
  100. package/dist/server/security.js +2 -13
  101. package/dist/storage/clock.d.ts +25 -0
  102. package/dist/storage/clock.js +23 -0
  103. package/dist/storage/data-dir-lock.d.ts +3 -36
  104. package/dist/storage/data-dir-lock.js +48 -881
  105. package/dist/storage/index.d.ts +8 -1
  106. package/dist/storage/index.js +8 -2
  107. package/dist/storage/lazy.js +1 -0
  108. package/dist/storage/lock-core.d.ts +162 -0
  109. package/dist/storage/lock-core.js +885 -0
  110. package/dist/storage/sqlite.d.ts +19 -6
  111. package/dist/storage/sqlite.js +81 -89
  112. package/dist/storage/types.d.ts +27 -5
  113. package/dist/storage/types.js +21 -0
  114. package/dist/storage/utils.d.ts +22 -0
  115. package/dist/storage/utils.js +34 -0
  116. package/dist/target/local.d.ts +1 -0
  117. package/dist/target/local.js +23 -17
  118. package/dist/target/remote-errors.d.ts +21 -0
  119. package/dist/target/remote-errors.js +51 -0
  120. package/dist/target/remote-polling.d.ts +35 -0
  121. package/dist/target/remote-polling.js +104 -0
  122. package/dist/target/remote.d.ts +4 -0
  123. package/dist/target/remote.js +108 -301
  124. package/dist/target/sse-parser.d.ts +35 -0
  125. package/dist/target/sse-parser.js +163 -0
  126. package/dist/target/target.js +2 -0
  127. package/dist/target/types.d.ts +6 -0
  128. package/dist/utils/index.d.ts +1 -0
  129. package/dist/utils/index.js +1 -0
  130. package/dist/utils/net.d.ts +10 -0
  131. package/dist/utils/net.js +16 -0
  132. package/dist/version.d.ts +1 -1
  133. package/dist/version.js +1 -1
  134. package/package.json +2 -2
@@ -3,7 +3,8 @@ import { ActionResolver } from "../catalog/action-resolver.js";
3
3
  import { computeDigest } from "../project/digest.js";
4
4
  import { InMemoryEventSink } from "../runtime/events.js";
5
5
  import { ActionRunner } from "../runtime/runner.js";
6
- import { ACTION_CANCELLED, ACTION_NOT_FOUND, ACTION_TIMEOUT, EXECUTION_FAILED, IDEMPOTENCY_CONFLICT, RUN_REPOSITORY_UNAVAILABLE, UNHANDLED_EXECUTION_ERROR, describeActionLoadFailure, } from "../errors.js";
6
+ import { ACTION_NOT_FOUND, EXECUTION_FAILED, IDEMPOTENCY_CONFLICT, RUN_REPOSITORY_UNAVAILABLE, UNHANDLED_EXECUTION_ERROR, describeActionLoadFailure, } from "../errors.js";
7
+ import { resultStatusToRunStatus } from "../storage/types.js";
7
8
  /**
8
9
  * 统一执行协调服务实现。
9
10
  */
@@ -49,6 +50,8 @@ export class DefaultExecutionService {
49
50
  options.platform.storage.createStorage(this.packageId, {
50
51
  projectRoot: options.projectRoot,
51
52
  customHome: options.customHome,
53
+ // 执行服务属于数据目录持有者主路径,打开时收割遗留孤儿运行
54
+ recoverOrphans: true,
52
55
  });
53
56
  }
54
57
  else {
@@ -60,7 +63,8 @@ export class DefaultExecutionService {
60
63
  this.storage = options.storage;
61
64
  }
62
65
  const globalStorage = options.platform
63
- ? (options.globalStorage ?? options.platform.storage.createGlobalStorage({ customHome: options.customHome }))
66
+ ? (options.globalStorage ??
67
+ options.platform.storage.createGlobalStorage({ customHome: options.customHome, recoverOrphans: true }))
64
68
  : options.globalStorage;
65
69
  this.ownsStorage = !options.storage;
66
70
  this.ownsGlobalStorage = !options.globalStorage && !!options.platform;
@@ -533,13 +537,7 @@ export class DefaultExecutionService {
533
537
  watchHandleCompletion(handle, activeItem, bridge) {
534
538
  handle.result
535
539
  .then((result) => {
536
- const finalStatus = result.ok
537
- ? "success"
538
- : result.error?.code === ACTION_TIMEOUT
539
- ? "timed_out"
540
- : result.error?.code === ACTION_CANCELLED
541
- ? "cancelled"
542
- : "failed";
540
+ const finalStatus = resultStatusToRunStatus(result.ok, result.ok ? undefined : result.error?.code);
543
541
  activeItem.status = finalStatus;
544
542
  bridge.emitEvent({ type: "status", status: finalStatus });
545
543
  bridge.emitEvent({ type: "finish", result });
@@ -633,6 +631,13 @@ export class DefaultExecutionService {
633
631
  }
634
632
  }
635
633
  this.activeRuns.clear();
634
+ // 级联释放跨包子包 Runner 及其独立创建的存储连接(幂等,异常不阻断后续释放)
635
+ try {
636
+ await this._runner.dispose();
637
+ }
638
+ catch {
639
+ // 子包释放异常已在 dispose 内部隔离,此处仅需保障主流程继续
640
+ }
636
641
  if (this.ownsStorage && this.storage && typeof this.storage.close === "function") {
637
642
  await this.storage.close();
638
643
  }
@@ -8,6 +8,7 @@ import type { ActionDockHost, ActionDockHostOptions } from "./types.js";
8
8
  */
9
9
  export declare class DefaultActionDockHost implements ActionDockHost {
10
10
  readonly hostSessionId: string;
11
+ readonly options: ActionDockHostOptions;
11
12
  private apps;
12
13
  private readonly internallyCreatedApps;
13
14
  private activeSubRunsPerRoot;
@@ -19,11 +20,43 @@ export declare class DefaultActionDockHost implements ActionDockHost {
19
20
  private isClosed;
20
21
  private dataDirLock?;
21
22
  private failedLinkedPackages;
23
+ private failedAutoLoad?;
24
+ /** 透传给内部创建 App 的存储收割开关(Host 默认持有者身份,显式可关) */
25
+ private recoverOrphans;
22
26
  constructor(options?: ActionDockHostOptions);
27
+ /**
28
+ * 阶段函数:注册显式传入的 packages 列表(现成 App 实例或 AppOptions 配置)。
29
+ */
30
+ private registerExplicitPackages;
31
+ /**
32
+ * 阶段函数:自动加载当前工程并注册依赖闭包内的全部包。
33
+ *
34
+ * 失败语义区分场景:
35
+ * - 显式传入 projectRoot 时,任何解析失败(损坏 actiondock.json、文件系统错误等)
36
+ * 必须向上抛出,由调用方感知,严禁吞没;
37
+ * - 自动探测场景(未传 projectRoot,由 findProjectRoot 发现)失败时记录实例诊断
38
+ * failedAutoLoad 并在创建时输出单行告警,保持宿主其余能力可用但绝不无声。
39
+ */
40
+ private loadCurrentProject;
41
+ /**
42
+ * 阶段函数:扫描全局注册表中已软链接的外部包并注册至 Host。
43
+ * 加载失败的链接包记录至 failedLinkedPackages 诊断并在调阅时透传精准失败原因。
44
+ */
45
+ private registerLinkedPackages;
23
46
  private resolvePackageContext;
24
47
  private bindApp;
48
+ /** 路由可见性上下文(公开包集合与依赖解析器) */
49
+ private visibility;
25
50
  getApp(packageId: string): ActionDockApp | undefined;
26
51
  listApps(): ActionDockApp[];
52
+ /**
53
+ * 获取自动加载工程的失败诊断信息。
54
+ * 仅自动探测场景会记录此诊断;显式传入 projectRoot 的加载失败会直接抛出,不产生此诊断。
55
+ */
56
+ getAutoLoadFailure(): {
57
+ projectRoot: string;
58
+ error: string;
59
+ } | undefined;
27
60
  private registerAppInternal;
28
61
  registerApp(app: ActionDockApp): void;
29
62
  info(): Promise<PackageInfo[]>;