@v587d/capital-generation 2.23.0 → 2.25.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 (63) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +9 -4
  3. package/THIRD_PARTY_NOTICES.md +20 -0
  4. package/automation/package.json +1 -1
  5. package/chart-ui/package.json +1 -1
  6. package/config/client.js +21 -5
  7. package/config/client.src.cjs +264 -0
  8. package/config/package.json +1 -1
  9. package/cordis.patch.yml +9 -2
  10. package/lib/agents/role-tool-policy.d.ts +1 -1
  11. package/lib/agents/root-tool-policy.d.ts +3 -3
  12. package/lib/agents/root-tool-policy.js +2 -2
  13. package/lib/data-collector/catalog-taxonomy.d.ts +16 -0
  14. package/lib/data-collector/catalog-taxonomy.js +179 -0
  15. package/lib/data-collector/hub.d.ts +16 -3
  16. package/lib/data-collector/hub.js +40 -6
  17. package/lib/data-collector/tools.js +46 -8
  18. package/lib/python-runtime/child-env.d.ts +11 -0
  19. package/lib/python-runtime/child-env.js +39 -0
  20. package/lib/python-runtime/errors.d.ts +8 -0
  21. package/lib/python-runtime/errors.js +34 -0
  22. package/lib/python-runtime/lock.d.ts +11 -0
  23. package/lib/python-runtime/lock.js +68 -0
  24. package/lib/python-runtime/manager.d.ts +61 -0
  25. package/lib/python-runtime/manager.js +517 -0
  26. package/lib/python-runtime/manifest.d.ts +5 -0
  27. package/lib/python-runtime/manifest.js +160 -0
  28. package/lib/python-runtime/paths.d.ts +20 -0
  29. package/lib/python-runtime/paths.js +156 -0
  30. package/lib/python-runtime/platform.d.ts +32 -0
  31. package/lib/python-runtime/platform.js +145 -0
  32. package/lib/python-runtime/pnpm.d.ts +24 -0
  33. package/lib/python-runtime/pnpm.js +115 -0
  34. package/lib/python-runtime/probe.d.ts +13 -0
  35. package/lib/python-runtime/probe.js +101 -0
  36. package/lib/python-runtime/routes.d.ts +6 -0
  37. package/lib/python-runtime/routes.js +152 -0
  38. package/lib/python-runtime/types.d.ts +105 -0
  39. package/lib/python-runtime/types.js +3 -0
  40. package/lib/python-runtime-entry.d.ts +10 -0
  41. package/lib/python-runtime-entry.js +60 -0
  42. package/lib/sources/eastmoney-http.js +346 -1
  43. package/lib/sources/tencent-http.js +248 -2
  44. package/lib/sources/tencent-public-core.js +1 -1
  45. package/lib/sources-entry.d.ts +1 -1
  46. package/lib/time/tools.js +2 -0
  47. package/lib/web-retriever/local-fetch.d.ts +1 -1
  48. package/lib/web-retriever/local-fetch.js +1 -1
  49. package/lib/web-retriever/sources.d.ts +16 -1
  50. package/lib/web-retriever/sources.js +133 -1
  51. package/lib/web-retriever/tools.js +41 -1
  52. package/lib/web-retriever/wind-client.d.ts +1 -1
  53. package/lib/web-retriever/wind-client.js +1 -1
  54. package/package.json +13 -1
  55. package/plugin-page/README.en.md +1 -7
  56. package/plugin-page/README.zh.md +1 -8
  57. package/preset/capital-generation/agent.patch.yml +12 -13
  58. package/preset/capital-generation/skills/capital-data-protocol/SKILL.md +21 -22
  59. package/preset/capital-generation/skills/capital-web-protocol/SKILL.md +10 -4
  60. package/python/worker.py +154 -0
  61. package/runtime/manifest.json +75 -0
  62. package/scripts/python-runtime.mjs +139 -0
  63. package/watchlist/package.json +1 -1
@@ -59,6 +59,8 @@ const SKILL_DOC_ROUTE = '/capital-skills'
59
59
  /** Automation host routes; same auth plane as the workspace dropdown. */
60
60
  const STORAGE_ROUTE = '/capital-automation/storage'
61
61
  const STORAGE_CLEAR_ROUTE = '/capital-automation/storage/clear'
