@yeaft/webchat-agent 0.1.893 → 0.1.894

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 (2) hide show
  1. package/package.json +1 -1
  2. package/yeaft/engine.js +21 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.893",
3
+ "version": "0.1.894",
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/yeaft/engine.js CHANGED
@@ -18,6 +18,7 @@
18
18
  */
19
19
 
20
20
  import { randomUUID } from 'crypto';
21
+ import { resolve as resolvePath } from 'path';
21
22
  import { buildSystemPrompt, buildWorkerPrompt } from './prompts.js';
22
23
  import { LLMContextError, LLMAbortError } from './llm/adapter.js';
23
24
  import { runMemoryPreflow, buildRelevantScopes } from './sessions/pre-flow.js';
@@ -877,7 +878,17 @@ export class Engine {
877
878
  return {
878
879
  signal,
879
880
  yeaftDir: this.#yeaftDir,
880
- cwd: process.cwd(),
881
+ // Group-scoped working directory. Threaded from #runQuery({ workDir })
882
+ // → set by web-bridge runVpTurn from sessionMeta.workDir. Tools read
883
+ // `ctx.cwd` and resolve relative paths against it. Always absolute
884
+ // (path.resolve normalizes relative inputs + trailing slashes) so
885
+ // tools that string-concatenate don't accidentally walk from
886
+ // process.cwd(). Falls back to process.cwd() in non-group / test
887
+ // contexts.
888
+ cwd: (() => {
889
+ const raw = typeof vpCtx?.workDir === 'string' ? vpCtx.workDir.trim() : '';
890
+ return raw ? resolvePath(raw) : process.cwd();
891
+ })(),
881
892
  mcpManager: this.#mcpManager,
882
893
  skillManager: this.#skillManager,
883
894
  conversationStore: this.#conversationStore,
@@ -2266,6 +2277,7 @@ export class Engine {
2266
2277
  contextWindow: currentContextWindow,
2267
2278
  getCurrentTodos,
2268
2279
  setCurrentTodos,
2280
+ workDir,
2269
2281
  requestEndTurn: (reason) => {
2270
2282
  // First call wins — preserve the kind/reason of the first tool
2271
2283
  // that asked to end the turn. Late callers (a second
@@ -2344,7 +2356,14 @@ export class Engine {
2344
2356
  output = await this.#toolRegistry.execute(tc.name, tc.input, toolCtx);
2345
2357
  } else {
2346
2358
  const tool = this.#tools.get(tc.name);
2347
- const rawOutput = await tool.execute(tc.input, { signal });
2359
+ // Pass the full toolCtx (cwd, workDir, signal, ) — not just
2360
+ // `{ signal }`. Legacy registerTool() callers historically got
2361
+ // a 1-field ctx, but that means tools like bash/file-read run
2362
+ // in the agent process cwd instead of the group's workDir.
2363
+ // Real production goes through #toolRegistry; the legacy path
2364
+ // is exercised by tests and a few standalone tools. Aligning
2365
+ // both paths keeps `ctx.cwd` semantics consistent.
2366
+ const rawOutput = await tool.execute(tc.input, toolCtx);
2348
2367
  // Legacy #tools branch must apply the same per-tool cap as
2349
2368
  // ToolRegistry.execute. Otherwise a deployment using the legacy
2350
2369
  // registration path bypasses the defense entirely.