@yeaft/webchat-agent 0.1.776 → 0.1.779
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/package.json +1 -1
- package/unify/engine.js +7 -0
- package/unify/eval/runner.js +5 -1
- package/unify/sub-agent/runner.js +6 -0
- package/unify/web-bridge.js +19 -0
package/package.json
CHANGED
package/unify/engine.js
CHANGED
|
@@ -326,10 +326,12 @@ export class Engine {
|
|
|
326
326
|
* config: object,
|
|
327
327
|
* conversationStore?: import('./conversation/persist.js').ConversationStore,
|
|
328
328
|
* memoryIndex?: import('./memory/index-db.js').SegmentIndex,
|
|
329
|
+
* amsRegistry?: object,
|
|
329
330
|
* toolRegistry?: import('./tools/registry.js').ToolRegistry,
|
|
330
331
|
* skillManager?: import('./skills.js').SkillManager,
|
|
331
332
|
* mcpManager?: import('./mcp.js').MCPManager,
|
|
332
333
|
* yeaftDir?: string,
|
|
334
|
+
* toolStats?: import('./stats/tool-usage.js').ToolUsageStats,
|
|
333
335
|
* }} params
|
|
334
336
|
*/
|
|
335
337
|
constructor({ adapter, trace, config, conversationStore, memoryIndex, amsRegistry, toolRegistry, skillManager, mcpManager, yeaftDir, toolStats = null }) {
|
|
@@ -772,6 +774,11 @@ export class Engine {
|
|
|
772
774
|
parentVpPersona: vpCtx?.vpPersona || null,
|
|
773
775
|
onEvent: this.#subAgentEventSink || null,
|
|
774
776
|
language: this.#config?.language || 'en',
|
|
777
|
+
// Forward the session-shared ToolUsageStats so sub-agent
|
|
778
|
+
// engines record tool calls into the same on-disk snapshot
|
|
779
|
+
// (~/.yeaft/stats/tool-usage.json) the parent engine writes
|
|
780
|
+
// to. Null when the parent has no stats wired (e.g. tests).
|
|
781
|
+
toolStats: this.#toolStats || null,
|
|
775
782
|
},
|
|
776
783
|
};
|
|
777
784
|
}
|
package/unify/eval/runner.js
CHANGED
|
@@ -90,7 +90,11 @@ export async function runSingleEval(evalCase, { adapter, model, config = {} }) {
|
|
|
90
90
|
const trace = new NullTrace();
|
|
91
91
|
const engineConfig = { model, maxOutputTokens: 4096, ...config };
|
|
92
92
|
|
|
93
|
-
// Build engine — optionally with ToolRegistry
|
|
93
|
+
// Build engine — optionally with ToolRegistry. NOTE: intentionally
|
|
94
|
+
// no `toolStats` here. The eval runner is an offline scoring harness
|
|
95
|
+
// and must NOT pollute the user-facing `~/.yeaft/stats/tool-usage.json`
|
|
96
|
+
// snapshot (see PR #782 for the session-shared ToolUsageStats
|
|
97
|
+
// wiring on the runtime paths).
|
|
94
98
|
const engineOpts = { adapter, trace, config: engineConfig };
|
|
95
99
|
|
|
96
100
|
if (evalCase.registryTools) {
|
|
@@ -86,6 +86,7 @@ export function isRestrictedToolName(name) {
|
|
|
86
86
|
* parentName?: string,
|
|
87
87
|
* parentVpId?: string,
|
|
88
88
|
* parentVpPersona?: object,
|
|
89
|
+
* toolStats?: object,
|
|
89
90
|
* onEvent?: (agentId: string, evt: object) => void,
|
|
90
91
|
* language?: 'en'|'zh',
|
|
91
92
|
* }} deps
|
|
@@ -112,6 +113,11 @@ export function startSubAgent(agent, deps = {}) {
|
|
|
112
113
|
skillManager: deps.skillManager || null,
|
|
113
114
|
mcpManager: deps.mcpManager || null,
|
|
114
115
|
yeaftDir: deps.yeaftDir || null,
|
|
116
|
+
// Share the session-shared ToolUsageStats so sub-agent tool calls
|
|
117
|
+
// land in the same on-disk snapshot the parent records into. Sub-
|
|
118
|
+
// agents are often the heaviest tool users — leaving them out
|
|
119
|
+
// skewed `unify_fetch_tool_stats` output.
|
|
120
|
+
toolStats: deps.toolStats || null,
|
|
115
121
|
});
|
|
116
122
|
|
|
117
123
|
agent.subEngine = subEngine;
|
package/unify/web-bridge.js
CHANGED
|
@@ -499,6 +499,19 @@ export function __testGroupContextEntry(groupId) {
|
|
|
499
499
|
return groupContexts.get(groupId);
|
|
500
500
|
}
|
|
501
501
|
|
|
502
|
+
/**
|
|
503
|
+
* Test-only: build (or return cached) per-VP Engine for a session that
|
|
504
|
+
* was wired via `__testSetSession`. Lets tests assert that the engine's
|
|
505
|
+
* dependencies (notably `toolStats`) come from the session reference —
|
|
506
|
+
* see `test/agent/web-bridge-vp-engine-tool-stats.test.js`.
|
|
507
|
+
*
|
|
508
|
+
* @param {string} groupId
|
|
509
|
+
* @param {string} vpId
|
|
510
|
+
*/
|
|
511
|
+
export function __testGetOrCreateVpEngine(groupId, vpId) {
|
|
512
|
+
return getOrCreateVpEngine(groupId, vpId);
|
|
513
|
+
}
|
|
514
|
+
|
|
502
515
|
/** Whether we've already sent a permission warning to the UI */
|
|
503
516
|
let _permissionDiagnosticSent = false;
|
|
504
517
|
|
|
@@ -540,6 +553,12 @@ function getOrCreateVpEngine(groupId, vpId) {
|
|
|
540
553
|
skillManager: session.skillManager,
|
|
541
554
|
mcpManager: session.mcpManager,
|
|
542
555
|
yeaftDir: session.yeaftDir,
|
|
556
|
+
// Share the session-shared ToolUsageStats so per-VP tool calls land
|
|
557
|
+
// in the same on-disk snapshot the `unify_fetch_tool_stats` handler
|
|
558
|
+
// reads. Without this, engine's record-on-tool-exec guard
|
|
559
|
+
// (`if (this.#toolStats && ...)`) is false and group VP tool calls
|
|
560
|
+
// are silently dropped.
|
|
561
|
+
toolStats: session.toolStats || null,
|
|
543
562
|
});
|
|
544
563
|
vpEngines.set(key, eng);
|
|
545
564
|
return eng;
|