@yeaft/webchat-agent 1.0.574 → 1.0.576

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.
@@ -28,10 +28,9 @@ import { handleRestartAgent, handleUpgradeAgent } from './upgrade.js';
28
28
  import { loadMcpServers, updateMcpConfig } from '../mcp.js';
29
29
  import { getLlmConfig, updateLlmConfig, getYeaftSettings, updateYeaftSettings, getPluginConfig, updatePluginConfig, getTelemetrySettings, updateTelemetrySettings, getWorkCenterFeatureSettings, updateWorkCenterFeatureSettings, getSearchSettings, updateSearchSettings, fetchTavilyUsage } from '../yeaft/config-api.js';
30
30
  import { loadConfig } from '../yeaft/config.js';
31
- import { mutateAgentConfig } from '../yeaft/config-store.js';
32
31
  import { discoverLlmModels } from '../llm-model-discovery.js';
33
32
  import { fetchModelsDev } from '../yeaft/llm/models-dev.js';
34
- import { handleYeaftSessionSend, handleYeaftAskUserAnswer, handleYeaftSubAgentPrompt, handleYeaftTaskCancel, handleYeaftModeSwitch, handleYeaftModelSwitch, resetYeaftSession, refreshLiveSessionConfig, setLiveDreamEnabled, handleYeaftLoadHistory, handleYeaftLoadHistoryOutline, handleYeaftSearchHistory, handleYeaftLoadHistoryWindow, handleYeaftLoadMoreHistory, handleYeaftAbortThread, handleYeaftAbortAll, handleYeaftAbortTurn, handleYeaftVpSubscribe, handleYeaftVpCreate, handleYeaftVpUpdate, handleYeaftVpDelete, handleYeaftVpRead, handleYeaftListSessions, handleYeaftProjectContextSync, handleYeaftProjectMutation, handleYeaftCreateSession, handleYeaftCopySession, handleYeaftRenameSession, handleYeaftUpdateSession, handleYeaftUpdateSessionConfig, handleYeaftArchiveSession, handleYeaftDeleteSession, handleYeaftSessionAddMember, handleYeaftSessionRemoveMember, handleYeaftSessionSetDefaultVp, handleYeaftScanWorkdirSessions, handleYeaftRestoreSession, handleYeaftDreamTrigger, handleYeaftFetchToolStats, handleYeaftFetchDebugHistory, handleYeaftMcpList, handleYeaftMcpAdd, handleYeaftMcpRemove, handleYeaftMcpReload, handleYeaftPluginCatalog, handleYeaftManagedSkill, ensureSessionLoaded, broadcastLanguageChange, broadcastYeaftSessionSnapshotEager, broadcastYeaftVpSnapshotEager, preloadYeaftSkillSlashCommands } from '../yeaft/web-bridge.js';
33
+ import { handleYeaftSessionSend, handleYeaftAskUserAnswer, handleYeaftSubAgentPrompt, handleYeaftTaskCancel, handleYeaftModeSwitch, handleYeaftModelSwitch, resetYeaftSession, refreshLiveSessionConfig, handleYeaftLoadHistory, handleYeaftLoadHistoryOutline, handleYeaftSearchHistory, handleYeaftLoadHistoryWindow, handleYeaftLoadMoreHistory, handleYeaftAbortThread, handleYeaftAbortAll, handleYeaftAbortTurn, handleYeaftVpSubscribe, handleYeaftVpCreate, handleYeaftVpUpdate, handleYeaftVpDelete, handleYeaftVpRead, handleYeaftListSessions, handleYeaftProjectContextSync, handleYeaftProjectMutation, handleYeaftCreateSession, handleYeaftCopySession, handleYeaftRenameSession, handleYeaftUpdateSession, handleYeaftUpdateSessionConfig, handleYeaftArchiveSession, handleYeaftDeleteSession, handleYeaftSessionAddMember, handleYeaftSessionRemoveMember, handleYeaftSessionSetDefaultVp, handleYeaftScanWorkdirSessions, handleYeaftRestoreSession, handleYeaftDreamTrigger, handleYeaftFetchToolStats, handleYeaftFetchDebugHistory, handleYeaftMcpList, handleYeaftMcpAdd, handleYeaftMcpRemove, handleYeaftMcpReload, handleYeaftPluginCatalog, handleYeaftManagedSkill, ensureSessionLoaded, broadcastLanguageChange, broadcastYeaftSessionSnapshotEager, broadcastYeaftVpSnapshotEager, preloadYeaftSkillSlashCommands } from '../yeaft/web-bridge.js';
35
34
  import { startYeaftStatusRefresh, forceRefreshYeaftStatus } from '../yeaft/status-cache.js';
