@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,225 @@
|
|
|
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/memory/built-in/record-memory.ts
|
|
53
|
+
import { z } from "zod";
|
|
54
|
+
var RecordMemorySchema = z.object({
|
|
55
|
+
scope: z.enum(["project", "global"]).describe("\u4F5C\u7528\u57DF: project/global"),
|
|
56
|
+
mode: z.enum(["append", "prepend", "overwrite", "delete"]).describe("\u6A21\u5F0F: append(\u8FFD\u52A0)/prepend(\u63D2\u5165)/overwrite(\u8986\u76D6)/delete(\u5220\u9664)"),
|
|
57
|
+
content: z.string().optional().describe("\u8BB0\u5FC6\u5185\u5BB9"),
|
|
58
|
+
title: z.string().optional().describe("\u7AE0\u8282\u6807\u9898")
|
|
59
|
+
});
|
|
60
|
+
function createRecordMemoryTool(recordMemory, getMemoryPaths, getMemoryFile) {
|
|
61
|
+
return {
|
|
62
|
+
name: "record_memory",
|
|
63
|
+
description: buildDescription(getMemoryPaths, getMemoryFile),
|
|
64
|
+
parameters: RecordMemorySchema,
|
|
65
|
+
execute: async (args, _ctx) => {
|
|
66
|
+
const params = RecordMemorySchema.parse(args);
|
|
67
|
+
const startTime = Date.now();
|
|
68
|
+
try {
|
|
69
|
+
const result = await recordMemory({
|
|
70
|
+
scope: params.scope,
|
|
71
|
+
mode: params.mode,
|
|
72
|
+
content: params.content,
|
|
73
|
+
title: params.title
|
|
74
|
+
});
|
|
75
|
+
if (!result) {
|
|
76
|
+
return {
|
|
77
|
+
success: false,
|
|
78
|
+
output: "",
|
|
79
|
+
error: "\u672A\u914D\u7F6E memory \u8DEF\u5F84\uFF0C\u65E0\u6CD5\u8BB0\u5F55\u8BB0\u5FC6",
|
|
80
|
+
metadata: { execution_time_ms: Date.now() - startTime }
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const actionMessages = {
|
|
84
|
+
created: "\u5DF2\u521B\u5EFA\u8BB0\u5FC6\u6587\u4EF6",
|
|
85
|
+
overwrite: "\u5DF2\u8986\u76D6\u8BB0\u5FC6\u6587\u4EF6",
|
|
86
|
+
append: "\u5DF2\u8FFD\u52A0\u5185\u5BB9\u5230\u8BB0\u5FC6\u6587\u4EF6",
|
|
87
|
+
prepend: "\u5DF2\u63D2\u5165\u5185\u5BB9\u5230\u8BB0\u5FC6\u6587\u4EF6\u5F00\u5934",
|
|
88
|
+
delete: "\u5DF2\u5220\u9664\u8BB0\u5FC6\u6587\u4EF6"
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
success: true,
|
|
92
|
+
output: `${actionMessages[result.action]}: ${result.path}`,
|
|
93
|
+
metadata: {
|
|
94
|
+
execution_time_ms: Date.now() - startTime,
|
|
95
|
+
path: result.path,
|
|
96
|
+
action: result.action
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
} catch (error) {
|
|
100
|
+
return {
|
|
101
|
+
success: false,
|
|
102
|
+
output: "",
|
|
103
|
+
error: error instanceof Error ? error.message : String(error),
|
|
104
|
+
metadata: { execution_time_ms: Date.now() - startTime }
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function buildDescription(getMemoryPaths, getMemoryFile) {
|
|
111
|
+
const paths = getMemoryPaths();
|
|
112
|
+
const memoryFile = getMemoryFile();
|
|
113
|
+
const lines = [
|
|
114
|
+
`# Record Memory Tool`,
|
|
115
|
+
"",
|
|
116
|
+
`Record memory to file. Writes to the memory.md file in the specified scope.`,
|
|
117
|
+
"",
|
|
118
|
+
`## Modes`,
|
|
119
|
+
"",
|
|
120
|
+
"| Mode | Description |",
|
|
121
|
+
"|------|-------------|",
|
|
122
|
+
"| **append** | \u8FFD\u52A0\u5185\u5BB9\u5230 ${memoryFile} \u5C3E\u90E8 |",
|
|
123
|
+
"| **prepend** | \u63D2\u5165\u5185\u5BB9\u5230 ${memoryFile} \u5F00\u5934 |",
|
|
124
|
+
"| **overwrite** | \u8986\u76D6 ${memoryFile} |",
|
|
125
|
+
"| **delete** | \u5220\u9664 ${memoryFile} |",
|
|
126
|
+
"",
|
|
127
|
+
`## Parameters`,
|
|
128
|
+
"",
|
|
129
|
+
"- **scope** (required): \u4F5C\u7528\u57DF - project \u6216 global",
|
|
130
|
+
"- **mode** (required): \u64CD\u4F5C\u6A21\u5F0F",
|
|
131
|
+
"- **content** (optional): \u8BB0\u5FC6\u5185\u5BB9",
|
|
132
|
+
"- **title** (optional): \u7AE0\u8282\u6807\u9898",
|
|
133
|
+
"",
|
|
134
|
+
`## Memory Paths`,
|
|
135
|
+
""
|
|
136
|
+
];
|
|
137
|
+
if (paths.length === 0) {
|
|
138
|
+
lines.push("No memory paths configured.");
|
|
139
|
+
} else {
|
|
140
|
+
lines.push("Files will be written to:");
|
|
141
|
+
for (const p of paths) {
|
|
142
|
+
lines.push(`- **[${p.type}]** ${p.path}/${memoryFile}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return lines.join(`
|
|
146
|
+
`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// packages/core/src/env/memory/built-in/recall-memory.ts
|
|
150
|
+
import { z as z2 } from "zod";
|
|
151
|
+
var RecallMemorySchema = z2.object({
|
|
152
|
+
scope: z2.enum(["project", "global"]).optional().describe("\u4F5C\u7528\u57DF\uFF08\u53EF\u9009\uFF0C\u4E0D\u4F20\u5219\u8BFB\u53D6\u6240\u6709\uFF09")
|
|
153
|
+
});
|
|
154
|
+
function createRecallMemoryTool(recallMemory, getMemoryPaths, getMemoryFile) {
|
|
155
|
+
return {
|
|
156
|
+
name: "recall_memory",
|
|
157
|
+
description: buildDescription2(getMemoryPaths, getMemoryFile),
|
|
158
|
+
parameters: RecallMemorySchema,
|
|
159
|
+
execute: async (args, _ctx) => {
|
|
160
|
+
const params = RecallMemorySchema.parse(args);
|
|
161
|
+
const startTime = Date.now();
|
|
162
|
+
try {
|
|
163
|
+
const content = await recallMemory(params.scope);
|
|
164
|
+
if (!content) {
|
|
165
|
+
return {
|
|
166
|
+
success: true,
|
|
167
|
+
output: "(No memory files found)",
|
|
168
|
+
metadata: { execution_time_ms: Date.now() - startTime }
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
success: true,
|
|
173
|
+
output: content,
|
|
174
|
+
metadata: { execution_time_ms: Date.now() - startTime }
|
|
175
|
+
};
|
|
176
|
+
} catch (error) {
|
|
177
|
+
return {
|
|
178
|
+
success: false,
|
|
179
|
+
output: "",
|
|
180
|
+
error: error instanceof Error ? error.message : String(error),
|
|
181
|
+
metadata: { execution_time_ms: Date.now() - startTime }
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function buildDescription2(getMemoryPaths, getMemoryFile) {
|
|
188
|
+
const paths = getMemoryPaths();
|
|
189
|
+
const memoryFile = getMemoryFile();
|
|
190
|
+
const lines = [
|
|
191
|
+
`# Recall Memory Tool`,
|
|
192
|
+
"",
|
|
193
|
+
`Recall memory from memory files. Reads from the memory.md file in the specified scope.`,
|
|
194
|
+
"",
|
|
195
|
+
`## Parameters`,
|
|
196
|
+
"",
|
|
197
|
+
"- **scope** (optional): \u4F5C\u7528\u57DF - project \u6216 global\uFF08\u4E0D\u4F20\u5219\u8BFB\u53D6\u6240\u6709\uFF09",
|
|
198
|
+
"",
|
|
199
|
+
`## Memory Files`,
|
|
200
|
+
""
|
|
201
|
+
];
|
|
202
|
+
if (paths.length === 0) {
|
|
203
|
+
lines.push("No memory paths configured.");
|
|
204
|
+
} else {
|
|
205
|
+
lines.push("Files will be read from:");
|
|
206
|
+
for (const p of paths) {
|
|
207
|
+
lines.push(`- **[${p.type}]** ${p.path}/${memoryFile}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return lines.join(`
|
|
211
|
+
`);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// packages/core/src/env/memory/built-in/index.ts
|
|
215
|
+
function createMemoryTools(recordMemory, recallMemory, config) {
|
|
216
|
+
return [
|
|
217
|
+
createRecordMemoryTool(recordMemory, config.getMemoryPaths, config.getMemoryFile),
|
|
218
|
+
createRecallMemoryTool(recallMemory, config.getMemoryPaths, config.getMemoryFile)
|
|
219
|
+
];
|
|
220
|
+
}
|
|
221
|
+
export {
|
|
222
|
+
createMemoryTools,
|
|
223
|
+
RecordMemorySchema,
|
|
224
|
+
RecallMemorySchema
|
|
225
|
+
};
|