@v587d/capital-generation 2.31.0 → 2.31.1
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/CHANGELOG.md +48 -0
- package/README.md +2 -2
- package/automation/package.json +1 -1
- package/chart-ui/package.json +1 -1
- package/config/package.json +1 -1
- package/lib/agents/messaging-policy.d.ts +23 -6
- package/lib/agents/messaging-policy.js +64 -9
- package/lib/agents/role-tool-policy.js +3 -3
- package/lib/analysis/schemas.d.ts +8 -2
- package/lib/analysis/schemas.js +8 -2
- package/lib/analysis/tools.js +5 -0
- package/lib/analysis/validation.js +59 -16
- package/lib/data-collector/store.js +3 -1
- package/lib/web-retriever/local-fetch.d.ts +1 -1
- package/lib/web-retriever/local-fetch.js +1 -1
- package/lib/web-retriever/wind-client.d.ts +1 -1
- package/lib/web-retriever/wind-client.js +1 -1
- package/package.json +1 -1
- package/preset/capital-generation/agent.patch.yml +12 -12
- package/preset/capital-generation/skills/capital-analysis-synthesis/SKILL.md +1 -1
- package/preset/capital-generation/skills/capital-analysis-validation/SKILL.md +9 -6
- package/preset/capital-generation/skills/capital-orchestration/SKILL.md +31 -26
- package/preset/capital-generation/skills/capital-senior-analysis/SKILL.md +13 -8
- package/watchlist/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,54 @@
|
|
|
7
7
|
- **第三位(patch)**:不破坏既有工具 / 配置 / 会话的新增与修复(如 2.1.1、2.1.2)。
|
|
8
8
|
- **第二位(minor)**:有需要用户知晓的行为变更,且段内附迁移说明(如 2.1.0 的图表呈现通道重做、2.2.0 的数据源与检索来源扩容、2.4.0 的**必须换宿主版本**、2.9.0 的选择器收敛与质检前置——本插件自己的工具与数据契约没变,所以只抬第二位)。
|
|
9
9
|
|
|
10
|
+
## [2.31.1] - 2026-11-25
|
|
11
|
+
|
|
12
|
+
高级分析师的协作层收尾:子 Agent 按邻接表直连(P4),同时修掉真实会话暴露的三处问题——跨 Agent 读 profile
|
|
13
|
+
的会话范围写错、20k 产物预算让综合多期报告反复删减重提、以及锚点校验把证券代码与四舍五入后的数字当成
|
|
14
|
+
无来源。本轮不新增分析模块;P5(模块扩展)与 P6(加固与评估)继续在 2.31.x 补丁里完成。
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- **子 Agent 直连邻接表**(设计 §5.2):主 Agent → 直系子 Agent;data-collector → data-junior / senior-analyst;
|
|
19
|
+
data-junior 与 web-retriever → senior-analyst;senior-analyst → data-junior(只请求"用已有 Dataset/profile
|
|
20
|
+
补计算",新数据 / 新检索仍经主 Agent)与 lead;visualization-specialist 仍不发消息。目标按固定树内名匹配,
|
|
21
|
+
表外目标逐角色给具名拒语;`list_agents` / `interrupt_agent` 仍只归主 Agent。直连是路由纪律,不是安全边界。
|
|
22
|
+
- **补计算往返预算 3 次**(设计 §5.6-2):senior 第 4 次向 peer 发请求在发送侧被拒;`submit_analysis` 再按
|
|
23
|
+
`task_id` 核对 `peer_exchanges[]`,超 3 条抛 `analysis_peer_budget_exhausted`;有未回执项不能写 `completed`。
|
|
24
|
+
- **`waiting_peer` 收尾状态**:等补计算回执 ≠ 完成,只有主 Agent 收到最终回执才算完;状态词汇、对账表
|
|
25
|
+
(`capital-orchestration` §4/§6.1/§7)与四册消息章节同步。
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- **分析产物预算 20000 → 30000 字符**:综合多期产物实测落在 20–21.7k,20k 上限让 senior 反复删减重提
|
|
30
|
+
(真实会话 7 连拒、其中 6 次是体积);单段上限不变(headline 300 / thesis 1200 / statement 600 /
|
|
31
|
+
每侧 claims 20 / scenarios 8)。
|
|
32
|
+
- **数字锚点按显示精度匹配**:`1.23` 可命中 `1.2345`、`4.44%` 命中 `4.4444%`、整数百分比 `18%` 命中
|
|
33
|
+
`18.04%`(无小数的整数本身不按小数位放宽);六位证券代码(`600519` / `000858` / `920000`)与 ≤20 的
|
|
34
|
+
结构性计数(`5 条` / `0 次`)进豁免集;同一字段里重复的未命中数字去重。真正无锚点的数字仍硬拒。
|
|
35
|
+
- **协议文案同步**:`capital-senior-analysis` / `capital-analysis-validation` / `capital-orchestration`
|
|
36
|
+
的消息、预算与锚点口径更新;`docs/dev/senior-analysis.md` 记录直连邻接表、往返预算与收尾四条。
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
|
|
40
|
+
- **兄弟 Agent 永远读不到对方的 profile**:`ProfileRef.session_id` 写入的是产出者 session id,而 `readProfile`
|
|
41
|
+
按 `sessionScopeFor(session)` 比较,跨 Agent(如 senior 读 junior 的 profile)必然 `dataset_session_mismatch`。
|
|
42
|
+
改为写会话范围,并补跨兄弟 profile 读取回归。
|
|
43
|
+
- **peer-only 子 Agent 的唤醒噪声**:只跟 peer 通信、没向根投递 relay 的子 Agent 可能在收尾多唤醒一个空轮。
|
|
44
|
+
首版按噪声接受(不丢数据),行为写进 `settled-wake` 回归与 `docs/dev/chart-delivery-events.md`。
|
|
45
|
+
|
|
46
|
+
### Notes
|
|
47
|
+
|
|
48
|
+
- 升级无需迁移:本补丁不破坏工具 / 配置 / 会话契约;直连目标按树内名匹配,已有会话继续可用。
|
|
49
|
+
- 路由纠偏(估值 / 收益风险 / 事件不派 senior)与"不输出买卖建议"护栏加固排在 P5 之后整体处理(真实会话
|
|
50
|
+
证据见设计文档 §17 Phase 4 实测)。
|
|
51
|
+
- 版本:根包 + 四个随包嵌套包(chart-ui / config / watchlist / automation)+
|
|
52
|
+
`LOCAL_FETCH_CLIENT_VERSION` / `WIND_CLIENT_VERSION` 同步 2.31.1。
|
|
53
|
+
- 回归:`npm test` **1792 pass / 0 fail**(直连邻接表逐边正反、peer 预算、跨兄弟 profile、锚点放宽与
|
|
54
|
+
30000 体积各有用例),`smoke:boot` 五个角色 preset 全 `broken: null`、族行 23/23,`check:dsh` 40/40。
|
|
55
|
+
- 依据:2026-11-25 真实 web profile 会话三场(轻量 FY2024 / 五年期复核 / 估值边界)——能力结论与两处失败
|
|
56
|
+
记录在 `docs/design/senior-analyst-development-design.md` §17 Phase 4 实测。
|
|
57
|
+
|
|
10
58
|
## [2.31.0] - 2026-11-24
|
|
11
59
|
|
|
12
60
|
高级分析师(`senior_analyst`)上线:补上「取数 → 质检 → 分析 → 结论」的最后一段——新增一个根直系叶子角色、
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-green" alt="License"></a>
|
|
4
4
|
<a href="https://github.com/v587d/capital-generation"><img src="https://img.shields.io/badge/Financial%20Market-CN%20%7C%20HK%20%7C%20US-orange" alt="Market·CN+HK+US"></a>
|
|
5
5
|
<a href="https://github.com/deepseek-ai"><img src="https://img.shields.io/badge/DSH%20Baseline-0.2.2--rc.5-blue" alt="DSH@0.2.2-rc.5"></a>
|
|
6
|
-
<a href="https://github.com/v587d/capital-generation/releases"><img src="https://img.shields.io/badge/version-2.31.
|
|
6
|
+
<a href="https://github.com/v587d/capital-generation/releases"><img src="https://img.shields.io/badge/version-2.31.1-9cf" alt="Version"></a>
|
|
7
7
|
<a href="https://www.npmjs.com/package/@v587d/capital-generation"><img src="https://img.shields.io/npm/v/%40v587d%2Fcapital-generation" alt="npm version"></a>
|
|
8
8
|
</p>
|
|
9
9
|
|
|
@@ -192,7 +192,7 @@ Capital Generation 是运行在 [DeepSeek Harness(DSH)](https://github.com/d
|
|
|
192
192
|
- **配置在哪?** 打开「插件」→ 已安装的 **Capital Generation**,插件介绍下方就是「数据源 / 投研自动化 / 精选 Skills / 包含的组件 / 分析环境」五格,五把密钥都在第一格;第二格可指定任务统一使用的默认工作区,也能改自动检查间隔与最长运行时间等上限;第五格准备 Python 分析环境;不在 DSH 的普通「设置」页面,也不用点进任何一行组件。保存密钥后新建会话再试。
|
|
193
193
|
- **升级到 2.9.0 后,分析师和绘图专员去哪了?** 这一版把它们收进自动模式内部,不再出现在选择器与预设管理里,避免误开一个没有取数入口的空会话。旧会话仍能按原身份恢复;新任务直接用自动模式提出即可。
|
|
194
194
|
- **宿主更新后插件显示异常、三个模式消失?** 插件只支持**同一 minor** 的宿主(本版是 `>=0.2.2-rc.5 <0.2.3-0`):宿主跨到 0.2.3 及以上时,旧插件会被启动拒载(插件页显示「异常」)。先把宿主升到与插件同一条 minor,再在插件页更新插件;应急可用版本豁免(有崩溃风险,见 CHANGELOG 的 Migration)。日志里出现「宿主 dsh … 未逐项验证」说明你跑在同一 minor 的未验证补丁版上——能跑,但遇异常请先升级插件并把那行日志附在 issue 里。
|
|
195
|
-
- **桌面端升级后仍是旧版?** 桌面端安装时会固定所解析的版本,不会自动升级。卸载后重新安装,再到插件详情查看版本号;如需指定版本,可在地址末尾加 `#v2.31.
|
|
195
|
+
- **桌面端升级后仍是旧版?** 桌面端安装时会固定所解析的版本,不会自动升级。卸载后重新安装,再到插件详情查看版本号;如需指定版本,可在地址末尾加 `#v2.31.1` 或 `@2.31.1`。
|
|
196
196
|
- **刚发布的新版本装不到?** 桌面端取包时会跳过**刚发布不久**的版本(宿主侧包管理器的发布冷却策略,实测会静默装成上一个版本),国内镜像的同步也可能滞后一段时间。急着用最新代码,改用仓库地址安装最直接;但仓库地址安装的是 git 依赖,插件页不显示「版本」检查。
|
|
197
197
|
- **插件页的「版本」段怎么用?** 只有用包名从 npm 安装的版本才有;它只列比当前新的版本。回旧版要先卸载,再安装 `@v587d/capital-generation@版本号`(桌面端地址末尾加 `#v版本号`);旧版必须匹配当前 DSH 基线,对应关系见 [CHANGELOG 的 Migration](CHANGELOG.md)。
|
|
198
198
|
- **网页抓取失败?** 配置卡片中的「允许启动本地提取网页内容」默认开启:AnySearch 提取失败时可尝试本机直连。关闭后,本机直连的具名来源查询也不可用;请检查该开关和网络连接。
|
package/automation/package.json
CHANGED
package/chart-ui/package.json
CHANGED
package/config/package.json
CHANGED
|
@@ -1,21 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Call-level `send_message` target guard.
|
|
3
|
-
* each other;
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Call-level `send_message` target guard. The host lets any two members of one subagent tree message
|
|
3
|
+
* each other; this plugin keeps the adjacency table from design §5.2: root -> direct child only,
|
|
4
|
+
* peer edges only where listed, specialist -> none. Targets match fixed tree names because the guard
|
|
5
|
+
* is synchronous and sees raw strings only (a session id is shaped like a name), so this is routing
|
|
6
|
+
* discipline, not a security boundary. Non-Capital presets fail open.
|
|
7
|
+
*
|
|
8
|
+
* The analyst's outgoing peer sends also carry the §5.6 round-trip budget: the send edge stops the
|
|
9
|
+
* fourth request, and `validateArtifact` re-checks the recorded exchanges per `task_id`.
|
|
6
10
|
*/
|
|
7
11
|
import type { GuardedExecution, PolicyContext } from './root-tool-policy.js';
|
|
8
12
|
export declare const MESSAGE_TOOL_NAME = "send_message";
|
|
13
|
+
/** Fixed tree names from the delegation prompt; peer edges match these strings, never session ids. */
|
|
14
|
+
export declare const ROLE_TREE_NAMES: {
|
|
15
|
+
readonly collector: "data-collector";
|
|
16
|
+
readonly junior: "data-junior";
|
|
17
|
+
readonly retriever: "web-retriever";
|
|
18
|
+
readonly specialist: "visualization-specialist";
|
|
19
|
+
readonly analyst: "senior-analyst";
|
|
20
|
+
readonly lead: "lead";
|
|
21
|
+
};
|
|
9
22
|
export declare const ROOT_MESSAGE_DENIED: string;
|
|
10
23
|
export declare const LEAF_MESSAGE_DENIED = "send_message \u53EA\u80FD\u53D1\u7ED9 `lead`\uFF1A\u53F6\u5B50\u89D2\u8272\u4E0D\u76F4\u63A5\u627E\u5144\u5F1F\u6216\u5B59 Agent\uFF0C\u6750\u6599\u4E0E\u8BF7\u6C42\u90FD\u7ECF\u4E3B Agent \u4E2D\u7EE7\u3002";
|
|
11
24
|
export declare const SPECIALIST_MESSAGE_DENIED = "visualization_specialist \u4E0D\u76F4\u63A5\u53D1\u6D88\u606F\uFF1A\u628A\u56FE\u8868\u7ED3\u679C\u4F5C\u4E3A\u6700\u7EC8\u7B54\u590D\u8FD4\u56DE data_junior\uFF0C\u7531\u5B83\u6C47\u603B\u3002";
|
|
12
|
-
/** Allowed
|
|
25
|
+
/** Allowed send edges per role preset. Empty means no messaging at all. Extending one is a product decision. */
|
|
13
26
|
export declare const ROLE_MESSAGE_TARGETS: Readonly<Record<string, readonly string[]>>;
|
|
27
|
+
/** §5.6-2 budget: one analysis task may ask its peer at most three times. */
|
|
28
|
+
export declare const PEER_ROUND_TRIP_BUDGET = 3;
|
|
29
|
+
export declare const PEER_BUDGET_DENIED: string;
|
|
30
|
+
export declare function peerSendCount(sessionId: string): number;
|
|
14
31
|
/** The host owns the required-field error; the guard only judges a target it can actually read. */
|
|
15
32
|
export declare function sendMessageTargetOf(exec: GuardedExecution | undefined): string | undefined;
|
|
16
33
|
/** Root may address a direct child only: no tree path, and never itself. */
|
|
17
34
|
export declare function isDirectChildName(name: string): boolean;
|
|
18
35
|
/** Read identity per call because a created-time gate misses manually opened modes; fail open otherwise. */
|
|
19
36
|
export declare function sendMessageGuardReasonFor(ctx: PolicyContext): (exec: GuardedExecution | undefined) => string | undefined;
|
|
20
|
-
/**
|
|
37
|
+
/** Install globally once; a created-time gate misses manually opened modes. */
|
|
21
38
|
export declare function registerSendMessageGuard(ctx: PolicyContext): void;
|
|
@@ -1,19 +1,52 @@
|
|
|
1
|
-
import { recordGuardDecision } from './root-tool-policy.js';
|
|
1
|
+
import { agentSessionId, recordGuardDecision } from './root-tool-policy.js';
|
|
2
2
|
import { readPresetClaim } from '../preset-claim.js';
|
|
3
3
|
import { CAPITAL_PRESET_IDS, ROLE_PRESET_IDS, ROOT_PRESET_ID } from '../preset-ids.js';
|
|
4
4
|
export const MESSAGE_TOOL_NAME = 'send_message';
|
|
5
|
+
const LEAD_NAME = 'lead';
|
|
6
|
+
/** Fixed tree names from the delegation prompt; peer edges match these strings, never session ids. */
|
|
7
|
+
export const ROLE_TREE_NAMES = {
|
|
8
|
+
collector: 'data-collector',
|
|
9
|
+
junior: 'data-junior',
|
|
10
|
+
retriever: 'web-retriever',
|
|
11
|
+
specialist: 'visualization-specialist',
|
|
12
|
+
analyst: 'senior-analyst',
|
|
13
|
+
lead: LEAD_NAME,
|
|
14
|
+
};
|
|
5
15
|
export const ROOT_MESSAGE_DENIED = 'send_message 只能发给你的直系子 Agent:目标名不能是 `lead`,也不能含 `/`(孙 Agent 走 data_junior 中继)。'
|
|
6
16
|
+ '重新调用 list_agents() 取直系 name 后再发。';
|
|
7
17
|
export const LEAF_MESSAGE_DENIED = 'send_message 只能发给 `lead`:叶子角色不直接找兄弟或孙 Agent,材料与请求都经主 Agent 中继。';
|
|
8
18
|
export const SPECIALIST_MESSAGE_DENIED = 'visualization_specialist 不直接发消息:把图表结果作为最终答复返回 data_junior,由它汇总。';
|
|
9
|
-
/** Allowed
|
|
19
|
+
/** Allowed send edges per role preset. Empty means no messaging at all. Extending one is a product decision. */
|
|
10
20
|
export const ROLE_MESSAGE_TARGETS = {
|
|
11
|
-
[ROLE_PRESET_IDS.collector]: [
|
|
12
|
-
[ROLE_PRESET_IDS.junior]: [
|
|
13
|
-
[ROLE_PRESET_IDS.retriever]: [
|
|
21
|
+
[ROLE_PRESET_IDS.collector]: [ROLE_TREE_NAMES.junior, ROLE_TREE_NAMES.analyst, LEAD_NAME],
|
|
22
|
+
[ROLE_PRESET_IDS.junior]: [ROLE_TREE_NAMES.analyst, LEAD_NAME],
|
|
23
|
+
[ROLE_PRESET_IDS.retriever]: [ROLE_TREE_NAMES.analyst, LEAD_NAME],
|
|
14
24
|
[ROLE_PRESET_IDS.specialist]: [],
|
|
15
|
-
[ROLE_PRESET_IDS.analyst]: [
|
|
25
|
+
[ROLE_PRESET_IDS.analyst]: [ROLE_TREE_NAMES.junior, LEAD_NAME],
|
|
26
|
+
};
|
|
27
|
+
/** Per-role denial copy; the range gate (new data via lead) belongs in the message, not only in docs. */
|
|
28
|
+
const ROLE_MESSAGE_DENIED = {
|
|
29
|
+
[ROLE_PRESET_IDS.collector]: 'send_message 只能发给 lead、data-junior 或 senior-analyst:DatasetRef 可直达材料消费者,'
|
|
30
|
+
+ '新数据请求仍经 lead。',
|
|
31
|
+
[ROLE_PRESET_IDS.junior]: 'send_message 只能发给 lead 或 senior-analyst:补计算结果可直发 senior,其他兄弟与孙 Agent 经 lead。',
|
|
32
|
+
[ROLE_PRESET_IDS.retriever]: 'send_message 只能发给 lead 或 senior-analyst:带来源的证据可直发 senior,其他目标经 lead。',
|
|
33
|
+
[ROLE_PRESET_IDS.analyst]: 'send_message 只能发给 lead 或 data-junior:新数据/新检索经 lead,'
|
|
34
|
+
+ '只有"用已有 Dataset/profile 补计算"可直连 data-junior。',
|
|
16
35
|
};
|
|
36
|
+
/** §5.6-2 budget: one analysis task may ask its peer at most three times. */
|
|
37
|
+
export const PEER_ROUND_TRIP_BUDGET = 3;
|
|
38
|
+
export const PEER_BUDGET_DENIED = `补计算往返已达 ${PEER_ROUND_TRIP_BUDGET} 次上限:不要再向同行发请求,`
|
|
39
|
+
+ '改用 analysis_blocked + peer_budget_exhausted 把未决缺口回给 lead 裁决。';
|
|
40
|
+
const PEER_SEND_BUDGET = {
|
|
41
|
+
[ROLE_PRESET_IDS.analyst]: PEER_ROUND_TRIP_BUDGET,
|
|
42
|
+
};
|
|
43
|
+
/** Outgoing peer sends per sender session. One senior session carries one analysis task. */
|
|
44
|
+
const peerSends = new Map();
|
|
45
|
+
/** Bounded bookkeeping: leak-free enough without a session lifecycle hook. */
|
|
46
|
+
const PEER_SEND_TRACK_MAX = 256;
|
|
47
|
+
export function peerSendCount(sessionId) {
|
|
48
|
+
return peerSends.get(sessionId) ?? 0;
|
|
49
|
+
}
|
|
17
50
|
function isRecord(value) {
|
|
18
51
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
19
52
|
}
|
|
@@ -27,7 +60,27 @@ export function sendMessageTargetOf(exec) {
|
|
|
27
60
|
}
|
|
28
61
|
/** Root may address a direct child only: no tree path, and never itself. */
|
|
29
62
|
export function isDirectChildName(name) {
|
|
30
|
-
return name !==
|
|
63
|
+
return name !== LEAD_NAME && !name.includes('/');
|
|
64
|
+
}
|
|
65
|
+
/** Counts the send once it passes the edge check; the artifact check is the authoritative record. */
|
|
66
|
+
function peerBudgetReason(role, target, exec) {
|
|
67
|
+
const budget = PEER_SEND_BUDGET[role];
|
|
68
|
+
if (budget === undefined || target === LEAD_NAME)
|
|
69
|
+
return undefined;
|
|
70
|
+
const sessionId = agentSessionId(exec?.agent);
|
|
71
|
+
// No session pull (old host shape / unit call): leave counting to the artifact check.
|
|
72
|
+
if (sessionId === undefined)
|
|
73
|
+
return undefined;
|
|
74
|
+
const used = peerSends.get(sessionId) ?? 0;
|
|
75
|
+
if (used >= budget)
|
|
76
|
+
return PEER_BUDGET_DENIED;
|
|
77
|
+
peerSends.set(sessionId, used + 1);
|
|
78
|
+
if (peerSends.size > PEER_SEND_TRACK_MAX) {
|
|
79
|
+
const oldest = peerSends.keys().next().value;
|
|
80
|
+
if (typeof oldest === 'string')
|
|
81
|
+
peerSends.delete(oldest);
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
31
84
|
}
|
|
32
85
|
/** Read identity per call because a created-time gate misses manually opened modes; fail open otherwise. */
|
|
33
86
|
export function sendMessageGuardReasonFor(ctx) {
|
|
@@ -46,11 +99,13 @@ export function sendMessageGuardReasonFor(ctx) {
|
|
|
46
99
|
const allowed = ROLE_MESSAGE_TARGETS[claim.claim] ?? [];
|
|
47
100
|
if (allowed.length === 0)
|
|
48
101
|
return SPECIALIST_MESSAGE_DENIED;
|
|
49
|
-
|
|
102
|
+
if (!allowed.includes(target))
|
|
103
|
+
return ROLE_MESSAGE_DENIED[claim.claim] ?? LEAF_MESSAGE_DENIED;
|
|
104
|
+
return peerBudgetReason(claim.claim, target, exec);
|
|
50
105
|
};
|
|
51
106
|
}
|
|
52
107
|
const installedGuardRoots = new WeakSet();
|
|
53
|
-
/**
|
|
108
|
+
/** Install globally once; a created-time gate misses manually opened modes. */
|
|
54
109
|
export function registerSendMessageGuard(ctx) {
|
|
55
110
|
const ref = ctx.root ?? ctx;
|
|
56
111
|
if (installedGuardRoots.has(ref))
|
|
@@ -143,10 +143,10 @@ export function roleSiblingGuardReasonFor(ctx) {
|
|
|
143
143
|
+ '等待归主 Agent 的 wait_for_agents 负责。';
|
|
144
144
|
}
|
|
145
145
|
if (name === 'list_agents') {
|
|
146
|
-
return `${name} 不对人设 ${claim.claim}
|
|
147
|
-
+ '
|
|
146
|
+
return `${name} 不对人设 ${claim.claim} 开放:子 Agent 名单与调度归主 Agent;peer 边只认固定树名,`
|
|
147
|
+
+ '按邻接表直接 send_message。需要别的 Agent 配合,不要自己换工具硬做。';
|
|
148
148
|
}
|
|
149
|
-
return `${name} 不对人设 ${claim.claim}
|
|
149
|
+
return `${name} 不对人设 ${claim.claim} 开放:打断别的会话归主 Agent 决定(peer 之间也不许)。`
|
|
150
150
|
+ '需要别的 Agent 停下来,用 send_message 回告主 Agent;不要自己换工具硬做。';
|
|
151
151
|
};
|
|
152
152
|
}
|
|
@@ -5,13 +5,19 @@
|
|
|
5
5
|
* `additionalProperties: false` everywhere is deliberate — an undeclared field is a protocol
|
|
6
6
|
* change, and silently accepting it would make the artifact contract a suggestion.
|
|
7
7
|
*/
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Submit-time budgets; exceeding one names the offending section (`analysis_result_too_large`).
|
|
10
|
+
* 30k: a comprehensive multi-period artifact naturally lands at 20–22k, and a 20k cap made the
|
|
11
|
+
* model rewrite the same artifact for minutes instead of finishing (2026-11-25 real session).
|
|
12
|
+
*/
|
|
13
|
+
export declare const ARTIFACT_MAX_CHARS = 30000;
|
|
10
14
|
export declare const HEADLINE_MAX_CHARS = 300;
|
|
11
15
|
export declare const THESIS_MAX_CHARS = 1200;
|
|
12
16
|
export declare const STATEMENT_MAX_CHARS = 600;
|
|
13
17
|
export declare const MAX_CLAIMS = 20;
|
|
14
18
|
export declare const MAX_SCENARIOS = 8;
|
|
19
|
+
/** §5.6-2 peer round-trip budget per task_id. The send edge stops the fourth request; this is the record check. */
|
|
20
|
+
export declare const MAX_PEER_EXCHANGES = 3;
|
|
15
21
|
/** Bounded evidence intake: single item bytes and total count. */
|
|
16
22
|
export declare const EVIDENCE_ITEM_MAX_BYTES = 2048;
|
|
17
23
|
export declare const EVIDENCE_MAX_ITEMS = 20;
|
package/lib/analysis/schemas.js
CHANGED
|
@@ -10,13 +10,19 @@ const strings = (description) => ({ type: 'array', items: { type: 'string' }, ..
|
|
|
10
10
|
// `oneOf`, not `anyOf`: the host's enforced JSON-Schema subset (dsh-tools) accepts exact-one only,
|
|
11
11
|
// and a tool definition outside that subset makes the whole family row unsupported at boot.
|
|
12
12
|
const nullable = (schema) => ({ oneOf: [schema, { type: 'null' }] });
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Submit-time budgets; exceeding one names the offending section (`analysis_result_too_large`).
|
|
15
|
+
* 30k: a comprehensive multi-period artifact naturally lands at 20–22k, and a 20k cap made the
|
|
16
|
+
* model rewrite the same artifact for minutes instead of finishing (2026-11-25 real session).
|
|
17
|
+
*/
|
|
18
|
+
export const ARTIFACT_MAX_CHARS = 30_000;
|
|
15
19
|
export const HEADLINE_MAX_CHARS = 300;
|
|
16
20
|
export const THESIS_MAX_CHARS = 1_200;
|
|
17
21
|
export const STATEMENT_MAX_CHARS = 600;
|
|
18
22
|
export const MAX_CLAIMS = 20;
|
|
19
23
|
export const MAX_SCENARIOS = 8;
|
|
24
|
+
/** §5.6-2 peer round-trip budget per task_id. The send edge stops the fourth request; this is the record check. */
|
|
25
|
+
export const MAX_PEER_EXCHANGES = 3;
|
|
20
26
|
/** Bounded evidence intake: single item bytes and total count. */
|
|
21
27
|
export const EVIDENCE_ITEM_MAX_BYTES = 2_048;
|
|
22
28
|
export const EVIDENCE_MAX_ITEMS = 20;
|
package/lib/analysis/tools.js
CHANGED
|
@@ -318,6 +318,11 @@ export function registerAnalysisTools(deps) {
|
|
|
318
318
|
});
|
|
319
319
|
const validation = validateArtifact(artifact, snapshot);
|
|
320
320
|
if (validation.tier1.length > 0) {
|
|
321
|
+
// The reserved code exists for exactly this budget (§5.6-2); a generic validation error
|
|
322
|
+
// would hide that the peer loop is the problem.
|
|
323
|
+
const budget = validation.tier1.find((issue) => issue.code === 'peer_budget_exhausted');
|
|
324
|
+
if (budget !== undefined)
|
|
325
|
+
throw new AnalysisError('analysis_peer_budget_exhausted', budget.detail);
|
|
321
326
|
throw new AnalysisError('analysis_validation_failed', `产物未通过硬校验(${validation.tier1.length} 条):${validation.tier1.slice(0, 6).map((issue) => `${issue.code} ${issue.detail}`).join(';')}`);
|
|
322
327
|
}
|
|
323
328
|
const downgraded = validation.tier2.length > 0 && artifact.status === 'completed' ? 'partial' : artifact.status;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HEADLINE_MAX_CHARS, MAX_CLAIMS, MAX_SCENARIOS, STATEMENT_MAX_CHARS, THESIS_MAX_CHARS } from './schemas.js';
|
|
1
|
+
import { HEADLINE_MAX_CHARS, MAX_CLAIMS, MAX_PEER_EXCHANGES, MAX_SCENARIOS, STATEMENT_MAX_CHARS, THESIS_MAX_CHARS } from './schemas.js';
|
|
2
2
|
/** Subset of JSON Schema used by the protocol: types, properties, required, items, enum, bounds. */
|
|
3
3
|
export function validateAgainstSchema(value, schema, path = '$') {
|
|
4
4
|
if (schema === undefined || Object.keys(schema).length === 0)
|
|
@@ -144,6 +144,10 @@ const UNIT_CONSTANTS = new Set([1e4, 1e6, 1e8, 1e12]);
|
|
|
144
144
|
const YEAR = /^(?:19|20)\d{2}$/u;
|
|
145
145
|
const NUMBER_TOKEN = /-?\d+(?:\.\d+)?/gu;
|
|
146
146
|
const PERCENT_AFTER = /^\s*[%%]/u;
|
|
147
|
+
// Six-digit securities codes (`600519`, `000858`, `300750`, `920000`, funds `510300`) are identifiers,
|
|
148
|
+
// not measured values. Amounts that start with 1 or 2 still need an anchor.
|
|
149
|
+
const SECURITY_CODE = /^(?:0|[3-9])\d{5}$/u;
|
|
150
|
+
const COUNT_CLASSIFIER = /^\s*[个条项期只家次类轮档组段页册笔位名张份套种年]/u;
|
|
147
151
|
/** Numeric tokens with just enough context to honour the exemption set. */
|
|
148
152
|
export function numberTokens(text) {
|
|
149
153
|
const tokens = [];
|
|
@@ -161,7 +165,7 @@ function tolerance(precision) {
|
|
|
161
165
|
const digits = typeof precision === 'number' && precision >= 0 && precision <= 12 ? precision : 4;
|
|
162
166
|
return 0.5 * 10 ** -digits;
|
|
163
167
|
}
|
|
164
|
-
function exemptToken(
|
|
168
|
+
function exemptToken(token, source) {
|
|
165
169
|
// Digits inside an identifier (`claim_1`, `FY2025`) are not quantities.
|
|
166
170
|
const before = source[token.start - 1];
|
|
167
171
|
const after = source[token.start + token.text.length];
|
|
@@ -169,15 +173,50 @@ function exemptToken(text, token, source) {
|
|
|
169
173
|
return true;
|
|
170
174
|
if (!token.percent && YEAR.test(token.text))
|
|
171
175
|
return true;
|
|
176
|
+
// A securities code is an identifier, not a measured value.
|
|
177
|
+
if (!token.percent && SECURITY_CODE.test(token.text))
|
|
178
|
+
return true;
|
|
172
179
|
if (Number.isInteger(token.value) && Math.abs(token.value) <= 20) {
|
|
173
|
-
const
|
|
174
|
-
if (/[第期条项]/u.test(
|
|
180
|
+
const head = source.slice(Math.max(0, token.start - 2), token.start);
|
|
181
|
+
if (/[第期条项]/u.test(head))
|
|
182
|
+
return true;
|
|
183
|
+
// Structural counts ("5 条"、"0 次"、"3 个情景") are not quantities to trace either.
|
|
184
|
+
if (!token.percent && COUNT_CLASSIFIER.test(source.slice(token.start + token.text.length)))
|
|
175
185
|
return true;
|
|
176
186
|
}
|
|
177
187
|
if (UNIT_CONSTANTS.has(token.value) && /^\d+$/u.test(token.text))
|
|
178
188
|
return true;
|
|
179
189
|
return false;
|
|
180
190
|
}
|
|
191
|
+
/** Digits after the decimal point as written: `18.00` → 2, an integer → 0. */
|
|
192
|
+
function shownDecimals(text) {
|
|
193
|
+
const dot = text.indexOf('.');
|
|
194
|
+
return dot === -1 ? 0 : text.length - dot - 1;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Prose rounds stored values: `1.23` is how `1.2345` is written, `4.44%` is how `4.4444%` is
|
|
198
|
+
* written. Compare at the precision the prose actually shows, for fractional tokens only — an
|
|
199
|
+
* integer is a quantity in its own right, not a rounded fraction.
|
|
200
|
+
*/
|
|
201
|
+
function displayMatch(token, value) {
|
|
202
|
+
const decimals = shownDecimals(token.text);
|
|
203
|
+
if (decimals === 0)
|
|
204
|
+
return false;
|
|
205
|
+
// Symmetric half-digit tolerance, so negative values round the same way as positive ones.
|
|
206
|
+
return Math.abs(value - token.value) <= 0.5 * 10 ** -decimals + 1e-12;
|
|
207
|
+
}
|
|
208
|
+
function matchesToken(token, value, precision) {
|
|
209
|
+
const tol = tolerance(precision);
|
|
210
|
+
if (Math.abs(value - token.value) <= tol)
|
|
211
|
+
return true;
|
|
212
|
+
// Ratio written as a percentage (0.1823 ↔ 18.23) — same precision, scaled by 100.
|
|
213
|
+
if (Math.abs(value * 100 - token.value) <= Math.max(tol * 100, 0.5 * 10 ** -2))
|
|
214
|
+
return true;
|
|
215
|
+
if (displayMatch(token, value) || displayMatch(token, value * 100))
|
|
216
|
+
return true;
|
|
217
|
+
// Whole-number percentages are a rounded display too: 0.1804 written as 18%.
|
|
218
|
+
return token.percent && shownDecimals(token.text) === 0 && Math.abs(value * 100 - token.value) < 0.5;
|
|
219
|
+
}
|
|
181
220
|
function anchoredNumbers(artifact) {
|
|
182
221
|
const anchors = [];
|
|
183
222
|
const values = [];
|
|
@@ -195,20 +234,18 @@ function anchoredNumbers(artifact) {
|
|
|
195
234
|
}
|
|
196
235
|
function unmatchedNumbers(text, anchors, calculations) {
|
|
197
236
|
const misses = [];
|
|
237
|
+
const seen = new Set();
|
|
198
238
|
for (const token of numberTokens(text)) {
|
|
199
|
-
if (exemptToken(
|
|
239
|
+
if (exemptToken(token, text))
|
|
240
|
+
continue;
|
|
241
|
+
if (anchors.some((anchor) => matchesToken(token, anchor.value, anchor.precision)))
|
|
200
242
|
continue;
|
|
201
|
-
|
|
202
|
-
const tol = tolerance(anchor.precision);
|
|
203
|
-
if (Math.abs(anchor.value - token.value) <= tol)
|
|
204
|
-
return true;
|
|
205
|
-
// Ratio written as a percentage (0.1823 ↔ 18.23) — same precision, scaled by 100.
|
|
206
|
-
return Math.abs(anchor.value * 100 - token.value) <= Math.max(tol * 100, 0.5 * 10 ** -2);
|
|
207
|
-
});
|
|
208
|
-
if (hit)
|
|
243
|
+
if (calculations.some((value) => matchesToken(token, value, undefined)))
|
|
209
244
|
continue;
|
|
210
|
-
|
|
245
|
+
// The same unanchored value repeated in one field is one problem, not six.
|
|
246
|
+
if (seen.has(token.text))
|
|
211
247
|
continue;
|
|
248
|
+
seen.add(token.text);
|
|
212
249
|
misses.push(token.text);
|
|
213
250
|
}
|
|
214
251
|
return misses;
|
|
@@ -317,11 +354,17 @@ export function validateArtifact(artifact, snapshot) {
|
|
|
317
354
|
tier2.push({ code: 'calculation_without_anchor', severity: 'warning', field: `calculations[${index}]`, detail: `计算结果 ${calculation.metric}=${calculation.value} 没有对应锚点` });
|
|
318
355
|
}
|
|
319
356
|
}
|
|
320
|
-
// Peer exchanges: an unanswered peer request means the result is not final
|
|
321
|
-
|
|
357
|
+
// Peer exchanges: an unanswered peer request means the result is not final, and the round-trip
|
|
358
|
+
// budget is a hard rule (§5.6-2). The send edge prevents the fourth request; this rejects a record
|
|
359
|
+
// that claims more than the budget (fabricated or from an unguarded client).
|
|
360
|
+
const exchanges = artifact.peer_exchanges ?? [];
|
|
361
|
+
const unanswered = exchanges.filter((item) => item?.answered !== true);
|
|
322
362
|
if (unanswered.length > 0) {
|
|
323
363
|
tier2.push({ code: 'peer_unanswered', severity: 'warning', field: 'peer_exchanges', detail: `${unanswered.length} 条 peer 请求没有回执;产物最多 partial` });
|
|
324
364
|
}
|
|
365
|
+
if (exchanges.length > MAX_PEER_EXCHANGES) {
|
|
366
|
+
tier1.push({ code: 'peer_budget_exhausted', severity: 'error', field: 'peer_exchanges', detail: `peer 往返 ${exchanges.length} 条,超过 ${MAX_PEER_EXCHANGES} 次预算;超出部分应回 analysis_blocked + peer_budget_exhausted 交 lead 裁决` });
|
|
367
|
+
}
|
|
325
368
|
if (artifact.status === 'completed' && unanswered.length > 0) {
|
|
326
369
|
tier1.push({ code: 'peer_unanswered_completed', severity: 'error', field: 'status', detail: '存在未回执的 peer 请求时不能写 completed' });
|
|
327
370
|
}
|
|
@@ -379,7 +379,9 @@ export class WorkspaceDatasetStore {
|
|
|
379
379
|
profile_id: profileId,
|
|
380
380
|
dataset_id: ref.dataset_id,
|
|
381
381
|
task_id: input.task_id ?? null,
|
|
382
|
-
|
|
382
|
+
// Scope id, not the producing session: siblings under one root must read the same profile
|
|
383
|
+
// (senior read_profile / snapshot staging), and `readProfile` compares against the scope.
|
|
384
|
+
session_id: sessionScopeFor(session),
|
|
383
385
|
artifact_ref: canonicalProfileRef(profileId),
|
|
384
386
|
created_at: createdAt,
|
|
385
387
|
retention_until: Math.min(ref.retention_until, createdAt + this.retentionMs),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Known limit: DNS resolves per request but the IP is not pinned to the connection,
|
|
4
4
|
* so a rebinding window remains (same trade-off as dsh-search-first).
|
|
5
5
|
*/
|
|
6
|
-
export declare const LOCAL_FETCH_CLIENT_VERSION = "2.31.
|
|
6
|
+
export declare const LOCAL_FETCH_CLIENT_VERSION = "2.31.1";
|
|
7
7
|
export declare const LOCAL_FETCH_MAX_URL_LENGTH = 2048;
|
|
8
8
|
export type LocalFetchErrorCode = 'ABORTED' | 'TIMEOUT' | 'INVALID_URL' | 'BLOCKED_URL' | 'DNS' | 'REDIRECT' | 'HTTP' | 'TOO_LARGE' | 'UNSUPPORTED_CONTENT_TYPE';
|
|
9
9
|
export declare class LocalFetchError extends Error {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* so a rebinding window remains (same trade-off as dsh-search-first).
|
|
5
5
|
*/
|
|
6
6
|
import { htmlToMarkdown, stripInvisibleText } from './html-markdown.js';
|
|
7
|
-
export const LOCAL_FETCH_CLIENT_VERSION = '2.31.
|
|
7
|
+
export const LOCAL_FETCH_CLIENT_VERSION = '2.31.1';
|
|
8
8
|
export const LOCAL_FETCH_MAX_URL_LENGTH = 2048;
|
|
9
9
|
export class LocalFetchError extends Error {
|
|
10
10
|
code;
|
|
@@ -35,7 +35,7 @@ export interface WindCallResult {
|
|
|
35
35
|
code?: WindErrorCode;
|
|
36
36
|
}
|
|
37
37
|
/** Must match `package.json` version; a test pins the two together. */
|
|
38
|
-
export declare const WIND_CLIENT_VERSION = "2.31.
|
|
38
|
+
export declare const WIND_CLIENT_VERSION = "2.31.1";
|
|
39
39
|
export interface WindClient {
|
|
40
40
|
callTool(toolName: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<WindCallResult>;
|
|
41
41
|
}
|
|
@@ -19,7 +19,7 @@ export const WIND_SERVER_ENDPOINTS = {
|
|
|
19
19
|
analytics_data: 'https://mcp.wind.com.cn/vserver_analytics_data/mcp/',
|
|
20
20
|
};
|
|
21
21
|
/** Must match `package.json` version; a test pins the two together. */
|
|
22
|
-
export const WIND_CLIENT_VERSION = '2.31.
|
|
22
|
+
export const WIND_CLIENT_VERSION = '2.31.1';
|
|
23
23
|
function errorText(error) {
|
|
24
24
|
return error instanceof Error ? error.message : String(error);
|
|
25
25
|
}
|
package/package.json
CHANGED
|
@@ -42,15 +42,15 @@
|
|
|
42
42
|
2. 取数:按问题选足相关能力,不限;request_data 阻塞等待(超时约 30 秒),一次只请求一个能力、串行推进。
|
|
43
43
|
params 按 input_schema 填,capability 以 list_capabilities 目录为准,不编造。
|
|
44
44
|
宿主只复用满足来源新鲜度要求的 Dataset;要最新 force_refresh=true,绝不覆盖旧文件。
|
|
45
|
-
遇 request_params_invalid,按错误中的 capability 调 describe_capability 重读 input_schema
|
|
45
|
+
遇 request_params_invalid,按错误中的 capability 调 describe_capability 重读 input_schema,修正后只重试一次;不要猜参数。
|
|
46
46
|
3. 每次 request_data 成功(包括缓存命中)立刻 send_message 一份 dataset_ready;
|
|
47
47
|
每次请求最终失败立刻发 data_failed;全部请求结束再发 data_collection_completed(不重发 DatasetRef)。
|
|
48
48
|
dataset_id / artifact_ref / source_label / captured_at / retention_until 按 request_data 返回原样填入;
|
|
49
49
|
字段、数值、日期不改写;禁止只回传 markdown 汇总或原始行。
|
|
50
50
|
4. 失败:绝不幻觉填充数据、绝不用编造的来源补位、绝不声称数据已保存;重试纪律按 skill
|
|
51
51
|
处置(可重试上游最多 3 次尝试;先换等价能力;upstream_retry_exhausted 即回传 failed,不再调用/wait_agent)。
|
|
52
|
-
5. 叶子边界:你不创建、不委派、不指挥任何下游子 Agent(data_junior 由主 Agent
|
|
53
|
-
|
|
52
|
+
5. 叶子边界:你不创建、不委派、不指挥任何下游子 Agent(data_junior 由主 Agent 直接创建);
|
|
53
|
+
数据可直达 data-junior / senior-analyst。
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
# TIME DISCIPLINE
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
(DatasetRef + 问题;describe_dataset 一次描述,单点复核才用 inspect/profile/query_dataset),
|
|
134
134
|
以及无 Dataset 假设建模(主 Agent 给)。有 Dataset 时按 DUTIES 6 出图;
|
|
135
135
|
创建 specialist 后等终态再回传。载荷中不得出现原始数据行。你不是投资分析师
|
|
136
|
-
(不做投资判断、不输出买卖建议),也不改写原始 Dataset。你是主 Agent 的直接子 Agent,与 data_collector 是兄弟,不会被 data_collector
|
|
136
|
+
(不做投资判断、不输出买卖建议),也不改写原始 Dataset。你是主 Agent 的直接子 Agent,与 data_collector 是兄弟,不会被 data_collector 创建,补计算回执直达 senior-analyst,其余经 lead;
|
|
137
137
|
visualization_specialist 是你的异步子 Agent,不直接发消息。
|
|
138
138
|
工具面没有外部行情 API、网页检索与凭据入口;run_code 里的 Node 也不得用于取数、联网或读凭据;宿主若暴露 web_search / web_fetch 也不得用于取数或查资料。不索取或保存账户密码。
|
|
139
139
|
|
|
@@ -146,9 +146,9 @@
|
|
|
146
146
|
1. 启动自检:先看 SDK 有无 tools.describe_dataset,没有就 send_message 回告;正常时登记 data_junior_ready。
|
|
147
147
|
|
|
148
148
|
2. 只用受控工具:dataset_ids 按主 Agent 转发的原样使用;一切路径都是 opaque
|
|
149
|
-
artifact_ref
|
|
149
|
+
artifact_ref,由受控工具解析;Dataset 工具只收 dataset_id 与 QuerySpec,
|
|
150
150
|
run_code 只调度工具与算术,不得读文件。
|
|
151
|
-
3. 默认用 describe_dataset 读 Dataset
|
|
151
|
+
3. 默认用 describe_dataset 读 Dataset(多份用 Promise.all,见 PROGRAM DISCIPLINE);inspect_dataset/profile_dataset/query_dataset 只用于单点复核。优先用 profile 的 time_facts 与 structure;query_dataset 只做受控聚合,你取不到原始行。
|
|
152
152
|
|
|
153
153
|
4. 数据缺口:先分清「数据里确实没有」与「那份数据还没取」。后者不要写成「无法确认」,
|
|
154
154
|
立即用 send_message({ agent: "lead" }) 发一次 data_gap(task_id / dataset_id / need / reason /
|
|
@@ -418,7 +418,7 @@
|
|
|
418
418
|
不取数、不检索、不读原始 rows、不出图、不写最终答复、不交易,也不创建子 Agent。
|
|
419
419
|
输入是主 Agent 给的研究问题加 DatasetRef / profile_ref / 证据;分析只在受控模块里跑,
|
|
420
420
|
你只选 module_id 与 params,不改模块代码、不提交脚本。与 data_collector / data_junior /
|
|
421
|
-
web_retriever
|
|
421
|
+
web_retriever 是兄弟;补计算直达 data-junior,其余经 lead。
|
|
422
422
|
|
|
423
423
|
# DUTIES
|
|
424
424
|
0. 第一步加载 skill capital-senior-analysis(整册读完再动手)。
|
|
@@ -428,9 +428,9 @@
|
|
|
428
428
|
4. 提交前加载 skill capital-analysis-validation,自检后 submit_analysis;被拒按 issue 修,不重发同一份。
|
|
429
429
|
5. 收口:submit 接受后 send_message 给 lead 发 analysis_result 小回执;主 Agent 没收到回执不写结论。
|
|
430
430
|
|
|
431
|
-
# MESSAGING
|
|
432
|
-
|
|
433
|
-
|
|
431
|
+
# MESSAGING(邻接表)
|
|
432
|
+
新数据、新检索、扩大范围经 lead;补计算可直发 data-junior(只限已有 Dataset/profile),
|
|
433
|
+
同一分析任务 ≤3 次,超出回 analysis_blocked + peer_budget_exhausted;信封与往返记账见 skill。
|
|
434
434
|
消息不带原始 rows,路径只用 opaque ref。
|
|
435
435
|
|
|
436
436
|
# TIME & SAFETY
|
|
@@ -559,8 +559,8 @@
|
|
|
559
559
|
b. 主 Agent 禁止自行检索;宿主若仍暴露 web_search / web_fetch,也不得调用;外部检索一律委派。
|
|
560
560
|
本地 PDF / 图片可直接用 ocr 解析(外部链接仍走委派)。
|
|
561
561
|
|
|
562
|
-
c.
|
|
563
|
-
根只发无 `/` 且不是 `lead`
|
|
562
|
+
c. 兄弟子 Agent 按邻接表直连(见 skill capital-orchestration);
|
|
563
|
+
根只发无 `/` 且不是 `lead` 的直系名;senior 对 junior 只补计算(≤3 次),新数据/新检索仍经你;
|
|
564
564
|
data_junior 是你的直接子 Agent,一律由你直接创建;data_collector 不得创建或指挥它。
|
|
565
565
|
|
|
566
566
|
d. visualization_specialist 是 data_junior 的可视化孙 Agent;
|
|
@@ -107,4 +107,4 @@ description: Use when writing the conclusion layer of a Capital analysis — tur
|
|
|
107
107
|
## 9. 回执里的 peer_exchanges
|
|
108
108
|
|
|
109
109
|
- 每条往返写 `{ "peer": "data-junior", "type": "analysis_calculation_request", "request_id": "...", "answered": true|false }`。
|
|
110
|
-
-
|
|
110
|
+
- 按实际往返填写,**不得超过 3 条**(超出会被宿主按预算拒);有 `answered:false` 就不能写 completed。
|
|
@@ -19,7 +19,7 @@ description: Use before submitting a Capital AnalysisArtifact — the pre-submit
|
|
|
19
19
|
7. `evidence_refs` 都在快照的 evidence 里;锚点 `source.ref` 都在快照或本次 `calculations` 里。
|
|
20
20
|
8. `methods_used` 的模块 id 与版本与 `run_analysis` 返回的一致。
|
|
21
21
|
9. `limitations` 非空;`alternative_explanations` 尽量非空。
|
|
22
|
-
10. 序列化后 ≤
|
|
22
|
+
10. 序列化后 ≤30000 字符(单条 statement ≤600、claims 每侧 ≤20、scenarios ≤8)。
|
|
23
23
|
|
|
24
24
|
## 2. 数字锚点怎么算命中
|
|
25
25
|
|
|
@@ -29,14 +29,17 @@ description: Use before submitting a Capital AnalysisArtifact — the pre-submit
|
|
|
29
29
|
1. 与某个 `number_anchors[].value` 在声明的 `precision` 内相等;
|
|
30
30
|
2. 等于某个 `calculations[].value`;
|
|
31
31
|
3. 等于某个锚点的 `value × 100`(比率与百分比互写,容差同 precision);
|
|
32
|
-
4.
|
|
33
|
-
|
|
32
|
+
4. 与锚点/计算值**按你写出的小数位四舍五入后相等**(`1.23` 命中 `1.2345`、`4.44%` 命中
|
|
33
|
+
`4.4444%`、整数百分比 `18%` 命中 `18.04%`;整数本身不按小数位放宽);
|
|
34
|
+
5. 属于豁免集:年份(19xx/20xx)、"第 N 期/条"里的整数、单位换算常数(1e4/1e6/1e8/1e12)、
|
|
35
|
+
标识符里的数字(`claim_1`、`FY2025`)、**六位证券代码**(`600519`、`000858`、`920000`)、
|
|
36
|
+
结构性计数(≤20 的整数且后面带"条/项/个/次/家/年"等量词)。
|
|
34
37
|
|
|
35
38
|
**precision 的算法**:容差 = 0.5 × 10^-precision,默认 4(即 ±0.00005)。
|
|
36
39
|
|
|
37
40
|
- 你写 `0.1823` → 锚点 `0.1823`、`precision: 4` 命中;写 `18.23%` 时按 `value × 100` 命中。
|
|
38
|
-
-
|
|
39
|
-
|
|
41
|
+
- 四舍五入成两位小数(`18.23%`、`1.41 倍`)现在**直接命中**,不必再声明 `precision: 2`;
|
|
42
|
+
但锚点仍要保留足够位数,别把 `0.1823` 写成 `0.18`。
|
|
40
43
|
- 比率类数字**优先写 4-6 位小数或原样引用 metrics**,最省事:`0.044444` 直接配 `0.044444`。
|
|
41
44
|
|
|
42
45
|
## 3. 引用核对
|
|
@@ -61,7 +64,7 @@ description: Use before submitting a Capital AnalysisArtifact — the pre-submit
|
|
|
61
64
|
|
|
62
65
|
## 5. 体积预算
|
|
63
66
|
|
|
64
|
-
整体 ≤
|
|
67
|
+
整体 ≤30000 字符;`headline` ≤300、`thesis` ≤1200、单条 `statement` ≤600、每侧 claims ≤20、`scenarios` ≤8。
|
|
65
68
|
超限错误会点名**哪一段最大**(headline / thesis / support_claims / calculations / …),按它压缩,
|
|
66
69
|
不要盲目删结论。压缩优先级:删重复论据 > 合并同类 claim > 缩短 statement > 砍 thesis。
|
|
67
70
|
|
|
@@ -14,14 +14,14 @@ description: Use when delegating in Capital mode — running the per-round list_
|
|
|
14
14
|
- 创建工具:`subagent_data_collector` / `subagent_data_junior` / `subagent_web_retriever`。
|
|
15
15
|
- 查询方式:`list_agents()`,一次即可。渲染行是 `<name> [<status>] — <description>`,首行 `lead`。
|
|
16
16
|
**直系子 Agent 的 name 不含 `/` 且不是 `lead`**;`data-junior/chart-1` 这类孙 Agent 一律忽略。
|
|
17
|
-
- 状态取值是 `running` / `inactive` / `corrupt` / `unsupported` / `unavailable
|
|
17
|
+
- 状态取值是 `running` / `inactive` / `corrupt` / `unsupported` / `unavailable`;只表示当下能否接消息,
|
|
18
18
|
不代表任务完成、成功或失败。
|
|
19
|
-
-
|
|
20
|
-
- 一次查询覆盖全部角色;等待回传期间不要轮询。
|
|
19
|
+
- 上一轮空列表不能代替本轮;一次查询覆盖全部角色,等待回传期间不轮询。
|
|
21
20
|
|
|
22
21
|
## 1.1 Canonical task_id(不可分叉)
|
|
23
22
|
|
|
24
|
-
主 Agent
|
|
23
|
+
主 Agent 在第一次委派前确定唯一的 `task_id`,原样写进所有任务 prompt;子 Agent 不得另造 task_id,
|
|
24
|
+
缺失或不一致必须回告,不要默默创建新任务。
|
|
25
25
|
|
|
26
26
|
委派清单的 `task_id` 是授权账本,不是描述性备注。`DatasetRef.task_id`、`profile_ref.task_id`、`chart_source_ref` 和 `chart_ref` 必须能沿同一个值对账。引用 chart receipt 前先核对它绑定的 task;若错误返回 `expected_task_id`,使用错误中给出的实际绑定值修正,不要猜测或反复试不同 id。
|
|
27
27
|
|
|
@@ -41,15 +41,12 @@ description: Use when delegating in Capital mode — running the per-round list_
|
|
|
41
41
|
|
|
42
42
|
### 2.1 名字纪律(防长上下文抄错名字)
|
|
43
43
|
|
|
44
|
-
child
|
|
45
|
-
**`list_agents` 即权威名字存储**:用之前查一次就够了:
|
|
44
|
+
child 的名字是树内路径,长会话凭记忆极易抄错甚至投错角色。**`list_agents` 即权威名字存储**:
|
|
46
45
|
|
|
47
46
|
- `send_message` 的 `agent` 只从**最近一次 `list_agents` 的渲染输出**复制(每行就是
|
|
48
47
|
`<name> [<status>] — <description>`);不从早前轮次的上下文、委派清单或旧工具回执里复述。
|
|
49
|
-
-
|
|
50
|
-
|
|
51
|
-
- 发送前三行核对:这一行 name 的 `description` 是不是目标角色、状态是否可投(`running` 与 `inactive`
|
|
52
|
-
均可投)、本次任务是否确实属于该角色。
|
|
48
|
+
- 两次调用之间别插其他工具;隔了长回传或多轮消息就重查一次再发。
|
|
49
|
+
- 发送前核对三行:name 对应的 `description` 是目标角色、状态可投、任务确实属于它。
|
|
53
50
|
- 名字规则:小写字母 / 数字 / 连字符,字母开头,最多 32 位;`lead` 保留给根。`data_collector`
|
|
54
51
|
这类下划线名字会被 `INVALID_AGENT_NAME` 拒绝;不发明名字,不改写宿主返回的名字。
|
|
55
52
|
- **同名创建**会被 `DUPLICATE_AGENT_NAME` 拒绝,不要重试;一个角色只保留一个 Agent。
|
|
@@ -67,7 +64,7 @@ child 的名字是树内路径,长会话里凭记忆复述极易抄错,甚
|
|
|
67
64
|
任务标题、标的、参数只能写进 `prompt`。写进 description 会让下一轮无法可靠识别角色。
|
|
68
65
|
- `prompt` 只写本次委托上下文;**不需要复制任何模板**——身份、职责与工具边界由委派行配置注入。
|
|
69
66
|
- 创建回执是 `started subagent <name>`;立即把 name、角色标签、本次任务记入委派清单。
|
|
70
|
-
-
|
|
67
|
+
- 每会话每角色一个,不反复创建。
|
|
71
68
|
|
|
72
69
|
## 4. 委派清单(会话内维护)
|
|
73
70
|
|
|
@@ -80,9 +77,8 @@ child 的名字是树内路径,长会话里凭记忆复述极易抄错,甚
|
|
|
80
77
|
| web_retriever | web-retriever | task_… | 交易所公告原文 | done | url + 正文要点 |
|
|
81
78
|
|
|
82
79
|
状态取值:`running` / `done` / `failed` / `waiting_data`(子 Agent 已发 `data_gap` 或
|
|
83
|
-
就绪登记、正等主 Agent
|
|
84
|
-
收到 `data_collection_completed` 才可标记取数结束。回传引用只记
|
|
85
|
-
**不记原始数据行**。
|
|
80
|
+
就绪登记、正等主 Agent 补数据)/ `waiting_peer`(在等同行回执)。collector 的 `dataset_ready` 是进度,不是 `done`;
|
|
81
|
+
收到 `data_collection_completed` 才可标记取数结束。回传引用只记 ref 与 URL 标识,**不记原始数据行**。
|
|
86
82
|
|
|
87
83
|
## 5. 路由表
|
|
88
84
|
|
|
@@ -98,11 +94,17 @@ child 的名字是树内路径,长会话里凭记忆复述极易抄错,甚
|
|
|
98
94
|
- **终判据是**错法**而不是形状**:凡要写进用户结论的数字,一律委派 `data_collector`;网页数字只能当线索或异常抽样。
|
|
99
95
|
- 多角色可并行委派,但每个角色都必须先按第 2 节复用或创建,各记清单,等结算通知齐了再综合
|
|
100
96
|
(齐不齐按 §6.1 的对账表逐行判定,不靠"看起来都回了")。
|
|
101
|
-
-
|
|
102
|
-
- 给 `web_retriever`
|
|
103
|
-
|
|
97
|
+
- 给 collector 写清标的、时间范围、证据用途与新鲜度,由它按目录选足能力,不预设固定上限。
|
|
98
|
+
- 给 `web_retriever` 的事实核查分级:核心事实(审计意见、商誉、质押/担保、现金流背离、有息负债等)
|
|
99
|
+
≤10 条逐条核验、每条一行来源;外围事实一句话清单。不预设默认审计级格式;异常项再深挖(口径见 `capital-web-evidence` §5)。
|
|
104
100
|
- 主 Agent 不自行调用任何网络检索/抓取/搜索类工具;外部检索入口只有 `web_retriever` 的回传。
|
|
105
|
-
-
|
|
101
|
+
- **没有通用委派出口**:只有上面三颗专用创建工具(专员归 junior),其余活自己做或如实说明缺口。
|
|
102
|
+
|
|
103
|
+
### 5.1 邻接表(谁可以直接给谁发消息)
|
|
104
|
+
|
|
105
|
+
邻接表:lead→仅直系;data-collector→data-junior、senior-analyst;data-junior、web-retriever→senior-analyst;
|
|
106
|
+
senior-analyst→data-junior(只补计算,同一分析任务 ≤3 次);visualization-specialist 无。
|
|
107
|
+
表外目标会被 `send_message` 闸门拒绝(闸门只看名字字符串,不是安全边界);新数据与新检索仍一律经 lead。
|
|
106
108
|
|
|
107
109
|
## 6. 回合纪律与结算
|
|
108
110
|
|
|
@@ -116,28 +118,31 @@ child 的名字是树内路径,长会话里凭记忆复述极易抄错,甚
|
|
|
116
118
|
- **结算通知 ≠ 任务完成**:collector 未发 `data_collection_completed`,或者清单里标 `waiting_data` 的子 Agent 结束本轮是在等回信,
|
|
117
119
|
不要向用户断言它已完成,也不要新建替代实例。
|
|
118
120
|
- 等待:用 `wait_for_agents`;不检索、不反复 `list_agents`。`wait_agent` 只返回 `{ timedOut }`,
|
|
119
|
-
不是收尾屏障,不要拿它替代 `wait_for_agents
|
|
121
|
+
不是收尾屏障,不要拿它替代 `wait_for_agents`;不用 `team_task_*`。
|
|
120
122
|
子 Agent 卡在上游重试时,发停止指令收已有数据,不等自愈。
|
|
121
|
-
- 回传到达后集中核对材料与结论,再决定继续委派或汇总输出。
|
|
122
123
|
- **收口顺序(硬)**:所有委派行结算 → 对账通过 → 有 `chart_refs` 先 `present_charts` 一次
|
|
123
124
|
(全部 ref;记不清就传 `task_id`)→ 再写最终答复;登记必须早于最终答复。
|
|
124
125
|
- 已答复后被唤醒且无新信息:不输出可见正文,或重发自足总结(§6.1);绝不写“已完成/见上”。
|
|
125
|
-
- 永远不要设置 `run_in_background: false`;所有委派必须是 continuable。
|
|
126
126
|
|
|
127
127
|
### 6.1 结算对账表(写结论前必交,硬)
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
**「收齐了吗」靠表,不靠印象。** 写最终结论前,在本步逐行列出本回合每个子 Agent
|
|
130
|
+
(含 `visualization_specialist` 的父链即 data-junior):
|
|
131
131
|
|
|
132
132
|
```text
|
|
133
133
|
结算对账|task_id=...
|
|
134
134
|
- data-collector 最后交互:<turn N 的 send_message> 结算已收 ✓
|
|
135
135
|
- data-junior 最后交互:<turn N 的 send_message> 结算 ✗ 未收
|
|
136
136
|
- web-retriever 最后交互:<turn N 的 send_message> 结算已收 ✓
|
|
137
|
+
- senior-analyst 最后交互:<turn N 的 analysis_result> waiting_peer(等补计算回执)
|
|
137
138
|
```
|
|
138
139
|
|
|
139
140
|
判据只有一条:**✗ 只能被结算通知翻正**。
|
|
140
141
|
|
|
142
|
+
- **`waiting_peer` 行不是 ✓**:结算通知可能只表示它在等同行回执(senior 等 data-junior 的补计算,
|
|
143
|
+
或 junior 等 senior 的补计算请求)。lead 必须收到它的最终回执(`analysis_result`、`profile_ref` 等)
|
|
144
|
+
才可记完成;等 peer 期间不写结论、不新建实例。
|
|
145
|
+
|
|
141
146
|
- 子 Agent 的 `send_message` 回传正文**无论写得多像完成**(「7/7 profile 完成」「pending = 0」
|
|
142
147
|
「本阶段全部完成」)都**不构成 ✓**——那是工单回执,不是生命周期事件。它下面紧跟的
|
|
143
148
|
「本轮工作已全部完成并回传主 Agent」之类的收尾正文,同样不构成 ✓(那正是结算通知的正文,
|
|
@@ -145,12 +150,11 @@ child 的名字是树内路径,长会话里凭记忆复述极易抄错,甚
|
|
|
145
150
|
- 有任何一行是 ✗ → 本步**只写等待行**(欠谁、在等什么),结论留到 ✗ 全部翻正的那一步。
|
|
146
151
|
- 这张表写在 reasoning 里即可,不要作为正文发给用户(用户只看到结论)。
|
|
147
152
|
|
|
148
|
-
**为什么必须等:**
|
|
153
|
+
**为什么必须等:** 回执可比结算通知早到十几秒;先综合会让结算落在结论后,被投成第二个 step。
|
|
149
154
|
|
|
150
155
|
**已经被追上(结论后才有结算)**:
|
|
151
156
|
|
|
152
|
-
- 无新信息/纠正 →
|
|
153
|
-
要么重发自足总结(结论/证据/来源、局限、观察/验证/防守);**绝不写
|
|
157
|
+
- 无新信息/纠正 → **不要写一行确认**:要么不输出可见正文,要么重发自足总结(结论/证据/来源、局限、观察/验证/防守);**绝不写
|
|
154
158
|
“分析已完成/结论见上/如上”**。
|
|
155
159
|
- 有新事实或推翻口径 → 重写一份完整结论,不要只补一段。
|
|
156
160
|
- 补齐后重新对账:这步之后又有人被唤醒,回到本节重来。
|
|
@@ -164,6 +168,7 @@ child 的名字是树内路径,长会话里凭记忆复述极易抄错,甚
|
|
|
164
168
|
| 创建报 `DUPLICATE_AGENT_NAME` / `INVALID_AGENT_NAME` | 同名复用不重试;下划线名改成 `data-collector` 这种连字符名 |
|
|
165
169
|
| 子 Agent 发来 `data_gap` | 按清单复用角色补数,`send_message` 发回同一个子 Agent;失败也要回执 |
|
|
166
170
|
| `waiting_data` 行发来结算通知 | 它在等补数据,不是完成;不要断言完成,也不要新建实例 |
|
|
171
|
+
| `waiting_peer` 行发来结算通知 | 它在等同行回执,不是完成;等最终回执,不写结论、不新建实例 |
|
|
167
172
|
| 只有回传、没有结算却想写结论 | 按 §6.1 交对账表;✗ 未被结算翻正就本步只写等待行 |
|
|
168
173
|
| 结论输出后才被结算通知唤醒 | 无新信息不写可见正文或重发自足总结;有新事实重写完整结论 |
|
|
169
174
|
| `send_message` 投错对象 | `interrupt_agent({ agent: "<name>" })` 停当前轮 → 重查 → 向正确 name 重发 |
|
|
@@ -59,9 +59,12 @@ description: Use when acting as the senior analyst in Capital mode — turning a
|
|
|
59
59
|
- 模块给不出的指标就是缺口:写进 `data_gaps` / `unresolved_gaps`,不自己用记忆补数字。
|
|
60
60
|
- 同一 `run_fingerprint` 会复用上次结果;想重算必须先改参数或重建快照,而不是反复调用等它变。
|
|
61
61
|
|
|
62
|
-
## 6.
|
|
62
|
+
## 6. 消息与回执(邻接表)
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
直连边(`send_message` 的目标只认固定树名):lead 收全部请求与最终回执;`data-junior` 只收
|
|
65
|
+
"用已有 Dataset/profile 补计算";**不能**直接找 data-collector / web-retriever 要新数据或新检索。
|
|
66
|
+
|
|
67
|
+
信封(发给任一目标都是 JSON 字符串):
|
|
65
68
|
|
|
66
69
|
```json
|
|
67
70
|
{ "protocol": "capital.agent.message/v1", "type": "analysis_result", "task_id": "task_...",
|
|
@@ -70,11 +73,12 @@ description: Use when acting as the senior analyst in Capital mode — turning a
|
|
|
70
73
|
"evidence_level": "limited", "peer_exchanges": [], "headline": "一句话结论" } }
|
|
71
74
|
```
|
|
72
75
|
|
|
73
|
-
- 要新数据 / 新检索 / 扩大范围 → `type: "analysis_data_request"
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
76
|
+
- 要新数据 / 新检索 / 扩大范围 → `type: "analysis_data_request"` 发 **lead**,写清标的、字段、期间、用途与为什么现有输入不够。
|
|
77
|
+
- 补计算(只限已有 Dataset/profile)→ 发 `data-junior` 的 `analysis_calculation_request`,带 `task_id` 与 `request_id`;
|
|
78
|
+
同一分析任务往返**最多 3 次**,超出就停:不要再发,改用 `analysis_blocked`(reason: `peer_budget_exhausted`)交 lead 裁决。
|
|
79
|
+
- 走不通(关键输入缺失、模块不适用、超预算)→ `type: "analysis_blocked"` 发 lead,点名缺什么、需要谁补。
|
|
80
|
+
- `analysis_result` 的 `peer_exchanges[]` 按实际往返填 `{peer, type, request_id, answered}`;有未回执项就**不能**写 `completed`。
|
|
81
|
+
- 任何消息不带完整原始 rows;路径只用 opaque ref。兄弟的回执只作证据,不替代工具返回值。
|
|
78
82
|
|
|
79
83
|
## 7. 失败处置
|
|
80
84
|
|
|
@@ -88,8 +92,9 @@ description: Use when acting as the senior analyst in Capital mode — turning a
|
|
|
88
92
|
| `analysis_runtime_not_ready` | 私有 Python 运行时就绪不了 | 报给 lead,让用户到插件设置安装;不要反复试 |
|
|
89
93
|
| `analysis_timeout` | 模块超时 | 缩小输入或换模块,不重试到"看起来成功" |
|
|
90
94
|
| `analysis_output_invalid` | 模块输出不合契约 | 这是模块问题,如实报给 lead |
|
|
91
|
-
| `analysis_result_too_large` | 产物超
|
|
95
|
+
| `analysis_result_too_large` | 产物超 30000 字符 | 按错误点名的段落压缩后重发 |
|
|
92
96
|
| `analysis_validation_failed` | Tier 1 硬校验未过 | 按具名 issue 改,不重发同一份 |
|
|
97
|
+
| `analysis_peer_budget_exhausted` | peer 往返超 3 次预算 | 停止补计算:写 `analysis_blocked` 交 lead,不要删记录重发 |
|
|
93
98
|
|
|
94
99
|
## 8. 质量底线
|
|
95
100
|
|
package/watchlist/package.json
CHANGED