@ai-setting/roy-agent-core 1.5.50 → 1.5.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/index.js +6 -6
- package/dist/env/agent/index.js +7 -7
- package/dist/env/commands/index.js +6 -6
- package/dist/env/context/index.js +2 -2
- package/dist/env/debug/index.js +6 -6
- package/dist/env/event-source/index.js +8 -8
- package/dist/env/hook/index.js +4 -4
- package/dist/env/index.js +20 -20
- package/dist/env/llm/index.js +6 -6
- package/dist/env/log-trace/index.js +6 -6
- package/dist/env/mcp/index.js +6 -6
- package/dist/env/memory/index.js +6 -6
- package/dist/env/plugin/index.js +6 -6
- package/dist/env/prompt/index.js +6 -6
- package/dist/env/session/index.js +8 -8
- package/dist/env/session/storage/index.js +2 -2
- package/dist/env/skill/index.js +6 -6
- package/dist/env/task/delegate/index.js +4 -4
- package/dist/env/task/index.js +8 -8
- package/dist/env/task/plugins/index.js +3 -3
- package/dist/env/task/tools/index.js +2 -2
- package/dist/env/tool/index.js +6 -6
- package/dist/env/workflow/engine/index.js +6 -6
- package/dist/env/workflow/index.js +9 -9
- package/dist/index.js +30 -30
- package/dist/shared/@ai-setting/{roy-agent-core-fpb999vd.js → roy-agent-core-0frwccap.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-ezfwx334.js → roy-agent-core-0x3g6snw.js} +8 -6
- package/dist/shared/@ai-setting/{roy-agent-core-c7cm1wjt.js → roy-agent-core-13vzexp2.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-9a2n122m.js → roy-agent-core-29867p67.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-y30njf6b.js → roy-agent-core-2g5j2nw6.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-hd6kd06t.js → roy-agent-core-2xah3h0z.js} +8 -3
- package/dist/shared/@ai-setting/{roy-agent-core-5ng0awvn.js → roy-agent-core-3jk7ngmx.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-a8gvea2f.js → roy-agent-core-4hk6ey73.js} +17 -2
- package/dist/shared/@ai-setting/{roy-agent-core-pa9wz5q0.js → roy-agent-core-4mw6rs37.js} +22 -9
- package/dist/shared/@ai-setting/{roy-agent-core-8nd895aq.js → roy-agent-core-5k8watmp.js} +20 -5
- package/dist/shared/@ai-setting/{roy-agent-core-qfdgg56t.js → roy-agent-core-5t6cryce.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-w65c5gac.js → roy-agent-core-88d3k0p0.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-9sarrbw9.js → roy-agent-core-9m9m6fe1.js} +2 -2
- package/dist/shared/@ai-setting/roy-agent-core-awmae5ax.js +258 -0
- package/dist/shared/@ai-setting/{roy-agent-core-rjf59e7k.js → roy-agent-core-cssnkkkg.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-vfk5mtbx.js → roy-agent-core-ct95gkee.js} +34 -30
- package/dist/shared/@ai-setting/{roy-agent-core-pvswd18d.js → roy-agent-core-e68xspar.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-7b35emr7.js → roy-agent-core-ew29335n.js} +3 -2
- package/dist/shared/@ai-setting/{roy-agent-core-y85xsddt.js → roy-agent-core-f336bk4g.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-yq4fv8ce.js → roy-agent-core-hd9p5490.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-t32gmaqn.js → roy-agent-core-kjdpe2ey.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-d8v4n80n.js → roy-agent-core-mab4mzg3.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-6mcb7nqa.js → roy-agent-core-pcjenbaf.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-48v06q1b.js → roy-agent-core-qmr365f5.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-316v7cm4.js → roy-agent-core-rmndq0sb.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-mangq9x1.js → roy-agent-core-rz57pqpa.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-4b18eceq.js → roy-agent-core-smwwze1m.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-s7bgrtch.js → roy-agent-core-v7583cf9.js} +12 -2
- package/dist/shared/@ai-setting/{roy-agent-core-5qe84a90.js → roy-agent-core-vbyct0e7.js} +21 -16
- package/dist/shared/@ai-setting/{roy-agent-core-m5g2jx7f.js → roy-agent-core-vehgmfj1.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-wtnwxn8h.js → roy-agent-core-wbqmmavh.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-sxd8snnj.js → roy-agent-core-zmw5d68q.js} +1 -1
- package/package.json +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-fy1y1aqx.js +0 -248
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
globalHookManager,
|
|
9
9
|
init_global_hook_manager
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-qmr365f5.js";
|
|
11
11
|
import {
|
|
12
12
|
init_env_context,
|
|
13
13
|
setCurrentTaskId
|
|
14
|
-
} from "./roy-agent-core-
|
|
14
|
+
} from "./roy-agent-core-v7583cf9.js";
|
|
15
15
|
import {
|
|
16
16
|
TracedAs,
|
|
17
17
|
init_decorator
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
BackgroundTaskManager,
|
|
6
6
|
createDelegateTool,
|
|
7
7
|
createStopTool
|
|
8
|
-
} from "./roy-agent-core-
|
|
8
|
+
} from "./roy-agent-core-vehgmfj1.js";
|
|
9
9
|
import {
|
|
10
10
|
SQLiteTaskStore,
|
|
11
11
|
getDefaultTaskDbPath
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
getTaskTool,
|
|
18
18
|
listTasksTool,
|
|
19
19
|
updateTaskTool
|
|
20
|
-
} from "./roy-agent-core-
|
|
20
|
+
} from "./roy-agent-core-2xah3h0z.js";
|
|
21
21
|
import {
|
|
22
22
|
createOperationTool,
|
|
23
23
|
deleteOperationTool,
|
|
@@ -33,11 +33,11 @@ import {
|
|
|
33
33
|
} from "./roy-agent-core-qxhq8ven.js";
|
|
34
34
|
import {
|
|
35
35
|
BaseComponent
|
|
36
|
-
} from "./roy-agent-core-
|
|
36
|
+
} from "./roy-agent-core-cssnkkkg.js";
|
|
37
37
|
import {
|
|
38
38
|
globalHookManager,
|
|
39
39
|
init_global_hook_manager
|
|
40
|
-
} from "./roy-agent-core-
|
|
40
|
+
} from "./roy-agent-core-qmr365f5.js";
|
|
41
41
|
import {
|
|
42
42
|
TracedAs,
|
|
43
43
|
init_decorator
|
package/package.json
CHANGED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WORKFLOW_JSON_OUTPUT_PLUGIN_KEY,
|
|
3
|
-
init_workflow_json_output_plugin,
|
|
4
|
-
registerWorkflowJsonOutputPlugin,
|
|
5
|
-
tracedExtractStructuredJsonViaLlm
|
|
6
|
-
} from "./roy-agent-core-9a2n122m.js";
|
|
7
|
-
import {
|
|
8
|
-
AskUserError,
|
|
9
|
-
init_workflow_hil
|
|
10
|
-
} from "./roy-agent-core-e25xkv53.js";
|
|
11
|
-
import {
|
|
12
|
-
__esm
|
|
13
|
-
} from "./roy-agent-core-fs0mn2jk.js";
|
|
14
|
-
|
|
15
|
-
// src/env/workflow/nodes/agent-component-adapter.ts
|
|
16
|
-
class AgentComponentAdapter {
|
|
17
|
-
agentComponent;
|
|
18
|
-
options;
|
|
19
|
-
_sessionComponent;
|
|
20
|
-
_llmComponent;
|
|
21
|
-
agentSessionPrefix = "agent";
|
|
22
|
-
_currentAgentSessionId;
|
|
23
|
-
pendingSessions = new Map;
|
|
24
|
-
runSessionToAgentSessions = new Map;
|
|
25
|
-
jsonOutputPluginRegistered = false;
|
|
26
|
-
constructor(agentComponent, options = {}, _sessionComponent, _llmComponent) {
|
|
27
|
-
this.agentComponent = agentComponent;
|
|
28
|
-
this.options = options;
|
|
29
|
-
this._sessionComponent = _sessionComponent;
|
|
30
|
-
this._llmComponent = _llmComponent;
|
|
31
|
-
this.ensureJsonOutputPluginRegistered();
|
|
32
|
-
}
|
|
33
|
-
setLLMComponent(llmComponent) {
|
|
34
|
-
this._llmComponent = llmComponent;
|
|
35
|
-
this.ensureJsonOutputPluginRegistered();
|
|
36
|
-
}
|
|
37
|
-
ensureJsonOutputPluginRegistered() {
|
|
38
|
-
if (this.jsonOutputPluginRegistered || !this._llmComponent) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
registerWorkflowJsonOutputPlugin(this._llmComponent);
|
|
42
|
-
this.jsonOutputPluginRegistered = true;
|
|
43
|
-
}
|
|
44
|
-
setSessionComponent(sessionComponent) {
|
|
45
|
-
this._sessionComponent = sessionComponent;
|
|
46
|
-
}
|
|
47
|
-
getCurrentAgentSessionId() {
|
|
48
|
-
return this._currentAgentSessionId;
|
|
49
|
-
}
|
|
50
|
-
registerAgent(name, config) {
|
|
51
|
-
this.agentComponent.registerAgent(name, {
|
|
52
|
-
type: config.type || "general",
|
|
53
|
-
model: config.model,
|
|
54
|
-
systemPrompt: config.systemPrompt,
|
|
55
|
-
maxIterations: config.maxIterations,
|
|
56
|
-
allowedTools: config.allowedTools,
|
|
57
|
-
deniedTools: config.deniedTools,
|
|
58
|
-
timeout: config.timeout,
|
|
59
|
-
maxErrorRetries: config.maxErrorRetries
|
|
60
|
-
});
|
|
61
|
-
if (config.sessionIdPrefix) {
|
|
62
|
-
this.agentSessionPrefixes.set(name, config.sessionIdPrefix);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
async run(config, resumeOptions) {
|
|
66
|
-
const startTime = Date.now();
|
|
67
|
-
const nodeId = config.nodeId || "unknown";
|
|
68
|
-
const runId = config.runId || "unknown";
|
|
69
|
-
const workflowSessionId = config.workflowSessionId;
|
|
70
|
-
const isResume = !!resumeOptions?.userQuery;
|
|
71
|
-
let agentSessionId = resumeOptions?.agentSessionId || config.agentSessionId || this._currentAgentSessionId;
|
|
72
|
-
if (!agentSessionId && this._sessionComponent) {
|
|
73
|
-
agentSessionId = `${this.agentSessionPrefix}_${runId}_${nodeId}_${Date.now()}`;
|
|
74
|
-
try {
|
|
75
|
-
await this._sessionComponent.create({
|
|
76
|
-
title: `Agent Session: ${config.type} (${agentSessionId})`,
|
|
77
|
-
metadata: {
|
|
78
|
-
type: "agent",
|
|
79
|
-
workflowRunId: runId,
|
|
80
|
-
workflowNodeId: nodeId
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
} catch (error) {
|
|
84
|
-
console.warn(`Failed to create agent session ${agentSessionId}:`, error);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (agentSessionId) {
|
|
88
|
-
this._currentAgentSessionId = agentSessionId;
|
|
89
|
-
if (workflowSessionId && this._sessionComponent) {
|
|
90
|
-
const mapping = this.runSessionToAgentSessions.get(workflowSessionId) || [];
|
|
91
|
-
if (!mapping.includes(agentSessionId)) {
|
|
92
|
-
mapping.push(agentSessionId);
|
|
93
|
-
this.runSessionToAgentSessions.set(workflowSessionId, mapping);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (isResume) {
|
|
97
|
-
this.pendingSessions.delete(agentSessionId);
|
|
98
|
-
} else {
|
|
99
|
-
this.pendingSessions.set(agentSessionId, {
|
|
100
|
-
agentSessionId,
|
|
101
|
-
nodeId,
|
|
102
|
-
runId,
|
|
103
|
-
createdAt: Date.now()
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
try {
|
|
108
|
-
const outputSchema = config.options?.outputSchema;
|
|
109
|
-
const context = {};
|
|
110
|
-
if (config.options?.timeout) {
|
|
111
|
-
context.abort = new AbortController;
|
|
112
|
-
}
|
|
113
|
-
if (agentSessionId) {
|
|
114
|
-
context.sessionId = agentSessionId;
|
|
115
|
-
}
|
|
116
|
-
if (config.options?.allowedTools) {
|
|
117
|
-
context.allowedTools = config.options.allowedTools;
|
|
118
|
-
}
|
|
119
|
-
if (config.options?.deniedTools) {
|
|
120
|
-
context.deniedTools = config.options.deniedTools;
|
|
121
|
-
}
|
|
122
|
-
context.metadata = {
|
|
123
|
-
runId,
|
|
124
|
-
nodeId,
|
|
125
|
-
sessionId: agentSessionId,
|
|
126
|
-
outputSchema
|
|
127
|
-
};
|
|
128
|
-
if (outputSchema) {
|
|
129
|
-
context.pluginEnabled = {
|
|
130
|
-
...context.pluginEnabled ?? {},
|
|
131
|
-
[WORKFLOW_JSON_OUTPUT_PLUGIN_KEY]: true
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
if (config.workflowHistory) {
|
|
135
|
-
context.workflowHistory = config.workflowHistory;
|
|
136
|
-
}
|
|
137
|
-
let additionInfo = config.prompt;
|
|
138
|
-
let userInput = resumeOptions?.userQuery || "";
|
|
139
|
-
if (agentSessionId && this._sessionComponent && !isResume) {
|
|
140
|
-
try {
|
|
141
|
-
const priorMessages = await this._sessionComponent.getMessages(agentSessionId);
|
|
142
|
-
const hasPriorAssistant = priorMessages.some((m) => m.role === "assistant" && (Boolean(m.content?.trim()) || m.parts?.some((p) => p.type === "tool-call" || p.type === "text")));
|
|
143
|
-
if (hasPriorAssistant && !userInput) {
|
|
144
|
-
userInput = "[Workflow re-run] Inputs were updated since your last reply. Produce a new result for this run.";
|
|
145
|
-
}
|
|
146
|
-
} catch {}
|
|
147
|
-
}
|
|
148
|
-
context.additionInfo = additionInfo;
|
|
149
|
-
const result = await this.agentComponent.run(config.type || "general", userInput, context);
|
|
150
|
-
if (result.error?.startsWith("__ASK_USER_ERROR__:")) {
|
|
151
|
-
const jsonStr = result.error.substring("__ASK_USER_ERROR__:".length);
|
|
152
|
-
const errorInfo = JSON.parse(jsonStr);
|
|
153
|
-
throw new AskUserError(runId, errorInfo.sessionId, errorInfo.nodeId, errorInfo.nodeType || "agent", errorInfo.query);
|
|
154
|
-
}
|
|
155
|
-
const duration = Date.now() - startTime;
|
|
156
|
-
if (agentSessionId) {
|
|
157
|
-
this.pendingSessions.delete(agentSessionId);
|
|
158
|
-
}
|
|
159
|
-
const structuredOutput = await this.resolveStructuredOutput(result.structuredOutput, outputSchema, config, agentSessionId);
|
|
160
|
-
return {
|
|
161
|
-
output: structuredOutput ?? result.finalText ?? result.output,
|
|
162
|
-
structuredOutput,
|
|
163
|
-
metadata: {
|
|
164
|
-
duration,
|
|
165
|
-
iterations: result.iterations,
|
|
166
|
-
toolCalls: result.toolCalls?.length,
|
|
167
|
-
toolCallsDetail: result.toolCalls,
|
|
168
|
-
agentSessionId
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
} catch (error) {
|
|
172
|
-
const isAskUserError = error instanceof Error && error.name === "AskUserError";
|
|
173
|
-
if (isAskUserError) {
|
|
174
|
-
throw error;
|
|
175
|
-
}
|
|
176
|
-
const duration = Date.now() - startTime;
|
|
177
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
178
|
-
if (agentSessionId) {
|
|
179
|
-
this.pendingSessions.delete(agentSessionId);
|
|
180
|
-
}
|
|
181
|
-
return {
|
|
182
|
-
output: undefined,
|
|
183
|
-
metadata: {
|
|
184
|
-
duration,
|
|
185
|
-
error: errorMessage,
|
|
186
|
-
agentSessionId
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
} finally {
|
|
190
|
-
if (isResume) {
|
|
191
|
-
this._currentAgentSessionId = undefined;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
async resumeAgent(agentSessionId, userQuery, config) {
|
|
196
|
-
this.pendingSessions.delete(agentSessionId);
|
|
197
|
-
this._currentAgentSessionId = agentSessionId;
|
|
198
|
-
config.agentSessionId = agentSessionId;
|
|
199
|
-
return this.run(config, { userQuery, agentSessionId });
|
|
200
|
-
}
|
|
201
|
-
getPendingSession(agentSessionId) {
|
|
202
|
-
return this.pendingSessions.get(agentSessionId);
|
|
203
|
-
}
|
|
204
|
-
getPendingSessionsForRun(runId) {
|
|
205
|
-
return Array.from(this.pendingSessions.values()).filter((session) => session.runId === runId);
|
|
206
|
-
}
|
|
207
|
-
getAgentSessionsForWorkflowSession(workflowSessionId) {
|
|
208
|
-
return this.runSessionToAgentSessions.get(workflowSessionId) || [];
|
|
209
|
-
}
|
|
210
|
-
hasAgent(name) {
|
|
211
|
-
return this.agentComponent.getAgent(name) !== undefined;
|
|
212
|
-
}
|
|
213
|
-
listAgents() {
|
|
214
|
-
return this.agentComponent.listAgents().map((a) => a.name);
|
|
215
|
-
}
|
|
216
|
-
getAgentComponent() {
|
|
217
|
-
return this.agentComponent;
|
|
218
|
-
}
|
|
219
|
-
async resolveStructuredOutput(fromPlugin, outputSchema, config, agentSessionId) {
|
|
220
|
-
if (fromPlugin) {
|
|
221
|
-
return fromPlugin;
|
|
222
|
-
}
|
|
223
|
-
if (!outputSchema || !this._llmComponent || !agentSessionId || !this._sessionComponent) {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
try {
|
|
227
|
-
const sessionMessages = await this._sessionComponent.getMessages(agentSessionId);
|
|
228
|
-
const history = sessionMessages.map((m) => ({
|
|
229
|
-
role: m.role,
|
|
230
|
-
content: m.content ?? ""
|
|
231
|
-
}));
|
|
232
|
-
return await tracedExtractStructuredJsonViaLlm(this._llmComponent, history, outputSchema, {
|
|
233
|
-
model: config.options?.model,
|
|
234
|
-
sessionId: agentSessionId
|
|
235
|
-
});
|
|
236
|
-
} catch (error) {
|
|
237
|
-
console.warn("Workflow JSON extraction fallback failed:", error);
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
agentSessionPrefixes = new Map;
|
|
242
|
-
}
|
|
243
|
-
var init_agent_component_adapter = __esm(() => {
|
|
244
|
-
init_workflow_hil();
|
|
245
|
-
init_workflow_json_output_plugin();
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
export { AgentComponentAdapter, init_agent_component_adapter };
|