@ai-setting/roy-agent-core 1.5.48 → 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.
Files changed (57) hide show
  1. package/dist/config/index.js +6 -5
  2. package/dist/env/agent/index.js +6 -5
  3. package/dist/env/commands/index.js +6 -5
  4. package/dist/env/context/index.js +9 -3
  5. package/dist/env/debug/index.js +6 -5
  6. package/dist/env/event-source/index.js +8 -7
  7. package/dist/env/hook/index.js +4 -3
  8. package/dist/env/index.js +20 -19
  9. package/dist/env/llm/index.js +6 -5
  10. package/dist/env/log-trace/index.js +6 -5
  11. package/dist/env/mcp/index.js +6 -5
  12. package/dist/env/memory/index.js +6 -5
  13. package/dist/env/plugin/index.js +6 -5
  14. package/dist/env/prompt/index.js +6 -5
  15. package/dist/env/session/index.js +6 -5
  16. package/dist/env/skill/index.js +6 -5
  17. package/dist/env/task/delegate/index.js +4 -3
  18. package/dist/env/task/index.js +15 -10
  19. package/dist/env/task/plugins/index.js +3 -2
  20. package/dist/env/task/storage/index.js +1 -1
  21. package/dist/env/task/tools/index.js +5 -1
  22. package/dist/env/tool/index.js +6 -5
  23. package/dist/env/workflow/engine/index.js +6 -5
  24. package/dist/env/workflow/index.js +9 -8
  25. package/dist/index.js +34 -28
  26. package/dist/shared/@ai-setting/{roy-agent-core-4gmxjdhn.js → roy-agent-core-14fna5qg.js} +4 -2
  27. package/dist/shared/@ai-setting/{roy-agent-core-2rtka82a.js → roy-agent-core-1a38hg1q.js} +1 -1
  28. package/dist/shared/@ai-setting/{roy-agent-core-pm73be85.js → roy-agent-core-2m5qnhv9.js} +1 -1
  29. package/dist/shared/@ai-setting/{roy-agent-core-1t5esk1r.js → roy-agent-core-3nw9vxp2.js} +4 -4
  30. package/dist/shared/@ai-setting/{roy-agent-core-pyv1vb7v.js → roy-agent-core-476ewnwy.js} +1 -1
  31. package/dist/shared/@ai-setting/{roy-agent-core-mjbfgqen.js → roy-agent-core-4zjdkqry.js} +2 -2
  32. package/dist/shared/@ai-setting/{roy-agent-core-00cpsj5z.js → roy-agent-core-5dkewp2h.js} +2 -6
  33. package/dist/shared/@ai-setting/{roy-agent-core-hdszq729.js → roy-agent-core-607ktjxs.js} +7 -5
  34. package/dist/shared/@ai-setting/{roy-agent-core-wa1kzqky.js → roy-agent-core-7qj11qp8.js} +46 -2
  35. package/dist/shared/@ai-setting/roy-agent-core-8f8dq3kj.js +13 -0
  36. package/dist/shared/@ai-setting/{roy-agent-core-eftqdsy5.js → roy-agent-core-8whpa5yz.js} +1 -1
  37. package/dist/shared/@ai-setting/{roy-agent-core-zwq6vhpj.js → roy-agent-core-bjphrqsm.js} +1 -1
  38. package/dist/shared/@ai-setting/{roy-agent-core-cg23b692.js → roy-agent-core-cv8kqab8.js} +28 -16
  39. package/dist/shared/@ai-setting/{roy-agent-core-1rzpnycm.js → roy-agent-core-d40gbvzj.js} +3 -2
  40. package/dist/shared/@ai-setting/{roy-agent-core-rm3hay00.js → roy-agent-core-dre9rcs0.js} +7 -6
  41. package/dist/shared/@ai-setting/{roy-agent-core-rx74rye7.js → roy-agent-core-dvrfs18y.js} +2 -2
  42. package/dist/shared/@ai-setting/{roy-agent-core-hsxn8m1j.js → roy-agent-core-e8eefm0k.js} +109 -6
  43. package/dist/shared/@ai-setting/{roy-agent-core-a5rhnsrg.js → roy-agent-core-g3j3ftbw.js} +45 -6
  44. package/dist/shared/@ai-setting/{roy-agent-core-6e3wz81d.js → roy-agent-core-gfzqwb6v.js} +2 -2
  45. package/dist/shared/@ai-setting/{roy-agent-core-twd8kzag.js → roy-agent-core-h6bqx4jj.js} +5 -4
  46. package/dist/shared/@ai-setting/{roy-agent-core-kzbj10gk.js → roy-agent-core-n1awj8ks.js} +1 -1
  47. package/dist/shared/@ai-setting/{roy-agent-core-rgj6hq15.js → roy-agent-core-nxf64fn4.js} +4 -2
  48. package/dist/shared/@ai-setting/{roy-agent-core-ebap34m2.js → roy-agent-core-pxp9yq24.js} +4 -3
  49. package/dist/shared/@ai-setting/{roy-agent-core-ja9qhg6d.js → roy-agent-core-rrsn14cr.js} +1 -1
  50. package/dist/shared/@ai-setting/{roy-agent-core-4k9a823d.js → roy-agent-core-rwt7b6dh.js} +1 -1
  51. package/dist/shared/@ai-setting/{roy-agent-core-38sc085e.js → roy-agent-core-sj2yd6g4.js} +17 -6
  52. package/dist/shared/@ai-setting/{roy-agent-core-sk535ft2.js → roy-agent-core-wv9as4ds.js} +1 -1
  53. package/dist/shared/@ai-setting/{roy-agent-core-20fm423j.js → roy-agent-core-xpw0mtfv.js} +2 -2
  54. package/dist/shared/@ai-setting/{roy-agent-core-ztx5eh72.js → roy-agent-core-ym6qbh1e.js} +1 -1
  55. package/dist/shared/@ai-setting/{roy-agent-core-g56g1jp6.js → roy-agent-core-yv7dppda.js} +11 -6
  56. package/dist/shared/@ai-setting/{roy-agent-core-vdwvamre.js → roy-agent-core-z3pq1nx9.js} +1 -1
  57. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  AgentComponentAdapter,
