@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.
Files changed (119) hide show
  1. package/dist/build/templates.d.ts +19 -0
  2. package/dist/catalog/action-index.d.ts +9 -0
  3. package/dist/catalog/action-resolver.d.ts +20 -0
  4. package/dist/catalog/location-registry.d.ts +15 -0
  5. package/dist/catalog/package-catalog.d.ts +7 -0
  6. package/dist/catalog/types.d.ts +68 -0
  7. package/dist/doctor/doctor.d.ts +6 -0
  8. package/dist/doctor/types.d.ts +23 -0
  9. package/dist/execution/index.d.ts +2 -0
  10. package/dist/execution/service.d.ts +74 -0
  11. package/dist/execution/types.d.ts +74 -0
  12. package/dist/export/templates.d.ts +33 -0
  13. package/dist/filter/intent.d.ts +33 -0
  14. package/{src/index.ts → dist/index.d.ts} +1 -1
  15. package/dist/index.js +8458 -0
  16. package/dist/profile/client.d.ts +116 -0
  17. package/dist/profile/manager.d.ts +47 -0
  18. package/dist/profile/types.d.ts +61 -0
  19. package/dist/project/closure.d.ts +25 -0
  20. package/{src/project/index.ts → dist/project/index.d.ts} +1 -0
  21. package/dist/project/init.d.ts +27 -0
  22. package/dist/project/loader.d.ts +105 -0
  23. package/dist/project/manifest.d.ts +44 -0
  24. package/dist/project/types.d.ts +131 -0
  25. package/dist/registry/registry.d.ts +24 -0
  26. package/dist/registry/types.d.ts +117 -0
  27. package/dist/runtime/clock.d.ts +21 -0
  28. package/dist/runtime/context.d.ts +75 -0
  29. package/dist/runtime/env.d.ts +54 -0
  30. package/dist/runtime/events.d.ts +61 -0
  31. package/dist/runtime/execution-manager.d.ts +48 -0
  32. package/{src/runtime/index.ts → dist/runtime/index.d.ts} +0 -1
  33. package/dist/runtime/module-loader.d.ts +42 -0
  34. package/dist/runtime/process.d.ts +11 -0
  35. package/dist/runtime/runner.d.ts +186 -0
  36. package/dist/runtime/standalone.d.ts +40 -0
  37. package/dist/schema/validator.d.ts +28 -0
  38. package/dist/server/body.d.ts +40 -0
  39. package/{src/server/index.ts → dist/server/index.d.ts} +0 -1
  40. package/dist/server/routes/actions.d.ts +5 -0
  41. package/dist/server/routes/common.d.ts +36 -0
  42. package/dist/server/routes/config.d.ts +5 -0
  43. package/dist/server/routes/doctor.d.ts +5 -0
  44. package/dist/server/routes/health.d.ts +5 -0
  45. package/dist/server/routes/info.d.ts +5 -0
  46. package/dist/server/routes/playbooks.d.ts +5 -0
  47. package/dist/server/routes/runs.d.ts +5 -0
  48. package/dist/server/routes/state.d.ts +5 -0
  49. package/dist/server/runtime-registry.d.ts +78 -0
  50. package/dist/server/security.d.ts +37 -0
  51. package/dist/server/server.d.ts +15 -0
  52. package/dist/server/types.d.ts +59 -0
  53. package/dist/storage/driver.d.ts +15 -0
  54. package/dist/storage/index.d.ts +44 -0
  55. package/{src/storage/mask.ts → dist/storage/mask.d.ts} +5 -20
  56. package/dist/storage/sqlite.d.ts +66 -0
  57. package/dist/storage/types.d.ts +121 -0
  58. package/dist/utils/index.d.ts +29 -0
  59. package/dist/version.d.ts +4 -0
  60. package/package.json +11 -10
  61. package/src/build/templates.ts +0 -59
  62. package/src/catalog/action-index.ts +0 -92
  63. package/src/catalog/action-resolver.ts +0 -120
  64. package/src/catalog/location-registry.ts +0 -134
  65. package/src/catalog/package-catalog.ts +0 -87
  66. package/src/catalog/types.ts +0 -75
  67. package/src/doctor/doctor.ts +0 -419
  68. package/src/doctor/types.ts +0 -25
  69. package/src/execution/index.ts +0 -2
  70. package/src/execution/service.ts +0 -322
  71. package/src/execution/types.ts +0 -73
  72. package/src/export/templates.ts +0 -590
  73. package/src/filter/intent.ts +0 -154
  74. package/src/profile/client.ts +0 -552
  75. package/src/profile/manager.ts +0 -341
  76. package/src/profile/types.ts +0 -71
  77. package/src/project/init.ts +0 -242
  78. package/src/project/loader.ts +0 -479
  79. package/src/project/manifest.ts +0 -299
  80. package/src/project/types.ts +0 -141
  81. package/src/registry/registry.ts +0 -940
  82. package/src/registry/types.ts +0 -127
  83. package/src/runtime/clock.ts +0 -41
  84. package/src/runtime/context.ts +0 -259
  85. package/src/runtime/env.ts +0 -172
  86. package/src/runtime/events.ts +0 -142
  87. package/src/runtime/execution-manager.ts +0 -74
  88. package/src/runtime/module-loader.ts +0 -67
  89. package/src/runtime/process.ts +0 -245
  90. package/src/runtime/runner.ts +0 -527
  91. package/src/runtime/standalone.ts +0 -429
  92. package/src/schema/validator.ts +0 -61
  93. package/src/server/body.ts +0 -112
  94. package/src/server/routes/actions.ts +0 -262
  95. package/src/server/routes/common.ts +0 -126
  96. package/src/server/routes/config.ts +0 -147
  97. package/src/server/routes/doctor.ts +0 -29
  98. package/src/server/routes/health.ts +0 -40
  99. package/src/server/routes/info.ts +0 -221
  100. package/src/server/routes/playbooks.ts +0 -109
  101. package/src/server/routes/runs.ts +0 -301
  102. package/src/server/routes/state.ts +0 -133
  103. package/src/server/runtime-registry.ts +0 -115
  104. package/src/server/security.ts +0 -115
  105. package/src/server/server.ts +0 -251
  106. package/src/server/types.ts +0 -57
  107. package/src/storage/driver.ts +0 -126
  108. package/src/storage/index.ts +0 -81
  109. package/src/storage/sqlite.ts +0 -714
  110. package/src/storage/types.ts +0 -139
  111. package/src/utils/index.ts +0 -62
  112. /package/{src/build/index.ts → dist/build/index.d.ts} +0 -0
  113. /package/{src/catalog/index.ts → dist/catalog/index.d.ts} +0 -0
  114. /package/{src/doctor/index.ts → dist/doctor/index.d.ts} +0 -0
  115. /package/{src/export/index.ts → dist/export/index.d.ts} +0 -0
  116. /package/{src/filter/index.ts → dist/filter/index.d.ts} +0 -0
  117. /package/{src/profile/index.ts → dist/profile/index.d.ts} +0 -0
  118. /package/{src/registry/index.ts → dist/registry/index.d.ts} +0 -0
  119. /package/{src/server/routes/index.ts → dist/server/routes/index.d.ts} +0 -0
