@ai-setting/roy-agent-core 1.5.6 → 1.5.8

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 (27) hide show
  1. package/dist/env/index.d.ts +21 -0
  2. package/dist/env/index.js +10 -9
  3. package/dist/env/llm/index.js +1 -1
  4. package/dist/env/task/delegate/index.d.ts +66 -76
  5. package/dist/env/task/delegate/index.js +4 -4
  6. package/dist/env/task/events/index.d.ts +171 -0
  7. package/dist/env/task/events/index.js +7 -0
  8. package/dist/env/task/hooks/index.d.ts +24 -7
  9. package/dist/env/task/index.d.ts +139 -1
  10. package/dist/env/task/index.js +8 -4
  11. package/dist/env/task/plugins/index.d.ts +4 -0
  12. package/dist/env/task/storage/index.d.ts +17 -0
  13. package/dist/env/task/storage/index.js +1 -1
  14. package/dist/env/task/tools/index.d.ts +21 -0
  15. package/dist/env/task/tools/index.js +1 -1
  16. package/dist/env/task/tools/operation/index.d.ts +21 -0
  17. package/dist/env/workflow/index.js +15 -15
  18. package/dist/index.d.ts +21 -0
  19. package/dist/index.js +14 -13
  20. package/dist/shared/@ai-setting/roy-agent-core-8gxth0eh.js +10 -0
  21. package/dist/shared/@ai-setting/{roy-agent-core-htwpckw9.js → roy-agent-core-bvr1761x.js} +17 -5
  22. package/dist/shared/@ai-setting/{roy-agent-core-n2cvdgd6.js → roy-agent-core-gwc4h96n.js} +28 -7
  23. package/dist/shared/@ai-setting/{roy-agent-core-z62zee1e.js → roy-agent-core-vf215qfv.js} +121 -97
  24. package/dist/shared/@ai-setting/{roy-agent-core-3xwneva0.js → roy-agent-core-vkz81f7v.js} +12 -1
  25. package/dist/shared/@ai-setting/{roy-agent-core-dbsk841j.js → roy-agent-core-wa1kzqky.js} +47 -5
  26. package/package.json +1 -1
  27. package/dist/shared/@ai-setting/{roy-agent-core-dc497hmk.js → roy-agent-core-rhmtwnw1.js} +5 -5
@@ -1,7 +1,12 @@
1
+ import {
2
+ BackgroundTaskManager,
3
+ createDelegateTool,
4
+ createStopTool
5
+ } from "./roy-agent-core-vf215qfv.js";
1
6
  import {
2
7
  SQLiteTaskStore,
3
8
  getDefaultTaskDbPath
4
- } from "./roy-agent-core-htwpckw9.js";
9
+ } from "./roy-agent-core-bvr1761x.js";
5
10
  import {
6
11
  completeTaskTool,
7
12
  createTaskTool,
@@ -9,7 +14,7 @@ import {
9
14
  getTaskTool,
10
15
  listTasksTool,
11
16
  updateTaskTool
12
- } from "./roy-agent-core-dbsk841j.js";
17
+ } from "./roy-agent-core-wa1kzqky.js";
13
18
  import {
14
19
  createOperationTool,
15
20
  deleteOperationTool,
@@ -17,14 +22,12 @@ import {
17
22
  listOperationsTool,
18
23
  updateOperationTool
19
24
  } from "./roy-agent-core-t94ktchq.js";
20
- import {
21
- BackgroundTaskManager,
22
- createDelegateTool,
23
- createStopTool
24
- } from "./roy-agent-core-z62zee1e.js";
25
25
  import {
26
26
  TaskHookPoints
27
27
  } from "./roy-agent-core-92z6t4he.js";
28
+ import {
29
+ TaskEntityEventTypes
30
+ } from "./roy-agent-core-8gxth0eh.js";
28
31
  import {
29
32
  envKeyToConfigKey
30
33
  } from "./roy-agent-core-qxhq8ven.js";
@@ -155,6 +158,19 @@ class TaskComponent extends BaseComponent {
155
158
  configComponent;
156
159
  tagService;
157
160
  plugins = new Map;
161
+ publishEvent(type, payload, sessionId) {
162
+ if (this.env?.pushEnvEvent) {
163
+ this.env.pushEnvEvent({
164
+ type,
165
+ payload,
166
+ metadata: {
167
+ source: "task.component",
168
+ trigger_session_id: sessionId
169
+ }
170
+ });
171
+ logger2.info(`[TaskComponent] Event published: ${type}`);
172
+ }
173
+ }
158
174
  constructor() {
159
175
  super();
160
176
  }
@@ -344,6 +360,7 @@ class TaskComponent extends BaseComponent {
344
360
  tagService: this.tagService
345
361
  };
346
362
  await this.executeHook(TaskHookPoints.AFTER_CREATE, resultCtx);
363
+ this.publishEvent(TaskEntityEventTypes.CREATED, { task, sessionId }, sessionId);
347
364
  logger2.info(`[TaskComponent] Task created: ${task.id} - ${task.title}`);
348
365
  return task;
349
366
  }
@@ -372,6 +389,7 @@ class TaskComponent extends BaseComponent {
372
389
  tagService: this.tagService
373
390
  };
374
391
  await this.executeHook(TaskHookPoints.AFTER_UPDATE, resultCtx);
392
+ this.publishEvent(TaskEntityEventTypes.UPDATED, { task, changes: options, sessionId: "" }, "");
375
393
  logger2.info(`[TaskComponent] Task updated: ${id}`);
376
394
  }
