@ai-setting/roy-agent-core 1.6.20 → 1.6.22
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/config/index.js +9 -9
- package/dist/env/agent/index.js +16 -15
- package/dist/env/commands/index.js +9 -9
- package/dist/env/context/index.js +5 -5
- package/dist/env/debug/index.js +9 -9
- package/dist/env/event-source/index.js +14 -13
- package/dist/env/hook/index.js +7 -7
- package/dist/env/index.js +40 -39
- package/dist/env/llm/index.js +11 -11
- package/dist/env/log-trace/index.js +9 -9
- package/dist/env/mcp/index.js +10 -10
- package/dist/env/mcp/tool/index.js +3 -3
- package/dist/env/memory/index.js +10 -10
- package/dist/env/memory/plugin/index.js +3 -3
- package/dist/env/plugin/index.js +9 -9
- package/dist/env/prompt/index.js +9 -9
- package/dist/env/session/index.js +12 -12
- package/dist/env/session/storage/index.js +5 -5
- package/dist/env/skill/index.js +9 -9
- package/dist/env/task/delegate/index.js +9 -9
- package/dist/env/task/index.js +14 -14
- package/dist/env/task/plugins/index.js +9 -8
- package/dist/env/task/storage/index.js +4 -4
- package/dist/env/task/tools/index.js +5 -5
- package/dist/env/tool/built-in/index.js +5 -5
- package/dist/env/tool/index.js +12 -12
- package/dist/env/workflow/engine/index.js +11 -11
- package/dist/env/workflow/index.js +22 -22
- package/dist/env/workflow/nodes/index.js +4 -4
- package/dist/env/workflow/service/index.js +4 -4
- package/dist/env/workflow/storage/index.js +5 -5
- package/dist/env/workflow/tools/index.js +16 -16
- package/dist/env/workflow/utils/index.js +6 -6
- package/dist/index.js +51 -50
- package/dist/shared/@ai-setting/{roy-agent-core-8n3je2r0.js → roy-agent-core-067w3nt1.js} +120 -28
- package/dist/shared/@ai-setting/{roy-agent-core-7kw06e4b.js → roy-agent-core-0qjw25e8.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-bq1gskrf.js → roy-agent-core-0v74marc.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-e0kaxcy1.js → roy-agent-core-12gac5zn.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-f1cjs6c4.js → roy-agent-core-16dqrewm.js} +6 -6
- package/dist/shared/@ai-setting/{roy-agent-core-7r72622v.js → roy-agent-core-1k9j90s7.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-m00kamqp.js → roy-agent-core-1khp1m0r.js} +8 -1
- package/dist/shared/@ai-setting/{roy-agent-core-77wfej1h.js → roy-agent-core-3e0w0ekw.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-zdzkzx5g.js → roy-agent-core-3ep1dxf1.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-gc75v3px.js → roy-agent-core-3x3k7gfs.js} +5 -5
- package/dist/shared/@ai-setting/roy-agent-core-4k8tv5q5.js +11 -0
- package/dist/shared/@ai-setting/{roy-agent-core-02aw62bv.js → roy-agent-core-5ts23mx0.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-atpchjdz.js → roy-agent-core-6m2gh57e.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-ehpnd2be.js → roy-agent-core-6re7eg4w.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-ett06sn8.js → roy-agent-core-7cxdkcrz.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-416rpxkp.js → roy-agent-core-7wv7gh6t.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-fxembepv.js → roy-agent-core-90wp1rgb.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-zs4f0tcy.js → roy-agent-core-afb03wwp.js} +130 -3
- package/dist/shared/@ai-setting/{roy-agent-core-5pzegp1x.js → roy-agent-core-b64s2vk9.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-ataagh3a.js → roy-agent-core-br7dmedr.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-8n0e62y4.js → roy-agent-core-c1stgqnw.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-gmnex23m.js → roy-agent-core-cjraf54z.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-kkt2ndpf.js → roy-agent-core-dbwvfe0m.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-mdp8y7ky.js → roy-agent-core-dxfd6p1c.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-wsqnf2za.js → roy-agent-core-ef486rdm.js} +7 -7
- package/dist/shared/@ai-setting/{roy-agent-core-bqe4c9f2.js → roy-agent-core-f2nync7q.js} +12 -4
- package/dist/shared/@ai-setting/{roy-agent-core-dh9rajdh.js → roy-agent-core-g7nmwg63.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-96mj6gvc.js → roy-agent-core-gb7pm9c0.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-grajzyhd.js → roy-agent-core-gns3wa97.js} +14 -18
- package/dist/shared/@ai-setting/{roy-agent-core-ez91vxas.js → roy-agent-core-h1cb2jzh.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-eskgj8nc.js → roy-agent-core-h28gcd77.js} +6 -6
- package/dist/shared/@ai-setting/{roy-agent-core-rdf8tqj7.js → roy-agent-core-h4sm7fyb.js} +8 -8
- package/dist/shared/@ai-setting/{roy-agent-core-sqt96sam.js → roy-agent-core-h7ak839w.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-c7e3htaq.js → roy-agent-core-hks28tys.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-vc7p80sd.js → roy-agent-core-j29yg06n.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-r15sn7ve.js → roy-agent-core-j9ybhwnq.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-nna4s0qs.js → roy-agent-core-kaq037np.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-e9jf4w3z.js → roy-agent-core-kv7frw13.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-44g3synv.js → roy-agent-core-mvs5sen6.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-zeztnvvb.js → roy-agent-core-mz69jdvv.js} +178 -78
- package/dist/shared/@ai-setting/{roy-agent-core-akb8mb9v.js → roy-agent-core-pde8hkq4.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-p4z6nxgz.js → roy-agent-core-pdnp5kj0.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-1qjgwjjs.js → roy-agent-core-pz2n121t.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-wr3pk3h3.js → roy-agent-core-qe3m3hec.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-v20nxrs1.js → roy-agent-core-qpt5fa8h.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-keb51jag.js → roy-agent-core-rs5tp44j.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-2b0mw2h3.js → roy-agent-core-s07nere5.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-ajp566yv.js → roy-agent-core-sfwt66pv.js} +2 -2
- package/dist/shared/@ai-setting/roy-agent-core-t3yqzgse.js +71 -0
- package/dist/shared/@ai-setting/{roy-agent-core-xzc53mnk.js → roy-agent-core-t9h4np6m.js} +4 -2
- package/dist/shared/@ai-setting/{roy-agent-core-1mrc9a1r.js → roy-agent-core-w8rv08d3.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-b9q2jfx4.js → roy-agent-core-watkmj7d.js} +6 -6
- package/dist/shared/@ai-setting/{roy-agent-core-bwqjwa0d.js → roy-agent-core-wr1pgw0x.js} +8 -8
- package/dist/shared/@ai-setting/{roy-agent-core-fntxq0gf.js → roy-agent-core-x0yztmm6.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-dtkbj8fk.js → roy-agent-core-xrr7t0qc.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-mekk4as5.js → roy-agent-core-xwnpygva.js} +14 -14
- package/dist/shared/@ai-setting/{roy-agent-core-pr4jekyy.js → roy-agent-core-z2w7wtqd.js} +5 -5
- package/dist/utils/temp-file-manager/index.js +3 -3
- package/package.json +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-w6kj6nmj.js +0 -11
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TracedAs,
|
|
3
3
|
init_decorator
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-gb7pm9c0.js";
|
|
5
5
|
import {
|
|
6
6
|
createLogger,
|
|
7
7
|
init_logger
|
|
8
|
-
} from "./roy-agent-core-
|
|
8
|
+
} from "./roy-agent-core-kaq037np.js";
|
|
9
9
|
import {
|
|
10
10
|
__esm,
|
|
11
11
|
__export,
|
|
@@ -3,21 +3,21 @@ import {
|
|
|
3
3
|
} from "./roy-agent-core-az13yzmc.js";
|
|
4
4
|
import {
|
|
5
5
|
BaseComponent
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-pde8hkq4.js";
|
|
7
7
|
import {
|
|
8
8
|
globalHookManager,
|
|
9
9
|
init_global_hook_manager
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-j29yg06n.js";
|
|
11
11
|
import {
|
|
12
12
|
init_context
|
|
13
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-h7ak839w.js";
|
|
14
14
|
import {
|
|
15
15
|
getEnvContextOrEmpty
|
|
16
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-xrr7t0qc.js";
|
|
17
17
|
import {
|
|
18
18
|
createLogger,
|
|
19
19
|
init_logger
|
|
20
|
-
} from "./roy-agent-core-
|
|
20
|
+
} from "./roy-agent-core-kaq037np.js";
|
|
21
21
|
|
|
22
22
|
// src/env/plugin/event-bus-notification-channel.ts
|
|
23
23
|
init_logger();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TagRepository
|
|
3
|
+
} from "./roy-agent-core-6m2gh57e.js";
|
|
4
|
+
import"./roy-agent-core-gb7pm9c0.js";
|
|
5
|
+
import"./roy-agent-core-kaq037np.js";
|
|
6
|
+
import"./roy-agent-core-1khp1m0r.js";
|
|
7
|
+
import"./roy-agent-core-4an1p9a1.js";
|
|
8
|
+
import"./roy-agent-core-fs0mn2jk.js";
|
|
9
|
+
export {
|
|
10
|
+
TagRepository
|
|
11
|
+
};
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
} from "./roy-agent-core-7hh0brvs.js";
|
|
5
5
|
import {
|
|
6
6
|
BaseComponent
|
|
7
|
-
} from "./roy-agent-core-
|
|
7
|
+
} from "./roy-agent-core-pde8hkq4.js";
|
|
8
8
|
import {
|
|
9
9
|
createLogger,
|
|
10
10
|
init_logger
|
|
11
|
-
} from "./roy-agent-core-
|
|
11
|
+
} from "./roy-agent-core-kaq037np.js";
|
|
12
12
|
|
|
13
13
|
// src/env/commands/commands-component.ts
|
|
14
14
|
import path2 from "path";
|
|
@@ -10,18 +10,18 @@ import {
|
|
|
10
10
|
} from "./roy-agent-core-7hh0brvs.js";
|
|
11
11
|
import {
|
|
12
12
|
BaseComponent
|
|
13
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-pde8hkq4.js";
|
|
14
14
|
import {
|
|
15
15
|
createHook
|
|
16
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-5ts23mx0.js";
|
|
17
17
|
import {
|
|
18
18
|
globalHookManager,
|
|
19
19
|
init_global_hook_manager
|
|
20
|
-
} from "./roy-agent-core-
|
|
20
|
+
} from "./roy-agent-core-j29yg06n.js";
|
|
21
21
|
import {
|
|
22
22
|
createLogger,
|
|
23
23
|
init_logger
|
|
24
|
-
} from "./roy-agent-core-
|
|
24
|
+
} from "./roy-agent-core-kaq037np.js";
|
|
25
25
|
|
|
26
26
|
// src/env/prompt/types.ts
|
|
27
27
|
import { z } from "zod";
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./roy-agent-core-y3g3ar7a.js";
|
|
4
4
|
import {
|
|
5
5
|
invoke
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-c1stgqnw.js";
|
|
7
7
|
import {
|
|
8
8
|
ContextError,
|
|
9
9
|
ErrorCodes
|
|
@@ -14,20 +14,20 @@ import {
|
|
|
14
14
|
} from "./roy-agent-core-7hh0brvs.js";
|
|
15
15
|
import {
|
|
16
16
|
BaseComponent
|
|
17
|
-
} from "./roy-agent-core-
|
|
17
|
+
} from "./roy-agent-core-pde8hkq4.js";
|
|
18
18
|
import {
|
|
19
19
|
LLMHookPoints,
|
|
20
20
|
globalHookManager,
|
|
21
21
|
init_global_hook_manager
|
|
22
|
-
} from "./roy-agent-core-
|
|
22
|
+
} from "./roy-agent-core-j29yg06n.js";
|
|
23
23
|
import {
|
|
24
24
|
TracedAs,
|
|
25
25
|
init_decorator
|
|
26
|
-
} from "./roy-agent-core-
|
|
26
|
+
} from "./roy-agent-core-gb7pm9c0.js";
|
|
27
27
|
import {
|
|
28
28
|
createLogger,
|
|
29
29
|
init_logger
|
|
30
|
-
} from "./roy-agent-core-
|
|
30
|
+
} from "./roy-agent-core-kaq037np.js";
|
|
31
31
|
import {
|
|
32
32
|
__legacyDecorateClassTS
|
|
33
33
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
@@ -2,12 +2,12 @@ import {
|
|
|
2
2
|
WorkflowRepository,
|
|
3
3
|
migrateEmptyTagsToDefault,
|
|
4
4
|
rowToWorkflow
|
|
5
|
-
} from "./roy-agent-core-
|
|
6
|
-
import"./roy-agent-core-
|
|
5
|
+
} from "./roy-agent-core-sfwt66pv.js";
|
|
6
|
+
import"./roy-agent-core-6m2gh57e.js";
|
|
7
7
|
import"./roy-agent-core-rvxg1wps.js";
|
|
8
|
-
import"./roy-agent-core-
|
|
9
|
-
import"./roy-agent-core-
|
|
10
|
-
import"./roy-agent-core-
|
|
8
|
+
import"./roy-agent-core-gb7pm9c0.js";
|
|
9
|
+
import"./roy-agent-core-kaq037np.js";
|
|
10
|
+
import"./roy-agent-core-1khp1m0r.js";
|
|
11
11
|
import"./roy-agent-core-4an1p9a1.js";
|
|
12
12
|
import"./roy-agent-core-fs0mn2jk.js";
|
|
13
13
|
export {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SessionMessageConverter
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-1k9j90s7.js";
|
|
4
4
|
import {
|
|
5
5
|
createLogger,
|
|
6
6
|
init_logger
|
|
7
|
-
} from "./roy-agent-core-
|
|
7
|
+
} from "./roy-agent-core-kaq037np.js";
|
|
8
8
|
import {
|
|
9
9
|
__require
|
|
10
10
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
@@ -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
|
-
|
|
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
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
} from "./roy-agent-core-7hh0brvs.js";
|
|
7
7
|
import {
|
|
8
8
|
BaseComponent
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-pde8hkq4.js";
|
|
10
10
|
import {
|
|
11
11
|
createLogger,
|
|
12
12
|
init_logger
|
|
13
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-kaq037np.js";
|
|
14
14
|
|
|
15
15
|
// src/env/skill/skill-component.ts
|
|
16
16
|
init_logger();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
safeParseToolArgs
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-12gac5zn.js";
|
|
4
4
|
import {
|
|
5
5
|
createLogger,
|
|
6
6
|
init_logger
|
|
7
|
-
} from "./roy-agent-core-
|
|
7
|
+
} from "./roy-agent-core-kaq037np.js";
|
|
8
8
|
import {
|
|
9
9
|
__require
|
|
10
10
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
@@ -9,16 +9,16 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
globalHookManager,
|
|
11
11
|
init_global_hook_manager
|
|
12
|
-
} from "./roy-agent-core-
|
|
12
|
+
} from "./roy-agent-core-j29yg06n.js";
|
|
13
13
|
import {
|
|
14
14
|
TracedAs,
|
|
15
15
|
init_decorator,
|
|
16
16
|
wrapFunction
|
|
17
|
-
} from "./roy-agent-core-
|
|
17
|
+
} from "./roy-agent-core-gb7pm9c0.js";
|
|
18
18
|
import {
|
|
19
19
|
createLogger,
|
|
20
20
|
init_logger
|
|
21
|
-
} from "./roy-agent-core-
|
|
21
|
+
} from "./roy-agent-core-kaq037np.js";
|
|
22
22
|
import {
|
|
23
23
|
__esm,
|
|
24
24
|
__legacyDecorateClassTS
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TAG_MAX_COUNT,
|
|
3
3
|
TAG_MIN_COUNT
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-j9ybhwnq.js";
|
|
5
5
|
import {
|
|
6
6
|
validateWorkflowDefinition
|
|
7
|
-
} from "./roy-agent-core-
|
|
7
|
+
} from "./roy-agent-core-w8rv08d3.js";
|
|
8
8
|
import {
|
|
9
9
|
AskUserError,
|
|
10
10
|
init_workflow_hil
|
|
@@ -14,15 +14,15 @@ import {
|
|
|
14
14
|
} from "./roy-agent-core-c1v263jn.js";
|
|
15
15
|
import {
|
|
16
16
|
isValidSessionId
|
|
17
|
-
} from "./roy-agent-core-
|
|
17
|
+
} from "./roy-agent-core-f2nync7q.js";
|
|
18
18
|
import {
|
|
19
19
|
TracedAs,
|
|
20
20
|
init_decorator
|
|
21
|
-
} from "./roy-agent-core-
|
|
21
|
+
} from "./roy-agent-core-gb7pm9c0.js";
|
|
22
22
|
import {
|
|
23
23
|
createLogger,
|
|
24
24
|
init_logger
|
|
25
|
-
} from "./roy-agent-core-
|
|
25
|
+
} from "./roy-agent-core-kaq037np.js";
|
|
26
26
|
import {
|
|
27
27
|
__legacyDecorateClassTS
|
|
28
28
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentComponentAdapter,
|
|
3
3
|
init_agent_component_adapter
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-cjraf54z.js";
|
|
5
5
|
import"./roy-agent-core-1db4vpc6.js";
|
|
6
6
|
import"./roy-agent-core-e25xkv53.js";
|
|
7
|
-
import"./roy-agent-core-
|
|
8
|
-
import"./roy-agent-core-
|
|
9
|
-
import"./roy-agent-core-
|
|
10
|
-
import"./roy-agent-core-
|
|
11
|
-
import"./roy-agent-core-
|
|
12
|
-
import"./roy-agent-core-
|
|
7
|
+
import"./roy-agent-core-j29yg06n.js";
|
|
8
|
+
import"./roy-agent-core-h7ak839w.js";
|
|
9
|
+
import"./roy-agent-core-xrr7t0qc.js";
|
|
10
|
+
import"./roy-agent-core-gb7pm9c0.js";
|
|
11
|
+
import"./roy-agent-core-kaq037np.js";
|
|
12
|
+
import"./roy-agent-core-1khp1m0r.js";
|
|
13
13
|
import"./roy-agent-core-4an1p9a1.js";
|
|
14
14
|
import"./roy-agent-core-fs0mn2jk.js";
|
|
15
15
|
init_agent_component_adapter();
|
|
@@ -6,21 +6,21 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
MemorySessionStore,
|
|
8
8
|
SQLiteSessionStore
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-afb03wwp.js";
|
|
10
10
|
import {
|
|
11
11
|
envKeyToConfigKey
|
|
12
12
|
} from "./roy-agent-core-7hh0brvs.js";
|
|
13
13
|
import {
|
|
14
14
|
BaseComponent
|
|
15
|
-
} from "./roy-agent-core-
|
|
15
|
+
} from "./roy-agent-core-pde8hkq4.js";
|
|
16
16
|
import {
|
|
17
17
|
TracedAs,
|
|
18
18
|
init_decorator
|
|
19
|
-
} from "./roy-agent-core-
|
|
19
|
+
} from "./roy-agent-core-gb7pm9c0.js";
|
|
20
20
|
import {
|
|
21
21
|
createLogger,
|
|
22
22
|
init_logger
|
|
23
|
-
} from "./roy-agent-core-
|
|
23
|
+
} from "./roy-agent-core-kaq037np.js";
|
|
24
24
|
import {
|
|
25
25
|
__legacyDecorateClassTS
|
|
26
26
|
} from "./roy-agent-core-fs0mn2jk.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) {
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
getMaxOutput,
|
|
4
4
|
init_logger,
|
|
5
5
|
simplifyFilePath
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-kaq037np.js";
|
|
7
7
|
import {
|
|
8
8
|
getTracerProvider,
|
|
9
9
|
init_tracer_provider
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-1khp1m0r.js";
|
|
11
11
|
import {
|
|
12
12
|
__esm
|
|
13
13
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
@@ -3,7 +3,10 @@ import {
|
|
|
3
3
|
} from "./roy-agent-core-az13yzmc.js";
|
|
4
4
|
import {
|
|
5
5
|
validateWorkflowDefinition
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-w8rv08d3.js";
|
|
7
|
+
import {
|
|
8
|
+
enqueueToAddFakeUserMessage
|
|
9
|
+
} from "./roy-agent-core-t3yqzgse.js";
|
|
7
10
|
import {
|
|
8
11
|
WORKFLOW_EXTRACT_PROMPT
|
|
9
12
|
} from "./roy-agent-core-skqt40yy.js";
|
|
@@ -12,22 +15,22 @@ import {
|
|
|
12
15
|
} from "./roy-agent-core-1pg0fepg.js";
|
|
13
16
|
import {
|
|
14
17
|
init_context
|
|
15
|
-
} from "./roy-agent-core-
|
|
18
|
+
} from "./roy-agent-core-h7ak839w.js";
|
|
16
19
|
import {
|
|
17
20
|
getEnvContextOrEmpty,
|
|
18
21
|
getEventFromEnvContext,
|
|
19
22
|
getLarkMessageId,
|
|
20
23
|
isLarkEvent
|
|
21
|
-
} from "./roy-agent-core-
|
|
24
|
+
} from "./roy-agent-core-xrr7t0qc.js";
|
|
22
25
|
import {
|
|
23
26
|
TracedAs,
|
|
24
27
|
init_decorator,
|
|
25
28
|
wrapFunction
|
|
26
|
-
} from "./roy-agent-core-
|
|
29
|
+
} from "./roy-agent-core-gb7pm9c0.js";
|
|
27
30
|
import {
|
|
28
31
|
createLogger,
|
|
29
32
|
init_logger
|
|
30
|
-
} from "./roy-agent-core-
|
|
33
|
+
} from "./roy-agent-core-kaq037np.js";
|
|
31
34
|
import {
|
|
32
35
|
__legacyDecorateClassTS,
|
|
33
36
|
__require
|
|
@@ -292,11 +295,11 @@ ${prompt}`;
|
|
|
292
295
|
}
|
|
293
296
|
if (!this._workflowRepo) {
|
|
294
297
|
try {
|
|
295
|
-
const sqlite = await import("./roy-agent-core-
|
|
298
|
+
const sqlite = await import("./roy-agent-core-z2w7wtqd.js");
|
|
296
299
|
this.ensureDataDir();
|
|
297
300
|
const db = sqlite.getDatabase();
|
|
298
301
|
sqlite.initializeTables();
|
|
299
|
-
const { WorkflowRepository } = await import("./roy-agent-core-
|
|
302
|
+
const { WorkflowRepository } = await import("./roy-agent-core-90wp1rgb.js");
|
|
300
303
|
this._workflowRepo = new WorkflowRepository(db);
|
|
301
304
|
return this._workflowRepo;
|
|
302
305
|
} catch {
|
|
@@ -339,17 +342,10 @@ function createAutoTaskPlugin(config) {
|
|
|
339
342
|
logger2.warn(`[AutoTaskPlugin] toolResult missing, skip meta-protocol (iteration=${ctx.iteration})`);
|
|
340
343
|
return { continue: true };
|
|
341
344
|
}
|
|
342
|
-
|
|
343
|
-
ctx.toolResult.result = {};
|
|
344
|
-
}
|
|
345
|
-
const innerResult = ctx.toolResult.result;
|
|
346
|
-
if (!innerResult.metadata) {
|
|
347
|
-
innerResult.metadata = {};
|
|
348
|
-
}
|
|
349
|
-
innerResult.metadata.toAddFakeUserMessage = {
|
|
345
|
+
enqueueToAddFakeUserMessage(ctx.toolResult, {
|
|
350
346
|
role: "user",
|
|
351
347
|
content: reminderContent
|
|
352
|
-
};
|
|
348
|
+
}, "delegate");
|
|
353
349
|
logger2.info(`[AutoTaskPlugin] user reminder meta-protocol set (session=${(ctx.context?.sessionId ?? "unknown").slice(0, 12)}..., iteration=${ctx.iteration})`);
|
|
354
350
|
return { continue: true };
|
|
355
351
|
} catch (err) {
|
|
@@ -364,8 +360,8 @@ function createAutoTaskPlugin(config) {
|
|
|
364
360
|
});
|
|
365
361
|
return {
|
|
366
362
|
name: "AutoTaskPlugin",
|
|
367
|
-
version: "5.
|
|
368
|
-
description: "ReAct iteration
|
|
363
|
+
version: "5.2.0",
|
|
364
|
+
description: "ReAct iteration 达到阈值时通过共享 meta-protocol helper 注入 user 消息(与 MaxIterReminder 共用字段、确定性合并)",
|
|
369
365
|
hooks: [
|
|
370
366
|
{ point: "agent:after.tool", priority: 50 }
|
|
371
367
|
],
|