@v587d/capital-generation 2.21.2 → 2.21.4

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.
@@ -1088,7 +1088,7 @@ function installStyles() {
1088
1088
  .capital-automation-paneltoggle:hover { color: var(--dsw-alias-label-primary); }
1089
1089
  .capital-automation-paneltoggle:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: 3px; border-radius: 4px; }
1090
1090
  .capital-automation-panelchevron { flex: none; color: var(--ca-caption); transition: transform .15s; }
1091
- .capital-automation-panelchevron[data-open="false"] { transform: rotate(-90deg); }
1091
+ .capital-automation-paneltoggle[aria-expanded="false"] .capital-automation-panelchevron { transform: rotate(-90deg); }
1092
1092
  .capital-automation-panelbody[hidden] { display: none; }
1093
1093
  .capital-automation-boardempty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; min-height: min(440px, calc(100dvh - 260px)); padding: 44px 24px; border: .5px dashed var(--ca-line); border-radius: 20px; background: var(--ca-card); color: var(--ca-muted); text-align: center; }
1094
1094
  .capital-automation-boardemptyicon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: color-mix(in srgb, var(--ca-business) 12%, var(--ca-card)); color: var(--ca-business-text); }
@@ -4092,8 +4092,15 @@ function boardTodoPeriod(item, now = new Date()) {
4092
4092
  const decidedToday = typeof decidedAt === 'string' && localDateKey(new Date(decidedAt)) === today
4093
4093
  // A decision is feedback for the rest of today, then it belongs to the archive.
4094
4094
  if (decidedAt !== undefined) return decidedToday ? 'today' : 'expired'
4095
- // A triggered condition is a fact: keep it actionable until the user decides.
4096
- if (watchedStatus === 'triggered') return 'today'
4095
+ // A triggered condition stays actionable through the day it fired (or was due); the next
4096
+ // day it joins the archive like any other settled TODO.
4097
+ if (watchedStatus === 'triggered') {
4098
+ const due = typeof item.dueAt === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(item.dueAt) ? item.dueAt : ''
4099
+ const at = Date.parse(item.watch?.checkedAt)
4100
+ const checked = Number.isFinite(at) ? localDateKey(new Date(at)) : ''
4101
+ const latest = due > checked ? due : checked
4102
+ return latest.length > 0 && latest < today ? 'expired' : 'today'
4103
+ }
4097
4104
  // A stopped watch has reached its lifecycle end, including date-less "尽快" items.
4098
4105
  if (item.watch?.status === 'expired') return 'expired'
4099
4106
  if (typeof item.dueAt === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(item.dueAt)) {
@@ -5356,7 +5363,6 @@ function BoardPanelHead(props) {
5356
5363
  h(IconChevronDownOutlineRegular, {
5357
5364
  size: 14,
5358
5365
  className: 'capital-automation-panelchevron',
5359
- 'data-open': open === true ? 'true' : 'false',
5360
5366
  }))),
5361
5367
  meta ?? null,
5362
5368
  action ?? null)
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Shared extraction for model-authored JSON. Briefs and TODO verdicts both arrive as an
3
+ * object wrapped in prose or a code fence, and models occasionally leave a trailing comma
4
+ * before `]`/`}`; one implementation keeps both readers on the same rules.
5
+ */
6
+
7
+ function parseValue(text) {
8
+ try {
9
+ return JSON.parse(text)
10
+ } catch {
11
+ return undefined
12
+ }
13
+ }
14
+
15
+ export function stripTrailingCommas(text) {
16
+ let output = ''
17
+ let inString = false
18
+ let escaped = false
19
+ for (let index = 0; index < text.length; index += 1) {
20
+ const char = text[index]
21
+ if (inString) {
22
+ output += char
23
+ if (escaped) escaped = false
24
+ else if (char === '\\') escaped = true
25
+ else if (char === '"') inString = false
26
+ continue
27
+ }
28
+ if (char === '"') {
29
+ inString = true
30
+ output += char
31
+ continue
32
+ }
33
+ if (char === ',') {
34
+ let next = index + 1
35
+ while (next < text.length && /\s/.test(text[next])) next += 1
36
+ if (text[next] === ']' || text[next] === '}') continue
37
+ }
38
+ output += char
39
+ }
40
+ return output
41
+ }
42
+
43
+ /** Parse any JSON value, retrying once with string-aware trailing-comma removal. */
44
+ export function parseJsonValue(text) {
45
+ const direct = parseValue(text)
46
+ if (direct !== undefined) return direct
47
+ return parseValue(stripTrailingCommas(text))
48
+ }
49
+
50
+ /**
51
+ * Narrow a model reply to the JSON text it carries: the last code fence when one exists,
52
+ * otherwise the outermost `{...}` after a prose preamble. Truncated text is returned as-is so
53
+ * the caller can report a parse failure instead of silently accepting half an object.
54
+ */
55
+ export function extractJsonText(raw) {
56
+ const text = String(raw ?? '').replace(/^\uFEFF/, '').trim()
57
+ const fences = [...text.matchAll(/```(?:json)?\s*([\s\S]*?)\s*```/gi)]
58
+ if (fences.length > 0) return fences.at(-1)[1].trim()
59
+ const start = text.indexOf('{')
60
+ if (start < 0) return text
61
+ const end = text.lastIndexOf('}')
62
+ return end > start ? text.slice(start, end + 1) : text.slice(start)
63
+ }
64
+
65
+ /** The extracted reply when it is a JSON object, otherwise undefined. */
66
+ export function extractJsonObject(raw) {
67
+ const value = parseJsonValue(extractJsonText(raw))
68
+ return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : undefined
69
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v587d/capital-automation",
3
- "version": "2.21.2",
3
+ "version": "2.21.4",
4
4
  "description": "CapGen 投研自动化:独立 host bundle(固定 capital_automation 域、单 scheduler owner、/capital-automation 路由与浏览器页面)。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -7,6 +7,7 @@ import { createHash } from 'node:crypto'
7
7
  import { isDeepStrictEqual } from 'node:util'
8
8
 
9
9
  import { includesQuote, sourceBlocksOf } from './brief.js'
10
+ import { extractJsonObject } from './json-text.js'
10
11
  import { sanitizeMessage } from './redact.js'
11
12
  import { localPartsAt } from './time.js'
12
13
 
@@ -91,65 +92,6 @@ function decisionCovers(decision, lastSeenAt) {
91
92
  return seenAt <= decidedAt
92
93
  }
93
94
 
94
- function parseObject(text) {
95
- try {
96
- const value = JSON.parse(text)
97
- return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : undefined
98
- } catch {
99
- return undefined
100
- }
101
- }
102
-
103
- /**
104
- * Models occasionally leave a trailing comma before `]`/`}`; JSON.parse then drops the whole
105
- * verdict block and every candidate silently falls back to insufficient.
106
- */
107
- function stripTrailingCommas(text) {
108
- let output = ''
109
- let inString = false
110
- let escaped = false
111
- for (let index = 0; index < text.length; index += 1) {
112
- const char = text[index]
113
- if (inString) {
114
- output += char
115
- if (escaped) escaped = false
116
- else if (char === '\\') escaped = true
117
- else if (char === '"') inString = false
118
- continue
119
- }
120
- if (char === '"') {
121
- inString = true
122
- output += char
123
- continue
124
- }
125
- if (char === ',') {
126
- let next = index + 1
127
- while (next < text.length && /\s/.test(text[next])) next += 1
128
- if (text[next] === ']' || text[next] === '}') continue
129
- }
130
- output += char
131
- }
132
- return output
133
- }
134
-
135
- /**
136
- * Validate the verifier's result block against the evidence text it claims to quote. A quote
137
- * that exists in neither the tool output nor the final answer is a fabrication and is dropped.
138
- */
139
- function extractJsonObject(raw) {
140
- let text = String(raw ?? '').trim()
141
- const fences = [...text.matchAll(/```(?:json)?\s*([\s\S]*?)\s*```/gi)]
142
- if (fences.length > 0) {
143
- text = fences.at(-1)[1].trim()
144
- } else {
145
- // A verifier may wrap the JSON in a short prose preamble; keep the outermost object.
146
- const start = text.indexOf('{')
147
- const end = text.lastIndexOf('}')
148
- if (start >= 0 && end > start) text = text.slice(start, end + 1)
149
- }
150
- return parseObject(text) ?? parseObject(stripTrailingCommas(text))
151
- }
152
-
153
95
  /**
154
96
  * The verifier authors the board card in the same final answer as its verdicts, so the brief
155
97
  * costs no extra model call. Validation and fallback live in `verifierBriefContent`.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v587d/capital-charts",
3
- "version": "2.21.2",
3
+ "version": "2.21.4",
4
4
  "description": "自动模式的图表前端组件(浏览器半边 + 序列旁路路由):由 @v587d/capital-generation 随包携带并作为 host 平面行挂载。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v587d/config",
3
- "version": "2.21.2",
3
+ "version": "2.21.4",
4
4
  "description": "自动模式的取数凭据与偏好配置行:卡片坐在 @v587d/capital-generation 插件主页的「配置」段,点这一行本身没有表单。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -3,7 +3,7 @@
3
3
  * Known limit: DNS resolves per request but the IP is not pinned to the connection,
4
4
  * so a rebinding window remains (same trade-off as dsh-search-first).
5
5
  */
6
- export declare const LOCAL_FETCH_CLIENT_VERSION = "2.21.2";
6
+ export declare const LOCAL_FETCH_CLIENT_VERSION = "2.21.4";
7
7
  export declare const LOCAL_FETCH_MAX_URL_LENGTH = 2048;
8
8
  export type LocalFetchErrorCode = 'ABORTED' | 'TIMEOUT' | 'INVALID_URL' | 'BLOCKED_URL' | 'DNS' | 'REDIRECT' | 'HTTP' | 'TOO_LARGE' | 'UNSUPPORTED_CONTENT_TYPE';
9
9
  export declare class LocalFetchError extends Error {
@@ -4,7 +4,7 @@
4
4
  * so a rebinding window remains (same trade-off as dsh-search-first).
5
5
  */
6
6
  import { htmlToMarkdown, stripInvisibleText } from './html-markdown.js';
7
- export const LOCAL_FETCH_CLIENT_VERSION = '2.21.2';
7
+ export const LOCAL_FETCH_CLIENT_VERSION = '2.21.4';
8
8
  export const LOCAL_FETCH_MAX_URL_LENGTH = 2048;
9
9
  export class LocalFetchError extends Error {
10
10
  code;
@@ -35,7 +35,7 @@ export interface WindCallResult {
35
35
  code?: WindErrorCode;
36
36
  }
37
37
  /** Must match `package.json` version; a test pins the two together. */
38
- export declare const WIND_CLIENT_VERSION = "2.21.2";
38
+ export declare const WIND_CLIENT_VERSION = "2.21.4";
39
39
  export interface WindClient {
40
40
  callTool(toolName: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<WindCallResult>;
41
41
  }
@@ -19,7 +19,7 @@ export const WIND_SERVER_ENDPOINTS = {
19
19
  analytics_data: 'https://mcp.wind.com.cn/vserver_analytics_data/mcp/',
20
20
  };
21
21
  /** Must match `package.json` version; a test pins the two together. */
22
- export const WIND_CLIENT_VERSION = '2.21.2';
22
+ export const WIND_CLIENT_VERSION = '2.21.4';
23
23
  function errorText(error) {
24
24
  return error instanceof Error ? error.message : String(error);
25
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v587d/capital-generation",
3
- "version": "2.21.2",
3
+ "version": "2.21.4",
4
4
  "description": "Capital Generation:面向中国散户的 AI 投资助手插件(自动模式 Agent Preset)",
5
5
  "icon": "assets/cg-icon.png",
6
6
  "author": "v587d",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v587d/watchlist",
3
- "version": "2.21.2",
3
+ "version": "2.21.4",
4
4
  "description": "自动模式的用户自选股(宿主级清单 + Fuyao 报价快照 + /capital-watchlist 路由 + 输入框菜单弹窗):由 @v587d/capital-generation 随包携带并作为 host 平面行挂载。",
5
5
  "license": "MIT",
6
6
  "type": "module",