62
+ /** Host-plane python-runtime row; status is read-only until the user clicks prepare. */
63
+ const PYTHON_RUNTIME_ROUTE = '/python-runtime'
62
64
  const DOC_URLS = {
63
65
  fuyao: 'https://fuyao.aicubes.cn/docs/',
64
66
  ftshare: 'https://market.ft.tech/gateway/doc/p/pb8eizu3',
@@ -117,6 +119,33 @@ const zh = {
117
119
  titleUnsaved: '数据源 未保存',
118
120
  componentsTitle: '包含的组件',
119
121
  componentsHint: '组件清单由 DSH 绘制,显示在下方。',
122
+ pythonTitle: '分析环境',
123
+ pythonLoading: '读取分析环境…',
124
+ pythonHint: 'Python 运行时由本插件独立管理,不修改系统 Python,也不使用 DSH 桌面端运行时。首次准备需要联网下载约 55–60 MB,安装后可离线使用。',
125
+ pythonNotInstalled: '尚未准备',
126
+ pythonReady: '已就绪',
127
+ pythonBroken: '需要修复',
128
+ pythonInstalling: '准备中…',
129
+ pythonUnsupported: '当前平台不支持:{reason}',
130
+ pythonBase: '基础环境',
131
+ pythonParquet: 'Parquet 支持',
132
+ pythonPrepare: '准备分析环境',
133
+ pythonInstallParquet: '安装 Parquet 支持',
134
+ pythonRepair: '修复分析环境',
135
+ pythonCancel: '取消',
136
+ pythonVerify: '重新检测',
137
+ pythonVerifyOk: '自检通过。',
138
+ pythonRemove: '移除',
139
+ pythonRemoveConfirm: '移除后需要重新下载,确定移除?',
140
+ pythonRemoveYes: '确定移除',
141
+ pythonNotInstalledShort: '未安装',
142
+ pythonVersions: 'Python {python} · numpy {numpy} · pandas {pandas}',
143
+ pythonPath: '位置:{path}',
144
+ pythonParquetHint: '全市场 Parquet 数据需要 pyarrow;额外约 50 MB 下载、155 MB 磁盘。',
145
+ pythonLoadFailed: '读取分析环境状态失败;稍后重试。',
146
+ pythonPrepareFailed: '准备失败:{message}',
147
+ pythonJob: '{stage}:{message}',
148
+ pythonParquetReady: 'Parquet 支持已就绪。',
120
149
  fuyaoLabel: 'Fuyao API Key',
121
150
  fuyaoHint: '同花顺 Fuyao 结构化数据接口。保存后新自动模式会话生效。',
122
151
  ftshareLabel: 'FTShare API Key',
@@ -219,6 +248,33 @@ const en = {
219
248
  titleUnsaved: 'Data Sources unsaved',
220
249
  componentsTitle: 'Components',
221
250
  componentsHint: 'The component list is drawn by DSH and appears below.',
251
+ pythonTitle: 'Analysis environment',
252
+ pythonLoading: 'Reading the analysis environment…',
253
+ pythonHint: 'The Python runtime is private to this plugin. It does not modify system Python or use the DSH Desktop runtime. The first prepare downloads about 55–60 MB; after that it works offline.',
254
+ pythonNotInstalled: 'Not prepared',
255
+ pythonReady: 'Ready',
256
+ pythonBroken: 'Repair needed',
257
+ pythonInstalling: 'Preparing…',
258
+ pythonUnsupported: 'This platform is not supported: {reason}',
259
+ pythonBase: 'Base environment',
260
+ pythonParquet: 'Parquet support',
261
+ pythonPrepare: 'Prepare analysis environment',
262
+ pythonInstallParquet: 'Install Parquet support',
263
+ pythonRepair: 'Repair analysis environment',
264
+ pythonCancel: 'Cancel',
265
+ pythonVerify: 'Re-check',
266
+ pythonVerifyOk: 'Self-check passed.',
267
+ pythonRemove: 'Remove',
268
+ pythonRemoveConfirm: 'Removing means downloading it again. Remove?',
269
+ pythonRemoveYes: 'Remove',
270
+ pythonNotInstalledShort: 'Not installed',
271
+ pythonVersions: 'Python {python} · numpy {numpy} · pandas {pandas}',
272
+ pythonPath: 'Location: {path}',
273
+ pythonParquetHint: 'Market-wide Parquet data needs pyarrow; about 50 MB download and 155 MB on disk.',
274
+ pythonLoadFailed: 'Could not read the analysis environment state; try again shortly.',
275
+ pythonPrepareFailed: 'Prepare failed: {message}',
276
+ pythonJob: '{stage}: {message}',
277
+ pythonParquetReady: 'Parquet support is ready.',
222
278
  fuyaoLabel: 'Fuyao API Key',
223
279
  fuyaoHint: 'Tonghuashun Fuyao structured-data API. Takes effect in new Auto mode sessions.',
224
280
  ftshareLabel: 'FTShare API Key',
@@ -339,6 +395,7 @@ function installStyles() {
339
395
  [data-plugin-detail="${BUNDLE_NAME}"]:has(.capital-config-card[data-capital-config-tab="sources"]) section[data-plugin-rows] { display: none; }
340
396
  [data-plugin-detail="${BUNDLE_NAME}"]:has(.capital-config-card[data-capital-config-tab="automation"]) section[data-plugin-rows] { display: none; }
341
397
  [data-plugin-detail="${BUNDLE_NAME}"]:has(.capital-config-card[data-capital-config-tab="skills"]) section[data-plugin-rows] { display: none; }
398
+ [data-plugin-detail="${BUNDLE_NAME}"]:has(.capital-config-card[data-capital-config-tab="analysis"]) section[data-plugin-rows] { display: none; }
342
399
  /* Internal roles must stay declared for delegation; hide their user-selectable cards in Settings. */
343
400
  [data-agent-preset-id="capital-data-junior"],
344
401
  [data-agent-preset-id="capital-visualization-specialist"] { display: none !important; }
@@ -379,6 +436,21 @@ function installStyles() {
379
436
  .capital-config-cache-button[data-variant="danger"]:hover:not(:disabled) { background: var(--dsw-alias-state-error-primary); color: var(--dsw-alias-bg-base); }
380
437
  .capital-config-cache-button:focus-visible { outline: var(--dsw-focus-ring-width, 2px) solid var(--dsw-focus-ring-color, var(--dsw-alias-brand-primary)); outline-offset: 0; }
381
438
  .capital-config-cache-button:disabled { opacity: .5; cursor: not-allowed; }
439
+ .capital-config-runtime { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }
440
+ .capital-config-runtime-head { display: flex; flex-direction: column; gap: 4px; }
441
+ .capital-config-runtime-title { display: flex; align-items: center; gap: 8px; color: var(--dsw-alias-label-primary); font-size: 13px; font-weight: 500; line-height: 20px; }
442
+ .capital-config-runtime-state { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; background: var(--dsw-alias-bg-module-platform); color: var(--dsw-alias-label-secondary); font-size: 11px; font-weight: 500; line-height: 16px; }
443
+ .capital-config-runtime-state[data-tone="ready"] { background: var(--dsw-alias-state-success-tertiary); color: var(--dsw-alias-state-success-primary); }
444
+ .capital-config-runtime-state[data-tone="warn"] { background: var(--dsw-alias-state-warn-tertiary); color: var(--dsw-alias-state-warn-primary); }
445
+ .capital-config-runtime-state[data-tone="error"] { background: var(--dsw-alias-state-error-tertiary); color: var(--dsw-alias-state-error-primary); }
446
+ .capital-config-runtime-copy { margin: 0; color: var(--dsw-alias-label-tertiary); font-size: 12px; line-height: 18px; }
447
+ .capital-config-runtime-card { display: flex; flex-direction: column; gap: 8px; padding: 10px 14px; border: .5px solid var(--dsw-alias-border-l1); border-radius: 10px; background: var(--dsw-alias-bg-layer-2); }
448
+ .capital-config-runtime-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-width: 0; }
449
+ .capital-config-runtime-label { color: var(--dsw-alias-label-secondary); font-size: 12.5px; line-height: 20px; }
450
+ .capital-config-runtime-meta { color: var(--dsw-alias-label-tertiary); font-size: 11.5px; line-height: 17px; overflow-wrap: anywhere; }
451
+ .capital-config-runtime-actions { display: flex; flex-wrap: wrap; gap: 8px; }
452
+ .capital-config-runtime-notice { margin: 0; color: var(--dsw-alias-state-success-primary); font-size: 12px; line-height: 18px; }
453
+ .capital-config-runtime-error { margin: 0; color: var(--dsw-alias-state-error-primary); font-size: 12px; line-height: 18px; }
382
454
  div.capital-config-cache-modal { width: min(480px, 100%); }
383
455
  .capital-config-cache-modal-content { min-height: 0; overflow: auto; }
384
456
  .capital-config-cache-modal-body { margin: 0; color: var(--dsw-alias-label-secondary); font-size: 12.5px; line-height: 20px; }
@@ -1213,6 +1285,196 @@ function ClearCacheModal({ open, bytes, displayPath, clearing, error, onCancel,
1213
1285
  errorText ? h('p', { role: 'alert', className: 'capital-config-write-failed' }, errorText) : null)
1214
1286
  }
1215
1287
 
1288
+ function PythonRuntimeSection({ t }) {
1289
+ const [status, setStatus] = useState(null)
1290
+ const [job, setJob] = useState(null)
1291
+ const [error, setError] = useState('')
1292
+ const [notice, setNotice] = useState('')
1293
+ const [removePack, setRemovePack] = useState('')
1294
+ const [busy, setBusy] = useState(false)
1295
+
1296
+ const load = async () => {
1297
+ try {
1298
+ const response = await fetch(`${PYTHON_RUNTIME_ROUTE}/status`, { method: 'GET', cache: 'no-store', credentials: 'same-origin' })
1299
+ const data = await response.json().catch(() => ({}))
1300
+ if (!response.ok) throw new Error(data?.error?.message || t('pythonLoadFailed'))
1301
+ setStatus(data)
1302
+ if (data.activeJob?.state === 'running') setJob(data.activeJob)
1303
+ setError('')
1304
+ } catch (failure) {
1305
+ setError(failure instanceof Error ? failure.message : t('pythonLoadFailed'))
1306
+ }
1307
+ }
1308
+
1309
+ useEffect(() => { load() }, [])
1310
+ useEffect(() => {
1311
+ if (job === null || job.state !== 'running') return undefined
1312
+ let cancelled = false
1313
+ const timer = setInterval(async () => {
1314
+ try {
1315
+ const response = await fetch(`${PYTHON_RUNTIME_ROUTE}/jobs/${encodeURIComponent(job.id)}`, { method: 'GET', cache: 'no-store', credentials: 'same-origin' })
1316
+ const data = await response.json().catch(() => ({}))
1317
+ if (cancelled || !response.ok || !data.job) return
1318
+ setJob(data.job)
1319
+ if (data.job.state !== 'running') {
1320
+ setJob(null)
1321
+ await load()
1322
+ }
1323
+ } catch {
1324
+ // Status polling is best-effort; the next tick retries.
1325
+ }
1326
+ }, 800)
1327
+ return () => { cancelled = true; clearInterval(timer) }
1328
+ }, [job?.id, job?.state])
1329
+
1330
+ const post = async (suffix, body) => {
1331
+ const response = await fetch(`${PYTHON_RUNTIME_ROUTE}${suffix}`, {
1332
+ method: 'POST',
1333
+ cache: 'no-store',
1334
+ credentials: 'same-origin',
1335
+ headers: { 'content-type': 'application/json' },
1336
+ body: JSON.stringify(body),
1337
+ })
1338
+ const data = await response.json().catch(() => ({}))
1339
+ if (!response.ok) throw new Error(data?.error?.message || t('pythonLoadFailed'))
1340
+ return data
1341
+ }
1342
+
1343
+ const prepare = async (packs) => {
1344
+ setBusy(true); setError(''); setNotice('')
1345
+ try {
1346
+ const data = await post('/prepare', { packs })
1347
+ if (data.job) setJob(data.job)
1348
+ } catch (failure) {
1349
+ setError(t('pythonPrepareFailed', { message: failure instanceof Error ? failure.message : String(failure) }))
1350
+ } finally {
1351
+ setBusy(false)
1352
+ }
1353
+ }
1354
+
1355
+ const cancel = async () => {
1356
+ if (job === null) return
1357
+ try {
1358
+ await post('/cancel', { jobId: job.id })
1359
+ } catch (failure) {
1360
+ setError(failure instanceof Error ? failure.message : String(failure))
1361
+ }
1362
+ }
1363
+
1364
+ const verify = async () => {
1365
+ setBusy(true); setError(''); setNotice('')
1366
+ try {
1367
+ await post('/verify', {})
1368
+ setNotice(t('pythonVerifyOk'))
1369
+ await load()
1370
+ } catch (failure) {
1371
+ setError(failure instanceof Error ? failure.message : String(failure))
1372
+ } finally {
1373
+ setBusy(false)
1374
+ }
1375
+ }
1376
+
1377
+ const remove = async (pack) => {
1378
+ setBusy(true); setError(''); setNotice('')
1379
+ try {
1380
+ if (pack === 'base' && status?.parquet?.state === 'ready') await post('/remove', { pack: 'parquet', confirm: true })
1381
+ await post('/remove', { pack, confirm: true })
1382
+ setRemovePack('')
1383
+ await load()
1384
+ } catch (failure) {
1385
+ setError(failure instanceof Error ? failure.message : String(failure))
1386
+ } finally {
1387
+ setBusy(false)
1388
+ }
1389
+ }
1390
+
1391
+ if (status === null) {
1392
+ return h('section', { className: 'capital-config-runtime' },
1393
+ h('p', { className: 'capital-config-runtime-copy' }, error === '' ? t('pythonLoading') : error))
1394
+ }
1395
+
1396
+ const supported = status.supported !== false
1397
+ const baseState = status.base?.state ?? 'not-installed'
1398
+ const parquetState = status.parquet?.state ?? 'not-installed'
1399
+ const baseReady = baseState === 'ready'
1400
+ const parquetReady = parquetState === 'ready'
1401
+ const baseTone = baseState === 'ready' ? 'ready' : baseState === 'broken' ? 'error' : baseState === 'installing' ? 'warn' : undefined
1402
+ const baseLabel = baseState === 'ready' ? t('pythonReady')
1403
+ : baseState === 'broken' ? t('pythonBroken')
1404
+ : baseState === 'installing' ? t('pythonInstalling') : t('pythonNotInstalled')
1405
+ const parquetLabel = parquetState === 'ready' ? t('pythonReady')
1406
+ : parquetState === 'broken' ? t('pythonBroken')
1407
+ : parquetState === 'installing' ? t('pythonInstalling') : t('pythonNotInstalledShort')
1408
+
1409
+ const button = (label, onClick, options = {}) => h('button', {
1410
+ type: 'button',
1411
+ className: 'capital-config-cache-button',
1412
+ disabled: busy || options.disabled === true,
1413
+ ...(options.danger === true ? { 'data-variant': 'danger' } : {}),
1414
+ onClick,
1415
+ }, label)
1416
+
1417
+ return h('section', { className: 'capital-config-runtime' },
1418
+ h('div', { className: 'capital-config-runtime-head' },
1419
+ h('div', { className: 'capital-config-runtime-title' },
1420
+ t('pythonTitle'),
1421
+ h('span', { className: 'capital-config-runtime-state', 'data-tone': baseTone }, baseLabel),
1422
+ ),
1423
+ h('p', { className: 'capital-config-runtime-copy' }, t('pythonHint')),
1424
+ ),
1425
+ supported ? null : h('p', { className: 'capital-config-runtime-error' }, t('pythonUnsupported', { reason: status.reason ?? '' })),
1426
+ h('div', { className: 'capital-config-runtime-card' },
1427
+ h('div', { className: 'capital-config-runtime-row' },
1428
+ h('span', { className: 'capital-config-runtime-label' }, t('pythonBase')),
1429
+ h('span', { className: 'capital-config-runtime-state', 'data-tone': baseTone }, baseLabel),
1430
+ ),
1431
+ baseReady
1432
+ ? h('p', { className: 'capital-config-runtime-copy' }, t('pythonVersions', {
1433
+ python: status.python,
1434
+ numpy: status.base?.packages?.numpy ?? '—',
1435
+ pandas: status.base?.packages?.pandas ?? '—',
1436
+ }))
1437
+ : h('p', { className: 'capital-config-runtime-copy' }, t('pythonPath', { path: status.cacheRoot })),
1438
+ h('div', { className: 'capital-config-runtime-actions' },
1439
+ !baseReady && supported ? button(baseState === 'broken' ? t('pythonRepair') : t('pythonPrepare'), () => prepare(['base']), { disabled: job?.state === 'running' }) : null,
1440
+ baseReady ? button(t('pythonVerify'), verify, { disabled: job?.state === 'running' }) : null,
1441
+ removePack === 'base'
1442
+ ? h('span', { className: 'capital-config-runtime-actions' },
1443
+ h('span', { className: 'capital-config-runtime-copy' }, t('pythonRemoveConfirm')),
1444
+ button(t('pythonRemoveYes'), () => remove('base'), { danger: true, disabled: busy }),
1445
+ button(t('pythonCancel'), () => setRemovePack(''), { disabled: busy }),
1446
+ )
1447
+ : baseReady ? button(t('pythonRemove'), () => setRemovePack('base'), { disabled: busy || job?.state === 'running' }) : null,
1448
+ ),
1449
+ ),
1450
+ h('div', { className: 'capital-config-runtime-card' },
1451
+ h('div', { className: 'capital-config-runtime-row' },
1452
+ h('span', { className: 'capital-config-runtime-label' }, t('pythonParquet')),
1453
+ h('span', { className: 'capital-config-runtime-state', 'data-tone': parquetReady ? 'ready' : undefined }, parquetLabel),
1454
+ ),
1455
+ h('p', { className: 'capital-config-runtime-copy' }, parquetReady ? t('pythonParquetReady') : t('pythonParquetHint')),
1456
+ h('div', { className: 'capital-config-runtime-actions' },
1457
+ baseReady && supported && !parquetReady
1458
+ ? button(t('pythonInstallParquet'), () => prepare(['parquet']), { disabled: job?.state === 'running' })
1459
+ : null,
1460
+ removePack === 'parquet'
1461
+ ? h('span', { className: 'capital-config-runtime-actions' },
1462
+ h('span', { className: 'capital-config-runtime-copy' }, t('pythonRemoveConfirm')),
1463
+ button(t('pythonRemoveYes'), () => remove('parquet'), { danger: true, disabled: busy }),
1464
+ button(t('pythonCancel'), () => setRemovePack(''), { disabled: busy }),
1465
+ )
1466
+ : parquetReady ? button(t('pythonRemove'), () => setRemovePack('parquet'), { disabled: busy || job?.state === 'running' }) : null,
1467
+ ),
1468
+ ),
1469
+ error === '' ? null : h('p', { className: 'capital-config-runtime-error', role: 'alert' }, error),
1470
+ notice === '' ? null : h('p', { className: 'capital-config-runtime-notice', role: 'status' }, notice),
1471
+ job === null ? null : h('div', { className: 'capital-config-runtime-card' },
1472
+ h('p', { className: 'capital-config-runtime-copy', role: 'status' }, t('pythonJob', { stage: job.stage, message: job.message })),
1473
+ job.state === 'running' ? h('div', { className: 'capital-config-runtime-actions' }, button(t('pythonCancel'), cancel, { disabled: busy })) : null,
1474
+ ),
1475
+ )
1476
+ }
1477
+
1216
1478
  function CapitalCard(props) {
1217
1479
  const t = props.t
1218
1480
  const state = props.useCapitalCard((snapshot) => snapshot)
@@ -1583,6 +1845,7 @@ function CapitalCard(props) {
1583
1845
  { value: 'automation', label: t('automationTitle') },
1584
1846
  { value: 'skills', label: t('selectedSkillsTitle') },
1585
1847
  { value: 'components', label: withCount(t('componentsTitle'), state.components?.count) },
1848
+ { value: 'analysis', label: t('pythonTitle') },
1586
1849
  ]
1587
1850
  const panel = (value, children) => h('section', {
1588
1851
  id: `${TABS_ID}-${value}-panel`,
@@ -1618,6 +1881,7 @@ function CapitalCard(props) {
1618
1881
  )]),
1619
1882
  // The panel is the host's rows list; keep the aria-controls target non-empty via sr-only.
1620
1883
  panel('components', [h('span', { className: 'capital-config-sr-only' }, t('componentsHint'))]),
1884
+ panel('analysis', [h(PythonRuntimeSection, { t })]),
1621
1885
  clearCacheOpen ? h(ClearCacheModal, {
1622
1886
  open: true,
1623
1887
  bytes: cacheBytes,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v587d/config",
3
- "version": "2.23.0",
3
+ "version": "2.25.0",
4
4
  "description": "自动模式的取数凭据与偏好配置行:卡片坐在 @v587d/capital-generation 插件主页的「配置」段,点这一行本身没有表单。",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/cordis.patch.yml CHANGED
@@ -66,13 +66,20 @@
66
66
  # Root and role presets mount separately, so apply() runs several times per process. Shared state
67
67
  # (chart source tokens, chart artifacts) and the agent/created listeners (root convergence, shell
68
68
  # and fs guards) must exist exactly once, which only a host-plane provide gives.
69
- # These two rows use package subpath entries (@v587d/capital-generation/runtime and /policy): they
70
- # are server-side, so the literal-path rule above doesn't apply — DSH composes its own
69
+ # These rows use package subpath entries (/runtime, /python-runtime and /policy): they are
70
+ # server-side, so the literal-path rule above doesn't apply — DSH composes its own
71
71
  # @deepseek-ai/dsh-tool-subagent-control rows the same way.
72
72
  - insert:
73
73
  - id: capital-runtime
74
74
  name: '@v587d/capital-generation/runtime'
75
75
 
76
+ # Plugin-private Python runtime. The row only provides the service and its local HTTP routes;
77
+ # the interpreter and third-party libraries live under the DSH home cache and are installed on
78
+ # demand. Never point this row at the host's dsh-primary-runtime.
79
+ - insert:
80
+ - id: python-runtime
81
+ name: '@v587d/capital-generation/python-runtime'
82
+
76
83
  - insert:
77
84
  - id: capital-policy
78
85
  name: '@v587d/capital-generation/policy'
@@ -12,7 +12,7 @@ export declare const SIBLING_DENIED_TOOLS: readonly ["interrupt_agent", "list_ag
12
12
  /** Full intended surface; only names that resolve as host-global are enforced by the allow-list.
13
13
  * Scoped family-row tools stay visible regardless; they must remain in this list for review. */
14
14
  export declare const COLLECTOR_ROLE_TOOLS: readonly ["send_message", "skill", "get_local_datetime", "resolve_data_time_range", "request_data", "list_capabilities", "describe_capability", "dc_status"];
15
- export declare const RETRIEVER_ROLE_TOOLS: readonly ["send_message", "skill", "get_local_datetime", "resolve_data_time_range", "anysearch_search", "web_retriever_fetch", "wind_docs_announcements", "wind_docs_news", "cls_telegraph", "wscn_lives", "cninfo_irm", "sseinfo_qa", "eastmoney_724", "eastmoney_stock_news", "eastmoney_reports", "eastmoney_announcements", "eastmoney_announcement_body", "sina_reports", "ths_eps_forecast", "ocr", "anysearch_batch_search", "anysearch_capabilities"];
15
+ export declare const RETRIEVER_ROLE_TOOLS: readonly ["send_message", "skill", "get_local_datetime", "resolve_data_time_range", "anysearch_search", "web_retriever_fetch", "wind_docs_announcements", "wind_docs_news", "cls_telegraph", "wscn_lives", "cninfo_irm", "cninfo_announcements", "sseinfo_qa", "eastmoney_724", "eastmoney_stock_news", "eastmoney_reports", "eastmoney_announcements", "eastmoney_announcement_body", "sina_reports", "ths_eps_forecast", "ocr", "anysearch_batch_search", "anysearch_capabilities"];
16
16
  export declare const SPECIALIST_ROLE_TOOLS: readonly ["get_local_datetime", "resolve_data_time_range", "skill", "render_chart"];
17
17
  /** Host-global allow-list plus residual per-name denies. */
18
18
  export interface RoleSurface {
@@ -2,8 +2,8 @@
2
2
  * Root Agent tool convergence on the root's own scope: preset-level deny would also hit
3
3
  * children. Listeners must live on `ctx.root`; tagged standing-scope listeners miss agent/created.
4
4
  */
5
- /** Outbound tools (search 2 + wind 2 + named sources 11); `ocr` is excluded because only its url form is restricted. */
6
- export declare const RETRIEVAL_DENIED_TOOLS: readonly ["anysearch_search", "web_retriever_fetch", "wind_docs_announcements", "wind_docs_news", "cls_telegraph", "wscn_lives", "cninfo_irm", "sseinfo_qa", "eastmoney_724", "eastmoney_stock_news", "eastmoney_reports", "eastmoney_announcements", "eastmoney_announcement_body", "sina_reports", "ths_eps_forecast"];
5
+ /** Outbound tools (search 2 + wind 2 + named sources 12); `ocr` is excluded because only its url form is restricted. */
6
+ export declare const RETRIEVAL_DENIED_TOOLS: readonly ["anysearch_search", "web_retriever_fetch", "wind_docs_announcements", "wind_docs_news", "cls_telegraph", "wscn_lives", "cninfo_irm", "cninfo_announcements", "sseinfo_qa", "eastmoney_724", "eastmoney_stock_news", "eastmoney_reports", "eastmoney_announcements", "eastmoney_announcement_body", "sina_reports", "ths_eps_forecast"];
7
7
  /** Generic host web entry points; the only outbound surface is web_retriever's named tools. */
8
8
  export declare const HOST_WEB_DENIED_TOOLS: readonly ["web_fetch", "anysearch_batch_search", "anysearch_capabilities"];
9
9
  export declare const OCR_TOOL_NAME = "ocr";
@@ -18,7 +18,7 @@ export declare const SHELL_TOOL_NAMES: readonly ["bash", "pwsh"];
18
18
  * four tools on every Capital agent; the `team:policy` prompt section is host-owned and cannot be
19
19
  * removed by a name deny, so Capital intentionally ignores that text. */
20
20
  export declare const TEAM_DENIED_TOOLS: readonly ["team_task_create", "team_task_list", "team_task_get", "team_task_update"];
21
- export declare const ROOT_AGENT_DENIED_TOOLS: readonly ["render_chart", "prepare_chart_source", "team_task_create", "team_task_list", "team_task_get", "team_task_update", "anysearch_search", "web_retriever_fetch", "wind_docs_announcements", "wind_docs_news", "cls_telegraph", "wscn_lives", "cninfo_irm", "sseinfo_qa", "eastmoney_724", "eastmoney_stock_news", "eastmoney_reports", "eastmoney_announcements", "eastmoney_announcement_body", "sina_reports", "ths_eps_forecast", "web_fetch", "anysearch_batch_search", "anysearch_capabilities", "write", "edit"];
21
+ export declare const ROOT_AGENT_DENIED_TOOLS: readonly ["render_chart", "prepare_chart_source", "team_task_create", "team_task_list", "team_task_get", "team_task_update", "anysearch_search", "web_retriever_fetch", "wind_docs_announcements", "wind_docs_news", "cls_telegraph", "wscn_lives", "cninfo_irm", "cninfo_announcements", "sseinfo_qa", "eastmoney_724", "eastmoney_stock_news", "eastmoney_reports", "eastmoney_announcements", "eastmoney_announcement_body", "sina_reports", "ths_eps_forecast", "web_fetch", "anysearch_batch_search", "anysearch_capabilities", "write", "edit"];
22
22
  export declare const CAPITAL_PRESET_ID = "capital-generation";
23
23
  interface ToolRestriction {
24
24
  allow?: readonly string[];
@@ -4,11 +4,11 @@
4
4
  */
5
5
  import { CAPITAL_PRESET_IDS, ROOT_PRESET_ID } from '../preset-ids.js';
6
6
  import { readPresetClaim } from '../preset-claim.js';
7
- /** Outbound tools (search 2 + wind 2 + named sources 11); `ocr` is excluded because only its url form is restricted. */
7
+ /** Outbound tools (search 2 + wind 2 + named sources 12); `ocr` is excluded because only its url form is restricted. */
8
8
  export const RETRIEVAL_DENIED_TOOLS = [
9
9
  'anysearch_search', 'web_retriever_fetch',
10
10
  'wind_docs_announcements', 'wind_docs_news',
11
- 'cls_telegraph', 'wscn_lives', 'cninfo_irm', 'sseinfo_qa',
11
+ 'cls_telegraph', 'wscn_lives', 'cninfo_irm', 'cninfo_announcements', 'sseinfo_qa',
12
12
  'eastmoney_724', 'eastmoney_stock_news', 'eastmoney_reports',
13
13
  'eastmoney_announcements', 'eastmoney_announcement_body',
14
14
  'sina_reports', 'ths_eps_forecast',
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Catalog shard key for every model-visible capability. One table, not one field per
3
+ * source: the nine shards must be audited together, and a missing production entry is a
4
+ * test failure rather than a capability that silently falls into `meta`.
5
+ */
6
+ export declare const CATALOG_TOPICS: readonly ["quote", "flow", "financials", "fund", "events", "macro", "futures", "cross", "meta"];
7
+ export type CatalogTopic = (typeof CATALOG_TOPICS)[number];
8
+ export declare const CATALOG_TOPIC_LABELS: Record<CatalogTopic, string>;
9
+ /**
10
+ * Keep this table explicit. Deriving a topic from a name prefix looks convenient until
11
+ * `dragon_tiger` lands in `quote` or `eastmoney_mutual_flow` lands in `flow` instead of
12
+ * `cross`; both are discovery-time failures, not cosmetic mislabels.
13
+ */
14
+ export declare const CATALOG_TAXONOMY: Record<string, CatalogTopic>;
15
+ /** Fallback exists only for test fixtures; assembly rejects any production capability not in the table. */
16
+ export declare function topicOf(capability: string): CatalogTopic;
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Catalog shard key for every model-visible capability. One table, not one field per
3
+ * source: the nine shards must be audited together, and a missing production entry is a
4
+ * test failure rather than a capability that silently falls into `meta`.
5
+ */
6
+ export const CATALOG_TOPICS = [
7
+ 'quote',
8
+ 'flow',
9
+ 'financials',
10
+ 'fund',
11
+ 'events',
12
+ 'macro',
13
+ 'futures',
14
+ 'cross',
15
+ 'meta',
16
+ ];
17
+ export const CATALOG_TOPIC_LABELS = {
18
+ quote: '行情与指数',
19
+ flow: '资金与筹码',
20
+ financials: '财务与估值',
21
+ fund: '基金',
22
+ events: '公告与公司行为',
23
+ macro: '宏观与利率',
24
+ futures: '期货与商品',
25
+ cross: '跨境与全球',
26
+ meta: '日历与元数据',
27
+ };
28
+ /**
29
+ * Keep this table explicit. Deriving a topic from a name prefix looks convenient until
30
+ * `dragon_tiger` lands in `quote` or `eastmoney_mutual_flow` lands in `flow` instead of
31
+ * `cross`; both are discovery-time failures, not cosmetic mislabels.
32
+ */
33
+ export const CATALOG_TAXONOMY = {
34
+ // quote
35
+ 'auction': 'quote',
36
+ 'eastmoney_global_kline': 'quote',
37
+ 'eastmoney_global_quote': 'quote',
38
+ 'eastmoney_sector_rotation': 'quote',
39
+ 'ftshare_ashare_quote': 'quote',
40
+ 'ftshare_convertible_bond_kline': 'quote',
41
+ 'ftshare_daily_kline_snapshot': 'quote',
42
+ 'ftshare_limit_price': 'quote',
43
+ 'ftshare_market_breadth': 'quote',
44
+ 'ftshare_prev_close': 'quote',
45
+ 'history': 'quote',
46
+ 'index_history': 'quote',
47
+ 'index_quote': 'quote',
48
+ 'quote': 'quote',
49
+ 'tencent_hk_index_quote': 'quote',
50
+ 'tencent_hk_kline': 'quote',
51
+ 'tencent_hk_quote': 'quote',
52
+ 'tencent_kline': 'quote',
53
+ 'tencent_quote': 'quote',
54
+ 'tencent_ticks': 'quote',
55
+ 'tencent_us_index_quote': 'quote',
56
+ 'tencent_us_kline': 'quote',
57
+ 'tencent_us_prepost_quote': 'quote',
58
+ 'tencent_us_quote': 'quote',
59
+ // flow
60
+ 'anomaly_list': 'flow',
61
+ 'anomaly_stock': 'flow',
62
+ 'auction_benchmark': 'flow',
63
+ 'dragon_tiger': 'flow',
64
+ 'eastmoney_cashflow_rotation': 'flow',
65
+ 'eastmoney_holder_number_snapshot': 'flow',
66
+ 'eastmoney_main_capital_snapshot': 'flow',
67
+ 'eastmoney_margin_total': 'flow',
68
+ 'eastmoney_margin_trading': 'flow',
69
+ 'eastmoney_top_buy_sell_market': 'flow',
70
+ 'eastmoney_top_buy_sell_ticker': 'flow',
71
+ 'ftshare_block_trades': 'flow',
72
+ 'ftshare_concept_daily_flow': 'flow',
73
+ 'ftshare_dragon_tiger_seats': 'flow',
74
+ 'ftshare_holder_number': 'flow',
75
+ 'ftshare_industry_daily_flow': 'flow',
76
+ 'ftshare_main_capital_flow': 'flow',
77
+ 'ftshare_stock_daily_flow': 'flow',
78
+ 'hot_stock_history': 'flow',
79
+ 'hot_stock_list': 'flow',
80
+ 'hot_stock_rank_trend': 'flow',
81
+ 'limit_break_pool': 'flow',
82
+ 'limit_down_pool': 'flow',
83
+ 'limit_up_ladder': 'flow',
84
+ 'limit_up_pool': 'flow',
85
+ 'skyrocket_list': 'flow',
86
+ // financials
87
+ 'balance_sheet': 'financials',
88
+ 'cash_flow': 'financials',
89
+ 'eastmoney_convertible_bond_list': 'financials',
90
+ 'financial_indicators': 'financials',
91
+ 'ftshare_performance_express': 'financials',
92
+ 'ftshare_performance_forecast': 'financials',
93
+ 'ftshare_sw_industry_metrics': 'financials',
94
+ 'ftshare_sw_industry_overview': 'financials',
95
+ 'income_statement': 'financials',
96
+ 'valuation': 'financials',
97
+ // fund
98
+ 'fund_asset_allocation': 'fund',
99
+ 'fund_backtest': 'fund',
100
+ 'fund_backtest_indicators': 'fund',
101
+ 'fund_balance': 'fund',
102
+ 'fund_bond_history': 'fund',
103
+ 'fund_bond_report_dates': 'fund',
104
+ 'fund_company': 'fund',
105
+ 'fund_diagnostics': 'fund',
106
+ 'fund_dividends': 'fund',
107
+ 'fund_drawdowns': 'fund',
108
+ 'fund_financial_indicators': 'fund',
109
+ 'fund_history': 'fund',
110
+ 'fund_holders': 'fund',
111
+ 'fund_holdings': 'fund',
112
+ 'fund_income': 'fund',
113
+ 'fund_indicator_line': 'fund',
114
+ 'fund_indicator_table': 'fund',
115
+ 'fund_industry_allocation': 'fund',
116
+ 'fund_manager': 'fund',
117
+ 'fund_manager_experience': 'fund',
118
+ 'fund_manager_performance': 'fund',
119
+ 'fund_manager_style': 'fund',
120
+ 'fund_nav': 'fund',
121
+ 'fund_offerings': 'fund',
122
+ 'fund_performance_history': 'fund',
123
+ 'fund_profile': 'fund',
124
+ 'fund_quota_list': 'fund',
125
+ 'fund_quota_summary': 'fund',
126
+ 'fund_quote': 'fund',
127
+ 'fund_returns': 'fund',
128
+ 'fund_stock_history': 'fund',
129
+ 'fund_stock_report_dates': 'fund',
130
+ 'fund_top_holders': 'fund',
131
+ // events
132
+ 'corporate_actions': 'events',
133
+ 'eastmoney_dividend_plan': 'events',
134
+ 'eastmoney_lockup_expiry': 'events',
135
+ // macro
136
+ 'eastmoney_cpi': 'macro',
137
+ 'eastmoney_customs_trade': 'macro',
138
+ 'eastmoney_deposit_reserve': 'macro',
139
+ 'eastmoney_gdp': 'macro',
140
+ 'eastmoney_money_supply': 'macro',
141
+ 'eastmoney_pmi': 'macro',
142
+ 'eastmoney_ppi': 'macro',
143
+ 'eastmoney_retail_sales': 'macro',
144
+ 'eastmoney_rmb_loan': 'macro',
145
+ 'ftshare_chinabond_yield': 'macro',
146
+ 'ftshare_hibor': 'macro',
147
+ 'ftshare_lpr': 'macro',
148
+ 'ftshare_shibor': 'macro',
149
+ 'wind_edb_query': 'macro',
150
+ 'wind_edb_search': 'macro',
151
+ // futures
152
+ 'ftshare_bullion_price': 'futures',
153
+ 'ftshare_futures_contract_detail': 'futures',
154
+ 'ftshare_futures_contracts': 'futures',
155
+ 'ftshare_futures_index_kline': 'futures',
156
+ 'ftshare_futures_kline': 'futures',
157
+ 'ftshare_futures_limit_price': 'futures',
158
+ 'ftshare_futures_member_rank': 'futures',
159
+ 'ftshare_futures_settle': 'futures',
160
+ 'ftshare_futures_warrant': 'futures',
161
+ 'ftshare_futures_weekly': 'futures',
162
+ // cross
163
+ 'eastmoney_mutual_flow': 'cross',
164
+ 'eastmoney_mutual_quota': 'cross',
165
+ 'ftshare_financial_calendar': 'cross',
166
+ 'ftshare_trading_calendar': 'cross',
167
+ 'wind_stock_kline': 'cross',
168
+ // meta
169
+ 'ftshare_index_weight': 'meta',
170
+ 'index_catalog': 'meta',
171
+ 'index_constituents': 'meta',
172
+ 'ticker_list': 'meta',
173
+ 'ticker_search': 'meta',
174
+ 'trading_calendar': 'meta',
175
+ };
176
+ /** Fallback exists only for test fixtures; assembly rejects any production capability not in the table. */
177
+ export function topicOf(capability) {
178
+ return CATALOG_TAXONOMY[capability] ?? 'meta';
179
+ }
@@ -1,6 +1,7 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
2
  import type { DataTimeContract } from '../time/tools.js';
3
3
  import type { DatasetRef, SaveDatasetInput, SessionLike } from './store.js';
4
+ import { type CatalogTopic } from './catalog-taxonomy.js';
4
5
  /** Normalize an internal data_key token; data_key is host-only and never model-visible. */
5
6
  export declare function normalizeKeyToken(value: string): string;
6
7
  export declare function buildDataKey(provider: string, kind: string, resource: string): string;
@@ -40,6 +41,14 @@ export interface CapabilitySummary {
40
41
  summary: string;
41
42
  paginated: boolean;
42
43
  }
44
+ /** One shard header for the discovery index; chars is the exact size of that shard's catalog text. */
45
+ export interface CatalogTopicSummary {
46
+ topic: CatalogTopic;
47
+ label: string;
48
+ count: number;
49
+ chars: number;
50
+ examples: string[];
51
+ }
43
52
  /** Full contract for one capability; must be read before calling. */
44
53
  export interface CapabilityDetail extends CapabilitySummary {
45
54
  description: string;
@@ -113,10 +122,14 @@ export declare class DataCollectorHub {
113
122
  private awaitSettlement;
114
123
  private settleWaiter;
115
124
  /** Catalog: capability, one-line summary, paginated only. Full schemas would be pruned; details come from describeCapability. */
116
- listCapabilities(): CapabilitySummary[];
125
+ listCapabilities(topic?: CatalogTopic): CapabilitySummary[];
117
126
  capabilityNames(): string[];
118
- /** Model-visible catalog: one `capability|summary|paginated` line each; JSON costs about twice the tokens. */
119
- capabilityDirectory(): string;
127
+ /** One row per non-empty topic; chars is the exact size of the shard text the model will receive. */
128
+ catalogTopicEntries(): CatalogTopicSummary[];
129
+ /** Discovery index: `topic|label|count|chars|examples`, one row per non-empty shard. */
130
+ catalogIndex(): string;
131
+ /** Full catalog is internal aggregation only; the model receives catalogIndex() or one topic shard. */
132
+ capabilityDirectory(topic?: CatalogTopic): string;
120
133
  /** Single capability contract; undefined for unknown names (the tool layer classifies it). */
121
134
  describeCapability(capability: string): CapabilityDetail | undefined;
122
135
  private processNext;