@yeaft/webchat-agent 1.0.532 → 1.0.533

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.
Binary file
@@ -17,6 +17,6 @@
17
17
  </head>
18
18
  <body>
19
19
  <div id="app"></div>
20
- <script type="module" src="app.bundle.js?v=66d6c50c"></script>
20
+ <script type="module" src="app.bundle.js?v=4b0c1e23"></script>
21
21
  </body>
22
22
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "1.0.532",
3
+ "version": "1.0.533",
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",
@@ -18,6 +18,7 @@ import { normaliseBrowserRuntimeSection, validateBrowserRuntimeUpdate } from '..
18
18
  import { normalizePluginConfig } from './plugins.js';
19
19
  import { mutateAgentConfig, readAgentConfigForWrite } from './config-store.js';
20
20
  import { isGitHubCopilotProvider, normalizeKnownProviderForRuntime, serializeKnownProviderForPersistence } from './llm/known-providers.js';
21
+ import { getWorkCenterFeatureState } from './work-center/feature.js';
21
22
 
22
23
  /** Agent-owned model catalog, with the same protocol/capability resolution as runtime. */
23
24
  function quickSendModels(config) {
@@ -393,6 +394,35 @@ export function updateTelemetrySettings(update, dir) {
393
394
  }
394
395
  }
395
396
 
397
+ export function getWorkCenterFeatureSettings(dir, env = process.env) {
398
+ const root = dir || process.env.YEAFT_DIR || DEFAULT_YEAFT_DIR;
399
+ const configPath = join(root, 'config.json');
400
+ try {
401
+ const json = existsSync(configPath) ? JSON.parse(readFileSync(configPath, 'utf8')) : {};
402
+ return getWorkCenterFeatureState(json, env);
403
+ } catch (error) {
404
+ return { error: `Failed to read config.json: ${error.message}` };
405
+ }
406
+ }
407
+
408
+ export function updateWorkCenterFeatureSettings(update, dir, env = process.env) {
409
+ if (!update || typeof update !== 'object' || Array.isArray(update) || typeof update.enabled !== 'boolean'
410
+ || Object.keys(update).some(key => key !== 'enabled')) return { error: 'enabled must be a boolean' };
411
+ const current = getWorkCenterFeatureSettings(dir, env);
412
+ if (current.error) return current;
413
+ if (current.overridden) return { ...current, error: 'Work Center is controlled by YEAFT_WORK_CENTER_ENABLED' };
414
+ const root = dir || process.env.YEAFT_DIR || DEFAULT_YEAFT_DIR;
415
+ try {
416
+ mutateAgentConfig(root, existing => {
417
+ existing.workCenter = { ...(existing.workCenter && typeof existing.workCenter === 'object' ? existing.workCenter : {}), enabled: update.enabled };
418
+ return existing.workCenter;
419
+ });
420
+ return { enabled: update.enabled, source: 'config', overridden: false };
421
+ } catch (error) {
422
+ return { error: `Failed to read config.json or persist update: ${error?.message || error}` };
423
+ }
424
+ }
425
+
396
426
  // ─── Browser Runtime settings ───────────────────────────────────────
397
427
 
