@ai-setting/roy-agent-core 1.5.89 → 1.5.90

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.
Files changed (26) hide show
  1. package/dist/env/agent/index.js +3 -3
  2. package/dist/env/event-source/index.js +8 -4
  3. package/dist/env/index.js +9 -9
  4. package/dist/env/llm/index.js +4 -2
  5. package/dist/env/session/index.js +3 -3
  6. package/dist/env/session/storage/index.js +2 -2
  7. package/dist/env/task/plugins/index.js +1 -1
  8. package/dist/env/workflow/engine/index.js +2 -2
  9. package/dist/env/workflow/index.js +3 -3
  10. package/dist/env/workflow/nodes/index.js +1 -1
  11. package/dist/index.js +119 -14
  12. package/dist/shared/@ai-setting/{roy-agent-core-r0m0at3x.js → roy-agent-core-0r4ndyn9.js} +119 -7
  13. package/dist/shared/@ai-setting/{roy-agent-core-fvfc7f6v.js → roy-agent-core-2c8eraxq.js} +62 -8
  14. package/dist/shared/@ai-setting/{roy-agent-core-h2d1s8yd.js → roy-agent-core-5ykms33a.js} +1 -1
  15. package/dist/shared/@ai-setting/{roy-agent-core-fgpnv7dt.js → roy-agent-core-8zjntsbb.js} +71 -28
  16. package/dist/shared/@ai-setting/{roy-agent-core-vneyghpg.js → roy-agent-core-ddq5hcp5.js} +1 -1
  17. package/dist/shared/@ai-setting/{roy-agent-core-qhhxx2x2.js → roy-agent-core-ds5f75pg.js} +2 -1
  18. package/dist/shared/@ai-setting/{roy-agent-core-3f6k060j.js → roy-agent-core-j0107ww1.js} +1 -1
  19. package/dist/shared/@ai-setting/{roy-agent-core-2q7cshpm.js → roy-agent-core-m683wd1n.js} +283 -15
  20. package/dist/shared/@ai-setting/{roy-agent-core-qbq3jgrn.js → roy-agent-core-rkz8r2sx.js} +1 -1
  21. package/dist/shared/@ai-setting/{roy-agent-core-c1j7ev4e.js → roy-agent-core-txwf64pd.js} +70 -0
  22. package/dist/shared/@ai-setting/{roy-agent-core-m3dkyprg.js → roy-agent-core-w0kb72ve.js} +7 -2
  23. package/dist/shared/@ai-setting/{roy-agent-core-hc20420t.js → roy-agent-core-z240ts1r.js} +27 -3
  24. package/dist/shared/@ai-setting/{roy-agent-core-q7sqeax6.js → roy-agent-core-zky9jse4.js} +163 -3
  25. package/package.json +1 -1
  26. /package/dist/shared/@ai-setting/{roy-agent-core-4f3976cd.js → roy-agent-core-k5hxvaf0.js} +0 -0
@@ -2,15 +2,15 @@ import {
2
2
  AgentComponent,
3
3
  AgentComponentConfigSchema,
4
4
  SummaryAgent
5
- } from "../../shared/@ai-setting/roy-agent-core-fgpnv7dt.js";
6
- import"../../shared/@ai-setting/roy-agent-core-r0m0at3x.js";
5
+ } from "../../shared/@ai-setting/roy-agent-core-8zjntsbb.js";
6
+ import"../../shared/@ai-setting/roy-agent-core-0r4ndyn9.js";
7
7
  import"../../shared/@ai-setting/roy-agent-core-hxsbegfc.js";
8
8
  import"../../shared/@ai-setting/roy-agent-core-yanpq5gb.js";
9
9
  import"../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
10
10
  import"../../shared/@ai-setting/roy-agent-core-nqzt9ne4.js";
11
11
  import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
12
12
  import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
13
- import"../../shared/@ai-setting/roy-agent-core-c1j7ev4e.js";
13
+ import"../../shared/@ai-setting/roy-agent-core-txwf64pd.js";
14
14
  import"../../shared/@ai-setting/roy-agent-core-ce10b0ez.js";
15
15
  import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
16
16
  import"../../shared/@ai-setting/roy-agent-core-rgckng3p.js";
