@v587d/capital-generation 2.8.3 → 2.9.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 +81 -1
- package/README.md +40 -19
- package/chart-ui/README.md +5 -4
- package/chart-ui/client.src.cjs +7 -16
- package/chart-ui/index.js +12 -33
- package/chart-ui/package.json +2 -2
- package/config/client.js +18 -39
- package/config/client.src.cjs +79 -217
- package/config/index.js +22 -72
- package/config/package.json +2 -2
- package/cordis.patch.yml +46 -51
- package/lib/agents/bash-guard.d.ts +9 -55
- package/lib/agents/bash-guard.js +27 -67
- package/lib/agents/preset-roster.d.ts +22 -0
- package/lib/agents/preset-roster.js +87 -0
- package/lib/agents/role-tool-policy.d.ts +46 -0
- package/lib/agents/role-tool-policy.js +205 -0
- package/lib/agents/root-tool-policy.d.ts +28 -124
- package/lib/agents/root-tool-policy.js +164 -237
- package/lib/agents/selected-skills-provider.d.ts +2 -6
- package/lib/agents/selected-skills-provider.js +27 -84
- package/lib/capital-settings.d.ts +27 -0
- package/lib/capital-settings.js +23 -0
- package/lib/chart/artifact-ref.d.ts +13 -8
- package/lib/chart/artifact-ref.js +27 -10
- package/lib/chart/downsample.d.ts +2 -5
- package/lib/chart/downsample.js +3 -8
- package/lib/chart/errors.d.ts +3 -7
- package/lib/chart/errors.js +1 -2
- package/lib/chart/event-context.d.ts +8 -0
- package/lib/chart/event-context.js +39 -0
- package/lib/chart/events.d.ts +21 -78
- package/lib/chart/events.js +43 -189
- package/lib/chart/html.d.ts +2 -5
- package/lib/chart/html.js +8 -15
- package/lib/chart/present-tool.d.ts +28 -0
- package/lib/chart/present-tool.js +128 -0
- package/lib/chart/runtime.d.ts +5 -18
- package/lib/chart/runtime.js +14 -34
- package/lib/chart/series.d.ts +10 -17
- package/lib/chart/series.js +22 -47
- package/lib/chart/source-token.d.ts +5 -13
- package/lib/chart/source-token.js +18 -17
- package/lib/chart/spec.d.ts +6 -12
- package/lib/chart/spec.js +7 -31
- package/lib/chart/tool.d.ts +7 -29
- package/lib/chart/tool.js +15 -25
- package/lib/chart-render-entry.d.ts +10 -0
- package/lib/chart-render-entry.js +14 -0
- package/lib/chart-source-entry.d.ts +13 -0
- package/lib/chart-source-entry.js +20 -0
- package/lib/collect-entry.d.ts +9 -0
- package/lib/collect-entry.js +10 -0
- package/lib/collector-runtime.d.ts +22 -0
- package/lib/collector-runtime.js +97 -0
- package/lib/data-collector/args.d.ts +6 -24
- package/lib/data-collector/args.js +6 -24
- package/lib/data-collector/dataset-tools.d.ts +7 -1
- package/lib/data-collector/dataset-tools.js +27 -56
- package/lib/data-collector/describe.d.ts +8 -33
- package/lib/data-collector/describe.js +17 -70
- package/lib/data-collector/hub.d.ts +27 -85
- package/lib/data-collector/hub.js +19 -85
- package/lib/data-collector/query-time.d.ts +7 -26
- package/lib/data-collector/query-time.js +8 -27
- package/lib/data-collector/store.d.ts +41 -117
- package/lib/data-collector/store.js +32 -111
- package/lib/data-collector/time-axis.d.ts +16 -76
- package/lib/data-collector/time-axis.js +25 -111
- package/lib/data-collector/tools.d.ts +6 -6
- package/lib/data-collector/tools.js +34 -43
- package/lib/dataset-read-entry.d.ts +9 -0
- package/lib/dataset-read-entry.js +7 -0
- package/lib/index.d.ts +7 -117
- package/lib/index.js +43 -422
- package/lib/net/eastmoney-client.d.ts +13 -65
- package/lib/net/eastmoney-client.js +12 -53
- package/lib/net/throttle.d.ts +2 -13
- package/lib/net/throttle.js +3 -14
- package/lib/ocr/client.d.ts +12 -21
- package/lib/ocr/client.js +23 -40
- package/lib/ocr/markdown.d.ts +20 -26
- package/lib/ocr/markdown.js +23 -36
- package/lib/ocr/store.d.ts +14 -47
- package/lib/ocr/store.js +15 -45
- package/lib/ocr-entry.d.ts +9 -0
- package/lib/ocr-entry.js +10 -0
- package/lib/policy-entry.d.ts +17 -0
- package/lib/policy-entry.js +22 -0
- package/lib/present-entry.d.ts +9 -0
- package/lib/present-entry.js +13 -0
- package/lib/preset-claim.d.ts +22 -0
- package/lib/preset-claim.js +24 -0
- package/lib/preset-ids.d.ts +38 -0
- package/lib/preset-ids.js +46 -0
- package/lib/retriever-config.d.ts +37 -0
- package/lib/retriever-config.js +36 -0
- package/lib/retriever-runtime.d.ts +31 -0
- package/lib/retriever-runtime.js +82 -0
- package/lib/root-extras-entry.d.ts +17 -0
- package/lib/root-extras-entry.js +25 -0
- package/lib/runtime-entry.d.ts +15 -0
- package/lib/runtime-entry.js +5 -0
- package/lib/runtime.d.ts +21 -0
- package/lib/runtime.js +33 -0
- package/lib/search-entry.d.ts +9 -0
- package/lib/search-entry.js +9 -0
- package/lib/sources/eastmoney-http.js +20 -68
- package/lib/sources/ftshare-rest.d.ts +6 -34
- package/lib/sources/ftshare-rest.js +84 -292
- package/lib/sources/fuyao-core.d.ts +8 -18
- package/lib/sources/fuyao-core.js +10 -21
- package/lib/sources/fuyao-rest.d.ts +2 -6
- package/lib/sources/fuyao-rest.js +23 -102
- package/lib/sources/security-code.d.ts +6 -12
- package/lib/sources/security-code.js +6 -12
- package/lib/sources/security-identity.d.ts +1 -4
- package/lib/sources/security-identity.js +3 -8
- package/lib/sources/tencent-http.js +14 -28
- package/lib/sources/tencent-public-core.d.ts +8 -60
- package/lib/sources/tencent-public-core.js +12 -77
- package/lib/sources/wind-mcp.d.ts +0 -5
- package/lib/sources/wind-mcp.js +23 -78
- package/lib/sources-entry.d.ts +9 -0
- package/lib/sources-entry.js +9 -0
- package/lib/time/tools.d.ts +8 -31
- package/lib/time/tools.js +30 -66
- package/lib/time-entry.d.ts +9 -0
- package/lib/time-entry.js +7 -0
- package/lib/tool-exec.d.ts +45 -11
- package/lib/tool-exec.js +59 -6
- package/lib/user-customization.d.ts +14 -0
- package/lib/user-customization.js +47 -0
- package/lib/watchlist/tools.d.ts +3 -13
- package/lib/watchlist/tools.js +10 -30
- package/lib/watchlist-entry.d.ts +9 -0
- package/lib/watchlist-entry.js +6 -0
- package/lib/web-retriever/engines.d.ts +6 -11
- package/lib/web-retriever/engines.js +9 -14
- package/lib/web-retriever/html-markdown.d.ts +14 -34
- package/lib/web-retriever/html-markdown.js +39 -75
- package/lib/web-retriever/local-fetch.d.ts +22 -58
- package/lib/web-retriever/local-fetch.js +33 -77
- package/lib/web-retriever/retriever.d.ts +6 -18
- package/lib/web-retriever/retriever.js +7 -7
- package/lib/web-retriever/sources.d.ts +37 -124
- package/lib/web-retriever/sources.js +64 -196
- package/lib/web-retriever/tools.d.ts +43 -27
- package/lib/web-retriever/tools.js +99 -137
- package/lib/web-retriever/wind-client.d.ts +14 -31
- package/lib/web-retriever/wind-client.js +16 -32
- package/locale/zh.json +1 -1
- package/package.json +72 -7
- package/preset/capital-generation/README.md +87 -53
- package/preset/capital-generation/agent.patch.yml +532 -337
- package/preset/capital-generation/skills/capital-chart-protocol/SKILL.md +6 -4
- package/preset/capital-generation/skills/capital-data-profile/SKILL.md +2 -2
- package/preset/capital-generation/skills/capital-data-protocol/SKILL.md +1 -1
- package/preset/capital-generation/skills/capital-equity-research/SKILL.md +4 -2
- package/preset/capital-generation/skills/capital-event-impact/SKILL.md +1 -1
- package/preset/capital-generation/skills/capital-orchestration/SKILL.md +30 -33
- package/preset/capital-generation/skills/capital-portfolio-review/SKILL.md +1 -1
- package/preset/capital-generation/skills/capital-visualization-protocol/SKILL.md +14 -16
- package/preset/capital-generation/skills/capital-web-evidence/SKILL.md +1 -1
- package/watchlist/client.js +15 -148
- package/watchlist/client.src.cjs +148 -662
- package/watchlist/holding-rules.js +11 -38
- package/watchlist/index.js +127 -397
- package/watchlist/package.json +2 -2
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Session reading and authorization have one implementation (src/tool-exec.ts); do not re-implement here.
|
|
2
|
+
import { authorizedSession, sessionIdentityDecisions } from '../tool-exec.js';
|
|
3
|
+
import { DATA_COLLECTION_PRESET_IDS } from '../preset-ids.js';
|
|
1
4
|
const jsonObject = (properties = {}, required = []) => ({ type: 'object', properties, required, additionalProperties: false });
|
|
2
5
|
const freeObject = { type: 'object', additionalProperties: true };
|
|
3
6
|
const MAX_ID_LENGTH = 256;
|
|
@@ -25,10 +28,7 @@ function boundedParams(value) {
|
|
|
25
28
|
throw new Error(`params exceeds maximum size ${MAX_PARAMS_BYTES} bytes`);
|
|
26
29
|
return value;
|
|
27
30
|
}
|
|
28
|
-
/**
|
|
29
|
-
* DatasetRef 输出结构(模型可见协议):只有元数据。任何 raw rows、内部
|
|
30
|
-
* data_key、绝对路径字段都不允许出现。
|
|
31
|
-
*/
|
|
31
|
+
/** Model-visible DatasetRef: metadata only; no raw rows, data_key or absolute paths. */
|
|
32
32
|
const datasetRefSchema = () => jsonObject({
|
|
33
33
|
dataset_id: { type: 'string' },
|
|
34
34
|
task_id: { oneOf: [{ type: 'string' }, { type: 'null' }] },
|
|
@@ -44,7 +44,7 @@ const datasetRefSchema = () => jsonObject({
|
|
|
44
44
|
params_digest: { type: 'string' },
|
|
45
45
|
}, ['dataset_id', 'task_id', 'session_id', 'artifact_ref', 'format', 'capability', 'source_label', 'schema', 'row_count', 'captured_at', 'retention_until', 'params_digest']);
|
|
46
46
|
function render(_args, value) {
|
|
47
|
-
// ToolOutputDefinition.render(args, value)
|
|
47
|
+
// ToolOutputDefinition.render(args, value): the first parameter is the input, the second the output.
|
|
48
48
|
return [{ type: 'text', text: JSON.stringify(value) }];
|
|
49
49
|
}
|
|
50
50
|
function tool(name, description, parameters, schema, execute, options = {}) {
|
|
@@ -54,32 +54,11 @@ function tool(name, description, parameters, schema, execute, options = {}) {
|
|
|
54
54
|
parameters,
|
|
55
55
|
output: { schema, render },
|
|
56
56
|
execute,
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
// 一次性 headless 探针核过,账本 L30)。⛔ 只给**纯读**的发现面开:
|
|
60
|
-
// `request_data` 刻意不标——Hub 的执行器是 FIFO 串行(`hub.ts` 的 Phase 1 注释),
|
|
61
|
-
// 让模型并行发取数等于把上游节流与 in-flight 合并放在我们没承诺过的位置上。
|
|
57
|
+
// Framework concurrency pool: mark pure-read discovery tools only. request_data stays serial
|
|
58
|
+
// because the Hub executes FIFO and upstream throttling/merging is not promised under parallelism.
|
|
62
59
|
...(options.concurrencySafe === true ? { isConcurrencySafe: () => true } : {}),
|
|
63
60
|
};
|
|
64
61
|
}
|
|
65
|
-
/**
|
|
66
|
-
* 调用方 Agent session(官方注入,不可由模型伪造)。请求归属恒为当前调用者,
|
|
67
|
-
* 不存在"代理请求"概念。workspace cwd 由 session.header.cwd 提供。
|
|
68
|
-
*/
|
|
69
|
-
const callerSession = (exec) => {
|
|
70
|
-
const session = exec.agent?.session;
|
|
71
|
-
if (session)
|
|
72
|
-
return session;
|
|
73
|
-
throw new Error('this tool requires a calling agent session (exec.agent.session was undefined)');
|
|
74
|
-
};
|
|
75
|
-
const delegatedSession = (exec, toolName) => {
|
|
76
|
-
const session = callerSession(exec);
|
|
77
|
-
if (typeof session.header?.parentSession !== 'string' || session.header.parentSession.length === 0) {
|
|
78
|
-
throw new Error(`${toolName} is restricted to delegated data agents; the main Agent must delegate this request`);
|
|
79
|
-
}
|
|
80
|
-
return session;
|
|
81
|
-
};
|
|
82
|
-
/** dc_status 真实执行计数(进程内递增,返回给模型可见)。 */
|
|
83
62
|
const dcStatusCalls = { current: 0 };
|
|
84
63
|
function capabilityError(code, detail) {
|
|
85
64
|
const error = new Error(`${code}: ${detail}`);
|
|
@@ -91,11 +70,7 @@ function errorCode(error) {
|
|
|
91
70
|
? error.code
|
|
92
71
|
: undefined;
|
|
93
72
|
}
|
|
94
|
-
/**
|
|
95
|
-
* 数据源在 normalizeParams 阶段抛出的错误对模型来说都是可修正的参数错误。
|
|
96
|
-
* 保留数据源的字段级原因,同时把恢复动作固定成一次 describe -> 修正 -> 重试,
|
|
97
|
-
* 避免子 Agent 只看到 "must be ..." 后凭记忆反复猜参数。
|
|
98
|
-
*/
|
|
73
|
+
/** normalizeParams errors are model-fixable: keep the field reason and pin recovery to describe -> fix -> retry. */
|
|
99
74
|
function requestParamsError(error, capability) {
|
|
100
75
|
if (errorCode(error))
|
|
101
76
|
return undefined;
|
|
@@ -145,7 +120,7 @@ export function registerDataCollectorTools(ctx, hub, diagnostics) {
|
|
|
145
120
|
task_id: { type: 'string' },
|
|
146
121
|
}, ['capability', 'params', 'task_id']), datasetRefSchema(), async (args, exec) => {
|
|
147
122
|
const requestedCapability = boundedString(args.capability, 'capability', MAX_ID_LENGTH);
|
|
148
|
-
const session =
|
|
123
|
+
const session = authorizedSession(ctx, exec, 'request_data', DATA_COLLECTION_PRESET_IDS);
|
|
149
124
|
try {
|
|
150
125
|
const params = boundedParams(args.params);
|
|
151
126
|
// Fail early with the same catalog guidance as describe_capability instead of
|
|
@@ -163,7 +138,7 @@ export function registerDataCollectorTools(ctx, hub, diagnostics) {
|
|
|
163
138
|
throw requestParamsError(error, requestedCapability) ?? error;
|
|
164
139
|
}
|
|
165
140
|
}),
|
|
166
|
-
tool('list_capabilities', '列出当前已注册的数据能力目录:**纯文本,一行一条** `capability|summary|paginated`,paginated 为 1(分页)/ 0(不分页)。名字或摘要里的 `|`、换行会转义成 `\\|`、`\\n`,所以一行就是一条能力,不要按冒号或空格拆分。目录是发现入口,**一个任务只需调用一次**:同一 session 的历史里已经保有这份目录,重复调用只会白占上下文。目录刻意不含参数与输出结构(完整 schema 约 23KB,会被剪枝截断);确定要用的能力后,用 describe_capability 单独取那一个能力的 input_schema 后即可 request_data。request_data 的 capability 必须以本目录为准,不要自行编造。', jsonObject(), { type: 'string' }, async (_args, exec) => {
|
|
141
|
+
tool('list_capabilities', '列出当前已注册的数据能力目录:**纯文本,一行一条** `capability|summary|paginated`,paginated 为 1(分页)/ 0(不分页)。名字或摘要里的 `|`、换行会转义成 `\\|`、`\\n`,所以一行就是一条能力,不要按冒号或空格拆分。目录是发现入口,**一个任务只需调用一次**:同一 session 的历史里已经保有这份目录,重复调用只会白占上下文。目录刻意不含参数与输出结构(完整 schema 约 23KB,会被剪枝截断);确定要用的能力后,用 describe_capability 单独取那一个能力的 input_schema 后即可 request_data。request_data 的 capability 必须以本目录为准,不要自行编造。', jsonObject(), { type: 'string' }, async (_args, exec) => { authorizedSession(ctx, exec, 'list_capabilities', DATA_COLLECTION_PRESET_IDS); return hub.capabilityDirectory(); }, { concurrencySafe: true }),
|
|
167
142
|
tool('describe_capability', '读取**一个**能力的完整契约:description(单位、null 语义、时间与分页口径)、input_schema(params 的取值与约束)、output_fields(返回字段的逐行字典 `路径:类型[:说明]`,类型后缀 `?` 为可为 null、`[].` 为数组元素的字段)与 paginated。request_data 的 params 必须按这里返回的 input_schema 填写;request_data 若返回 request_params_invalid,应回到这里重新读取后再重试。一个能力描述一次即可:结果已在本 session 历史里,重复描述同一个能力只会白占上下文;需要几个能力就**在同一条消息里一次发出多个调用**(本工具是纯读、可并发执行,框架会把它们放进并发池、在同一个下一步一起返回),但一次仍只传**一个**名字,不要用逗号把多个名字塞进一条调用。错误按 code 引导:capability_required(没给名字,先 list_capabilities())、capability_invalid(不是字符串/超长/含逗号,改为目录中的单个名字)、capability_catalog_empty(数据源未注册,别重试,回告主 Agent)、capability_unknown(名字不存在,错误里会列出全部可用能力名并要求原样复制)。', jsonObject({ capability: { type: 'string' } }, ['capability']), jsonObject({
|
|
168
143
|
capability: { type: 'string' },
|
|
169
144
|
summary: { type: 'string' },
|
|
@@ -172,7 +147,7 @@ export function registerDataCollectorTools(ctx, hub, diagnostics) {
|
|
|
172
147
|
input_schema: freeObject,
|
|
173
148
|
output_fields: { oneOf: [{ type: 'string' }, { type: 'null' }] },
|
|
174
149
|
}, ['capability', 'summary', 'paginated', 'description', 'input_schema', 'output_fields']), async (args, exec) => {
|
|
175
|
-
|
|
150
|
+
authorizedSession(ctx, exec, 'describe_capability', DATA_COLLECTION_PRESET_IDS);
|
|
176
151
|
const capability = resolveCapability(hub, args.capability);
|
|
177
152
|
const detail = hub.describeCapability(capability);
|
|
178
153
|
if (!detail)
|
|
@@ -180,28 +155,36 @@ export function registerDataCollectorTools(ctx, hub, diagnostics) {
|
|
|
180
155
|
return detail;
|
|
181
156
|
}, { concurrencySafe: true }),
|
|
182
157
|
...(diagnostics ? [
|
|
183
|
-
tool('dc_status', '诊断工具:返回数据管道运行状态 —— at/call 为本次真实执行的时间戳与计数(防伪)、api_key 为**本次调用现取**的凭据解析结果(present/source,不含密钥值)、registered_capabilities 为当前已注册 capability 列表、
|
|
158
|
+
tool('dc_status', '诊断工具:返回数据管道运行状态 —— at/call 为本次真实执行的时间戳与计数(防伪)、api_key 为**本次调用现取**的凭据解析结果(present/source,不含密钥值)、registered_capabilities 为当前已注册 capability 列表、agent_tool_policy 为工具面收敛的现场记录(preset_id / root / outcome / allowed / denied / failed:`outcome=restricted` 是组合期那次减名字的账,`guard-denied` 是一次调用真的被调用级闸门拦下(`ocr` 的 url 形态、`write` / `edit`、角色的 `interrupt_agent`),`not-capital` / `skipped` / `unavailable` / `pending` 是四种没生效的原因;`root=true` 是用户手开出来的会话。工具面本身由该 preset 挂的工具行决定,allowed 恒为空。排查"某个 Agent 为什么看得见、或为什么用不了某颗工具"用)、session_identity 为最近的工具授权判据现场(tool / via=preset|topology / preset_id / allowed;`via:"topology"` 表示 registry 读不到身份、回落到"必须是被委派的子会话"这一旧判据)。数据源注册不依赖 key:api_key.present=false 时同花顺能力仍在目录里,但每次取数会点名 FUYAO_API_KEY 失败。排障时优先调用。', jsonObject(), jsonObject({
|
|
184
159
|
at: { type: 'integer' },
|
|
185
160
|
call: { type: 'integer' },
|
|
186
161
|
api_key: jsonObject({ present: { type: 'boolean' }, source: { oneOf: [{ type: 'string' }, { type: 'null' }] }, error: { oneOf: [{ type: 'string' }, { type: 'null' }] } }, ['present']),
|
|
187
162
|
registered_capabilities: { type: 'array', items: { type: 'string' } },
|
|
188
|
-
|
|
163
|
+
agent_tool_policy: { type: 'array', items: jsonObject({
|
|
189
164
|
agent_id: { oneOf: [{ type: 'string' }, { type: 'null' }] },
|
|
190
165
|
root: { type: 'boolean' },
|
|
191
166
|
preset_id: { type: 'string' },
|
|
192
167
|
outcome: { type: 'string' },
|
|
168
|
+
allowed: { type: 'array', items: { type: 'string' } },
|
|
193
169
|
denied: { type: 'array', items: { type: 'string' } },
|
|
194
170
|
failed: { type: 'array', items: { type: 'string' } },
|
|
195
|
-
}, ['agent_id', 'root', 'preset_id', 'outcome', 'denied', 'failed']) },
|
|
171
|
+
}, ['agent_id', 'root', 'preset_id', 'outcome', 'allowed', 'denied', 'failed']) },
|
|
172
|
+
session_identity: { type: 'array', items: jsonObject({
|
|
173
|
+
tool: { type: 'string' },
|
|
174
|
+
via: { type: 'string' },
|
|
175
|
+
preset_id: { oneOf: [{ type: 'string' }, { type: 'null' }] },
|
|
176
|
+
allowed: { type: 'boolean' },
|
|
177
|
+
}, ['tool', 'via', 'preset_id', 'allowed']) },
|
|
196
178
|
}, ['at', 'call', 'api_key', 'registered_capabilities']), async (_args, exec) => {
|
|
197
|
-
|
|
179
|
+
authorizedSession(ctx, exec, 'dc_status', DATA_COLLECTION_PRESET_IDS);
|
|
198
180
|
const apiKey = await diagnostics.probeApiKey();
|
|
199
181
|
const capabilities = hub.capabilityNames();
|
|
200
|
-
const
|
|
182
|
+
const agentToolPolicy = diagnostics.rootPolicy?.()?.map((probe) => ({
|
|
201
183
|
agent_id: probe.agentId ?? null,
|
|
202
184
|
root: probe.root,
|
|
203
185
|
preset_id: probe.presetId,
|
|
204
186
|
outcome: probe.outcome,
|
|
187
|
+
allowed: probe.allowed ?? [],
|
|
205
188
|
denied: probe.denied,
|
|
206
189
|
failed: probe.failed,
|
|
207
190
|
}));
|
|
@@ -212,7 +195,15 @@ export function registerDataCollectorTools(ctx, hub, diagnostics) {
|
|
|
212
195
|
call: snapshot.call,
|
|
213
196
|
api_key: apiKey,
|
|
214
197
|
registered_capabilities: capabilities,
|
|
215
|
-
...(
|
|
198
|
+
...(agentToolPolicy === undefined ? {} : { agent_tool_policy: agentToolPolicy }),
|
|
199
|
+
// Authorization decision trail: preset identity vs fallback to session topology; without
|
|
200
|
+
// it, "identity unavailable" and "identity confirmed" look identical to the model.
|
|
201
|
+
session_identity: sessionIdentityDecisions().map((record) => ({
|
|
202
|
+
tool: record.tool,
|
|
203
|
+
via: record.via,
|
|
204
|
+
preset_id: record.presetId,
|
|
205
|
+
allowed: record.allowed,
|
|
206
|
+
})),
|
|
216
207
|
};
|
|
217
208
|
}),
|
|
218
209
|
] : []),
|
|
@@ -220,7 +211,7 @@ export function registerDataCollectorTools(ctx, hub, diagnostics) {
|
|
|
220
211
|
for (const definition of registrations)
|
|
221
212
|
ctx.effect(() => tools.register(definition), `capital-generation.tool(${definition.name})`);
|
|
222
213
|
}
|
|
223
|
-
/**
|
|
214
|
+
/** Model-visible DatasetRef field whitelist (tests and host assertions). */
|
|
224
215
|
export const DATASET_REF_FIELDS = [
|
|
225
216
|
'dataset_id', 'task_id', 'session_id', 'artifact_ref', 'format',
|
|
226
217
|
'capability', 'source_label', 'schema', 'row_count', 'captured_at',
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tools/dataset-read` row: describe / inspect / profile / query_dataset.
|
|
3
|
+
* Each row builds its own store (no shared memory state; a shared hub would collide).
|
|
4
|
+
* Raw rows never leave these tools — only summaries, structure and controlled aggregates.
|
|
5
|
+
*/
|
|
6
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
7
|
+
export declare const name = "capital-dataset-read-tools";
|
|
8
|
+
export declare const inject: string[];
|
|
9
|
+
export declare function apply(ctx: Context): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerDatasetTools } from './data-collector/dataset-tools.js';
|
|
2
|
+
import { capitalDatasetStore } from './runtime.js';
|
|
3
|
+
export const name = 'capital-dataset-read-tools';
|
|
4
|
+
export const inject = ['tools'];
|
|
5
|
+
export function apply(ctx) {
|
|
6
|
+
registerDatasetTools(ctx, capitalDatasetStore(ctx));
|
|
7
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,97 +1,19 @@
|
|
|
1
1
|
import { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import z from '@deepseek-ai/schemastery';
|
|
3
3
|
import { type SelectedSkillSelection } from './agents/selected-skills-provider.js';
|
|
4
|
-
|
|
4
|
+
import { type RetrieverConfig } from './retriever-config.js';
|
|
5
|
+
export { LOCAL_FETCH_DEFAULTS, PADDLE_OCR_DEFAULTS, resolveLocalFetchConfig, type LocalFetchConfig, type PaddleOcrConfig, type RetrieverConfig, type WindDocsConfig, } from './retriever-config.js';
|
|
6
|
+
export { resolveUserCustomizationSection } from './user-customization.js';
|
|
5
7
|
export declare const name = "capital-generation";
|
|
6
|
-
/**
|
|
7
|
-
* 取数配置所在的 **profile 条目 id**(随包的 `capital-config` 行)。0.1.7 的 settings 面
|
|
8
|
-
* 以条目 id 为命名空间,本插件经 `settings.describe()` 按它读回用户配的引用名与开关。
|
|
9
|
-
*
|
|
10
|
-
* 这个字符串有三处必须一致:`cordis.patch.yml` 的行 id、`config/index.js` 的
|
|
11
|
-
* `SETTINGS_ENTRY_ID`、以及浏览器半边 `client.src.cjs` 的 `ENTRY_ID`;由
|
|
12
|
-
* `test/capital-config.test.mjs` 逐一对齐(漂移的表现为卡片静默消失)。
|
|
13
|
-
*/
|
|
8
|
+
/** Entry id shared by `cordis.patch.yml`, `config/index.js` and `client.src.cjs`; drift hides the settings card. */
|
|
14
9
|
export declare const CAPITAL_CONFIG_ENTRY_ID = "capital-config";
|
|
15
|
-
/** Wind 文档检索配置:JSON-RPC 端点与凭据名(线格式为 MCP 线协议,零依赖适配)。 */
|
|
16
|
-
export interface WindDocsConfig {
|
|
17
|
-
endpoint?: string;
|
|
18
|
-
credentialRef?: string;
|
|
19
|
-
timeoutMs?: number;
|
|
20
|
-
}
|
|
21
|
-
/** 本地直连回退配置(AnySearch 明确失败后改由本机直连抓取公开文本页面)。 */
|
|
22
|
-
export interface LocalFetchConfig {
|
|
23
|
-
enabled?: boolean;
|
|
24
|
-
timeoutMs?: number;
|
|
25
|
-
maxBytes?: number;
|
|
26
|
-
maxContentChars?: number;
|
|
27
|
-
maxRedirects?: number;
|
|
28
|
-
userAgent?: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* PaddleOCR 文档解析(`ocr` 工具)配置。
|
|
32
|
-
*
|
|
33
|
-
* `endpoint` / `model` 空值 = 用 `src/ocr/client.ts` 里的官方端点与模型名(真值只在那一处,
|
|
34
|
-
* 与 `windDocs.endpoint` 同一口径)。`pollBudgetMs` 是**工具内部**等作业的自有预算,
|
|
35
|
-
* 必须小于工具声明的 `timeoutMs: 240000`——余量留给"决定回 pending 之后把回执写出去",
|
|
36
|
-
* 撞上框架超时就没有 `doc_id` 可续查了。
|
|
37
|
-
*/
|
|
38
|
-
export interface PaddleOcrConfig {
|
|
39
|
-
endpoint?: string;
|
|
40
|
-
credentialRef?: string;
|
|
41
|
-
model?: string;
|
|
42
|
-
pollBudgetMs?: number;
|
|
43
|
-
}
|
|
44
|
-
/** web_retriever 会话配置:anysearch(广度)+ wind_docs(public_document 精准)+ 文档解析。 */
|
|
45
|
-
export interface RetrieverConfig {
|
|
46
|
-
baseURL?: string;
|
|
47
|
-
credentialRef?: string;
|
|
48
|
-
windDocs?: WindDocsConfig;
|
|
49
|
-
localFetch?: LocalFetchConfig;
|
|
50
|
-
paddleOcr?: PaddleOcrConfig;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* 本地直连回退的默认值(唯一真值来源):schema 的 `.default()` 与消费点
|
|
54
|
-
* `resolveLocalFetchConfig()` 都引用它,两处不再各写一份字面量。
|
|
55
|
-
*
|
|
56
|
-
* 数值口径对齐官方 `dsh-web-fetch-http`(DSH 自己的同类本机抓取器):
|
|
57
|
-
* - `timeoutMs` = 30000(官方默认)。2026-09 实测:环境代理的故障转移慢路径约
|
|
58
|
-
* 15.2–15.4s,15s 预算会把证券业协会官网这类站点误判成 TIMEOUT。
|
|
59
|
-
* - `maxContentChars` = 100000(官方 `maxBodyChars` 默认值)。注意它切的是**转换前的
|
|
60
|
-
* 原始 HTML**(见 `html-markdown.ts`),而 markdown 输出只有 HTML 的 12–33%,
|
|
61
|
-
* 所以这个数必须按 HTML 体积给足;20,000 会把 109KB 的页面腰斩到 18%。
|
|
62
|
-
*
|
|
63
|
-
* `userAgent` 默认是产品标识(`@v587d/capital-generation`):裸版本号是
|
|
64
|
-
* WAF 眼里的典型爬虫特征。显式配成空串时消费点回落到 `LOCAL_FETCH_CLIENT_VERSION`
|
|
65
|
-
* (版本号真值仍只有一处,由测试守着等于 `package.json` 的 version)。
|
|
66
|
-
*/
|
|
67
|
-
export declare const LOCAL_FETCH_DEFAULTS: Required<LocalFetchConfig>;
|
|
68
|
-
/**
|
|
69
|
-
* `ocr`(PaddleOCR 文档解析)配置的默认值:与 `LOCAL_FETCH_DEFAULTS` 同一口径,
|
|
70
|
-
* schema 的 `.default()` 与消费点都引用它,字面量只有一处。
|
|
71
|
-
*
|
|
72
|
-
* `endpoint` / `model` 留空是把真值让给 `src/ocr/client.ts`(那边还有 `PADDLE_OCR_MAX_PAGES`
|
|
73
|
-
* 这类跟着端点走的常数);`pollBudgetMs: 0` 同理让给客户端的 `DEFAULT_WAIT_BUDGET_MS`。
|
|
74
|
-
*/
|
|
75
|
-
export declare const PADDLE_OCR_DEFAULTS: Required<PaddleOcrConfig>;
|
|
76
|
-
/**
|
|
77
|
-
* 消费点独立补齐默认值。`apply()` 在无 settings 的宿主/测试里拿到的是**未过 schema**
|
|
78
|
-
* 的原始对象,`retriever.localFetch` 可能是 `undefined`,因此消费点不能依赖 schema 补默认值。
|
|
79
|
-
*/
|
|
80
|
-
export declare function resolveLocalFetchConfig(config?: LocalFetchConfig): Required<LocalFetchConfig>;
|
|
81
|
-
/** Configuration accepted by the Capital Generation plugin. */
|
|
82
10
|
export interface Config {
|
|
83
|
-
/** Optional additive persona override; core safety guidance is preserved. */
|
|
84
11
|
customPersona?: string;
|
|
85
|
-
/** Community experiments explicitly selected for the Capital root Agent only. */
|
|
86
12
|
selectedSkills?: SelectedSkillSelection;
|
|
87
|
-
/** Fuyao credentials 引用名;空值回退到 FUYAO_API_KEY。 */
|
|
88
13
|
fuyaoCredentialRef?: string;
|
|
89
|
-
/** FTShare(非凸科技)credentials 引用名;空值回退到 FTSHARE_API_KEY。 */
|
|
90
14
|
ftshareCredentialRef?: string;
|
|
91
|
-
/** web_retriever 配置(可选;缺省使用 AnySearch 默认地址与凭据名)。 */
|
|
92
15
|
retriever?: RetrieverConfig;
|
|
93
16
|
}
|
|
94
|
-
/** DSH 0.1.2-rc.1 configuration schema. */
|
|
95
17
|
export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
96
18
|
customPersona: z<string, string, "defined">;
|
|
97
19
|
selectedSkills: z<Schemastery.ObjectS<NoInfer<{
|
|
@@ -266,44 +188,12 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
266
188
|
}>>, "defined">;
|
|
267
189
|
}>>, "plain">;
|
|
268
190
|
export type CapitalSettingsSource = 'settings-describe' | 'config-editor' | 'preset';
|
|
269
|
-
/**
|
|
270
|
-
*
|
|
271
|
-
* 1. `settings.describe()`:活动条目的已应用视图(0.1.7 官方读回面);
|
|
272
|
-
* 2. `configEditor.entries()` 的条目保存层:设置卡写入的就是这层(complete raw config)。
|
|
273
|
-
* describe() 在条目 fiber 未挂好的窗口会**整个跳过条目**,用户已保存的值仍然在这里可读;
|
|
274
|
-
* 3. preset 配置兜底,且必须可辨认(`source === 'preset'`)——"读不到"不许伪装成"用户全关"。
|
|
275
|
-
*
|
|
276
|
-
* ⛔ 服务引用一律**调用期现取**(AGENTS.md §9.7):装配期 `ctx.get()` 押的是"宿主服务已注册"
|
|
277
|
-
* 这个外部时刻——boot 里各 fiber 并行 apply,settings / configEditor 晚于本插件注册时,装配期
|
|
278
|
-
* 捕获到 undefined,整场进程会静默降级成 preset 默认。2026-10-13 复盘(session-bb8635a1:
|
|
279
|
-
* 07:51 保存 10 个开关、07:54 建会话读到全关、08:30 重组后同一条读取路径立刻读对)就是这一族。
|
|
280
|
-
*/
|
|
191
|
+
/** Fallback order: settings.describe → configEditor.entries → boot preset, so unreadable never
|
|
192
|
+
* reads as "all toggles off". Resolve services per call: boot fibers apply in parallel. */
|
|
281
193
|
export declare function readCapitalSettings(ctx: Context, bootConfig: Config): {
|
|
282
194
|
config: Config;
|
|
283
195
|
source: CapitalSettingsSource;
|
|
284
196
|
};
|
|
285
|
-
/**
|
|
286
|
-
* 把可选的用户人设文本转成独立 system-prompt section(官方 systemPrompt
|
|
287
|
-
* registry 的注册对象)。空白输入返回 undefined(不注册);超长抛错;
|
|
288
|
-
* 追加不可覆盖的安全提醒。只影响表达风格与呈现。
|
|
289
|
-
*/
|
|
290
|
-
export declare function resolveUserCustomizationSection(customPersona?: string): {
|
|
291
|
-
name: string;
|
|
292
|
-
order: number;
|
|
293
|
-
text: string;
|
|
294
|
-
} | undefined;
|
|
295
|
-
/** The system-prompt service is a hard dependency for the optional section. */
|
|
197
|
+
/** `systemPrompt` is a hard dependency of the optional persona section. */
|
|
296
198
|
export declare const inject: string[];
|
|
297
|
-
/**
|
|
298
|
-
* Register the Capital mode data services and tools.
|
|
299
|
-
*
|
|
300
|
-
* 人设文本全部由 preset 组合承载(dsh-persona 行 + 两个委派行 config.persona),
|
|
301
|
-
* 不在插件代码中。本包只装配服务与工具:
|
|
302
|
-
* - datasetStore(workspace-local Dataset 持久化,7 天保留,权限失败显式报错)
|
|
303
|
-
* - dataCollectorHub(阻塞 FIFO + in-flight 合并,成功后由 store 立即落盘,
|
|
304
|
-
* 只回传 DatasetRef,不保留长期 raw 缓存)
|
|
305
|
-
* - 无状态 AnySearch 网页检索(单查询 search + 单 URL fetch)
|
|
306
|
-
* - 无状态 Wind 文档检索客户端(public_document:公告/年报/招股书与权威新闻)
|
|
307
|
-
* - 各自的模型工具;时间工具。
|
|
308
|
-
*/
|
|
309
199
|
export declare function apply(ctx: Context, config: Config): void;
|