@actiondock/core 2.6.0 → 2.7.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 (53) hide show
  1. package/dist/errors.d.ts +20 -0
  2. package/dist/errors.js +20 -0
  3. package/dist/export/templates.js +42 -30
  4. package/dist/index.d.ts +3 -1
  5. package/dist/index.js +3 -1
  6. package/dist/input/advice.d.ts +100 -0
  7. package/dist/input/advice.js +767 -0
  8. package/dist/input/describe.d.ts +106 -0
  9. package/dist/input/describe.js +176 -0
  10. package/dist/input/file-input.d.ts +54 -0
  11. package/dist/input/file-input.js +124 -0
  12. package/dist/input/flat-decode.d.ts +11 -0
  13. package/dist/input/flat-decode.js +13 -0
  14. package/dist/input/flat-errors.d.ts +72 -0
  15. package/dist/input/flat-errors.js +87 -0
  16. package/dist/input/flat-materializer.d.ts +29 -0
  17. package/dist/input/flat-materializer.js +179 -0
  18. package/dist/input/flat-parser.d.ts +50 -0
  19. package/dist/input/flat-parser.js +169 -0
  20. package/dist/input/flat-predicates.d.ts +34 -0
  21. package/dist/input/flat-predicates.js +50 -0
  22. package/dist/input/index.d.ts +14 -0
  23. package/dist/input/index.js +14 -0
  24. package/dist/input/input-resolver.d.ts +63 -0
  25. package/dist/input/input-resolver.js +254 -0
  26. package/dist/input/json-depth-scanner.d.ts +17 -0
  27. package/dist/input/json-depth-scanner.js +49 -0
  28. package/dist/input/metadata.d.ts +99 -0
  29. package/dist/input/metadata.js +99 -0
  30. package/dist/input/stdin-input.d.ts +26 -0
  31. package/dist/input/stdin-input.js +125 -0
  32. package/dist/input/utf8.d.ts +19 -0
  33. package/dist/input/utf8.js +36 -0
  34. package/dist/input/validation-mapper.d.ts +27 -0
  35. package/dist/input/validation-mapper.js +144 -0
  36. package/dist/json/index.d.ts +1 -0
  37. package/dist/json/index.js +1 -0
  38. package/dist/json/value-validator.d.ts +88 -0
  39. package/dist/json/value-validator.js +330 -0
  40. package/dist/profile/client-health.js +1 -0
  41. package/dist/profile/client-transport.js +1 -0
  42. package/dist/project/init.js +2 -2
  43. package/dist/runtime/runner.d.ts +2 -12
  44. package/dist/runtime/runner.js +38 -68
  45. package/dist/runtime/standalone.d.ts +14 -1
  46. package/dist/runtime/standalone.js +177 -71
  47. package/dist/schema/index.d.ts +1 -0
  48. package/dist/schema/index.js +1 -0
  49. package/dist/schema/validator.d.ts +10 -0
  50. package/dist/schema/validator.js +48 -54
  51. package/dist/version.d.ts +1 -1
  52. package/dist/version.js +1 -1
  53. package/package.json +2 -2
package/dist/errors.d.ts CHANGED
@@ -152,6 +152,26 @@ export declare const QUEUE_FULL = "QUEUE_FULL";
152
152
  export declare const QUOTA_EXCEEDED = "QUOTA_EXCEEDED";
153
153
  /** 输入通道已关闭拒绝继续写入 */
154
154
  export declare const INPUT_CLOSED = "INPUT_CLOSED";
