@ai-setting/roy-agent-core 1.7.0 → 1.7.2
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/agent/index.js +3 -4
- package/dist/env/index.js +9 -10
- package/dist/env/llm/index.js +3 -4
- package/dist/env/session/index.js +4 -4
- package/dist/env/session/storage/index.js +3 -3
- package/dist/env/task/index.js +2 -2
- package/dist/env/task/tools/index.js +1 -1
- package/dist/env/workflow/index.js +6 -6
- package/dist/env/workflow/tools/index.js +5 -5
- package/dist/index.js +15 -16
- package/dist/shared/@ai-setting/{roy-agent-core-167qsqrz.js → roy-agent-core-2xb3f3ye.js} +143 -23
- package/dist/shared/@ai-setting/{roy-agent-core-q34tv05y.js → roy-agent-core-3dwcwgn5.js} +136 -29
- package/dist/shared/@ai-setting/{roy-agent-core-hks28tys.js → roy-agent-core-k4byknt1.js} +37 -6
- package/dist/shared/@ai-setting/{roy-agent-core-mreh3s0v.js → roy-agent-core-qatz3q31.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-w66q6zst.js → roy-agent-core-w93wrd77.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-xcs0vjqg.js → roy-agent-core-wgp3q62x.js} +7 -4
- package/dist/shared/@ai-setting/{roy-agent-core-mhayyp5c.js → roy-agent-core-xmacq00w.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-bs3c1x02.js → roy-agent-core-xvag5pd0.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-8s7qyr5y.js → roy-agent-core-y9q3jdcx.js} +29 -6
- package/dist/shared/@ai-setting/{roy-agent-core-879dbkpx.js → roy-agent-core-zcx8nf4a.js} +1 -1
- package/package.json +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-ddrc00er.js +0 -50
package/dist/env/agent/index.js
CHANGED
|
@@ -2,8 +2,7 @@ import {
|
|
|
2
2
|
AgentComponent,
|
|
3
3
|
AgentComponentConfigSchema,
|
|
4
4
|
SummaryAgent
|
|
5
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
6
|
-
import"../../shared/@ai-setting/roy-agent-core-167qsqrz.js";
|
|
5
|
+
} from "../../shared/@ai-setting/roy-agent-core-3dwcwgn5.js";
|
|
7
6
|
import"../../shared/@ai-setting/roy-agent-core-h28gcd77.js";
|
|
8
7
|
import"../../shared/@ai-setting/roy-agent-core-br7dmedr.js";
|
|
9
8
|
import"../../shared/@ai-setting/roy-agent-core-t3yqzgse.js";
|
|
@@ -12,8 +11,8 @@ import"../../shared/@ai-setting/roy-agent-core-x0yztmm6.js";
|
|
|
12
11
|
import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
13
12
|
import"../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
14
13
|
import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
|
|
15
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
16
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
14
|
+
import"../../shared/@ai-setting/roy-agent-core-zcx8nf4a.js";
|
|
15
|
+
import"../../shared/@ai-setting/roy-agent-core-2xb3f3ye.js";
|
|
17
16
|
import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
18
17
|
import"../../shared/@ai-setting/roy-agent-core-pde8hkq4.js";
|
|
19
18
|
import"../../shared/@ai-setting/roy-agent-core-5ts23mx0.js";
|
package/dist/env/index.js
CHANGED
|
@@ -21,7 +21,7 @@ import"../shared/@ai-setting/roy-agent-core-gns3wa97.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-xmacq00w.js";
|
|
25
25
|
import"../shared/@ai-setting/roy-agent-core-3e0w0ekw.js";
|
|
26
26
|
import"../shared/@ai-setting/roy-agent-core-s4r8f6se.js";
|
|
27
27
|
import"../shared/@ai-setting/roy-agent-core-6atd905e.js";
|
|
@@ -30,7 +30,7 @@ import"../shared/@ai-setting/roy-agent-core-h1cb2jzh.js";
|
|
|
30
30
|
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-0qjw25e8.js";
|
|
33
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
33
|
+
import"../shared/@ai-setting/roy-agent-core-qatz3q31.js";
|
|
34
34
|
import"../shared/@ai-setting/roy-agent-core-1db4vpc6.js";
|
|
35
35
|
import"../shared/@ai-setting/roy-agent-core-j9ybhwnq.js";
|
|
36
36
|
import"../shared/@ai-setting/roy-agent-core-w8rv08d3.js";
|
|
@@ -41,15 +41,14 @@ import"../shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
|
41
41
|
import {
|
|
42
42
|
AgentComponent,
|
|
43
43
|
AgentComponentConfigSchema
|
|
44
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
45
|
-
import"../shared/@ai-setting/roy-agent-core-167qsqrz.js";
|
|
44
|
+
} from "../shared/@ai-setting/roy-agent-core-3dwcwgn5.js";
|
|
46
45
|
import"../shared/@ai-setting/roy-agent-core-h28gcd77.js";
|
|
47
46
|
import"../shared/@ai-setting/roy-agent-core-br7dmedr.js";
|
|
48
47
|
import"../shared/@ai-setting/roy-agent-core-t3yqzgse.js";
|
|
49
48
|
import"../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
50
49
|
import {
|
|
51
50
|
TaskComponent
|
|
52
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
51
|
+
} from "../shared/@ai-setting/roy-agent-core-y9q3jdcx.js";
|
|
53
52
|
import"../shared/@ai-setting/roy-agent-core-amkqnyzy.js";
|
|
54
53
|
import"../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
|
|
55
54
|
import"../shared/@ai-setting/roy-agent-core-50jdqb7r.js";
|
|
@@ -63,7 +62,7 @@ import {
|
|
|
63
62
|
getXDGPaths
|
|
64
63
|
} from "../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
65
64
|
import"../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
66
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
65
|
+
import"../shared/@ai-setting/roy-agent-core-k4byknt1.js";
|
|
67
66
|
import"../shared/@ai-setting/roy-agent-core-rn57psp0.js";
|
|
68
67
|
import"../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
|
|
69
68
|
import {
|
|
@@ -72,11 +71,11 @@ import {
|
|
|
72
71
|
import"../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
|
|
73
72
|
import"../shared/@ai-setting/roy-agent-core-fnv3ev18.js";
|
|
74
73
|
import"../shared/@ai-setting/roy-agent-core-dxfd6p1c.js";
|
|
75
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
74
|
+
import"../shared/@ai-setting/roy-agent-core-xvag5pd0.js";
|
|
76
75
|
import"../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
|
|
77
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
78
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
79
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
76
|
+
import"../shared/@ai-setting/roy-agent-core-wgp3q62x.js";
|
|
77
|
+
import"../shared/@ai-setting/roy-agent-core-zcx8nf4a.js";
|
|
78
|
+
import"../shared/@ai-setting/roy-agent-core-2xb3f3ye.js";
|
|
80
79
|
import"../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
81
80
|
import {
|
|
82
81
|
BaseComponent
|
package/dist/env/llm/index.js
CHANGED
|
@@ -14,17 +14,16 @@ import {
|
|
|
14
14
|
createLLMAdapter,
|
|
15
15
|
getLLMProviderOverride,
|
|
16
16
|
setLLMProvider
|
|
17
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
17
|
+
} from "../../shared/@ai-setting/roy-agent-core-w93wrd77.js";
|
|
18
18
|
import"../../shared/@ai-setting/roy-agent-core-y3g3ar7a.js";
|
|
19
|
+
import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
|
|
19
20
|
import {
|
|
20
21
|
convertToSDKMessages,
|
|
21
22
|
createInvokeConfig,
|
|
22
23
|
invoke,
|
|
23
24
|
invokeNonStream,
|
|
24
25
|
parseModelString
|
|
25
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
26
|
-
import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
|
|
27
|
-
import"../../shared/@ai-setting/roy-agent-core-ddrc00er.js";
|
|
26
|
+
} from "../../shared/@ai-setting/roy-agent-core-2xb3f3ye.js";
|
|
28
27
|
import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
29
28
|
import"../../shared/@ai-setting/roy-agent-core-pde8hkq4.js";
|
|
30
29
|
import"../../shared/@ai-setting/roy-agent-core-5ts23mx0.js";
|
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
MIN_SESSION_ID_LENGTH,
|
|
4
4
|
SessionComponent,
|
|
5
5
|
isValidSessionId
|
|
6
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
6
|
+
} from "../../shared/@ai-setting/roy-agent-core-xvag5pd0.js";
|
|
7
7
|
import"../../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
|
|
8
8
|
import {
|
|
9
9
|
MemorySessionStore
|
|
10
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
10
|
+
} from "../../shared/@ai-setting/roy-agent-core-wgp3q62x.js";
|
|
11
11
|
import {
|
|
12
12
|
SessionMessageConverter
|
|
13
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
14
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
13
|
+
} from "../../shared/@ai-setting/roy-agent-core-zcx8nf4a.js";
|
|
14
|
+
import"../../shared/@ai-setting/roy-agent-core-2xb3f3ye.js";
|
|
15
15
|
import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
16
16
|
import"../../shared/@ai-setting/roy-agent-core-pde8hkq4.js";
|
|
17
17
|
import"../../shared/@ai-setting/roy-agent-core-5ts23mx0.js";
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
SQLiteSessionStore,
|
|
4
4
|
getDefaultDataDir,
|
|
5
5
|
getDefaultSessionDbPath
|
|
6
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
7
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
8
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
6
|
+
} from "../../../shared/@ai-setting/roy-agent-core-wgp3q62x.js";
|
|
7
|
+
import"../../../shared/@ai-setting/roy-agent-core-zcx8nf4a.js";
|
|
8
|
+
import"../../../shared/@ai-setting/roy-agent-core-2xb3f3ye.js";
|
|
9
9
|
import"../../../shared/@ai-setting/roy-agent-core-kaq037np.js";
|
|
10
10
|
import"../../../shared/@ai-setting/roy-agent-core-1khp1m0r.js";
|
|
11
11
|
import"../../../shared/@ai-setting/roy-agent-core-4an1p9a1.js";
|
package/dist/env/task/index.js
CHANGED
|
@@ -5,7 +5,7 @@ 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-y9q3jdcx.js";
|
|
9
9
|
import"../../shared/@ai-setting/roy-agent-core-amkqnyzy.js";
|
|
10
10
|
import {
|
|
11
11
|
TaskEntityEventTypes
|
|
@@ -20,7 +20,7 @@ import"../../shared/@ai-setting/roy-agent-core-skqt40yy.js";
|
|
|
20
20
|
import"../../shared/@ai-setting/roy-agent-core-x0yztmm6.js";
|
|
21
21
|
import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
22
22
|
import"../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
23
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
23
|
+
import"../../shared/@ai-setting/roy-agent-core-k4byknt1.js";
|
|
24
24
|
import"../../shared/@ai-setting/roy-agent-core-rn57psp0.js";
|
|
25
25
|
import"../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
|
|
26
26
|
import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
searchTasksTool,
|
|
10
10
|
treeTasksTool,
|
|
11
11
|
updateTaskTool
|
|
12
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
12
|
+
} from "../../../shared/@ai-setting/roy-agent-core-k4byknt1.js";
|
|
13
13
|
import"../../../shared/@ai-setting/roy-agent-core-xrr7t0qc.js";
|
|
14
14
|
import"../../../shared/@ai-setting/roy-agent-core-gb7pm9c0.js";
|
|
15
15
|
import"../../../shared/@ai-setting/roy-agent-core-kaq037np.js";
|
|
@@ -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-xmacq00w.js";
|
|
4
4
|
import"../../shared/@ai-setting/roy-agent-core-3e0w0ekw.js";
|
|
5
5
|
import"../../shared/@ai-setting/roy-agent-core-s4r8f6se.js";
|
|
6
6
|
import"../../shared/@ai-setting/roy-agent-core-6atd905e.js";
|
|
@@ -9,7 +9,7 @@ import"../../shared/@ai-setting/roy-agent-core-h1cb2jzh.js";
|
|
|
9
9
|
import"../../shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
|
|
10
10
|
import"../../shared/@ai-setting/roy-agent-core-hhrg314p.js";
|
|
11
11
|
import"../../shared/@ai-setting/roy-agent-core-0qjw25e8.js";
|
|
12
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
12
|
+
import"../../shared/@ai-setting/roy-agent-core-qatz3q31.js";
|
|
13
13
|
import"../../shared/@ai-setting/roy-agent-core-1db4vpc6.js";
|
|
14
14
|
import"../../shared/@ai-setting/roy-agent-core-j9ybhwnq.js";
|
|
15
15
|
import"../../shared/@ai-setting/roy-agent-core-w8rv08d3.js";
|
|
@@ -84,11 +84,11 @@ import {
|
|
|
84
84
|
createWorkflowAskUserEvent
|
|
85
85
|
} from "../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
86
86
|
import"../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
87
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
87
|
+
import"../../shared/@ai-setting/roy-agent-core-xvag5pd0.js";
|
|
88
88
|
import"../../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
|
|
89
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
90
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
91
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
89
|
+
import"../../shared/@ai-setting/roy-agent-core-wgp3q62x.js";
|
|
90
|
+
import"../../shared/@ai-setting/roy-agent-core-zcx8nf4a.js";
|
|
91
|
+
import"../../shared/@ai-setting/roy-agent-core-2xb3f3ye.js";
|
|
92
92
|
import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
93
93
|
import"../../shared/@ai-setting/roy-agent-core-pde8hkq4.js";
|
|
94
94
|
import"../../shared/@ai-setting/roy-agent-core-5ts23mx0.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-qatz3q31.js";
|
|
28
28
|
import {
|
|
29
29
|
WORKFLOW_SUBMIT_OUTPUT_TOOL_NAME,
|
|
30
30
|
WorkflowJsonOutputMarker,
|
|
@@ -38,11 +38,11 @@ import"../../../shared/@ai-setting/roy-agent-core-0v74marc.js";
|
|
|
38
38
|
import"../../../shared/@ai-setting/roy-agent-core-jrj30vq3.js";
|
|
39
39
|
import"../../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
40
40
|
import"../../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
41
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
41
|
+
import"../../../shared/@ai-setting/roy-agent-core-xvag5pd0.js";
|
|
42
42
|
import"../../../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
|
|
43
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
44
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
45
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
43
|
+
import"../../../shared/@ai-setting/roy-agent-core-wgp3q62x.js";
|
|
44
|
+
import"../../../shared/@ai-setting/roy-agent-core-zcx8nf4a.js";
|
|
45
|
+
import"../../../shared/@ai-setting/roy-agent-core-2xb3f3ye.js";
|
|
46
46
|
import"../../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
47
47
|
import"../../../shared/@ai-setting/roy-agent-core-pde8hkq4.js";
|
|
48
48
|
import"../../../shared/@ai-setting/roy-agent-core-5ts23mx0.js";
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
ModelLimitsSchema,
|
|
10
10
|
ProviderCapabilitiesSchema,
|
|
11
11
|
ProviderConfigSchema
|
|
12
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
12
|
+
} from "./shared/@ai-setting/roy-agent-core-w93wrd77.js";
|
|
13
13
|
import {
|
|
14
14
|
ConfigComponent
|
|
15
15
|
} from "./shared/@ai-setting/roy-agent-core-g7nmwg63.js";
|
|
@@ -102,7 +102,7 @@ import {
|
|
|
102
102
|
} from "./shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
103
103
|
import {
|
|
104
104
|
WorkflowComponent
|
|
105
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
105
|
+
} from "./shared/@ai-setting/roy-agent-core-xmacq00w.js";
|
|
106
106
|
import {
|
|
107
107
|
init_node_registry_helper,
|
|
108
108
|
registerDecoratorNodeType
|
|
@@ -114,7 +114,7 @@ import"./shared/@ai-setting/roy-agent-core-h1cb2jzh.js";
|
|
|
114
114
|
import"./shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
|
|
115
115
|
import"./shared/@ai-setting/roy-agent-core-hhrg314p.js";
|
|
116
116
|
import"./shared/@ai-setting/roy-agent-core-0qjw25e8.js";
|
|
117
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
117
|
+
import"./shared/@ai-setting/roy-agent-core-qatz3q31.js";
|
|
118
118
|
import"./shared/@ai-setting/roy-agent-core-1db4vpc6.js";
|
|
119
119
|
import"./shared/@ai-setting/roy-agent-core-j9ybhwnq.js";
|
|
120
120
|
import"./shared/@ai-setting/roy-agent-core-w8rv08d3.js";
|
|
@@ -131,13 +131,7 @@ import"./shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
|
131
131
|
import {
|
|
132
132
|
AgentComponent,
|
|
133
133
|
AgentComponentConfigSchema
|
|
134
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
135
|
-
import {
|
|
136
|
-
createInvokeConfig,
|
|
137
|
-
invoke,
|
|
138
|
-
invokeNonStream,
|
|
139
|
-
parseModelString
|
|
140
|
-
} from "./shared/@ai-setting/roy-agent-core-167qsqrz.js";
|
|
134
|
+
} from "./shared/@ai-setting/roy-agent-core-3dwcwgn5.js";
|
|
141
135
|
import {
|
|
142
136
|
ToolComponent,
|
|
143
137
|
ToolRegistry,
|
|
@@ -151,7 +145,7 @@ import {
|
|
|
151
145
|
} from "./shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
152
146
|
import {
|
|
153
147
|
TaskComponent
|
|
154
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
148
|
+
} from "./shared/@ai-setting/roy-agent-core-y9q3jdcx.js";
|
|
155
149
|
import"./shared/@ai-setting/roy-agent-core-amkqnyzy.js";
|
|
156
150
|
import"./shared/@ai-setting/roy-agent-core-8gxth0eh.js";
|
|
157
151
|
import"./shared/@ai-setting/roy-agent-core-50jdqb7r.js";
|
|
@@ -173,7 +167,7 @@ import {
|
|
|
173
167
|
getXDGPaths
|
|
174
168
|
} from "./shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
175
169
|
import"./shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
176
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
170
|
+
import"./shared/@ai-setting/roy-agent-core-k4byknt1.js";
|
|
177
171
|
import"./shared/@ai-setting/roy-agent-core-rn57psp0.js";
|
|
178
172
|
import {
|
|
179
173
|
TaskHookPoints
|
|
@@ -200,13 +194,18 @@ import"./shared/@ai-setting/roy-agent-core-fnv3ev18.js";
|
|
|
200
194
|
import"./shared/@ai-setting/roy-agent-core-dxfd6p1c.js";
|
|
201
195
|
import {
|
|
202
196
|
SessionComponent
|
|
203
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
197
|
+
} from "./shared/@ai-setting/roy-agent-core-xvag5pd0.js";
|
|
204
198
|
import"./shared/@ai-setting/roy-agent-core-rvxg1wps.js";
|
|
205
199
|
import {
|
|
206
200
|
MemorySessionStore
|
|
207
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
208
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
209
|
-
import
|
|
201
|
+
} from "./shared/@ai-setting/roy-agent-core-wgp3q62x.js";
|
|
202
|
+
import"./shared/@ai-setting/roy-agent-core-zcx8nf4a.js";
|
|
203
|
+
import {
|
|
204
|
+
createInvokeConfig,
|
|
205
|
+
invoke,
|
|
206
|
+
invokeNonStream,
|
|
207
|
+
parseModelString
|
|
208
|
+
} from "./shared/@ai-setting/roy-agent-core-2xb3f3ye.js";
|
|
210
209
|
import"./shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
211
210
|
import {
|
|
212
211
|
BaseComponent
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
safeParseToolArgs
|
|
3
|
-
} from "./roy-agent-core-ddrc00er.js";
|
|
4
1
|
import {
|
|
5
2
|
createLogger,
|
|
6
3
|
init_logger
|
|
@@ -18,7 +15,113 @@ import { createAnthropic } from "@ai-sdk/anthropic";
|
|
|
18
15
|
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
19
16
|
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
20
17
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
21
|
-
|
|
18
|
+
|
|
19
|
+
// src/env/llm/tool-args-parser.ts
|
|
20
|
+
init_logger();
|
|
21
|
+
var logger = createLogger("llm:tool-args-parser");
|
|
22
|
+
var MAX_SAFE_DEPTH = 5;
|
|
23
|
+
function safeParseToolArgs(args, depth = 0) {
|
|
24
|
+
if (depth >= MAX_SAFE_DEPTH) {
|
|
25
|
+
logger.warn(`[safeParseToolArgs] Max recursion depth (${MAX_SAFE_DEPTH}) exceeded at depth ${depth}. ` + "Input may be malicious or abnormally deeply nested. Returning empty object.", { depth, argsType: typeof args });
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
if (typeof args === "object" && args !== null && !Array.isArray(args)) {
|
|
29
|
+
return args;
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(args)) {
|
|
32
|
+
logger.debug(`[safeParseToolArgs] Input is an array. Tool arguments should be objects. Returning empty object.`, { depth, arrayLength: args.length });
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
if (typeof args === "string") {
|
|
36
|
+
try {
|
|
37
|
+
const parsed = JSON.parse(args);
|
|
38
|
+
if (typeof parsed === "string") {
|
|
39
|
+
logger.debug(`[safeParseToolArgs] Detected double/multi-stringified JSON at depth ${depth}. ` + "LLM may be double-stringifying tool arguments. Parsing recursively.", { depth, parsedLength: parsed.length });
|
|
40
|
+
return safeParseToolArgs(parsed, depth + 1);
|
|
41
|
+
}
|
|
42
|
+
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
43
|
+
return parsed;
|
|
44
|
+
}
|
|
45
|
+
if (Array.isArray(parsed)) {
|
|
46
|
+
logger.debug(`[safeParseToolArgs] Parsed result is an array at depth ${depth}. ` + "Tool arguments should be objects, not arrays. Returning empty object.", { depth, parsedLength: parsed.length });
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
return { value: parsed };
|
|
50
|
+
} catch (e) {
|
|
51
|
+
logger.warn(`[safeParseToolArgs] JSON.parse failed at depth ${depth}`, {
|
|
52
|
+
parse_failed: true,
|
|
53
|
+
input_length: args.length,
|
|
54
|
+
depth,
|
|
55
|
+
error: e.message
|
|
56
|
+
});
|
|
57
|
+
return {};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/env/llm/llm-cache.ts
|
|
64
|
+
function isOpenAICompatibleProvider(providerName) {
|
|
65
|
+
return providerName === "openai-compatible" || providerName === "openai" || providerName.startsWith("minimax") || providerName === "deepseek" || providerName.startsWith("deepseek") || providerName === "glm" || providerName.startsWith("glm");
|
|
66
|
+
}
|
|
67
|
+
function clampOpenAIPromptCacheKey(sessionId, maxLen = 64) {
|
|
68
|
+
if (sessionId.length <= maxLen)
|
|
69
|
+
return sessionId;
|
|
70
|
+
return sessionId.slice(0, maxLen - 8) + "-" + sessionId.slice(-7);
|
|
71
|
+
}
|
|
72
|
+
function buildOpenAICompatProviderOptions(sessionId, cacheRetention = "long") {
|
|
73
|
+
if (!sessionId)
|
|
74
|
+
return {};
|
|
75
|
+
return {
|
|
76
|
+
openai: {
|
|
77
|
+
promptCacheKey: clampOpenAIPromptCacheKey(sessionId),
|
|
78
|
+
promptCacheRetention: cacheRetention === "long" ? "24h" : undefined
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function applyToolCacheControl(tools, providerName) {
|
|
83
|
+
if (!tools || tools.length === 0)
|
|
84
|
+
return tools;
|
|
85
|
+
if (providerName !== "anthropic" && !providerName.startsWith("anthropic")) {
|
|
86
|
+
return tools;
|
|
87
|
+
}
|
|
88
|
+
const result = tools.map((t) => ({ ...t }));
|
|
89
|
+
const lastTool = result[result.length - 1];
|
|
90
|
+
lastTool.providerOptions = {
|
|
91
|
+
anthropic: { cacheControl: { type: "ephemeral" } }
|
|
92
|
+
};
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
function canonicalizeParts(parts) {
|
|
96
|
+
if (!parts)
|
|
97
|
+
return JSON.stringify(parts);
|
|
98
|
+
const sorted = sortObjectKeysDeep(parts);
|
|
99
|
+
canonicalizeToolCallArgsInPlace(sorted);
|
|
100
|
+
return JSON.stringify(sorted);
|
|
101
|
+
}
|
|
102
|
+
function canonicalizeToolCallArgsInPlace(value) {
|
|
103
|
+
if (Array.isArray(value)) {
|
|
104
|
+
for (const item of value)
|
|
105
|
+
canonicalizeToolCallArgsInPlace(item);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (value && typeof value === "object") {
|
|
109
|
+
const obj = value;
|
|
110
|
+
if (obj.type === "tool-call" && typeof obj.arguments === "string") {
|
|
111
|
+
try {
|
|
112
|
+
const parsed = JSON.parse(obj.arguments);
|
|
113
|
+
const sorted = sortObjectKeysDeep(parsed);
|
|
114
|
+
obj.arguments = JSON.stringify(sorted);
|
|
115
|
+
} catch {}
|
|
116
|
+
}
|
|
117
|
+
for (const key of Object.keys(obj)) {
|
|
118
|
+
canonicalizeToolCallArgsInPlace(obj[key]);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/env/llm/invoke.ts
|
|
124
|
+
var logger2 = createLogger("llm:invoke");
|
|
22
125
|
var MAX_RETRIES = 3;
|
|
23
126
|
var DEFAULT_TIMEOUT = 60000;
|
|
24
127
|
|
|
@@ -153,7 +256,7 @@ function isPlainObject(obj) {
|
|
|
153
256
|
var ANTHROPIC_CACHE_CONTROL = {
|
|
154
257
|
anthropic: { cacheControl: { type: "ephemeral" } }
|
|
155
258
|
};
|
|
156
|
-
function convertToSDKMessages(messages) {
|
|
259
|
+
function convertToSDKMessages(messages, options) {
|
|
157
260
|
let lastUserIndex = -1;
|
|
158
261
|
for (let i = messages.length - 1;i >= 0; i--) {
|
|
159
262
|
if (messages[i].role === "user") {
|
|
@@ -161,12 +264,13 @@ function convertToSDKMessages(messages) {
|
|
|
161
264
|
break;
|
|
162
265
|
}
|
|
163
266
|
}
|
|
267
|
+
const openaiOptions = isOpenAICompatibleProvider(options?.provider ?? "") ? buildOpenAICompatProviderOptions(options?.sessionId, "long") : {};
|
|
164
268
|
return messages.map((msg, index) => {
|
|
165
269
|
if (msg.role === "system") {
|
|
166
270
|
return {
|
|
167
271
|
role: "system",
|
|
168
272
|
content: typeof msg.content === "string" ? msg.content : "",
|
|
169
|
-
providerOptions: ANTHROPIC_CACHE_CONTROL
|
|
273
|
+
providerOptions: Object.keys(openaiOptions).length > 0 ? { ...ANTHROPIC_CACHE_CONTROL, ...openaiOptions } : ANTHROPIC_CACHE_CONTROL
|
|
170
274
|
};
|
|
171
275
|
}
|
|
172
276
|
if (msg.role === "user" && Array.isArray(msg.content)) {
|
|
@@ -237,7 +341,7 @@ function convertToSDKMessages(messages) {
|
|
|
237
341
|
}
|
|
238
342
|
if (msg.role === "tool") {
|
|
239
343
|
if (!msg.toolCallId) {
|
|
240
|
-
|
|
344
|
+
logger2.warn("Tool message missing toolCallId", { msg });
|
|
241
345
|
}
|
|
242
346
|
let outputValue = "";
|
|
243
347
|
const content = msg.content;
|
|
@@ -270,7 +374,7 @@ function convertToSDKMessages(messages) {
|
|
|
270
374
|
return msg;
|
|
271
375
|
});
|
|
272
376
|
}
|
|
273
|
-
function convertToolsToSDK(tools) {
|
|
377
|
+
function convertToolsToSDK(tools, providerName) {
|
|
274
378
|
const result = {};
|
|
275
379
|
for (const tool of tools) {
|
|
276
380
|
const jsonSchemaObj = extractToolSchema(tool.parameters);
|
|
@@ -279,6 +383,16 @@ function convertToolsToSDK(tools) {
|
|
|
279
383
|
inputSchema: jsonSchema(jsonSchemaObj)
|
|
280
384
|
};
|
|
281
385
|
}
|
|
386
|
+
if (providerName) {
|
|
387
|
+
const cached = applyToolCacheControl(Object.entries(result).map(([name, def]) => ({ name, ...def || {} })), providerName);
|
|
388
|
+
if (cached && cached.length > 0) {
|
|
389
|
+
const lastCached = cached[cached.length - 1];
|
|
390
|
+
const lastName = lastCached.name || Object.keys(result)[Object.keys(result).length - 1];
|
|
391
|
+
if (result[lastName]) {
|
|
392
|
+
result[lastName].providerOptions = lastCached.providerOptions;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
282
396
|
return result;
|
|
283
397
|
}
|
|
284
398
|
function extractToolSchema(parameters) {
|
|
@@ -331,7 +445,7 @@ function convertToolChoice(toolChoice) {
|
|
|
331
445
|
}
|
|
332
446
|
function createEnvEventEmitter(env, context) {
|
|
333
447
|
if (!env || typeof env.pushEnvEvent !== "function") {
|
|
334
|
-
|
|
448
|
+
logger2.warn("[invoke] createEnvEventEmitter: env is null/undefined or pushEnvEvent is unavailable, streaming events will be disabled");
|
|
335
449
|
return null;
|
|
336
450
|
}
|
|
337
451
|
return (event) => {
|
|
@@ -349,7 +463,7 @@ function createEnvEventEmitter(env, context) {
|
|
|
349
463
|
payload: event
|
|
350
464
|
});
|
|
351
465
|
} catch (err) {
|
|
352
|
-
|
|
466
|
+
logger2.warn("Failed to push env event", { error: String(err), eventType: event.type });
|
|
353
467
|
}
|
|
354
468
|
};
|
|
355
469
|
}
|
|
@@ -432,7 +546,7 @@ function processThinkingStream(textDelta, config, state) {
|
|
|
432
546
|
async function invoke(config, options, ctx) {
|
|
433
547
|
try {
|
|
434
548
|
const emitToEnv = createEnvEventEmitter(options.env, options.context);
|
|
435
|
-
|
|
549
|
+
logger2.info("[invoke] Created event emitter", {
|
|
436
550
|
envAvailable: !!options.env,
|
|
437
551
|
hasContext: options.context !== undefined
|
|
438
552
|
});
|
|
@@ -441,7 +555,10 @@ async function invoke(config, options, ctx) {
|
|
|
441
555
|
if (!provider) {
|
|
442
556
|
throw new Error(`Failed to create provider for ${providerId}`);
|
|
443
557
|
}
|
|
444
|
-
const messages = convertToSDKMessages(options.messages
|
|
558
|
+
const messages = convertToSDKMessages(options.messages, {
|
|
559
|
+
sessionId: options.context?.sessionId,
|
|
560
|
+
provider: providerId
|
|
561
|
+
});
|
|
445
562
|
const toolCallIds = new Set;
|
|
446
563
|
const assistantToolCalls = [];
|
|
447
564
|
const toolResultIds = [];
|
|
@@ -468,24 +585,24 @@ async function invoke(config, options, ctx) {
|
|
|
468
585
|
const missingToolResults = assistantToolCalls.filter((tc) => !toolResultIds.includes(tc.id));
|
|
469
586
|
const orphanedToolResults = toolResultIds.filter((id) => !toolCallIds.has(id));
|
|
470
587
|
if (assistantToolCalls.length > 0 || toolResultIds.length > 0) {
|
|
471
|
-
|
|
588
|
+
logger2.debug("[invoke] ToolCallId matching analysis:", {
|
|
472
589
|
assistantToolCalls,
|
|
473
590
|
toolResultIds,
|
|
474
591
|
missingToolResults: missingToolResults.length > 0 ? missingToolResults : "none",
|
|
475
592
|
orphanedToolResults: orphanedToolResults.length > 0 ? orphanedToolResults : "none"
|
|
476
593
|
});
|
|
477
594
|
}
|
|
478
|
-
const tools = options.tools && options.tools.length > 0 ? convertToolsToSDK(options.tools) : undefined;
|
|
595
|
+
const tools = options.tools && options.tools.length > 0 ? convertToolsToSDK(options.tools, providerId) : undefined;
|
|
479
596
|
const providerOptions = generateProviderOptions(providerId, {
|
|
480
597
|
temperature: options.temperature,
|
|
481
598
|
maxTokens: options.maxTokens
|
|
482
599
|
});
|
|
483
600
|
const model = `${providerId}/${modelId}`;
|
|
484
601
|
if (emitToEnv) {
|
|
485
|
-
|
|
602
|
+
logger2.info("[invoke] Emitting llm.start event");
|
|
486
603
|
emitToEnv({ type: "start", metadata: { model } });
|
|
487
604
|
} else {
|
|
488
|
-
|
|
605
|
+
logger2.warn("[invoke] emitToEnv is null, skipping llm.start event");
|
|
489
606
|
}
|
|
490
607
|
const streamTextOptions = {
|
|
491
608
|
model: provider.languageModel(modelId),
|
|
@@ -607,7 +724,7 @@ async function invoke(config, options, ctx) {
|
|
|
607
724
|
`).filter(Boolean);
|
|
608
725
|
const uniqueLines = new Set(outputLines);
|
|
609
726
|
if (outputLines.length !== uniqueLines.size) {
|
|
610
|
-
|
|
727
|
+
logger2.warn("[DEBUG_DUPLICATE] outputContent has duplicate lines", {
|
|
611
728
|
fullContent,
|
|
612
729
|
rawFullContent,
|
|
613
730
|
outputContent,
|
|
@@ -615,7 +732,7 @@ async function invoke(config, options, ctx) {
|
|
|
615
732
|
textDeltas: textDeltaLog
|
|
616
733
|
});
|
|
617
734
|
} else {
|
|
618
|
-
|
|
735
|
+
logger2.info("[DEBUG_DUPLICATE] outputContent OK", {
|
|
619
736
|
charCount: outputContent.length,
|
|
620
737
|
lineCount: outputLines.length,
|
|
621
738
|
uniqueLineCount: uniqueLines.size,
|
|
@@ -650,7 +767,7 @@ async function invoke(config, options, ctx) {
|
|
|
650
767
|
})
|
|
651
768
|
};
|
|
652
769
|
} catch (error) {
|
|
653
|
-
|
|
770
|
+
logger2.error("Error during invocation", {
|
|
654
771
|
error: error instanceof Error ? error.message : String(error),
|
|
655
772
|
stack: error instanceof Error ? error.stack : undefined
|
|
656
773
|
});
|
|
@@ -690,7 +807,7 @@ function createProviderInstance(providerId, apiKey, baseURL) {
|
|
|
690
807
|
});
|
|
691
808
|
return defaultProvider;
|
|
692
809
|
} catch (error) {
|
|
693
|
-
|
|
810
|
+
logger2.error(`Failed to create provider ${providerId}`, { error: String(error) });
|
|
694
811
|
return null;
|
|
695
812
|
}
|
|
696
813
|
}
|
|
@@ -700,8 +817,11 @@ async function invokeNonStream(config, options, ctx) {
|
|
|
700
817
|
if (!provider) {
|
|
701
818
|
throw new Error(`Failed to create provider for ${providerId}`);
|
|
702
819
|
}
|
|
703
|
-
const messages = convertToSDKMessages(options.messages
|
|
704
|
-
|
|
820
|
+
const messages = convertToSDKMessages(options.messages, {
|
|
821
|
+
sessionId: options.context?.sessionId,
|
|
822
|
+
provider: providerId
|
|
823
|
+
});
|
|
824
|
+
const tools = options.tools && options.tools.length > 0 ? convertToolsToSDK(options.tools, providerId) : undefined;
|
|
705
825
|
const providerOptions = generateProviderOptions(providerId, {
|
|
706
826
|
temperature: options.temperature,
|
|
707
827
|
maxTokens: options.maxTokens
|
|
@@ -759,4 +879,4 @@ function createInvokeConfig(model, apiKey, baseURL) {
|
|
|
759
879
|
};
|
|
760
880
|
}
|
|
761
881
|
|
|
762
|
-
export { withTimeout, parseModelString, convertToSDKMessages, invoke, invokeNonStream, createInvokeConfig };
|
|
882
|
+
export { safeParseToolArgs, canonicalizeParts, withTimeout, parseModelString, convertToSDKMessages, invoke, invokeNonStream, createInvokeConfig };
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
withTimeout
|
|
3
|
-
} from "./roy-agent-core-167qsqrz.js";
|
|
4
1
|
import {
|
|
5
2
|
truncateOutputInline
|
|
6
3
|
} from "./roy-agent-core-h28gcd77.js";
|
|
@@ -22,10 +19,11 @@ import {
|
|
|
22
19
|
} from "./roy-agent-core-ctdhjv68.js";
|
|
23
20
|
import {
|
|
24
21
|
SessionMessageConverter
|
|
25
|
-
} from "./roy-agent-core-
|
|
22
|
+
} from "./roy-agent-core-zcx8nf4a.js";
|
|
26
23
|
import {
|
|
27
|
-
safeParseToolArgs
|
|
28
|
-
|
|
24
|
+
safeParseToolArgs,
|
|
25
|
+
withTimeout
|
|
26
|
+
} from "./roy-agent-core-2xb3f3ye.js";
|
|
29
27
|
import {
|
|
30
28
|
envKeyToConfigKey
|
|
31
29
|
} from "./roy-agent-core-7hh0brvs.js";
|
|
@@ -810,20 +808,6 @@ class AgentComponent extends BaseComponent {
|
|
|
810
808
|
const workspaceDir = this.env?.getComponent?.("config")?.get?.("workspace_dir") || process.cwd();
|
|
811
809
|
resolvedSystemPrompt = resolvedSystemPrompt.replaceAll("{{workspace_dir}}", String(workspaceDir));
|
|
812
810
|
}
|
|
813
|
-
if (resolvedSystemPrompt.includes("{{memory}}")) {
|
|
814
|
-
try {
|
|
815
|
-
const memoryComponent = this.env?.getComponent?.("memory");
|
|
816
|
-
if (memoryComponent && typeof memoryComponent.recallMemory === "function") {
|
|
817
|
-
const memoryContent = await memoryComponent.recallMemory();
|
|
818
|
-
resolvedSystemPrompt = resolvedSystemPrompt.replaceAll("{{memory}}", memoryContent || "(No memory)");
|
|
819
|
-
} else {
|
|
820
|
-
resolvedSystemPrompt = resolvedSystemPrompt.replaceAll("{{memory}}", "(Memory component not available)");
|
|
821
|
-
}
|
|
822
|
-
} catch (err) {
|
|
823
|
-
logger2.warn(`[AgentComponent._run] Failed to replace {{memory}}: ${err}`);
|
|
824
|
-
resolvedSystemPrompt = resolvedSystemPrompt.replaceAll("{{memory}}", "(Failed to load memory)");
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
811
|
}
|
|
828
812
|
const effectiveContext = {
|
|
829
813
|
...context,
|
|
@@ -846,6 +830,12 @@ class AgentComponent extends BaseComponent {
|
|
|
846
830
|
resolvedSystemPrompt = eventSourceSystemPrompt;
|
|
847
831
|
}
|
|
848
832
|
}
|
|
833
|
+
const { snapshot: cacheSnapshot, systemPromptOverride } = await this._loadOrCreateCacheSnapshot(effectiveContext.sessionId, effectiveContext, resolvedSystemPrompt, agent.config.systemPrompt);
|
|
834
|
+
if (systemPromptOverride !== undefined) {
|
|
835
|
+
resolvedSystemPrompt = systemPromptOverride;
|
|
836
|
+
} else if (resolvedSystemPrompt) {
|
|
837
|
+
resolvedSystemPrompt = await this._fallbackReplaceMemory(resolvedSystemPrompt);
|
|
838
|
+
}
|
|
849
839
|
const hookCtx = {
|
|
850
840
|
agent,
|
|
851
841
|
iteration: 0,
|
|
@@ -853,7 +843,8 @@ class AgentComponent extends BaseComponent {
|
|
|
853
843
|
messages: [],
|
|
854
844
|
tools: this.getAvailableTools(agent, effectiveContext),
|
|
855
845
|
systemPrompt: resolvedSystemPrompt ?? agent.config.systemPrompt ?? "You are a helpful assistant.",
|
|
856
|
-
context: effectiveContext
|
|
846
|
+
context: effectiveContext,
|
|
847
|
+
...cacheSnapshot ? { _cacheSnapshot: cacheSnapshot } : {}
|
|
857
848
|
};
|
|
858
849
|
let historyMessageCount = 0;
|
|
859
850
|
if (effectiveContext.messages && effectiveContext.messages.length > 0) {
|
|
@@ -1328,7 +1319,80 @@ class AgentComponent extends BaseComponent {
|
|
|
1328
1319
|
}
|
|
1329
1320
|
logger2.info(`All agents aborted (${this.abortControllers.size} runs)`);
|
|
1330
1321
|
}
|
|
1322
|
+
async _loadOrCreateCacheSnapshot(sessionId, effectiveContext, initialSystemPrompt, agentConfigSystemPrompt) {
|
|
1323
|
+
if (!sessionId) {
|
|
1324
|
+
return { snapshot: null, systemPromptOverride: undefined };
|
|
1325
|
+
}
|
|
1326
|
+
try {
|
|
1327
|
+
const sessionComponent = this.env?.getComponent?.("session");
|
|
1328
|
+
if (!sessionComponent) {
|
|
1329
|
+
return { snapshot: null, systemPromptOverride: undefined };
|
|
1330
|
+
}
|
|
1331
|
+
const session = await sessionComponent.get(sessionId);
|
|
1332
|
+
const existingSnapshot = session?.metadata?.cacheSnapshot;
|
|
1333
|
+
if (existingSnapshot && typeof existingSnapshot === "object" && existingSnapshot.systemPrompt) {
|
|
1334
|
+
logger2.debug(`[AgentComponent._run] Reusing cacheSnapshot for session ${sessionId} (snapshotAt=${existingSnapshot.snapshotAt})`);
|
|
1335
|
+
return {
|
|
1336
|
+
snapshot: existingSnapshot,
|
|
1337
|
+
systemPromptOverride: existingSnapshot.systemPrompt
|
|
1338
|
+
};
|
|
1339
|
+
}
|
|
1340
|
+
let resolvedSystemPrompt = initialSystemPrompt;
|
|
1341
|
+
if (resolvedSystemPrompt && resolvedSystemPrompt.includes("{{memory}}")) {
|
|
1342
|
+
try {
|
|
1343
|
+
const memoryComponent = this.env?.getComponent?.("memory");
|
|
1344
|
+
if (memoryComponent && typeof memoryComponent.recallMemory === "function") {
|
|
1345
|
+
const memoryContent = await memoryComponent.recallMemory();
|
|
1346
|
+
resolvedSystemPrompt = resolvedSystemPrompt.replaceAll("{{memory}}", memoryContent || "(No memory)");
|
|
1347
|
+
} else {
|
|
1348
|
+
resolvedSystemPrompt = resolvedSystemPrompt.replaceAll("{{memory}}", "(Memory component not available)");
|
|
1349
|
+
}
|
|
1350
|
+
} catch (err) {
|
|
1351
|
+
logger2.warn(`[AgentComponent._run] Failed to replace {{memory}}: ${err}`);
|
|
1352
|
+
resolvedSystemPrompt = resolvedSystemPrompt.replaceAll("{{memory}}", "(Failed to load memory)");
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
const snapshot = {
|
|
1356
|
+
systemPrompt: resolvedSystemPrompt ?? agentConfigSystemPrompt ?? "",
|
|
1357
|
+
additionInfo: effectiveContext.additionInfo || "",
|
|
1358
|
+
snapshotAt: Date.now()
|
|
1359
|
+
};
|
|
1360
|
+
try {
|
|
1361
|
+
await sessionComponent.update(sessionId, {
|
|
1362
|
+
metadata: {
|
|
1363
|
+
...session?.metadata ?? {},
|
|
1364
|
+
cacheSnapshot: snapshot
|
|
1365
|
+
}
|
|
1366
|
+
});
|
|
1367
|
+
logger2.debug(`[AgentComponent._run] Created cacheSnapshot for session ${sessionId} (snapshotAt=${snapshot.snapshotAt})`);
|
|
1368
|
+
} catch (updateErr) {
|
|
1369
|
+
logger2.warn(`[AgentComponent._run] Failed to persist cacheSnapshot for session ${sessionId}: ${updateErr}`);
|
|
1370
|
+
}
|
|
1371
|
+
return { snapshot, systemPromptOverride: resolvedSystemPrompt };
|
|
1372
|
+
} catch (err) {
|
|
1373
|
+
logger2.warn(`[AgentComponent._run] Failed to load cacheSnapshot: ${err}`);
|
|
1374
|
+
return { snapshot: null, systemPromptOverride: undefined };
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
async _fallbackReplaceMemory(systemPrompt) {
|
|
1378
|
+
if (!systemPrompt.includes("{{memory}}"))
|
|
1379
|
+
return systemPrompt;
|
|
1380
|
+
try {
|
|
1381
|
+
const memoryComponent = this.env?.getComponent?.("memory");
|
|
1382
|
+
if (memoryComponent && typeof memoryComponent.recallMemory === "function") {
|
|
1383
|
+
const memoryContent = await memoryComponent.recallMemory();
|
|
1384
|
+
return systemPrompt.replaceAll("{{memory}}", memoryContent || "(No memory)");
|
|
1385
|
+
}
|
|
1386
|
+
return systemPrompt.replaceAll("{{memory}}", "(Memory component not available)");
|
|
1387
|
+
} catch (err) {
|
|
1388
|
+
logger2.warn(`[AgentComponent._run] Failed to replace {{memory}}: ${err}`);
|
|
1389
|
+
return systemPrompt.replaceAll("{{memory}}", "(Failed to load memory)");
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1331
1392
|
async _buildAdditionInfo(ctx) {
|
|
1393
|
+
if (ctx._cacheSnapshot) {
|
|
1394
|
+
return ctx._cacheSnapshot.additionInfo;
|
|
1395
|
+
}
|
|
1332
1396
|
let additionInfo = ctx.context?.additionInfo || "";
|
|
1333
1397
|
return additionInfo;
|
|
1334
1398
|
}
|
|
@@ -1336,21 +1400,28 @@ class AgentComponent extends BaseComponent {
|
|
|
1336
1400
|
const messages = [];
|
|
1337
1401
|
const additionInfo = await this._buildAdditionInfo(ctx);
|
|
1338
1402
|
if (ctx.systemPrompt) {
|
|
1403
|
+
messages.push(...buildMultiBlockSystem({
|
|
1404
|
+
characterSheet: ctx.systemPrompt,
|
|
1405
|
+
toolDefinitions: undefined,
|
|
1406
|
+
memoryBlock: undefined,
|
|
1407
|
+
dynamicContext: additionInfo
|
|
1408
|
+
}));
|
|
1409
|
+
} else if (additionInfo) {
|
|
1339
1410
|
messages.push({
|
|
1340
1411
|
role: "system",
|
|
1341
|
-
content:
|
|
1342
|
-
|
|
1343
|
-
${additionInfo}`
|
|
1344
|
-
});
|
|
1345
|
-
} else {
|
|
1346
|
-
messages.push({
|
|
1347
|
-
role: "system",
|
|
1348
|
-
content: `${additionInfo}`
|
|
1412
|
+
content: additionInfo
|
|
1349
1413
|
});
|
|
1350
1414
|
}
|
|
1351
1415
|
messages.push(...ctx.messages);
|
|
1352
1416
|
return messages;
|
|
1353
1417
|
}
|
|
1418
|
+
_formatToolDefinitions(tools) {
|
|
1419
|
+
if (!tools || tools.length === 0)
|
|
1420
|
+
return "";
|
|
1421
|
+
const sorted = [...tools].sort((a, b) => a.name.localeCompare(b.name));
|
|
1422
|
+
return sorted.map((t) => `${t.name}: ${t.description || ""}`).join(`
|
|
1423
|
+
`);
|
|
1424
|
+
}
|
|
1354
1425
|
async invokeLLM(ctx) {
|
|
1355
1426
|
logger2.debug("[invokeLLM] Starting LLM invocation");
|
|
1356
1427
|
if (this.llmComponent?.invoke) {
|
|
@@ -1693,6 +1764,9 @@ __legacyDecorateClassTS([
|
|
|
1693
1764
|
__legacyDecorateClassTS([
|
|
1694
1765
|
TracedAs("agent.component.run", { recordParams: true, recordResult: true, log: true })
|
|
1695
1766
|
], AgentComponent.prototype, "_run", null);
|
|
1767
|
+
__legacyDecorateClassTS([
|
|
1768
|
+
TracedAs("agent.component.loadOrCreateCacheSnapshot", { recordParams: true, recordResult: true, log: true })
|
|
1769
|
+
], AgentComponent.prototype, "_loadOrCreateCacheSnapshot", null);
|
|
1696
1770
|
__legacyDecorateClassTS([
|
|
1697
1771
|
TracedAs("agent.component.buildAdditionInfo", { recordParams: true, recordResult: true, log: true })
|
|
1698
1772
|
], AgentComponent.prototype, "_buildAdditionInfo", null);
|
|
@@ -1730,6 +1804,39 @@ __legacyDecorateClassTS([
|
|
|
1730
1804
|
__legacyDecorateClassTS([
|
|
1731
1805
|
TracedAs("agent.component.getConversationHistory", { recordParams: true, recordResult: true, log: true })
|
|
1732
1806
|
], AgentComponent.prototype, "getConversationHistory", null);
|
|
1807
|
+
function buildMultiBlockSystem(ctx) {
|
|
1808
|
+
const ANTHROPIC_CACHE_CONTROL = {
|
|
1809
|
+
anthropic: { cacheControl: { type: "ephemeral" } }
|
|
1810
|
+
};
|
|
1811
|
+
const messages = [];
|
|
1812
|
+
if (ctx.characterSheet) {
|
|
1813
|
+
messages.push({
|
|
1814
|
+
role: "system",
|
|
1815
|
+
content: ctx.characterSheet,
|
|
1816
|
+
providerOptions: ANTHROPIC_CACHE_CONTROL
|
|
1817
|
+
});
|
|
1818
|
+
}
|
|
1819
|
+
if (ctx.toolDefinitions) {
|
|
1820
|
+
messages.push({
|
|
1821
|
+
role: "system",
|
|
1822
|
+
content: ctx.toolDefinitions,
|
|
1823
|
+
providerOptions: ANTHROPIC_CACHE_CONTROL
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
if (ctx.memoryBlock) {
|
|
1827
|
+
messages.push({
|
|
1828
|
+
role: "system",
|
|
1829
|
+
content: ctx.memoryBlock
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1832
|
+
if (ctx.dynamicContext) {
|
|
1833
|
+
messages.push({
|
|
1834
|
+
role: "system",
|
|
1835
|
+
content: ctx.dynamicContext
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1838
|
+
return messages;
|
|
1839
|
+
}
|
|
1733
1840
|
// src/env/agent/summary-agent.ts
|
|
1734
1841
|
class SummaryAgent {
|
|
1735
1842
|
llmComponent;
|
|
@@ -72,6 +72,10 @@ var UpdateTaskToolSchema = z.object({
|
|
|
72
72
|
var DeleteTaskToolSchema = z.object({
|
|
73
73
|
task_id: z.number().describe("Task ID")
|
|
74
74
|
});
|
|
75
|
+
var CompleteTaskToolSchema = z.object({
|
|
76
|
+
task_id: z.number().describe("Task ID"),
|
|
77
|
+
deliverable_storage_path: z.string().optional().describe("交付物的寻址地址(路径 / URL / 分支名等)。" + "调用本工具前,请先读取任务的 goal(description)和 delivery(goals_and_expected_deliverables)栏位," + "建议验证目标和交付物是否符合预期,然后将实际交付物的寻址地址填入此参数。")
|
|
78
|
+
});
|
|
75
79
|
var BatchArchiveToolSchema = z.object({
|
|
76
80
|
task_ids: z.array(z.number()).describe("要归档的任务 ID 列表"),
|
|
77
81
|
reason: z.string().optional().describe("归档原因(可选,会写入每个任务的 operation 记录)")
|
|
@@ -817,13 +821,38 @@ function deleteTaskTool(taskComponent) {
|
|
|
817
821
|
init_env_context();
|
|
818
822
|
init_logger();
|
|
819
823
|
var logger4 = createLogger("task:tools:complete");
|
|
824
|
+
var TASK_COMPLETE_DESCRIPTION = `
|
|
825
|
+
Mark a task as completed (progress=100, status=completed). Creates an operation record.
|
|
826
|
+
|
|
827
|
+
**Before calling this tool**, you MUST:
|
|
828
|
+
|
|
829
|
+
1. Read the task's \`goal\` (description) and \`delivery\` (goals_and_expected_deliverables) fields.
|
|
830
|
+
- Use \`task_get(task_id=<id>)\` to fetch the full task record.
|
|
831
|
+
2. **Validate** whether the goal and delivery match what you actually delivered.
|
|
832
|
+
- If mismatch, either: (a) extend the task via \`task_update\`, or (b) honestly note the discrepancy in your final report.
|
|
833
|
+
3. **Provide \`deliverable_storage_path\`** parameter with the deliverable's address:
|
|
834
|
+
- Feishu doc URL (e.g., https://my.feishu.cn/docx/abc)
|
|
835
|
+
- Local file path (e.g., /tmp/report.md)
|
|
836
|
+
- Git branch or worktree path (e.g., feature/my-feature)
|
|
837
|
+
- GitHub commit URL or PR URL
|
|
838
|
+
- Cloud drive URL (e.g., https://my.feishu.cn/file/abc)
|
|
839
|
+
- Or any other locator that points to where the work product lives
|
|
840
|
+
|
|
841
|
+
The \`deliverable_storage_path\` will be persisted to the task's \`context.deliverable_storage_path\` for future reference and traceability.
|
|
842
|
+
|
|
843
|
+
**Restrictions**:
|
|
844
|
+
- Cannot complete cycle-type tasks (they are periodic). Use \`task_update\` to reset progress instead.
|
|
845
|
+
- Marks the task as 100% complete; use \`task_update\` to record partial progress first if needed.
|
|
846
|
+
|
|
847
|
+
**Backward compatibility**: \`deliverable_storage_path\` is optional. Existing callers that omit it continue to work as before.
|
|
848
|
+
`.trim();
|
|
820
849
|
function completeTaskTool(taskComponent) {
|
|
821
850
|
return {
|
|
822
851
|
name: "task_complete",
|
|
823
|
-
description:
|
|
824
|
-
parameters:
|
|
852
|
+
description: TASK_COMPLETE_DESCRIPTION,
|
|
853
|
+
parameters: CompleteTaskToolSchema,
|
|
825
854
|
execute: async (args, ctx) => {
|
|
826
|
-
const params =
|
|
855
|
+
const params = CompleteTaskToolSchema.parse(args);
|
|
827
856
|
const sessionId = ctx.session_id || "unknown";
|
|
828
857
|
try {
|
|
829
858
|
const currentTask = await taskComponent.getTask(params.task_id);
|
|
@@ -843,7 +872,7 @@ function completeTaskTool(taskComponent) {
|
|
|
843
872
|
metadata: { execution_time_ms: 0 }
|
|
844
873
|
};
|
|
845
874
|
}
|
|
846
|
-
const task = await taskComponent.completeTask(params.task_id, sessionId);
|
|
875
|
+
const task = await taskComponent.completeTask(params.task_id, sessionId, params.deliverable_storage_path);
|
|
847
876
|
if (!task) {
|
|
848
877
|
return {
|
|
849
878
|
success: false,
|
|
@@ -853,10 +882,12 @@ function completeTaskTool(taskComponent) {
|
|
|
853
882
|
};
|
|
854
883
|
}
|
|
855
884
|
setCurrentTaskId(undefined);
|
|
856
|
-
logger4.info(`[completeTask] Trace: Task #${params.task_id} completed, currentTaskId cleared from EnvContext`);
|
|
885
|
+
logger4.info(`[completeTask] Trace: Task #${params.task_id} completed, deliverable=${params.deliverable_storage_path || "(none)"}, currentTaskId cleared from EnvContext`);
|
|
857
886
|
return {
|
|
858
887
|
success: true,
|
|
859
|
-
output: `Task completed: #${task.id} - ${task.title}
|
|
888
|
+
output: params.deliverable_storage_path ? `Task completed: #${task.id} - ${task.title}
|
|
889
|
+
Deliverable (context + operation): ${params.deliverable_storage_path}` : `Task completed: #${task.id} - ${task.title}
|
|
890
|
+
Deliverable: (no path provided)`,
|
|
860
891
|
metadata: { execution_time_ms: 0, task }
|
|
861
892
|
};
|
|
862
893
|
} catch (error) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EnvSource
|
|
3
3
|
} from "./roy-agent-core-y3g3ar7a.js";
|
|
4
|
-
import {
|
|
5
|
-
invoke,
|
|
6
|
-
invokeNonStream
|
|
7
|
-
} from "./roy-agent-core-167qsqrz.js";
|
|
8
4
|
import {
|
|
9
5
|
ContextError,
|
|
10
6
|
ErrorCodes
|
|
11
7
|
} from "./roy-agent-core-ctdhjv68.js";
|
|
8
|
+
import {
|
|
9
|
+
invoke,
|
|
10
|
+
invokeNonStream
|
|
11
|
+
} from "./roy-agent-core-2xb3f3ye.js";
|
|
12
12
|
import {
|
|
13
13
|
envKeyToConfigKey,
|
|
14
14
|
toEnvKey
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SessionMessageConverter
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-zcx8nf4a.js";
|
|
4
|
+
import {
|
|
5
|
+
canonicalizeParts
|
|
6
|
+
} from "./roy-agent-core-2xb3f3ye.js";
|
|
4
7
|
import {
|
|
5
8
|
createLogger,
|
|
6
9
|
init_logger
|
|
@@ -796,7 +799,7 @@ class SQLiteSessionStore extends BaseSessionStore {
|
|
|
796
799
|
INSERT INTO message (id, session_id, role, content, timestamp, parts, metadata)
|
|
797
800
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
798
801
|
`);
|
|
799
|
-
stmt.run(msg.id, msg.sessionID, msg.role, msg.content, msg.timestamp, msg.parts ?
|
|
802
|
+
stmt.run(msg.id, msg.sessionID, msg.role, msg.content, msg.timestamp, msg.parts ? canonicalizeParts(msg.parts) : null, msg.metadata ? JSON.stringify(msg.metadata) : null);
|
|
800
803
|
const countResult = this.db.prepare("SELECT COUNT(*) as count FROM message WHERE session_id = ? AND is_archived = 0").get(sessionId);
|
|
801
804
|
session.messageCount = countResult?.count || 0;
|
|
802
805
|
session.updatedAt = now;
|
|
@@ -856,7 +859,7 @@ class SQLiteSessionStore extends BaseSessionStore {
|
|
|
856
859
|
for (const message of messages) {
|
|
857
860
|
const id = generateMessageId2();
|
|
858
861
|
ids.push(id);
|
|
859
|
-
insertStmt.run(id, sessionId, message.role, message.content, now, message.parts ?
|
|
862
|
+
insertStmt.run(id, sessionId, message.role, message.content, now, message.parts ? canonicalizeParts(message.parts) : null, message.metadata ? JSON.stringify(message.metadata) : null);
|
|
860
863
|
}
|
|
861
864
|
const countResult = this.db.prepare("SELECT COUNT(*) as count FROM message WHERE session_id = ? AND is_archived = 0").get(sessionId);
|
|
862
865
|
const newCount = countResult?.count ?? 0;
|
|
@@ -911,7 +914,7 @@ class SQLiteSessionStore extends BaseSessionStore {
|
|
|
911
914
|
}
|
|
912
915
|
if (updates.parts !== undefined) {
|
|
913
916
|
sets.push("parts = ?");
|
|
914
|
-
values.push(
|
|
917
|
+
values.push(canonicalizeParts(updates.parts));
|
|
915
918
|
}
|
|
916
919
|
if (updates.metadata !== undefined) {
|
|
917
920
|
sets.push("metadata = ?");
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
searchTasksTool,
|
|
25
25
|
treeTasksTool,
|
|
26
26
|
updateTaskTool
|
|
27
|
-
} from "./roy-agent-core-
|
|
27
|
+
} from "./roy-agent-core-k4byknt1.js";
|
|
28
28
|
import {
|
|
29
29
|
createOperationTool,
|
|
30
30
|
deleteOperationTool,
|
|
@@ -182,6 +182,12 @@ class DefaultTagService {
|
|
|
182
182
|
// src/env/task/task-component.ts
|
|
183
183
|
init_decorator();
|
|
184
184
|
var logger2 = createLogger("task");
|
|
185
|
+
var DELIVERABLE_OPERATION_PREFIX = "Deliverable: ";
|
|
186
|
+
function formatDeliverableForOperation(deliverableStoragePath) {
|
|
187
|
+
if (!deliverableStoragePath)
|
|
188
|
+
return;
|
|
189
|
+
return `${DELIVERABLE_OPERATION_PREFIX}${deliverableStoragePath}`;
|
|
190
|
+
}
|
|
185
191
|
|
|
186
192
|
class TaskComponent extends BaseComponent {
|
|
187
193
|
name = "task";
|
|
@@ -489,24 +495,41 @@ class TaskComponent extends BaseComponent {
|
|
|
489
495
|
async getChildTasks(taskId, options) {
|
|
490
496
|
return this.store.getChildTasks(taskId, options);
|
|
491
497
|
}
|
|
492
|
-
async completeTask(id, sessionId) {
|
|
498
|
+
async completeTask(id, sessionId, deliverableStoragePath) {
|
|
493
499
|
const existing = await this.store.getTask(id);
|
|
494
500
|
if (existing && existing.type === "cycle") {
|
|
495
501
|
throw new Error(`Cannot complete cycle task: #${id} - ${existing.title}. Cycle tasks are not meant to be completed.`);
|
|
496
502
|
}
|
|
497
|
-
const
|
|
503
|
+
const updateOptions = {
|
|
498
504
|
status: "completed",
|
|
499
505
|
progress: 100
|
|
500
|
-
}
|
|
506
|
+
};
|
|
507
|
+
if (deliverableStoragePath) {
|
|
508
|
+
let existingContext = {};
|
|
509
|
+
if (existing?.context) {
|
|
510
|
+
try {
|
|
511
|
+
const parsed = JSON.parse(existing.context);
|
|
512
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
513
|
+
existingContext = parsed;
|
|
514
|
+
}
|
|
515
|
+
} catch {
|
|
516
|
+
logger2.warn(`[TaskComponent] Task #${id} context is not valid JSON, ignoring when merging deliverable`);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
existingContext.deliverable_storage_path = deliverableStoragePath;
|
|
520
|
+
updateOptions.context = JSON.stringify(existingContext);
|
|
521
|
+
}
|
|
522
|
+
const task = await this.updateTask(id, updateOptions);
|
|
501
523
|
if (task) {
|
|
502
524
|
await this.createOperation({
|
|
503
525
|
taskId: id,
|
|
504
526
|
sessionId,
|
|
505
527
|
milestoneType: "completed",
|
|
506
|
-
milestoneTitle: "Task completed"
|
|
528
|
+
milestoneTitle: "Task completed",
|
|
529
|
+
milestoneDescription: formatDeliverableForOperation(deliverableStoragePath)
|
|
507
530
|
});
|
|
508
531
|
this.publishEvent(TaskEntityEventTypes.COMPLETED, { task, sessionId }, sessionId);
|
|
509
|
-
logger2.info(`[TaskComponent] Task completed: ${id}`);
|
|
532
|
+
logger2.info(`[TaskComponent] Task completed: ${id}, deliverable=${deliverableStoragePath || "(none)"}`);
|
|
510
533
|
}
|
|
511
534
|
return task;
|
|
512
535
|
}
|
package/package.json
CHANGED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createLogger,
|
|
3
|
-
init_logger
|
|
4
|
-
} from "./roy-agent-core-kaq037np.js";
|
|
5
|
-
|
|
6
|
-
// src/env/llm/tool-args-parser.ts
|
|
7
|
-
init_logger();
|
|
8
|
-
var logger = createLogger("llm:tool-args-parser");
|
|
9
|
-
var MAX_SAFE_DEPTH = 5;
|
|
10
|
-
function safeParseToolArgs(args, depth = 0) {
|
|
11
|
-
if (depth >= MAX_SAFE_DEPTH) {
|
|
12
|
-
logger.warn(`[safeParseToolArgs] Max recursion depth (${MAX_SAFE_DEPTH}) exceeded at depth ${depth}. ` + "Input may be malicious or abnormally deeply nested. Returning empty object.", { depth, argsType: typeof args });
|
|
13
|
-
return {};
|
|
14
|
-
}
|
|
15
|
-
if (typeof args === "object" && args !== null && !Array.isArray(args)) {
|
|
16
|
-
return args;
|
|
17
|
-
}
|
|
18
|
-
if (Array.isArray(args)) {
|
|
19
|
-
logger.debug(`[safeParseToolArgs] Input is an array. Tool arguments should be objects. Returning empty object.`, { depth, arrayLength: args.length });
|
|
20
|
-
return {};
|
|
21
|
-
}
|
|
22
|
-
if (typeof args === "string") {
|
|
23
|
-
try {
|
|
24
|
-
const parsed = JSON.parse(args);
|
|
25
|
-
if (typeof parsed === "string") {
|
|
26
|
-
logger.debug(`[safeParseToolArgs] Detected double/multi-stringified JSON at depth ${depth}. ` + "LLM may be double-stringifying tool arguments. Parsing recursively.", { depth, parsedLength: parsed.length });
|
|
27
|
-
return safeParseToolArgs(parsed, depth + 1);
|
|
28
|
-
}
|
|
29
|
-
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
30
|
-
return parsed;
|
|
31
|
-
}
|
|
32
|
-
if (Array.isArray(parsed)) {
|
|
33
|
-
logger.debug(`[safeParseToolArgs] Parsed result is an array at depth ${depth}. ` + "Tool arguments should be objects, not arrays. Returning empty object.", { depth, parsedLength: parsed.length });
|
|
34
|
-
return {};
|
|
35
|
-
}
|
|
36
|
-
return { value: parsed };
|
|
37
|
-
} catch (e) {
|
|
38
|
-
logger.warn(`[safeParseToolArgs] JSON.parse failed at depth ${depth}`, {
|
|
39
|
-
parse_failed: true,
|
|
40
|
-
input_length: args.length,
|
|
41
|
-
depth,
|
|
42
|
-
error: e.message
|
|
43
|
-
});
|
|
44
|
-
return {};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return {};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export { safeParseToolArgs };
|