@@ -0,0 +1,19 @@
1
+ /**
2
+ * 构建时 Action 导入映射。
3
+ */
4
+ export interface ActionImport {
5
+ /** Action 唯一标识符 */
6
+ id: string;
7
+ /** Action 源码文件物理路径 */
8
+ filePath: string;
9
+ }
10
+ /**
11
+ * 动态生成 Standalone 独立可执行文件的 TypeScript 入口文件源码。
12
+ *
13
+ * @param packageId 所属 Package ID
14
+ * @param version 版本号
15
+ * @param description 描述
16
+ * @param actions 待打包 Action 列表
17
+ * @param configDefs 声明的配置定义字典
18
+ */
19
+ export declare function generateStandaloneEntrypoint(packageId: string, version: string, description: string | undefined, actions: ActionImport[], configDefs?: Record<string, unknown>): string;
@@ -0,0 +1,9 @@
1
+ import type { CatalogSnapshot, IndexedAction } from "./types";
2
+ export declare class ActionIndex {
3
+ private actions;
4
+ constructor(snapshot: CatalogSnapshot);
5
+ private indexSnapshot;
6
+ private add;
7
+ list(packageId?: string): IndexedAction[];
8
+ find(actionId: string, packageId?: string): IndexedAction[];
9
+ }
@@ -0,0 +1,20 @@
1
+ import type { ActionRef, ResolvedActionRef } from "@actiondock/sdk";
2
+ import { ActionIndex } from "./action-index";
3
+ import type { CatalogSnapshot, IndexedAction } from "./types";
4
+ export interface ResolveOptions {
5
+ currentPackageId?: string;
6
+ }
7
+ export declare class ActionResolver {
8
+ private snapshot;
9
+ private index;
10
+ constructor(snapshot: CatalogSnapshot, index?: ActionIndex);
11
+ /**
12
+ * 解析字符串或 ActionRef 为规范化的 ActionRef。
13
+ * 支持 greet、my-tools/greet、@team/github/issues.list。
14
+ */
15
+ static parseRef(refStringOrObj: string | ActionRef): ActionRef;
16
+ resolve(refStringOrObj: string | ActionRef, options?: ResolveOptions): {
17
+ resolved: ResolvedActionRef;
18
+ action: IndexedAction;
19
+ };
20
+ }
@@ -0,0 +1,15 @@
1
+ import type { LocationLink, LocationRegistryData } from "./types";
2
+ export declare class LocationRegistry {
3
+ private customHome?;
4
+ private filePath;
5
+ constructor(customHome?: string);
6
+ getFilePath(): string;
7
+ load(): LocationRegistryData;
8
+ save(data: LocationRegistryData): void;
9
+ addLink(path: string, options?: {
10
+ type?: "package" | "workspace";
11
+ depth?: number;
12
+ }): LocationLink;
13
+ removeLink(targetPathOrId: string): LocationLink | null;
14
+ prune(): LocationLink[];
15
+ }
@@ -0,0 +1,7 @@
1
+ import { LocationRegistry } from "./location-registry";
2
+ import type { CatalogSnapshot } from "./types";
3
+ export declare class PackageCatalog {
4
+ private registry;
5
+ constructor(registry?: LocationRegistry);
6
+ buildSnapshot(cwd?: string): CatalogSnapshot;
7
+ }
@@ -0,0 +1,68 @@
1
+ import type { ActionContract } from "@actiondock/sdk";
2
+ import type { ProjectConfig } from "../project/types";
3
+ /**
4
+ * 注册的位置条目类型。
5
+ */
6
+ export type LocationType = "package" | "workspace";
7
+ /**
8
+ * 位置注册表中的单条链接记录。
9
+ */
10
+ export interface LocationLink {
11
+ /** 位置类型:单包或工作区 */
12
+ type: LocationType;
13
+ /** 目录绝对物理路径 */
14
+ path: string;
15
+ /** 注册时间(ISO 8601) */
16
+ linkedAt: string;
17
+ /** 扫描最大深度(工作区模式有效,默认 3) */
18
+ depth?: number;
19
+ }
20
+ /**
21
+ * 物理位置注册表文件(~/.actiondock/registry.json)格式。
22
+ */
23
+ export interface LocationRegistryData {
24
+ schemaVersion: 1;
25
+ links: LocationLink[];
26
+ }
27
+ /**
28
+ * 解析后的包实例快照。
29
+ */
30
+ export interface CatalogPackageEntry {
31
+ /** 逻辑包标识 */
32
+ id: string;
33
+ /** 包物理实例唯一标识 */
34
+ packageInstanceId: string;
35
+ /** 项目根目录绝对路径 */
36
+ projectRoot: string;
37
+ /** 项目配置 */
38
+ config: ProjectConfig;
39
+ /** 是否来自工作区自动发现 */
40
+ isWorkspaceChild?: boolean;
41
+ }
42
+ /**
43
+ * 运行时目录与包快照。
44
+ */
45
+ export interface CatalogSnapshot {
46
+ /** 快照代次唯一标识 */
47
+ generationId: string;
48
+ /** 生成快照时间 */
49
+ createdAt: string;
50
+ /** 已发现的包集合(按 packageId 索引) */
51
+ packages: Map<string, CatalogPackageEntry>;
52
+ }
53
+ /**
54
+ * 索引中的 Action 描述符。
55
+ */
56
+ export interface IndexedAction {
57
+ /** 所属逻辑包 ID */
58
+ packageId: string;
59
+ /** 动作 ID */
60
+ actionId: string;
61
+ /** 契约元数据 */
62
+ contract: ActionContract;
63
+ /** 实现入口相对路径 */
64
+ entry: string;
65
+ /** 包根目录绝对路径 */
66
+ projectRoot: string;
67
+ }
68
+ export type { ModuleLoader } from "../runtime/module-loader";
@@ -0,0 +1,6 @@
1
+ import type { DoctorReport } from "./types";
2
+ export declare function runDoctorChecks(options?: {
3
+ cwd?: string;
4
+ packageIdOrPath?: string;
5
+ customHome?: string;
6
+ }): Promise<DoctorReport>;
@@ -0,0 +1,23 @@
1
+ export type CheckStatus = "ok" | "warn" | "error";
2
+ export interface DoctorCheckItem {
3
+ id: string;
4
+ category: "runtime" | "storage" | "registry" | "project";
5
+ name: string;
6
+ status: CheckStatus;
7
+ message: string;
8
+ detail?: string;
9
+ fix?: string;
10
+ }
11
+ export interface DoctorReport {
12
+ ok: boolean;
13
+ hasProject: boolean;
14
+ projectRoot?: string;
15
+ packageId?: string;
16
+ summary: {
17
+ total: number;
18
+ ok: number;
19
+ warn: number;
20
+ error: number;
21
+ };
22
+ checks: DoctorCheckItem[];
23
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./types";
2
+ export { DefaultExecutionService, DefaultExecutionService as ExecutionService, type ExecutionServiceOptions, } from "./service";
@@ -0,0 +1,74 @@
1
+ import type { ActionDefinition, ActionRef, ExecutionEvent, ExecutionResult, JsonValue, Logger, ProcessAPI, RunRecord } from "@actiondock/sdk";
2
+ import type { ProjectConfig } from "../project/types";
3
+ import type { Clock } from "../runtime/clock";
4
+ import { type EventSink } from "../runtime/events";
5
+ import { ActionRunner, type ExecutionHandle } from "../runtime/runner";
6
+ import type { RuntimeStorage } from "../storage/types";
7
+ import type { CancelResult, ExecuteOptions, ExecutionService, ExecutionTicket } from "./types";
8
+ export interface ExecutionServiceOptions {
9
+ packageId: string;
10
+ storage: RuntimeStorage;
11
+ globalStorage?: RuntimeStorage;
12
+ projectRoot?: string;
13
+ projectConfig?: ProjectConfig;
14
+ configOverrides?: Record<string, unknown>;
15
+ actions?: Map<string, ActionDefinition>;
16
+ process?: ProcessAPI;
17
+ clock?: Clock;
18
+ logger?: Logger;
19
+ eventSink?: EventSink;
20
+ maxActiveRuns?: number;
21
+ maxCallDepth?: number;
22
+ maxSubRuns?: number;
23
+ ownerId?: string;
24
+ actionResolver?: (ref: ActionRef | string) => ActionDefinition | undefined | Promise<ActionDefinition | undefined>;
25
+ getStorageForPackage?: (packageId: string, projectRoot?: string) => RuntimeStorage;
26
+ packageContextResolver?: (packageId: string) => Promise<{
27
+ projectRoot?: string;
28
+ projectConfig?: ProjectConfig;
29
+ storage: RuntimeStorage;
30
+ actions?: Map<string, ActionDefinition>;
31
+ } | undefined> | {
32
+ projectRoot?: string;
33
+ projectConfig?: ProjectConfig;
34
+ storage: RuntimeStorage;
35
+ actions?: Map<string, ActionDefinition>;
36
+ } | undefined;
37
+ customHome?: string;
38
+ }
39
+ /**
40
+ * 统一执行协调服务实现。
41
+ */
42
+ export declare class DefaultExecutionService implements ExecutionService {
43
+ private packageId;
44
+ private storage;
45
+ private projectConfig?;
46
+ private eventSink;
47
+ private maxActiveRuns;
48
+ private ownerId;
49
+ private _runner;
50
+ private logger?;
51
+ private clock?;
52
+ private actionResolver?;
53
+ private activeRuns;
54
+ private isClosing;
55
+ constructor(options: ExecutionServiceOptions);
56
+ get runner(): ActionRunner;
57
+ registerAction(action: ActionDefinition): void;
58
+ getAction(id: string): ActionDefinition | undefined;
59
+ listActions(): ActionDefinition[];
60
+ getActiveHandle(runId: string): ExecutionHandle | undefined;
61
+ private resolveTargetAction;
62
+ execute(ref: ActionRef | string, input: JsonValue, options?: ExecuteOptions): Promise<ExecutionResult>;
63
+ start(ref: ActionRef | string, input: JsonValue, options?: ExecuteOptions): Promise<ExecutionTicket>;
64
+ get(runId: string): Promise<RunRecord | undefined>;
65
+ cancel(runId: string, reason?: string): Promise<CancelResult>;
66
+ events(runId: string, options?: {
67
+ after?: number;
68
+ signal?: AbortSignal;
69
+ }): AsyncIterable<ExecutionEvent>;
70
+ close(options?: {
71
+ graceMs?: number;
72
+ }): Promise<void>;
73
+ }
74
+ export { DefaultExecutionService as ExecutionService };
@@ -0,0 +1,74 @@
1
+ import type { ActionRef, ExecutionEvent, ExecutionResult, JsonValue, Logger, ProcessAPI, ProgressReporter, RunRecord, RunStatus } from "@actiondock/sdk";
2
+ /**
3
+ * 执行参数选项。
4
+ */
5
+ export interface ExecuteOptions {
6
+ /** 外部取消信号 */
7
+ signal?: AbortSignal;
8
+ /** 超时时间(毫秒) */
9
+ timeoutMs?: number;
10
+ /** 配置临时覆盖字典 */
11
+ config?: Record<string, JsonValue>;
12
+ /** 父运行 ID */
13
+ parentRunId?: string;
14
+ /** 根运行 ID */
15
+ rootRunId?: string;
16
+ /** 最大调用嵌套深度限制 */
17
+ maxCallDepth?: number;
18
+ /** 外部日志注入 */
19
+ logger?: Logger;
20
+ /** 外部进度报告器注入 */
21
+ progress?: ProgressReporter;
22
+ /** 外部进程执行器注入 */
23
+ process?: ProcessAPI;
24
+ }
25
+ /**
26
+ * 异步任务执行票据。
27
+ */
28
+ export interface ExecutionTicket {
29
+ /** 运行标识 */
30
+ runId: string;
31
+ /** 当前状态 */
32
+ status: RunStatus;
33
+ /** 任务终态结果 Promise(用于需要异步等待执行结果的场景) */
34
+ result?: Promise<ExecutionResult>;
35
+ }
36
+ /**
37
+ * 取消操作结果枚举。
38
+ */
39
+ export type CancelResult = {
40
+ outcome: "requested";
41
+ runId: string;
42
+ } | {
43
+ outcome: "already_terminal";
44
+ runId: string;
45
+ status: RunStatus;
46
+ } | {
47
+ outcome: "not_found";
48
+ runId: string;
49
+ } | {
50
+ outcome: "not_owner";
51
+ runId: string;
52
+ };
53
+ /**
54
+ * 统一执行协调服务接口。
55
+ */
56
+ export interface ExecutionService {
57
+ /** 同步执行 Action 并等待终态结果 */
58
+ execute(ref: ActionRef | string, input: JsonValue, options?: ExecuteOptions): Promise<ExecutionResult>;
59
+ /** 异步启动 Action 并立即返回任务票据 */
60
+ start(ref: ActionRef | string, input: JsonValue, options?: ExecuteOptions): Promise<ExecutionTicket>;
61
+ /** 根据 ID 获取运行记录 */
62
+ get(runId: string): Promise<RunRecord | undefined>;
63
+ /** 取消指定的在运行任务 */
64
+ cancel(runId: string, reason?: string): Promise<CancelResult>;
65
+ /** 订阅执行事件流 */
66
+ events(runId: string, options?: {
67
+ after?: number;
68
+ signal?: AbortSignal;
69
+ }): AsyncIterable<ExecutionEvent>;
70
+ /** 优雅关闭服务并等待活跃任务收尾 */
71
+ close(options?: {
72
+ graceMs?: number;
73
+ }): Promise<void>;
74
+ }
@@ -0,0 +1,33 @@
1
+ import type { ActionDefinition } from "@actiondock/sdk";
2
+ import type { PlaybookDefinition, ProjectConfig } from "../project/types";
3
+ export declare function generateSourceSkillMd(config: ProjectConfig, actions: ActionDefinition[], playbooks: PlaybookDefinition[]): string;
4
+ export declare function generateStandaloneSkillMd(config: ProjectConfig, actions: ActionDefinition[], playbooks: PlaybookDefinition[], binaryRelPath?: string): string;
5
+ export declare function generateSkillMd(config: ProjectConfig, actions: ActionDefinition[], playbooks: PlaybookDefinition[], optionsOrBinaryPath?: string | {
6
+ mode?: "source" | "standalone";
7
+ binaryRelPath?: string;
8
+ }): string;
9
+ export interface CompositeSkillPackageInfo {
10
+ config: ProjectConfig;
11
+ actions: Array<{
12
+ id: string;
13
+ description?: string;
14
+ }>;
15
+ playbooks: Array<{
16
+ id: string;
17
+ name?: string;
18
+ description?: string;
19
+ filePath: string;
20
+ }>;
21
+ packageDir: string;
22
+ }
23
+ /**
24
+ * 生成多包聚合的复合模式 SKILL.md 文档。
25
+ */
26
+ export declare function generateCompositeSkillMd(bundleName: string, description: string, packages: CompositeSkillPackageInfo[]): string;
27
+ export interface GenerateSkillJsonOptions {
28
+ mode?: "source" | "standalone";
29
+ executable?: string;
30
+ target?: string;
31
+ playbooks?: PlaybookDefinition[];
32
+ }
33
+ export declare function generateSkillJson(config: ProjectConfig, actions: ActionDefinition[], binaryNameOrOptions?: string | GenerateSkillJsonOptions, target?: string, playbooksList?: PlaybookDefinition[]): string;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * 从对象中提取待过滤字段的提取器函数类型。
3
+ */
4
+ export type Extractor<T> = (item: T) => unknown;
5
+ /**
6
+ * 安全地将模式字符串、数组或现有正则编译为不区分大小写的 RegExp 正则表达式。
7
+ * 若正则语法不合法,自动对特殊字符进行转义并降级为字面量匹配正则,保证零 Crash。
8
+ *
9
+ * @param intent 意图关键词、正则或数组
10
+ */
11
+ export declare function compileIntentRegex(intent?: string | string[] | RegExp | null): RegExp | null;
12
+ /**
13
+ * 递归检查某个值(包括嵌套的数组或对象结构)是否匹配给定的正则表达式。
14
+ *
15
+ * @param value 待检测的任意数据类型
16
+ * @param regex 正则表达式
17
+ */
18
+ export declare function matchIntent(value: unknown, regex: RegExp): boolean;
19
+ export interface FilterResult<T> {
20
+ items: T[];
21
+ isFallback: boolean;
22
+ matchedCount: number;
23
+ }
24
+ /**
25
+ * Filters a collection of items based on an intent pattern across specified extractor functions.
26
+ * Returns detailed result including whether a fallback was triggered when 0 items matched.
27
+ */
28
+ export declare function filterWithFallbackInfo<T>(items: T[], intent?: string | string[] | RegExp | null, extractors?: Extractor<T>[], fallback?: boolean): FilterResult<T>;
29
+ /**
30
+ * Filters a collection of items based on an intent pattern across specified extractor functions.
31
+ * When fallback is enabled (default), returns the full list if no items match the intent.
32
+ */
33
+ export declare function filterByIntent<T>(items: T[], intent?: string | string[] | RegExp | null, extractors?: Extractor<T>[], fallback?: boolean): T[];
@@ -12,5 +12,5 @@ export * from "./schema/validator";
12
12
  export * from "./server";
13
13
  export * from "./storage";
14
14
  export * from "./utils";
15
+ export * from "./version";
15
16
  export type { ModuleLoader } from "./runtime";
16
-