155
+ /** 扁平入参赋值表达式格式非法 */
156
+ export declare const INVALID_FLAT_ARGUMENT = "INVALID_FLAT_ARGUMENT";
157
+ /** 完整 JSON 文档解析失败 */
158
+ export declare const INVALID_JSON = "INVALID_JSON";
159
+ /** JSON 字面量解析失败或包含非有限数值 */
160
+ export declare const INVALID_JSON_LITERAL = "INVALID_JSON_LITERAL";
161
+ /** 扁平入参路径冲突 */
162
+ export declare const INPUT_PATH_CONFLICT = "INPUT_PATH_CONFLICT";
163
+ /** 扁平入参超出安全阈值上限 */
164
+ export declare const FLAT_INPUT_LIMIT_EXCEEDED = "FLAT_INPUT_LIMIT_EXCEEDED";
165
+ /** 输入数据超出上限(字节大小、嵌套深度等) */
166
+ export declare const INPUT_LIMIT_EXCEEDED = "INPUT_LIMIT_EXCEEDED";
167
+ /** 输入违反 ActionDock 安全策略(如包含全局禁止属性) */
168
+ export declare const INPUT_POLICY_VIOLATION = "INPUT_POLICY_VIOLATION";
169
+ /** 输入源互斥冲突 */
170
+ export declare const INPUT_CONFLICT = "INPUT_CONFLICT";
171
+ /** 输入文件不存在 */
172
+ export declare const INPUT_FILE_NOT_FOUND = "INPUT_FILE_NOT_FOUND";
173
+ /** 输入文件或流读取失败 */
174
+ export declare const INPUT_FILE_READ_FAILED = "INPUT_FILE_READ_FAILED";
155
175
  /**
156
176
  * 进程领域结构化异常类。
157
177
  */
package/dist/errors.js CHANGED
@@ -153,6 +153,26 @@ export const QUEUE_FULL = "QUEUE_FULL";
153
153
  export const QUOTA_EXCEEDED = "QUOTA_EXCEEDED";
154
154
  /** 输入通道已关闭拒绝继续写入 */
155
155
  export const INPUT_CLOSED = "INPUT_CLOSED";
156
+ /** 扁平入参赋值表达式格式非法 */
157
+ export const INVALID_FLAT_ARGUMENT = "INVALID_FLAT_ARGUMENT";
158
+ /** 完整 JSON 文档解析失败 */
159
+ export const INVALID_JSON = "INVALID_JSON";
160
+ /** JSON 字面量解析失败或包含非有限数值 */
161
+ export const INVALID_JSON_LITERAL = "INVALID_JSON_LITERAL";
162
+ /** 扁平入参路径冲突 */
163
+ export const INPUT_PATH_CONFLICT = "INPUT_PATH_CONFLICT";
164
+ /** 扁平入参超出安全阈值上限 */
165
+ export const FLAT_INPUT_LIMIT_EXCEEDED = "FLAT_INPUT_LIMIT_EXCEEDED";
166
+ /** 输入数据超出上限(字节大小、嵌套深度等) */
167
+ export const INPUT_LIMIT_EXCEEDED = "INPUT_LIMIT_EXCEEDED";
168
+ /** 输入违反 ActionDock 安全策略(如包含全局禁止属性) */
169
+ export const INPUT_POLICY_VIOLATION = "INPUT_POLICY_VIOLATION";
170
+ /** 输入源互斥冲突 */
171
+ export const INPUT_CONFLICT = "INPUT_CONFLICT";
172
+ /** 输入文件不存在 */
173
+ export const INPUT_FILE_NOT_FOUND = "INPUT_FILE_NOT_FOUND";
174
+ /** 输入文件或流读取失败 */
175
+ export const INPUT_FILE_READ_FAILED = "INPUT_FILE_READ_FAILED";
156
176
  /**
157
177
  * 进程领域结构化异常类。
158
178
  */
@@ -124,7 +124,7 @@ ad link "<skill_root>"
124
124
 
125
125
  ### 动作参数契约按需调阅
126
126
 
127
- 在调用未知参数的 Action 前,可在终端执行命令按需查阅该 Action 的输入输出模式与详细说明:
127
+ 在调用未知参数的 Action 前,可在终端执行命令查阅该 Action 的输入输出模式与详细说明:
128
128
 
