@actiondock/core 2.10.0 → 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 (252) 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 +8 -14
  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 +20 -88
  28. package/dist/doctor/checks/runtime.d.ts +0 -4
  29. package/dist/doctor/checks/runtime.js +0 -28
  30. package/dist/doctor/doctor.js +1 -2
  31. package/dist/errors.d.ts +53 -3
  32. package/dist/errors.js +53 -3
  33. package/dist/execution/service.d.ts +55 -37
  34. package/dist/execution/service.js +601 -212
  35. package/dist/execution/types.d.ts +24 -5
  36. package/dist/host/host.d.ts +42 -22
  37. package/dist/host/host.js +562 -149
  38. package/dist/host/routing.js +6 -6
  39. package/dist/host/types.d.ts +25 -13
  40. package/dist/index.d.ts +9 -4
  41. package/dist/index.js +5 -2
  42. package/dist/input/advice.d.ts +0 -44
  43. package/dist/input/advice.js +7 -141
  44. package/dist/input/flat-materializer.js +1 -1
  45. package/dist/input/flat-parser.js +1 -1
  46. package/dist/input/index.d.ts +0 -1
  47. package/dist/input/index.js +0 -1
  48. package/dist/input/input-resolver.js +1 -1
  49. package/dist/input/validation-mapper.d.ts +1 -1
  50. package/dist/ipc/diagnostic.d.ts +8 -21
  51. package/dist/ipc/diagnostic.js +24 -57
  52. package/dist/ipc/host.js +21 -7
  53. package/dist/ipc/service.d.ts +14 -0
  54. package/dist/ipc/service.js +132 -26
  55. package/dist/ipc/types.d.ts +0 -4
  56. package/dist/package/index.d.ts +4 -5
  57. package/dist/package/index.js +1 -2
  58. package/dist/package/runtime.d.ts +94 -23
  59. package/dist/package/runtime.js +628 -274
  60. package/dist/package/static-index.d.ts +3 -6
  61. package/dist/package/static-index.js +11 -40
  62. package/dist/package/types.d.ts +19 -4
  63. package/dist/platform/index.d.ts +2 -1
  64. package/dist/platform/index.js +2 -1
  65. package/dist/platform/loader-hook.d.ts +32 -0
  66. package/dist/platform/loader-hook.js +90 -0
  67. package/dist/{node → platform}/module-loader.d.ts +13 -0
  68. package/dist/{node → platform}/module-loader.js +51 -4
  69. package/dist/platform/node.d.ts +19 -8
  70. package/dist/platform/node.js +50 -20
  71. package/dist/platform/types.d.ts +7 -47
  72. package/dist/process/context-process.d.ts +3 -18
  73. package/dist/process/context-process.js +3 -44
  74. package/dist/process/control.d.ts +21 -0
  75. package/dist/process/control.js +34 -0
  76. package/dist/process/converters.d.ts +23 -0
  77. package/dist/process/converters.js +92 -0
  78. package/dist/process/cursor.js +2 -22
  79. package/dist/process/{diagnostics-sink.d.ts → diagnostics.d.ts} +0 -7
  80. package/dist/process/{diagnostics-sink.js → diagnostics.js} +6 -8
  81. package/dist/process/index.d.ts +1 -3
  82. package/dist/process/index.js +1 -3
  83. package/dist/process/input-dispatcher.d.ts +4 -13
  84. package/dist/process/input-dispatcher.js +48 -69
  85. package/dist/process/managed-record.d.ts +3 -31
  86. package/dist/process/metadata-store.d.ts +0 -41
  87. package/dist/process/metadata-store.js +2 -341
  88. package/dist/process/process-driver.js +2 -2
  89. package/dist/process/process-manager.d.ts +8 -50
  90. package/dist/process/process-manager.js +28 -417
  91. package/dist/process/quotas.d.ts +14 -0
  92. package/dist/process/quotas.js +29 -0
  93. package/dist/process/run-executor.js +0 -1
  94. package/dist/process/terminal-output-cache.d.ts +20 -34
  95. package/dist/process/terminal-output-cache.js +43 -64
  96. package/dist/profile/index.d.ts +1 -2
  97. package/dist/profile/index.js +1 -2
  98. package/dist/profile/manager.d.ts +2 -4
  99. package/dist/profile/manager.js +10 -40
  100. package/dist/profile/types.d.ts +1 -17
  101. package/dist/project/digest.d.ts +5 -1
  102. package/dist/project/digest.js +81 -219
  103. package/dist/project/index.d.ts +4 -5
  104. package/dist/project/index.js +4 -5
  105. package/dist/project/init.js +2 -2
  106. package/dist/project/loader.d.ts +3 -3
  107. package/dist/project/loader.js +72 -50
  108. package/dist/project/lockfile.js +6 -5
  109. package/dist/project/manifest.js +5 -4
  110. package/dist/project/transactions.d.ts +4 -42
  111. package/dist/project/transactions.js +83 -138
  112. package/dist/project/types-generator.js +2 -1
  113. package/dist/project/types.d.ts +2 -0
  114. package/dist/registry/index.d.ts +0 -1
  115. package/dist/registry/index.js +0 -1
  116. package/dist/registry/lock.d.ts +2 -11
  117. package/dist/registry/lock.js +14 -183
  118. package/dist/registry/registry.d.ts +1 -6
  119. package/dist/registry/registry.js +5 -17
  120. package/dist/runtime/action-registry.d.ts +1 -5
  121. package/dist/runtime/action-registry.js +0 -12
  122. package/dist/runtime/context.js +2 -2
  123. package/dist/runtime/events.d.ts +11 -50
  124. package/dist/runtime/events.js +88 -368
  125. package/dist/runtime/index.d.ts +0 -4
  126. package/dist/runtime/index.js +0 -4
  127. package/dist/runtime/run-persistence.d.ts +2 -0
  128. package/dist/runtime/run-persistence.js +2 -1
  129. package/dist/runtime/standalone-commands.d.ts +18 -0
  130. package/dist/runtime/standalone-commands.js +466 -0
  131. package/dist/runtime/standalone-help.d.ts +20 -0
  132. package/dist/runtime/standalone-help.js +72 -0
  133. package/dist/runtime/standalone.d.ts +1 -44
  134. package/dist/runtime/standalone.js +32 -573
  135. package/dist/schema/validator.d.ts +2 -2
  136. package/dist/schema/validator.js +2 -9
  137. package/dist/server/index.d.ts +0 -2
  138. package/dist/server/index.js +0 -2
  139. package/dist/server/routes/actions.js +1 -1
  140. package/dist/server/routes/info.js +1 -1
  141. package/dist/server/routes/playbooks.js +1 -1
  142. package/dist/server/routes/runs.js +123 -16
  143. package/dist/server/routes/state.js +43 -18
  144. package/dist/server/security.d.ts +1 -1
  145. package/dist/server/security.js +2 -2
  146. package/dist/server/server.js +3 -7
  147. package/dist/service/factory.js +4 -3
  148. package/dist/service/index.d.ts +1 -1
  149. package/dist/service/index.js +1 -1
  150. package/dist/service/remote-errors.d.ts +1 -1
  151. package/dist/service/remote-errors.js +6 -6
  152. package/dist/service/remote-polling.d.ts +3 -0
  153. package/dist/service/remote-polling.js +10 -5
  154. package/dist/service/remote.d.ts +5 -1
  155. package/dist/service/remote.js +108 -17
  156. package/dist/service/sse-stream.js +2 -2
  157. package/dist/service/types.d.ts +22 -19
  158. package/dist/service/types.js +1 -24
  159. package/dist/storage/clock.d.ts +1 -1
  160. package/dist/storage/clock.js +1 -1
  161. package/dist/storage/data-dir-lock.d.ts +10 -22
  162. package/dist/storage/data-dir-lock.js +28 -56
  163. package/dist/storage/file-lock.d.ts +64 -0
  164. package/dist/storage/file-lock.js +447 -0
  165. package/dist/storage/index.d.ts +2 -2
  166. package/dist/storage/index.js +5 -4
  167. package/dist/storage/run-liveness.d.ts +48 -0
  168. package/dist/storage/run-liveness.js +44 -0
  169. package/dist/storage/sqlite-config.d.ts +16 -0
  170. package/dist/storage/sqlite-config.js +59 -0
  171. package/dist/storage/sqlite-driver.d.ts +3 -1
  172. package/dist/storage/sqlite-driver.js +14 -4
  173. package/dist/storage/sqlite-events.d.ts +13 -0
  174. package/dist/storage/sqlite-events.js +48 -0
  175. package/dist/storage/sqlite-runs.d.ts +107 -0
  176. package/dist/storage/sqlite-runs.js +622 -0
  177. package/dist/storage/sqlite-schema.d.ts +5 -0
  178. package/dist/storage/sqlite-schema.js +143 -0
  179. package/dist/storage/sqlite-state.d.ts +33 -0
  180. package/dist/storage/sqlite-state.js +270 -0
  181. package/dist/storage/sqlite.d.ts +30 -57
  182. package/dist/storage/sqlite.js +84 -741
  183. package/dist/storage/types.d.ts +35 -2
  184. package/dist/utils/index.d.ts +18 -14
  185. package/dist/utils/index.js +37 -29
  186. package/dist/utils/semver.d.ts +18 -0
  187. package/dist/utils/semver.js +19 -0
  188. package/dist/utils/warning.d.ts +1 -0
  189. package/dist/utils/warning.js +52 -0
  190. package/dist/{json/value-validator.d.ts → value-validator.d.ts} +9 -0
  191. package/dist/value-validator.js +330 -0
  192. package/dist/version.d.ts +1 -1
  193. package/dist/version.js +1 -1
  194. package/package.json +10 -12
  195. package/dist/execution/index.d.ts +0 -2
  196. package/dist/execution/index.js +0 -2
  197. package/dist/filter/index.d.ts +0 -1
  198. package/dist/filter/index.js +0 -1
  199. package/dist/graph/index.d.ts +0 -4
  200. package/dist/graph/index.js +0 -4
  201. package/dist/input/metadata.d.ts +0 -99
  202. package/dist/input/metadata.js +0 -99
  203. package/dist/invocation/index.d.ts +0 -2
  204. package/dist/invocation/index.js +0 -2
  205. package/dist/ipc/index.d.ts +0 -4
  206. package/dist/ipc/index.js +0 -4
  207. package/dist/json/index.d.ts +0 -1
  208. package/dist/json/index.js +0 -1
  209. package/dist/json/value-validator.js +0 -330
  210. package/dist/node/index.d.ts +0 -1
  211. package/dist/node/index.js +0 -1
  212. package/dist/platform/node-fs.d.ts +0 -37
  213. package/dist/platform/node-fs.js +0 -81
  214. package/dist/process/control-arbiter.d.ts +0 -108
  215. package/dist/process/control-arbiter.js +0 -250
  216. package/dist/process/process-executor.d.ts +0 -47
  217. package/dist/process/process-executor.js +0 -296
  218. package/dist/profile/client-health.d.ts +0 -14
  219. package/dist/profile/client-query.d.ts +0 -30
  220. package/dist/profile/client-query.js +0 -69
  221. package/dist/profile/client.d.ts +0 -26
  222. package/dist/profile/client.js +0 -31
  223. package/dist/project/closure.d.ts +0 -25
  224. package/dist/project/closure.js +0 -74
  225. package/dist/registry/store.d.ts +0 -42
  226. package/dist/registry/store.js +0 -43
  227. package/dist/runtime/clock.d.ts +0 -7
  228. package/dist/runtime/clock.js +0 -7
  229. package/dist/runtime/module-loader.d.ts +0 -2
  230. package/dist/runtime/module-loader.js +0 -1
  231. package/dist/runtime/process.d.ts +0 -8
  232. package/dist/runtime/process.js +0 -1
  233. package/dist/runtime/runner.d.ts +0 -234
  234. package/dist/runtime/runner.js +0 -609
  235. package/dist/schema/index.d.ts +0 -1
  236. package/dist/schema/index.js +0 -1
  237. package/dist/server/dispatcher.d.ts +0 -25
  238. package/dist/server/dispatcher.js +0 -54
  239. package/dist/service/local.d.ts +0 -27
  240. package/dist/service/local.js +0 -141
  241. package/dist/storage/driver.d.ts +0 -10
  242. package/dist/storage/driver.js +0 -10
  243. package/dist/storage/lazy.d.ts +0 -8
  244. package/dist/storage/lazy.js +0 -45
  245. package/dist/storage/lock-core.d.ts +0 -158
  246. package/dist/storage/lock-core.js +0 -872
  247. package/dist/utils/net.d.ts +0 -10
  248. package/dist/utils/net.js +0 -16
  249. package/dist/utils/process.d.ts +0 -10
  250. package/dist/utils/process.js +0 -21
  251. /package/dist/{filter → utils}/intent.d.ts +0 -0
  252. /package/dist/{filter → utils}/intent.js +0 -0