377
395
  return task;
@@ -383,6 +401,7 @@ class TaskComponent extends BaseComponent {
383
401
  const resultCtx = { id, deleted: result };
384
402
  await this.executeHook(TaskHookPoints.AFTER_DELETE, resultCtx);
385
403
  if (result) {
404
+ this.publishEvent(TaskEntityEventTypes.DELETED, { taskId: id, sessionId: "" }, "");
386
405
  logger2.info(`[TaskComponent] Task deleted: ${id}`);
387
406
  }
388
407
  return result;
@@ -402,6 +421,7 @@ class TaskComponent extends BaseComponent {
402
421
  actionType: "completed",
403
422
  actionTitle: "Task completed"
404
423
  });
424
+ this.publishEvent(TaskEntityEventTypes.COMPLETED, { task, sessionId }, sessionId);
405
425
  logger2.info(`[TaskComponent] Task completed: ${id}`);
406
426
  }
407
427
  return task;
@@ -414,6 +434,7 @@ class TaskComponent extends BaseComponent {
414
434
  const op = await this.store.createOperation(createCtx.options);
415
435
  const resultCtx = { operation: op };
416
436
  await this.executeHook(TaskHookPoints.OPERATION_AFTER_CREATE, resultCtx);
437
+ this.publishEvent(TaskEntityEventTypes.OPERATION_ADDED, { operation: op, taskId: op.taskId }, op.sessionId);
417
438
  logger2.info(`[TaskComponent] Operation created: ${op.id} for task ${op.taskId}`);
418
439
  return op;
419
440
  }
