@actiondock/core 2.0.11 → 2.2.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 (258) hide show
  1. package/README.md +61 -30
  2. package/dist/app/app.d.ts +73 -0
  3. package/dist/app/app.js +700 -0
  4. package/dist/app/index.d.ts +2 -0
  5. package/dist/app/index.js +2 -0
  6. package/dist/app/types.d.ts +283 -0
  7. package/dist/app/types.js +1 -0
  8. package/dist/catalog/action-index.d.ts +9 -0
  9. package/dist/catalog/action-index.js +93 -0
  10. package/dist/catalog/action-resolver.d.ts +20 -0
  11. package/dist/catalog/action-resolver.js +95 -0
  12. package/dist/catalog/index.d.ts +5 -0
  13. package/dist/catalog/index.js +5 -0
  14. package/dist/catalog/location-registry.d.ts +15 -0
  15. package/dist/catalog/location-registry.js +138 -0
  16. package/dist/catalog/package-catalog.d.ts +7 -0
  17. package/dist/catalog/package-catalog.js +76 -0
  18. package/dist/catalog/types.d.ts +68 -0
  19. package/dist/catalog/types.js +1 -0
  20. package/dist/doctor/doctor.d.ts +7 -0
  21. package/dist/doctor/doctor.js +613 -0
  22. package/dist/doctor/index.d.ts +2 -0
  23. package/dist/doctor/index.js +2 -0
  24. package/dist/doctor/types.d.ts +23 -0
  25. package/dist/doctor/types.js +1 -0
  26. package/dist/errors.d.ts +122 -0
  27. package/dist/errors.js +123 -0
  28. package/dist/execution/index.d.ts +2 -0
  29. package/dist/execution/index.js +2 -0
  30. package/dist/execution/service.d.ts +79 -0
  31. package/dist/execution/service.js +633 -0
  32. package/dist/execution/types.d.ts +131 -0
  33. package/dist/execution/types.js +1 -0
  34. package/dist/export/index.d.ts +1 -0
  35. package/dist/export/index.js +1 -0
  36. package/dist/export/templates.d.ts +71 -0
  37. package/dist/export/templates.js +621 -0
  38. package/dist/filter/index.d.ts +1 -0
  39. package/dist/filter/index.js +1 -0
  40. package/dist/filter/intent.d.ts +33 -0
  41. package/dist/filter/intent.js +123 -0
  42. package/dist/host/host.d.ts +55 -0
  43. package/dist/host/host.js +740 -0
  44. package/dist/host/index.d.ts +2 -0
  45. package/dist/host/index.js +2 -0
  46. package/dist/host/types.d.ts +81 -0
  47. package/dist/host/types.js +1 -0
  48. package/dist/index.d.ts +21 -0
  49. package/dist/index.js +20 -0
  50. package/dist/ipc/diagnostic.d.ts +65 -0
  51. package/dist/ipc/diagnostic.js +129 -0
  52. package/dist/ipc/host.d.ts +7 -0
  53. package/dist/ipc/host.js +93 -0
  54. package/dist/ipc/index.d.ts +4 -0
  55. package/dist/ipc/index.js +4 -0
  56. package/dist/ipc/target.d.ts +56 -0
  57. package/dist/ipc/target.js +297 -0
  58. package/dist/ipc/types.d.ts +42 -0
  59. package/dist/ipc/types.js +1 -0
  60. package/dist/platform/default.d.ts +32 -0
  61. package/dist/platform/default.js +40 -0
  62. package/dist/platform/index.d.ts +3 -0
  63. package/dist/platform/index.js +3 -0
  64. package/dist/platform/node-fs.d.ts +37 -0
  65. package/dist/platform/node-fs.js +81 -0
  66. package/dist/platform/types.d.ts +104 -0
  67. package/dist/platform/types.js +1 -0
  68. package/dist/profile/client.d.ts +162 -0
  69. package/dist/profile/client.js +467 -0
  70. package/dist/profile/index.d.ts +3 -0
  71. package/dist/profile/index.js +3 -0
  72. package/dist/profile/manager.d.ts +47 -0
  73. package/dist/profile/manager.js +294 -0
  74. package/dist/profile/types.d.ts +61 -0
  75. package/dist/profile/types.js +1 -0
  76. package/dist/project/closure.d.ts +25 -0
  77. package/dist/project/closure.js +68 -0
  78. package/dist/project/digest.d.ts +29 -0
  79. package/dist/project/digest.js +324 -0
  80. package/dist/project/index.d.ts +10 -0
  81. package/dist/project/index.js +10 -0
  82. package/dist/project/init.d.ts +26 -0
  83. package/dist/project/init.js +175 -0
  84. package/dist/project/loader.d.ts +99 -0
  85. package/dist/project/loader.js +484 -0
  86. package/dist/project/lockfile.d.ts +55 -0
  87. package/dist/project/lockfile.js +175 -0
  88. package/dist/project/manifest.d.ts +22 -0
  89. package/dist/project/manifest.js +220 -0
  90. package/dist/project/resolver.d.ts +116 -0
  91. package/dist/project/resolver.js +376 -0
  92. package/dist/project/transactions.d.ts +103 -0
  93. package/dist/project/transactions.js +1203 -0
  94. package/dist/project/types-generator.d.ts +33 -0
  95. package/dist/project/types-generator.js +168 -0
  96. package/dist/project/types.d.ts +107 -0
  97. package/dist/project/types.js +1 -0
  98. package/dist/registry/index.d.ts +5 -0
  99. package/dist/registry/index.js +5 -0
  100. package/dist/registry/lock.d.ts +27 -0
  101. package/dist/registry/lock.js +93 -0
  102. package/dist/registry/registry.d.ts +45 -0
  103. package/dist/registry/registry.js +611 -0
  104. package/dist/registry/resolve.d.ts +62 -0
  105. package/dist/registry/resolve.js +195 -0
  106. package/dist/registry/scan.d.ts +38 -0
  107. package/dist/registry/scan.js +135 -0
  108. package/dist/registry/types.d.ts +117 -0
  109. package/dist/registry/types.js +1 -0
  110. package/dist/runtime/action-collection.d.ts +27 -0
  111. package/dist/runtime/action-collection.js +57 -0
  112. package/dist/runtime/clock.d.ts +19 -0
  113. package/dist/runtime/clock.js +17 -0
  114. package/dist/runtime/context.d.ts +86 -0
  115. package/dist/runtime/context.js +242 -0
  116. package/dist/runtime/env.d.ts +56 -0
  117. package/dist/runtime/env.js +159 -0
  118. package/dist/runtime/events.d.ts +93 -0
  119. package/dist/runtime/events.js +604 -0
  120. package/dist/runtime/execution-manager.d.ts +48 -0
  121. package/dist/runtime/execution-manager.js +66 -0
  122. package/dist/runtime/index.d.ts +10 -0
  123. package/dist/runtime/index.js +10 -0
  124. package/dist/runtime/module-loader.d.ts +34 -0
  125. package/dist/runtime/module-loader.js +16 -0
  126. package/dist/runtime/process.d.ts +9 -0
  127. package/dist/runtime/process.js +146 -0
  128. package/dist/runtime/runner.d.ts +293 -0
  129. package/dist/runtime/runner.js +984 -0
  130. package/dist/runtime/standalone.d.ts +89 -0
  131. package/dist/runtime/standalone.js +536 -0
  132. package/dist/schema/validator.d.ts +28 -0
  133. package/dist/schema/validator.js +116 -0
  134. package/dist/server/body.d.ts +40 -0
  135. package/dist/server/body.js +93 -0
  136. package/dist/server/index.d.ts +5 -0
  137. package/dist/server/index.js +5 -0
  138. package/dist/server/routes/actions.d.ts +5 -0
  139. package/dist/server/routes/actions.js +298 -0
  140. package/dist/server/routes/common.d.ts +47 -0
  141. package/dist/server/routes/common.js +104 -0
  142. package/dist/server/routes/config.d.ts +6 -0
  143. package/dist/server/routes/config.js +173 -0
  144. package/dist/server/routes/doctor.d.ts +5 -0
  145. package/dist/server/routes/doctor.js +63 -0
  146. package/dist/server/routes/health.d.ts +5 -0
  147. package/dist/server/routes/health.js +35 -0
  148. package/dist/server/routes/index.d.ts +9 -0
  149. package/dist/server/routes/index.js +9 -0
  150. package/dist/server/routes/info.d.ts +7 -0
  151. package/dist/server/routes/info.js +158 -0
  152. package/dist/server/routes/playbooks.d.ts +5 -0
  153. package/dist/server/routes/playbooks.js +134 -0
  154. package/dist/server/routes/runs.d.ts +5 -0
  155. package/dist/server/routes/runs.js +343 -0
  156. package/dist/server/routes/state.d.ts +6 -0
  157. package/dist/server/routes/state.js +169 -0
  158. package/dist/server/security.d.ts +44 -0
  159. package/dist/server/security.js +101 -0
  160. package/dist/server/server.d.ts +15 -0
  161. package/dist/server/server.js +355 -0
  162. package/dist/server/types.d.ts +78 -0
  163. package/dist/server/types.js +1 -0
  164. package/dist/storage/data-dir-lock.d.ts +119 -0
  165. package/dist/storage/data-dir-lock.js +1016 -0
  166. package/dist/storage/driver.d.ts +9 -0
  167. package/dist/storage/driver.js +59 -0
  168. package/dist/storage/index.d.ts +64 -0
  169. package/dist/storage/index.js +98 -0
  170. package/dist/storage/lazy.d.ts +8 -0
  171. package/dist/storage/lazy.js +44 -0
  172. package/dist/storage/mask.d.ts +26 -0
  173. package/dist/storage/mask.js +48 -0
  174. package/dist/storage/params.d.ts +13 -0
  175. package/dist/storage/params.js +32 -0
  176. package/dist/storage/sqlite.d.ts +79 -0
  177. package/dist/storage/sqlite.js +689 -0
  178. package/dist/storage/types.d.ts +172 -0
  179. package/dist/storage/types.js +14 -0
  180. package/dist/target/index.d.ts +4 -0
  181. package/dist/target/index.js +4 -0
  182. package/dist/target/local.d.ts +52 -0
  183. package/dist/target/local.js +343 -0
  184. package/dist/target/remote.d.ts +76 -0
  185. package/dist/target/remote.js +839 -0
  186. package/dist/target/target.d.ts +6 -0
  187. package/dist/target/target.js +35 -0
  188. package/dist/target/types.d.ts +246 -0
  189. package/dist/target/types.js +34 -0
  190. package/dist/utils/index.d.ts +49 -0
  191. package/dist/utils/index.js +180 -0
  192. package/dist/version.d.ts +4 -0
  193. package/dist/version.js +4 -0
  194. package/package.json +13 -13
  195. package/src/build/index.ts +0 -1
  196. package/src/build/templates.ts +0 -59
  197. package/src/catalog/action-index.ts +0 -92
  198. package/src/catalog/action-resolver.ts +0 -120
  199. package/src/catalog/index.ts +0 -5
  200. package/src/catalog/location-registry.ts +0 -134
  201. package/src/catalog/package-catalog.ts +0 -87
  202. package/src/catalog/types.ts +0 -75
  203. package/src/doctor/doctor.ts +0 -419
  204. package/src/doctor/index.ts +0 -2
  205. package/src/doctor/types.ts +0 -25
  206. package/src/execution/index.ts +0 -2
  207. package/src/execution/service.ts +0 -322
  208. package/src/execution/types.ts +0 -73
  209. package/src/export/index.ts +0 -1
  210. package/src/export/templates.ts +0 -590
  211. package/src/filter/index.ts +0 -1
  212. package/src/filter/intent.ts +0 -154
  213. package/src/index.ts +0 -16
  214. package/src/profile/client.ts +0 -552
  215. package/src/profile/index.ts +0 -3
  216. package/src/profile/manager.ts +0 -341
  217. package/src/profile/types.ts +0 -71
  218. package/src/project/index.ts +0 -4
  219. package/src/project/init.ts +0 -242
  220. package/src/project/loader.ts +0 -479
  221. package/src/project/manifest.ts +0 -299
  222. package/src/project/types.ts +0 -141
  223. package/src/registry/index.ts +0 -2
  224. package/src/registry/registry.ts +0 -940
  225. package/src/registry/types.ts +0 -127
  226. package/src/runtime/clock.ts +0 -41
  227. package/src/runtime/context.ts +0 -259
  228. package/src/runtime/env.ts +0 -172
  229. package/src/runtime/events.ts +0 -142
  230. package/src/runtime/execution-manager.ts +0 -74
  231. package/src/runtime/index.ts +0 -10
  232. package/src/runtime/module-loader.ts +0 -67
  233. package/src/runtime/process.ts +0 -245
  234. package/src/runtime/runner.ts +0 -527
  235. package/src/runtime/standalone.ts +0 -429
  236. package/src/schema/validator.ts +0 -61
  237. package/src/server/body.ts +0 -112
  238. package/src/server/index.ts +0 -7
  239. package/src/server/routes/actions.ts +0 -262
  240. package/src/server/routes/common.ts +0 -126
  241. package/src/server/routes/config.ts +0 -147
  242. package/src/server/routes/doctor.ts +0 -29
  243. package/src/server/routes/health.ts +0 -40
  244. package/src/server/routes/index.ts +0 -9
  245. package/src/server/routes/info.ts +0 -221
  246. package/src/server/routes/playbooks.ts +0 -109
  247. package/src/server/routes/runs.ts +0 -301
  248. package/src/server/routes/state.ts +0 -133
  249. package/src/server/runtime-registry.ts +0 -115
  250. package/src/server/security.ts +0 -115
  251. package/src/server/server.ts +0 -251
  252. package/src/server/types.ts +0 -57
  253. package/src/storage/driver.ts +0 -126
  254. package/src/storage/index.ts +0 -81
  255. package/src/storage/mask.ts +0 -34
  256. package/src/storage/sqlite.ts +0 -714
  257. package/src/storage/types.ts +0 -139
  258. package/src/utils/index.ts +0 -62
