@ai-setting/roy-agent-core 1.5.17-beta.1 → 1.5.23
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/env/event-source/index.js +41 -0
- package/dist/env/index.js +24 -10
- package/dist/env/log-trace/index.js +1 -1
- package/dist/env/prompt/index.js +1 -1
- package/dist/env/workflow/engine/index.js +1 -1
- package/dist/env/workflow/index.js +2 -2
- package/dist/index.js +35 -8
- package/dist/shared/@ai-setting/roy-agent-core-2grcjaad.js +0 -0
- package/dist/shared/@ai-setting/{roy-agent-core-xq8hhqb8.js → roy-agent-core-4wjywp3c.js} +4 -2
- package/dist/shared/@ai-setting/roy-agent-core-5ex3za0m.js +817 -0
- package/dist/shared/@ai-setting/roy-agent-core-8jxva565.js +19 -0
- package/dist/shared/@ai-setting/roy-agent-core-avq1x4t7.js +84 -0
- package/dist/shared/@ai-setting/{roy-agent-core-gq20wsgv.js → roy-agent-core-ffb9fq4v.js} +23 -2
- package/dist/shared/@ai-setting/roy-agent-core-j1sr5pk9.js +424 -0
- package/dist/shared/@ai-setting/{roy-agent-core-93zfb3r1.js → roy-agent-core-mrcxzpbg.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-rhmtwnw1.js → roy-agent-core-pw7cv1px.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-wrcy0h6z.js → roy-agent-core-ty94k28r.js} +1 -1
- package/package.json +8 -29
- package/dist/config/index.d.ts +0 -1250
- package/dist/env/agent/index.d.ts +0 -2279
- package/dist/env/commands/index.d.ts +0 -1131
- package/dist/env/debug/formatters/index.d.ts +0 -236
- package/dist/env/debug/index.d.ts +0 -1652
- package/dist/env/hook/index.d.ts +0 -279
- package/dist/env/index.d.ts +0 -3481
- package/dist/env/llm/index.d.ts +0 -1760
- package/dist/env/log-trace/index.d.ts +0 -1574
- package/dist/env/mcp/index.d.ts +0 -1331
- package/dist/env/mcp/tool/index.d.ts +0 -183
- package/dist/env/memory/built-in/index.d.ts +0 -232
- package/dist/env/memory/index.d.ts +0 -1799
- package/dist/env/memory/plugin/index.d.ts +0 -747
- package/dist/env/prompt/index.d.ts +0 -1164
- package/dist/env/session/index.d.ts +0 -1908
- package/dist/env/session/storage/index.d.ts +0 -564
- package/dist/env/skill/index.d.ts +0 -1266
- package/dist/env/skill/tool/index.d.ts +0 -193
- package/dist/env/task/delegate/index.d.ts +0 -1612
- package/dist/env/task/events/index.d.ts +0 -171
- package/dist/env/task/hooks/index.d.ts +0 -624
- package/dist/env/task/index.d.ts +0 -1553
- package/dist/env/task/plugins/index.d.ts +0 -466
- package/dist/env/task/storage/index.d.ts +0 -241
- package/dist/env/task/tools/index.d.ts +0 -1485
- package/dist/env/task/tools/operation/index.d.ts +0 -1484
- package/dist/env/tool/built-in/index.d.ts +0 -218
- package/dist/env/tool/index.d.ts +0 -1396
- package/dist/env/workflow/decorators/index.d.ts +0 -2161
- package/dist/env/workflow/engine/index.d.ts +0 -3453
- package/dist/env/workflow/index.d.ts +0 -3546
- package/dist/env/workflow/nodes/index.d.ts +0 -2092
- package/dist/env/workflow/service/index.d.ts +0 -227
- package/dist/env/workflow/storage/index.d.ts +0 -165
- package/dist/env/workflow/tools/index.d.ts +0 -416
- package/dist/env/workflow/types/index.d.ts +0 -2255
- package/dist/env/workflow/utils/index.d.ts +0 -2031
- package/dist/index.d.ts +0 -7858
- package/dist/shared/@ai-setting/roy-agent-core-gbqcyegm.js +0 -1387
|
@@ -1,466 +0,0 @@
|
|
|
1
|
-
import { z as z5 } from "zod";
|
|
2
|
-
/**
|
|
3
|
-
* Agent 类型
|
|
4
|
-
*/
|
|
5
|
-
type AgentType = "primary" | "sub" | "summary";
|
|
6
|
-
/**
|
|
7
|
-
* Agent 实例配置
|
|
8
|
-
*/
|
|
9
|
-
interface AgentInstanceConfig {
|
|
10
|
-
/** Agent 类型 */
|
|
11
|
-
type: AgentType;
|
|
12
|
-
/** Agent 名称 */
|
|
13
|
-
name?: string;
|
|
14
|
-
/** System Prompt */
|
|
15
|
-
systemPrompt?: string;
|
|
16
|
-
/** Behavior Spec ID */
|
|
17
|
-
behaviorSpecId?: string;
|
|
18
|
-
/** 使用的模型 */
|
|
19
|
-
model?: string;
|
|
20
|
-
/** 最大迭代次数 */
|
|
21
|
-
maxIterations?: number;
|
|
22
|
-
/** 最大错误重试次数 */
|
|
23
|
-
maxErrorRetries?: number;
|
|
24
|
-
/** 死循环检测阈值 */
|
|
25
|
-
doomLoopThreshold?: number;
|
|
26
|
-
/** 允许的工具列表 */
|
|
27
|
-
allowedTools?: string[];
|
|
28
|
-
/** 拒绝的工具列表 */
|
|
29
|
-
deniedTools?: string[];
|
|
30
|
-
/** 工具超时(毫秒) */
|
|
31
|
-
toolTimeout?: number;
|
|
32
|
-
/** 工具重试次数 */
|
|
33
|
-
toolRetries?: number;
|
|
34
|
-
/** 是否过滤 history 中的 tool 消息(默认过滤,避免上下文过长) */
|
|
35
|
-
filterHistory?: boolean;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Checkpoint type
|
|
39
|
-
*/
|
|
40
|
-
type CheckpointType = "compact" | "manual";
|
|
41
|
-
/**
|
|
42
|
-
* Checkpoint metadata (stored in Session.metadata)
|
|
43
|
-
*/
|
|
44
|
-
interface CheckpointMeta {
|
|
45
|
-
id: string;
|
|
46
|
-
messageIndex: number;
|
|
47
|
-
title: string;
|
|
48
|
-
createdAt: number;
|
|
49
|
-
type: CheckpointType;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* User Intent type - represents a user's intent extracted from conversation
|
|
53
|
-
*/
|
|
54
|
-
type UserIntent = string;
|
|
55
|
-
/**
|
|
56
|
-
* Recent message for checkpoint
|
|
57
|
-
*
|
|
58
|
-
* Stores a simplified version of a message for context preservation
|
|
59
|
-
*/
|
|
60
|
-
interface RecentMessage {
|
|
61
|
-
role: string;
|
|
62
|
-
content: string;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Complete checkpoint information (includes generated content)
|
|
66
|
-
*/
|
|
67
|
-
interface SessionCheckpoint extends CheckpointMeta {
|
|
68
|
-
summary: string;
|
|
69
|
-
processKeyPoints: string[];
|
|
70
|
-
currentState: string;
|
|
71
|
-
nextSteps: string[];
|
|
72
|
-
messageCountBefore: number;
|
|
73
|
-
metadata?: Record<string, unknown>;
|
|
74
|
-
/** User intents extracted from the conversation */
|
|
75
|
-
userIntents: UserIntent[];
|
|
76
|
-
/**
|
|
77
|
-
* Recent messages preserved from the compacted conversation
|
|
78
|
-
*
|
|
79
|
-
* Contains the last N turns of user query + assistant text response
|
|
80
|
-
* (excluding tool calls and tool results).
|
|
81
|
-
* This allows the checkpoint to serve as a fresh history context.
|
|
82
|
-
*
|
|
83
|
-
* Format: [user, assistant, user, assistant, ...] from most recent
|
|
84
|
-
*/
|
|
85
|
-
recentMessages?: RecentMessage[];
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Session message
|
|
89
|
-
*/
|
|
90
|
-
interface SessionMessage {
|
|
91
|
-
id: string;
|
|
92
|
-
sessionID: string;
|
|
93
|
-
role: Role;
|
|
94
|
-
content: string;
|
|
95
|
-
timestamp: number;
|
|
96
|
-
parts?: MessagePart[];
|
|
97
|
-
/** Whether the message has been archived (compacted) */
|
|
98
|
-
isArchived?: boolean;
|
|
99
|
-
/** Timestamp when the message was archived */
|
|
100
|
-
archivedAt?: number;
|
|
101
|
-
/** Checkpoint ID this message belongs to */
|
|
102
|
-
checkpointId?: string;
|
|
103
|
-
/** Message metadata (includes checkpoint info if this is a checkpoint message) */
|
|
104
|
-
metadata?: MessageMetadata;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Message metadata
|
|
108
|
-
*/
|
|
109
|
-
interface MessageMetadata extends Record<string, unknown> {
|
|
110
|
-
/** 消息类型标识,用于过滤和分类 */
|
|
111
|
-
type?: "tool_call" | "tool_result" | "checkpoint" | "user_intent" | "workflow.node.start" | "workflow.node.interrupt" | "workflow.node.end" | "workflow.node.resume";
|
|
112
|
-
isCheckpoint?: boolean;
|
|
113
|
-
checkpointId?: string;
|
|
114
|
-
checkpointMeta?: SessionCheckpoint;
|
|
115
|
-
/** Workflow node ID (for workflow.node.* messages) */
|
|
116
|
-
workflowNodeId?: string;
|
|
117
|
-
/** Workflow node type (for workflow.node.* messages) */
|
|
118
|
-
workflowNodeType?: string;
|
|
119
|
-
/** Agent session ID (for agent nodes in workflow) */
|
|
120
|
-
agentSessionId?: string;
|
|
121
|
-
/** User response (for workflow.node.resume messages) */
|
|
122
|
-
response?: string;
|
|
123
|
-
/** Success flag (for workflow.node.end messages) */
|
|
124
|
-
success?: boolean;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Message role
|
|
128
|
-
*/
|
|
129
|
-
type Role = "user" | "assistant" | "system" | "tool" | "workflow.node.start" | "workflow.node.interrupt" | "workflow.node.end" | "workflow.node.resume";
|
|
130
|
-
/**
|
|
131
|
-
* Message part
|
|
132
|
-
*/
|
|
133
|
-
type MessagePart = SessionPart;
|
|
134
|
-
/**
|
|
135
|
-
* Text part - plain text content
|
|
136
|
-
*/
|
|
137
|
-
interface TextPart {
|
|
138
|
-
type: "text";
|
|
139
|
-
content: string;
|
|
140
|
-
/** If true, this part was generated by the system (e.g., auto-summary) */
|
|
141
|
-
synthetic?: boolean;
|
|
142
|
-
/** If true, this part should be ignored (e.g., replaced by reasoning) */
|
|
143
|
-
ignored?: boolean;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Tool call part - represents a tool invocation
|
|
147
|
-
*/
|
|
148
|
-
interface ToolCallPart {
|
|
149
|
-
type: "tool-call";
|
|
150
|
-
/** AI SDK standard field name */
|
|
151
|
-
toolCallId: string;
|
|
152
|
-
toolName: string;
|
|
153
|
-
/** Tool arguments - can be string (JSON) or object */
|
|
154
|
-
arguments: string | Record<string, unknown>;
|
|
155
|
-
state: "pending" | "running";
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Tool result part - represents the result of a tool execution
|
|
159
|
-
*/
|
|
160
|
-
interface ToolResultPart {
|
|
161
|
-
type: "tool-result";
|
|
162
|
-
toolCallId: string;
|
|
163
|
-
toolName: string;
|
|
164
|
-
output: string;
|
|
165
|
-
error?: string;
|
|
166
|
-
state: "completed" | "error";
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Reasoning part - AI thinking/thought content
|
|
170
|
-
*/
|
|
171
|
-
interface ReasoningPart {
|
|
172
|
-
type: "reasoning";
|
|
173
|
-
/** Reasoning content */
|
|
174
|
-
content: string;
|
|
175
|
-
/** Reasoning type (for different models) */
|
|
176
|
-
reasoningType?: "core" | "effort" | "summary";
|
|
177
|
-
/** State */
|
|
178
|
-
state?: "thinking" | "completed";
|
|
179
|
-
/** Whether to collapse by default (like AI SDK default) */
|
|
180
|
-
isCollapsed?: boolean;
|
|
181
|
-
/** Metadata */
|
|
182
|
-
metadata?: {
|
|
183
|
-
tokenCount?: number;
|
|
184
|
-
time?: {
|
|
185
|
-
start: number;
|
|
186
|
-
end?: number;
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* File part - file attachment
|
|
192
|
-
*/
|
|
193
|
-
interface FilePart {
|
|
194
|
-
type: "file";
|
|
195
|
-
mime: string;
|
|
196
|
-
url: string;
|
|
197
|
-
filename?: string;
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Checkpoint part - compaction checkpoint marker
|
|
201
|
-
*
|
|
202
|
-
* Represents a checkpoint message in the conversation history.
|
|
203
|
-
* This is stored as a user role message with markdown content summarizing
|
|
204
|
-
* the compacted conversation segment.
|
|
205
|
-
*/
|
|
206
|
-
interface CheckpointPart {
|
|
207
|
-
type: "checkpoint";
|
|
208
|
-
/** Checkpoint ID reference */
|
|
209
|
-
checkpointId: string;
|
|
210
|
-
/** Markdown content summarizing the checkpoint */
|
|
211
|
-
content: string;
|
|
212
|
-
/** Title of the checkpoint */
|
|
213
|
-
title?: string;
|
|
214
|
-
/** Process key points */
|
|
215
|
-
processKeyPoints?: string[];
|
|
216
|
-
/** Current state description */
|
|
217
|
-
currentState?: string;
|
|
218
|
-
/** Next steps */
|
|
219
|
-
nextSteps?: string[];
|
|
220
|
-
/** Number of messages that were compacted */
|
|
221
|
-
messageCountBefore?: number;
|
|
222
|
-
/** Creation timestamp */
|
|
223
|
-
createdAt?: number;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Union type for all Session Part types
|
|
227
|
-
*/
|
|
228
|
-
type SessionPart = TextPart | ToolCallPart | ToolResultPart | ReasoningPart | FilePart | CheckpointPart | WorkflowNodeStartPart | WorkflowNodeInterruptPart | WorkflowNodeEndPart | WorkflowNodeResumePart;
|
|
229
|
-
/**
|
|
230
|
-
* workflow.node.start 消息 part (对应 tool-call)
|
|
231
|
-
*/
|
|
232
|
-
interface WorkflowNodeStartPart {
|
|
233
|
-
type: "workflow-node-start";
|
|
234
|
-
nodeId: string;
|
|
235
|
-
nodeType: string;
|
|
236
|
-
input?: unknown;
|
|
237
|
-
startTime: number;
|
|
238
|
-
/** Agent session ID (only for agent nodes) */
|
|
239
|
-
agentSessionId?: string;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* workflow.node.interrupt 消息 part
|
|
243
|
-
*/
|
|
244
|
-
interface WorkflowNodeInterruptPart {
|
|
245
|
-
type: "workflow-node-interrupt";
|
|
246
|
-
nodeId: string;
|
|
247
|
-
nodeType: string;
|
|
248
|
-
query: string;
|
|
249
|
-
options?: string[];
|
|
250
|
-
timestamp: number;
|
|
251
|
-
/** Agent session ID (only for agent nodes) */
|
|
252
|
-
agentSessionId?: string;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* workflow.node.end 消息 part (对应 tool-result)
|
|
256
|
-
*/
|
|
257
|
-
interface WorkflowNodeEndPart {
|
|
258
|
-
type: "workflow-node-end";
|
|
259
|
-
nodeId: string;
|
|
260
|
-
nodeType: string;
|
|
261
|
-
output?: unknown;
|
|
262
|
-
error?: string;
|
|
263
|
-
durationMs: number;
|
|
264
|
-
/** Agent session ID (only for agent nodes) */
|
|
265
|
-
agentSessionId?: string;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* workflow.node.resume 消息 part
|
|
269
|
-
*/
|
|
270
|
-
interface WorkflowNodeResumePart {
|
|
271
|
-
type: "workflow-node-resume";
|
|
272
|
-
nodeId: string;
|
|
273
|
-
response: string;
|
|
274
|
-
timestamp: number;
|
|
275
|
-
/** Agent session ID (only for agent nodes) */
|
|
276
|
-
agentSessionId?: string;
|
|
277
|
-
}
|
|
278
|
-
declare const WorkflowDefinitionSchema: unknown;
|
|
279
|
-
type WorkflowDefinition = z5.infer<typeof WorkflowDefinitionSchema>;
|
|
280
|
-
/**
|
|
281
|
-
* TaskPlugin 配置
|
|
282
|
-
*/
|
|
283
|
-
interface TaskPluginConfig {
|
|
284
|
-
/** 是否启用 */
|
|
285
|
-
enabled?: boolean;
|
|
286
|
-
/** 优先级 */
|
|
287
|
-
priority?: number;
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* TaskPlugin Hook 定义
|
|
291
|
-
*/
|
|
292
|
-
interface TaskPluginHook {
|
|
293
|
-
/** Hook 点 */
|
|
294
|
-
point: string;
|
|
295
|
-
/** 优先级(数字越大越先执行)*/
|
|
296
|
-
priority?: number;
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* TaskPlugin 基类
|
|
300
|
-
*/
|
|
301
|
-
declare abstract class TaskPlugin {
|
|
302
|
-
abstract readonly name: string;
|
|
303
|
-
abstract readonly hooks: TaskPluginHook[];
|
|
304
|
-
protected config: TaskPluginConfig;
|
|
305
|
-
constructor(config?: TaskPluginConfig);
|
|
306
|
-
/**
|
|
307
|
-
* 设置依赖组件(可选实现)
|
|
308
|
-
*/
|
|
309
|
-
setComponents?(llmComponent: unknown, taskComponent: unknown): void;
|
|
310
|
-
/**
|
|
311
|
-
* 获取 Hook 点列表
|
|
312
|
-
*/
|
|
313
|
-
getHookPoints(): string[];
|
|
314
|
-
/**
|
|
315
|
-
* 获取指定 Hook 点的优先级
|
|
316
|
-
*/
|
|
317
|
-
getPriorityForHook(hookPoint: string): number;
|
|
318
|
-
/**
|
|
319
|
-
* 检查是否启用
|
|
320
|
-
*/
|
|
321
|
-
isEnabled(): boolean;
|
|
322
|
-
/**
|
|
323
|
-
* 设置启用状态
|
|
324
|
-
*/
|
|
325
|
-
setEnabled(enabled: boolean): void;
|
|
326
|
-
}
|
|
327
|
-
import { z as z7 } from "zod";
|
|
328
|
-
/**
|
|
329
|
-
* Task status enum
|
|
330
|
-
*/
|
|
331
|
-
declare const TaskStatusEnum: unknown;
|
|
332
|
-
type TaskStatus = z7.infer<typeof TaskStatusEnum>;
|
|
333
|
-
/**
|
|
334
|
-
* Task priority enum
|
|
335
|
-
*/
|
|
336
|
-
declare const TaskPriorityEnum: unknown;
|
|
337
|
-
type TaskPriority = z7.infer<typeof TaskPriorityEnum>;
|
|
338
|
-
/**
|
|
339
|
-
* Action type for task operations
|
|
340
|
-
*/
|
|
341
|
-
declare const ActionTypeEnum: unknown;
|
|
342
|
-
type ActionType = z7.infer<typeof ActionTypeEnum>;
|
|
343
|
-
/**
|
|
344
|
-
* Task entity
|
|
345
|
-
*/
|
|
346
|
-
interface Task {
|
|
347
|
-
id: number;
|
|
348
|
-
title: string;
|
|
349
|
-
description: string;
|
|
350
|
-
status: TaskStatus;
|
|
351
|
-
priority: TaskPriority;
|
|
352
|
-
progress: number;
|
|
353
|
-
current_status: string;
|
|
354
|
-
goals_and_expected_deliverables: string;
|
|
355
|
-
parent_task_id?: number;
|
|
356
|
-
createdAt: string;
|
|
357
|
-
updatedAt: string;
|
|
358
|
-
due_date?: string;
|
|
359
|
-
tags?: string[];
|
|
360
|
-
/** Project root path for task positioning */
|
|
361
|
-
project_path: string;
|
|
362
|
-
/** JSON string with time-space positioning info (worktree, branch, etc.) */
|
|
363
|
-
context: string;
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* TaskOperation entity
|
|
367
|
-
*
|
|
368
|
-
* 记录任务的操作历史,每个操作关联到一个 sessionId
|
|
369
|
-
*/
|
|
370
|
-
interface TaskOperation {
|
|
371
|
-
id: number;
|
|
372
|
-
taskId: number;
|
|
373
|
-
sessionId: string;
|
|
374
|
-
actionType: ActionType;
|
|
375
|
-
actionTitle: string;
|
|
376
|
-
actionDescription: string;
|
|
377
|
-
timestamp: string;
|
|
378
|
-
mdPath?: string;
|
|
379
|
-
}
|
|
380
|
-
interface TaskComponentLike {
|
|
381
|
-
getTask(id: number): Promise<Task | undefined>;
|
|
382
|
-
listOperations(options: {
|
|
383
|
-
taskId: number;
|
|
384
|
-
limit?: number;
|
|
385
|
-
}): Promise<Array<{
|
|
386
|
-
id: number;
|
|
387
|
-
taskId: number;
|
|
388
|
-
actionType: string;
|
|
389
|
-
actionTitle: string;
|
|
390
|
-
actionDescription: string;
|
|
391
|
-
}>>;
|
|
392
|
-
createOperation(options: any): Promise<any>;
|
|
393
|
-
env?: {
|
|
394
|
-
getComponent(name: string): unknown;
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
declare class TaskTagPlugin extends TaskPlugin {
|
|
398
|
-
readonly name = "TaskTagPlugin";
|
|
399
|
-
readonly hooks: readonly [{
|
|
400
|
-
readonly priority: 20;
|
|
401
|
-
}, {
|
|
402
|
-
readonly priority: 10;
|
|
403
|
-
}];
|
|
404
|
-
private taskComponent;
|
|
405
|
-
private agentComponent;
|
|
406
|
-
constructor(config?: TaskPluginConfig);
|
|
407
|
-
static getRequiredAgents(): unknown;
|
|
408
|
-
setComponents(_llmComponent: unknown, taskComponent: TaskComponentLike | null): void;
|
|
409
|
-
execute(ctx: any): Promise<void>;
|
|
410
|
-
/**
|
|
411
|
-
* 委派前:注入类似任务信息
|
|
412
|
-
*
|
|
413
|
-
* 1. 从 task.tags 和 title 提取关键词
|
|
414
|
-
* 2. 检索最多 5 个类似任务
|
|
415
|
-
* 3. 只注入任务 ID、描述和目标
|
|
416
|
-
* 4. 提示可通过 task_get 获取详细信息
|
|
417
|
-
*/
|
|
418
|
-
private onDelegateBefore;
|
|
419
|
-
/**
|
|
420
|
-
* 从 task 提取关键词
|
|
421
|
-
*/
|
|
422
|
-
private extractKeywords;
|
|
423
|
-
/**
|
|
424
|
-
* 格式化类似任务(简洁版)
|
|
425
|
-
*
|
|
426
|
-
* 注入格式:
|
|
427
|
-
* - Task ID: 用于引用和检索
|
|
428
|
-
* - Title: 任务标题
|
|
429
|
-
* - Description: 任务描述(截断至 100 字符)
|
|
430
|
-
* - Goal: 目标(截断至 100 字符)
|
|
431
|
-
* - 提醒:通过 task_get 和 task_operation_list 获取详细信息
|
|
432
|
-
*/
|
|
433
|
-
private formatSimilarTasks;
|
|
434
|
-
private onOperationAfterCreate;
|
|
435
|
-
private extractWorkflow;
|
|
436
|
-
private getWorkflowRepository;
|
|
437
|
-
private ensureDataDir;
|
|
438
|
-
private _workflowRepo;
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* Workflow Extractor Agent System Prompt
|
|
442
|
-
*/
|
|
443
|
-
declare const WORKFLOW_EXTRACTOR_PROMPT = "你是 Workflow 提取专家,负责将自然语言描述转换为符合规范的 Workflow YAML。\n\n## 提取原则\n\n1. **优先具象节点**:优先使用特定工具节点(如 read_file, write_file, grep, bash 等)\n2. **Fallback 到通用节点**:没有对应工具时,使用 agent/llm/bash 节点\n3. **避免条件分支**:不提取循环和条件判断,保持线性流程\n4. **泛化但可执行**:步骤描述可泛化,但节点类型和工具要具体\n\n## 构建流程\n\n**重要**:构建的 Workflow 必须通过 `roy workflow validate` 验证才能输出。\n\n```\n1. 理解用户需求\n2. 参考 roy workflow nodes 查看可用节点类型\n3. 参考 roy workflow get <name> 查看已有 workflow 示例\n4. 生成 Workflow YAML\n5. 使用 roy workflow validate --yaml \"<生成的YAML>\" 验证\n6. 验证通过后输出最终结果\n```\n\n## 验证检查清单\n\n完成 Workflow 构建后,必须使用以下命令验证:\n\n```bash\nroy workflow validate --yaml \"<your-yaml>\"\n```\n\n验证通过后(无错误输出)才输出最终结果。验证失败时根据错误信息修正后重新验证。\n\n## 可用的 Workflow 节点类型\n\n使用以下命令查看所有节点类型的详细配置:\n\n```bash\nroy workflow nodes # 列出所有节点类型\nroy workflow nodes <type> # 查看特定节点详情(如 tool, agent, skill)\n```\n\n**支持的节点类型:**\n- **tool**:执行工具(bash, read-file, write-file, grep 等)\n- **skill**:调用技能\n- **agent**:AI Agent\n- **workflow**:子工作流\n- **condition**:条件判断\n- **merge**:合并结果\n- **decorator**:装饰器方法\n\n## 查看已有 Workflow 示例\n\n使用以下命令查看已有 workflow 的 YAML 结构:\n\n```bash\nroy workflow list # 列出所有 workflow\nroy workflow get <name> # 获取指定 workflow 详情(YAML 格式)\n```\n\n## 输出要求\n\n验证通过后,输出符合以下格式的 YAML Workflow:\n\n```yaml\nname: {泛化的任务名称}\nversion: \"1.0\"\ndescription: {一句话描述}\nnodes:\n - id: node-1\n type: tool|skill|agent|workflow|condition|merge|decorator\n name: {节点名称}\n config:\n # 根据类型配置必填字段:\n # tool: tool, input/args\n # skill: skill, input\n # agent: agent_type, prompt, options\n # workflow: workflow_name, input\n # condition: condition\n # merge: strategy, depends_on\n # decorator: _methodName, _instance\n depends_on: []\noutputs: []\n```\n\n## 限制\n\n- 至少 2 个节点才有意义\n- 不要生成条件节点(if/else/switch)\n- 不要生成循环节点(while/for)\n- 每个节点要有清晰的名称和描述\n- 必须为 tool 节点指定 tool 名称\n- 必须为 agent 节点指定 agent_type 和 prompt";
|
|
444
|
-
/**
|
|
445
|
-
* 创建 WorkflowExtractorAgent 配置
|
|
446
|
-
*/
|
|
447
|
-
declare function createWorkflowExtractorAgent(): AgentInstanceConfig;
|
|
448
|
-
/**
|
|
449
|
-
* 格式化提取器输入 - 从 Task 提取
|
|
450
|
-
*/
|
|
451
|
-
declare function formatExtractorInput(params: {
|
|
452
|
-
task: Task;
|
|
453
|
-
operations: TaskOperation[];
|
|
454
|
-
messages: SessionMessage[];
|
|
455
|
-
}): string;
|
|
456
|
-
/**
|
|
457
|
-
* 格式化提取器输入 - 从自然语言描述提取
|
|
458
|
-
*/
|
|
459
|
-
declare function formatExtractorInputFromDescription(params: {
|
|
460
|
-
description: string;
|
|
461
|
-
}): string;
|
|
462
|
-
/**
|
|
463
|
-
* 解析提取器输出
|
|
464
|
-
*/
|
|
465
|
-
declare function parseExtractorOutput(output: string): Promise<WorkflowDefinition | null>;
|
|
466
|
-
export { parseExtractorOutput, formatExtractorInputFromDescription, formatExtractorInput, createWorkflowExtractorAgent, WORKFLOW_EXTRACTOR_PROMPT, TaskTagPlugin, TaskPluginHook, TaskPluginConfig, TaskPlugin };
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/**
|
|
3
|
-
* Task status enum
|
|
4
|
-
*/
|
|
5
|
-
declare const TaskStatusEnum: unknown;
|
|
6
|
-
type TaskStatus = z.infer<typeof TaskStatusEnum>;
|
|
7
|
-
/**
|
|
8
|
-
* Task priority enum
|
|
9
|
-
*/
|
|
10
|
-
declare const TaskPriorityEnum: unknown;
|
|
11
|
-
type TaskPriority = z.infer<typeof TaskPriorityEnum>;
|
|
12
|
-
/**
|
|
13
|
-
* Action type for task operations
|
|
14
|
-
*/
|
|
15
|
-
declare const ActionTypeEnum: unknown;
|
|
16
|
-
type ActionType = z.infer<typeof ActionTypeEnum>;
|
|
17
|
-
/**
|
|
18
|
-
* Task entity
|
|
19
|
-
*/
|
|
20
|
-
interface Task {
|
|
21
|
-
id: number;
|
|
22
|
-
title: string;
|
|
23
|
-
description: string;
|
|
24
|
-
status: TaskStatus;
|
|
25
|
-
priority: TaskPriority;
|
|
26
|
-
progress: number;
|
|
27
|
-
current_status: string;
|
|
28
|
-
goals_and_expected_deliverables: string;
|
|
29
|
-
parent_task_id?: number;
|
|
30
|
-
createdAt: string;
|
|
31
|
-
updatedAt: string;
|
|
32
|
-
due_date?: string;
|
|
33
|
-
tags?: string[];
|
|
34
|
-
/** Project root path for task positioning */
|
|
35
|
-
project_path: string;
|
|
36
|
-
/** JSON string with time-space positioning info (worktree, branch, etc.) */
|
|
37
|
-
context: string;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* TaskOperation entity
|
|
41
|
-
*
|
|
42
|
-
* 记录任务的操作历史,每个操作关联到一个 sessionId
|
|
43
|
-
*/
|
|
44
|
-
interface TaskOperation {
|
|
45
|
-
id: number;
|
|
46
|
-
taskId: number;
|
|
47
|
-
sessionId: string;
|
|
48
|
-
actionType: ActionType;
|
|
49
|
-
actionTitle: string;
|
|
50
|
-
actionDescription: string;
|
|
51
|
-
timestamp: string;
|
|
52
|
-
mdPath?: string;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* TaskTag entity
|
|
56
|
-
*
|
|
57
|
-
* Tag 池中的单个 Tag
|
|
58
|
-
*/
|
|
59
|
-
interface TaskTag {
|
|
60
|
-
id: number;
|
|
61
|
-
name: string;
|
|
62
|
-
createdAt: string;
|
|
63
|
-
taskCount: number;
|
|
64
|
-
}
|
|
65
|
-
interface CreateTaskOptions {
|
|
66
|
-
title: string;
|
|
67
|
-
description?: string;
|
|
68
|
-
priority?: TaskPriority;
|
|
69
|
-
parent_task_id?: number;
|
|
70
|
-
goals_and_expected_deliverables?: string;
|
|
71
|
-
due_date?: string;
|
|
72
|
-
tags?: string[];
|
|
73
|
-
sessionId: string;
|
|
74
|
-
/** Project root path for task positioning. Use 'unknown' if unknown. */
|
|
75
|
-
project_path: string;
|
|
76
|
-
/**
|
|
77
|
-
* JSON string with time-space positioning info.
|
|
78
|
-
* - For coding tasks: include worktree_path, branch, type
|
|
79
|
-
* - For other tasks: use '{}' or '{"type":"unknown"}'
|
|
80
|
-
* Must be a valid JSON string.
|
|
81
|
-
*/
|
|
82
|
-
context: string;
|
|
83
|
-
}
|
|
84
|
-
interface UpdateTaskOptions {
|
|
85
|
-
title?: string;
|
|
86
|
-
description?: string;
|
|
87
|
-
status?: TaskStatus;
|
|
88
|
-
priority?: TaskPriority;
|
|
89
|
-
progress?: number;
|
|
90
|
-
current_status?: string;
|
|
91
|
-
goals_and_expected_deliverables?: string;
|
|
92
|
-
due_date?: string;
|
|
93
|
-
tags?: string[];
|
|
94
|
-
/** 项目路径,标识任务所属的项目 */
|
|
95
|
-
project_path?: string;
|
|
96
|
-
/** 任务上下文信息,用于存储额外上下文 */
|
|
97
|
-
context?: string;
|
|
98
|
-
}
|
|
99
|
-
interface ListTasksOptions {
|
|
100
|
-
status?: TaskStatus;
|
|
101
|
-
priority?: TaskPriority;
|
|
102
|
-
parent_task_id?: number;
|
|
103
|
-
limit?: number;
|
|
104
|
-
offset?: number;
|
|
105
|
-
}
|
|
106
|
-
interface CreateOperationOptions {
|
|
107
|
-
taskId: number;
|
|
108
|
-
sessionId: string;
|
|
109
|
-
actionType: ActionType;
|
|
110
|
-
actionTitle: string;
|
|
111
|
-
actionDescription?: string;
|
|
112
|
-
mdPath?: string;
|
|
113
|
-
}
|
|
114
|
-
interface ListOperationsOptions {
|
|
115
|
-
taskId: number;
|
|
116
|
-
actionType?: ActionType;
|
|
117
|
-
limit?: number;
|
|
118
|
-
offset?: number;
|
|
119
|
-
}
|
|
120
|
-
interface ListTagsOptions {
|
|
121
|
-
limit?: number;
|
|
122
|
-
offset?: number;
|
|
123
|
-
orderBy?: "count" | "name" | "created_at";
|
|
124
|
-
}
|
|
125
|
-
interface SearchTagsOptions {
|
|
126
|
-
query: string;
|
|
127
|
-
limit?: number;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Get default data directory for task storage
|
|
131
|
-
*/
|
|
132
|
-
declare function getDefaultDataDir(): string;
|
|
133
|
-
/**
|
|
134
|
-
* Get default database path for task storage
|
|
135
|
-
*/
|
|
136
|
-
declare function getDefaultTaskDbPath(): string;
|
|
137
|
-
interface TaskStore {
|
|
138
|
-
createTask(options: CreateTaskOptions): Promise<Task>;
|
|
139
|
-
getTask(id: number): Promise<Task | undefined>;
|
|
140
|
-
updateTask(id: number, options: UpdateTaskOptions): Promise<Task | undefined>;
|
|
141
|
-
deleteTask(id: number): Promise<boolean>;
|
|
142
|
-
listTasks(options?: ListTasksOptions): Promise<Task[]>;
|
|
143
|
-
createOperation(options: CreateOperationOptions): Promise<TaskOperation>;
|
|
144
|
-
getOperation(id: number): Promise<TaskOperation | undefined>;
|
|
145
|
-
updateOperation(id: number, updates: {
|
|
146
|
-
actionTitle?: string;
|
|
147
|
-
actionDescription?: string;
|
|
148
|
-
}): Promise<TaskOperation | undefined>;
|
|
149
|
-
deleteOperation(id: number): Promise<boolean>;
|
|
150
|
-
listOperations(options: ListOperationsOptions): Promise<TaskOperation[]>;
|
|
151
|
-
createTag(name: string): Promise<TaskTag>;
|
|
152
|
-
getTag(id: number): Promise<TaskTag | undefined>;
|
|
153
|
-
getTagByName(name: string): Promise<TaskTag | undefined>;
|
|
154
|
-
listTags(options?: ListTagsOptions): Promise<TaskTag[]>;
|
|
155
|
-
searchTags(options: SearchTagsOptions): Promise<TaskTag[]>;
|
|
156
|
-
deleteTag(id: number): Promise<boolean>;
|
|
157
|
-
addTagsToTask(taskId: number, tagIds: number[]): Promise<void>;
|
|
158
|
-
removeTagsFromTask(taskId: number, tagIds: number[]): Promise<void>;
|
|
159
|
-
getTagsForTask(taskId: number): Promise<TaskTag[]>;
|
|
160
|
-
getTaskIdsByTags(tagNames: string[]): Promise<number[]>;
|
|
161
|
-
updateTaskTags(taskId: number, tagNames: string[]): Promise<void>;
|
|
162
|
-
/** Search tasks by keywords (tags, description, goals, operations) */
|
|
163
|
-
searchTasksByKeywords(keywords: string[], options?: {
|
|
164
|
-
limit?: number;
|
|
165
|
-
excludeTaskId?: number;
|
|
166
|
-
}): Promise<Task[]>;
|
|
167
|
-
/** Find similar tasks using new keywords search */
|
|
168
|
-
findSimilarTasksByKeywords(keywords: string[], options?: {
|
|
169
|
-
limit?: number;
|
|
170
|
-
excludeTaskId?: number;
|
|
171
|
-
}): Promise<Task[]>;
|
|
172
|
-
findSimilarTasks(taskId: number, limit?: number): Promise<Task[]>;
|
|
173
|
-
searchTasks(query: string, limit?: number): Promise<Task[]>;
|
|
174
|
-
close(): void;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* SQLite-based Task Store
|
|
178
|
-
*
|
|
179
|
-
* 参考 Session SQLiteStore 实现模式:
|
|
180
|
-
* - 使用 bun:sqlite 内置模块
|
|
181
|
-
* - 内存缓存提高性能
|
|
182
|
-
* - 默认路径:~/.local/share/roy-agent/tasks.db
|
|
183
|
-
*/
|
|
184
|
-
declare class SQLiteTaskStore implements TaskStore {
|
|
185
|
-
private db;
|
|
186
|
-
private dbPath;
|
|
187
|
-
private initialized;
|
|
188
|
-
private tasksCache;
|
|
189
|
-
private operationsCache;
|
|
190
|
-
constructor(dbPath?: string);
|
|
191
|
-
private initialize;
|
|
192
|
-
createTask(options: CreateTaskOptions): Promise<Task>;
|
|
193
|
-
getTask(id: number): Promise<Task | undefined>;
|
|
194
|
-
updateTask(id: number, options: UpdateTaskOptions): Promise<Task | undefined>;
|
|
195
|
-
deleteTask(id: number): Promise<boolean>;
|
|
196
|
-
listTasks(options?: ListTasksOptions): Promise<Task[]>;
|
|
197
|
-
createOperation(options: CreateOperationOptions): Promise<TaskOperation>;
|
|
198
|
-
getOperation(id: number): Promise<TaskOperation | undefined>;
|
|
199
|
-
updateOperation(id: number, updates: {
|
|
200
|
-
actionTitle?: string;
|
|
201
|
-
actionDescription?: string;
|
|
202
|
-
}): Promise<TaskOperation | undefined>;
|
|
203
|
-
deleteOperation(id: number): Promise<boolean>;
|
|
204
|
-
listOperations(options: ListOperationsOptions): Promise<TaskOperation[]>;
|
|
205
|
-
private rowToTask;
|
|
206
|
-
private rowToOperation;
|
|
207
|
-
createTag(name: string): Promise<TaskTag>;
|
|
208
|
-
getTag(id: number): Promise<TaskTag | undefined>;
|
|
209
|
-
getTagByName(name: string): Promise<TaskTag | undefined>;
|
|
210
|
-
listTags(options?: ListTagsOptions): Promise<TaskTag[]>;
|
|
211
|
-
searchTags(options: SearchTagsOptions): Promise<TaskTag[]>;
|
|
212
|
-
deleteTag(id: number): Promise<boolean>;
|
|
213
|
-
addTagsToTask(taskId: number, tagIds: number[]): Promise<void>;
|
|
214
|
-
removeTagsFromTask(taskId: number, tagIds: number[]): Promise<void>;
|
|
215
|
-
getTagsForTask(taskId: number): Promise<TaskTag[]>;
|
|
216
|
-
getTaskIdsByTags(tagNames: string[]): Promise<number[]>;
|
|
217
|
-
updateTaskTags(taskId: number, tagNames: string[]): Promise<void>;
|
|
218
|
-
/**
|
|
219
|
-
* Search tasks by keywords list
|
|
220
|
-
* Searches in: tags (JSON), description, goals_and_expected_deliverables, operations
|
|
221
|
-
*/
|
|
222
|
-
searchTasksByKeywords(keywords: string[], options?: {
|
|
223
|
-
limit?: number;
|
|
224
|
-
excludeTaskId?: number;
|
|
225
|
-
}): Promise<Task[]>;
|
|
226
|
-
/**
|
|
227
|
-
* Find similar tasks by keywords
|
|
228
|
-
* Excludes the target task and sorts by relevance
|
|
229
|
-
* Default limit is 5 to keep prompt concise
|
|
230
|
-
*/
|
|
231
|
-
findSimilarTasksByKeywords(keywords: string[], options?: {
|
|
232
|
-
limit?: number;
|
|
233
|
-
excludeTaskId?: number;
|
|
234
|
-
}): Promise<Task[]>;
|
|
235
|
-
findSimilarTasks(taskId: number, limit?: number): Promise<Task[]>;
|
|
236
|
-
searchTasks(query: string, limit?: number): Promise<Task[]>;
|
|
237
|
-
private rowToTag;
|
|
238
|
-
private syncTaskTagsJson;
|
|
239
|
-
close(): Promise<void>;
|
|
240
|
-
}
|
|
241
|
-
export { getDefaultTaskDbPath, getDefaultDataDir, TaskStore, SQLiteTaskStore };
|