@ai-setting/roy-agent-core 1.5.47 → 1.5.48

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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BaseEnvironment
3
- } from "../shared/@ai-setting/roy-agent-core-a23brrex.js";
3
+ } from "../shared/@ai-setting/roy-agent-core-00cpsj5z.js";
4
4
  import {
5
5
  EventSourceComponent,
6
6
  builtInHandlers,
@@ -42,9 +42,9 @@ import {
42
42
  import"../shared/@ai-setting/roy-agent-core-e25xkv53.js";
43
43
  import {
44
44
  TaskComponent
45
- } from "../shared/@ai-setting/roy-agent-core-t1ytby5n.js";
45
+ } from "../shared/@ai-setting/roy-agent-core-g56g1jp6.js";
46
46
  import"../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
47
- import"../shared/@ai-setting/roy-agent-core-jqq7c2rk.js";
47
+ import"../shared/@ai-setting/roy-agent-core-a5rhnsrg.js";
48
48
  import"../shared/@ai-setting/roy-agent-core-hsxn8m1j.js";
49
49
  import"../shared/@ai-setting/roy-agent-core-emk3q2nt.js";
50
50
  import {
@@ -3,7 +3,7 @@ import {
3
3
  PromptConfigSchema,
4
4
  PromptPathSchema,
5
5
  PromptRenderer
6
- } from "../../shared/@ai-setting/roy-agent-core-a67e90d1.js";
6
+ } from "../../shared/@ai-setting/roy-agent-core-cg23b692.js";
7
7
  import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
8
8
  import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
9
9
  import"../../shared/@ai-setting/roy-agent-core-6e3wz81d.js";
@@ -3,7 +3,7 @@ import {
3
3
  BackgroundTaskManager,
4
4
  createDelegateTool,
5
5
  createStopTool
6
- } from "../../../shared/@ai-setting/roy-agent-core-jqq7c2rk.js";
6
+ } from "../../../shared/@ai-setting/roy-agent-core-a5rhnsrg.js";
7
7
  import"../../../shared/@ai-setting/roy-agent-core-emk3q2nt.js";
8
8
  import"../../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
9
9
  import"../../../shared/@ai-setting/roy-agent-core-92z6t4he.js";
@@ -4,11 +4,11 @@ import {
4
4
  TaskConfigSchema,
5
5
  TaskPriorityEnum,
6
6
  TaskStatusEnum
7
- } from "../../shared/@ai-setting/roy-agent-core-t1ytby5n.js";
7
+ } from "../../shared/@ai-setting/roy-agent-core-g56g1jp6.js";
8
8
  import {
9
9
  TaskEntityEventTypes
10
10
  } from "../../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
11
- import"../../shared/@ai-setting/roy-agent-core-jqq7c2rk.js";
11
+ import"../../shared/@ai-setting/roy-agent-core-a5rhnsrg.js";
12
12
  import {
13
13
  SQLiteTaskStore
14
14
  } from "../../shared/@ai-setting/roy-agent-core-hsxn8m1j.js";
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  PromptStore,
4
4
  getBuiltInPrompt,
5
5
  getBuiltInPromptNames
6
- } from "./shared/@ai-setting/roy-agent-core-a67e90d1.js";
6
+ } from "./shared/@ai-setting/roy-agent-core-cg23b692.js";
7
7
  import {
8
8
  LLMComponent,
9
9
  LLMConfigSchema,
@@ -61,7 +61,7 @@ import {
61
61
  BaseEnvironment,
62
62
  generateDescendingId,
63
63
  generateId
64
- } from "./shared/@ai-setting/roy-agent-core-a23brrex.js";
64
+ } from "./shared/@ai-setting/roy-agent-core-00cpsj5z.js";
65
65
  import {
66
66
  EventSourceComponent,
67
67
  builtInHandlers,
@@ -125,9 +125,9 @@ import {
125
125
  } from "./shared/@ai-setting/roy-agent-core-e25xkv53.js";
126
126
  import {
127
127
  TaskComponent
128
- } from "./shared/@ai-setting/roy-agent-core-t1ytby5n.js";
128
+ } from "./shared/@ai-setting/roy-agent-core-g56g1jp6.js";
129
129
  import"./shared/@ai-setting/roy-agent-core-8gxth0eh.js";
