@ai-setting/roy-agent-core 1.7.44 → 1.7.46
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 -3
- package/dist/env/index.js +7 -7
- package/dist/env/llm/index.js +12 -2
- 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 +14 -8
- package/dist/shared/@ai-setting/{roy-agent-core-eakjnbaj.js → roy-agent-core-12d4qzmw.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-w3tq0j5c.js → roy-agent-core-2ccy0zd2.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-5tzc2spk.js → roy-agent-core-4eke3pd4.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-0gmnp1jt.js → roy-agent-core-4w5vdzg8.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-z6kv2mdp.js → roy-agent-core-9jmzyc8t.js} +13 -5
- package/dist/shared/@ai-setting/{roy-agent-core-2ahddbdf.js → roy-agent-core-r4z6h3ch.js} +55 -35
- package/dist/shared/@ai-setting/{roy-agent-core-c95tpapc.js → roy-agent-core-xv7k1p2j.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-65q93n1k.js → roy-agent-core-ykrcrktp.js} +1 -1
- package/package.json +1 -1
package/dist/env/agent/index.js
CHANGED
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
AgentComponent,
|
|
3
3
|
AgentComponentConfigSchema,
|
|
4
4
|
SummaryAgent
|
|
5
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
5
|
+
} from "../../shared/@ai-setting/roy-agent-core-4w5vdzg8.js";
|
|
6
6
|
import"../../shared/@ai-setting/roy-agent-core-jjw7xcxv.js";
|
|
7
7
|
import"../../shared/@ai-setting/roy-agent-core-kzg1jwt8.js";
|
|
8
8
|
import"../../shared/@ai-setting/roy-agent-core-za09t5g3.js";
|
|
9
9
|
import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
10
10
|
import"../../shared/@ai-setting/roy-agent-core-4cj6hram.js";
|
|
11
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
12
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
11
|
+
import"../../shared/@ai-setting/roy-agent-core-ykrcrktp.js";
|
|
12
|
+
import"../../shared/@ai-setting/roy-agent-core-r4z6h3ch.js";
|
|
13
13
|
import"../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
14
14
|
import"../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
15
15
|
import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
|
package/dist/env/index.js
CHANGED
|
@@ -30,13 +30,13 @@ import"../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
|
|
|
30
30
|
import"../shared/@ai-setting/roy-agent-core-223v204d.js";
|
|
31
31
|
import {
|
|
32
32
|
WorkflowComponent
|
|
33
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
33
|
+
} from "../shared/@ai-setting/roy-agent-core-12d4qzmw.js";
|
|
34
34
|
import"../shared/@ai-setting/roy-agent-core-hkj5v9xq.js";
|
|
35
35
|
import"../shared/@ai-setting/roy-agent-core-h0x19xgn.js";
|
|
36
36
|
import"../shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
37
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
38
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
39
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
37
|
+
import"../shared/@ai-setting/roy-agent-core-2ccy0zd2.js";
|
|
38
|
+
import"../shared/@ai-setting/roy-agent-core-xv7k1p2j.js";
|
|
39
|
+
import"../shared/@ai-setting/roy-agent-core-4eke3pd4.js";
|
|
40
40
|
import"../shared/@ai-setting/roy-agent-core-hhrg314p.js";
|
|
41
41
|
import"../shared/@ai-setting/roy-agent-core-8nv07zgr.js";
|
|
42
42
|
import"../shared/@ai-setting/roy-agent-core-rczz7e81.js";
|
|
@@ -54,7 +54,7 @@ import"../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
|
|
|
54
54
|
import {
|
|
55
55
|
AgentComponent,
|
|
56
56
|
AgentComponentConfigSchema
|
|
57
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
57
|
+
} from "../shared/@ai-setting/roy-agent-core-4w5vdzg8.js";
|
|
58
58
|
import"../shared/@ai-setting/roy-agent-core-jjw7xcxv.js";
|
|
59
59
|
import"../shared/@ai-setting/roy-agent-core-kzg1jwt8.js";
|
|
60
60
|
import"../shared/@ai-setting/roy-agent-core-za09t5g3.js";
|
|
@@ -64,8 +64,8 @@ import {
|
|
|
64
64
|
getXDGPaths
|
|
65
65
|
} from "../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
66
66
|
import"../shared/@ai-setting/roy-agent-core-4cj6hram.js";
|
|
67
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
68
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
67
|
+
import"../shared/@ai-setting/roy-agent-core-ykrcrktp.js";
|
|
68
|
+
import"../shared/@ai-setting/roy-agent-core-r4z6h3ch.js";
|
|
69
69
|
import"../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
70
70
|
import"../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
71
71
|
import {
|
package/dist/env/llm/index.js
CHANGED
|
@@ -14,16 +14,21 @@ 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-9jmzyc8t.js";
|
|
18
18
|
import"../../shared/@ai-setting/roy-agent-core-adg9ghbt.js";
|
|
19
19
|
import"../../shared/@ai-setting/roy-agent-core-zjdzk1gg.js";
|
|
20
20
|
import {
|
|
21
|
+
buildOpencodeHeaders,
|
|
21
22
|
convertToSDKMessages,
|
|
22
23
|
createInvokeConfig,
|
|
24
|
+
generateOpencodeSessionId,
|
|
25
|
+
getOrCreateOpencodeSessionId,
|
|
23
26
|
invoke,
|
|
24
27
|
invokeNonStream,
|
|
28
|
+
isOpencodeEndpoint,
|
|
29
|
+
isOpencodeProvider,
|
|
25
30
|
parseModelString
|
|
26
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
31
|
+
} from "../../shared/@ai-setting/roy-agent-core-r4z6h3ch.js";
|
|
27
32
|
import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
|
|
28
33
|
import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
29
34
|
import"../../shared/@ai-setting/roy-agent-core-9t675te0.js";
|
|
@@ -38,12 +43,17 @@ import"../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
|
38
43
|
export {
|
|
39
44
|
setLLMProvider,
|
|
40
45
|
parseModelString,
|
|
46
|
+
isOpencodeProvider,
|
|
47
|
+
isOpencodeEndpoint,
|
|
41
48
|
invokeNonStream,
|
|
42
49
|
invoke,
|
|
50
|
+
getOrCreateOpencodeSessionId,
|
|
43
51
|
getLLMProviderOverride,
|
|
52
|
+
generateOpencodeSessionId,
|
|
44
53
|
createLLMAdapter,
|
|
45
54
|
createInvokeConfig,
|
|
46
55
|
convertToSDKMessages,
|
|
56
|
+
buildOpencodeHeaders,
|
|
47
57
|
ProviderManager,
|
|
48
58
|
ProviderConfigSchema,
|
|
49
59
|
ProviderCapabilitiesSchema,
|
|
@@ -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-xv7k1p2j.js";
|
|
7
7
|
import {
|
|
8
8
|
MemorySessionStore
|
|
9
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
9
|
+
} from "../../shared/@ai-setting/roy-agent-core-4eke3pd4.js";
|
|
10
10
|
import"../../shared/@ai-setting/roy-agent-core-rvxg1wps.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-ykrcrktp.js";
|
|
14
|
+
import"../../shared/@ai-setting/roy-agent-core-r4z6h3ch.js";
|
|
15
15
|
import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
16
16
|
import"../../shared/@ai-setting/roy-agent-core-9t675te0.js";
|
|
17
17
|
import"../../shared/@ai-setting/roy-agent-core-cw89yj9d.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-4eke3pd4.js";
|
|
7
|
+
import"../../../shared/@ai-setting/roy-agent-core-ykrcrktp.js";
|
|
8
|
+
import"../../../shared/@ai-setting/roy-agent-core-r4z6h3ch.js";
|
|
9
9
|
import"../../../shared/@ai-setting/roy-agent-core-8seq65bp.js";
|
|
10
10
|
import"../../../shared/@ai-setting/roy-agent-core-jnszp0jq.js";
|
|
11
11
|
import"../../../shared/@ai-setting/roy-agent-core-fs0mn2jk.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-12d4qzmw.js";
|
|
4
4
|
import"../../shared/@ai-setting/roy-agent-core-hkj5v9xq.js";
|
|
5
5
|
import {
|
|
6
6
|
Edge,
|
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
DecoratorNode,
|
|
15
15
|
init_decorator_node
|
|
16
16
|
} from "../../shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
17
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
18
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
19
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
17
|
+
import"../../shared/@ai-setting/roy-agent-core-2ccy0zd2.js";
|
|
18
|
+
import"../../shared/@ai-setting/roy-agent-core-xv7k1p2j.js";
|
|
19
|
+
import"../../shared/@ai-setting/roy-agent-core-4eke3pd4.js";
|
|
20
20
|
import"../../shared/@ai-setting/roy-agent-core-hhrg314p.js";
|
|
21
21
|
import"../../shared/@ai-setting/roy-agent-core-8nv07zgr.js";
|
|
22
22
|
import"../../shared/@ai-setting/roy-agent-core-rczz7e81.js";
|
|
@@ -82,8 +82,8 @@ import {
|
|
|
82
82
|
unresolvedVariable
|
|
83
83
|
} from "../../shared/@ai-setting/roy-agent-core-jrj30vq3.js";
|
|
84
84
|
import"../../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
|
|
85
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
86
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
85
|
+
import"../../shared/@ai-setting/roy-agent-core-ykrcrktp.js";
|
|
86
|
+
import"../../shared/@ai-setting/roy-agent-core-r4z6h3ch.js";
|
|
87
87
|
import"../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
88
88
|
import {
|
|
89
89
|
AskUserError,
|
|
@@ -24,9 +24,9 @@ import {
|
|
|
24
24
|
getRunWorkflowTool,
|
|
25
25
|
initRunWorkflowTool,
|
|
26
26
|
resetRunWorkflowTool
|
|
27
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
28
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
29
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
27
|
+
} from "../../../shared/@ai-setting/roy-agent-core-2ccy0zd2.js";
|
|
28
|
+
import"../../../shared/@ai-setting/roy-agent-core-xv7k1p2j.js";
|
|
29
|
+
import"../../../shared/@ai-setting/roy-agent-core-4eke3pd4.js";
|
|
30
30
|
import"../../../shared/@ai-setting/roy-agent-core-8nv07zgr.js";
|
|
31
31
|
import {
|
|
32
32
|
WORKFLOW_SUBMIT_OUTPUT_TOOL_NAME,
|
|
@@ -40,8 +40,8 @@ import"../../../shared/@ai-setting/roy-agent-core-6vbgswjw.js";
|
|
|
40
40
|
import"../../../shared/@ai-setting/roy-agent-core-tm57tmds.js";
|
|
41
41
|
import"../../../shared/@ai-setting/roy-agent-core-jrj30vq3.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-
|
|
43
|
+
import"../../../shared/@ai-setting/roy-agent-core-ykrcrktp.js";
|
|
44
|
+
import"../../../shared/@ai-setting/roy-agent-core-r4z6h3ch.js";
|
|
45
45
|
import"../../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
46
46
|
import"../../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
47
47
|
import"../../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
ModelLimitsSchema,
|
|
13
13
|
ProviderCapabilitiesSchema,
|
|
14
14
|
ProviderConfigSchema
|
|
15
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
15
|
+
} from "./shared/@ai-setting/roy-agent-core-9jmzyc8t.js";
|
|
16
16
|
import"./shared/@ai-setting/roy-agent-core-adg9ghbt.js";
|
|
17
17
|
import"./shared/@ai-setting/roy-agent-core-wjmwwc4a.js";
|
|
18
18
|
import {
|
|
@@ -125,7 +125,7 @@ import {
|
|
|
125
125
|
} from "./shared/@ai-setting/roy-agent-core-223v204d.js";
|
|
126
126
|
import {
|
|
127
127
|
WorkflowComponent
|
|
128
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
128
|
+
} from "./shared/@ai-setting/roy-agent-core-12d4qzmw.js";
|
|
129
129
|
import {
|
|
130
130
|
init_node_registry_helper,
|
|
131
131
|
registerDecoratorNodeType
|
|
@@ -138,13 +138,13 @@ import {
|
|
|
138
138
|
createWorkflowFromClass
|
|
139
139
|
} from "./shared/@ai-setting/roy-agent-core-h0x19xgn.js";
|
|
140
140
|
import"./shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
141
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
141
|
+
import"./shared/@ai-setting/roy-agent-core-2ccy0zd2.js";
|
|
142
142
|
import {
|
|
143
143
|
SessionComponent
|
|
144
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
144
|
+
} from "./shared/@ai-setting/roy-agent-core-xv7k1p2j.js";
|
|
145
145
|
import {
|
|
146
146
|
MemorySessionStore
|
|
147
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
147
|
+
} from "./shared/@ai-setting/roy-agent-core-4eke3pd4.js";
|
|
148
148
|
import"./shared/@ai-setting/roy-agent-core-hhrg314p.js";
|
|
149
149
|
import"./shared/@ai-setting/roy-agent-core-8nv07zgr.js";
|
|
150
150
|
import"./shared/@ai-setting/roy-agent-core-rczz7e81.js";
|
|
@@ -165,7 +165,7 @@ import {
|
|
|
165
165
|
import {
|
|
166
166
|
AgentComponent,
|
|
167
167
|
AgentComponentConfigSchema
|
|
168
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
168
|
+
} from "./shared/@ai-setting/roy-agent-core-4w5vdzg8.js";
|
|
169
169
|
import {
|
|
170
170
|
ToolComponent,
|
|
171
171
|
ToolRegistry,
|
|
@@ -181,13 +181,16 @@ import {
|
|
|
181
181
|
getXDGPaths
|
|
182
182
|
} from "./shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
183
183
|
import"./shared/@ai-setting/roy-agent-core-4cj6hram.js";
|
|
184
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
184
|
+
import"./shared/@ai-setting/roy-agent-core-ykrcrktp.js";
|
|
185
185
|
import {
|
|
186
|
+
buildOpencodeHeaders,
|
|
186
187
|
createInvokeConfig,
|
|
187
188
|
invoke,
|
|
188
189
|
invokeNonStream,
|
|
190
|
+
isOpencodeEndpoint,
|
|
191
|
+
isOpencodeProvider,
|
|
189
192
|
parseModelString
|
|
190
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
193
|
+
} from "./shared/@ai-setting/roy-agent-core-r4z6h3ch.js";
|
|
191
194
|
import"./shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
192
195
|
import {
|
|
193
196
|
AskUserError,
|
|
@@ -510,6 +513,8 @@ export {
|
|
|
510
513
|
isValidEventSourceType,
|
|
511
514
|
isRoyError,
|
|
512
515
|
isQuietMode,
|
|
516
|
+
isOpencodeProvider,
|
|
517
|
+
isOpencodeEndpoint,
|
|
513
518
|
isMediaType,
|
|
514
519
|
isBuiltInEventSourceType,
|
|
515
520
|
invokeNonStream,
|
|
@@ -548,6 +553,7 @@ export {
|
|
|
548
553
|
closeDatabase,
|
|
549
554
|
cascadeStopSessionTree,
|
|
550
555
|
builtInHandlers,
|
|
556
|
+
buildOpencodeHeaders,
|
|
551
557
|
buildDefaultBountyIMSystemPrompt,
|
|
552
558
|
bountyIMHandler,
|
|
553
559
|
bashTool,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SessionMessageConverter
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-ykrcrktp.js";
|
|
4
4
|
import {
|
|
5
5
|
canonicalizeParts
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-r4z6h3ch.js";
|
|
7
7
|
import {
|
|
8
8
|
createLogger,
|
|
9
9
|
init_logger
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
} from "./roy-agent-core-4cj6hram.js";
|
|
10
10
|
import {
|
|
11
11
|
SessionMessageConverter
|
|
12
|
-
} from "./roy-agent-core-
|
|
12
|
+
} from "./roy-agent-core-ykrcrktp.js";
|
|
13
13
|
import {
|
|
14
14
|
safeParseToolArgs,
|
|
15
15
|
withTimeout
|
|
16
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-r4z6h3ch.js";
|
|
17
17
|
import {
|
|
18
18
|
getCurrentBgTaskId
|
|
19
19
|
} from "./roy-agent-core-c1v263jn.js";
|
|
@@ -6,9 +6,10 @@ import {
|
|
|
6
6
|
sniffImageMime
|
|
7
7
|
} from "./roy-agent-core-zjdzk1gg.js";
|
|
8
8
|
import {
|
|
9
|
+
buildOpencodeHeaders,
|
|
9
10
|
invoke,
|
|
10
11
|
invokeNonStream
|
|
11
|
-
} from "./roy-agent-core-
|
|
12
|
+
} from "./roy-agent-core-r4z6h3ch.js";
|
|
12
13
|
import {
|
|
13
14
|
ContextError,
|
|
14
15
|
ErrorCodes
|
|
@@ -194,6 +195,10 @@ function toPiTools(tools) {
|
|
|
194
195
|
parameters: convertToolParameters(t.parameters)
|
|
195
196
|
}));
|
|
196
197
|
}
|
|
198
|
+
function piRequestExtras(req) {
|
|
199
|
+
const headers = buildOpencodeHeaders(req.provider, req.sessionId, req.baseURL);
|
|
200
|
+
return Object.keys(headers).length > 0 ? { headers } : {};
|
|
201
|
+
}
|
|
197
202
|
function fromAssistantMessage(msg) {
|
|
198
203
|
let text = "";
|
|
199
204
|
const toolCalls = [];
|
|
@@ -247,7 +252,8 @@ class PiAiAdapter {
|
|
|
247
252
|
baseURL: req.baseURL,
|
|
248
253
|
temperature: req.temperature,
|
|
249
254
|
maxTokens: req.maxTokens,
|
|
250
|
-
signal: req.signal
|
|
255
|
+
signal: req.signal,
|
|
256
|
+
...piRequestExtras(req)
|
|
251
257
|
});
|
|
252
258
|
return fromAssistantMessage(msg);
|
|
253
259
|
}
|
|
@@ -260,7 +266,7 @@ class PiAiAdapter {
|
|
|
260
266
|
messages: toPiMessages(req.messages),
|
|
261
267
|
tools: toPiTools(req.tools)
|
|
262
268
|
};
|
|
263
|
-
const eventStream = piStream(model, ctx, { apiKey: req.apiKey, baseURL: req.baseURL, temperature: req.temperature, maxTokens: req.maxTokens, signal: req.signal });
|
|
269
|
+
const eventStream = piStream(model, ctx, { apiKey: req.apiKey, baseURL: req.baseURL, temperature: req.temperature, maxTokens: req.maxTokens, signal: req.signal, ...piRequestExtras(req) });
|
|
264
270
|
return { events: eventStream, result: async () => fromAssistantMessage(await eventStream.result()) };
|
|
265
271
|
}
|
|
266
272
|
async embed(_req) {
|
|
@@ -417,7 +423,8 @@ class AiSdkAdapter {
|
|
|
417
423
|
tools: req.tools,
|
|
418
424
|
temperature: req.temperature,
|
|
419
425
|
maxTokens: req.maxTokens,
|
|
420
|
-
model: req.modelId
|
|
426
|
+
model: `${req.provider}/${req.modelId}`,
|
|
427
|
+
context: req.sessionId ? { sessionId: req.sessionId } : undefined
|
|
421
428
|
};
|
|
422
429
|
}
|
|
423
430
|
}
|
|
@@ -1211,7 +1218,8 @@ class LLMComponent extends BaseComponent {
|
|
|
1211
1218
|
maxTokens: ctx.maxTokens,
|
|
1212
1219
|
apiKey: ctx.invokeConfig.apiKey || "",
|
|
1213
1220
|
baseURL: ctx.invokeConfig.baseURL,
|
|
1214
|
-
signal: ctx.abortSignal
|
|
1221
|
+
signal: ctx.abortSignal,
|
|
1222
|
+
sessionId: request.context?.sessionId
|
|
1215
1223
|
};
|
|
1216
1224
|
let output = {
|
|
1217
1225
|
content: "",
|
|
@@ -6,6 +6,59 @@ import {
|
|
|
6
6
|
__require
|
|
7
7
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
8
8
|
|
|
9
|
+
// src/env/llm/opencode-session.ts
|
|
10
|
+
var OPENCODE_SESSION_ID_CACHE_MAX = 1000;
|
|
11
|
+
var opencodeSessionIdCache = new Map;
|
|
12
|
+
function generateOpencodeSessionId(nowMs = Date.now()) {
|
|
13
|
+
const timestampHex = Math.floor(nowMs / 1000).toString(16).padStart(12, "0");
|
|
14
|
+
const randomChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
15
|
+
let suffix = "";
|
|
16
|
+
for (let i = 0;i < 14; i++) {
|
|
17
|
+
suffix += randomChars[Math.floor(Math.random() * randomChars.length)];
|
|
18
|
+
}
|
|
19
|
+
return `ses_${timestampHex}${suffix}`;
|
|
20
|
+
}
|
|
21
|
+
function isOpencodeProvider(providerId) {
|
|
22
|
+
if (!providerId)
|
|
23
|
+
return false;
|
|
24
|
+
const normalized = providerId.toLowerCase().replace(/[-_]/g, "");
|
|
25
|
+
return normalized === "opencode" || normalized === "opencodego";
|
|
26
|
+
}
|
|
27
|
+
function isOpencodeEndpoint(baseURL) {
|
|
28
|
+
if (!baseURL)
|
|
29
|
+
return false;
|
|
30
|
+
try {
|
|
31
|
+
const url = new URL(baseURL);
|
|
32
|
+
return url.hostname === "opencode.ai" && url.pathname.startsWith("/inference/go");
|
|
33
|
+
} catch {
|
|
34
|
+
return /^https?:\/\/opencode\.ai\/inference\/go(\/|$)/i.test(baseURL);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function getOrCreateOpencodeSessionId(conversationId, nowMs = Date.now()) {
|
|
38
|
+
if (!conversationId) {
|
|
39
|
+
return generateOpencodeSessionId(nowMs);
|
|
40
|
+
}
|
|
41
|
+
const cached = opencodeSessionIdCache.get(conversationId);
|
|
42
|
+
if (cached) {
|
|
43
|
+
return cached;
|
|
44
|
+
}
|
|
45
|
+
const sessionId = generateOpencodeSessionId(nowMs);
|
|
46
|
+
if (opencodeSessionIdCache.size >= OPENCODE_SESSION_ID_CACHE_MAX) {
|
|
47
|
+
const oldest = opencodeSessionIdCache.keys().next().value;
|
|
48
|
+
if (oldest !== undefined) {
|
|
49
|
+
opencodeSessionIdCache.delete(oldest);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
opencodeSessionIdCache.set(conversationId, sessionId);
|
|
53
|
+
return sessionId;
|
|
54
|
+
}
|
|
55
|
+
function buildOpencodeHeaders(providerId, conversationId, baseURL) {
|
|
56
|
+
if (!isOpencodeProvider(providerId) && !isOpencodeEndpoint(baseURL)) {
|
|
57
|
+
return {};
|
|
58
|
+
}
|
|
59
|
+
return { "x-opencode-session": getOrCreateOpencodeSessionId(conversationId) };
|
|
60
|
+
}
|
|
61
|
+
|
|
9
62
|
// src/env/llm/invoke.ts
|
|
10
63
|
init_logger();
|
|
11
64
|
import { randomUUID } from "crypto";
|
|
@@ -119,7 +172,6 @@ function canonicalizeToolCallArgsInPlace(value) {
|
|
|
119
172
|
}
|
|
120
173
|
}
|
|
121
174
|
}
|
|
122
|
-
|
|
123
175
|
// src/env/llm/invoke.ts
|
|
124
176
|
var logger2 = createLogger("llm:invoke");
|
|
125
177
|
var MAX_RETRIES = 3;
|
|
@@ -793,35 +845,6 @@ function redactSecrets(text, knownSecrets = []) {
|
|
|
793
845
|
out = out.replace(/\bBearer\s+[A-Za-z0-9._\-+/=]{12,}\b/g, "<redacted>");
|
|
794
846
|
return out;
|
|
795
847
|
}
|
|
796
|
-
function generateOpencodeSessionId(nowMs = Date.now()) {
|
|
797
|
-
const timestampHex = Math.floor(nowMs / 1000).toString(16).padStart(12, "0");
|
|
798
|
-
const randomChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
799
|
-
let suffix = "";
|
|
800
|
-
for (let i = 0;i < 14; i++) {
|
|
801
|
-
suffix += randomChars[Math.floor(Math.random() * randomChars.length)];
|
|
802
|
-
}
|
|
803
|
-
return `ses_${timestampHex}${suffix}`;
|
|
804
|
-
}
|
|
805
|
-
var OPENCODE_SESSION_ID_CACHE_MAX = 1000;
|
|
806
|
-
var opencodeSessionIdCache = new Map;
|
|
807
|
-
function getOrCreateOpencodeSessionId(conversationId, nowMs = Date.now()) {
|
|
808
|
-
if (!conversationId) {
|
|
809
|
-
return generateOpencodeSessionId(nowMs);
|
|
810
|
-
}
|
|
811
|
-
const cached = opencodeSessionIdCache.get(conversationId);
|
|
812
|
-
if (cached) {
|
|
813
|
-
return cached;
|
|
814
|
-
}
|
|
815
|
-
const sessionId = generateOpencodeSessionId(nowMs);
|
|
816
|
-
if (opencodeSessionIdCache.size >= OPENCODE_SESSION_ID_CACHE_MAX) {
|
|
817
|
-
const oldest = opencodeSessionIdCache.keys().next().value;
|
|
818
|
-
if (oldest !== undefined) {
|
|
819
|
-
opencodeSessionIdCache.delete(oldest);
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
opencodeSessionIdCache.set(conversationId, sessionId);
|
|
823
|
-
return sessionId;
|
|
824
|
-
}
|
|
825
848
|
function createProviderInstance(providerId, apiKey, baseURL, conversationId) {
|
|
826
849
|
try {
|
|
827
850
|
if (providerId === "openai") {
|
|
@@ -843,10 +866,7 @@ function createProviderInstance(providerId, apiKey, baseURL, conversationId) {
|
|
|
843
866
|
});
|
|
844
867
|
return google;
|
|
845
868
|
}
|
|
846
|
-
const providerHeaders =
|
|
847
|
-
if (providerId === "opencode" || providerId === "opencode-go" || providerId === "opencodego") {
|
|
848
|
-
providerHeaders["x-opencode-session"] = getOrCreateOpencodeSessionId(conversationId);
|
|
849
|
-
}
|
|
869
|
+
const providerHeaders = buildOpencodeHeaders(providerId, conversationId, baseURL);
|
|
850
870
|
const defaultProvider = createOpenAICompatible({
|
|
851
871
|
name: providerId,
|
|
852
872
|
apiKey,
|
|
@@ -928,4 +948,4 @@ function createInvokeConfig(model, apiKey, baseURL) {
|
|
|
928
948
|
};
|
|
929
949
|
}
|
|
930
950
|
|
|
931
|
-
export { safeParseToolArgs, canonicalizeParts, withTimeout, parseModelString, convertToSDKMessages, invoke, invokeNonStream, createInvokeConfig };
|
|
951
|
+
export { safeParseToolArgs, generateOpencodeSessionId, isOpencodeProvider, isOpencodeEndpoint, getOrCreateOpencodeSessionId, buildOpencodeHeaders, canonicalizeParts, withTimeout, parseModelString, convertToSDKMessages, invoke, invokeNonStream, createInvokeConfig };
|