36
35
  import { handleWorkCenterRequest } from '../yeaft/work-center/bridge.js';
37
36
  import { handleBrowserRuntimeMessage } from '../browser-runtime/messages.js';
@@ -220,8 +219,7 @@ export async function handleMessage(msg) {
220
219
  await ctx.assetOutbox?.drain();
221
220
 
222
221
  // ★ Phase 1: 通知 server 同步完成
223
- const runtimeConfig = loadConfig({ dir: ctx.CONFIG?.yeaftDir });
224
- sendToServer({ type: 'agent_sync_complete', dreamEnabled: runtimeConfig.dream?.enabled === true });
222
+ sendToServer({ type: 'agent_sync_complete', dreamEnabled: false });
225
223
 
226
224
  // ★ 发送 MCP servers 列表给 server(供前端 Settings > Tools tab 使用)
227
225
  if (ctx.mcpServers.length > 0) {
@@ -437,24 +435,12 @@ export async function handleMessage(msg) {
437
435
  await handleRestartAgent({ requestId: msg.requestId, clientId: msg.clientId });
438
436
  break;
439
437
 
438
+ // Compatibility response for old Web clients; never persist or re-enable Dream.
440
439
  case 'set_dream_enabled': {
441
- const enabled = msg.enabled !== false;
442
- try {
443
- mutateAgentConfig(ctx.CONFIG?.yeaftDir, (config) => {
444
- if (!config.dream || typeof config.dream !== 'object' || Array.isArray(config.dream)) config.dream = {};
445
- config.dream.enabled = enabled;
446
- });
447
- const persisted = loadConfig({ dir: ctx.CONFIG?.yeaftDir }).dream?.enabled === true;
448
- if (persisted !== enabled) throw new Error('Dream setting was not persisted');
449
- try {
450
- setLiveDreamEnabled(persisted);
451
- } catch (error) {
452
- console.warn('[Dream] persisted setting but live runtime update failed:', error?.message || error);
453
- }
454
- sendToServer({ type: 'dream_enabled_changed', enabled: persisted, requestId: msg.requestId, clientId: msg.clientId });
455
- } catch (error) {
456
- sendToServer({ type: 'dream_enabled_changed', enabled: !enabled, error: error?.message || String(error), requestId: msg.requestId, clientId: msg.clientId });
457
- }
440
+ sendToServer({
441
+ type: 'dream_enabled_changed', enabled: false, error: 'Dream is disabled.',
442
+ requestId: msg.requestId, clientId: msg.clientId,
443
+ });
458
444
  break;
459
445
  }
460
446
 
@@ -867,7 +853,7 @@ export async function handleMessage(msg) {
867
853
  handleYeaftTaskCancel(msg);
868
854
  break;
869
855
 
870
- // wave-6b: manual dream trigger from VP detail page
856
+ // Retired Dream commands receive an explicit disabled response.
871
857
  case 'yeaft_dream_trigger':
872
858
  case 'unify_dream_trigger':
873
859
  await handleYeaftDreamTrigger(msg);
@@ -8,6 +8,14 @@ import { yeaftAssetStore } from '../yeaft-asset-store.js';
8
8
  import { recordPerfTraceEvent } from '../perf-trace.js';
9
9
 
10
10
 
11
+ // Older Dream bridges reused the ordinary debug lifecycle with a reserved
12
+ // dream- turn id. Drop these before projection/relay, not only named Dream events.
13
+ function isRetiredDreamEvent(event) {
14
+ return ['yeaft_dream_snapshot', 'yeaft_dream_status', 'yeaft_dream_result', 'dream_progress', 'dream_memory_loaded'].includes(event?.type)
15
+ || (['turn_open', 'loop', 'turn_close'].includes(event?.type)
16
+ && typeof event.turnId === 'string' && event.turnId.startsWith('dream-'));
17
+ }
18
+
11
19
  export function decorateYeaftSessionsWithPinned(agentId, sessions) {
12
20
  const rawRows = Array.isArray(sessions) ? sessions : [];
13
21
  const rowsById = new Map();
@@ -602,6 +610,7 @@ export async function handleAgentOutput(agentId, agent, msg) {
602
610
  case 'yeaft_output':
603
611
  case 'yeaft_session_output':
604
612
  case 'session_output': {
613
+ if (isRetiredDreamEvent(msg.event)) break;
605
614
  const data = hydrateInlinePreviewData(msg.data);
606
615
  let event = syncYeaftSessionMetadata(agentId, agent, msg.event);
607
616
  if ((event?.type === 'session_list_updated' || event?.type === 'session_crud_result') && agent.ownerId) {
@@ -880,39 +889,8 @@ export async function handleAgentOutput(agentId, agent, msg) {
880
889
 
881
890
  case 'yeaft_dream_status':
882
891
  case 'yeaft_dream_result':
883
- // Forward Dream lifecycle envelopes to the web client.
884
- //
885
- // The bug this fixes: `handleYeaftDreamTrigger` in
886
- // `agent/yeaft/web-bridge.js` emits these as BARE top-level
887
- // messages when the user clicks "Run dream now" (in the topbar or
888
- // group settings). Without a case here, the switch hit
889
- // `default: return false` and silently dropped the message,
890
- // leaving the UI stuck on "Running…" even after the dream pass
891
- // completed.
892
- //
893
- // Whitelist spread matches the pattern used by sibling cases
894
- // (`yeaft_output`, `yeaft_history_chunk`) so a future agent-side
895
- // bug that tags an internal field onto a dream envelope can't
896
- // leak it to the web client. Keep in sync with the agent emit at
897
- // `handleYeaftDreamTrigger`.
898
- for (const [, c] of webClients) {
899
- if (c.authenticated && (CONFIG.skipAuth || c.userId === agent.ownerId)) {
900
- await sendToWebClient(c, {
901
- type: msg.type,
902
- ...(msg.sessionId != null ? { sessionId: msg.sessionId } : {}),
903
- ...(msg.vpId != null ? { vpId: msg.vpId } : {}),
904
- ...(msg.status != null ? { status: msg.status } : {}),
905
- ...(typeof msg.success === 'boolean' ? { success: msg.success } : {}),
906
- ...(typeof msg.entriesCreated === 'number' ? { entriesCreated: msg.entriesCreated } : {}),
907
- ...(msg.lastDreamAt != null ? { lastDreamAt: msg.lastDreamAt } : {}),
908
- ...(msg.skipped ? { skipped: true } : {}),
909
- ...(msg.error != null ? { error: msg.error } : {}),
910
- ...(Array.isArray(msg.groups) ? { groups: msg.groups } : {}),
911
- ...(Array.isArray(msg.targets) ? { targets: msg.targets } : {}),
912
- ...(msg.startedAt != null ? { startedAt: msg.startedAt } : {}),
913
- });
914
- }
915
- }
892
+ case 'yeaft_dream_snapshot':
893
+ // Retired UI: older Agents may still send these. Do not relay memory data.
916
894
  break;
917
895
 
918
896
  case 'yeaft_plugin_catalog_result': {
@@ -1117,7 +1095,7 @@ export async function handleAgentOutput(agentId, agent, msg) {
1117
1095
  agentId,
1118
1096
  loops: Array.isArray(msg.loops) ? msg.loops : [],
1119
1097
  turns: Array.isArray(msg.turns) ? msg.turns : [],
1120
- dreamEvents: Array.isArray(msg.dreamEvents) ? msg.dreamEvents : [],
1098
+ dreamEvents: [],
1121
1099
  ...(msg.projection && typeof msg.projection === 'object' ? { projection: msg.projection } : {}),
1122
1100
  ...(msg.sessionId != null ? { sessionId: msg.sessionId } : {}),
1123
1101
  ...(msg.threadId != null ? { threadId: msg.threadId } : {}),
@@ -81,7 +81,7 @@ export async function handleAgentSync(agentId, agent, msg) {
81
81
  // Phase 1: Agent 同步完成
82
82
  case 'agent_sync_complete': {
83
83
  agent.status = 'ready';
84
- agent.dreamEnabled = msg.dreamEnabled === true;
84
+ agent.dreamEnabled = false;
85
85
  if (agent._syncTimeout) {
86
86
  clearTimeout(agent._syncTimeout);
87
87
  delete agent._syncTimeout;
@@ -91,21 +91,10 @@ export async function handleAgentSync(agentId, agent, msg) {
91
91
  break;
92
92
  }
93
93
 
94
- case 'dream_enabled_changed': {
95
- if (!msg.error) {
96
- agent.dreamEnabled = msg.enabled !== false;
97
- await broadcastAgentList();
98
- }
99
- const payload = {
100
- type: 'dream_enabled_changed',
101
- agentId,
102
- requestId: msg.requestId,
103
- enabled: msg.error ? agent.dreamEnabled === true : msg.enabled !== false,
104
- ...(msg.error ? { error: msg.error } : {}),
105
- };
106
- await sendAgentSettingsReply(agentId, agent, 'dream', msg, payload);
94
+ case 'dream_enabled_changed':
95
+ // Retired setting: ignore unsolicited acknowledgements from older Agents.
96
+ agent.dreamEnabled = false;
107
97
  break;
108
- }
109
98
 
110
99
  case 'agent_capabilities_updated': {
111
100
  const capabilities = Array.isArray(msg.capabilities)
@@ -1395,7 +1395,7 @@ export async function handleClientConversation(clientId, client, msg, checkAgent
1395
1395
  requestId: debugRequestId,
1396
1396
  requestKind: msg.requestKind === 'detail' ? 'detail' : 'list',
1397
1397
  limit: typeof msg.limit === 'number' ? msg.limit : 10,
1398
- dreamLimit: typeof msg.dreamLimit === 'number' ? msg.dreamLimit : 5,
1398
+ dreamLimit: 0,
1399
1399
  indexOnly: msg.indexOnly === true,
1400
1400
  detailTurnId: typeof msg.detailTurnId === 'string' ? msg.detailTurnId : null,
1401
1401
  search: typeof msg.search === 'string' ? msg.search.slice(0, 500) : '',
@@ -1661,7 +1661,7 @@ export async function handleClientConversation(clientId, client, msg, checkAgent
1661
1661
  default: {
1662
1662
  // task-fix: generic relay for all `yeaft_*` messages so any new
1663
1663
  // agent-router case (yeaft_vp_*, yeaft_user_memory_*, yeaft_*_group,
1664
- // yeaft_dream_*, etc.) works without a dedicated server case.
1664
+ // etc.) works without a dedicated server case.
1665
1665
  // Without this, messages like `yeaft_vp_subscribe` arrive at the
1666
1666
  // server, fall through to default, return false, and are silently
1667
1667
  // dropped — which is why the GroupCreateWizard's "VP 加载中..."
@@ -1710,6 +1710,11 @@ export async function handleClientConversation(clientId, client, msg, checkAgent
1710
1710
  }
1711
1711
  return true;
1712
1712
  }
1713
+ // Do not let an older Web client restart Dream on an older Agent.
1714
+ if (relayType === 'yeaft_dream_trigger') {
1715
+ await sendToWebClient(client, skippedYeaftDreamResult(msg, 'disabled'));
1716
+ return true;
1717
+ }
1713
1718
  if (relayType === 'yeaft_copy_session'
1714
1719
  && Object.prototype.hasOwnProperty.call(msg, 'throughTurnId')
1715
1720
  && !agents.get(relayAgentId)?.capabilities?.includes('session_fork_from_turn')) {
@@ -105,12 +105,10 @@ export async function handleClientMisc(clientId, client, msg, checkAgentAccess)
105
105
  const agentId = msg.agentId;
106
106
  if (!agentId) break;
107
107
  if (!await checkAgentAccess(agentId)) break;
108
- if (msg.requestId) {
109
- await forwardRegisteredAgentRequest({ client, clientId, agentId, operation: 'dream', requestId: msg.requestId,
110
- message: { type: 'set_dream_enabled', enabled: msg.enabled !== false, requestId: msg.requestId, clientId }, responseType: 'dream_enabled_changed' });
111
- } else {
112
- await forwardToAgent(agentId, { type: 'set_dream_enabled', enabled: msg.enabled !== false });
113
- }
108
+ await sendToWebClient(client, {
109
+ type: 'dream_enabled_changed', agentId, requestId: msg.requestId,
110
+ enabled: false, error: 'Dream is disabled.',
111
+ });
114
112
  break;
115
113
  }
116
114
 
@@ -1 +1 @@
1
- {"version":"1.0.574"}
1
+ {"version":"1.0.576"}