@yeaft/webchat-agent 0.1.221 → 0.1.224
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/conductor.js +46 -0
- package/connection/message-router.js +48 -0
- package/connection/upgrade.js +4 -3
- package/index.js +2 -0
- package/package.json +1 -1
package/conductor.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conductor Mode — 自适应项目执行引擎
|
|
3
|
+
*
|
|
4
|
+
* V2 的核心入口。与 crew.js 并存,不替代。
|
|
5
|
+
*
|
|
6
|
+
* 本文件聚合并重新导出 conductor 子模块的公共 API,
|
|
7
|
+
* 供 message-router.js 消费。
|
|
8
|
+
*
|
|
9
|
+
* hideConductorSession / handleLoadConductorHistory 需要跨模块依赖,
|
|
10
|
+
* 在这里注入,避免 persistence.js ↔ session.js 循环引用。
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Session 核心
|
|
14
|
+
export {
|
|
15
|
+
conductorSessions,
|
|
16
|
+
createConductorSession,
|
|
17
|
+
handleListConductorSessions,
|
|
18
|
+
resumeConductorSession,
|
|
19
|
+
handleConductorUserInput,
|
|
20
|
+
handleUpdateWorkDir,
|
|
21
|
+
handleUpdateConductorSession,
|
|
22
|
+
stopConductorSession,
|
|
23
|
+
clearConductorSession
|
|
24
|
+
} from './conductor/session.js';
|
|
25
|
+
|
|
26
|
+
// 持久化(原始导出)
|
|
27
|
+
export { loadConductorIndex } from './conductor/persistence.js';
|
|
28
|
+
|
|
29
|
+
// 依赖注入包装:hideConductorSession
|
|
30
|
+
import { conductorSessions } from './conductor/session.js';
|
|
31
|
+
import { sendConductorMessage } from './conductor/ui-messages.js';
|
|
32
|
+
import {
|
|
33
|
+
hideConductorSession as _hideConductorSession,
|
|
34
|
+
handleLoadConductorHistory as _handleLoadConductorHistory
|
|
35
|
+
} from './conductor/persistence.js';
|
|
36
|
+
|
|
37
|
+
export async function hideConductorSession(sessionId) {
|
|
38
|
+
return _hideConductorSession(sessionId, conductorSessions);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function handleLoadConductorHistory(msg) {
|
|
42
|
+
return _handleLoadConductorHistory(msg, conductorSessions, sendConductorMessage);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 信号量
|
|
46
|
+
export { globalSemaphore } from './conductor/semaphore.js';
|
|
@@ -20,6 +20,13 @@ import {
|
|
|
20
20
|
handleListCrewSessions, handleCheckCrewExists, handleDeleteCrewDir, resumeCrewSession, removeFromCrewIndex, hideCrewSession,
|
|
21
21
|
handleLoadCrewHistory, handleCheckCrewContext
|
|
22
22
|
} from '../crew.js';
|
|
23
|
+
import {
|
|
24
|
+
createConductorSession, handleListConductorSessions,
|
|
25
|
+
resumeConductorSession, handleConductorUserInput,
|
|
26
|
+
handleUpdateWorkDir, handleUpdateConductorSession,
|
|
27
|
+
stopConductorSession, clearConductorSession,
|
|
28
|
+
hideConductorSession, handleLoadConductorHistory
|
|
29
|
+
} from '../conductor.js';
|
|
23
30
|
import { sendToServer, flushMessageBuffer } from './buffer.js';
|
|
24
31
|
import { handleRestartAgent, handleUpgradeAgent } from './upgrade.js';
|
|
25
32
|
import { loadMcpServers, updateMcpConfig } from '../mcp.js';
|
|
@@ -252,6 +259,47 @@ export async function handleMessage(msg) {
|
|
|
252
259
|
await handleLoadCrewHistory(msg);
|
|
253
260
|
break;
|
|
254
261
|
|
|
262
|
+
// Conductor (V2) messages
|
|
263
|
+
case 'create_conductor_session':
|
|
264
|
+
await createConductorSession(msg);
|
|
265
|
+
break;
|
|
266
|
+
|
|
267
|
+
case 'list_conductor_sessions':
|
|
268
|
+
await handleListConductorSessions(msg);
|
|
269
|
+
break;
|
|
270
|
+
|
|
271
|
+
case 'resume_conductor_session':
|
|
272
|
+
await resumeConductorSession(msg);
|
|
273
|
+
break;
|
|
274
|
+
|
|
275
|
+
case 'conductor_user_input':
|
|
276
|
+
await handleConductorUserInput(msg);
|
|
277
|
+
break;
|
|
278
|
+
|
|
279
|
+
case 'conductor_update_workdir':
|
|
280
|
+
await handleUpdateWorkDir(msg);
|
|
281
|
+
break;
|
|
282
|
+
|
|
283
|
+
case 'update_conductor_session':
|
|
284
|
+
await handleUpdateConductorSession(msg);
|
|
285
|
+
break;
|
|
286
|
+
|
|
287
|
+
case 'stop_conductor_session':
|
|
288
|
+
await stopConductorSession(msg.sessionId);
|
|
289
|
+
break;
|
|
290
|
+
|
|
291
|
+
case 'clear_conductor_session':
|
|
292
|
+
await clearConductorSession(msg.sessionId);
|
|
293
|
+
break;
|
|
294
|
+
|
|
295
|
+
case 'delete_conductor_session':
|
|
296
|
+
await hideConductorSession(msg.sessionId);
|
|
297
|
+
break;
|
|
298
|
+
|
|
299
|
+
case 'conductor_load_history':
|
|
300
|
+
await handleLoadConductorHistory(msg);
|
|
301
|
+
break;
|
|
302
|
+
|
|
255
303
|
// Port proxy
|
|
256
304
|
case 'proxy_request':
|
|
257
305
|
handleProxyHttpRequest(msg);
|
package/connection/upgrade.js
CHANGED
|
@@ -17,6 +17,7 @@ const nodeBinDir = dirname(process.execPath);
|
|
|
17
17
|
const isWin = platform() === 'win32';
|
|
18
18
|
const npmPath = join(nodeBinDir, isWin ? 'npm.cmd' : 'npm');
|
|
19
19
|
const pm2Path = join(nodeBinDir, isWin ? 'pm2.cmd' : 'pm2');
|
|
20
|
+
const shellOpt = isWin ? { shell: true } : {};
|
|
20
21
|
|
|
21
22
|
// Shared cleanup logic for restart/upgrade
|
|
22
23
|
function cleanupAndExit(exitCode) {
|
|
@@ -54,7 +55,7 @@ export async function handleUpgradeAgent() {
|
|
|
54
55
|
const pkgName = ctx.pkgName || '@yeaft/webchat-agent';
|
|
55
56
|
// Check latest version (async to avoid blocking heartbeat)
|
|
56
57
|
const latestVersion = await new Promise((resolve, reject) => {
|
|
57
|
-
execFile(npmPath, ['view', pkgName, 'version'], { stdio: 'pipe' }, (err, stdout) => {
|
|
58
|
+
execFile(npmPath, ['view', pkgName, 'version'], { stdio: 'pipe', ...shellOpt }, (err, stdout) => {
|
|
58
59
|
if (err) reject(err); else resolve(stdout.toString().trim());
|
|
59
60
|
});
|
|
60
61
|
});
|
|
@@ -82,7 +83,7 @@ export async function handleUpgradeAgent() {
|
|
|
82
83
|
|
|
83
84
|
// 判断全局安装 vs 局部安装
|
|
84
85
|
const isGlobalInstall = await new Promise((resolve) => {
|
|
85
|
-
execFile(npmPath, ['prefix', '-g'], (err, stdout) => {
|
|
86
|
+
execFile(npmPath, ['prefix', '-g'], { ...shellOpt }, (err, stdout) => {
|
|
86
87
|
if (err) { resolve(false); return; }
|
|
87
88
|
const globalPrefix = stdout.toString().trim().replace(/\\/g, '/');
|
|
88
89
|
resolve(installDir === globalPrefix || installDir === globalPrefix + '/lib');
|
|
@@ -102,7 +103,7 @@ export async function handleUpgradeAgent() {
|
|
|
102
103
|
const isPm2 = !!process.env.pm_id;
|
|
103
104
|
if (isPm2) {
|
|
104
105
|
try {
|
|
105
|
-
execFileSync(pm2Path, ['delete', PM2_APP_NAME], { stdio: 'pipe' });
|
|
106
|
+
execFileSync(pm2Path, ['delete', PM2_APP_NAME], { stdio: 'pipe', ...shellOpt });
|
|
106
107
|
console.log(`[Agent] PM2 app deleted to prevent auto-restart during upgrade`);
|
|
107
108
|
} catch {
|
|
108
109
|
console.log(`[Agent] PM2 delete skipped (app may not be registered)`);
|
package/index.js
CHANGED
|
@@ -99,6 +99,8 @@ async function detectCapabilities() {
|
|
|
99
99
|
const { getDefaultClaudeCodePath } = await import('./sdk/utils.js');
|
|
100
100
|
const claudePath = getDefaultClaudeCodePath();
|
|
101
101
|
if (claudePath) capabilities.push('crew');
|
|
102
|
+
// Conductor V2 reuses the same Claude CLI
|
|
103
|
+
if (claudePath) capabilities.push('conductor');
|
|
102
104
|
} catch {}
|
|
103
105
|
|
|
104
106
|
console.log(`[Capabilities] Detected: ${capabilities.join(', ')}`);
|