@yeaft/webchat-agent 0.1.421 → 0.1.422

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,6 @@ 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 } from '../unify/web-bridge.js';
29
28
 
30
29
  export async function handleMessage(msg) {
31
30
  switch (msg.type) {
@@ -319,10 +318,5 @@ export async function handleMessage(msg) {
319
318
  sendToServer({ type: 'llm_config_updated', ...result });
320
319
  break;
321
320
  }
322
-
323
- // Unify — independent chat via Engine
324
- case 'unify_chat':
325
- await handleUnifyChat(msg);
326
- break;
327
321
  }
328
322
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.421",
3
+ "version": "0.1.422",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,99 +0,0 @@
1
- /**
2
- * web-bridge.js — Bridge between web UI and Yeaft Unify Engine.
3
- *
4
- * Handles `unify_chat` messages from the server, runs queries through
5
- * the Engine, and streams `unify_output` events back.
6
- *
7
- * The session is lazily initialized on first use and reused across queries.
8
- * Engine internally manages conversation history and persistence.
9
- */
10
-
11
- import { loadSession } from './session.js';
12
- import { sendToServer } from '../connection/buffer.js';
13
- import ctx from '../context.js';
14
-
15
- /** @type {import('./session.js').Session | null} */
16
- let session = null;
17
-
18
- /** @type {AbortController | null} */
19
- let currentAbort = null;
20
-
21
- /**
22
- * Handle a unify_chat message from the web UI.
23
- *
24
- * @param {{ prompt: string, userId?: string, username?: string }} msg
25
- */
26
- export async function handleUnifyChat(msg) {
27
- const { prompt } = msg;
28
- if (!prompt?.trim()) return;
29
-
30
- try {
31
- // Lazy-init session (reuse across queries — Engine manages history)
32
- if (!session) {
33
- const yeaftDir = ctx.CONFIG?.yeaftDir;
34
- session = await loadSession({
35
- ...(yeaftDir && { dir: yeaftDir }),
36
- skipMCP: true,
37
- skipSkills: true,
38
- });
39
-
40
- // Send model info to UI so the badge updates
41
- sendToServer({
42
- type: 'unify_output',
43
- event: { type: 'model_info', model: session.config.model },
44
- });
45
- }
46
-
47
- // Cancel any in-flight query
48
- if (currentAbort) {
49
- currentAbort.abort();
50
- currentAbort = null;
51
- }
52
-
53
- currentAbort = new AbortController();
54
-
55
- // Stream query events → unify_output messages
56
- for await (const event of session.engine.query({ prompt, signal: currentAbort.signal })) {
57
- switch (event.type) {
58
- case 'text_delta':
59
- sendToServer({
60
- type: 'unify_output',
61
- event: { type: 'text_delta', text: event.text },
62
- });
63
- break;
64
-
65
- case 'error':
66
- sendToServer({
67
- type: 'unify_output',
68
- event: {
69
- type: 'error',
70
- message: event.error?.message || 'Unknown error',
71
- },
72
- });
73
- break;
74
-
75
- // Silently consume other events (tool_call, thinking_delta, usage, etc.)
76
- // These can be surfaced later as the Unify UI grows.
77
- default:
78
- break;
79
- }
80
- }
81
-
82
- // Signal completion
83
- sendToServer({
84
- type: 'unify_output',
85
- event: { type: 'done' },
86
- });
87
- } catch (err) {
88
- // Don't report abort errors
89
- if (err.name === 'AbortError') return;
90
-
91
- console.error('[Unify] query error:', err.message);
92
- sendToServer({
93
- type: 'unify_output',
94
- event: { type: 'error', message: err.message || 'Session error' },
95
- });
96
- } finally {
97
- currentAbort = null;
98
- }
99
- }