@yeaft/webchat-agent 0.1.443 → 0.1.444

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.
@@ -25,7 +25,7 @@ import { sendToServer, flushMessageBuffer } from './buffer.js';
25
25
  import { handleRestartAgent, handleUpgradeAgent } from './upgrade.js';
26
26
  import { loadMcpServers, updateMcpConfig } from '../mcp.js';
27
27
  import { getLlmConfig, updateLlmConfig } from '../unify/config-api.js';
28
- import { handleUnifyChat, handleUnifyModeSwitch, resetUnifySession } from '../unify/web-bridge.js';
28
+ import { handleUnifyChat, handleUnifyModeSwitch, handleUnifyModelSwitch, resetUnifySession } from '../unify/web-bridge.js';
29
29
 
30
30
  export async function handleMessage(msg) {
31
31
  switch (msg.type) {
@@ -329,6 +329,10 @@ export async function handleMessage(msg) {
329
329
  handleUnifyModeSwitch(msg);
330
330
  break;
331
331
 
332
+ case 'unify_model_switch':
333
+ handleUnifyModelSwitch(msg);
334
+ break;
335
+
332
336
  case 'unify_reset':
333
337
  await resetUnifySession();
334
338
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.443",
3
+ "version": "0.1.444",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/unify/config.js CHANGED
@@ -260,6 +260,24 @@ export function loadConfig(overrides = {}) {
260
260
  adapter: null,
261
261
  };
262
262
 
263
+ // Aggregate all available models from providers
264
+ config.availableModels = [];
265
+ if (providers) {
266
+ for (const p of providers) {
267
+ if (!Array.isArray(p.models)) continue;
268
+ for (const m of p.models) {
269
+ // Avoid duplicates (first provider wins)
270
+ if (!config.availableModels.some(am => am.id === m)) {
271
+ config.availableModels.push({
272
+ id: m,
273
+ provider: p.name,
274
+ label: m,
275
+ });
276
+ }
277
+ }
278
+ }
279
+ }
280
+
263
281
  return config;
264
282
  }
265
283
 
@@ -103,6 +103,7 @@ export async function handleUnifyChat(msg) {
103
103
  type: 'session_ready',
104
104
  conversationId: unifyConversationId,
105
105
  model: session.config.model,
106
+ availableModels: session.config.availableModels || [],
106
107
  skills: session.status.skills,
107
108
  mcpServers: session.status.mcpServers,
108
109
  tools: session.status.tools,
@@ -385,6 +386,32 @@ export function handleUnifyModeSwitch(msg) {
385
386
  }
386
387
  }
387
388
 
389
+ /**
390
+ * Handle model switch from the web UI.
391
+ * Updates Engine's config so the next query uses the new model.
392
+ * @param {{ model: string }} msg
393
+ */
394
+ export function handleUnifyModelSwitch(msg) {
395
+ if (!session || !msg.model) return;
396
+
397
+ // Validate: model must be in availableModels list
398
+ const available = session.config.availableModels || [];
399
+ const found = available.some(m => m.id === msg.model);
400
+ if (!found) {
401
+ console.warn(`[Unify] model switch rejected — "${msg.model}" not in availableModels`);
402
+ return;
403
+ }
404
+
405
+ // Update Engine's model for subsequent queries
406
+ session.config.model = msg.model;
407
+
408
+ // Confirm switch to frontend
409
+ sendUnifyEvent({
410
+ type: 'model_switched',
411
+ model: msg.model,
412
+ });
413
+ }
414
+
388
415
  /**
389
416
  * Reset Unify session (for clear messages).
390
417
  */