@yeaft/webchat-agent 0.0.91 → 0.0.93
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/connection.js +9 -1
- package/crew.js +15 -5
- package/package.json +1 -1
package/connection.js
CHANGED
|
@@ -46,7 +46,15 @@ async function sendToServer(msg) {
|
|
|
46
46
|
ctx.messageBuffer.push(msg);
|
|
47
47
|
console.log(`[WS] Buffered message: ${msg.type} (queue: ${ctx.messageBuffer.length})`);
|
|
48
48
|
} else {
|
|
49
|
-
|
|
49
|
+
// Buffer full: drop oldest non-status messages to make room
|
|
50
|
+
const dropIdx = ctx.messageBuffer.findIndex(m => m.type !== 'crew_status' && m.type !== 'turn_completed');
|
|
51
|
+
if (dropIdx >= 0) {
|
|
52
|
+
ctx.messageBuffer.splice(dropIdx, 1);
|
|
53
|
+
ctx.messageBuffer.push(msg);
|
|
54
|
+
console.warn(`[WS] Buffer full, dropped oldest to make room for: ${msg.type}`);
|
|
55
|
+
} else {
|
|
56
|
+
console.warn(`[WS] Buffer full (${ctx.messageBufferMaxSize}), dropping: ${msg.type}`);
|
|
57
|
+
}
|
|
50
58
|
}
|
|
51
59
|
} else {
|
|
52
60
|
console.warn(`[WS] Cannot send message, WebSocket not open: ${msg.type}`);
|
package/crew.js
CHANGED
|
@@ -368,8 +368,8 @@ export async function createCrewSession(msg) {
|
|
|
368
368
|
await upsertCrewIndex(session);
|
|
369
369
|
await saveSessionMeta(session);
|
|
370
370
|
|
|
371
|
-
//
|
|
372
|
-
if (roles.length > 0) {
|
|
371
|
+
// 如果有目标,自动启动第一个角色;否则等待用户输入
|
|
372
|
+
if (goal && roles.length > 0) {
|
|
373
373
|
const firstRole = roles.find(r => r.name === 'pm') || roles[0];
|
|
374
374
|
if (firstRole) {
|
|
375
375
|
const initialPrompt = buildInitialTask(goal, firstRole, roles);
|
|
@@ -707,7 +707,7 @@ function buildRoleSystemPrompt(role, session) {
|
|
|
707
707
|
const otherRoles = allRoles.filter(r => r.name !== role.name);
|
|
708
708
|
|
|
709
709
|
let prompt = `# 团队协作
|
|
710
|
-
你正在一个 AI
|
|
710
|
+
你正在一个 AI 团队中工作。${session.goal ? `项目目标是: ${session.goal}` : '等待用户提出任务或问题。'}
|
|
711
711
|
|
|
712
712
|
团队成员:
|
|
713
713
|
${allRoles.map(r => `- ${r.icon} ${r.displayName}: ${r.description}${r.isDecisionMaker ? ' (决策者)' : ''}`).join('\n')}`;
|
|
@@ -724,7 +724,7 @@ summary: <简要说明要传递什么>
|
|
|
724
724
|
\`\`\`
|
|
725
725
|
|
|
726
726
|
可用的路由目标:
|
|
727
|
-
${otherRoles.map(r => `- ${r.name}: ${r.displayName}`).join('\n')}
|
|
727
|
+
${otherRoles.map(r => `- ${r.name}: ${r.icon} ${r.displayName} — ${r.description}`).join('\n')}
|
|
728
728
|
- human: 人工(只在决策者也无法决定时使用)
|
|
729
729
|
|
|
730
730
|
注意:
|
|
@@ -732,7 +732,9 @@ ${otherRoles.map(r => `- ${r.name}: ${r.displayName}`).join('\n')}
|
|
|
732
732
|
- 如果你遇到不确定的问题,@ 决策者 "${session.decisionMaker}",而不是直接 @ human
|
|
733
733
|
- 如果你是决策者且遇到需要人类判断的问题,才 @ human
|
|
734
734
|
- 每次回复最多只能有一个 ROUTE 块
|
|
735
|
-
- ROUTE
|
|
735
|
+
- ROUTE 块必须在回复的最末尾
|
|
736
|
+
- 当你的任务已完成且不需要其他角色继续时,ROUTE 回决策者 "${session.decisionMaker}" 做总结
|
|
737
|
+
- 在正文中可用 @角色name 提及某个角色(如 @developer),但这不会触发路由,仅供阅读`;
|
|
736
738
|
}
|
|
737
739
|
|
|
738
740
|
// 决策者额外 prompt
|
|
@@ -744,6 +746,14 @@ ${otherRoles.map(r => `- ${r.name}: ${r.displayName}`).join('\n')}
|
|
|
744
746
|
- 如果问题超出你的能力范围或需要业务判断,@human 请人类决定
|
|
745
747
|
- 你可以随时审查其他角色的工作并给出反馈
|
|
746
748
|
|
|
749
|
+
# 工作流终结点
|
|
750
|
+
团队的工作流有明确的结束条件。当以下任一条件满足时,你应该给出总结并结束当前工作流:
|
|
751
|
+
1. **代码已提交** - 所有代码修改已经 commit(如需要,可让 developer 执行 git commit)
|
|
752
|
+
2. **需要用户输入** - 遇到需要用户决定的问题时,@human 提出具体问题,等待用户回复
|
|
753
|
+
3. **任务完成** - 所有任务已完成,给出完成总结(列出完成了什么、变更了哪些文件、还有什么后续建议)
|
|
754
|
+
|
|
755
|
+
重要:不要无限循环地在角色之间传递。当工作实质性完成时,主动给出总结并结束。
|
|
756
|
+
|
|
747
757
|
# 任务清单
|
|
748
758
|
你可以在回复中添加 TASKS 块来发布/更新任务清单,团队界面会自动展示:
|
|
749
759
|
|