3
3
  init_agent_component_adapter
4
- } from "./roy-agent-core-2rtka82a.js";
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
- return this.waitForCompletion(sessionId, options?.timeout);
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
- // src/env/context/index.ts
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-6e3wz81d.js";
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-rgj6hq15.js";
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
- __require
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-rgj6hq15.js";
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
- 1. **Read task details first**: Use \`task_get\` to read the task's:
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: ["glob", "grep", "read", "bash"],
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 (optional)").optional(),
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 = 900000;
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
+ mergeEnvContext({ currentTaskId: 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
+ mergeEnvContext({ currentTaskId: 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,9 +1,9 @@
1
1
  import {
2
2
  createHook
3
- } from "./roy-agent-core-vdwvamre.js";
3
+ } from "./roy-agent-core-z3pq1nx9.js";
4
4
  import {
5
5
  HookManager
6
- } from "./roy-agent-core-rgj6hq15.js";
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-2rtka82a.js";
5
- import"./roy-agent-core-kzbj10gk.js";
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-rgj6hq15.js";
10
- import"./roy-agent-core-rm3hay00.js";
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";
@@ -15,7 +15,7 @@ import {
15
15
  import {
16
16
  globalHookManager,
17
17
  init_global_hook_manager
18
- } from "./roy-agent-core-rgj6hq15.js";
18
+ } from "./roy-agent-core-nxf64fn4.js";
19
19
  import {
20
20
  createLogger,
21
21
  init_logger
@@ -1,7 +1,9 @@
1
1
  import {
2
- getEnvContext,
3
2
  init_context
4
- } from "./roy-agent-core-rm3hay00.js";
3
+ } from "./roy-agent-core-8f8dq3kj.js";
4
+ import {
5
+ getEnvContext
6
+ } from "./roy-agent-core-dre9rcs0.js";
5
7
  import {
6
8
  __esm
7
9
  } from "./roy-agent-core-fs0mn2jk.js";
@@ -10,12 +10,13 @@ import {
10
10
  tracedExtractStructuredJsonViaLlm,
11
11
  tracedRunWorkflowJsonOutputExtraction,
12
12
  unregisterWorkflowJsonOutputPlugin
13
- } from "./roy-agent-core-kzbj10gk.js";
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-rgj6hq15.js";
18
- import"./roy-agent-core-rm3hay00.js";
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";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./roy-agent-core-qxhq8ven.js";
7
7
  import {
8
8
  BaseComponent
9
- } from "./roy-agent-core-6e3wz81d.js";
9
+ } from "./roy-agent-core-gfzqwb6v.js";
10
10
  import {
11
11
  createLogger,
12
12
  init_logger,
@@ -4,7 +4,7 @@ import {
4
4
  } from "./roy-agent-core-qxhq8ven.js";
5
5
  import {
6
6
  BaseComponent
7
- } from "./roy-agent-core-6e3wz81d.js";
7
+ } from "./roy-agent-core-gfzqwb6v.js";
8
8
  import {
9
9
  createLogger,
10
10
  init_logger
@@ -20,15 +20,18 @@ import {
20
20
  } from "./roy-agent-core-qxhq8ven.js";
21
21
  import {
22
22
  BaseComponent
23
- } from "./roy-agent-core-6e3wz81d.js";
23
+ } from "./roy-agent-core-gfzqwb6v.js";
24
24
  import {
25
25
  globalHookManager,
26
26
  init_global_hook_manager
27
- } from "./roy-agent-core-rgj6hq15.js";
27
+ } from "./roy-agent-core-nxf64fn4.js";
28
28
  import {
29
- init_context,
29
+ init_context
30
+ } from "./roy-agent-core-8f8dq3kj.js";
31
+ import {
32
+ getCurrentTaskId,
30
33
  runWithEnvContextAsync
31
- } from "./roy-agent-core-rm3hay00.js";
34
+ } from "./roy-agent-core-dre9rcs0.js";
32
35
  import {
33
36
  createLogger,
34
37
  init_logger
@@ -954,11 +957,19 @@ class AgentComponent extends BaseComponent {
954
957
  content: ctx.systemPrompt
955
958
  });
956
959
  }
957
- if (ctx.context?.additionInfo) {
960
+ let additionInfo = ctx.context?.additionInfo || "";
961
+ const currentTaskId = getCurrentTaskId();
962
+ if (currentTaskId !== undefined) {
963
+ const taskInfo = `[当前 Task #${currentTaskId}] 提醒:当前正在处理 Task #${currentTaskId},可通过 task_get #${currentTaskId} 查看任务详情,通过 task_operation_list 查看操作记录。`;
964
+ additionInfo = additionInfo ? `${additionInfo}
965
+
966
+ ${taskInfo}` : taskInfo;
967
+ }
968
+ if (additionInfo) {
958
969
  messages.push({
959
970
  role: "user",
960
971
  content: `额外信息:
961
- ${ctx.context.additionInfo}`
972
+ ${additionInfo}`
962
973
  });
963
974
  }
964
975
  messages.push(...ctx.messages);
@@ -6,7 +6,7 @@ import {
6
6
  } from "./roy-agent-core-qxhq8ven.js";
7
7
  import {
8
8
  BaseComponent
9
- } from "./roy-agent-core-6e3wz81d.js";
9
+ } from "./roy-agent-core-gfzqwb6v.js";
10
10
  import {
11
11
  createLogger,
12
12
  init_logger
@@ -12,12 +12,12 @@ import {
12
12
  } from "./roy-agent-core-qxhq8ven.js";
13
13
  import {
14
14
  BaseComponent
15
- } from "./roy-agent-core-6e3wz81d.js";
15
+ } from "./roy-agent-core-gfzqwb6v.js";
16
16
  import {
17
17
  LLMHookPoints,
18
18
  globalHookManager,
19
19
  init_global_hook_manager
20
- } from "./roy-agent-core-rgj6hq15.js";
20
+ } from "./roy-agent-core-nxf64fn4.js";
21
21
  import {
22
22
  createLogger,
23
23
  init_logger
@@ -6,7 +6,7 @@ import {
6
6
  } from "./roy-agent-core-qxhq8ven.js";
7
7
  import {
8
8
  BaseComponent
9
- } from "./roy-agent-core-6e3wz81d.js";
9
+ } from "./roy-agent-core-gfzqwb6v.js";
10
10
  import {
11
11
  createLogger,
12
12
  init_logger
@@ -5,11 +5,11 @@ import {
5
5
  BackgroundTaskManager,
6
6
  createDelegateTool,
7
7
  createStopTool
8
- } from "./roy-agent-core-a5rhnsrg.js";
8
+ } from "./roy-agent-core-g3j3ftbw.js";
9
9
  import {
10
10
  SQLiteTaskStore,
11
11
  getDefaultTaskDbPath
12
- } from "./roy-agent-core-hsxn8m1j.js";
12
+ } from "./roy-agent-core-e8eefm0k.js";
13
13
  import {
14
14
  completeTaskTool,
15
15
  createTaskTool,
@@ -17,7 +17,7 @@ import {
17
17
  getTaskTool,
18
18
  listTasksTool,
19
19
  updateTaskTool
20
- } from "./roy-agent-core-wa1kzqky.js";
20
+ } from "./roy-agent-core-7qj11qp8.js";
21
21
  import {
22
22
  createOperationTool,
23
23
  deleteOperationTool,
@@ -37,11 +37,11 @@ import {
37
37
  } from "./roy-agent-core-qxhq8ven.js";
38
38
  import {
39
39
  BaseComponent
40
- } from "./roy-agent-core-6e3wz81d.js";
40
+ } from "./roy-agent-core-gfzqwb6v.js";
41
41
  import {
42
42
  globalHookManager,
43
43
  init_global_hook_manager
44
- } from "./roy-agent-core-rgj6hq15.js";
44
+ } from "./roy-agent-core-nxf64fn4.js";
45
45
  import {
46
46
  createLogger,
47
47
  init_logger
@@ -422,6 +422,10 @@ class TaskComponent extends BaseComponent {
422
422
  return this.store.listTasks(options);
423
423
  }
424
424
  async completeTask(id, sessionId) {
425
+ const existing = await this.store.getTask(id);
426
+ if (existing && existing.type === "cycle") {
427
+ throw new Error(`Cannot complete cycle task: #${id} - ${existing.title}. Cycle tasks are not meant to be completed.`);
428
+ }
425
429
  const task = await this.updateTask(id, {
426
430
  status: "completed",
427
431
  progress: 100
@@ -500,6 +504,7 @@ __legacyDecorateClassTS([
500
504
  import { z } from "zod";
501
505
  var TaskStatusEnum = z.enum(["todo", "active", "completed", "paused", "cancelled"]);
502
506
  var TaskPriorityEnum = z.enum(["low", "medium", "high"]);
507
+ var TaskTypeEnum = z.enum(["normal", "cycle", "longterm"]);
503
508
  var ActionTypeEnum = z.enum([
504
509
  "create",
505
510
  "progress",
@@ -517,4 +522,4 @@ var TaskConfigSchema = z.object({
517
522
  dbPath: z.string().optional()
518
523
  }).default({})
519
524
  }).default({});
520
- export { TaskComponent, TaskStatusEnum, TaskPriorityEnum, ActionTypeEnum, TaskConfigSchema };
525
+ export { TaskComponent, TaskStatusEnum, TaskPriorityEnum, TaskTypeEnum, ActionTypeEnum, TaskConfigSchema };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  init_global_hook_manager,
3
3
  init_hook_manager
4
- } from "./roy-agent-core-rgj6hq15.js";
4
+ } from "./roy-agent-core-nxf64fn4.js";
5
5
 
6
6
  // src/env/hook/types.ts
7
7
  function createHook(meta, fn) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.5.48",
3
+ "version": "1.5.49",
4
4
  "type": "module",
5
5
  "description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
6
6
  "main": "./dist/index.js",