@@ -1,12 +1,14 @@
1
- import"../../shared/@ai-setting/roy-agent-core-4f3976cd.js";
1
+ import"../../shared/@ai-setting/roy-agent-core-k5hxvaf0.js";
2
2
  import {
3
+ BountyIMInstance,
3
4
  EventSourceComponent,
4
5
  TimerInstance,
6
+ bountyIMHandler,
5
7
  builtInHandlers,
6
8
  getBuiltInHandler,
7
9
  larkCliHandler,
8
10
  timerHandler
9
- } from "../../shared/@ai-setting/roy-agent-core-2q7cshpm.js";
11
+ } from "../../shared/@ai-setting/roy-agent-core-m683wd1n.js";
10
12
  import {
11
13
  BUILT_IN_EVENT_SOURCE_TYPES,
12
14
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
@@ -15,9 +17,9 @@ import {
15
17
  isBuiltInEventSourceType,
16
18
  isValidEventSourceType,
17
19
  validateEventSourceConfig
18
- } from "../../shared/@ai-setting/roy-agent-core-qhhxx2x2.js";
20
+ } from "../../shared/@ai-setting/roy-agent-core-ds5f75pg.js";
19
21
  import"../../shared/@ai-setting/roy-agent-core-v8xa6vs8.js";
20
- import"../../shared/@ai-setting/roy-agent-core-m3dkyprg.js";
22
+ import"../../shared/@ai-setting/roy-agent-core-w0kb72ve.js";
21
23
  import"../../shared/@ai-setting/roy-agent-core-83d035pp.js";
22
24
  import"../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
23
25
  import"../../shared/@ai-setting/roy-agent-core-8wd3qwx5.js";
@@ -44,9 +46,11 @@ export {
44
46
  getDefaultConfigForType,
45
47
  getBuiltInHandler,
46
48
  builtInHandlers,
49
+ bountyIMHandler,
47
50
  TimerInstance,
48
51
  EventSourceInitHooks,
49
52
  EventSourceComponent,
53
+ BountyIMInstance,
50
54
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
51
55
  BUILT_IN_EVENT_SOURCE_TYPES
52
56
  };
package/dist/env/index.js CHANGED
@@ -5,32 +5,32 @@ import {
5
5
  EventSourceComponent,
6
6
  builtInHandlers,
7
7
  larkCliHandler
8
- } from "../shared/@ai-setting/roy-agent-core-2q7cshpm.js";
8
+ } from "../shared/@ai-setting/roy-agent-core-m683wd1n.js";
9
9
  import {
10
10
  EventSourceInitHooks,
11
11
  getDefaultConfigForType,
12
12
  isBuiltInEventSourceType,
13
13
  isValidEventSourceType,
14
14
  validateEventSourceConfig
15
- } from "../shared/@ai-setting/roy-agent-core-qhhxx2x2.js";
15
+ } from "../shared/@ai-setting/roy-agent-core-ds5f75pg.js";
16
16
  import"../shared/@ai-setting/roy-agent-core-v8xa6vs8.js";
17
17
  import {
18
18
  PluginComponent
19
19
  } from "../shared/@ai-setting/roy-agent-core-t1ef8hf2.js";
20
- import"../shared/@ai-setting/roy-agent-core-m3dkyprg.js";
20
+ import"../shared/@ai-setting/roy-agent-core-w0kb72ve.js";
21
21
  import"../shared/@ai-setting/roy-agent-core-83d035pp.js";
22
22
  import"../shared/@ai-setting/roy-agent-core-az13yzmc.js";
23
23
  import {
24
24
  WorkflowComponent
25
- } from "../shared/@ai-setting/roy-agent-core-qbq3jgrn.js";
25
+ } from "../shared/@ai-setting/roy-agent-core-rkz8r2sx.js";
26
26
  import"../shared/@ai-setting/roy-agent-core-fjexv5nm.js";
27
- import"../shared/@ai-setting/roy-agent-core-3f6k060j.js";
27
+ import"../shared/@ai-setting/roy-agent-core-j0107ww1.js";
28
28
  import"../shared/@ai-setting/roy-agent-core-5kdw0p98.js";
29
29
  import"../shared/@ai-setting/roy-agent-core-6atd905e.js";
30
30
  import"../shared/@ai-setting/roy-agent-core-gb9gbkc3.js";
31
31
  import"../shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
32
32
  import"../shared/@ai-setting/roy-agent-core-hhrg314p.js";
33
- import"../shared/@ai-setting/roy-agent-core-hc20420t.js";
33
+ import"../shared/@ai-setting/roy-agent-core-z240ts1r.js";
34
34
  import"../shared/@ai-setting/roy-agent-core-qnrf2aw6.js";
35
35
  import"../shared/@ai-setting/roy-agent-core-32m0nb9j.js";
36
36
  import"../shared/@ai-setting/roy-agent-core-1db4vpc6.js";
