@ai-setting/roy-agent-core 1.6.19 → 1.6.21

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 +2 -2
  2. package/dist/env/event-source/index.js +3 -3
  3. package/dist/env/index.js +12 -12
  4. package/dist/env/prompt/index.js +2 -2
  5. package/dist/env/session/index.js +2 -2
  6. package/dist/env/session/storage/index.js +1 -1
  7. package/dist/env/task/delegate/index.js +3 -3
  8. package/dist/env/task/index.js +4 -4
  9. package/dist/env/task/plugins/index.js +2 -2
  10. package/dist/env/workflow/index.js +4 -4
  11. package/dist/env/workflow/tools/index.js +3 -3
  12. package/dist/index.js +13 -13
  13. package/dist/shared/@ai-setting/{roy-agent-core-m0wy7p0q.js → roy-agent-core-b9q2jfx4.js} +1 -1
  14. package/dist/shared/@ai-setting/{roy-agent-core-5kc9qtej.js → roy-agent-core-bb20se79.js} +1 -1
  15. package/dist/shared/@ai-setting/{roy-agent-core-8wd5awxg.js → roy-agent-core-bwqjwa0d.js} +1 -1
  16. package/dist/shared/@ai-setting/{roy-agent-core-5ka95kh7.js → roy-agent-core-ett06sn8.js} +1 -1
  17. package/dist/shared/@ai-setting/{roy-agent-core-tycbpm17.js → roy-agent-core-fntxq0gf.js} +1 -1
  18. package/dist/shared/@ai-setting/{roy-agent-core-btp589bw.js → roy-agent-core-grajzyhd.js} +1 -1
  19. package/dist/shared/@ai-setting/{roy-agent-core-kkt2ndpf.js → roy-agent-core-j8t1tyhr.js} +1 -1
  20. package/dist/shared/@ai-setting/{roy-agent-core-bqe4c9f2.js → roy-agent-core-kr58bgz0.js} +9 -1
  21. package/dist/shared/@ai-setting/{roy-agent-core-mekk4as5.js → roy-agent-core-q06h6qf8.js} +1 -1
  22. package/dist/shared/@ai-setting/{roy-agent-core-4djnmd86.js → roy-agent-core-skqt40yy.js} +85 -12
  23. package/dist/shared/@ai-setting/{roy-agent-core-zs4f0tcy.js → roy-agent-core-xjj88tpn.js} +128 -1
  24. package/dist/shared/@ai-setting/{roy-agent-core-qyb2z42s.js → roy-agent-core-zeztnvvb.js} +1 -1
  25. package/dist/shared/@ai-setting/{roy-agent-core-mqeqevym.js → roy-agent-core-zvwdfm79.js} +115 -23
  26. package/package.json +1 -1
@@ -2,12 +2,12 @@ import {
2
2
  AgentComponent,
3
3
  AgentComponentConfigSchema,
4
4
  SummaryAgent
5
- } from "../../shared/@ai-setting/roy-agent-core-qyb2z42s.js";
5
+ } from "../../shared/@ai-setting/roy-agent-core-zeztnvvb.js";
6
6
  import"../../shared/@ai-setting/roy-agent-core-8n0e62y4.js";
7
7
  import"../../shared/@ai-setting/roy-agent-core-eskgj8nc.js";
8
8
  import"../../shared/@ai-setting/roy-agent-core-ataagh3a.js";
9
9
  import"../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
10
- import"../../shared/@ai-setting/roy-agent-core-tycbpm17.js";
10
+ import"../../shared/@ai-setting/roy-agent-core-fntxq0gf.js";
11
11
  import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
12
12
  import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
13
13
  import"../../shared/@ai-setting/roy-agent-core-7r72622v.js";
@@ -11,7 +11,7 @@ import {
11
11
  larkCliHandler,
12
12
  resolveBountyIMSystemPrompt,
13
13
  timerHandler
14
- } from "../../shared/@ai-setting/roy-agent-core-8wd5awxg.js";
14
+ } from "../../shared/@ai-setting/roy-agent-core-bwqjwa0d.js";
15
15
  import {
16
16
  BUILT_IN_EVENT_SOURCE_TYPES,
17
17
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
@@ -22,13 +22,13 @@ import {
22
22
  validateEventSourceConfig
23
23
  } from "../../shared/@ai-setting/roy-agent-core-ds5f75pg.js";
24
24
  import"../../shared/@ai-setting/roy-agent-core-1qjgwjjs.js";
25
- import"../../shared/@ai-setting/roy-agent-core-btp589bw.js";
25
+ import"../../shared/@ai-setting/roy-agent-core-grajzyhd.js";
26
26
  import"../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
27
27
  import"../../shared/@ai-setting/roy-agent-core-1mrc9a1r.js";
28
28
  import"../../shared/@ai-setting/roy-agent-core-bq1gskrf.js";
29
29
  import"../../shared/@ai-setting/roy-agent-core-jrj30vq3.js";
30
30
  import"../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
31
- import"../../shared/@ai-setting/roy-agent-core-4djnmd86.js";
31
+ import"../../shared/@ai-setting/roy-agent-core-skqt40yy.js";
32
32
  import"../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
33
33
  import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
34
34
  import"../../shared/@ai-setting/roy-agent-core-akb8mb9v.js";
package/dist/env/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  BaseEnvironment
3
- } from "../shared/@ai-setting/roy-agent-core-m0wy7p0q.js";
3
+ } from "../shared/@ai-setting/roy-agent-core-b9q2jfx4.js";
4
4
  import {
5
5
  EventSourceComponent,
6
6
  builtInHandlers,
7
7
  larkCliHandler
8
- } from "../shared/@ai-setting/roy-agent-core-8wd5awxg.js";
8
+ } from "../shared/@ai-setting/roy-agent-core-bwqjwa0d.js";
9
9
  import {
10
10
  EventSourceInitHooks,
11
11
  getDefaultConfigForType,
@@ -17,11 +17,11 @@ import"../shared/@ai-setting/roy-agent-core-1qjgwjjs.js";
17
17
  import {
18
18
  PluginComponent
19
19
  } from "../shared/@ai-setting/roy-agent-core-gc75v3px.js";
20
- import"../shared/@ai-setting/roy-agent-core-btp589bw.js";
20
+ import"../shared/@ai-setting/roy-agent-core-grajzyhd.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-mekk4as5.js";
24
+ } from "../shared/@ai-setting/roy-agent-core-q06h6qf8.js";
25
25
  import"../shared/@ai-setting/roy-agent-core-77wfej1h.js";
26
26
  import"../shared/@ai-setting/roy-agent-core-f1cjs6c4.js";
27
27
  import"../shared/@ai-setting/roy-agent-core-6atd905e.js";
@@ -30,7 +30,7 @@ import"../shared/@ai-setting/roy-agent-core-ez91vxas.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-7kw06e4b.js";
33
- import"../shared/@ai-setting/roy-agent-core-kkt2ndpf.js";
33
+ import"../shared/@ai-setting/roy-agent-core-j8t1tyhr.js";
34
34
  import"../shared/@ai-setting/roy-agent-core-1db4vpc6.js";
35
35
  import"../shared/@ai-setting/roy-agent-core-r15sn7ve.js";
36
36
  import"../shared/@ai-setting/roy-agent-core-1mrc9a1r.js";
@@ -41,22 +41,22 @@ 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-qyb2z42s.js";
44
+ } from "../shared/@ai-setting/roy-agent-core-zeztnvvb.js";
45
45
  import"../shared/@ai-setting/roy-agent-core-8n0e62y4.js";
46
46
  import"../shared/@ai-setting/roy-agent-core-eskgj8nc.js";
47
47
  import"../shared/@ai-setting/roy-agent-core-ataagh3a.js";
48
48
  import"../shared/@ai-setting/roy-agent-core-e25xkv53.js";
49
49
  import {
50
50
  TaskComponent
51
- } from "../shared/@ai-setting/roy-agent-core-5kc9qtej.js";
51
+ } from "../shared/@ai-setting/roy-agent-core-bb20se79.js";
52
52
  import"../shared/@ai-setting/roy-agent-core-amkqnyzy.js";
