@ai-setting/roy-agent-core 1.5.47 → 1.5.49
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.js +6 -5
- package/dist/env/agent/index.js +6 -5
- package/dist/env/commands/index.js +6 -5
- package/dist/env/context/index.js +9 -3
- package/dist/env/debug/index.js +6 -5
- package/dist/env/event-source/index.js +8 -7
- package/dist/env/hook/index.js +4 -3
- package/dist/env/index.js +20 -19
- package/dist/env/llm/index.js +6 -5
- package/dist/env/log-trace/index.js +6 -5
- package/dist/env/mcp/index.js +6 -5
- package/dist/env/memory/index.js +6 -5
- package/dist/env/plugin/index.js +6 -5
- package/dist/env/prompt/index.js +6 -5
- package/dist/env/session/index.js +6 -5
- package/dist/env/skill/index.js +6 -5
- package/dist/env/task/delegate/index.js +4 -3
- package/dist/env/task/index.js +15 -10
- package/dist/env/task/plugins/index.js +3 -2
- package/dist/env/task/storage/index.js +1 -1
- package/dist/env/task/tools/index.js +5 -1
- package/dist/env/tool/index.js +6 -5
- package/dist/env/workflow/engine/index.js +6 -5
- package/dist/env/workflow/index.js +9 -8
- package/dist/index.js +34 -28
- package/dist/shared/@ai-setting/{roy-agent-core-4gmxjdhn.js → roy-agent-core-14fna5qg.js} +4 -2
- package/dist/shared/@ai-setting/{roy-agent-core-2rtka82a.js → roy-agent-core-1a38hg1q.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-pm73be85.js → roy-agent-core-2m5qnhv9.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-1t5esk1r.js → roy-agent-core-3nw9vxp2.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-pyv1vb7v.js → roy-agent-core-476ewnwy.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-mjbfgqen.js → roy-agent-core-4zjdkqry.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-a23brrex.js → roy-agent-core-5dkewp2h.js} +60 -3
- package/dist/shared/@ai-setting/{roy-agent-core-hdszq729.js → roy-agent-core-607ktjxs.js} +7 -5
- package/dist/shared/@ai-setting/{roy-agent-core-wa1kzqky.js → roy-agent-core-7qj11qp8.js} +46 -2
- package/dist/shared/@ai-setting/roy-agent-core-8f8dq3kj.js +13 -0
- package/dist/shared/@ai-setting/{roy-agent-core-eftqdsy5.js → roy-agent-core-8whpa5yz.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-zwq6vhpj.js → roy-agent-core-bjphrqsm.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-a67e90d1.js → roy-agent-core-cv8kqab8.js} +175 -6
- package/dist/shared/@ai-setting/{roy-agent-core-1rzpnycm.js → roy-agent-core-d40gbvzj.js} +3 -2
- package/dist/shared/@ai-setting/{roy-agent-core-rm3hay00.js → roy-agent-core-dre9rcs0.js} +7 -6
- package/dist/shared/@ai-setting/{roy-agent-core-rx74rye7.js → roy-agent-core-dvrfs18y.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-hsxn8m1j.js → roy-agent-core-e8eefm0k.js} +109 -6
- package/dist/shared/@ai-setting/{roy-agent-core-jqq7c2rk.js → roy-agent-core-g3j3ftbw.js} +45 -22
- package/dist/shared/@ai-setting/{roy-agent-core-6e3wz81d.js → roy-agent-core-gfzqwb6v.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-twd8kzag.js → roy-agent-core-h6bqx4jj.js} +5 -4
- package/dist/shared/@ai-setting/{roy-agent-core-kzbj10gk.js → roy-agent-core-n1awj8ks.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-rgj6hq15.js → roy-agent-core-nxf64fn4.js} +4 -2
- package/dist/shared/@ai-setting/{roy-agent-core-ebap34m2.js → roy-agent-core-pxp9yq24.js} +4 -3
- package/dist/shared/@ai-setting/{roy-agent-core-ja9qhg6d.js → roy-agent-core-rrsn14cr.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-4k9a823d.js → roy-agent-core-rwt7b6dh.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-38sc085e.js → roy-agent-core-sj2yd6g4.js} +17 -6
- package/dist/shared/@ai-setting/{roy-agent-core-sk535ft2.js → roy-agent-core-wv9as4ds.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-20fm423j.js → roy-agent-core-xpw0mtfv.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-ztx5eh72.js → roy-agent-core-ym6qbh1e.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-t1ytby5n.js → roy-agent-core-yv7dppda.js} +11 -6
- package/dist/shared/@ai-setting/{roy-agent-core-vdwvamre.js → roy-agent-core-z3pq1nx9.js} +1 -1
- package/package.json +1 -1
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
} from "./roy-agent-core-qxhq8ven.js";
|
|
8
8
|
import {
|
|
9
9
|
BaseComponent
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-gfzqwb6v.js";
|
|
11
11
|
import {
|
|
12
12
|
createHook
|
|
13
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-z3pq1nx9.js";
|
|
14
14
|
import {
|
|
15
15
|
globalHookManager,
|
|
16
16
|
init_global_hook_manager
|
|
17
|
-
} from "./roy-agent-core-
|
|
17
|
+
} from "./roy-agent-core-nxf64fn4.js";
|
|
18
18
|
import {
|
|
19
19
|
createLogger,
|
|
20
20
|
init_logger
|
|
@@ -81,7 +81,133 @@ function escapeRegex(str) {
|
|
|
81
81
|
|
|
82
82
|
// src/env/prompt/prompts-index.ts
|
|
83
83
|
var builtInPrompts = {
|
|
84
|
-
default:
|
|
84
|
+
default: `你是 Roy 接待智能体(Receptionist Agent)—— Roy 系统的智能入口。
|
|
85
|
+
|
|
86
|
+
## 工作目录
|
|
87
|
+
|
|
88
|
+
**workspace_dir**: {{workspace_dir}}
|
|
89
|
+
|
|
90
|
+
## 你的身份
|
|
91
|
+
|
|
92
|
+
- **名称**: Roy(接待员)
|
|
93
|
+
- **角色**: 入口 AI 助手,分析用户请求并将其委托给合适的子智能体执行
|
|
94
|
+
- **个性**: 友好、善于分析、高效、简洁
|
|
95
|
+
|
|
96
|
+
## 核心使命
|
|
97
|
+
|
|
98
|
+
你是 Roy 系统的**前门**。你的工作只有:
|
|
99
|
+
|
|
100
|
+
1. **倾听** 用户的请求
|
|
101
|
+
2. **分析** 需要做什么
|
|
102
|
+
3. **委托** 工作给合适的子智能体
|
|
103
|
+
|
|
104
|
+
你**不**自己解决问题。复杂工作必须委托给子智能体。
|
|
105
|
+
|
|
106
|
+
## 你的工具
|
|
107
|
+
|
|
108
|
+
你有两个工具可用:
|
|
109
|
+
|
|
110
|
+
| 工具 | 描述 |
|
|
111
|
+
|------|------|
|
|
112
|
+
| \`delegate_task\` | 委托复杂/多步骤任务给子智能体执行 |
|
|
113
|
+
| \`bash\` | **仅**用于执行简单的 Roy Agent 相关命令(如 \`bun packages/cli/dist/bin/roy-agent.js ...\`) |
|
|
114
|
+
|
|
115
|
+
### 工具使用规则
|
|
116
|
+
|
|
117
|
+
**\`delegate_task\`** — 用于一切复杂、多步骤、需要读文件、运行命令、搜索、实现功能等场景。这是你的主要工具。
|
|
118
|
+
|
|
119
|
+
**\`bash\`** — **仅限**以下简单场景:
|
|
120
|
+
- 执行简单的 \`roy-agent\` 命令(如 \`bun packages/cli/dist/bin/roy-agent.js act "你好"\`)
|
|
121
|
+
- 检查 Roy Agent 版本或帮助信息
|
|
122
|
+
- 运行已经由子智能体构建好的脚本
|
|
123
|
+
- 创建简单的问候或快速测试
|
|
124
|
+
|
|
125
|
+
**\`bash\` 禁止用于:**
|
|
126
|
+
- 任何需要多步骤的复杂逻辑
|
|
127
|
+
- 代码分析、文件读写、搜索
|
|
128
|
+
- 功能开发、调试、重构
|
|
129
|
+
- 即使可以用 bash 实现,复杂任务也必须使用 \`delegate_task\`
|
|
130
|
+
|
|
131
|
+
## 何时委托
|
|
132
|
+
|
|
133
|
+
对于以下任何请求,**必须**使用 \`delegate_task\` 委托:
|
|
134
|
+
|
|
135
|
+
- **多步骤** — 需要多个动作(读+分析+写)
|
|
136
|
+
- **调研类** — 需要代码分析、网络搜索或数据收集
|
|
137
|
+
- **复杂查询** — 涉及推理、规划或决策
|
|
138
|
+
- **实施工作** — 功能开发、bug 修复、重构、文档生成
|
|
139
|
+
- **不明确的请求** — 需要探索才能明确方向的任务
|
|
140
|
+
- **文件/代码/数据访问** — 任何需要读文件、运行命令或查询数据的请求
|
|
141
|
+
|
|
142
|
+
**不需要委托的情况:**
|
|
143
|
+
- 简单的问候 / 闲聊
|
|
144
|
+
- 你凭自身知识就能回答的一次性简单问题
|
|
145
|
+
|
|
146
|
+
## 子智能体选择策略
|
|
147
|
+
|
|
148
|
+
你有两个子智能体。**默认首次委托使用 \`roy\`**。仅在需要严格 Plan→Execute→Verify 纪律时使用 \`strict-task-agent\`。
|
|
149
|
+
|
|
150
|
+
### \uD83E\uDD47 首选:\`roy\`(首次委托默认)
|
|
151
|
+
全功能的 Roy AI 助手,拥有所有工具和技能,提示词中内置了 **任务作为一等公民** 原则。遵循结构化任务生命周期(创建→跟踪→完成),同时保持灵活性。
|
|
152
|
+
- ✅ 通用问题解决
|
|
153
|
+
- ✅ 代码探索、阅读和分析
|
|
154
|
+
- ✅ 创造性/探索性工作,可迭代优化
|
|
155
|
+
- ✅ 开放式请求的多轮对话
|
|
156
|
+
- ✅ 功能开发、bug 修复、重构、文档生成
|
|
157
|
+
- ✅ 网络搜索和研究
|
|
158
|
+
|
|
159
|
+
**roy** 的提示词中内置了任务生命周期——它知道如何使用 \`task_create\`、\`task_update\`、\`task_operation_create\` 和 \`task_complete\` 来跟踪每项工作。
|
|
160
|
+
|
|
161
|
+
推荐使用(长时间运行任务使用后台模式):
|
|
162
|
+
\`\`\`
|
|
163
|
+
delegate_task(
|
|
164
|
+
description="简要 3-5 字摘要",
|
|
165
|
+
prompt="详细说明。
|
|
166
|
+
|
|
167
|
+
重要:遵循任务作为一等公民原则 — 使用 \`task_create\` 创建任务,使用 \`task_update\` 跟踪进度,使用 \`task_operation_create\` 记录里程碑,并使用 \`task_complete\` 完成任务。",
|
|
168
|
+
subagent_type="roy",
|
|
169
|
+
background=true
|
|
170
|
+
)
|
|
171
|
+
\`\`\`
|
|
172
|
+
|
|
173
|
+
### \uD83E\uDD48 次选:\`strict-task-agent\`(需要严格验证时使用)
|
|
174
|
+
结构化 Plan → Execute → Verify 工作流智能体,内置自动重试(最多 8 次)。在以下情况使用:
|
|
175
|
+
- **复杂功能开发** — 需要严格的 Plan→Execute→Verify 纪律
|
|
176
|
+
- **关键 bug 修复** — 需要根因分析、修复和强制验证
|
|
177
|
+
- **安全关键型变更** — 验证不可妥协
|
|
178
|
+
- **代码审查/审计** — 需要系统性对照目标进行检查
|
|
179
|
+
|
|
180
|
+
使用:
|
|
181
|
+
\`\`\`
|
|
182
|
+
delegate_task(
|
|
183
|
+
description="简要 3-5 字摘要",
|
|
184
|
+
prompt="详细说明。
|
|
185
|
+
|
|
186
|
+
重要:遵循任务作为一等公民原则 — 使用 \`task_create\` 创建任务,使用 \`task_update\` 跟踪进度,使用 \`task_operation_create\` 记录里程碑,并使用 \`task_complete\` 完成任务。",
|
|
187
|
+
subagent_type="strict-task-agent"
|
|
188
|
+
)
|
|
189
|
+
\`\`\`
|
|
190
|
+
|
|
191
|
+
## 如何处理用户请求
|
|
192
|
+
|
|
193
|
+
1. **理解** — 用户到底想要什么?
|
|
194
|
+
2. **分类** — 如果需要任何超出简单对话的操作 → 委托。如果是问候/一次性回答 → 直接回复。
|
|
195
|
+
3. **选择智能体** — \`roy\`(默认)或 \`strict-task-agent\`(需要严格验证时)
|
|
196
|
+
4. **委托时包含任务生命周期** — 在给子智能体的提示词中,始终包含简要指令,要求将工作视为任务一等公民:创建任务(\`task_create\`)、跟踪进度并完成。
|
|
197
|
+
5. **汇报结果** — 向用户总结结果
|
|
198
|
+
|
|
199
|
+
## 行为规则
|
|
200
|
+
|
|
201
|
+
1. **复杂任务必须委托** — 不要尝试自己解决复杂任务。使用 \`delegate_task\` 委托给子智能体。
|
|
202
|
+
2. **bash 仅限简单命令** — \`bash\` 只能用于执行简单的 Roy Agent 命令(如调用 \`bun packages/cli/dist/bin/roy-agent.js ...\`)。任何需要多步骤逻辑的复杂工作,即使可以用 bash 实现,也必须使用 \`delegate_task\`。
|
|
203
|
+
3. **保持简洁** — 简短分析,然后立即委托。不要冗长。
|
|
204
|
+
4. **首选 roy** — 首次委托默认使用 \`roy\`
|
|
205
|
+
5. **次选 strict-task-agent** — 需要严格 Plan→Execute→Verify 纪律时使用
|
|
206
|
+
6. **始终包含任务生命周期** — 每次委托时,指示子智能体使用 \`task_create\` → \`task_update\` → \`task_operation_create\` → \`task_complete\`
|
|
207
|
+
7. **简单回复** — 对于问候、简单问答或结果总结,可以直接回复
|
|
208
|
+
|
|
209
|
+
### {{memory}}`,
|
|
210
|
+
roy: `You are Roy, a versatile AI assistant inspired by Jarvis - intelligent, proactive, and capable.
|
|
85
211
|
|
|
86
212
|
## Working Directory
|
|
87
213
|
|
|
@@ -312,6 +438,21 @@ roy-agent <command> <subcmd> --help
|
|
|
312
438
|
- Feature development or bug fixes
|
|
313
439
|
- The user explicitly asks to track or manage a task
|
|
314
440
|
|
|
441
|
+
**⚠️ Task Selection Logic — PRIORITY ORDER**:
|
|
442
|
+
1. **If [当前 Task #N] is provided in the context** (via additionInfo):
|
|
443
|
+
Use \`task_get #N\` directly to read the task details.
|
|
444
|
+
**Do NOT search** — this is the confirmed task to work on.
|
|
445
|
+
Skip the search step entirely and proceed with context gathering.
|
|
446
|
+
2. **If no taskId is in context, OR task_get fails** (task not found):
|
|
447
|
+
Fall back to \`task_list\` to search for existing tasks related to the
|
|
448
|
+
current request. Many tasks are continuations of previous work.
|
|
449
|
+
If a relevant task exists, use \`task_update\` to extend it:
|
|
450
|
+
- **Append** new information to description and goals (do NOT replace)
|
|
451
|
+
- Update \`current_status\` to reflect the new scope
|
|
452
|
+
- Create an operation record to document the continuation
|
|
453
|
+
3. **Only** create a brand-new task via \`task_create\` if:
|
|
454
|
+
- No taskId in context, AND no relevant existing task found.
|
|
455
|
+
|
|
315
456
|
### Task Management Tools
|
|
316
457
|
|
|
317
458
|
| Tool | Description |
|
|
@@ -333,8 +474,22 @@ Follow this lifecycle for every task:
|
|
|
333
474
|
|
|
334
475
|
\`\`\`text
|
|
335
476
|
┌─────────────────────────────────────────────────────────────────┐
|
|
336
|
-
│
|
|
337
|
-
│ -
|
|
477
|
+
│ 0. CHECK TASK CONTEXT OR SEARCH │
|
|
478
|
+
│ - First: Check if [当前 Task #N] is in the context │
|
|
479
|
+
│ If yes → use \`task_get #N\` directly, skip to step 1 │
|
|
480
|
+
│ - If no taskId in context: │
|
|
481
|
+
│ Use \`task_list\` to search for existing related tasks │
|
|
482
|
+
│ - If found → reuse, extend, and update (see rules below) │
|
|
483
|
+
│ - If not found → proceed to step 1 │
|
|
484
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
485
|
+
↓
|
|
486
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
487
|
+
│ 1. CREATE (task_create) OR REUSE (task_get + task_update) │
|
|
488
|
+
│ - No existing task → Create new with title, desc, goals │
|
|
489
|
+
│ - Existing task → Reuse via task_get, then task_update: │
|
|
490
|
+
│ * Append new context to description (preserve old) │
|
|
491
|
+
│ * Add/extend goals_and_expected_deliverables │
|
|
492
|
+
│ * Create operation record documenting the continuation │
|
|
338
493
|
│ - Set priority (low/medium/high) and due date (if any) │
|
|
339
494
|
└─────────────────────────────────────────────────────────────────┘
|
|
340
495
|
↓
|
|
@@ -387,6 +542,14 @@ Follow this lifecycle for every task:
|
|
|
387
542
|
└─────────────────────────────────────────────────────────────────┘
|
|
388
543
|
\`\`\`
|
|
389
544
|
|
|
545
|
+
### Task Update Rules
|
|
546
|
+
|
|
547
|
+
When reusing an existing task, you MUST follow these rules:
|
|
548
|
+
|
|
549
|
+
1. **Append, don't replace** — When using \`task_update\`, the \`description\` and \`goals\` fields MUST **preserve existing content** and append new content after it.
|
|
550
|
+
2. **Document the continuation** — Use \`task_operation_create\` to create an operation record explaining why the task is being continued and what new scope has been added.
|
|
551
|
+
3. **Reset the status** — If the original task was completed, change status to \`active\` and reset progress to a reasonable value.
|
|
552
|
+
|
|
390
553
|
### Task Properties
|
|
391
554
|
|
|
392
555
|
| Property | Description |
|
|
@@ -404,6 +567,12 @@ Follow this lifecycle for every task:
|
|
|
404
567
|
|
|
405
568
|
**Before starting any task-related work, you MUST gather context:**
|
|
406
569
|
|
|
570
|
+
**Step 0: Check for Task ID in Context**
|
|
571
|
+
- If the system provides \`[当前 Task #N]\` in the context messages:
|
|
572
|
+
Use \`task_get #N\` directly — this is your confirmed task. **Skip searching.**
|
|
573
|
+
- If no taskId is provided, use \`task_list\` to search for existing related tasks.
|
|
574
|
+
|
|
575
|
+
**Then gather full context:**
|
|
407
576
|
1. **Read task details**: Use \`task_get\` to read description, goals, status
|
|
408
577
|
2. **Read operation history**: Use \`task_operation_list\` to get the last ~20 operation records
|
|
409
578
|
3. **Read parent context** (if \`parent_task_id\` exists): Understand overall goal
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentComponentAdapter,
|
|
3
3
|
init_agent_component_adapter
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-1a38hg1q.js";
|
|
5
5
|
import {
|
|
6
6
|
buildWorkflowNodeMetadata,
|
|
7
7
|
getWorkflowNodeIdFromMetadata,
|
|
@@ -1923,7 +1923,8 @@ var init_engine = __esm(() => {
|
|
|
1923
1923
|
this.failWorkflow(sessionState, error);
|
|
1924
1924
|
});
|
|
1925
1925
|
if (options?.sync !== false) {
|
|
1926
|
-
|
|
1926
|
+
const wfTimeout = options?.timeout ?? sessionState.config.timeout ?? undefined;
|
|
1927
|
+
return this.waitForCompletion(sessionId, wfTimeout);
|
|
1927
1928
|
}
|
|
1928
1929
|
return { runId, status: "running" };
|
|
1929
1930
|
}
|
|
@@ -13,6 +13,9 @@ function getEnvContextOrEmpty() {
|
|
|
13
13
|
function hasEnvContext() {
|
|
14
14
|
return envContextStorage.getStore() !== undefined;
|
|
15
15
|
}
|
|
16
|
+
function getCurrentTaskId() {
|
|
17
|
+
return envContextStorage.getStore()?.currentTaskId;
|
|
18
|
+
}
|
|
16
19
|
function runWithEnvContext(context, fn) {
|
|
17
20
|
if (context) {
|
|
18
21
|
return envContextStorage.run(context, fn);
|
|
@@ -44,14 +47,12 @@ function mergeEnvContext(partial) {
|
|
|
44
47
|
Object.assign(current, partial);
|
|
45
48
|
}
|
|
46
49
|
}
|
|
50
|
+
function setCurrentTaskId(taskId) {
|
|
51
|
+
mergeEnvContext({ currentTaskId: taskId });
|
|
52
|
+
}
|
|
47
53
|
var envContextStorage;
|
|
48
54
|
var init_env_context = __esm(() => {
|
|
49
55
|
envContextStorage = new AsyncLocalStorage;
|
|
50
56
|
});
|
|
51
57
|
|
|
52
|
-
|
|
53
|
-
var init_context = __esm(() => {
|
|
54
|
-
init_env_context();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
export { envContextStorage, getEnvContext, getEnvContextOrEmpty, hasEnvContext, runWithEnvContext, runWithEnvContextAsync, createEnvContext, mergeEnvContext, init_context };
|
|
58
|
+
export { envContextStorage, getEnvContext, getEnvContextOrEmpty, hasEnvContext, getCurrentTaskId, runWithEnvContext, runWithEnvContextAsync, createEnvContext, mergeEnvContext, setCurrentTaskId, init_env_context };
|
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
} from "./roy-agent-core-qxhq8ven.js";
|
|
9
9
|
import {
|
|
10
10
|
BaseComponent
|
|
11
|
-
} from "./roy-agent-core-
|
|
11
|
+
} from "./roy-agent-core-gfzqwb6v.js";
|
|
12
12
|
import {
|
|
13
13
|
ToolHookPoints,
|
|
14
14
|
globalHookManager,
|
|
15
15
|
init_global_hook_manager
|
|
16
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-nxf64fn4.js";
|
|
17
17
|
import {
|
|
18
18
|
createLogger,
|
|
19
19
|
init_logger
|
|
@@ -3,11 +3,81 @@ import {
|
|
|
3
3
|
init_logger
|
|
4
4
|
} from "./roy-agent-core-10n2jh7p.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
__esm,
|
|
7
|
+
__export,
|
|
8
|
+
__require,
|
|
9
|
+
__toCommonJS
|
|
7
10
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
8
11
|
|
|
12
|
+
// src/env/task/storage/migrations/001_add_project_path_context.ts
|
|
13
|
+
var exports_001_add_project_path_context = {};
|
|
14
|
+
__export(exports_001_add_project_path_context, {
|
|
15
|
+
runMigration: () => runMigration
|
|
16
|
+
});
|
|
17
|
+
function runMigration(dbPath) {
|
|
18
|
+
console.log(`[Migration 001] Starting migration for: ${dbPath}`);
|
|
19
|
+
const db = createCompatibleDatabase(dbPath);
|
|
20
|
+
try {
|
|
21
|
+
try {
|
|
22
|
+
db.run(`ALTER TABLE task ADD COLUMN project_path TEXT`);
|
|
23
|
+
console.log(`[Migration 001] Added project_path column`);
|
|
24
|
+
} catch (e) {
|
|
25
|
+
if (e.message?.includes("duplicate column name")) {
|
|
26
|
+
console.log(`[Migration 001] project_path column already exists, skipping`);
|
|
27
|
+
} else {
|
|
28
|
+
throw e;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
db.run(`ALTER TABLE task ADD COLUMN context TEXT`);
|
|
33
|
+
console.log(`[Migration 001] Added context column`);
|
|
34
|
+
} catch (e) {
|
|
35
|
+
if (e.message?.includes("duplicate column name")) {
|
|
36
|
+
console.log(`[Migration 001] context column already exists, skipping`);
|
|
37
|
+
} else {
|
|
38
|
+
throw e;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
console.log(`[Migration 001] Migration completed successfully`);
|
|
42
|
+
} finally {
|
|
43
|
+
db.close();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
var init_001_add_project_path_context = __esm(() => {
|
|
47
|
+
init_sqlite_task_store();
|
|
48
|
+
if (false) {}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// src/env/task/storage/migrations/002_add_task_type.ts
|
|
52
|
+
var exports_002_add_task_type = {};
|
|
53
|
+
__export(exports_002_add_task_type, {
|
|
54
|
+
runMigration: () => runMigration2
|
|
55
|
+
});
|
|
56
|
+
function runMigration2(dbPath) {
|
|
57
|
+
console.log(`[Migration 002] Starting migration for: ${dbPath}`);
|
|
58
|
+
const db = createCompatibleDatabase(dbPath);
|
|
59
|
+
try {
|
|
60
|
+
try {
|
|
61
|
+
db.run(`ALTER TABLE task ADD COLUMN type TEXT NOT NULL DEFAULT 'normal'`);
|
|
62
|
+
console.log(`[Migration 002] Added type column`);
|
|
63
|
+
} catch (e) {
|
|
64
|
+
if (e.message?.includes("duplicate column name")) {
|
|
65
|
+
console.log(`[Migration 002] type column already exists, skipping`);
|
|
66
|
+
} else {
|
|
67
|
+
throw e;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
console.log(`[Migration 002] Migration completed successfully`);
|
|
71
|
+
} finally {
|
|
72
|
+
db.close();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
var init_002_add_task_type = __esm(() => {
|
|
76
|
+
init_sqlite_task_store();
|
|
77
|
+
if (false) {}
|
|
78
|
+
});
|
|
79
|
+
|
|
9
80
|
// src/env/task/storage/sqlite-task-store.ts
|
|
10
|
-
init_logger();
|
|
11
81
|
import { join } from "path";
|
|
12
82
|
function getDatabaseClass() {
|
|
13
83
|
if (typeof Bun !== "undefined") {
|
|
@@ -31,7 +101,6 @@ function createCompatibleDatabase(path) {
|
|
|
31
101
|
}
|
|
32
102
|
return db;
|
|
33
103
|
}
|
|
34
|
-
var logger = createLogger("task:store");
|
|
35
104
|
function getDefaultDataDir() {
|
|
36
105
|
const home = process.env.HOME || process.env.USERPROFILE || "/tmp";
|
|
37
106
|
return join(home, ".local", "share");
|
|
@@ -68,6 +137,7 @@ class SQLiteTaskStore {
|
|
|
68
137
|
description TEXT DEFAULT '',
|
|
69
138
|
status TEXT DEFAULT 'todo',
|
|
70
139
|
priority TEXT DEFAULT 'medium',
|
|
140
|
+
type TEXT DEFAULT 'normal',
|
|
71
141
|
progress INTEGER DEFAULT 0,
|
|
72
142
|
current_status TEXT DEFAULT '',
|
|
73
143
|
goals_and_expected_deliverables TEXT DEFAULT '',
|
|
@@ -114,6 +184,20 @@ class SQLiteTaskStore {
|
|
|
114
184
|
)
|
|
115
185
|
`);
|
|
116
186
|
this.db.run("CREATE INDEX IF NOT EXISTS idx_task_tag_relation_tag_id ON task_tag_relation(tag_id)");
|
|
187
|
+
if (this.dbPath !== ":memory:") {
|
|
188
|
+
try {
|
|
189
|
+
const { runMigration: runMigration001 } = (init_001_add_project_path_context(), __toCommonJS(exports_001_add_project_path_context));
|
|
190
|
+
runMigration001(this.dbPath);
|
|
191
|
+
} catch (e) {
|
|
192
|
+
logger.warn(`[Migration 001] Failed to run: ${e.message}`);
|
|
193
|
+
}
|
|
194
|
+
try {
|
|
195
|
+
const { runMigration: runMigration002 } = (init_002_add_task_type(), __toCommonJS(exports_002_add_task_type));
|
|
196
|
+
runMigration002(this.dbPath);
|
|
197
|
+
} catch (e) {
|
|
198
|
+
logger.warn(`[Migration 002] Failed to run: ${e.message}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
117
201
|
this.initialized = true;
|
|
118
202
|
logger.info(`TaskStore initialized at ${this.dbPath}`);
|
|
119
203
|
}
|
|
@@ -121,12 +205,12 @@ class SQLiteTaskStore {
|
|
|
121
205
|
await this.initialize();
|
|
122
206
|
const now = Date.now();
|
|
123
207
|
const stmt = this.db.prepare(`
|
|
124
|
-
INSERT INTO task (title, description, priority, parent_task_id,
|
|
208
|
+
INSERT INTO task (title, description, priority, type, parent_task_id,
|
|
125
209
|
goals_and_expected_deliverables, due_date, tags, status,
|
|
126
210
|
current_status, created_at, updated_at, project_path, context)
|
|
127
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, 'todo', '', ?, ?, ?, ?)
|
|
211
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 'todo', '', ?, ?, ?, ?)
|
|
128
212
|
`);
|
|
129
|
-
const result = stmt.run(options.title, options.description || "", options.priority || "medium", options.parent_task_id || null, options.goals_and_expected_deliverables || "", options.due_date || null, options.tags ? JSON.stringify(options.tags) : null, now, now, options.project_path, options.context);
|
|
213
|
+
const result = stmt.run(options.title, options.description || "", options.priority || "medium", options.type || "normal", options.parent_task_id || null, options.goals_and_expected_deliverables || "", options.due_date || null, options.tags ? JSON.stringify(options.tags) : null, now, now, options.project_path, options.context);
|
|
130
214
|
const task = await this.getTask(result.lastInsertRowid);
|
|
131
215
|
if (task) {
|
|
132
216
|
this.tasksCache.set(task.id, task);
|
|
@@ -170,6 +254,10 @@ class SQLiteTaskStore {
|
|
|
170
254
|
updates.push("priority = ?");
|
|
171
255
|
values.push(options.priority);
|
|
172
256
|
}
|
|
257
|
+
if (options.type !== undefined) {
|
|
258
|
+
updates.push("type = ?");
|
|
259
|
+
values.push(options.type);
|
|
260
|
+
}
|
|
173
261
|
if (options.progress !== undefined) {
|
|
174
262
|
updates.push("progress = ?");
|
|
175
263
|
values.push(options.progress);
|
|
@@ -230,6 +318,10 @@ class SQLiteTaskStore {
|
|
|
230
318
|
sql += " AND priority = ?";
|
|
231
319
|
params.push(options.priority);
|
|
232
320
|
}
|
|
321
|
+
if (options?.type) {
|
|
322
|
+
sql += " AND type = ?";
|
|
323
|
+
params.push(options.type);
|
|
324
|
+
}
|
|
233
325
|
if (options?.parent_task_id !== undefined) {
|
|
234
326
|
sql += " AND parent_task_id = ?";
|
|
235
327
|
params.push(options.parent_task_id);
|
|
@@ -332,6 +424,7 @@ class SQLiteTaskStore {
|
|
|
332
424
|
description: row.description,
|
|
333
425
|
status: row.status,
|
|
334
426
|
priority: row.priority,
|
|
427
|
+
type: row.type || "normal",
|
|
335
428
|
progress: row.progress,
|
|
336
429
|
current_status: row.current_status,
|
|
337
430
|
goals_and_expected_deliverables: row.goals_and_expected_deliverables,
|
|
@@ -650,4 +743,14 @@ class SQLiteTaskStore {
|
|
|
650
743
|
}
|
|
651
744
|
}
|
|
652
745
|
}
|
|
746
|
+
var logger;
|
|
747
|
+
var init_sqlite_task_store = __esm(() => {
|
|
748
|
+
init_logger();
|
|
749
|
+
logger = createLogger("task:store");
|
|
750
|
+
});
|
|
751
|
+
|
|
752
|
+
// src/env/task/storage/index.ts
|
|
753
|
+
init_sqlite_task_store();
|
|
754
|
+
init_sqlite_task_store();
|
|
755
|
+
|
|
653
756
|
export { getDefaultDataDir, getDefaultTaskDbPath, SQLiteTaskStore };
|
|
@@ -11,7 +11,11 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
globalHookManager,
|
|
13
13
|
init_global_hook_manager
|
|
14
|
-
} from "./roy-agent-core-
|
|
14
|
+
} from "./roy-agent-core-nxf64fn4.js";
|
|
15
|
+
import {
|
|
16
|
+
init_env_context,
|
|
17
|
+
mergeEnvContext
|
|
18
|
+
} from "./roy-agent-core-dre9rcs0.js";
|
|
15
19
|
import {
|
|
16
20
|
createLogger,
|
|
17
21
|
init_logger
|
|
@@ -22,6 +26,7 @@ import {
|
|
|
22
26
|
|
|
23
27
|
// src/env/task/delegate/delegate-tool.ts
|
|
24
28
|
init_logger();
|
|
29
|
+
init_env_context();
|
|
25
30
|
init_decorator();
|
|
26
31
|
import { z } from "zod";
|
|
27
32
|
|
|
@@ -115,7 +120,17 @@ var builtInSubAgents = [
|
|
|
115
120
|
|
|
116
121
|
**IMPORTANT: Before starting any work, you MUST gather task context to avoid working with outdated or missing information.**
|
|
117
122
|
|
|
118
|
-
|
|
123
|
+
**Step 0: Check if task_id is already provided**
|
|
124
|
+
- The session info above includes \`task_id\`.
|
|
125
|
+
- **If task_id is provided** (not N/A or 0):
|
|
126
|
+
Use \`task_get\` with that task_id directly — this is your confirmed task.
|
|
127
|
+
**Skip any searching.** Read its details and operations.
|
|
128
|
+
- **If no valid task_id** is provided:
|
|
129
|
+
Use the task description to guide your work.
|
|
130
|
+
Look for the task via \`task_list\` if needed.
|
|
131
|
+
|
|
132
|
+
**Then gather full context:**
|
|
133
|
+
1. **Read task details**: Use \`task_get\` to read the task's:
|
|
119
134
|
- \`description\`: Detailed description of what needs to be done
|
|
120
135
|
- \`goals_and_expected_deliverables\`: Clear success criteria and expected outputs
|
|
121
136
|
- \`current_status\`: Current work progress
|
|
@@ -153,23 +168,7 @@ var builtInSubAgents = [
|
|
|
153
168
|
name: "explore",
|
|
154
169
|
mode: "subagent",
|
|
155
170
|
description: "Fast agent specialized for exploring codebases, finding files, and searching for patterns.",
|
|
156
|
-
allowedTools: ["
|
|
157
|
-
deniedTools: ["delegate_task", "stop_task"]
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
id: "file_agent",
|
|
161
|
-
name: "file_agent",
|
|
162
|
-
mode: "subagent",
|
|
163
|
-
description: "File operation expert, skilled at reading, writing, searching and organizing files.",
|
|
164
|
-
allowedTools: ["file_read", "file_write", "file_glob", "grep", "glob", "read"],
|
|
165
|
-
deniedTools: ["delegate_task", "stop_task"]
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
id: "web_search_agent",
|
|
169
|
-
name: "web_search_agent",
|
|
170
|
-
mode: "subagent",
|
|
171
|
-
description: "Web search expert, using Exa search engine to get latest information.",
|
|
172
|
-
allowedTools: ["exa_web_search_exa"],
|
|
171
|
+
allowedTools: ["read_file", "glob", "grep", "bash"],
|
|
173
172
|
deniedTools: ["delegate_task", "stop_task"]
|
|
174
173
|
}
|
|
175
174
|
];
|
|
@@ -207,12 +206,12 @@ var DelegateToolParameters = z.object({
|
|
|
207
206
|
prompt: z.string().describe("The task for the agent to perform"),
|
|
208
207
|
subagent_type: z.string().describe("The type of specialized agent to use for this task").default("general"),
|
|
209
208
|
background: z.boolean().describe("Whether to run the task in background. If true, returns immediately and notifies when complete (default: false)").default(false),
|
|
210
|
-
timeout: z.number().describe("Task timeout in milliseconds. If set, task will be terminated after timeout
|
|
209
|
+
timeout: z.number().describe("Task timeout in milliseconds. Default: 1200000 (20 minutes). If set, task will be terminated after timeout.").optional(),
|
|
211
210
|
cleanup: z.enum(["delete", "keep"]).describe("Whether to delete sub session after completion. 'delete' removes the session, 'keep' retains it (default: keep)").default("keep").optional(),
|
|
212
211
|
task_id: z.number().describe("Optional task ID to associate with this delegate task, for tracking in operation records").optional(),
|
|
213
212
|
reason: z.string().describe("Brief reason for calling this tool (max 30 chars, e.g., 'Delegate refactor task')").optional()
|
|
214
213
|
});
|
|
215
|
-
var DEFAULT_TIMEOUT =
|
|
214
|
+
var DEFAULT_TIMEOUT = 1200000;
|
|
216
215
|
var PROGRESS_INTERVAL = 120000;
|
|
217
216
|
|
|
218
217
|
class BackgroundTaskManager {
|
|
@@ -407,6 +406,7 @@ class BackgroundTaskManager {
|
|
|
407
406
|
backgroundTaskId: taskId,
|
|
408
407
|
subSessionId: task.subSessionId,
|
|
409
408
|
parentSessionId,
|
|
409
|
+
description: task.description,
|
|
410
410
|
status: task.status,
|
|
411
411
|
progress: task.progress
|
|
412
412
|
};
|
|
@@ -533,6 +533,18 @@ ${prompt}
|
|
|
533
533
|
logger.info(`[BackgroundTaskManager] Disposed`);
|
|
534
534
|
}
|
|
535
535
|
}
|
|
536
|
+
__legacyDecorateClassTS([
|
|
537
|
+
TracedAs("task.background.createTask", { recordParams: false, recordResult: true, log: true })
|
|
538
|
+
], BackgroundTaskManager.prototype, "createTask", null);
|
|
539
|
+
__legacyDecorateClassTS([
|
|
540
|
+
TracedAs("task.background.executeTask", { recordParams: true, recordResult: true, log: true })
|
|
541
|
+
], BackgroundTaskManager.prototype, "executeTask", null);
|
|
542
|
+
__legacyDecorateClassTS([
|
|
543
|
+
TracedAs("task.background.startProgressReporter", { recordParams: false, recordResult: true, log: true })
|
|
544
|
+
], BackgroundTaskManager.prototype, "startProgressReporter", null);
|
|
545
|
+
__legacyDecorateClassTS([
|
|
546
|
+
TracedAs("task.background.stopProgressReporter", { recordParams: false, recordResult: true, log: true })
|
|
547
|
+
], BackgroundTaskManager.prototype, "stopProgressReporter", null);
|
|
536
548
|
__legacyDecorateClassTS([
|
|
537
549
|
TracedAs("delegate.executeWithAbort", { recordParams: true, recordResult: true, log: true })
|
|
538
550
|
], BackgroundTaskManager.prototype, "executeWithAbort", null);
|
|
@@ -722,9 +734,18 @@ ${prompt}
|
|
|
722
734
|
role: "assistant",
|
|
723
735
|
content: result
|
|
724
736
|
});
|
|
737
|
+
let taskNotification = "";
|
|
738
|
+
if (taskId) {
|
|
739
|
+
taskNotification = `
|
|
740
|
+
|
|
741
|
+
---
|
|
742
|
+
\uD83D\uDCCB [委托任务完成] 已委托子智能体完成 Task #${taskId} 的处理工作,请知悉。可通过 task_get #${taskId} 查看最新状态。`;
|
|
743
|
+
}
|
|
744
|
+
mergeEnvContext({ currentTaskId: undefined });
|
|
745
|
+
logger.info(`[delegate_task.sync] Task completed, currentTaskId cleared from EnvContext${taskId ? ` (was: #${taskId})` : ""}`);
|
|
725
746
|
return {
|
|
726
747
|
success: true,
|
|
727
|
-
output: result + `
|
|
748
|
+
output: result + taskNotification + `
|
|
728
749
|
|
|
729
750
|
` + [
|
|
730
751
|
"<task_metadata>",
|
|
@@ -739,6 +760,8 @@ ${prompt}
|
|
|
739
760
|
}
|
|
740
761
|
};
|
|
741
762
|
} catch (error) {
|
|
763
|
+
mergeEnvContext({ currentTaskId: undefined });
|
|
764
|
+
logger.info(`[delegate_task.sync] Error occurred, currentTaskId cleared from EnvContext${taskId ? ` (was: #${taskId})` : ""}`);
|
|
742
765
|
return {
|
|
743
766
|
success: false,
|
|
744
767
|
output: "",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createHook
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-z3pq1nx9.js";
|
|
4
4
|
import {
|
|
5
5
|
HookManager
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-nxf64fn4.js";
|
|
7
7
|
|
|
8
8
|
// src/env/component.ts
|
|
9
9
|
class BaseComponent {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentComponentAdapter,
|
|
3
3
|
init_agent_component_adapter
|
|
4
|
-
} from "./roy-agent-core-
|
|
5
|
-
import"./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-1a38hg1q.js";
|
|
5
|
+
import"./roy-agent-core-n1awj8ks.js";
|
|
6
6
|
import"./roy-agent-core-nhfy3p8q.js";
|
|
7
7
|
import"./roy-agent-core-e25xkv53.js";
|
|
8
8
|
import"./roy-agent-core-q5qj0fes.js";
|
|
9
|
-
import"./roy-agent-core-
|
|
10
|
-
import"./roy-agent-core-
|
|
9
|
+
import"./roy-agent-core-nxf64fn4.js";
|
|
10
|
+
import"./roy-agent-core-8f8dq3kj.js";
|
|
11
|
+
import"./roy-agent-core-dre9rcs0.js";
|
|
11
12
|
import"./roy-agent-core-10n2jh7p.js";
|
|
12
13
|
import"./roy-agent-core-58k274fg.js";
|
|
13
14
|
import"./roy-agent-core-c6592r3c.js";
|
|
@@ -10,12 +10,13 @@ import {
|
|
|
10
10
|
tracedExtractStructuredJsonViaLlm,
|
|
11
11
|
tracedRunWorkflowJsonOutputExtraction,
|
|
12
12
|
unregisterWorkflowJsonOutputPlugin
|
|
13
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-n1awj8ks.js";
|
|
14
14
|
import"./roy-agent-core-nhfy3p8q.js";
|
|
15
15
|
import"./roy-agent-core-e25xkv53.js";
|
|
16
16
|
import"./roy-agent-core-q5qj0fes.js";
|
|
17
|
-
import"./roy-agent-core-
|
|
18
|
-
import"./roy-agent-core-
|
|
17
|
+
import"./roy-agent-core-nxf64fn4.js";
|
|
18
|
+
import"./roy-agent-core-8f8dq3kj.js";
|
|
19
|
+
import"./roy-agent-core-dre9rcs0.js";
|
|
19
20
|
import"./roy-agent-core-10n2jh7p.js";
|
|
20
21
|
import"./roy-agent-core-58k274fg.js";
|
|
21
22
|
import"./roy-agent-core-c6592r3c.js";
|