@@ -42,8 +42,8 @@ import"../shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
42
42
  import {
43
43
  AgentComponent,
44
44
  AgentComponentConfigSchema
45
- } from "../shared/@ai-setting/roy-agent-core-fgpnv7dt.js";
46
- import"../shared/@ai-setting/roy-agent-core-r0m0at3x.js";
45
+ } from "../shared/@ai-setting/roy-agent-core-8zjntsbb.js";
46
+ import"../shared/@ai-setting/roy-agent-core-0r4ndyn9.js";
47
47
  import"../shared/@ai-setting/roy-agent-core-hxsbegfc.js";
48
48
  import"../shared/@ai-setting/roy-agent-core-yanpq5gb.js";
49
49
  import"../shared/@ai-setting/roy-agent-core-e25xkv53.js";
@@ -69,7 +69,7 @@ import {
69
69
  import"../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
70
70
  import"../shared/@ai-setting/roy-agent-core-fnv3ev18.js";
71
71
  import"../shared/@ai-setting/roy-agent-core-djtkntar.js";
72
- import"../shared/@ai-setting/roy-agent-core-c1j7ev4e.js";
72
+ import"../shared/@ai-setting/roy-agent-core-txwf64pd.js";
73
73
  import"../shared/@ai-setting/roy-agent-core-ce10b0ez.js";
74
74
  import"../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
75
75
  import {
@@ -8,13 +8,14 @@ import {
8
8
  ProviderCapabilitiesSchema,
9
9
  ProviderConfigSchema,
10
10
  ProviderManager
11
- } from "../../shared/@ai-setting/roy-agent-core-h2d1s8yd.js";
11
+ } from "../../shared/@ai-setting/roy-agent-core-5ykms33a.js";
12
12
  import {
13
+ convertToSDKMessages,
13
14
  createInvokeConfig,
14
15
  invoke,
15
16
  invokeNonStream,
16
17
  parseModelString
17
- } from "../../shared/@ai-setting/roy-agent-core-r0m0at3x.js";
18
+ } from "../../shared/@ai-setting/roy-agent-core-0r4ndyn9.js";
18
19
  import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
19
20
  import"../../shared/@ai-setting/roy-agent-core-ce10b0ez.js";
20
21
  import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
@@ -33,6 +34,7 @@ export {
33
34
  invokeNonStream,
34
35
  invoke,
35
36
  createInvokeConfig,
37
+ convertToSDKMessages,
36
38
  ProviderManager,
37
39
  ProviderConfigSchema,
38
40
  ProviderCapabilitiesSchema,
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  SessionComponent
3
- } from "../../shared/@ai-setting/roy-agent-core-fvfc7f6v.js";
3
+ } from "../../shared/@ai-setting/roy-agent-core-2c8eraxq.js";
4
4
  import"../../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
5
5
  import {
6
6
  MemorySessionStore
7
- } from "../../shared/@ai-setting/roy-agent-core-q7sqeax6.js";
7
+ } from "../../shared/@ai-setting/roy-agent-core-zky9jse4.js";
8
8
  import {
9
9
  SessionMessageConverter
10
- } from "../../shared/@ai-setting/roy-agent-core-c1j7ev4e.js";
10
+ } from "../../shared/@ai-setting/roy-agent-core-txwf64pd.js";
11
11
  import"../../shared/@ai-setting/roy-agent-core-ce10b0ez.js";
12
12
  import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
13
13
  import"../../shared/@ai-setting/roy-agent-core-rgckng3p.js";
@@ -3,8 +3,8 @@ import {
3
3
  SQLiteSessionStore,
4
4
  getDefaultDataDir,
5
5
  getDefaultSessionDbPath
6
- } from "../../../shared/@ai-setting/roy-agent-core-q7sqeax6.js";
7
- import"../../../shared/@ai-setting/roy-agent-core-c1j7ev4e.js";
6
+ } from "../../../shared/@ai-setting/roy-agent-core-zky9jse4.js";
7
+ import"../../../shared/@ai-setting/roy-agent-core-txwf64pd.js";
8
8
  import"../../../shared/@ai-setting/roy-agent-core-ce10b0ez.js";
9
9
  import"../../../shared/@ai-setting/roy-agent-core-shme7set.js";
10
10
  import"../../../shared/@ai-setting/roy-agent-core-7z9b1fm8.js";
@@ -7,7 +7,7 @@ import {
7
7
  formatExtractorInput,
8
8
  formatExtractorInputFromDescription,
9
9
  parseExtractorOutput
10
- } from "../../../shared/@ai-setting/roy-agent-core-m3dkyprg.js";
10
+ } from "../../../shared/@ai-setting/roy-agent-core-w0kb72ve.js";
11
11
  import"../../../shared/@ai-setting/roy-agent-core-83d035pp.js";
12
12
  import"../../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
