@ai-setting/roy-agent-core 1.5.13-test → 1.5.15-test
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/package.json +1 -1
- package/dist/config/index.d.ts +0 -1250
- package/dist/config/index.js +0 -32
- package/dist/env/agent/index.d.ts +0 -2279
- package/dist/env/agent/index.js +0 -24
- package/dist/env/commands/index.d.ts +0 -1131
- package/dist/env/commands/index.js +0 -14
- package/dist/env/debug/formatters/index.d.ts +0 -236
- package/dist/env/debug/formatters/index.js +0 -11
- package/dist/env/debug/index.d.ts +0 -1652
- package/dist/env/debug/index.js +0 -26
- package/dist/env/hook/index.d.ts +0 -279
- package/dist/env/hook/index.js +0 -29
- package/dist/env/index.d.ts +0 -3481
- package/dist/env/index.js +0 -82
- package/dist/env/llm/index.d.ts +0 -1760
- package/dist/env/llm/index.js +0 -40
- package/dist/env/log-trace/index.d.ts +0 -1574
- package/dist/env/log-trace/index.js +0 -83
- package/dist/env/mcp/index.d.ts +0 -1331
- package/dist/env/mcp/index.js +0 -39
- package/dist/env/mcp/tool/index.d.ts +0 -183
- package/dist/env/mcp/tool/index.js +0 -14
- package/dist/env/memory/built-in/index.d.ts +0 -232
- package/dist/env/memory/built-in/index.js +0 -11
- package/dist/env/memory/index.d.ts +0 -1799
- package/dist/env/memory/index.js +0 -56
- package/dist/env/memory/plugin/index.d.ts +0 -747
- package/dist/env/memory/plugin/index.js +0 -36
- package/dist/env/prompt/index.d.ts +0 -1164
- package/dist/env/prompt/index.js +0 -20
- package/dist/env/session/index.d.ts +0 -1908
- package/dist/env/session/index.js +0 -25
- package/dist/env/session/storage/index.d.ts +0 -564
- package/dist/env/session/storage/index.js +0 -18
- package/dist/env/skill/index.d.ts +0 -1266
- package/dist/env/skill/index.js +0 -34
- package/dist/env/skill/tool/index.d.ts +0 -193
- package/dist/env/skill/tool/index.js +0 -9
- package/dist/env/task/delegate/index.d.ts +0 -1612
- package/dist/env/task/delegate/index.js +0 -18
- package/dist/env/task/events/index.d.ts +0 -171
- package/dist/env/task/events/index.js +0 -7
- package/dist/env/task/hooks/index.d.ts +0 -624
- package/dist/env/task/hooks/index.js +0 -7
- package/dist/env/task/index.d.ts +0 -1553
- package/dist/env/task/index.js +0 -34
- package/dist/env/task/plugins/index.d.ts +0 -466
- package/dist/env/task/plugins/index.js +0 -23
- package/dist/env/task/storage/index.d.ts +0 -241
- package/dist/env/task/storage/index.js +0 -14
- package/dist/env/task/tools/index.d.ts +0 -1485
- package/dist/env/task/tools/index.js +0 -17
- package/dist/env/task/tools/operation/index.d.ts +0 -1484
- package/dist/env/task/tools/operation/index.js +0 -15
- package/dist/env/tool/built-in/index.d.ts +0 -218
- package/dist/env/tool/built-in/index.js +0 -25
- package/dist/env/tool/index.d.ts +0 -1396
- package/dist/env/tool/index.js +0 -39
- package/dist/env/workflow/decorators/index.d.ts +0 -2161
- package/dist/env/workflow/decorators/index.js +0 -27
- package/dist/env/workflow/engine/index.d.ts +0 -3453
- package/dist/env/workflow/engine/index.js +0 -28
- package/dist/env/workflow/index.d.ts +0 -3546
- package/dist/env/workflow/index.js +0 -136
- package/dist/env/workflow/nodes/index.d.ts +0 -2092
- package/dist/env/workflow/nodes/index.js +0 -19
- package/dist/env/workflow/service/index.d.ts +0 -227
- package/dist/env/workflow/service/index.js +0 -13
- package/dist/env/workflow/storage/index.d.ts +0 -165
- package/dist/env/workflow/storage/index.js +0 -27
- package/dist/env/workflow/tools/index.d.ts +0 -416
- package/dist/env/workflow/tools/index.js +0 -159
- package/dist/env/workflow/types/index.d.ts +0 -2255
- package/dist/env/workflow/types/index.js +0 -98
- package/dist/env/workflow/utils/index.d.ts +0 -2031
- package/dist/env/workflow/utils/index.js +0 -637
- package/dist/index.d.ts +0 -7858
- package/dist/index.js +0 -399
- package/dist/shared/@ai-setting/roy-agent-core-0rtxwr28.js +0 -258
- package/dist/shared/@ai-setting/roy-agent-core-0vbdz0x7.js +0 -36
- package/dist/shared/@ai-setting/roy-agent-core-1akcqxj9.js +0 -349
- package/dist/shared/@ai-setting/roy-agent-core-1ce3fqrk.js +0 -117
- package/dist/shared/@ai-setting/roy-agent-core-2dhd60aw.js +0 -11
- package/dist/shared/@ai-setting/roy-agent-core-3jywqmdd.js +0 -393
- package/dist/shared/@ai-setting/roy-agent-core-3rr5k71j.js +0 -200
- package/dist/shared/@ai-setting/roy-agent-core-44hnfb02.js +0 -299
- package/dist/shared/@ai-setting/roy-agent-core-4t40mkpv.js +0 -206
- package/dist/shared/@ai-setting/roy-agent-core-4txzpsbt.js +0 -393
- package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +0 -350
- package/dist/shared/@ai-setting/roy-agent-core-69jskqjg.js +0 -180
- package/dist/shared/@ai-setting/roy-agent-core-6kvtahqv.js +0 -408
- package/dist/shared/@ai-setting/roy-agent-core-7fgf85wc.js +0 -284
- package/dist/shared/@ai-setting/roy-agent-core-81w1963m.js +0 -762
- package/dist/shared/@ai-setting/roy-agent-core-8gxth0eh.js +0 -10
- package/dist/shared/@ai-setting/roy-agent-core-92z6t4he.js +0 -14
- package/dist/shared/@ai-setting/roy-agent-core-93zfb3r1.js +0 -922
- package/dist/shared/@ai-setting/roy-agent-core-9yxb3ty9.js +0 -15
- package/dist/shared/@ai-setting/roy-agent-core-b0x5dda6.js +0 -1130
- package/dist/shared/@ai-setting/roy-agent-core-bcbqy27c.js +0 -14
- package/dist/shared/@ai-setting/roy-agent-core-bvr1761x.js +0 -653
- package/dist/shared/@ai-setting/roy-agent-core-ctdhjv68.js +0 -93
- package/dist/shared/@ai-setting/roy-agent-core-d7cyjkf7.js +0 -872
- package/dist/shared/@ai-setting/roy-agent-core-dh9d7a3m.js +0 -11
- package/dist/shared/@ai-setting/roy-agent-core-e25xkv53.js +0 -64
- package/dist/shared/@ai-setting/roy-agent-core-eajcvp4e.js +0 -378
- package/dist/shared/@ai-setting/roy-agent-core-f7q2x5z6.js +0 -492
- package/dist/shared/@ai-setting/roy-agent-core-fs0mn2jk.js +0 -52
- package/dist/shared/@ai-setting/roy-agent-core-g1s2h0e5.js +0 -171
- package/dist/shared/@ai-setting/roy-agent-core-g99pxzn5.js +0 -862
- package/dist/shared/@ai-setting/roy-agent-core-gbqcyegm.js +0 -1387
- package/dist/shared/@ai-setting/roy-agent-core-gjq1yk68.js +0 -208
- package/dist/shared/@ai-setting/roy-agent-core-gq20wsgv.js +0 -139
- package/dist/shared/@ai-setting/roy-agent-core-gwc4h96n.js +0 -534
- package/dist/shared/@ai-setting/roy-agent-core-jfh9q2qh.js +0 -204
- package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +0 -603
- package/dist/shared/@ai-setting/roy-agent-core-kkbwepqb.js +0 -97
- package/dist/shared/@ai-setting/roy-agent-core-pjr12nnd.js +0 -587
- package/dist/shared/@ai-setting/roy-agent-core-psv4v63c.js +0 -176
- package/dist/shared/@ai-setting/roy-agent-core-psvxt4c9.js +0 -60
- package/dist/shared/@ai-setting/roy-agent-core-qqceba6k.js +0 -442
- package/dist/shared/@ai-setting/roy-agent-core-qxhq8ven.js +0 -57
- package/dist/shared/@ai-setting/roy-agent-core-qxnbvgwe.js +0 -66
- package/dist/shared/@ai-setting/roy-agent-core-r9ezzemr.js +0 -10
- package/dist/shared/@ai-setting/roy-agent-core-rhmtwnw1.js +0 -267
- package/dist/shared/@ai-setting/roy-agent-core-rvv6ydff.js +0 -584
- package/dist/shared/@ai-setting/roy-agent-core-rvxg1wps.js +0 -102
- package/dist/shared/@ai-setting/roy-agent-core-satmq6sh.js +0 -549
- package/dist/shared/@ai-setting/roy-agent-core-sx7wsvnn.js +0 -15
- package/dist/shared/@ai-setting/roy-agent-core-t94ktchq.js +0 -213
- package/dist/shared/@ai-setting/roy-agent-core-vf215qfv.js +0 -812
- package/dist/shared/@ai-setting/roy-agent-core-vkz81f7v.js +0 -1316
- package/dist/shared/@ai-setting/roy-agent-core-vn2bc59q.js +0 -1205
- package/dist/shared/@ai-setting/roy-agent-core-wa1kzqky.js +0 -328
- package/dist/shared/@ai-setting/roy-agent-core-wft9ra24.js +0 -20
- package/dist/shared/@ai-setting/roy-agent-core-wrcy0h6z.js +0 -2098
- package/dist/shared/@ai-setting/roy-agent-core-xq8hhqb8.js +0 -419
- package/dist/shared/@ai-setting/roy-agent-core-xs5rsgat.js +0 -368
- package/dist/shared/@ai-setting/roy-agent-core-zbkpc41z.js +0 -377
- package/dist/shared/@ai-setting/roy-agent-core-zgypchmt.js +0 -172
- package/dist/shared/@ai-setting/roy-agent-core-zpn0bqa8.js +0 -103
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createSkillTool
|
|
3
|
-
} from "./roy-agent-core-psvxt4c9.js";
|
|
4
|
-
import {
|
|
5
|
-
envKeyToConfigKey
|
|
6
|
-
} from "./roy-agent-core-qxhq8ven.js";
|
|
7
|
-
import {
|
|
8
|
-
BaseComponent
|
|
9
|
-
} from "./roy-agent-core-kkbwepqb.js";
|
|
10
|
-
import {
|
|
11
|
-
createLogger,
|
|
12
|
-
init_logger
|
|
13
|
-
} from "./roy-agent-core-44hnfb02.js";
|
|
14
|
-
|
|
15
|
-
// src/env/skill/skill-component.ts
|
|
16
|
-
init_logger();
|
|
17
|
-
|
|
18
|
-
// src/env/skill/scanner.ts
|
|
19
|
-
init_logger();
|
|
20
|
-
import fs2 from "fs/promises";
|
|
21
|
-
import path2 from "path";
|
|
22
|
-
import { glob } from "glob";
|
|
23
|
-
|
|
24
|
-
// src/env/skill/parser.ts
|
|
25
|
-
init_logger();
|
|
26
|
-
import fs from "fs/promises";
|
|
27
|
-
var logger = createLogger("skill-parser");
|
|
28
|
-
function parseFrontmatter(text) {
|
|
29
|
-
const result = {};
|
|
30
|
-
const lines = text.split(`
|
|
31
|
-
`);
|
|
32
|
-
for (const line of lines) {
|
|
33
|
-
const match = line.match(/^(\w+):\s*"?(.+?)"?\s*$/);
|
|
34
|
-
if (match) {
|
|
35
|
-
const key = match[1];
|
|
36
|
-
let value = match[2];
|
|
37
|
-
if (value.startsWith('"') && value.endsWith('"')) {
|
|
38
|
-
value = value.slice(1, -1);
|
|
39
|
-
}
|
|
40
|
-
result[key] = value;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
async function parseSkillFile(filePath, source) {
|
|
46
|
-
try {
|
|
47
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
48
|
-
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---\n?/);
|
|
49
|
-
if (!frontmatterMatch) {
|
|
50
|
-
logger.warn(`[SkillParser] Missing frontmatter in: ${filePath}`);
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
const frontmatter = parseFrontmatter(frontmatterMatch[1]);
|
|
54
|
-
const name = frontmatter.name;
|
|
55
|
-
const description = frontmatter.description;
|
|
56
|
-
if (!name) {
|
|
57
|
-
logger.warn(`[SkillParser] Missing name in frontmatter: ${filePath}`);
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
if (!description) {
|
|
61
|
-
logger.warn(`[SkillParser] Missing description in frontmatter: ${filePath}`);
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
const actualContent = content.replace(/^---\n[\s\S]*?\n---\n?/, "");
|
|
65
|
-
return {
|
|
66
|
-
name,
|
|
67
|
-
description,
|
|
68
|
-
filePath,
|
|
69
|
-
content: actualContent,
|
|
70
|
-
source,
|
|
71
|
-
loadedAt: Date.now()
|
|
72
|
-
};
|
|
73
|
-
} catch (error) {
|
|
74
|
-
logger.error(`[SkillParser] Failed to parse file: ${filePath}`, error);
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// src/env/skill/config.ts
|
|
80
|
-
import path from "path";
|
|
81
|
-
import os from "os";
|
|
82
|
-
var DEFAULT_SKILL_CONFIG = {
|
|
83
|
-
skillPaths: [
|
|
84
|
-
{
|
|
85
|
-
type: "user",
|
|
86
|
-
path: path.join(os.homedir(), ".config", "roy-agent", "skills")
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
type: "project",
|
|
90
|
-
path: ".roy/skills"
|
|
91
|
-
}
|
|
92
|
-
],
|
|
93
|
-
recursive: true,
|
|
94
|
-
cacheEnabled: true
|
|
95
|
-
};
|
|
96
|
-
var SOURCE_PRIORITY = {
|
|
97
|
-
"built-in": 0,
|
|
98
|
-
user: 1,
|
|
99
|
-
project: 2
|
|
100
|
-
};
|
|
101
|
-
function getSourcePriority(source) {
|
|
102
|
-
return SOURCE_PRIORITY[source] ?? 0;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// src/env/skill/scanner.ts
|
|
106
|
-
var logger2 = createLogger("skill-scanner");
|
|
107
|
-
function expandPath(inputPath) {
|
|
108
|
-
if (inputPath.startsWith("~/")) {
|
|
109
|
-
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
110
|
-
return path2.join(home, inputPath.slice(2));
|
|
111
|
-
}
|
|
112
|
-
return path2.resolve(inputPath);
|
|
113
|
-
}
|
|
114
|
-
async function pathExists(p) {
|
|
115
|
-
try {
|
|
116
|
-
await fs2.access(p);
|
|
117
|
-
return true;
|
|
118
|
-
} catch {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
class SkillScanner {
|
|
124
|
-
config;
|
|
125
|
-
skillsMap;
|
|
126
|
-
constructor(config) {
|
|
127
|
-
this.config = config;
|
|
128
|
-
this.skillsMap = new Map;
|
|
129
|
-
}
|
|
130
|
-
async scan() {
|
|
131
|
-
this.skillsMap.clear();
|
|
132
|
-
for (const skillPath of this.config.skillPaths) {
|
|
133
|
-
await this.scanPath(skillPath);
|
|
134
|
-
}
|
|
135
|
-
return this.skillsMap;
|
|
136
|
-
}
|
|
137
|
-
async scanPath(skillPath) {
|
|
138
|
-
const expandedPath = expandPath(skillPath.path);
|
|
139
|
-
if (!await pathExists(expandedPath)) {
|
|
140
|
-
logger2.info(`[SkillScanner] Path not found, skipping: ${expandedPath}`);
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
logger2.info(`[SkillScanner] Scanning: ${expandedPath}`);
|
|
144
|
-
const sep = "/";
|
|
145
|
-
const basePattern = expandedPath.replace(/\\/g, "/");
|
|
146
|
-
const pattern = this.config.recursive ? `${basePattern}${sep}**${sep}SKILL.md` : `${basePattern}${sep}SKILL.md`;
|
|
147
|
-
const files = await glob(pattern, {
|
|
148
|
-
absolute: true,
|
|
149
|
-
ignore: ["**/node_modules/**"]
|
|
150
|
-
});
|
|
151
|
-
logger2.info(`[SkillScanner] Found ${files.length} SKILL.md files`);
|
|
152
|
-
for (const filePath of files) {
|
|
153
|
-
await this.processFile(filePath, skillPath.type);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
async processFile(filePath, source) {
|
|
157
|
-
const entry = await parseSkillFile(filePath, source);
|
|
158
|
-
if (!entry) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
const existing = this.skillsMap.get(entry.name);
|
|
162
|
-
if (!existing || getSourcePriority(source) > getSourcePriority(existing.source)) {
|
|
163
|
-
this.skillsMap.set(entry.name, entry);
|
|
164
|
-
logger2.debug(`[SkillScanner] Loaded skill: ${entry.name} (${source})`);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
getSkills() {
|
|
168
|
-
return this.skillsMap;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// src/env/skill/skill-config-registration.ts
|
|
173
|
-
import path3 from "path";
|
|
174
|
-
import os2 from "os";
|
|
175
|
-
var SKILL_DEFAULTS = {
|
|
176
|
-
"skill.skillPaths": [
|
|
177
|
-
{ type: "user", path: path3.join(os2.homedir(), ".config", "roy-agent", "skills") },
|
|
178
|
-
{ type: "project", path: ".roy/skills" }
|
|
179
|
-
],
|
|
180
|
-
"skill.recursive": true,
|
|
181
|
-
"skill.cacheEnabled": true
|
|
182
|
-
};
|
|
183
|
-
var SKILL_CONFIG_REGISTRATION = {
|
|
184
|
-
name: "skill",
|
|
185
|
-
sources: [
|
|
186
|
-
{ type: "env", envPrefix: "SKILL", priority: 20, watch: false }
|
|
187
|
-
],
|
|
188
|
-
keys: [
|
|
189
|
-
{ key: "skill.skillPaths", sources: ["env", "file"] },
|
|
190
|
-
{ key: "skill.recursive", sources: ["env", "file"] },
|
|
191
|
-
{ key: "skill.cacheEnabled", sources: ["env", "file"] }
|
|
192
|
-
]
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
// src/env/skill/skill-component.ts
|
|
196
|
-
var logger3 = createLogger("skill");
|
|
197
|
-
|
|
198
|
-
class SkillComponent extends BaseComponent {
|
|
199
|
-
name = "skill";
|
|
200
|
-
version = "1.0.0";
|
|
201
|
-
config;
|
|
202
|
-
toolComponent;
|
|
203
|
-
scanner;
|
|
204
|
-
skillsMap = new Map;
|
|
205
|
-
configComponent;
|
|
206
|
-
configWatcher;
|
|
207
|
-
async init(config) {
|
|
208
|
-
await super.init(config);
|
|
209
|
-
const options = config?.options;
|
|
210
|
-
if (!options?.configComponent) {
|
|
211
|
-
throw new Error("ConfigComponent is required for SkillComponent initialization");
|
|
212
|
-
}
|
|
213
|
-
this.configComponent = options.configComponent;
|
|
214
|
-
await this.registerConfig(options);
|
|
215
|
-
this.scanner = new SkillScanner(this.config);
|
|
216
|
-
logger3.info("[SkillComponent] Initialized");
|
|
217
|
-
}
|
|
218
|
-
async registerConfig(options) {
|
|
219
|
-
const configComponent = this.configComponent;
|
|
220
|
-
if (!configComponent)
|
|
221
|
-
return;
|
|
222
|
-
const { configPath, envPrefix, config } = options;
|
|
223
|
-
const prefix = envPrefix ?? "SKILL";
|
|
224
|
-
configComponent.registerComponent(SKILL_CONFIG_REGISTRATION);
|
|
225
|
-
if (configPath) {
|
|
226
|
-
configComponent.registerSource({
|
|
227
|
-
type: "file",
|
|
228
|
-
relativePath: configPath,
|
|
229
|
-
optional: true,
|
|
230
|
-
watch: false
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
configComponent.registerSource({
|
|
234
|
-
type: "env",
|
|
235
|
-
envPrefix: prefix,
|
|
236
|
-
priority: 20,
|
|
237
|
-
watch: false
|
|
238
|
-
});
|
|
239
|
-
await configComponent.load("skill");
|
|
240
|
-
for (const envKey of Object.keys(process.env)) {
|
|
241
|
-
const configKey = envKeyToConfigKey(envKey, prefix, "skill");
|
|
242
|
-
if (!configKey)
|
|
243
|
-
continue;
|
|
244
|
-
const value = process.env[envKey];
|
|
245
|
-
if (value !== undefined) {
|
|
246
|
-
await configComponent.set(configKey, value);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
for (const [key, value] of Object.entries(SKILL_DEFAULTS)) {
|
|
250
|
-
if (configComponent.get(key) === undefined) {
|
|
251
|
-
await configComponent.set(key, value);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
if (config) {
|
|
255
|
-
const flatConfig = this.flattenConfig(config);
|
|
256
|
-
for (const [key, value] of Object.entries(flatConfig)) {
|
|
257
|
-
await configComponent.set(key, value);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
this.registerConfigWatcher(configComponent);
|
|
261
|
-
this.buildConfig(configComponent);
|
|
262
|
-
}
|
|
263
|
-
buildConfig(configComponent) {
|
|
264
|
-
const recursive = configComponent.get("skill.recursive") ?? true;
|
|
265
|
-
const cacheEnabled = configComponent.get("skill.cacheEnabled") ?? true;
|
|
266
|
-
const skillPathsConfig = configComponent.get("skill.skillPaths");
|
|
267
|
-
let skillPaths = [];
|
|
268
|
-
if (Array.isArray(skillPathsConfig)) {
|
|
269
|
-
skillPaths = skillPathsConfig;
|
|
270
|
-
} else if (typeof skillPathsConfig === "string") {
|
|
271
|
-
try {
|
|
272
|
-
skillPaths = JSON.parse(skillPathsConfig);
|
|
273
|
-
} catch {
|
|
274
|
-
skillPaths = DEFAULT_SKILL_CONFIG.skillPaths;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
if (skillPaths.length === 0) {
|
|
278
|
-
skillPaths = DEFAULT_SKILL_CONFIG.skillPaths;
|
|
279
|
-
}
|
|
280
|
-
this.config = {
|
|
281
|
-
skillPaths,
|
|
282
|
-
recursive,
|
|
283
|
-
cacheEnabled
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
flattenConfig(obj, prefix = "skill") {
|
|
287
|
-
const result = {};
|
|
288
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
289
|
-
const fullKey = `${prefix}.${key}`;
|
|
290
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
291
|
-
Object.assign(result, this.flattenConfig(value, fullKey));
|
|
292
|
-
} else {
|
|
293
|
-
result[fullKey] = value;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
return result;
|
|
297
|
-
}
|
|
298
|
-
registerConfigWatcher(configComponent) {
|
|
299
|
-
if (typeof configComponent.watch !== "function") {
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
this.configWatcher = configComponent.watch("skill.*", (event) => {
|
|
303
|
-
this.onConfigChange(event);
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
onConfigChange(event) {
|
|
307
|
-
logger3.info(`[SkillComponent] Config changed: ${event.key}`, {
|
|
308
|
-
oldValue: event.oldValue,
|
|
309
|
-
newValue: event.newValue
|
|
310
|
-
});
|
|
311
|
-
if (this.configComponent) {
|
|
312
|
-
this.buildConfig(this.configComponent);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
async start() {
|
|
316
|
-
await super.start();
|
|
317
|
-
this.toolComponent = this.env?.getComponent("tool");
|
|
318
|
-
if (!this.toolComponent) {
|
|
319
|
-
logger3.warn("[SkillComponent] ToolComponent not found, skipping tool registration");
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
await this.scanSkills();
|
|
323
|
-
await this.registerTool();
|
|
324
|
-
this.setStatus("running");
|
|
325
|
-
logger3.info(`[SkillComponent] Started with ${this.skillsMap.size} skills`);
|
|
326
|
-
}
|
|
327
|
-
async stop() {
|
|
328
|
-
if (this.configWatcher) {
|
|
329
|
-
this.configWatcher();
|
|
330
|
-
this.configWatcher = undefined;
|
|
331
|
-
}
|
|
332
|
-
if (this.toolComponent) {
|
|
333
|
-
this.toolComponent.unregister("skill");
|
|
334
|
-
}
|
|
335
|
-
await super.stop();
|
|
336
|
-
logger3.info("[SkillComponent] Stopped");
|
|
337
|
-
}
|
|
338
|
-
getSkill(name) {
|
|
339
|
-
return this.skillsMap.get(name);
|
|
340
|
-
}
|
|
341
|
-
getSkillList() {
|
|
342
|
-
return Array.from(this.skillsMap.values()).map((entry) => ({
|
|
343
|
-
name: entry.name,
|
|
344
|
-
description: entry.description,
|
|
345
|
-
source: entry.source
|
|
346
|
-
}));
|
|
347
|
-
}
|
|
348
|
-
hasSkill(name) {
|
|
349
|
-
return this.skillsMap.has(name);
|
|
350
|
-
}
|
|
351
|
-
getAllSkills() {
|
|
352
|
-
return Array.from(this.skillsMap.values());
|
|
353
|
-
}
|
|
354
|
-
async scanSkills() {
|
|
355
|
-
this.scanner = new SkillScanner(this.config);
|
|
356
|
-
this.skillsMap = await this.scanner.scan();
|
|
357
|
-
logger3.info(`[SkillComponent] Scanned ${this.skillsMap.size} skills`);
|
|
358
|
-
}
|
|
359
|
-
async reload() {
|
|
360
|
-
if (!this.toolComponent) {
|
|
361
|
-
throw new Error("ToolComponent not available");
|
|
362
|
-
}
|
|
363
|
-
logger3.info("[SkillComponent] Reloading skills...");
|
|
364
|
-
this.toolComponent.unregister("skill");
|
|
365
|
-
await this.scanSkills();
|
|
366
|
-
await this.registerTool();
|
|
367
|
-
logger3.info(`[SkillComponent] Reloaded ${this.skillsMap.size} skills`);
|
|
368
|
-
}
|
|
369
|
-
async registerTool() {
|
|
370
|
-
if (!this.toolComponent)
|
|
371
|
-
return;
|
|
372
|
-
const tool = createSkillTool(() => this.getSkillList(), (name) => this.getSkill(name));
|
|
373
|
-
this.toolComponent.register(tool);
|
|
374
|
-
logger3.info("[SkillComponent] Registered SkillTool");
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
export { parseFrontmatter, parseSkillFile, DEFAULT_SKILL_CONFIG, SOURCE_PRIORITY, getSourcePriority, SkillScanner, SkillComponent };
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createLogger,
|
|
3
|
-
getMaxOutput,
|
|
4
|
-
init_logger,
|
|
5
|
-
simplifyFilePath
|
|
6
|
-
} from "./roy-agent-core-44hnfb02.js";
|
|
7
|
-
import {
|
|
8
|
-
getTracerProvider,
|
|
9
|
-
init_tracer_provider
|
|
10
|
-
} from "./roy-agent-core-xs5rsgat.js";
|
|
11
|
-
import {
|
|
12
|
-
__esm
|
|
13
|
-
} from "./roy-agent-core-fs0mn2jk.js";
|
|
14
|
-
|
|
15
|
-
// src/env/log-trace/decorator.ts
|
|
16
|
-
function Traced(options) {
|
|
17
|
-
return function(target, propertyKey, descriptor) {
|
|
18
|
-
const originalFn = descriptor.value;
|
|
19
|
-
const spanName = options?.name || propertyKey;
|
|
20
|
-
descriptor.value = wrapFunction(originalFn, spanName, {
|
|
21
|
-
recordParams: options?.recordParams ?? true,
|
|
22
|
-
recordResult: options?.recordResult ?? false,
|
|
23
|
-
recordError: options?.recordError ?? true,
|
|
24
|
-
log: options?.log ?? false,
|
|
25
|
-
maxLogSize: options?.maxLogSize,
|
|
26
|
-
paramFilter: options?.paramFilter
|
|
27
|
-
});
|
|
28
|
-
return descriptor;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function TracedAs(name, options) {
|
|
32
|
-
return Traced({ name, ...options });
|
|
33
|
-
}
|
|
34
|
-
function TracedLightweight(options) {
|
|
35
|
-
return Traced({ recordParams: false, recordResult: false, log: options?.log ?? false, maxLogSize: options?.maxLogSize });
|
|
36
|
-
}
|
|
37
|
-
function wrapFunction(fn, name, options) {
|
|
38
|
-
const shouldLog = options?.log ?? false;
|
|
39
|
-
const getMaxLogSize = () => {
|
|
40
|
-
if (options?.maxLogSize !== undefined) {
|
|
41
|
-
return options.maxLogSize;
|
|
42
|
-
}
|
|
43
|
-
const configMaxOutput = getMaxOutput();
|
|
44
|
-
return configMaxOutput !== undefined ? configMaxOutput : 500;
|
|
45
|
-
};
|
|
46
|
-
const truncate = (obj) => {
|
|
47
|
-
if (obj === undefined)
|
|
48
|
-
return;
|
|
49
|
-
if (obj === null)
|
|
50
|
-
return null;
|
|
51
|
-
const maxLogSize = getMaxLogSize();
|
|
52
|
-
let str;
|
|
53
|
-
try {
|
|
54
|
-
str = typeof obj === "string" ? obj : JSON.stringify(obj, null, 0).replace(/\n/g, "");
|
|
55
|
-
} catch (e) {
|
|
56
|
-
str = `[Object with circular reference: ${e instanceof Error ? e.message : String(e)}]`;
|
|
57
|
-
}
|
|
58
|
-
if (maxLogSize > 0 && str.length > maxLogSize) {
|
|
59
|
-
return str.slice(0, maxLogSize) + " [TRUNCATED]";
|
|
60
|
-
}
|
|
61
|
-
try {
|
|
62
|
-
return JSON.parse(str);
|
|
63
|
-
} catch {
|
|
64
|
-
return str;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
const truncateString = (obj) => {
|
|
68
|
-
if (obj === undefined)
|
|
69
|
-
return "undefined";
|
|
70
|
-
if (obj === null)
|
|
71
|
-
return "null";
|
|
72
|
-
const maxLogSize = getMaxLogSize();
|
|
73
|
-
let str;
|
|
74
|
-
try {
|
|
75
|
-
str = typeof obj === "string" ? obj : JSON.stringify(obj, null, 0).replace(/\n/g, "");
|
|
76
|
-
} catch (e) {
|
|
77
|
-
str = `[Object with circular reference: ${e instanceof Error ? e.message : String(e)}]`;
|
|
78
|
-
}
|
|
79
|
-
return maxLogSize > 0 && str.length > maxLogSize ? str.slice(0, maxLogSize) + " [TRUNCATED]" : str;
|
|
80
|
-
};
|
|
81
|
-
const TRACE_LOG_PREFIX = "[TRACE]";
|
|
82
|
-
const getCallerLocation = () => {
|
|
83
|
-
const originalLimit = Error.stackTraceLimit;
|
|
84
|
-
Error.stackTraceLimit = 15;
|
|
85
|
-
const err = new Error;
|
|
86
|
-
Error.captureStackTrace(err, getCallerLocation);
|
|
87
|
-
const stack = err.stack?.split(`
|
|
88
|
-
`) || [];
|
|
89
|
-
Error.stackTraceLimit = originalLimit;
|
|
90
|
-
for (let i = 1;i < stack.length; i++) {
|
|
91
|
-
const line = stack[i];
|
|
92
|
-
if (line.includes("decorator.ts") || line.includes("decorator.js") || line.includes("logFn") || line.includes("getCallerLocation"))
|
|
93
|
-
continue;
|
|
94
|
-
const match = line.match(/at\s+.+\s+\((.+):(\d+):\d+\)/) || line.match(/at\s+(.+):(\d+):\d+/);
|
|
95
|
-
if (match) {
|
|
96
|
-
const filePath = match[1];
|
|
97
|
-
if (!filePath || filePath === "native")
|
|
98
|
-
continue;
|
|
99
|
-
const relativePath = simplifyFilePath(filePath);
|
|
100
|
-
return `${relativePath}:${match[2]}`;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return "";
|
|
104
|
-
};
|
|
105
|
-
const logFn = (event, argsOrData, callerLocation) => {
|
|
106
|
-
if (!shouldLog)
|
|
107
|
-
return;
|
|
108
|
-
const logger = createLogger("traced:" + name);
|
|
109
|
-
const tag = event === "enter" ? ">>>" : event === "quit" ? "<<<" : "!!!";
|
|
110
|
-
const prefix = `${TRACE_LOG_PREFIX} ${tag} ${name}`;
|
|
111
|
-
const originalFnLocation = callerLocation || getCallerLocation();
|
|
112
|
-
const logMessage = (msg, data) => {
|
|
113
|
-
if (data !== undefined) {
|
|
114
|
-
logger.info(`${prefix} ${msg}: ${truncateString(data)}`, { callerLocation: originalFnLocation });
|
|
115
|
-
} else {
|
|
116
|
-
logger.info(`${prefix} ${msg}`, { callerLocation: originalFnLocation });
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
if (event === "enter") {
|
|
120
|
-
logMessage("enter", argsOrData);
|
|
121
|
-
} else if (event === "quit") {
|
|
122
|
-
logMessage("quit", options?.recordResult ? argsOrData : undefined);
|
|
123
|
-
} else {
|
|
124
|
-
logMessage("error", argsOrData);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
return function(...args) {
|
|
128
|
-
const tracer = getTracerProvider().getTracer("roy-tracer");
|
|
129
|
-
const attributes = {};
|
|
130
|
-
if (options?.recordParams !== false) {
|
|
131
|
-
if (options?.paramFilter) {
|
|
132
|
-
attributes["params"] = truncate(options.paramFilter(args));
|
|
133
|
-
} else {
|
|
134
|
-
attributes["params"] = truncate(args);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
const callerLocation = getCallerLocation();
|
|
138
|
-
logFn("enter", args, callerLocation);
|
|
139
|
-
const span = tracer.startSpan(name, { attributes });
|
|
140
|
-
try {
|
|
141
|
-
const result = fn.call(this, ...args);
|
|
142
|
-
if (result && typeof result === "object" && typeof result.then === "function") {
|
|
143
|
-
return result.then((resolved) => {
|
|
144
|
-
span.setAttribute("result", JSON.stringify(truncate(resolved)));
|
|
145
|
-
span.end(resolved);
|
|
146
|
-
logFn("quit", options?.recordResult ? resolved : undefined, callerLocation);
|
|
147
|
-
return resolved;
|
|
148
|
-
}, (rejected) => {
|
|
149
|
-
span.setAttribute("error", String(rejected));
|
|
150
|
-
span.end(undefined, rejected instanceof Error ? rejected : new Error(String(rejected)));
|
|
151
|
-
logFn("error", rejected.message, callerLocation);
|
|
152
|
-
throw rejected;
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
span.setAttribute("result", JSON.stringify(truncate(result)));
|
|
156
|
-
span.end(result);
|
|
157
|
-
logFn("quit", options?.recordResult ? result : undefined, callerLocation);
|
|
158
|
-
return result;
|
|
159
|
-
} catch (error) {
|
|
160
|
-
span.setAttribute("error", String(error));
|
|
161
|
-
span.end(undefined, error instanceof Error ? error : new Error(String(error)));
|
|
162
|
-
logFn("error", error.message, callerLocation);
|
|
163
|
-
throw error;
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
var init_decorator = __esm(() => {
|
|
168
|
-
init_tracer_provider();
|
|
169
|
-
init_logger();
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
export { Traced, TracedAs, TracedLightweight, wrapFunction, init_decorator };
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createLogger,
|
|
3
|
-
init_logger
|
|
4
|
-
} from "./roy-agent-core-44hnfb02.js";
|
|
5
|
-
import {
|
|
6
|
-
__require
|
|
7
|
-
} from "./roy-agent-core-fs0mn2jk.js";
|
|
8
|
-
|
|
9
|
-
// src/env/workflow/storage/sqlite.ts
|
|
10
|
-
init_logger();
|
|
11
|
-
import { join } from "path";
|
|
12
|
-
var logger = createLogger("workflow:sqlite");
|
|
13
|
-
function getDatabaseClass() {
|
|
14
|
-
if (typeof Bun !== "undefined") {
|
|
15
|
-
const { Database } = __require("bun:sqlite");
|
|
16
|
-
return Database;
|
|
17
|
-
} else {
|
|
18
|
-
return __require("better-sqlite3");
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function createCompatibleDatabase(path) {
|
|
22
|
-
const Database = getDatabaseClass();
|
|
23
|
-
const db = new Database(path);
|
|
24
|
-
if (typeof db.run !== "function") {
|
|
25
|
-
db.run = function(sql, ...params) {
|
|
26
|
-
if (params.length > 0) {
|
|
27
|
-
return this.prepare(sql).run(...params);
|
|
28
|
-
} else {
|
|
29
|
-
return this.exec(sql);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return db;
|
|
34
|
-
}
|
|
35
|
-
function getDefaultDataDir() {
|
|
36
|
-
const home = process.env.HOME || process.env.USERPROFILE || "/tmp";
|
|
37
|
-
return join(home, ".local", "share", "roy-agent");
|
|
38
|
-
}
|
|
39
|
-
function getDatabasePath() {
|
|
40
|
-
return join(getDefaultDataDir(), "workflows.db");
|
|
41
|
-
}
|
|
42
|
-
var dbInstance = null;
|
|
43
|
-
function getDatabase(path) {
|
|
44
|
-
if (!dbInstance) {
|
|
45
|
-
const dbPath = path ?? getDatabasePath();
|
|
46
|
-
const dbDir = dbPath.substring(0, dbPath.lastIndexOf("/"));
|
|
47
|
-
if (dbDir && dbDir !== "/") {
|
|
48
|
-
try {
|
|
49
|
-
const { mkdirSync } = __require("fs");
|
|
50
|
-
mkdirSync(dbDir, { recursive: true });
|
|
51
|
-
} catch {}
|
|
52
|
-
}
|
|
53
|
-
dbInstance = createCompatibleDatabase(dbPath);
|
|
54
|
-
try {
|
|
55
|
-
if (typeof dbInstance.pragma === "function") {
|
|
56
|
-
dbInstance.pragma("journal_mode = WAL");
|
|
57
|
-
}
|
|
58
|
-
} catch {
|
|
59
|
-
logger?.debug("WAL mode not available, using default journal mode");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return dbInstance;
|
|
63
|
-
}
|
|
64
|
-
function closeDatabase() {
|
|
65
|
-
if (dbInstance) {
|
|
66
|
-
dbInstance.close();
|
|
67
|
-
dbInstance = null;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function initializeTables() {
|
|
71
|
-
const db = getDatabase();
|
|
72
|
-
db.exec(`
|
|
73
|
-
CREATE TABLE IF NOT EXISTS workflows (
|
|
74
|
-
id TEXT PRIMARY KEY,
|
|
75
|
-
name TEXT NOT NULL UNIQUE,
|
|
76
|
-
version TEXT NOT NULL DEFAULT '1.0',
|
|
77
|
-
description TEXT,
|
|
78
|
-
definition TEXT NOT NULL,
|
|
79
|
-
config TEXT NOT NULL DEFAULT '{}',
|
|
80
|
-
metadata TEXT NOT NULL DEFAULT '{}',
|
|
81
|
-
tags TEXT NOT NULL DEFAULT '[]',
|
|
82
|
-
task_id INTEGER,
|
|
83
|
-
created_at TEXT NOT NULL,
|
|
84
|
-
updated_at TEXT NOT NULL
|
|
85
|
-
)
|
|
86
|
-
`);
|
|
87
|
-
db.exec(`
|
|
88
|
-
CREATE INDEX IF NOT EXISTS idx_workflows_name ON workflows(name);
|
|
89
|
-
CREATE INDEX IF NOT EXISTS idx_workflows_tags ON workflows(tags);
|
|
90
|
-
CREATE INDEX IF NOT EXISTS idx_workflows_task_id ON workflows(task_id);
|
|
91
|
-
`);
|
|
92
|
-
}
|
|
93
|
-
function resetDatabase() {
|
|
94
|
-
closeDatabase();
|
|
95
|
-
dbInstance = null;
|
|
96
|
-
}
|
|
97
|
-
function initDatabase(path) {
|
|
98
|
-
const db = getDatabase(path);
|
|
99
|
-
initializeTables();
|
|
100
|
-
return db;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export { getDatabasePath, getDatabase, closeDatabase, initializeTables, resetDatabase, initDatabase };
|