@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.
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  SessionMessageConverter
3
- } from "./roy-agent-core-1k9j90s7.js";
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 ? JSON.stringify(msg.parts) : null, msg.metadata ? JSON.stringify(msg.metadata) : null);
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 ? JSON.stringify(message.parts) : null, message.metadata ? JSON.stringify(message.metadata) : null);
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(JSON.stringify(updates.parts));
917
+ values.push(canonicalizeParts(updates.parts));
915
918
  }
916
919
  if (updates.metadata !== undefined) {
917
920
  sets.push("metadata = ?");
@@ -18,7 +18,7 @@ import {
18
18
  createWorkflowSearchTool,
19
19
  createWorkflowTagListTool,
20
20
  createWorkflowValidateTool
21
- } from "./roy-agent-core-dbwvfe0m.js";
21
+ } from "./roy-agent-core-qatz3q31.js";
22
22
  import {
23
23
  WorkflowService
24
24
  } from "./roy-agent-core-j9ybhwnq.js";
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  MemorySessionStore,
8
8
  SQLiteSessionStore
9
- } from "./roy-agent-core-afb03wwp.js";
9
+ } from "./roy-agent-core-wgp3q62x.js";
10
10
  import {
11
11
  envKeyToConfigKey
12
12
  } from "./roy-agent-core-7hh0brvs.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  safeParseToolArgs
3
- } from "./roy-agent-core-12gac5zn.js";
3
+ } from "./roy-agent-core-2xb3f3ye.js";
4
4
 
5
5
  // src/env/session/session-message-converter.ts
6
6
  import { randomUUID } from "crypto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.6.42",
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 };