@ai-setting/roy-agent-core 1.6.8 → 1.6.10
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 +11 -9
- package/dist/env/agent/index.js +10 -10
- package/dist/env/commands/index.js +8 -8
- package/dist/env/context/index.js +3 -3
- package/dist/env/debug/index.js +7 -7
- package/dist/env/event-source/index.js +11 -11
- package/dist/env/hook/index.js +5 -5
- package/dist/env/index.js +30 -29
- package/dist/env/llm/index.js +9 -8
- package/dist/env/log-trace/index.js +8 -8
- package/dist/env/mcp/index.js +8 -8
- package/dist/env/memory/index.js +8 -8
- package/dist/env/plugin/index.js +7 -7
- package/dist/env/prompt/index.js +9 -9
- package/dist/env/session/index.js +8 -8
- package/dist/env/skill/index.js +8 -8
- package/dist/env/task/delegate/index.js +8 -7
- package/dist/env/task/index.js +13 -12
- package/dist/env/task/plugins/index.js +5 -5
- package/dist/env/task/tools/index.js +3 -3
- package/dist/env/tool/built-in/index.js +2 -2
- package/dist/env/tool/index.js +9 -9
- package/dist/env/workflow/engine/index.js +8 -8
- package/dist/env/workflow/index.js +17 -16
- package/dist/env/workflow/nodes/index.js +2 -2
- package/dist/env/workflow/service/index.js +2 -2
- package/dist/env/workflow/storage/index.js +3 -3
- package/dist/env/workflow/tools/index.js +11 -10
- package/dist/env/workflow/utils/index.js +2 -2
- package/dist/index.js +41 -39
- package/dist/shared/@ai-setting/{roy-agent-core-12ttd2w1.js → roy-agent-core-0cftbg62.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-2vevsd36.js → roy-agent-core-0n2a8cbn.js} +55 -9
- package/dist/shared/@ai-setting/{roy-agent-core-33rhv946.js → roy-agent-core-1gsnq4p2.js} +5 -197
- package/dist/shared/@ai-setting/{roy-agent-core-jexyz11d.js → roy-agent-core-1mq9erp8.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-jzza6c2r.js → roy-agent-core-2ek596yd.js} +58 -18
- package/dist/shared/@ai-setting/{roy-agent-core-634ee5jb.js → roy-agent-core-2yavqjsh.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-971gwby7.js → roy-agent-core-38kbfarg.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-578qk38y.js → roy-agent-core-3kbf53sh.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-zwwkczvj.js → roy-agent-core-4mhrz08q.js} +23 -14
- package/dist/shared/@ai-setting/{roy-agent-core-b77yz0wt.js → roy-agent-core-606z25nw.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-qxhq8ven.js → roy-agent-core-7hh0brvs.js} +5 -0
- package/dist/shared/@ai-setting/{roy-agent-core-2r1rc0fe.js → roy-agent-core-80bdhnwk.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-c94yan0b.js → roy-agent-core-8bhncxep.js} +101 -17
- package/dist/shared/@ai-setting/{roy-agent-core-zttjq1h3.js → roy-agent-core-9hqqhye6.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-b2thb9xj.js → roy-agent-core-atjd1tpt.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-c1v263jn.js +11 -0
- package/dist/shared/@ai-setting/{roy-agent-core-r08qk37k.js → roy-agent-core-ck0m8754.js} +37 -4
- package/dist/shared/@ai-setting/{roy-agent-core-gp872e7m.js → roy-agent-core-dbkkjmqz.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-scp0afxg.js → roy-agent-core-endah27g.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-ddghwfmk.js → roy-agent-core-f79ee0aw.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-cg146hmg.js → roy-agent-core-fdm579b1.js} +28 -2
- package/dist/shared/@ai-setting/{roy-agent-core-ka4b12eg.js → roy-agent-core-g9p7e2ys.js} +25 -5
- package/dist/shared/@ai-setting/{roy-agent-core-xgnpr28w.js → roy-agent-core-htjag2nr.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-pf1c360e.js → roy-agent-core-j62bjagf.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-w7mhnc4c.js → roy-agent-core-jenchn33.js} +47 -4
- package/dist/shared/@ai-setting/{roy-agent-core-sssn8kt9.js → roy-agent-core-jw0hbacv.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-34xt19yg.js → roy-agent-core-m38q2azm.js} +42 -20
- package/dist/shared/@ai-setting/{roy-agent-core-d2bmfnb5.js → roy-agent-core-nw39k111.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-gdkq55yg.js → roy-agent-core-nzpw62d3.js} +7 -7
- package/dist/shared/@ai-setting/{roy-agent-core-b75jtybq.js → roy-agent-core-p2vpsd1d.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-gw43m8yd.js → roy-agent-core-p6x6n3k4.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-cx9p8b2t.js → roy-agent-core-qbm5zy6s.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-hf8pqrvy.js → roy-agent-core-qfdj8872.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-ksx9a556.js → roy-agent-core-r74v00c7.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-0tfv18rf.js → roy-agent-core-resnbd2j.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-bqwj1dq0.js → roy-agent-core-rga3f0hm.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-sxqy40cs.js → roy-agent-core-rpq0mcvv.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-4extx33r.js → roy-agent-core-trdpar9f.js} +49 -183
- package/dist/shared/@ai-setting/{roy-agent-core-cx67bv9d.js → roy-agent-core-txsswwhm.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-q88vxmx5.js → roy-agent-core-w22tzjj5.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-as3phr7n.js → roy-agent-core-wqe84f84.js} +15 -6
- package/dist/shared/@ai-setting/{roy-agent-core-wmkx79b1.js → roy-agent-core-xxgazz27.js} +3 -3
- package/dist/shared/@ai-setting/roy-agent-core-y3g3ar7a.js +229 -0
- package/dist/shared/@ai-setting/{roy-agent-core-jayzyg7h.js → roy-agent-core-y5ymc4f8.js} +6 -6
- package/dist/shared/@ai-setting/{roy-agent-core-8jmkghjc.js → roy-agent-core-z7f8hyv7.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-02n40zbs.js → roy-agent-core-zs31w092.js} +40 -26
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
TracedAs,
|
|
6
6
|
init_decorator
|
|
7
|
-
} from "./roy-agent-core-
|
|
7
|
+
} from "./roy-agent-core-fdm579b1.js";
|
|
8
8
|
import {
|
|
9
9
|
createLogger,
|
|
10
10
|
init_logger
|
|
@@ -158,14 +158,15 @@ class AgentRegistry {
|
|
|
158
158
|
}
|
|
159
159
|
return agent.entryAgent;
|
|
160
160
|
}
|
|
161
|
-
|
|
162
|
-
const name = "workflow-
|
|
161
|
+
registerWorkflowRunner() {
|
|
162
|
+
const name = "workflow-runner";
|
|
163
163
|
if (this.agents.has(name))
|
|
164
164
|
return;
|
|
165
165
|
const agent = {
|
|
166
166
|
name,
|
|
167
|
-
type: "
|
|
168
|
-
description: "Workflow
|
|
167
|
+
type: "sub",
|
|
168
|
+
description: "Workflow runner — 负责调用 workflow_run 启动 workflow,支持 session resume 和 stop",
|
|
169
|
+
systemPromptRef: "workflow-runner",
|
|
169
170
|
allowedTools: [
|
|
170
171
|
"workflow_get",
|
|
171
172
|
"workflow_list",
|
|
@@ -173,7 +174,8 @@ class AgentRegistry {
|
|
|
173
174
|
"workflow_run_status",
|
|
174
175
|
"workflow_run_stop"
|
|
175
176
|
],
|
|
176
|
-
deniedTools: []
|
|
177
|
+
deniedTools: ["delegate_task", "stop_task"],
|
|
178
|
+
maxIterations: 30
|
|
177
179
|
};
|
|
178
180
|
this.agents.set(name, agent);
|
|
179
181
|
}
|
|
@@ -421,6 +423,13 @@ __legacyDecorateClassTS([
|
|
|
421
423
|
__legacyDecorateClassTS([
|
|
422
424
|
TracedAs("agent.registry.getEntryAgent", { recordParams: true, recordResult: true })
|
|
423
425
|
], AgentRegistry.prototype, "getEntryAgent", null);
|
|
426
|
+
__legacyDecorateClassTS([
|
|
427
|
+
TracedAs("agent.registry.registerWorkflowRunner", {
|
|
428
|
+
recordParams: false,
|
|
429
|
+
recordResult: true,
|
|
430
|
+
log: true
|
|
431
|
+
})
|
|
432
|
+
], AgentRegistry.prototype, "registerWorkflowRunner", null);
|
|
424
433
|
__legacyDecorateClassTS([
|
|
425
434
|
TracedAs("agent.registry.load", { recordParams: false, recordResult: true, log: true })
|
|
426
435
|
], AgentRegistry.prototype, "load", null);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
envKeyToConfigKey
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-7hh0brvs.js";
|
|
4
4
|
import {
|
|
5
5
|
BaseComponent
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-j62bjagf.js";
|
|
7
7
|
import {
|
|
8
8
|
init_decorator
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-fdm579b1.js";
|
|
10
10
|
import {
|
|
11
11
|
createLogger,
|
|
12
12
|
init_logger,
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import {
|
|
2
|
+
envKeyToConfigKey,
|
|
3
|
+
fromEnvKey,
|
|
4
|
+
toEnvKey
|
|
5
|
+
} from "./roy-agent-core-7hh0brvs.js";
|
|
6
|
+
|
|
7
|
+
// src/config/env-source.ts
|
|
8
|
+
class EnvSource {
|
|
9
|
+
name = "env";
|
|
10
|
+
priority = 20;
|
|
11
|
+
prefix;
|
|
12
|
+
transform;
|
|
13
|
+
pollInterval;
|
|
14
|
+
watchers = new Set;
|
|
15
|
+
pollTimer;
|
|
16
|
+
lastValues = new Map;
|
|
17
|
+
watchEnabled = true;
|
|
18
|
+
constructor(options = {}) {
|
|
19
|
+
this.prefix = options.prefix ?? "";
|
|
20
|
+
this.transform = options.transform;
|
|
21
|
+
this.pollInterval = options.pollInterval;
|
|
22
|
+
this.watchEnabled = options.watch ?? true;
|
|
23
|
+
}
|
|
24
|
+
getEnvKey(key) {
|
|
25
|
+
return toEnvKey(key, this.prefix);
|
|
26
|
+
}
|
|
27
|
+
getInternalKey(envKey) {
|
|
28
|
+
return fromEnvKey(envKey, this.prefix);
|
|
29
|
+
}
|
|
30
|
+
read(key) {
|
|
31
|
+
const envKey = this.getEnvKey(key);
|
|
32
|
+
const value = process.env[envKey];
|
|
33
|
+
if (value === undefined) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (this.transform) {
|
|
37
|
+
return this.transform(value, key);
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
write(key, value) {
|
|
42
|
+
const envKey = this.getEnvKey(key);
|
|
43
|
+
const oldValue = process.env[envKey];
|
|
44
|
+
const stringValue = String(value);
|
|
45
|
+
process.env[envKey] = stringValue;
|
|
46
|
+
const event = {
|
|
47
|
+
type: oldValue === undefined ? "add" : "change",
|
|
48
|
+
key,
|
|
49
|
+
oldValue: oldValue !== undefined ? this.transformValue(oldValue, key) : undefined,
|
|
50
|
+
newValue: this.transformValue(stringValue, key),
|
|
51
|
+
source: this.name,
|
|
52
|
+
timestamp: Date.now()
|
|
53
|
+
};
|
|
54
|
+
this.notifyWatchers(event);
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
delete(key) {
|
|
58
|
+
const envKey = this.getEnvKey(key);
|
|
59
|
+
const oldValue = process.env[envKey];
|
|
60
|
+
if (oldValue === undefined) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
delete process.env[envKey];
|
|
64
|
+
const event = {
|
|
65
|
+
type: "delete",
|
|
66
|
+
key,
|
|
67
|
+
oldValue: this.transformValue(oldValue, key),
|
|
68
|
+
newValue: undefined,
|
|
69
|
+
source: this.name,
|
|
70
|
+
timestamp: Date.now()
|
|
71
|
+
};
|
|
72
|
+
this.notifyWatchers(event);
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
list() {
|
|
76
|
+
const result = [];
|
|
77
|
+
const prefix = this.prefix.toUpperCase();
|
|
78
|
+
for (const envKey of Object.keys(process.env)) {
|
|
79
|
+
if (prefix && !envKey.startsWith(prefix)) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const key = this.getInternalKey(envKey);
|
|
83
|
+
const value = process.env[envKey];
|
|
84
|
+
if (value !== undefined) {
|
|
85
|
+
result.push({
|
|
86
|
+
key,
|
|
87
|
+
value: this.transformValue(value, key)
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
watch(callback) {
|
|
94
|
+
this.watchers.add(callback);
|
|
95
|
+
if (!this.watchEnabled) {
|
|
96
|
+
return () => {
|
|
97
|
+
this.watchers.delete(callback);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
this.ensurePolling();
|
|
101
|
+
this.recordCurrentValues();
|
|
102
|
+
return () => {
|
|
103
|
+
this.watchers.delete(callback);
|
|
104
|
+
if (this.watchers.size === 0) {
|
|
105
|
+
this.stopPolling();
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
ensurePolling() {
|
|
110
|
+
if (this.pollTimer !== undefined) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const interval = this.pollInterval ?? 1000;
|
|
114
|
+
this.pollTimer = setInterval(() => {
|
|
115
|
+
this.checkForChanges();
|
|
116
|
+
}, interval);
|
|
117
|
+
}
|
|
118
|
+
stopPolling() {
|
|
119
|
+
if (this.pollTimer) {
|
|
120
|
+
clearInterval(this.pollTimer);
|
|
121
|
+
this.pollTimer = undefined;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
recordCurrentValues() {
|
|
125
|
+
this.lastValues.clear();
|
|
126
|
+
const entries = this.list();
|
|
127
|
+
for (const entry of entries) {
|
|
128
|
+
const envKey = this.getEnvKey(entry.key);
|
|
129
|
+
const value = process.env[envKey];
|
|
130
|
+
if (value !== undefined) {
|
|
131
|
+
this.lastValues.set(envKey, value);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
checkForChanges() {
|
|
136
|
+
const currentEntries = this.list();
|
|
137
|
+
const currentValues = new Map;
|
|
138
|
+
for (const entry of currentEntries) {
|
|
139
|
+
const envKey = this.getEnvKey(entry.key);
|
|
140
|
+
const value = process.env[envKey];
|
|
141
|
+
if (value !== undefined) {
|
|
142
|
+
currentValues.set(envKey, value);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
for (const [envKey, oldValue] of this.lastValues.entries()) {
|
|
146
|
+
if (!currentValues.has(envKey)) {
|
|
147
|
+
const key = this.getInternalKey(envKey);
|
|
148
|
+
this.notifyWatchers({
|
|
149
|
+
type: "delete",
|
|
150
|
+
key,
|
|
151
|
+
oldValue: this.transformValue(oldValue, key),
|
|
152
|
+
newValue: undefined,
|
|
153
|
+
source: this.name,
|
|
154
|
+
timestamp: Date.now()
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
for (const [envKey, newValue] of currentValues.entries()) {
|
|
159
|
+
const key = this.getInternalKey(envKey);
|
|
160
|
+
const oldValue = this.lastValues.get(envKey);
|
|
161
|
+
if (oldValue === undefined) {
|
|
162
|
+
this.notifyWatchers({
|
|
163
|
+
type: "add",
|
|
164
|
+
key,
|
|
165
|
+
oldValue: undefined,
|
|
166
|
+
newValue: this.transformValue(newValue, key),
|
|
167
|
+
source: this.name,
|
|
168
|
+
timestamp: Date.now()
|
|
169
|
+
});
|
|
170
|
+
} else if (oldValue !== newValue) {
|
|
171
|
+
this.notifyWatchers({
|
|
172
|
+
type: "change",
|
|
173
|
+
key,
|
|
174
|
+
oldValue: this.transformValue(oldValue, key),
|
|
175
|
+
newValue: this.transformValue(newValue, key),
|
|
176
|
+
source: this.name,
|
|
177
|
+
timestamp: Date.now()
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
this.lastValues = currentValues;
|
|
182
|
+
}
|
|
183
|
+
transformValue(value, key) {
|
|
184
|
+
if (this.transform) {
|
|
185
|
+
return this.transform(value, key);
|
|
186
|
+
}
|
|
187
|
+
return value;
|
|
188
|
+
}
|
|
189
|
+
notifyWatchers(event) {
|
|
190
|
+
this.watchers.forEach((cb) => cb(event));
|
|
191
|
+
}
|
|
192
|
+
close() {
|
|
193
|
+
this.stopPolling();
|
|
194
|
+
this.watchers.clear();
|
|
195
|
+
}
|
|
196
|
+
validateUnrecognizedEnvVars(options = {}) {
|
|
197
|
+
const { componentName, knownKeys, logger } = options;
|
|
198
|
+
const prefixUpper = this.prefix.toUpperCase();
|
|
199
|
+
const unrecognized = [];
|
|
200
|
+
if (!knownKeys || knownKeys.size === 0) {
|
|
201
|
+
return unrecognized;
|
|
202
|
+
}
|
|
203
|
+
for (const envKey of Object.keys(process.env)) {
|
|
204
|
+
if (prefixUpper && !envKey.toUpperCase().startsWith(prefixUpper)) {
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const configKey = componentName ? envKeyToConfigKey(envKey, this.prefix, componentName) : undefined;
|
|
208
|
+
const candidateKey = configKey ?? fromEnvKey(envKey, this.prefix).toLowerCase().replace(/_/g, ".");
|
|
209
|
+
const isKnown = Array.from(knownKeys).some((known) => {
|
|
210
|
+
if (known === candidateKey)
|
|
211
|
+
return true;
|
|
212
|
+
if (candidateKey.startsWith(known + "."))
|
|
213
|
+
return true;
|
|
214
|
+
return false;
|
|
215
|
+
});
|
|
216
|
+
if (!isKnown) {
|
|
217
|
+
const valuePreview = JSON.stringify(process.env[envKey]);
|
|
218
|
+
const truncated = valuePreview.length > 50 ? valuePreview.slice(0, 47) + "..." : valuePreview;
|
|
219
|
+
const msg = `[EnvSource] Unrecognized env var: ${envKey}=${truncated} ` + `(resolved config key "${candidateKey}" not in known keys: ${Array.from(knownKeys).join(", ") || "<empty>"}). ` + `Check spelling, or add the key to the component's known config keys.`;
|
|
220
|
+
unrecognized.push(envKey);
|
|
221
|
+
if (logger?.warn)
|
|
222
|
+
logger.warn(msg);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return unrecognized;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export { EnvSource };
|
|
@@ -6,21 +6,21 @@ import {
|
|
|
6
6
|
} from "./roy-agent-core-8wd3qwx5.js";
|
|
7
7
|
import {
|
|
8
8
|
WORKFLOW_EXTRACT_PROMPT
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-trdpar9f.js";
|
|
10
10
|
import {
|
|
11
11
|
TaskHookPoints
|
|
12
12
|
} from "./roy-agent-core-1pg0fepg.js";
|
|
13
13
|
import {
|
|
14
14
|
init_context
|
|
15
|
-
} from "./roy-agent-core-
|
|
15
|
+
} from "./roy-agent-core-9hqqhye6.js";
|
|
16
16
|
import {
|
|
17
17
|
getEnvContextOrEmpty
|
|
18
|
-
} from "./roy-agent-core-
|
|
18
|
+
} from "./roy-agent-core-endah27g.js";
|
|
19
19
|
import {
|
|
20
20
|
TracedAs,
|
|
21
21
|
init_decorator,
|
|
22
22
|
wrapFunction
|
|
23
|
-
} from "./roy-agent-core-
|
|
23
|
+
} from "./roy-agent-core-fdm579b1.js";
|
|
24
24
|
import {
|
|
25
25
|
createLogger,
|
|
26
26
|
init_logger
|
|
@@ -289,11 +289,11 @@ ${prompt}`;
|
|
|
289
289
|
}
|
|
290
290
|
if (!this._workflowRepo) {
|
|
291
291
|
try {
|
|
292
|
-
const sqlite = await import("./roy-agent-core-
|
|
292
|
+
const sqlite = await import("./roy-agent-core-qbm5zy6s.js");
|
|
293
293
|
this.ensureDataDir();
|
|
294
294
|
const db = sqlite.getDatabase();
|
|
295
295
|
sqlite.initializeTables();
|
|
296
|
-
const { WorkflowRepository } = await import("./roy-agent-core-
|
|
296
|
+
const { WorkflowRepository } = await import("./roy-agent-core-jw0hbacv.js");
|
|
297
297
|
this._workflowRepo = new WorkflowRepository(db);
|
|
298
298
|
return this._workflowRepo;
|
|
299
299
|
} catch {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentComponentAdapter,
|
|
3
3
|
init_agent_component_adapter
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-jenchn33.js";
|
|
5
5
|
import"./roy-agent-core-1db4vpc6.js";
|
|
6
6
|
import"./roy-agent-core-e25xkv53.js";
|
|
7
|
-
import"./roy-agent-core-
|
|
8
|
-
import"./roy-agent-core-
|
|
9
|
-
import"./roy-agent-core-
|
|
10
|
-
import"./roy-agent-core-
|
|
7
|
+
import"./roy-agent-core-dbkkjmqz.js";
|
|
8
|
+
import"./roy-agent-core-9hqqhye6.js";
|
|
9
|
+
import"./roy-agent-core-endah27g.js";
|
|
10
|
+
import"./roy-agent-core-fdm579b1.js";
|
|
11
11
|
import"./roy-agent-core-vyygk314.js";
|
|
12
12
|
import"./roy-agent-core-7z9b1fm8.js";
|
|
13
13
|
import"./roy-agent-core-c6592r3c.js";
|
|
@@ -8,24 +8,29 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
envKeyToConfigKey,
|
|
10
10
|
toEnvKey
|
|
11
|
-
} from "./roy-agent-core-
|
|
11
|
+
} from "./roy-agent-core-7hh0brvs.js";
|
|
12
12
|
import {
|
|
13
13
|
BaseComponent
|
|
14
|
-
} from "./roy-agent-core-
|
|
14
|
+
} from "./roy-agent-core-j62bjagf.js";
|
|
15
15
|
import {
|
|
16
16
|
ToolHookPoints,
|
|
17
17
|
globalHookManager,
|
|
18
18
|
init_global_hook_manager
|
|
19
|
-
} from "./roy-agent-core-
|
|
19
|
+
} from "./roy-agent-core-dbkkjmqz.js";
|
|
20
20
|
import {
|
|
21
21
|
getCurrentTaskId,
|
|
22
22
|
init_env_context
|
|
23
|
-
} from "./roy-agent-core-
|
|
23
|
+
} from "./roy-agent-core-endah27g.js";
|
|
24
|
+
import {
|
|
25
|
+
TracedAs,
|
|
26
|
+
init_decorator
|
|
27
|
+
} from "./roy-agent-core-fdm579b1.js";
|
|
24
28
|
import {
|
|
25
29
|
createLogger,
|
|
26
30
|
init_logger
|
|
27
31
|
} from "./roy-agent-core-vyygk314.js";
|
|
28
32
|
import {
|
|
33
|
+
__legacyDecorateClassTS,
|
|
29
34
|
__require
|
|
30
35
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
31
36
|
|
|
@@ -156,6 +161,7 @@ class ToolValidator {
|
|
|
156
161
|
// src/env/tool/tool-component.ts
|
|
157
162
|
import { z } from "zod";
|
|
158
163
|
init_logger();
|
|
164
|
+
init_decorator();
|
|
159
165
|
init_global_hook_manager();
|
|
160
166
|
|
|
161
167
|
// src/env/tool/tool-config-registration.ts
|
|
@@ -237,13 +243,16 @@ function getMaxOutputSizeForTool(toolName, overrideMaxSize) {
|
|
|
237
243
|
}
|
|
238
244
|
return getMaxOutputSize();
|
|
239
245
|
}
|
|
240
|
-
function truncateOutputInline(result, maxSize, overrideMaxSize, toolName) {
|
|
246
|
+
function truncateOutputInline(result, maxSize, overrideMaxSize, toolName, tool) {
|
|
241
247
|
const cloned = {
|
|
242
248
|
success: result.success,
|
|
243
249
|
output: result.output,
|
|
244
250
|
error: result.error,
|
|
245
251
|
metadata: result.metadata ? { ...result.metadata } : { execution_time_ms: 0 }
|
|
246
252
|
};
|
|
253
|
+
if (tool?.metadata?.skipTruncation) {
|
|
254
|
+
return cloned;
|
|
255
|
+
}
|
|
247
256
|
const effectiveMax = typeof maxSize === "number" ? maxSize : getMaxOutputSizeForTool(toolName, overrideMaxSize);
|
|
248
257
|
if (effectiveMax <= 0) {
|
|
249
258
|
return cloned;
|
|
@@ -475,31 +484,33 @@ class ToolComponent extends BaseComponent {
|
|
|
475
484
|
result.metadata.execution_time_ms = Date.now() - startTime;
|
|
476
485
|
}
|
|
477
486
|
if (typeof result.output === "string") {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
487
|
+
if (!tool.metadata?.skipTruncation) {
|
|
488
|
+
const maxOutputSize = getMaxOutputSize();
|
|
489
|
+
let fullOutput = null;
|
|
490
|
+
if (maxOutputSize > 0) {
|
|
491
|
+
fullOutput = result.output;
|
|
492
|
+
const { output: truncatedOutput, metadata: truncationMeta } = truncateOutput(result.output, maxOutputSize);
|
|
493
|
+
result.output = truncatedOutput;
|
|
494
|
+
result.metadata = {
|
|
495
|
+
...result.metadata,
|
|
496
|
+
...truncationMeta
|
|
497
|
+
};
|
|
498
|
+
if (truncationMeta.output_truncated === true && tool.name !== "read_file" && fullOutput !== null) {
|
|
499
|
+
try {
|
|
500
|
+
const tempFilePath = await TempFileManager.getInstance().writeTempFile(fullOutput, tool.name);
|
|
501
|
+
result.metadata = {
|
|
502
|
+
...result.metadata,
|
|
503
|
+
truncation_temp_file: tempFilePath
|
|
504
|
+
};
|
|
505
|
+
result.output += `
|
|
496
506
|
|
|
497
507
|
⚠️ 输出被截断(原 ${truncationMeta.original_output_size} 字符,截断到 ${truncationMeta.truncated_output_size} 字符)
|
|
498
508
|
\uD83D\uDCC1 完整内容保存到: ${tempFilePath}
|
|
499
509
|
\uD83D\uDD0D 使用 read_file 工具按需读取`;
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
510
|
+
logger.debug(`[tool-component] Truncated output saved to temp file: ${tempFilePath} (${truncationMeta.original_output_size} bytes)`);
|
|
511
|
+
} catch (err) {
|
|
512
|
+
logger.warn(`[tool-component] Failed to write temp file for truncated output: ${err}`);
|
|
513
|
+
}
|
|
503
514
|
}
|
|
504
515
|
}
|
|
505
516
|
}
|
|
@@ -559,6 +570,9 @@ class ToolComponent extends BaseComponent {
|
|
|
559
570
|
];
|
|
560
571
|
}
|
|
561
572
|
}
|
|
573
|
+
__legacyDecorateClassTS([
|
|
574
|
+
TracedAs("tool.component.execute", { recordParams: true, recordResult: true, log: true })
|
|
575
|
+
], ToolComponent.prototype, "execute", null);
|
|
562
576
|
var ToolComponentConfigSchema = z.object({
|
|
563
577
|
toolsDir: z.string().optional(),
|
|
564
578
|
builtInTools: z.object({
|