53
53
  import"../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
54
- import"../shared/@ai-setting/roy-agent-core-mqeqevym.js";
54
+ import"../shared/@ai-setting/roy-agent-core-zvwdfm79.js";
55
55
  import"../shared/@ai-setting/roy-agent-core-44g3synv.js";
56
56
  import"../shared/@ai-setting/roy-agent-core-zdzkzx5g.js";
57
- import"../shared/@ai-setting/roy-agent-core-4djnmd86.js";
57
+ import"../shared/@ai-setting/roy-agent-core-skqt40yy.js";
58
58
  import"../shared/@ai-setting/roy-agent-core-c1v263jn.js";
59
- import"../shared/@ai-setting/roy-agent-core-tycbpm17.js";
59
+ import"../shared/@ai-setting/roy-agent-core-fntxq0gf.js";
60
60
  import {
61
61
  XDG_PATHS,
62
62
  getXDGPath,
@@ -71,9 +71,9 @@ import {
71
71
  import"../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
72
72
  import"../shared/@ai-setting/roy-agent-core-fnv3ev18.js";
73
73
  import"../shared/@ai-setting/roy-agent-core-mdp8y7ky.js";
74
- import"../shared/@ai-setting/roy-agent-core-bqe4c9f2.js";
74
+ import"../shared/@ai-setting/roy-agent-core-kr58bgz0.js";
75
75
  import"../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
76
- import"../shared/@ai-setting/roy-agent-core-zs4f0tcy.js";
76
+ import"../shared/@ai-setting/roy-agent-core-xjj88tpn.js";
77
77
  import"../shared/@ai-setting/roy-agent-core-7r72622v.js";
78
78
  import"../shared/@ai-setting/roy-agent-core-e0kaxcy1.js";
79
79
  import"../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
@@ -3,8 +3,8 @@ import {
3
3
  PromptConfigSchema,
4
4
  PromptPathSchema,
5
5
  PromptRenderer
6
- } from "../../shared/@ai-setting/roy-agent-core-5ka95kh7.js";
7
- import"../../shared/@ai-setting/roy-agent-core-4djnmd86.js";
6
+ } from "../../shared/@ai-setting/roy-agent-core-ett06sn8.js";
7
+ import"../../shared/@ai-setting/roy-agent-core-skqt40yy.js";
8
8
  import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
9
9
  import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
10
10
  import"../../shared/@ai-setting/roy-agent-core-akb8mb9v.js";
@@ -3,11 +3,11 @@ import {
3
3
  MIN_SESSION_ID_LENGTH,
4
4
  SessionComponent,
5
5
  isValidSessionId
6
- } from "../../shared/@ai-setting/roy-agent-core-bqe4c9f2.js";
6
+ } from "../../shared/@ai-setting/roy-agent-core-kr58bgz0.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-zs4f0tcy.js";
10
+ } from "../../shared/@ai-setting/roy-agent-core-xjj88tpn.js";
11
11
  import {
12
12
  SessionMessageConverter
13
13
  } from "../../shared/@ai-setting/roy-agent-core-7r72622v.js";
@@ -3,7 +3,7 @@ import {
3
3
  SQLiteSessionStore,
4
4
  getDefaultDataDir,
5
5
  getDefaultSessionDbPath
6
- } from "../../../shared/@ai-setting/roy-agent-core-zs4f0tcy.js";
6
+ } from "../../../shared/@ai-setting/roy-agent-core-xjj88tpn.js";
7
7
  import"../../../shared/@ai-setting/roy-agent-core-7r72622v.js";
8
8
  import"../../../shared/@ai-setting/roy-agent-core-e0kaxcy1.js";
9
9
  import"../../../shared/@ai-setting/roy-agent-core-nna4s0qs.js";
@@ -3,11 +3,11 @@ import {
3
3
  BackgroundTaskManager,
4
4
  createDelegateTool,
5
5
  createStopTool
6
- } from "../../../shared/@ai-setting/roy-agent-core-mqeqevym.js";
6
+ } from "../../../shared/@ai-setting/roy-agent-core-zvwdfm79.js";
7
7
  import"../../../shared/@ai-setting/roy-agent-core-44g3synv.js";
8
- import"../../../shared/@ai-setting/roy-agent-core-4djnmd86.js";
8
+ import"../../../shared/@ai-setting/roy-agent-core-skqt40yy.js";
9
9
  import"../../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
10
- import"../../../shared/@ai-setting/roy-agent-core-tycbpm17.js";
10
+ import"../../../shared/@ai-setting/roy-agent-core-fntxq0gf.js";
11
11
  import"../../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
12
12
  import"../../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
13
13
  import"../../../shared/@ai-setting/roy-agent-core-vc7p80sd.js";
@@ -5,20 +5,20 @@ import {
5
5
  TaskPriorityEnum,
6
6
  TaskStatusEnum,
7
7
  TaskTypeEnum
8
- } from "../../shared/@ai-setting/roy-agent-core-5kc9qtej.js";
8
+ } from "../../shared/@ai-setting/roy-agent-core-bb20se79.js";
9
9
  import"../../shared/@ai-setting/roy-agent-core-amkqnyzy.js";
10
10
  import {
11
11
  TaskEntityEventTypes
12
12
  } from "../../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
13
- import"../../shared/@ai-setting/roy-agent-core-mqeqevym.js";
13
+ import"../../shared/@ai-setting/roy-agent-core-zvwdfm79.js";
14
14
  import"../../shared/@ai-setting/roy-agent-core-44g3synv.js";
15
15
  import {
16
16
  SQLiteTaskStore,
17
17
  getDefaultTaskDbPath
18
18
  } from "../../shared/@ai-setting/roy-agent-core-zdzkzx5g.js";
19
- import"../../shared/@ai-setting/roy-agent-core-4djnmd86.js";
19
+ import"../../shared/@ai-setting/roy-agent-core-skqt40yy.js";
20
20
  import"../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
21
- import"../../shared/@ai-setting/roy-agent-core-tycbpm17.js";
21
+ import"../../shared/@ai-setting/roy-agent-core-fntxq0gf.js";
22
22
  import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
23
23
  import"../../shared/@ai-setting/roy-agent-core-c7e3htaq.js";
24
24
  import"../../shared/@ai-setting/roy-agent-core-rn57psp0.js";
@@ -8,13 +8,13 @@ import {
8
8
  formatExtractorInput,
9
9
  formatExtractorInputFromDescription,
10
10
  parseExtractorOutput
11
- } from "../../../shared/@ai-setting/roy-agent-core-btp589bw.js";
11
+ } from "../../../shared/@ai-setting/roy-agent-core-grajzyhd.js";
12
12
  import"../../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
13
13
  import"../../../shared/@ai-setting/roy-agent-core-1mrc9a1r.js";
14
14
  import"../../../shared/@ai-setting/roy-agent-core-bq1gskrf.js";
15
15
  import"../../../shared/@ai-setting/roy-agent-core-jrj30vq3.js";
16
16
  import"../../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
17
- import"../../../shared/@ai-setting/roy-agent-core-4djnmd86.js";
17
+ import"../../../shared/@ai-setting/roy-agent-core-skqt40yy.js";
18
18
  import"../../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
19
19
  import"../../../shared/@ai-setting/roy-agent-core-sqt96sam.js";
20
20
  import"../../../shared/@ai-setting/roy-agent-core-dtkbj8fk.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  WorkflowComponent
3
- } from "../../shared/@ai-setting/roy-agent-core-mekk4as5.js";
3
+ } from "../../shared/@ai-setting/roy-agent-core-q06h6qf8.js";
4
4
  import"../../shared/@ai-setting/roy-agent-core-77wfej1h.js";
5
5
  import"../../shared/@ai-setting/roy-agent-core-f1cjs6c4.js";
6
6
  import"../../shared/@ai-setting/roy-agent-core-6atd905e.js";
