@ai-setting/roy-agent-core 1.6.10 → 1.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/env/index.js +4 -4
- package/dist/env/task/delegate/index.js +1 -1
- package/dist/env/task/index.js +2 -2
- package/dist/env/workflow/index.js +2 -2
- package/dist/env/workflow/tools/index.js +1 -1
- package/dist/index.js +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-4mhrz08q.js → roy-agent-core-06574wqa.js} +3 -2
- package/dist/shared/@ai-setting/{roy-agent-core-nzpw62d3.js → roy-agent-core-3rs38pf7.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-8bhncxep.js → roy-agent-core-5w9a1eqa.js} +43 -6
- package/dist/shared/@ai-setting/{roy-agent-core-g9p7e2ys.js → roy-agent-core-mb7b62sm.js} +51 -13
- package/package.json +1 -1
package/dist/env/index.js
CHANGED
|
@@ -21,7 +21,7 @@ import"../shared/@ai-setting/roy-agent-core-y5ymc4f8.js";
|
|
|
21
21
|
import"../shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
22
22
|
import {
|
|
23
23
|
WorkflowComponent
|
|
24
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
24
|
+
} from "../shared/@ai-setting/roy-agent-core-06574wqa.js";
|
|
25
25
|
import"../shared/@ai-setting/roy-agent-core-htjag2nr.js";
|
|
26
26
|
import"../shared/@ai-setting/roy-agent-core-0n2a8cbn.js";
|
|
27
27
|
import"../shared/@ai-setting/roy-agent-core-6atd905e.js";
|
|
@@ -31,7 +31,7 @@ import"../shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
|
|
|
31
31
|
import"../shared/@ai-setting/roy-agent-core-hhrg314p.js";
|
|
32
32
|
import"../shared/@ai-setting/roy-agent-core-resnbd2j.js";
|
|
33
33
|
import"../shared/@ai-setting/roy-agent-core-qnrf2aw6.js";
|
|
34
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
34
|
+
import"../shared/@ai-setting/roy-agent-core-mb7b62sm.js";
|
|
35
35
|
import"../shared/@ai-setting/roy-agent-core-1db4vpc6.js";
|
|
36
36
|
import"../shared/@ai-setting/roy-agent-core-p2vpsd1d.js";
|
|
37
37
|
import"../shared/@ai-setting/roy-agent-core-8wd3qwx5.js";
|
|
@@ -48,10 +48,10 @@ import"../shared/@ai-setting/roy-agent-core-5h49ct1a.js";
|
|
|
48
48
|
import"../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
49
49
|
import {
|
|
50
50
|
TaskComponent
|
|
51
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
51
|
+
} from "../shared/@ai-setting/roy-agent-core-3rs38pf7.js";
|
|
52
52
|
import"../shared/@ai-setting/roy-agent-core-amkqnyzy.js";
|
|
53
53
|
import"../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
|
|
54
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
54
|
+
import"../shared/@ai-setting/roy-agent-core-5w9a1eqa.js";
|
|
55
55
|
import"../shared/@ai-setting/roy-agent-core-pzeexnhf.js";
|
|
56
56
|
import"../shared/@ai-setting/roy-agent-core-9xby523m.js";
|
|
57
57
|
import"../shared/@ai-setting/roy-agent-core-trdpar9f.js";
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
BackgroundTaskManager,
|
|
4
4
|
createDelegateTool,
|
|
5
5
|
createStopTool
|
|
6
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
6
|
+
} from "../../../shared/@ai-setting/roy-agent-core-5w9a1eqa.js";
|
|
7
7
|
import"../../../shared/@ai-setting/roy-agent-core-pzeexnhf.js";
|
|
8
8
|
import"../../../shared/@ai-setting/roy-agent-core-trdpar9f.js";
|
|
9
9
|
import"../../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
package/dist/env/task/index.js
CHANGED
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
TaskPriorityEnum,
|
|
6
6
|
TaskStatusEnum,
|
|
7
7
|
TaskTypeEnum
|
|
8
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
8
|
+
} from "../../shared/@ai-setting/roy-agent-core-3rs38pf7.js";
|
|
9
9
|
import"../../shared/@ai-setting/roy-agent-core-amkqnyzy.js";
|
|
10
10
|
import {
|
|
11
11
|
TaskEntityEventTypes
|
|
12
12
|
} from "../../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
|
|
13
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
13
|
+
import"../../shared/@ai-setting/roy-agent-core-5w9a1eqa.js";
|
|
14
14
|
import"../../shared/@ai-setting/roy-agent-core-pzeexnhf.js";
|
|
15
15
|
import {
|
|
16
16
|
SQLiteTaskStore,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WorkflowComponent
|
|
3
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
3
|
+
} from "../../shared/@ai-setting/roy-agent-core-06574wqa.js";
|
|
4
4
|
import"../../shared/@ai-setting/roy-agent-core-htjag2nr.js";
|
|
5
5
|
import"../../shared/@ai-setting/roy-agent-core-0n2a8cbn.js";
|
|
6
6
|
import"../../shared/@ai-setting/roy-agent-core-6atd905e.js";
|
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
pathNotFound,
|
|
61
61
|
unresolvedVariable
|
|
62
62
|
} from "../../shared/@ai-setting/roy-agent-core-qnrf2aw6.js";
|
|
63
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
63
|
+
import"../../shared/@ai-setting/roy-agent-core-mb7b62sm.js";
|
|
64
64
|
import"../../shared/@ai-setting/roy-agent-core-1db4vpc6.js";
|
|
65
65
|
import"../../shared/@ai-setting/roy-agent-core-p2vpsd1d.js";
|
|
66
66
|
import"../../shared/@ai-setting/roy-agent-core-8wd3qwx5.js";
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
getRunWorkflowTool,
|
|
25
25
|
initRunWorkflowTool,
|
|
26
26
|
resetRunWorkflowTool
|
|
27
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
27
|
+
} from "../../../shared/@ai-setting/roy-agent-core-mb7b62sm.js";
|
|
28
28
|
import {
|
|
29
29
|
WORKFLOW_SUBMIT_OUTPUT_TOOL_NAME,
|
|
30
30
|
WorkflowJsonOutputMarker,
|
package/dist/index.js
CHANGED
|
@@ -101,7 +101,7 @@ import {
|
|
|
101
101
|
} from "./shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
102
102
|
import {
|
|
103
103
|
WorkflowComponent
|
|
104
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
104
|
+
} from "./shared/@ai-setting/roy-agent-core-06574wqa.js";
|
|
105
105
|
import {
|
|
106
106
|
init_node_registry_helper,
|
|
107
107
|
registerDecoratorNodeType
|
|
@@ -114,7 +114,7 @@ import"./shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
|
|
|
114
114
|
import"./shared/@ai-setting/roy-agent-core-hhrg314p.js";
|
|
115
115
|
import"./shared/@ai-setting/roy-agent-core-resnbd2j.js";
|
|
116
116
|
import"./shared/@ai-setting/roy-agent-core-qnrf2aw6.js";
|
|
117
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
117
|
+
import"./shared/@ai-setting/roy-agent-core-mb7b62sm.js";
|
|
118
118
|
import"./shared/@ai-setting/roy-agent-core-1db4vpc6.js";
|
|
119
119
|
import"./shared/@ai-setting/roy-agent-core-p2vpsd1d.js";
|
|
120
120
|
import"./shared/@ai-setting/roy-agent-core-8wd3qwx5.js";
|
|
@@ -149,10 +149,10 @@ import {
|
|
|
149
149
|
} from "./shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
150
150
|
import {
|
|
151
151
|
TaskComponent
|
|
152
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
152
|
+
} from "./shared/@ai-setting/roy-agent-core-3rs38pf7.js";
|
|
153
153
|
import"./shared/@ai-setting/roy-agent-core-amkqnyzy.js";
|
|
154
154
|
import"./shared/@ai-setting/roy-agent-core-8gxth0eh.js";
|
|
155
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
155
|
+
import"./shared/@ai-setting/roy-agent-core-5w9a1eqa.js";
|
|
156
156
|
import"./shared/@ai-setting/roy-agent-core-pzeexnhf.js";
|
|
157
157
|
import {
|
|
158
158
|
SQLiteTaskStore,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
createWorkflowSearchTool,
|
|
19
19
|
createWorkflowTagListTool,
|
|
20
20
|
createWorkflowValidateTool
|
|
21
|
-
} from "./roy-agent-core-
|
|
21
|
+
} from "./roy-agent-core-mb7b62sm.js";
|
|
22
22
|
import {
|
|
23
23
|
WorkflowService
|
|
24
24
|
} from "./roy-agent-core-p2vpsd1d.js";
|
|
@@ -217,7 +217,8 @@ class WorkflowComponent extends BaseComponent {
|
|
|
217
217
|
}
|
|
218
218
|
const lifecycleHooks = backgroundTaskManager ? {
|
|
219
219
|
attachWorkflowRun: (bgTaskId, runId) => backgroundTaskManager.attachWorkflowRun(bgTaskId, runId),
|
|
220
|
-
detachWorkflowRun: (bgTaskId, runId) => backgroundTaskManager.detachWorkflowRun(bgTaskId, runId)
|
|
220
|
+
detachWorkflowRun: (bgTaskId, runId) => backgroundTaskManager.detachWorkflowRun(bgTaskId, runId),
|
|
221
|
+
replaceWorkflowRun: (bgTaskId, oldRunId, newRunId) => backgroundTaskManager.replaceWorkflowRun(bgTaskId, oldRunId, newRunId)
|
|
221
222
|
} : undefined;
|
|
222
223
|
const tools = [
|
|
223
224
|
createWorkflowGetTool(this.workflowService),
|
|
@@ -296,24 +296,48 @@ class BackgroundTaskManager {
|
|
|
296
296
|
detachWorkflowRun(bgTaskId, workflowRunId) {
|
|
297
297
|
this.workflowRunRegistries.get(bgTaskId)?.delete(workflowRunId);
|
|
298
298
|
}
|
|
299
|
-
|
|
299
|
+
replaceWorkflowRun(bgTaskId, oldRunId, newRunId) {
|
|
300
|
+
if (!bgTaskId)
|
|
301
|
+
return;
|
|
300
302
|
const set = this.workflowRunRegistries.get(bgTaskId);
|
|
301
|
-
if (!set
|
|
303
|
+
if (!set)
|
|
302
304
|
return;
|
|
305
|
+
if (oldRunId) {
|
|
306
|
+
set.delete(oldRunId);
|
|
307
|
+
}
|
|
308
|
+
if (newRunId) {
|
|
309
|
+
set.add(newRunId);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
async propagateStopToWorkflowRuns(bgTaskId, reason) {
|
|
313
|
+
const set = this.workflowRunRegistries.get(bgTaskId);
|
|
314
|
+
if (!set || set.size === 0) {
|
|
315
|
+
return { runIds: [], stopResults: [] };
|
|
316
|
+
}
|
|
303
317
|
const runIds = Array.from(set);
|
|
304
318
|
logger.info(`[BackgroundTaskManager] propagateStopToWorkflowRuns count=${runIds.length} bgTaskId=${bgTaskId}`);
|
|
319
|
+
const stopResults = [];
|
|
305
320
|
for (const runId of runIds) {
|
|
306
321
|
if (typeof this.workflowService?.stopRun !== "function") {
|
|
307
322
|
logger.warn(`[BackgroundTaskManager] workflowService not injected; cannot stop ${runId}`);
|
|
323
|
+
stopResults.push({
|
|
324
|
+
runId,
|
|
325
|
+
success: false,
|
|
326
|
+
error: "workflowService not injected"
|
|
327
|
+
});
|
|
308
328
|
continue;
|
|
309
329
|
}
|
|
310
330
|
try {
|
|
311
331
|
await this.workflowService.stopRun(runId, reason);
|
|
332
|
+
stopResults.push({ runId, success: true });
|
|
312
333
|
} catch (err) {
|
|
313
|
-
|
|
334
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
335
|
+
logger.warn(`[BackgroundTaskManager] workflowService.stopRun(${runId}) failed (likely already terminal): ${errMsg}`);
|
|
336
|
+
stopResults.push({ runId, success: false, error: errMsg });
|
|
314
337
|
}
|
|
315
338
|
}
|
|
316
339
|
set.clear();
|
|
340
|
+
return { runIds, stopResults };
|
|
317
341
|
}
|
|
318
342
|
static DEFAULT_WORKFLOW_ENTRY_AGENT = "workflow-runner";
|
|
319
343
|
resolveEntryAgent(subagentType) {
|
|
@@ -758,7 +782,7 @@ Use these as guidance to improve task execution efficiency.`;
|
|
|
758
782
|
error: err instanceof Error ? err.message : String(err)
|
|
759
783
|
});
|
|
760
784
|
}
|
|
761
|
-
await this.propagateStopToWorkflowRuns(taskId, "Task stopped by user");
|
|
785
|
+
const { runIds, stopResults } = await this.propagateStopToWorkflowRuns(taskId, "Task stopped by user");
|
|
762
786
|
const stoppedPayload = {
|
|
763
787
|
backgroundTaskId: task.id,
|
|
764
788
|
subSessionId: task.subSessionId,
|
|
@@ -770,7 +794,13 @@ Use these as guidance to improve task execution efficiency.`;
|
|
|
770
794
|
associatedTaskId: task.associatedTaskId
|
|
771
795
|
};
|
|
772
796
|
this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, task.parentSessionId);
|
|
773
|
-
return {
|
|
797
|
+
return {
|
|
798
|
+
success: true,
|
|
799
|
+
task,
|
|
800
|
+
message: "Task has been stopped",
|
|
801
|
+
attached_workflow_run_ids: runIds,
|
|
802
|
+
workflow_stop_results: stopResults
|
|
803
|
+
};
|
|
774
804
|
}
|
|
775
805
|
getTask(taskId) {
|
|
776
806
|
return this.tasks.get(taskId);
|
|
@@ -817,11 +847,18 @@ __legacyDecorateClassTS([
|
|
|
817
847
|
})
|
|
818
848
|
], BackgroundTaskManager.prototype, "detachWorkflowRun", null);
|
|
819
849
|
__legacyDecorateClassTS([
|
|
820
|
-
TracedAs("task.background.
|
|
850
|
+
TracedAs("task.background.replaceWorkflowRun", {
|
|
821
851
|
recordParams: true,
|
|
822
852
|
recordResult: false,
|
|
823
853
|
log: true
|
|
824
854
|
})
|
|
855
|
+
], BackgroundTaskManager.prototype, "replaceWorkflowRun", null);
|
|
856
|
+
__legacyDecorateClassTS([
|
|
857
|
+
TracedAs("task.background.propagateStopToWorkflowRuns", {
|
|
858
|
+
recordParams: true,
|
|
859
|
+
recordResult: true,
|
|
860
|
+
log: true
|
|
861
|
+
})
|
|
825
862
|
], BackgroundTaskManager.prototype, "propagateStopToWorkflowRuns", null);
|
|
826
863
|
__legacyDecorateClassTS([
|
|
827
864
|
TracedAs("task.background.resolveEntryAgent", { recordParams: true, recordResult: true })
|
|
@@ -671,6 +671,48 @@ __legacyDecorateClassTS([
|
|
|
671
671
|
recordResult: true
|
|
672
672
|
})
|
|
673
673
|
], RunWorkflowToolRunner.prototype, "execute", null);
|
|
674
|
+
|
|
675
|
+
class RunWorkflowLifecycleTracer {
|
|
676
|
+
runner;
|
|
677
|
+
bgTaskId;
|
|
678
|
+
hooks;
|
|
679
|
+
constructor(runner, bgTaskId, hooks) {
|
|
680
|
+
this.runner = runner;
|
|
681
|
+
this.bgTaskId = bgTaskId;
|
|
682
|
+
this.hooks = hooks;
|
|
683
|
+
}
|
|
684
|
+
async execute(args, ctx) {
|
|
685
|
+
const hasHooks = !!this.hooks?.attachWorkflowRun;
|
|
686
|
+
const hasBgTask = !!this.bgTaskId;
|
|
687
|
+
const result = await this.runner.execute(args, ctx);
|
|
688
|
+
let detached = false;
|
|
689
|
+
if (this.bgTaskId && this.hooks?.detachWorkflowRun) {
|
|
690
|
+
const runId = result?.metadata?.run_id ?? result?.output?.run_id ?? "";
|
|
691
|
+
if (runId && result.success) {
|
|
692
|
+
this.hooks.detachWorkflowRun(this.bgTaskId, runId);
|
|
693
|
+
detached = true;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
return {
|
|
697
|
+
...result,
|
|
698
|
+
metadata: {
|
|
699
|
+
...result.metadata,
|
|
700
|
+
__pre_attach: {
|
|
701
|
+
hasBgTask,
|
|
702
|
+
hasHooks,
|
|
703
|
+
detached,
|
|
704
|
+
success: !!result.success
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
__legacyDecorateClassTS([
|
|
711
|
+
TracedAs("workflow.run-tool.pre-attach", {
|
|
712
|
+
recordParams: true,
|
|
713
|
+
recordResult: true
|
|
714
|
+
})
|
|
715
|
+
], RunWorkflowLifecycleTracer.prototype, "execute", null);
|
|
674
716
|
function createRunWorkflowTool(workflowService, hooks) {
|
|
675
717
|
const tool = {
|
|
676
718
|
name: "workflow_run",
|
|
@@ -708,12 +750,19 @@ function createRunWorkflowTool(workflowService, hooks) {
|
|
|
708
750
|
let timedOut = false;
|
|
709
751
|
let capturedByCallback = false;
|
|
710
752
|
let capturedRunId = session ? session : reservedRunId;
|
|
753
|
+
const bgTaskIdForAttach = getCurrentBgTaskId();
|
|
754
|
+
if (bgTaskIdForAttach && hooks?.attachWorkflowRun) {
|
|
755
|
+
hooks.attachWorkflowRun(bgTaskIdForAttach, reservedRunId);
|
|
756
|
+
}
|
|
711
757
|
const onSessionCreated = (sid) => {
|
|
712
758
|
capturedRunId = sid;
|
|
713
759
|
capturedByCallback = true;
|
|
714
760
|
if (timedOut) {
|
|
715
761
|
attemptStopOnTimeout(workflowService, sid, "timed out");
|
|
716
762
|
}
|
|
763
|
+
if (bgTaskIdForAttach && hooks?.replaceWorkflowRun) {
|
|
764
|
+
hooks.replaceWorkflowRun(bgTaskIdForAttach, reservedRunId, sid);
|
|
765
|
+
}
|
|
717
766
|
};
|
|
718
767
|
try {
|
|
719
768
|
let result;
|
|
@@ -811,19 +860,8 @@ function createRunWorkflowTool(workflowService, hooks) {
|
|
|
811
860
|
const runner = new RunWorkflowToolRunner(tool.execute);
|
|
812
861
|
const wrappedExecute = async (args, ctx) => {
|
|
813
862
|
const bgTaskId = getCurrentBgTaskId();
|
|
814
|
-
|
|
815
|
-
|
|
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;
|
|
863
|
+
const lifecycleTracer = new RunWorkflowLifecycleTracer(runner, bgTaskId, hooks);
|
|
864
|
+
return lifecycleTracer.execute(args, ctx);
|
|
827
865
|
};
|
|
828
866
|
return {
|
|
829
867
|
...tool,
|