13
13
  import"../../../shared/@ai-setting/roy-agent-core-8wd3qwx5.js";
@@ -5,12 +5,12 @@ import {
5
5
  Scheduler,
6
6
  WorkflowEngine,
7
7
  init_engine
8
- } from "../../../shared/@ai-setting/roy-agent-core-3f6k060j.js";
8
+ } from "../../../shared/@ai-setting/roy-agent-core-j0107ww1.js";
9
9
  import"../../../shared/@ai-setting/roy-agent-core-5kdw0p98.js";
10
10
  import"../../../shared/@ai-setting/roy-agent-core-6atd905e.js";
11
11
  import"../../../shared/@ai-setting/roy-agent-core-gb9gbkc3.js";
12
12
  import"../../../shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
13
- import"../../../shared/@ai-setting/roy-agent-core-hc20420t.js";
13
+ import"../../../shared/@ai-setting/roy-agent-core-z240ts1r.js";
14
14
  import"../../../shared/@ai-setting/roy-agent-core-qnrf2aw6.js";
15
15
  import"../../../shared/@ai-setting/roy-agent-core-1db4vpc6.js";
16
16
  import {
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  WorkflowComponent
3
- } from "../../shared/@ai-setting/roy-agent-core-qbq3jgrn.js";
3
+ } from "../../shared/@ai-setting/roy-agent-core-rkz8r2sx.js";
4
4
  import"../../shared/@ai-setting/roy-agent-core-fjexv5nm.js";
5
- import"../../shared/@ai-setting/roy-agent-core-3f6k060j.js";
5
+ import"../../shared/@ai-setting/roy-agent-core-j0107ww1.js";
6
6
  import"../../shared/@ai-setting/roy-agent-core-5kdw0p98.js";
7
7
  import"../../shared/@ai-setting/roy-agent-core-6atd905e.js";
8
8
  import"../../shared/@ai-setting/roy-agent-core-gb9gbkc3.js";
9
9
  import"../../shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
10
10
  import"../../shared/@ai-setting/roy-agent-core-hhrg314p.js";
11
- import"../../shared/@ai-setting/roy-agent-core-hc20420t.js";
11
+ import"../../shared/@ai-setting/roy-agent-core-z240ts1r.js";
12
12
  import {
13
13
  BaseEventSchema,
14
14
  ControlPauseEventSchema,
@@ -5,7 +5,7 @@ import {
5
5
  init_skill_node,
6
6
  init_tool_node,
7
7
  init_workflow_node
8
- } from "../../../shared/@ai-setting/roy-agent-core-hc20420t.js";
8
+ } from "../../../shared/@ai-setting/roy-agent-core-z240ts1r.js";
9
9
  import"../../../shared/@ai-setting/roy-agent-core-k05v31rc.js";
10
10
  import"../../../shared/@ai-setting/roy-agent-core-shme7set.js";
11
11
  import"../../../shared/@ai-setting/roy-agent-core-7z9b1fm8.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-h2d1s8yd.js";
12
+ } from "./shared/@ai-setting/roy-agent-core-5ykms33a.js";
13
13
  import {
14
14
  ConfigComponent
15
15
  } from "./shared/@ai-setting/roy-agent-core-prdngx28.js";
@@ -31,7 +31,7 @@ import {
31
31
  closeDatabase
32
32
  } from "./shared/@ai-setting/roy-agent-core-h4h55x4h.js";
33
33
  import"./shared/@ai-setting/roy-agent-core-3sv590cv.js";
34
- import"./shared/@ai-setting/roy-agent-core-4f3976cd.js";
34
+ import"./shared/@ai-setting/roy-agent-core-k5hxvaf0.js";
35
35
  import {
36
36
  MemoryComponent
37
37
  } from "./shared/@ai-setting/roy-agent-core-2h38rvyj.js";
@@ -54,13 +54,15 @@ import {
54
54
  generateId
55
55
  } from "./shared/@ai-setting/roy-agent-core-bwjpte58.js";