129
129
  \`\`\`bash
130
130
  ad describe ${pkgId}/${firstAction}
@@ -134,29 +134,28 @@ ad describe ${pkgId}/${firstAction}
134
134
 
135
135
  为避免多技能之间的 Action ID 命名冲突,建议统一使用带有 Package 前缀的完全限定 ID。
136
136
 
137
- 推荐最佳实践:使用文件传递参数,杜绝终端引号转义问题:
137
+ 推荐在执行前调用 describe 命令调阅确切参数契约:
138
138
 
139
139
  \`\`\`bash
140
- # 写入参数到临时文件并通过 --input-file 传递
141
- cat << 'EOF' > /tmp/input.json
142
- {
143
- "param": "value"
144
- }
145
- EOF
146
- ad run ${pkgId}/${firstAction} --input-file /tmp/input.json
140
+ # 调阅参数契约与建议赋值样例
141
+ ad describe ${pkgId}/${firstAction}
147
142
  \`\`\`
148
143
 
149
- 亦可通过内联参数进行简易命令调用:
144
+ 调用语法格式:
145
+ ad run ${pkgId}/${firstAction} --json -- ASSIGNMENT...
146
+ (其中 ASSIGNMENT 根据 ad describe ${pkgId}/${firstAction} 查阅的参数契约提供)
147
+
148
+ 将参数写入 JSON 文件并通过 --input-file 传递:
150
149
 
151
150
  \`\`\`bash
152
- ad run ${pkgId}/${firstAction} --input '{"param": "value"}'
151
+ ad run ${pkgId}/${firstAction} --json --input-file input.json
153
152
  \`\`\`
154
153
 
155
- > **免注册本地执行**:
154
+ > 免注册本地执行:
156
155
  > 若工作目录已位于本技能根目录,亦可直接免 link 执行:
157
156
  > \`\`\`bash
158
157
  > cd <skill_root>
159
- > ad run <action-id> --input-file /tmp/input.json
158
+ > ad run ${firstAction} --json
160
159
  > \`\`\`
161
160
 
162
161
  ### 结构化响应解析
@@ -258,24 +257,31 @@ description: ${desc}
258
257
  ${desc}
259
258
 
260
259
 
260
+ ### 动作参数契约按需调阅
261
+
262
+ 在调用未知参数的 Action 前,可在终端执行命令查阅该 Action 的输入输出模式与详细说明:
263
+
264
+ \`\`\`bash
265
+ ${binaryRelPath} describe ${firstAction}
266
+ \`\`\`
267
+
261
268
  ### 执行 Action
262
269
 
263
- 推荐最佳实践:使用文件传递参数,杜绝终端引号转义问题:
270
+ 推荐在执行前调用 describe 命令调阅确切参数契约:
264
271
 
265
272
  \`\`\`bash
266
- # 写入参数到临时文件并通过 --input-file 传递
267
- cat << 'EOF' > /tmp/input.json
268
- {
269
- "param": "value"
270
- }
271
- EOF
272
- ${binaryRelPath} run <action-id> --input-file /tmp/input.json
273
+ # 调阅参数契约与建议赋值样例
274
+ ${binaryRelPath} describe ${firstAction}
273
275
  \`\`\`
274
276
 
275
- 亦可通过内联参数进行简易命令调用:
277
+ 调用语法格式:
278
+ ${binaryRelPath} run ${firstAction} --json -- ASSIGNMENT...
279
+ (其中 ASSIGNMENT 根据 ${binaryRelPath} describe ${firstAction} 查阅的参数契约提供)
280
+
281
+ 将参数写入 JSON 文件并通过 --input-file 传递:
276
282
 
277
283
  \`\`\`bash
278
- ${binaryRelPath} run ${firstAction} --input '{"param": "value"}'
284
+ ${binaryRelPath} run ${firstAction} --json --input-file input.json
279
285
  \`\`\`
280
286
 
281
287
  ### 结构化响应解析
@@ -466,16 +472,22 @@ ${playbookEntries.join("\n")}
466
472
  ---`
467
473
  : "";
