@actiondock/core 2.0.11 → 2.0.12
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/build/templates.d.ts +19 -0
- package/dist/catalog/action-index.d.ts +9 -0
- package/dist/catalog/action-resolver.d.ts +20 -0
- package/dist/catalog/location-registry.d.ts +15 -0
- package/dist/catalog/package-catalog.d.ts +7 -0
- package/dist/catalog/types.d.ts +68 -0
- package/dist/doctor/doctor.d.ts +6 -0
- package/dist/doctor/types.d.ts +23 -0
- package/dist/execution/index.d.ts +2 -0
- package/dist/execution/service.d.ts +74 -0
- package/dist/execution/types.d.ts +74 -0
- package/dist/export/templates.d.ts +33 -0
- package/dist/filter/intent.d.ts +33 -0
- package/{src/index.ts → dist/index.d.ts} +1 -1
- package/dist/index.js +8458 -0
- package/dist/profile/client.d.ts +116 -0
- package/dist/profile/manager.d.ts +47 -0
- package/dist/profile/types.d.ts +61 -0
- package/dist/project/closure.d.ts +25 -0
- package/{src/project/index.ts → dist/project/index.d.ts} +1 -0
- package/dist/project/init.d.ts +27 -0
- package/dist/project/loader.d.ts +105 -0
- package/dist/project/manifest.d.ts +44 -0
- package/dist/project/types.d.ts +131 -0
- package/dist/registry/registry.d.ts +24 -0
- package/dist/registry/types.d.ts +117 -0
- package/dist/runtime/clock.d.ts +21 -0
- package/dist/runtime/context.d.ts +75 -0
- package/dist/runtime/env.d.ts +54 -0
- package/dist/runtime/events.d.ts +61 -0
- package/dist/runtime/execution-manager.d.ts +48 -0
- package/{src/runtime/index.ts → dist/runtime/index.d.ts} +0 -1
- package/dist/runtime/module-loader.d.ts +42 -0
- package/dist/runtime/process.d.ts +11 -0
- package/dist/runtime/runner.d.ts +186 -0
- package/dist/runtime/standalone.d.ts +40 -0
- package/dist/schema/validator.d.ts +28 -0
- package/dist/server/body.d.ts +40 -0
- package/{src/server/index.ts → dist/server/index.d.ts} +0 -1
- package/dist/server/routes/actions.d.ts +5 -0
- package/dist/server/routes/common.d.ts +36 -0
- package/dist/server/routes/config.d.ts +5 -0
- package/dist/server/routes/doctor.d.ts +5 -0
- package/dist/server/routes/health.d.ts +5 -0
- package/dist/server/routes/info.d.ts +5 -0
- package/dist/server/routes/playbooks.d.ts +5 -0
- package/dist/server/routes/runs.d.ts +5 -0
- package/dist/server/routes/state.d.ts +5 -0
- package/dist/server/runtime-registry.d.ts +78 -0
- package/dist/server/security.d.ts +37 -0
- package/dist/server/server.d.ts +15 -0
- package/dist/server/types.d.ts +59 -0
- package/dist/storage/driver.d.ts +15 -0
- package/dist/storage/index.d.ts +44 -0
- package/{src/storage/mask.ts → dist/storage/mask.d.ts} +5 -20
- package/dist/storage/sqlite.d.ts +66 -0
- package/dist/storage/types.d.ts +121 -0
- package/dist/utils/index.d.ts +29 -0
- package/dist/version.d.ts +4 -0
- package/package.json +11 -10
- package/src/build/templates.ts +0 -59
- package/src/catalog/action-index.ts +0 -92
- package/src/catalog/action-resolver.ts +0 -120
- package/src/catalog/location-registry.ts +0 -134
- package/src/catalog/package-catalog.ts +0 -87
- package/src/catalog/types.ts +0 -75
- package/src/doctor/doctor.ts +0 -419
- package/src/doctor/types.ts +0 -25
- package/src/execution/index.ts +0 -2
- package/src/execution/service.ts +0 -322
- package/src/execution/types.ts +0 -73
- package/src/export/templates.ts +0 -590
- package/src/filter/intent.ts +0 -154
- package/src/profile/client.ts +0 -552
- package/src/profile/manager.ts +0 -341
- package/src/profile/types.ts +0 -71
- package/src/project/init.ts +0 -242
- package/src/project/loader.ts +0 -479
- package/src/project/manifest.ts +0 -299
- package/src/project/types.ts +0 -141
- package/src/registry/registry.ts +0 -940
- package/src/registry/types.ts +0 -127
- package/src/runtime/clock.ts +0 -41
- package/src/runtime/context.ts +0 -259
- package/src/runtime/env.ts +0 -172
- package/src/runtime/events.ts +0 -142
- package/src/runtime/execution-manager.ts +0 -74
- package/src/runtime/module-loader.ts +0 -67
- package/src/runtime/process.ts +0 -245
- package/src/runtime/runner.ts +0 -527
- package/src/runtime/standalone.ts +0 -429
- package/src/schema/validator.ts +0 -61
- package/src/server/body.ts +0 -112
- package/src/server/routes/actions.ts +0 -262
- package/src/server/routes/common.ts +0 -126
- package/src/server/routes/config.ts +0 -147
- package/src/server/routes/doctor.ts +0 -29
- package/src/server/routes/health.ts +0 -40
- package/src/server/routes/info.ts +0 -221
- package/src/server/routes/playbooks.ts +0 -109
- package/src/server/routes/runs.ts +0 -301
- package/src/server/routes/state.ts +0 -133
- package/src/server/runtime-registry.ts +0 -115
- package/src/server/security.ts +0 -115
- package/src/server/server.ts +0 -251
- package/src/server/types.ts +0 -57
- package/src/storage/driver.ts +0 -126
- package/src/storage/index.ts +0 -81
- package/src/storage/sqlite.ts +0 -714
- package/src/storage/types.ts +0 -139
- package/src/utils/index.ts +0 -62
- /package/{src/build/index.ts → dist/build/index.d.ts} +0 -0
- /package/{src/catalog/index.ts → dist/catalog/index.d.ts} +0 -0
- /package/{src/doctor/index.ts → dist/doctor/index.d.ts} +0 -0
- /package/{src/export/index.ts → dist/export/index.d.ts} +0 -0
- /package/{src/filter/index.ts → dist/filter/index.d.ts} +0 -0
- /package/{src/profile/index.ts → dist/profile/index.d.ts} +0 -0
- /package/{src/registry/index.ts → dist/registry/index.d.ts} +0 -0
- /package/{src/server/routes/index.ts → dist/server/routes/index.d.ts} +0 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { ExecutionResult, RunRecord } from "@actiondock/sdk";
|
|
2
|
+
import type { RemoteHealthResult } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* 调用远端 ActionDock 服务端执行 Action 时的选项参数。
|
|
5
|
+
*/
|
|
6
|
+
export interface RemoteExecuteOptions {
|
|
7
|
+
/** 动态配置覆盖 */
|
|
8
|
+
configOverrides?: Record<string, unknown>;
|
|
9
|
+
/** 鉴权 Bearer Token */
|
|
10
|
+
token?: string;
|
|
11
|
+
/** 超时毫秒数 */
|
|
12
|
+
timeoutMs?: number;
|
|
13
|
+
/** 中断信号 */
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
/** 是否异步触发(202 Accepted 立即返回 runId) */
|
|
16
|
+
async?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 远端 Action 执行结果信封对象。
|
|
20
|
+
*/
|
|
21
|
+
export type RemoteExecutionResult<T = unknown> = ExecutionResult<T> & {
|
|
22
|
+
status?: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* 探测指定远端 ActionDock 服务的健康状态与网络延迟。
|
|
26
|
+
*
|
|
27
|
+
* @param serverUrl 目标服务端地址
|
|
28
|
+
* @param token 鉴权 Token(可选)
|
|
29
|
+
* @param timeoutMs 探测超时时间(默认 5000ms)
|
|
30
|
+
*/
|
|
31
|
+
export declare function checkRemoteHealth(serverUrl: string, token?: string, timeoutMs?: number): Promise<RemoteHealthResult>;
|
|
32
|
+
export declare function executeRemoteAction<T = unknown>(serverUrl: string, actionId: string, input?: unknown, configOverridesOrOptions?: Record<string, unknown> | RemoteExecuteOptions, tokenArg?: string): Promise<RemoteExecutionResult<T>>;
|
|
33
|
+
export declare function fetchRemoteRun(serverUrl: string, runId: string, token?: string): Promise<RunRecord>;
|
|
34
|
+
export declare function cancelRemoteRun(serverUrl: string, runId: string, token?: string, reason?: string): Promise<{
|
|
35
|
+
ok: boolean;
|
|
36
|
+
runId: string;
|
|
37
|
+
status: string;
|
|
38
|
+
}>;
|
|
39
|
+
export declare function fetchRemoteActions(serverUrl: string, token?: string, intent?: string): Promise<Array<{
|
|
40
|
+
id: string;
|
|
41
|
+
description: string;
|
|
42
|
+
packageId?: string;
|
|
43
|
+
}>>;
|
|
44
|
+
export declare function fetchRemoteActionShow(serverUrl: string, actionId: string, token?: string): Promise<any>;
|
|
45
|
+
export declare function fetchRemoteInfo(serverUrl: string, token?: string, options?: {
|
|
46
|
+
intent?: string;
|
|
47
|
+
package?: string;
|
|
48
|
+
tree?: boolean;
|
|
49
|
+
}): Promise<any>;
|
|
50
|
+
export declare function fetchRemoteDoctor(serverUrl: string, token?: string, targetPackage?: string): Promise<any>;
|
|
51
|
+
export declare function fetchRemotePlaybooks(serverUrl: string, token?: string, options?: {
|
|
52
|
+
intent?: string;
|
|
53
|
+
package?: string;
|
|
54
|
+
}): Promise<Array<{
|
|
55
|
+
id: string;
|
|
56
|
+
description: string;
|
|
57
|
+
actions: string[];
|
|
58
|
+
packageId: string;
|
|
59
|
+
filePath: string;
|
|
60
|
+
}>>;
|
|
61
|
+
export declare function fetchRemotePlaybookShow(serverUrl: string, playbookId: string, token?: string): Promise<any>;
|
|
62
|
+
export declare function fetchRemoteRuns(serverUrl: string, token?: string, options?: {
|
|
63
|
+
status?: string;
|
|
64
|
+
actionId?: string;
|
|
65
|
+
packageId?: string;
|
|
66
|
+
intent?: string;
|
|
67
|
+
limit?: number;
|
|
68
|
+
}): Promise<{
|
|
69
|
+
ok: boolean;
|
|
70
|
+
total: number;
|
|
71
|
+
items: RunRecord[];
|
|
72
|
+
}>;
|
|
73
|
+
export declare function clearRemoteRuns(serverUrl: string, token?: string, options?: {
|
|
74
|
+
packageId?: string;
|
|
75
|
+
actionId?: string;
|
|
76
|
+
status?: string;
|
|
77
|
+
}): Promise<{
|
|
78
|
+
ok: boolean;
|
|
79
|
+
clearedCount: number;
|
|
80
|
+
}>;
|
|
81
|
+
export declare function fetchRemoteStateList(serverUrl: string, token?: string, options?: {
|
|
82
|
+
package?: string;
|
|
83
|
+
namespace?: string;
|
|
84
|
+
prefix?: string;
|
|
85
|
+
}): Promise<{
|
|
86
|
+
ok: boolean;
|
|
87
|
+
packageId: string;
|
|
88
|
+
keys: string[];
|
|
89
|
+
}>;
|
|
90
|
+
export declare function getRemoteStateKey(serverUrl: string, key: string, token?: string, options?: {
|
|
91
|
+
package?: string;
|
|
92
|
+
namespace?: string;
|
|
93
|
+
}): Promise<any>;
|
|
94
|
+
export declare function setRemoteStateKey(serverUrl: string, key: string, value: unknown, token?: string, options?: {
|
|
95
|
+
package?: string;
|
|
96
|
+
namespace?: string;
|
|
97
|
+
ttl?: number;
|
|
98
|
+
}): Promise<any>;
|
|
99
|
+
export declare function deleteRemoteStateKey(serverUrl: string, key: string, token?: string, options?: {
|
|
100
|
+
package?: string;
|
|
101
|
+
namespace?: string;
|
|
102
|
+
}): Promise<any>;
|
|
103
|
+
export declare function clearRemoteState(serverUrl: string, token?: string, options?: {
|
|
104
|
+
package?: string;
|
|
105
|
+
namespace?: string;
|
|
106
|
+
prefix?: string;
|
|
107
|
+
all?: boolean;
|
|
108
|
+
}): Promise<{
|
|
109
|
+
ok: boolean;
|
|
110
|
+
packageId: string;
|
|
111
|
+
clearedCount: number;
|
|
112
|
+
}>;
|
|
113
|
+
export declare function fetchRemoteConfig(serverUrl: string, token?: string, packageId?: string): Promise<any>;
|
|
114
|
+
export declare function setRemoteConfig(serverUrl: string, key: string, value: unknown, token?: string, packageId?: string): Promise<any>;
|
|
115
|
+
export declare function deleteRemoteConfig(serverUrl: string, key: string, token?: string, packageId?: string): Promise<any>;
|
|
116
|
+
export declare function fetchRemoteConfigEnv(serverUrl: string, token?: string, packageId?: string): Promise<any>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ProfileEntry, ProfilesConfig, ResolvedTarget, TokenResolutionSource } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* 默认初始 Profiles 配置(预设 local 本地环境)。
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_PROFILES_CONFIG: ProfilesConfig;
|
|
6
|
+
/**
|
|
7
|
+
* 格式化并规范化 Server URL 地址(自动补齐 http:// 协议头并移除末尾斜杠)。
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeServerUrl(url: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* 获取 profiles.json 配置文件的物理绝对路径(~/.actiondock/profiles.json)。
|
|
12
|
+
*/
|
|
13
|
+
export declare function getProfilesFilePath(customHome?: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* 加载并读取 profiles.json 配置文件。
|
|
16
|
+
*/
|
|
17
|
+
export declare function loadProfiles(customHome?: string): ProfilesConfig;
|
|
18
|
+
/**
|
|
19
|
+
* 保存并写入 profiles.json 配置文件,并严格限制文件权限为 0600。
|
|
20
|
+
*/
|
|
21
|
+
export declare function saveProfiles(data: ProfilesConfig, customHome?: string): void;
|
|
22
|
+
export declare function addProfile(name: string, entry: ProfileEntry, customHome?: string): void;
|
|
23
|
+
export declare function removeProfile(name: string, customHome?: string): boolean;
|
|
24
|
+
export declare function useProfile(name: string, customHome?: string): void;
|
|
25
|
+
export declare function getProfile(name: string, customHome?: string): ProfileEntry | undefined;
|
|
26
|
+
export declare function listProfiles(customHome?: string): Array<{
|
|
27
|
+
name: string;
|
|
28
|
+
isCurrent: boolean;
|
|
29
|
+
entry: ProfileEntry;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Resolves token following multi-tier precedence:
|
|
33
|
+
* 1. CLI explicit --token
|
|
34
|
+
* 2. profile.tokenEnv specified environment variable
|
|
35
|
+
* 3. Derived profile environment variable: ACTIONDOCK_<PROFILE>_TOKEN or <PROFILE>_TOKEN
|
|
36
|
+
* 4. Stored token in profiles.json (deprecated)
|
|
37
|
+
* 5. Global ACTIONDOCK_TOKEN
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveProfileToken(profileName?: string, entry?: ProfileEntry, explicitToken?: string): {
|
|
40
|
+
token?: string;
|
|
41
|
+
source: TokenResolutionSource;
|
|
42
|
+
};
|
|
43
|
+
export declare function resolveTarget(options?: {
|
|
44
|
+
profile?: string;
|
|
45
|
+
server?: string;
|
|
46
|
+
token?: string;
|
|
47
|
+
}, customHome?: string): ResolvedTarget;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 单个远端配置环境(Profile)实体定义。
|
|
3
|
+
*/
|
|
4
|
+
export interface ProfileEntry {
|
|
5
|
+
/** 远端 ActionDock 服务端地址(如 "http://192.168.1.100:5177" 或 "local") */
|
|
6
|
+
serverUrl: string;
|
|
7
|
+
/**
|
|
8
|
+
* 存储在配置文件中的明文鉴权 Token。
|
|
9
|
+
* @deprecated 强烈建议使用 tokenEnv 或标准环境变量(如 ACTIONDOCK_<PROFILE>_TOKEN),避免明文持久化
|
|
10
|
+
*/
|
|
11
|
+
token?: string;
|
|
12
|
+
/** 指定从哪一个操作系统环境变量名动态读取 Token */
|
|
13
|
+
tokenEnv?: string;
|
|
14
|
+
/** 该机器/环境的描述信息 */
|
|
15
|
+
description?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 全局 profiles.json 配置文件结构契约。
|
|
19
|
+
*/
|
|
20
|
+
export interface ProfilesConfig {
|
|
21
|
+
/** 当前激活的默认 Profile 名称(默认为 "local") */
|
|
22
|
+
currentProfile?: string;
|
|
23
|
+
/** 已配置的 Profile 字典映射表 */
|
|
24
|
+
profiles: Record<string, ProfileEntry>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Token 解析命中来源枚举。
|
|
28
|
+
*/
|
|
29
|
+
export type TokenResolutionSource = "cli" | "tokenEnv" | "profileEnv" | "profile" | "globalEnv" | "none";
|
|
30
|
+
/**
|
|
31
|
+
* 经过解析后确定的最终执行目标环境。
|
|
32
|
+
*/
|
|
33
|
+
export interface ResolvedTarget {
|
|
34
|
+
/** 执行环境类型:local (本地 Bun 进程) 或 remote (远端 HTTP Server) */
|
|
35
|
+
type: "local" | "remote";
|
|
36
|
+
/** 命中的 Profile 名称 */
|
|
37
|
+
profileName?: string;
|
|
38
|
+
/** 远端 Server URL */
|
|
39
|
+
serverUrl?: string;
|
|
40
|
+
/** 解析出的有效鉴权 Token */
|
|
41
|
+
token?: string;
|
|
42
|
+
/** Token 数据来源 */
|
|
43
|
+
tokenSource?: TokenResolutionSource;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 远端服务器健康探测与时延检测结果。
|
|
47
|
+
*/
|
|
48
|
+
export interface RemoteHealthResult {
|
|
49
|
+
/** 服务端是否连通且鉴权成功 */
|
|
50
|
+
ok: boolean;
|
|
51
|
+
/** 服务端状态标识(如 "ok") */
|
|
52
|
+
status?: string;
|
|
53
|
+
/** 远端 ActionDock 版本号 */
|
|
54
|
+
version?: string;
|
|
55
|
+
/** 远端服务运行时间(秒) */
|
|
56
|
+
uptime?: number;
|
|
57
|
+
/** 网络往返延迟(毫秒) */
|
|
58
|
+
latencyMs: number;
|
|
59
|
+
/** 探测失败时的错误信息 */
|
|
60
|
+
error?: string;
|
|
61
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 声明的跨包依赖闭包,对涉及的每个项目包逐一执行依赖预装(ensureProjectDependencies)。
|
|
19
|
+
* 内部已尊重 ACTIONDOCK_AUTO_INSTALL=false 环境变量。
|
|
20
|
+
*
|
|
21
|
+
* @param roots 根项目目录列表
|
|
22
|
+
* @param opts 选项参数
|
|
23
|
+
* @returns 安装成功的路径列表及警告信息
|
|
24
|
+
*/
|
|
25
|
+
export declare function ensureDependencyClosure(roots: string[], opts?: EnsureDependencyClosureOptions): Promise<DependencyClosureResult>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 项目初始化脚手架选项。
|
|
3
|
+
*/
|
|
4
|
+
export interface InitOptions {
|
|
5
|
+
/** 自定义项目 ID(默认使用目录名) */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** 自定义项目展示名称(默认由目录名美化生成) */
|
|
8
|
+
name?: string;
|
|
9
|
+
/** 自定义项目描述 */
|
|
10
|
+
description?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 在目标目录初始化一个完整的 ActionDock 2.0 Action Package 脚手架。
|
|
14
|
+
* 生成内容包括:
|
|
15
|
+
* - actiondock.json(项目元数据与配置声明)
|
|
16
|
+
* - actiondock.manifest.json(声明式元数据清单事实源)
|
|
17
|
+
* - package.json(Node.js 标准脚本与依赖声明)
|
|
18
|
+
* - tsconfig.json(现代 NodeNext 模块规范)
|
|
19
|
+
* - .gitignore(排除持久化 db、node_modules、dist)
|
|
20
|
+
* - actions/greet.ts(标准示例 Action,演示 config、state、log 使用)
|
|
21
|
+
* - playbooks/greet-user.md(标准 SOP Playbook 演示)
|
|
22
|
+
* - tests/greet.test.ts(基于 node:test 与 @actiondock/testing 的测试用例)
|
|
23
|
+
*
|
|
24
|
+
* @param targetDir 目标项目目录
|
|
25
|
+
* @param options 初始化选项
|
|
26
|
+
*/
|
|
27
|
+
export declare function initProject(targetDir: string, options?: InitOptions): void;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { ActionDefinition } from "@actiondock/sdk";
|
|
2
|
+
import type { PlaybookDefinition, ProjectConfig } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* 从指定目录开始向上逐级递归查找包含 `actiondock.json` 的项目根目录。
|
|
5
|
+
*
|
|
6
|
+
* @param cwd 起始搜索目录(默认为 process.cwd())
|
|
7
|
+
* @returns 项目根目录绝对路径,若未找到则返回 null
|
|
8
|
+
*/
|
|
9
|
+
export declare function findProjectRoot(cwd?: string): string | null;
|
|
10
|
+
export declare const ACTION_ID_REGEX: RegExp;
|
|
11
|
+
export declare const PLAYBOOK_ID_REGEX: RegExp;
|
|
12
|
+
/**
|
|
13
|
+
* 加载并校验指定目录下的 `actiondock.json` 配置文件。
|
|
14
|
+
*
|
|
15
|
+
* @param projectRoot 项目根目录绝对路径
|
|
16
|
+
* @returns 解析后的 ProjectConfig 对象
|
|
17
|
+
* @throws {Error} 若文件不存在或 JSON 格式错误、缺失必要字段
|
|
18
|
+
*/
|
|
19
|
+
export declare function loadProjectConfig(projectRoot: string): ProjectConfig;
|
|
20
|
+
export declare const ALLOWED_INSTALLERS: Set<string>;
|
|
21
|
+
/**
|
|
22
|
+
* 探测宿主系统中可用的包管理工具。
|
|
23
|
+
* 优先级:
|
|
24
|
+
* - 环境变量 ACTIONDOCK_INSTALLER 显式指定(严格白名单校验:npm, bun);
|
|
25
|
+
* - 依据项目根目录下现存的锁文件进行精确匹配(bun.lock/bun.lockb -> bun, package-lock.json/npm-shrinkwrap.json -> npm);
|
|
26
|
+
* - 候选回退优先级探测(npm > bun)。
|
|
27
|
+
*/
|
|
28
|
+
export declare function getInstallCommand(projectRoot?: string): string[];
|
|
29
|
+
/**
|
|
30
|
+
* 读取项目当前缓存的依赖指纹哈希。
|
|
31
|
+
*/
|
|
32
|
+
export declare function readStoredDependencyFingerprint(projectRoot: string): string | null;
|
|
33
|
+
/**
|
|
34
|
+
* 将最新的依赖指纹哈希写入缓存文件。
|
|
35
|
+
*/
|
|
36
|
+
export declare function saveDependencyFingerprint(projectRoot: string, fingerprint: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* 计算项目依赖的指纹哈希(基于 package.json 依赖声明及可能存在的锁文件内容)。
|
|
39
|
+
*
|
|
40
|
+
* @param projectRoot 项目根目录
|
|
41
|
+
* @returns 64位十六进制哈希字符串,若 package.json 不存在或解析失败则返回 null
|
|
42
|
+
*/
|
|
43
|
+
export declare function computeDependencyFingerprint(projectRoot: string): string | null;
|
|
44
|
+
/**
|
|
45
|
+
* 确保项目依赖(node_modules)已正确安装。
|
|
46
|
+
* 若尚未安装、依赖版本变更(指纹不匹配)或加载失败时,自动触发包管理器执行依赖安装。
|
|
47
|
+
*
|
|
48
|
+
* @param projectRoot 项目根目录
|
|
49
|
+
* @param force 是否强制重新安装
|
|
50
|
+
* @returns 是否成功执行了安装或更新
|
|
51
|
+
*/
|
|
52
|
+
export declare function ensureProjectDependencies(projectRoot: string, force?: boolean): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* 发现并检索项目 actions 目录下的所有 Action 源码文件(.ts)。
|
|
55
|
+
*
|
|
56
|
+
* @param projectRoot 项目根目录
|
|
57
|
+
* @param actionsDir actions 子目录名称(默认 "actions")
|
|
58
|
+
*/
|
|
59
|
+
export declare function discoverActionFiles(projectRoot: string, actionsDir?: string): string[];
|
|
60
|
+
/**
|
|
61
|
+
* 动态导入并加载项目下的所有 Action 定义对象。
|
|
62
|
+
*
|
|
63
|
+
* @param projectRoot 项目根目录
|
|
64
|
+
* @param actionsDir actions 子目录(默认 "actions")
|
|
65
|
+
* @param options 控制是否允许自动安装依赖等选项
|
|
66
|
+
* @returns Map<ActionId, ActionDefinition> 映射
|
|
67
|
+
*/
|
|
68
|
+
export declare function loadActions(projectRoot: string, actionsDir?: string, options?: {
|
|
69
|
+
autoInstall?: boolean;
|
|
70
|
+
}): Promise<Map<string, ActionDefinition>>;
|
|
71
|
+
/**
|
|
72
|
+
* Action 文件映射条目,包含 Action ID、源文件绝对路径与 Action 定义对象。
|
|
73
|
+
*/
|
|
74
|
+
export interface ActionFileEntry {
|
|
75
|
+
id: string;
|
|
76
|
+
filePath: string;
|
|
77
|
+
action: ActionDefinition;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 加载并建立 Action ID 与其物理源码文件路径之间的映射关系(供构建打包器及清单同步使用)。
|
|
81
|
+
*/
|
|
82
|
+
export declare function loadActionFileMap(projectRoot: string, actionsDir?: string, options?: {
|
|
83
|
+
autoInstall?: boolean;
|
|
84
|
+
strict?: boolean;
|
|
85
|
+
}): Promise<Map<string, ActionFileEntry>>;
|
|
86
|
+
/**
|
|
87
|
+
* 发现项目 playbooks 目录下的所有 Playbook Markdown 文档(.md)。
|
|
88
|
+
*/
|
|
89
|
+
export declare function discoverPlaybookFiles(projectRoot: string, playbooksDir?: string): string[];
|
|
90
|
+
/**
|
|
91
|
+
* 解析单个 Playbook Markdown 文件的内容与 YAML Frontmatter 头部元数据。
|
|
92
|
+
*
|
|
93
|
+
* @param content 文件文本内容
|
|
94
|
+
* @param filePath 物理文件路径
|
|
95
|
+
* @returns PlaybookDefinition 对象
|
|
96
|
+
*/
|
|
97
|
+
export declare function parsePlaybookContent(content: string, filePath: string): PlaybookDefinition;
|
|
98
|
+
/**
|
|
99
|
+
* 加载项目 playbooks 目录下的所有 Playbook SOP 文档。
|
|
100
|
+
*
|
|
101
|
+
* @param projectRoot 项目根目录
|
|
102
|
+
* @param playbooksDir playbooks 子目录(默认 "playbooks")
|
|
103
|
+
* @returns Map<PlaybookId, PlaybookDefinition> 映射
|
|
104
|
+
*/
|
|
105
|
+
export declare function loadPlaybooks(projectRoot: string, playbooksDir?: string): Map<string, PlaybookDefinition>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ActionDockManifest, ActionManifestEntry, ManifestSyncResult, SyncManifestOptions } from "./types";
|
|
2
|
+
export declare const MANIFEST_FILE_NAME = "actiondock.manifest.json";
|
|
3
|
+
/**
|
|
4
|
+
* 读取并解析项目的声明式清单文件。
|
|
5
|
+
* 若文件不存在则返回 null。
|
|
6
|
+
*/
|
|
7
|
+
export declare function loadManifest(projectRoot: string): ActionDockManifest | null;
|
|
8
|
+
/**
|
|
9
|
+
* 保存声明式清单文件至项目根目录。
|
|
10
|
+
*/
|
|
11
|
+
export declare function saveManifest(projectRoot: string, manifest: ActionDockManifest): void;
|
|
12
|
+
/**
|
|
13
|
+
* 校验清单数据结构的合法性与安全性。
|
|
14
|
+
*/
|
|
15
|
+
export declare function validateManifest(manifest: unknown, options?: {
|
|
16
|
+
projectRoot?: string;
|
|
17
|
+
}): {
|
|
18
|
+
valid: boolean;
|
|
19
|
+
errors?: string[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 为单个 Action 构建清单项。
|
|
23
|
+
*/
|
|
24
|
+
export declare function createManifestEntry(options: {
|
|
25
|
+
entry: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
inputSchema?: Record<string, unknown> | boolean;
|
|
28
|
+
outputSchema?: Record<string, unknown> | boolean;
|
|
29
|
+
uses?: string[];
|
|
30
|
+
tags?: string[];
|
|
31
|
+
annotations?: Record<string, unknown>;
|
|
32
|
+
}): ActionManifestEntry;
|
|
33
|
+
/**
|
|
34
|
+
* 依据动作源码目录中的 Action 定义,增量同步或校验 actiondock.manifest.json 文件。
|
|
35
|
+
*
|
|
36
|
+
* @param projectRoot 项目根目录绝对路径
|
|
37
|
+
* @param options 同步选项(包括 actionsDir、check、prune、autoInstall)
|
|
38
|
+
* @returns 同步变更结果报告
|
|
39
|
+
*/
|
|
40
|
+
export declare function syncManifest(projectRoot: string, options?: SyncManifestOptions): Promise<ManifestSyncResult>;
|
|
41
|
+
/**
|
|
42
|
+
* 校验当前 actiondock.manifest.json 是否与动作源码定义保持一致(只读检查)。
|
|
43
|
+
*/
|
|
44
|
+
export declare function checkManifestSync(projectRoot: string, options?: Omit<SyncManifestOptions, "check">): Promise<ManifestSyncResult>;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 配置项的值类型枚举。用于自动类型推断与环境变量自动转换。
|
|
3
|
+
*/
|
|
4
|
+
export type ConfigValueType = "string" | "number" | "boolean" | "object" | "array";
|
|
5
|
+
/**
|
|
6
|
+
* 在 actiondock.json 中声明的单项配置定义。
|
|
7
|
+
*/
|
|
8
|
+
export interface ConfigItemDefinition {
|
|
9
|
+
/** 配置项的功能描述,展示在 CLI 配置提示与帮助文档中 */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** 默认回退值。若未配置任何自定义值或环境变量,将使用此默认值 */
|
|
12
|
+
default?: unknown;
|
|
13
|
+
/** 是否为敏感信息(如 API Key, Password)。若为 true,在日志与 CLI 输出中默认脱敏 */
|
|
14
|
+
secret?: boolean;
|
|
15
|
+
/** 期望的目标数据类型,从 process.env 读取字符串时将自动尝试强转为此类型 */
|
|
16
|
+
type?: ConfigValueType;
|
|
17
|
+
/** 显式绑定的外部环境变量名(支持单个或优先级数组) */
|
|
18
|
+
env?: string | string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* ActionDock 项目根配置文件契约(对应 actiondock.json)。
|
|
22
|
+
*/
|
|
23
|
+
export interface ProjectConfig {
|
|
24
|
+
/** 项目全局唯一 ID(例如 "team4u.github-tools") */
|
|
25
|
+
id: string;
|
|
26
|
+
/** 项目展示名称(例如 "GitHub Tools") */
|
|
27
|
+
name: string;
|
|
28
|
+
/** 项目版本号(遵循语义化版本 Semantic Versioning,如 "1.0.0") */
|
|
29
|
+
version: string;
|
|
30
|
+
/** 项目描述信息 */
|
|
31
|
+
description?: string;
|
|
32
|
+
/** Action 脚本文件存放目录(相对于项目根目录,默认为 "actions") */
|
|
33
|
+
actionsDir?: string;
|
|
34
|
+
/** Playbook SOP 文档存放目录(相对于项目根目录,默认为 "playbooks") */
|
|
35
|
+
playbooksDir?: string;
|
|
36
|
+
/** 声明的项目依赖配置项清单 */
|
|
37
|
+
config?: Record<string, ConfigItemDefinition>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Playbook Markdown 文档头部 YAML Frontmatter 元数据。
|
|
41
|
+
*/
|
|
42
|
+
export interface PlaybookFrontmatter {
|
|
43
|
+
/** Playbook 唯一标识符(例如 "review-pr") */
|
|
44
|
+
id: string;
|
|
45
|
+
/** Playbook 任务描述 */
|
|
46
|
+
description?: string;
|
|
47
|
+
/** 该 Playbook SOP 所依赖/调用的 Action ID 列表(用于最小化构建与 Tree-shaking 导出) */
|
|
48
|
+
actions?: string[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 解析后的完整 Playbook 定义对象。
|
|
52
|
+
*/
|
|
53
|
+
export interface PlaybookDefinition extends PlaybookFrontmatter {
|
|
54
|
+
/** Markdown 正文内容(去除了头部 YAML Frontmatter 后的 SOP 指南内容) */
|
|
55
|
+
content: string;
|
|
56
|
+
/** Playbook 源文件的绝对物理路径 */
|
|
57
|
+
filePath: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 单个 Action 在清单中的声明项。
|
|
61
|
+
*/
|
|
62
|
+
export interface ActionManifestEntry {
|
|
63
|
+
/** Action 入口文件相对路径(如 "actions/greet.ts") */
|
|
64
|
+
entry: string;
|
|
65
|
+
/** Action 功能描述 */
|
|
66
|
+
description?: string;
|
|
67
|
+
/** 输入参数模式规范 */
|
|
68
|
+
inputSchema?: Record<string, unknown> | boolean;
|
|
69
|
+
/** 输出结果模式规范 */
|
|
70
|
+
outputSchema?: Record<string, unknown> | boolean;
|
|
71
|
+
/** 静态依赖的 Action 列表 */
|
|
72
|
+
uses?: string[];
|
|
73
|
+
/** 标签列表 */
|
|
74
|
+
tags?: string[];
|
|
75
|
+
/** 协议注解元数据 */
|
|
76
|
+
annotations?: Record<string, unknown>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* ActionDock 声明式清单(actiondock.manifest.json)规范。
|
|
80
|
+
* 作为元数据的单一事实源,实现无副作用的模块发现与构建规划。
|
|
81
|
+
*/
|
|
82
|
+
export interface ActionDockManifest {
|
|
83
|
+
schemaVersion: number;
|
|
84
|
+
actions: Record<string, ActionManifestEntry>;
|
|
85
|
+
assets?: string[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 清单同步操作选项。
|
|
89
|
+
*/
|
|
90
|
+
export interface SyncManifestOptions {
|
|
91
|
+
/** 自定义 actions 源码目录(默认为工程配置中的 actionsDir 或 "actions") */
|
|
92
|
+
actionsDir?: string;
|
|
93
|
+
/** 是否仅检查同步状态而不保存写入文件(默认 false) */
|
|
94
|
+
check?: boolean;
|
|
95
|
+
/** 是否自动移除源码中已不存在的 Action(默认 true) */
|
|
96
|
+
prune?: boolean;
|
|
97
|
+
/** 缺失依赖时是否自动执行安装(默认 true) */
|
|
98
|
+
autoInstall?: boolean;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* 单个 Action 的清单同步变更项。
|
|
102
|
+
*/
|
|
103
|
+
export interface ManifestSyncChange {
|
|
104
|
+
/** Action 标识符 */
|
|
105
|
+
actionId: string;
|
|
106
|
+
/** 变更类型:新增、更新、删除或未变 */
|
|
107
|
+
type: "added" | "updated" | "removed" | "unchanged";
|
|
108
|
+
/** 源码入口文件相对路径 */
|
|
109
|
+
entry?: string;
|
|
110
|
+
/** 发生变更的字段列表(例如 ["description", "inputSchema"]) */
|
|
111
|
+
changedFields?: string[];
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* 清单同步执行结果。
|
|
115
|
+
*/
|
|
116
|
+
export interface ManifestSyncResult {
|
|
117
|
+
/** 清单当前是否已与源码完全一致 */
|
|
118
|
+
inSync: boolean;
|
|
119
|
+
/** 清单文件的物理绝对路径 */
|
|
120
|
+
manifestPath: string;
|
|
121
|
+
/** 所有 Action 的变更详情列表 */
|
|
122
|
+
changes: ManifestSyncChange[];
|
|
123
|
+
/** 新增的 Action 标识列表 */
|
|
124
|
+
added: string[];
|
|
125
|
+
/** 更新的 Action 标识列表 */
|
|
126
|
+
updated: string[];
|
|
127
|
+
/** 移除的 Action 标识列表 */
|
|
128
|
+
removed: string[];
|
|
129
|
+
/** 未改变的 Action 标识列表 */
|
|
130
|
+
unchanged: string[];
|
|
131
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { GlobalRegistryData, LinkedPackageEntry, LinkedWorkspaceEntry, LinkResult, PruneResult, RegistryStatusReport, ResolvedActionProject, ResolvedPlaybookProject, UnlinkResult } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* 跨平台注册表写锁控制函数(防止多进程并发读写导致 registry.json 损坏)。
|
|
4
|
+
*/
|
|
5
|
+
export declare function withRegistryLock<T>(filePath: string, fn: () => T): T;
|
|
6
|
+
/**
|
|
7
|
+
* 递归扫描包含 actiondock.json 的子项目根目录
|
|
8
|
+
*/
|
|
9
|
+
export declare function discoverProjects(dir: string, maxDepth?: number): string[];
|
|
10
|
+
export declare function getRegistryFilePath(customHome?: string): string;
|
|
11
|
+
export declare function loadRegistry(customHome?: string): GlobalRegistryData;
|
|
12
|
+
export declare function saveRegistry(data: GlobalRegistryData, customHome?: string): void;
|
|
13
|
+
export declare function linkPackage(targetPath?: string, customHome?: string, options?: {
|
|
14
|
+
recursive?: boolean;
|
|
15
|
+
}): LinkResult;
|
|
16
|
+
export declare function unlinkPackage(identifier?: string, customHome?: string): UnlinkResult | null;
|
|
17
|
+
export declare function listLinkedPackages(customHome?: string): LinkedPackageEntry[];
|
|
18
|
+
export declare function listLinkedWorkspaces(customHome?: string): LinkedWorkspaceEntry[];
|
|
19
|
+
export declare function resolveActionProjectSync(actionIdentifier: string, cwd?: string, customHome?: string): ResolvedActionProject;
|
|
20
|
+
export declare function resolveActionProject(actionIdentifier: string, cwd?: string, customHome?: string): Promise<ResolvedActionProject>;
|
|
21
|
+
export declare function resolvePackageRoot(packageIdOrPath?: string, cwd?: string, customHome?: string): string | null;
|
|
22
|
+
export declare function resolvePlaybookProject(playbookIdentifier: string, cwd?: string, customHome?: string): ResolvedPlaybookProject;
|
|
23
|
+
export declare function getRegistryStatus(customHome?: string): RegistryStatusReport;
|
|
24
|
+
export declare function pruneRegistry(customHome?: string): PruneResult;
|