@ai-setting/roy-agent-core 1.5.15-test → 1.5.17-beta.1
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.d.ts +1250 -0
- package/dist/config/index.js +32 -0
- package/dist/env/agent/index.d.ts +2279 -0
- package/dist/env/agent/index.js +24 -0
- package/dist/env/commands/index.d.ts +1131 -0
- package/dist/env/commands/index.js +14 -0
- package/dist/env/debug/formatters/index.d.ts +236 -0
- package/dist/env/debug/formatters/index.js +11 -0
- package/dist/env/debug/index.d.ts +1652 -0
- package/dist/env/debug/index.js +26 -0
- package/dist/env/hook/index.d.ts +279 -0
- package/dist/env/hook/index.js +29 -0
- package/dist/env/index.d.ts +3481 -0
- package/dist/env/index.js +82 -0
- package/dist/env/llm/index.d.ts +1760 -0
- package/dist/env/llm/index.js +40 -0
- package/dist/env/log-trace/index.d.ts +1574 -0
- package/dist/env/log-trace/index.js +83 -0
- package/dist/env/mcp/index.d.ts +1331 -0
- package/dist/env/mcp/index.js +39 -0
- package/dist/env/mcp/tool/index.d.ts +183 -0
- package/dist/env/mcp/tool/index.js +14 -0
- package/dist/env/memory/built-in/index.d.ts +232 -0
- package/dist/env/memory/built-in/index.js +11 -0
- package/dist/env/memory/index.d.ts +1799 -0
- package/dist/env/memory/index.js +56 -0
- package/dist/env/memory/plugin/index.d.ts +747 -0
- package/dist/env/memory/plugin/index.js +36 -0
- package/dist/env/prompt/index.d.ts +1164 -0
- package/dist/env/prompt/index.js +20 -0
- package/dist/env/session/index.d.ts +1908 -0
- package/dist/env/session/index.js +25 -0
- package/dist/env/session/storage/index.d.ts +564 -0
- package/dist/env/session/storage/index.js +18 -0
- package/dist/env/skill/index.d.ts +1266 -0
- package/dist/env/skill/index.js +34 -0
- package/dist/env/skill/tool/index.d.ts +193 -0
- package/dist/env/skill/tool/index.js +9 -0
- package/dist/env/task/delegate/index.d.ts +1612 -0
- package/dist/env/task/delegate/index.js +18 -0
- package/dist/env/task/events/index.d.ts +171 -0
- package/dist/env/task/events/index.js +7 -0
- package/dist/env/task/hooks/index.d.ts +624 -0
- package/dist/env/task/hooks/index.js +7 -0
- package/dist/env/task/index.d.ts +1553 -0
- package/dist/env/task/index.js +34 -0
- package/dist/env/task/plugins/index.d.ts +466 -0
- package/dist/env/task/plugins/index.js +23 -0
- package/dist/env/task/storage/index.d.ts +241 -0
- package/dist/env/task/storage/index.js +14 -0
- package/dist/env/task/tools/index.d.ts +1485 -0
- package/dist/env/task/tools/index.js +17 -0
- package/dist/env/task/tools/operation/index.d.ts +1484 -0
- package/dist/env/task/tools/operation/index.js +15 -0
- package/dist/env/tool/built-in/index.d.ts +218 -0
- package/dist/env/tool/built-in/index.js +25 -0
- package/dist/env/tool/index.d.ts +1396 -0
- package/dist/env/tool/index.js +39 -0
- package/dist/env/workflow/decorators/index.d.ts +2161 -0
- package/dist/env/workflow/decorators/index.js +27 -0
- package/dist/env/workflow/engine/index.d.ts +3453 -0
- package/dist/env/workflow/engine/index.js +28 -0
- package/dist/env/workflow/index.d.ts +3546 -0
- package/dist/env/workflow/index.js +136 -0
- package/dist/env/workflow/nodes/index.d.ts +2092 -0
- package/dist/env/workflow/nodes/index.js +19 -0
- package/dist/env/workflow/service/index.d.ts +227 -0
- package/dist/env/workflow/service/index.js +13 -0
- package/dist/env/workflow/storage/index.d.ts +165 -0
- package/dist/env/workflow/storage/index.js +27 -0
- package/dist/env/workflow/tools/index.d.ts +416 -0
- package/dist/env/workflow/tools/index.js +159 -0
- package/dist/env/workflow/types/index.d.ts +2255 -0
- package/dist/env/workflow/types/index.js +98 -0
- package/dist/env/workflow/utils/index.d.ts +2031 -0
- package/dist/env/workflow/utils/index.js +637 -0
- package/dist/index.d.ts +7858 -0
- package/dist/index.js +399 -0
- package/dist/shared/@ai-setting/roy-agent-core-0rtxwr28.js +258 -0
- package/dist/shared/@ai-setting/roy-agent-core-0vbdz0x7.js +36 -0
- package/dist/shared/@ai-setting/roy-agent-core-1akcqxj9.js +349 -0
- package/dist/shared/@ai-setting/roy-agent-core-1ce3fqrk.js +117 -0
- package/dist/shared/@ai-setting/roy-agent-core-2dhd60aw.js +11 -0
- package/dist/shared/@ai-setting/roy-agent-core-3jywqmdd.js +393 -0
- package/dist/shared/@ai-setting/roy-agent-core-3rr5k71j.js +200 -0
- package/dist/shared/@ai-setting/roy-agent-core-44hnfb02.js +299 -0
- package/dist/shared/@ai-setting/roy-agent-core-4t40mkpv.js +206 -0
- package/dist/shared/@ai-setting/roy-agent-core-4txzpsbt.js +393 -0
- package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +350 -0
- package/dist/shared/@ai-setting/roy-agent-core-69jskqjg.js +180 -0
- package/dist/shared/@ai-setting/roy-agent-core-6kvtahqv.js +408 -0
- package/dist/shared/@ai-setting/roy-agent-core-7fgf85wc.js +284 -0
- package/dist/shared/@ai-setting/roy-agent-core-81w1963m.js +762 -0
- package/dist/shared/@ai-setting/roy-agent-core-8gxth0eh.js +10 -0
- package/dist/shared/@ai-setting/roy-agent-core-92z6t4he.js +14 -0
- package/dist/shared/@ai-setting/roy-agent-core-93zfb3r1.js +922 -0
- package/dist/shared/@ai-setting/roy-agent-core-9yxb3ty9.js +15 -0
- package/dist/shared/@ai-setting/roy-agent-core-b0x5dda6.js +1130 -0
- package/dist/shared/@ai-setting/roy-agent-core-bcbqy27c.js +14 -0
- package/dist/shared/@ai-setting/roy-agent-core-bvr1761x.js +653 -0
- package/dist/shared/@ai-setting/roy-agent-core-ctdhjv68.js +93 -0
- package/dist/shared/@ai-setting/roy-agent-core-d7cyjkf7.js +872 -0
- package/dist/shared/@ai-setting/roy-agent-core-dh9d7a3m.js +11 -0
- package/dist/shared/@ai-setting/roy-agent-core-e25xkv53.js +64 -0
- package/dist/shared/@ai-setting/roy-agent-core-eajcvp4e.js +378 -0
- package/dist/shared/@ai-setting/roy-agent-core-f7q2x5z6.js +492 -0
- package/dist/shared/@ai-setting/roy-agent-core-fs0mn2jk.js +52 -0
- package/dist/shared/@ai-setting/roy-agent-core-g1s2h0e5.js +171 -0
- package/dist/shared/@ai-setting/roy-agent-core-g99pxzn5.js +862 -0
- package/dist/shared/@ai-setting/roy-agent-core-gbqcyegm.js +1387 -0
- package/dist/shared/@ai-setting/roy-agent-core-gjq1yk68.js +208 -0
- package/dist/shared/@ai-setting/roy-agent-core-gq20wsgv.js +139 -0
- package/dist/shared/@ai-setting/roy-agent-core-gwc4h96n.js +534 -0
- package/dist/shared/@ai-setting/roy-agent-core-jfh9q2qh.js +204 -0
- package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +603 -0
- package/dist/shared/@ai-setting/roy-agent-core-kkbwepqb.js +97 -0
- package/dist/shared/@ai-setting/roy-agent-core-pjr12nnd.js +587 -0
- package/dist/shared/@ai-setting/roy-agent-core-psv4v63c.js +176 -0
- package/dist/shared/@ai-setting/roy-agent-core-psvxt4c9.js +60 -0
- package/dist/shared/@ai-setting/roy-agent-core-qqceba6k.js +442 -0
- package/dist/shared/@ai-setting/roy-agent-core-qxhq8ven.js +57 -0
- package/dist/shared/@ai-setting/roy-agent-core-qxnbvgwe.js +66 -0
- package/dist/shared/@ai-setting/roy-agent-core-r9ezzemr.js +10 -0
- package/dist/shared/@ai-setting/roy-agent-core-rhmtwnw1.js +267 -0
- package/dist/shared/@ai-setting/roy-agent-core-rvv6ydff.js +584 -0
- package/dist/shared/@ai-setting/roy-agent-core-rvxg1wps.js +102 -0
- package/dist/shared/@ai-setting/roy-agent-core-satmq6sh.js +549 -0
- package/dist/shared/@ai-setting/roy-agent-core-sx7wsvnn.js +15 -0
- package/dist/shared/@ai-setting/roy-agent-core-t94ktchq.js +213 -0
- package/dist/shared/@ai-setting/roy-agent-core-vf215qfv.js +812 -0
- package/dist/shared/@ai-setting/roy-agent-core-vkz81f7v.js +1316 -0
- package/dist/shared/@ai-setting/roy-agent-core-vn2bc59q.js +1205 -0
- package/dist/shared/@ai-setting/roy-agent-core-wa1kzqky.js +328 -0
- package/dist/shared/@ai-setting/roy-agent-core-wft9ra24.js +20 -0
- package/dist/shared/@ai-setting/roy-agent-core-wrcy0h6z.js +2098 -0
- package/dist/shared/@ai-setting/roy-agent-core-xq8hhqb8.js +419 -0
- package/dist/shared/@ai-setting/roy-agent-core-xs5rsgat.js +368 -0
- package/dist/shared/@ai-setting/roy-agent-core-zbkpc41z.js +377 -0
- package/dist/shared/@ai-setting/roy-agent-core-zgypchmt.js +172 -0
- package/dist/shared/@ai-setting/roy-agent-core-zpn0bqa8.js +103 -0
- package/package.json +29 -8
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// src/config/env-key.ts
|
|
2
|
+
function toEnvKey(key, prefix) {
|
|
3
|
+
let keyNormalized = key.replace(/[.-]/g, "_");
|
|
4
|
+
keyNormalized = keyNormalized.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/_+/g, "_").toUpperCase();
|
|
5
|
+
if (prefix) {
|
|
6
|
+
const separator = prefix.endsWith("_") ? "" : "_";
|
|
7
|
+
return `${prefix}${separator}${keyNormalized}`;
|
|
8
|
+
}
|
|
9
|
+
return keyNormalized;
|
|
10
|
+
}
|
|
11
|
+
function fromEnvKey(envKey, prefix) {
|
|
12
|
+
if (!prefix) {
|
|
13
|
+
return envKey;
|
|
14
|
+
}
|
|
15
|
+
if (envKey.startsWith(prefix)) {
|
|
16
|
+
const afterPrefix = envKey.slice(prefix.length);
|
|
17
|
+
if (afterPrefix.startsWith("_")) {
|
|
18
|
+
return afterPrefix.slice(1);
|
|
19
|
+
}
|
|
20
|
+
return afterPrefix;
|
|
21
|
+
}
|
|
22
|
+
return envKey;
|
|
23
|
+
}
|
|
24
|
+
function envKeyToConfigKey(envKey, prefix, componentName) {
|
|
25
|
+
const prefixUpper = prefix.toUpperCase();
|
|
26
|
+
if (!envKey.startsWith(prefixUpper)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const componentUpperNormalized = componentName.replace(/-/g, "_").toUpperCase();
|
|
30
|
+
let keyPart = envKey.slice(prefixUpper.length);
|
|
31
|
+
if (keyPart.startsWith("_")) {
|
|
32
|
+
keyPart = keyPart.slice(1);
|
|
33
|
+
}
|
|
34
|
+
if (!keyPart) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const firstUnderscore = keyPart.indexOf("_");
|
|
38
|
+
let restPart;
|
|
39
|
+
if (firstUnderscore === -1) {
|
|
40
|
+
restPart = keyPart;
|
|
41
|
+
} else {
|
|
42
|
+
const firstPart = keyPart.slice(0, firstUnderscore);
|
|
43
|
+
const remaining = keyPart.slice(firstUnderscore + 1);
|
|
44
|
+
if (firstPart === componentUpperNormalized) {
|
|
45
|
+
restPart = remaining;
|
|
46
|
+
} else {
|
|
47
|
+
restPart = keyPart;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (!restPart) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const restPartConverted = restPart.replace(/_/g, ".");
|
|
54
|
+
return `${componentName}.${restPartConverted.toLowerCase()}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { toEnvKey, fromEnvKey, envKeyToConfigKey };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__require
|
|
3
|
+
} from "./roy-agent-core-fs0mn2jk.js";
|
|
4
|
+
|
|
5
|
+
// src/env/paths.ts
|
|
6
|
+
import os from "os";
|
|
7
|
+
import path from "path";
|
|
8
|
+
var APP_NAME = "roy-agent";
|
|
9
|
+
function getXdgBase() {
|
|
10
|
+
const home = os.homedir();
|
|
11
|
+
try {
|
|
12
|
+
const xdg = __require("xdg-basedir");
|
|
13
|
+
return {
|
|
14
|
+
config: xdg.xdgConfig || path.join(home, ".config"),
|
|
15
|
+
state: xdg.xdgState || path.join(home, ".local", "state"),
|
|
16
|
+
data: xdg.xdgData || path.join(home, ".local", "share"),
|
|
17
|
+
cache: xdg.xdgCache || path.join(home, ".cache")
|
|
18
|
+
};
|
|
19
|
+
} catch {
|
|
20
|
+
return {
|
|
21
|
+
config: path.join(home, ".config"),
|
|
22
|
+
state: path.join(home, ".local", "state"),
|
|
23
|
+
data: path.join(home, ".local", "share"),
|
|
24
|
+
cache: path.join(home, ".cache")
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function computeXDGPaths() {
|
|
29
|
+
const home = os.homedir();
|
|
30
|
+
const xdg = getXdgBase();
|
|
31
|
+
return {
|
|
32
|
+
home,
|
|
33
|
+
config: path.join(xdg.config, APP_NAME),
|
|
34
|
+
state: path.join(xdg.state, APP_NAME),
|
|
35
|
+
data: path.join(xdg.data, APP_NAME),
|
|
36
|
+
cache: path.join(xdg.cache, APP_NAME)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
class XDGPathsCalculator {
|
|
41
|
+
_paths;
|
|
42
|
+
get paths() {
|
|
43
|
+
if (!this._paths) {
|
|
44
|
+
this._paths = computeXDGPaths();
|
|
45
|
+
}
|
|
46
|
+
return this._paths;
|
|
47
|
+
}
|
|
48
|
+
getPath(type) {
|
|
49
|
+
return this.paths[type];
|
|
50
|
+
}
|
|
51
|
+
getComponentPath(base, subPath) {
|
|
52
|
+
return path.join(this.paths[base], subPath);
|
|
53
|
+
}
|
|
54
|
+
reset() {
|
|
55
|
+
this._paths = undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
var XDG_PATHS = new XDGPathsCalculator;
|
|
59
|
+
function getXDGPaths() {
|
|
60
|
+
return XDG_PATHS.paths;
|
|
61
|
+
}
|
|
62
|
+
function getXDGPath(type) {
|
|
63
|
+
return XDG_PATHS.getPath(type);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { XDG_PATHS, getXDGPaths, getXDGPath };
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import {
|
|
2
|
+
exports_node_registry_helper,
|
|
3
|
+
init_node_registry_helper
|
|
4
|
+
} from "./roy-agent-core-0rtxwr28.js";
|
|
5
|
+
import {
|
|
6
|
+
WorkflowEngine,
|
|
7
|
+
exports_engine,
|
|
8
|
+
init_engine
|
|
9
|
+
} from "./roy-agent-core-wrcy0h6z.js";
|
|
10
|
+
import {
|
|
11
|
+
WorkflowService
|
|
12
|
+
} from "./roy-agent-core-4t40mkpv.js";
|
|
13
|
+
import {
|
|
14
|
+
askUserTool
|
|
15
|
+
} from "./roy-agent-core-0vbdz0x7.js";
|
|
16
|
+
import {
|
|
17
|
+
BaseComponent
|
|
18
|
+
} from "./roy-agent-core-kkbwepqb.js";
|
|
19
|
+
import {
|
|
20
|
+
createLogger,
|
|
21
|
+
init_logger
|
|
22
|
+
} from "./roy-agent-core-44hnfb02.js";
|
|
23
|
+
import {
|
|
24
|
+
__require,
|
|
25
|
+
__toCommonJS
|
|
26
|
+
} from "./roy-agent-core-fs0mn2jk.js";
|
|
27
|
+
|
|
28
|
+
// src/env/workflow/workflow-component.ts
|
|
29
|
+
import"reflect-metadata";
|
|
30
|
+
init_engine();
|
|
31
|
+
init_logger();
|
|
32
|
+
init_engine();
|
|
33
|
+
init_node_registry_helper();
|
|
34
|
+
var componentLogger = createLogger("workflow");
|
|
35
|
+
|
|
36
|
+
class SkillRegistryAdapter {
|
|
37
|
+
skillComponent;
|
|
38
|
+
constructor(skillComponent) {
|
|
39
|
+
this.skillComponent = skillComponent;
|
|
40
|
+
}
|
|
41
|
+
getSkill(name) {
|
|
42
|
+
const entry = this.skillComponent.getSkill(name);
|
|
43
|
+
if (!entry)
|
|
44
|
+
return;
|
|
45
|
+
return {
|
|
46
|
+
name: entry.name,
|
|
47
|
+
invoke: async (input, context) => {
|
|
48
|
+
return entry.content;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
hasSkill(name) {
|
|
53
|
+
return this.skillComponent.hasSkill(name);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
class WorkflowComponent extends BaseComponent {
|
|
58
|
+
name = "workflow";
|
|
59
|
+
version = "1.0.0";
|
|
60
|
+
workflowService = null;
|
|
61
|
+
sessionComponent = null;
|
|
62
|
+
nodeRegistry = null;
|
|
63
|
+
decoratorsRegistered = false;
|
|
64
|
+
getService() {
|
|
65
|
+
return this.workflowService;
|
|
66
|
+
}
|
|
67
|
+
toolComponent;
|
|
68
|
+
llmComponent;
|
|
69
|
+
logTraceComponent;
|
|
70
|
+
_workflowEnv;
|
|
71
|
+
skillRegistry;
|
|
72
|
+
agentRunner;
|
|
73
|
+
async init(options) {
|
|
74
|
+
const opts = options;
|
|
75
|
+
this._status = "initializing";
|
|
76
|
+
componentLogger.info("Initializing WorkflowComponent...");
|
|
77
|
+
this.toolComponent = opts.toolComponent;
|
|
78
|
+
this.llmComponent = opts.llmComponent;
|
|
79
|
+
this.logTraceComponent = opts.logTraceComponent;
|
|
80
|
+
this._workflowEnv = opts.env;
|
|
81
|
+
this.skillRegistry = opts.skillRegistry;
|
|
82
|
+
this.agentRunner = opts.agentRunner;
|
|
83
|
+
try {
|
|
84
|
+
if (opts.autoRegisterDecorators !== false) {
|
|
85
|
+
await this.registerDecorators();
|
|
86
|
+
}
|
|
87
|
+
this._status = "ready";
|
|
88
|
+
componentLogger.info("WorkflowComponent initialized successfully");
|
|
89
|
+
} catch (error) {
|
|
90
|
+
this._status = "error";
|
|
91
|
+
componentLogger.error("Failed to initialize WorkflowComponent:", error);
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async registerDecorators() {
|
|
96
|
+
if (this.decoratorsRegistered)
|
|
97
|
+
return;
|
|
98
|
+
try {
|
|
99
|
+
const { NodeRegistry } = await import("../../env/workflow/engine/index.js");
|
|
100
|
+
const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-9yxb3ty9.js");
|
|
101
|
+
this.nodeRegistry = new NodeRegistry;
|
|
102
|
+
registerDecoratorNodeType2(this.nodeRegistry);
|
|
103
|
+
this.decoratorsRegistered = true;
|
|
104
|
+
componentLogger.info("Decorator node type registered");
|
|
105
|
+
} catch (error) {
|
|
106
|
+
componentLogger.error("Failed to register decorator node type:", error);
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
createService(options) {
|
|
111
|
+
const skillRegistryAdapter = options.skillRegistry ? new SkillRegistryAdapter(options.skillRegistry) : undefined;
|
|
112
|
+
const sessionComponentForEngine = options.sessionComponent;
|
|
113
|
+
const engineFactory = (workflow, opts) => {
|
|
114
|
+
const { NodeRegistry, WorkflowEngine: WorkflowEngine2 } = (init_engine(), __toCommonJS(exports_engine));
|
|
115
|
+
const registry = new NodeRegistry({
|
|
116
|
+
toolRegistry: options.toolComponent,
|
|
117
|
+
agentComponent: options.env?.getComponent("agent"),
|
|
118
|
+
skillRegistry: skillRegistryAdapter,
|
|
119
|
+
sessionComponent: sessionComponentForEngine
|
|
120
|
+
});
|
|
121
|
+
const { registerDecoratorNodeType: registerDecoratorNodeType2 } = (init_node_registry_helper(), __toCommonJS(exports_node_registry_helper));
|
|
122
|
+
registerDecoratorNodeType2(registry);
|
|
123
|
+
return new WorkflowEngine2(registry, sessionComponentForEngine, options.workflowRepository);
|
|
124
|
+
};
|
|
125
|
+
this.workflowService = new WorkflowService(options.workflowRepository, engineFactory, options.sessionComponent);
|
|
126
|
+
return this.workflowService;
|
|
127
|
+
}
|
|
128
|
+
async runWorkflow(definition, input, options) {
|
|
129
|
+
const { NodeRegistry } = await import("../../env/workflow/engine/index.js");
|
|
130
|
+
const { registerDecoratorNodeType: registerDecoratorNodeType2 } = await import("./roy-agent-core-9yxb3ty9.js");
|
|
131
|
+
const toolComponent = this.toolComponent || this._workflowEnv?.getComponent("tool");
|
|
132
|
+
const skillComponent = this._workflowEnv?.getComponent("skill");
|
|
133
|
+
let agentRunner = this.agentRunner;
|
|
134
|
+
if (!agentRunner && this._workflowEnv) {
|
|
135
|
+
const agentComponent = this._workflowEnv.getComponent("agent");
|
|
136
|
+
if (agentComponent) {
|
|
137
|
+
const { AgentComponentAdapter } = await import("./roy-agent-core-dh9d7a3m.js");
|
|
138
|
+
agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const registry = new NodeRegistry({
|
|
142
|
+
toolRegistry: toolComponent,
|
|
143
|
+
skillRegistry: skillComponent,
|
|
144
|
+
agentRunner,
|
|
145
|
+
sessionComponent: this.sessionComponent
|
|
146
|
+
});
|
|
147
|
+
registerDecoratorNodeType2(registry);
|
|
148
|
+
const engine = new WorkflowEngine(registry);
|
|
149
|
+
return engine.runWorkflow(definition, { ...options, input });
|
|
150
|
+
}
|
|
151
|
+
async onStop() {
|
|
152
|
+
componentLogger.info("[WorkflowComponent] Stopping and cleaning up resources...");
|
|
153
|
+
if (this.nodeRegistry) {
|
|
154
|
+
this.nodeRegistry = null;
|
|
155
|
+
}
|
|
156
|
+
if (this.workflowService) {
|
|
157
|
+
this.workflowService = null;
|
|
158
|
+
try {
|
|
159
|
+
const { closeDatabase } = await import("./roy-agent-core-wft9ra24.js");
|
|
160
|
+
closeDatabase();
|
|
161
|
+
componentLogger.info("[WorkflowComponent] SQLite database closed");
|
|
162
|
+
} catch (error) {
|
|
163
|
+
componentLogger.warn("[WorkflowComponent] Failed to close SQLite database:", error);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
this._status = "stopped";
|
|
167
|
+
componentLogger.info("[WorkflowComponent] Cleanup completed");
|
|
168
|
+
}
|
|
169
|
+
async start() {
|
|
170
|
+
await super.start();
|
|
171
|
+
await this.initSqliteService();
|
|
172
|
+
await this.registerAskUserTool();
|
|
173
|
+
}
|
|
174
|
+
async registerAskUserTool() {
|
|
175
|
+
try {
|
|
176
|
+
const toolComponent = this.toolComponent || this._workflowEnv?.getComponent("tool");
|
|
177
|
+
if (!toolComponent) {
|
|
178
|
+
componentLogger.warn("ToolComponent not available, cannot register ask_user tool");
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (typeof toolComponent.register === "function") {
|
|
182
|
+
toolComponent.register(askUserTool);
|
|
183
|
+
componentLogger.info("ask_user tool registered to ToolComponent");
|
|
184
|
+
} else if (typeof toolComponent.registerMany === "function") {
|
|
185
|
+
toolComponent.registerMany([askUserTool]);
|
|
186
|
+
componentLogger.info("ask_user tool registered to ToolComponent");
|
|
187
|
+
} else {
|
|
188
|
+
componentLogger.warn("ToolComponent does not support tool registration");
|
|
189
|
+
}
|
|
190
|
+
} catch (error) {
|
|
191
|
+
componentLogger.warn("Failed to register ask_user tool:", error);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async initSqliteService() {
|
|
195
|
+
try {
|
|
196
|
+
const { getDatabase, initializeTables } = await import("./roy-agent-core-wft9ra24.js");
|
|
197
|
+
const { WorkflowRepository } = await import("./roy-agent-core-bcbqy27c.js");
|
|
198
|
+
const db = getDatabase();
|
|
199
|
+
initializeTables();
|
|
200
|
+
const workflowRepository = new WorkflowRepository(db);
|
|
201
|
+
const toolComponent = this.toolComponent || this._workflowEnv?.getComponent("tool");
|
|
202
|
+
const llmComponent = this.llmComponent || this._workflowEnv?.getComponent("llm");
|
|
203
|
+
const agentComponent = this._workflowEnv?.getComponent("agent");
|
|
204
|
+
const skillComponent = this.skillRegistry || this._workflowEnv?.getComponent("skill");
|
|
205
|
+
const sessionComponent = this._workflowEnv?.getComponent("session");
|
|
206
|
+
componentLogger.info(`initSqliteService - toolComponent: ${!!toolComponent}, llmComponent: ${!!llmComponent}, skillRegistry: ${!!skillComponent}, sessionComponent: ${!!sessionComponent}`);
|
|
207
|
+
this.createService({
|
|
208
|
+
workflowRepository,
|
|
209
|
+
toolComponent,
|
|
210
|
+
llmComponent,
|
|
211
|
+
env: this._workflowEnv,
|
|
212
|
+
skillRegistry: skillComponent,
|
|
213
|
+
sessionComponent
|
|
214
|
+
});
|
|
215
|
+
this.sessionComponent = sessionComponent;
|
|
216
|
+
await this.registerAskUserTool();
|
|
217
|
+
componentLogger.info("SQLite WorkflowService initialized successfully");
|
|
218
|
+
} catch (error) {
|
|
219
|
+
componentLogger.error("Failed to initialize SQLite WorkflowService:", error);
|
|
220
|
+
await this.createInMemoryService();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
createInMemoryService() {
|
|
224
|
+
const workflows = new Map;
|
|
225
|
+
const workflowRepository = {
|
|
226
|
+
create: (wf) => {
|
|
227
|
+
const id = wf.id || `wf_${Date.now()}`;
|
|
228
|
+
const record = { ...wf, id, createdAt: new Date, updatedAt: new Date };
|
|
229
|
+
workflows.set(id, record);
|
|
230
|
+
return record;
|
|
231
|
+
},
|
|
232
|
+
getById: (id) => workflows.get(id) || null,
|
|
233
|
+
getByName: (name) => {
|
|
234
|
+
for (const wf of workflows.values()) {
|
|
235
|
+
if (wf.name === name)
|
|
236
|
+
return wf;
|
|
237
|
+
}
|
|
238
|
+
return null;
|
|
239
|
+
},
|
|
240
|
+
list: () => Array.from(workflows.values()),
|
|
241
|
+
update: (id, updates) => {
|
|
242
|
+
const wf = workflows.get(id);
|
|
243
|
+
if (!wf)
|
|
244
|
+
return null;
|
|
245
|
+
const updated = { ...wf, ...updates, updatedAt: new Date };
|
|
246
|
+
workflows.set(id, updated);
|
|
247
|
+
return updated;
|
|
248
|
+
},
|
|
249
|
+
delete: (id) => workflows.delete(id)
|
|
250
|
+
};
|
|
251
|
+
const sessionComponent = this._workflowEnv?.getComponent("session");
|
|
252
|
+
return this.createService({
|
|
253
|
+
workflowRepository,
|
|
254
|
+
sessionComponent
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
async stop() {
|
|
258
|
+
componentLogger.info("Stopping WorkflowComponent...");
|
|
259
|
+
this._status = "stopping";
|
|
260
|
+
this.workflowService = null;
|
|
261
|
+
this.nodeRegistry = null;
|
|
262
|
+
this._status = "stopped";
|
|
263
|
+
componentLogger.info("WorkflowComponent stopped");
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export { WorkflowComponent };
|