@fieldwangai/agentflow 0.1.36 → 0.1.37

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.
@@ -1207,9 +1207,10 @@ function buildWorkspaceGeneratePrompt(payload) {
1207
1207
  ].join("\n")
1208
1208
  : [
1209
1209
  "你是 AgentFlow Workspace Composer。",
1210
- "优先根据已选择的 Skills 操作 workspace.graph.json,创建或修改 workspace 画布节点、连线与展示节点。",
1211
- "如果用户请求需要项目分析、加载代码、整理流程或生成展示结果,不要只给泛泛回答;应先让 Skills 驱动画布建模,例如创建 Git/工作目录/Load Skills/Agent/Markdown Display 等合适节点。",
1212
- "只有当用户明确只是询问概念或无需画布变更时,才直接输出 Markdown 回复。",
1210
+ "默认以用户当前选择的 workspace 节点作为上下文范围;选中节点不是让你重建整张画布的授权。",
1211
+ "默认不要修改 workspace.graph.json,不要新增/删除/重连画布节点;只有当用户明确要求“更新画布、加节点、改连线、展示成节点、生成流程”时,才编辑 workspace.graph.json。",
1212
+ "如果用户请求生成或恢复文档/文件,可以直接在 workspace 文件系统中完成,最终只输出简短结果:改了什么、路径在哪里、是否需要下一步。",
1213
+ "不要在最终回答中列出过程性步骤,例如“先查看结构”“继续检索”“正在生成”;这些属于执行过程,不属于最终结果。",
1213
1214
  ].join("\n");
1214
1215
  return [
1215
1216
  "你正在 AgentFlow 的 Workspace 工作画布中执行任务。",
@@ -3050,7 +3051,8 @@ export function startUiServer({
3050
3051
  const promptText = buildWorkspaceGeneratePrompt({ ...payload, skillsBlock });
3051
3052
  const modelKey = typeof payload?.model === "string" ? payload.model.trim() : "";
3052
3053
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
3053
- let attemptContent = "";
3054
+ let attemptResult = "";
3055
+ const assistantSegments = [];
3054
3056
  try {
3055
3057
  if (attempt > 1) {
3056
3058
  events.push({
@@ -3068,12 +3070,16 @@ export function startUiServer({
3068
3070
  onStreamEvent: (ev) => {
3069
3071
  events.push(ev);
3070
3072
  if (ev?.type === "natural" && ev.kind === "assistant" && typeof ev.text === "string") {
3071
- attemptContent += (attemptContent ? "\n" : "") + ev.text;
3073
+ const text = ev.text.trim();
3074
+ if (text) assistantSegments.push(text);
3075
+ } else if (ev?.type === "natural" && ev.kind === "result" && typeof ev.text === "string") {
3076
+ const text = ev.text.trim();
3077
+ if (text) attemptResult = text;
3072
3078
  }
3073
3079
  },
3074
3080
  });
3075
3081
  await handle.finished;
3076
- content = attemptContent;
3082
+ content = attemptResult || assistantSegments.at(-1) || "";
3077
3083
  break;
3078
3084
  } catch (e) {
3079
3085
  if (attempt < maxAttempts && isTransientAgentNetworkError(e)) {