@@ -9,7 +9,7 @@ import"../../shared/@ai-setting/roy-agent-core-ez91vxas.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-7kw06e4b.js";
12
- import"../../shared/@ai-setting/roy-agent-core-kkt2ndpf.js";
12
+ import"../../shared/@ai-setting/roy-agent-core-j8t1tyhr.js";
13
13
  import"../../shared/@ai-setting/roy-agent-core-1db4vpc6.js";
14
14
  import"../../shared/@ai-setting/roy-agent-core-r15sn7ve.js";
15
15
  import"../../shared/@ai-setting/roy-agent-core-1mrc9a1r.js";
@@ -84,9 +84,9 @@ 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-bqe4c9f2.js";
87
+ import"../../shared/@ai-setting/roy-agent-core-kr58bgz0.js";
88
88
  import"../../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
89
- import"../../shared/@ai-setting/roy-agent-core-zs4f0tcy.js";
89
+ import"../../shared/@ai-setting/roy-agent-core-xjj88tpn.js";
90
90
  import"../../shared/@ai-setting/roy-agent-core-7r72622v.js";
91
91
  import"../../shared/@ai-setting/roy-agent-core-e0kaxcy1.js";
92
92
  import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
@@ -24,7 +24,7 @@ import {
24
24
  getRunWorkflowTool,
25
25
  initRunWorkflowTool,
26
26
  resetRunWorkflowTool
27
- } from "../../../shared/@ai-setting/roy-agent-core-kkt2ndpf.js";
27
+ } from "../../../shared/@ai-setting/roy-agent-core-j8t1tyhr.js";
28
28
  import {
29
29
  WORKFLOW_SUBMIT_OUTPUT_TOOL_NAME,
30
30
  WorkflowJsonOutputMarker,
@@ -38,9 +38,9 @@ import"../../../shared/@ai-setting/roy-agent-core-bq1gskrf.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-bqe4c9f2.js";
41
+ import"../../../shared/@ai-setting/roy-agent-core-kr58bgz0.js";
42
42
  import"../../../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
43
- import"../../../shared/@ai-setting/roy-agent-core-zs4f0tcy.js";
43
+ import"../../../shared/@ai-setting/roy-agent-core-xjj88tpn.js";
44
44
  import"../../../shared/@ai-setting/roy-agent-core-7r72622v.js";
45
45
  import"../../../shared/@ai-setting/roy-agent-core-e0kaxcy1.js";
46
46
  import"../../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PromptComponent,
3
3
  PromptStore
4
- } from "./shared/@ai-setting/roy-agent-core-5ka95kh7.js";
4
+ } from "./shared/@ai-setting/roy-agent-core-ett06sn8.js";
5
5
  import {
6
6
  LLMComponent,
7
7
  LLMConfigSchema,
@@ -63,7 +63,7 @@ import {
63
63
  BaseEnvironment,
64
64
  generateDescendingId,
65
65
  generateId
66
- } from "./shared/@ai-setting/roy-agent-core-m0wy7p0q.js";
66
+ } from "./shared/@ai-setting/roy-agent-core-b9q2jfx4.js";
67
67
  import {
68
68
  BountyIMInstance,
69
69
  EventSourceComponent,
@@ -76,7 +76,7 @@ import {
76
76
  larkCliHandler,
77
77
  resolveBountyIMSystemPrompt,
78
78
  timerHandler
79
- } from "./shared/@ai-setting/roy-agent-core-8wd5awxg.js";
79
+ } from "./shared/@ai-setting/roy-agent-core-bwqjwa0d.js";
80
80
  import {
81
81
  BUILT_IN_EVENT_SOURCE_TYPES,
82
82
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
@@ -96,13 +96,13 @@ import {
96
96
  import {
97
97
  TaskTagPlugin,
98
98
  createAutoTaskPlugin
99
- } from "./shared/@ai-setting/roy-agent-core-btp589bw.js";
99
+ } from "./shared/@ai-setting/roy-agent-core-grajzyhd.js";
100
100
  import {
101
101
  BasePlugin
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-mekk4as5.js";
105
+ } from "./shared/@ai-setting/roy-agent-core-q06h6qf8.js";
106
106
  import {
107
107
  init_node_registry_helper,
108
108
  registerDecoratorNodeType
@@ -114,7 +114,7 @@ import"./shared/@ai-setting/roy-agent-core-ez91vxas.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-7kw06e4b.js";
117
- import"./shared/@ai-setting/roy-agent-core-kkt2ndpf.js";
117
+ import"./shared/@ai-setting/roy-agent-core-j8t1tyhr.js";
118
118
  import"./shared/@ai-setting/roy-agent-core-1db4vpc6.js";
119
119
  import"./shared/@ai-setting/roy-agent-core-r15sn7ve.js";
120
120
  import"./shared/@ai-setting/roy-agent-core-1mrc9a1r.js";
@@ -131,7 +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-qyb2z42s.js";
134
+ } from "./shared/@ai-setting/roy-agent-core-zeztnvvb.js";
135
135
  import {
136
136
  createInvokeConfig,
137
137
  invoke,
@@ -150,10 +150,10 @@ import {
150
150
  } from "./shared/@ai-setting/roy-agent-core-e25xkv53.js";
151
151
  import {
152
152
  TaskComponent
153
- } from "./shared/@ai-setting/roy-agent-core-5kc9qtej.js";
153
+ } from "./shared/@ai-setting/roy-agent-core-bb20se79.js";
154
154
  import"./shared/@ai-setting/roy-agent-core-amkqnyzy.js";
155
155
  import"./shared/@ai-setting/roy-agent-core-8gxth0eh.js";
156
- import"./shared/@ai-setting/roy-agent-core-mqeqevym.js";
156
+ import"./shared/@ai-setting/roy-agent-core-zvwdfm79.js";
157
157
  import"./shared/@ai-setting/roy-agent-core-44g3synv.js";
158
158
  import {
159
159
  SQLiteTaskStore,
@@ -162,11 +162,11 @@ import {
162
162
  import {
163
163
  getBuiltInPrompt,
164
164
  getBuiltInPromptNames
165
- } from "./shared/@ai-setting/roy-agent-core-4djnmd86.js";
165
+ } from "./shared/@ai-setting/roy-agent-core-skqt40yy.js";
166
166
  import"./shared/@ai-setting/roy-agent-core-c1v263jn.js";
167
167
  import {
168
168
  AgentRegistry
169
- } from "./shared/@ai-setting/roy-agent-core-tycbpm17.js";
169
+ } from "./shared/@ai-setting/roy-agent-core-fntxq0gf.js";
170
170
  import {
171
171
  XDG_PATHS,
172
172
  getXDGPath,
@@ -199,11 +199,11 @@ import"./shared/@ai-setting/roy-agent-core-fnv3ev18.js";
199
199
  import"./shared/@ai-setting/roy-agent-core-mdp8y7ky.js";
200
200
  import {
201
201
  SessionComponent
202
- } from "./shared/@ai-setting/roy-agent-core-bqe4c9f2.js";
202
+ } from "./shared/@ai-setting/roy-agent-core-kr58bgz0.js";
203
203
  import"./shared/@ai-setting/roy-agent-core-rvxg1wps.js";
204
204
  import {
205
205
  MemorySessionStore
206
- } from "./shared/@ai-setting/roy-agent-core-zs4f0tcy.js";
206
+ } from "./shared/@ai-setting/roy-agent-core-xjj88tpn.js";
207
207
  import"./shared/@ai-setting/roy-agent-core-7r72622v.js";
208
208
  import"./shared/@ai-setting/roy-agent-core-e0kaxcy1.js";
209
209
  import"./shared/@ai-setting/roy-agent-core-7hh0brvs.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createAutoTaskPlugin
