@atlisp/agent 0.1.14 → 0.1.16

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/README.md CHANGED
@@ -115,7 +115,7 @@ export LLM_MAX_TOKENS=2048
115
115
 
116
116
  # MCP
117
117
  export MCP_MODE=stdio
118
- export MCP_URL=http://localhost:8120
118
+ export MCP_URL=http://localhost:8110
119
119
  export MCP_COMMAND=atlisp-mcp
120
120
 
121
121
  # Agent
@@ -139,7 +139,7 @@ LLM_MAX_TOKENS=2048
139
139
 
140
140
  # MCP 配置
141
141
  MCP_MODE=stdio
142
- MCP_URL=http://localhost:8120
142
+ MCP_URL=http://localhost:8110
143
143
 
144
144
  # Agent 配置
145
145
  AGENT_VERBOSE=true
@@ -173,7 +173,7 @@ npx atlisp-agent tools
173
173
 
174
174
  ```bash
175
175
  npm run server
176
- # 启动在 http://0.0.0.0:8120
176
+ # 启动在 http://0.0.0.0:8110
177
177
  ```
178
178
 
179
179
  ### API 端点
@@ -190,7 +190,7 @@ npm run server
190
190
  ### API 调用示例
191
191
 
192
192
  ```bash
193
- curl -X POST http://localhost:8120/chat \
193
+ curl -X POST http://localhost:8110/chat \
194
194
  -H "Content-Type: application/json" \
195
195
  -d '{"message": "查询 CAD 版本"}'
196
196
  ```
