@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
@@ -0,0 +1,35 @@
1
+ /**
2
+ * 手写 SSE(Server-Sent Events)流解析器。
3
+ *
4
+ * 职责单一:将远端字节流增量解析为 SSE 消息,完整承载协议细节:
5
+ * - 跨 chunk 行分隔符缓冲(行尾 \r 需暂存等待下个 chunk 判定是否为 \r\n)
6
+ * - 兼容 \n、\r 与 \r\n 三种行分隔符
7
+ * - 冒号字段解析(冒号后单空格剔除,其余空格原样保留)
8
+ * - 注释行(冒号开头)忽略与未知字段忽略
9
+ * - 多行 data 按换行拼接合并
10
+ * - 含空字符的非法事件标识忽略
11
+ * - 流结束时未以空行收尾的剩余事件兜底分发
12
+ *
13
+ * 本模块为纯流转换函数,不感知 HTTP 传输、候选路由与 ActionDock 事件语义,
14
+ * 可独立单测;底层流在提前退出(break/异常/中止)时防御性取消,避免连接泄漏。
15
+ */
16
+ /**
17
+ * SSE 消息解析结果。
18
+ */
19
+ export interface SseMessage {
20
+ /** 事件类型(未声明时缺省 message) */
21
+ event: string;
22
+ /** 事件标识(含空字符的非法标识会被忽略,保持 undefined) */
23
+ id?: string;
24
+ /** 多行 data 按换行拼接后的完整数据载荷 */
25
+ data: string;
26
+ }
27
+ /**
28
+ * 将 SSE 字节流增量解析为 SSE 消息。
29
+ *
30
+ * @param body 远端响应字节流
31
+ * @param options.signal 外部取消信号:中止后立即停止读取,不进行剩余事件兜底分发
32
+ */
33
+ export declare function parseSseMessages(body: ReadableStream<Uint8Array>, options?: {
34
+ signal?: AbortSignal;
35
+ }): AsyncGenerator<SseMessage>;
@@ -0,0 +1,163 @@
1
+ /**
2
+ * 手写 SSE(Server-Sent Events)流解析器。
3
+ *
4
+ * 职责单一:将远端字节流增量解析为 SSE 消息,完整承载协议细节:
5
+ * - 跨 chunk 行分隔符缓冲(行尾 \r 需暂存等待下个 chunk 判定是否为 \r\n)
6
+ * - 兼容 \n、\r 与 \r\n 三种行分隔符
7
+ * - 冒号字段解析(冒号后单空格剔除,其余空格原样保留)
8
+ * - 注释行(冒号开头)忽略与未知字段忽略
9
+ * - 多行 data 按换行拼接合并
10
+ * - 含空字符的非法事件标识忽略
11
+ * - 流结束时未以空行收尾的剩余事件兜底分发
12
+ *
13
+ * 本模块为纯流转换函数,不感知 HTTP 传输、候选路由与 ActionDock 事件语义,
14
+ * 可独立单测;底层流在提前退出(break/异常/中止)时防御性取消,避免连接泄漏。
15
+ */
16
+ /**
17
+ * 将 SSE 字节流增量解析为 SSE 消息。
18
+ *
19
+ * @param body 远端响应字节流
20
+ * @param options.signal 外部取消信号:中止后立即停止读取,不进行剩余事件兜底分发
21
+ */
22
+ export async function* parseSseMessages(body, options) {
23
+ const reader = body.getReader();
24
+ const decoder = new TextDecoder();
25
+ let buffer = "";
26
+ let eventType = "message";
27
+ let eventId;
28
+ let dataLines = [];
29
+ function dispatchCurrentEvent() {
30
+ if (dataLines.length === 0) {
31
+ eventType = "message";
32
+ eventId = undefined;
33
+ dataLines = [];
34
+ return undefined;
35
+ }
36
+ const dataStr = dataLines.join("\n");
37
+ const currentType = eventType;
38
+ const currentId = eventId;
39
+ eventType = "message";
40
+ eventId = undefined;
41
+ dataLines = [];
42
+ if (!dataStr) {
43
+ return undefined;
44
+ }
45
+ return {
46
+ event: currentType,
47
+ id: currentId,
48
+ data: dataStr,
49
+ };
50
+ }
51
+ function processLine(line) {
52
+ // 遇到空行分发事件
53
+ if (line === "") {
54
+ return dispatchCurrentEvent();
55
+ }
56
+ // 以冒号开头的为注释忽略
57
+ if (line.startsWith(":")) {
58
+ return undefined;
59
+ }
60
+ let field = line;
61
+ let value = "";
62
+ const colonIdx = line.indexOf(":");
63
+ if (colonIdx !== -1) {
64
+ field = line.slice(0, colonIdx);
65
+ const rawVal = line.slice(colonIdx + 1);
66
+ value = rawVal.startsWith(" ") ? rawVal.slice(1) : rawVal;
67
+ }
68
+ if (field === "event") {
69
+ eventType = value;
70
+ }
71
+ else if (field === "data") {
72
+ dataLines.push(value);
73
+ }
74
+ else if (field === "id") {
75
+ if (!value.includes("\0")) {
76
+ eventId = value;
77
+ }
78
+ }
79
+ return undefined;
80
+ }
81
+ try {
82
+ while (true) {
83
+ if (options?.signal?.aborted)
84
+ break;
85
+ const { done, value } = await reader.read();
86
+ if (value) {
87
+ buffer += decoder.decode(value, { stream: !done });
88
+ }
89
+ else if (done) {
90
+ buffer += decoder.decode();
91
+ }
92
+ let pos = 0;
93
+ while (pos < buffer.length) {
94
+ const cr = buffer.indexOf("\r", pos);
95
+ const lf = buffer.indexOf("\n", pos);
96
+ let nextSepPos = -1;
97
+ let sepLen = 0;
98
+ if (cr !== -1 && (lf === -1 || cr < lf)) {
99
+ if (cr === buffer.length - 1) {
100
+ if (!done) {
101
+ // 遇到未完结的 \r 暂存等待下个 chunk
102
+ break;
103
+ }
104
+ else {
105
+ nextSepPos = cr;
106
+ sepLen = 1;
107
+ }
108
+ }
109
+ else {
110
+ if (buffer[cr + 1] === "\n") {
111
+ nextSepPos = cr;
112
+ sepLen = 2;
113
+ }
114
+ else {
115
+ nextSepPos = cr;
116
+ sepLen = 1;
117
+ }
118
+ }
119
+ }
120
+ else if (lf !== -1 && (cr === -1 || lf < cr)) {
121
+ nextSepPos = lf;
122
+ sepLen = 1;
123
+ }
124
+ else {
125
+ break;
126
+ }
127
+ const line = buffer.slice(pos, nextSepPos);
128
+ pos = nextSepPos + sepLen;
129
+ const evt = processLine(line);
130
+ if (evt)
131
+ yield evt;
132
+ }
133
+ buffer = buffer.slice(pos);
134
+ if (done) {
135
+ if (buffer.length > 0) {
136
+ const line = buffer;
137
+ buffer = "";
138
+ const evt = processLine(line);
139
+ if (evt)
140
+ yield evt;
141
+ }
142
+ // 流读取完成时若有剩余待分发事件则进行分发
143
+ const remainingEvt = dispatchCurrentEvent();
144
+ if (remainingEvt)
145
+ yield remainingEvt;
146
+ break;
147
+ }
148
+ }
149
+ }
150
+ finally {
151
+ // 防御性取消底层流:仅 releaseLock 会让连接保持挂起,造成连接泄漏
152
+ try {
153
+ await reader.cancel();
154
+ }
155
+ catch {
156
+ // 流已自然结束或已被取消时忽略次级异常
157
+ }
158
+ try {
159
+ reader.releaseLock();
160
+ }
161
+ catch { }
162
+ }
163
+ }
@@ -29,6 +29,8 @@ export async function createActionDockTarget(options = {}) {
29
29
  const host = await createActionDockHost({
30
30
  scanLinkedPackages: localOpts.scanLinkedPackages ?? true,
31
31
  ...localOpts,
32
+ // CLI 查询命令缺省旁观打开;显式声明 recoverOrphans 的执行命令透传持有者语义
33
+ recoverOrphans: localOpts.recoverOrphans === true,
32
34
  ...(localOpts.hostOptions || {}),
33
35
  });
34
36
  return new LocalActionDockTarget(host);
@@ -202,6 +202,12 @@ export interface LocalTargetOptions {
202
202
  scanLinkedPackages?: boolean;
203
203
  /** 运行时平台适配 */
204
204
  platform?: RuntimePlatform;
205
+ /**
206
+ * 是否以数据目录持有者身份打开本地存储:true 时 App 存储在打开阶段收割
207
+ * 遗留非终态运行记录。默认 false(旁观查询语义),供 CLI 查询命令与
208
+ * 运行中的 serve 进程并发访问同一库文件。
209
+ */
210
+ recoverOrphans?: boolean;
205
211
  }
206
212
  /**
207
213
  * 远程 Target 初始化选项。
@@ -1,3 +1,4 @@
1
+ export { isLoopbackHost } from "./net.js";
1
2
  /**
2
3
  * 跨运行时安全查找可执行文件绝对物理路径。
3
4
  *
@@ -1,6 +1,7 @@
1
1
  import { existsSync, realpathSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
4
+ export { isLoopbackHost } from "./net.js";
4
5
  /**
5
6
  * 跨运行时安全查找可执行文件绝对物理路径。
6
7
  *
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 检查指定的主机地址是否为本地回环接口(Loopback Host)。
3
+ * 支持 127.0.0.1, localhost, ::1 等形式。
4
+ *
5
+ * 本函数为跨域通用谓词单一事实源:客户端域(profile)与服务端域(server)
6
+ * 共同引用,故置于 utils 通用层;server/security.ts 保留 re-export 兼容旧引用路径。
7
+ *
8
+ * @param host 主机名或 IP 字符串
9
+ */
10
+ export declare function isLoopbackHost(host: string): boolean;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 检查指定的主机地址是否为本地回环接口(Loopback Host)。
3
+ * 支持 127.0.0.1, localhost, ::1 等形式。
4
+ *
5
+ * 本函数为跨域通用谓词单一事实源:客户端域(profile)与服务端域(server)
6
+ * 共同引用,故置于 utils 通用层;server/security.ts 保留 re-export 兼容旧引用路径。
7
+ *
8
+ * @param host 主机名或 IP 字符串
9
+ */
10
+ export function isLoopbackHost(host) {
11
+ const trimmed = host.trim().toLowerCase().replace(/^\[|\]$/g, "");
12
+ return (trimmed === "127.0.0.1" ||
13
+ trimmed === "::1" ||
14
+ trimmed === "localhost" ||
15
+ trimmed === "0:0:0:0:0:0:0:1");
16
+ }
package/dist/version.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * ActionDock 核心版本号单一事实源。
3
3
  */
4
- export declare const ACTIONDOCK_VERSION = "2.5.0";
4
+ export declare const ACTIONDOCK_VERSION = "2.6.0";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * ActionDock 核心版本号单一事实源。
3
3
  */
4
- export const ACTIONDOCK_VERSION = "2.5.0";
4
+ export const ACTIONDOCK_VERSION = "2.6.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actiondock/core",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "ActionDock Core Engine - Project loader, runtime execution, SQLite storage, standalone builder, and skill exporter",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -29,7 +29,7 @@
29
29
  "test": "node ../../scripts/run-tests.ts"
30
30
  },
31
31
  "dependencies": {
32
- "@actiondock/sdk": "^2.5.0",
32
+ "@actiondock/sdk": "^2.6.0",
33
33
  "ajv": "^8.17.1",
34
34
  "ajv-formats": "^3.0.1"
35
35
  },