3
- } from "./roy-agent-core-btp589bw.js";
3
+ } from "./roy-agent-core-grajzyhd.js";
4
4
  import {
5
5
  ContextError,
6
6
  ErrorCodes
@@ -8,7 +8,7 @@ import {
8
8
  BackgroundTaskManager,
9
9
  createDelegateTool,
10
10
  createStopTool
11
- } from "./roy-agent-core-mqeqevym.js";
11
+ } from "./roy-agent-core-zvwdfm79.js";
12
12
  import {
13
13
  SQLiteTaskStore,
14
14
  getDefaultTaskDbPath
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  TaskTagPlugin,
3
3
  createLarkCliTaskNotifyHook
4
- } from "./roy-agent-core-btp589bw.js";
4
+ } from "./roy-agent-core-grajzyhd.js";
5
5
  import {
6
6
  envKeyToConfigKey
7
7
  } from "./roy-agent-core-7hh0brvs.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  builtInPrompts
3
- } from "./roy-agent-core-4djnmd86.js";
3
+ } from "./roy-agent-core-skqt40yy.js";
4
4
  import {
5
5
  getXDGPath
6
6
  } from "./roy-agent-core-qxnbvgwe.js";
@@ -165,7 +165,7 @@ class AgentRegistry {
165
165
  const agent = {
166
166
  name,
167
167
  type: "sub",
168
- description: "Workflow runner — 负责调用 workflow_run 启动 workflow,支持 session resume 和 stop;失败接管由 prompt 推理触发 (Task #2251 简化版)。",
168
+ description: "Workflow runner — 接受带 workflow_name(必填)的委托,或指示其按 search-first 流程自行选定(workflow_tag_list + workflow_search + workflow_list + workflow_get),然后通过 workflow_run 执行 workflow;支持 session resume 和 stop;失败接管由 prompt 推理触发 (Task #2251)。**调用方必须在 prompt 中明确指定 workflow 名,或指示 sub-agent 自行搜索选择;禁止盲猜/绕过/跳过 schema 验证** (Task #2486)。",
169
169
  systemPromptRef: "workflow-runner",
170
170
  deniedTools: ["delegate_task", "stop_task"],
171
171
  maxIterations: 30
@@ -6,7 +6,7 @@ import {
6
6
  } from "./roy-agent-core-1mrc9a1r.js";
7
7
  import {
8
8
  WORKFLOW_EXTRACT_PROMPT
9
- } from "./roy-agent-core-4djnmd86.js";
9
+ } from "./roy-agent-core-skqt40yy.js";
10
10
  import {
11
11
  TaskHookPoints
12
12
  } from "./roy-agent-core-1pg0fepg.js";
@@ -14,7 +14,7 @@ import {
14
14
  } from "./roy-agent-core-c1v263jn.js";
15
15
  import {
16
16
  isValidSessionId
17
- } from "./roy-agent-core-bqe4c9f2.js";
17
+ } from "./roy-agent-core-kr58bgz0.js";
18
18
  import {
19
19
  TracedAs,
20
20
  init_decorator
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  MemorySessionStore,
8
8
  SQLiteSessionStore
9
- } from "./roy-agent-core-zs4f0tcy.js";
9
+ } from "./roy-agent-core-xjj88tpn.js";
10
10
  import {
11
11
  envKeyToConfigKey
12
12
  } from "./roy-agent-core-7hh0brvs.js";
@@ -664,6 +664,14 @@ class SessionComponent extends BaseComponent {
664
664
  }
665
665
  return success;
666
666
  }
