@yeaft/webchat-agent 0.1.213 → 0.1.216
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 +15 -1
- package/package.json +1 -1
package/crew/role-query.js
CHANGED
|
@@ -6,6 +6,7 @@ import { query, Stream } from '../sdk/index.js';
|
|
|
6
6
|
import { promises as fs, mkdirSync } from 'fs';
|
|
7
7
|
import { join } from 'path';
|
|
8
8
|
import { getMessages } from '../crew-i18n.js';
|
|
9
|
+
import { handleAskUserQuestion } from '../conversation.js';
|
|
9
10
|
import ctx from '../context.js';
|
|
10
11
|
|
|
11
12
|
/** Format role label */
|
|
@@ -146,6 +147,9 @@ async function _createRoleQueryInner(session, roleName) {
|
|
|
146
147
|
|
|
147
148
|
// 继承全局 MCP disallowedTools,避免不必要的 tool schema token 消耗
|
|
148
149
|
const globalDisallowed = ctx.CONFIG?.disallowedTools || [];
|
|
150
|
+
// Crew 角色禁用 Agent 工具,强制通过 ROUTE 块协作
|
|
151
|
+
const crewDisallowed = ['Agent'];
|
|
152
|
+
const effectiveDisallowed = [...globalDisallowed, ...crewDisallowed];
|
|
149
153
|
|
|
150
154
|
const queryOptions = {
|
|
151
155
|
cwd: roleCwd,
|
|
@@ -153,9 +157,19 @@ async function _createRoleQueryInner(session, roleName) {
|
|
|
153
157
|
abort: abortController.signal,
|
|
154
158
|
model: role.model || undefined,
|
|
155
159
|
appendSystemPrompt: systemPrompt,
|
|
156
|
-
...(
|
|
160
|
+
...(effectiveDisallowed.length > 0 && { disallowedTools: effectiveDisallowed })
|
|
157
161
|
};
|
|
158
162
|
|
|
163
|
+
// Only the decision maker intercepts AskUserQuestion to forward to Web UI
|
|
164
|
+
if (role.isDecisionMaker) {
|
|
165
|
+
queryOptions.canCallTool = async (toolName, input, toolCtx) => {
|
|
166
|
+
if (toolName === 'AskUserQuestion') {
|
|
167
|
+
return await handleAskUserQuestion(session.id, input, toolCtx);
|
|
168
|
+
}
|
|
169
|
+
return input;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
159
173
|
if (savedSessionId) {
|
|
160
174
|
queryOptions.resume = savedSessionId;
|
|
161
175
|
console.log(`[Crew] Resuming ${roleName} with sessionId: ${savedSessionId}`);
|