@ai-setting/roy-agent-core 1.5.49 → 1.5.51
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 +10 -6
- package/dist/env/agent/index.js +7 -7
- package/dist/env/commands/index.js +7 -6
- package/dist/env/context/index.js +6 -2
- package/dist/env/debug/index.js +10 -6
- package/dist/env/event-source/index.js +9 -9
- package/dist/env/hook/index.js +8 -4
- package/dist/env/index.js +20 -20
- package/dist/env/llm/index.js +7 -7
- package/dist/env/log-trace/index.js +7 -7
- package/dist/env/mcp/index.js +7 -6
- package/dist/env/memory/index.js +7 -6
- package/dist/env/plugin/index.js +7 -6
- package/dist/env/prompt/index.js +7 -6
- package/dist/env/session/index.js +7 -7
- package/dist/env/skill/index.js +7 -6
- package/dist/env/task/delegate/index.js +4 -4
- package/dist/env/task/index.js +9 -9
- package/dist/env/task/plugins/index.js +3 -3
- package/dist/env/task/tools/index.js +3 -2
- package/dist/env/tool/index.js +7 -6
- package/dist/env/workflow/engine/index.js +6 -6
- package/dist/env/workflow/index.js +9 -9
- package/dist/index.js +34 -34
- package/dist/shared/@ai-setting/{roy-agent-core-h6bqx4jj.js → roy-agent-core-0frwccap.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-607ktjxs.js → roy-agent-core-0x3g6snw.js} +8 -6
- package/dist/shared/@ai-setting/{roy-agent-core-8f8dq3kj.js → roy-agent-core-13vzexp2.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-n1awj8ks.js → roy-agent-core-29867p67.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-bjphrqsm.js → roy-agent-core-2g5j2nw6.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-sj2yd6g4.js → roy-agent-core-2k4r9grg.js} +27 -17
- package/dist/shared/@ai-setting/{roy-agent-core-7qj11qp8.js → roy-agent-core-2xah3h0z.js} +11 -6
- package/dist/shared/@ai-setting/{roy-agent-core-pxp9yq24.js → roy-agent-core-3jk7ngmx.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-dvrfs18y.js → roy-agent-core-4hk6ey73.js} +17 -2
- package/dist/shared/@ai-setting/{roy-agent-core-5dkewp2h.js → roy-agent-core-5k8watmp.js} +24 -9
- package/dist/shared/@ai-setting/{roy-agent-core-wv9as4ds.js → roy-agent-core-5t6cryce.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-476ewnwy.js → roy-agent-core-6de35s2n.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-rrsn14cr.js → roy-agent-core-88d3k0p0.js} +4 -4
- package/dist/shared/@ai-setting/roy-agent-core-awmae5ax.js +258 -0
- package/dist/shared/@ai-setting/{roy-agent-core-gfzqwb6v.js → roy-agent-core-cssnkkkg.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-8whpa5yz.js → roy-agent-core-e68xspar.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-14fna5qg.js → roy-agent-core-f336bk4g.js} +6 -6
- package/dist/shared/@ai-setting/{roy-agent-core-cv8kqab8.js → roy-agent-core-h9tpga25.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-z3pq1nx9.js → roy-agent-core-hd9p5490.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-rwt7b6dh.js → roy-agent-core-kjdpe2ey.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-ym6qbh1e.js → roy-agent-core-mab4mzg3.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-xpw0mtfv.js → roy-agent-core-qjh1ec46.js} +6 -6
- package/dist/shared/@ai-setting/{roy-agent-core-nxf64fn4.js → roy-agent-core-qmr365f5.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-d40gbvzj.js → roy-agent-core-rmndq0sb.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-4zjdkqry.js → roy-agent-core-rz57pqpa.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-3nw9vxp2.js → roy-agent-core-smwwze1m.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-dre9rcs0.js → roy-agent-core-v7583cf9.js} +28 -5
- package/dist/shared/@ai-setting/{roy-agent-core-g3j3ftbw.js → roy-agent-core-vehgmfj1.js} +9 -9
- package/dist/shared/@ai-setting/{roy-agent-core-yv7dppda.js → roy-agent-core-wbqmmavh.js} +8 -8
- package/dist/shared/@ai-setting/{roy-agent-core-2m5qnhv9.js → roy-agent-core-zmw5d68q.js} +1 -1
- package/package.json +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-1a38hg1q.js +0 -248
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
init_decorator
|
|
3
|
-
} from "./roy-agent-core-q5qj0fes.js";
|
|
4
1
|
import {
|
|
5
2
|
envKeyToConfigKey
|
|
6
3
|
} from "./roy-agent-core-qxhq8ven.js";
|
|
7
4
|
import {
|
|
8
5
|
BaseComponent
|
|
9
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-cssnkkkg.js";
|
|
7
|
+
import {
|
|
8
|
+
init_decorator
|
|
9
|
+
} from "./roy-agent-core-q5qj0fes.js";
|
|
10
10
|
import {
|
|
11
11
|
createLogger,
|
|
12
12
|
init_logger,
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WORKFLOW_JSON_OUTPUT_PLUGIN_KEY,
|
|
3
|
+
init_workflow_json_output_plugin,
|
|
4
|
+
registerWorkflowJsonOutputPlugin,
|
|
5
|
+
tracedExtractStructuredJsonViaLlm
|
|
6
|
+
} from "./roy-agent-core-29867p67.js";
|
|
7
|
+
import {
|
|
8
|
+
AskUserError,
|
|
9
|
+
init_workflow_hil
|
|
10
|
+
} from "./roy-agent-core-e25xkv53.js";
|
|
11
|
+
import {
|
|
12
|
+
TracedAs,
|
|
13
|
+
init_decorator
|
|
14
|
+
} from "./roy-agent-core-q5qj0fes.js";
|
|
15
|
+
import {
|
|
16
|
+
__esm,
|
|
17
|
+
__legacyDecorateClassTS
|
|
18
|
+
} from "./roy-agent-core-fs0mn2jk.js";
|
|
19
|
+
|
|
20
|
+
// src/env/workflow/nodes/agent-component-adapter.ts
|
|
21
|
+
var AgentComponentAdapter;
|
|
22
|
+
var init_agent_component_adapter = __esm(() => {
|
|
23
|
+
init_workflow_hil();
|
|
24
|
+
init_workflow_json_output_plugin();
|
|
25
|
+
init_decorator();
|
|
26
|
+
AgentComponentAdapter = class AgentComponentAdapter {
|
|
27
|
+
agentComponent;
|
|
28
|
+
options;
|
|
29
|
+
_sessionComponent;
|
|
30
|
+
_llmComponent;
|
|
31
|
+
agentSessionPrefix = "agent";
|
|
32
|
+
_currentAgentSessionId;
|
|
33
|
+
pendingSessions = new Map;
|
|
34
|
+
runSessionToAgentSessions = new Map;
|
|
35
|
+
jsonOutputPluginRegistered = false;
|
|
36
|
+
constructor(agentComponent, options = {}, _sessionComponent, _llmComponent) {
|
|
37
|
+
this.agentComponent = agentComponent;
|
|
38
|
+
this.options = options;
|
|
39
|
+
this._sessionComponent = _sessionComponent;
|
|
40
|
+
this._llmComponent = _llmComponent;
|
|
41
|
+
this.ensureJsonOutputPluginRegistered();
|
|
42
|
+
}
|
|
43
|
+
setLLMComponent(llmComponent) {
|
|
44
|
+
this._llmComponent = llmComponent;
|
|
45
|
+
this.ensureJsonOutputPluginRegistered();
|
|
46
|
+
}
|
|
47
|
+
ensureJsonOutputPluginRegistered() {
|
|
48
|
+
if (this.jsonOutputPluginRegistered || !this._llmComponent) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
registerWorkflowJsonOutputPlugin(this._llmComponent);
|
|
52
|
+
this.jsonOutputPluginRegistered = true;
|
|
53
|
+
}
|
|
54
|
+
setSessionComponent(sessionComponent) {
|
|
55
|
+
this._sessionComponent = sessionComponent;
|
|
56
|
+
}
|
|
57
|
+
getCurrentAgentSessionId() {
|
|
58
|
+
return this._currentAgentSessionId;
|
|
59
|
+
}
|
|
60
|
+
registerAgent(name, config) {
|
|
61
|
+
this.agentComponent.registerAgent(name, {
|
|
62
|
+
type: config.type || "general",
|
|
63
|
+
model: config.model,
|
|
64
|
+
systemPrompt: config.systemPrompt,
|
|
65
|
+
maxIterations: config.maxIterations,
|
|
66
|
+
allowedTools: config.allowedTools,
|
|
67
|
+
deniedTools: config.deniedTools,
|
|
68
|
+
timeout: config.timeout,
|
|
69
|
+
maxErrorRetries: config.maxErrorRetries
|
|
70
|
+
});
|
|
71
|
+
if (config.sessionIdPrefix) {
|
|
72
|
+
this.agentSessionPrefixes.set(name, config.sessionIdPrefix);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async run(config, resumeOptions) {
|
|
76
|
+
const startTime = Date.now();
|
|
77
|
+
const nodeId = config.nodeId || "unknown";
|
|
78
|
+
const runId = config.runId || "unknown";
|
|
79
|
+
const workflowSessionId = config.workflowSessionId;
|
|
80
|
+
const isResume = !!resumeOptions?.userQuery;
|
|
81
|
+
let agentSessionId = resumeOptions?.agentSessionId || config.agentSessionId || this._currentAgentSessionId;
|
|
82
|
+
if (!agentSessionId && this._sessionComponent) {
|
|
83
|
+
agentSessionId = `${this.agentSessionPrefix}_${runId}_${nodeId}_${Date.now()}`;
|
|
84
|
+
try {
|
|
85
|
+
await this._sessionComponent.create({
|
|
86
|
+
title: `Agent Session: ${config.type} (${agentSessionId})`,
|
|
87
|
+
metadata: {
|
|
88
|
+
type: "agent",
|
|
89
|
+
workflowRunId: runId,
|
|
90
|
+
workflowNodeId: nodeId
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.warn(`Failed to create agent session ${agentSessionId}:`, error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (agentSessionId) {
|
|
98
|
+
this._currentAgentSessionId = agentSessionId;
|
|
99
|
+
if (workflowSessionId && this._sessionComponent) {
|
|
100
|
+
const mapping = this.runSessionToAgentSessions.get(workflowSessionId) || [];
|
|
101
|
+
if (!mapping.includes(agentSessionId)) {
|
|
102
|
+
mapping.push(agentSessionId);
|
|
103
|
+
this.runSessionToAgentSessions.set(workflowSessionId, mapping);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (isResume) {
|
|
107
|
+
this.pendingSessions.delete(agentSessionId);
|
|
108
|
+
} else {
|
|
109
|
+
this.pendingSessions.set(agentSessionId, {
|
|
110
|
+
agentSessionId,
|
|
111
|
+
nodeId,
|
|
112
|
+
runId,
|
|
113
|
+
createdAt: Date.now()
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const outputSchema = config.options?.outputSchema;
|
|
119
|
+
const context = {};
|
|
120
|
+
if (config.options?.timeout) {
|
|
121
|
+
context.abort = new AbortController;
|
|
122
|
+
}
|
|
123
|
+
if (agentSessionId) {
|
|
124
|
+
context.sessionId = agentSessionId;
|
|
125
|
+
}
|
|
126
|
+
if (config.options?.allowedTools) {
|
|
127
|
+
context.allowedTools = config.options.allowedTools;
|
|
128
|
+
}
|
|
129
|
+
if (config.options?.deniedTools) {
|
|
130
|
+
context.deniedTools = config.options.deniedTools;
|
|
131
|
+
}
|
|
132
|
+
context.metadata = {
|
|
133
|
+
runId,
|
|
134
|
+
nodeId,
|
|
135
|
+
sessionId: agentSessionId,
|
|
136
|
+
outputSchema
|
|
137
|
+
};
|
|
138
|
+
if (outputSchema) {
|
|
139
|
+
context.pluginEnabled = {
|
|
140
|
+
...context.pluginEnabled ?? {},
|
|
141
|
+
[WORKFLOW_JSON_OUTPUT_PLUGIN_KEY]: true
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (config.workflowHistory) {
|
|
145
|
+
context.workflowHistory = config.workflowHistory;
|
|
146
|
+
}
|
|
147
|
+
let additionInfo = config.prompt;
|
|
148
|
+
let userInput = resumeOptions?.userQuery || "";
|
|
149
|
+
if (agentSessionId && this._sessionComponent && !isResume) {
|
|
150
|
+
try {
|
|
151
|
+
const priorMessages = await this._sessionComponent.getMessages(agentSessionId);
|
|
152
|
+
const hasPriorAssistant = priorMessages.some((m) => m.role === "assistant" && (Boolean(m.content?.trim()) || m.parts?.some((p) => p.type === "tool-call" || p.type === "text")));
|
|
153
|
+
if (hasPriorAssistant && !userInput) {
|
|
154
|
+
userInput = "[Workflow re-run] Inputs were updated since your last reply. Produce a new result for this run.";
|
|
155
|
+
}
|
|
156
|
+
} catch {}
|
|
157
|
+
}
|
|
158
|
+
context.additionInfo = additionInfo;
|
|
159
|
+
const result = await this.agentComponent.run(config.type || "general", userInput, context);
|
|
160
|
+
if (result.error?.startsWith("__ASK_USER_ERROR__:")) {
|
|
161
|
+
const jsonStr = result.error.substring("__ASK_USER_ERROR__:".length);
|
|
162
|
+
const errorInfo = JSON.parse(jsonStr);
|
|
163
|
+
throw new AskUserError(runId, errorInfo.sessionId, errorInfo.nodeId, errorInfo.nodeType || "agent", errorInfo.query);
|
|
164
|
+
}
|
|
165
|
+
const duration = Date.now() - startTime;
|
|
166
|
+
if (agentSessionId) {
|
|
167
|
+
this.pendingSessions.delete(agentSessionId);
|
|
168
|
+
}
|
|
169
|
+
const structuredOutput = await this.resolveStructuredOutput(result.structuredOutput, outputSchema, config, agentSessionId);
|
|
170
|
+
return {
|
|
171
|
+
output: structuredOutput ?? result.finalText ?? result.output,
|
|
172
|
+
structuredOutput,
|
|
173
|
+
metadata: {
|
|
174
|
+
duration,
|
|
175
|
+
iterations: result.iterations,
|
|
176
|
+
toolCalls: result.toolCalls?.length,
|
|
177
|
+
toolCallsDetail: result.toolCalls,
|
|
178
|
+
agentSessionId
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
} catch (error) {
|
|
182
|
+
const isAskUserError = error instanceof Error && error.name === "AskUserError";
|
|
183
|
+
if (isAskUserError) {
|
|
184
|
+
throw error;
|
|
185
|
+
}
|
|
186
|
+
const duration = Date.now() - startTime;
|
|
187
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
188
|
+
if (agentSessionId) {
|
|
189
|
+
this.pendingSessions.delete(agentSessionId);
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
output: undefined,
|
|
193
|
+
metadata: {
|
|
194
|
+
duration,
|
|
195
|
+
error: errorMessage,
|
|
196
|
+
agentSessionId
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
} finally {
|
|
200
|
+
if (isResume) {
|
|
201
|
+
this._currentAgentSessionId = undefined;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
async resumeAgent(agentSessionId, userQuery, config) {
|
|
206
|
+
this.pendingSessions.delete(agentSessionId);
|
|
207
|
+
this._currentAgentSessionId = agentSessionId;
|
|
208
|
+
config.agentSessionId = agentSessionId;
|
|
209
|
+
return this.run(config, { userQuery, agentSessionId });
|
|
210
|
+
}
|
|
211
|
+
getPendingSession(agentSessionId) {
|
|
212
|
+
return this.pendingSessions.get(agentSessionId);
|
|
213
|
+
}
|
|
214
|
+
getPendingSessionsForRun(runId) {
|
|
215
|
+
return Array.from(this.pendingSessions.values()).filter((session) => session.runId === runId);
|
|
216
|
+
}
|
|
217
|
+
getAgentSessionsForWorkflowSession(workflowSessionId) {
|
|
218
|
+
return this.runSessionToAgentSessions.get(workflowSessionId) || [];
|
|
219
|
+
}
|
|
220
|
+
hasAgent(name) {
|
|
221
|
+
return this.agentComponent.getAgent(name) !== undefined;
|
|
222
|
+
}
|
|
223
|
+
listAgents() {
|
|
224
|
+
return this.agentComponent.listAgents().map((a) => a.name);
|
|
225
|
+
}
|
|
226
|
+
getAgentComponent() {
|
|
227
|
+
return this.agentComponent;
|
|
228
|
+
}
|
|
229
|
+
async resolveStructuredOutput(fromPlugin, outputSchema, config, agentSessionId) {
|
|
230
|
+
if (fromPlugin) {
|
|
231
|
+
return fromPlugin;
|
|
232
|
+
}
|
|
233
|
+
if (!outputSchema || !this._llmComponent || !agentSessionId || !this._sessionComponent) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
const sessionMessages = await this._sessionComponent.getMessages(agentSessionId);
|
|
238
|
+
const history = sessionMessages.map((m) => ({
|
|
239
|
+
role: m.role,
|
|
240
|
+
content: m.content ?? ""
|
|
241
|
+
}));
|
|
242
|
+
return await tracedExtractStructuredJsonViaLlm(this._llmComponent, history, outputSchema, {
|
|
243
|
+
model: config.options?.model,
|
|
244
|
+
sessionId: agentSessionId
|
|
245
|
+
});
|
|
246
|
+
} catch (error) {
|
|
247
|
+
console.warn("Workflow JSON extraction fallback failed:", error);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
agentSessionPrefixes = new Map;
|
|
252
|
+
};
|
|
253
|
+
__legacyDecorateClassTS([
|
|
254
|
+
TracedAs("workflow.agent_adapter.run", { recordParams: true, recordResult: true, log: true })
|
|
255
|
+
], AgentComponentAdapter.prototype, "run", null);
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
export { AgentComponentAdapter, init_agent_component_adapter };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createHook
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-hd9p5490.js";
|
|
4
4
|
import {
|
|
5
5
|
HookManager
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-qmr365f5.js";
|
|
7
7
|
|
|
8
8
|
// src/env/component.ts
|
|
9
9
|
class BaseComponent {
|
|
@@ -4,16 +4,16 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
TaskHookPoints
|
|
6
6
|
} from "./roy-agent-core-92z6t4he.js";
|
|
7
|
-
import {
|
|
8
|
-
TracedAs,
|
|
9
|
-
init_decorator
|
|
10
|
-
} from "./roy-agent-core-q5qj0fes.js";
|
|
11
7
|
import {
|
|
12
8
|
init_context
|
|
13
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-13vzexp2.js";
|
|
14
10
|
import {
|
|
15
11
|
getEnvContextOrEmpty
|
|
16
|
-
} from "./roy-agent-core-
|
|
12
|
+
} from "./roy-agent-core-v7583cf9.js";
|
|
13
|
+
import {
|
|
14
|
+
TracedAs,
|
|
15
|
+
init_decorator
|
|
16
|
+
} from "./roy-agent-core-q5qj0fes.js";
|
|
17
17
|
import {
|
|
18
18
|
createLogger,
|
|
19
19
|
init_logger
|
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
} from "./roy-agent-core-qxhq8ven.js";
|
|
8
8
|
import {
|
|
9
9
|
BaseComponent
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-cssnkkkg.js";
|
|
11
11
|
import {
|
|
12
12
|
createHook
|
|
13
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-hd9p5490.js";
|
|
14
14
|
import {
|
|
15
15
|
globalHookManager,
|
|
16
16
|
init_global_hook_manager
|
|
17
|
-
} from "./roy-agent-core-
|
|
17
|
+
} from "./roy-agent-core-qmr365f5.js";
|
|
18
18
|
import {
|
|
19
19
|
createLogger,
|
|
20
20
|
init_logger
|
|
@@ -2,22 +2,22 @@ import {
|
|
|
2
2
|
ContextError,
|
|
3
3
|
ErrorCodes
|
|
4
4
|
} from "./roy-agent-core-ctdhjv68.js";
|
|
5
|
-
import {
|
|
6
|
-
TracedAs,
|
|
7
|
-
init_decorator
|
|
8
|
-
} from "./roy-agent-core-q5qj0fes.js";
|
|
9
5
|
import {
|
|
10
6
|
envKeyToConfigKey,
|
|
11
7
|
toEnvKey
|
|
12
8
|
} from "./roy-agent-core-qxhq8ven.js";
|
|
13
9
|
import {
|
|
14
10
|
BaseComponent
|
|
15
|
-
} from "./roy-agent-core-
|
|
11
|
+
} from "./roy-agent-core-cssnkkkg.js";
|
|
16
12
|
import {
|
|
17
13
|
LLMHookPoints,
|
|
18
14
|
globalHookManager,
|
|
19
15
|
init_global_hook_manager
|
|
20
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-qmr365f5.js";
|
|
17
|
+
import {
|
|
18
|
+
TracedAs,
|
|
19
|
+
init_decorator
|
|
20
|
+
} from "./roy-agent-core-q5qj0fes.js";
|
|
21
21
|
import {
|
|
22
22
|
createLogger,
|
|
23
23
|
init_logger
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
init_context
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-13vzexp2.js";
|
|
4
4
|
import {
|
|
5
5
|
getEnvContext
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-v7583cf9.js";
|
|
7
7
|
import {
|
|
8
8
|
__esm
|
|
9
9
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseComponent
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-cssnkkkg.js";
|
|
4
4
|
import {
|
|
5
5
|
globalHookManager,
|
|
6
6
|
init_global_hook_manager
|
|
7
|
-
} from "./roy-agent-core-
|
|
7
|
+
} from "./roy-agent-core-qmr365f5.js";
|
|
8
8
|
import {
|
|
9
9
|
createLogger,
|
|
10
10
|
init_logger
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
WorkflowEngine,
|
|
7
7
|
exports_engine,
|
|
8
8
|
init_engine
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-rmndq0sb.js";
|
|
10
10
|
import {
|
|
11
11
|
WorkflowService
|
|
12
12
|
} from "./roy-agent-core-4t40mkpv.js";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./roy-agent-core-0vbdz0x7.js";
|
|
16
16
|
import {
|
|
17
17
|
BaseComponent
|
|
18
|
-
} from "./roy-agent-core-
|
|
18
|
+
} from "./roy-agent-core-cssnkkkg.js";
|
|
19
19
|
import {
|
|
20
20
|
createLogger,
|
|
21
21
|
init_logger
|
|
@@ -136,7 +136,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
136
136
|
const agentComponent = this._workflowEnv.getComponent("agent");
|
|
137
137
|
const llmComponent = this._workflowEnv.getComponent("llm");
|
|
138
138
|
if (agentComponent) {
|
|
139
|
-
const { AgentComponentAdapter } = await import("./roy-agent-core-
|
|
139
|
+
const { AgentComponentAdapter } = await import("./roy-agent-core-0frwccap.js");
|
|
140
140
|
agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent, llmComponent);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -208,7 +208,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
208
208
|
const sessionComponent = this._workflowEnv?.getComponent("session");
|
|
209
209
|
componentLogger.info(`initSqliteService - toolComponent: ${!!toolComponent}, llmComponent: ${!!llmComponent}, skillRegistry: ${!!skillComponent}, sessionComponent: ${!!sessionComponent}`);
|
|
210
210
|
if (llmComponent) {
|
|
211
|
-
const { registerWorkflowJsonOutputPlugin } = await import("./roy-agent-core-
|
|
211
|
+
const { registerWorkflowJsonOutputPlugin } = await import("./roy-agent-core-3jk7ngmx.js");
|
|
212
212
|
registerWorkflowJsonOutputPlugin(llmComponent);
|
|
213
213
|
}
|
|
214
214
|
this.createService({
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_decorator,
|
|
3
|
+
wrapFunction
|
|
4
|
+
} from "./roy-agent-core-q5qj0fes.js";
|
|
5
|
+
import {
|
|
6
|
+
createLogger,
|
|
7
|
+
init_logger
|
|
8
|
+
} from "./roy-agent-core-10n2jh7p.js";
|
|
1
9
|
import {
|
|
2
10
|
__esm
|
|
3
11
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
@@ -14,7 +22,7 @@ function hasEnvContext() {
|
|
|
14
22
|
return envContextStorage.getStore() !== undefined;
|
|
15
23
|
}
|
|
16
24
|
function getCurrentTaskId() {
|
|
17
|
-
return envContextStorage.getStore()?.currentTaskId;
|
|
25
|
+
return envContextStorage.getStore()?.agentContext?.currentTaskId;
|
|
18
26
|
}
|
|
19
27
|
function runWithEnvContext(context, fn) {
|
|
20
28
|
if (context) {
|
|
@@ -44,15 +52,30 @@ function createEnvContext(options) {
|
|
|
44
52
|
function mergeEnvContext(partial) {
|
|
45
53
|
const current = envContextStorage.getStore();
|
|
46
54
|
if (current) {
|
|
55
|
+
if (partial.agentContext && current.agentContext) {
|
|
56
|
+
Object.assign(current.agentContext, partial.agentContext);
|
|
57
|
+
delete partial.agentContext;
|
|
58
|
+
}
|
|
47
59
|
Object.assign(current, partial);
|
|
48
60
|
}
|
|
49
61
|
}
|
|
50
|
-
|
|
51
|
-
mergeEnvContext({ currentTaskId: taskId });
|
|
52
|
-
}
|
|
53
|
-
var envContextStorage;
|
|
62
|
+
var logger, envContextStorage, setCurrentTaskId;
|
|
54
63
|
var init_env_context = __esm(() => {
|
|
64
|
+
init_logger();
|
|
65
|
+
init_decorator();
|
|
66
|
+
logger = createLogger("env:context:env-context");
|
|
55
67
|
envContextStorage = new AsyncLocalStorage;
|
|
68
|
+
setCurrentTaskId = wrapFunction(function _setCurrentTaskId(taskId) {
|
|
69
|
+
const prev = getCurrentTaskId();
|
|
70
|
+
const ctx = envContextStorage.getStore();
|
|
71
|
+
if (ctx) {
|
|
72
|
+
if (!ctx.agentContext) {
|
|
73
|
+
ctx.agentContext = {};
|
|
74
|
+
}
|
|
75
|
+
ctx.agentContext.currentTaskId = taskId;
|
|
76
|
+
}
|
|
77
|
+
logger.info(`[setCurrentTaskId] taskId=${taskId ?? "undefined"} (was: ${prev ?? "undefined"})`);
|
|
78
|
+
}, "env-context.setCurrentTaskId", { recordParams: true, recordResult: false, log: true });
|
|
56
79
|
});
|
|
57
80
|
|
|
58
81
|
export { envContextStorage, getEnvContext, getEnvContextOrEmpty, hasEnvContext, getCurrentTaskId, runWithEnvContext, runWithEnvContextAsync, createEnvContext, mergeEnvContext, setCurrentTaskId, init_env_context };
|
|
@@ -4,18 +4,18 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
TaskHookPoints
|
|
6
6
|
} from "./roy-agent-core-92z6t4he.js";
|
|
7
|
-
import {
|
|
8
|
-
TracedAs,
|
|
9
|
-
init_decorator
|
|
10
|
-
} from "./roy-agent-core-q5qj0fes.js";
|
|
11
7
|
import {
|
|
12
8
|
globalHookManager,
|
|
13
9
|
init_global_hook_manager
|
|
14
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-qmr365f5.js";
|
|
15
11
|
import {
|
|
16
12
|
init_env_context,
|
|
17
|
-
|
|
18
|
-
} from "./roy-agent-core-
|
|
13
|
+
setCurrentTaskId
|
|
14
|
+
} from "./roy-agent-core-v7583cf9.js";
|
|
15
|
+
import {
|
|
16
|
+
TracedAs,
|
|
17
|
+
init_decorator
|
|
18
|
+
} from "./roy-agent-core-q5qj0fes.js";
|
|
19
19
|
import {
|
|
20
20
|
createLogger,
|
|
21
21
|
init_logger
|
|
@@ -741,7 +741,7 @@ ${prompt}
|
|
|
741
741
|
---
|
|
742
742
|
\uD83D\uDCCB [委托任务完成] 已委托子智能体完成 Task #${taskId} 的处理工作,请知悉。可通过 task_get #${taskId} 查看最新状态。`;
|
|
743
743
|
}
|
|
744
|
-
|
|
744
|
+
setCurrentTaskId(undefined);
|
|
745
745
|
logger.info(`[delegate_task.sync] Task completed, currentTaskId cleared from EnvContext${taskId ? ` (was: #${taskId})` : ""}`);
|
|
746
746
|
return {
|
|
747
747
|
success: true,
|
|
@@ -760,7 +760,7 @@ ${prompt}
|
|
|
760
760
|
}
|
|
761
761
|
};
|
|
762
762
|
} catch (error) {
|
|
763
|
-
|
|
763
|
+
setCurrentTaskId(undefined);
|
|
764
764
|
logger.info(`[delegate_task.sync] Error occurred, currentTaskId cleared from EnvContext${taskId ? ` (was: #${taskId})` : ""}`);
|
|
765
765
|
return {
|
|
766
766
|
success: false,
|
|
@@ -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,
|
|
@@ -28,20 +28,20 @@ import {
|
|
|
28
28
|
import {
|
|
29
29
|
TaskHookPoints
|
|
30
30
|
} from "./roy-agent-core-92z6t4he.js";
|
|
31
|
-
import {
|
|
32
|
-
TracedAs,
|
|
33
|
-
init_decorator
|
|
34
|
-
} from "./roy-agent-core-q5qj0fes.js";
|
|
35
31
|
import {
|
|
36
32
|
envKeyToConfigKey
|
|
37
33
|
} from "./roy-agent-core-qxhq8ven.js";
|
|
38
34
|
import {
|
|
39
35
|
BaseComponent
|
|
40
|
-
} from "./roy-agent-core-
|
|
36
|
+
} from "./roy-agent-core-cssnkkkg.js";
|
|
41
37
|
import {
|
|
42
38
|
globalHookManager,
|
|
43
39
|
init_global_hook_manager
|
|
44
|
-
} from "./roy-agent-core-
|
|
40
|
+
} from "./roy-agent-core-qmr365f5.js";
|
|
41
|
+
import {
|
|
42
|
+
TracedAs,
|
|
43
|
+
init_decorator
|
|
44
|
+
} from "./roy-agent-core-q5qj0fes.js";
|
|
45
45
|
import {
|
|
46
46
|
createLogger,
|
|
47
47
|
init_logger
|