@@ -12,55 +12,15 @@ import {
12
12
  // src/env/task/delegate/delegate-tool.ts
13
13
  init_logger();
14
14
  import { z } from "zod";
15
-
16
- // src/env/task/delegate/task-events.ts
17
- var TaskEventTypes = {
18
- TASK_STARTED: "task.started",
19
- TASK_PROGRESS: "task.progress",
20
- TASK_COMPLETED: "task.completed",
21
- TASK_FAILED: "task.failed",
22
- TASK_TIMEOUT: "task.timeout",
23
- TASK_STOPPED: "task.stopped"
24
- };
25
- function createTaskStartedPayload(task, parentSessionId) {
26
- return {
27
- taskId: task.id,
28
- subSessionId: task.subSessionId,
29
- parentSessionId,
30
- description: task.description,
31
- subagentType: task.subagentType,
32
- associatedTaskId: task.taskId
33
- };
34
- }
35
- function createTaskProgressPayload(task, parentSessionId) {
36
- return {
37
- taskId: task.id,
38
- subSessionId: task.subSessionId,
39
- parentSessionId,
40
- status: task.status,
41
- progress: task.progress,
42
- progressMessage: task.progressMessage,
43
- description: task.description,
44
- subagentType: task.subagentType
45
- };
46
- }
47
- function createTaskCompletedPayload(task, parentSessionId, executionTimeMs) {
48
- return {
49
- taskId: task.id,
50
- subSessionId: task.subSessionId,
51
- parentSessionId,
52
- status: task.status,
53
- result: task.result,
54
- error: task.error,
55
- executionTimeMs,
56
- associatedTaskId: task.taskId,
57
- description: task.description,
58
- subagentType: task.subagentType
59
- };
60
- }
61
-
62
- // src/env/task/delegate/delegate-tool.ts
63
15
  var logger = createLogger("task:delegate");
16
+ var BackgroundTaskEventTypes = {
17
+ STARTED: "task.background.started",
18
+ PROGRESS: "task.background.progress",
19
+ COMPLETED: "task.background.completed",
20
+ FAILED: "task.background.failed",
21
+ TIMEOUT: "task.background.timeout",
22
+ STOPPED: "task.background.stopped"
23
+ };
64
24
  var builtInSubAgents = [
65
25
  {
66
26
  id: "general",
@@ -177,14 +137,27 @@ var PROGRESS_INTERVAL = 120000;
177
137
  class BackgroundTaskManager {
178
138
  env;
179
139
  tasks = new Map;
180
- progressTimers = new Map;
181
140
  abortControllers = new Map;
141
+ progressTimers = new Map;
182
142
  constructor(env) {
183
143
  this.env = env;
184
144
  }
185
145
  getSessionComponent() {
186
146
  return this.env?.getComponent?.("session");
187
147
  }
148
+ publishBackgroundEvent(type, payload, parentSessionId) {
149
+ if (this.env?.pushEnvEvent) {
150
+ this.env.pushEnvEvent({
151
+ type,
152
+ payload,
153
+ metadata: {
154
+ source: "task.background",
155
+ trigger_session_id: parentSessionId
156
+ }
157
+ });
158
+ logger.info(`[BackgroundTaskManager] Event published: ${type}`);
159
+ }
160
+ }
188
161
  async createTask(options) {
189
162
  const { parentSessionId, description, prompt, subagentType, timeout, cleanup, taskId } = options;
190
163
  const taskIdGen = `task_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
@@ -225,7 +198,15 @@ class BackgroundTaskManager {
225
198
  };
226
199
  this.tasks.set(taskIdGen, task);
227
200
  this.abortControllers.set(taskIdGen, abortController);
228
- this.publishEvent(TaskEventTypes.TASK_STARTED, createTaskStartedPayload(task, parentSessionId), parentSessionId);
201
+ const startedPayload = {
202
+ backgroundTaskId: taskIdGen,
203
+ subSessionId: subSession.id,
204
+ parentSessionId,
205
+ description,
206
+ subagentType,
207
+ associatedTaskId: taskId
208
+ };
209
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.STARTED, startedPayload, parentSessionId);
229
210
  this.executeTask(taskIdGen, prompt, timeout, cleanup, parentSessionId).catch((err) => {
230
211
  logger.error(`[BackgroundTaskManager] executeTask unhandled rejection`, {
231
212
  taskId: taskIdGen,
@@ -260,7 +241,17 @@ class BackgroundTaskManager {
260
241
  task.completedAt = Date.now();
261
242
  task.result = result;
262
243
  const executionTimeMs = task.completedAt - task.startedAt;
263
- this.publishEvent(TaskEventTypes.TASK_COMPLETED, createTaskCompletedPayload(task, parentSessionId || task.parentSessionId, executionTimeMs), parentSessionId || task.parentSessionId);
244
+ const completedPayload = {
245
+ backgroundTaskId: task.id,
246
+ subSessionId: task.subSessionId,
247
+ parentSessionId: parentSessionId || task.parentSessionId,
248
+ status: "completed",
249
+ result: task.result,
250
+ description: task.description,
251
+ executionTimeMs,
252
+ associatedTaskId: task.taskId
253
+ };
254
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.COMPLETED, completedPayload, parentSessionId || task.parentSessionId);
264
255
  logger.info(`[BackgroundTaskManager] Task completed successfully`, {
265
256
  taskId,
266
257
  executionTimeMs
@@ -268,15 +259,46 @@ class BackgroundTaskManager {
268
259
  } catch (error) {
269
260
  const errorMessage = error instanceof Error ? error.message : String(error);
270
261
  const isStoppedError = errorMessage.toLowerCase().includes("stopped") || errorMessage.toLowerCase().includes("aborted");
262
+ const executionTimeMs = task.startedAt ? Date.now() - task.startedAt : 0;
271
263
  if (isStoppedError) {
272
264
  task.status = "stopped";
273
- this.publishEvent(TaskEventTypes.TASK_STOPPED, createTaskCompletedPayload(task, parentSessionId || task.parentSessionId, task.completedAt - task.startedAt), parentSessionId || task.parentSessionId);
265
+ const stoppedPayload = {
266
+ backgroundTaskId: task.id,
267
+ subSessionId: task.subSessionId,
268
+ parentSessionId: parentSessionId || task.parentSessionId,
269
+ status: "stopped",
270
+ description: task.description,
271
+ error: errorMessage,
272
+ executionTimeMs,
273
+ associatedTaskId: task.taskId
274
+ };
275
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, parentSessionId || task.parentSessionId);
274
276
  } else if (errorMessage.includes("timeout")) {
275
277
  task.status = "timeout";
276
- this.publishEvent(TaskEventTypes.TASK_TIMEOUT, createTaskCompletedPayload(task, parentSessionId || task.parentSessionId, task.completedAt - task.startedAt), parentSessionId || task.parentSessionId);
278
+ const timeoutPayload = {
279
+ backgroundTaskId: task.id,
280
+ subSessionId: task.subSessionId,
281
+ parentSessionId: parentSessionId || task.parentSessionId,
282
+ status: "timeout",
283
+ description: task.description,
284
+ error: errorMessage,
285
+ executionTimeMs,
286
+ associatedTaskId: task.taskId
287
+ };
288
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.TIMEOUT, timeoutPayload, parentSessionId || task.parentSessionId);
277
289
  } else {
278
290
  task.status = "failed";
279
- this.publishEvent(TaskEventTypes.TASK_FAILED, createTaskCompletedPayload(task, parentSessionId || task.parentSessionId, task.completedAt - task.startedAt), parentSessionId || task.parentSessionId);
291
+ const failedPayload = {
292
+ backgroundTaskId: task.id,
293
+ subSessionId: task.subSessionId,
294
+ parentSessionId: parentSessionId || task.parentSessionId,
295
+ status: "failed",
296
+ description: task.description,
297
+ error: errorMessage,
298
+ executionTimeMs,
299
+ associatedTaskId: task.taskId
300
+ };
301
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.FAILED, failedPayload, parentSessionId || task.parentSessionId);
280
302
  }
281
303
  task.error = errorMessage;
282
304
  task.completedAt = Date.now();
@@ -289,6 +311,35 @@ class BackgroundTaskManager {
289
311
  this.stopProgressReporter(taskId);
290
312
  }
291
313
  }
314
+ startProgressReporter(taskId, parentSessionId) {
315
+ const timer = setInterval(() => {
316
+ const task = this.tasks.get(taskId);
317
+ if (!task || task.status !== "running") {
318
+ this.stopProgressReporter(taskId);
319
+ return;
320
+ }
321
+ if (task.startedAt) {
322
+ const elapsedMs = Date.now() - task.startedAt;
323
+ task.progress = Math.min(95, Math.floor(elapsedMs / PROGRESS_INTERVAL * 100));
324
+ }
325
+ const progressPayload = {
326
+ backgroundTaskId: taskId,
327
+ subSessionId: task.subSessionId,
328
+ parentSessionId,
329
+ status: task.status,
330
+ progress: task.progress
331
+ };
332
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.PROGRESS, progressPayload, parentSessionId);
333
+ }, PROGRESS_INTERVAL);
334
+ this.progressTimers.set(taskId, timer);
335
+ }
336
+ stopProgressReporter(taskId) {
337
+ const timer = this.progressTimers.get(taskId);
338
+ if (timer) {
339
+ clearInterval(timer);
340
+ this.progressTimers.delete(taskId);
341
+ }
342
+ }
292
343
  async executeWithAbort(subSession, prompt, timeoutMs, signal) {
293
344
  return new Promise((resolve, reject) => {
294
345
  const timer = setTimeout(() => {
@@ -346,41 +397,6 @@ ${prompt}
346
397
  });
347
398
  });
348
399
  }
349
- startProgressReporter(taskId, parentSessionId) {
350
- const timer = setInterval(() => {
351
- const task = this.tasks.get(taskId);
352
- if (!task || task.status !== "running") {
353
- this.stopProgressReporter(taskId);
354
- return;
355
- }
356
- if (task.startedAt) {
357
- const elapsedMs = Date.now() - task.startedAt;
358
- task.progress = Math.min(95, Math.floor(elapsedMs / PROGRESS_INTERVAL * 100));
359
- }
360
- this.publishEvent(TaskEventTypes.TASK_PROGRESS, createTaskProgressPayload(task, parentSessionId), parentSessionId);
361
- }, PROGRESS_INTERVAL);
362
- this.progressTimers.set(taskId, timer);
363
- }
364
- stopProgressReporter(taskId) {
365
- const timer = this.progressTimers.get(taskId);
366
- if (timer) {
367
- clearInterval(timer);
368
- this.progressTimers.delete(taskId);
369
- }
370
- }
371
- publishEvent(type, payload, triggerSessionId) {
372
- if (this.env?.pushEnvEvent) {
373
- this.env.pushEnvEvent({
374
- type,
375
- metadata: {
376
- trigger_session_id: triggerSessionId,
377
- source: "task.delegate"
378
- },
379
- payload
380
- });
381
- logger.info(`[BackgroundTaskManager] Event published: ${type}`, { payload });
382
- }
383
- }
384
400
  stopTask(taskId) {
385
401
  const task = this.tasks.get(taskId);
386
402
  if (!task) {
@@ -396,7 +412,17 @@ ${prompt}
396
412
  task.status = "stopped";
397
413
  task.abortController?.abort();
398
414
  task.completedAt = Date.now();
399
- this.publishEvent(TaskEventTypes.TASK_STOPPED, createTaskCompletedPayload(task, task.parentSessionId, task.completedAt - task.startedAt), task.parentSessionId);
415
+ const stoppedPayload = {
416
+ backgroundTaskId: task.id,
417
+ subSessionId: task.subSessionId,
418
+ parentSessionId: task.parentSessionId,
419
+ status: "stopped",
420
+ description: task.description,
421
+ error: "Task stopped by user",
422
+ executionTimeMs: task.startedAt ? task.completedAt - task.startedAt : 0,
423
+ associatedTaskId: task.taskId
424
+ };
425
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, task.parentSessionId);
400
426
  return { success: true, task, message: "Task has been stopped" };
401
427
  }
402
428
  getTask(taskId) {
@@ -406,11 +432,6 @@ ${prompt}
406
432
  return Array.from(this.tasks.values());
407
433
  }
408
434
  dispose() {
409
- for (const [taskId, timer] of this.progressTimers) {
410
- clearInterval(timer);
411
- logger.debug(`[BackgroundTaskManager] Cleared progress timer for task: ${taskId}`);
412
- }
413
- this.progressTimers.clear();
414
435
  for (const [taskId, controller] of this.abortControllers) {
415
436
  controller.abort();
416
437
  logger.debug(`[BackgroundTaskManager] Aborted task: ${taskId}`);
@@ -423,6 +444,7 @@ ${prompt}
423
444
  function createDelegateTool(taskComponent) {
424
445
  const env = taskComponent.env;
425
446
  const backgroundTaskManager = new BackgroundTaskManager(env);
447
+ taskComponent._backgroundTaskManager = backgroundTaskManager;
426
448
  const tool = {
427
449
  name: "delegate_task",
428
450
  description: `Launch a new sub-agent to handle complex, multistep tasks autonomously.
@@ -622,7 +644,9 @@ async function handleBackgroundTask(taskComponent, backgroundTaskManager, parent
622
644
  description: `Background task delegated to ${subagentType} subagent`,
623
645
  priority: "medium",
624
646
  goals_and_expected_deliverables: prompt,
625
- sessionId: parentSessionId
647
+ sessionId: parentSessionId,
648
+ project_path: "unknown",
649
+ context: "unknown"
626
650
  });
627
651
  associatedTaskId = newTask.id;
628
652
  await taskComponent.createOperation({
@@ -785,4 +809,4 @@ function createStopTool(taskManager) {
785
809
  }
786
810
  };
787
811
  }
788
- export { TaskEventTypes, BackgroundTaskManager, createDelegateTool, createStopTool };
812
+ export { BackgroundTaskEventTypes, BackgroundTaskManager, createDelegateTool, createStopTool };
@@ -486,13 +486,19 @@ function generateProviderOptions(providerType, options) {
486
486
  }
487
487
  function createEnvEventEmitter(env, context) {
488
488
  if (!env) {
489
+ logger.warn("[invoke] createEnvEventEmitter: env is null/undefined, streaming events will be disabled");
489
490
  return null;
490
491
  }
491
492
  return (event) => {
492
493
  try {
494
+ const fullType = `llm.${event.type}`;
495
+ logger.info(`[invoke] Pushing LLM event: ${fullType}`, {
496
+ hasPayload: !!event,
497
+ payloadType: typeof event
498
+ });
493
499
  env.pushEnvEvent({
494
500
  id: randomUUID(),
495
- type: `llm.${event.type}`,
501
+ type: fullType,
496
502
  timestamp: Date.now(),
497
503
  metadata: {
498
504
  source: "llm.invoke",
@@ -501,6 +507,7 @@ function createEnvEventEmitter(env, context) {
501
507
  },
502
508
  payload: event
503
509
  });
510
+ logger.info(`[invoke] LLM event pushed successfully: ${fullType}`);
504
511
  } catch (err) {
505
512
  logger.warn("Failed to push env event", { error: String(err), eventType: event.type });
506
513
  }
@@ -576,6 +583,7 @@ function processThinkingStream(textDelta, config, state) {
576
583
  async function invoke(config, options, ctx) {
577
584
  try {
578
585
  const emitToEnv = createEnvEventEmitter(options.env, options.context);
586
+ logger.info("[invoke] Created event emitter, env available:", !!options.env, "context:", options.context);
579
587
  const { providerId, modelId } = parseModelString(options.model || config.model);
580
588
  const provider = createProviderInstance(providerId, config.apiKey, config.baseURL);
581
589
  if (!provider) {
@@ -622,7 +630,10 @@ async function invoke(config, options, ctx) {
622
630
  });
623
631
  const model = `${providerId}/${modelId}`;
624
632
  if (emitToEnv) {
633
+ logger.info("[invoke] Emitting llm.start event");
625
634
  emitToEnv({ type: "start", metadata: { model } });
635
+ } else {
636
+ logger.warn("[invoke] emitToEnv is null, skipping llm.start event");
626
637
  }
627
638
  const streamTextOptions = {
628
639
  model: provider.languageModel(modelId),
@@ -6,7 +6,9 @@ var CreateTaskToolSchema = z.object({
6
6
  priority: z.enum(["low", "medium", "high"]).optional().describe("Task priority"),
7
7
  goals_and_expected_deliverables: z.string().optional().describe("Goals and expected deliverables"),
8
8
  due_date: z.string().optional().describe("Due date (ISO format)"),
9
- tags: z.array(z.string()).optional().describe("Task tags (for search, stored in task.tags JSON field)")
9
+ tags: z.array(z.string()).optional().describe("Task tags (for search, stored in task.tags JSON field)"),
10
+ project_path: z.string().describe("Project root path for task positioning. " + "Used to locate the project space for this task. " + "Use 'unknown' if unknown."),
11
+ context: z.string().describe("JSON string with time-space positioning information for task continuity. " + "This field is crucial for Agent task handoff. " + "Core fields: worktree_path (git worktree path), branch (current branch), type (feature/bug/refactor/chore). " + 'Example for coding: {"worktree_path": "/path/worktree", "branch": "feature/xyz", "type": "feature"}. ' + 'Example for other: {"type": "general"}. ' + `If unknown, use '{}' or '{"type":"unknown"}'. ` + "IMPORTANT: Must be a valid JSON string!")
10
12
  });
11
13
  var GetTaskToolSchema = z.object({
12
14
  task_id: z.number().describe("Task ID"),
@@ -28,7 +30,9 @@ var UpdateTaskToolSchema = z.object({
28
30
  current_status: z.string().optional(),
29
31
  goals_and_expected_deliverables: z.string().optional(),
30
32
  due_date: z.string().optional(),
31
- tags: z.array(z.string()).optional()
33
+ tags: z.array(z.string()).optional(),
34
+ project_path: z.string().optional().describe("Project path, identifies which project this task belongs to"),
35
+ context: z.string().optional().describe("Task context information for storing additional context")
32
36
  });
33
37
  var DeleteTaskToolSchema = z.object({
34
38
  task_id: z.number().describe("Task ID")
@@ -38,7 +42,41 @@ var DeleteTaskToolSchema = z.object({
38
42
  function createTaskTool(taskComponent) {
39
43
  return {
40
44
  name: "task_create",
41
- description: "Create a new task. The task will be associated with the current session.",
45
+ description: `
46
+ Create a new task for tracking work.
47
+
48
+ ## IMPORTANT: Task Continuity Fields
49
+
50
+ This tool creates persistent task records that can be picked up by a
51
+ Task Manager Agent to continue推进未完成的任务.
52
+
53
+ The following fields are critical for task context preservation:
54
+
55
+ - project_path: The project root path where this task belongs.
56
+ Used to locate the project space for this task.
57
+ If unknown, use 'unknown'.
58
+
59
+ - context: A JSON string containing time-space positioning information.
60
+ This field is crucial for Agent task handoff.
61
+
62
+ **Required format**: Valid JSON string (parseable).
63
+
64
+ **Core fields**:
65
+ - worktree_path: Git worktree path (for code development)
66
+ - branch: Current branch name
67
+ - type: Task type (feature/bug/refactor/chore)
68
+
69
+ **Example for coding tasks**:
70
+ {"worktree_path": "/path/to/worktree", "branch": "feature/xyz", "type": "feature", "parent_branch": "main"}
71
+
72
+ **Example for other tasks**:
73
+ {"type": "general"}
74
+
75
+ If unable to fill in details, use at minimum:
76
+ {"type": "unknown"}
77
+
78
+ **DO NOT leave this as plain text** - it must be valid JSON!
79
+ `,
42
80
  parameters: CreateTaskToolSchema,
43
81
  execute: async (args, ctx) => {
44
82
  const params = CreateTaskToolSchema.parse(args);
@@ -51,7 +89,9 @@ function createTaskTool(taskComponent) {
51
89
  goals_and_expected_deliverables: params.goals_and_expected_deliverables,
52
90
  due_date: params.due_date,
53
91
  tags: params.tags,
54
- sessionId
92
+ sessionId,
93
+ project_path: params.project_path,
94
+ context: params.context
55
95
  });
56
96
  return {
57
97
  success: true,
@@ -175,7 +215,9 @@ function updateTaskTool(taskComponent) {
175
215
  current_status: params.current_status,
176
216
  goals_and_expected_deliverables: params.goals_and_expected_deliverables,
177
217
  due_date: params.due_date,
178
- tags: params.tags
218
+ tags: params.tags,
219
+ project_path: params.project_path,
220
+ context: params.context
179
221
  });
180
222
  if (!task) {
181
223
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.5.6",
3
+ "version": "1.5.8",
4
4
  "type": "module",
5
5
  "description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
6
6
  "main": "./dist/index.js",
@@ -2,17 +2,17 @@ import {
2
2
  exports_node_registry_helper,
3
3
  init_node_registry_helper
4
4
  } from "./roy-agent-core-0rtxwr28.js";
5
+ import {
6
+ WorkflowEngine,
7
+ exports_engine,
8
+ init_engine
9
+ } from "./roy-agent-core-wrcy0h6z.js";
5
10
  import {
6
11
  WorkflowService
7
12
  } from "./roy-agent-core-4t40mkpv.js";
8
13
  import {
9
14
  askUserTool
10
15
  } from "./roy-agent-core-0vbdz0x7.js";
11
- import {
12
- WorkflowEngine,
13
- exports_engine,
14
- init_engine
15
- } from "./roy-agent-core-wrcy0h6z.js";
16
16
  import {
17
17
  BaseComponent
18
18
  } from "./roy-agent-core-kkbwepqb.js";