@yeaft/webchat-agent 0.0.132 → 0.0.133
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.js +34 -1
- package/package.json +1 -1
package/crew.js
CHANGED
|
@@ -1854,7 +1854,9 @@ function sendCrewOutput(session, roleName, outputType, rawMessage, extra = {}) {
|
|
|
1854
1854
|
session.uiMessages.push({
|
|
1855
1855
|
role: roleName, roleIcon, roleName: displayName,
|
|
1856
1856
|
type: 'route', routeTo: extra.routeTo,
|
|
1857
|
+
routeSummary: extra.routeSummary || '',
|
|
1857
1858
|
content: `→ @${extra.routeTo} ${extra.routeSummary || ''}`,
|
|
1859
|
+
taskId, taskTitle,
|
|
1858
1860
|
timestamp: Date.now()
|
|
1859
1861
|
});
|
|
1860
1862
|
} else if (outputType === 'system') {
|
|
@@ -1871,8 +1873,39 @@ function sendCrewOutput(session, roleName, outputType, rawMessage, extra = {}) {
|
|
|
1871
1873
|
type: 'system', content: text,
|
|
1872
1874
|
timestamp: Date.now()
|
|
1873
1875
|
});
|
|
1876
|
+
} else if (outputType === 'tool_use') {
|
|
1877
|
+
// 结束该角色前一条 streaming
|
|
1878
|
+
endRoleStreaming(session, roleName);
|
|
1879
|
+
const content = rawMessage?.message?.content;
|
|
1880
|
+
if (Array.isArray(content)) {
|
|
1881
|
+
for (const block of content) {
|
|
1882
|
+
if (block.type === 'tool_use') {
|
|
1883
|
+
session.uiMessages.push({
|
|
1884
|
+
role: roleName, roleIcon, roleName: displayName,
|
|
1885
|
+
type: 'tool',
|
|
1886
|
+
toolName: block.name,
|
|
1887
|
+
toolId: block.id,
|
|
1888
|
+
content: `${block.name} ${block.input?.file_path || block.input?.command?.substring(0, 60) || ''}`,
|
|
1889
|
+
hasResult: false,
|
|
1890
|
+
taskId, taskTitle,
|
|
1891
|
+
timestamp: Date.now()
|
|
1892
|
+
});
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
} else if (outputType === 'tool_result') {
|
|
1897
|
+
// 标记对应 tool 的 hasResult
|
|
1898
|
+
const toolId = rawMessage?.message?.tool_use_id;
|
|
1899
|
+
if (toolId) {
|
|
1900
|
+
for (let i = session.uiMessages.length - 1; i >= 0; i--) {
|
|
1901
|
+
if (session.uiMessages[i].type === 'tool' && session.uiMessages[i].toolId === toolId) {
|
|
1902
|
+
session.uiMessages[i].hasResult = true;
|
|
1903
|
+
break;
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1874
1907
|
}
|
|
1875
|
-
//
|
|
1908
|
+
// tool 只保存精简信息(toolName + 摘要),不存完整 toolInput/toolResult
|
|
1876
1909
|
}
|
|
1877
1910
|
|
|
1878
1911
|
/**
|