@yeaft/webchat-agent 0.1.809 → 0.1.811
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/claude.js +8 -4
- package/crew/role-query.js +5 -2
- package/package.json +1 -1
- package/unify/web-bridge.js +37 -8
package/claude.js
CHANGED
|
@@ -102,15 +102,19 @@ export async function startClaudeQuery(conversationId, workDir, resumeSessionId)
|
|
|
102
102
|
// 配置 SDK query 选项
|
|
103
103
|
const options = {
|
|
104
104
|
cwd: workDir,
|
|
105
|
-
|
|
105
|
+
// 不显式设 permissionMode(让它走 SDK 默认 'default')。
|
|
106
|
+
// bypassPermissions 会让 CLI 跳过整个 permission 通道,但我们注册了
|
|
107
|
+
// canCallTool(→ --permission-prompt-tool stdio)来拦截
|
|
108
|
+
// AskUserQuestion;新版 Claude CLI 在 bypass+stdio 同时存在时会
|
|
109
|
+
// 卡在 init 握手 / message_start 后死等。改用 default mode +
|
|
110
|
+
// canCallTool 自动放行,是新 CLI 期望的形态。
|
|
106
111
|
abort: abortController.signal,
|
|
107
|
-
// 拦截 AskUserQuestion 工具调用,转发到 Web UI
|
|
112
|
+
// 拦截 AskUserQuestion 工具调用,转发到 Web UI;其他工具自动放行
|
|
108
113
|
canCallTool: async (toolName, input, toolCtx) => {
|
|
109
114
|
if (toolName === 'AskUserQuestion') {
|
|
110
115
|
return await handleAskUserQuestion(conversationId, input, toolCtx);
|
|
111
116
|
}
|
|
112
|
-
|
|
113
|
-
return input;
|
|
117
|
+
return { behavior: 'allow', updatedInput: input };
|
|
114
118
|
}
|
|
115
119
|
};
|
|
116
120
|
|
package/crew/role-query.js
CHANGED
|
@@ -160,7 +160,10 @@ async function _createRoleQueryInner(session, roleName) {
|
|
|
160
160
|
|
|
161
161
|
const queryOptions = {
|
|
162
162
|
cwd: roleCwd,
|
|
163
|
-
permissionMode
|
|
163
|
+
// 不设 permissionMode(走 SDK 默认 'default')。bypassPermissions +
|
|
164
|
+
// canCallTool 在新版 Claude CLI 会卡死 init 握手 / message_start。
|
|
165
|
+
// canCallTool 在 default 模式下能正常工作,并对非 AskUserQuestion
|
|
166
|
+
// 工具返回 { behavior:'allow', updatedInput } 等同放行。
|
|
164
167
|
abort: abortController.signal,
|
|
165
168
|
model: role.model || undefined,
|
|
166
169
|
appendSystemPrompt: systemPrompt,
|
|
@@ -177,7 +180,7 @@ async function _createRoleQueryInner(session, roleName) {
|
|
|
177
180
|
if (toolName === 'AskUserQuestion') {
|
|
178
181
|
return await handleAskUserQuestion(session.id, input, toolCtx);
|
|
179
182
|
}
|
|
180
|
-
return input;
|
|
183
|
+
return { behavior: 'allow', updatedInput: input };
|
|
181
184
|
};
|
|
182
185
|
|
|
183
186
|
if (savedSessionId) {
|
package/package.json
CHANGED
package/unify/web-bridge.js
CHANGED
|
@@ -1653,6 +1653,10 @@ function maybeTransitionVpStatus(hctx, state) {
|
|
|
1653
1653
|
* @param {object} event — engine event (text_delta / tool_call / …)
|
|
1654
1654
|
* @param {{assistantTextParts:string[], toolCallsAccum:Array, toolResultsAccum:Array, thinkingBlocksAccum?:Array, resetQueryTimer:Function, groupId?:string, vpId?:string, turnId?:string}} hctx
|
|
1655
1655
|
*/
|
|
1656
|
+
export function __testHandleEngineEvent(event, hctx) {
|
|
1657
|
+
return handleEngineEvent(event, hctx);
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1656
1660
|
function handleEngineEvent(event, hctx) {
|
|
1657
1661
|
hctx.resetQueryTimer();
|
|
1658
1662
|
const envelope = {
|
|
@@ -1773,14 +1777,39 @@ function handleEngineEvent(event, hctx) {
|
|
|
1773
1777
|
break;
|
|
1774
1778
|
|
|
1775
1779
|
case 'turn_end':
|
|
1776
|
-
// turn_end
|
|
1777
|
-
//
|
|
1778
|
-
//
|
|
1779
|
-
//
|
|
1780
|
-
//
|
|
1781
|
-
//
|
|
1782
|
-
|
|
1783
|
-
|
|
1780
|
+
// Most engine turn_end events are internal loop boundaries. A normal
|
|
1781
|
+
// tool_use stop means "run tools, then call the adapter again", so it
|
|
1782
|
+
// must NOT end the VP's visible turn. route_forward is different: the
|
|
1783
|
+
// tool has handed control to another VP and Engine.query will not
|
|
1784
|
+
// stream more text for this VP. Settle the current VP immediately so
|
|
1785
|
+
// the roster row does not sit on "thinking" until later result cleanup.
|
|
1786
|
+
if (event.stopReason === 'tool_handoff' && event.detail?.kind === 'route_forward') {
|
|
1787
|
+
try {
|
|
1788
|
+
if (hctx.thread) {
|
|
1789
|
+
hctx.thread.status = 'idle';
|
|
1790
|
+
hctx.thread.updatedAt = Date.now();
|
|
1791
|
+
}
|
|
1792
|
+
getVpStatusBroker().settleIdle({
|
|
1793
|
+
groupId: hctx.groupId || null,
|
|
1794
|
+
vpId: hctx.vpId,
|
|
1795
|
+
threadId: hctx.threadId || 'main',
|
|
1796
|
+
title: hctx.thread?.title || '',
|
|
1797
|
+
messageCount: hctx.thread?.messageIds?.length || 0,
|
|
1798
|
+
});
|
|
1799
|
+
} catch (err) {
|
|
1800
|
+
console.warn('[Unify] vp-status settleIdle (route_forward) failed:', err?.message || err);
|
|
1801
|
+
}
|
|
1802
|
+
sendUnifyEvent({
|
|
1803
|
+
type: 'vp_turn_end',
|
|
1804
|
+
groupId: hctx.groupId,
|
|
1805
|
+
vpId: hctx.vpId,
|
|
1806
|
+
threadId: hctx.threadId || event.threadId || 'main',
|
|
1807
|
+
turnId: hctx.turnId,
|
|
1808
|
+
stopReason: event.stopReason,
|
|
1809
|
+
detail: event.detail || null,
|
|
1810
|
+
ts: Date.now(),
|
|
1811
|
+
}, envelope);
|
|
1812
|
+
}
|
|
1784
1813
|
break;
|
|
1785
1814
|
|
|
1786
1815
|
case 'usage':
|