@yeaft/webchat-agent 1.0.350 → 1.0.352

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.
Files changed (45) hide show
  1. package/connection/message-router.js +29 -1
  2. package/index.js +2 -0
  3. package/local-runtime/server/handlers/agent-sync.js +14 -0
  4. package/local-runtime/server/handlers/client-misc.js +21 -0
  5. package/local-runtime/version.json +1 -1
  6. package/local-runtime/web/app.bundle.js +110 -97
  7. package/local-runtime/web/app.bundle.js.gz +0 -0
  8. package/local-runtime/web/index.html +2 -2
  9. package/local-runtime/web/style.bundle.css +1 -1
  10. package/local-runtime/web/style.bundle.css.gz +0 -0
  11. package/package.json +1 -1
  12. package/yeaft/config-api.js +53 -1
  13. package/yeaft/config.js +54 -0
  14. package/yeaft/conversation/history-index-worker.js +13 -10
  15. package/yeaft/conversation/internal-control.js +1 -0
  16. package/yeaft/debug-trace.js +164 -47
  17. package/yeaft/engine.js +318 -28
  18. package/yeaft/llm/adapter.js +38 -0
  19. package/yeaft/llm/anthropic.js +11 -8
  20. package/yeaft/llm/openai-responses.js +11 -8
  21. package/yeaft/llm/router.js +1 -1
  22. package/yeaft/perf-trace.js +156 -24
  23. package/yeaft/session.js +7 -0
  24. package/yeaft/sessions/session-crud.js +19 -4
  25. package/yeaft/sub-agent/runner.js +4 -0
  26. package/yeaft/tools/agent.js +4 -0
  27. package/yeaft/tools/ask-user.js +1 -0
  28. package/yeaft/tools/bash.js +4 -0
  29. package/yeaft/tools/create-work-item.js +3 -0
  30. package/yeaft/tools/file-read.js +1 -0
  31. package/yeaft/tools/glob.js +1 -0
  32. package/yeaft/tools/grep.js +1 -0
  33. package/yeaft/tools/history-search.js +74 -20
  34. package/yeaft/tools/js-repl.js +1 -0
  35. package/yeaft/tools/list-agents.js +1 -0
  36. package/yeaft/tools/list-dir.js +1 -0
  37. package/yeaft/tools/list-tasks.js +1 -0
  38. package/yeaft/tools/read-task-log.js +1 -0
  39. package/yeaft/tools/route-forward.js +4 -0
  40. package/yeaft/tools/send-message.js +3 -0
  41. package/yeaft/tools/types.js +8 -0
  42. package/yeaft/tools/wait-agent.js +1 -0
  43. package/yeaft/utf8.js +44 -0
  44. package/yeaft/web-bridge.js +6 -0
  45. package/yeaft/work-center/runner.js +1 -0
@@ -26,7 +26,7 @@ import { sendToServer, flushMessageBuffer } from './buffer.js';
26
26
  import { sendAgentMetricsSnapshot } from '../metrics.js';
27
27
  import { handleRestartAgent, handleUpgradeAgent } from './upgrade.js';
28
28
  import { loadMcpServers, updateMcpConfig } from '../mcp.js';
29
- import { getLlmConfig, updateLlmConfig, getYeaftSettings, updateYeaftSettings, getSearchSettings, updateSearchSettings, fetchTavilyUsage } from '../yeaft/config-api.js';
29
+ import { getLlmConfig, updateLlmConfig, getYeaftSettings, updateYeaftSettings, getTelemetrySettings, updateTelemetrySettings, getSearchSettings, updateSearchSettings, fetchTavilyUsage } from '../yeaft/config-api.js';
30
30
  import { loadConfig } from '../yeaft/config.js';
31
31
  import { discoverLlmModels } from '../llm-model-discovery.js';
32
32
  import { fetchModelsDev } from '../yeaft/llm/models-dev.js';
@@ -448,6 +448,34 @@ export async function handleMessage(msg) {
448
448
  break;
449
449
  }
450
450
 
