@ai-setting/roy-agent-core 1.6.42 → 1.7.1
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 +7 -8
- package/dist/env/llm/index.js +17 -6
- package/dist/env/session/index.js +4 -4
- package/dist/env/session/storage/index.js +3 -3
- package/dist/env/workflow/index.js +6 -6
- package/dist/env/workflow/tools/index.js +5 -5
- package/dist/index.js +13 -14
- package/dist/shared/@ai-setting/{roy-agent-core-c1stgqnw.js → roy-agent-core-2xb3f3ye.js} +143 -23
- package/dist/shared/@ai-setting/{roy-agent-core-fzyn4fxx.js → roy-agent-core-3dwcwgn5.js} +163 -30
- package/dist/shared/@ai-setting/{roy-agent-core-dbwvfe0m.js → roy-agent-core-qatz3q31.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-7wv7gh6t.js → roy-agent-core-w93wrd77.js} +627 -46
- package/dist/shared/@ai-setting/{roy-agent-core-afb03wwp.js → roy-agent-core-wgp3q62x.js} +7 -4
- package/dist/shared/@ai-setting/{roy-agent-core-9yf6we04.js → roy-agent-core-xmacq00w.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-f2nync7q.js → roy-agent-core-xvag5pd0.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-1k9j90s7.js → roy-agent-core-zcx8nf4a.js} +1 -1
- package/package.json +5 -2
- package/dist/shared/@ai-setting/roy-agent-core-12gac5zn.js +0 -44
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-c1stgqnw.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,8 +41,7 @@ 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-c1stgqnw.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";
|
|
@@ -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
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ADAPTER_NAMES,
|
|
3
|
+
AiSdkAdapter,
|
|
2
4
|
LLMComponent,
|
|
3
5
|
LLMConfigSchema,
|
|
4
6
|
LLMDefaultConfigSchema,
|
|
5
7
|
LLMHooks,
|
|
6
8
|
LLMTransform,
|
|
7
9
|
ModelLimitsSchema,
|
|
10
|
+
PiAiAdapter,
|
|
8
11
|
ProviderCapabilitiesSchema,
|
|
9
12
|
ProviderConfigSchema,
|
|
10
|
-
ProviderManager
|
|
11
|
-
|
|
13
|
+
ProviderManager,
|
|
14
|
+
createLLMAdapter,
|
|
15
|
+
getLLMProviderOverride,
|
|
16
|
+
setLLMProvider
|
|
17
|
+
} from "../../shared/@ai-setting/roy-agent-core-w93wrd77.js";
|
|
12
18
|
import"../../shared/@ai-setting/roy-agent-core-y3g3ar7a.js";
|
|
19
|
+
import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
|
|
13
20
|
import {
|
|
14
21
|
convertToSDKMessages,
|
|
15
22
|
createInvokeConfig,
|
|
16
23
|
invoke,
|
|
17
24
|
invokeNonStream,
|
|
18
25
|
parseModelString
|
|
19
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
20
|
-
import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
|
|
21
|
-
import"../../shared/@ai-setting/roy-agent-core-12gac5zn.js";
|
|
26
|
+
} from "../../shared/@ai-setting/roy-agent-core-2xb3f3ye.js";
|
|
22
27
|
import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
23
28
|
import"../../shared/@ai-setting/roy-agent-core-pde8hkq4.js";
|
|
24
29
|
import"../../shared/@ai-setting/roy-agent-core-5ts23mx0.js";
|
|
@@ -31,18 +36,24 @@ import"../../shared/@ai-setting/roy-agent-core-1khp1m0r.js";
|
|
|
31
36
|
import"../../shared/@ai-setting/roy-agent-core-4an1p9a1.js";
|
|
32
37
|
import"../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
33
38
|
export {
|
|
39
|
+
setLLMProvider,
|
|
34
40
|
parseModelString,
|
|
35
41
|
invokeNonStream,
|
|
36
42
|
invoke,
|
|
43
|
+
getLLMProviderOverride,
|
|
44
|
+
createLLMAdapter,
|
|
37
45
|
createInvokeConfig,
|
|
38
46
|
convertToSDKMessages,
|
|
39
47
|
ProviderManager,
|
|
40
48
|
ProviderConfigSchema,
|
|
41
49
|
ProviderCapabilitiesSchema,
|
|
50
|
+
PiAiAdapter,
|
|
42
51
|
ModelLimitsSchema,
|
|
43
52
|
LLMTransform,
|
|
44
53
|
LLMHooks,
|
|
45
54
|
LLMDefaultConfigSchema,
|
|
46
55
|
LLMConfigSchema,
|
|
47
|
-
LLMComponent
|
|
56
|
+
LLMComponent,
|
|
57
|
+
AiSdkAdapter,
|
|
58
|
+
ADAPTER_NAMES
|
|
48
59
|
};
|
|
@@ -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";
|
|
@@ -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-c1stgqnw.js";
|
|
134
|
+
} from "./shared/@ai-setting/roy-agent-core-3dwcwgn5.js";
|
|
141
135
|
import {
|
|
142
136
|
ToolComponent,
|
|
143
137
|
ToolRegistry,
|
|
@@ -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-12gac5zn.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 };
|