@@ -0,0 +1,123 @@
1
+ /**
2
+ * 安全地将模式字符串、数组或现有正则编译为不区分大小写的 RegExp 正则表达式。
3
+ * 若正则语法不合法,自动对特殊字符进行转义并降级为字面量匹配正则,保证零 Crash。
4
+ *
5
+ * @param intent 意图关键词、正则或数组
6
+ */
7
+ export function compileIntentRegex(intent) {
8
+ if (!intent)
9
+ return null;
10
+ if (intent instanceof RegExp)
11
+ return intent;
12
+ let patternStr;
13
+ if (Array.isArray(intent)) {
14
+ const valid = intent.map((s) => s.trim()).filter(Boolean);
15
+ if (valid.length === 0)
16
+ return null;
17
+ patternStr = valid.join("|");
18
+ }
19
+ else {
20
+ patternStr = intent.trim();
21
+ if (!patternStr)
22
+ return null;
23
+ }
24
+ try {
25
+ return new RegExp(patternStr, "i");
26
+ }
27
+ catch {
28
+ const escaped = patternStr.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
29
+ return new RegExp(escaped, "i");
30
+ }
31
+ }
32
+ /**
33
+ * 递归检查某个值(包括嵌套的数组或对象结构)是否匹配给定的正则表达式。
34
+ *
35
+ * @param value 待检测的任意数据类型
36
+ * @param regex 正则表达式
37
+ */
38
+ export function matchIntent(value, regex) {
39
+ if (value === undefined || value === null)
40
+ return false;
41
+ if (typeof value === "string") {
42
+ return regex.test(value);
43
+ }
44
+ if (typeof value === "number" || typeof value === "boolean") {
45
+ return regex.test(String(value));
46
+ }
47
+ if (Array.isArray(value)) {
48
+ for (const elem of value) {
49
+ if (matchIntent(elem, regex))
50
+ return true;
51
+ }
52
+ return false;
53
+ }
54
+ if (typeof value === "object") {
55
+ try {
56
+ return regex.test(JSON.stringify(value));
57
+ }
58
+ catch {
59
+ return false;
60
+ }
61
+ }
62
+ return false;
63
+ }
64
+ /**
65
+ * Filters a collection of items based on an intent pattern across specified extractor functions.
66
+ * Returns detailed result including whether a fallback was triggered when 0 items matched.
67
+ */
68
+ export function filterWithFallbackInfo(items, intent, extractors, fallback = true) {
69
+ if (!intent) {
70
+ return {
71
+ items,
72
+ isFallback: false,
73
+ matchedCount: items.length,
74
+ };
75
+ }
76
+ const regex = compileIntentRegex(intent);
77
+ if (!regex) {
78
+ return {
79
+ items,
80
+ isFallback: false,
81
+ matchedCount: items.length,
82
+ };
83
+ }
84
+ const defaultExtractors = [
85
+ (item) => typeof item === "string"
86
+ ? item
87
+ : item?.id || item?.name || item?.key || String(item),
88
+ ];
89
+ const effectiveExtractors = extractors && extractors.length > 0 ? extractors : defaultExtractors;
90
+ const matched = items.filter((item) => {
91
+ for (const extractor of effectiveExtractors) {
92
+ try {
93
+ const val = extractor(item);
94
+ if (matchIntent(val, regex)) {
95
+ return true;
96
+ }
97
+ }
98
+ catch {
99
+ // Ignore extraction error
100
+ }
101
+ }
102
+ return false;
103
+ });
104
+ if (matched.length === 0 && fallback) {
105
+ return {
106
+ items,
107
+ isFallback: true,
108
+ matchedCount: 0,
109
+ };
110
+ }
111
+ return {
112
+ items: matched,
113
+ isFallback: false,
114
+ matchedCount: matched.length,
115
+ };
116
+ }
117
+ /**
118
+ * Filters a collection of items based on an intent pattern across specified extractor functions.
119
+ * When fallback is enabled (default), returns the full list if no items match the intent.
120
+ */
121
+ export function filterByIntent(items, intent, extractors, fallback = true) {
122
+ return filterWithFallbackInfo(items, intent, extractors, fallback).items;
123
+ }
@@ -0,0 +1,55 @@
1
+ import type { ActionRef, ExecutionEvent, ExecutionResult, JsonValue, RunRecord } from "@actiondock/sdk";
2
+ import type { ActionDockApp, ActionSpec, ActionSummary, ListActionsOptions, PackageInfo, PlaybookSpec, PlaybookSummary } from "../app/types.js";
3
+ import type { CancelResult, ExecuteOptions, ExecutionTicket } from "../execution/types.js";
4
+ import type { ActionDockHost, ActionDockHostOptions } from "./types.js";
5
+ /**
6
+ * ActionDock 统一多包宿主容器默认实现。
7
+ * 负责聚合与调度多个 ActionDockApp 实例,提供跨包引用路由、依赖声明校验与资源配额控制。
8
+ */
9
+ export declare class DefaultActionDockHost implements ActionDockHost {
10
+ readonly hostSessionId: string;
11
+ private apps;
12
+ private readonly internallyCreatedApps;
13
+ private activeSubRunsPerRoot;
14
+ private hostPublicPackageIds;
15
+ private resolver?;
16
+ private maxCallDepth;
17
+ private maxSubRuns;
18
+ private eventSink;
19
+ private isClosed;
20
+ private dataDirLock?;
21
+ private failedLinkedPackages;
22
+ constructor(options?: ActionDockHostOptions);
23
+ private resolvePackageContext;
24
+ private bindApp;
25
+ getApp(packageId: string): ActionDockApp | undefined;
26
+ listApps(): ActionDockApp[];
27
+ private registerAppInternal;
28
+ registerApp(app: ActionDockApp): void;
29
+ info(): Promise<PackageInfo[]>;
30
+ listActions(options?: ListActionsOptions): Promise<ActionSummary[]>;
31
+ describeAction(ref: ActionRef | string): Promise<ActionSpec>;
32
+ listPlaybooks(): Promise<PlaybookSummary[]>;
33
+ describePlaybook(id: string): Promise<PlaybookSpec>;
34
+ runAction(ref: ActionRef | string, input: JsonValue, options?: ExecuteOptions): Promise<ExecutionResult>;
35
+ startAction(ref: ActionRef | string, input: JsonValue, options?: ExecuteOptions): Promise<ExecutionTicket>;
36
+ getRun(runId: string): Promise<RunRecord | undefined>;
37
+ cancelRun(runId: string, reason?: string): Promise<CancelResult>;
38
+ events(runId: string, options?: {
39
+ after?: number | string;
40
+ signal?: AbortSignal;
41
+ maxQueueSize?: number;
42
+ }): AsyncIterable<ExecutionEvent>;
43
+ /**
44
+ * 优雅关闭宿主容器。
45
+ * 仅对内部创建的 App 实例执行 close 并安全释放底层资源;
46
+ * 外部传入借用的 App 实例生命周期完全由调用方负责管理,Host 关闭时仅解绑引用并清理自身内部实例。
47
+ */
48
+ close(options?: {
49
+ graceMs?: number;
50
+ }): Promise<void>;
51
+ }
52
+ /**
53
+ * 工厂函数:创建并初始化 ActionDockHost 宿主容器。
54
+ */
55
+ export declare function createActionDockHost(options?: ActionDockHostOptions): Promise<ActionDockHost>;