667
+ async endSessionCleanup(sessionId, opts) {
668
+ const store = this.store;
669
+ if (typeof store?.endSessionCleanup === "function") {
670
+ await store.endSessionCleanup(sessionId, opts);
671
+ } else {
672
+ logger.debug(`[SessionComponent] endSessionCleanup skipped: store type ${this.config?.storage?.type ?? "unknown"} 不实现该方法`);
673
+ }
674
+ }
667
675
  async getContext(sessionId, options) {
668
676
  const session = await this.get(sessionId);
669
677
  if (!session) {
@@ -18,7 +18,7 @@ import {
18
18
  createWorkflowSearchTool,
19
19
  createWorkflowTagListTool,
20
20
  createWorkflowValidateTool
21
- } from "./roy-agent-core-kkt2ndpf.js";
21
+ } from "./roy-agent-core-j8t1tyhr.js";
22
22
  import {
23
23
  WorkflowService
24
24
  } from "./roy-agent-core-r15sn7ve.js";
@@ -110,6 +110,10 @@ var builtInPrompts = {
110
110
 
111
111
  ## 子智能体选择策略
112
112
 
113
+ **核心铁律**:选了某个 subagent 后,必须**遵循该 subagent 的工作模式**——把任务用它的 prompt 模板、工具集和决策路径表达,**不能用自己的方式硬塞**。
114
+
115
+ > \uD83D\uDCA1 **典型例子**:选 \`workflow-runner\` 时,prompt 必须**明确指定 workflow 名**(让 sub-agent 直接 \`workflow_run\`)**或**让 sub-agent **先 \`workflow_search\` / \`workflow_list\` / \`workflow_get\` 自行选定**——不要让 sub-agent 替你做不属于它的决策(如 \`workflow_creat\`)。
116
+
113
117
  你有多类子智能体。**默认首次委托使用 \`roy\`**。**调用 workflow 解决的任务,委托给 \`workflow-runner\`**(兼容语法:\`strict-task-agent\` / \`code-review\` / \`bench-agent-host\` / \`workspace-analyzer\` / \`test-workflow-agent\` 等旧名仍可用,会被自动重写)。
114
118
 
115
119
  ### \uD83E\uDD47 首选:\`roy\`(首次委托默认)
@@ -147,15 +151,34 @@ delegate_task(
147
151
  - **安全关键型变更** — 验证不可妥协
148
152
  - **代码审查/审计** — 需要系统性对照目标进行检查
149
153
 
150
- 使用:
154
+ #### 两种合法委托模式(**workflow_name 必传 / search-first 二选一**)
155
+
156
+ \`workflow-runner\` 的 \`<workflow_name>\` 是它的第一铁律(参见 \`workflow-runner\` prompt 的"## ⚠️ workflow_name 处理规则")。委托时必须在 prompt 里:
157
+
158
+ - **模式 A — 传具体 workflow_name**(首选):你已经知道该跑哪个 workflow,直接在 prompt 中指定名字,sub-agent 直接 \`workflow_get(name)\` → \`workflow_run\`。
159
+ - **模式 B — search-first 兜底**:你只知道任务目标但不确定 workflow 名,指示 sub-agent 自行 \`workflow_tag_list\` + \`workflow_search\` + \`workflow_list\` + \`workflow_get\` 选定再 \`workflow_run\`。
160
+
161
+ **禁止**:让 sub-agent 猜 workflow_name、绕过 workflow 自己完成任务、或跳过 schema 验证。
162
+
163
+ #### 模式 A 示例 — 传具体 workflow_name
164
+
151
165
  \`\`\`
152
166
  delegate_task(
153
- description="简要 3-5 字摘要",
154
- prompt="详细说明。
167
+ description="执行 strict-task-agent workflow",
168
+ prompt="调用 workflow_run 执行 workflow strict-task-agent,任务是修复 roy-rd-with-trace 中的 X bug。",
169
+ subagent_type="workflow-runner",
170
+ similar_task_ids=[]
171
+ )
172
+ \`\`\`
155
173
 
156
- 重要:遵循任务作为一等公民原则 使用 \`task_create\` 创建任务,使用 \`task_update\` 跟踪进度,使用 \`task_operation_create\` 记录里程碑,并使用 \`task_complete\` 完成任务。",
157
- subagent_type="workflow-runner", prompt="运行 workflow strict-task-agent,任务是..."
158
- similar_task_ids=[] // 必填:先使用 task_search 搜索相似任务,将找到的 ID 填入此处(最多 3 个)
174
+ #### 模式 B 示例 search-first 兜底
175
+
176
+ \`\`\`
177
+ delegate_task(
178
+ description="寻找并执行合适的 workflow",
179
+ prompt="用户目标:批量跑 stock 筛选分析。请按 workflow-runner 的 search-first 流程:先 \`workflow_tag_list\` + \`workflow_search --keyword stock\` + \`workflow_list\` 找到匹配的 workflow,再 \`workflow_get <name>\` 验证 schema,最后 \`workflow_run <name>\` 执行。不要猜测 workflow 名。",
180
+ subagent_type="workflow-runner",
181
+ similar_task_ids=[]
159
182
  )
160
183
  \`\`\`
161
184
 
@@ -379,13 +402,22 @@ const status = await query_background_process({ bgProcessId: result.bgProcessId
379
402
 
380
403
  Workflow 是预定义的自动化流程,可以高效解决常见类型的任务。**Default agent 自身不应直接 bash 跑 workflow**——所有 workflow 调用必须通过 \`delegate_task\` 委托给 \`workflow-runner\` 子智能体执行。
381
404
 
405
+ ### ⚠️ 委托时 workflow_name 必传 / search-first 二选一(Task #2486)
406
+
407
+ \`workflow-runner\` 的 \`<workflow_name>\` 是它的**第一铁律**(详见 \`workflow-runner\` prompt "## ⚠️ workflow_name 处理规则")。**Default agent 在委托时必须**:
408
+
409
+ - **指定 workflow 名** — prompt 里明确写出 \`运行 workflow <workflow-name>\`,sub-agent 直接 \`workflow_get(name)\` → \`workflow_run\`。
410
+ - **或指示 sub-agent 自行搜索** — prompt 里说"按 search-first 流程:先 \`workflow_tag_list\` + \`workflow_search\` + \`workflow_list\` + \`workflow_get\` 选定再执行",让 sub-agent 自决。
411
+
412
+ **绝对禁止**:让 sub-agent 猜 workflow 名 / 绕过 workflow / 跳过 schema 验证。
413
+
382
414
  ### 如何通过 \`delegate_task\` 调用 workflow(标准路径)
383
415
 
384
416
  1. **查 tag 发现可用 workflow**:\`workflow tag list\` — 查看 tag 池,找与任务领域匹配的 tag
385
417
  2. **按 tag 搜索 workflow**:\`workflow list --tag <tag>\` — 找到相关的 workflow
386
418
  3. **按关键词搜索**:\`workflow search --keyword <key>\` — 用关键词匹配
387
419
  4. **查看详情**:\`workflow get <name>\` — 了解 workflow 的输入参数和节点流程
388
- 5. **委托 \`workflow-runner\` 执行**:用下列模板派发
420
+ 5. **委托 \`workflow-runner\` 执行**:用下列模板派发(workflow_name 由 default agent 自己查好后填入,或改成"按 search-first 流程自行选定")
389
421
 
390
422
  \`\`\`text
391
423
  delegate_task(
@@ -394,6 +426,14 @@ delegate_task(
394
426
  )
395
427
  \`\`\`
396
428
 
429
+ **search-first 替代模板**(当你不确定 workflow 名时):
430
+ \`\`\`text
431
+ delegate_task(
432
+ subagent_type="workflow-runner",
433
+ prompt="按 search-first 流程执行:先 \`workflow_tag_list\` + \`workflow_search --keyword <key>\` + \`workflow_list\` 找到匹配 workflow,再 \`workflow_get <name>\` 验证 schema,最后 \`workflow_run <name>\` 执行。"
434
+ )
435
+ \`\`\`
436
+
397
437
  > \uD83D\uDCA1 **什么时候该用 workflow?**
398
438
  > - ✅ 你的任务与现有 workflow 的 tag 或描述高度匹配时 → 委托 \`workflow-runner\` 执行
399
439
  > - ✅ 现有 workflow 可以作为参考模板 → 参考其设计自行实现
@@ -1111,6 +1151,36 @@ When reusing an existing task, you MUST follow these rules:
1111
1151
 
1112
1152
  workflow 名必须从 \`<workflow_name>\` 标签读取,不得根据上下文猜测。
1113
1153
 
1154
+ ## ⚠️ workflow_name 处理规则(关键 — Task #2486)
1155
+
1156
+ **这是 workflow-runner 的第一铁律。** 在调用任何 \`workflow_run\` 之前,**必须**确认 workflow 名是真实、确定的。
1157
+
1158
+ ### 三种合法情况
1159
+
1160
+ | 情况 | 判定 | 第一步动作 |
1161
+ |---|---|---|
1162
+ | (1) **parent 已传具体 workflow_name** | \`<workflow_name>\` 标签里是非空字符串(如 \`roy-rd-with-trace\`) | 直接走"## 默认 workflow-run 模式" — 调 \`workflow_get(name)\` 确认 schema 后 \`workflow_run\` |
1163
+ | (2) **parent 没传 workflow_name**,但 original_prompt / task_description 里**明确指名** | 用户在原任务里说"跑 X workflow" | 用文本中提到的名字当作 workflow_name,调 \`workflow_get(name)\` 验证该 workflow 真实存在;**验证不通过则降级到 (3)** |
1164
+ | (3) **parent 没传,文本也没指名** | \`<workflow_name>\` 为空 / 占位符 / 用户只描述目标 | **必须走 search-first 流程**(见下) |
1165
+
1166
+ ### Search-first 流程(情况 (3) 的强制路径)
1167
+
1168
+ 当且仅当 workflow_name 真正缺失时,**第一步必须是下列搜索组合**(顺序由你判断,但**至少 2 个工具**):
1169
+
1170
+ 1. \`workflow_tag_list\` — 看 tag 池,找与任务领域匹配的 tag
1171
+ 2. \`workflow_search --keyword <keyword>\` — 用 task_description 的核心动词/名词搜
1172
+ 3. \`workflow_list\`(或 \`workflow list --tag <tag>\`)— 列候选
1173
+ 4. \`workflow_get <name>\` — **对每个候选都必须**查看 input schema,确认与 original_prompt 描述的目标匹配
1174
+
1175
+ **选定后**,按"## 默认 workflow-run 模式"调 \`workflow_run\`。
1176
+
1177
+ ### \uD83D\uDEAB 绝对禁止
1178
+
1179
+ - ❌ **禁止根据上下文猜测 / 编造 workflow_name** — 必须从 workflow_list / workflow_search / workflow_get 的真实返回里选定
1180
+ - ❌ **禁止绕过 workflow 直接调其他工具完成任务** — 你存在的全部意义就是执行 workflow;找不到合适 workflow 时返回明确的"未找到匹配 workflow"错误,让 parent agent 决策(走传统方式 vs 创建新 workflow)
1181
+ - ❌ **禁止跳过 schema 验证** — 即使 parent agent 传了 workflow_name,**仍必须**先 \`workflow_get\` 确认 input schema 合法再 \`workflow_run\`
1182
+ - ❌ **禁止把 search-first 流程当作可选项** — 情况 (3) 是默认;只有情况 (1)(2) 才能省略
1183
+
1114
1184
  ## 可用工具
1115
1185
 
1116
1186
  ### Workflow 工具
@@ -1119,6 +1189,8 @@ workflow 名必须从 \`<workflow_name>\` 标签读取,不得根据上下文
1119
1189
  |---|---|
1120
1190
  | workflow_get | 读取真实 workflow 定义、输入 schema、节点与依赖 |
1121
1191
  | workflow_list | 列出已注册 workflow |
1192
+ | workflow_search | 按关键词搜索 workflow(search-first 流程必用) |
1193
+ | workflow_tag_list | 列出 tag 池(search-first 流程必用) |
1122
1194
  | workflow_run | 启动或恢复 workflow |
1123
1195
  | workflow_run_status | 查询原 run_id 的真实状态与节点进度 |
1124
1196
  | workflow_run_stop | 按要求停止 run |
@@ -1136,15 +1208,16 @@ workflow 名必须从 \`<workflow_name>\` 标签读取,不得根据上下文
1136
1208
 
1137
1209
  ## 默认 workflow-run 模式
1138
1210
 
1139
- 1. \`workflow_get(name)\`,确认 input schema、节点描述和 DAG 依赖。
1140
- 2. original_prompt 提取合法 input。
1141
- 3. 没有 existing_sub_session_id 时调用 fresh \`workflow_run\`;有该 ID 时先调
1211
+ 1. **再次确认 workflow_name 已通过 search-first 流程选定**(参见"## ⚠️ workflow_name 处理规则")。
1212
+ 2. \`workflow_get(name)\`,确认 input schema、节点描述和 DAG 依赖。
1213
+ 3. original_prompt 提取合法 input。
1214
+ 4. 没有 existing_sub_session_id 时调用 fresh \`workflow_run\`;有该 ID 时先调
1142
1215
  \`workflow_run_status(run_id)\`,再以同一 ID 作为 session 恢复。runId == sessionId。
1143
1216
 
1144
1217
  Copy-paste CLI 示例:
1145
1218
  \`roy-agent workflow run roy-rd-with-trace -s workflow_run_1783407282099_1_ah8pho\`
1146
- 4. 对 \`completed\` / \`paused\` 返回真实 output;对 \`running\` / \`stopped\` 按真实状态报告。
1147
- 5. 对每次 \`failed\` / \`timeout\`,扫描你自己最近的 workflow_run tool results,推理连续失败次数。
1219
+ 5. 对 \`completed\` / \`paused\` 返回真实 output;对 \`running\` / \`stopped\` 按真实状态报告。
1220
+ 6. 对每次 \`failed\` / \`timeout\`,扫描你自己最近的 workflow_run tool results,推理连续失败次数。
1148
1221
 
1149
1222
  ## 连续 2 次失败阈值(由 LLM 自行推理)
1150
1223
 
@@ -32,10 +32,24 @@ function generateMessageId() {
32
32
  }
33
33
 
34
34
  class MemorySessionStore extends BaseSessionStore {
35
+ maxMessagesPerSession;
36
+ maxCheckpointsPerSession;
37
+ defaultKeepAllMessagesUntilCompaction;
35
38
  sessions = new Map;
36
39
  messages = new Map;
37
40
  checkpoints = new Map;
38
41
  messageConverter = new SessionMessageConverter;
42
+ constructor(options = {}) {
43
+ super();
44
+ this.maxMessagesPerSession = options.maxMessagesPerSession ?? 1e4;
45
+ this.maxCheckpointsPerSession = options.maxCheckpointsPerSession ?? 1000;
46
+ this.defaultKeepAllMessagesUntilCompaction = options.keepAllMessagesUntilCompaction ?? true;
47
+ }
48
+ trimMessages(messages) {
49
+ if (messages.length > this.maxMessagesPerSession) {
50
+ messages.splice(0, messages.length - this.maxMessagesPerSession);
51
+ }
52
+ }
39
53
  async create(options) {
40
54
  const now = Date.now();
41
55
  const rawParent = options.parentSessionId !== undefined ? options.parentSessionId : options.parentID ?? null;
@@ -126,6 +140,7 @@ class MemorySessionStore extends BaseSessionStore {
126
140
  if (deleted) {
127
141
  this.messages.delete(id);
128
142
  this.checkpoints.delete(id);
143
+ this.messageTruncOffsets.delete(id);
129
144
  }
130
145
  return deleted;
131
146
  }
@@ -149,6 +164,7 @@ class MemorySessionStore extends BaseSessionStore {
149
164
  msg.timestamp = Date.now();
150
165
  const sessionMessages = this.messages.get(sessionId) ?? [];
151
166
  sessionMessages.push(msg);
167
+ this.trimMessages(sessionMessages);
152
168
  this.messages.set(sessionId, sessionMessages);
153
169
  session.messageCount = sessionMessages.filter((m) => !m.isArchived).length;
154
170
  session.metadata = {
@@ -183,6 +199,7 @@ class MemorySessionStore extends BaseSessionStore {
183
199
  sessionMessages.push(msg);
184
200
  ids.push(msg.id);
185
201
  }
202
+ this.trimMessages(sessionMessages);
186
203
  this.messages.set(sessionId, sessionMessages);
187
204
  session.messageCount = sessionMessages.filter((m) => !m.isArchived).length;
188
205
  session.metadata = {
@@ -262,6 +279,13 @@ class MemorySessionStore extends BaseSessionStore {
262
279
  }
263
280
  const cps = this.checkpoints.get(sessionId) ?? [];
264
281
  cps.push(checkpoint);
282
+ let droppedCheckpoints = [];
283
+ if (cps.length > this.maxCheckpointsPerSession) {
284
+ droppedCheckpoints = cps.splice(0, cps.length - this.maxCheckpointsPerSession);
285
+ }
286
+ if (!this.defaultKeepAllMessagesUntilCompaction && cps.length > 1) {
287
+ droppedCheckpoints = droppedCheckpoints.concat(cps.splice(0, cps.length - 1));
288
+ }
265
289
  this.checkpoints.set(sessionId, cps);
266
290
  const meta = session.metadata || {};
267
291
  const checkpointsMeta = meta.checkpoints || { checkpoints: [] };
@@ -272,13 +296,115 @@ class MemorySessionStore extends BaseSessionStore {
272
296
  createdAt: checkpoint.createdAt,
273
297
  type: checkpoint.type
274
298
  });
275
- checkpointsMeta.latestCheckpointId = checkpoint.id;
299
+ if (droppedCheckpoints.length > 0) {
300
+ const droppedIds = new Set(droppedCheckpoints.map((c) => c.id));
301
+ checkpointsMeta.checkpoints = checkpointsMeta.checkpoints.filter((c) => !droppedIds.has(c.id));
302
+ if (meta.checkpointDetails) {
303
+ for (const id of droppedIds) {
304
+ delete meta.checkpointDetails[id];
305
+ }
306
+ }
307
+ }
308
+ checkpointsMeta.latestCheckpointId = cps[cps.length - 1]?.id ?? checkpoint.id;
276
309
  meta.checkpoints = checkpointsMeta;
277
310
  if (!meta.checkpointDetails) {
278
311
  meta.checkpointDetails = {};
279
312
  }
280
313
  meta.checkpointDetails[checkpoint.id] = checkpoint;
281
314
  session.metadata = meta;
315
+ if (!this.defaultKeepAllMessagesUntilCompaction && cps.length > 0) {
316
+ const latest = cps[cps.length - 1];
317
+ this.truncateMessagesBeforeIndex(sessionId, latest.messageIndex);
318
+ const sessionMessages = this.messages.get(sessionId) ?? [];
319
+ session.messageCount = sessionMessages.filter((m) => !m.isArchived).length;
320
+ session.metadata = {
321
+ ...session.metadata,
322
+ messageCount: session.messageCount
323
+ };
324
+ }
325
+ session.updatedAt = Date.now();
326
+ }
327
+ messageTruncOffsets = new Map;
328
+ truncateMessagesBeforeIndex(sessionId, originalBeforeIndex) {
329
+ const sessionMessages = this.messages.get(sessionId);
330
+ if (!sessionMessages || sessionMessages.length === 0)
331
+ return;
332
+ const offset = this.messageTruncOffsets.get(sessionId) ?? 0;
333
+ const adjustedIndex = originalBeforeIndex - offset;
334
+ if (adjustedIndex <= 0) {
335
+ return;
336
+ }
337
+ if (adjustedIndex >= sessionMessages.length) {
338
+ return;
339
+ }
340
+ sessionMessages.splice(0, adjustedIndex);
341
+ this.messageTruncOffsets.set(sessionId, offset + adjustedIndex);
342
+ this.messages.set(sessionId, sessionMessages);
343
+ const cps = this.checkpoints.get(sessionId);
344
+ if (cps) {
345
+ for (const cp of cps) {
346
+ cp.messageIndex = Math.max(0, cp.messageIndex - adjustedIndex);
347
+ }
348
+ }
349
+ const session = this.sessions.get(sessionId);
350
+ if (session) {
351
+ const meta = session.metadata;
352
+ if (meta) {
353
+ const checkpointsMeta = meta.checkpoints;
354
+ if (checkpointsMeta?.checkpoints) {
355
+ for (const cm of checkpointsMeta.checkpoints) {
356
+ cm.messageIndex = Math.max(0, cm.messageIndex - adjustedIndex);
357
+ }
358
+ }
359
+ if (meta.checkpointDetails) {
360
+ const details = meta.checkpointDetails;
361
+ for (const id in details) {
362
+ details[id].messageIndex = Math.max(0, details[id].messageIndex - adjustedIndex);
363
+ }
364
+ }
365
+ }
366
+ }
367
+ }
368
+ async endSessionCleanup(sessionId, opts = {}) {
369
+ const session = this.sessions.get(sessionId);
370
+ if (!session) {
371
+ return;
372
+ }
373
+ const keepAllMessages = opts.keepAllMessagesUntilCompaction ?? this.defaultKeepAllMessagesUntilCompaction;
374
+ const keepLatest = Math.max(0, opts.keepLatestCheckpoints ?? 1);
375
+ const cps = this.checkpoints.get(sessionId) ?? [];
376
+ let droppedCheckpoints = [];
377
+ const targetCheckpointCap = keepAllMessages ? this.maxCheckpointsPerSession : keepLatest;
378
+ if (cps.length > targetCheckpointCap) {
379
+ droppedCheckpoints = cps.splice(0, cps.length - targetCheckpointCap);
380
+ }
381
+ this.checkpoints.set(sessionId, cps);
382
+ if (droppedCheckpoints.length > 0) {
383
+ const meta = session.metadata;
384
+ const droppedIds = new Set(droppedCheckpoints.map((c) => c.id));
385
+ const checkpointsMeta = meta.checkpoints ?? {
386
+ checkpoints: []
387
+ };
388
+ checkpointsMeta.checkpoints = checkpointsMeta.checkpoints.filter((c) => !droppedIds.has(c.id));
389
+ checkpointsMeta.latestCheckpointId = cps[cps.length - 1]?.id;
390
+ meta.checkpoints = checkpointsMeta;
391
+ if (meta.checkpointDetails) {
392
+ for (const id of droppedIds) {
393
+ delete meta.checkpointDetails[id];
394
+ }
395
+ }
396
+ session.metadata = meta;
397
+ }
398
+ if (!keepAllMessages && cps.length > 0) {
399
+ const latest = cps[cps.length - 1];
400
+ this.truncateMessagesBeforeIndex(sessionId, latest.messageIndex);
401
+ const sessionMessages = this.messages.get(sessionId) ?? [];
402
+ session.messageCount = sessionMessages.filter((m) => !m.isArchived).length;
403
+ session.metadata = {
404
+ ...session.metadata,
405
+ messageCount: session.messageCount
406
+ };
407
+ }
282
408
  session.updatedAt = Date.now();
283
409
  }
284
410
  async getCheckpoints(sessionId) {
@@ -420,6 +546,7 @@ class MemorySessionStore extends BaseSessionStore {
420
546
  this.sessions.clear();
421
547
  this.messages.clear();
422
548
  this.checkpoints.clear();
549
+ this.messageTruncOffsets.clear();
423
550
  }
424
551
  }
425
552
  // src/env/session/storage/sqlite.ts
@@ -10,7 +10,7 @@ import {
10
10
  } from "./roy-agent-core-e25xkv53.js";
11
11
  import {
12
12
  AgentRegistry
13
- } from "./roy-agent-core-tycbpm17.js";
13
+ } from "./roy-agent-core-fntxq0gf.js";
14
14
  import {
15
15
  ContextError
16
16
  } from "./roy-agent-core-ctdhjv68.js";
@@ -4,13 +4,13 @@ import {
4
4
  } from "./roy-agent-core-44g3synv.js";
5
5
  import {
6
6
  builtInPrompts
7
- } from "./roy-agent-core-4djnmd86.js";
7
+ } from "./roy-agent-core-skqt40yy.js";
8
8
  import {
9
9
  runWithBgTaskIdAsync
10
10
  } from "./roy-agent-core-c1v263jn.js";
11
11
  import {
12
12
  DEFAULT_SUBAGENT_PROMPT
13
- } from "./roy-agent-core-tycbpm17.js";
13
+ } from "./roy-agent-core-fntxq0gf.js";
14
14
  import {
15
15
  TaskHookPoints
16
16
  } from "./roy-agent-core-1pg0fepg.js";
@@ -896,7 +896,10 @@ var PROGRESS_INTERVAL = 1200000;
896
896
 
897
897
  class BackgroundTaskManager {
898
898
  env;
899
+ maxProcessRegistries = 1000;
900
+ maxTerminalTasks = 1000;
899
901
  tasks = new Map;
902
+ terminalTasks = new Map;
900
903
  abortControllers = new Map;
901
904
  progressTimers = new Map;
902
905
  processRegistries = new Map;
@@ -964,6 +967,52 @@ class BackgroundTaskManager {
964
967
  set.clear();
965
968
  return { runIds, stopResults };
966
969
  }
970
+ finalizeTask(taskId, reason) {
971
+ if (!taskId)
972
+ return;
973
+ this.stopProgressReporter(taskId);
974
+ this.progressTimers.delete(taskId);
975
+ const task = this.tasks.get(taskId);
976
+ if (task) {
977
+ this.tasks.delete(taskId);
978
+ if (this.terminalTasks.size >= this.maxTerminalTasks) {
979
+ const oldestKey = this.terminalTasks.keys().next().value;
980
+ if (oldestKey !== undefined) {
981
+ this.terminalTasks.delete(oldestKey);
982
+ }
983
+ }
984
+ this.terminalTasks.set(taskId, task);
985
+ }
986
+ const abortCtl = this.abortControllers.get(taskId);
987
+ if (abortCtl) {
988
+ try {
989
+ abortCtl.abort();
990
+ } catch {}
991
+ }
992
+ this.abortControllers.delete(taskId);
993
+ this.workflowRunRegistries.delete(taskId);
994
+ const registry = this.processRegistries.get(taskId);
995
+ if (registry && registry.size() > 0) {
996
+ logger3.debug(`[BackgroundTaskManager] finalizeTask保留 processRegistry ${taskId} (residualPIDs=${registry.size()}, reason=${reason})`);
997
+ }
998
+ logger3.debug(`[BackgroundTaskManager] finalizeTask taskId=${taskId} reason=${reason}`);
999
+ }
1000
+ getProcessRegistrySize() {
1001
+ return this.processRegistries.size;
1002
+ }
1003
+ getMaxProcessRegistries() {
1004
+ return this.maxProcessRegistries;
1005
+ }
1006
+ cleanupEmptyProcessRegistries() {
1007
+ let cleaned = 0;
1008
+ for (const [taskId, registry] of this.processRegistries) {
1009
+ if (registry.size() === 0) {
1010
+ this.processRegistries.delete(taskId);
1011
+ cleaned++;
1012
+ }
1013
+ }
1014
+ return cleaned;
1015
+ }
967
1016
  static DEFAULT_WORKFLOW_ENTRY_AGENT = "workflow-runner";
968
1017
  resolveEntryAgent(subagentType) {
969
1018
  try {
@@ -1074,6 +1123,12 @@ class BackgroundTaskManager {
1074
1123
  }
1075
1124
  }
1076
1125
  const abortController = new AbortController;
1126
+ if (this.processRegistries.size >= this.maxProcessRegistries) {
1127
+ this.cleanupEmptyProcessRegistries();
1128
+ if (this.processRegistries.size >= this.maxProcessRegistries) {
1129
+ throw new Error(`BackgroundTaskManager.processRegistries 达到上限 ${this.maxProcessRegistries}(含残留 PID),拒绝创建新 task(taskId=${taskIdGen})。请清理 / 重启 / 调高 maxProcessRegistries。`);
1130
+ }
1131
+ }
1077
1132
  const processRegistry = new ProcessRegistry;
1078
1133
  this.processRegistries.set(taskIdGen, processRegistry);
1079
1134
  const createdAt = Date.now();
@@ -1214,7 +1269,15 @@ class BackgroundTaskManager {
1214
1269
  error: errorMessage
1215
1270
  });
1216
1271
  } finally {
1217
- this.stopProgressReporter(taskId);
1272
+ this.finalizeTask(taskId, task.status);
1273
+ const sessionComp = this.getSessionComponent();
1274
+ if (sessionComp?.endSessionCleanup && task?.subSessionId) {
1275
+ try {
1276
+ await sessionComp.endSessionCleanup(task.subSessionId);
1277
+ } catch (err) {
1278
+ logger3.warn(`[BackgroundTaskManager] endSessionCleanup failed for ${task.subSessionId}`, { error: err instanceof Error ? err.message : String(err) });
1279
+ }
1280
+ }
1218
1281
  }
1219
1282
  }
1220
1283
  startProgressReporter(taskId, parentSessionId) {
@@ -1426,10 +1489,17 @@ ${reuseSection.markdown}`;
1426
1489
  });
