@dsh-plus/agent-preset-rea 0.0.0-stage → 0.1.1
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/lib/client.js +1197 -0
- package/lib/index.d.ts +431 -0
- package/lib/index.js +1224 -0
- package/package.json +61 -3
- package/skills/reverse-engineer-anything/LICENSE +21 -0
- package/skills/reverse-engineer-anything/SKILL.md +342 -0
- package/skills/reverse-engineer-anything/references/android-applications.md +34 -0
- package/skills/reverse-engineer-anything/references/connection-and-recovery.md +127 -0
- package/skills/reverse-engineer-anything/references/evidence-workflows.md +71 -0
- package/skills/reverse-engineer-anything/references/javascript-applications.md +175 -0
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +277 -0
- package/skills/reverse-engineer-anything/references/runtime-observation.md +78 -0
- package/src/client/api.ts +76 -0
- package/src/client/card.tsx +145 -0
- package/src/client/client.ts +51 -0
- package/src/client/draft.ts +55 -0
- package/src/client/i18n.ts +134 -0
- package/src/client/install.tsx +274 -0
- package/src/client/styles.ts +57 -0
- package/src/config.ts +121 -0
- package/src/definition.ts +245 -0
- package/src/dto.ts +87 -0
- package/src/exec.ts +155 -0
- package/src/index.ts +186 -0
- package/src/jobs.ts +145 -0
- package/src/manager.ts +419 -0
- package/src/mcp.ts +83 -0
- package/src/ns.ts +9 -0
- package/src/prompt.ts +25 -0
- package/src/registration.ts +86 -0
- package/src/routes.ts +181 -0
- package/src/skill.ts +34 -0
- package/README.md +0 -3
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import { UnwrapVolatile } from "@dsh-plus/shared";
|
|
2
|
+
import z from "@deepseek-ai/schemastery";
|
|
3
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
4
|
+
import { PresetDefinition } from "@deepseek-ai/dsh-agent-preset-registry";
|
|
5
|
+
//#region src/config.d.ts
|
|
6
|
+
/** settings 命名空间(字面量即合法命名空间;配置卡片与运行期读取同一份)。 */
|
|
7
|
+
declare const SETTINGS_NS = "dsh-plus-agent-preset-rea";
|
|
8
|
+
declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
9
|
+
enabled: z<boolean, boolean, "defined">;
|
|
10
|
+
name: z<string, string, "defined">;
|
|
11
|
+
description: z<string, string, "defined">;
|
|
12
|
+
order: z<number, number, "defined">;
|
|
13
|
+
personaPrefix: z<string, string, "volatile-defined">;
|
|
14
|
+
mcpEnabled: z<boolean, boolean, "defined">;
|
|
15
|
+
mcpServerName: z<string, string, "defined">;
|
|
16
|
+
reaVersion: z<string, string, "defined">;
|
|
17
|
+
installRoot: z<string, string, "defined">;
|
|
18
|
+
proxyPort: z<number, number, "volatile-defined">;
|
|
19
|
+
mcpCommand: z<string, string, "defined">;
|
|
20
|
+
mcpArgs: z<string[], string[], "defined">;
|
|
21
|
+
inputSchemaProfile: z<"compact" | "full", "compact" | "full", "defined">;
|
|
22
|
+
outputSchemaProfile: z<"full" | "off", "full" | "off", "defined">;
|
|
23
|
+
toolCallTimeoutMs: z<number, number, "defined">;
|
|
24
|
+
failOnStartupError: z<boolean, boolean, "defined">;
|
|
25
|
+
extraSkillDirs: z<string[], string[], "defined">;
|
|
26
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
27
|
+
enabled: z<boolean, boolean, "defined">;
|
|
28
|
+
name: z<string, string, "defined">;
|
|
29
|
+
description: z<string, string, "defined">;
|
|
30
|
+
order: z<number, number, "defined">;
|
|
31
|
+
personaPrefix: z<string, string, "volatile-defined">;
|
|
32
|
+
mcpEnabled: z<boolean, boolean, "defined">;
|
|
33
|
+
mcpServerName: z<string, string, "defined">;
|
|
34
|
+
reaVersion: z<string, string, "defined">;
|
|
35
|
+
installRoot: z<string, string, "defined">;
|
|
36
|
+
proxyPort: z<number, number, "volatile-defined">;
|
|
37
|
+
mcpCommand: z<string, string, "defined">;
|
|
38
|
+
mcpArgs: z<string[], string[], "defined">;
|
|
39
|
+
inputSchemaProfile: z<"compact" | "full", "compact" | "full", "defined">;
|
|
40
|
+
outputSchemaProfile: z<"full" | "off", "full" | "off", "defined">;
|
|
41
|
+
toolCallTimeoutMs: z<number, number, "defined">;
|
|
42
|
+
failOnStartupError: z<boolean, boolean, "defined">;
|
|
43
|
+
extraSkillDirs: z<string[], string[], "defined">;
|
|
44
|
+
}>>, "plain">;
|
|
45
|
+
/** 活动字段形态(loader 解析产物:`personaPrefix` 为活动引用)。 */
|
|
46
|
+
type AgentPresetReaConfigFields = Schemastery.TypeT<typeof Config>;
|
|
47
|
+
/** 平面配置形态(消费面的读取形态,由活动引用解包得到)。 */
|
|
48
|
+
type AgentPresetReaConfig = UnwrapVolatile<AgentPresetReaConfigFields>;
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/exec.d.ts
|
|
51
|
+
/** npm 命令名(Windows 经 shell 执行,见 {@link spawnRunner} 注释)。 */
|
|
52
|
+
declare const NPM = "npm";
|
|
53
|
+
/** 作业取消(AbortSignal 触发后由 runner 抛出)。 */
|
|
54
|
+
declare class JobCancelled extends Error {
|
|
55
|
+
constructor();
|
|
56
|
+
}
|
|
57
|
+
/** 外部命令执行面。 */
|
|
58
|
+
interface CommandRunner {
|
|
59
|
+
run(command: string, args: string[], options: {
|
|
60
|
+
env: Record<string, string>;
|
|
61
|
+
signal: AbortSignal;
|
|
62
|
+
onLine(line: string): void;
|
|
63
|
+
}): Promise<{
|
|
64
|
+
code: number;
|
|
65
|
+
}>;
|
|
66
|
+
}
|
|
67
|
+
/** 作业执行上下文(阶段推进 + 日志 + 取消信号)。 */
|
|
68
|
+
interface JobTaskContext {
|
|
69
|
+
/** 进入第 step 个阶段(从 0 起,与 {@link JobOperation.phases} 对应)。 */
|
|
70
|
+
phase(step: number): void;
|
|
71
|
+
log(line: string): void;
|
|
72
|
+
signal: AbortSignal;
|
|
73
|
+
}
|
|
74
|
+
/** 一类作业:阶段名 + 实现。 */
|
|
75
|
+
interface JobOperation {
|
|
76
|
+
phases: string[];
|
|
77
|
+
run(ctx: JobTaskContext): Promise<string>;
|
|
78
|
+
}
|
|
79
|
+
/** 实际 runner:spawn 子进程、逐行回调、AbortSignal 触发即杀。 */
|
|
80
|
+
declare const spawnRunner: CommandRunner;
|
|
81
|
+
/**
|
|
82
|
+
* npm 子进程环境:继承宿主环境,附带代理端口(port > 0 时同时给 npm 与
|
|
83
|
+
* prebuild-install 注入代理——后者只认 `https_proxy` 系列环境变量,
|
|
84
|
+
* 这是原生依赖 prebuild 下载卡死的正解)。
|
|
85
|
+
*/
|
|
86
|
+
declare function npmEnv(config: AgentPresetReaConfig): Record<string, string>;
|
|
87
|
+
/** 版本收窄:进命令前把配置里的钉版校验成纯版本号。 */
|
|
88
|
+
declare function safeVersion(version: string): string;
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/manager.d.ts
|
|
91
|
+
/** npm 包名。 */
|
|
92
|
+
declare const REA_PACKAGE = "rea-agents";
|
|
93
|
+
/** 受管安装树目录名。 */
|
|
94
|
+
declare const REA_INSTALL_DIR = "rea-agent";
|
|
95
|
+
/** 手动更新 skill 的目录名。 */
|
|
96
|
+
declare const REA_SKILL_DIR = "skills";
|
|
97
|
+
/** REA 随包 skill 名(tar 包内路径与目录名同此)。 */
|
|
98
|
+
declare const REA_SKILL_NAME = "reverse-engineer-anything";
|
|
99
|
+
/** 已安装的 REA 事实。 */
|
|
100
|
+
interface ReaInstall {
|
|
101
|
+
version: string;
|
|
102
|
+
root: string;
|
|
103
|
+
/** spawn 用的可执行文件(`process.execPath`,即当前 node)。 */
|
|
104
|
+
command: string;
|
|
105
|
+
/** 入口脚本绝对路径(`scripts/rea.mjs`)。 */
|
|
106
|
+
entry: string;
|
|
107
|
+
}
|
|
108
|
+
/** skill 来源事实。 */
|
|
109
|
+
interface SkillState {
|
|
110
|
+
/** `bundled` = 随包副本;`updated` = 插件数据目录里的手动更新副本。 */
|
|
111
|
+
source: 'bundled' | 'updated';
|
|
112
|
+
/** 来源版本(从清单 source 解析;解析不出为 null)。 */
|
|
113
|
+
version: string | null;
|
|
114
|
+
root: string;
|
|
115
|
+
files: number;
|
|
116
|
+
updatedAt: string | null;
|
|
117
|
+
}
|
|
118
|
+
/** 运行期事实快照(现探,不进配置;声明组装按它决定 mcp 行与 skill 根)。 */
|
|
119
|
+
interface RuntimeSnapshot {
|
|
120
|
+
install: ReaInstall | null;
|
|
121
|
+
skill: SkillState;
|
|
122
|
+
}
|
|
123
|
+
/** skill 清单(与随包夹具同形;更新副本多写入 updatedAt)。 */
|
|
124
|
+
interface SkillManifest {
|
|
125
|
+
source: string;
|
|
126
|
+
files: {
|
|
127
|
+
path: string;
|
|
128
|
+
sha256: string;
|
|
129
|
+
bytes: number;
|
|
130
|
+
}[];
|
|
131
|
+
updatedAt?: string;
|
|
132
|
+
}
|
|
133
|
+
/** 受管路径。 */
|
|
134
|
+
interface ManagerPaths {
|
|
135
|
+
installRoot: string;
|
|
136
|
+
skillRoot: string;
|
|
137
|
+
}
|
|
138
|
+
/** 作业可一次性覆盖的配置项(卡片未保存的代理端口即时生效用)。 */
|
|
139
|
+
interface JobOverrides {
|
|
140
|
+
proxyPort?: number;
|
|
141
|
+
}
|
|
142
|
+
/** REA 管理面。 */
|
|
143
|
+
interface ReaManager {
|
|
144
|
+
paths(): ManagerPaths;
|
|
145
|
+
/** 现探运行期事实(同步;声明组装在 `apply` 期就要读到)。 */
|
|
146
|
+
snapshot(): RuntimeSnapshot;
|
|
147
|
+
/** 重新现探并更新快照(作业完成、volatile 变更后调用)。 */
|
|
148
|
+
refresh(): RuntimeSnapshot;
|
|
149
|
+
/** 受管作业(安装/更新 REA 包、更新 skill)。 */
|
|
150
|
+
operations(overrides?: JobOverrides): {
|
|
151
|
+
install: JobOperation;
|
|
152
|
+
skill: JobOperation;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/** 安装作业阶段名。 */
|
|
156
|
+
declare const INSTALL_PHASES: string[];
|
|
157
|
+
/** skill 作业阶段名。 */
|
|
158
|
+
declare const SKILL_PHASES: string[];
|
|
159
|
+
/**
|
|
160
|
+
* 解析受管路径:`installRoot` 非空即运维指定位置(部署方平面),
|
|
161
|
+
* 否则落插件数据目录;skill 更新副本固定落插件数据目录。
|
|
162
|
+
*/
|
|
163
|
+
declare function managerPaths(config: AgentPresetReaConfig): ManagerPaths;
|
|
164
|
+
/**
|
|
165
|
+
* 探测已安装 REA:包版本可读 **且** 入口脚本存在才算安装完整
|
|
166
|
+
* (只有一半的安装树、或换目录中断留下的 staging 都不算)。
|
|
167
|
+
*/
|
|
168
|
+
declare function probeInstall(paths: ManagerPaths): ReaInstall | null;
|
|
169
|
+
/** 探测 skill 来源:数据目录里清单完整且技能文件在位才认更新副本。 */
|
|
170
|
+
declare function probeSkill(paths: ManagerPaths, bundledRoot: string, bundledVersion: string): SkillState;
|
|
171
|
+
/** 现探运行期事实。 */
|
|
172
|
+
declare function probeRuntime(config: AgentPresetReaConfig, bundledRoot: string, bundledVersion: string): RuntimeSnapshot;
|
|
173
|
+
/** 作业依赖:生效配置、命令执行面、作业完成后的现探刷新。 */
|
|
174
|
+
interface JobDeps {
|
|
175
|
+
config: AgentPresetReaConfig;
|
|
176
|
+
runner: CommandRunner;
|
|
177
|
+
refresh(): void;
|
|
178
|
+
}
|
|
179
|
+
/** 生效配置:作业可带一次性覆盖(卡片未保存的代理端口即时可用)。 */
|
|
180
|
+
declare function configWith(base: AgentPresetReaConfig, overrides?: JobOverrides): AgentPresetReaConfig;
|
|
181
|
+
/** 建一个 REA 管理器。 */
|
|
182
|
+
declare function createManager(options: {
|
|
183
|
+
config: () => AgentPresetReaConfig;
|
|
184
|
+
bundledRoot: string;
|
|
185
|
+
bundledVersion: string;
|
|
186
|
+
runner?: CommandRunner;
|
|
187
|
+
}): ReaManager;
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region src/definition.d.ts
|
|
190
|
+
/** 预设注册表身份(改 id 等于换预设,default 等引用都会落空)。 */
|
|
191
|
+
declare const REA_PRESET_ID = "rea";
|
|
192
|
+
/** 相对上游 `standard` 新增的行 id(镜像测试按此白名单放行自造行)。 */
|
|
193
|
+
declare const ADDED_ROWS: readonly string[];
|
|
194
|
+
/**
|
|
195
|
+
* 已镜像行 → 允许偏离上游的字段名(其余字段必须逐字一致)。
|
|
196
|
+
* 删除某条等于把该行改回上游原文;改动上游不存在的字段会被测试拦下。
|
|
197
|
+
*/
|
|
198
|
+
declare const CONFIG_DELTAS: Readonly<Record<string, readonly string[]>>;
|
|
199
|
+
/** 未安装、随包 skill 的运行期事实(默认值:测试与无 manager 场景)。 */
|
|
200
|
+
declare function emptyRuntime(): RuntimeSnapshot;
|
|
201
|
+
/**
|
|
202
|
+
* 由配置 + 运行期事实拼出注册表声明。
|
|
203
|
+
* @param config - 已验证的插件配置。
|
|
204
|
+
* @param runtime - 受管安装与 skill 来源事实(默认「未安装 + 随包 skill」)。
|
|
205
|
+
* @returns id 固定为 `rea` 的预设声明。
|
|
206
|
+
*/
|
|
207
|
+
declare function reaPresetDefinition(config: AgentPresetReaConfig, runtime?: RuntimeSnapshot): PresetDefinition;
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/dto.d.ts
|
|
210
|
+
/**
|
|
211
|
+
* 宿主半与浏览器半之间的 wire 数据门面(纯类型 + 纯函数,零 node 依赖)。
|
|
212
|
+
*
|
|
213
|
+
* 浏览器半只 `import type` 消费本文件(编译期擦除,不进 client bundle),
|
|
214
|
+
* 两端共用同一份字段定义,避免「宿主改了字段、卡片还在读老名字」的静默漂移。
|
|
215
|
+
* @module @dsh-plus/agent-preset-rea/dto
|
|
216
|
+
*/
|
|
217
|
+
/** 作业种类。 */
|
|
218
|
+
type JobKind = 'install' | 'skill';
|
|
219
|
+
/** 作业状态。 */
|
|
220
|
+
type JobState = 'running' | 'ok' | 'error' | 'cancelled';
|
|
221
|
+
/** 作业进度(按阶段推进;percent 为进入该阶段时的完成度)。 */
|
|
222
|
+
interface JobProgressDto {
|
|
223
|
+
step: number;
|
|
224
|
+
steps: number;
|
|
225
|
+
phase: string;
|
|
226
|
+
percent: number;
|
|
227
|
+
}
|
|
228
|
+
/** 作业快照。 */
|
|
229
|
+
interface JobDto {
|
|
230
|
+
id: number;
|
|
231
|
+
kind: JobKind;
|
|
232
|
+
state: JobState;
|
|
233
|
+
progress: JobProgressDto;
|
|
234
|
+
/** 日志尾部(宿主已有界)。 */
|
|
235
|
+
log: string[];
|
|
236
|
+
startedAt: string;
|
|
237
|
+
finishedAt: string | null;
|
|
238
|
+
version: string | null;
|
|
239
|
+
error: string | null;
|
|
240
|
+
}
|
|
241
|
+
/** 受管安装事实。 */
|
|
242
|
+
interface InstallDto {
|
|
243
|
+
installed: boolean;
|
|
244
|
+
/** 已安装版本(未安装为 null)。 */
|
|
245
|
+
version: string | null;
|
|
246
|
+
/** 受管安装树位置(无论是否已安装都有值,便于用户核对)。 */
|
|
247
|
+
root: string;
|
|
248
|
+
/** 入口脚本(未安装为 null)。 */
|
|
249
|
+
entry: string | null;
|
|
250
|
+
}
|
|
251
|
+
/** skill 来源事实。 */
|
|
252
|
+
interface SkillDto {
|
|
253
|
+
source: 'bundled' | 'updated';
|
|
254
|
+
version: string | null;
|
|
255
|
+
root: string;
|
|
256
|
+
files: number;
|
|
257
|
+
updatedAt: string | null;
|
|
258
|
+
}
|
|
259
|
+
/** MCP 行形态。 */
|
|
260
|
+
interface McpDto {
|
|
261
|
+
/** `installed` = 用受管安装入口;`custom` = 用显式 mcpCommand;`missing` = 未安装且无显式命令(行禁用)。 */
|
|
262
|
+
mode: 'installed' | 'custom' | 'missing';
|
|
263
|
+
/** 行是否启用(mcpEnabled && 有启动方式)。 */
|
|
264
|
+
enabled: boolean;
|
|
265
|
+
command: string | null;
|
|
266
|
+
args: string[];
|
|
267
|
+
}
|
|
268
|
+
/** `GET /status` 响应。 */
|
|
269
|
+
interface StatusDto {
|
|
270
|
+
config: {
|
|
271
|
+
reaVersion: string;
|
|
272
|
+
proxyPort: number;
|
|
273
|
+
mcpEnabled: boolean;
|
|
274
|
+
installRoot: string;
|
|
275
|
+
};
|
|
276
|
+
install: InstallDto;
|
|
277
|
+
skill: SkillDto;
|
|
278
|
+
mcp: McpDto;
|
|
279
|
+
paths: {
|
|
280
|
+
installRoot: string;
|
|
281
|
+
skillRoot: string;
|
|
282
|
+
};
|
|
283
|
+
job: JobDto | null;
|
|
284
|
+
}
|
|
285
|
+
/** 作业类响应(启动/取消)。 */
|
|
286
|
+
interface JobActionDto {
|
|
287
|
+
job: JobDto | null;
|
|
288
|
+
/** 拒绝原因(409/400 时给出人话)。 */
|
|
289
|
+
error?: string;
|
|
290
|
+
}
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/jobs.d.ts
|
|
293
|
+
/** 作业快照(与 wire DTO 同形,HTTP 直接回传)。 */
|
|
294
|
+
type JobSnapshot = JobDto;
|
|
295
|
+
/** 作业板。 */
|
|
296
|
+
interface JobBoard {
|
|
297
|
+
/** 启动作业;已有作业在跑时返回 null(调用方回 409)。 */
|
|
298
|
+
start(kind: JobKind, operation: JobOperation): JobSnapshot | null;
|
|
299
|
+
/** 取消当前作业(返回是否真的发出取消)。 */
|
|
300
|
+
cancel(): boolean;
|
|
301
|
+
/** 当前/最近一次作业快照。 */
|
|
302
|
+
snapshot(): JobSnapshot | null;
|
|
303
|
+
/** 订阅作业完成(返回退订函数)。 */
|
|
304
|
+
onSettled(listener: (snapshot: JobSnapshot) => void): () => void;
|
|
305
|
+
}
|
|
306
|
+
/** 建一个作业板。 */
|
|
307
|
+
declare function createJobBoard(): JobBoard;
|
|
308
|
+
//#endregion
|
|
309
|
+
//#region src/mcp.d.ts
|
|
310
|
+
/** 钉版基线:`rea-agents@6.5.0`(升级时同步测试断言、tests 清单与包文档)。 */
|
|
311
|
+
declare const REA_PINNED_VERSION = "6.5.0";
|
|
312
|
+
/** 显式命令配 npx 时的参数配方基准值(`mcpArgs` 留空即按它派生)。 */
|
|
313
|
+
declare const DEFAULT_MCP_COMMAND = "npx";
|
|
314
|
+
/** REA 工具入参 schema 广告档位:`compact` 压请求前缀体积,`full` 与上游默认一致。 */
|
|
315
|
+
declare const INPUT_SCHEMA_PROFILES: readonly ['compact', 'full'];
|
|
316
|
+
/** REA 工具出参 schema 广告档位:`off` 不下发(结果仍由 REA 侧校验),`full` 与上游默认一致。 */
|
|
317
|
+
declare const OUTPUT_SCHEMA_PROFILES: readonly ['off', 'full'];
|
|
318
|
+
/** 受管安装的入口事实(结构上由 manager 的 ReaInstall 满足)。 */
|
|
319
|
+
interface InstalledEntry {
|
|
320
|
+
/** spawn 用的可执行文件。 */
|
|
321
|
+
command: string;
|
|
322
|
+
/** 入口脚本绝对路径。 */
|
|
323
|
+
entry: string;
|
|
324
|
+
}
|
|
325
|
+
/** MCP 行的启动方式。 */
|
|
326
|
+
interface McpLaunch {
|
|
327
|
+
command: string;
|
|
328
|
+
args: string[];
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* 显式命令(`mcpCommand` 非空)时的参数:`mcpArgs` 优先;
|
|
332
|
+
* 留空时 npx 走 `-y rea-agents@<钉版> mcp`,其他可执行文件只补 `mcp`。
|
|
333
|
+
*/
|
|
334
|
+
declare function reaMcpArgs(config: AgentPresetReaConfig): string[];
|
|
335
|
+
/**
|
|
336
|
+
* 本预设 MCP 行的启动方式:
|
|
337
|
+
* 1. `mcpCommand` 显式配置 → 用用户命令(Windows 配方、全局安装场景);
|
|
338
|
+
* 2. 受管安装存在 → 用当前 node 直接跑安装树里的入口脚本(跨平台、不经 shell shim);
|
|
339
|
+
* 3. 都没有 → `null`,调用方把该行置 `disabled`(未安装,等卡片上的安装动作)。
|
|
340
|
+
*/
|
|
341
|
+
declare function reaMcpLaunch(config: AgentPresetReaConfig, installed: InstalledEntry | null): McpLaunch | null;
|
|
342
|
+
/**
|
|
343
|
+
* 传给 REA 子进程的环境变量(并入被清洗过的宿主环境之上)。
|
|
344
|
+
*
|
|
345
|
+
* REA 有 207 个工具(`server.json` 同版的 skill 元数据 `tool_count`),工具定义
|
|
346
|
+
* 是每轮请求的固定开销,因此两个 schema 档位默认都取最省的一档;REA 自己仍按
|
|
347
|
+
* 规范契约校验结果,`full` 可逐项还原上游默认。
|
|
348
|
+
*/
|
|
349
|
+
declare function reaMcpEnv(config: AgentPresetReaConfig): Record<string, string>;
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region src/prompt.d.ts
|
|
352
|
+
/**
|
|
353
|
+
* 本包随包携带的上游提示词文本:`standard` 预设 `plan-mode` 行的 section 原文。
|
|
354
|
+
*
|
|
355
|
+
* `dsh-plan-mode` 要求 `config.section` 非空(部署方所有权),因此该文本必须随包;
|
|
356
|
+
* 逐字相等由 tests/upstream-mirror.test.ts 对着上游夹具守卫,上游一改即失败。
|
|
357
|
+
*
|
|
358
|
+
* persona 不在本文件:本预设的 persona 前缀默认为**空串**(见 config.ts 的
|
|
359
|
+
* `personaPrefix`),不随包任何自有 persona 文案;官方工具指引、项目指令
|
|
360
|
+
* (AGENTS.md)与运行时上下文照常装配。
|
|
361
|
+
* @module @dsh-plus/agent-preset-rea/prompt
|
|
362
|
+
*/
|
|
363
|
+
/** 上游 `standard` 预设 `plan-mode` 行的 section 原文(逐字,勿手改)。 */
|
|
364
|
+
declare const PLAN_MODE_SECTION = "You are in plan mode. Stay in plan mode until the user approves your plan through exit_plan_mode or switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.\n\nExplore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.\n\nThe tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.\n\nResolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.\n\nMake the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.\n\nWhen ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask \"should I proceed?\" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.\n";
|
|
365
|
+
//#endregion
|
|
366
|
+
//#region src/registration.d.ts
|
|
367
|
+
/** 注册表返回的注销句柄。 */
|
|
368
|
+
type Unregister = () => Promise<void>;
|
|
369
|
+
interface PresetRegistrarOptions {
|
|
370
|
+
/** 注册一份声明,返回其注销句柄(即 `ctx.agentPresets.register`)。 */
|
|
371
|
+
register(definition: PresetDefinition): Promise<Unregister>;
|
|
372
|
+
/** 按当前配置构造声明(每次换代重新调用,读到的必须是活值)。 */
|
|
373
|
+
build(): PresetDefinition;
|
|
374
|
+
/** 注册/注销失败的上报口(不抛)。 */
|
|
375
|
+
onError(error: unknown): void;
|
|
376
|
+
}
|
|
377
|
+
/** 换代器:`refresh()` 触发一次换代,`dispose()` 停用并注销。 */
|
|
378
|
+
interface PresetRegistrar {
|
|
379
|
+
refresh(): void;
|
|
380
|
+
dispose(): void;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* 建一个换代器并立即调度初始注册。
|
|
384
|
+
* 后台串行链不返回句柄:需要等待完成的是测试与调用方的关停流程,而不是业务路径。
|
|
385
|
+
*/
|
|
386
|
+
declare function createPresetRegistrar(options: PresetRegistrarOptions): PresetRegistrar;
|
|
387
|
+
//#endregion
|
|
388
|
+
//#region src/routes.d.ts
|
|
389
|
+
/** 路由前缀。 */
|
|
390
|
+
declare const ROUTE_BASE = "/dsh-plus/agent-preset-rea";
|
|
391
|
+
/** 路由依赖。 */
|
|
392
|
+
interface ReaRoutesOptions {
|
|
393
|
+
manager: ReaManager;
|
|
394
|
+
board: JobBoard;
|
|
395
|
+
config: () => AgentPresetReaConfig;
|
|
396
|
+
}
|
|
397
|
+
/** 组装状态响应(纯函数,可直接单测)。 */
|
|
398
|
+
declare function statusPayload(options: ReaRoutesOptions): StatusDto;
|
|
399
|
+
/** 注册全部路由。 */
|
|
400
|
+
declare function registerReaRoutes(ctx: Context, options: ReaRoutesOptions): void;
|
|
401
|
+
//#endregion
|
|
402
|
+
//#region src/skill.d.ts
|
|
403
|
+
/**
|
|
404
|
+
* 随包 REA 官方 skill 根(包内 `skills/`)。
|
|
405
|
+
*
|
|
406
|
+
* `src/` 与构建产物 `lib/` 同为包根下一级,`../skills` 在源码直跑测试与安装后
|
|
407
|
+
* 运行产物两种位置下解析到同一目录。
|
|
408
|
+
*/
|
|
409
|
+
declare const BUNDLED_SKILL_ROOT: string;
|
|
410
|
+
/**
|
|
411
|
+
* skill-filesystem 的追加根清单。
|
|
412
|
+
* @param config - 插件配置。
|
|
413
|
+
* @param updatedRoot - 手动更新副本根(存在即替代随包根;来自 manager 现探)。
|
|
414
|
+
*/
|
|
415
|
+
declare function reaSkillDirs(config: AgentPresetReaConfig, updatedRoot?: string | null): string[];
|
|
416
|
+
//#endregion
|
|
417
|
+
//#region src/index.d.ts
|
|
418
|
+
declare const name = "dsh-plus-agent-preset-rea";
|
|
419
|
+
/** 无硬 inject:agentPresets 经 apply 内惰性 inject 接线(缺席即空转)。 */
|
|
420
|
+
declare const inject: readonly [];
|
|
421
|
+
/**
|
|
422
|
+
* 注册 rea 预设,并在 persona 热更后换代;卸载时注销当前一代。
|
|
423
|
+
*
|
|
424
|
+
* 注册与换代都在 effect 生命周期内完成:fiber 早于注册完成被卸下时,
|
|
425
|
+
* 换代器自己收掉晚到的 disposer,不泄漏预设子树。
|
|
426
|
+
* @param ctx - 宿主上下文。
|
|
427
|
+
* @param config - 已验证的插件配置(`personaPrefix` 为活动引用)。
|
|
428
|
+
*/
|
|
429
|
+
declare function apply(ctx: Context, config: AgentPresetReaConfigFields): void;
|
|
430
|
+
//#endregion
|
|
431
|
+
export { ADDED_ROWS, type AgentPresetReaConfig, type AgentPresetReaConfigFields, BUNDLED_SKILL_ROOT, CONFIG_DELTAS, type CommandRunner, Config, DEFAULT_MCP_COMMAND, INPUT_SCHEMA_PROFILES, INSTALL_PHASES, type InstallDto, type InstalledEntry, type JobActionDto, type JobBoard, JobCancelled, type JobDeps, type JobDto, type JobKind, type JobOperation, type JobOverrides, type JobProgressDto, type JobSnapshot, type JobState, type JobTaskContext, type ManagerPaths, type McpDto, type McpLaunch, NPM, OUTPUT_SCHEMA_PROFILES, PLAN_MODE_SECTION, type PresetRegistrar, REA_INSTALL_DIR, REA_PACKAGE, REA_PINNED_VERSION, REA_PRESET_ID, REA_SKILL_DIR, REA_SKILL_NAME, ROUTE_BASE, type ReaInstall, type ReaManager, type RuntimeSnapshot, SETTINGS_NS, SKILL_PHASES, type SkillDto, type SkillManifest, type SkillState, type StatusDto, type Unregister, apply, configWith, createJobBoard, createManager, createPresetRegistrar, emptyRuntime, inject, managerPaths, name, npmEnv, probeInstall, probeRuntime, probeSkill, reaMcpArgs, reaMcpEnv, reaMcpLaunch, reaPresetDefinition, reaSkillDirs, registerReaRoutes, safeVersion, spawnRunner, statusPayload };
|