56
56
  import {
57
+ BountyIMInstance,
57
58
  EventSourceComponent,
58
59
  TimerInstance,
60
+ bountyIMHandler,
59
61
  builtInHandlers,
60
62
  getBuiltInHandler,
61
63
  larkCliHandler,
62
64
  timerHandler
63
- } from "./shared/@ai-setting/roy-agent-core-2q7cshpm.js";
65
+ } from "./shared/@ai-setting/roy-agent-core-m683wd1n.js";
64
66
  import {
65
67
  BUILT_IN_EVENT_SOURCE_TYPES,
66
68
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
@@ -69,7 +71,7 @@ import {
69
71
  isBuiltInEventSourceType,
70
72
  isValidEventSourceType,
71
73
  validateEventSourceConfig
72
- } from "./shared/@ai-setting/roy-agent-core-qhhxx2x2.js";
74
+ } from "./shared/@ai-setting/roy-agent-core-ds5f75pg.js";
73
75
  import {
74
76
  LogTraceComponent,
75
77
  LogTraceConfigSchema
@@ -79,7 +81,7 @@ import {
79
81
  } from "./shared/@ai-setting/roy-agent-core-t1ef8hf2.js";
80
82
  import {
81
83
  TaskTagPlugin
82
- } from "./shared/@ai-setting/roy-agent-core-m3dkyprg.js";
84
+ } from "./shared/@ai-setting/roy-agent-core-w0kb72ve.js";
83
85
  import {
84
86
  getBuiltInPrompt,
85
87
  getBuiltInPromptNames
@@ -89,18 +91,18 @@ import {
89
91
  } from "./shared/@ai-setting/roy-agent-core-az13yzmc.js";
90
92
  import {
91
93
  WorkflowComponent
92
- } from "./shared/@ai-setting/roy-agent-core-qbq3jgrn.js";
94
+ } from "./shared/@ai-setting/roy-agent-core-rkz8r2sx.js";
93
95
  import {
94
96
  init_node_registry_helper,
95
97
  registerDecoratorNodeType
96
98
  } from "./shared/@ai-setting/roy-agent-core-fjexv5nm.js";
97
- import"./shared/@ai-setting/roy-agent-core-3f6k060j.js";
99
+ import"./shared/@ai-setting/roy-agent-core-j0107ww1.js";
98
100
  import"./shared/@ai-setting/roy-agent-core-5kdw0p98.js";
99
101
  import"./shared/@ai-setting/roy-agent-core-6atd905e.js";
100
102
  import"./shared/@ai-setting/roy-agent-core-gb9gbkc3.js";
101
103
  import"./shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
102
104
  import"./shared/@ai-setting/roy-agent-core-hhrg314p.js";
103
- import"./shared/@ai-setting/roy-agent-core-hc20420t.js";
105
+ import"./shared/@ai-setting/roy-agent-core-z240ts1r.js";
104
106
  import"./shared/@ai-setting/roy-agent-core-qnrf2aw6.js";
105
107
  import"./shared/@ai-setting/roy-agent-core-32m0nb9j.js";
106
108
  import"./shared/@ai-setting/roy-agent-core-1db4vpc6.js";
@@ -118,13 +120,13 @@ import"./shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
118
120
  import {
119
121
  AgentComponent,
120
122
  AgentComponentConfigSchema
121
- } from "./shared/@ai-setting/roy-agent-core-fgpnv7dt.js";
123
+ } from "./shared/@ai-setting/roy-agent-core-8zjntsbb.js";
122
124
  import {
123
125
  createInvokeConfig,
124
126
  invoke,
125
127
  invokeNonStream,
126
128
  parseModelString
127
- } from "./shared/@ai-setting/roy-agent-core-r0m0at3x.js";
129
+ } from "./shared/@ai-setting/roy-agent-core-0r4ndyn9.js";
128
130
  import {
129
131
  ToolComponent,
130
132
  ToolRegistry,
@@ -182,12 +184,12 @@ import"./shared/@ai-setting/roy-agent-core-fnv3ev18.js";
182
184
  import"./shared/@ai-setting/roy-agent-core-djtkntar.js";
183
185
  import {
184
186
  SessionComponent
185
- } from "./shared/@ai-setting/roy-agent-core-fvfc7f6v.js";
187
+ } from "./shared/@ai-setting/roy-agent-core-2c8eraxq.js";
186
188
  import"./shared/@ai-setting/roy-agent-core-rvxg1wps.js";
187
189
  import {
188
190
  MemorySessionStore
189
- } from "./shared/@ai-setting/roy-agent-core-q7sqeax6.js";
190
- import"./shared/@ai-setting/roy-agent-core-c1j7ev4e.js";
191
+ } from "./shared/@ai-setting/roy-agent-core-zky9jse4.js";
192
+ import"./shared/@ai-setting/roy-agent-core-txwf64pd.js";
191
193
  import"./shared/@ai-setting/roy-agent-core-ce10b0ez.js";
192
194
  import"./shared/@ai-setting/roy-agent-core-qxhq8ven.js";
