@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
|
@@ -3,17 +3,17 @@ import {
|
|
|
3
3
|
} from "./roy-agent-core-az13yzmc.js";
|
|
4
4
|
import {
|
|
5
5
|
BaseComponent
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-j62bjagf.js";
|
|
7
7
|
import {
|
|
8
8
|
globalHookManager,
|
|
9
9
|
init_global_hook_manager
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-dbkkjmqz.js";
|
|
11
11
|
import {
|
|
12
12
|
init_context
|
|
13
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-9hqqhye6.js";
|
|
14
14
|
import {
|
|
15
15
|
getEnvContextOrEmpty
|
|
16
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-endah27g.js";
|
|
17
17
|
import {
|
|
18
18
|
createLogger,
|
|
19
19
|
init_logger
|
|
@@ -4,27 +4,31 @@ import {
|
|
|
4
4
|
} from "./roy-agent-core-pzeexnhf.js";
|
|
5
5
|
import {
|
|
6
6
|
builtInPrompts
|
|
7
|
-
} from "./roy-agent-core-
|
|
7
|
+
} from "./roy-agent-core-trdpar9f.js";
|
|
8
|
+
import {
|
|
9
|
+
runWithBgTaskIdAsync
|
|
10
|
+
} from "./roy-agent-core-c1v263jn.js";
|
|
8
11
|
import {
|
|
9
12
|
DEFAULT_SUBAGENT_PROMPT
|
|
10
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-wqe84f84.js";
|
|
11
14
|
import {
|
|
12
15
|
TaskHookPoints
|
|
13
16
|
} from "./roy-agent-core-1pg0fepg.js";
|
|
14
17
|
import {
|
|
15
18
|
globalHookManager,
|
|
16
19
|
init_global_hook_manager
|
|
17
|
-
} from "./roy-agent-core-
|
|
20
|
+
} from "./roy-agent-core-dbkkjmqz.js";
|
|
18
21
|
import {
|
|
19
22
|
init_context
|
|
20
|
-
} from "./roy-agent-core-
|
|
23
|
+
} from "./roy-agent-core-9hqqhye6.js";
|
|
21
24
|
import {
|
|
22
25
|
getCurrentTaskId
|
|
23
|
-
} from "./roy-agent-core-
|
|
26
|
+
} from "./roy-agent-core-endah27g.js";
|
|
24
27
|
import {
|
|
25
28
|
TracedAs,
|
|
26
|
-
init_decorator
|
|
27
|
-
|
|
29
|
+
init_decorator,
|
|
30
|
+
wrapFunction
|
|
31
|
+
} from "./roy-agent-core-fdm579b1.js";
|
|
28
32
|
import {
|
|
29
33
|
createLogger,
|
|
30
34
|
init_logger
|
|
@@ -232,11 +236,13 @@ function buildEntryAgentPrompt(options) {
|
|
|
232
236
|
return `# Workflow 调度请求
|
|
233
237
|
|
|
234
238
|
你被调用是因为上游 \`delegate_task\` 检测到 workflow 类型 subagent **${workflowName}**。
|
|
235
|
-
请通过 \`
|
|
239
|
+
请通过 \`workflow_run\` 命令调度对应 workflow。
|
|
240
|
+
|
|
241
|
+
<workflow_name>${workflowName}</workflow_name>
|
|
236
242
|
|
|
237
243
|
## 调度目标
|
|
238
244
|
|
|
239
|
-
- **Workflow 名称**: \`${workflowName}\`
|
|
245
|
+
- **Workflow 名称**: \`${workflowName}\` (权威来源: \`<workflow_name>\` 标签, 不要从上下文猜测)
|
|
240
246
|
- **任务描述**: ${description}
|
|
241
247
|
|
|
242
248
|
## 原始用户请求
|
|
@@ -245,14 +251,21 @@ ${originalPrompt}
|
|
|
245
251
|
|
|
246
252
|
## 你的行动
|
|
247
253
|
|
|
248
|
-
1. \`
|
|
254
|
+
1. \`workflow_get(${workflowName})\` 取 workflow 入参 schema
|
|
249
255
|
2. 从"原始用户请求"提取符合 schema 的 input 字段
|
|
250
|
-
3. \`
|
|
251
|
-
4.
|
|
256
|
+
3. \`workflow_run(${workflowName}, input)\` 触发 workflow
|
|
257
|
+
4. 把 output 原样回给 parent agent
|
|
252
258
|
|
|
253
|
-
不要做其他工作。只走 \`
|
|
259
|
+
不要做其他工作。只走 \`workflow_run\` 路径。
|
|
254
260
|
`;
|
|
255
261
|
}
|
|
262
|
+
var WORKFLOW_COMPAT_ALIASES = new Set([
|
|
263
|
+
"strict-task-agent",
|
|
264
|
+
"code-review",
|
|
265
|
+
"bench-agent-host",
|
|
266
|
+
"workspace-analyzer",
|
|
267
|
+
"test-workflow-agent"
|
|
268
|
+
]);
|
|
256
269
|
var DEFAULT_TIMEOUT = 1800000;
|
|
257
270
|
var PROGRESS_INTERVAL = 1200000;
|
|
258
271
|
|
|
@@ -262,12 +275,53 @@ class BackgroundTaskManager {
|
|
|
262
275
|
abortControllers = new Map;
|
|
263
276
|
progressTimers = new Map;
|
|
264
277
|
processRegistries = new Map;
|
|
278
|
+
workflowRunRegistries = new Map;
|
|
279
|
+
workflowService;
|
|
265
280
|
constructor(env) {
|
|
266
281
|
this.env = env;
|
|
267
282
|
}
|
|
268
|
-
|
|
283
|
+
setWorkflowService(svc) {
|
|
284
|
+
this.workflowService = svc;
|
|
285
|
+
}
|
|
286
|
+
attachWorkflowRun(bgTaskId, workflowRunId) {
|
|
287
|
+
if (!bgTaskId || !workflowRunId)
|
|
288
|
+
return;
|
|
289
|
+
let set = this.workflowRunRegistries.get(bgTaskId);
|
|
290
|
+
if (!set) {
|
|
291
|
+
set = new Set;
|
|
292
|
+
this.workflowRunRegistries.set(bgTaskId, set);
|
|
293
|
+
}
|
|
294
|
+
set.add(workflowRunId);
|
|
295
|
+
}
|
|
296
|
+
detachWorkflowRun(bgTaskId, workflowRunId) {
|
|
297
|
+
this.workflowRunRegistries.get(bgTaskId)?.delete(workflowRunId);
|
|
298
|
+
}
|
|
299
|
+
async propagateStopToWorkflowRuns(bgTaskId, reason) {
|
|
300
|
+
const set = this.workflowRunRegistries.get(bgTaskId);
|
|
301
|
+
if (!set || set.size === 0)
|
|
302
|
+
return;
|
|
303
|
+
const runIds = Array.from(set);
|
|
304
|
+
logger.info(`[BackgroundTaskManager] propagateStopToWorkflowRuns count=${runIds.length} bgTaskId=${bgTaskId}`);
|
|
305
|
+
for (const runId of runIds) {
|
|
306
|
+
if (typeof this.workflowService?.stopRun !== "function") {
|
|
307
|
+
logger.warn(`[BackgroundTaskManager] workflowService not injected; cannot stop ${runId}`);
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
try {
|
|
311
|
+
await this.workflowService.stopRun(runId, reason);
|
|
312
|
+
} catch (err) {
|
|
313
|
+
logger.warn(`[BackgroundTaskManager] workflowService.stopRun(${runId}) failed (likely already terminal): ${err instanceof Error ? err.message : String(err)}`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
set.clear();
|
|
317
|
+
}
|
|
318
|
+
static DEFAULT_WORKFLOW_ENTRY_AGENT = "workflow-runner";
|
|
269
319
|
resolveEntryAgent(subagentType) {
|
|
270
320
|
try {
|
|
321
|
+
if (BackgroundTaskManager.detectWorkflowShortcutCompat(subagentType)) {
|
|
322
|
+
logger.info(`[BackgroundTaskManager] Compat rewrite: '${subagentType}' → '${BackgroundTaskManager.DEFAULT_WORKFLOW_ENTRY_AGENT}'`);
|
|
323
|
+
return BackgroundTaskManager.DEFAULT_WORKFLOW_ENTRY_AGENT;
|
|
324
|
+
}
|
|
271
325
|
const agentComponent = this.env?.getComponent?.("agent");
|
|
272
326
|
const registry = agentComponent?.getRegistry?.();
|
|
273
327
|
const agent = registry?.get?.(subagentType);
|
|
@@ -280,6 +334,10 @@ class BackgroundTaskManager {
|
|
|
280
334
|
return;
|
|
281
335
|
}
|
|
282
336
|
}
|
|
337
|
+
static _detectWorkflowShortcutWrapped = wrapFunction((subagentType) => WORKFLOW_COMPAT_ALIASES.has(subagentType), "delegate.detectWorkflowShortcut", { recordParams: true, recordResult: true, log: true });
|
|
338
|
+
static detectWorkflowShortcutCompat(subagentType) {
|
|
339
|
+
return BackgroundTaskManager._detectWorkflowShortcutWrapped(subagentType);
|
|
340
|
+
}
|
|
283
341
|
getSessionComponent() {
|
|
284
342
|
return this.env?.getComponent?.("session");
|
|
285
343
|
}
|
|
@@ -400,7 +458,7 @@ class BackgroundTaskManager {
|
|
|
400
458
|
throw new Error(`Sub session not found: ${task.subSessionId}`);
|
|
401
459
|
}
|
|
402
460
|
const taskRegistry = this.processRegistries.get(taskId);
|
|
403
|
-
const result = await this.executeWithAbort(subSession, prompt, timeoutMs, abortController?.signal, task.similarTaskIds, taskRegistry);
|
|
461
|
+
const result = await this.executeWithAbort(subSession, prompt, timeoutMs, taskId, abortController?.signal, task.similarTaskIds, taskRegistry);
|
|
404
462
|
if (abortController?.signal.aborted) {
|
|
405
463
|
logger.info(`[BackgroundTaskManager] Task was aborted`, { taskId });
|
|
406
464
|
return;
|
|
@@ -521,7 +579,7 @@ class BackgroundTaskManager {
|
|
|
521
579
|
this.progressTimers.delete(taskId);
|
|
522
580
|
}
|
|
523
581
|
}
|
|
524
|
-
async executeWithAbort(subSession, prompt, timeoutMs, signal, similarTaskIds, processRegistry) {
|
|
582
|
+
async executeWithAbort(subSession, prompt, timeoutMs, bgTaskId, signal, similarTaskIds, processRegistry) {
|
|
525
583
|
const metadata = subSession.info?.metadata || {};
|
|
526
584
|
const taskId = metadata.task_id;
|
|
527
585
|
const taskDescription = metadata.task_description || "";
|
|
@@ -665,7 +723,7 @@ Use these as guidance to improve task execution efficiency.`;
|
|
|
665
723
|
agentType: subagentType,
|
|
666
724
|
abort: signal
|
|
667
725
|
});
|
|
668
|
-
const wrappedPromise = processRegistry ? runWithProcessRegistryAsync(processRegistry, () => invokeHandleQuery()) :
|
|
726
|
+
const wrappedPromise = processRegistry ? runWithProcessRegistryAsync(processRegistry, () => runWithBgTaskIdAsync(bgTaskId, () => invokeHandleQuery())) : runWithBgTaskIdAsync(bgTaskId, () => invokeHandleQuery());
|
|
669
727
|
wrappedPromise?.then((result) => {
|
|
670
728
|
clearTimeout(timer);
|
|
671
729
|
resolve(result);
|
|
@@ -700,6 +758,7 @@ Use these as guidance to improve task execution efficiency.`;
|
|
|
700
758
|
error: err instanceof Error ? err.message : String(err)
|
|
701
759
|
});
|
|
702
760
|
}
|
|
761
|
+
await this.propagateStopToWorkflowRuns(taskId, "Task stopped by user");
|
|
703
762
|
const stoppedPayload = {
|
|
704
763
|
backgroundTaskId: task.id,
|
|
705
764
|
subSessionId: task.subSessionId,
|
|
@@ -735,10 +794,35 @@ Use these as guidance to improve task execution efficiency.`;
|
|
|
735
794
|
}
|
|
736
795
|
}
|
|
737
796
|
this.processRegistries.clear();
|
|
797
|
+
for (const taskId of this.workflowRunRegistries.keys()) {
|
|
798
|
+
await this.propagateStopToWorkflowRuns(taskId, "BackgroundTaskManager disposed");
|
|
799
|
+
}
|
|
800
|
+
this.workflowRunRegistries.clear();
|
|
738
801
|
this.tasks.clear();
|
|
739
802
|
logger.info(`[BackgroundTaskManager] Disposed`);
|
|
740
803
|
}
|
|
741
804
|
}
|
|
805
|
+
__legacyDecorateClassTS([
|
|
806
|
+
TracedAs("task.background.attachWorkflowRun", {
|
|
807
|
+
recordParams: true,
|
|
808
|
+
recordResult: false,
|
|
809
|
+
log: true
|
|
810
|
+
})
|
|
811
|
+
], BackgroundTaskManager.prototype, "attachWorkflowRun", null);
|
|
812
|
+
__legacyDecorateClassTS([
|
|
813
|
+
TracedAs("task.background.detachWorkflowRun", {
|
|
814
|
+
recordParams: true,
|
|
815
|
+
recordResult: false,
|
|
816
|
+
log: true
|
|
817
|
+
})
|
|
818
|
+
], BackgroundTaskManager.prototype, "detachWorkflowRun", null);
|
|
819
|
+
__legacyDecorateClassTS([
|
|
820
|
+
TracedAs("task.background.propagateStopToWorkflowRuns", {
|
|
821
|
+
recordParams: true,
|
|
822
|
+
recordResult: false,
|
|
823
|
+
log: true
|
|
824
|
+
})
|
|
825
|
+
], BackgroundTaskManager.prototype, "propagateStopToWorkflowRuns", null);
|
|
742
826
|
__legacyDecorateClassTS([
|
|
743
827
|
TracedAs("task.background.resolveEntryAgent", { recordParams: true, recordResult: true })
|
|
744
828
|
], BackgroundTaskManager.prototype, "resolveEntryAgent", null);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/env/task/delegate/bg-task-id-storage.ts
|
|
2
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
3
|
+
var bgTaskIdStorage = new AsyncLocalStorage;
|
|
4
|
+
function runWithBgTaskIdAsync(bgTaskId, fn) {
|
|
5
|
+
return bgTaskIdStorage.run(bgTaskId, fn);
|
|
6
|
+
}
|
|
7
|
+
function getCurrentBgTaskId() {
|
|
8
|
+
return bgTaskIdStorage.getStore();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { runWithBgTaskIdAsync, getCurrentBgTaskId };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EnvSource
|
|
3
|
+
} from "./roy-agent-core-y3g3ar7a.js";
|
|
1
4
|
import {
|
|
2
5
|
invoke
|
|
3
6
|
} from "./roy-agent-core-dcd1s7ct.js";
|
|
@@ -8,19 +11,19 @@ import {
|
|
|
8
11
|
import {
|
|
9
12
|
envKeyToConfigKey,
|
|
10
13
|
toEnvKey
|
|
11
|
-
} from "./roy-agent-core-
|
|
14
|
+
} from "./roy-agent-core-7hh0brvs.js";
|
|
12
15
|
import {
|
|
13
16
|
BaseComponent
|
|
14
|
-
} from "./roy-agent-core-
|
|
17
|
+
} from "./roy-agent-core-j62bjagf.js";
|
|
15
18
|
import {
|
|
16
19
|
LLMHookPoints,
|
|
17
20
|
globalHookManager,
|
|
18
21
|
init_global_hook_manager
|
|
19
|
-
} from "./roy-agent-core-
|
|
22
|
+
} from "./roy-agent-core-dbkkjmqz.js";
|
|
20
23
|
import {
|
|
21
24
|
TracedAs,
|
|
22
25
|
init_decorator
|
|
23
|
-
} from "./roy-agent-core-
|
|
26
|
+
} from "./roy-agent-core-fdm579b1.js";
|
|
24
27
|
import {
|
|
25
28
|
createLogger,
|
|
26
29
|
init_logger
|
|
@@ -541,12 +544,42 @@ class LLMComponent extends BaseComponent {
|
|
|
541
544
|
await configComponent.set(configKey, value);
|
|
542
545
|
}
|
|
543
546
|
}
|
|
547
|
+
if (envSource instanceof EnvSource) {
|
|
548
|
+
const knownKeys = new Set([
|
|
549
|
+
"llm.defaultModel",
|
|
550
|
+
"llm.defaultProvider",
|
|
551
|
+
"llm.temperature",
|
|
552
|
+
"llm.maxTokens",
|
|
553
|
+
"llm.topP",
|
|
554
|
+
"llm.stream",
|
|
555
|
+
"llm.options",
|
|
556
|
+
"llm.default",
|
|
557
|
+
"llm.providers",
|
|
558
|
+
"llm.limits",
|
|
559
|
+
"llm.capabilities"
|
|
560
|
+
]);
|
|
561
|
+
envSource.validateUnrecognizedEnvVars({
|
|
562
|
+
componentName: "llm",
|
|
563
|
+
knownKeys,
|
|
564
|
+
logger: {
|
|
565
|
+
warn: (msg) => logger.warn(msg)
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
}
|
|
544
569
|
if (config) {
|
|
545
570
|
const flatConfig = this.flattenConfig(config);
|
|
546
571
|
for (const [key, value] of Object.entries(flatConfig)) {
|
|
547
572
|
await configComponent.set(key, value);
|
|
548
573
|
}
|
|
549
574
|
}
|
|
575
|
+
const configuredProviders = configComponent.get("llm.providers");
|
|
576
|
+
const configuredDefaultProvider = configComponent.get("llm.defaultProvider");
|
|
577
|
+
if (typeof configuredDefaultProvider === "string" && configuredProviders && typeof configuredProviders === "object" && Object.keys(configuredProviders).length > 0) {
|
|
578
|
+
const providerKeys = Object.keys(configuredProviders);
|
|
579
|
+
if (!providerKeys.includes(configuredDefaultProvider)) {
|
|
580
|
+
throw new Error(`[LLM] Invalid llm.defaultProvider: "${configuredDefaultProvider}". ` + `Known providers: ${providerKeys.join(", ")}. ` + `Add it to llm.providers first, or remove the env var / config entry.`);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
550
583
|
this.registerConfigWatcher(configComponent);
|
|
551
584
|
}
|
|
552
585
|
flattenConfig(obj, prefix = "llm") {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
init_context
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-9hqqhye6.js";
|
|
4
4
|
import {
|
|
5
5
|
getEnvContext
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-endah27g.js";
|
|
7
7
|
import {
|
|
8
8
|
__esm
|
|
9
9
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
hasDecoratorNodes,
|
|
4
4
|
init_node_registry_helper,
|
|
5
5
|
registerDecoratorNodeType
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-htjag2nr.js";
|
|
7
7
|
import"./roy-agent-core-ddwa0n6h.js";
|
|
8
8
|
import"./roy-agent-core-1ce3fqrk.js";
|
|
9
|
-
import"./roy-agent-core-
|
|
9
|
+
import"./roy-agent-core-fdm579b1.js";
|
|
10
10
|
import"./roy-agent-core-vyygk314.js";
|
|
11
11
|
import"./roy-agent-core-7z9b1fm8.js";
|
|
12
12
|
import"./roy-agent-core-c6592r3c.js";
|
|
@@ -23,7 +23,9 @@ function Traced(options) {
|
|
|
23
23
|
recordError: options?.recordError ?? true,
|
|
24
24
|
log: options?.log ?? false,
|
|
25
25
|
maxLogSize: options?.maxLogSize,
|
|
26
|
-
paramFilter: options?.paramFilter
|
|
26
|
+
paramFilter: options?.paramFilter,
|
|
27
|
+
resultFilter: options?.resultFilter,
|
|
28
|
+
flattenParamFilter: options?.flattenParamFilter
|
|
27
29
|
});
|
|
28
30
|
return descriptor;
|
|
29
31
|
};
|
|
@@ -129,7 +131,15 @@ function wrapFunction(fn, name, options) {
|
|
|
129
131
|
const attributes = {};
|
|
130
132
|
if (options?.recordParams !== false) {
|
|
131
133
|
if (options?.paramFilter) {
|
|
132
|
-
|
|
134
|
+
const filtered = options.paramFilter(args);
|
|
135
|
+
attributes["params"] = truncate(filtered);
|
|
136
|
+
if (options?.flattenParamFilter && filtered && typeof filtered === "object" && !Array.isArray(filtered)) {
|
|
137
|
+
for (const [key, value] of Object.entries(filtered)) {
|
|
138
|
+
if (!(key in attributes)) {
|
|
139
|
+
attributes[key] = truncate(value);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
133
143
|
} else {
|
|
134
144
|
attributes["params"] = truncate(args);
|
|
135
145
|
}
|
|
@@ -145,6 +155,14 @@ function wrapFunction(fn, name, options) {
|
|
|
145
155
|
if (result && typeof result === "object" && typeof result.then === "function") {
|
|
146
156
|
return result.then((resolved) => {
|
|
147
157
|
if (span) {
|
|
158
|
+
if (options?.resultFilter) {
|
|
159
|
+
const filtered = options.resultFilter(resolved);
|
|
160
|
+
if (filtered && typeof filtered === "object") {
|
|
161
|
+
for (const [key, value] of Object.entries(filtered)) {
|
|
162
|
+
span.setAttribute(key, truncate(value));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
148
166
|
span.setAttribute("result", JSON.stringify(truncate(resolved)));
|
|
149
167
|
span.end(resolved);
|
|
150
168
|
}
|
|
@@ -160,6 +178,14 @@ function wrapFunction(fn, name, options) {
|
|
|
160
178
|
});
|
|
161
179
|
}
|
|
162
180
|
if (span) {
|
|
181
|
+
if (options?.resultFilter) {
|
|
182
|
+
const filtered = options.resultFilter(result);
|
|
183
|
+
if (filtered && typeof filtered === "object") {
|
|
184
|
+
for (const [key, value] of Object.entries(filtered)) {
|
|
185
|
+
span.setAttribute(key, truncate(value));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
163
189
|
span.setAttribute("result", JSON.stringify(truncate(result)));
|
|
164
190
|
span.end(result);
|
|
165
191
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TAG_MAX_COUNT,
|
|
3
3
|
TAG_MIN_COUNT
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-p2vpsd1d.js";
|
|
5
5
|
import {
|
|
6
6
|
validateWorkflowDefinition
|
|
7
7
|
} from "./roy-agent-core-8wd3qwx5.js";
|
|
@@ -9,13 +9,16 @@ import {
|
|
|
9
9
|
AskUserError,
|
|
10
10
|
init_workflow_hil
|
|
11
11
|
} from "./roy-agent-core-e25xkv53.js";
|
|
12
|
+
import {
|
|
13
|
+
getCurrentBgTaskId
|
|
14
|
+
} from "./roy-agent-core-c1v263jn.js";
|
|
12
15
|
import {
|
|
13
16
|
isValidSessionId
|
|
14
|
-
} from "./roy-agent-core-
|
|
17
|
+
} from "./roy-agent-core-nw39k111.js";
|
|
15
18
|
import {
|
|
16
19
|
TracedAs,
|
|
17
20
|
init_decorator
|
|
18
|
-
} from "./roy-agent-core-
|
|
21
|
+
} from "./roy-agent-core-fdm579b1.js";
|
|
19
22
|
import {
|
|
20
23
|
createLogger,
|
|
21
24
|
init_logger
|
|
@@ -67,6 +70,7 @@ function createWorkflowGetTool(workflowService) {
|
|
|
67
70
|
name: "workflow_get",
|
|
68
71
|
description: "Get workflow definition details by name, or run status by run_id. Returns workflow name, version, description, inputs schema, and node list.",
|
|
69
72
|
parameters: WorkflowGetInputSchema,
|
|
73
|
+
metadata: { skipTruncation: true },
|
|
70
74
|
execute: async (args, ctx) => {
|
|
71
75
|
const params = WorkflowGetInputSchema.parse(args);
|
|
72
76
|
try {
|
|
@@ -667,7 +671,7 @@ __legacyDecorateClassTS([
|
|
|
667
671
|
recordResult: true
|
|
668
672
|
})
|
|
669
673
|
], RunWorkflowToolRunner.prototype, "execute", null);
|
|
670
|
-
function createRunWorkflowTool(workflowService) {
|
|
674
|
+
function createRunWorkflowTool(workflowService, hooks) {
|
|
671
675
|
const tool = {
|
|
672
676
|
name: "workflow_run",
|
|
673
677
|
description: "Run a workflow by name with optional input, OR resume an existing workflow run via the `session` field (the runId itself acts as session ID, both have `workflow_` prefix natively — pass the workflow run's runId directly). Returns run_id (== session_id, ALWAYS populated — even on timeout/abort/error paths), status, output, error, and duration_ms. Default timeout: 30 minutes.",
|
|
@@ -805,9 +809,25 @@ function createRunWorkflowTool(workflowService) {
|
|
|
805
809
|
}
|
|
806
810
|
};
|
|
807
811
|
const runner = new RunWorkflowToolRunner(tool.execute);
|
|
812
|
+
const wrappedExecute = async (args, ctx) => {
|
|
813
|
+
const bgTaskId = getCurrentBgTaskId();
|
|
814
|
+
if (!bgTaskId || !hooks?.attachWorkflowRun) {
|
|
815
|
+
return runner.execute(args, ctx);
|
|
816
|
+
}
|
|
817
|
+
const initialRunId = "wf_attach_pending_placeholder";
|
|
818
|
+
const result = await runner.execute(args, ctx);
|
|
819
|
+
const runId = result?.metadata?.run_id ?? result?.output?.run_id ?? "";
|
|
820
|
+
if (runId) {
|
|
821
|
+
hooks.attachWorkflowRun?.(bgTaskId, runId);
|
|
822
|
+
if (result.success) {
|
|
823
|
+
hooks.detachWorkflowRun?.(bgTaskId, runId);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
return result;
|
|
827
|
+
};
|
|
808
828
|
return {
|
|
809
829
|
...tool,
|
|
810
|
-
execute:
|
|
830
|
+
execute: wrappedExecute.bind({})
|
|
811
831
|
};
|
|
812
832
|
}
|
|
813
833
|
var _runWorkflowTool = null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createHook
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-r74v00c7.js";
|
|
4
4
|
import {
|
|
5
5
|
HookManager
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-dbkkjmqz.js";
|
|
7
7
|
|
|
8
8
|
// src/env/component.ts
|
|
9
9
|
class BaseComponent {
|
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
globalHookManager,
|
|
11
11
|
init_global_hook_manager
|
|
12
|
-
} from "./roy-agent-core-
|
|
12
|
+
} from "./roy-agent-core-dbkkjmqz.js";
|
|
13
13
|
import {
|
|
14
14
|
TracedAs,
|
|
15
15
|
init_decorator,
|
|
16
16
|
wrapFunction
|
|
17
|
-
} from "./roy-agent-core-
|
|
17
|
+
} from "./roy-agent-core-fdm579b1.js";
|
|
18
18
|
import {
|
|
19
19
|
createLogger,
|
|
20
20
|
init_logger
|
|
@@ -68,6 +68,46 @@ function registerWorkflowJsonOutputPlugin(options = undefined) {
|
|
|
68
68
|
});
|
|
69
69
|
logger.info("Workflow JSON output plugin registered on agent:after.react");
|
|
70
70
|
}
|
|
71
|
+
function readProviderReasoning(source) {
|
|
72
|
+
if (!source)
|
|
73
|
+
return;
|
|
74
|
+
const configComponent = source.configComponent;
|
|
75
|
+
if (!configComponent)
|
|
76
|
+
return;
|
|
77
|
+
const isConfigError = (e) => e instanceof Error && (e.name === "ConfigValidationError" || e.name === "ConfigError");
|
|
78
|
+
let providerId;
|
|
79
|
+
try {
|
|
80
|
+
providerId = configComponent.get("llm.defaultProvider");
|
|
81
|
+
} catch (e) {
|
|
82
|
+
if (isConfigError(e))
|
|
83
|
+
return;
|
|
84
|
+
throw e;
|
|
85
|
+
}
|
|
86
|
+
if (!providerId)
|
|
87
|
+
return;
|
|
88
|
+
let capabilities;
|
|
89
|
+
try {
|
|
90
|
+
const capKey = `llm.providers.${providerId}.capabilities`;
|
|
91
|
+
capabilities = configComponent.get(capKey);
|
|
92
|
+
} catch (e) {
|
|
93
|
+
if (isConfigError(e))
|
|
94
|
+
return;
|
|
95
|
+
throw e;
|
|
96
|
+
}
|
|
97
|
+
return { providerId, reasoning: capabilities?.reasoning === true };
|
|
98
|
+
}
|
|
99
|
+
function resolveProviderToolChoice(source) {
|
|
100
|
+
const ctx = readProviderReasoning(source);
|
|
101
|
+
if (!ctx)
|
|
102
|
+
return "required";
|
|
103
|
+
if (FIRST_PARTY_PROVIDERS.has(ctx.providerId)) {
|
|
104
|
+
return "required";
|
|
105
|
+
}
|
|
106
|
+
if (ctx.reasoning) {
|
|
107
|
+
return "auto";
|
|
108
|
+
}
|
|
109
|
+
return "required";
|
|
110
|
+
}
|
|
71
111
|
async function runWorkflowJsonOutputExtraction(hookCtx) {
|
|
72
112
|
const schema = hookCtx.context.metadata?.outputSchema;
|
|
73
113
|
if (!schema) {
|
|
@@ -113,11 +153,13 @@ async function runWorkflowJsonOutputExtraction(hookCtx) {
|
|
|
113
153
|
content: userQuery
|
|
114
154
|
}
|
|
115
155
|
];
|
|
156
|
+
const resolvedToolChoice = resolveProviderToolChoice(agentComponentRef);
|
|
116
157
|
const extractContext = {
|
|
117
158
|
messages: messagesOverride,
|
|
118
159
|
extraTools: [submitToolAsExtra],
|
|
119
160
|
persistSession: false,
|
|
120
|
-
abort: hookCtx.context.abort
|
|
161
|
+
abort: hookCtx.context.abort,
|
|
162
|
+
toolChoice: resolvedToolChoice
|
|
121
163
|
};
|
|
122
164
|
try {
|
|
123
165
|
const result = await agentComponentRef.run("json-extract", "", extractContext);
|
|
@@ -134,7 +176,7 @@ async function runWorkflowJsonOutputExtraction(hookCtx) {
|
|
|
134
176
|
logger.error(`Workflow JSON extraction: json-extract sub-agent threw: ${error instanceof Error ? error.message : String(error)}`);
|
|
135
177
|
}
|
|
136
178
|
}
|
|
137
|
-
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;
|
|
179
|
+
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, FIRST_PARTY_PROVIDERS, tracedRunWorkflowJsonOutputExtraction;
|
|
138
180
|
var init_workflow_json_output_plugin = __esm(() => {
|
|
139
181
|
init_global_hook_manager();
|
|
140
182
|
init_workflow_hil();
|
|
@@ -144,6 +186,7 @@ var init_workflow_json_output_plugin = __esm(() => {
|
|
|
144
186
|
logger = createLogger("WorkflowJsonOutputPlugin");
|
|
145
187
|
WORKFLOW_JSON_OUTPUT_PLUGIN_KEY = `${WORKFLOW_JSON_OUTPUT_SOURCE_ID}:${WORKFLOW_JSON_OUTPUT_PLUGIN_NAME}`;
|
|
146
188
|
HOOK_NAME = `${WORKFLOW_JSON_OUTPUT_PLUGIN_NAME}:${HOOK_POINT}`;
|
|
189
|
+
FIRST_PARTY_PROVIDERS = new Set(["openai", "anthropic", "google"]);
|
|
147
190
|
tracedRunWorkflowJsonOutputExtraction = wrapFunction(runWorkflowJsonOutputExtraction, "workflow.json_output.extraction", { recordParams: true, recordResult: true, log: true });
|
|
148
191
|
});
|
|
149
192
|
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
WorkflowRepository,
|
|
3
3
|
migrateEmptyTagsToDefault,
|
|
4
4
|
rowToWorkflow
|
|
5
|
-
} from "./roy-agent-core-
|
|
6
|
-
import"./roy-agent-core-
|
|
5
|
+
} from "./roy-agent-core-1mq9erp8.js";
|
|
6
|
+
import"./roy-agent-core-606z25nw.js";
|
|
7
7
|
import"./roy-agent-core-rvxg1wps.js";
|
|
8
|
-
import"./roy-agent-core-
|
|
8
|
+
import"./roy-agent-core-fdm579b1.js";
|
|
9
9
|
import"./roy-agent-core-vyygk314.js";
|
|
10
10
|
import"./roy-agent-core-7z9b1fm8.js";
|
|
11
11
|
import"./roy-agent-core-c6592r3c.js";
|