398
428
  export function getBrowserRuntimeSettings(dir) {
package/yeaft/config.js CHANGED
@@ -544,6 +544,7 @@ export function loadConfig(overrides = {}) {
544
544
  // don't pollute the flat config namespace used by chat code.
545
545
  yeaft: normaliseYeaftSection(jsonConfig.yeaft),
546
546
  telemetry: normaliseTelemetrySection(jsonConfig.telemetry),
547
+ workCenter: { enabled: jsonConfig.workCenter?.enabled === true },
547
548
  dream: { enabled: jsonConfig.dream?.enabled === true },
548
549
  browserRuntime: normaliseBrowserRuntimeSection(jsonConfig.browserRuntime),
549
550
 
package/yeaft/session.js CHANGED
@@ -141,7 +141,7 @@ export async function loadSession(options = {}) {
141
141
  serverMode = false,
142
142
  dreamEnabled,
143
143
  managedCliReady = null,
144
- workCenterEnabled = isWorkCenterEnabled(),
144
+ workCenterEnabled,
145
145
  } = options;
146
146
 
147
147
  // ─── 1. Determine config + store directories ─────────────
@@ -173,6 +173,7 @@ export async function loadSession(options = {}) {
173
173
 
174
174
  // ─── 2. Load config ───────────────────────────────────
175
175
  const config = loadConfig(overrides);
176
+ const effectiveWorkCenterEnabled = workCenterEnabled ?? isWorkCenterEnabled(process.env, config);
176
177
  // fix/dream-cadence-and-ui-trigger: tag config so the dream scheduler
177
178
  // can decide whether to keep its interval timer alive (server) or
178
179
  // unref it (CLI / tests). Non-persisted — set per-session by caller.
@@ -412,7 +413,7 @@ export async function loadSession(options = {}) {
412
413
  // ─── 8. Build tool registry ────────────────────────────
413
414
  const taskManager = new TaskManager({ yeaftDir });
414
415
  const toolRegistry = createFullRegistry();
415
- if (!workCenterEnabled) toolRegistry.unregister('CreateWorkItem');
416
+ if (!effectiveWorkCenterEnabled) toolRegistry.unregister('CreateWorkItem');
416
417
 
417
418
  // Register any extra tools from caller
418
419
  for (const tool of extraTools) {
@@ -18,6 +18,7 @@ let initPromise = null;
18
18
  let shuttingDown = false;
19
19
  let shutdownPromise = null;
20
20
  let serviceFactory = null;
21
+ let featureEnabled = false;
21
22
 
22
23
  const BROWSER_DETAIL_OPS = new Set([
23
24
  'get', 'create', 'update', 'start', 'cancel', 'resume', 'extend_budget', 'post_work_item_message', 'action_input', 'retry_action', 'guide', 'retry',
@@ -161,8 +162,9 @@ async function createDefaultService() {
161
162
  }
162
163
 
163
164
  async function ensureWorkCenter() {
164
- if (service) return service;
165
+ if (!featureEnabled) throw new Error('Work Center is disabled');
165
166
  if (shuttingDown) throw new Error('Work Center is shutting down');
167
+ if (service) return service;
166
168
  if (initPromise) return initPromise;
167
169
  initPromise = (async () => {
168
170
  const created = serviceFactory ? await serviceFactory() : await createDefaultService();
@@ -182,9 +184,14 @@ async function ensureWorkCenter() {
182
184
  }
183
185
 
184
186
  export async function bootWorkCenter() {
187
+ featureEnabled = true;
185
188
  return ensureWorkCenter();
186
189
  }
187
190
 
191
+ export function setWorkCenterFeatureEnabled(enabled) {
192
+ featureEnabled = enabled === true;
193
+ }
194
+
188
195
  export async function snapshotCurrentSessionContext(sessionId) {
189
196
  const runtime = await getRuntime();
190
197
  return snapshotSessionContext(runtime?.conversationStore, sessionId);
@@ -269,6 +276,7 @@ export async function shutdownWorkCenter() {
269
276
  } finally {
270
277
  initPromise = null;
271
278
  shutdownPromise = null;
279
+ shuttingDown = false;
272
280
  }
273
281
  }
274
282
 
@@ -277,6 +285,7 @@ export function __testSetWorkCenterService(next) {
277
285
  initPromise = null;
278
286
  shuttingDown = false;
279
287
  shutdownPromise = null;
288
+ featureEnabled = !!next;
280
289
  }
281
290
 
282
291
  export function __testSetWorkCenterFactory(factory) {
@@ -285,4 +294,5 @@ export function __testSetWorkCenterFactory(factory) {
285
294
  initPromise = null;
286
295
  shuttingDown = false;
287
296
  shutdownPromise = null;
297
+ featureEnabled = false;
288
298
  }
@@ -1,10 +1,27 @@
1
1
  /**
2
- * Work Center is opt-in. Only the explicit string "true" enables the feature;
3
- * missing, malformed, and legacy configurations remain disabled.
4
- *
5
- * @param {NodeJS.ProcessEnv|Record<string, string|undefined>} [env]
6
- * @returns {boolean}
2
+ * Resolve the Work Center gate. An explicitly present legacy environment
3
+ * variable overrides the persisted Agent setting; otherwise config defaults off.
7
4
  */
8
- export function isWorkCenterEnabled(env = process.env) {
9
- return env?.YEAFT_WORK_CENTER_ENABLED === 'true';
5
+ export function getWorkCenterFeatureState(config = {}, env = process.env) {
6
+ const overridden = Object.prototype.hasOwnProperty.call(env || {}, 'YEAFT_WORK_CENTER_ENABLED');
7
+ return {
8
+ enabled: overridden ? env.YEAFT_WORK_CENTER_ENABLED === 'true' : config?.workCenter?.enabled === true,
9
+ source: overridden ? 'environment' : 'config',
10
+ overridden,
11
+ };
12
+ }
13
+
14
+ export function isWorkCenterEnabled(env = process.env, config = {}) {
15
+ return getWorkCenterFeatureState(config, env).enabled;
16
+ }
17
+
18
+ /** Boot the persisted feature without changing its configured value. */
19
+ export async function startWorkCenterFeature(enabled, boot) {
20
+ if (enabled !== true) return { effective: false, runtimeError: null };
21
+ try {
22
+ await boot();
23
+ return { effective: true, runtimeError: null };
24
+ } catch (error) {
25
+ return { effective: false, runtimeError: error?.message || String(error) };
26
+ }
10
27
  }