@v587d/capital-generation 0.0.0-stage → 2.6.0

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.
Files changed (117) hide show
  1. package/CHANGELOG.md +794 -0
  2. package/LICENSE +21 -0
  3. package/README.md +116 -2
  4. package/assets/cg-icon.png +0 -0
  5. package/capital-config/client.js +28 -0
  6. package/capital-config/client.src.cjs +388 -0
  7. package/capital-config/index.js +113 -0
  8. package/capital-config/package.json +36 -0
  9. package/capital-watchlist/client.js +182 -0
  10. package/capital-watchlist/client.src.cjs +1229 -0
  11. package/capital-watchlist/index.js +772 -0
  12. package/capital-watchlist/package.json +37 -0
  13. package/chart-ui/README.md +112 -0
  14. package/chart-ui/client.js +16 -0
  15. package/chart-ui/client.src.cjs +126 -0
  16. package/chart-ui/index.js +205 -0
  17. package/chart-ui/package.json +30 -0
  18. package/cordis.patch.yml +72 -0
  19. package/lib/agents/bash-guard.d.ts +55 -0
  20. package/lib/agents/bash-guard.js +162 -0
  21. package/lib/agents/root-tool-policy.d.ts +164 -0
  22. package/lib/agents/root-tool-policy.js +309 -0
  23. package/lib/chart/artifact-ref.d.ts +65 -0
  24. package/lib/chart/artifact-ref.js +107 -0
  25. package/lib/chart/downsample.d.ts +8 -0
  26. package/lib/chart/downsample.js +53 -0
  27. package/lib/chart/errors.d.ts +16 -0
  28. package/lib/chart/errors.js +15 -0
  29. package/lib/chart/events.d.ts +120 -0
  30. package/lib/chart/events.js +471 -0
  31. package/lib/chart/html.d.ts +21 -0
  32. package/lib/chart/html.js +154 -0
  33. package/lib/chart/runtime.d.ts +20 -0
  34. package/lib/chart/runtime.js +270 -0
  35. package/lib/chart/series.d.ts +102 -0
  36. package/lib/chart/series.js +424 -0
  37. package/lib/chart/source-token.d.ts +64 -0
  38. package/lib/chart/source-token.js +217 -0
  39. package/lib/chart/spec.d.ts +58 -0
  40. package/lib/chart/spec.js +265 -0
  41. package/lib/chart/tool.d.ts +86 -0
  42. package/lib/chart/tool.js +288 -0
  43. package/lib/chart/vendor/LICENSE +201 -0
  44. package/lib/chart/vendor/VERSION.json +8 -0
  45. package/lib/chart/vendor/lightweight-charts.standalone.production.js +7 -0
  46. package/lib/data-collector/args.d.ts +38 -0
  47. package/lib/data-collector/args.js +114 -0
  48. package/lib/data-collector/dataset-tools.d.ts +3 -0
  49. package/lib/data-collector/dataset-tools.js +421 -0
  50. package/lib/data-collector/describe.d.ts +99 -0
  51. package/lib/data-collector/describe.js +256 -0
  52. package/lib/data-collector/hub.d.ts +187 -0
  53. package/lib/data-collector/hub.js +469 -0
  54. package/lib/data-collector/query-time.d.ts +58 -0
  55. package/lib/data-collector/query-time.js +101 -0
  56. package/lib/data-collector/query.d.ts +57 -0
  57. package/lib/data-collector/query.js +473 -0
  58. package/lib/data-collector/store.d.ts +499 -0
  59. package/lib/data-collector/store.js +1486 -0
  60. package/lib/data-collector/time-axis.d.ts +169 -0
  61. package/lib/data-collector/time-axis.js +419 -0
  62. package/lib/data-collector/tools.d.ts +32 -0
  63. package/lib/data-collector/tools.js +216 -0
  64. package/lib/index.d.ts +275 -0
  65. package/lib/index.js +458 -0
  66. package/lib/net/eastmoney-client.d.ts +104 -0
  67. package/lib/net/eastmoney-client.js +118 -0
  68. package/lib/net/throttle.d.ts +16 -0
  69. package/lib/net/throttle.js +34 -0
  70. package/lib/ocr/client.d.ts +82 -0
  71. package/lib/ocr/client.js +281 -0
  72. package/lib/ocr/markdown.d.ts +75 -0
  73. package/lib/ocr/markdown.js +209 -0
  74. package/lib/ocr/store.d.ts +119 -0
  75. package/lib/ocr/store.js +226 -0
  76. package/lib/sources/eastmoney-http.d.ts +2 -0
  77. package/lib/sources/eastmoney-http.js +1253 -0
  78. package/lib/sources/fuyao-core.d.ts +52 -0
  79. package/lib/sources/fuyao-core.js +96 -0
  80. package/lib/sources/fuyao-rest.d.ts +14 -0
  81. package/lib/sources/fuyao-rest.js +2057 -0
  82. package/lib/sources/security-code.d.ts +27 -0
  83. package/lib/sources/security-code.js +104 -0
  84. package/lib/sources/security-identity.d.ts +24 -0
  85. package/lib/sources/security-identity.js +89 -0
  86. package/lib/sources/tencent-http.d.ts +2 -0
  87. package/lib/sources/tencent-http.js +1053 -0
  88. package/lib/sources/wind-mcp.d.ts +8 -0
  89. package/lib/sources/wind-mcp.js +593 -0
  90. package/lib/time/tools.d.ts +74 -0
  91. package/lib/time/tools.js +464 -0
  92. package/lib/tool-exec.d.ts +29 -0
  93. package/lib/tool-exec.js +17 -0
  94. package/lib/web-retriever/engines.d.ts +61 -0
  95. package/lib/web-retriever/engines.js +202 -0
  96. package/lib/web-retriever/html-markdown.d.ts +50 -0
  97. package/lib/web-retriever/html-markdown.js +321 -0
  98. package/lib/web-retriever/local-fetch.d.ts +121 -0
  99. package/lib/web-retriever/local-fetch.js +562 -0
  100. package/lib/web-retriever/retriever.d.ts +58 -0
  101. package/lib/web-retriever/retriever.js +94 -0
  102. package/lib/web-retriever/sources.d.ts +235 -0
  103. package/lib/web-retriever/sources.js +961 -0
  104. package/lib/web-retriever/tools.d.ts +50 -0
  105. package/lib/web-retriever/tools.js +1029 -0
  106. package/lib/web-retriever/wind-client.d.ts +69 -0
  107. package/lib/web-retriever/wind-client.js +311 -0
  108. package/locale/en.json +6 -0
  109. package/locale/zh.json +6 -0
  110. package/package.json +76 -4
  111. package/preset/capital-generation/README.md +161 -0
  112. package/preset/capital-generation/agent.patch.yml +509 -0
  113. package/preset/capital-generation/skills/capital-chart-protocol/SKILL.md +137 -0
  114. package/preset/capital-generation/skills/capital-data-protocol/SKILL.md +416 -0
  115. package/preset/capital-generation/skills/capital-orchestration/SKILL.md +174 -0
  116. package/preset/capital-generation/skills/capital-visualization-protocol/SKILL.md +296 -0
  117. package/preset/capital-generation/skills/capital-web-protocol/SKILL.md +240 -0
