@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.
- package/README.md +61 -30
- package/dist/app/app.d.ts +73 -0
- package/dist/app/app.js +700 -0
- package/dist/app/index.d.ts +2 -0
- package/dist/app/index.js +2 -0
- package/dist/app/types.d.ts +283 -0
- package/dist/app/types.js +1 -0
- package/dist/catalog/action-index.d.ts +9 -0
- package/dist/catalog/action-index.js +93 -0
- package/dist/catalog/action-resolver.d.ts +20 -0
- package/dist/catalog/action-resolver.js +95 -0
- package/dist/catalog/index.d.ts +5 -0
- package/dist/catalog/index.js +5 -0
- package/dist/catalog/location-registry.d.ts +15 -0
- package/dist/catalog/location-registry.js +138 -0
- package/dist/catalog/package-catalog.d.ts +7 -0
- package/dist/catalog/package-catalog.js +76 -0
- package/dist/catalog/types.d.ts +68 -0
- package/dist/catalog/types.js +1 -0
- package/dist/doctor/doctor.d.ts +7 -0
- package/dist/doctor/doctor.js +613 -0
- package/dist/doctor/index.d.ts +2 -0
- package/dist/doctor/index.js +2 -0
- package/dist/doctor/types.d.ts +23 -0
- package/dist/doctor/types.js +1 -0
- package/dist/errors.d.ts +122 -0
- package/dist/errors.js +123 -0
- package/dist/execution/index.d.ts +2 -0
- package/dist/execution/index.js +2 -0
- package/dist/execution/service.d.ts +79 -0
- package/dist/execution/service.js +633 -0
- package/dist/execution/types.d.ts +131 -0
- package/dist/execution/types.js +1 -0
- package/dist/export/index.d.ts +1 -0
- package/dist/export/index.js +1 -0
- package/dist/export/templates.d.ts +71 -0
- package/dist/export/templates.js +621 -0
- package/dist/filter/index.d.ts +1 -0
- package/dist/filter/index.js +1 -0
- package/dist/filter/intent.d.ts +33 -0
- package/dist/filter/intent.js +123 -0
- package/dist/host/host.d.ts +55 -0
- package/dist/host/host.js +740 -0
- package/dist/host/index.d.ts +2 -0
- package/dist/host/index.js +2 -0
- package/dist/host/types.d.ts +81 -0
- package/dist/host/types.js +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +20 -0
- package/dist/ipc/diagnostic.d.ts +65 -0
- package/dist/ipc/diagnostic.js +129 -0
- package/dist/ipc/host.d.ts +7 -0
- package/dist/ipc/host.js +93 -0
- package/dist/ipc/index.d.ts +4 -0
- package/dist/ipc/index.js +4 -0
- package/dist/ipc/target.d.ts +56 -0
- package/dist/ipc/target.js +297 -0
- package/dist/ipc/types.d.ts +42 -0
- package/dist/ipc/types.js +1 -0
- package/dist/platform/default.d.ts +32 -0
- package/dist/platform/default.js +40 -0
- package/dist/platform/index.d.ts +3 -0
- package/dist/platform/index.js +3 -0
- package/dist/platform/node-fs.d.ts +37 -0
- package/dist/platform/node-fs.js +81 -0
- package/dist/platform/types.d.ts +104 -0
- package/dist/platform/types.js +1 -0
- package/dist/profile/client.d.ts +162 -0
- package/dist/profile/client.js +467 -0
- package/dist/profile/index.d.ts +3 -0
- package/dist/profile/index.js +3 -0
- package/dist/profile/manager.d.ts +47 -0
- package/dist/profile/manager.js +294 -0
- package/dist/profile/types.d.ts +61 -0
- package/dist/profile/types.js +1 -0
- package/dist/project/closure.d.ts +25 -0
- package/dist/project/closure.js +68 -0
- package/dist/project/digest.d.ts +29 -0
- package/dist/project/digest.js +324 -0
- package/dist/project/index.d.ts +10 -0
- package/dist/project/index.js +10 -0
- package/dist/project/init.d.ts +26 -0
- package/dist/project/init.js +175 -0
- package/dist/project/loader.d.ts +99 -0
- package/dist/project/loader.js +484 -0
- package/dist/project/lockfile.d.ts +55 -0
- package/dist/project/lockfile.js +175 -0
- package/dist/project/manifest.d.ts +22 -0
- package/dist/project/manifest.js +220 -0
- package/dist/project/resolver.d.ts +116 -0
- package/dist/project/resolver.js +376 -0
- package/dist/project/transactions.d.ts +103 -0
- package/dist/project/transactions.js +1203 -0
- package/dist/project/types-generator.d.ts +33 -0
- package/dist/project/types-generator.js +168 -0
- package/dist/project/types.d.ts +107 -0
- package/dist/project/types.js +1 -0
- package/dist/registry/index.d.ts +5 -0
- package/dist/registry/index.js +5 -0
- package/dist/registry/lock.d.ts +27 -0
- package/dist/registry/lock.js +93 -0
- package/dist/registry/registry.d.ts +45 -0
- package/dist/registry/registry.js +611 -0
- package/dist/registry/resolve.d.ts +62 -0
- package/dist/registry/resolve.js +195 -0
- package/dist/registry/scan.d.ts +38 -0
- package/dist/registry/scan.js +135 -0
- package/dist/registry/types.d.ts +117 -0
- package/dist/registry/types.js +1 -0
- package/dist/runtime/action-collection.d.ts +27 -0
- package/dist/runtime/action-collection.js +57 -0
- package/dist/runtime/clock.d.ts +19 -0
- package/dist/runtime/clock.js +17 -0
- package/dist/runtime/context.d.ts +86 -0
- package/dist/runtime/context.js +242 -0
- package/dist/runtime/env.d.ts +56 -0
- package/dist/runtime/env.js +159 -0
- package/dist/runtime/events.d.ts +93 -0
- package/dist/runtime/events.js +604 -0
- package/dist/runtime/execution-manager.d.ts +48 -0
- package/dist/runtime/execution-manager.js +66 -0
- package/dist/runtime/index.d.ts +10 -0
- package/dist/runtime/index.js +10 -0
- package/dist/runtime/module-loader.d.ts +34 -0
- package/dist/runtime/module-loader.js +16 -0
- package/dist/runtime/process.d.ts +9 -0
- package/dist/runtime/process.js +146 -0
- package/dist/runtime/runner.d.ts +293 -0
- package/dist/runtime/runner.js +984 -0
- package/dist/runtime/standalone.d.ts +89 -0
- package/dist/runtime/standalone.js +536 -0
- package/dist/schema/validator.d.ts +28 -0
- package/dist/schema/validator.js +116 -0
- package/dist/server/body.d.ts +40 -0
- package/dist/server/body.js +93 -0
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.js +5 -0
- package/dist/server/routes/actions.d.ts +5 -0
- package/dist/server/routes/actions.js +298 -0
- package/dist/server/routes/common.d.ts +47 -0
- package/dist/server/routes/common.js +104 -0
- package/dist/server/routes/config.d.ts +6 -0
- package/dist/server/routes/config.js +173 -0
- package/dist/server/routes/doctor.d.ts +5 -0
- package/dist/server/routes/doctor.js +63 -0
- package/dist/server/routes/health.d.ts +5 -0
- package/dist/server/routes/health.js +35 -0
- package/dist/server/routes/index.d.ts +9 -0
- package/dist/server/routes/index.js +9 -0
- package/dist/server/routes/info.d.ts +7 -0
- package/dist/server/routes/info.js +158 -0
- package/dist/server/routes/playbooks.d.ts +5 -0
- package/dist/server/routes/playbooks.js +134 -0
- package/dist/server/routes/runs.d.ts +5 -0
- package/dist/server/routes/runs.js +343 -0
- package/dist/server/routes/state.d.ts +6 -0
- package/dist/server/routes/state.js +169 -0
- package/dist/server/security.d.ts +44 -0
- package/dist/server/security.js +101 -0
- package/dist/server/server.d.ts +15 -0
- package/dist/server/server.js +355 -0
- package/dist/server/types.d.ts +78 -0
- package/dist/server/types.js +1 -0
- package/dist/storage/data-dir-lock.d.ts +119 -0
- package/dist/storage/data-dir-lock.js +1016 -0
- package/dist/storage/driver.d.ts +9 -0
- package/dist/storage/driver.js +59 -0
- package/dist/storage/index.d.ts +64 -0
- package/dist/storage/index.js +98 -0
- package/dist/storage/lazy.d.ts +8 -0
- package/dist/storage/lazy.js +44 -0
- package/dist/storage/mask.d.ts +26 -0
- package/dist/storage/mask.js +48 -0
- package/dist/storage/params.d.ts +13 -0
- package/dist/storage/params.js +32 -0
- package/dist/storage/sqlite.d.ts +79 -0
- package/dist/storage/sqlite.js +689 -0
- package/dist/storage/types.d.ts +172 -0
- package/dist/storage/types.js +14 -0
- package/dist/target/index.d.ts +4 -0
- package/dist/target/index.js +4 -0
- package/dist/target/local.d.ts +52 -0
- package/dist/target/local.js +343 -0
- package/dist/target/remote.d.ts +76 -0
- package/dist/target/remote.js +839 -0
- package/dist/target/target.d.ts +6 -0
- package/dist/target/target.js +35 -0
- package/dist/target/types.d.ts +246 -0
- package/dist/target/types.js +34 -0
- package/dist/utils/index.d.ts +49 -0
- package/dist/utils/index.js +180 -0
- package/dist/version.d.ts +4 -0
- package/dist/version.js +4 -0
- package/package.json +13 -13
- package/src/build/index.ts +0 -1
- 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/index.ts +0 -5
- 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/index.ts +0 -2
- 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/index.ts +0 -1
- package/src/export/templates.ts +0 -590
- package/src/filter/index.ts +0 -1
- package/src/filter/intent.ts +0 -154
- package/src/index.ts +0 -16
- package/src/profile/client.ts +0 -552
- package/src/profile/index.ts +0 -3
- package/src/profile/manager.ts +0 -341
- package/src/profile/types.ts +0 -71
- package/src/project/index.ts +0 -4
- 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/index.ts +0 -2
- 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/index.ts +0 -10
- 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/index.ts +0 -7
- 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/index.ts +0 -9
- 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/mask.ts +0 -34
- package/src/storage/sqlite.ts +0 -714
- package/src/storage/types.ts +0 -139
- package/src/utils/index.ts +0 -62
package/src/export/templates.ts
DELETED
|
@@ -1,590 +0,0 @@
|
|
|
1
|
-
import { basename } from "node:path";
|
|
2
|
-
import type { ActionDefinition } from "@actiondock/sdk";
|
|
3
|
-
import type { PlaybookDefinition, ProjectConfig } from "../project/types";
|
|
4
|
-
|
|
5
|
-
function getCleanSkillMetadata(config: ProjectConfig) {
|
|
6
|
-
const cleanName = config.id.replace(/[^a-zA-Z0-9-_]/g, "-").toLowerCase();
|
|
7
|
-
const desc = config.description || `AI Agent skill for ${config.name} (${config.id})`;
|
|
8
|
-
return { cleanName, desc };
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function renderActionListMarkdown(
|
|
12
|
-
actions: ActionDefinition[],
|
|
13
|
-
options: { packageId?: string } = {}
|
|
14
|
-
): string {
|
|
15
|
-
return actions
|
|
16
|
-
.map((a) => {
|
|
17
|
-
const aDesc = a.description ? ` - ${a.description}` : "";
|
|
18
|
-
const idLabel = options.packageId
|
|
19
|
-
? `\`${options.packageId}/${a.id}\` (或 \`${a.id}\`)`
|
|
20
|
-
: `\`${a.id}\``;
|
|
21
|
-
|
|
22
|
-
const lines: string[] = [`- ${idLabel}${aDesc}`];
|
|
23
|
-
|
|
24
|
-
// 标注元数据解析
|
|
25
|
-
if (a.annotations && typeof a.annotations === "object") {
|
|
26
|
-
const annoList: string[] = [];
|
|
27
|
-
if ((a.annotations as any).readOnly === true) {
|
|
28
|
-
annoList.push("只读操作");
|
|
29
|
-
}
|
|
30
|
-
if ((a.annotations as any).destructive === true) {
|
|
31
|
-
annoList.push("破坏性操作(执行前须向用户确认)");
|
|
32
|
-
}
|
|
33
|
-
if (annoList.length > 0) {
|
|
34
|
-
lines.push(` - 属性标注: ${annoList.join(", ")}`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// 输入参数模式解析
|
|
39
|
-
if (
|
|
40
|
-
a.inputSchema &&
|
|
41
|
-
typeof a.inputSchema === "object" &&
|
|
42
|
-
(a.inputSchema as any).properties
|
|
43
|
-
) {
|
|
44
|
-
const props = (a.inputSchema as any).properties as Record<string, any>;
|
|
45
|
-
const req = ((a.inputSchema as any).required || []) as string[];
|
|
46
|
-
const propKeys = Object.keys(props);
|
|
47
|
-
|
|
48
|
-
if (propKeys.length > 0) {
|
|
49
|
-
lines.push(" - 输入参数:");
|
|
50
|
-
for (const k of propKeys) {
|
|
51
|
-
const p = props[k] || {};
|
|
52
|
-
const typeStr = p.type ? `\`${p.type}\`` : "`any`";
|
|
53
|
-
const reqStr = req.includes(k) ? ", 必填" : "";
|
|
54
|
-
const descStr = p.description ? `: ${p.description}` : "";
|
|
55
|
-
const defStr =
|
|
56
|
-
p.default !== undefined
|
|
57
|
-
? ` (默认值: \`${JSON.stringify(p.default)}\`)`
|
|
58
|
-
: "";
|
|
59
|
-
lines.push(` - \`${k}\` (${typeStr}${reqStr})${descStr}${defStr}`);
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
lines.push(" - 输入参数: 无");
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
lines.push(" - 输入参数: 无");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// 输出字段模式解析
|
|
69
|
-
if (
|
|
70
|
-
a.outputSchema &&
|
|
71
|
-
typeof a.outputSchema === "object" &&
|
|
72
|
-
(a.outputSchema as any).properties
|
|
73
|
-
) {
|
|
74
|
-
const outProps = (a.outputSchema as any).properties as Record<string, any>;
|
|
75
|
-
const outKeys = Object.keys(outProps);
|
|
76
|
-
if (outKeys.length > 0) {
|
|
77
|
-
lines.push(" - 输出字段:");
|
|
78
|
-
for (const k of outKeys) {
|
|
79
|
-
const p = outProps[k] || {};
|
|
80
|
-
const typeStr = p.type ? `\`${p.type}\`` : "`any`";
|
|
81
|
-
const descStr = p.description ? `: ${p.description}` : "";
|
|
82
|
-
lines.push(` - \`${k}\` (${typeStr})${descStr}`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return lines.join("\n");
|
|
88
|
-
})
|
|
89
|
-
.join("\n\n");
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function renderPlaybookSectionMarkdown(playbooks: PlaybookDefinition[]): string {
|
|
93
|
-
if (playbooks.length === 0) return "";
|
|
94
|
-
const list = playbooks
|
|
95
|
-
.map((p) => {
|
|
96
|
-
const rel = `./playbooks/${basename(p.filePath)}`;
|
|
97
|
-
return `- **${p.id}** (\`${rel}\`): ${p.description || "业务操作指南"}`;
|
|
98
|
-
})
|
|
99
|
-
.join("\n");
|
|
100
|
-
return `
|
|
101
|
-
## 业务操作规程
|
|
102
|
-
|
|
103
|
-
> [!IMPORTANT]
|
|
104
|
-
> **规程优先准则**:当处理复合业务任务时,智能体必须优先检查是否存在匹配场景的 Playbook。若存在规程,必须优先查阅并严格遵循规程界定的步骤时序与校验逻辑推进,严禁无序拼凑调用底层 Action。
|
|
105
|
-
|
|
106
|
-
Playbook SOPs 为复杂业务任务提供逐步指导规程。详细规程请查阅对应文档:
|
|
107
|
-
|
|
108
|
-
${list}
|
|
109
|
-
`;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function generateSourceSkillMd(
|
|
113
|
-
config: ProjectConfig,
|
|
114
|
-
actions: ActionDefinition[],
|
|
115
|
-
playbooks: PlaybookDefinition[]
|
|
116
|
-
): string {
|
|
117
|
-
const { cleanName, desc } = getCleanSkillMetadata(config);
|
|
118
|
-
const pkgId = config.id;
|
|
119
|
-
const firstAction = actions[0]?.id || "sample.greet";
|
|
120
|
-
|
|
121
|
-
const playbookSection = renderPlaybookSectionMarkdown(playbooks);
|
|
122
|
-
const actionListMd = renderActionListMarkdown(actions, { packageId: pkgId });
|
|
123
|
-
|
|
124
|
-
return `---
|
|
125
|
-
name: ${cleanName}
|
|
126
|
-
description: ${desc}
|
|
127
|
-
---
|
|
128
|
-
|
|
129
|
-
# ${config.name} (${config.id})
|
|
130
|
-
|
|
131
|
-
${desc}
|
|
132
|
-
|
|
133
|
-
## ActionDock 运行时
|
|
134
|
-
|
|
135
|
-
本技能为 **ActionDock 源码型技能包**。智能体可直接通过宿主环境中已安装的 ActionDock 命令行工具 \`ad\` 执行其中的 Action。
|
|
136
|
-
|
|
137
|
-
### 注册与链接
|
|
138
|
-
|
|
139
|
-
在初次调用或初始化时,将包含本 \`SKILL.md\` 的目录解析为 \`<skill_root>\` 并完成注册:
|
|
140
|
-
|
|
141
|
-
\`\`\`bash
|
|
142
|
-
ad link "<skill_root>"
|
|
143
|
-
\`\`\`
|
|
144
|
-
|
|
145
|
-
> \`ad link\` 天然具备幂等性,同一 Package 多次执行会直接更新路径,可安全重复调用。
|
|
146
|
-
|
|
147
|
-
### 动作参数契约按需调阅
|
|
148
|
-
|
|
149
|
-
在调用未知参数的 Action 前,可在终端执行命令按需查阅该 Action 的输入输出模式与详细说明:
|
|
150
|
-
|
|
151
|
-
\`\`\`bash
|
|
152
|
-
ad action show ${pkgId}/${firstAction}
|
|
153
|
-
\`\`\`
|
|
154
|
-
|
|
155
|
-
### 执行 Action
|
|
156
|
-
|
|
157
|
-
为避免多技能之间的 Action ID 命名冲突,建议统一使用带有 Package 前缀的完全限定 ID。
|
|
158
|
-
|
|
159
|
-
推荐最佳实践:使用文件传递参数,杜绝终端引号转义问题:
|
|
160
|
-
|
|
161
|
-
\`\`\`bash
|
|
162
|
-
# 写入参数到临时文件并通过 --input-file 传递
|
|
163
|
-
cat << 'EOF' > /tmp/input.json
|
|
164
|
-
{
|
|
165
|
-
"param": "value"
|
|
166
|
-
}
|
|
167
|
-
EOF
|
|
168
|
-
ad run ${pkgId}/${firstAction} --input-file /tmp/input.json
|
|
169
|
-
\`\`\`
|
|
170
|
-
|
|
171
|
-
亦可通过内联参数进行简易命令调用:
|
|
172
|
-
|
|
173
|
-
\`\`\`bash
|
|
174
|
-
ad run ${pkgId}/${firstAction} --input '{"param": "value"}'
|
|
175
|
-
\`\`\`
|
|
176
|
-
|
|
177
|
-
> **免注册本地执行**:
|
|
178
|
-
> 若工作目录已位于本技能根目录,亦可直接免 link 执行:
|
|
179
|
-
> \`\`\`bash
|
|
180
|
-
> cd <skill_root>
|
|
181
|
-
> ad run <action-id> --input-file /tmp/input.json
|
|
182
|
-
> \`\`\`
|
|
183
|
-
|
|
184
|
-
### 结构化响应解析
|
|
185
|
-
|
|
186
|
-
所有 Action 执行结果均在 \`stdout\` 输出标准格式的 JSON 信封:
|
|
187
|
-
|
|
188
|
-
\`\`\`json
|
|
189
|
-
// 执行成功响应 (ok 为 true)
|
|
190
|
-
{
|
|
191
|
-
"ok": true,
|
|
192
|
-
"runId": "01J...",
|
|
193
|
-
"data": { ... }
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// 执行失败响应 (ok 为 false)
|
|
197
|
-
{
|
|
198
|
-
"ok": false,
|
|
199
|
-
"runId": "01J...",
|
|
200
|
-
"error": {
|
|
201
|
-
"code": "ACTION_EXECUTION_FAILED",
|
|
202
|
-
"message": "错误详细描述信息"
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
\`\`\`
|
|
206
|
-
|
|
207
|
-
- \`stdout\`:标准 JSON 信封结果。当 \`ok\` 为 \`true\` 时,从 \`data\` 提取业务返回值推进后续步骤;当 \`ok\` 为 \`false\` 时,从 \`error\` 提取错误码与信息以判定自愈策略或上报。
|
|
208
|
-
- \`stderr\`:执行日志与诊断跟踪信息。
|
|
209
|
-
${playbookSection}
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
## Action 目录
|
|
213
|
-
|
|
214
|
-
${actionListMd}
|
|
215
|
-
|
|
216
|
-
---
|
|
217
|
-
|
|
218
|
-
## 运行时配置与持久化状态
|
|
219
|
-
|
|
220
|
-
如需检查或配置该 Package 的运行时参数与持久化数据:
|
|
221
|
-
|
|
222
|
-
\`\`\`bash
|
|
223
|
-
# 查看与设置配置项
|
|
224
|
-
ad config list --package ${pkgId}
|
|
225
|
-
ad config set KEY VALUE --package ${pkgId}
|
|
226
|
-
|
|
227
|
-
# 查看与检索状态数据
|
|
228
|
-
ad state list --package ${pkgId}
|
|
229
|
-
ad state get KEY --package ${pkgId}
|
|
230
|
-
\`\`\`
|
|
231
|
-
|
|
232
|
-
---
|
|
233
|
-
|
|
234
|
-
## 故障排查与环境安装指引(按需查阅)
|
|
235
|
-
|
|
236
|
-
> [!NOTE]
|
|
237
|
-
> **按需排查原则**:默认宿主环境中已预置 \`ad\` 命令行工具与 Node.js 运行环境。正常执行流程直接调用上述 Action 即可,**严禁在任务启动前盲目进行前置环境检查或体检**;仅在终端明确报错提示命令不存在(如 \`ad: command not found\`)时,方可按本节指引安装初始化。
|
|
238
|
-
|
|
239
|
-
### 命令行工具未找到时的安装指引
|
|
240
|
-
|
|
241
|
-
若宿主环境未安装 \`ad\` 命令行工具,请依次按如下步骤完成安装:
|
|
242
|
-
|
|
243
|
-
- **环境要求**:Node.js 版本大于等于 22.12.0(执行 \`node -v\` 确认)。
|
|
244
|
-
- **全局安装 ActionDock 命令行工具**:
|
|
245
|
-
\`\`\`bash
|
|
246
|
-
npm install -g @actiondock/cli
|
|
247
|
-
\`\`\`
|
|
248
|
-
- **验证工具就绪**:
|
|
249
|
-
\`\`\`bash
|
|
250
|
-
ad --version
|
|
251
|
-
\`\`\`
|
|
252
|
-
- **环境诊断与体检**:
|
|
253
|
-
安装完成后若仍遇到异常,执行体检命令排查:
|
|
254
|
-
\`\`\`bash
|
|
255
|
-
ad doctor
|
|
256
|
-
\`\`\`
|
|
257
|
-
- **完成安装后重新链接本技能**:
|
|
258
|
-
\`\`\`bash
|
|
259
|
-
ad link "<skill_root>"
|
|
260
|
-
\`\`\`
|
|
261
|
-
`;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
export function generateStandaloneSkillMd(
|
|
265
|
-
config: ProjectConfig,
|
|
266
|
-
actions: ActionDefinition[],
|
|
267
|
-
playbooks: PlaybookDefinition[],
|
|
268
|
-
binaryRelPath = "./bin/action-bin"
|
|
269
|
-
): string {
|
|
270
|
-
const { cleanName, desc } = getCleanSkillMetadata(config);
|
|
271
|
-
const firstAction = actions[0]?.id || "sample.greet";
|
|
272
|
-
|
|
273
|
-
const playbookSection = renderPlaybookSectionMarkdown(playbooks);
|
|
274
|
-
const actionListMd = renderActionListMarkdown(actions);
|
|
275
|
-
|
|
276
|
-
return `---
|
|
277
|
-
name: ${cleanName}
|
|
278
|
-
description: ${desc}
|
|
279
|
-
---
|
|
280
|
-
|
|
281
|
-
# ${config.name} (${config.id})
|
|
282
|
-
|
|
283
|
-
${desc}
|
|
284
|
-
|
|
285
|
-
## 如何调用 Action
|
|
286
|
-
|
|
287
|
-
使用技能目录中自带的独立可执行程序 \`${binaryRelPath}\` 即可完成工具发现与调用。
|
|
288
|
-
**该工具无需在系统预先安装任何依赖**(无需安装 Node.js、Bun、Python 或 Java)。
|
|
289
|
-
|
|
290
|
-
### 发现可用 Action 清单
|
|
291
|
-
|
|
292
|
-
\`\`\`bash
|
|
293
|
-
${binaryRelPath} list --json
|
|
294
|
-
\`\`\`
|
|
295
|
-
|
|
296
|
-
### 查看 Action 结构与入参规范
|
|
297
|
-
|
|
298
|
-
\`\`\`bash
|
|
299
|
-
${binaryRelPath} describe <action-id> --json
|
|
300
|
-
\`\`\`
|
|
301
|
-
|
|
302
|
-
### 执行 Action
|
|
303
|
-
|
|
304
|
-
推荐最佳实践:使用文件传递参数,杜绝终端引号转义问题:
|
|
305
|
-
|
|
306
|
-
\`\`\`bash
|
|
307
|
-
# 写入参数到临时文件并通过 --input-file 传递
|
|
308
|
-
cat << 'EOF' > /tmp/input.json
|
|
309
|
-
{
|
|
310
|
-
"param": "value"
|
|
311
|
-
}
|
|
312
|
-
EOF
|
|
313
|
-
${binaryRelPath} run <action-id> --input-file /tmp/input.json
|
|
314
|
-
\`\`\`
|
|
315
|
-
|
|
316
|
-
亦可通过内联参数进行简易命令调用:
|
|
317
|
-
|
|
318
|
-
\`\`\`bash
|
|
319
|
-
${binaryRelPath} run ${firstAction} --input '{"param": "value"}'
|
|
320
|
-
\`\`\`
|
|
321
|
-
|
|
322
|
-
### 结构化响应解析
|
|
323
|
-
|
|
324
|
-
所有 Action 执行结果均在 \`stdout\` 输出标准格式的 JSON 结果:
|
|
325
|
-
|
|
326
|
-
\`\`\`json
|
|
327
|
-
// 执行成功响应 (ok 为 true)
|
|
328
|
-
{
|
|
329
|
-
"ok": true,
|
|
330
|
-
"runId": "01J...",
|
|
331
|
-
"data": { ... }
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// 执行失败响应 (ok 为 false)
|
|
335
|
-
{
|
|
336
|
-
"ok": false,
|
|
337
|
-
"runId": "01J...",
|
|
338
|
-
"error": {
|
|
339
|
-
"code": "ACTION_EXECUTION_FAILED",
|
|
340
|
-
"message": "错误详细描述信息"
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
\`\`\`
|
|
344
|
-
|
|
345
|
-
- \`stdout\`:标准 JSON 结果信封。当 \`ok\` 为 \`true\` 时,从 \`data\` 提取业务数据;当 \`ok\` 为 \`false\` 时,从 \`error\` 读取错误原因以处理异常。
|
|
346
|
-
- \`stderr\`:执行日志与诊断信息。
|
|
347
|
-
${playbookSection}
|
|
348
|
-
---
|
|
349
|
-
|
|
350
|
-
## Action 目录
|
|
351
|
-
|
|
352
|
-
${actionListMd}
|
|
353
|
-
|
|
354
|
-
---
|
|
355
|
-
|
|
356
|
-
## 运行时配置与持久化状态
|
|
357
|
-
|
|
358
|
-
独立二进制程序会自动管理其本地 SQLite 数据库。如需检查或配置:
|
|
359
|
-
|
|
360
|
-
\`\`\`bash
|
|
361
|
-
# 查看与设置配置项
|
|
362
|
-
${binaryRelPath} config list
|
|
363
|
-
${binaryRelPath} config set KEY VALUE
|
|
364
|
-
|
|
365
|
-
# 查看与检索状态数据
|
|
366
|
-
${binaryRelPath} state list
|
|
367
|
-
${binaryRelPath} state get KEY
|
|
368
|
-
\`\`\`
|
|
369
|
-
`;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
export function generateSkillMd(
|
|
373
|
-
config: ProjectConfig,
|
|
374
|
-
actions: ActionDefinition[],
|
|
375
|
-
playbooks: PlaybookDefinition[],
|
|
376
|
-
optionsOrBinaryPath: string | { mode?: "source" | "standalone"; binaryRelPath?: string } = "./bin/action-bin"
|
|
377
|
-
): string {
|
|
378
|
-
if (typeof optionsOrBinaryPath === "string") {
|
|
379
|
-
return generateStandaloneSkillMd(config, actions, playbooks, optionsOrBinaryPath);
|
|
380
|
-
}
|
|
381
|
-
if (optionsOrBinaryPath.mode === "source") {
|
|
382
|
-
return generateSourceSkillMd(config, actions, playbooks);
|
|
383
|
-
}
|
|
384
|
-
return generateStandaloneSkillMd(config, actions, playbooks, optionsOrBinaryPath.binaryRelPath || "./bin/action-bin");
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
export interface CompositeSkillPackageInfo {
|
|
388
|
-
config: ProjectConfig;
|
|
389
|
-
actions: Array<{ id: string; description?: string }>;
|
|
390
|
-
playbooks: Array<{ id: string; name?: string; description?: string; filePath: string }>;
|
|
391
|
-
packageDir: string;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* 生成多包聚合的复合模式 SKILL.md 文档。
|
|
396
|
-
*/
|
|
397
|
-
export function generateCompositeSkillMd(
|
|
398
|
-
bundleName: string,
|
|
399
|
-
description: string,
|
|
400
|
-
packages: CompositeSkillPackageInfo[]
|
|
401
|
-
): string {
|
|
402
|
-
const cleanName = bundleName.replace(/[^a-zA-Z0-9-_]/g, "-").toLowerCase();
|
|
403
|
-
const samplePkg = packages.find((p) => p.actions && p.actions.length > 0);
|
|
404
|
-
const sampleActionId = samplePkg
|
|
405
|
-
? `${samplePkg.config.id}/${samplePkg.actions[0].id}`
|
|
406
|
-
: "sample.greet";
|
|
407
|
-
|
|
408
|
-
const actionSections = packages
|
|
409
|
-
.map((pkg) => {
|
|
410
|
-
const actList = pkg.actions
|
|
411
|
-
.map((a) => {
|
|
412
|
-
const desc = a.description ? `: ${a.description}` : "";
|
|
413
|
-
return `- \`${pkg.config.id}/${a.id}\`${desc}`;
|
|
414
|
-
})
|
|
415
|
-
.join("\n");
|
|
416
|
-
return `### ${pkg.config.name} (${pkg.config.id})\n${actList || "- 无可用 Action"}`;
|
|
417
|
-
})
|
|
418
|
-
.join("\n\n");
|
|
419
|
-
|
|
420
|
-
const playbookEntries: string[] = [];
|
|
421
|
-
for (const pkg of packages) {
|
|
422
|
-
for (const pb of pkg.playbooks) {
|
|
423
|
-
const relPath = `packages/${pkg.packageDir}/playbooks/${basename(pb.filePath)}`;
|
|
424
|
-
playbookEntries.push(`- [${pb.name || pb.id}](${relPath}): ${pb.description || "标准操作规程"}`);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
const playbookSection =
|
|
429
|
-
playbookEntries.length > 0
|
|
430
|
-
? `## 推荐操作规程\n\n涉及多步骤或业务流程时,优先遵循以下原位规程:\n\n${playbookEntries.join("\n")}\n\n---\n`
|
|
431
|
-
: "";
|
|
432
|
-
|
|
433
|
-
return `---
|
|
434
|
-
name: ${cleanName}
|
|
435
|
-
description: ${description}
|
|
436
|
-
---
|
|
437
|
-
|
|
438
|
-
# ${bundleName} 复合技能套件
|
|
439
|
-
|
|
440
|
-
${description}
|
|
441
|
-
|
|
442
|
-
## ActionDock 运行时初始化
|
|
443
|
-
|
|
444
|
-
本技能为 **ActionDock 复合工作区技能包**,聚合了多个功能包。智能体在初次调用或初始化时,在当前技能根目录执行注册命令:
|
|
445
|
-
|
|
446
|
-
\`\`\`bash
|
|
447
|
-
ad link "<skill_root>"
|
|
448
|
-
\`\`\`
|
|
449
|
-
|
|
450
|
-
> \`ad link\` 会自动识别并注册工作区下的所有子包,使其中的 Action 随时可以通过完全限定标识调用。
|
|
451
|
-
|
|
452
|
-
## 动作参数契约按需调阅
|
|
453
|
-
|
|
454
|
-
为节省上下文开销,各 Action 的详细参数结构不静态内嵌在说明书中。在调用未知参数的 Action 前,可在终端执行命令查阅输入输出约束:
|
|
455
|
-
|
|
456
|
-
\`\`\`bash
|
|
457
|
-
ad action show ${sampleActionId}
|
|
458
|
-
\`\`\`
|
|
459
|
-
|
|
460
|
-
## 可用 Action 工具清单
|
|
461
|
-
|
|
462
|
-
${actionSections}
|
|
463
|
-
|
|
464
|
-
---
|
|
465
|
-
|
|
466
|
-
${playbookSection}
|
|
467
|
-
## 标准调用命令
|
|
468
|
-
|
|
469
|
-
推荐使用参数文件传递内容,杜绝终端引号转义问题:
|
|
470
|
-
|
|
471
|
-
\`\`\`bash
|
|
472
|
-
cat << 'EOF' > /tmp/input.json
|
|
473
|
-
{
|
|
474
|
-
"param": "value"
|
|
475
|
-
}
|
|
476
|
-
EOF
|
|
477
|
-
ad run ${sampleActionId} --input-file /tmp/input.json
|
|
478
|
-
\`\`\`
|
|
479
|
-
|
|
480
|
-
### 结构化响应解析
|
|
481
|
-
|
|
482
|
-
所有 Action 执行结果均在 \`stdout\` 输出标准格式的 JSON 信封:
|
|
483
|
-
|
|
484
|
-
\`\`\`json
|
|
485
|
-
// 执行成功响应 (ok 为 true)
|
|
486
|
-
{
|
|
487
|
-
"ok": true,
|
|
488
|
-
"runId": "01J...",
|
|
489
|
-
"data": { ... }
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
// 执行失败响应 (ok 为 false)
|
|
493
|
-
{
|
|
494
|
-
"ok": false,
|
|
495
|
-
"runId": "01J...",
|
|
496
|
-
"error": {
|
|
497
|
-
"code": "ACTION_EXECUTION_FAILED",
|
|
498
|
-
"message": "错误详细描述信息"
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
\`\`\`
|
|
502
|
-
`;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
export interface GenerateSkillJsonOptions {
|
|
507
|
-
mode?: "source" | "standalone";
|
|
508
|
-
executable?: string;
|
|
509
|
-
target?: string;
|
|
510
|
-
playbooks?: PlaybookDefinition[];
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
export function generateSkillJson(
|
|
514
|
-
config: ProjectConfig,
|
|
515
|
-
actions: ActionDefinition[],
|
|
516
|
-
binaryNameOrOptions?: string | GenerateSkillJsonOptions,
|
|
517
|
-
target = "host",
|
|
518
|
-
playbooksList: PlaybookDefinition[] = []
|
|
519
|
-
): string {
|
|
520
|
-
let mode: "source" | "standalone" = "source";
|
|
521
|
-
let executable: string | undefined;
|
|
522
|
-
let targetPlatform = target;
|
|
523
|
-
let playbooks = playbooksList;
|
|
524
|
-
|
|
525
|
-
if (typeof binaryNameOrOptions === "string") {
|
|
526
|
-
mode = "standalone";
|
|
527
|
-
executable = `./bin/${binaryNameOrOptions}`;
|
|
528
|
-
} else if (binaryNameOrOptions && typeof binaryNameOrOptions === "object") {
|
|
529
|
-
mode = binaryNameOrOptions.mode || (binaryNameOrOptions.executable ? "standalone" : "source");
|
|
530
|
-
executable = binaryNameOrOptions.executable;
|
|
531
|
-
targetPlatform = binaryNameOrOptions.target || target;
|
|
532
|
-
if (binaryNameOrOptions.playbooks) {
|
|
533
|
-
playbooks = binaryNameOrOptions.playbooks;
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
const manifest: Record<string, unknown> = {
|
|
538
|
-
schemaVersion: "2.0.0",
|
|
539
|
-
packageId: config.id,
|
|
540
|
-
name: config.name,
|
|
541
|
-
version: config.version,
|
|
542
|
-
description: config.description,
|
|
543
|
-
mode,
|
|
544
|
-
};
|
|
545
|
-
|
|
546
|
-
if (mode === "standalone" && executable) {
|
|
547
|
-
manifest.target = targetPlatform;
|
|
548
|
-
manifest.executable = executable;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
manifest.actions = actions.map((a: any) => {
|
|
552
|
-
const item: Record<string, unknown> = {
|
|
553
|
-
id: a.id,
|
|
554
|
-
};
|
|
555
|
-
if (a.entry) {
|
|
556
|
-
item.entry = a.entry;
|
|
557
|
-
}
|
|
558
|
-
if (a.description) {
|
|
559
|
-
item.description = a.description;
|
|
560
|
-
}
|
|
561
|
-
if (a.inputSchema !== undefined) {
|
|
562
|
-
item.inputSchema = a.inputSchema;
|
|
563
|
-
}
|
|
564
|
-
if (a.outputSchema !== undefined) {
|
|
565
|
-
item.outputSchema = a.outputSchema;
|
|
566
|
-
}
|
|
567
|
-
if (a.uses) {
|
|
568
|
-
item.uses = a.uses;
|
|
569
|
-
}
|
|
570
|
-
if (a.tags) {
|
|
571
|
-
item.tags = a.tags;
|
|
572
|
-
}
|
|
573
|
-
if (a.annotations) {
|
|
574
|
-
item.annotations = a.annotations;
|
|
575
|
-
}
|
|
576
|
-
return item;
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
if (playbooks && playbooks.length > 0) {
|
|
580
|
-
manifest.playbooks = playbooks.map((p) => ({
|
|
581
|
-
id: p.id,
|
|
582
|
-
description: p.description,
|
|
583
|
-
entry: `playbooks/${basename(p.filePath)}`,
|
|
584
|
-
}));
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
manifest.exportedAt = new Date().toISOString();
|
|
588
|
-
|
|
589
|
-
return JSON.stringify(manifest, null, 2) + "\n";
|
|
590
|
-
}
|
package/src/filter/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./intent";
|