@ai-setting/roy-agent-core 1.4.12 → 1.4.14

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 (127) hide show
  1. package/dist/packages/core/src/config/index.js +32 -0
  2. package/dist/packages/core/src/env/agent/index.js +24 -0
  3. package/dist/packages/core/src/env/commands/index.js +14 -0
  4. package/dist/packages/core/src/env/debug/formatters/index.js +11 -0
  5. package/dist/packages/core/src/env/debug/index.js +26 -0
  6. package/dist/packages/core/src/env/hook/index.js +29 -0
  7. package/dist/packages/core/src/env/index.js +81 -0
  8. package/dist/packages/core/src/env/llm/index.js +40 -0
  9. package/dist/packages/core/src/env/log-trace/index.js +83 -0
  10. package/dist/packages/core/src/env/mcp/index.js +39 -0
  11. package/dist/packages/core/src/env/mcp/tool/index.js +14 -0
  12. package/dist/packages/core/src/env/memory/built-in/index.js +11 -0
  13. package/dist/packages/core/src/env/memory/index.js +56 -0
  14. package/dist/packages/core/src/env/memory/plugin/index.js +36 -0
  15. package/dist/packages/core/src/env/prompt/index.js +20 -0
  16. package/dist/packages/core/src/env/session/index.js +25 -0
  17. package/dist/packages/core/src/env/session/storage/index.js +18 -0
  18. package/dist/packages/core/src/env/skill/index.js +34 -0
  19. package/dist/packages/core/src/env/skill/tool/index.js +9 -0
  20. package/dist/packages/core/src/env/task/delegate/index.js +18 -0
  21. package/dist/packages/core/src/env/task/hooks/index.js +7 -0
  22. package/dist/packages/core/src/env/task/index.js +30 -0
  23. package/dist/packages/core/src/env/task/plugins/index.js +23 -0
  24. package/dist/packages/core/src/env/task/storage/index.js +14 -0
  25. package/dist/packages/core/src/env/task/tools/index.js +17 -0
  26. package/dist/packages/core/src/env/task/tools/operation/index.js +15 -0
  27. package/dist/packages/core/src/env/tool/built-in/index.js +25 -0
  28. package/dist/packages/core/src/env/tool/index.js +39 -0
  29. package/dist/packages/core/src/env/workflow/decorators/index.js +27 -0
  30. package/dist/packages/core/src/env/workflow/engine/index.js +28 -0
  31. package/dist/packages/core/src/env/workflow/index.js +132 -0
  32. package/dist/packages/core/src/env/workflow/nodes/index.js +19 -0
  33. package/dist/packages/core/src/env/workflow/service/index.js +13 -0
  34. package/dist/packages/core/src/env/workflow/storage/index.js +27 -0
  35. package/dist/packages/core/src/env/workflow/tools/index.js +159 -0
  36. package/dist/packages/core/src/env/workflow/types/index.js +94 -0
  37. package/dist/packages/core/src/env/workflow/utils/index.js +637 -0
  38. package/dist/packages/core/src/index.js +398 -0
  39. package/dist/shared/@ai-setting/roy-agent-core-04fm8177.js +393 -0
  40. package/dist/shared/@ai-setting/roy-agent-core-04qgbjbe.js +172 -0
  41. package/dist/shared/@ai-setting/roy-agent-core-084qqd7t.js +11 -0
  42. package/dist/shared/@ai-setting/roy-agent-core-0gekht4e.js +1130 -0
  43. package/dist/shared/@ai-setting/roy-agent-core-0hdry23r.js +419 -0
  44. package/dist/shared/@ai-setting/roy-agent-core-0sgn3de4.js +102 -0
  45. package/dist/{env/task/tools/index.js → shared/@ai-setting/roy-agent-core-12x57kf1.js} +1 -59
  46. package/dist/shared/@ai-setting/roy-agent-core-1f3xrrm6.js +393 -0
  47. package/dist/shared/@ai-setting/roy-agent-core-1k28kg7h.js +368 -0
  48. package/dist/shared/@ai-setting/roy-agent-core-1z1zv5g8.js +258 -0
  49. package/dist/shared/@ai-setting/roy-agent-core-2hqxnaf3.js +851 -0
  50. package/dist/shared/@ai-setting/roy-agent-core-3dfq8awb.js +587 -0
  51. package/dist/shared/@ai-setting/roy-agent-core-3takar0s.js +93 -0
  52. package/dist/shared/@ai-setting/roy-agent-core-3tnb2005.js +117 -0
  53. package/dist/shared/@ai-setting/roy-agent-core-4vmcvkav.js +14 -0
  54. package/dist/shared/@ai-setting/roy-agent-core-4ws8atva.js +107 -0
  55. package/dist/{env/workflow/nodes/index.js → shared/@ai-setting/roy-agent-core-5fbp24se.js} +8 -55
  56. package/dist/shared/@ai-setting/roy-agent-core-5my94ywp.js +66 -0
  57. package/dist/shared/@ai-setting/roy-agent-core-6j0zcmwk.js +2146 -0
  58. package/dist/shared/@ai-setting/roy-agent-core-6w4pmxc7.js +266 -0
  59. package/dist/shared/@ai-setting/roy-agent-core-7vrk3add.js +10 -0
  60. package/dist/shared/@ai-setting/roy-agent-core-8dvbn7tw.js +64 -0
  61. package/dist/{env/memory/built-in/index.js → shared/@ai-setting/roy-agent-core-8mbmrwzs.js} +22 -76
  62. package/dist/shared/@ai-setting/roy-agent-core-8wzz66qe.js +620 -0
  63. package/dist/shared/@ai-setting/roy-agent-core-9ykq91jc.js +762 -0
  64. package/dist/shared/@ai-setting/roy-agent-core-dde19zke.js +1305 -0
  65. package/dist/shared/@ai-setting/roy-agent-core-f7g67gce.js +913 -0
  66. package/dist/{env/workflow/types/index.js → shared/@ai-setting/roy-agent-core-fq5mtxsy.js} +16 -154
  67. package/dist/{env/task/hooks/index.js → shared/@ai-setting/roy-agent-core-fs0mn2jk.js} +3 -18
  68. package/dist/{config/index.js → shared/@ai-setting/roy-agent-core-fvd9g6k8.js} +140 -605
  69. package/dist/shared/@ai-setting/roy-agent-core-gv1hrn3x.js +378 -0
  70. package/dist/{env/task/tools/operation/index.js → shared/@ai-setting/roy-agent-core-gy0wp5h7.js} +1 -58
  71. package/dist/shared/@ai-setting/roy-agent-core-hyza1gm7.js +15 -0
  72. package/dist/shared/@ai-setting/roy-agent-core-j8zx62zr.js +154 -0
  73. package/dist/shared/@ai-setting/roy-agent-core-jb2exr0d.js +442 -0
  74. package/dist/shared/@ai-setting/roy-agent-core-jv3b7v9w.js +57 -0
  75. package/dist/shared/@ai-setting/roy-agent-core-k1rxf9ya.js +513 -0
  76. package/dist/shared/@ai-setting/roy-agent-core-kydc9nwb.js +60 -0
  77. package/dist/shared/@ai-setting/roy-agent-core-m2x48hw6.js +97 -0
  78. package/dist/shared/@ai-setting/roy-agent-core-m6y668cc.js +377 -0
  79. package/dist/shared/@ai-setting/roy-agent-core-nczzf0ms.js +15 -0
  80. package/dist/shared/@ai-setting/roy-agent-core-nfj6knp5.js +36 -0
  81. package/dist/shared/@ai-setting/roy-agent-core-ntrp979d.js +204 -0
  82. package/dist/shared/@ai-setting/roy-agent-core-pd7g8z5v.js +1387 -0
  83. package/dist/shared/@ai-setting/roy-agent-core-pzk1syce.js +14 -0
  84. package/dist/shared/@ai-setting/roy-agent-core-q50tg9m2.js +862 -0
  85. package/dist/shared/@ai-setting/roy-agent-core-qg9tcaph.js +11 -0
  86. package/dist/shared/@ai-setting/roy-agent-core-qhyerewk.js +20 -0
  87. package/dist/shared/@ai-setting/roy-agent-core-qxybm159.js +82 -0
  88. package/dist/shared/@ai-setting/roy-agent-core-rh9dpkpw.js +549 -0
  89. package/dist/shared/@ai-setting/roy-agent-core-rr9p1g43.js +205 -0
  90. package/dist/{env/workflow/decorators/index.js → shared/@ai-setting/roy-agent-core-sbzvpfn7.js} +8 -173
  91. package/dist/shared/@ai-setting/roy-agent-core-t22nqt4d.js +788 -0
  92. package/dist/shared/@ai-setting/roy-agent-core-tkr5ynkh.js +200 -0
  93. package/dist/shared/@ai-setting/roy-agent-core-v4aabsf0.js +303 -0
  94. package/dist/{env/hook/index.js → shared/@ai-setting/roy-agent-core-w75rafhy.js} +3 -74
  95. package/dist/{env/debug/formatters/index.js → shared/@ai-setting/roy-agent-core-w76hqkmg.js} +11 -66
  96. package/dist/shared/@ai-setting/roy-agent-core-yfbgwes2.js +408 -0
  97. package/dist/shared/@ai-setting/roy-agent-core-yn761yve.js +299 -0
  98. package/dist/shared/@ai-setting/roy-agent-core-yrzmn4m1.js +492 -0
  99. package/dist/{env/workflow/service/index.js → shared/@ai-setting/roy-agent-core-yt8wdh2w.js} +1 -57
  100. package/package.json +3 -2
  101. package/dist/env/agent/index.js +0 -3035
  102. package/dist/env/commands/index.js +0 -1685
  103. package/dist/env/debug/index.js +0 -2300
  104. package/dist/env/index.js +0 -12591
  105. package/dist/env/llm/index.js +0 -2736
  106. package/dist/env/log-trace/index.js +0 -1779
  107. package/dist/env/mcp/index.js +0 -2173
  108. package/dist/env/mcp/tool/index.js +0 -1149
  109. package/dist/env/memory/index.js +0 -2171
  110. package/dist/env/memory/plugin/index.js +0 -1263
  111. package/dist/env/prompt/index.js +0 -2107
  112. package/dist/env/session/index.js +0 -3594
  113. package/dist/env/session/storage/index.js +0 -2049
  114. package/dist/env/skill/index.js +0 -1635
  115. package/dist/env/skill/tool/index.js +0 -114
  116. package/dist/env/task/delegate/index.js +0 -1844
  117. package/dist/env/task/index.js +0 -3578
  118. package/dist/env/task/plugins/index.js +0 -1626
  119. package/dist/env/task/storage/index.js +0 -1464
  120. package/dist/env/tool/built-in/index.js +0 -1151
  121. package/dist/env/tool/index.js +0 -2284
  122. package/dist/env/workflow/engine/index.js +0 -4391
  123. package/dist/env/workflow/index.js +0 -6214
  124. package/dist/env/workflow/storage/index.js +0 -1236
  125. package/dist/env/workflow/tools/index.js +0 -1081
  126. package/dist/env/workflow/utils/index.js +0 -1631
  127. package/dist/index.js +0 -22778