@@ -0,0 +1,216 @@
1
+ const jsonObject = (properties = {}, required = []) => ({ type: 'object', properties, required, additionalProperties: false });
2
+ const freeObject = { type: 'object', additionalProperties: true };
3
+ const MAX_ID_LENGTH = 256;
4
+ const MAX_PARAMS_BYTES = 64 * 1024;
5
+ function boundedString(value, name, maxLength) {
6
+ if (typeof value !== 'string' || value.length === 0)
7
+ throw new Error(`${name} is required`);
8
+ if (value.length > maxLength)
9
+ throw new Error(`${name} exceeds maximum length ${maxLength}`);
10
+ return value;
11
+ }
12
+ function boundedParams(value) {
13
+ if (value === undefined)
14
+ return {};
15
+ if (!value || typeof value !== 'object' || Array.isArray(value))
16
+ throw new Error('params must be an object');
17
+ let encoded;
18
+ try {
19
+ encoded = JSON.stringify(value);
20
+ }
21
+ catch {
22
+ throw new Error('params must be JSON-serializable');
23
+ }
24
+ if (encoded.length > MAX_PARAMS_BYTES)
25
+ throw new Error(`params exceeds maximum size ${MAX_PARAMS_BYTES} bytes`);
26
+ return value;
27
+ }
28
+ /**
29
+ * DatasetRef 输出结构(模型可见协议):只有元数据。任何 raw rows、内部
30
+ * data_key、绝对路径字段都不允许出现。
31
+ */
32
+ const datasetRefSchema = () => jsonObject({
33
+ dataset_id: { type: 'string' },
34
+ task_id: { oneOf: [{ type: 'string' }, { type: 'null' }] },
35
+ session_id: { type: 'string' },
36
+ artifact_ref: { type: 'string' },
37
+ format: { type: 'string' },
38
+ capability: { type: 'string' },
39
+ source_label: { type: 'string' },
40
+ schema: { oneOf: [{ type: 'object', additionalProperties: true }, { type: 'null' }] },
41
+ row_count: { oneOf: [{ type: 'integer' }, { type: 'null' }] },
42
+ captured_at: { type: 'integer' },
43
+ retention_until: { type: 'integer' },
44
+ params_digest: { type: 'string' },
45
+ }, ['dataset_id', 'task_id', 'session_id', 'artifact_ref', 'format', 'capability', 'source_label', 'schema', 'row_count', 'captured_at', 'retention_until', 'params_digest']);
46
+ function render(_args, value) {
47
+ // ToolOutputDefinition.render(args, value):第一参是入参、第二参才是返回值。
48
+ return [{ type: 'text', text: JSON.stringify(value) }];
49
+ }
50
+ function tool(name, description, parameters, schema, execute) {
51
+ return { name, description, parameters, output: { schema, render }, execute };
52
+ }
53
+ /**
54
+ * 调用方 Agent session(官方注入,不可由模型伪造)。请求归属恒为当前调用者,
55
+ * 不存在"代理请求"概念。workspace cwd 由 session.header.cwd 提供。
56
+ */
57
+ const callerSession = (exec) => {
58
+ const session = exec.agent?.session;
59
+ if (session)
60
+ return session;
61
+ throw new Error('this tool requires a calling agent session (exec.agent.session was undefined)');
62
+ };
63
+ const delegatedSession = (exec, toolName) => {
64
+ const session = callerSession(exec);
65
+ if (typeof session.header?.parentSession !== 'string' || session.header.parentSession.length === 0) {
66
+ throw new Error(`${toolName} is restricted to delegated data agents; the main Agent must delegate this request`);
67
+ }
68
+ return session;
69
+ };
70
+ /** dc_status 真实执行计数(进程内递增,返回给模型可见)。 */
71
+ const dcStatusCalls = { current: 0 };
72
+ function capabilityError(code, detail) {
73
+ const error = new Error(`${code}: ${detail}`);
74
+ error.code = code;
75
+ return error;
76
+ }
77
+ function errorCode(error) {
78
+ return error && typeof error === 'object' && typeof error.code === 'string'
79
+ ? error.code
80
+ : undefined;
81
+ }
82
+ /**
83
+ * 数据源在 normalizeParams 阶段抛出的错误对模型来说都是可修正的参数错误。
84
+ * 保留数据源的字段级原因,同时把恢复动作固定成一次 describe -> 修正 -> 重试,
85
+ * 避免子 Agent 只看到 "must be ..." 后凭记忆反复猜参数。
86
+ */
87
+ function requestParamsError(error, capability) {
88
+ if (errorCode(error))
89
+ return undefined;
90
+ const message = error instanceof Error ? error.message : String(error);
91
+ if (!/(?:\bparameter\b|\bparams\b|missing required parameter|unsupported parameter|at least one of)/i.test(message))
92
+ return undefined;
93
+ const detail = `request_params_invalid: ${message}. 请先调用 describe_capability({ "capability": ${JSON.stringify(capability)} }) 重新读取该能力的 input_schema,再严格按 schema 修正 params 后重试 request_data;不要凭记忆猜测参数。 Please read describe_capability(${JSON.stringify(capability)}) before retrying request_data.`;
94
+ const failure = new Error(detail);
95
+ failure.code = 'request_params_invalid';
96
+ return failure;
97
+ }
98
+ function resolveCapability(hub, value) {
99
+ if (value === undefined || value === null || value === '') {
100
+ throw capabilityError('capability_required', '缺少 capability 参数。请先调用 list_capabilities() 取回能力目录,再调用 describe_capability({ "capability": "<目录中的名字>" }) 读取该能力契约。');
101
+ }
102
+ if (typeof value !== 'string') {
103
+ throw capabilityError('capability_invalid', `capability 必须是字符串(收到 ${Array.isArray(value) ? 'array' : typeof value})。一次只描述一个能力;请从 list_capabilities() 的目录中原样复制名字,再调用 describe_capability。`);
104
+ }
105
+ const name = value.trim();
106
+ if (name.length === 0) {
107
+ throw capabilityError('capability_required', 'capability 是空白字符串。请先调用 list_capabilities(),再把目录中的 capability 名原样传给 describe_capability。');
108
+ }
109
+ if (name.length > MAX_ID_LENGTH) {
110
+ throw capabilityError('capability_invalid', `capability 超过 ${MAX_ID_LENGTH} 字符,不是合法能力名。请从 list_capabilities() 的目录里原样复制一个名字。`);
111
+ }
112
+ if (name.includes(',')) {
113
+ throw capabilityError('capability_invalid', `capability 不接受逗号分隔的多个名字(收到 "${name}")。一次只调用 describe_capability 描述一个能力;需要多个就分多次调用。`);
114
+ }
115
+ if (!hub.describeCapability(name)) {
116
+ const available = hub.capabilityNames();
117
+ if (available.length === 0) {
118
+ throw capabilityError('capability_catalog_empty', '当前没有任何已注册的数据能力(数据源注册没有生效)。注意:缺凭据**不会**让目录变空——同花顺能力始终在目录里,只在取数那一刻点名 FUYAO_API_KEY 失败。本工具此刻对任何名字都会失败——不要反复重试,也不要编造能力名;请把该状态回告主 Agent,必要时用 dc_status 核对 registered_capabilities 与 api_key。');
119
+ }
120
+ throw capabilityError('capability_unknown', `未注册的能力 "${name}"。当前可用能力:${available.join(', ')}。请从 list_capabilities() 返回的目录里原样复制一个名字,再调用 describe_capability;不要自行编造、缩写或改写。`);
121
+ }
122
+ return name;
123
+ }
124
+ export function registerDataCollectorTools(ctx, hub, diagnostics) {
125
+ const tools = ctx.get('tools');
126
+ if (!tools)
127
+ return;
128
+ const registrations = [
129
+ tool('request_data', '向数据管道请求数据:宿主先按 capability+params 校验当前 session 的已验证 manifest;force_refresh=false 或省略且命中未过期、满足该来源缓存新鲜度的 Dataset 时直接返回已有 DatasetRef,不访问上游;force_refresh=true 才重新取数并生成新的不可变 Dataset(默认保留 7 天),绝不覆盖旧 Dataset。明确要现在/最新的行情快照时请用 force_refresh=true,7 天是保留期而非实时新鲜度。本工具只返回 DatasetRef(dataset_id / artifact_ref / schema / row_count / captured_at / retention_until 等元数据),绝不返回原始数据行。capability 必须是 list_capabilities 返回的短能力名(如 ticker_search / quote / history / trading_calendar),params 必须按 describe_capability({ capability }) 返回的 input_schema 填写。若返回 request_params_invalid,先重新调用 describe_capability({ capability: "<当前能力名>" }),再按 schema 修正并重试一次;不要凭记忆猜参数。task_id 必须由主 Agent 在本轮委派前确定,并在所有子 Agent 与最终报告中原样复用;不要由 data_collector 自行生成。相同 capability+params 的并发请求合并为同一次执行。当前 workspace 只读或落盘失败时抛错 workspace_not_writable(绝不退化为内存假成功)。请求归属自动记为当前 delegated child session,不接收 requester_agent_id 参数。', jsonObject({
130
+ capability: { type: 'string' },
131
+ params: freeObject,
132
+ force_refresh: { type: 'boolean' },
133
+ task_id: { type: 'string' },
134
+ }, ['capability', 'params', 'task_id']), datasetRefSchema(), async (args, exec) => {
135
+ const requestedCapability = boundedString(args.capability, 'capability', MAX_ID_LENGTH);
136
+ const session = delegatedSession(exec, 'request_data');
137
+ try {
138
+ const params = boundedParams(args.params);
139
+ // Fail early with the same catalog guidance as describe_capability instead of
140
+ // making the model infer a capability typo from a low-level Hub error.
141
+ const capability = resolveCapability(hub, requestedCapability);
142
+ return await hub.request({
143
+ capability,
144
+ params,
145
+ force_refresh: args.force_refresh === true,
146
+ task_id: boundedString(args.task_id, 'task_id', MAX_ID_LENGTH),
147
+ session,
148
+ }, { signal: exec.signal });
149
+ }
150
+ catch (error) {
151
+ throw requestParamsError(error, requestedCapability) ?? error;
152
+ }
153
+ }),
154
+ 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) => { delegatedSession(exec, 'list_capabilities'); return hub.capabilityDirectory(); }),
155
+ 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({
156
+ capability: { type: 'string' },
157
+ summary: { type: 'string' },
158
+ paginated: { type: 'boolean' },
159
+ description: { type: 'string' },
160
+ input_schema: freeObject,
161
+ output_fields: { oneOf: [{ type: 'string' }, { type: 'null' }] },
162
+ }, ['capability', 'summary', 'paginated', 'description', 'input_schema', 'output_fields']), async (args, exec) => {
163
+ delegatedSession(exec, 'describe_capability');
164
+ const capability = resolveCapability(hub, args.capability);
165
+ const detail = hub.describeCapability(capability);
166
+ if (!detail)
167
+ throw capabilityError('capability_unknown', `未注册的能力 "${capability}"。`);
168
+ return detail;
169
+ }),
170
+ ...(diagnostics ? [
171
+ tool('dc_status', '诊断工具:返回数据管道运行状态 —— at/call 为本次真实执行的时间戳与计数(防伪)、api_key 为**本次调用现取**的凭据解析结果(present/source,不含密钥值)、registered_capabilities 为当前已注册 capability 列表、root_tool_policy 为根 Agent 工具收敛的现场记录(preset_id / outcome / denied / failed,排查"主 Agent 为什么看得见本该收敛掉的工具"用)。数据源注册不依赖 key:api_key.present=false 时同花顺能力仍在目录里,但每次取数会点名 FUYAO_API_KEY 失败。排障时优先调用。', jsonObject(), jsonObject({
172
+ at: { type: 'integer' },
173
+ call: { type: 'integer' },
174
+ api_key: jsonObject({ present: { type: 'boolean' }, source: { oneOf: [{ type: 'string' }, { type: 'null' }] }, error: { oneOf: [{ type: 'string' }, { type: 'null' }] } }, ['present']),
175
+ registered_capabilities: { type: 'array', items: { type: 'string' } },
176
+ root_tool_policy: { type: 'array', items: jsonObject({
177
+ agent_id: { oneOf: [{ type: 'string' }, { type: 'null' }] },
178
+ root: { type: 'boolean' },
179
+ preset_id: { type: 'string' },
180
+ outcome: { type: 'string' },
181
+ denied: { type: 'array', items: { type: 'string' } },
182
+ failed: { type: 'array', items: { type: 'string' } },
183
+ }, ['agent_id', 'root', 'preset_id', 'outcome', 'denied', 'failed']) },
184
+ }, ['at', 'call', 'api_key', 'registered_capabilities']), async (_args, exec) => {
185
+ delegatedSession(exec, 'dc_status');
186
+ const apiKey = await diagnostics.probeApiKey();
187
+ const capabilities = hub.capabilityNames();
188
+ const rootPolicy = diagnostics.rootPolicy?.()?.map((probe) => ({
189
+ agent_id: probe.agentId ?? null,
190
+ root: probe.root,
191
+ preset_id: probe.presetId,
192
+ outcome: probe.outcome,
193
+ denied: probe.denied,
194
+ failed: probe.failed,
195
+ }));
196
+ const snapshot = { at: Date.now(), call: ++dcStatusCalls.current, apiKey, capabilities };
197
+ diagnostics.onCall?.(snapshot);
198
+ return {
199
+ at: snapshot.at,
200
+ call: snapshot.call,
201
+ api_key: apiKey,
202
+ registered_capabilities: capabilities,
203
+ ...(rootPolicy === undefined ? {} : { root_tool_policy: rootPolicy }),
204
+ };
205
+ }),
206
+ ] : []),
207
+ ];
208
+ for (const definition of registrations)
209
+ ctx.effect(() => tools.register(definition), `capital-generation.tool(${definition.name})`);
210
+ }
211
+ /** 供测试与宿主侧断言复用:模型可见的 DatasetRef 字段白名单。 */
212
+ export const DATASET_REF_FIELDS = [
213
+ 'dataset_id', 'task_id', 'session_id', 'artifact_ref', 'format',
214
+ 'capability', 'source_label', 'schema', 'row_count', 'captured_at',
215
+ 'retention_until', 'params_digest',
216
+ ];
package/lib/index.d.ts ADDED
@@ -0,0 +1,275 @@
1
+ import { Context } from '@deepseek-ai/cordis';
2
+ import z from '@deepseek-ai/schemastery';
3
+ /** Internal plugin name used by the Capital mode preset. */
4
+ export declare const name = "capital-generation";
5
+ /**
6
+ * 取数配置所在的 **profile 条目 id**(随包的 `capital-config` 行)。0.1.7 的 settings 面
7
+ * 以条目 id 为命名空间,本插件经 `settings.describe()` 按它读回用户配的引用名与开关。
8
+ *
9
+ * 这个字符串有三处必须一致:`cordis.patch.yml` 的行 id、`capital-config/index.js` 的
10
+ * `SETTINGS_ENTRY_ID`、以及浏览器半边 `client.src.cjs` 的 `ENTRY_ID`;由
11
+ * `test/capital-config.test.mjs` 逐一对齐(漂移的表现为卡片静默消失)。
12
+ */
13
+ export declare const CAPITAL_CONFIG_ENTRY_ID = "capital-config";
14
+ /** Wind 文档检索配置:JSON-RPC 端点与凭据名(线格式为 MCP 线协议,零依赖适配)。 */
15
+ export interface WindDocsConfig {
16
+ endpoint?: string;
17
+ credentialRef?: string;
18
+ timeoutMs?: number;
19
+ }
20
+ /** 本地直连回退配置(AnySearch 明确失败后改由本机直连抓取公开文本页面)。 */
21
+ export interface LocalFetchConfig {
22
+ enabled?: boolean;
23
+ timeoutMs?: number;
24
+ maxBytes?: number;
25
+ maxContentChars?: number;
26
+ maxRedirects?: number;
27
+ userAgent?: string;
28
+ }
29
+ /**
30
+ * PaddleOCR 文档解析(`ocr` 工具)配置。
31
+ *
32
+ * `endpoint` / `model` 空值 = 用 `src/ocr/client.ts` 里的官方端点与模型名(真值只在那一处,
33
+ * 与 `windDocs.endpoint` 同一口径)。`pollBudgetMs` 是**工具内部**等作业的自有预算,
34
+ * 必须小于工具声明的 `timeoutMs: 240000`——余量留给"决定回 pending 之后把回执写出去",
35
+ * 撞上框架超时就没有 `doc_id` 可续查了。
36
+ */
37
+ export interface PaddleOcrConfig {
38
+ endpoint?: string;
39
+ credentialRef?: string;
40
+ model?: string;
41
+ pollBudgetMs?: number;
42
+ }
43
+ /** web_retriever 会话配置:anysearch(广度)+ wind_docs(public_document 精准)+ 文档解析。 */
44
+ export interface RetrieverConfig {
45
+ baseURL?: string;
46
+ credentialRef?: string;
47
+ windDocs?: WindDocsConfig;
48
+ localFetch?: LocalFetchConfig;
49
+ paddleOcr?: PaddleOcrConfig;
50
+ }
51
+ /**
52
+ * 本地直连回退的默认值(唯一真值来源):schema 的 `.default()` 与消费点
53
+ * `resolveLocalFetchConfig()` 都引用它,两处不再各写一份字面量。
54
+ *
55
+ * 数值口径对齐官方 `dsh-web-fetch-http`(DSH 自己的同类本机抓取器):
56
+ * - `timeoutMs` = 30000(官方默认)。2026-09 实测:环境代理的故障转移慢路径约
57
+ * 15.2–15.4s,15s 预算会把证券业协会官网这类站点误判成 TIMEOUT。
58
+ * - `maxContentChars` = 100000(官方 `maxBodyChars` 默认值)。注意它切的是**转换前的
59
+ * 原始 HTML**(见 `html-markdown.ts`),而 markdown 输出只有 HTML 的 12–33%,
60
+ * 所以这个数必须按 HTML 体积给足;20,000 会把 109KB 的页面腰斩到 18%。
61
+ *
62
+ * `userAgent` 默认是产品标识(`@v587d/capital-generation`):裸版本号是
63
+ * WAF 眼里的典型爬虫特征。显式配成空串时消费点回落到 `LOCAL_FETCH_CLIENT_VERSION`
64
+ * (版本号真值仍只有一处,由测试守着等于 `package.json` 的 version)。
65
+ */
66
+ export declare const LOCAL_FETCH_DEFAULTS: Required<LocalFetchConfig>;
67
+ /**
68
+ * `ocr`(PaddleOCR 文档解析)配置的默认值:与 `LOCAL_FETCH_DEFAULTS` 同一口径,
69
+ * schema 的 `.default()` 与消费点都引用它,字面量只有一处。
70
+ *
71
+ * `endpoint` / `model` 留空是把真值让给 `src/ocr/client.ts`(那边还有 `PADDLE_OCR_MAX_PAGES`
72
+ * 这类跟着端点走的常数);`pollBudgetMs: 0` 同理让给客户端的 `DEFAULT_WAIT_BUDGET_MS`。
73
+ */
74
+ export declare const PADDLE_OCR_DEFAULTS: Required<PaddleOcrConfig>;
75
+ /**
76
+ * 消费点独立补齐默认值。`apply()` 在无 settings 的宿主/测试里拿到的是**未过 schema**
77
+ * 的原始对象,`retriever.localFetch` 可能是 `undefined`,因此消费点不能依赖 schema 补默认值。
78
+ */
79
+ export declare function resolveLocalFetchConfig(config?: LocalFetchConfig): Required<LocalFetchConfig>;
80
+ /** Configuration accepted by the Capital Generation plugin. */
81
+ export interface Config {
82
+ /** Optional additive persona override; core safety guidance is preserved. */
83
+ customPersona?: string;
84
+ /** Fuyao credentials 引用名;空值回退到 FUYAO_API_KEY。 */
85
+ fuyaoCredentialRef?: string;
86
+ /** web_retriever 配置(可选;缺省使用 AnySearch 默认地址与凭据名)。 */
87
+ retriever?: RetrieverConfig;
88
+ }
89
+ /** DSH 0.1.2-rc.1 configuration schema. */
90
+ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
91
+ customPersona: z<string, string, "defined">;
92
+ fuyaoCredentialRef: z<string, string, "defined">;
93
+ retriever: z<Schemastery.ObjectS<NoInfer<{
94
+ baseURL: z<string, string, "defined">;
95
+ credentialRef: z<string, string, "defined">;
96
+ windDocs: z<Schemastery.ObjectS<NoInfer<{
97
+ endpoint: z<string, string, "defined">;
98
+ credentialRef: z<string, string, "defined">;
99
+ timeoutMs: z<number, number, "defined">;
100
+ }>>, Schemastery.ObjectT<NoInfer<{
101
+ endpoint: z<string, string, "defined">;
102
+ credentialRef: z<string, string, "defined">;
103
+ timeoutMs: z<number, number, "defined">;
104
+ }>>, "defined">;
105
+ localFetch: z<Schemastery.ObjectS<NoInfer<{
106
+ enabled: z<boolean, boolean, "defined">;
107
+ timeoutMs: z<number, number, "defined">;
108
+ maxBytes: z<number, number, "defined">;
109
+ maxContentChars: z<number, number, "defined">;
110
+ maxRedirects: z<number, number, "defined">;
111
+ userAgent: z<string, string, "defined">;
112
+ }>>, Schemastery.ObjectT<NoInfer<{
113
+ enabled: z<boolean, boolean, "defined">;
114
+ timeoutMs: z<number, number, "defined">;
115
+ maxBytes: z<number, number, "defined">;
116
+ maxContentChars: z<number, number, "defined">;
117
+ maxRedirects: z<number, number, "defined">;
118
+ userAgent: z<string, string, "defined">;
119
+ }>>, "defined">;
120
+ paddleOcr: z<Schemastery.ObjectS<NoInfer<{
121
+ endpoint: z<string, string, "defined">;
122
+ credentialRef: z<string, string, "defined">;
123
+ model: z<string, string, "defined">;
124
+ pollBudgetMs: z<number, number, "defined">;
125
+ }>>, Schemastery.ObjectT<NoInfer<{
126
+ endpoint: z<string, string, "defined">;
127
+ credentialRef: z<string, string, "defined">;
128
+ model: z<string, string, "defined">;
129
+ pollBudgetMs: z<number, number, "defined">;
130
+ }>>, "defined">;
131
+ }>>, Schemastery.ObjectT<NoInfer<{
132
+ baseURL: z<string, string, "defined">;
133
+ credentialRef: z<string, string, "defined">;
134
+ windDocs: z<Schemastery.ObjectS<NoInfer<{
135
+ endpoint: z<string, string, "defined">;
136
+ credentialRef: z<string, string, "defined">;
137
+ timeoutMs: z<number, number, "defined">;
138
+ }>>, Schemastery.ObjectT<NoInfer<{
139
+ endpoint: z<string, string, "defined">;
140
+ credentialRef: z<string, string, "defined">;
141
+ timeoutMs: z<number, number, "defined">;
142
+ }>>, "defined">;
143
+ localFetch: z<Schemastery.ObjectS<NoInfer<{
144
+ enabled: z<boolean, boolean, "defined">;
145
+ timeoutMs: z<number, number, "defined">;
146
+ maxBytes: z<number, number, "defined">;
147
+ maxContentChars: z<number, number, "defined">;
148
+ maxRedirects: z<number, number, "defined">;
149
+ userAgent: z<string, string, "defined">;
150
+ }>>, Schemastery.ObjectT<NoInfer<{
151
+ enabled: z<boolean, boolean, "defined">;
152
+ timeoutMs: z<number, number, "defined">;
153
+ maxBytes: z<number, number, "defined">;
154
+ maxContentChars: z<number, number, "defined">;
155
+ maxRedirects: z<number, number, "defined">;
156
+ userAgent: z<string, string, "defined">;
157
+ }>>, "defined">;
158
+ paddleOcr: z<Schemastery.ObjectS<NoInfer<{
159
+ endpoint: z<string, string, "defined">;
160
+ credentialRef: z<string, string, "defined">;
161
+ model: z<string, string, "defined">;
162
+ pollBudgetMs: z<number, number, "defined">;
163
+ }>>, Schemastery.ObjectT<NoInfer<{
164
+ endpoint: z<string, string, "defined">;
165
+ credentialRef: z<string, string, "defined">;
166
+ model: z<string, string, "defined">;
167
+ pollBudgetMs: z<number, number, "defined">;
168
+ }>>, "defined">;
169
+ }>>, "defined">;
170
+ }>>, Schemastery.ObjectT<NoInfer<{
171
+ customPersona: z<string, string, "defined">;
172
+ fuyaoCredentialRef: z<string, string, "defined">;
173
+ retriever: z<Schemastery.ObjectS<NoInfer<{
174
+ baseURL: z<string, string, "defined">;
175
+ credentialRef: z<string, string, "defined">;
176
+ windDocs: z<Schemastery.ObjectS<NoInfer<{
177
+ endpoint: z<string, string, "defined">;
178
+ credentialRef: z<string, string, "defined">;
179
+ timeoutMs: z<number, number, "defined">;
180
+ }>>, Schemastery.ObjectT<NoInfer<{
181
+ endpoint: z<string, string, "defined">;
182
+ credentialRef: z<string, string, "defined">;
183
+ timeoutMs: z<number, number, "defined">;
184
+ }>>, "defined">;
185
+ localFetch: z<Schemastery.ObjectS<NoInfer<{
186
+ enabled: z<boolean, boolean, "defined">;
187
+ timeoutMs: z<number, number, "defined">;
188
+ maxBytes: z<number, number, "defined">;
189
+ maxContentChars: z<number, number, "defined">;
190
+ maxRedirects: z<number, number, "defined">;
191
+ userAgent: z<string, string, "defined">;
192
+ }>>, Schemastery.ObjectT<NoInfer<{
193
+ enabled: z<boolean, boolean, "defined">;
194
+ timeoutMs: z<number, number, "defined">;
195
+ maxBytes: z<number, number, "defined">;
196
+ maxContentChars: z<number, number, "defined">;
197
+ maxRedirects: z<number, number, "defined">;
198
+ userAgent: z<string, string, "defined">;
199
+ }>>, "defined">;
200
+ paddleOcr: z<Schemastery.ObjectS<NoInfer<{
201
+ endpoint: z<string, string, "defined">;
202
+ credentialRef: z<string, string, "defined">;
203
+ model: z<string, string, "defined">;
204
+ pollBudgetMs: z<number, number, "defined">;
205
+ }>>, Schemastery.ObjectT<NoInfer<{
206
+ endpoint: z<string, string, "defined">;
207
+ credentialRef: z<string, string, "defined">;
208
+ model: z<string, string, "defined">;
209
+ pollBudgetMs: z<number, number, "defined">;
210
+ }>>, "defined">;
211
+ }>>, Schemastery.ObjectT<NoInfer<{
212
+ baseURL: z<string, string, "defined">;
213
+ credentialRef: z<string, string, "defined">;
214
+ windDocs: z<Schemastery.ObjectS<NoInfer<{
215
+ endpoint: z<string, string, "defined">;
216
+ credentialRef: z<string, string, "defined">;
217
+ timeoutMs: z<number, number, "defined">;
218
+ }>>, Schemastery.ObjectT<NoInfer<{
219
+ endpoint: z<string, string, "defined">;
220
+ credentialRef: z<string, string, "defined">;
221
+ timeoutMs: z<number, number, "defined">;
222
+ }>>, "defined">;
223
+ localFetch: z<Schemastery.ObjectS<NoInfer<{
224
+ enabled: z<boolean, boolean, "defined">;
225
+ timeoutMs: z<number, number, "defined">;
226
+ maxBytes: z<number, number, "defined">;
227
+ maxContentChars: z<number, number, "defined">;
228
+ maxRedirects: z<number, number, "defined">;
229
+ userAgent: z<string, string, "defined">;
230
+ }>>, Schemastery.ObjectT<NoInfer<{
231
+ enabled: z<boolean, boolean, "defined">;
232
+ timeoutMs: z<number, number, "defined">;
233
+ maxBytes: z<number, number, "defined">;
234
+ maxContentChars: z<number, number, "defined">;
235
+ maxRedirects: z<number, number, "defined">;
236
+ userAgent: z<string, string, "defined">;
237
+ }>>, "defined">;
238
+ paddleOcr: z<Schemastery.ObjectS<NoInfer<{
239
+ endpoint: z<string, string, "defined">;
240
+ credentialRef: z<string, string, "defined">;
241
+ model: z<string, string, "defined">;
242
+ pollBudgetMs: z<number, number, "defined">;
243
+ }>>, Schemastery.ObjectT<NoInfer<{
244
+ endpoint: z<string, string, "defined">;
245
+ credentialRef: z<string, string, "defined">;
246
+ model: z<string, string, "defined">;
247
+ pollBudgetMs: z<number, number, "defined">;
248
+ }>>, "defined">;
249
+ }>>, "defined">;
250
+ }>>, "plain">;
251
+ /**
252
+ * 把可选的用户人设文本转成独立 system-prompt section(官方 systemPrompt
253
+ * registry 的注册对象)。空白输入返回 undefined(不注册);超长抛错;
254
+ * 追加不可覆盖的安全提醒。只影响表达风格与呈现。
255
+ */
256
+ export declare function resolveUserCustomizationSection(customPersona?: string): {
257
+ name: string;
258
+ order: number;
259
+ text: string;
260
+ } | undefined;
261
+ /** The system-prompt service is a hard dependency for the optional section. */
262
+ export declare const inject: string[];
263
+ /**
264
+ * Register the Capital mode data services and tools.
265
+ *
266
+ * 人设文本全部由 preset 组合承载(dsh-persona 行 + 两个委派行 config.persona),
267
+ * 不在插件代码中。本包只装配服务与工具:
268
+ * - datasetStore(workspace-local Dataset 持久化,7 天保留,权限失败显式报错)
269
+ * - dataCollectorHub(阻塞 FIFO + in-flight 合并,成功后由 store 立即落盘,
270
+ * 只回传 DatasetRef,不保留长期 raw 缓存)
271
+ * - 无状态 AnySearch 网页检索(单查询 search + 单 URL fetch)
272
+ * - 无状态 Wind 文档检索客户端(public_document:公告/年报/招股书与权威新闻)
273
+ * - 各自的模型工具;时间工具。
274
+ */
275
+ export declare function apply(ctx: Context, config: Config): void;