1427
1490
  }
1428
1491
  async stopTask(taskId) {
1429
- const task = this.tasks.get(taskId);
1492
+ const task = this.tasks.get(taskId) ?? this.terminalTasks.get(taskId);
1430
1493
  if (!task) {
1431
1494
  return { success: false, message: "Task not found" };
1432
1495
  }
1496
+ if (this.terminalTasks.has(taskId)) {
1497
+ return {
1498
+ success: false,
1499
+ task,
1500
+ message: `Cannot stop task with status: ${task.status}`
1501
+ };
1502
+ }
1433
1503
  if (task.status === "completed" || task.status === "failed" || task.status === "stopped" || task.status === "timeout") {
1434
1504
  return {
1435
1505
  success: false,
@@ -1462,6 +1532,7 @@ ${reuseSection.markdown}`;
1462
1532
  associatedTaskId: task.associatedTaskId
1463
1533
  };
1464
1534
  this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, task.parentSessionId);
1535
+ this.finalizeTask(taskId, "stopped");
1465
1536
  return {
1466
1537
  success: true,
1467
1538
  task,
@@ -1471,10 +1542,10 @@ ${reuseSection.markdown}`;
1471
1542
  };
1472
1543
  }
1473
1544
  getTask(taskId) {
1474
- return this.tasks.get(taskId);
1545
+ return this.tasks.get(taskId) ?? this.terminalTasks.get(taskId);
1475
1546
  }
1476
1547
  listTasks() {
1477
- return Array.from(this.tasks.values());
1548
+ return Array.from(this.tasks.values()).concat(Array.from(this.terminalTasks.values()));
1478
1549
  }
1479
1550
  hasActiveTaskForParent(parentSessionId) {
1480
1551
  if (!parentSessionId)
@@ -1506,7 +1577,18 @@ ${reuseSection.markdown}`;
1506
1577
  return { stoppedTaskIds };
1507
1578
  }
1508
1579
  async forceStopAllAcrossParents() {
1509
- for (const [taskId, task] of this.tasks) {
1580
+ const seen = new Set;
1581
+ const allTaskIds = new Set([
1582
+ ...this.tasks.keys(),
1583
+ ...this.terminalTasks.keys(),
1584
+ ...this.processRegistries.keys()
1585
+ ]);
1586
+ for (const taskId of allTaskIds) {
1587
+ if (seen.has(taskId))
1588
+ continue;
1589
+ seen.add(taskId);
1590
+ const task = this.tasks.get(taskId) ?? this.terminalTasks.get(taskId);
1591
+ const taskSafe = task;
1510
1592
  try {
1511
1593
  await this.processRegistries.get(taskId)?.killAll();
1512
1594
  } catch (err) {
@@ -1518,29 +1600,29 @@ ${reuseSection.markdown}`;
1518
1600
  logger3.warn(`[BackgroundTaskManager] forceStopAllAcrossParents propagateStopToWorkflowRuns failed for ${taskId}: ${err instanceof Error ? err.message : String(err)}`);
1519
1601
  }
1520
1602
  let justMarkedStopped = false;
1521
- if (task.status === "running" || task.status === "pending") {
1603
+ if (taskSafe && (taskSafe.status === "running" || taskSafe.status === "pending")) {
1522
1604
  try {
1523
- task.status = "stopped";
1524
- task.completedAt = Date.now();
1525
- task.lastUpdatedAt = task.completedAt;
1526
- task.abortController?.abort();
1605
+ taskSafe.status = "stopped";
1606
+ taskSafe.completedAt = Date.now();
1607
+ taskSafe.lastUpdatedAt = taskSafe.completedAt;
1608
+ taskSafe.abortController?.abort();
1527
1609
  justMarkedStopped = true;
1528
1610
  } catch (err) {
1529
1611
  logger3.warn(`[BackgroundTaskManager] forceStopAllAcrossParents mark stopped failed for ${taskId}: ${err instanceof Error ? err.message : String(err)}`);
1530
1612
  }
1531
1613
  }
1532
- if (justMarkedStopped) {
1614
+ if (justMarkedStopped && taskSafe) {
1533
1615
  const stoppedPayload = {
1534
- backgroundTaskId: task.id,
1535
- subSessionId: task.subSessionId,
1536
- parentSessionId: task.parentSessionId,
1616
+ backgroundTaskId: taskSafe.id,
1617
+ subSessionId: taskSafe.subSessionId,
1618
+ parentSessionId: taskSafe.parentSessionId,
1537
1619
  status: "stopped",
1538
- description: task.description,
1620
+ description: taskSafe.description,
1539
1621
  error: "force stop all",
1540
- executionTimeMs: task.startedAt && task.completedAt ? task.completedAt - task.startedAt : 0,
1541
- associatedTaskId: task.associatedTaskId
1622
+ executionTimeMs: taskSafe.startedAt && taskSafe.completedAt ? taskSafe.completedAt - taskSafe.startedAt : 0,
1623
+ associatedTaskId: taskSafe.associatedTaskId
1542
1624
  };
1543
- this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, task.parentSessionId);
1625
+ this.publishBackgroundEvent(BackgroundTaskEventTypes.STOPPED, stoppedPayload, taskSafe.parentSessionId);
1544
1626
  }
1545
1627
  }
1546
1628
  }