193
195
  import {
@@ -231,6 +233,103 @@ import {
231
233
  SQLiteSpanStorage
232
234
  } from "./shared/@ai-setting/roy-agent-core-c6592r3c.js";
233
235
  import"./shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
236
+ // src/utils/media.ts
237
+ import * as fs from "node:fs/promises";
238
+ import * as path from "node:path";
239
+ var ATTACH_FILE_MAX_BYTES = 10 * 1024 * 1024;
240
+ function startsWith(buf, sig) {
241
+ if (buf.length < sig.length)
242
+ return false;
243
+ for (let i = 0;i < sig.length; i++) {
244
+ if (buf[i] !== sig[i])
245
+ return false;
246
+ }
247
+ return true;
248
+ }
249
+ function sniffMimeType(buffer, fallbackName) {
250
+ if (startsWith(buffer, [137, 80, 78, 71, 13, 10, 26, 10])) {
251
+ return "image/png";
252
+ }
253
+ if (startsWith(buffer, [255, 216, 255])) {
254
+ return "image/jpeg";
255
+ }
256
+ if (startsWith(buffer, [71, 73, 70, 56])) {
257
+ return "image/gif";
258
+ }
259
+ if (startsWith(buffer, [66, 77])) {
260
+ return "image/bmp";
261
+ }
262
+ if (startsWith(buffer, [37, 80, 68, 70, 45])) {
263
+ return "application/pdf";
264
+ }
265
+ if (startsWith(buffer, [82, 73, 70, 70]) && startsWith(buffer.subarray(8), [87, 69, 66, 80])) {
266
+ return "image/webp";
267
+ }
268
+ if (fallbackName) {
269
+ const ext = path.extname(fallbackName).toLowerCase();
270
+ const extMap = {
271
+ ".png": "image/png",
272
+ ".jpg": "image/jpeg",
273
+ ".jpeg": "image/jpeg",
274
+ ".gif": "image/gif",
275
+ ".webp": "image/webp",
276
+ ".bmp": "image/bmp",
277
+ ".pdf": "application/pdf",
278
+ ".mp3": "audio/mpeg",
279
+ ".wav": "audio/wav",
280
+ ".ogg": "audio/ogg",
281
+ ".m4a": "audio/mp4",
282
+ ".mp4": "video/mp4",
283
+ ".mov": "video/quicktime",
284
+ ".webm": "video/webm"
285
+ };
286
+ const mapped = extMap[ext];
287
+ if (mapped)
288
+ return mapped;
289
+ }
290
+ return "application/octet-stream";
291
+ }
292
+ function isMediaType(mime) {
293
+ if (typeof mime !== "string")
294
+ return false;
295
+ const m = mime.toLowerCase();
296
+ return m.startsWith("image/") || m.startsWith("audio/") || m.startsWith("video/") || m === "application/pdf";
297
+ }
298
+ var HTTP_URL_RE = /^https?:\/\//i;
299
+ var DATA_URL_RE = /^data:([^;,]+)(;base64)?,(.*)$/s;
300
+ async function parseImageInput(input) {
301
+ if (!input || typeof input !== "string" || input.trim().length === 0) {
302
+ throw new Error("parseImageInput: input is empty");
303
+ }
304
+ const trimmed = input.trim();
305
+ if (HTTP_URL_RE.test(trimmed)) {
306
+ return { type: "image", image: trimmed };
307
+ }
308
+ if (DATA_URL_RE.test(trimmed)) {
309
+ return { type: "image", image: trimmed };
310
+ }
311
+ return await parseLocalImagePath(trimmed);
312
+ }
313
+ async function parseLocalImagePath(filePath) {
314
+ let stat2;
315
+ try {
316
+ stat2 = await fs.stat(filePath);
317
+ } catch (err) {
318
+ throw new Error(`parseImageInput: cannot stat file '${filePath}': ${err.message}`);
319
+ }
320
+ if (!stat2.isFile()) {
321
+ throw new Error(`parseImageInput: not a regular file: ${filePath}`);
322
+ }
323
+ if (stat2.size > ATTACH_FILE_MAX_BYTES) {
324
+ throw new Error(`parseImageInput: file '${filePath}' exceeds 10 MiB limit ` + `(${stat2.size} bytes > ${ATTACH_FILE_MAX_BYTES} bytes)`);
325
+ }
326
+ const buffer = await fs.readFile(filePath);
327
+ const mime = sniffMimeType(buffer, filePath);
328
+ if (!mime.startsWith("image/")) {
329
+ throw new Error(`parseImageInput: file '${filePath}' is not an image (detected ${mime}). ` + `Use ContentPart type 'file' for non-image attachments.`);
330
+ }
331
+ return { type: "image", image: buffer };
332
+ }
234
333
  // src/env/memory/tools/memory-agent-tools.ts
235
334
  import { z } from "zod";
236
335
  var SearchSessionsSchema = z.object({
@@ -356,6 +455,7 @@ export {
356
455
  wrapFunction,
357
456
  validateEventSourceConfig,
358
457
  timerHandler,
458
+ sniffMimeType,
359
459
  setQuietMode,
360
460
  setConfigComponent as setLoggerConfigComponent,
361
461
  setLogDirOverride,
@@ -364,10 +464,12 @@ export {
364
464
  readFileTool,
365
465
  propagation,
366
466
  parseModelString,
467
+ parseImageInput,
367
468
  larkCliHandler,
368
469
  isValidEventSourceType,
369
470
  isRoyError,
370
471
  isQuietMode,
472
+ isMediaType,
371
473
  isBuiltInEventSourceType,
372
474
  invokeNonStream,
373
475
  invoke,
@@ -401,6 +503,7 @@ export {
401
503
  createAutoTaskPlugin,
402
504
  closeDatabase,
403
505
  builtInHandlers,
506
+ bountyIMHandler,
404
507
  bashTool,
405
508
  XDG_PATHS,
406
509
  WorkflowEdges,
@@ -455,6 +558,7 @@ export {
455
558
  ConfigComponent,
456
559
  ComponentError,
457
560
  CommandsComponent,
561
+ BountyIMInstance,
458
562
  BasePlugin,
459
563
  BaseEnvironment,
460
564
  BaseComponent,
@@ -464,5 +568,6 @@ export {
464
568
  AgentRegistry,
465
569
  AgentError,
466
570
  AgentComponentConfigSchema,
467
- AgentComponent
571
+ AgentComponent,
572
+ ATTACH_FILE_MAX_BYTES
468
573
  };
@@ -59,10 +59,15 @@ function extractUsageInfo(usage) {
59
59
  if (!usage)
60
60
  return;
61
61
  if (usage.inputTokens && typeof usage.inputTokens === "object") {
62
+ const inputTokens = usage.inputTokens;
63
+ const cacheRead = typeof inputTokens.cacheRead === "number" ? inputTokens.cacheRead : typeof usage.inputTokenDetails?.cacheReadTokens === "number" ? usage.inputTokenDetails.cacheReadTokens : undefined;
64
+ const cacheWrite = typeof inputTokens.cacheWrite === "number" ? inputTokens.cacheWrite : typeof usage.inputTokenDetails?.cacheWriteTokens === "number" ? usage.inputTokenDetails.cacheWriteTokens : undefined;
62
65
  return {
63
- promptTokens: usage.inputTokens.total ?? 0,
66
+ promptTokens: inputTokens.total ?? 0,
64
67
  completionTokens: usage.outputTokens?.total ?? 0,
65
- totalTokens: usage.totalTokens ?? 0
68
+ totalTokens: usage.totalTokens ?? 0,
69
+ cacheRead,
70
+ cacheWrite
66
71
  };
67
72
  }
68
73
  if (typeof usage.promptTokens === "number") {
@@ -73,10 +78,13 @@ function extractUsageInfo(usage) {
73
78
  };
74
79
  }
75
80
  if (usage.inputTokenDetails || usage.outputTokenDetails) {
81
+ const details = usage.inputTokenDetails;
76
82
  return {
77
- promptTokens: usage.inputTokenDetails?.tokens ?? 0,
83
+ promptTokens: details?.tokens ?? 0,
78
84
  completionTokens: usage.outputTokenDetails?.tokens ?? 0,
79
- totalTokens: usage.totalTokens ?? 0
85
+ totalTokens: usage.totalTokens ?? 0,
86
+ cacheRead: details?.cacheReadTokens,
87
+ cacheWrite: details?.cacheWriteTokens
80
88
  };
81
89
  }
82
90
  if (usage.raw && typeof usage.raw.total_tokens === "number") {
@@ -88,8 +96,111 @@ function extractUsageInfo(usage) {
88
96
  }
89
97
  return;
90
98
  }
99
+ function flattenAssistantContentToText(content) {
100
+ if (typeof content === "string") {
101
+ return content;
102
+ }
103
+ return content.filter((p) => p.type === "text").map((p) => p.text).join("");
104
+ }
105
+ function sortObjectKeysDeep(obj, seen = new WeakSet) {
106
+ if (obj === null || obj === undefined)
107
+ return obj;
108
+ if (typeof obj !== "object")
109
+ return obj;
110
+ if (seen.has(obj))
111
+ return obj;
112
+ seen.add(obj);
113
+ if (Array.isArray(obj)) {
114
+ return obj.map((item) => sortObjectKeysDeep(item, seen));
115
+ }
116
+ if (obj instanceof Uint8Array)
117
+ return obj;
118
+ if (obj instanceof URL)
119
+ return obj;
120
+ if (obj instanceof Date)
121
+ return obj;
122
+ if (obj instanceof RegExp)
123
+ return obj;
124
+ if (obj instanceof WeakSet)
125
+ return obj;
126
+ if (obj instanceof WeakMap)
127
+ return obj;
128
+ if (obj instanceof Map) {
129
+ const sortedEntries = [...obj.entries()].sort(([a], [b]) => String(a).localeCompare(String(b)));
130
+ const sorted2 = {};
131
+ for (const [k, v] of sortedEntries) {
132
+ sorted2[String(k)] = sortObjectKeysDeep(v, seen);
133
+ }
134
+ return sorted2;
135
+ }
136
+ if (obj instanceof Set) {
137
+ return [...obj].sort().map((v) => sortObjectKeysDeep(v, seen));
138
+ }
139
+ if (!isPlainObject(obj))
140
+ return obj;
141
+ const sorted = {};
142
+ for (const key of Object.keys(obj).sort()) {
143
+ sorted[key] = sortObjectKeysDeep(obj[key], seen);
144
+ }
145
+ return sorted;
146
+ }
147
+ function isPlainObject(obj) {
148
+ if (obj === null || typeof obj !== "object")
149
+ return false;
150
+ const proto = Object.getPrototypeOf(obj);
151
+ return proto === Object.prototype || proto === null;
152
+ }
153
+ var ANTHROPIC_CACHE_CONTROL = {
154
+ anthropic: { cacheControl: { type: "ephemeral" } }
155
+ };
91
156
  function convertToSDKMessages(messages) {
92
- return messages.map((msg) => {
157
+ let lastUserIndex = -1;
158
+ for (let i = messages.length - 1;i >= 0; i--) {
159
+ if (messages[i].role === "user") {
160
+ lastUserIndex = i;
161
+ break;
162
+ }
163
+ }
164
+ return messages.map((msg, index) => {
165
+ if (msg.role === "system") {
166
+ return {
167
+ role: "system",
168
+ content: typeof msg.content === "string" ? msg.content : "",
169
+ providerOptions: ANTHROPIC_CACHE_CONTROL
170
+ };
171
+ }
172
+ if (msg.role === "user" && Array.isArray(msg.content)) {
173
+ const contentParts = msg.content.map((part) => {
174
+ if (part.type === "image") {
175
+ return { type: "image", image: part.image };
176
+ }
177
+ if (part.type === "file") {
178
+ return { type: "file", data: part.file, mediaType: part.mediaType };
179
+ }
180
+ return { type: "text", text: part.text };
181
+ });
182
+ if (index === lastUserIndex && contentParts.length > 0) {
183
+ const lastPart = contentParts[contentParts.length - 1];
184
+ lastPart.providerOptions = ANTHROPIC_CACHE_CONTROL;
185
+ }
186
+ return {
187
+ role: "user",
188
+ content: contentParts
189
+ };
190
+ }
191
+ if (msg.role === "user" && typeof msg.content === "string") {
192
+ if (index === lastUserIndex) {
193
+ return {
194
+ role: "user",
195
+ content: msg.content,
196
+ providerOptions: ANTHROPIC_CACHE_CONTROL
197
+ };
198
+ }
199
+ return {
200
+ role: "user",
201
+ content: msg.content
202
+ };
203
+ }
93
204
  if (msg.role === "assistant" && msg.toolCalls && msg.toolCalls.length > 0) {
94
205
  const toolCallParts = msg.toolCalls.map((tc) => {
95
206
  let input = {};
@@ -106,6 +217,7 @@ function convertToSDKMessages(messages) {
106
217
  input = tc.arguments;
107
218
  }
108
219
  }
220
+ input = sortObjectKeysDeep(input);
109
221
  return {
110
222
  type: "tool-call",
111
223
  toolCallId: tc.id,
@@ -115,7 +227,7 @@ function convertToSDKMessages(messages) {
115
227
  });
116
228
  const contentParts = [];
117
229
  if (msg.content) {
118
- contentParts.push({ type: "text", text: msg.content });
230
+ contentParts.push({ type: "text", text: flattenAssistantContentToText(msg.content) });
119
231
  }
120
232
  contentParts.push(...toolCallParts);
121
233
  return {
@@ -644,4 +756,4 @@ function createInvokeConfig(model, apiKey, baseURL) {
644
756
  };
645
757
  }
646
758
 
647
- export { withTimeout, parseModelString, invoke, invokeNonStream, createInvokeConfig };
759
+ export { withTimeout, parseModelString, convertToSDKMessages, invoke, invokeNonStream, createInvokeConfig };