@amical/aiagent-sdk 0.1.1 → 0.1.3

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.
@@ -0,0 +1,110 @@
1
+ import * as fs from 'fs';
2
+ import { IMemoryManager, AgentMessage, IMcpManager, McpServerInfo, McpTool, McpToolCallResult, IAgentRuntime, ClineAgent } from '../index.mjs';
3
+ export { AgentDefaultTool, AgentOptions, AgentState, ApiProviderInfo, ApiStreamChunk, AssistantMessageContent, IApiHandler, IPromptManager, READ_ONLY_TOOLS, ReasoningStreamContent, TOOL_RESULT_BLOCK, TextStreamContent, ToolParamName, ToolUse, VERSION, defaultTools, getToolUseNames, parseAssistantMessageV2, setDynamicToolUseNames, toolParamNames, toolUseNames } from '../index.mjs';
4
+ import { W as WebMemoryManager } from '../WebMemoryManager-Bk19j8i6.mjs';
5
+
6
+ interface NodeApiHandlerConfig {
7
+ providerId?: string;
8
+ modelId?: string;
9
+ apiKey: string;
10
+ baseURL?: string;
11
+ headers?: Record<string, string>;
12
+ fetch?: typeof fetch;
13
+ }
14
+
15
+ /**
16
+ * Node 端 MemoryManager 实现
17
+ * 将对话历史持久化到本地文件系统(JSON 格式)。
18
+ */
19
+ declare class NodeMemoryManager implements IMemoryManager {
20
+ private filePath;
21
+ private maxMessages;
22
+ /**
23
+ * @param dbPath 存储历史记录的本地文件路径(例如:'./.cline_memory.json')
24
+ * @param maxMessages 保留的最大消息数量,用于简单的历史截断(默认 150)
25
+ */
26
+ constructor(dbPath: string, maxMessages?: number);
27
+ private ensureFile;
28
+ private readMessages;
29
+ private writeMessages;
30
+ getHistory(): Promise<AgentMessage[]>;
31
+ appendMessage(message: AgentMessage): Promise<void>;
32
+ condenseHistory(): Promise<void>;
33
+ clear(): Promise<void>;
34
+ }
35
+
36
+ interface StdioServerConfig {
37
+ command: string;
38
+ args?: string[];
39
+ env?: Record<string, string>;
40
+ }
41
+ interface NodeMcpManagerConfig {
42
+ servers: Record<string, StdioServerConfig>;
43
+ }
44
+ declare class NodeMcpManager implements IMcpManager {
45
+ private config;
46
+ private clients;
47
+ private transports;
48
+ private serverStatuses;
49
+ constructor(config: NodeMcpManagerConfig);
50
+ /**
51
+ * 初始化并连接所有的 MCP Servers
52
+ */
53
+ init(): Promise<void>;
54
+ getServers(): McpServerInfo[];
55
+ getTools(): Promise<McpTool[]>;
56
+ callTool(serverName: string, toolName: string, args: any): Promise<McpToolCallResult>;
57
+ readResource(serverName: string, uri: string): Promise<any>;
58
+ /**
59
+ * 断开并清理所有的 MCP Servers
60
+ */
61
+ destroy(): Promise<void>;
62
+ }
63
+
64
+ /**
65
+ * 默认的 Node.js 运行时实现
66
+ */
67
+ declare class DefaultNodeRuntime implements IAgentRuntime {
68
+ fs: {
69
+ readFile: (filepath: string) => Promise<string>;
70
+ writeFile: (filepath: string, content: string) => Promise<void>;
71
+ deleteFile: (filepath: string) => Promise<void>;
72
+ deleteDirectory: (dirpath: string) => Promise<void>;
73
+ fileExists: (filepath: string) => Promise<boolean>;
74
+ readDir: (dirpath: string) => Promise<fs.Dirent<string>[]>;
75
+ mkdir: (dirpath: string) => Promise<void>;
76
+ };
77
+ path: {
78
+ join: (...paths: string[]) => string;
79
+ };
80
+ env: {
81
+ get: (key: string) => string | undefined;
82
+ cwd: () => string;
83
+ osInfo: () => string;
84
+ shell: () => string;
85
+ };
86
+ terminal: {
87
+ execCommand: (command: string, options?: {
88
+ cwd?: string;
89
+ }) => Promise<{
90
+ stdout: any;
91
+ stderr: any;
92
+ exitCode: any;
93
+ }>;
94
+ };
95
+ }
96
+ interface NodeAgentOptions {
97
+ apiConfig: NodeApiHandlerConfig;
98
+ dbPath?: string;
99
+ customInstructions?: string;
100
+ customTools?: any[];
101
+ allowDefaultTools?: string[];
102
+ memory?: NodeMemoryManager | WebMemoryManager;
103
+ maxLoopCount?: number;
104
+ }
105
+ /**
106
+ * 快速创建 Node 端 Agent 的工厂方法
107
+ */
108
+ declare function createNodeAgent(options: NodeAgentOptions): ClineAgent;
109
+
110
+ export { AgentMessage, ClineAgent, DefaultNodeRuntime, IAgentRuntime, IMcpManager, IMemoryManager, McpServerInfo, McpTool, McpToolCallResult, type NodeAgentOptions, NodeMcpManager, type NodeMcpManagerConfig, type StdioServerConfig, createNodeAgent };
@@ -0,0 +1,110 @@
1
+ import * as fs from 'fs';
2
+ import { IMemoryManager, AgentMessage, IMcpManager, McpServerInfo, McpTool, McpToolCallResult, IAgentRuntime, ClineAgent } from '../index.js';
3
+ export { AgentDefaultTool, AgentOptions, AgentState, ApiProviderInfo, ApiStreamChunk, AssistantMessageContent, IApiHandler, IPromptManager, READ_ONLY_TOOLS, ReasoningStreamContent, TOOL_RESULT_BLOCK, TextStreamContent, ToolParamName, ToolUse, VERSION, defaultTools, getToolUseNames, parseAssistantMessageV2, setDynamicToolUseNames, toolParamNames, toolUseNames } from '../index.js';
4
+ import { W as WebMemoryManager } from '../WebMemoryManager-DXxLUDBB.js';
5
+
6
+ interface NodeApiHandlerConfig {
7
+ providerId?: string;
8
+ modelId?: string;
9
+ apiKey: string;
10
+ baseURL?: string;
11
+ headers?: Record<string, string>;
12
+ fetch?: typeof fetch;
13
+ }
14
+
15
+ /**
16
+ * Node 端 MemoryManager 实现
17
+ * 将对话历史持久化到本地文件系统(JSON 格式)。
18
+ */
19
+ declare class NodeMemoryManager implements IMemoryManager {
20
+ private filePath;
21
+ private maxMessages;
22
+ /**
23
+ * @param dbPath 存储历史记录的本地文件路径(例如:'./.cline_memory.json')
24
+ * @param maxMessages 保留的最大消息数量,用于简单的历史截断(默认 150)
25
+ */
26
+ constructor(dbPath: string, maxMessages?: number);
27
+ private ensureFile;
28
+ private readMessages;
29
+ private writeMessages;
30
+ getHistory(): Promise<AgentMessage[]>;
31
+ appendMessage(message: AgentMessage): Promise<void>;
32
+ condenseHistory(): Promise<void>;
33
+ clear(): Promise<void>;
34
+ }
35
+
36
+ interface StdioServerConfig {
37
+ command: string;
38
+ args?: string[];
39
+ env?: Record<string, string>;
40
+ }
41
+ interface NodeMcpManagerConfig {
42
+ servers: Record<string, StdioServerConfig>;
43
+ }
44
+ declare class NodeMcpManager implements IMcpManager {
45
+ private config;
46
+ private clients;
47
+ private transports;
48
+ private serverStatuses;
49
+ constructor(config: NodeMcpManagerConfig);
50
+ /**
51
+ * 初始化并连接所有的 MCP Servers
52
+ */
53
+ init(): Promise<void>;
54
+ getServers(): McpServerInfo[];
55
+ getTools(): Promise<McpTool[]>;
56
+ callTool(serverName: string, toolName: string, args: any): Promise<McpToolCallResult>;
57
+ readResource(serverName: string, uri: string): Promise<any>;
58
+ /**
59
+ * 断开并清理所有的 MCP Servers
60
+ */
61
+ destroy(): Promise<void>;
62
+ }
63
+
64
+ /**
65
+ * 默认的 Node.js 运行时实现
66
+ */
67
+ declare class DefaultNodeRuntime implements IAgentRuntime {
68
+ fs: {
69
+ readFile: (filepath: string) => Promise<string>;
70
+ writeFile: (filepath: string, content: string) => Promise<void>;
71
+ deleteFile: (filepath: string) => Promise<void>;
72
+ deleteDirectory: (dirpath: string) => Promise<void>;
73
+ fileExists: (filepath: string) => Promise<boolean>;
74
+ readDir: (dirpath: string) => Promise<fs.Dirent<string>[]>;
75
+ mkdir: (dirpath: string) => Promise<void>;
76
+ };
77
+ path: {
78
+ join: (...paths: string[]) => string;
79
+ };
80
+ env: {
81
+ get: (key: string) => string | undefined;
82
+ cwd: () => string;
83
+ osInfo: () => string;
84
+ shell: () => string;
85
+ };
86
+ terminal: {
87
+ execCommand: (command: string, options?: {
88
+ cwd?: string;
89
+ }) => Promise<{
90
+ stdout: any;
91
+ stderr: any;
92
+ exitCode: any;
93
+ }>;
94
+ };
95
+ }
96
+ interface NodeAgentOptions {
97
+ apiConfig: NodeApiHandlerConfig;
98
+ dbPath?: string;
99
+ customInstructions?: string;
100
+ customTools?: any[];
101
+ allowDefaultTools?: string[];
102
+ memory?: NodeMemoryManager | WebMemoryManager;
103
+ maxLoopCount?: number;
104
+ }
105
+ /**
106
+ * 快速创建 Node 端 Agent 的工厂方法
107
+ */
108
+ declare function createNodeAgent(options: NodeAgentOptions): ClineAgent;
109
+
110
+ export { AgentMessage, ClineAgent, DefaultNodeRuntime, IAgentRuntime, IMcpManager, IMemoryManager, McpServerInfo, McpTool, McpToolCallResult, type NodeAgentOptions, NodeMcpManager, type NodeMcpManagerConfig, type StdioServerConfig, createNodeAgent };