@yeaft/webchat-agent 1.0.347 → 1.0.348

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/yeaft/session.js CHANGED
@@ -250,23 +250,12 @@ export async function loadSession(options = {}) {
250
250
  }
251
251
 
252
252
  // ─── 3. Create trajectory trace ─────────────────────────
253
- // Always-on request trace for the Debug panel. It is file-backed, not
254
- // SQLite-backed: each request writes one bounded JSON file under
255
- // `<yeaftDir>/debug/` (session traces are nested under
256
- // `<yeaftDir>/sessions/<sessionId>/debug/requests/`). A request file stores one
257
- // base request snapshot plus per-loop deltas, so 100-200 loop requests do
258
- // not become hundreds of tiny files or repeated cumulative payloads.
253
+ // Debug traces can contain prompts, tool payloads, and provider envelopes.
254
+ // Keep collection opt-in and avoid scanning trace history during Session boot.
259
255
  const trace = createTrace({
260
- enabled: true,
256
+ enabled: config.debug === true,
261
257
  dirPath: yeaftDir,
262
258
  });
263
- // Hard cap debug history to the most recent 10 requests per Session. Trace
264
- // failures are best-effort and must never stop the agent loop. cleanup() is
265
- // now async (it hydrates the in-memory index, then prunes); run it
266
- // fire-and-forget so session load never blocks on the startup disk scan.
267
- Promise.resolve(trace.cleanup?.(10)).catch((err) => {
268
- console.warn('[Yeaft] trace.cleanup failed:', err?.message || err);
269
- });
270
259
 
271
260
  // ─── 4. Create LLM adapter ────────────────────────────
272
261
  const adapter = withUsageAccounting(
@@ -6440,7 +6440,13 @@ export async function handleYeaftFetchDebugHistory(msg = {}) {
6440
6440
  let dreamEvents = [];
6441
6441
  let hasMore = false;
6442
6442
  try {
6443
- if (session?.trace && typeof session.trace.fetchRecentDebugHistory === 'function') {
6443
+ if (session?.trace && detailTurnId && sessionId && typeof session.trace.fetchTurnDebug === 'function') {
6444
+ const out = await session.trace.fetchTurnDebug({ sessionId, turnId: detailTurnId, dreamLimit });
6445
+ loops = Array.isArray(out?.loops) ? out.loops : [];
6446
+ turns = Array.isArray(out?.turns) ? out.turns : [];
6447
+ dreamEvents = Array.isArray(out?.dreamEvents) ? out.dreamEvents : [];
6448
+ hasMore = false;
6449
+ } else if (session?.trace && typeof session.trace.fetchRecentDebugHistory === 'function') {
6444
6450
  const out = await session.trace.fetchRecentDebugHistory({ limit, dreamLimit, sessionId, threadId, indexOnly, detailTurnId, search });
6445
6451
  loops = Array.isArray(out?.loops) ? out.loops : [];
6446
6452
  turns = Array.isArray(out?.turns) ? out.turns : [];
@@ -121,6 +121,7 @@ async function createDefaultService() {
121
121
  policyProvider: async () => readWorkCenterSettings(yeaftDir),
122
122
  attachmentRoot: join(yeaftDir, 'work-center', 'attachments'),
123
123
  yeaftDir,
124
+ debug: ctx.CONFIG?.debug === true,
124
125
  actionWorktreeRoot: join(yeaftDir, 'work-center', 'worktrees'),
125
126
  registry: defaultRegistry,
126
127
  store: null,
@@ -797,7 +797,7 @@ export class WorkItemRunner {
797
797
  this.policyProvider = typeof options.policyProvider === 'function' ? options.policyProvider : null;
798
798
  this.attachmentRoot = options.attachmentRoot || null;
799
799
  this.trace = options.trace || createTrace({
800
- enabled: Boolean(options.yeaftDir),
800
+ enabled: options.debug === true && Boolean(options.yeaftDir),
801
801
  dirPath: options.yeaftDir || null,
802
802
  });
803
803
  this.actionWorktreeRoot = options.actionWorktreeRoot || null;