package/agent.js CHANGED
@@ -20,10 +20,13 @@ export class Agent {
20
20
  console.error('[Agent] 正在启动 npx @atlisp/mcp...');
21
21
 
22
22
  const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
23
- const mcpProc = spawn(`${npxCmd} -y @atlisp/mcp --http`, {
23
+ const cmdStr = `${npxCmd} -y @atlisp/mcp --http`;
24
+ const shell = process.platform === 'win32' ? 'cmd.exe' : '/bin/sh';
25
+ const shellArgs = process.platform === 'win32' ? ['/c', cmdStr] : ['-c', cmdStr];
26
+ const mcpProc = spawn(shell, shellArgs, {
24
27
  stdio: ['ignore', 'pipe', 'pipe'],
25
28
  detached: true,
26
- shell: true,
29
+ windowsHide: true,
27
30
  });
28
31
 
29
32
  let output = '';
@@ -50,7 +53,7 @@ export class Agent {
50
53
  }
51
54
  } catch {}
52
55
 
53
- if (output.includes('started') || output.includes('listen') || output.includes('8120')) {
56
+ if (output.includes('started') || output.includes('listen') || output.includes('8110')) {
54
57
  clearTimeout(timeout);
55
58
  console.error('[Agent] MCP 服务已启动');
56
59
  resolve(true);
package/config.js CHANGED
@@ -67,11 +67,11 @@ function getDefaultConfig() {
67
67
  model: 'deepseek-v4-flash',
68
68
  apiKey: '',
69
69
  temperature: 0.7,
70
- maxTokens: 2048,
70
+ maxTokens: 65536,
71
71
  },
72
72
  mcp: {
73
73
  mode: 'stdio',
74
- url: 'http://localhost:8120',
74
+ url: 'http://localhost:8110',
75
75
  command: 'atlisp-mcp',
76
76
  args: ['--stdio'],
77
77
  },
@@ -126,6 +126,14 @@ function deepMerge(target, source) {
126
126
  }
127
127
 
128
128
  let config = null;
129
+ let cachedEnvVars = null;
130
+
131
+ function getEnvVars() {
132
+ if (!cachedEnvVars) {
133
+ cachedEnvVars = loadEnvFile();
134
+ }
135
+ return cachedEnvVars;
136
+ }
129
137
 
130
138
  function loadConfig() {
131
139
  const fileConfig = loadConfigFile();
@@ -135,7 +143,7 @@ function loadConfig() {
135
143
  saveDefaultConfig(jsonPath);
136
144
  }
137
145
 
138
- let merged = deepMerge(getDefaultConfig(), fileConfig);
146
+ let merged = deepMerge(getDefaultConfig(), fileConfig || {});
139
147
  return merged;
140
148
  }
141
149
 
@@ -148,7 +156,7 @@ function getConfig() {
148
156
 
149
157
  export function getAgentConfig() {
150
158
  const config = getConfig().agent;
151
- const envVars = loadEnvFile();
159
+ const envVars = getEnvVars();
152
160
 
153
161
  const envOverrides = {};
154
162
  if (envVars.AGENT_ENABLED) envOverrides.enabled = envVars.AGENT_ENABLED === 'true';
@@ -160,7 +168,7 @@ export function getAgentConfig() {
160
168
 
161
169
  export function getLlmConfig() {
162
170
  const config = getConfig().llm;
163
- const envVars = loadEnvFile();
171
+ const envVars = getEnvVars();
164
172
 
165
173
  const envOverrides = {};
166
174
  if (envVars.LLM_PROVIDER) envOverrides.provider = envVars.LLM_PROVIDER;
@@ -175,7 +183,7 @@ export function getLlmConfig() {
175
183
 
176
184
  export function getMcpConfig() {
177
185
  const config = getConfig().mcp;
178
- const envVars = loadEnvFile();
186
+ const envVars = getEnvVars();
179
187
 
180
188
  const envOverrides = {};
181
189
  if (envVars.MCP_MODE) envOverrides.mode = envVars.MCP_MODE;
@@ -18,9 +18,10 @@ export class StdioMcpClient {
18
18
  try {
19
19
  const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
20
20
  const cmdStr = `${npxCmd} -y ${this.command} ${this.args.join(' ')}`;
21
- this.proc = spawn(cmdStr, {
21
+ const shell = process.platform === 'win32' ? 'cmd.exe' : '/bin/sh';
22
+ const shellArgs = process.platform === 'win32' ? ['/c', cmdStr] : ['-c', cmdStr];
23
+ this.proc = spawn(shell, shellArgs, {
22
24
  stdio: ['pipe', 'pipe', 'pipe'],
23
- shell: true,
24
25
  });
25
26
 
26
27
  this.proc.stdout.on('data', (data) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlisp/agent",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "AI Agent for @lisp - Connects to MCP Server for CAD operations",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -24,7 +24,7 @@
24
24
  "author": "vitalgg",
25
25
  "license": "ISC",
26
26
  "dependencies": {
27
- "@atlisp/mcp": "^1.0.20",
27
+ "@atlisp/mcp": "^1.0.21",
28
28
  "commander": "^11.1.0",
29
29
  "express": "^5.2.1",
30
30
  "yaml": "^2.6.1"
@@ -1,12 +1,14 @@
1
1
  import { VllmProvider } from './vllm.js';
2
2
  import { DeepseekProvider } from './deepseek.js';
3
3
  import { OpenAIProvider } from './openai.js';
4
+ import { MinimaxProvider } from './minimax.js';
4
5
  import { getLlmConfig } from '../config.js';
5
6
 
6
7
  const PROVIDERS = {
7
8
  vllm: VllmProvider,
8
9
  deepseek: DeepseekProvider,
9
10
  openai: OpenAIProvider,
11
+ minimax: MinimaxProvider,
10
12
  };
11
13
 
12
14
  export function createProvider(config = {}) {
@@ -0,0 +1,68 @@
1
+ import { getLlmConfig } from '../config.js';
2
+
3
+ export class MinimaxProvider {
4
+ constructor(config = {}) {
5
+ this.config = { ...getLlmConfig(), ...config };
6
+ this.baseURL = this.config.baseURL || 'https://api.minimax.chat/v1';
7
+ this.model = this.config.model || 'abab6.5s-chat';
8
+ this.apiKey = this.config.apiKey;
9
+ this.temperature = this.config.temperature;
10
+ this.maxTokens = this.config.maxTokens;
11
+ }
12
+
13
+ async chat(messages, options = {}) {
14
+ const url = `${this.baseURL}/text/chatcompletion`;
15
+ const body = {
16
+ model: this.model,
17
+ messages: messages,
18
+ temperature: options.temperature ?? this.temperature,
19
+ max_tokens: options.maxTokens ?? this.maxTokens,
20
+ };
21
+
22
+ const headers = {
23
+ 'Content-Type': 'application/json',
24
+ };
25
+
26
+ if (this.apiKey) {
27
+ headers['Authorization'] = `Bearer ${this.apiKey}`;
28
+ }
29
+
30
+ try {
31
+ const response = await fetch(url, {
32
+ method: 'POST',
33
+ headers: headers,
34
+ body: JSON.stringify(body),
35
+ });
36
+
37
+ if (!response.ok) {
38
+ const errorText = await response.text();
39
+ throw new Error(`Minimax API error: ${response.status} ${errorText}`);
40
+ }
41
+
42
+ const data = await response.json();
43
+
44
+ if (data.base_resp?.status_code !== 0 && data.base_resp?.status_code !== 200) {
45
+ const errMsg = data.base_resp?.status_msg || 'Unknown error';
46
+ throw new Error(`Minimax API error: ${errMsg}`);
47
+ }
48
+
49
+ if (data.reply) return data.reply;
50
+ if (data.choices && data.choices.length > 0) {
51
+ return data.choices[0].message.content;
52
+ }
53
+
54
+ throw new Error('No response content from Minimax: ' + JSON.stringify(data));
55
+ } catch (error) {
56
+ if (error.message.includes('fetch')) {
57
+ throw new Error(`无法连接到 Minimax API: ${error.message}`);
58
+ }
59
+ throw error;
60
+ }
61
+ }
62
+
63
+ getName() {
64
+ return 'minimax';
65
+ }
66
+ }
67
+
68
+ export default MinimaxProvider;
package/server.js CHANGED
@@ -6,7 +6,7 @@ import { getLlmConfig, getMcpConfig, getAgentConfig } from './config.js';
6
6
 
7
7
  const app = express();
8
8
 
9
- const PORT = process.env.AGENT_PORT || '8120';
9
+ const PORT = process.env.AGENT_PORT || '8110';
10
10
  const HOST = process.env.AGENT_HOST || '0.0.0.0';
11
11
 
12
12
  app.use(express.json({ limit: '10mb' }));