@actiondock/core 2.5.1 → 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.
- package/dist/app/app.d.ts +14 -1
- package/dist/app/app.js +88 -222
- package/dist/app/static-index.d.ts +39 -0
- package/dist/app/static-index.js +164 -0
- package/dist/app/types.d.ts +5 -0
- package/dist/catalog/action-index.js +6 -4
- package/dist/catalog/package-catalog.js +2 -1
- package/dist/doctor/checks/index.d.ts +5 -0
- package/dist/doctor/checks/index.js +5 -0
- package/dist/doctor/checks/project-locate.d.ts +6 -0
- package/dist/doctor/checks/project-locate.js +36 -0
- package/dist/doctor/checks/project.d.ts +6 -0
- package/dist/doctor/checks/project.js +383 -0
- package/dist/doctor/checks/registry.d.ts +13 -0
- package/dist/doctor/checks/registry.js +207 -0
- package/dist/doctor/checks/runtime.d.ts +13 -0
- package/dist/doctor/checks/runtime.js +90 -0
- package/dist/doctor/checks/storage.d.ts +5 -0
- package/dist/doctor/checks/storage.js +34 -0
- package/dist/doctor/context.d.ts +35 -0
- package/dist/doctor/context.js +11 -0
- package/dist/doctor/doctor.d.ts +5 -0
- package/dist/doctor/doctor.js +33 -602
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +2 -0
- package/dist/execution/service.js +14 -9
- package/dist/host/host.d.ts +33 -0
- package/dist/host/host.js +222 -362
- package/dist/host/routing.d.ts +92 -0
- package/dist/host/routing.js +238 -0
- package/dist/host/types.d.ts +8 -0
- package/dist/ipc/host.js +38 -0
- package/dist/platform/types.d.ts +7 -0
- package/dist/process/control-arbiter.d.ts +107 -0
- package/dist/process/control-arbiter.js +251 -0
- package/dist/process/diagnostics-sink.d.ts +26 -0
- package/dist/process/diagnostics-sink.js +35 -0
- package/dist/process/index.d.ts +7 -0
- package/dist/process/index.js +7 -0
- package/dist/process/input-dispatcher.d.ts +88 -0
- package/dist/process/input-dispatcher.js +240 -0
- package/dist/process/managed-record.d.ts +78 -0
- package/dist/process/managed-record.js +1 -0
- package/dist/process/process-manager.d.ts +15 -56
- package/dist/process/process-manager.js +119 -707
- package/dist/process/reservation-table.d.ts +39 -0
- package/dist/process/reservation-table.js +80 -0
- package/dist/process/run-executor.d.ts +16 -0
- package/dist/process/run-executor.js +155 -0
- package/dist/process/terminal-output-cache.d.ts +66 -0
- package/dist/process/terminal-output-cache.js +132 -0
- package/dist/profile/client-actions.d.ts +56 -0
- package/dist/profile/client-actions.js +215 -0
- package/dist/profile/client-config.d.ts +20 -0
- package/dist/profile/client-config.js +51 -0
- package/dist/profile/client-health.d.ts +14 -0
- package/dist/profile/client-health.js +68 -0
- package/dist/profile/client-playbooks.d.ts +19 -0
- package/dist/profile/client-playbooks.js +36 -0
- package/dist/profile/client-query.d.ts +30 -0
- package/dist/profile/client-query.js +70 -0
- package/dist/profile/client-runs.d.ts +42 -0
- package/dist/profile/client-runs.js +58 -0
- package/dist/profile/client-state.d.ts +56 -0
- package/dist/profile/client-state.js +83 -0
- package/dist/profile/client-transport.d.ts +61 -0
- package/dist/profile/client-transport.js +155 -0
- package/dist/profile/client.d.ts +23 -142
- package/dist/profile/client.js +28 -588
- package/dist/profile/manager.js +1 -1
- package/dist/project/closure.d.ts +4 -4
- package/dist/project/closure.js +11 -5
- package/dist/project/init.js +2 -2
- package/dist/project/loader.d.ts +0 -25
- package/dist/project/loader.js +1 -154
- package/dist/project/transactions.d.ts +12 -14
- package/dist/project/transactions.js +60 -836
- package/dist/registry/registry.js +6 -4
- package/dist/registry/resolve.js +1 -1
- package/dist/runtime/action-registry.d.ts +45 -0
- package/dist/runtime/action-registry.js +108 -0
- package/dist/runtime/clock.d.ts +5 -17
- package/dist/runtime/clock.js +5 -15
- package/dist/runtime/context.d.ts +3 -0
- package/dist/runtime/context.js +17 -56
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +3 -0
- package/dist/runtime/package-runner-factory.d.ts +82 -0
- package/dist/runtime/package-runner-factory.js +186 -0
- package/dist/runtime/run-persistence.d.ts +85 -0
- package/dist/runtime/run-persistence.js +111 -0
- package/dist/runtime/runner.d.ts +23 -33
- package/dist/runtime/runner.js +92 -286
- package/dist/runtime/standalone.d.ts +11 -1
- package/dist/runtime/standalone.js +137 -25
- package/dist/server/dispatcher.d.ts +8 -3
- package/dist/server/dispatcher.js +16 -40
- package/dist/server/routes/runs.js +6 -4
- package/dist/server/security.d.ts +1 -7
- package/dist/server/security.js +2 -13
- package/dist/storage/clock.d.ts +25 -0
- package/dist/storage/clock.js +23 -0
- package/dist/storage/data-dir-lock.d.ts +3 -36
- package/dist/storage/data-dir-lock.js +48 -881
- package/dist/storage/index.d.ts +8 -1
- package/dist/storage/index.js +8 -2
- package/dist/storage/lazy.js +1 -0
- package/dist/storage/lock-core.d.ts +162 -0
- package/dist/storage/lock-core.js +885 -0
- package/dist/storage/sqlite.d.ts +19 -6
- package/dist/storage/sqlite.js +81 -89
- package/dist/storage/types.d.ts +27 -5
- package/dist/storage/types.js +21 -0
- package/dist/storage/utils.d.ts +22 -0
- package/dist/storage/utils.js +34 -0
- package/dist/target/local.d.ts +1 -0
- package/dist/target/local.js +23 -17
- package/dist/target/remote-errors.d.ts +21 -0
- package/dist/target/remote-errors.js +51 -0
- package/dist/target/remote-polling.d.ts +35 -0
- package/dist/target/remote-polling.js +104 -0
- package/dist/target/remote.d.ts +4 -0
- package/dist/target/remote.js +108 -301
- package/dist/target/sse-parser.d.ts +35 -0
- package/dist/target/sse-parser.js +163 -0
- package/dist/target/target.js +2 -0
- package/dist/target/types.d.ts +6 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/net.d.ts +10 -0
- package/dist/utils/net.js +16 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ControlGrant, Limits, OperationReceipt, ProcessControlAction, ProcessInfo } from "@actiondock/sdk";
|
|
2
|
+
import type { ProcessDriverHandle } from "./driver.js";
|
|
3
|
+
import type { ProcessRequestKey } from "./metadata-store.js";
|
|
4
|
+
import type { ProcessOutputLog } from "./output-log.js";
|
|
5
|
+
import type { EvictedOutputTombstone } from "./terminal-output-cache.js";
|
|
6
|
+
/**
|
|
7
|
+
* 受管进程归属所有者身份。
|
|
8
|
+
*/
|
|
9
|
+
export interface ProcessOwner {
|
|
10
|
+
tenantId: string;
|
|
11
|
+
principalId: string;
|
|
12
|
+
packageInstanceId: string;
|
|
13
|
+
generationId: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 待调度的异步操作队列条目。
|
|
17
|
+
*/
|
|
18
|
+
export interface QueuedOperation {
|
|
19
|
+
type: "write" | "control";
|
|
20
|
+
requestId: string;
|
|
21
|
+
token: string;
|
|
22
|
+
bytes?: Uint8Array;
|
|
23
|
+
action?: ProcessControlAction;
|
|
24
|
+
/** 入队时进程的取消纪元,用于 stop 与 dispatch 竞态判定 */
|
|
25
|
+
cancelEpoch: number;
|
|
26
|
+
receipt: OperationReceipt;
|
|
27
|
+
key: ProcessRequestKey;
|
|
28
|
+
payloadHash: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 排队等待获取控制权的调用者条目。
|
|
32
|
+
*/
|
|
33
|
+
export interface AcquireWaiter {
|
|
34
|
+
requestId: string;
|
|
35
|
+
waitMs: number;
|
|
36
|
+
ttlMs: number;
|
|
37
|
+
runId?: string;
|
|
38
|
+
timer?: ReturnType<typeof setTimeout>;
|
|
39
|
+
onAbort?: () => void;
|
|
40
|
+
resolve: (grant: ControlGrant) => void;
|
|
41
|
+
reject: (err: unknown) => void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 进程管理器内部维护的活跃受管进程记录。
|
|
45
|
+
*
|
|
46
|
+
* 该结构为进程管理器、控制权仲裁器与输入调度器的共享事实源:
|
|
47
|
+
* 控制权与输入队列相关字段经仲裁器与调度器协作推进,禁止绕过二者直接改写。
|
|
48
|
+
*/
|
|
49
|
+
export interface ManagedProcessRecord {
|
|
50
|
+
info: ProcessInfo;
|
|
51
|
+
owner: ProcessOwner;
|
|
52
|
+
scope: string;
|
|
53
|
+
handle?: ProcessDriverHandle;
|
|
54
|
+
outputLog: ProcessOutputLog;
|
|
55
|
+
outputUnavailable?: boolean;
|
|
56
|
+
outputTombstone?: EvictedOutputTombstone;
|
|
57
|
+
controlEpoch: number;
|
|
58
|
+
/** 取消纪元:stop 接管输入队列时递增,用于让挂起中的 dispatch 放弃过期结算 */
|
|
59
|
+
cancelEpoch: number;
|
|
60
|
+
currentGrant?: {
|
|
61
|
+
token: string;
|
|
62
|
+
epoch: number;
|
|
63
|
+
ttlMs: number;
|
|
64
|
+
expiresAt: string;
|
|
65
|
+
runId?: string;
|
|
66
|
+
requestId: string;
|
|
67
|
+
};
|
|
68
|
+
ttlTimer?: ReturnType<typeof setTimeout>;
|
|
69
|
+
idleTimer?: ReturnType<typeof setTimeout>;
|
|
70
|
+
lifetimeTimer?: ReturnType<typeof setTimeout>;
|
|
71
|
+
drainTimer?: ReturnType<typeof setTimeout>;
|
|
72
|
+
inputQueue: QueuedOperation[];
|
|
73
|
+
pendingInputBytes: number;
|
|
74
|
+
acquireWaiters: AcquireWaiter[];
|
|
75
|
+
inputClosed: boolean;
|
|
76
|
+
isDispatching: boolean;
|
|
77
|
+
effectiveLimits: Required<Limits>;
|
|
78
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,15 +2,8 @@ import { type CallOptions, type ControlGrant, type Limits, type Logger, type Ope
|
|
|
2
2
|
import { ContextProcessAPI } from "./context-process.js";
|
|
3
3
|
import type { ProcessDriver } from "./driver.js";
|
|
4
4
|
import { type ProcessMetadataStore } from "./metadata-store.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
export interface ProcessOwner {
|
|
9
|
-
tenantId: string;
|
|
10
|
-
principalId: string;
|
|
11
|
-
packageInstanceId: string;
|
|
12
|
-
generationId: string;
|
|
13
|
-
}
|
|
5
|
+
import type { ProcessOwner } from "./managed-record.js";
|
|
6
|
+
export type { ManagedProcessRecord, QueuedOperation, AcquireWaiter, ProcessOwner, } from "./managed-record.js";
|
|
14
7
|
/**
|
|
15
8
|
* 宿主与作用域资源配额配置。
|
|
16
9
|
*/
|
|
@@ -75,18 +68,21 @@ export declare class ProcessManager {
|
|
|
75
68
|
readonly defaultLimits: Required<Limits>;
|
|
76
69
|
readonly drainDeadlineMs: number;
|
|
77
70
|
readonly terminalLogRetentionMs: number;
|
|
78
|
-
private readonly logger?;
|
|
79
71
|
private processes;
|
|
80
|
-
/**
|
|
81
|
-
private
|
|
82
|
-
/** 已淘汰输出日志的墓碑缓存:防止因日志淘汰静默丢失输出数据,支撑缺口明确告知与不可用异常 */
|
|
83
|
-
private evictedOutputTombstones;
|
|
72
|
+
/** 内部诊断日志汇聚器:未注入 logger 时保留最近的持久化与驱动错误,避免静默吞没异常 */
|
|
73
|
+
private readonly diagnosticsSink;
|
|
84
74
|
/** 同步幂等预占表:以复合键在异步落盘窗口内锁定并发重复请求 */
|
|
85
|
-
private
|
|
75
|
+
private readonly reservationTable;
|
|
76
|
+
/** 终态输出日志保留缓存:附带 TTL 过期回收与 LRU 淘汰,及墓碑登记 */
|
|
77
|
+
private readonly terminalOutputCache;
|
|
78
|
+
/** 一次性 run 执行器:仅依赖驱动、错误映射与输入校验,不触碰进程注册表 */
|
|
79
|
+
private readonly runExecutor;
|
|
80
|
+
/** 控制权仲裁器:独占控制权状态机全部推进路径的唯一持有者 */
|
|
81
|
+
private readonly controlArbiter;
|
|
82
|
+
/** 输入调度器:输入队列入队、串行调度与接管原语的唯一持有者 */
|
|
83
|
+
private readonly inputDispatcher;
|
|
86
84
|
private initPromise;
|
|
87
85
|
private isShutdown;
|
|
88
|
-
/** 内部诊断日志:未注入 logger 时保留最近的持久化与驱动错误,避免静默吞没异常 */
|
|
89
|
-
private diagnostics;
|
|
90
86
|
constructor(options: ProcessManagerOptions);
|
|
91
87
|
/**
|
|
92
88
|
* 初始化宿主环境,原子性收敛旧宿主遗留的非终态进程。
|
|
@@ -115,9 +111,7 @@ export declare class ProcessManager {
|
|
|
115
111
|
private persistReceipt;
|
|
116
112
|
/**
|
|
117
113
|
* 同步预占幂等请求:跨 await 的检查与落盘窗口内锁定同复合键并发调用。
|
|
118
|
-
*
|
|
119
|
-
* 返回 RequestReservation 表示已有同请求进行中,调用方可等待其结果。
|
|
120
|
-
* 若已有请求负载或操作类型不同,立即抛出 REQUEST_CONFLICT 杜绝混用结果。
|
|
114
|
+
* 实现委托给独立持有的预占表,语义详见 ReservationTable.reserve。
|
|
121
115
|
*/
|
|
122
116
|
private reserveRequest;
|
|
123
117
|
private commitReservation;
|
|
@@ -181,28 +175,9 @@ export declare class ProcessManager {
|
|
|
181
175
|
quarantineProcess(owner: ProcessOwner, processId: string, token?: string, reason?: string): Promise<void>;
|
|
182
176
|
/**
|
|
183
177
|
* 一次性运行外部命令,收集有限输出并支持协作式取消与超时回收。
|
|
178
|
+
* 实现委托给独立持有的一次性 run 执行器,不触碰受管进程注册表。
|
|
184
179
|
*/
|
|
185
180
|
run(owner: ProcessOwner, input: ProcessRunInput, call?: CallOptions): Promise<ProcessRunResult>;
|
|
186
|
-
/**
|
|
187
|
-
* 授予指定受管进程控制令牌。
|
|
188
|
-
*/
|
|
189
|
-
private grantControl;
|
|
190
|
-
/**
|
|
191
|
-
* 控制权到期未释放时自动转为隔离状态。
|
|
192
|
-
*/
|
|
193
|
-
private handleGrantTtlExpired;
|
|
194
|
-
/**
|
|
195
|
-
* 唤醒排队等待控制权的下一个调用者。
|
|
196
|
-
*/
|
|
197
|
-
private wakeNextAcquireWaiter;
|
|
198
|
-
/**
|
|
199
|
-
* 串行调度执行输入队列操作。
|
|
200
|
-
*/
|
|
201
|
-
private dispatchNext;
|
|
202
|
-
/**
|
|
203
|
-
* 操作提交前校验持有者令牌与授权。
|
|
204
|
-
*/
|
|
205
|
-
private checkOperationAuth;
|
|
206
181
|
/**
|
|
207
182
|
* 启动空闲超时定时器。
|
|
208
183
|
*/
|
|
@@ -239,26 +214,10 @@ export declare class ProcessManager {
|
|
|
239
214
|
* 加载或读取受管进程记录并校验所有者鉴权。
|
|
240
215
|
*/
|
|
241
216
|
private getOrLoadProcess;
|
|
242
|
-
/**
|
|
243
|
-
* 记录已淘汰输出日志的墓碑信息(保留最近 2048 条,防止内存无限积压)。
|
|
244
|
-
*/
|
|
245
|
-
private recordTombstone;
|
|
246
|
-
/**
|
|
247
|
-
* 清理已过期的终态输出日志条目。
|
|
248
|
-
*/
|
|
249
|
-
private cleanExpiredTerminalLogs;
|
|
250
217
|
/**
|
|
251
218
|
* 统计终态保留日志当前在内存中实际占用的输出缓冲字节总数。
|
|
252
219
|
*/
|
|
253
220
|
private countRetainedOutputBufferBytes;
|
|
254
|
-
/**
|
|
255
|
-
* 将终态输出日志存入保留缓存,并根据宿主配额执行 LRU 与 TTL 淘汰。
|
|
256
|
-
*/
|
|
257
|
-
private retainTerminalOutputLog;
|
|
258
|
-
/**
|
|
259
|
-
* 获取终态保留日志(附带过期清理与 LRU 触达更新)。
|
|
260
|
-
*/
|
|
261
|
-
private getRetainedOutputLog;
|
|
262
221
|
/**
|
|
263
222
|
* 终态驱逐与驱动释放:进程到达终态且输出已关闭后移除内存记录,
|
|
264
223
|
* 并防御性释放底层驱动句柄(失败仅记录诊断不中断)。
|