@ai-setting/roy-agent-core 1.5.48 → 1.5.50
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 +10 -5
- package/dist/env/agent/index.js +7 -6
- package/dist/env/commands/index.js +7 -5
- package/dist/env/context/index.js +13 -3
- package/dist/env/debug/index.js +10 -5
- package/dist/env/event-source/index.js +9 -8
- package/dist/env/hook/index.js +8 -3
- package/dist/env/index.js +21 -20
- package/dist/env/llm/index.js +7 -6
- package/dist/env/log-trace/index.js +7 -6
- package/dist/env/mcp/index.js +7 -5
- package/dist/env/memory/index.js +7 -5
- package/dist/env/plugin/index.js +7 -5
- package/dist/env/prompt/index.js +7 -5
- package/dist/env/session/index.js +7 -6
- package/dist/env/skill/index.js +7 -5
- package/dist/env/task/delegate/index.js +4 -3
- package/dist/env/task/index.js +16 -11
- 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 +6 -1
- package/dist/env/tool/index.js +7 -5
- package/dist/env/workflow/engine/index.js +6 -5
- package/dist/env/workflow/index.js +9 -8
- package/dist/index.js +40 -34
- package/dist/shared/@ai-setting/{roy-agent-core-1rzpnycm.js → roy-agent-core-316v7cm4.js} +3 -2
- package/dist/shared/@ai-setting/{roy-agent-core-rgj6hq15.js → roy-agent-core-48v06q1b.js} +4 -2
- package/dist/shared/@ai-setting/{roy-agent-core-1t5esk1r.js → roy-agent-core-4b18eceq.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-ebap34m2.js → roy-agent-core-5ng0awvn.js} +4 -3
- package/dist/shared/@ai-setting/{roy-agent-core-cg23b692.js → roy-agent-core-5qe84a90.js} +28 -16
- package/dist/shared/@ai-setting/{roy-agent-core-00cpsj5z.js → roy-agent-core-8nd895aq.js} +6 -10
- package/dist/shared/@ai-setting/{roy-agent-core-kzbj10gk.js → roy-agent-core-9a2n122m.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-pyv1vb7v.js → roy-agent-core-9sarrbw9.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-rx74rye7.js → roy-agent-core-a8gvea2f.js} +2 -2
- package/dist/shared/@ai-setting/roy-agent-core-c7cm1wjt.js +13 -0
- package/dist/shared/@ai-setting/{roy-agent-core-ztx5eh72.js → roy-agent-core-d8v4n80n.js} +1 -1
- 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-hdszq729.js → roy-agent-core-ezfwx334.js} +7 -5
- package/dist/shared/@ai-setting/{roy-agent-core-twd8kzag.js → roy-agent-core-fpb999vd.js} +5 -4
- package/dist/shared/@ai-setting/{roy-agent-core-2rtka82a.js → roy-agent-core-fy1y1aqx.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-wa1kzqky.js → roy-agent-core-hd6kd06t.js} +46 -2
- package/dist/shared/@ai-setting/{roy-agent-core-a5rhnsrg.js → roy-agent-core-m5g2jx7f.js} +48 -9
- package/dist/shared/@ai-setting/{roy-agent-core-mjbfgqen.js → roy-agent-core-mangq9x1.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-38sc085e.js → roy-agent-core-pa9wz5q0.js} +32 -11
- package/dist/shared/@ai-setting/{roy-agent-core-eftqdsy5.js → roy-agent-core-pvswd18d.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-sk535ft2.js → roy-agent-core-qfdgg56t.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-6e3wz81d.js → roy-agent-core-rjf59e7k.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-rm3hay00.js → roy-agent-core-s7bgrtch.js} +21 -7
- package/dist/shared/@ai-setting/{roy-agent-core-pm73be85.js → roy-agent-core-sxd8snnj.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-4k9a823d.js → roy-agent-core-t32gmaqn.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-20fm423j.js → roy-agent-core-vfk5mtbx.js} +6 -6
- package/dist/shared/@ai-setting/{roy-agent-core-ja9qhg6d.js → roy-agent-core-w65c5gac.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-g56g1jp6.js → roy-agent-core-wtnwxn8h.js} +15 -10
- package/dist/shared/@ai-setting/{roy-agent-core-zwq6vhpj.js → roy-agent-core-y30njf6b.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-4gmxjdhn.js → roy-agent-core-y85xsddt.js} +6 -4
- package/dist/shared/@ai-setting/{roy-agent-core-vdwvamre.js → roy-agent-core-yq4fv8ce.js} +1 -1
- package/package.json +1 -1
|
@@ -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 };
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TaskTagPlugin,
|
|
3
3
|
createLarkCliTaskNotifyHook
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-y85xsddt.js";
|
|
5
5
|
import {
|
|
6
6
|
envKeyToConfigKey
|
|
7
7
|
} from "./roy-agent-core-qxhq8ven.js";
|
|
8
8
|
import {
|
|
9
9
|
BaseComponent
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-rjf59e7k.js";
|
|
11
11
|
import {
|
|
12
12
|
globalHookManager,
|
|
13
13
|
init_global_hook_manager
|
|
14
|
-
} from "./roy-agent-core-
|
|
14
|
+
} from "./roy-agent-core-48v06q1b.js";
|
|
15
|
+
import {
|
|
16
|
+
init_context
|
|
17
|
+
} from "./roy-agent-core-c7cm1wjt.js";
|
|
15
18
|
import {
|
|
16
19
|
createEnvContext,
|
|
17
|
-
init_context,
|
|
18
20
|
runWithEnvContext
|
|
19
|
-
} from "./roy-agent-core-
|
|
21
|
+
} from "./roy-agent-core-s7bgrtch.js";
|
|
20
22
|
import {
|
|
21
23
|
createLogger,
|
|
22
24
|
init_logger
|
|
@@ -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-fy1y1aqx.js";
|
|
5
|
+
import"./roy-agent-core-9a2n122m.js";
|
|
6
6
|
import"./roy-agent-core-nhfy3p8q.js";
|
|
7
7
|
import"./roy-agent-core-e25xkv53.js";
|
|
8
|
+
import"./roy-agent-core-48v06q1b.js";
|
|
9
|
+
import"./roy-agent-core-c7cm1wjt.js";
|
|
10
|
+
import"./roy-agent-core-s7bgrtch.js";
|
|
8
11
|
import"./roy-agent-core-q5qj0fes.js";
|
|
9
|
-
import"./roy-agent-core-rgj6hq15.js";
|
|
10
|
-
import"./roy-agent-core-rm3hay00.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";
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_env_context,
|
|
3
|
+
setCurrentTaskId
|
|
4
|
+
} from "./roy-agent-core-s7bgrtch.js";
|
|
5
|
+
import {
|
|
6
|
+
createLogger,
|
|
7
|
+
init_logger
|
|
8
|
+
} from "./roy-agent-core-10n2jh7p.js";
|
|
9
|
+
|
|
1
10
|
// src/env/task/tools/task-types.ts
|
|
2
11
|
import { z } from "zod";
|
|
3
12
|
var CreateTaskToolSchema = z.object({
|
|
4
13
|
title: z.string().describe("Task title"),
|
|
5
14
|
description: z.string().optional().describe("Task description"),
|
|
6
15
|
priority: z.enum(["low", "medium", "high"]).optional().describe("Task priority"),
|
|
16
|
+
type: z.enum(["normal", "cycle", "longterm"]).optional().default("normal").describe("Task type. normal: 常规任务,需要跟踪完成. cycle: 周期任务(如每周发周报),无需 complete,定期执行. longterm: 长期任务/愿景目标(如提升公司影响力),难以一次性完成,持续跟进"),
|
|
7
17
|
goals_and_expected_deliverables: z.string().optional().describe("Goals and expected deliverables"),
|
|
8
18
|
due_date: z.string().optional().describe("Due date (ISO format)"),
|
|
9
19
|
tags: z.array(z.string()).optional().describe("Task tags (for search, stored in task.tags JSON field)"),
|
|
@@ -17,6 +27,7 @@ var GetTaskToolSchema = z.object({
|
|
|
17
27
|
var ListTasksToolSchema = z.object({
|
|
18
28
|
status: z.enum(["todo", "active", "completed", "paused", "cancelled"]).optional(),
|
|
19
29
|
priority: z.enum(["low", "medium", "high"]).optional(),
|
|
30
|
+
type: z.enum(["normal", "cycle", "longterm"]).optional().describe("Filter by task type"),
|
|
20
31
|
limit: z.number().optional().default(20),
|
|
21
32
|
offset: z.number().optional().default(0)
|
|
22
33
|
});
|
|
@@ -26,6 +37,7 @@ var UpdateTaskToolSchema = z.object({
|
|
|
26
37
|
description: z.string().optional(),
|
|
27
38
|
status: z.enum(["todo", "active", "completed", "paused", "cancelled"]).optional(),
|
|
28
39
|
priority: z.enum(["low", "medium", "high"]).optional(),
|
|
40
|
+
type: z.enum(["normal", "cycle", "longterm"]).optional().describe("Task type"),
|
|
29
41
|
progress: z.number().min(0).max(100).optional(),
|
|
30
42
|
current_status: z.string().optional(),
|
|
31
43
|
goals_and_expected_deliverables: z.string().optional(),
|
|
@@ -39,6 +51,9 @@ var DeleteTaskToolSchema = z.object({
|
|
|
39
51
|
});
|
|
40
52
|
|
|
41
53
|
// src/env/task/tools/create-tool.ts
|
|
54
|
+
init_env_context();
|
|
55
|
+
init_logger();
|
|
56
|
+
var logger = createLogger("task:tools:create");
|
|
42
57
|
function createTaskTool(taskComponent) {
|
|
43
58
|
return {
|
|
44
59
|
name: "task_create",
|
|
@@ -64,7 +79,9 @@ function createTaskTool(taskComponent) {
|
|
|
64
79
|
**Core fields**:
|
|
65
80
|
- worktree_path: Git worktree path (for code development)
|
|
66
81
|
- branch: Current branch name
|
|
67
|
-
- type:
|
|
82
|
+
- type: Work type classification (feature/bug/refactor/chore).
|
|
83
|
+
⚠️ NOTE: This is the **context.type** (work classification), NOT the
|
|
84
|
+
task's type field (normal/cycle/longterm). They are independent concepts.
|
|
68
85
|
|
|
69
86
|
**Example for coding tasks**:
|
|
70
87
|
{"worktree_path": "/path/to/worktree", "branch": "feature/xyz", "type": "feature", "parent_branch": "main"}
|
|
@@ -86,6 +103,7 @@ function createTaskTool(taskComponent) {
|
|
|
86
103
|
title: params.title,
|
|
87
104
|
description: params.description,
|
|
88
105
|
priority: params.priority,
|
|
106
|
+
type: params.type || "normal",
|
|
89
107
|
goals_and_expected_deliverables: params.goals_and_expected_deliverables,
|
|
90
108
|
due_date: params.due_date,
|
|
91
109
|
tags: params.tags,
|
|
@@ -93,6 +111,8 @@ function createTaskTool(taskComponent) {
|
|
|
93
111
|
project_path: params.project_path,
|
|
94
112
|
context: params.context
|
|
95
113
|
});
|
|
114
|
+
setCurrentTaskId(task.id);
|
|
115
|
+
logger.info(`[createTask] Trace: Task #${task.id} created, currentTaskId=${task.id} set in EnvContext`);
|
|
96
116
|
return {
|
|
97
117
|
success: true,
|
|
98
118
|
output: `Task created successfully: #${task.id} - ${task.title}`,
|
|
@@ -169,7 +189,7 @@ function getTaskTool(taskComponent) {
|
|
|
169
189
|
function listTasksTool(taskComponent) {
|
|
170
190
|
return {
|
|
171
191
|
name: "task_list",
|
|
172
|
-
description: "List tasks with optional filters for status and
|
|
192
|
+
description: "List tasks with optional filters for status, priority, and type.",
|
|
173
193
|
parameters: ListTasksToolSchema,
|
|
174
194
|
execute: async (args, ctx) => {
|
|
175
195
|
const params = ListTasksToolSchema.parse(args);
|
|
@@ -177,6 +197,7 @@ function listTasksTool(taskComponent) {
|
|
|
177
197
|
const tasks = await taskComponent.listTasks({
|
|
178
198
|
status: params.status,
|
|
179
199
|
priority: params.priority,
|
|
200
|
+
type: params.type,
|
|
180
201
|
limit: params.limit,
|
|
181
202
|
offset: params.offset
|
|
182
203
|
});
|
|
@@ -211,6 +232,7 @@ function updateTaskTool(taskComponent) {
|
|
|
211
232
|
description: params.description,
|
|
212
233
|
status: params.status,
|
|
213
234
|
priority: params.priority,
|
|
235
|
+
type: params.type,
|
|
214
236
|
progress: params.progress,
|
|
215
237
|
current_status: params.current_status,
|
|
216
238
|
goals_and_expected_deliverables: params.goals_and_expected_deliverables,
|
|
@@ -291,6 +313,9 @@ function deleteTaskTool(taskComponent) {
|
|
|
291
313
|
};
|
|
292
314
|
}
|
|
293
315
|
// src/env/task/tools/complete-tool.ts
|
|
316
|
+
init_env_context();
|
|
317
|
+
init_logger();
|
|
318
|
+
var logger2 = createLogger("task:tools:complete");
|
|
294
319
|
function completeTaskTool(taskComponent) {
|
|
295
320
|
return {
|
|
296
321
|
name: "task_complete",
|
|
@@ -300,6 +325,23 @@ function completeTaskTool(taskComponent) {
|
|
|
300
325
|
const params = DeleteTaskToolSchema.parse(args);
|
|
301
326
|
const sessionId = ctx.session_id || "unknown";
|
|
302
327
|
try {
|
|
328
|
+
const currentTask = await taskComponent.getTask(params.task_id);
|
|
329
|
+
if (!currentTask) {
|
|
330
|
+
return {
|
|
331
|
+
success: false,
|
|
332
|
+
output: "",
|
|
333
|
+
error: `Task not found: ${params.task_id}`,
|
|
334
|
+
metadata: { execution_time_ms: 0 }
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
if (currentTask.type === "cycle") {
|
|
338
|
+
return {
|
|
339
|
+
success: false,
|
|
340
|
+
output: "",
|
|
341
|
+
error: `Cannot complete a cycle-type task (id: ${params.task_id}). Cycle tasks are periodic (e.g., weekly reports) and should not be marked as completed. Use task_update to reset progress instead.`,
|
|
342
|
+
metadata: { execution_time_ms: 0 }
|
|
343
|
+
};
|
|
344
|
+
}
|
|
303
345
|
const task = await taskComponent.completeTask(params.task_id, sessionId);
|
|
304
346
|
if (!task) {
|
|
305
347
|
return {
|
|
@@ -309,6 +351,8 @@ function completeTaskTool(taskComponent) {
|
|
|
309
351
|
metadata: { execution_time_ms: 0 }
|
|
310
352
|
};
|
|
311
353
|
}
|
|
354
|
+
setCurrentTaskId(undefined);
|
|
355
|
+
logger2.info(`[completeTask] Trace: Task #${params.task_id} completed, currentTaskId cleared from EnvContext`);
|
|
312
356
|
return {
|
|
313
357
|
success: true,
|
|
314
358
|
output: `Task completed: #${task.id} - ${task.title}`,
|
|
@@ -4,14 +4,18 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
TaskHookPoints
|
|
6
6
|
} from "./roy-agent-core-92z6t4he.js";
|
|
7
|
+
import {
|
|
8
|
+
globalHookManager,
|
|
9
|
+
init_global_hook_manager
|
|
10
|
+
} from "./roy-agent-core-48v06q1b.js";
|
|
11
|
+
import {
|
|
12
|
+
init_env_context,
|
|
13
|
+
setCurrentTaskId
|
|
14
|
+
} from "./roy-agent-core-s7bgrtch.js";
|
|
7
15
|
import {
|
|
8
16
|
TracedAs,
|
|
9
17
|
init_decorator
|
|
10
18
|
} from "./roy-agent-core-q5qj0fes.js";
|
|
11
|
-
import {
|
|
12
|
-
globalHookManager,
|
|
13
|
-
init_global_hook_manager
|
|
14
|
-
} from "./roy-agent-core-rgj6hq15.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,7 +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: ["
|
|
171
|
+
allowedTools: ["read_file", "glob", "grep", "bash"],
|
|
157
172
|
deniedTools: ["delegate_task", "stop_task"]
|
|
158
173
|
}
|
|
159
174
|
];
|
|
@@ -191,12 +206,12 @@ var DelegateToolParameters = z.object({
|
|
|
191
206
|
prompt: z.string().describe("The task for the agent to perform"),
|
|
192
207
|
subagent_type: z.string().describe("The type of specialized agent to use for this task").default("general"),
|
|
193
208
|
background: z.boolean().describe("Whether to run the task in background. If true, returns immediately and notifies when complete (default: false)").default(false),
|
|
194
|
-
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(),
|
|
195
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(),
|
|
196
211
|
task_id: z.number().describe("Optional task ID to associate with this delegate task, for tracking in operation records").optional(),
|
|
197
212
|
reason: z.string().describe("Brief reason for calling this tool (max 30 chars, e.g., 'Delegate refactor task')").optional()
|
|
198
213
|
});
|
|
199
|
-
var DEFAULT_TIMEOUT =
|
|
214
|
+
var DEFAULT_TIMEOUT = 1200000;
|
|
200
215
|
var PROGRESS_INTERVAL = 120000;
|
|
201
216
|
|
|
202
217
|
class BackgroundTaskManager {
|
|
@@ -391,6 +406,7 @@ class BackgroundTaskManager {
|
|
|
391
406
|
backgroundTaskId: taskId,
|
|
392
407
|
subSessionId: task.subSessionId,
|
|
393
408
|
parentSessionId,
|
|
409
|
+
description: task.description,
|
|
394
410
|
status: task.status,
|
|
395
411
|
progress: task.progress
|
|
396
412
|
};
|
|
@@ -517,6 +533,18 @@ ${prompt}
|
|
|
517
533
|
logger.info(`[BackgroundTaskManager] Disposed`);
|
|
518
534
|
}
|
|
519
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);
|
|
520
548
|
__legacyDecorateClassTS([
|
|
521
549
|
TracedAs("delegate.executeWithAbort", { recordParams: true, recordResult: true, log: true })
|
|
522
550
|
], BackgroundTaskManager.prototype, "executeWithAbort", null);
|
|
@@ -706,9 +734,18 @@ ${prompt}
|
|
|
706
734
|
role: "assistant",
|
|
707
735
|
content: result
|
|
708
736
|
});
|
|
737
|
+
let taskNotification = "";
|
|
738
|
+
if (taskId) {
|
|
739
|
+
taskNotification = `
|
|
740
|
+
|
|
741
|
+
---
|
|
742
|
+
\uD83D\uDCCB [委托任务完成] 已委托子智能体完成 Task #${taskId} 的处理工作,请知悉。可通过 task_get #${taskId} 查看最新状态。`;
|
|
743
|
+
}
|
|
744
|
+
setCurrentTaskId(undefined);
|
|
745
|
+
logger.info(`[delegate_task.sync] Task completed, currentTaskId cleared from EnvContext${taskId ? ` (was: #${taskId})` : ""}`);
|
|
709
746
|
return {
|
|
710
747
|
success: true,
|
|
711
|
-
output: result + `
|
|
748
|
+
output: result + taskNotification + `
|
|
712
749
|
|
|
713
750
|
` + [
|
|
714
751
|
"<task_metadata>",
|
|
@@ -723,6 +760,8 @@ ${prompt}
|
|
|
723
760
|
}
|
|
724
761
|
};
|
|
725
762
|
} catch (error) {
|
|
763
|
+
setCurrentTaskId(undefined);
|
|
764
|
+
logger.info(`[delegate_task.sync] Error occurred, currentTaskId cleared from EnvContext${taskId ? ` (was: #${taskId})` : ""}`);
|
|
726
765
|
return {
|
|
727
766
|
success: false,
|
|
728
767
|
output: "",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseComponent
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-rjf59e7k.js";
|
|
4
4
|
import {
|
|
5
5
|
globalHookManager,
|
|
6
6
|
init_global_hook_manager
|
|
7
|
-
} from "./roy-agent-core-
|
|
7
|
+
} from "./roy-agent-core-48v06q1b.js";
|
|
8
8
|
import {
|
|
9
9
|
createLogger,
|
|
10
10
|
init_logger
|
|
@@ -11,24 +11,28 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
SessionMessageConverter
|
|
13
13
|
} from "./roy-agent-core-7b35emr7.js";
|
|
14
|
-
import {
|
|
15
|
-
TracedAs,
|
|
16
|
-
init_decorator
|
|
17
|
-
} from "./roy-agent-core-q5qj0fes.js";
|
|
18
14
|
import {
|
|
19
15
|
envKeyToConfigKey
|
|
20
16
|
} from "./roy-agent-core-qxhq8ven.js";
|
|
21
17
|
import {
|
|
22
18
|
BaseComponent
|
|
23
|
-
} from "./roy-agent-core-
|
|
19
|
+
} from "./roy-agent-core-rjf59e7k.js";
|
|
24
20
|
import {
|
|
25
21
|
globalHookManager,
|
|
26
22
|
init_global_hook_manager
|
|
27
|
-
} from "./roy-agent-core-
|
|
23
|
+
} from "./roy-agent-core-48v06q1b.js";
|
|
28
24
|
import {
|
|
29
|
-
init_context
|
|
25
|
+
init_context
|
|
26
|
+
} from "./roy-agent-core-c7cm1wjt.js";
|
|
27
|
+
import {
|
|
28
|
+
getCurrentTaskId,
|
|
29
|
+
getEnvContext,
|
|
30
30
|
runWithEnvContextAsync
|
|
31
|
-
} from "./roy-agent-core-
|
|
31
|
+
} from "./roy-agent-core-s7bgrtch.js";
|
|
32
|
+
import {
|
|
33
|
+
TracedAs,
|
|
34
|
+
init_decorator
|
|
35
|
+
} from "./roy-agent-core-q5qj0fes.js";
|
|
32
36
|
import {
|
|
33
37
|
createLogger,
|
|
34
38
|
init_logger
|
|
@@ -562,10 +566,12 @@ class AgentComponent extends BaseComponent {
|
|
|
562
566
|
logger.warn(`Failed to load session history: ${err}`);
|
|
563
567
|
}
|
|
564
568
|
}
|
|
569
|
+
const parentEnvContext = getEnvContext();
|
|
565
570
|
const envContext = {
|
|
571
|
+
...parentEnvContext,
|
|
566
572
|
traceId: effectiveContext.metadata?.traceId,
|
|
567
573
|
sessionId: effectiveContext.sessionId,
|
|
568
|
-
userId: effectiveContext.metadata?.userId,
|
|
574
|
+
userId: effectiveContext.metadata?.userId ?? "",
|
|
569
575
|
messageId: effectiveContext.metadata?.messageId,
|
|
570
576
|
pluginEnabled: effectiveContext.pluginEnabled,
|
|
571
577
|
plugins: effectiveContext.plugins,
|
|
@@ -946,6 +952,17 @@ class AgentComponent extends BaseComponent {
|
|
|
946
952
|
}
|
|
947
953
|
logger.info(`Agent aborted: ${agentName}`);
|
|
948
954
|
}
|
|
955
|
+
async _buildAdditionInfo(ctx) {
|
|
956
|
+
let additionInfo = ctx.context?.additionInfo || "";
|
|
957
|
+
const currentTaskId = getCurrentTaskId();
|
|
958
|
+
if (currentTaskId !== undefined) {
|
|
959
|
+
const taskInfo = `[当前 Task #${currentTaskId}] 提醒:当前正在处理 Task #${currentTaskId},可通过 task_get #${currentTaskId} 查看任务详情,通过 task_operation_list 查看操作记录。`;
|
|
960
|
+
additionInfo = additionInfo ? `${additionInfo}
|
|
961
|
+
|
|
962
|
+
${taskInfo}` : taskInfo;
|
|
963
|
+
}
|
|
964
|
+
return additionInfo;
|
|
965
|
+
}
|
|
949
966
|
async buildMessages(ctx) {
|
|
950
967
|
const messages = [];
|
|
951
968
|
if (ctx.systemPrompt) {
|
|
@@ -954,11 +971,12 @@ class AgentComponent extends BaseComponent {
|
|
|
954
971
|
content: ctx.systemPrompt
|
|
955
972
|
});
|
|
956
973
|
}
|
|
957
|
-
|
|
974
|
+
const additionInfo = await this._buildAdditionInfo(ctx);
|
|
975
|
+
if (additionInfo) {
|
|
958
976
|
messages.push({
|
|
959
977
|
role: "user",
|
|
960
978
|
content: `额外信息:
|
|
961
|
-
${
|
|
979
|
+
${additionInfo}`
|
|
962
980
|
});
|
|
963
981
|
}
|
|
964
982
|
messages.push(...ctx.messages);
|
|
@@ -1260,6 +1278,9 @@ __legacyDecorateClassTS([
|
|
|
1260
1278
|
__legacyDecorateClassTS([
|
|
1261
1279
|
TracedAs("agent.component.run", { recordParams: true, recordResult: true, log: true })
|
|
1262
1280
|
], AgentComponent.prototype, "_run", null);
|
|
1281
|
+
__legacyDecorateClassTS([
|
|
1282
|
+
TracedAs("agent.component.buildAdditionInfo", { recordParams: true, recordResult: true, log: true })
|
|
1283
|
+
], AgentComponent.prototype, "_buildAdditionInfo", null);
|
|
1263
1284
|
__legacyDecorateClassTS([
|
|
1264
1285
|
TracedAs("agent.component.invokeLLM", { recordParams: true, recordResult: true, log: true })
|
|
1265
1286
|
], AgentComponent.prototype, "invokeLLM", null);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createHook
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-yq4fv8ce.js";
|
|
4
4
|
import {
|
|
5
5
|
HookManager
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-48v06q1b.js";
|
|
7
7
|
|
|
8
8
|
// src/env/component.ts
|
|
9
9
|
class BaseComponent {
|