130
- import"./shared/@ai-setting/roy-agent-core-jqq7c2rk.js";
130
+ import"./shared/@ai-setting/roy-agent-core-a5rhnsrg.js";
131
131
  import"./shared/@ai-setting/roy-agent-core-hsxn8m1j.js";
132
132
  import {
133
133
  AgentRegistry
@@ -134,10 +134,71 @@ class BaseEnvironment extends BaseComponent {
134
134
  agent = agentComponent.getAgent("default");
135
135
  }
136
136
  if (!agent) {
137
+ const defaultDeniedTools = [
138
+ "echo",
139
+ "glob",
140
+ "grep",
141
+ "read_file",
142
+ "write_file",
143
+ "edit_file",
144
+ "task_create",
145
+ "task_get",
146
+ "task_list",
147
+ "task_update",
148
+ "task_delete",
149
+ "task_complete",
150
+ "task_operation_create",
151
+ "task_operation_get",
152
+ "task_operation_list",
153
+ "task_operation_update",
154
+ "task_operation_delete",
155
+ "skill",
156
+ "record_memory",
157
+ "recall_memory",
158
+ "search_sessions",
159
+ "get_session",
160
+ "write_memory"
161
+ ];
162
+ try {
163
+ const toolComponent = this.getComponent("tool");
164
+ if (toolComponent?.listTools) {
165
+ const allTools = toolComponent.listTools();
166
+ const mcpTools = allTools.filter((t) => t.name.startsWith("mcp_")).map((t) => t.name);
167
+ if (mcpTools.length > 0) {
168
+ defaultDeniedTools.push(...mcpTools);
169
+ logger.debug(`[handle_query] Dynamically denied MCP tools: ${mcpTools.join(", ")}`);
170
+ }
171
+ }
172
+ } catch (err) {
173
+ logger.warn(`[handle_query] Failed to dynamically filter MCP tools: ${err}`);
174
+ }
137
175
  agent = agentComponent.registerAgent("default", {
138
176
  type: "primary",
139
- systemPrompt: finalSystemPrompt
177
+ systemPrompt: finalSystemPrompt,
178
+ deniedTools: defaultDeniedTools
140
179
  });
180
+ logger.info(`[handle_query] Created default receptionist agent with deniedTools: ${defaultDeniedTools.length} tools denied`);
181
+ } else {
182
+ if (agent.config?.systemPrompt) {
183
+ if (agent.config.systemPrompt.includes("{{memory}}")) {
184
+ try {
185
+ const memoryComponent = this.getComponent("memory");
186
+ if (memoryComponent) {
187
+ const memoryContent = await memoryComponent.recallMemory();
188
+ agent.config.systemPrompt = agent.config.systemPrompt.replace("{{memory}}", memoryContent || "(No memory)");
189
+ } else {
190
+ agent.config.systemPrompt = agent.config.systemPrompt.replace("{{memory}}", "(Memory component not available)");
191
+ }
192
+ } catch (err) {
193
+ logger.warn(`[handle_query] Failed to inject memory for agent ${agentName}: ${err}`);
194
+ agent.config.systemPrompt = agent.config.systemPrompt.replace("{{memory}}", "(Failed to load memory)");
195
+ }
196
+ }
197
+ if (agent.config.systemPrompt.includes("{{workspace_dir}}")) {
198
+ agent.config.systemPrompt = agent.config.systemPrompt.replace("{{workspace_dir}}", process.cwd());
199
+ }
200
+ }
201
+ logger.debug(`[handle_query] Injected memory/workspace_dir for existing agent: ${agentName}`);
141
202
  }
142
203
  const result = await agentComponent.run(agent.name, query, context);
143
204
  if (result.error) {
@@ -155,22 +155,6 @@ var builtInSubAgents = [
155
155
  description: "Fast agent specialized for exploring codebases, finding files, and searching for patterns.",
156
156
  allowedTools: ["glob", "grep", "read", "bash"],
157
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"],
173
- deniedTools: ["delegate_task", "stop_task"]
174
158
  }
175
159
  ];
176
160
  function getSubAgentSpec(id) {
@@ -81,7 +81,133 @@ function escapeRegex(str) {
81
81
 
82
82
  // src/env/prompt/prompts-index.ts
83
83
  var builtInPrompts = {
84
- default: `You are Roy, a versatile AI assistant inspired by Jarvis - intelligent, proactive, and capable.
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,16 @@ 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
+ **⚠️ Always search existing tasks first**: Before creating a new task,
442
+ use \`task_list\` to search for existing tasks that are related to the
443
+ current request. Many tasks are continuations of previous work — e.g.,
444
+ reviewing the same project again, fixing a related bug, or extending a
445
+ feature. If a relevant task exists, use \`task_update\` to extend it:
446
+ - **Append** new information to description and goals (do NOT replace)
447
+ - Update \`current_status\` to reflect the new scope
448
+ - Create an operation record to document the continuation
449
+ Only create a brand-new task if absolutely no relevant task exists.
450
+
315
451
  ### Task Management Tools
316
452
 
317
453
  | Tool | Description |
@@ -333,8 +469,21 @@ Follow this lifecycle for every task:
333
469
 
334
470
  \`\`\`text
335
471
  ┌─────────────────────────────────────────────────────────────────┐
336
- 1. CREATE (task_create)
337
- │ - Create task with title, description, goals
472
+ 0. SEARCH (task_list)
473
+ │ - BEFORE creating anything, search for existing tasks
474
+ │ - Use \`task_list\` with relevant keywords/tags to find │
475
+ │ related tasks │
476
+ │ - If found → reuse, extend, and update (see rules below) │
477
+ │ - If not found → proceed to step 1 │
478
+ └─────────────────────────────────────────────────────────────────┘
479
+
480
+ ┌─────────────────────────────────────────────────────────────────┐
481
+ │ 1. CREATE (task_create) OR REUSE (task_get + task_update) │
482
+ │ - No existing task → Create new with title, desc, goals │
483
+ │ - Existing task → Reuse via task_get, then task_update: │
484
+ │ * Append new context to description (preserve old) │
485
+ │ * Add/extend goals_and_expected_deliverables │
486
+ │ * Create operation record documenting the continuation │
338
487
  │ - Set priority (low/medium/high) and due date (if any) │
339
488
  └─────────────────────────────────────────────────────────────────┘
340
489
 
@@ -387,6 +536,14 @@ Follow this lifecycle for every task:
387
536
  └─────────────────────────────────────────────────────────────────┘
388
537
  \`\`\`
389
538
 
539
+ ### Task Update Rules
540
+
541
+ When reusing an existing task, you MUST follow these rules:
542
+
543
+ 1. **Append, don't replace** — When using \`task_update\`, the \`description\` and \`goals\` fields MUST **preserve existing content** and append new content after it.
544
+ 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.
545
+ 3. **Reset the status** — If the original task was completed, change status to \`active\` and reset progress to a reasonable value.
546
+
390
547
  ### Task Properties
391
548
 
392
549
  | Property | Description |
@@ -5,7 +5,7 @@ import {
5
5
  BackgroundTaskManager,
6
6
  createDelegateTool,
7
7
  createStopTool
8
- } from "./roy-agent-core-jqq7c2rk.js";
8
+ } from "./roy-agent-core-a5rhnsrg.js";
9
9
  import {
10
10
  SQLiteTaskStore,
11
11
  getDefaultTaskDbPath
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.5.47",
3
+ "version": "1.5.48",
4
4
  "type": "module",
5
5
  "description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
6
6
  "main": "./dist/index.js",