@@ -1,296 +0,0 @@
1
- import { PROCESS_CANCELLED, PROCESS_OUTPUT_LIMIT, PROCESS_SPAWN_ERROR, PROCESS_TIMEOUT, UNSUPPORTED_CAPABILITY, ProcessError, } from "../errors.js";
2
- import { NodeProcessDriver, killProcessGroup } from "./process-driver.js";
3
- import { RunExecutor } from "./run-executor.js";
4
- export { killProcessGroup };
5
- /**
6
- * 基于 NodeProcessDriver 实现的兼容命令执行器。
7
- * 核心 OS 进程派生与生命周期管理统一由 NodeProcessDriver 承担,不再重复派生与调度。
8
- */
9
- export class NodeProcessExecutor {
10
- driver;
11
- gracePeriodMs;
12
- constructor(options) {
13
- if (typeof options === "number") {
14
- this.gracePeriodMs = options;
15
- this.driver = new NodeProcessDriver();
16
- }
17
- else {
18
- this.gracePeriodMs = options?.gracePeriodMs ?? 500;
19
- this.driver =
20
- options?.driver ??
21
- new NodeProcessDriver({
22
- spawnFn: options?.spawnFn,
23
- });
24
- }
25
- }
26
- /**
27
- * 执行外部系统命令,完整支持标准输入管道、超时控制、取消信号、输出容量截断及错误拦截。
28
- *
29
- * @param command 执行命令
30
- * @param args 参数列表
31
- * @param options 执行选项
32
- * @param internal 内部专用参数:envAlreadyResolved 为 true 时 options.env 视为已完整解析
33
- */
34
- async exec(command, args = [], options = {}, internal) {
35
- const startTime = Date.now();
36
- const maxOutputBytes = options.maxOutputBytes ?? 10 * 1024 * 1024;
37
- const encoding = options.encoding || "utf8";
38
- const processId = `exec-${crypto.randomUUID()}`;
39
- return new Promise(async (resolve, reject) => {
40
- let settled = false;
41
- let timedOut = false;
42
- let cancelled = false;
43
- let outputLimitExceeded = false;
44
- let error;
45
- let writeErr;
46
- const stdoutChunks = [];
47
- const stderrChunks = [];
48
- let totalBytes = 0;
49
- let timeoutTimer;
50
- let graceTimer;
51
- let abortHandler;
52
- let handle;
53
- /** 子进程是否已退出:grace 宽限期 SIGKILL 升级前的存活二闪确认依据 */
54
- let childExited = false;
55
- const finish = (result) => {
56
- if (settled)
57
- return;
58
- settled = true;
59
- if (timeoutTimer) {
60
- clearTimeout(timeoutTimer);
61
- timeoutTimer = undefined;
62
- }
63
- // 结算时同步清理 grace 宽限定时器:子进程已退出(或已故障),
64
- // 后续 SIGKILL 升级不再必要,且可避免定时器泄漏与 pid 复用误杀
65
- if (graceTimer) {
66
- clearTimeout(graceTimer);
67
- graceTimer = undefined;
68
- }
69
- if (options.signal && abortHandler) {
70
- options.signal.removeEventListener("abort", abortHandler);
71
- }
72
- if (!result.ok && options.throwOnError) {
73
- const errMsg = result.error?.message || result.stderr || `Process exited with code ${result.exitCode}`;
74
- reject(new Error(errMsg));
75
- }
76
- else {
77
- resolve(result);
78
- }
79
- };
80
- const terminateChild = (sig = "SIGTERM") => {
81
- const pid = handle?.pid;
82
- if (pid) {
83
- killProcessGroup(pid, sig, this.driver.spawnFn);
84
- }
85
- if (timeoutTimer) {
86
- clearTimeout(timeoutTimer);
87
- timeoutTimer = undefined;
88
- }
89
- if (sig === "SIGKILL") {
90
- if (graceTimer) {
91
- clearTimeout(graceTimer);
92
- graceTimer = undefined;
93
- }
94
- }
95
- else if (!graceTimer) {
96
- graceTimer = setTimeout(() => {
97
- graceTimer = undefined;
98
- // 宽限期到时二次确认子进程句柄仍存活:已退出则跳过 SIGKILL,
99
- // 杜绝对已复用 pid 的无关进程组误杀
100
- if (childExited) {
101
- return;
102
- }
103
- const targetPid = handle?.pid;
104
- if (targetPid) {
105
- killProcessGroup(targetPid, "SIGKILL", this.driver.spawnFn);
106
- }
107
- }, this.gracePeriodMs);
108
- graceTimer.unref?.();
109
- }
110
- };
111
- const callbacks = {
112
- onOutput: (stream, data) => {
113
- if (outputLimitExceeded)
114
- return;
115
- const chunk = Buffer.from(data.buffer, data.byteOffset, data.byteLength);
116
- totalBytes += chunk.length;
117
- if (totalBytes > maxOutputBytes) {
118
- outputLimitExceeded = true;
119
- if (!error) {
120
- error = {
121
- code: PROCESS_OUTPUT_LIMIT,
122
- message: `Process output exceeded limit of ${maxOutputBytes} bytes`,
123
- };
124
- }
125
- terminateChild("SIGTERM");
126
- return;
127
- }
128
- if (stream === "stdout")
129
- stdoutChunks.push(chunk);
130
- else if (stream === "stderr")
131
- stderrChunks.push(chunk);
132
- },
133
- onExit: (exit) => {
134
- childExited = true;
135
- const durationMs = Date.now() - startTime;
136
- const stdoutBuf = Buffer.concat(stdoutChunks);
137
- const stderrBuf = Buffer.concat(writeErr
138
- ? [...stderrChunks, Buffer.from(`\n[stdin write failed: ${writeErr.message}]`)]
139
- : stderrChunks);
140
- const stdoutStr = stdoutBuf.toString(encoding);
141
- const stderrStr = stderrBuf.toString(encoding);
142
- const ok = exit.code === 0 && !timedOut && !cancelled && !error;
143
- finish({
144
- ok,
145
- exitCode: exit.code,
146
- signal: exit.signal || undefined,
147
- stdout: stdoutStr.trim(),
148
- stderr: stderrStr.trim(),
149
- raw: new Uint8Array(stdoutBuf),
150
- timedOut,
151
- cancelled,
152
- durationMs,
153
- error,
154
- });
155
- },
156
- onError: (err) => {
157
- childExited = true;
158
- const durationMs = Date.now() - startTime;
159
- const spawnError = error || {
160
- code: PROCESS_SPAWN_ERROR,
161
- message: err.message || "Failed to spawn process",
162
- };
163
- const stdoutBuf = Buffer.concat(stdoutChunks);
164
- const stderrBuf = Buffer.concat(writeErr
165
- ? [...stderrChunks, Buffer.from(`\n[stdin write failed: ${writeErr.message}]`)]
166
- : stderrChunks);
167
- finish({
168
- ok: false,
169
- exitCode: null,
170
- signal: undefined,
171
- stdout: stdoutBuf.toString(encoding).trim(),
172
- stderr: stderrBuf.toString(encoding).trim() || spawnError.message,
173
- raw: new Uint8Array(stdoutBuf),
174
- timedOut,
175
- cancelled,
176
- durationMs,
177
- error: spawnError,
178
- });
179
- },
180
- };
181
- const effectiveEnv = internal?.envAlreadyResolved
182
- ? { inherit: "none", set: options.env }
183
- : options.env
184
- ? { inherit: "allowlisted", set: options.env }
185
- : undefined;
186
- const spec = {
187
- executable: command,
188
- args,
189
- cwd: options.cwd,
190
- env: effectiveEnv,
191
- io: { mode: "pipe" },
192
- };
193
- if (options.signal) {
194
- abortHandler = () => {
195
- cancelled = true;
196
- if (!error) {
197
- error = {
198
- code: PROCESS_CANCELLED,
199
- message: "Process was cancelled by AbortSignal",
200
- };
201
- }
202
- terminateChild("SIGTERM");
203
- };
204
- if (options.signal.aborted) {
205
- abortHandler();
206
- }
207
- else {
208
- options.signal.addEventListener("abort", abortHandler, { once: true });
209
- }
210
- }
211
- if (options.timeoutMs && options.timeoutMs > 0) {
212
- timeoutTimer = setTimeout(() => {
213
- timedOut = true;
214
- if (!error) {
215
- error = {
216
- code: PROCESS_TIMEOUT,
217
- message: `Process timed out after ${options.timeoutMs}ms`,
218
- };
219
- }
220
- terminateChild("SIGTERM");
221
- }, options.timeoutMs);
222
- }
223
- try {
224
- const observer = {
225
- output: (stream, data) => callbacks.onOutput(stream, data),
226
- exited: (exit) => callbacks.onExit(exit),
227
- outputClosed: (reason) => callbacks.onOutputClosed?.(reason),
228
- fault: (err) => callbacks.onError(err),
229
- };
230
- handle = (await this.driver.spawn(spec, observer));
231
- if (cancelled || timedOut || outputLimitExceeded) {
232
- terminateChild("SIGTERM");
233
- }
234
- }
235
- catch (spawnErr) {
236
- callbacks.onError(spawnErr);
237
- return;
238
- }
239
- if (options.input !== undefined && options.input !== null && handle) {
240
- const inputBytes = typeof options.input === "string"
241
- ? new TextEncoder().encode(options.input)
242
- : options.input;
243
- handle
244
- .write(inputBytes)
245
- .then(() => handle?.sendInputEOF?.())
246
- .catch((err) => {
247
- writeErr = err;
248
- });
249
- }
250
- });
251
- }
252
- async spawn(command, args = [], options = {}) {
253
- return this.exec(command, args, options);
254
- }
255
- async run(input, call) {
256
- const runExecutor = new RunExecutor(this.driver);
257
- return runExecutor.execute(input, call);
258
- }
259
- async start(_input, _call) {
260
- throw new ProcessError(UNSUPPORTED_CAPABILITY, "NodeProcessExecutor does not support managed process start; use ProcessManager with NodeProcessDriver");
261
- }
262
- async inspect(_id, _call) {
263
- throw new ProcessError(UNSUPPORTED_CAPABILITY, "NodeProcessExecutor does not support managed process inspect");
264
- }
265
- async list(_input, _call) {
266
- return { processes: [] };
267
- }
268
- async acquire(_id, _input, _call) {
269
- throw new ProcessError(UNSUPPORTED_CAPABILITY, "NodeProcessExecutor does not support managed process acquire");
270
- }
271
- async renew(_id, _token, _ttlMs, _call) {
272
- throw new ProcessError(UNSUPPORTED_CAPABILITY, "NodeProcessExecutor does not support managed process renew");
273
- }
274
- async release(_id, _token, _call) {
275
- throw new ProcessError(UNSUPPORTED_CAPABILITY, "NodeProcessExecutor does not support managed process release");
276
- }
277
- async write(_id, _input, _call) {
278
- throw new ProcessError(UNSUPPORTED_CAPABILITY, "NodeProcessExecutor does not support managed process write");
279
- }
280
- async operation(_id, _requestId, _call) {
281
- throw new ProcessError(UNSUPPORTED_CAPABILITY, "NodeProcessExecutor does not support managed process operation");
282
- }
283
- async read(_id, _input, _call) {
284
- throw new ProcessError(UNSUPPORTED_CAPABILITY, "NodeProcessExecutor does not support managed process read");
285
- }
286
- async control(_id, _input, _call) {
287
- throw new ProcessError(UNSUPPORTED_CAPABILITY, "NodeProcessExecutor does not support managed process control");
288
- }
289
- async stop(_id, _input, _call) {
290
- throw new ProcessError(UNSUPPORTED_CAPABILITY, "NodeProcessExecutor does not support managed process stop");
291
- }
292
- }
293
- /**
294
- * 兼容原有类名导出。
295
- */
296
- export { NodeProcessExecutor as ExecaProcessExecutor };
@@ -1,14 +0,0 @@
1
- import type { RemoteHealthResult } from "./types.js";
2
- import { type RemoteClientRequestOptions } from "./client-transport.js";
3
- /**
4
- * 远端健康检查域端点。
5
- */
6
- /**
7
- * 探测指定远端 ActionDock 服务的健康状态与网络延迟。
8
- *
9
- * @param serverUrl 目标服务端地址
10
- * @param token 鉴权 Token(可选)
11
- * @param timeoutMs 探测超时时间(默认 5000ms)
12
- * @param options 传输与安全控制选项
13
- */
14
- export declare function checkRemoteHealth(serverUrl: string, token?: string, timeoutMs?: number, options?: RemoteClientRequestOptions): Promise<RemoteHealthResult>;
@@ -1,30 +0,0 @@
1
- import { type RemoteClientRequestOptions } from "./client-transport.js";
2
- /**
3
- * 远端端点函数共享的请求与查询构造层。
4
- *
5
- * 职责单一聚焦:JSON 响应解析与错误信封透传、查询参数序列化,
6
- * 供各按域端点模块复用,杜绝端点函数内手工拼 query 样板。
7
- */
8
- /**
9
- * 执行远端请求并将响应解析为 JSON,统一处理错误信封透传。
10
- * 非 2xx 响应或显式 ok=false 信封抛出携带 code/status/details 的 Error。
11
- */
12
- export declare function fetchRemoteJson<T = any>(serverUrl: string, path: string, token?: string, options?: {
13
- method?: string;
14
- body?: unknown;
15
- errorPrefix?: string;
16
- } & RemoteClientRequestOptions): Promise<T>;
17
- /**
18
- * 由可选参数字典构造查询串(无参数时返回空串)。
19
- *
20
- * 序列化规则与既有端点行为严格一致:
21
- * - undefined 与空串一律跳过(对应原有 if (options?.xxx) 真值守卫);
22
- * - 需保留「存在但为空」语义的参数(如 namespace,服务端区分空串与未传递)
23
- * 由调用方显式处理,不经由此助手序列化空串。
24
- */
25
- export declare function buildQueryString(params: Record<string, string | number | boolean | undefined>): string;
26
- /**
27
- * 构造保留「存在但为空」语义的查询串:仅跳过 undefined,空串照常序列化。
28
- * 适用 namespace 类参数:服务端以参数是否存在区分空命名空间与默认命名空间。
29
- */
30
- export declare function buildQueryStringPreservingEmpty(params: Record<string, string | number | boolean | undefined>): string;
@@ -1,69 +0,0 @@
1
- import { createRemoteFetch } from "./client-transport.js";
2
- import { ActionDockError, NOT_FOUND, REMOTE_REQUEST_FAILED, UNAUTHORIZED } from "../errors.js";
3
- /**
4
- * 远端端点函数共享的请求与查询构造层。
5
- *
6
- * 职责单一聚焦:JSON 响应解析与错误信封透传、查询参数序列化,
7
- * 供各按域端点模块复用,杜绝端点函数内手工拼 query 样板。
8
- */
9
- /**
10
- * 执行远端请求并将响应解析为 JSON,统一处理错误信封透传。
11
- * 非 2xx 响应或显式 ok=false 信封抛出携带 code/status/details 的 Error。
12
- */
13
- export async function fetchRemoteJson(serverUrl, path, token, options = {}) {
14
- const remoteFetch = createRemoteFetch(serverUrl, token, {
15
- allowInsecureHttp: options.allowInsecureHttp,
16
- insecure: options.insecure,
17
- dispatcher: options.dispatcher,
18
- });
19
- const res = await remoteFetch(path, {
20
- method: options.method,
21
- body: options.body,
22
- });
23
- const data = (await res.json().catch(() => ({})));
24
- if (!res.ok || (options.method === "POST" && data && data.ok === false)) {
25
- const errorPrefix = options.errorPrefix || "Remote request failed";
26
- const msg = data?.error?.message || `${errorPrefix} (${res.status}): ${res.statusText}`;
27
- const code = data?.error?.code ||
28
- (res.status === 404 ? NOT_FOUND : res.status === 401 ? UNAUTHORIZED : REMOTE_REQUEST_FAILED);
29
- const details = data?.error?.details ?? data?.error;
30
- const err = new ActionDockError(code, msg, details, res.status);
31
- err.errorData = data?.error;
32
- throw err;
33
- }
34
- return data;
35
- }
36
- /**
37
- * 由可选参数字典构造查询串(无参数时返回空串)。
38
- *
39
- * 序列化规则与既有端点行为严格一致:
40
- * - undefined 与空串一律跳过(对应原有 if (options?.xxx) 真值守卫);
41
- * - 需保留「存在但为空」语义的参数(如 namespace,服务端区分空串与未传递)
42
- * 由调用方显式处理,不经由此助手序列化空串。
43
- */
44
- export function buildQueryString(params) {
45
- const search = new URLSearchParams();
46
- for (const [key, value] of Object.entries(params)) {
47
- if (value === undefined || value === "") {
48
- continue;
49
- }
50
- search.set(key, String(value));
51
- }
52
- const qs = search.toString();
53
- return qs ? `?${qs}` : "";
54
- }
55
- /**
56
- * 构造保留「存在但为空」语义的查询串:仅跳过 undefined,空串照常序列化。
57
- * 适用 namespace 类参数:服务端以参数是否存在区分空命名空间与默认命名空间。
58
- */
59
- export function buildQueryStringPreservingEmpty(params) {
60
- const search = new URLSearchParams();
61
- for (const [key, value] of Object.entries(params)) {
62
- if (value === undefined) {
63
- continue;
64
- }
65
- search.set(key, String(value));
66
- }
67
- const qs = search.toString();
68
- return qs ? `?${qs}` : "";
69
- }
@@ -1,26 +0,0 @@
1
- /**
2
- * 远端 Profile 客户端聚合入口。
3
- *
4
- * 历史上全部端点函数集中于单一 client.ts(约 950 行),现按域拆分为
5
- * 单一职责模块,此处仅保留聚合 re-export,导入路径 ./client 与
6
- * @actiondock/core 的公共导出面保持完全兼容。
7
- *
8
- * 模块划分:
9
- * - client-transport:传输层(鉴权头、明文校验、协议回退)
10
- * - client-query:共享请求与查询构造层
11
- * - client-health:健康检查
12
- * - client-actions:执行与 Action 查询
13
- * - client-playbooks:Playbook 规程查询
14
- * - client-runs:运行记录管理
15
- * - client-state:状态存储管理
16
- * - client-config:配置管理
17
- */
18
- export { assertSecureTransport, createRemoteFetch, fetchRemoteRoute, } from "./client-transport.js";
19
- export type { RemoteClientRequestOptions, RemoteFetchInit, SecureTransportOptions, } from "./client-transport.js";
20
- export { checkRemoteHealth } from "./client-health.js";
21
- export { executeRemoteAction, fetchRemoteActionShow, fetchRemoteActions, fetchRemoteDoctor, fetchRemoteInfo, } from "./client-actions.js";
22
- export type { RemoteExecuteOptions, RemoteExecutionResult } from "./client-actions.js";
23
- export { fetchRemotePlaybookShow, fetchRemotePlaybooks } from "./client-playbooks.js";
24
- export { cancelRemoteRun, clearRemoteRuns, cleanExpiredRemoteRuns, fetchRemoteRun, fetchRemoteRuns, } from "./client-runs.js";
25
- export { clearRemoteState, deleteRemoteStateKey, fetchRemoteStateList, getRemoteStateKey, setRemoteStateKey, } from "./client-state.js";
26
- export { deleteRemoteConfig, fetchRemoteConfig, fetchRemoteConfigEnv, setRemoteConfig, } from "./client-config.js";
@@ -1,31 +0,0 @@
1
- /**
2
- * 远端 Profile 客户端聚合入口。
3
- *
4
- * 历史上全部端点函数集中于单一 client.ts(约 950 行),现按域拆分为
5
- * 单一职责模块,此处仅保留聚合 re-export,导入路径 ./client 与
6
- * @actiondock/core 的公共导出面保持完全兼容。
7
- *
8
- * 模块划分:
9
- * - client-transport:传输层(鉴权头、明文校验、协议回退)
10
- * - client-query:共享请求与查询构造层
11
- * - client-health:健康检查
12
- * - client-actions:执行与 Action 查询
13
- * - client-playbooks:Playbook 规程查询
14
- * - client-runs:运行记录管理
15
- * - client-state:状态存储管理
16
- * - client-config:配置管理
17
- */
18
- // 传输层与通用类型
19
- export { assertSecureTransport, createRemoteFetch, fetchRemoteRoute, } from "./client-transport.js";
20
- // 健康检查
21
- export { checkRemoteHealth } from "./client-health.js";
22
- // 执行与 Action 查询
23
- export { executeRemoteAction, fetchRemoteActionShow, fetchRemoteActions, fetchRemoteDoctor, fetchRemoteInfo, } from "./client-actions.js";
24
- // Playbook 规程查询
25
- export { fetchRemotePlaybookShow, fetchRemotePlaybooks } from "./client-playbooks.js";
26
- // 运行记录管理
27
- export { cancelRemoteRun, clearRemoteRuns, cleanExpiredRemoteRuns, fetchRemoteRun, fetchRemoteRuns, } from "./client-runs.js";
28
- // 状态存储管理
29
- export { clearRemoteState, deleteRemoteStateKey, fetchRemoteStateList, getRemoteStateKey, setRemoteStateKey, } from "./client-state.js";
30
- // 配置管理
31
- export { deleteRemoteConfig, fetchRemoteConfig, fetchRemoteConfigEnv, setRemoteConfig, } from "./client-config.js";
@@ -1,25 +0,0 @@
1
- export interface EnsureDependencyClosureOptions {
2
- /**
3
- * 自定义依赖安装回调函数(便于单测 Mock 与自定义扩展)
4
- */
5
- ensure?: (root: string) => boolean | Promise<boolean>;
6
- /**
7
- * 自定义 ActionDock 家目录
8
- */
9
- customHome?: string;
10
- }
11
- export interface DependencyClosureResult {
12
- /** 成功执行依赖预装的项目根路径列表(默认实现下永远为空) */
13
- installed: string[];
14
- /** 无法在注册表中解析包引用的警告列表 */
15
- warnings: string[];
16
- }
17
- /**
18
- * 广度优先遍历 (BFS) uses 声明的跨包依赖闭包,对涉及的每个项目包逐一调用依赖预装回调。
19
- * 默认预装回调为明确的不操作(ActionDock 2.0 不做运行时安装);可通过 opts.ensure 注入自定义实现。
20
- *
21
- * @param roots 根项目目录列表
22
- * @param opts 选项参数
23
- * @returns 预装成功的路径列表及警告信息
24
- */
25
- export declare function ensureDependencyClosure(roots: string[], opts?: EnsureDependencyClosureOptions): Promise<DependencyClosureResult>;
@@ -1,74 +0,0 @@
1
- import { resolve } from "node:path";
2
- import { parseActionRef } from "../catalog/resolve-action.js";
3
- import { resolvePackageRoot } from "../registry/registry.js";
4
- import { loadManifest } from "./manifest.js";
5
- /**
6
- * 依赖预装的默认实现:明确的不操作。
7
- * ActionDock 2.0 移除了运行时静默在线安装,保留该签名仅为闭包遍历提供注入点(便于单测 Mock 与自定义扩展)。
8
- */
9
- function noopEnsure() {
10
- return false;
11
- }
12
- /**
13
- * 广度优先遍历 (BFS) uses 声明的跨包依赖闭包,对涉及的每个项目包逐一调用依赖预装回调。
14
- * 默认预装回调为明确的不操作(ActionDock 2.0 不做运行时安装);可通过 opts.ensure 注入自定义实现。
15
- *
16
- * @param roots 根项目目录列表
17
- * @param opts 选项参数
18
- * @returns 预装成功的路径列表及警告信息
19
- */
20
- export async function ensureDependencyClosure(roots, opts = {}) {
21
- const seen = new Set();
22
- const queue = [...roots];
23
- const installed = [];
24
- const warnings = [];
25
- while (queue.length > 0) {
26
- const rawRoot = queue.shift();
27
- if (!rawRoot)
28
- continue;
29
- const root = resolve(rawRoot);
30
- if (seen.has(root))
31
- continue;
32
- seen.add(root);
33
- const ensureFn = opts.ensure ?? noopEnsure;
34
- const wasInstalled = await ensureFn(root);
35
- if (wasInstalled) {
36
- installed.push(root);
37
- }
38
- let manifest;
39
- try {
40
- manifest = loadManifest(root);
41
- }
42
- catch {
43
- continue;
44
- }
45
- if (!manifest || !manifest.actions)
46
- continue;
47
- for (const actionEntry of Object.values(manifest.actions)) {
48
- if (!Array.isArray(actionEntry.uses))
49
- continue;
50
- for (const rawRef of actionEntry.uses) {
51
- if (typeof rawRef !== "string" || !rawRef.trim())
52
- continue;
53
- let parsed;
54
- try {
55
- parsed = parseActionRef(rawRef);
56
- }
57
- catch {
58
- warnings.push(`uses 声明 '${rawRef}' 未在注册表中解析到包`);
59
- continue;
60
- }
61
- if (parsed.packageId) {
62
- const depRoot = resolvePackageRoot(parsed.packageId, root, opts.customHome);
63
- if (depRoot) {
64
- queue.push(resolve(depRoot));
65
- }
66
- else {
67
- warnings.push(`uses 声明 '${rawRef}' 未在注册表中解析到包`);
68
- }
69
- }
70
- }
71
- }
72
- }
73
- return { installed, warnings };
74
- }
@@ -1,42 +0,0 @@
1
- import type { GlobalRegistryData, LinkedPackageEntry, LinkedWorkspaceEntry, LinkResult, PruneResult, RegistryStatusReport, UnlinkResult } from "./types.js";
2
- /**
3
- * 用户显式注册位置存储契约。
4
- * 职责严格限制为存储与读取用户显式 link/unlink 的物理位置(packages 与 workspaces)。
5
- */
6
- export interface RegistryStore {
7
- readonly customHome?: string;
8
- getFilePath(): string;
9
- load(): GlobalRegistryData;
10
- loadAsync(): Promise<GlobalRegistryData>;
11
- save(data: GlobalRegistryData): Promise<void>;
12
- listPackages(): LinkedPackageEntry[];
13
- listWorkspaces(): LinkedWorkspaceEntry[];
14
- link(path: string, options?: {
15
- recursive?: boolean;
16
- }): Promise<LinkResult>;
17
- unlink(idOrPath: string): Promise<UnlinkResult | null>;
18
- prune(): Promise<PruneResult>;
19
- getStatus(): RegistryStatusReport;
20
- }
21
- /**
22
- * 默认注册表物理位置存储实现。
23
- * 直接基于文件系统注册表文件(~/.actiondock/registry.json)读写;
24
- * 全部方法均为向 registry.ts 自由函数透传 customHome 的零逻辑转发,
25
- * 收敛为单行委托以消除重复样板。
26
- */
27
- export declare class DefaultRegistryStore implements RegistryStore {
28
- readonly customHome?: string;
29
- constructor(customHome?: string);
30
- getFilePath(): string;
31
- load(): GlobalRegistryData;
32
- loadAsync(): Promise<GlobalRegistryData>;
33
- save(data: GlobalRegistryData): Promise<void>;
34
- listPackages(): LinkedPackageEntry[];
35
- listWorkspaces(): LinkedWorkspaceEntry[];
36
- link(path: string, options?: {
37
- recursive?: boolean;
38
- }): Promise<LinkResult>;
39
- unlink(idOrPath: string): Promise<UnlinkResult | null>;
40
- prune(): Promise<PruneResult>;
41
- getStatus(): RegistryStatusReport;
42
- }
@@ -1,43 +0,0 @@
1
- import { getRegistryFilePath, getRegistryStatus, linkPackage, listLinkedPackages, listLinkedWorkspaces, loadRegistry, loadRegistryAsync, pruneRegistry, saveRegistry, unlinkPackage, } from "./registry.js";
2
- /**
3
- * 默认注册表物理位置存储实现。
4
- * 直接基于文件系统注册表文件(~/.actiondock/registry.json)读写;
5
- * 全部方法均为向 registry.ts 自由函数透传 customHome 的零逻辑转发,
6
- * 收敛为单行委托以消除重复样板。
7
- */
8
- export class DefaultRegistryStore {
9
- customHome;
10
- constructor(customHome) {
11
- this.customHome = customHome;
12
- }
13
- getFilePath() {
14
- return getRegistryFilePath(this.customHome);
15
- }
16
- load() {
17
- return loadRegistry(this.customHome);
18
- }
19
- loadAsync() {
20
- return loadRegistryAsync(this.customHome);
21
- }
22
- save(data) {
23
- return saveRegistry(data, this.customHome);
24
- }
25
- listPackages() {
26
- return listLinkedPackages(this.customHome);
27
- }
28
- listWorkspaces() {
29
- return listLinkedWorkspaces(this.customHome);
30
- }
31
- link(path, options) {
32
- return linkPackage(path, this.customHome, options);
33
- }
34
- unlink(idOrPath) {
35
- return unlinkPackage(idOrPath, this.customHome);
36
- }
37
- prune() {
38
- return pruneRegistry(this.customHome);
39
- }
40
- getStatus() {
41
- return getRegistryStatus(this.customHome);
42
- }
43
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * 时钟契约单一事实源已下沉至 storage/clock.ts(基础契约层)。
3
- *
4
- * 此处 re-export 维持 `runtime/clock` 与 `@actiondock/core` 根入口的既有
5
- * 导入路径兼容,外部消费方无需变更。
6
- */
7
- export { type Clock, SystemClock } from "../storage/clock.js";
@@ -1,7 +0,0 @@
1
- /**
2
- * 时钟契约单一事实源已下沉至 storage/clock.ts(基础契约层)。
3
- *
4
- * 此处 re-export 维持 `runtime/clock` 与 `@actiondock/core` 根入口的既有
5
- * 导入路径兼容,外部消费方无需变更。
6
- */
7
- export { SystemClock } from "../storage/clock.js";