@agentscope-ai/chat 1.1.29 → 1.1.30
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/bin/cli.js +16 -74
- package/package.json +2 -3
- package/bin/cli.bundle.js +0 -3125
- package/bin/client.js +0 -14
- package/bin/template.html +0 -31
package/bin/cli.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
const { program } = require('commander');
|
|
2
|
-
const {
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs');
|
|
2
|
+
const { execSync } = require('child_process');
|
|
5
3
|
|
|
6
4
|
program
|
|
7
5
|
.name('agentscope-runtime-webui')
|
|
8
6
|
.description('启动 AgentScope Runtime WebUI 服务')
|
|
9
|
-
.option('-p, --port <port>', '指定服务端口', '3000')
|
|
10
7
|
.option('-u, --url <url>', '指定后端 API 地址')
|
|
11
8
|
.option('-t, --token <token>', '指定认证 token')
|
|
12
9
|
.parse(process.argv);
|
|
@@ -14,92 +11,37 @@ program
|
|
|
14
11
|
const options = program.opts();
|
|
15
12
|
|
|
16
13
|
async function startServer() {
|
|
17
|
-
console.log('🚀
|
|
18
|
-
console.log(`📦 端口: ${options.port}`);
|
|
19
|
-
if (options.url) {
|
|
20
|
-
console.log(`🔗 API 地址: ${options.url}`);
|
|
21
|
-
}
|
|
22
|
-
if (options.token) {
|
|
23
|
-
console.log(`🔑 Token: ${options.token.substring(0, 10)}...`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const templatePath = path.join(__dirname, 'template.html');
|
|
27
|
-
let htmlContent = fs.readFileSync(templatePath, 'utf-8');
|
|
14
|
+
console.log('\n🚀 Starting AgentScope Runtime WebUI...\n');
|
|
28
15
|
|
|
29
16
|
try {
|
|
30
|
-
// 找到项目根目录(包含 node_modules 的目录)
|
|
31
|
-
const projectRoot = path.resolve(__dirname, '..');
|
|
32
|
-
|
|
33
|
-
const server = await createServer({
|
|
34
|
-
configFile: false,
|
|
35
|
-
root: projectRoot,
|
|
36
|
-
server: {
|
|
37
|
-
port: parseInt(options.port),
|
|
38
|
-
host: '127.0.0.1',
|
|
39
|
-
},
|
|
40
|
-
resolve: {
|
|
41
|
-
alias: {
|
|
42
|
-
'@agentscope-ai/chat': path.resolve(projectRoot, 'lib/index.js'),
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
// 将 React 标记为外部依赖,使用 UMD 全局变量
|
|
46
|
-
build: {
|
|
47
|
-
rollupOptions: {
|
|
48
|
-
external: ['react', 'react-dom', 'react/jsx-runtime', 'react-dom/client'],
|
|
49
|
-
},
|
|
50
|
-
commonjsOptions: {
|
|
51
|
-
include: [/node_modules/],
|
|
52
|
-
transformMixedEsModules: true
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
plugins: [
|
|
56
|
-
{
|
|
57
|
-
name: 'agentscope-runtime-webui',
|
|
58
|
-
configureServer(server) {
|
|
59
|
-
server.middlewares.use((req, res, next) => {
|
|
60
|
-
if (req.url === '/' || req.url === '/index.html') {
|
|
61
|
-
// 注入配置到 HTML
|
|
62
|
-
const configScript = `
|
|
63
|
-
<script>
|
|
64
|
-
window.__AGENTSCOPE_CONFIG__ = {
|
|
65
|
-
url: '${options.url || ''}',
|
|
66
|
-
token: '${options.token || ''}',
|
|
67
|
-
};
|
|
68
|
-
</script>`;
|
|
69
|
-
const html = htmlContent.replace('</head>', `${configScript}\n </head>`);
|
|
70
|
-
res.setHeader('Content-Type', 'text/html');
|
|
71
|
-
res.end(html);
|
|
72
|
-
} else {
|
|
73
|
-
next();
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
});
|
|
80
17
|
|
|
81
|
-
|
|
18
|
+
try {
|
|
19
|
+
execSync('git clone https://github.com/agentscope-ai/agentscope-runtime.git -b dev', {
|
|
20
|
+
stdio: 'inherit',
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
} catch (error) {}
|
|
24
|
+
|
|
25
|
+
execSync(
|
|
26
|
+
'cd agentscope-runtime/web/starter_webui && npm install && npm run dev',
|
|
27
|
+
{
|
|
28
|
+
stdio: 'inherit',
|
|
29
|
+
},
|
|
30
|
+
);
|
|
82
31
|
|
|
83
|
-
console.log('\n✅ AgentScope Runtime WebUI 已启动!');
|
|
84
|
-
console.log(`\n🌐 访问地址: http://localhost:${options.port}\n`);
|
|
85
|
-
|
|
86
32
|
process.on('SIGINT', () => {
|
|
87
|
-
console.log('\n\n👋 正在关闭服务器...');
|
|
88
33
|
server.close();
|
|
89
34
|
process.exit(0);
|
|
90
35
|
});
|
|
91
36
|
|
|
92
37
|
process.on('SIGTERM', () => {
|
|
93
|
-
console.log('\n\n👋 正在关闭服务器...');
|
|
94
38
|
server.close();
|
|
95
39
|
process.exit(0);
|
|
96
40
|
});
|
|
97
|
-
|
|
98
41
|
} catch (error) {
|
|
99
|
-
console.error(
|
|
42
|
+
console.error(error);
|
|
100
43
|
process.exit(1);
|
|
101
44
|
}
|
|
102
45
|
}
|
|
103
46
|
|
|
104
47
|
startServer();
|
|
105
|
-
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentscope-ai/chat",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.30",
|
|
4
4
|
"description": "a free and open-source chat framework for building excellent LLM-powered chat experiences",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": [
|
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
"components"
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "npm run
|
|
23
|
-
"build:cli": "node scripts/build-cli.js",
|
|
22
|
+
"build": "npm run src:build && npm run docs:build",
|
|
24
23
|
"build:doc-api": "rm -rf node_modules && tnpm i && npm run start",
|
|
25
24
|
"build:publish": "NPM_PUBLISH=1 npm run build:cli && npm run src:build",
|
|
26
25
|
"build:watch": "father dev",
|