@yeaft/webchat-agent 1.0.120 → 1.0.121

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.120",
3
+ "version": "1.0.121",
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",
package/yeaft/engine.js CHANGED
@@ -23,7 +23,7 @@ import { join, resolve as resolvePath } from 'path';
23
23
  import { buildSystemPrompt, buildWorkerPrompt } from './prompts.js';
24
24
  import { getRuntimePlatformInfo } from './runtime-platform.js';
25
25
  import { LLMContextError, LLMAbortError, LLMRateLimitError, LLMServerError, LLMStreamIdleTimeoutError } from './llm/adapter.js';
26
- import { runMemoryPreflow, buildRelevantScopes } from './sessions/pre-flow.js';
26
+ import { runMemoryPreflow, buildRelevantScopes, memoryScopeLabel } from './sessions/pre-flow.js';
27
27
  import { readProjectDoc, pickProjectDocFile, DEFAULT_PROJECT_DOC_MAX_BYTES } from './sessions/project-doc.js';
28
28
  import { partitionMessages } from './compact/partition.js';
29
29
  import { runCompact as runCompactOrchestrator } from './compact/orchestrator.js';
@@ -905,19 +905,19 @@ export class Engine {
905
905
  if (snap.resident.length > 0) {
906
906
  parts.push(zh ? '### 常驻记忆' : '### Resident');
907
907
  for (const r of snap.resident) {
908
- parts.push(`- **${r.scope}**: ${r.summary}`);
908
+ parts.push(`- **${memoryScopeLabel(r.scope)}**: ${r.summary}`);
909
909
  }
910
910
  }
911
911
  if (snap.recent.length > 0) {
912
912
  parts.push(zh ? '### 最近记忆' : '### Recent');
913
913
  for (const s of snap.recent) {
914
- parts.push(`- (${s.scope}) ${(s.body || '').trim()}`);
914
+ parts.push(`- (${memoryScopeLabel(s.scope)}) ${(s.body || '').trim()}`);
915
915
  }
916
916
  }
917
917
  if (snap.onDemand.length > 0) {
918
918
  parts.push(zh ? '### 按需记忆' : '### OnDemand');
919
919
  for (const s of snap.onDemand) {
920
- parts.push(`- (${s.scope}) ${(s.body || '').trim()}`);
920
+ parts.push(`- (${memoryScopeLabel(s.scope)}) ${(s.body || '').trim()}`);
921
921
  }
922
922
  }
923
923
  return parts.join('\n');
@@ -157,6 +157,24 @@ export function selectRespondingVps(input) {
157
157
  }
158
158
 
159
159
 
160
+ /**
161
+ * Turn an internal memory scope into the compact label shown to the model.
162
+ * The active-scope prompt already carries the current session id, so repeating
163
+ * the full storage path on every memory entry only wastes context. Internal
164
+ * entries and debug events keep the original scope for ACLs and diagnostics.
165
+ *
166
+ * @param {string} scope
167
+ * @returns {string}
168
+ */
169
+ export function memoryScopeLabel(scope) {
170
+ const value = typeof scope === 'string' && scope ? scope : 'unknown';
171
+ const sessionTopic = /^(?:sessions|session|group)\/[^/]+\/topic\/(.+)$/.exec(value);
172
+ if (sessionTopic) return `topic: ${sessionTopic[1]}`;
173
+ if (/^(?:sessions|session|group)\/[^/]+$/.test(value)) return 'session';
174
+ if (value.startsWith('topic/')) return `topic: ${value.slice(6)}`;
175
+ return value;
176
+ }
177
+
160
178
  /**
161
179
  * Build the heading for a single scope's formatted memory block.
162
180
  *
@@ -167,6 +185,8 @@ export function selectRespondingVps(input) {
167
185
  * @returns {string}
168
186
  */
169
187
  function scopeHeading(scope) {
188
+ const label = memoryScopeLabel(scope);
189
+ if (label.startsWith('topic: ')) return `## Memory: Topic ${label.slice(7)}`;
170
190
  if (scope === 'user') return '## Memory: User';
171
191
  // Nested chat scopes first.
172
192
  let m = /^chat\/([^/]+)\/vp\/(.+)$/.exec(scope);
@@ -180,10 +200,6 @@ function scopeHeading(scope) {
180
200
  if (m) return `## Memory: Session ${m[1]} (user)`;
181
201
  m = /^session\/([^/]+)\/feature\/(.+)$/.exec(scope);
182
202
  if (m) return `## Memory: Feature ${m[2]}`;
183
- m = /^sessions\/([^/]+)\/topic\/(.+)$/.exec(scope);
184
- if (m) return `## Memory: Topic ${m[2]}`;
185
- m = /^session\/([^/]+)\/topic\/(.+)$/.exec(scope);
186
- if (m) return `## Memory: Topic ${m[2]}`;
187
203
  // Legacy nested group scopes (un-migrated data).
188
204
  m = /^group\/([^/]+)\/vp\/(.+)$/.exec(scope);
189
205
  if (m) return `## Memory: VP ${m[2]}`;
@@ -191,8 +207,6 @@ function scopeHeading(scope) {
191
207
  if (m) return `## Memory: Session ${m[1]} (user)`;
192
208
  m = /^group\/([^/]+)\/feature\/(.+)$/.exec(scope);
193
209
  if (m) return `## Memory: Feature ${m[2]}`;
194
- m = /^group\/([^/]+)\/topic\/(.+)$/.exec(scope);
195
- if (m) return `## Memory: Topic ${m[2]}`;
196
210
  if (scope.startsWith('session/')) return `## Memory: Session ${scope.slice(8)}`;
197
211
  if (scope.startsWith('group/')) return `## Memory: Session ${scope.slice(6)}`;
198
212
  if (scope.startsWith('vp/')) return `## Memory: VP ${scope.slice(3)}`;