@yeaft/webchat-agent 0.1.1004 → 0.1.1005
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 +1 -1
- package/yeaft/prompts.js +42 -2
- package/yeaft/tools/route-forward.js +10 -5
package/package.json
CHANGED
package/yeaft/prompts.js
CHANGED
|
@@ -197,6 +197,7 @@ const PROMPTS = {
|
|
|
197
197
|
tools: (names) => `Available tools: ${names}`,
|
|
198
198
|
// DESIGN-PROMPT §3 ④ — Active Scope header
|
|
199
199
|
activeScopeHeader: '## active_scope',
|
|
200
|
+
multiVpRoutingHeader: '## multi_vp_routing',
|
|
200
201
|
sessionAnnouncementHeader: '[Session Announcement]',
|
|
201
202
|
// Project-doc (CLAUDE.md / AGENTS.md) header + one-liner intro. Both
|
|
202
203
|
// filenames are recognized: CLAUDE.md is this project's convention,
|
|
@@ -212,6 +213,7 @@ const PROMPTS = {
|
|
|
212
213
|
tools: (names) => `可用工具:${names}`,
|
|
213
214
|
// DESIGN-PROMPT §3 ④ — Active Scope header
|
|
214
215
|
activeScopeHeader: '## active_scope',
|
|
216
|
+
multiVpRoutingHeader: '## multi_vp_routing',
|
|
215
217
|
sessionAnnouncementHeader: '[会话公告]',
|
|
216
218
|
// 项目文档块:CLAUDE.md / AGENTS.md(与 Codex 通用命名兼容)。
|
|
217
219
|
projectDocHeader: '[项目文档]',
|
|
@@ -393,6 +395,9 @@ export function buildSystemPrompt({
|
|
|
393
395
|
const activeScopeBlock = renderActiveScope(activeScope, lang);
|
|
394
396
|
if (activeScopeBlock) parts.push(activeScopeBlock);
|
|
395
397
|
|
|
398
|
+
const multiVpRoutingBlock = renderMultiVpRouting(activeScope, lang);
|
|
399
|
+
if (multiVpRoutingBlock) parts.push(multiVpRoutingBlock);
|
|
400
|
+
|
|
396
401
|
return parts.join('\n\n');
|
|
397
402
|
}
|
|
398
403
|
|
|
@@ -490,7 +495,11 @@ function firstNonEmptyString(...values) {
|
|
|
490
495
|
}
|
|
491
496
|
|
|
492
497
|
function renderSessionMembersLine(members) {
|
|
493
|
-
|
|
498
|
+
return normalizeSessionMemberIds(members).join(', ');
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
function normalizeSessionMemberIds(members) {
|
|
502
|
+
if (!Array.isArray(members)) return [];
|
|
494
503
|
const clean = [];
|
|
495
504
|
const seen = new Set();
|
|
496
505
|
for (const member of members) {
|
|
@@ -500,7 +509,38 @@ function renderSessionMembersLine(members) {
|
|
|
500
509
|
seen.add(id);
|
|
501
510
|
clean.push(id);
|
|
502
511
|
}
|
|
503
|
-
return clean
|
|
512
|
+
return clean;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function renderMultiVpRouting(activeScope, lang) {
|
|
516
|
+
if (!activeScope || typeof activeScope !== 'object') return '';
|
|
517
|
+
const ownId = firstNonEmptyString(activeScope.sessionMember, activeScope.vpId);
|
|
518
|
+
const members = normalizeSessionMemberIds(activeScope.sessionMembers || activeScope.members);
|
|
519
|
+
const peers = ownId ? members.filter((member) => member !== ownId) : members;
|
|
520
|
+
if (peers.length === 0) return '';
|
|
521
|
+
|
|
522
|
+
const header = lang.multiVpRoutingHeader || '## multi_vp_routing';
|
|
523
|
+
if (lang === PROMPTS.zh) {
|
|
524
|
+
return [
|
|
525
|
+
header,
|
|
526
|
+
`当前 VP: ${ownId || 'unknown'}`,
|
|
527
|
+
`可转发 VP: ${peers.join(', ')}`,
|
|
528
|
+
'- 多 VP session 中,先主动感知这些 VP 的职责;不要假装只有你一个人在场。',
|
|
529
|
+
'- 当用户点名其他 VP、任务明显属于其他 VP、需要并行协作,或你需要另一个 VP 继续处理时,必须调用 `route_forward`。',
|
|
530
|
+
'- VP 自己写 @mention 不会触发路由;只有 `route_forward` 工具会真正把任务交给目标 VP。',
|
|
531
|
+
'- 如果要多人一起处理,调用 `route_forward`,`to` 可填目标 vpId 或 `all`;`text` 要包含明确任务和必要上下文。',
|
|
532
|
+
].join('\n');
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
return [
|
|
536
|
+
header,
|
|
537
|
+
`Current VP: ${ownId || 'unknown'}`,
|
|
538
|
+
`Forwardable VPs: ${peers.join(', ')}`,
|
|
539
|
+
'- In a multi-VP session, actively notice these peers and their likely responsibilities; do not behave as if you are alone.',
|
|
540
|
+
'- When the user names another VP, the task clearly belongs to another VP, parallel collaboration is needed, or another VP should continue the work, you MUST call `route_forward`.',
|
|
541
|
+
'- VP-written @mentions do not route anything; only the `route_forward` tool performs a real hand-off.',
|
|
542
|
+
'- For multi-person work, call `route_forward` with a target vpId or `all`; include the concrete task and required context in `text`.',
|
|
543
|
+
].join('\n');
|
|
504
544
|
}
|
|
505
545
|
|
|
506
546
|
/**
|
|
@@ -27,16 +27,21 @@ import { defineTool } from './types.js';
|
|
|
27
27
|
|
|
28
28
|
export default defineTool({
|
|
29
29
|
name: 'RouteForward',
|
|
30
|
-
description: `Hand this turn off to another VP in the same
|
|
30
|
+
description: `Hand this turn off to another VP in the same session.
|
|
31
31
|
|
|
32
32
|
Use this tool — NOT free-text @mentions — to route a question or task to
|
|
33
33
|
another VP. VP-authored @mentions in chat text are NOT automatically routed
|
|
34
|
-
(the
|
|
35
|
-
|
|
34
|
+
(the coordinator only text-routes user messages); you must call RouteForward
|
|
35
|
+
for the hand-off to take effect.
|
|
36
|
+
|
|
37
|
+
In a multi-VP session, treat RouteForward as the required hand-off mechanism:
|
|
38
|
+
- If the user names another VP, call RouteForward to that vpId.
|
|
39
|
+
- If another VP clearly owns the domain or should continue the work, call RouteForward instead of only mentioning them.
|
|
40
|
+
- If the task needs parallel collaboration, call RouteForward with a target vpId or "all".
|
|
36
41
|
|
|
37
42
|
Arguments:
|
|
38
43
|
- to (string): target vpId, or the literal "all" to broadcast to every
|
|
39
|
-
other member of the
|
|
44
|
+
other member of the session (subject to the session fan-out cap).
|
|
40
45
|
- text (string): the message body to send on your behalf.
|
|
41
46
|
- reason (string, optional): short rationale for the forward, recorded on
|
|
42
47
|
the message meta for audit / UI display.
|
|
@@ -47,7 +52,7 @@ Rules:
|
|
|
47
52
|
- Forwards carry a causedBy chain; chains deeper than 10 hops are blocked
|
|
48
53
|
(chain_depth_exceeded).
|
|
49
54
|
- A single target may be forwarded to at most 8 times per 5-second window
|
|
50
|
-
per
|
|
55
|
+
per session (throttled).
|
|
51
56
|
|
|
52
57
|
Returns JSON: { ok, dispatched?, error?, detail? }.`,
|
|
53
58
|
parameters: {
|