@yeaft/webchat-agent 1.0.142 → 1.0.144

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "1.0.142",
3
+ "version": "1.0.144",
4
4
  "description": "Remote worker agent for Yeaft Web Code Agent — connects the native Yeaft engine, CLI providers, and workbench tools",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -34,7 +34,7 @@ Use this when work must continue beyond the current turn, needs role handoffs, r
34
34
  },
35
35
  workDir: {
36
36
  type: 'string',
37
- description: { en: 'Optional project directory for execution', zh: '执行时使用的可选项目目录' },
37
+ description: { en: 'Existing project directory for execution', zh: '执行时使用的已存在项目目录' },
38
38
  },
39
39
  start: {
40
40
  type: 'boolean',
@@ -70,6 +70,7 @@ async function getSettingsRuntime() {
70
70
  models: Array.isArray(runtime.config.availableModels) ? runtime.config.availableModels : [],
71
71
  primaryModel: runtime.config.primaryModel || runtime.config.model || null,
72
72
  fastModel: runtime.config.fastModel || null,
73
+ defaultWorkDir: ctx.CONFIG?.workDir || process.cwd(),
73
74
  defaultStageInstructions: defaultWorkCenterStageInstructions(),
74
75
  };
75
76
  }
@@ -1,4 +1,5 @@
1
- import { join } from 'node:path';
1
+ import { realpathSync, statSync } from 'node:fs';
2
+ import { join, resolve } from 'node:path';
2
3
  import { randomUUID } from 'node:crypto';
3
4
  import { WorkItemStore } from './store.js';
4
5
  import { WorkflowController } from './controller.js';
@@ -16,6 +17,18 @@ function requiredString(value, name) {
16
17
  return value.trim();
17
18
  }
18
19
 
20
+ function requiredWorkDir(value) {
21
+ const workDir = requiredString(value, 'workDir');
22
+ let canonical;
23
+ try {
24
+ canonical = realpathSync(resolve(workDir));
25
+ if (!statSync(canonical).isDirectory()) throw new Error('not a directory');
26
+ } catch {
27
+ throw new Error('workDir must be an existing directory');
28
+ }
29
+ return canonical;
30
+ }
31
+
19
32
  export class WorkCenterService {
20
33
  constructor(options) {
21
34
  const yeaftDir = requiredString(options?.yeaftDir, 'yeaftDir');
@@ -72,6 +85,12 @@ export class WorkCenterService {
72
85
  const workflowSnapshot = explicitWorkflow
73
86
  ? resolveWorkflowSnapshot(settings, explicitWorkflow, payload.stageOverrides)
74
87
  : resolvePlanningWorkflowSnapshot(settings);
88
+ const runtime = !Object.hasOwn(payload, 'workDir') && !settings.defaultWorkDir
89
+ ? await this.runtimeInfo()
90
+ : null;
91
+ const workDir = requiredWorkDir(Object.hasOwn(payload, 'workDir')
92
+ ? payload.workDir
93
+ : settings.defaultWorkDir || runtime?.defaultWorkDir);
75
94
  const item = this.controller.create({
76
95
  title: requiredString(payload.title, 'title'),
77
96
  goal: requiredString(payload.goal, 'goal'),
@@ -80,9 +99,7 @@ export class WorkCenterService {
80
99
  : [],
81
100
  workflowTemplate,
82
101
  workflowSnapshot,
83
- workDir: typeof payload.workDir === 'string' && payload.workDir.trim()
84
- ? payload.workDir.trim()
85
- : settings.defaultWorkDir,
102
+ workDir,
86
103
  reuseMemory: payload.reuseMemory !== false,
87
104
  origin: payload.origin && typeof payload.origin === 'object'
88
105
  ? {