@yeaft/webchat-agent 0.1.202 → 0.1.204
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/crew/role-query.js +3 -2
- package/package.json +1 -1
- package/sdk/query.js +2 -1
- package/terminal.js +4 -4
package/crew/role-query.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* createRoleQuery, buildRoleSystemPrompt, sessionId 持久化, 错误分类
|
|
4
4
|
*/
|
|
5
5
|
import { query, Stream } from '../sdk/index.js';
|
|
6
|
-
import { promises as fs } from 'fs';
|
|
6
|
+
import { promises as fs, mkdirSync } from 'fs';
|
|
7
7
|
import { join } from 'path';
|
|
8
8
|
import { getMessages } from '../crew-i18n.js';
|
|
9
9
|
import ctx from '../context.js';
|
|
@@ -140,8 +140,9 @@ async function _createRoleQueryInner(session, roleName) {
|
|
|
140
140
|
// 尝试加载之前保存的 sessionId
|
|
141
141
|
const savedSessionId = await loadRoleSessionId(session.sharedDir, roleName);
|
|
142
142
|
|
|
143
|
-
// cwd
|
|
143
|
+
// cwd 设为角色目录(确保目录存在,否则 spawn() 会报误导性的 ENOENT)
|
|
144
144
|
const roleCwd = join(session.sharedDir, 'roles', roleName);
|
|
145
|
+
mkdirSync(roleCwd, { recursive: true });
|
|
145
146
|
|
|
146
147
|
// 继承全局 MCP disallowedTools,避免不必要的 tool schema token 消耗
|
|
147
148
|
const globalDisallowed = ctx.CONFIG?.disallowedTools || [];
|
package/package.json
CHANGED
package/sdk/query.js
CHANGED
|
@@ -445,7 +445,8 @@ export function query(config) {
|
|
|
445
445
|
if (abort?.aborted) {
|
|
446
446
|
queryInstance.setError(new AbortError('Claude Code process aborted by user'));
|
|
447
447
|
} else {
|
|
448
|
-
|
|
448
|
+
const cwdInfo = error.code === 'ENOENT' && cwd ? ` (cwd: ${cwd})` : '';
|
|
449
|
+
queryInstance.setError(new Error(`Failed to spawn Claude Code process: ${error.message}${cwdInfo}`));
|
|
449
450
|
}
|
|
450
451
|
});
|
|
451
452
|
|
package/terminal.js
CHANGED
|
@@ -4,11 +4,11 @@ import { join, dirname } from 'path';
|
|
|
4
4
|
import { createRequire } from 'module';
|
|
5
5
|
import ctx from './context.js';
|
|
6
6
|
|
|
7
|
-
//
|
|
7
|
+
// Ensure spawn-helper has executable permission on Unix systems.
|
|
8
8
|
// npm may strip execute bits from prebuilt binaries, causing
|
|
9
9
|
// "posix_spawnp failed" on macOS/Linux.
|
|
10
10
|
// TODO: Remove this workaround once node-pty ships with correct permissions.
|
|
11
|
-
function
|
|
11
|
+
function ensureSpawnHelperPermissions() {
|
|
12
12
|
if (platform() === 'win32') return;
|
|
13
13
|
try {
|
|
14
14
|
const cjsRequire = createRequire(import.meta.url);
|
|
@@ -26,7 +26,7 @@ function fixSpawnHelperPermissions() {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
} catch (e) {
|
|
29
|
-
console.warn('[PTY]
|
|
29
|
+
console.warn('[PTY] Could not ensure spawn-helper permissions:', e.message);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -36,7 +36,7 @@ export async function loadNodePty() {
|
|
|
36
36
|
try {
|
|
37
37
|
let pty = await import('node-pty');
|
|
38
38
|
if (pty.default) pty = pty.default;
|
|
39
|
-
|
|
39
|
+
ensureSpawnHelperPermissions();
|
|
40
40
|
ctx.nodePty = pty;
|
|
41
41
|
console.log('[PTY] node-pty loaded successfully');
|
|
42
42
|
return pty;
|