@ai-setting/roy-agent-core 1.5.83 → 1.5.85
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/env/agent/index.js +2 -2
- package/dist/env/event-source/index.js +2 -2
- package/dist/env/index.js +14 -14
- package/dist/env/prompt/index.js +1 -1
- package/dist/env/task/delegate/index.js +2 -2
- package/dist/env/task/index.js +3 -3
- package/dist/env/task/plugins/index.js +1 -1
- package/dist/env/workflow/engine/index.js +3 -4
- package/dist/env/workflow/index.js +7 -7
- package/dist/env/workflow/service/index.js +8 -2
- package/dist/env/workflow/storage/index.js +11 -6
- package/dist/env/workflow/tools/index.js +16 -2
- package/dist/index.js +17 -16
- package/dist/shared/@ai-setting/{roy-agent-core-f6p7wwpd.js → roy-agent-core-0kt57b72.js} +1 -6
- package/dist/shared/@ai-setting/{roy-agent-core-whw7jap0.js → roy-agent-core-1db4vpc6.js} +3 -2
- package/dist/shared/@ai-setting/{roy-agent-core-68sef3es.js → roy-agent-core-29fh9mxg.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-3sv590cv.js +132 -0
- package/dist/shared/@ai-setting/{roy-agent-core-m4qjnhz6.js → roy-agent-core-5kdw0p98.js} +114 -68
- package/dist/shared/@ai-setting/{roy-agent-core-78yzt2bq.js → roy-agent-core-7fdzfsm6.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-mbre4fxg.js → roy-agent-core-7z4xtrmw.js} +16 -0
- package/dist/shared/@ai-setting/{roy-agent-core-am646wfz.js → roy-agent-core-86d4exyf.js} +5 -2
- package/dist/shared/@ai-setting/roy-agent-core-c67wr8sp.js +11 -0
- package/dist/shared/@ai-setting/{roy-agent-core-v3t28k5n.js → roy-agent-core-dp73ghtz.js} +24 -26
- package/dist/shared/@ai-setting/{roy-agent-core-qjv8537d.js → roy-agent-core-dv12wpdv.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-6b0r2e7j.js → roy-agent-core-gttz2jpm.js} +15 -52
- package/dist/shared/@ai-setting/{roy-agent-core-496zzm5a.js → roy-agent-core-h4h55x4h.js} +183 -3
- package/dist/shared/@ai-setting/roy-agent-core-hhrg314p.js +34 -0
- package/dist/shared/@ai-setting/{roy-agent-core-vcvgq9hy.js → roy-agent-core-mmkyydw7.js} +128 -6
- package/dist/shared/@ai-setting/roy-agent-core-r5axf0ad.js +751 -0
- package/dist/shared/@ai-setting/{roy-agent-core-74cp3zp1.js → roy-agent-core-taxvytzz.js} +4 -1
- package/dist/shared/@ai-setting/roy-agent-core-tq9528d3.js +336 -0
- package/dist/shared/@ai-setting/{roy-agent-core-nc0n0bdc.js → roy-agent-core-xckhrs2p.js} +2 -3
- package/dist/shared/@ai-setting/{roy-agent-core-67yzhmg2.js → roy-agent-core-ya1ayt1k.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-015vw11k.js → roy-agent-core-yx0vw1aw.js} +8 -6
- package/package.json +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-4t40mkpv.js +0 -206
- package/dist/shared/@ai-setting/roy-agent-core-6b57g1zk.js +0 -103
- package/dist/shared/@ai-setting/roy-agent-core-7z8fzxck.js +0 -265
- package/dist/shared/@ai-setting/roy-agent-core-a6j7g1qe.js +0 -428
- package/dist/shared/@ai-setting/roy-agent-core-qf9gvx02.js +0 -39
|
@@ -1,59 +1,138 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WORKFLOW_JSON_OUTPUT_PLUGIN_KEY,
|
|
3
|
-
init_workflow_json_output_plugin,
|
|
4
|
-
registerWorkflowJsonOutputPlugin,
|
|
5
|
-
tracedExtractStructuredJsonViaLlm
|
|
6
|
-
} from "./roy-agent-core-7z8fzxck.js";
|
|
7
1
|
import {
|
|
8
2
|
createSubmitJsonOutputTool,
|
|
9
3
|
init_submit_json_output_tool
|
|
10
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-1db4vpc6.js";
|
|
11
5
|
import {
|
|
12
6
|
AskUserError,
|
|
13
7
|
init_workflow_hil
|
|
14
8
|
} from "./roy-agent-core-e25xkv53.js";
|
|
9
|
+
import {
|
|
10
|
+
globalHookManager,
|
|
11
|
+
init_global_hook_manager
|
|
12
|
+
} from "./roy-agent-core-7tp56w6n.js";
|
|
15
13
|
import {
|
|
16
14
|
TracedAs,
|
|
17
|
-
init_decorator
|
|
15
|
+
init_decorator,
|
|
16
|
+
wrapFunction
|
|
18
17
|
} from "./roy-agent-core-k05v31rc.js";
|
|
18
|
+
import {
|
|
19
|
+
createLogger,
|
|
20
|
+
init_logger
|
|
21
|
+
} from "./roy-agent-core-shme7set.js";
|
|
19
22
|
import {
|
|
20
23
|
__esm,
|
|
21
24
|
__legacyDecorateClassTS
|
|
22
25
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
23
26
|
|
|
27
|
+
// src/env/workflow/plugins/workflow-json-output-plugin.ts
|
|
28
|
+
function registerWorkflowJsonOutputPlugin(options = undefined) {
|
|
29
|
+
if (registered) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (options?.agentComponent) {
|
|
33
|
+
agentComponentRef = options.agentComponent;
|
|
34
|
+
}
|
|
35
|
+
registered = true;
|
|
36
|
+
globalHookManager.register(HOOK_POINT, {
|
|
37
|
+
name: HOOK_NAME,
|
|
38
|
+
pluginName: WORKFLOW_JSON_OUTPUT_PLUGIN_NAME,
|
|
39
|
+
sourceId: WORKFLOW_JSON_OUTPUT_SOURCE_ID,
|
|
40
|
+
priority: 100,
|
|
41
|
+
description: "Extract structured JSON output by invoking the json-extract sub-agent on the main session history",
|
|
42
|
+
execute: async (wrapper) => {
|
|
43
|
+
const hookCtx = wrapper.data;
|
|
44
|
+
await tracedRunWorkflowJsonOutputExtraction(hookCtx);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
logger.info("Workflow JSON output plugin registered on agent:after.react");
|
|
48
|
+
}
|
|
49
|
+
async function runWorkflowJsonOutputExtraction(hookCtx) {
|
|
50
|
+
const schema = hookCtx.context.metadata?.outputSchema;
|
|
51
|
+
if (!schema) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (hookCtx.error instanceof AskUserError) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (hookCtx.structuredOutputExtracted) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (!agentComponentRef) {
|
|
61
|
+
logger.warn("Workflow JSON extraction: agentComponent not registered. " + "Plugin cannot invoke json-extract sub-agent. " + "Ensure registerWorkflowJsonOutputPlugin({ agentComponent }) was called.");
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const sessionId = hookCtx.context.sessionId;
|
|
65
|
+
if (!sessionId) {
|
|
66
|
+
logger.warn("Workflow JSON extraction: no sessionId in hookCtx.context. " + "Cannot reuse main session history for json-extract sub-agent.");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
const submitTool = createSubmitJsonOutputTool(schema, hookCtx);
|
|
71
|
+
const submitToolAsExtra = {
|
|
72
|
+
name: submitTool.name,
|
|
73
|
+
description: submitTool.description ?? "",
|
|
74
|
+
parameters: submitTool.parameters,
|
|
75
|
+
execute: submitTool.execute
|
|
76
|
+
};
|
|
77
|
+
const extractContext = {
|
|
78
|
+
sessionId,
|
|
79
|
+
extraTools: [submitToolAsExtra],
|
|
80
|
+
persistSession: false,
|
|
81
|
+
abort: hookCtx.context.abort
|
|
82
|
+
};
|
|
83
|
+
const result = await agentComponentRef.run("json-extract", "", extractContext);
|
|
84
|
+
if (result.error) {
|
|
85
|
+
logger.warn(`Workflow JSON extraction: json-extract sub-agent returned error: ${result.error}`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (hookCtx.structuredOutputExtracted) {
|
|
89
|
+
logger.info("Workflow JSON output extracted via json-extract sub-agent " + `(iterations=${result.iterations}, toolCalls=${result.toolCalls?.length ?? 0})`);
|
|
90
|
+
} else {
|
|
91
|
+
logger.warn("Workflow JSON extraction: json-extract sub-agent did not call workflow_submit_output. " + "Check that the model supports tool calls.");
|
|
92
|
+
}
|
|
93
|
+
} catch (error) {
|
|
94
|
+
logger.error(`Workflow JSON extraction: json-extract sub-agent threw: ${error instanceof Error ? error.message : String(error)}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
var logger, WORKFLOW_JSON_OUTPUT_SOURCE_ID = "workflow", WORKFLOW_JSON_OUTPUT_PLUGIN_NAME = "json-output", WORKFLOW_JSON_OUTPUT_PLUGIN_KEY, HOOK_POINT = "agent:after.react", HOOK_NAME, registered = false, agentComponentRef = null, tracedRunWorkflowJsonOutputExtraction;
|
|
98
|
+
var init_workflow_json_output_plugin = __esm(() => {
|
|
99
|
+
init_global_hook_manager();
|
|
100
|
+
init_workflow_hil();
|
|
101
|
+
init_submit_json_output_tool();
|
|
102
|
+
init_logger();
|
|
103
|
+
init_decorator();
|
|
104
|
+
logger = createLogger("WorkflowJsonOutputPlugin");
|
|
105
|
+
WORKFLOW_JSON_OUTPUT_PLUGIN_KEY = `${WORKFLOW_JSON_OUTPUT_SOURCE_ID}:${WORKFLOW_JSON_OUTPUT_PLUGIN_NAME}`;
|
|
106
|
+
HOOK_NAME = `${WORKFLOW_JSON_OUTPUT_PLUGIN_NAME}:${HOOK_POINT}`;
|
|
107
|
+
tracedRunWorkflowJsonOutputExtraction = wrapFunction(runWorkflowJsonOutputExtraction, "workflow.json_output.extraction", { recordParams: true, recordResult: true, log: true });
|
|
108
|
+
});
|
|
109
|
+
|
|
24
110
|
// src/env/workflow/nodes/agent-component-adapter.ts
|
|
25
111
|
var AgentComponentAdapter;
|
|
26
112
|
var init_agent_component_adapter = __esm(() => {
|
|
27
113
|
init_workflow_hil();
|
|
28
114
|
init_workflow_json_output_plugin();
|
|
29
115
|
init_decorator();
|
|
30
|
-
init_submit_json_output_tool();
|
|
31
116
|
AgentComponentAdapter = class AgentComponentAdapter {
|
|
32
117
|
agentComponent;
|
|
33
118
|
options;
|
|
34
119
|
_sessionComponent;
|
|
35
|
-
_llmComponent;
|
|
36
120
|
agentSessionPrefix = "agent";
|
|
37
121
|
_currentAgentSessionId;
|
|
38
122
|
pendingSessions = new Map;
|
|
39
123
|
runSessionToAgentSessions = new Map;
|
|
40
124
|
jsonOutputPluginRegistered = false;
|
|
41
|
-
constructor(agentComponent, options = {}, _sessionComponent
|
|
125
|
+
constructor(agentComponent, options = {}, _sessionComponent) {
|
|
42
126
|
this.agentComponent = agentComponent;
|
|
43
127
|
this.options = options;
|
|
44
128
|
this._sessionComponent = _sessionComponent;
|
|
45
|
-
this._llmComponent = _llmComponent;
|
|
46
|
-
this.ensureJsonOutputPluginRegistered();
|
|
47
|
-
}
|
|
48
|
-
setLLMComponent(llmComponent) {
|
|
49
|
-
this._llmComponent = llmComponent;
|
|
50
129
|
this.ensureJsonOutputPluginRegistered();
|
|
51
130
|
}
|
|
52
131
|
ensureJsonOutputPluginRegistered() {
|
|
53
|
-
if (this.jsonOutputPluginRegistered
|
|
132
|
+
if (this.jsonOutputPluginRegistered) {
|
|
54
133
|
return;
|
|
55
134
|
}
|
|
56
|
-
registerWorkflowJsonOutputPlugin(this.
|
|
135
|
+
registerWorkflowJsonOutputPlugin({ agentComponent: this.agentComponent });
|
|
57
136
|
this.jsonOutputPluginRegistered = true;
|
|
58
137
|
}
|
|
59
138
|
setSessionComponent(sessionComponent) {
|
|
@@ -84,19 +163,21 @@ var init_agent_component_adapter = __esm(() => {
|
|
|
84
163
|
const workflowSessionId = config.workflowSessionId;
|
|
85
164
|
const isResume = !!resumeOptions?.userQuery;
|
|
86
165
|
let agentSessionId = resumeOptions?.agentSessionId || config.agentSessionId || this._currentAgentSessionId;
|
|
87
|
-
if (!agentSessionId
|
|
166
|
+
if (!agentSessionId) {
|
|
88
167
|
agentSessionId = `${this.agentSessionPrefix}_${runId}_${nodeId}_${Date.now()}`;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
168
|
+
if (this._sessionComponent) {
|
|
169
|
+
try {
|
|
170
|
+
await this._sessionComponent.create({
|
|
171
|
+
title: `Agent Session: ${config.type} (${agentSessionId})`,
|
|
172
|
+
metadata: {
|
|
173
|
+
type: "agent",
|
|
174
|
+
workflowRunId: runId,
|
|
175
|
+
workflowNodeId: nodeId
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.warn(`Failed to create agent session ${agentSessionId}:`, error);
|
|
180
|
+
}
|
|
100
181
|
}
|
|
101
182
|
}
|
|
102
183
|
if (agentSessionId) {
|
|
@@ -126,9 +207,7 @@ var init_agent_component_adapter = __esm(() => {
|
|
|
126
207
|
if (config.options?.timeout) {
|
|
127
208
|
context.abort = new AbortController;
|
|
128
209
|
}
|
|
129
|
-
|
|
130
|
-
context.sessionId = agentSessionId;
|
|
131
|
-
}
|
|
210
|
+
context.sessionId = agentSessionId;
|
|
132
211
|
if (config.options?.allowedTools) {
|
|
133
212
|
context.allowedTools = config.options.allowedTools;
|
|
134
213
|
}
|
|
@@ -139,24 +218,13 @@ var init_agent_component_adapter = __esm(() => {
|
|
|
139
218
|
runId,
|
|
140
219
|
nodeId,
|
|
141
220
|
sessionId: agentSessionId,
|
|
142
|
-
outputSchema
|
|
143
|
-
workflowJsonOutputFallbackModel: config.options?.workflowJsonOutputFallbackModel
|
|
221
|
+
outputSchema
|
|
144
222
|
};
|
|
145
223
|
if (outputSchema) {
|
|
146
224
|
context.pluginEnabled = {
|
|
147
225
|
...context.pluginEnabled ?? {},
|
|
148
226
|
[WORKFLOW_JSON_OUTPUT_PLUGIN_KEY]: true
|
|
149
227
|
};
|
|
150
|
-
const submitTool = createSubmitJsonOutputTool(outputSchema);
|
|
151
|
-
context.extraTools = [
|
|
152
|
-
...context.extraTools ?? [],
|
|
153
|
-
{
|
|
154
|
-
name: submitTool.name,
|
|
155
|
-
description: submitTool.description ?? "",
|
|
156
|
-
parameters: submitTool.parameters,
|
|
157
|
-
execute: submitTool.execute
|
|
158
|
-
}
|
|
159
|
-
];
|
|
160
228
|
}
|
|
161
229
|
if (config.workflowHistory) {
|
|
162
230
|
context.workflowHistory = config.workflowHistory;
|
|
@@ -183,7 +251,7 @@ var init_agent_component_adapter = __esm(() => {
|
|
|
183
251
|
if (agentSessionId) {
|
|
184
252
|
this.pendingSessions.delete(agentSessionId);
|
|
185
253
|
}
|
|
186
|
-
const structuredOutput =
|
|
254
|
+
const structuredOutput = result.structuredOutput;
|
|
187
255
|
return {
|
|
188
256
|
output: structuredOutput ?? result.finalText ?? result.output,
|
|
189
257
|
structuredOutput,
|
|
@@ -256,28 +324,6 @@ var init_agent_component_adapter = __esm(() => {
|
|
|
256
324
|
getAgentComponent() {
|
|
257
325
|
return this.agentComponent;
|
|
258
326
|
}
|
|
259
|
-
async resolveStructuredOutput(fromPlugin, outputSchema, config, agentSessionId) {
|
|
260
|
-
if (fromPlugin) {
|
|
261
|
-
return fromPlugin;
|
|
262
|
-
}
|
|
263
|
-
if (!outputSchema || !this._llmComponent || !agentSessionId || !this._sessionComponent) {
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
try {
|
|
267
|
-
const sessionMessages = await this._sessionComponent.getMessages(agentSessionId);
|
|
268
|
-
const history = sessionMessages.map((m) => ({
|
|
269
|
-
role: m.role,
|
|
270
|
-
content: m.content ?? ""
|
|
271
|
-
}));
|
|
272
|
-
return await tracedExtractStructuredJsonViaLlm(this._llmComponent, history, outputSchema, {
|
|
273
|
-
model: config.options?.model,
|
|
274
|
-
sessionId: agentSessionId
|
|
275
|
-
});
|
|
276
|
-
} catch (error) {
|
|
277
|
-
console.warn("Workflow JSON extraction fallback failed:", error);
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
327
|
agentSessionPrefixes = new Map;
|
|
282
328
|
};
|
|
283
329
|
__legacyDecorateClassTS([
|
|
@@ -369,11 +369,11 @@ ${prompt}`;
|
|
|
369
369
|
}
|
|
370
370
|
if (!this._workflowRepo) {
|
|
371
371
|
try {
|
|
372
|
-
const sqlite = await import("./roy-agent-core-
|
|
372
|
+
const sqlite = await import("./roy-agent-core-taxvytzz.js");
|
|
373
373
|
this.ensureDataDir();
|
|
374
374
|
const db = sqlite.getDatabase();
|
|
375
375
|
sqlite.initializeTables();
|
|
376
|
-
const { WorkflowRepository } = await import("./roy-agent-core-
|
|
376
|
+
const { WorkflowRepository } = await import("./roy-agent-core-86d4exyf.js");
|
|
377
377
|
this._workflowRepo = new WorkflowRepository(db);
|
|
378
378
|
return this._workflowRepo;
|
|
379
379
|
} catch {
|
|
@@ -177,6 +177,22 @@ class AgentRegistry {
|
|
|
177
177
|
};
|
|
178
178
|
this.agents.set(name, agent);
|
|
179
179
|
}
|
|
180
|
+
registerJsonExtractAgent() {
|
|
181
|
+
const name = "json-extract";
|
|
182
|
+
if (this.agents.has(name))
|
|
183
|
+
return;
|
|
184
|
+
const agent = {
|
|
185
|
+
name,
|
|
186
|
+
type: "sub",
|
|
187
|
+
description: "JSON 提取子智能体 — 从父 session 历史中提取结构化 JSON,通过 workflow_submit_output 工具提交",
|
|
188
|
+
systemPromptRef: "json-extract",
|
|
189
|
+
allowedTools: ["workflow_submit_output"],
|
|
190
|
+
deniedTools: [],
|
|
191
|
+
maxIterations: 1,
|
|
192
|
+
filterHistory: false
|
|
193
|
+
};
|
|
194
|
+
this.agents.set(name, agent);
|
|
195
|
+
}
|
|
180
196
|
async load() {
|
|
181
197
|
try {
|
|
182
198
|
return await this.loadFromDirectory(this.configDir);
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WorkflowRepository,
|
|
3
|
+
migrateEmptyTagsToDefault,
|
|
3
4
|
rowToWorkflow
|
|
4
|
-
} from "./roy-agent-core-
|
|
5
|
-
import"./roy-agent-core-
|
|
5
|
+
} from "./roy-agent-core-h4h55x4h.js";
|
|
6
|
+
import"./roy-agent-core-3sv590cv.js";
|
|
6
7
|
import"./roy-agent-core-rvxg1wps.js";
|
|
8
|
+
import"./roy-agent-core-k05v31rc.js";
|
|
7
9
|
import"./roy-agent-core-shme7set.js";
|
|
8
10
|
import"./roy-agent-core-7z9b1fm8.js";
|
|
9
11
|
import"./roy-agent-core-c6592r3c.js";
|
|
10
12
|
import"./roy-agent-core-fs0mn2jk.js";
|
|
11
13
|
export {
|
|
12
14
|
rowToWorkflow,
|
|
15
|
+
migrateEmptyTagsToDefault,
|
|
13
16
|
WorkflowRepository
|
|
14
17
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TagRepository
|
|
3
|
+
} from "./roy-agent-core-3sv590cv.js";
|
|
4
|
+
import"./roy-agent-core-k05v31rc.js";
|
|
5
|
+
import"./roy-agent-core-shme7set.js";
|
|
6
|
+
import"./roy-agent-core-7z9b1fm8.js";
|
|
7
|
+
import"./roy-agent-core-c6592r3c.js";
|
|
8
|
+
import"./roy-agent-core-fs0mn2jk.js";
|
|
9
|
+
export {
|
|
10
|
+
TagRepository
|
|
11
|
+
};
|
|
@@ -6,18 +6,21 @@ import {
|
|
|
6
6
|
WorkflowEngine,
|
|
7
7
|
exports_engine,
|
|
8
8
|
init_engine
|
|
9
|
-
} from "./roy-agent-core-
|
|
10
|
-
import {
|
|
11
|
-
WorkflowService
|
|
12
|
-
} from "./roy-agent-core-4t40mkpv.js";
|
|
9
|
+
} from "./roy-agent-core-gttz2jpm.js";
|
|
13
10
|
import {
|
|
14
11
|
askUserTool,
|
|
15
12
|
createRunWorkflowTool,
|
|
13
|
+
createWorkflowAddTool,
|
|
16
14
|
createWorkflowGetTool,
|
|
17
15
|
createWorkflowListTool,
|
|
18
16
|
createWorkflowRunStatusTool,
|
|
19
|
-
createWorkflowRunStopTool
|
|
20
|
-
|
|
17
|
+
createWorkflowRunStopTool,
|
|
18
|
+
createWorkflowSearchTool,
|
|
19
|
+
createWorkflowTagListTool
|
|
20
|
+
} from "./roy-agent-core-r5axf0ad.js";
|
|
21
|
+
import {
|
|
22
|
+
WorkflowService
|
|
23
|
+
} from "./roy-agent-core-tq9528d3.js";
|
|
21
24
|
import {
|
|
22
25
|
BaseComponent
|
|
23
26
|
} from "./roy-agent-core-rgckng3p.js";
|
|
@@ -70,7 +73,6 @@ class WorkflowComponent extends BaseComponent {
|
|
|
70
73
|
return this.workflowService;
|
|
71
74
|
}
|
|
72
75
|
toolComponent;
|
|
73
|
-
llmComponent;
|
|
74
76
|
logTraceComponent;
|
|
75
77
|
_workflowEnv;
|
|
76
78
|
skillRegistry;
|
|
@@ -80,7 +82,6 @@ class WorkflowComponent extends BaseComponent {
|
|
|
80
82
|
this._status = "initializing";
|
|
81
83
|
componentLogger.info("Initializing WorkflowComponent...");
|
|
82
84
|
this.toolComponent = opts.toolComponent;
|
|
83
|
-
this.llmComponent = opts.llmComponent;
|
|
84
85
|
this.logTraceComponent = opts.logTraceComponent;
|
|
85
86
|
this._workflowEnv = opts.env;
|
|
86
87
|
this.skillRegistry = opts.skillRegistry;
|
|
@@ -120,7 +121,6 @@ class WorkflowComponent extends BaseComponent {
|
|
|
120
121
|
const registry = new NodeRegistry({
|
|
121
122
|
toolRegistry: options.toolComponent,
|
|
122
123
|
agentComponent: options.env?.getComponent("agent"),
|
|
123
|
-
llmComponent: options.env?.getComponent("llm"),
|
|
124
124
|
skillRegistry: skillRegistryAdapter,
|
|
125
125
|
sessionComponent: sessionComponentForEngine
|
|
126
126
|
});
|
|
@@ -128,7 +128,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
128
128
|
registerDecoratorNodeType2(registry);
|
|
129
129
|
return new WorkflowEngine2(registry, sessionComponentForEngine, options.workflowRepository);
|
|
130
130
|
};
|
|
131
|
-
this.workflowService = new WorkflowService(options.workflowRepository, engineFactory, options.sessionComponent);
|
|
131
|
+
this.workflowService = new WorkflowService(options.workflowRepository, engineFactory, options.sessionComponent, options.tagRepository);
|
|
132
132
|
return this.workflowService;
|
|
133
133
|
}
|
|
134
134
|
async runWorkflow(definition, input, options) {
|
|
@@ -139,18 +139,16 @@ class WorkflowComponent extends BaseComponent {
|
|
|
139
139
|
let agentRunner = this.agentRunner;
|
|
140
140
|
if (!agentRunner && this._workflowEnv) {
|
|
141
141
|
const agentComponent = this._workflowEnv.getComponent("agent");
|
|
142
|
-
const llmComponent = this._workflowEnv.getComponent("llm");
|
|
143
142
|
if (agentComponent) {
|
|
144
|
-
const { AgentComponentAdapter } = await import("./roy-agent-core-
|
|
145
|
-
agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent
|
|
143
|
+
const { AgentComponentAdapter } = await import("./roy-agent-core-xckhrs2p.js");
|
|
144
|
+
agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent);
|
|
146
145
|
}
|
|
147
146
|
}
|
|
148
147
|
const registry = new NodeRegistry({
|
|
149
148
|
toolRegistry: toolComponent,
|
|
150
149
|
skillRegistry: skillComponent,
|
|
151
150
|
agentRunner,
|
|
152
|
-
sessionComponent: this.sessionComponent
|
|
153
|
-
llmComponent: this._workflowEnv?.getComponent("llm")
|
|
151
|
+
sessionComponent: this.sessionComponent
|
|
154
152
|
});
|
|
155
153
|
registerDecoratorNodeType2(registry);
|
|
156
154
|
const engine = new WorkflowEngine(registry, this.sessionComponent);
|
|
@@ -164,7 +162,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
164
162
|
if (this.workflowService) {
|
|
165
163
|
this.workflowService = null;
|
|
166
164
|
try {
|
|
167
|
-
const { closeDatabase } = await import("./roy-agent-core-
|
|
165
|
+
const { closeDatabase } = await import("./roy-agent-core-taxvytzz.js");
|
|
168
166
|
closeDatabase();
|
|
169
167
|
componentLogger.info("[WorkflowComponent] SQLite database closed");
|
|
170
168
|
} catch (error) {
|
|
@@ -214,6 +212,9 @@ class WorkflowComponent extends BaseComponent {
|
|
|
214
212
|
const tools = [
|
|
215
213
|
createWorkflowGetTool(this.workflowService),
|
|
216
214
|
createWorkflowListTool(this.workflowService),
|
|
215
|
+
createWorkflowAddTool(this.workflowService),
|
|
216
|
+
createWorkflowSearchTool(this.workflowService),
|
|
217
|
+
createWorkflowTagListTool(this.workflowService),
|
|
217
218
|
createRunWorkflowTool(this.workflowService),
|
|
218
219
|
createWorkflowRunStatusTool(this.workflowService),
|
|
219
220
|
createWorkflowRunStopTool(this.workflowService)
|
|
@@ -228,25 +229,22 @@ class WorkflowComponent extends BaseComponent {
|
|
|
228
229
|
}
|
|
229
230
|
async initSqliteService() {
|
|
230
231
|
try {
|
|
231
|
-
const { getDatabase, initializeTables } = await import("./roy-agent-core-
|
|
232
|
-
const { WorkflowRepository } = await import("./roy-agent-core-
|
|
232
|
+
const { getDatabase, initializeTables } = await import("./roy-agent-core-taxvytzz.js");
|
|
233
|
+
const { WorkflowRepository } = await import("./roy-agent-core-86d4exyf.js");
|
|
234
|
+
const { TagRepository } = await import("./roy-agent-core-c67wr8sp.js");
|
|
233
235
|
const db = getDatabase();
|
|
234
236
|
initializeTables();
|
|
235
237
|
const workflowRepository = new WorkflowRepository(db);
|
|
238
|
+
const tagRepository = new TagRepository(db);
|
|
236
239
|
const toolComponent = this.toolComponent || this._workflowEnv?.getComponent("tool");
|
|
237
|
-
const llmComponent = this.llmComponent || this._workflowEnv?.getComponent("llm");
|
|
238
240
|
const agentComponent = this._workflowEnv?.getComponent("agent");
|
|
239
241
|
const skillComponent = this.skillRegistry || this._workflowEnv?.getComponent("skill");
|
|
240
242
|
const sessionComponent = this._workflowEnv?.getComponent("session");
|
|
241
|
-
componentLogger.info(`initSqliteService - toolComponent: ${!!toolComponent},
|
|
242
|
-
if (llmComponent) {
|
|
243
|
-
const { registerWorkflowJsonOutputPlugin } = await import("./roy-agent-core-qf9gvx02.js");
|
|
244
|
-
registerWorkflowJsonOutputPlugin(llmComponent);
|
|
245
|
-
}
|
|
243
|
+
componentLogger.info(`initSqliteService - toolComponent: ${!!toolComponent}, skillRegistry: ${!!skillComponent}, sessionComponent: ${!!sessionComponent}`);
|
|
246
244
|
this.createService({
|
|
247
245
|
workflowRepository,
|
|
246
|
+
tagRepository,
|
|
248
247
|
toolComponent,
|
|
249
|
-
llmComponent,
|
|
250
248
|
env: this._workflowEnv,
|
|
251
249
|
skillRegistry: skillComponent,
|
|
252
250
|
sessionComponent
|
|
@@ -299,7 +297,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
299
297
|
this.workflowService = null;
|
|
300
298
|
this.nodeRegistry = null;
|
|
301
299
|
try {
|
|
302
|
-
const { closeDatabase } = await import("./roy-agent-core-
|
|
300
|
+
const { closeDatabase } = await import("./roy-agent-core-taxvytzz.js");
|
|
303
301
|
closeDatabase();
|
|
304
302
|
} catch {}
|
|
305
303
|
this._status = "stopped";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentComponentAdapter,
|
|
3
3
|
init_agent_component_adapter
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-5kdw0p98.js";
|
|
5
5
|
import {
|
|
6
6
|
buildWorkflowNodeMetadata,
|
|
7
7
|
getWorkflowNodeIdFromMetadata,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
jsonSchemaToZod,
|
|
35
35
|
parseWorkflowJsonOutput,
|
|
36
36
|
validateJsonOutputSchema
|
|
37
|
-
} from "./roy-agent-core-
|
|
37
|
+
} from "./roy-agent-core-1db4vpc6.js";
|
|
38
38
|
import {
|
|
39
39
|
AskUserError,
|
|
40
40
|
createNodeInterruptEvent,
|
|
@@ -1305,67 +1305,37 @@ var init_extract_agent_json_output = __esm(() => {
|
|
|
1305
1305
|
|
|
1306
1306
|
// src/env/workflow/utils/build-agent-node-output.ts
|
|
1307
1307
|
function buildAgentNodeOutput(agentResult, outputConfig) {
|
|
1308
|
-
const base = {
|
|
1309
|
-
metadata: agentResult.metadata,
|
|
1310
|
-
workflowHistory: agentResult.messages
|
|
1311
|
-
};
|
|
1312
1308
|
if (outputConfig.mode === "json") {
|
|
1313
1309
|
const schema = outputConfig.schema;
|
|
1314
1310
|
const jsonData = extractAgentJsonOutput(agentResult, schema);
|
|
1315
|
-
if (
|
|
1316
|
-
const defaults = buildSchemaDefaults(schema);
|
|
1317
|
-
const fallbackData = { ...defaults, rawOutput: agentResult.output };
|
|
1311
|
+
if (jsonData) {
|
|
1318
1312
|
return {
|
|
1319
|
-
result:
|
|
1320
|
-
...
|
|
1313
|
+
result: jsonData,
|
|
1314
|
+
...jsonData,
|
|
1321
1315
|
metadata: {
|
|
1322
1316
|
...agentResult.metadata,
|
|
1323
|
-
outputMode: "
|
|
1324
|
-
_extractionWarning: "JSON extraction failed, using defaults"
|
|
1317
|
+
outputMode: "json"
|
|
1325
1318
|
},
|
|
1326
1319
|
workflowHistory: agentResult.messages
|
|
1327
1320
|
};
|
|
1328
1321
|
}
|
|
1322
|
+
const rawText = typeof agentResult.output === "string" ? agentResult.output : JSON.stringify(agentResult.output ?? {});
|
|
1329
1323
|
return {
|
|
1330
|
-
result:
|
|
1331
|
-
...jsonData,
|
|
1324
|
+
result: rawText,
|
|
1332
1325
|
metadata: {
|
|
1333
1326
|
...agentResult.metadata,
|
|
1334
|
-
outputMode: "
|
|
1327
|
+
outputMode: "json_error",
|
|
1328
|
+
_extractionWarning: "JSON extraction failed — raw output surfaced"
|
|
1335
1329
|
},
|
|
1336
1330
|
workflowHistory: agentResult.messages
|
|
1337
1331
|
};
|
|
1338
1332
|
}
|
|
1339
1333
|
return {
|
|
1340
1334
|
result: agentResult.output,
|
|
1341
|
-
|
|
1335
|
+
metadata: agentResult.metadata,
|
|
1336
|
+
workflowHistory: agentResult.messages
|
|
1342
1337
|
};
|
|
1343
1338
|
}
|
|
1344
|
-
function buildSchemaDefaults(schema) {
|
|
1345
|
-
const defaults = {};
|
|
1346
|
-
if (!schema?.properties || !schema?.required)
|
|
1347
|
-
return defaults;
|
|
1348
|
-
for (const key of schema.required) {
|
|
1349
|
-
const prop = schema.properties[key];
|
|
1350
|
-
if (!prop?.type)
|
|
1351
|
-
continue;
|
|
1352
|
-
switch (prop.type) {
|
|
1353
|
-
case "boolean":
|
|
1354
|
-
defaults[key] = false;
|
|
1355
|
-
break;
|
|
1356
|
-
case "string":
|
|
1357
|
-
defaults[key] = "";
|
|
1358
|
-
break;
|
|
1359
|
-
case "number":
|
|
1360
|
-
case "integer":
|
|
1361
|
-
defaults[key] = 0;
|
|
1362
|
-
break;
|
|
1363
|
-
default:
|
|
1364
|
-
defaults[key] = null;
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
return defaults;
|
|
1368
|
-
}
|
|
1369
1339
|
var init_build_agent_node_output = __esm(() => {
|
|
1370
1340
|
init_extract_agent_json_output();
|
|
1371
1341
|
});
|
|
@@ -1452,8 +1422,7 @@ var init_agent_node = __esm(() => {
|
|
|
1452
1422
|
model: effectiveModel,
|
|
1453
1423
|
allowedTools: effectiveAllowedTools,
|
|
1454
1424
|
deniedTools: effectiveDeniedTools,
|
|
1455
|
-
outputSchema: outputConfig.schema
|
|
1456
|
-
workflowJsonOutputFallbackModel: options.workflowJsonOutputFallbackModel
|
|
1425
|
+
outputSchema: outputConfig.schema
|
|
1457
1426
|
},
|
|
1458
1427
|
workflowHistory: context.workflowHistory,
|
|
1459
1428
|
nodeId: this.definition.id,
|
|
@@ -1595,8 +1564,7 @@ class NodeRegistry {
|
|
|
1595
1564
|
agentComponent,
|
|
1596
1565
|
agentRunner,
|
|
1597
1566
|
workflowRunner,
|
|
1598
|
-
sessionComponent
|
|
1599
|
-
llmComponent
|
|
1567
|
+
sessionComponent
|
|
1600
1568
|
} = options ?? {};
|
|
1601
1569
|
this.toolRegistry = toolRegistry;
|
|
1602
1570
|
this.skillRegistry = skillRegistry;
|
|
@@ -1607,11 +1575,8 @@ class NodeRegistry {
|
|
|
1607
1575
|
if (agentRunner.setSessionComponent && sessionComponent) {
|
|
1608
1576
|
agentRunner.setSessionComponent(sessionComponent);
|
|
1609
1577
|
}
|
|
1610
|
-
if (llmComponent && "setLLMComponent" in agentRunner && typeof agentRunner.setLLMComponent === "function") {
|
|
1611
|
-
agentRunner.setLLMComponent(llmComponent);
|
|
1612
|
-
}
|
|
1613
1578
|
} else if (agentComponent) {
|
|
1614
|
-
this.agentComponentAdapter = new AgentComponentAdapter(agentComponent, {}, sessionComponent
|
|
1579
|
+
this.agentComponentAdapter = new AgentComponentAdapter(agentComponent, {}, sessionComponent);
|
|
1615
1580
|
this.agentRunner = this.agentComponentAdapter;
|
|
1616
1581
|
}
|
|
1617
1582
|
this.registerBuiltInTypes();
|
|
@@ -1728,12 +1693,10 @@ var init_engine = __esm(() => {
|
|
|
1728
1693
|
static async create(options) {
|
|
1729
1694
|
const agentComponent = options.env?.getComponent("agent");
|
|
1730
1695
|
const sessionComponent = options.sessionComponent;
|
|
1731
|
-
const llmComponent = options.env?.getComponent("llm");
|
|
1732
1696
|
const nodeRegistry = new NodeRegistry({
|
|
1733
1697
|
toolRegistry: options.toolRegistry,
|
|
1734
1698
|
skillRegistry: options.skillRegistry,
|
|
1735
1699
|
agentComponent,
|
|
1736
|
-
llmComponent,
|
|
1737
1700
|
workflowRunner: options.workflowRunner,
|
|
1738
1701
|
sessionComponent
|
|
1739
1702
|
});
|