@yeaft/webchat-agent 0.1.707 → 0.1.710
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/message-router.js +17 -1
- package/package.json +1 -1
- package/unify/engine.js +16 -0
- package/unify/web-bridge.js +24 -0
|
@@ -36,7 +36,7 @@ import { sendToServer, flushMessageBuffer } from './buffer.js';
|
|
|
36
36
|
import { handleRestartAgent, handleUpgradeAgent } from './upgrade.js';
|
|
37
37
|
import { loadMcpServers, updateMcpConfig } from '../mcp.js';
|
|
38
38
|
import { getLlmConfig, updateLlmConfig, getUnifySettings, updateUnifySettings, getSearchSettings, updateSearchSettings, fetchTavilyUsage } from '../unify/config-api.js';
|
|
39
|
-
import { handleUnifyGroupChat, handleUnifyModeSwitch, handleUnifyModelSwitch, resetUnifySession, handleUnifyLoadHistory, handleUnifyAbortThread, handleUnifyAbortAll, handleUnifyAbortTurn, handleUnifyVpSubscribe, handleUnifyVpCreate, handleUnifyVpUpdate, handleUnifyVpDelete, handleUnifyVpRead, handleUnifyFeatureMessage, handleUnifyFetchSummaryHistory, handleUnifyFeatureCrud, handleUnifyListGroups, handleUnifyCreateGroup, handleUnifyRenameGroup, handleUnifyUpdateGroup, handleUnifyArchiveGroup, handleUnifyDeleteGroup, handleUnifyAddMember, handleUnifyRemoveMember, handleUnifySetDefaultVp, handleUnifyDreamTrigger } from '../unify/web-bridge.js';
|
|
39
|
+
import { handleUnifyGroupChat, handleUnifyModeSwitch, handleUnifyModelSwitch, resetUnifySession, handleUnifyLoadHistory, handleUnifyAbortThread, handleUnifyAbortAll, handleUnifyAbortTurn, handleUnifyVpSubscribe, handleUnifyVpCreate, handleUnifyVpUpdate, handleUnifyVpDelete, handleUnifyVpRead, handleUnifyFeatureMessage, handleUnifyFetchSummaryHistory, handleUnifyFeatureCrud, handleUnifyListGroups, handleUnifyCreateGroup, handleUnifyRenameGroup, handleUnifyUpdateGroup, handleUnifyArchiveGroup, handleUnifyDeleteGroup, handleUnifyAddMember, handleUnifyRemoveMember, handleUnifySetDefaultVp, handleUnifyDreamTrigger, broadcastLanguageChange } from '../unify/web-bridge.js';
|
|
40
40
|
|
|
41
41
|
export async function handleMessage(msg) {
|
|
42
42
|
switch (msg.type) {
|
|
@@ -326,7 +326,23 @@ export async function handleMessage(msg) {
|
|
|
326
326
|
}
|
|
327
327
|
|
|
328
328
|
case 'update_llm_config': {
|
|
329
|
+
// Capture the user's intent BEFORE updateLlmConfig — the return
|
|
330
|
+
// envelope ALWAYS populates `language` (falls back to 'en'), so
|
|
331
|
+
// gating on the *output* would broadcast on every provider /
|
|
332
|
+
// primaryModel / fastModel save, not just locale flips. Gate on
|
|
333
|
+
// the *input* `language` field instead.
|
|
334
|
+
const incomingLanguage = typeof msg.config?.language === 'string' && msg.config.language
|
|
335
|
+
? msg.config.language
|
|
336
|
+
: null;
|
|
329
337
|
const result = updateLlmConfig(msg.config || {}, ctx.CONFIG?.yeaftDir);
|
|
338
|
+
// task-708: live locale propagation. When the user flips the UI
|
|
339
|
+
// language dropdown, push the new value into every cached Engine
|
|
340
|
+
// (per-VP pool + 1:1 chat session.engine) so the very next turn
|
|
341
|
+
// renders the system prompt in the chosen language without the
|
|
342
|
+
// user reloading the session.
|
|
343
|
+
if (!result.error && incomingLanguage) {
|
|
344
|
+
broadcastLanguageChange(result.language);
|
|
345
|
+
}
|
|
330
346
|
sendToServer({ type: 'llm_config_updated', ...result });
|
|
331
347
|
break;
|
|
332
348
|
}
|
package/package.json
CHANGED
package/unify/engine.js
CHANGED
|
@@ -366,6 +366,22 @@ export class Engine {
|
|
|
366
366
|
return !!this.#currentAbortCtrl && !this.#currentAbortCtrl.signal.aborted;
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
+
/**
|
|
370
|
+
* Mutate the engine's effective language at runtime. The next call to
|
|
371
|
+
* #buildSystemPrompt reads this.#config.language live, so the very next
|
|
372
|
+
* turn renders in the new language without reconstructing the engine.
|
|
373
|
+
*
|
|
374
|
+
* Used by the live-locale broadcast path: when the user flips the UI
|
|
375
|
+
* language dropdown, web → server → message-router calls
|
|
376
|
+
* broadcastLanguageChange(lang) (web-bridge.js) which fans out to every
|
|
377
|
+
* Engine in the per-VP pool plus the 1:1-chat session engine.
|
|
378
|
+
*
|
|
379
|
+
* @param {string} lang — 'en' | 'zh'
|
|
380
|
+
*/
|
|
381
|
+
setLanguage(lang) {
|
|
382
|
+
if (typeof lang !== 'string' || !lang) return;
|
|
383
|
+
this.#config.language = lang;
|
|
384
|
+
}
|
|
369
385
|
|
|
370
386
|
/**
|
|
371
387
|
* Unregister a tool.
|
package/unify/web-bridge.js
CHANGED
|
@@ -164,6 +164,30 @@ function invalidateGroupContext(groupId) {
|
|
|
164
164
|
// directly. They *are* dropped on `resetUnifySession`.
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Live-locale broadcast: push a new language onto every Engine instance
|
|
169
|
+
* the agent currently holds.
|
|
170
|
+
*
|
|
171
|
+
* Called from `agent/connection/message-router.js` after `update_llm_config`
|
|
172
|
+
* persists `language` to ~/.yeaft/config.json. Without this, the per-VP
|
|
173
|
+
* engine pool (constructed once per VP and cached) keeps serving its
|
|
174
|
+
* old language until the session is reloaded — that's the bug fix from
|
|
175
|
+
* task-708 group-locale-sync. The 1:1-chat session.engine is also
|
|
176
|
+
* updated so Chat-mode prompts pick up the new language on the very
|
|
177
|
+
* next turn.
|
|
178
|
+
*
|
|
179
|
+
* No-op when `language` is falsy.
|
|
180
|
+
*
|
|
181
|
+
* @param {string} language — 'en' | 'zh'
|
|
182
|
+
*/
|
|
183
|
+
export function broadcastLanguageChange(language) {
|
|
184
|
+
if (!language) return;
|
|
185
|
+
for (const eng of vpEngines.values()) {
|
|
186
|
+
try { eng.setLanguage?.(language); } catch { /* best-effort */ }
|
|
187
|
+
}
|
|
188
|
+
try { session?.engine?.setLanguage?.(language); } catch { /* best-effort */ }
|
|
189
|
+
}
|
|
190
|
+
|
|
167
191
|
/** Query timeout in ms — abort if LLM doesn't respond within this window */
|
|
168
192
|
const QUERY_TIMEOUT_MS = 120_000;
|
|
169
193
|
|