451
+ // Local performance telemetry settings — read/write the `telemetry`
452
+ // section of config.json. This does not expose trace payloads.
453
+ case 'get_telemetry_settings': {
454
+ const settings = getTelemetrySettings(ctx.CONFIG?.yeaftDir);
455
+ sendToServer({ type: 'telemetry_settings', ...settings });
456
+ break;
457
+ }
458
+
459
+ case 'update_telemetry_settings': {
460
+ const result = updateTelemetrySettings(msg.settings || msg.config || {}, ctx.CONFIG?.yeaftDir);
461
+ if (!result.error) {
462
+ // Bridge trace producers use the agent-owned config object directly.
463
+ // The result is the normalized section that was successfully written,
464
+ // so apply it before refresh can yield and leave no enabled-by-default
465
+ // gap for diagnostics emitted outside a loaded Session.
466
+ if (ctx.CONFIG && typeof ctx.CONFIG === 'object') {
467
+ ctx.CONFIG.telemetry = { ...result };
468
+ }
469
+ try {
470
+ await refreshLiveSessionConfig({});
471
+ } catch (error) {
472
+ result.runtimeRefreshError = error?.message || String(error);
473
+ }
474
+ }
475
+ sendToServer({ type: 'telemetry_settings_updated', ...result });
476
+ break;
477
+ }
478
+
451
479
  // Search settings (web-search backend + Tavily key) — read/write the
452
480
  // `search` section of config.json. `get_tavily_usage` hits Tavily's
453
481
  // /usage endpoint with the saved key and is fired from the UI only
package/index.js CHANGED
@@ -14,6 +14,7 @@ import { getDefaultAgentName, getDefaultYeaftDir, resolveRuntimeIdentity, getCon
14
14
  import { loadNodePty } from './terminal.js';
15
15
  import { connect } from './connection.js';
16
16
  import { loadMcpServers } from './mcp.js';
17
+ import { loadConfig as loadYeaftConfig } from './yeaft/config.js';
17
18
  import {
18
19
  ensureManagedCliTools,
19
20
  prepareManagedCliToolEnvironment,
@@ -105,6 +106,7 @@ const CONFIG = {
105
106
  agentName: AGENT_NAME,
106
107
  workDir: process.env.WORK_DIR || fileConfig.workDir || process.cwd(),
107
108
  yeaftDir: YEAFT_DIR,
109
+ telemetry: loadYeaftConfig({ dir: YEAFT_DIR }).telemetry,
108
110
  reconnectInterval: fileConfig.reconnectInterval,
109
111
  agentSecret: process.env.AGENT_SECRET || fileConfig.agentSecret,
110
112
  // 显式禁用的工具(非 MCP 相关)
@@ -356,6 +356,20 @@ export async function handleAgentSync(agentId, agent, msg) {
356
356
  break;
357
357
  }
358
358
 
359
+ // Local telemetry settings relay. Only bounded config is forwarded;
360
+ // trace payloads stay on the Agent.
361
+ case 'telemetry_settings':
362
+ case 'telemetry_settings_updated':
363
+ for (const [, client] of webClients) {
364
+ if (client.authenticated && (CONFIG.skipAuth ||
365
+ (agent.ownerId && client.userId === agent.ownerId) ||
366
+ (!agent.ownerId && client.role === 'admin')
367
+ )) {
368
+ await sendToWebClient(client, { ...msg, agentId });
369
+ }
370
+ }
371
+ break;
372
+
359
373
  // Search settings + Tavily usage relays. We pass the whole msg
360
374
  // through (minus agentId, which we set ourselves) — the payload
361
375
  // shapes differ per type and the front-end already filters on
@@ -166,6 +166,27 @@ export async function handleClientMisc(clientId, client, msg, checkAgentAccess)
166
166
  break;
167
167
  }
168
168
 
169
+ // Local performance telemetry settings. The agent owns the config file;
170
+ // the server only checks access and relays the request.
171
+ case 'get_telemetry_settings': {
172
+ const a = msg.agentId || client.currentAgent;
173
+ if (!a) break;
174
+ if (!await checkAgentAccess(a)) break;
175
+ await forwardToAgent(a, { type: 'get_telemetry_settings' });
176
+ break;
177
+ }
178
+
179
+ case 'update_telemetry_settings': {
180
+ const a = msg.agentId || client.currentAgent;
181
+ if (!a) break;
182
+ if (!await checkAgentAccess(a)) break;
183
+ await forwardToAgent(a, {
184
+ type: 'update_telemetry_settings',
185
+ settings: msg.settings || msg.config || {},
186
+ });
187
+ break;
188
+ }
189
+
169
190
  // Search settings (web-search backend + Tavily key + on-demand usage probe).
170
191
  // Mirrors the get/update_yeaft_settings pair: the agent owns the
171
192
  // config file, server is just a relay.
@@ -1 +1 @@
1
- {"version":"1.0.350"}
1
+ {"version":"1.0.352"}