@yeaft/webchat-agent 0.0.132 → 0.0.134
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 +41 -1
- package/package.json +1 -1
package/crew.js
CHANGED
|
@@ -1682,6 +1682,9 @@ async function pauseAll(session) {
|
|
|
1682
1682
|
message: { role: 'assistant', content: [{ type: 'text', text: 'Session 已暂停' }] }
|
|
1683
1683
|
});
|
|
1684
1684
|
sendStatusUpdate(session);
|
|
1685
|
+
|
|
1686
|
+
// 显式 await 保存,确保暂停状态落盘
|
|
1687
|
+
await saveSessionMeta(session);
|
|
1685
1688
|
}
|
|
1686
1689
|
|
|
1687
1690
|
/**
|
|
@@ -1776,6 +1779,10 @@ async function stopAll(session) {
|
|
|
1776
1779
|
// 清理 git worktrees
|
|
1777
1780
|
await cleanupWorktrees(session.projectDir);
|
|
1778
1781
|
|
|
1782
|
+
// 显式 await 保存,确保 session.json 落盘后再从内存中移除
|
|
1783
|
+
await saveSessionMeta(session);
|
|
1784
|
+
await upsertCrewIndex(session);
|
|
1785
|
+
|
|
1779
1786
|
// 从活跃 sessions 中移除
|
|
1780
1787
|
crewSessions.delete(session.id);
|
|
1781
1788
|
console.log(`[Crew] Session ${session.id} stopped`);
|
|
@@ -1854,7 +1861,9 @@ function sendCrewOutput(session, roleName, outputType, rawMessage, extra = {}) {
|
|
|
1854
1861
|
session.uiMessages.push({
|
|
1855
1862
|
role: roleName, roleIcon, roleName: displayName,
|
|
1856
1863
|
type: 'route', routeTo: extra.routeTo,
|
|
1864
|
+
routeSummary: extra.routeSummary || '',
|
|
1857
1865
|
content: `→ @${extra.routeTo} ${extra.routeSummary || ''}`,
|
|
1866
|
+
taskId, taskTitle,
|
|
1858
1867
|
timestamp: Date.now()
|
|
1859
1868
|
});
|
|
1860
1869
|
} else if (outputType === 'system') {
|
|
@@ -1871,8 +1880,39 @@ function sendCrewOutput(session, roleName, outputType, rawMessage, extra = {}) {
|
|
|
1871
1880
|
type: 'system', content: text,
|
|
1872
1881
|
timestamp: Date.now()
|
|
1873
1882
|
});
|
|
1883
|
+
} else if (outputType === 'tool_use') {
|
|
1884
|
+
// 结束该角色前一条 streaming
|
|
1885
|
+
endRoleStreaming(session, roleName);
|
|
1886
|
+
const content = rawMessage?.message?.content;
|
|
1887
|
+
if (Array.isArray(content)) {
|
|
1888
|
+
for (const block of content) {
|
|
1889
|
+
if (block.type === 'tool_use') {
|
|
1890
|
+
session.uiMessages.push({
|
|
1891
|
+
role: roleName, roleIcon, roleName: displayName,
|
|
1892
|
+
type: 'tool',
|
|
1893
|
+
toolName: block.name,
|
|
1894
|
+
toolId: block.id,
|
|
1895
|
+
content: `${block.name} ${block.input?.file_path || block.input?.command?.substring(0, 60) || ''}`,
|
|
1896
|
+
hasResult: false,
|
|
1897
|
+
taskId, taskTitle,
|
|
1898
|
+
timestamp: Date.now()
|
|
1899
|
+
});
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
} else if (outputType === 'tool_result') {
|
|
1904
|
+
// 标记对应 tool 的 hasResult
|
|
1905
|
+
const toolId = rawMessage?.message?.tool_use_id;
|
|
1906
|
+
if (toolId) {
|
|
1907
|
+
for (let i = session.uiMessages.length - 1; i >= 0; i--) {
|
|
1908
|
+
if (session.uiMessages[i].type === 'tool' && session.uiMessages[i].toolId === toolId) {
|
|
1909
|
+
session.uiMessages[i].hasResult = true;
|
|
1910
|
+
break;
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1874
1914
|
}
|
|
1875
|
-
//
|
|
1915
|
+
// tool 只保存精简信息(toolName + 摘要),不存完整 toolInput/toolResult
|
|
1876
1916
|
}
|
|
1877
1917
|
|
|
1878
1918
|
/**
|