@@ -0,0 +1,377 @@
1
+ import {
2
+ createSkillTool
3
+ } from "./roy-agent-core-kydc9nwb.js";
4
+ import {
5
+ envKeyToConfigKey
6
+ } from "./roy-agent-core-jv3b7v9w.js";
7
+ import {
8
+ BaseComponent
9
+ } from "./roy-agent-core-m2x48hw6.js";
10
+ import {
11
+ createLogger,
12
+ init_logger
13
+ } from "./roy-agent-core-yn761yve.js";
14
+
15
+ // packages/core/src/env/skill/skill-component.ts
16
+ init_logger();
17
+
18
+ // packages/core/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
+ // packages/core/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
+ // packages/core/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
+ // packages/core/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
+ // packages/core/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
+ // packages/core/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 };
@@ -0,0 +1,15 @@
1
+ import {
2
+ OTelTracerProvider,
3
+ getTracerProvider,
4
+ init_tracer_provider,
5
+ resetTracerProvider
6
+ } from "./roy-agent-core-1k28kg7h.js";
7
+ import"./roy-agent-core-j8zx62zr.js";
8
+ import"./roy-agent-core-fs0mn2jk.js";
9
+ init_tracer_provider();
10
+
11
+ export {
12
+ resetTracerProvider,
13
+ getTracerProvider,
14
+ OTelTracerProvider
15
+ };
@@ -0,0 +1,36 @@
1
+ import {
2
+ AskUserError,
3
+ init_workflow_hil
4
+ } from "./roy-agent-core-8dvbn7tw.js";
5
+
6
+ // packages/core/src/env/workflow/tools/ask-user-tool.ts
7
+ init_workflow_hil();
8
+ import { z } from "zod";
9
+ var AskUserInputSchema = z.object({
10
+ query: z.string().describe("The question or request to ask the user"),
11
+ options: z.array(z.string()).optional().describe("Optional choices for the user"),
12
+ required_confirm: z.boolean().optional().describe("If true, user must explicitly confirm")
13
+ });
14
+ var askUserTool = {
15
+ name: "ask_user",
16
+ description: "Ask user for input or confirmation. Use this tool when you need user input or validation to continue the workflow.",
17
+ parameters: AskUserInputSchema,
18
+ async execute(args, context) {
19
+ const runId = context.metadata?.runId || "unknown";
20
+ const sessionId = context.metadata?.sessionId || `workflow_${runId}`;
21
+ const nodeId = context.metadata?.nodeId || "unknown";
22
+ let fullQuery = args.query;
23
+ if (args.options && args.options.length > 0) {
24
+ fullQuery = `${args.query} (选项: ${args.options.join(", ")})`;
25
+ }
26
+ throw new AskUserError(runId, sessionId, nodeId, "agent", fullQuery);
27
+ },
28
+ metadata: {
29
+ category: "workflow",
30
+ tags: ["human-in-loop", "user-input"],
31
+ version: "1.0.0"
32
+ }
33
+ };
34
+ var askUserToolInstance = askUserTool;
35
+
36
+ export { AskUserInputSchema, askUserTool, askUserToolInstance };
@@ -0,0 +1,204 @@
1
+ import {
2
+ TracedAs,
3
+ init_decorator
4
+ } from "./roy-agent-core-04qgbjbe.js";
5
+ import {
6
+ __legacyDecorateClassTS
7
+ } from "./roy-agent-core-fs0mn2jk.js";
8
+
9
+ // packages/core/src/env/session/session-message-converter.ts
10
+ init_decorator();
11
+ import { randomUUID } from "crypto";
12
+ var DEFAULT_REASONING_BUDGET_TOKENS = 1e4;
13
+
14
+ class SessionMessageConverter {
15
+ toModelMessage(msg) {
16
+ if (msg.role === "assistant") {
17
+ const content = [];
18
+ for (const part of msg.parts || []) {
19
+ if (part.type === "text") {
20
+ const textPart = part;
21
+ content.push({
22
+ type: "text",
23
+ text: textPart.content,
24
+ ...textPart.synthetic !== undefined && { synthetic: textPart.synthetic }
25
+ });
26
+ } else if (part.type === "reasoning") {
27
+ const reasoningPart = part;
28
+ content.push({
29
+ type: "reasoning",
30
+ text: reasoningPart.content,
31
+ reasoningType: reasoningPart.reasoningType
32
+ });
33
+ } else if (part.type === "tool-call") {
34
+ const toolPart = part;
35
+ let parsedArgs = {};
36
+ if (typeof toolPart.arguments === "string") {
37
+ try {
38
+ parsedArgs = JSON.parse(toolPart.arguments);
39
+ } catch {
40
+ parsedArgs = { _raw: toolPart.arguments };
41
+ }
42
+ } else {
43
+ parsedArgs = toolPart.arguments;
44
+ }
45
+ content.push({
46
+ type: "tool-call",
47
+ toolCallId: toolPart.toolCallId,
48
+ toolName: toolPart.toolName,
49
+ input: parsedArgs
50
+ });
51
+ } else if (part.type === "file") {
52
+ const filePart = part;
53
+ content.push({
54
+ type: "file",
55
+ url: filePart.url,
56
+ mimeType: filePart.mime,
57
+ filename: filePart.filename
58
+ });
59
+ } else if (part.type === "tool-result" || part.type === "checkpoint") {} else {
60
+ console.debug(`[session-message-converter] Skipping unsupported part type in assistant: ${part.type}`);
61
+ }
62
+ }
63
+ if (content.length === 0 && msg.content) {
64
+ return { role: "assistant", content: msg.content };
65
+ }
66
+ return { role: "assistant", content };
67
+ }
68
+ if (msg.role === "tool") {
69
+ const toolPart = msg.parts?.find((p) => p.type === "tool-result");
70
+ return {
71
+ role: "tool",
72
+ content: [{
73
+ type: "tool-result",
74
+ toolCallId: toolPart?.toolCallId || "",
75
+ toolName: toolPart?.toolName || "",
76
+ output: toolPart?.output || msg.content || ""
77
+ }]
78
+ };
79
+ }
80
+ return {
81
+ role: msg.role,
82
+ content: msg.content || ""
83
+ };
84
+ }
85
+ fromModelMessage(aiMsg, options) {
86
+ const parts = [];
87
+ const content = typeof aiMsg.content === "string" || Array.isArray(aiMsg.content) ? aiMsg.content : "";
88
+ let hasToolCallPart = false;
89
+ let hasToolResultPart = false;
90
+ if (typeof content === "string") {
91
+ parts.push({ type: "text", content });
92
+ } else if (Array.isArray(content)) {
93
+ for (const part of content) {
94
+ const p = part;
95
+ if (p.type === "text") {
96
+ parts.push({ type: "text", content: p.text || "" });
97
+ } else if (p.type === "reasoning") {
98
+ parts.push({
99
+ type: "reasoning",
100
+ content: p.text || "",
101
+ reasoningType: p.reasoningType,
102
+ state: "completed"
103
+ });
104
+ } else if (p.type === "tool-call") {
105
+ hasToolCallPart = true;
106
+ parts.push({
107
+ type: "tool-call",
108
+ toolCallId: p.toolCallId,
109
+ toolName: p.toolName,
110
+ arguments: p.input,
111
+ state: "pending"
112
+ });
113
+ } else if (p.type === "tool-result") {
114
+ hasToolResultPart = true;
115
+ parts.push({
116
+ type: "tool-result",
117
+ toolCallId: p.toolCallId,
118
+ toolName: p.toolName,
119
+ output: typeof p.output === "string" ? p.output : JSON.stringify(p.output),
120
+ state: "completed"
121
+ });
122
+ } else if (p.type === "file") {
123
+ parts.push({
124
+ type: "file",
125
+ mime: p.mimeType || "application/octet-stream",
126
+ url: p.url,
127
+ filename: p.filename
128
+ });
129
+ } else {
130
+ console.debug(`[session-message-converter] Unknown part type: ${p.type}`);
131
+ }
132
+ }
133
+ }
134
+ let metadataType;
135
+ if (aiMsg.role === "assistant" && hasToolCallPart) {
136
+ metadataType = "tool_call";
137
+ } else if (aiMsg.role === "tool") {
138
+ metadataType = "tool_result";
139
+ }
140
+ const result = {
141
+ id: options?.messageID || `msg_${randomUUID()}`,
142
+ sessionID: options?.sessionID || "",
143
+ role: aiMsg.role,
144
+ timestamp: Date.now(),
145
+ parts,
146
+ content: typeof content === "string" ? content : ""
147
+ };
148
+ if (metadataType) {
149
+ result.metadata = { type: metadataType };
150
+ }
151
+ return result;
152
+ }
153
+ sessionToHistory(messages) {
154
+ return messages.filter((msg) => !msg.metadata?.isArchived && !msg.isArchived).map((msg) => this.toModelMessage(msg));
155
+ }
156
+ extractProviderOptions(msg) {
157
+ const options = {};
158
+ const reasoningParts = msg.parts?.filter((p) => p.type === "reasoning");
159
+ if (reasoningParts && reasoningParts.length > 0) {
160
+ const firstReasoning = reasoningParts[0];
161
+ if (firstReasoning.reasoningType) {
162
+ options.openai = {
163
+ thinking: {
164
+ type: firstReasoning.reasoningType === "effort" ? "extended" : "core"
165
+ }
166
+ };
167
+ if (firstReasoning.reasoningType === "effort") {
168
+ const budgetTokens = firstReasoning.metadata?.tokenCount || DEFAULT_REASONING_BUDGET_TOKENS;
169
+ options.anthropic = {
170
+ thinking: {
171
+ type: "enabled",
172
+ budgetTokens
173
+ }
174
+ };
175
+ }
176
+ }
177
+ }
178
+ return options;
179
+ }
180
+ migrateMessage(oldMsg) {
181
+ if (oldMsg.parts && oldMsg.parts.length > 0) {
182
+ const firstPart = oldMsg.parts[0];
183
+ if (firstPart && typeof firstPart.type === "string" && firstPart.type.length > 0) {
184
+ return {
185
+ ...oldMsg,
186
+ content: oldMsg.content || ""
187
+ };
188
+ }
189
+ }
190
+ return {
191
+ ...oldMsg,
192
+ content: oldMsg.content || "",
193
+ parts: oldMsg.content ? [{ type: "text", content: oldMsg.content }] : []
194
+ };
195
+ }
196
+ }
197
+ __legacyDecorateClassTS([
198
+ TracedAs("session-message-converter.toModelMessage", { recordParams: true, recordResult: true, log: true })
199
+ ], SessionMessageConverter.prototype, "toModelMessage", null);
200
+ __legacyDecorateClassTS([
201
+ TracedAs("session-message-converter.fromModelMessage", { recordParams: true, recordResult: true, log: true })
202
+ ], SessionMessageConverter.prototype, "fromModelMessage", null);
203
+
204
+ export { SessionMessageConverter };