@agentscope-ai/chat 1.1.28 → 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 CHANGED
@@ -1,12 +1,9 @@
1
1
  const { program } = require('commander');
2
- const { createServer } = require('vite');
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,90 +11,37 @@ program
14
11
  const options = program.opts();
15
12
 
16
13
  async function startServer() {
17
- console.log('🚀 正在启动 AgentScope Runtime WebUI...');
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
- dedupe: ['react', 'react-dom'],
42
- alias: {
43
- '@agentscope-ai/chat': path.resolve(projectRoot, 'lib/index.js'),
44
- }
45
- },
46
-
47
- build: {
48
- commonjsOptions: {
49
- include: [/node_modules/],
50
- transformMixedEsModules: true
51
- }
52
- },
53
- plugins: [
54
- {
55
- name: 'agentscope-runtime-webui',
56
- configureServer(server) {
57
- server.middlewares.use((req, res, next) => {
58
- if (req.url === '/' || req.url === '/index.html') {
59
- // 注入配置到 HTML
60
- const configScript = `
61
- <script>
62
- window.__AGENTSCOPE_CONFIG__ = {
63
- url: '${options.url || ''}',
64
- token: '${options.token || ''}',
65
- };
66
- </script>`;
67
- const html = htmlContent.replace('</head>', `${configScript}\n </head>`);
68
- res.setHeader('Content-Type', 'text/html');
69
- res.end(html);
70
- } else {
71
- next();
72
- }
73
- });
74
- },
75
- },
76
- ],
77
- });
78
17
 
79
- await server.listen();
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
+ );
80
31
 
81
- console.log('\n✅ AgentScope Runtime WebUI 已启动!');
82
- console.log(`\n🌐 访问地址: http://localhost:${options.port}\n`);
83
-
84
32
  process.on('SIGINT', () => {
85
- console.log('\n\n👋 正在关闭服务器...');
86
33
  server.close();
87
34
  process.exit(0);
88
35
  });
89
36
 
90
37
  process.on('SIGTERM', () => {
91
- console.log('\n\n👋 正在关闭服务器...');
92
38
  server.close();
93
39
  process.exit(0);
94
40
  });
95
-
96
41
  } catch (error) {
97
- console.error('❌ 启动失败:', error);
42
+ console.error(error);
98
43
  process.exit(1);
99
44
  }
100
45
  }
101
46
 
102
47
  startServer();
103
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentscope-ai/chat",
3
- "version": "1.1.28",
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 build:cli && npm run src:build && npm run docs:build",
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",
@@ -105,9 +104,7 @@
105
104
  "xstate": "^5.19.4",
106
105
  "zustand": "^5.0.3",
107
106
  "vite": "^5.4.11",
108
- "antd": "^5.18.0",
109
- "react": "^18.0.0",
110
- "react-dom": "^18.0.0"
107
+ "antd": "^5.18.0"
111
108
  },
112
109
  "devDependencies": {
113
110
  "@agentscope-ai/dumi-theme-spark": "0.0.98",
@@ -125,6 +122,8 @@
125
122
  "dumi": "^2.4.13",
126
123
  "esbuild": "^0.19.12",
127
124
  "eslint": "^8.23.0",
125
+ "react": "^18.0.0",
126
+ "react-dom": "^18.0.0",
128
127
  "father": "^4.1.0",
129
128
  "husky": "^8.0.1",
130
129
  "lint-staged": "^13.0.3",