@atlisp/agent 0.1.15 → 0.1.17
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 +4 -4
- package/agent.js +6 -3
- package/config.js +13 -5
- package/mcp/stdio-client.js +3 -2
- package/package.json +2 -2
- package/server.js +1 -1
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
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
|
-
|
|
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('
|
|
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:
|
|
70
|
+
maxTokens: 65536,
|
|
71
71
|
},
|
|
72
72
|
mcp: {
|
|
73
73
|
mode: 'stdio',
|
|
74
|
-
url: 'http://localhost:
|
|
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();
|
|
@@ -148,7 +156,7 @@ function getConfig() {
|
|
|
148
156
|
|
|
149
157
|
export function getAgentConfig() {
|
|
150
158
|
const config = getConfig().agent;
|
|
151
|
-
const envVars =
|
|
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 =
|
|
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 =
|
|
186
|
+
const envVars = getEnvVars();
|
|
179
187
|
|
|
180
188
|
const envOverrides = {};
|
|
181
189
|
if (envVars.MCP_MODE) envOverrides.mode = envVars.MCP_MODE;
|
package/mcp/stdio-client.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
3
|
+
"version": "0.1.17",
|
|
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.
|
|
27
|
+
"@atlisp/mcp": "^1.0.21",
|
|
28
28
|
"commander": "^11.1.0",
|
|
29
29
|
"express": "^5.2.1",
|
|
30
30
|
"yaml": "^2.6.1"
|
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 || '
|
|
9
|
+
const PORT = process.env.AGENT_PORT || '8210';
|
|
10
10
|
const HOST = process.env.AGENT_HOST || '0.0.0.0';
|
|
11
11
|
|
|
12
12
|
app.use(express.json({ limit: '10mb' }));
|