@yeaft/webchat-agent 1.0.514 → 1.0.515
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/local-runtime/version.json +1 -1
- package/local-runtime/web/app.bundle.js +19 -0
- package/local-runtime/web/app.bundle.js.gz +0 -0
- package/local-runtime/web/index.html +2 -2
- package/local-runtime/web/style.bundle.css +1 -1
- package/local-runtime/web/style.bundle.css.gz +0 -0
- package/package.json +1 -1
- package/yeaft/engine.js +9 -44
- package/yeaft/prompts.js +27 -320
- package/yeaft/tasks/manager.js +0 -56
- package/yeaft/templates/common-rules.md +2 -2
- package/yeaft/tools/file-read.js +4 -5
- package/yeaft/web-bridge.js +3 -30
- package/yeaft/templates/tool-guidance.md +0 -11
package/yeaft/tasks/manager.js
CHANGED
|
@@ -20,7 +20,6 @@ import { getRuntimePlatformInfo } from '../runtime-platform.js';
|
|
|
20
20
|
const LOG_PREVIEW_BYTES = 4096;
|
|
21
21
|
const SUB_AGENT_LOG_PREVIEW_BYTES = 1024 * 1024;
|
|
22
22
|
const DEFAULT_CANCEL_ESCALATION_MS = 2000;
|
|
23
|
-
const PROMPT_TASK_LIMIT = 5;
|
|
24
23
|
|
|
25
24
|
function logPreviewBytesFor(task) {
|
|
26
25
|
return task?.kind === 'sub_agent' ? SUB_AGENT_LOG_PREVIEW_BYTES : LOG_PREVIEW_BYTES;
|
|
@@ -55,37 +54,6 @@ function publicSnapshot(task) {
|
|
|
55
54
|
};
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
function taskKindLabel(kind, language) {
|
|
59
|
-
const zh = String(language || '').toLowerCase().startsWith('zh');
|
|
60
|
-
if (kind === 'sub_agent') return zh ? '子 Agent' : 'sub-agent';
|
|
61
|
-
if (kind === 'shell') return zh ? '后台命令' : 'background command';
|
|
62
|
-
return zh ? '后台任务' : 'background task';
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function safeTaskName(task) {
|
|
66
|
-
const name = typeof task?.runtime?.name === 'string' ? task.runtime.name.trim() : '';
|
|
67
|
-
return /^[\p{L}\p{N}][\p{L}\p{N}._-]{0,63}$/u.test(name) ? name : '';
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function promptTaskLabel(task, language) {
|
|
71
|
-
const name = task?.kind === 'sub_agent' ? safeTaskName(task) : '';
|
|
72
|
-
if (!name) return taskKindLabel(task?.kind, language);
|
|
73
|
-
return String(language || '').toLowerCase().startsWith('zh')
|
|
74
|
-
? `子 Agent ${name}`
|
|
75
|
-
: `sub-agent ${name}`;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function taskStatusLabel(status, language) {
|
|
79
|
-
const zh = String(language || '').toLowerCase().startsWith('zh');
|
|
80
|
-
if (!zh) return String(status || 'running').replace(/_/g, ' ');
|
|
81
|
-
const labels = {
|
|
82
|
-
running: '运行中',
|
|
83
|
-
queued: '等待中',
|
|
84
|
-
cancelling: '正在取消',
|
|
85
|
-
};
|
|
86
|
-
return labels[status] || String(status || '运行中').replace(/_/g, ' ');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
57
|
export class TaskManager {
|
|
90
58
|
constructor({ yeaftDir, onEvent = null, runtimePlatform = null, cancelEscalationMs = DEFAULT_CANCEL_ESCALATION_MS } = {}) {
|
|
91
59
|
if (!yeaftDir) throw new Error('TaskManager requires yeaftDir');
|
|
@@ -384,28 +352,4 @@ export class TaskManager {
|
|
|
384
352
|
this.#emit('updated', task);
|
|
385
353
|
return publicSnapshot(task);
|
|
386
354
|
}
|
|
387
|
-
|
|
388
|
-
renderActiveTasksForPrompt(sessionId = null, { language = 'en', limit = PROMPT_TASK_LIMIT } = {}) {
|
|
389
|
-
const tasks = this.listActiveTasks(sessionId);
|
|
390
|
-
if (tasks.length === 0) return '';
|
|
391
|
-
const zh = String(language || '').toLowerCase().startsWith('zh');
|
|
392
|
-
const maxTasks = Number.isFinite(limit) && limit > 0 ? Math.floor(limit) : PROMPT_TASK_LIMIT;
|
|
393
|
-
const visible = tasks.slice(0, maxTasks);
|
|
394
|
-
const lines = [zh ? '## 可能相关的任务' : '## Possibly Relevant Tasks'];
|
|
395
|
-
lines.push(zh
|
|
396
|
-
? '以下任务仍在后台运行。需要进度或完整输出时使用任务工具查询;不要把它们当成记忆事实。'
|
|
397
|
-
: 'These tasks are still running in the background. Use the task tools for progress or full output; do not treat them as memory facts.');
|
|
398
|
-
for (const task of visible) {
|
|
399
|
-
const title = promptTaskLabel(task, language);
|
|
400
|
-
const detail = zh
|
|
401
|
-
? `${taskKindLabel(task.kind, language)},${taskStatusLabel(task.status, language)}`
|
|
402
|
-
: `${taskKindLabel(task.kind, language)}, ${taskStatusLabel(task.status, language)}`;
|
|
403
|
-
lines.push(`- ${title} (${detail})`);
|
|
404
|
-
}
|
|
405
|
-
if (tasks.length > visible.length) {
|
|
406
|
-
const remaining = tasks.length - visible.length;
|
|
407
|
-
lines.push(zh ? `- 另有 ${remaining} 个运行中任务,可用任务列表查看。` : `- ${remaining} more running task${remaining === 1 ? '' : 's'}; use the task list to inspect them.`);
|
|
408
|
-
}
|
|
409
|
-
return lines.join('\n');
|
|
410
|
-
}
|
|
411
355
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## Compatibility Note
|
|
4
4
|
|
|
5
|
-
Runtime prompt assembly now uses `core.md
|
|
5
|
+
Runtime prompt assembly now uses `core.md`; tool behavior is carried by provider tool schemas. This file remains packaged for deployments or integrations that still read the historical fragment directly.
|
|
6
6
|
|
|
7
7
|
<!-- lang:zh -->
|
|
8
8
|
|
|
9
9
|
## 兼容说明
|
|
10
10
|
|
|
11
|
-
运行时 Prompt
|
|
11
|
+
运行时 Prompt 现在使用 `core.md`;工具行为由 provider tool schema 承载。此文件继续随包发布,只用于仍直接读取旧 fragment 的部署或集成兼容。
|
package/yeaft/tools/file-read.js
CHANGED
|
@@ -27,11 +27,10 @@ const BINARY_EXTS = new Set([
|
|
|
27
27
|
/** Max file size to read (10 MB). */
|
|
28
28
|
const MAX_FILE_SIZE = 10 * 1024 * 1024;
|
|
29
29
|
|
|
30
|
-
/** Default number of lines to read. Aligned with the
|
|
31
|
-
* lines" rule
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* round-trip this tool's prompt guidance promises to avoid). */
|
|
30
|
+
/** Default number of lines to read. Aligned with the FileRead tool schema's
|
|
31
|
+
* "large file = >3000 lines" rule so a ≤3000-line file is returned in one
|
|
32
|
+
* call (no silent truncation that would trigger a follow-up `offset:3000`
|
|
33
|
+
* call — exactly the round-trip the tool guidance avoids). */
|
|
35
34
|
const DEFAULT_LIMIT = 3000;
|
|
36
35
|
|
|
37
36
|
/** Keep raw output close to the model-facing 32 KiB budget while leaving
|
package/yeaft/web-bridge.js
CHANGED
|
@@ -760,25 +760,6 @@ function legacyProjectContext(yeaftDir, sessionId) {
|
|
|
760
760
|
}, sessionId);
|
|
761
761
|
}
|
|
762
762
|
|
|
763
|
-
function buildProjectSharedBlock(projectContext, summaries = '') {
|
|
764
|
-
const context = normalizeProjectContext(projectContext, null);
|
|
765
|
-
const body = typeof summaries === 'string' ? summaries.trim() : '';
|
|
766
|
-
if (!context?.projectId && !body) return '';
|
|
767
|
-
const lines = ['[Project Shared Context]'];
|
|
768
|
-
if (context?.projectId) {
|
|
769
|
-
const label = context.projectName
|
|
770
|
-
? `${context.projectName} (${context.projectId})`
|
|
771
|
-
: context.projectId;
|
|
772
|
-
lines.push(`Project: ${label}`);
|
|
773
|
-
lines.push('Sharing boundary: sibling Sessions in this Project on this Agent only.');
|
|
774
|
-
} else {
|
|
775
|
-
lines.push('Sharing boundary: sibling Sessions in the same Project on this Agent only.');
|
|
776
|
-
}
|
|
777
|
-
lines.push('Read-only memory summaries preserve each source Session identity.');
|
|
778
|
-
if (body) lines.push('', body);
|
|
779
|
-
return lines.join('\n');
|
|
780
|
-
}
|
|
781
|
-
|
|
782
763
|
function vpKey(sessionId, vpId) {
|
|
783
764
|
return `${sessionId}::${vpId}`;
|
|
784
765
|
}
|
|
@@ -5721,16 +5702,9 @@ async function runVpTurn({ prompt, promptParts = null, sessionId, vpId, threadId
|
|
|
5721
5702
|
? `${projectContext.projectName} (${projectContext.projectId})`
|
|
5722
5703
|
: (projectContext?.projectId || '');
|
|
5723
5704
|
queryOpts.projectInstruction = projectContext?.projectInstruction || '';
|
|
5724
|
-
//
|
|
5725
|
-
//
|
|
5726
|
-
//
|
|
5727
|
-
// that sub-agents receive through memory.
|
|
5728
|
-
const sharedBlock = buildProjectSharedBlock(projectContext);
|
|
5729
|
-
if (sharedBlock) {
|
|
5730
|
-
queryOpts.sessionAnnouncement = queryOpts.sessionAnnouncement
|
|
5731
|
-
? `${queryOpts.sessionAnnouncement}\n\n${sharedBlock}`
|
|
5732
|
-
: sharedBlock;
|
|
5733
|
-
}
|
|
5705
|
+
// Project sibling identity remains available to Engine memory recall via
|
|
5706
|
+
// projectSessionIds. Do not mirror internal sharing metadata into the
|
|
5707
|
+
// user-authored Session announcement shown to the model.
|
|
5734
5708
|
}
|
|
5735
5709
|
let turnSessionMeta = null;
|
|
5736
5710
|
try { turnSessionMeta = sessionCoordinator?.group?.getMeta?.() || null; } catch { turnSessionMeta = null; }
|
|
@@ -8238,7 +8212,6 @@ export function handleYeaftMcpReload(msg = {}) {
|
|
|
8238
8212
|
export const __testHooks = {
|
|
8239
8213
|
loadProjects,
|
|
8240
8214
|
sharedProjectContext,
|
|
8241
|
-
buildProjectSharedBlock,
|
|
8242
8215
|
normalizeProjectContext,
|
|
8243
8216
|
handleProjectContextSyncForTest(msg) {
|
|
8244
8217
|
handleYeaftProjectContextSync(msg);
|