@ai-setting/roy-agent-core 1.5.15-test → 1.5.16-test
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/config/index.d.ts +1250 -0
- package/dist/config/index.js +32 -0
- package/dist/env/agent/index.d.ts +2279 -0
- package/dist/env/agent/index.js +24 -0
- package/dist/env/commands/index.d.ts +1131 -0
- package/dist/env/commands/index.js +14 -0
- package/dist/env/debug/formatters/index.d.ts +236 -0
- package/dist/env/debug/formatters/index.js +11 -0
- package/dist/env/debug/index.d.ts +1652 -0
- package/dist/env/debug/index.js +26 -0
- package/dist/env/hook/index.d.ts +279 -0
- package/dist/env/hook/index.js +29 -0
- package/dist/env/index.d.ts +3481 -0
- package/dist/env/index.js +82 -0
- package/dist/env/llm/index.d.ts +1760 -0
- package/dist/env/llm/index.js +40 -0
- package/dist/env/log-trace/index.d.ts +1574 -0
- package/dist/env/log-trace/index.js +83 -0
- package/dist/env/mcp/index.d.ts +1331 -0
- package/dist/env/mcp/index.js +39 -0
- package/dist/env/mcp/tool/index.d.ts +183 -0
- package/dist/env/mcp/tool/index.js +14 -0
- package/dist/env/memory/built-in/index.d.ts +232 -0
- package/dist/env/memory/built-in/index.js +11 -0
- package/dist/env/memory/index.d.ts +1799 -0
- package/dist/env/memory/index.js +56 -0
- package/dist/env/memory/plugin/index.d.ts +747 -0
- package/dist/env/memory/plugin/index.js +36 -0
- package/dist/env/prompt/index.d.ts +1164 -0
- package/dist/env/prompt/index.js +20 -0
- package/dist/env/session/index.d.ts +1908 -0
- package/dist/env/session/index.js +25 -0
- package/dist/env/session/storage/index.d.ts +564 -0
- package/dist/env/session/storage/index.js +18 -0
- package/dist/env/skill/index.d.ts +1266 -0
- package/dist/env/skill/index.js +34 -0
- package/dist/env/skill/tool/index.d.ts +193 -0
- package/dist/env/skill/tool/index.js +9 -0
- package/dist/env/task/delegate/index.d.ts +1612 -0
- package/dist/env/task/delegate/index.js +18 -0
- package/dist/env/task/events/index.d.ts +171 -0
- package/dist/env/task/events/index.js +7 -0
- package/dist/env/task/hooks/index.d.ts +624 -0
- package/dist/env/task/hooks/index.js +7 -0
- package/dist/env/task/index.d.ts +1553 -0
- package/dist/env/task/index.js +34 -0
- package/dist/env/task/plugins/index.d.ts +466 -0
- package/dist/env/task/plugins/index.js +23 -0
- package/dist/env/task/storage/index.d.ts +241 -0
- package/dist/env/task/storage/index.js +14 -0
- package/dist/env/task/tools/index.d.ts +1485 -0
- package/dist/env/task/tools/index.js +17 -0
- package/dist/env/task/tools/operation/index.d.ts +1484 -0
- package/dist/env/task/tools/operation/index.js +15 -0
- package/dist/env/tool/built-in/index.d.ts +218 -0
- package/dist/env/tool/built-in/index.js +25 -0
- package/dist/env/tool/index.d.ts +1396 -0
- package/dist/env/tool/index.js +39 -0
- package/dist/env/workflow/decorators/index.d.ts +2161 -0
- package/dist/env/workflow/decorators/index.js +27 -0
- package/dist/env/workflow/engine/index.d.ts +3453 -0
- package/dist/env/workflow/engine/index.js +28 -0
- package/dist/env/workflow/index.d.ts +3546 -0
- package/dist/env/workflow/index.js +136 -0
- package/dist/env/workflow/nodes/index.d.ts +2092 -0
- package/dist/env/workflow/nodes/index.js +19 -0
- package/dist/env/workflow/service/index.d.ts +227 -0
- package/dist/env/workflow/service/index.js +13 -0
- package/dist/env/workflow/storage/index.d.ts +165 -0
- package/dist/env/workflow/storage/index.js +27 -0
- package/dist/env/workflow/tools/index.d.ts +416 -0
- package/dist/env/workflow/tools/index.js +159 -0
- package/dist/env/workflow/types/index.d.ts +2255 -0
- package/dist/env/workflow/types/index.js +98 -0
- package/dist/env/workflow/utils/index.d.ts +2031 -0
- package/dist/env/workflow/utils/index.js +637 -0
- package/dist/index.d.ts +7858 -0
- package/dist/index.js +399 -0
- package/dist/shared/@ai-setting/roy-agent-core-0rtxwr28.js +258 -0
- package/dist/shared/@ai-setting/roy-agent-core-0vbdz0x7.js +36 -0
- package/dist/shared/@ai-setting/roy-agent-core-1akcqxj9.js +349 -0
- package/dist/shared/@ai-setting/roy-agent-core-1ce3fqrk.js +117 -0
- package/dist/shared/@ai-setting/roy-agent-core-2dhd60aw.js +11 -0
- package/dist/shared/@ai-setting/roy-agent-core-3jywqmdd.js +393 -0
- package/dist/shared/@ai-setting/roy-agent-core-3rr5k71j.js +200 -0
- package/dist/shared/@ai-setting/roy-agent-core-44hnfb02.js +299 -0
- package/dist/shared/@ai-setting/roy-agent-core-4t40mkpv.js +206 -0
- package/dist/shared/@ai-setting/roy-agent-core-4txzpsbt.js +393 -0
- package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +350 -0
- package/dist/shared/@ai-setting/roy-agent-core-69jskqjg.js +180 -0
- package/dist/shared/@ai-setting/roy-agent-core-6kvtahqv.js +408 -0
- package/dist/shared/@ai-setting/roy-agent-core-7fgf85wc.js +284 -0
- package/dist/shared/@ai-setting/roy-agent-core-81w1963m.js +762 -0
- package/dist/shared/@ai-setting/roy-agent-core-8gxth0eh.js +10 -0
- package/dist/shared/@ai-setting/roy-agent-core-92z6t4he.js +14 -0
- package/dist/shared/@ai-setting/roy-agent-core-93zfb3r1.js +922 -0
- package/dist/shared/@ai-setting/roy-agent-core-9yxb3ty9.js +15 -0
- package/dist/shared/@ai-setting/roy-agent-core-b0x5dda6.js +1130 -0
- package/dist/shared/@ai-setting/roy-agent-core-bcbqy27c.js +14 -0
- package/dist/shared/@ai-setting/roy-agent-core-bvr1761x.js +653 -0
- package/dist/shared/@ai-setting/roy-agent-core-ctdhjv68.js +93 -0
- package/dist/shared/@ai-setting/roy-agent-core-d7cyjkf7.js +872 -0
- package/dist/shared/@ai-setting/roy-agent-core-dh9d7a3m.js +11 -0
- package/dist/shared/@ai-setting/roy-agent-core-e25xkv53.js +64 -0
- package/dist/shared/@ai-setting/roy-agent-core-eajcvp4e.js +378 -0
- package/dist/shared/@ai-setting/roy-agent-core-f7q2x5z6.js +492 -0
- package/dist/shared/@ai-setting/roy-agent-core-fs0mn2jk.js +52 -0
- package/dist/shared/@ai-setting/roy-agent-core-g1s2h0e5.js +171 -0
- package/dist/shared/@ai-setting/roy-agent-core-g99pxzn5.js +862 -0
- package/dist/shared/@ai-setting/roy-agent-core-gbqcyegm.js +1387 -0
- package/dist/shared/@ai-setting/roy-agent-core-gjq1yk68.js +208 -0
- package/dist/shared/@ai-setting/roy-agent-core-gq20wsgv.js +139 -0
- package/dist/shared/@ai-setting/roy-agent-core-gwc4h96n.js +534 -0
- package/dist/shared/@ai-setting/roy-agent-core-jfh9q2qh.js +204 -0
- package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +603 -0
- package/dist/shared/@ai-setting/roy-agent-core-kkbwepqb.js +97 -0
- package/dist/shared/@ai-setting/roy-agent-core-pjr12nnd.js +587 -0
- package/dist/shared/@ai-setting/roy-agent-core-psv4v63c.js +176 -0
- package/dist/shared/@ai-setting/roy-agent-core-psvxt4c9.js +60 -0
- package/dist/shared/@ai-setting/roy-agent-core-qqceba6k.js +442 -0
- package/dist/shared/@ai-setting/roy-agent-core-qxhq8ven.js +57 -0
- package/dist/shared/@ai-setting/roy-agent-core-qxnbvgwe.js +66 -0
- package/dist/shared/@ai-setting/roy-agent-core-r9ezzemr.js +10 -0
- package/dist/shared/@ai-setting/roy-agent-core-rhmtwnw1.js +267 -0
- package/dist/shared/@ai-setting/roy-agent-core-rvv6ydff.js +584 -0
- package/dist/shared/@ai-setting/roy-agent-core-rvxg1wps.js +102 -0
- package/dist/shared/@ai-setting/roy-agent-core-satmq6sh.js +549 -0
- package/dist/shared/@ai-setting/roy-agent-core-sx7wsvnn.js +15 -0
- package/dist/shared/@ai-setting/roy-agent-core-t94ktchq.js +213 -0
- package/dist/shared/@ai-setting/roy-agent-core-vf215qfv.js +812 -0
- package/dist/shared/@ai-setting/roy-agent-core-vkz81f7v.js +1316 -0
- package/dist/shared/@ai-setting/roy-agent-core-vn2bc59q.js +1205 -0
- package/dist/shared/@ai-setting/roy-agent-core-wa1kzqky.js +328 -0
- package/dist/shared/@ai-setting/roy-agent-core-wft9ra24.js +20 -0
- package/dist/shared/@ai-setting/roy-agent-core-wrcy0h6z.js +2098 -0
- package/dist/shared/@ai-setting/roy-agent-core-xq8hhqb8.js +419 -0
- package/dist/shared/@ai-setting/roy-agent-core-xs5rsgat.js +368 -0
- package/dist/shared/@ai-setting/roy-agent-core-zbkpc41z.js +377 -0
- package/dist/shared/@ai-setting/roy-agent-core-zgypchmt.js +172 -0
- package/dist/shared/@ai-setting/roy-agent-core-zpn0bqa8.js +103 -0
- package/package.json +1 -1
|
@@ -0,0 +1,624 @@
|
|
|
1
|
+
import { z as z2, ZodType, ZodError } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* 沙箱配置
|
|
4
|
+
*/
|
|
5
|
+
interface SandboxConfig {
|
|
6
|
+
/** 是否启用沙箱 */
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
/** 沙箱类型 */
|
|
9
|
+
type: "native" | "docker";
|
|
10
|
+
/** 动作过滤 */
|
|
11
|
+
actionFilter?: {
|
|
12
|
+
/** 包含的动作 */
|
|
13
|
+
include?: string[];
|
|
14
|
+
/** 排除的动作 */
|
|
15
|
+
exclude?: string[];
|
|
16
|
+
};
|
|
17
|
+
/** 文件系统限制 */
|
|
18
|
+
filesystem?: {
|
|
19
|
+
/** 允许读取 */
|
|
20
|
+
allowRead?: string[];
|
|
21
|
+
/** 禁止读取 */
|
|
22
|
+
denyRead?: string[];
|
|
23
|
+
/** 允许写入 */
|
|
24
|
+
allowWrite?: string[];
|
|
25
|
+
/** 禁止写入 */
|
|
26
|
+
denyWrite?: string[];
|
|
27
|
+
};
|
|
28
|
+
/** 网络限制 */
|
|
29
|
+
network?: {
|
|
30
|
+
/** 允许的域名 */
|
|
31
|
+
allowedDomains?: string[];
|
|
32
|
+
/** 禁止的域名 */
|
|
33
|
+
deniedDomains?: string[];
|
|
34
|
+
};
|
|
35
|
+
/** Docker 配置 */
|
|
36
|
+
docker?: {
|
|
37
|
+
/** 镜像 */
|
|
38
|
+
image?: string;
|
|
39
|
+
/** 网络模式 */
|
|
40
|
+
networkMode?: "bridge" | "host" | "none";
|
|
41
|
+
/** 卷挂载 */
|
|
42
|
+
volumes?: Record<string, string>;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 工具执行上下文
|
|
47
|
+
*/
|
|
48
|
+
interface ToolContext {
|
|
49
|
+
/** 工作目录 */
|
|
50
|
+
workdir?: string;
|
|
51
|
+
/** 用户 ID */
|
|
52
|
+
user_id?: string;
|
|
53
|
+
/** 会话 ID */
|
|
54
|
+
session_id?: string;
|
|
55
|
+
/** 消息 ID */
|
|
56
|
+
message_id?: string;
|
|
57
|
+
/** 中断信号 */
|
|
58
|
+
abort?: AbortSignal;
|
|
59
|
+
/** 额外元数据 */
|
|
60
|
+
metadata?: Record<string, unknown>;
|
|
61
|
+
/** 沙箱配置 */
|
|
62
|
+
sandbox?: SandboxConfig;
|
|
63
|
+
/** 沙箱 Provider */
|
|
64
|
+
sandboxProvider?: unknown | null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 工具结果元数据
|
|
68
|
+
*/
|
|
69
|
+
interface ToolResultMetadata {
|
|
70
|
+
/** 执行时间(毫秒) */
|
|
71
|
+
execution_time_ms: number;
|
|
72
|
+
/** 输出大小(字节) */
|
|
73
|
+
output_size?: number;
|
|
74
|
+
/** 标准输出 */
|
|
75
|
+
stdout?: string;
|
|
76
|
+
/** 标准错误 */
|
|
77
|
+
stderr?: string;
|
|
78
|
+
/** 退出码 */
|
|
79
|
+
exit_code?: number;
|
|
80
|
+
/** Token 使用量 */
|
|
81
|
+
usage?: {
|
|
82
|
+
inputTokens: number;
|
|
83
|
+
outputTokens: number;
|
|
84
|
+
totalTokens?: number;
|
|
85
|
+
};
|
|
86
|
+
/** 额外元数据 */
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* 工具执行结果
|
|
91
|
+
*/
|
|
92
|
+
interface ToolResult2 {
|
|
93
|
+
/** 是否成功 */
|
|
94
|
+
success: boolean;
|
|
95
|
+
/** 输出内容 */
|
|
96
|
+
output: string | Record<string, unknown>;
|
|
97
|
+
/** 错误信息 */
|
|
98
|
+
error?: string;
|
|
99
|
+
/** 结果元数据 */
|
|
100
|
+
metadata?: ToolResultMetadata;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 工具元数据
|
|
104
|
+
*/
|
|
105
|
+
interface ToolMetadata {
|
|
106
|
+
/** 分类 */
|
|
107
|
+
category?: string;
|
|
108
|
+
/** 标签 */
|
|
109
|
+
tags?: string[];
|
|
110
|
+
/** 版本 */
|
|
111
|
+
version?: string;
|
|
112
|
+
/** 作者 */
|
|
113
|
+
author?: string;
|
|
114
|
+
/** 是否实验性 */
|
|
115
|
+
experimental?: boolean;
|
|
116
|
+
/** MCP 工具信息(MCP adapter 使用) */
|
|
117
|
+
mcpTool?: {
|
|
118
|
+
originalName: string;
|
|
119
|
+
originalDescription: string;
|
|
120
|
+
inputSchema?: unknown;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* 工具沙箱配置
|
|
125
|
+
*/
|
|
126
|
+
interface ToolSandboxConfig {
|
|
127
|
+
/** 是否启用沙箱 */
|
|
128
|
+
enabled: boolean;
|
|
129
|
+
/** 沙箱配置 */
|
|
130
|
+
config?: Partial<SandboxConfig>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 工具权限配置
|
|
134
|
+
*/
|
|
135
|
+
interface ToolPermissionConfig {
|
|
136
|
+
/** 是否需要用户确认 */
|
|
137
|
+
requireConfirmation?: boolean;
|
|
138
|
+
/** 权限级别 */
|
|
139
|
+
level?: "safe" | "dangerous" | "critical";
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* 工具信息
|
|
143
|
+
*/
|
|
144
|
+
interface ToolInfo<Parameters extends ZodType = ZodType> {
|
|
145
|
+
/** 工具名称 */
|
|
146
|
+
name: string;
|
|
147
|
+
/** 工具描述 */
|
|
148
|
+
description: string;
|
|
149
|
+
/** 参数 Schema */
|
|
150
|
+
parameters: Parameters;
|
|
151
|
+
/** 初始化函数(可选) */
|
|
152
|
+
init?: (ctx?: ToolContext) => Promise<void>;
|
|
153
|
+
/** 执行函数 */
|
|
154
|
+
execute: (args: z2.infer<Parameters>, ctx: ToolContext) => Promise<ToolResult2>;
|
|
155
|
+
/** 参数验证错误格式化(可选) */
|
|
156
|
+
formatValidationError?: (error: ZodError) => string;
|
|
157
|
+
/** 沙箱配置 */
|
|
158
|
+
sandbox?: ToolSandboxConfig;
|
|
159
|
+
/** 权限配置 */
|
|
160
|
+
permission?: ToolPermissionConfig;
|
|
161
|
+
/** 工具元数据 */
|
|
162
|
+
metadata?: ToolMetadata;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* 工具类型别名
|
|
166
|
+
*/
|
|
167
|
+
type Tool = ToolInfo;
|
|
168
|
+
import { z as z7 } from "zod";
|
|
169
|
+
/**
|
|
170
|
+
* Task status enum
|
|
171
|
+
*/
|
|
172
|
+
declare const TaskStatusEnum: unknown;
|
|
173
|
+
type TaskStatus = z7.infer<typeof TaskStatusEnum>;
|
|
174
|
+
/**
|
|
175
|
+
* Task priority enum
|
|
176
|
+
*/
|
|
177
|
+
declare const TaskPriorityEnum: unknown;
|
|
178
|
+
type TaskPriority = z7.infer<typeof TaskPriorityEnum>;
|
|
179
|
+
/**
|
|
180
|
+
* Action type for task operations
|
|
181
|
+
*/
|
|
182
|
+
declare const ActionTypeEnum: unknown;
|
|
183
|
+
type ActionType = z7.infer<typeof ActionTypeEnum>;
|
|
184
|
+
/**
|
|
185
|
+
* Task entity
|
|
186
|
+
*/
|
|
187
|
+
interface Task {
|
|
188
|
+
id: number;
|
|
189
|
+
title: string;
|
|
190
|
+
description: string;
|
|
191
|
+
status: TaskStatus;
|
|
192
|
+
priority: TaskPriority;
|
|
193
|
+
progress: number;
|
|
194
|
+
current_status: string;
|
|
195
|
+
goals_and_expected_deliverables: string;
|
|
196
|
+
parent_task_id?: number;
|
|
197
|
+
createdAt: string;
|
|
198
|
+
updatedAt: string;
|
|
199
|
+
due_date?: string;
|
|
200
|
+
tags?: string[];
|
|
201
|
+
/** Project root path for task positioning */
|
|
202
|
+
project_path: string;
|
|
203
|
+
/** JSON string with time-space positioning info (worktree, branch, etc.) */
|
|
204
|
+
context: string;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* TaskOperation entity
|
|
208
|
+
*
|
|
209
|
+
* 记录任务的操作历史,每个操作关联到一个 sessionId
|
|
210
|
+
*/
|
|
211
|
+
interface TaskOperation {
|
|
212
|
+
id: number;
|
|
213
|
+
taskId: number;
|
|
214
|
+
sessionId: string;
|
|
215
|
+
actionType: ActionType;
|
|
216
|
+
actionTitle: string;
|
|
217
|
+
actionDescription: string;
|
|
218
|
+
timestamp: string;
|
|
219
|
+
mdPath?: string;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* TaskTag entity
|
|
223
|
+
*
|
|
224
|
+
* Tag 池中的单个 Tag
|
|
225
|
+
*/
|
|
226
|
+
interface TaskTag {
|
|
227
|
+
id: number;
|
|
228
|
+
name: string;
|
|
229
|
+
createdAt: string;
|
|
230
|
+
taskCount: number;
|
|
231
|
+
}
|
|
232
|
+
interface CreateTaskOptions {
|
|
233
|
+
title: string;
|
|
234
|
+
description?: string;
|
|
235
|
+
priority?: TaskPriority;
|
|
236
|
+
parent_task_id?: number;
|
|
237
|
+
goals_and_expected_deliverables?: string;
|
|
238
|
+
due_date?: string;
|
|
239
|
+
tags?: string[];
|
|
240
|
+
sessionId: string;
|
|
241
|
+
/** Project root path for task positioning. Use 'unknown' if unknown. */
|
|
242
|
+
project_path: string;
|
|
243
|
+
/**
|
|
244
|
+
* JSON string with time-space positioning info.
|
|
245
|
+
* - For coding tasks: include worktree_path, branch, type
|
|
246
|
+
* - For other tasks: use '{}' or '{"type":"unknown"}'
|
|
247
|
+
* Must be a valid JSON string.
|
|
248
|
+
*/
|
|
249
|
+
context: string;
|
|
250
|
+
}
|
|
251
|
+
interface UpdateTaskOptions {
|
|
252
|
+
title?: string;
|
|
253
|
+
description?: string;
|
|
254
|
+
status?: TaskStatus;
|
|
255
|
+
priority?: TaskPriority;
|
|
256
|
+
progress?: number;
|
|
257
|
+
current_status?: string;
|
|
258
|
+
goals_and_expected_deliverables?: string;
|
|
259
|
+
due_date?: string;
|
|
260
|
+
tags?: string[];
|
|
261
|
+
/** 项目路径,标识任务所属的项目 */
|
|
262
|
+
project_path?: string;
|
|
263
|
+
/** 任务上下文信息,用于存储额外上下文 */
|
|
264
|
+
context?: string;
|
|
265
|
+
}
|
|
266
|
+
interface CreateOperationOptions {
|
|
267
|
+
taskId: number;
|
|
268
|
+
sessionId: string;
|
|
269
|
+
actionType: ActionType;
|
|
270
|
+
actionTitle: string;
|
|
271
|
+
actionDescription?: string;
|
|
272
|
+
mdPath?: string;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* @fileoverview Task Hook Points - Hook 点常量定义
|
|
276
|
+
*
|
|
277
|
+
* 定义 Task Component 生命周期中的所有 Hook 点
|
|
278
|
+
*/
|
|
279
|
+
declare const TaskHookPoints: {
|
|
280
|
+
/** 创建 Task 前 - 可干预 options */
|
|
281
|
+
readonly BEFORE_CREATE: "task:before.create";
|
|
282
|
+
/** 创建 Task 后 - 观察或触发副作用 */
|
|
283
|
+
readonly AFTER_CREATE: "task:after.create";
|
|
284
|
+
/** 更新 Task 前 - 可干预 options */
|
|
285
|
+
readonly BEFORE_UPDATE: "task:before.update";
|
|
286
|
+
/** 更新 Task 后 - 观察变更 */
|
|
287
|
+
readonly AFTER_UPDATE: "task:after.update";
|
|
288
|
+
/** 删除 Task 前 - 观察 */
|
|
289
|
+
readonly BEFORE_DELETE: "task:before.delete";
|
|
290
|
+
/** 删除 Task 后 - 清理关联资源 */
|
|
291
|
+
readonly AFTER_DELETE: "task:after.delete";
|
|
292
|
+
/** 委派任务前 - 可干预 prompt、参数 */
|
|
293
|
+
readonly DELEGATE_BEFORE: "task:delegate:before";
|
|
294
|
+
/** 委派任务后 - 观察结果 */
|
|
295
|
+
readonly DELEGATE_AFTER: "task:delegate:after";
|
|
296
|
+
/** 创建操作记录前 - 可干预 options */
|
|
297
|
+
readonly OPERATION_BEFORE_CREATE: "task:operation:before.create";
|
|
298
|
+
/** 创建操作记录后 - 观察或触发副作用 */
|
|
299
|
+
readonly OPERATION_AFTER_CREATE: "task:operation:after.create";
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Task Hook 点类型
|
|
303
|
+
*/
|
|
304
|
+
type TaskHookPoint = typeof TaskHookPoints[keyof typeof TaskHookPoints];
|
|
305
|
+
interface ListTagsOptions {
|
|
306
|
+
limit?: number;
|
|
307
|
+
offset?: number;
|
|
308
|
+
orderBy?: "count" | "name" | "created_at";
|
|
309
|
+
}
|
|
310
|
+
interface SearchTagsOptions {
|
|
311
|
+
query: string;
|
|
312
|
+
limit?: number;
|
|
313
|
+
}
|
|
314
|
+
interface TagService {
|
|
315
|
+
/**
|
|
316
|
+
* 创建 Tag(如果已存在则返回现有 Tag)
|
|
317
|
+
*/
|
|
318
|
+
createTag(name: string): Promise<TaskTag>;
|
|
319
|
+
/**
|
|
320
|
+
* 获取 Tag by ID
|
|
321
|
+
*/
|
|
322
|
+
getTag(id: number): Promise<TaskTag | undefined>;
|
|
323
|
+
/**
|
|
324
|
+
* 获取 Tag by Name
|
|
325
|
+
*/
|
|
326
|
+
getTagByName(name: string): Promise<TaskTag | undefined>;
|
|
327
|
+
/**
|
|
328
|
+
* 列出所有 Tag
|
|
329
|
+
*/
|
|
330
|
+
listTags(options?: ListTagsOptions): Promise<TaskTag[]>;
|
|
331
|
+
/**
|
|
332
|
+
* 搜索 Tag(模糊匹配)
|
|
333
|
+
*/
|
|
334
|
+
searchTags(options: SearchTagsOptions): Promise<TaskTag[]>;
|
|
335
|
+
/**
|
|
336
|
+
* 删除 Tag(同时删除所有关联)
|
|
337
|
+
*/
|
|
338
|
+
deleteTag(id: number): Promise<boolean>;
|
|
339
|
+
/**
|
|
340
|
+
* 给 Task 添加 Tags
|
|
341
|
+
*/
|
|
342
|
+
addTagsToTask(taskId: number, tagIds: number[]): Promise<void>;
|
|
343
|
+
/**
|
|
344
|
+
* 从 Task 移除 Tags
|
|
345
|
+
*/
|
|
346
|
+
removeTagsFromTask(taskId: number, tagIds: number[]): Promise<void>;
|
|
347
|
+
/**
|
|
348
|
+
* 获取 Task 的所有 Tags
|
|
349
|
+
*/
|
|
350
|
+
getTagsForTask(taskId: number): Promise<TaskTag[]>;
|
|
351
|
+
/**
|
|
352
|
+
* 根据 Tag 名称获取关联的 Task IDs
|
|
353
|
+
*/
|
|
354
|
+
getTaskIdsByTags(tagNames: string[]): Promise<number[]>;
|
|
355
|
+
/**
|
|
356
|
+
* 根据关键词列表搜索 Task(检索 tags、description、goals、operations)
|
|
357
|
+
* 这是新的核心检索方法
|
|
358
|
+
*/
|
|
359
|
+
searchTasksByKeywords(keywords: string[], options?: {
|
|
360
|
+
limit?: number;
|
|
361
|
+
excludeTaskId?: number;
|
|
362
|
+
}): Promise<Task[]>;
|
|
363
|
+
/**
|
|
364
|
+
* 根据关键词查找类似 Task(排除自身,按相关性排序)
|
|
365
|
+
* 这是新的核心检索方法
|
|
366
|
+
*/
|
|
367
|
+
findSimilarTasksByKeywords(keywords: string[], options?: {
|
|
368
|
+
limit?: number;
|
|
369
|
+
excludeTaskId?: number;
|
|
370
|
+
}): Promise<Task[]>;
|
|
371
|
+
/**
|
|
372
|
+
* 同步 Tags 到 Task(根据 tag 名称列表)
|
|
373
|
+
* - 查找或创建 Tag
|
|
374
|
+
* - 更新关联关系
|
|
375
|
+
* - 更新 task.tags JSON 字段
|
|
376
|
+
*/
|
|
377
|
+
syncTagsToTask(taskId: number, tagNames: string[]): Promise<void>;
|
|
378
|
+
/**
|
|
379
|
+
* 查找类似 Task(基于 Tag 匹配度)- 原始实现,保留兼容
|
|
380
|
+
* @deprecated 使用 findSimilarTasksByKeywords 代替
|
|
381
|
+
*/
|
|
382
|
+
findSimilarTasks(taskId: number, limit?: number): Promise<Task[]>;
|
|
383
|
+
/**
|
|
384
|
+
* 根据关键词搜索 Task(标题 + 描述)- 原始实现,保留兼容
|
|
385
|
+
* @deprecated 使用 searchTasksByKeywords 代替
|
|
386
|
+
*/
|
|
387
|
+
searchTasks(query: string, limit?: number): Promise<Task[]>;
|
|
388
|
+
}
|
|
389
|
+
interface DelegateToolResult {
|
|
390
|
+
tool: Tool;
|
|
391
|
+
backgroundTaskManager: BackgroundTaskManager;
|
|
392
|
+
}
|
|
393
|
+
interface BackgroundTask {
|
|
394
|
+
id: string;
|
|
395
|
+
subSessionId: string;
|
|
396
|
+
parentSessionId: string;
|
|
397
|
+
description: string;
|
|
398
|
+
subagentType: string;
|
|
399
|
+
status: "pending" | "running" | "completed" | "failed" | "timeout" | "stopped";
|
|
400
|
+
createdAt: number;
|
|
401
|
+
startedAt?: number;
|
|
402
|
+
completedAt?: number;
|
|
403
|
+
result?: string;
|
|
404
|
+
error?: string;
|
|
405
|
+
progress?: number;
|
|
406
|
+
progressMessage?: string;
|
|
407
|
+
abortController?: AbortController;
|
|
408
|
+
taskId?: number;
|
|
409
|
+
}
|
|
410
|
+
interface CreateBackgroundTaskOptions {
|
|
411
|
+
parentSessionId: string;
|
|
412
|
+
description: string;
|
|
413
|
+
prompt: string;
|
|
414
|
+
subagentType: string;
|
|
415
|
+
timeout?: number;
|
|
416
|
+
cleanup?: "delete" | "keep";
|
|
417
|
+
taskId?: number;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Background Task Manager (简化版)
|
|
421
|
+
*
|
|
422
|
+
* 管理后台任务的创建、执行、状态跟踪
|
|
423
|
+
* 发布 task.background.* 事件供外部订阅
|
|
424
|
+
*/
|
|
425
|
+
declare class BackgroundTaskManager {
|
|
426
|
+
private env;
|
|
427
|
+
private tasks;
|
|
428
|
+
private abortControllers;
|
|
429
|
+
private progressTimers;
|
|
430
|
+
constructor(env: any);
|
|
431
|
+
/**
|
|
432
|
+
* Get SessionComponent from env
|
|
433
|
+
*/
|
|
434
|
+
private getSessionComponent;
|
|
435
|
+
/**
|
|
436
|
+
* Publish a task.background.* event
|
|
437
|
+
*/
|
|
438
|
+
private publishBackgroundEvent;
|
|
439
|
+
createTask(options: CreateBackgroundTaskOptions): Promise<{
|
|
440
|
+
taskId: string;
|
|
441
|
+
subSessionId: string;
|
|
442
|
+
}>;
|
|
443
|
+
private executeTask;
|
|
444
|
+
/**
|
|
445
|
+
* Start progress reporter for a task
|
|
446
|
+
*/
|
|
447
|
+
private startProgressReporter;
|
|
448
|
+
/**
|
|
449
|
+
* Stop progress reporter for a task
|
|
450
|
+
*/
|
|
451
|
+
private stopProgressReporter;
|
|
452
|
+
private executeWithAbort;
|
|
453
|
+
stopTask(taskId: string): {
|
|
454
|
+
success: boolean;
|
|
455
|
+
task?: BackgroundTask;
|
|
456
|
+
message: string;
|
|
457
|
+
};
|
|
458
|
+
getTask(taskId: string): BackgroundTask | undefined;
|
|
459
|
+
listTasks(): BackgroundTask[];
|
|
460
|
+
/**
|
|
461
|
+
* Dispose and cleanup all resources
|
|
462
|
+
* Call this when shutting down to prevent process from hanging
|
|
463
|
+
*/
|
|
464
|
+
dispose(): void;
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Task Create Hook Context
|
|
468
|
+
*
|
|
469
|
+
* 触发时机:createTask() 方法调用后,实际创建前
|
|
470
|
+
*
|
|
471
|
+
* Plugin 可直接修改 options 来干预创建行为
|
|
472
|
+
*/
|
|
473
|
+
interface TaskCreateContext {
|
|
474
|
+
/** 创建选项(Plugin 可直接修改) */
|
|
475
|
+
options: CreateTaskOptions;
|
|
476
|
+
/** Session ID */
|
|
477
|
+
sessionId: string;
|
|
478
|
+
/** Tag 服务引用 */
|
|
479
|
+
tagService: TagService;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Task Create Result Hook Context
|
|
483
|
+
*
|
|
484
|
+
* 触发时机:Task 创建成功后
|
|
485
|
+
*
|
|
486
|
+
* Plugin 可在此 Hook 中:
|
|
487
|
+
* - 同步 Tag 到数据库
|
|
488
|
+
* - 创建关联资源
|
|
489
|
+
* - 发送通知
|
|
490
|
+
*/
|
|
491
|
+
interface TaskCreateResultContext {
|
|
492
|
+
/** 创建后的 Task(已包含生成 ID) */
|
|
493
|
+
task: Task;
|
|
494
|
+
/** Session ID */
|
|
495
|
+
sessionId: string;
|
|
496
|
+
/** Tag 服务引用 */
|
|
497
|
+
tagService: TagService;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Task Update Hook Context
|
|
501
|
+
*
|
|
502
|
+
* 触发时机:updateTask() 方法调用后,实际更新前
|
|
503
|
+
*
|
|
504
|
+
* Plugin 可直接修改 options 来干预更新行为
|
|
505
|
+
*/
|
|
506
|
+
interface TaskUpdateContext {
|
|
507
|
+
/** Task ID */
|
|
508
|
+
id: number;
|
|
509
|
+
/** 更新选项(Plugin 可直接修改) */
|
|
510
|
+
options: UpdateTaskOptions;
|
|
511
|
+
/** Tag 服务引用 */
|
|
512
|
+
tagService: TagService;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Task Update Result Hook Context
|
|
516
|
+
*
|
|
517
|
+
* 触发时机:Task 更新成功后
|
|
518
|
+
*/
|
|
519
|
+
interface TaskUpdateResultContext {
|
|
520
|
+
/** 更新后的 Task */
|
|
521
|
+
task: Task;
|
|
522
|
+
/** 变更的字段 */
|
|
523
|
+
changes: Partial<UpdateTaskOptions>;
|
|
524
|
+
/** Tag 服务引用 */
|
|
525
|
+
tagService: TagService;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Task Delete Hook Context
|
|
529
|
+
*
|
|
530
|
+
* 触发时机:deleteTask() 方法调用后,实际删除前
|
|
531
|
+
*/
|
|
532
|
+
interface TaskDeleteContext {
|
|
533
|
+
/** Task ID */
|
|
534
|
+
id: number;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Task Delete Result Hook Context
|
|
538
|
+
*
|
|
539
|
+
* 触发时机:Task 删除成功后
|
|
540
|
+
*
|
|
541
|
+
* 注意:删除成功后无法获取 Task 的详细信息
|
|
542
|
+
*/
|
|
543
|
+
interface TaskDeleteResultContext {
|
|
544
|
+
/** 被删除的 Task ID */
|
|
545
|
+
id: number;
|
|
546
|
+
/** 是否成功删除 */
|
|
547
|
+
deleted: boolean;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Delegate Before Hook Context
|
|
551
|
+
*
|
|
552
|
+
* 触发时机:delegate_task 工具执行前
|
|
553
|
+
*
|
|
554
|
+
* Plugin 可直接修改 prompt 来注入上下文
|
|
555
|
+
*/
|
|
556
|
+
interface TaskDelegateContext {
|
|
557
|
+
/** 关联的 Task ID */
|
|
558
|
+
taskId?: number;
|
|
559
|
+
/** 执行提示词(Plugin 可直接修改以注入上下文) */
|
|
560
|
+
prompt: string;
|
|
561
|
+
/** SubAgent 类型 */
|
|
562
|
+
subagentType: string;
|
|
563
|
+
/** 是否后台执行 */
|
|
564
|
+
background: boolean;
|
|
565
|
+
/** 超时时间 */
|
|
566
|
+
timeout?: number;
|
|
567
|
+
/** 清理策略 */
|
|
568
|
+
cleanup?: "delete" | "keep";
|
|
569
|
+
/** 执行原因 */
|
|
570
|
+
reason?: string;
|
|
571
|
+
/** Tag 服务引用 */
|
|
572
|
+
tagService: TagService;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Delegate After Hook Context
|
|
576
|
+
*
|
|
577
|
+
* 触发时机:delegate_task 工具执行后
|
|
578
|
+
*/
|
|
579
|
+
interface TaskDelegateResultContext {
|
|
580
|
+
/** 关联的 Task ID */
|
|
581
|
+
taskId?: number;
|
|
582
|
+
/** 执行结果 */
|
|
583
|
+
result: DelegateToolResult;
|
|
584
|
+
/** Tag 服务引用 */
|
|
585
|
+
tagService: TagService;
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Operation Create Hook Context
|
|
589
|
+
*
|
|
590
|
+
* 触发时机:createOperation() 方法调用后,实际创建前
|
|
591
|
+
*
|
|
592
|
+
* Plugin 可直接修改 options 来干预操作记录创建
|
|
593
|
+
*/
|
|
594
|
+
interface TaskOperationCreateContext {
|
|
595
|
+
/** 创建选项(Plugin 可直接修改) */
|
|
596
|
+
options: CreateOperationOptions;
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Operation Create Result Hook Context
|
|
600
|
+
*
|
|
601
|
+
* 触发时机:操作记录创建成功后
|
|
602
|
+
*/
|
|
603
|
+
interface TaskOperationCreateResultContext {
|
|
604
|
+
/** 创建后的操作记录 */
|
|
605
|
+
operation: TaskOperation;
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* TaskHookContextMap - Hook 点与 Context 类型的映射
|
|
609
|
+
*
|
|
610
|
+
* 用于 Hook 执行时类型安全的 Context 获取
|
|
611
|
+
*/
|
|
612
|
+
interface TaskHookContextMap {
|
|
613
|
+
"task:before.create": TaskCreateContext;
|
|
614
|
+
"task:after.create": TaskCreateResultContext;
|
|
615
|
+
"task:before.update": TaskUpdateContext;
|
|
616
|
+
"task:after.update": TaskUpdateResultContext;
|
|
617
|
+
"task:before.delete": TaskDeleteContext;
|
|
618
|
+
"task:after.delete": TaskDeleteResultContext;
|
|
619
|
+
"task:delegate:before": TaskDelegateContext;
|
|
620
|
+
"task:delegate:after": TaskDelegateResultContext;
|
|
621
|
+
"task:operation:before.create": TaskOperationCreateContext;
|
|
622
|
+
"task:operation:after.create": TaskOperationCreateResultContext;
|
|
623
|
+
}
|
|
624
|
+
export { TaskUpdateResultContext, TaskUpdateContext, TaskOperationCreateResultContext, TaskOperationCreateContext, TaskHookPoints, TaskHookPoint, TaskHookContextMap, TaskDeleteResultContext, TaskDeleteContext, TaskDelegateResultContext, TaskDelegateContext, TaskCreateResultContext, TaskCreateContext };
|