468
474
  const sInvoke = `## 标准调用命令
475
+
476
+ 推荐在执行前调用 describe 命令调阅确切参数契约:
469
477
 
470
- 推荐使用参数文件传递内容,杜绝终端引号转义问题:
478
+ \`\`\`bash
479
+ # 调阅参数契约与建议赋值样例
480
+ ad describe ${sampleActionId}
481
+ \`\`\`
471
482
 
483
+ 调用语法格式:
484
+ ad run ${sampleActionId} --json -- ASSIGNMENT...
485
+ (其中 ASSIGNMENT 根据 ad describe ${sampleActionId} 查阅的参数契约提供)
486
+
487
+ 将参数写入 JSON 文件并通过 --input-file 传递:
488
+
472
489
  \`\`\`bash
473
- cat << 'EOF' > /tmp/input.json
474
- {
475
- "param": "value"
476
- }
477
- EOF
478
- ad run ${sampleActionId} --input-file /tmp/input.json
490
+ ad run ${sampleActionId} --json --input-file input.json
479
491
  \`\`\`
480
492
 
481
493
  ### 结构化响应解析
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ export * from "./profile/index.js";
9
9
  export * from "./project/index.js";
10
10
  export * from "./registry/index.js";
11
11
  export * from "./runtime/index.js";
12
- export * from "./schema/validator.js";
12
+ export * from "./schema/index.js";
13
13
  export * from "./server/index.js";
14
14
  export * from "./storage/index.js";
15
15
  export * from "./utils/index.js";
@@ -19,4 +19,6 @@ export * from "./host/index.js";
19
19
  export * from "./target/index.js";
20
20
  export * from "./ipc/index.js";
21
21
  export * from "./process/index.js";
22
+ export * from "./input/index.js";
23
+ export * from "./json/index.js";
22
24
  export type { ModuleLoader } from "./runtime/index.js";
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ export * from "./profile/index.js";
9
9
  export * from "./project/index.js";
10
10
  export * from "./registry/index.js";
11
11
  export * from "./runtime/index.js";
12
- export * from "./schema/validator.js";
12
+ export * from "./schema/index.js";
13
13
  export * from "./server/index.js";
14
14
  export * from "./storage/index.js";
15
15
  export * from "./utils/index.js";
@@ -19,3 +19,5 @@ export * from "./host/index.js";
19
19
  export * from "./target/index.js";
20
20
  export * from "./ipc/index.js";
21
21
  export * from "./process/index.js";
22
+ export * from "./input/index.js";
23
+ export * from "./json/index.js";
@@ -0,0 +1,100 @@
1
+ /**
2
+ * 单个字段的输入建议明细(v1 机器契约)。
3
+ */
4
+ export interface CliInputFieldAdviceV1 {
5
+ /** 字段路径(属性名) */
6
+ path: string;
7
+ /** 是否允许作为输入传入 */
8
+ inputAllowed: boolean;
9
+ /** 是否可通过扁平语法安全赋值 */
10
+ flatSafe: boolean;
11
+ /** 是否为必填字段 */
12
+ required?: boolean;
13
+ /** 字段模式类型 */
14
+ type?: string;
15
+ /** 赋值操作符("=" 或 ":=") */
16
+ operator?: "=" | ":=";
17
+ /** 编码类型标识 */
18
+ encoding?: "string" | "json-number" | "json-boolean" | "json-null" | "json-array" | "json-object" | "json" | string;
19
+ /** 赋值模板样例 */
20
+ assignmentTemplate?: string;
21
+ /** 无法通过扁平赋值或被禁止的原因代码 */
22
+ reason?: "FORBIDDEN_PROPERTY" | "UNSAFE_FLAT_PROPERTY" | "PROPERTY_SCHEMA_FALSE" | string;
23
+ /** 推荐的降级输入通道 */
24
+ fallback?: "stdin-json" | null;
25
+ /** 字段描述信息 */
26
+ description?: string;
27
+ /** 人类提示信息 */
28
+ hint?: string;
29
+ }
30
+ /**
31
+ * Action 输入模式编码顾问分析报告(v1 机器契约)。
32
+ */
33
+ export interface CliInputAdviceV1 {
34
+ version: 1;
35
+ analysisMode: "declared-properties-only";
36
+ analysisStatus: "ok" | "unsupported" | "malformed";
37
+ analysisCode?: "MALFORMED_SCHEMA" | "COMPLEX_SCHEMA" | "UNSUPPORTED_SCHEMA_SHAPE";
38
+ analysisMessage?: string;
39
+ schemaState: "absent" | "reject-all" | "any" | "object" | "json-only" | "complex";
40
+ inputFeasibility: "known-impossible" | "possible-or-unknown";
41
+ flatAvailable: boolean;
42
+ requiredSatisfiable: boolean | null;
43
+ flatCandidate: boolean;
44
+ schemaRecommendedMode: "none" | "flat" | "full-json";
45
+ feasibilityCode?: "SCHEMA_REJECTS_ALL" | "REQUIRED_FIELD_FORBIDDEN" | "REQUIRED_FIELD_REJECTS_ALL" | "REQUIRED_FIELD_DISALLOWED_BY_ADDITIONAL_PROPERTIES";
46
+ fields: CliInputFieldAdviceV1[];
47
+ }
48
+ /**
49
+ * 依据 inputSchema 构造 v1 版本的 Action 输入编码顾问报告(机器契约)。
50
+ *
51
+ * @param schema Action 的 inputSchema 定义
52
+ * @returns 遵循技术设计文档规范的结构化输入建议
53
+ */
54
+ export declare function buildCliInputAdviceV1(schema: unknown): CliInputAdviceV1;
55
+ export declare const FLAT_SAFE_KEY_REGEX: RegExp;
56
+ export declare const FLAT_ENCODING_GUIDELINES: readonly string[];
57
+ /**
58
+ * 单个字段的输入建议明细。
59
+ */
60
+ export interface ActionInputFieldAdvice {
61
+ /** 字段路径(属性名) */
62
+ path: string;
63
+ /** 字段类型字符串 */
64
+ type: string;
65
+ /** 是否为必填字段 */
66
+ required: boolean;
67
+ /** 字段名是否满足扁平编码安全规范 */
68
+ flatSafe: boolean;
69
+ /** 编码模板(如 "name=TEXT"、"age:=NUMBER"、"meta:=JSON"),非直接可执行 token */
70
+ assignmentTemplate?: string;
71
+ /** 人类说明文字,如 "大型结构建议使用 --input-file" */
72
+ hint?: string;
73
+ /** 字段描述信息 */
74
+ description?: string;
75
+ }
76
+ /**
77
+ * Action 输入模式整体编码顾问分析报告。
78
+ */
79
+ export interface ActionInputAdvice {
80
+ /** 根模式是否支持扁平入参赋值(仅当根模式为对象且所有 required 字段均具备 flatSafe 赋值方案时为 true) */
81
+ flatSupported: boolean;
82
+ /** 是否存在至少一个可扁平化的字段 */
83
+ hasFlatFields: boolean;
84
+ /** 字段明细清单 */
85
+ fields: ActionInputFieldAdvice[];
86
+ /** 所有必填字段的编码模板数组 */
87
+ requiredTemplates: string[];
88
+ /** 可选字段的编码模板数组 */
89
+ optionalTemplates: string[];
90
+ /** 结构化提示与降级说明清单 */
91
+ notes: string[];
92
+ }
93
+ /**
94
+ * 依据 inputSchema 构造统一的 Action 输入编码建议。
95
+ *
96
+ * @param schema Action 的 inputSchema 定义
97
+ * @returns 结构化编码建议报告
98
+ */
99
+ export declare function buildActionInputAdvice(schema: unknown): ActionInputAdvice;
100
+ export { formatActionDetail } from "./describe.js";