@@ -1548,9 +1630,16 @@ ${reuseSection.markdown}`;
1548
1630
  return this.forceStopAllAcrossParents();
1549
1631
  }
1550
1632
  async dispose() {
1551
- for (const [taskId, controller] of this.abortControllers) {
1552
- controller.abort();
1553
- logger3.debug(`[BackgroundTaskManager] Aborted task: ${taskId}`);
1633
+ for (const [, timer] of this.progressTimers) {
1634
+ try {
1635
+ clearInterval(timer);
1636
+ } catch {}
1637
+ }
1638
+ this.progressTimers.clear();
1639
+ for (const [, controller] of this.abortControllers) {
1640
+ try {
1641
+ controller.abort();
1642
+ } catch {}
1554
1643
  }
1555
1644
  this.abortControllers.clear();
1556
1645
  for (const [, registry] of this.processRegistries) {
@@ -1599,6 +1688,9 @@ __legacyDecorateClassTS([
1599
1688
  log: true
1600
1689
  })
1601
1690
  ], BackgroundTaskManager.prototype, "propagateStopToWorkflowRuns", null);
1691
+ __legacyDecorateClassTS([
1692
+ TracedAs("task.background.finalizeTask", { recordParams: true, recordResult: false, log: true })
1693
+ ], BackgroundTaskManager.prototype, "finalizeTask", null);
1602
1694
  __legacyDecorateClassTS([
1603
1695
  TracedAs("task.background.resolveEntryAgent", { recordParams: true, recordResult: true })
1604
1696
  ], BackgroundTaskManager.prototype, "resolveEntryAgent", null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.6.19",
3
+ "version": "1.6.21",
4
4
  "type": "module",
5
5
  "description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
6
6
  "main": "./dist/index.js",