@ai-setting/roy-agent-core 1.6.42 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/env/agent/index.js +3 -4
- package/dist/env/index.js +7 -8
- package/dist/env/llm/index.js +17 -6
- package/dist/env/session/index.js +4 -4
- package/dist/env/session/storage/index.js +3 -3
- package/dist/env/workflow/index.js +6 -6
- package/dist/env/workflow/tools/index.js +5 -5
- package/dist/index.js +13 -14
- package/dist/shared/@ai-setting/{roy-agent-core-c1stgqnw.js → roy-agent-core-2xb3f3ye.js} +143 -23
- package/dist/shared/@ai-setting/{roy-agent-core-fzyn4fxx.js → roy-agent-core-3dwcwgn5.js} +163 -30
- package/dist/shared/@ai-setting/{roy-agent-core-dbwvfe0m.js → roy-agent-core-qatz3q31.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-7wv7gh6t.js → roy-agent-core-w93wrd77.js} +627 -46
- package/dist/shared/@ai-setting/{roy-agent-core-afb03wwp.js → roy-agent-core-wgp3q62x.js} +7 -4
- package/dist/shared/@ai-setting/{roy-agent-core-9yf6we04.js → roy-agent-core-xmacq00w.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-f2nync7q.js → roy-agent-core-xvag5pd0.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-1k9j90s7.js → roy-agent-core-zcx8nf4a.js} +1 -1
- package/package.json +5 -2
- package/dist/shared/@ai-setting/roy-agent-core-12gac5zn.js +0 -44
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SessionMessageConverter
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-zcx8nf4a.js";
|
|
4
|
+
import {
|
|
5
|
+
canonicalizeParts
|
|
6
|
+
} from "./roy-agent-core-2xb3f3ye.js";
|
|
4
7
|
import {
|
|
5
8
|
createLogger,
|
|
6
9
|
init_logger
|
|
@@ -796,7 +799,7 @@ class SQLiteSessionStore extends BaseSessionStore {
|
|
|
796
799
|
INSERT INTO message (id, session_id, role, content, timestamp, parts, metadata)
|
|
797
800
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
798
801
|
`);
|
|
799
|
-
stmt.run(msg.id, msg.sessionID, msg.role, msg.content, msg.timestamp, msg.parts ?
|
|
802
|
+
stmt.run(msg.id, msg.sessionID, msg.role, msg.content, msg.timestamp, msg.parts ? canonicalizeParts(msg.parts) : null, msg.metadata ? JSON.stringify(msg.metadata) : null);
|
|
800
803
|
const countResult = this.db.prepare("SELECT COUNT(*) as count FROM message WHERE session_id = ? AND is_archived = 0").get(sessionId);
|
|
801
804
|
session.messageCount = countResult?.count || 0;
|
|
802
805
|
session.updatedAt = now;
|
|
@@ -856,7 +859,7 @@ class SQLiteSessionStore extends BaseSessionStore {
|
|
|
856
859
|
for (const message of messages) {
|
|
857
860
|
const id = generateMessageId2();
|
|
858
861
|
ids.push(id);
|
|
859
|
-
insertStmt.run(id, sessionId, message.role, message.content, now, message.parts ?
|
|
862
|
+
insertStmt.run(id, sessionId, message.role, message.content, now, message.parts ? canonicalizeParts(message.parts) : null, message.metadata ? JSON.stringify(message.metadata) : null);
|
|
860
863
|
}
|
|
861
864
|
const countResult = this.db.prepare("SELECT COUNT(*) as count FROM message WHERE session_id = ? AND is_archived = 0").get(sessionId);
|
|
862
865
|
const newCount = countResult?.count ?? 0;
|
|
@@ -911,7 +914,7 @@ class SQLiteSessionStore extends BaseSessionStore {
|
|
|
911
914
|
}
|
|
912
915
|
if (updates.parts !== undefined) {
|
|
913
916
|
sets.push("parts = ?");
|
|
914
|
-
values.push(
|
|
917
|
+
values.push(canonicalizeParts(updates.parts));
|
|
915
918
|
}
|
|
916
919
|
if (updates.metadata !== undefined) {
|
|
917
920
|
sets.push("metadata = ?");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-setting/roy-agent-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,13 +31,16 @@
|
|
|
31
31
|
"build": "bunup",
|
|
32
32
|
"build:main": "bunup -- --entry src/index.ts",
|
|
33
33
|
"clean": "rm -rf dist",
|
|
34
|
-
"typecheck": "npx tsc --noEmit --skipLibCheck --project tsconfig.json"
|
|
34
|
+
"typecheck": "npx tsc --noEmit --skipLibCheck --project tsconfig.json",
|
|
35
|
+
"test:llm": "bun test test/llm/",
|
|
36
|
+
"test:llm:fast": "bun test --parallel 4 test/llm/"
|
|
35
37
|
},
|
|
36
38
|
"dependencies": {
|
|
37
39
|
"@ai-sdk/anthropic": "^3.0.0",
|
|
38
40
|
"@ai-sdk/google": "^3.0.0",
|
|
39
41
|
"@ai-sdk/openai": "^3.0.0",
|
|
40
42
|
"@ai-sdk/openai-compatible": "^2.0.0",
|
|
43
|
+
"@earendil-works/pi-ai": "^0.74.2",
|
|
41
44
|
"@effect/platform": "^0.96.1",
|
|
42
45
|
"@effect/platform-node": "^0.106.0",
|
|
43
46
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createLogger,
|
|
3
|
-
init_logger
|
|
4
|
-
} from "./roy-agent-core-kaq037np.js";
|
|
5
|
-
|
|
6
|
-
// src/env/llm/tool-args-parser.ts
|
|
7
|
-
init_logger();
|
|
8
|
-
var logger = createLogger("llm:tool-args-parser");
|
|
9
|
-
var MAX_SAFE_DEPTH = 5;
|
|
10
|
-
function safeParseToolArgs(args, depth = 0) {
|
|
11
|
-
if (depth >= MAX_SAFE_DEPTH) {
|
|
12
|
-
logger.warn(`[safeParseToolArgs] Max recursion depth (${MAX_SAFE_DEPTH}) exceeded at depth ${depth}. ` + "Input may be malicious or abnormally deeply nested. Returning empty object.", { depth, argsType: typeof args });
|
|
13
|
-
return {};
|
|
14
|
-
}
|
|
15
|
-
if (typeof args === "object" && args !== null && !Array.isArray(args)) {
|
|
16
|
-
return args;
|
|
17
|
-
}
|
|
18
|
-
if (Array.isArray(args)) {
|
|
19
|
-
logger.debug(`[safeParseToolArgs] Input is an array. Tool arguments should be objects. Returning empty object.`, { depth, arrayLength: args.length });
|
|
20
|
-
return {};
|
|
21
|
-
}
|
|
22
|
-
if (typeof args === "string") {
|
|
23
|
-
try {
|
|
24
|
-
const parsed = JSON.parse(args);
|
|
25
|
-
if (typeof parsed === "string") {
|
|
26
|
-
logger.debug(`[safeParseToolArgs] Detected double/multi-stringified JSON at depth ${depth}. ` + "LLM may be double-stringifying tool arguments. Parsing recursively.", { depth, parsedLength: parsed.length });
|
|
27
|
-
return safeParseToolArgs(parsed, depth + 1);
|
|
28
|
-
}
|
|
29
|
-
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
30
|
-
return parsed;
|
|
31
|
-
}
|
|
32
|
-
if (Array.isArray(parsed)) {
|
|
33
|
-
logger.debug(`[safeParseToolArgs] Parsed result is an array at depth ${depth}. ` + "Tool arguments should be objects, not arrays. Returning empty object.", { depth, parsedLength: parsed.length });
|
|
34
|
-
return {};
|
|
35
|
-
}
|
|
36
|
-
return { value: parsed };
|
|
37
|
-
} catch {
|
|
38
|
-
return {};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return {};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { safeParseToolArgs };
|