@ai-setting/roy-agent-core 1.4.10 → 1.4.12
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 +23 -0
- package/dist/env/agent/index.js +3035 -0
- package/dist/env/commands/index.js +1685 -0
- package/dist/env/debug/formatters/index.js +639 -0
- package/dist/env/debug/index.js +2300 -0
- package/dist/env/hook/index.js +273 -0
- package/dist/env/index.js +12591 -0
- package/dist/env/llm/index.js +2736 -0
- package/dist/env/log-trace/index.js +1779 -0
- package/dist/env/mcp/index.js +2173 -0
- package/dist/env/mcp/tool/index.js +1149 -0
- package/dist/env/memory/built-in/index.js +225 -0
- package/dist/env/memory/index.js +2171 -0
- package/dist/env/memory/plugin/index.js +1263 -0
- package/dist/env/prompt/index.js +2107 -0
- package/dist/env/session/index.js +3594 -0
- package/dist/env/session/storage/index.js +2049 -0
- package/dist/env/skill/index.js +1635 -0
- package/dist/env/skill/tool/index.js +114 -0
- package/dist/env/task/delegate/index.js +1844 -0
- package/dist/env/task/hooks/index.js +67 -0
- package/dist/env/task/index.js +3578 -0
- package/dist/env/task/plugins/index.js +1626 -0
- package/dist/env/task/storage/index.js +1464 -0
- package/dist/env/task/tools/index.js +344 -0
- package/dist/env/task/tools/operation/index.js +270 -0
- package/dist/env/tool/built-in/index.js +1151 -0
- package/dist/env/tool/index.js +2284 -0
- package/dist/env/workflow/decorators/index.js +449 -0
- package/dist/env/workflow/engine/index.js +4391 -0
- package/dist/env/workflow/index.js +6214 -0
- package/dist/env/workflow/nodes/index.js +650 -0
- package/dist/env/workflow/service/index.js +262 -0
- package/dist/env/workflow/storage/index.js +1236 -0
- package/dist/env/workflow/tools/index.js +1081 -0
- package/dist/env/workflow/types/index.js +479 -0
- package/dist/env/workflow/utils/index.js +1631 -0
- package/dist/index.js +15006 -14265
- package/package.json +2 -2
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
function __accessProp(key) {
|
|
7
|
+
return this[key];
|
|
8
|
+
}
|
|
9
|
+
var __toCommonJS = (from) => {
|
|
10
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
11
|
+
if (entry)
|
|
12
|
+
return entry;
|
|
13
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (var key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(entry, key))
|
|
17
|
+
__defProp(entry, key, {
|
|
18
|
+
get: __accessProp.bind(from, key),
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
__moduleCache.set(from, entry);
|
|
23
|
+
return entry;
|
|
24
|
+
};
|
|
25
|
+
var __moduleCache;
|
|
26
|
+
var __returnValue = (v) => v;
|
|
27
|
+
function __exportSetter(name, newValue) {
|
|
28
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
29
|
+
}
|
|
30
|
+
var __export = (target, all) => {
|
|
31
|
+
for (var name in all)
|
|
32
|
+
__defProp(target, name, {
|
|
33
|
+
get: all[name],
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
set: __exportSetter.bind(all, name)
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
var __legacyDecorateClassTS = function(decorators, target, key, desc) {
|
|
40
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
41
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
42
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
43
|
+
else
|
|
44
|
+
for (var i = decorators.length - 1;i >= 0; i--)
|
|
45
|
+
if (d = decorators[i])
|
|
46
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
47
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
48
|
+
};
|
|
49
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
50
|
+
var __require = import.meta.require;
|
|
51
|
+
|
|
52
|
+
// packages/core/src/env/task/tools/task-types.ts
|
|
53
|
+
import { z } from "zod";
|
|
54
|
+
var CreateTaskToolSchema = z.object({
|
|
55
|
+
title: z.string().describe("Task title"),
|
|
56
|
+
description: z.string().optional().describe("Task description"),
|
|
57
|
+
priority: z.enum(["low", "medium", "high"]).optional().describe("Task priority"),
|
|
58
|
+
goals_and_expected_deliverables: z.string().optional().describe("Goals and expected deliverables"),
|
|
59
|
+
due_date: z.string().optional().describe("Due date (ISO format)"),
|
|
60
|
+
tags: z.array(z.string()).optional().describe("Task tags (for search, stored in task.tags JSON field)")
|
|
61
|
+
});
|
|
62
|
+
var GetTaskToolSchema = z.object({
|
|
63
|
+
task_id: z.number().describe("Task ID"),
|
|
64
|
+
include_operations: z.boolean().optional().default(false).describe("Include operation records")
|
|
65
|
+
});
|
|
66
|
+
var ListTasksToolSchema = z.object({
|
|
67
|
+
status: z.enum(["todo", "active", "completed", "paused", "cancelled"]).optional(),
|
|
68
|
+
priority: z.enum(["low", "medium", "high"]).optional(),
|
|
69
|
+
limit: z.number().optional().default(20),
|
|
70
|
+
offset: z.number().optional().default(0)
|
|
71
|
+
});
|
|
72
|
+
var UpdateTaskToolSchema = z.object({
|
|
73
|
+
task_id: z.number().describe("Task ID"),
|
|
74
|
+
title: z.string().optional(),
|
|
75
|
+
description: z.string().optional(),
|
|
76
|
+
status: z.enum(["todo", "active", "completed", "paused", "cancelled"]).optional(),
|
|
77
|
+
priority: z.enum(["low", "medium", "high"]).optional(),
|
|
78
|
+
progress: z.number().min(0).max(100).optional(),
|
|
79
|
+
current_status: z.string().optional(),
|
|
80
|
+
goals_and_expected_deliverables: z.string().optional(),
|
|
81
|
+
due_date: z.string().optional(),
|
|
82
|
+
tags: z.array(z.string()).optional()
|
|
83
|
+
});
|
|
84
|
+
var DeleteTaskToolSchema = z.object({
|
|
85
|
+
task_id: z.number().describe("Task ID")
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// packages/core/src/env/task/tools/create-tool.ts
|
|
89
|
+
function createTaskTool(taskComponent) {
|
|
90
|
+
return {
|
|
91
|
+
name: "task_create",
|
|
92
|
+
description: "Create a new task. The task will be associated with the current session.",
|
|
93
|
+
parameters: CreateTaskToolSchema,
|
|
94
|
+
execute: async (args, ctx) => {
|
|
95
|
+
const params = CreateTaskToolSchema.parse(args);
|
|
96
|
+
const sessionId = ctx.session_id || "unknown";
|
|
97
|
+
try {
|
|
98
|
+
const task = await taskComponent.createTask({
|
|
99
|
+
title: params.title,
|
|
100
|
+
description: params.description,
|
|
101
|
+
priority: params.priority,
|
|
102
|
+
goals_and_expected_deliverables: params.goals_and_expected_deliverables,
|
|
103
|
+
due_date: params.due_date,
|
|
104
|
+
tags: params.tags,
|
|
105
|
+
sessionId
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
success: true,
|
|
109
|
+
output: `Task created successfully: #${task.id} - ${task.title}`,
|
|
110
|
+
metadata: {
|
|
111
|
+
execution_time_ms: 0,
|
|
112
|
+
task_id: task.id,
|
|
113
|
+
status: task.status,
|
|
114
|
+
createdAt: task.createdAt
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
} catch (error) {
|
|
118
|
+
return {
|
|
119
|
+
success: false,
|
|
120
|
+
output: "",
|
|
121
|
+
error: error instanceof Error ? error.message : String(error),
|
|
122
|
+
metadata: { execution_time_ms: 0 }
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
// packages/core/src/env/task/tools/get-tool.ts
|
|
129
|
+
function getTaskTool(taskComponent) {
|
|
130
|
+
return {
|
|
131
|
+
name: "task_get",
|
|
132
|
+
description: "Get task details by ID. Optionally include operation records.",
|
|
133
|
+
parameters: GetTaskToolSchema,
|
|
134
|
+
execute: async (args, ctx) => {
|
|
135
|
+
const params = GetTaskToolSchema.parse(args);
|
|
136
|
+
try {
|
|
137
|
+
if (params.include_operations) {
|
|
138
|
+
const result = await taskComponent.getTaskWithOperations(params.task_id);
|
|
139
|
+
if (!result) {
|
|
140
|
+
return {
|
|
141
|
+
success: false,
|
|
142
|
+
output: "",
|
|
143
|
+
error: `Task not found: ${params.task_id}`,
|
|
144
|
+
metadata: { execution_time_ms: 0 }
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
success: true,
|
|
149
|
+
output: JSON.stringify(result, null, 2),
|
|
150
|
+
metadata: { execution_time_ms: 0 }
|
|
151
|
+
};
|
|
152
|
+
} else {
|
|
153
|
+
const task = await taskComponent.getTask(params.task_id);
|
|
154
|
+
if (!task) {
|
|
155
|
+
return {
|
|
156
|
+
success: false,
|
|
157
|
+
output: "",
|
|
158
|
+
error: `Task not found: ${params.task_id}`,
|
|
159
|
+
metadata: { execution_time_ms: 0 }
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
success: true,
|
|
164
|
+
output: JSON.stringify(task, null, 2),
|
|
165
|
+
metadata: { execution_time_ms: 0 }
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
} catch (error) {
|
|
169
|
+
return {
|
|
170
|
+
success: false,
|
|
171
|
+
output: "",
|
|
172
|
+
error: error instanceof Error ? error.message : String(error),
|
|
173
|
+
metadata: { execution_time_ms: 0 }
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
// packages/core/src/env/task/tools/list-tool.ts
|
|
180
|
+
function listTasksTool(taskComponent) {
|
|
181
|
+
return {
|
|
182
|
+
name: "task_list",
|
|
183
|
+
description: "List tasks with optional filters for status and priority.",
|
|
184
|
+
parameters: ListTasksToolSchema,
|
|
185
|
+
execute: async (args, ctx) => {
|
|
186
|
+
const params = ListTasksToolSchema.parse(args);
|
|
187
|
+
try {
|
|
188
|
+
const tasks = await taskComponent.listTasks({
|
|
189
|
+
status: params.status,
|
|
190
|
+
priority: params.priority,
|
|
191
|
+
limit: params.limit,
|
|
192
|
+
offset: params.offset
|
|
193
|
+
});
|
|
194
|
+
return {
|
|
195
|
+
success: true,
|
|
196
|
+
output: JSON.stringify({ tasks, count: tasks.length }),
|
|
197
|
+
metadata: { execution_time_ms: 0 }
|
|
198
|
+
};
|
|
199
|
+
} catch (error) {
|
|
200
|
+
return {
|
|
201
|
+
success: false,
|
|
202
|
+
output: "",
|
|
203
|
+
error: error instanceof Error ? error.message : String(error),
|
|
204
|
+
metadata: { execution_time_ms: 0 }
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
// packages/core/src/env/task/tools/update-tool.ts
|
|
211
|
+
function updateTaskTool(taskComponent) {
|
|
212
|
+
return {
|
|
213
|
+
name: "task_update",
|
|
214
|
+
description: "Update an existing task's properties. Status and progress changes will create operation records.",
|
|
215
|
+
parameters: UpdateTaskToolSchema,
|
|
216
|
+
execute: async (args, ctx) => {
|
|
217
|
+
const params = UpdateTaskToolSchema.parse(args);
|
|
218
|
+
const sessionId = ctx.session_id || "unknown";
|
|
219
|
+
try {
|
|
220
|
+
const task = await taskComponent.updateTask(params.task_id, {
|
|
221
|
+
title: params.title,
|
|
222
|
+
description: params.description,
|
|
223
|
+
status: params.status,
|
|
224
|
+
priority: params.priority,
|
|
225
|
+
progress: params.progress,
|
|
226
|
+
current_status: params.current_status,
|
|
227
|
+
goals_and_expected_deliverables: params.goals_and_expected_deliverables,
|
|
228
|
+
due_date: params.due_date,
|
|
229
|
+
tags: params.tags
|
|
230
|
+
});
|
|
231
|
+
if (!task) {
|
|
232
|
+
return {
|
|
233
|
+
success: false,
|
|
234
|
+
output: "",
|
|
235
|
+
error: `Task not found: ${params.task_id}`,
|
|
236
|
+
metadata: { execution_time_ms: 0 }
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
if (params.status || params.progress !== undefined || params.current_status) {
|
|
240
|
+
await taskComponent.createOperation({
|
|
241
|
+
taskId: params.task_id,
|
|
242
|
+
sessionId,
|
|
243
|
+
actionType: "progress",
|
|
244
|
+
actionTitle: params.current_status || `Updated: ${params.status || `${params.progress}%`}`,
|
|
245
|
+
actionDescription: JSON.stringify({
|
|
246
|
+
status: params.status,
|
|
247
|
+
progress: params.progress,
|
|
248
|
+
current_status: params.current_status
|
|
249
|
+
})
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
success: true,
|
|
254
|
+
output: `Task updated: #${task.id} - ${task.title}`,
|
|
255
|
+
metadata: { execution_time_ms: 0, task }
|
|
256
|
+
};
|
|
257
|
+
} catch (error) {
|
|
258
|
+
return {
|
|
259
|
+
success: false,
|
|
260
|
+
output: "",
|
|
261
|
+
error: error instanceof Error ? error.message : String(error),
|
|
262
|
+
metadata: { execution_time_ms: 0 }
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
// packages/core/src/env/task/tools/delete-tool.ts
|
|
269
|
+
function deleteTaskTool(taskComponent) {
|
|
270
|
+
return {
|
|
271
|
+
name: "task_delete",
|
|
272
|
+
description: "Delete a task and all its operation records.",
|
|
273
|
+
parameters: DeleteTaskToolSchema,
|
|
274
|
+
execute: async (args, ctx) => {
|
|
275
|
+
const params = DeleteTaskToolSchema.parse(args);
|
|
276
|
+
try {
|
|
277
|
+
const deleted = await taskComponent.deleteTask(params.task_id);
|
|
278
|
+
if (!deleted) {
|
|
279
|
+
return {
|
|
280
|
+
success: false,
|
|
281
|
+
output: "",
|
|
282
|
+
error: `Task not found: ${params.task_id}`,
|
|
283
|
+
metadata: { execution_time_ms: 0 }
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
success: true,
|
|
288
|
+
output: `Task deleted: #${params.task_id}`,
|
|
289
|
+
metadata: { execution_time_ms: 0 }
|
|
290
|
+
};
|
|
291
|
+
} catch (error) {
|
|
292
|
+
return {
|
|
293
|
+
success: false,
|
|
294
|
+
output: "",
|
|
295
|
+
error: error instanceof Error ? error.message : String(error),
|
|
296
|
+
metadata: { execution_time_ms: 0 }
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
// packages/core/src/env/task/tools/complete-tool.ts
|
|
303
|
+
function completeTaskTool(taskComponent) {
|
|
304
|
+
return {
|
|
305
|
+
name: "task_complete",
|
|
306
|
+
description: "Mark a task as completed (progress=100, status=completed). Creates an operation record.",
|
|
307
|
+
parameters: DeleteTaskToolSchema,
|
|
308
|
+
execute: async (args, ctx) => {
|
|
309
|
+
const params = DeleteTaskToolSchema.parse(args);
|
|
310
|
+
const sessionId = ctx.session_id || "unknown";
|
|
311
|
+
try {
|
|
312
|
+
const task = await taskComponent.completeTask(params.task_id, sessionId);
|
|
313
|
+
if (!task) {
|
|
314
|
+
return {
|
|
315
|
+
success: false,
|
|
316
|
+
output: "",
|
|
317
|
+
error: `Task not found: ${params.task_id}`,
|
|
318
|
+
metadata: { execution_time_ms: 0 }
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
return {
|
|
322
|
+
success: true,
|
|
323
|
+
output: `Task completed: #${task.id} - ${task.title}`,
|
|
324
|
+
metadata: { execution_time_ms: 0, task }
|
|
325
|
+
};
|
|
326
|
+
} catch (error) {
|
|
327
|
+
return {
|
|
328
|
+
success: false,
|
|
329
|
+
output: "",
|
|
330
|
+
error: error instanceof Error ? error.message : String(error),
|
|
331
|
+
metadata: { execution_time_ms: 0 }
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
export {
|
|
338
|
+
updateTaskTool,
|
|
339
|
+
listTasksTool,
|
|
340
|
+
getTaskTool,
|
|
341
|
+
deleteTaskTool,
|
|
342
|
+
createTaskTool,
|
|
343
|
+
completeTaskTool
|
|
344
|
+
};
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
function __accessProp(key) {
|
|
7
|
+
return this[key];
|
|
8
|
+
}
|
|
9
|
+
var __toCommonJS = (from) => {
|
|
10
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
11
|
+
if (entry)
|
|
12
|
+
return entry;
|
|
13
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (var key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(entry, key))
|
|
17
|
+
__defProp(entry, key, {
|
|
18
|
+
get: __accessProp.bind(from, key),
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
__moduleCache.set(from, entry);
|
|
23
|
+
return entry;
|
|
24
|
+
};
|
|
25
|
+
var __moduleCache;
|
|
26
|
+
var __returnValue = (v) => v;
|
|
27
|
+
function __exportSetter(name, newValue) {
|
|
28
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
29
|
+
}
|
|
30
|
+
var __export = (target, all) => {
|
|
31
|
+
for (var name in all)
|
|
32
|
+
__defProp(target, name, {
|
|
33
|
+
get: all[name],
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
set: __exportSetter.bind(all, name)
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
var __legacyDecorateClassTS = function(decorators, target, key, desc) {
|
|
40
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
41
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
42
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
43
|
+
else
|
|
44
|
+
for (var i = decorators.length - 1;i >= 0; i--)
|
|
45
|
+
if (d = decorators[i])
|
|
46
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
47
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
48
|
+
};
|
|
49
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
50
|
+
var __require = import.meta.require;
|
|
51
|
+
|
|
52
|
+
// packages/core/src/env/task/tools/operation/operation-types.ts
|
|
53
|
+
import { z } from "zod";
|
|
54
|
+
var ActionTypeEnum = z.enum([
|
|
55
|
+
"create",
|
|
56
|
+
"progress",
|
|
57
|
+
"milestone",
|
|
58
|
+
"problem",
|
|
59
|
+
"solution",
|
|
60
|
+
"decision",
|
|
61
|
+
"review",
|
|
62
|
+
"completed"
|
|
63
|
+
]);
|
|
64
|
+
var CreateOperationToolSchema = z.object({
|
|
65
|
+
task_id: z.number().describe("Task ID"),
|
|
66
|
+
action_type: ActionTypeEnum.describe("Type of action"),
|
|
67
|
+
action_title: z.string().describe("Title of the action"),
|
|
68
|
+
action_description: z.string().optional().describe("Detailed description"),
|
|
69
|
+
md_path: z.string().optional().describe("Path to detailed markdown documentation")
|
|
70
|
+
});
|
|
71
|
+
var GetOperationToolSchema = z.object({
|
|
72
|
+
operation_id: z.number().describe("Operation ID")
|
|
73
|
+
});
|
|
74
|
+
var ListOperationsToolSchema = z.object({
|
|
75
|
+
task_id: z.number().describe("Task ID"),
|
|
76
|
+
action_type: ActionTypeEnum.optional(),
|
|
77
|
+
limit: z.number().optional().default(20),
|
|
78
|
+
offset: z.number().optional().default(0)
|
|
79
|
+
});
|
|
80
|
+
var UpdateOperationToolSchema = z.object({
|
|
81
|
+
operation_id: z.number().describe("Operation ID"),
|
|
82
|
+
action_title: z.string().optional(),
|
|
83
|
+
action_description: z.string().optional()
|
|
84
|
+
});
|
|
85
|
+
var DeleteOperationToolSchema = z.object({
|
|
86
|
+
operation_id: z.number().describe("Operation ID")
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// packages/core/src/env/task/tools/operation/create-tool.ts
|
|
90
|
+
function createOperationTool(taskComponent) {
|
|
91
|
+
return {
|
|
92
|
+
name: "task_operation_create",
|
|
93
|
+
description: "Create an operation record for a task. Tracks progress, milestones, problems, etc.",
|
|
94
|
+
parameters: CreateOperationToolSchema,
|
|
95
|
+
execute: async (args, ctx) => {
|
|
96
|
+
const params = CreateOperationToolSchema.parse(args);
|
|
97
|
+
const sessionId = ctx.session_id || "unknown";
|
|
98
|
+
try {
|
|
99
|
+
const operation = await taskComponent.createOperation({
|
|
100
|
+
taskId: params.task_id,
|
|
101
|
+
sessionId,
|
|
102
|
+
actionType: params.action_type,
|
|
103
|
+
actionTitle: params.action_title,
|
|
104
|
+
actionDescription: params.action_description,
|
|
105
|
+
mdPath: params.md_path
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
success: true,
|
|
109
|
+
output: `Operation created: #${operation.id} for task #${operation.taskId}`,
|
|
110
|
+
metadata: {
|
|
111
|
+
execution_time_ms: 0,
|
|
112
|
+
operation_id: operation.id,
|
|
113
|
+
task_id: operation.taskId,
|
|
114
|
+
session_id: operation.sessionId
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
} catch (error) {
|
|
118
|
+
return {
|
|
119
|
+
success: false,
|
|
120
|
+
output: "",
|
|
121
|
+
error: error instanceof Error ? error.message : String(error),
|
|
122
|
+
metadata: { execution_time_ms: 0 }
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
// packages/core/src/env/task/tools/operation/get-tool.ts
|
|
129
|
+
function getOperationTool(taskComponent) {
|
|
130
|
+
return {
|
|
131
|
+
name: "task_operation_get",
|
|
132
|
+
description: "Get a single operation record by ID.",
|
|
133
|
+
parameters: GetOperationToolSchema,
|
|
134
|
+
execute: async (args, ctx) => {
|
|
135
|
+
const params = GetOperationToolSchema.parse(args);
|
|
136
|
+
try {
|
|
137
|
+
const operation = await taskComponent.getOperation(params.operation_id);
|
|
138
|
+
if (!operation) {
|
|
139
|
+
return {
|
|
140
|
+
success: false,
|
|
141
|
+
output: "",
|
|
142
|
+
error: `Operation not found: ${params.operation_id}`,
|
|
143
|
+
metadata: { execution_time_ms: 0 }
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
success: true,
|
|
148
|
+
output: JSON.stringify(operation, null, 2),
|
|
149
|
+
metadata: { execution_time_ms: 0 }
|
|
150
|
+
};
|
|
151
|
+
} catch (error) {
|
|
152
|
+
return {
|
|
153
|
+
success: false,
|
|
154
|
+
output: "",
|
|
155
|
+
error: error instanceof Error ? error.message : String(error),
|
|
156
|
+
metadata: { execution_time_ms: 0 }
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
// packages/core/src/env/task/tools/operation/list-tool.ts
|
|
163
|
+
function listOperationsTool(taskComponent) {
|
|
164
|
+
return {
|
|
165
|
+
name: "task_operation_list",
|
|
166
|
+
description: "List operation records for a task with optional filters.",
|
|
167
|
+
parameters: ListOperationsToolSchema,
|
|
168
|
+
execute: async (args, ctx) => {
|
|
169
|
+
const params = ListOperationsToolSchema.parse(args);
|
|
170
|
+
try {
|
|
171
|
+
const operations = await taskComponent.listOperations({
|
|
172
|
+
taskId: params.task_id,
|
|
173
|
+
actionType: params.action_type,
|
|
174
|
+
limit: params.limit,
|
|
175
|
+
offset: params.offset
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
success: true,
|
|
179
|
+
output: JSON.stringify({ operations, count: operations.length }),
|
|
180
|
+
metadata: { execution_time_ms: 0 }
|
|
181
|
+
};
|
|
182
|
+
} catch (error) {
|
|
183
|
+
return {
|
|
184
|
+
success: false,
|
|
185
|
+
output: "",
|
|
186
|
+
error: error instanceof Error ? error.message : String(error),
|
|
187
|
+
metadata: { execution_time_ms: 0 }
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
// packages/core/src/env/task/tools/operation/update-tool.ts
|
|
194
|
+
function updateOperationTool(taskComponent) {
|
|
195
|
+
return {
|
|
196
|
+
name: "task_operation_update",
|
|
197
|
+
description: "Update an operation record's title or description.",
|
|
198
|
+
parameters: UpdateOperationToolSchema,
|
|
199
|
+
execute: async (args, ctx) => {
|
|
200
|
+
const params = UpdateOperationToolSchema.parse(args);
|
|
201
|
+
try {
|
|
202
|
+
const operation = await taskComponent.updateOperation(params.operation_id, {
|
|
203
|
+
actionTitle: params.action_title,
|
|
204
|
+
actionDescription: params.action_description
|
|
205
|
+
});
|
|
206
|
+
if (!operation) {
|
|
207
|
+
return {
|
|
208
|
+
success: false,
|
|
209
|
+
output: "",
|
|
210
|
+
error: `Operation not found: ${params.operation_id}`,
|
|
211
|
+
metadata: { execution_time_ms: 0 }
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
success: true,
|
|
216
|
+
output: `Operation updated: #${operation.id}`,
|
|
217
|
+
metadata: { execution_time_ms: 0, operation }
|
|
218
|
+
};
|
|
219
|
+
} catch (error) {
|
|
220
|
+
return {
|
|
221
|
+
success: false,
|
|
222
|
+
output: "",
|
|
223
|
+
error: error instanceof Error ? error.message : String(error),
|
|
224
|
+
metadata: { execution_time_ms: 0 }
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
// packages/core/src/env/task/tools/operation/delete-tool.ts
|
|
231
|
+
function deleteOperationTool(taskComponent) {
|
|
232
|
+
return {
|
|
233
|
+
name: "task_operation_delete",
|
|
234
|
+
description: "Delete an operation record.",
|
|
235
|
+
parameters: DeleteOperationToolSchema,
|
|
236
|
+
execute: async (args, ctx) => {
|
|
237
|
+
const params = DeleteOperationToolSchema.parse(args);
|
|
238
|
+
try {
|
|
239
|
+
const deleted = await taskComponent.deleteOperation(params.operation_id);
|
|
240
|
+
if (!deleted) {
|
|
241
|
+
return {
|
|
242
|
+
success: false,
|
|
243
|
+
output: "",
|
|
244
|
+
error: `Operation not found: ${params.operation_id}`,
|
|
245
|
+
metadata: { execution_time_ms: 0 }
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
success: true,
|
|
250
|
+
output: `Operation deleted: #${params.operation_id}`,
|
|
251
|
+
metadata: { execution_time_ms: 0 }
|
|
252
|
+
};
|
|
253
|
+
} catch (error) {
|
|
254
|
+
return {
|
|
255
|
+
success: false,
|
|
256
|
+
output: "",
|
|
257
|
+
error: error instanceof Error ? error.message : String(error),
|
|
258
|
+
metadata: { execution_time_ms: 0 }
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
export {
|
|
265
|
+
updateOperationTool,
|
|
266
|
+
listOperationsTool,
|
|
267
|
+
getOperationTool,
|
|
268
|
+
deleteOperationTool,
|
|
269
|
+
createOperationTool
|
|
270
|
+
};
|