@v587d/capital-generation 2.18.0 → 2.19.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 +51 -0
- package/README.md +3 -3
- package/automation/board.js +23 -2
- package/automation/brief.js +3 -13
- package/automation/client.js +11 -12
- package/automation/client.src.cjs +146 -65
- package/automation/defaults.js +1 -0
- package/automation/package.json +1 -1
- package/automation/route.js +3 -0
- package/automation/runner.js +2 -2
- package/automation/schema.js +16 -0
- package/automation/service.js +15 -0
- package/automation/store.js +45 -0
- package/automation/task-icons.js +8 -0
- package/chart-ui/package.json +1 -1
- package/config/package.json +1 -1
- package/lib/web-retriever/local-fetch.d.ts +1 -1
- package/lib/web-retriever/local-fetch.js +1 -1
- package/lib/web-retriever/wind-client.d.ts +1 -1
- package/lib/web-retriever/wind-client.js +1 -1
- package/package.json +1 -1
- package/watchlist/package.json +1 -1
|
@@ -34,7 +34,7 @@ const {
|
|
|
34
34
|
TASK_ICON_CATALOG,
|
|
35
35
|
TASK_ICON_IDS,
|
|
36
36
|
DEFAULT_CUSTOM_ICON,
|
|
37
|
-
|
|
37
|
+
taskIconId,
|
|
38
38
|
} = require('./task-icons.js')
|
|
39
39
|
|
|
40
40
|
const ENTRY_NAME = 'capital-automation'
|
|
@@ -82,7 +82,7 @@ const INSTRUCTION_MAX_LENGTH = 12_000
|
|
|
82
82
|
const AUTOSAVE_DELAY_MS = 600
|
|
83
83
|
const BOARD_UI_KEY = 'capital-automation:board-ui:v3'
|
|
84
84
|
const BOARD_PANEL_KEYS = ['todo', 'stocks', 'gaps', 'health']
|
|
85
|
-
const BOARD_TODO_PERIODS = ['today', '
|
|
85
|
+
const BOARD_TODO_PERIODS = ['today', 'future', 'expired']
|
|
86
86
|
const BOARD_PANEL_IDS = {
|
|
87
87
|
'capital-automation-todo': 'todo',
|
|
88
88
|
'capital-automation-stocks': 'stocks',
|
|
@@ -102,7 +102,7 @@ const zh = {
|
|
|
102
102
|
goEnable: '去启用任务',
|
|
103
103
|
newTask: '新建任务',
|
|
104
104
|
statsBriefs: '本期简报',
|
|
105
|
-
statsTodos: 'TODO',
|
|
105
|
+
statsTodos: '今日 TODO',
|
|
106
106
|
statsStocks: '标的',
|
|
107
107
|
statsGaps: '缺口',
|
|
108
108
|
statsIssues: '近 7 天异常',
|
|
@@ -132,15 +132,16 @@ const zh = {
|
|
|
132
132
|
todoConfirm: '待确认',
|
|
133
133
|
todoVerify: '待验证',
|
|
134
134
|
todoTrack: '跟踪',
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
todoAck: '确认',
|
|
136
|
+
todoAckTitle: '确认并移除这条 TODO',
|
|
137
|
+
todoAcked: '已确认,已从 TODO 移除',
|
|
138
|
+
todoEmptyToday: '今天暂无待办',
|
|
139
|
+
todoEmptyGroup: '暂无「{label}」待办',
|
|
138
140
|
todoFilterLabel: '按日期筛选',
|
|
139
141
|
dueToday: '今天',
|
|
140
|
-
|
|
141
|
-
dueThisWeek: '本周',
|
|
142
|
-
dueLater: '以后',
|
|
142
|
+
dueAsap: '尽快',
|
|
143
143
|
dueNoDate: '未定',
|
|
144
|
+
dueFuture: '将来',
|
|
144
145
|
dueExpired: '已过期',
|
|
145
146
|
showBasis: '查看依据',
|
|
146
147
|
hideBasis: '收起依据',
|
|
@@ -493,7 +494,7 @@ function installStyles() {
|
|
|
493
494
|
body:not([data-ds-dark-theme]) .capital-automation-page, body:not([data-ds-dark-theme]) .capital-automation-modal { --ca-line: #0000001f; --ca-line-soft: #0000001a; --ca-table-line: #00000026; --ca-muted: #5d626a; --ca-caption: #6a6f77; --ca-hover: #eef1f5; --ca-field: #f7f8fa; --ca-business: #2f63d6; --ca-success: #16a34a; --ca-error: #dc2626; --ca-warn: #d97706; --ca-business-text: #2f63d6; --ca-success-text: #15803d; --ca-error-text: #c81e1e; --ca-warn-text: #b45309; --ca-tag-news: #2f6fd0; --ca-tag-market: #a85a08; --ca-tag-review: #6d4ac4; --ca-tag-research: #0f766e; --ca-tag-portfolio: #4d7c0f; --ca-tag-monitor: #0e7490; --ca-tag-custom: #b3246d; --ca-heat-0: #eef1f4; --ca-heat-1: #b7e4c0; --ca-heat-2: #74c98a; --ca-heat-3: #3ba55c; --ca-heat-4: #1f7a3a; --ca-heat-fail: #cf222e; }
|
|
494
495
|
.capital-automation-page { display: flex; flex-direction: column; min-height: 0; height: 100%; color: var(--dsw-alias-label-primary); }
|
|
495
496
|
.capital-automation-head { flex: none; padding: 18px 0 0; }
|
|
496
|
-
.capital-automation-headinner { box-sizing: border-box; width: min(1080px, 100%); margin: 0 auto; padding: 0 clamp(20px, 3vw, 36px); }
|
|
497
|
+
.capital-automation-headinner { box-sizing: border-box; width: min(1080px, 100%); margin: 0 auto 5px; padding: 0 clamp(20px, 3vw, 36px); }
|
|
497
498
|
.capital-automation-topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px 18px; min-width: 0; }
|
|
498
499
|
.capital-automation-brand { display: flex; align-items: center; gap: 10px; min-width: 0; justify-self: start; }
|
|
499
500
|
.capital-automation-brandmark { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; color: #fff; background: linear-gradient(135deg, #4f8cff, #7c3aed); box-shadow: inset 0 1px 0 rgba(255,255,255,.24); }
|
|
@@ -996,12 +997,13 @@ function installStyles() {
|
|
|
996
997
|
.capital-automation-todolist, .capital-automation-stocktodos, .capital-automation-gaplist, .capital-automation-gaprow { list-style: none; margin: 0; padding: 0; }
|
|
997
998
|
.capital-automation-todoitem { padding: 8px 0; border-top: .5px solid var(--ca-line); }
|
|
998
999
|
.capital-automation-todoitem:first-child { border-top: 0; }
|
|
999
|
-
.capital-automation-todoline { display: flex; align-items:
|
|
1000
|
+
.capital-automation-todoline { display: flex; flex-direction: column; align-items: stretch; gap: 5px; min-width: 0; }
|
|
1001
|
+
.capital-automation-todotop { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
|
|
1000
1002
|
.capital-automation-todokind { display: inline-flex; flex: none; align-items: center; justify-content: center; min-height: 20px; padding: 0 5px; border-radius: 5px; background: var(--dsw-alias-bg-module-platform); color: var(--ca-muted); font-size: 10px; line-height: 20px; white-space: nowrap; }
|
|
1001
1003
|
.capital-automation-todokind[data-kind="confirm"] { color: var(--ca-warn-text); }
|
|
1002
1004
|
.capital-automation-todokind[data-kind="verify"] { color: var(--ca-business-text); }
|
|
1003
1005
|
.capital-automation-todokind[data-kind="track"] { color: var(--ca-success-text); }
|
|
1004
|
-
.capital-automation-todotitle { flex:
|
|
1006
|
+
.capital-automation-todotitle { flex: none; width: 100%; min-width: 0; padding: 0; border: 0; background: transparent; font: inherit; color: var(--dsw-alias-label-primary); font-size: 13px; line-height: 20px; font-weight: 600; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
|
|
1005
1007
|
.capital-automation-todotitle:hover, .capital-automation-gaptitle:hover { color: var(--ca-business-text); }
|
|
1006
1008
|
.capital-automation-todotitle:focus-visible, .capital-automation-gaptitle:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: 2px; border-radius: 4px; }
|
|
1007
1009
|
.capital-automation-basiscaret { display: inline-flex; align-items: center; margin-left: 4px; color: var(--ca-muted); vertical-align: -2px; transform: rotate(-90deg); transition: transform .16s ease; }
|
|
@@ -1063,8 +1065,6 @@ function installStyles() {
|
|
|
1063
1065
|
.capital-automation-boardempty { min-height: 320px; padding: 32px 16px; }
|
|
1064
1066
|
.capital-automation-briefcard { padding: 14px 14px 12px; }
|
|
1065
1067
|
.capital-automation-briefcard h4 { font-size: 17px; line-height: 25px; }
|
|
1066
|
-
.capital-automation-briefhead { grid-template-columns: minmax(0, 1fr); }
|
|
1067
|
-
.capital-automation-briefhead > .capital-automation-btn { justify-self: start; }
|
|
1068
1068
|
}
|
|
1069
1069
|
`
|
|
1070
1070
|
document.head.appendChild(style)
|
|
@@ -1114,6 +1114,7 @@ function createApi() {
|
|
|
1114
1114
|
runs: (query = '') => request(`/runs${query}`),
|
|
1115
1115
|
history: (query = '') => request(`/runs/history${query}`),
|
|
1116
1116
|
board: (query = '') => request(`/board${query}`),
|
|
1117
|
+
confirmTodo: (id) => request('/board/todos/confirm', { method: 'POST', body: { id } }),
|
|
1117
1118
|
retryBrief: (runId) => request(`/board/briefs/${encodeURIComponent(runId)}/retry`, { method: 'POST' }),
|
|
1118
1119
|
notifications: () => request('/notifications'),
|
|
1119
1120
|
markRead: (body) => request('/notifications/read', { method: 'POST', body }),
|
|
@@ -1195,12 +1196,6 @@ function iconDefinition(id) {
|
|
|
1195
1196
|
: undefined
|
|
1196
1197
|
}
|
|
1197
1198
|
|
|
1198
|
-
function taskIconId(task) {
|
|
1199
|
-
if (iconDefinition(task?.icon) !== undefined) return task.icon
|
|
1200
|
-
if (task?.origin === 'custom') return DEFAULT_CUSTOM_ICON
|
|
1201
|
-
return builtinTaskIcon(task?.sourceBuiltinId)
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
1199
|
function taskIcon(task) {
|
|
1205
1200
|
return iconDefinition(taskIconId(task)) ?? TASK_ICON_CATALOG[DEFAULT_CUSTOM_ICON]
|
|
1206
1201
|
}
|
|
@@ -1225,13 +1220,13 @@ function TaskGlyph(props) {
|
|
|
1225
1220
|
}
|
|
1226
1221
|
|
|
1227
1222
|
function Glyph(props) {
|
|
1228
|
-
const { task, size = 34, large = false } = props
|
|
1223
|
+
const { task, size = 34, large = false, radius, glyphSize } = props
|
|
1229
1224
|
const edge = large ? 44 : size
|
|
1230
1225
|
return h('span', {
|
|
1231
1226
|
className: 'capital-automation-glyph',
|
|
1232
1227
|
'data-tone': toneOf(task),
|
|
1233
|
-
style: { width: edge, height: edge, borderRadius: large ? 13 : 10 },
|
|
1234
|
-
}, h(TaskGlyph, { task, size: large ? 22 : 17 }))
|
|
1228
|
+
style: { width: edge, height: edge, borderRadius: radius ?? (large ? 13 : 10) },
|
|
1229
|
+
}, h(TaskGlyph, { task, size: glyphSize ?? (large ? 22 : 17) }))
|
|
1235
1230
|
}
|
|
1236
1231
|
|
|
1237
1232
|
function IconPickerTrigger(props) {
|
|
@@ -3859,38 +3854,44 @@ function boardRelativeTime(value, now = Date.now()) {
|
|
|
3859
3854
|
return `${Math.floor(diff / year)}年前`
|
|
3860
3855
|
}
|
|
3861
3856
|
|
|
3862
|
-
function boardTodoPeriod(item) {
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3857
|
+
function boardTodoPeriod(item, now = new Date()) {
|
|
3858
|
+
const today = localDateKey(now)
|
|
3859
|
+
if (typeof item.dueAt === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(item.dueAt)) {
|
|
3860
|
+
if (item.dueAt < today) return 'expired'
|
|
3861
|
+
if (item.dueAt === today) return 'today'
|
|
3862
|
+
// Future dates are not today's action items; they become today on the date itself.
|
|
3863
|
+
return 'future'
|
|
3864
|
+
}
|
|
3865
|
+
const label = typeof item.dueLabel === 'string' ? item.dueLabel.trim() : ''
|
|
3866
|
+
const seen = typeof item.finishedAt === 'string' ? new Date(item.finishedAt) : null
|
|
3867
|
+
const seenToday = seen !== null && !Number.isNaN(seen.getTime()) && localDateKey(seen) === today
|
|
3868
|
+
if (['尽快', '马上', '现在'].includes(label)) return seenToday ? 'today' : 'future'
|
|
3869
|
+
if (['今天', '今日'].includes(label)) return seenToday ? 'today' : 'expired'
|
|
3870
|
+
return 'future'
|
|
3871
|
+
}
|
|
3872
|
+
|
|
3873
|
+
function boardTodoTodayCount(todos, now = new Date()) {
|
|
3874
|
+
return todos.filter((item) => boardTodoPeriod(item, now) === 'today').length
|
|
3871
3875
|
}
|
|
3872
3876
|
|
|
3873
3877
|
function boardTodoGroupLabel(period) {
|
|
3874
|
-
if (period === 'all') return zh.board.todoFilterAll
|
|
3875
3878
|
if (period === 'today') return zh.board.dueToday
|
|
3876
|
-
if (period === 'tomorrow') return zh.board.dueTomorrow
|
|
3877
|
-
if (period === 'week') return zh.board.dueThisWeek
|
|
3878
|
-
if (period === 'later') return zh.board.dueLater
|
|
3879
3879
|
if (period === 'expired') return zh.board.dueExpired
|
|
3880
|
-
return zh.board.
|
|
3880
|
+
return zh.board.dueFuture
|
|
3881
3881
|
}
|
|
3882
3882
|
|
|
3883
3883
|
function boardTodoFilterOptions() {
|
|
3884
|
-
return
|
|
3884
|
+
return BOARD_TODO_PERIODS.map((period) => ({ value: period, label: boardTodoGroupLabel(period) }))
|
|
3885
3885
|
}
|
|
3886
3886
|
|
|
3887
3887
|
function boardTodoDueLabel(item, period) {
|
|
3888
|
-
const
|
|
3889
|
-
if (period === 'today')
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
return
|
|
3888
|
+
const date = typeof item.dueAt === 'string' && item.dueAt.length >= 10 ? item.dueAt.slice(5) : ''
|
|
3889
|
+
if (period === 'today') {
|
|
3890
|
+
const label = typeof item.dueLabel === 'string' ? item.dueLabel.trim() : ''
|
|
3891
|
+
return ['尽快', '马上', '现在'].includes(label) && date.length === 0 ? zh.board.dueAsap : zh.board.dueToday
|
|
3892
|
+
}
|
|
3893
|
+
if (period === 'expired') return date ? `${zh.board.dueExpired} · ${date}` : zh.board.dueExpired
|
|
3894
|
+
return date || zh.board.dueNoDate
|
|
3894
3895
|
}
|
|
3895
3896
|
|
|
3896
3897
|
function boardTodoKindLabel(kind) {
|
|
@@ -4043,13 +4044,26 @@ function BoardToolbar(props) {
|
|
|
4043
4044
|
}
|
|
4044
4045
|
|
|
4045
4046
|
function BriefCard(props) {
|
|
4046
|
-
const { card, onOpenSession, onRetry, retrying } = props
|
|
4047
|
+
const { card, task, onOpenSession, onRetry, retrying } = props
|
|
4048
|
+
// Older /board payloads omit icon/origin; the task list carries the same identity.
|
|
4049
|
+
const identity = typeof card.icon === 'string' ? card : (task ?? card)
|
|
4047
4050
|
const brief = card.brief
|
|
4048
4051
|
const status = brief?.status ?? 'pending'
|
|
4049
4052
|
const titleId = `capital-automation-brief-${card.runId}`
|
|
4050
4053
|
const sessionId = card.sessionId
|
|
4051
|
-
const
|
|
4052
|
-
|
|
4054
|
+
const openSession = sessionId ? () => onOpenSession(sessionId) : null
|
|
4055
|
+
const openIcon = openSession
|
|
4056
|
+
? h('button', {
|
|
4057
|
+
type: 'button',
|
|
4058
|
+
className: 'capital-automation-btn',
|
|
4059
|
+
'data-size': 'icon',
|
|
4060
|
+
title: zh.openSession,
|
|
4061
|
+
'aria-label': zh.openSession,
|
|
4062
|
+
onClick: openSession,
|
|
4063
|
+
}, h(IconRightUpOutlineRegular, { size: 14 }))
|
|
4064
|
+
: null
|
|
4065
|
+
const openLink = openSession
|
|
4066
|
+
? h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', onClick: openSession }, zh.openSession)
|
|
4053
4067
|
: null
|
|
4054
4068
|
const trigger = card.trigger === 'manual' ? zh.triggerManual : zh.triggerScheduled
|
|
4055
4069
|
const relativeTime = boardRelativeTime(card.finishedAt)
|
|
@@ -4074,11 +4088,11 @@ function BriefCard(props) {
|
|
|
4074
4088
|
disabled: retrying === true,
|
|
4075
4089
|
onClick: () => onRetry(card.runId),
|
|
4076
4090
|
}, retrying === true ? zh.processing : zh.board.retry),
|
|
4077
|
-
|
|
4091
|
+
openLink))
|
|
4078
4092
|
} else if (status === 'skipped') {
|
|
4079
4093
|
body = h('div', { className: 'capital-automation-briefstate' },
|
|
4080
4094
|
h('p', null, zh.board.briefSkipped),
|
|
4081
|
-
h('div', { className: 'capital-automation-briefactions' },
|
|
4095
|
+
h('div', { className: 'capital-automation-briefactions' }, openLink))
|
|
4082
4096
|
} else {
|
|
4083
4097
|
body = h('div', { className: 'capital-automation-briefstate' },
|
|
4084
4098
|
h(SkeletonBlock, { width: '72%', height: 14 }),
|
|
@@ -4089,6 +4103,7 @@ function BriefCard(props) {
|
|
|
4089
4103
|
return h('article', { className: 'capital-automation-briefcard', 'data-status': status, 'aria-labelledby': titleId },
|
|
4090
4104
|
h('div', { className: 'capital-automation-briefhead' },
|
|
4091
4105
|
h('div', { className: 'capital-automation-brieftitle' },
|
|
4106
|
+
h(Glyph, { task: identity, size: 24, radius: 8, glyphSize: 14 }),
|
|
4092
4107
|
h('h3', { id: titleId }, card.taskTitle),
|
|
4093
4108
|
h('span', { className: 'capital-automation-tag', 'data-tone': card.category }, categoryLabel(card.category)),
|
|
4094
4109
|
h('span', { className: 'capital-automation-tag' }, trigger),
|
|
@@ -4097,7 +4112,7 @@ function BriefCard(props) {
|
|
|
4097
4112
|
dateTime: card.finishedAt,
|
|
4098
4113
|
title: exactTime,
|
|
4099
4114
|
}, relativeTime)),
|
|
4100
|
-
|
|
4115
|
+
openIcon),
|
|
4101
4116
|
body)
|
|
4102
4117
|
}
|
|
4103
4118
|
|
|
@@ -4114,7 +4129,9 @@ function BoardSkeleton(props) {
|
|
|
4114
4129
|
h('div', { className: 'capital-automation-boardgrid', 'data-rail': railOpen === true ? 'open' : 'closed' },
|
|
4115
4130
|
h('section', { className: 'capital-automation-boardmain' },
|
|
4116
4131
|
[0, 1].map((index) => h('div', { key: index, className: 'capital-automation-briefcard' },
|
|
4117
|
-
h(
|
|
4132
|
+
h('div', { className: 'capital-automation-brieftitle' },
|
|
4133
|
+
h(SkeletonBlock, { width: 24, height: 24, radius: 8 }),
|
|
4134
|
+
h(SkeletonBlock, { width: '48%', height: 12 })),
|
|
4118
4135
|
h(SkeletonBlock, { width: '80%', height: 16 }),
|
|
4119
4136
|
h(SkeletonBlock, { width: '100%', height: 10 }),
|
|
4120
4137
|
h(SkeletonBlock, { width: '92%', height: 10 })))),
|
|
@@ -4128,7 +4145,7 @@ function BoardSkeleton(props) {
|
|
|
4128
4145
|
}
|
|
4129
4146
|
|
|
4130
4147
|
function BriefFeed(props) {
|
|
4131
|
-
const { cards, loading, error, onOpenSession, onRetry, retryingRunId, onViewAll, onClearFilter, onLoadMore, hasMore, loadingMore, railOpen } = props
|
|
4148
|
+
const { cards, tasks, loading, error, onOpenSession, onRetry, retryingRunId, onViewAll, onClearFilter, onLoadMore, hasMore, loadingMore, railOpen } = props
|
|
4132
4149
|
if (loading === true) return h(BoardSkeleton, { railOpen })
|
|
4133
4150
|
if (typeof error === 'string' && error.length > 0) {
|
|
4134
4151
|
return h('section', { className: 'capital-automation-boardmain', id: 'capital-automation-briefs' },
|
|
@@ -4144,10 +4161,12 @@ function BriefFeed(props) {
|
|
|
4144
4161
|
onViewAll ? h('button', { type: 'button', className: 'capital-automation-btn', onClick: onViewAll }, zh.board.viewAll) : null,
|
|
4145
4162
|
onClearFilter ? h('button', { type: 'button', className: 'capital-automation-btn', onClick: onClearFilter }, zh.board.clearFilter) : null)))
|
|
4146
4163
|
}
|
|
4164
|
+
const taskById = new Map((Array.isArray(tasks) ? tasks : []).map((task) => [task.id, task]))
|
|
4147
4165
|
return h('section', { className: 'capital-automation-boardmain', id: 'capital-automation-briefs', 'aria-label': zh.board.briefTitle },
|
|
4148
4166
|
cards.map((card) => h(BriefCard, {
|
|
4149
4167
|
key: card.runId,
|
|
4150
4168
|
card,
|
|
4169
|
+
task: taskById.get(card.taskId),
|
|
4151
4170
|
onOpenSession,
|
|
4152
4171
|
onRetry,
|
|
4153
4172
|
retrying: retryingRunId === card.runId,
|
|
@@ -4163,7 +4182,7 @@ function BriefFeed(props) {
|
|
|
4163
4182
|
}
|
|
4164
4183
|
|
|
4165
4184
|
function TodoRow(props) {
|
|
4166
|
-
const { item, period, showDue = true, onOpenSession } = props
|
|
4185
|
+
const { item, period, showDue = true, onOpenSession, onAck, acking = false, ackDisabled = false } = props
|
|
4167
4186
|
const [open, setOpen] = useState(false)
|
|
4168
4187
|
const quote = item.sourceQuote ?? item.sources?.[0]?.sourceQuote
|
|
4169
4188
|
const due = showDue === true ? boardTodoDueLabel(item, period) : ''
|
|
@@ -4179,7 +4198,17 @@ function TodoRow(props) {
|
|
|
4179
4198
|
const basisCaret = h('span', { className: 'capital-automation-basiscaret', 'aria-hidden': 'true' }, h(IconChevronDownOutlineRegular, { size: 12 }))
|
|
4180
4199
|
return h('li', { className: 'capital-automation-todoitem' },
|
|
4181
4200
|
h('div', { className: 'capital-automation-todoline' },
|
|
4182
|
-
h('
|
|
4201
|
+
h('div', { className: 'capital-automation-todotop' },
|
|
4202
|
+
h('span', { className: 'capital-automation-todokind', 'data-kind': item.kind }, boardTodoKindLabel(item.kind)),
|
|
4203
|
+
h('button', {
|
|
4204
|
+
type: 'button',
|
|
4205
|
+
className: 'capital-automation-btn',
|
|
4206
|
+
'data-size': 'sm',
|
|
4207
|
+
title: zh.board.todoAckTitle,
|
|
4208
|
+
'aria-label': `${zh.board.todoAckTitle}:${item.title}`,
|
|
4209
|
+
disabled: ackDisabled === true,
|
|
4210
|
+
onClick: () => onAck(item),
|
|
4211
|
+
}, acking === true ? zh.processing : zh.board.todoAck)),
|
|
4183
4212
|
h('button', {
|
|
4184
4213
|
type: 'button',
|
|
4185
4214
|
className: 'capital-automation-todotitle',
|
|
@@ -4240,13 +4269,14 @@ function BoardPanel(props) {
|
|
|
4240
4269
|
}
|
|
4241
4270
|
|
|
4242
4271
|
function TodoPanel(props) {
|
|
4243
|
-
const { todos, onOpenSession, open, onToggle } = props
|
|
4244
|
-
const [filter, setFilter] = useState('
|
|
4245
|
-
const
|
|
4272
|
+
const { todos, onOpenSession, onAckTodo, ackingTodoId, open, onToggle } = props
|
|
4273
|
+
const [filter, setFilter] = useState('today')
|
|
4274
|
+
const now = new Date()
|
|
4275
|
+
const entries = todos.map((item) => ({ item, period: boardTodoPeriod(item, now) }))
|
|
4246
4276
|
entries.sort((left, right) => BOARD_TODO_PERIODS.indexOf(left.period) - BOARD_TODO_PERIODS.indexOf(right.period))
|
|
4247
|
-
const visible =
|
|
4248
|
-
const emptyText = filter === '
|
|
4249
|
-
? zh.board.
|
|
4277
|
+
const visible = entries.filter((entry) => entry.period === filter)
|
|
4278
|
+
const emptyText = filter === 'today'
|
|
4279
|
+
? zh.board.todoEmptyToday
|
|
4250
4280
|
: zh.board.todoEmptyGroup.replace('{label}', boardTodoGroupLabel(filter))
|
|
4251
4281
|
return h(BoardPanel, {
|
|
4252
4282
|
id: 'capital-automation-todo',
|
|
@@ -4268,8 +4298,11 @@ function TodoPanel(props) {
|
|
|
4268
4298
|
key: entry.item.id,
|
|
4269
4299
|
item: entry.item,
|
|
4270
4300
|
period: entry.period,
|
|
4271
|
-
showDue:
|
|
4301
|
+
showDue: true,
|
|
4272
4302
|
onOpenSession,
|
|
4303
|
+
onAck: onAckTodo,
|
|
4304
|
+
acking: ackingTodoId === entry.item.id,
|
|
4305
|
+
ackDisabled: ackingTodoId !== null && ackingTodoId !== undefined,
|
|
4273
4306
|
}))))
|
|
4274
4307
|
}
|
|
4275
4308
|
|
|
@@ -4437,9 +4470,9 @@ function RunHealthPanel(props) {
|
|
|
4437
4470
|
|
|
4438
4471
|
function BoardPage(props) {
|
|
4439
4472
|
const {
|
|
4440
|
-
board, loading, error, range, category, onRange, onCategory, onRefresh,
|
|
4473
|
+
board, tasks, loading, error, range, category, onRange, onCategory, onRefresh,
|
|
4441
4474
|
onOpenSession, onRetryBrief, retryingRunId, onLoadMore, loadingMore, onGoTasks, onNewTask, onGoRuns,
|
|
4442
|
-
hasActiveTasks, storageReady,
|
|
4475
|
+
onAckTodo, ackingTodoId, hasActiveTasks, storageReady,
|
|
4443
4476
|
} = props
|
|
4444
4477
|
const [railOpen, setRailOpen] = useState(() => readBoardUi().rail !== false)
|
|
4445
4478
|
const [openPanels, setOpenPanels] = useState(() => boardPanelFlags(readBoardUi().panels))
|
|
@@ -4500,6 +4533,9 @@ function BoardPage(props) {
|
|
|
4500
4533
|
error.length > 0 ? h('div', { className: 'capital-automation-banner', 'data-tone': 'error', role: 'alert' }, error) : null,
|
|
4501
4534
|
h(BoardEmpty, { hasActiveTasks, storageReady, onGoTasks, onNewTask }))
|
|
4502
4535
|
}
|
|
4536
|
+
const boardStats = board?.stats === undefined
|
|
4537
|
+
? undefined
|
|
4538
|
+
: { ...board.stats, todos: boardTodoTodayCount(board?.todos ?? []) }
|
|
4503
4539
|
return h('div', { className: 'capital-automation-board' },
|
|
4504
4540
|
h(BoardToolbar, {
|
|
4505
4541
|
range,
|
|
@@ -4512,13 +4548,14 @@ function BoardPage(props) {
|
|
|
4512
4548
|
onToggleRail: toggleRail,
|
|
4513
4549
|
}),
|
|
4514
4550
|
error.length > 0 ? h('div', { className: 'capital-automation-banner', 'data-tone': 'error', role: 'alert' }, error) : null,
|
|
4515
|
-
h(BoardStats, { stats:
|
|
4551
|
+
h(BoardStats, { stats: boardStats, onJump: jumpTo }),
|
|
4516
4552
|
h('div', {
|
|
4517
4553
|
className: 'capital-automation-boardgrid',
|
|
4518
4554
|
'data-rail': railOpen === true ? 'open' : 'closed',
|
|
4519
4555
|
},
|
|
4520
4556
|
h(BriefFeed, {
|
|
4521
4557
|
cards: board?.cards ?? [],
|
|
4558
|
+
tasks,
|
|
4522
4559
|
loading: loading === true && board === null,
|
|
4523
4560
|
error: '',
|
|
4524
4561
|
onOpenSession,
|
|
@@ -4536,7 +4573,14 @@ function BoardPage(props) {
|
|
|
4536
4573
|
className: 'capital-automation-boardrail',
|
|
4537
4574
|
hidden: railOpen !== true,
|
|
4538
4575
|
},
|
|
4539
|
-
h(TodoPanel, {
|
|
4576
|
+
h(TodoPanel, {
|
|
4577
|
+
todos: board?.todos ?? [],
|
|
4578
|
+
onOpenSession,
|
|
4579
|
+
onAckTodo,
|
|
4580
|
+
ackingTodoId,
|
|
4581
|
+
open: openPanels.todo,
|
|
4582
|
+
onToggle: () => togglePanel('todo'),
|
|
4583
|
+
}),
|
|
4540
4584
|
h(StockRadar, {
|
|
4541
4585
|
stocks: board?.stocks ?? [],
|
|
4542
4586
|
todos: board?.todos ?? [],
|
|
@@ -4574,6 +4618,7 @@ function AutomationPage(props) {
|
|
|
4574
4618
|
const [boardRange, setBoardRange] = useState('14')
|
|
4575
4619
|
const [boardCategory, setBoardCategory] = useState('all')
|
|
4576
4620
|
const [retryingBriefId, setRetryingBriefId] = useState(null)
|
|
4621
|
+
const [ackingTodoId, setAckingTodoId] = useState(null)
|
|
4577
4622
|
const [boardLoadingMore, setBoardLoadingMore] = useState(false)
|
|
4578
4623
|
const [unread, setUnread] = useState(0)
|
|
4579
4624
|
const [selectedId, setSelectedId] = useState(null)
|
|
@@ -4696,6 +4741,39 @@ function AutomationPage(props) {
|
|
|
4696
4741
|
}
|
|
4697
4742
|
}
|
|
4698
4743
|
|
|
4744
|
+
async function ackTodo(item) {
|
|
4745
|
+
if (ackingTodoId !== null) return
|
|
4746
|
+
setAckingTodoId(item.id)
|
|
4747
|
+
setBoardError('')
|
|
4748
|
+
try {
|
|
4749
|
+
await api.confirmTodo(item.id)
|
|
4750
|
+
setBoard((current) => {
|
|
4751
|
+
if (current === null) return current
|
|
4752
|
+
const removed = (current.todos ?? []).find((entry) => entry.id === item.id)
|
|
4753
|
+
if (removed === undefined) return current
|
|
4754
|
+
const todos = current.todos.filter((entry) => entry.id !== item.id)
|
|
4755
|
+
const stocks = (current.stocks ?? []).map((stock) =>
|
|
4756
|
+
removed.symbol !== undefined && stock.symbol === removed.symbol
|
|
4757
|
+
? { ...stock, todoCount: Math.max(0, (stock.todoCount ?? 0) - 1) }
|
|
4758
|
+
: stock)
|
|
4759
|
+
return {
|
|
4760
|
+
...current,
|
|
4761
|
+
todos,
|
|
4762
|
+
stocks,
|
|
4763
|
+
stats: current.stats === undefined
|
|
4764
|
+
? current.stats
|
|
4765
|
+
: { ...current.stats, todos: Math.max(0, (current.stats.todos ?? 0) - 1) },
|
|
4766
|
+
}
|
|
4767
|
+
})
|
|
4768
|
+
setNotice(zh.board.todoAcked)
|
|
4769
|
+
void loadBoard(boardRange, boardCategory)
|
|
4770
|
+
} catch (error) {
|
|
4771
|
+
setBoardError(error.message ?? zh.errorGeneric)
|
|
4772
|
+
} finally {
|
|
4773
|
+
setAckingTodoId(null)
|
|
4774
|
+
}
|
|
4775
|
+
}
|
|
4776
|
+
|
|
4699
4777
|
async function loadDetail(id) {
|
|
4700
4778
|
const requestSequence = detailSequenceRef.current + 1
|
|
4701
4779
|
detailSequenceRef.current = requestSequence
|
|
@@ -4907,6 +4985,7 @@ function AutomationPage(props) {
|
|
|
4907
4985
|
tab === 'board'
|
|
4908
4986
|
? h(BoardPage, {
|
|
4909
4987
|
board,
|
|
4988
|
+
tasks,
|
|
4910
4989
|
loading: boardLoading,
|
|
4911
4990
|
error: boardError,
|
|
4912
4991
|
range: boardRange,
|
|
@@ -4917,6 +4996,8 @@ function AutomationPage(props) {
|
|
|
4917
4996
|
onOpenSession: openSession,
|
|
4918
4997
|
onRetryBrief: (runId) => { void retryBrief(runId) },
|
|
4919
4998
|
retryingRunId: retryingBriefId,
|
|
4999
|
+
onAckTodo: (item) => { void ackTodo(item) },
|
|
5000
|
+
ackingTodoId,
|
|
4920
5001
|
onLoadMore: () => { void loadMoreBoard() },
|
|
4921
5002
|
loadingMore: boardLoadingMore,
|
|
4922
5003
|
onGoTasks: () => switchTab('tasks'),
|
package/automation/defaults.js
CHANGED
|
@@ -35,6 +35,7 @@ export const QUIET_SETTLE_MS = 750
|
|
|
35
35
|
export const MAX_RUNS_PER_TASK = 200
|
|
36
36
|
export const MAX_RUNS_PER_PROFILE = 2_000
|
|
37
37
|
export const MAX_NOTIFICATIONS_PER_PROFILE = 200
|
|
38
|
+
export const MAX_TODO_ACKS_PER_PROFILE = 500
|
|
38
39
|
export const MAX_ERRORS_PER_RUN = 20
|
|
39
40
|
|
|
40
41
|
export const MAX_TITLE_CHARS = 120
|
package/automation/package.json
CHANGED
package/automation/route.js
CHANGED
|
@@ -233,6 +233,9 @@ async function dispatch({ req, method, suffix, url, service, requestId }) {
|
|
|
233
233
|
if (suffix === '/board' && method === 'GET') {
|
|
234
234
|
return { body: await service.board(queryOf(url, new Set(['days', 'tz', 'limit', 'before', 'category']), 5)) }
|
|
235
235
|
}
|
|
236
|
+
if (suffix === '/board/todos/confirm' && method === 'POST') {
|
|
237
|
+
return { body: await service.confirmTodo(await readBody(req)) }
|
|
238
|
+
}
|
|
236
239
|
const briefRetry = /^\/board\/briefs\/([^/]+)\/retry$/.exec(suffix)
|
|
237
240
|
if (briefRetry !== null && method === 'POST') {
|
|
238
241
|
return { body: await service.retryBrief(decodeId(briefRetry[1])), status: 202 }
|
package/automation/runner.js
CHANGED
|
@@ -440,7 +440,7 @@ export function createRunRunner(options) {
|
|
|
440
440
|
armIdle(entry)
|
|
441
441
|
return
|
|
442
442
|
}
|
|
443
|
-
await finalize(entry, outcomeOf(entry), outcomeError(entry))
|
|
443
|
+
await finalize(entry, outcomeOf(entry), { error: outcomeError(entry) })
|
|
444
444
|
} finally {
|
|
445
445
|
entry.completing = false
|
|
446
446
|
}
|
|
@@ -680,7 +680,7 @@ export function createRunRunner(options) {
|
|
|
680
680
|
if (settled !== undefined) {
|
|
681
681
|
entry.abandoned = true
|
|
682
682
|
entry.abandonPromise = (async () => {
|
|
683
|
-
await finalize(entry, settled)
|
|
683
|
+
await finalize(entry, settled, { error: outcomeError(entry) })
|
|
684
684
|
await stopEntryAgent(entry, controller)
|
|
685
685
|
})()
|
|
686
686
|
return entry.abandonPromise
|
package/automation/schema.js
CHANGED
|
@@ -338,6 +338,18 @@ export const TaskBriefSchema = z.strictObject({
|
|
|
338
338
|
}
|
|
339
339
|
})
|
|
340
340
|
|
|
341
|
+
/**
|
|
342
|
+
* User acknowledgement of an aggregated TODO. Briefs stay read-only; the ack only suppresses
|
|
343
|
+
* the version the user saw. A later run mentioning the same item produces a newer `lastSeenAt`
|
|
344
|
+
* and the item shows up again.
|
|
345
|
+
*/
|
|
346
|
+
export const TodoAckSchema = z.strictObject({
|
|
347
|
+
schemaVersion: z.literal(1),
|
|
348
|
+
profileKey: z.string().min(1).max(80),
|
|
349
|
+
todoId: z.string().min(1).max(200),
|
|
350
|
+
confirmedAt: isoInstant,
|
|
351
|
+
})
|
|
352
|
+
|
|
341
353
|
export const OwnerRecordSchema = z.strictObject({
|
|
342
354
|
schemaVersion: z.literal(1),
|
|
343
355
|
profileKey: z.string().min(1).max(80),
|
|
@@ -374,6 +386,10 @@ export const TaskPatchSchema = z.strictObject({
|
|
|
374
386
|
notifications: NotificationsSchema.optional(),
|
|
375
387
|
})
|
|
376
388
|
|
|
389
|
+
export const TodoConfirmSchema = z.strictObject({
|
|
390
|
+
id: z.string().min(1).max(200),
|
|
391
|
+
})
|
|
392
|
+
|
|
377
393
|
export const NotificationsReadSchema = z.strictObject({
|
|
378
394
|
ids: z.array(z.string().min(1).max(80)).max(200).optional(),
|
|
379
395
|
all: z.boolean().optional(),
|
package/automation/service.js
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
TaskCategorySchema,
|
|
22
22
|
TaskCreateSchema,
|
|
23
23
|
TaskPatchSchema,
|
|
24
|
+
TodoConfirmSchema,
|
|
24
25
|
parseStrict,
|
|
25
26
|
} from './schema.js'
|
|
26
27
|
import { sanitizeMessage } from './redact.js'
|
|
@@ -384,6 +385,19 @@ export function createAutomationService(options) {
|
|
|
384
385
|
}
|
|
385
386
|
}
|
|
386
387
|
|
|
388
|
+
async function confirmTodo(input) {
|
|
389
|
+
if (boardService === undefined || typeof boardService.confirmTodo !== 'function') {
|
|
390
|
+
throw new AutomationError('board_unavailable', '看板服务暂时不可用。', 503)
|
|
391
|
+
}
|
|
392
|
+
const parsed = parseStrict(TodoConfirmSchema, input, 'board/todo-confirm')
|
|
393
|
+
try {
|
|
394
|
+
return await boardService.confirmTodo(parsed.id)
|
|
395
|
+
} catch (error) {
|
|
396
|
+
if (error?.boardError === true) throw new AutomationError(error.code, error.message, error.status ?? 400)
|
|
397
|
+
throw error
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
387
401
|
async function retryBrief(runId) {
|
|
388
402
|
if (briefs === undefined || typeof briefs.retry !== 'function') {
|
|
389
403
|
throw new AutomationError('brief_not_found', '任务简报服务暂时不可用。', 503)
|
|
@@ -444,6 +458,7 @@ export function createAutomationService(options) {
|
|
|
444
458
|
listRuns,
|
|
445
459
|
runHistory,
|
|
446
460
|
board,
|
|
461
|
+
confirmTodo,
|
|
447
462
|
retryBrief,
|
|
448
463
|
listNotifications,
|
|
449
464
|
markNotificationsRead,
|
package/automation/store.js
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
TaskBriefSchema,
|
|
16
16
|
TaskOverridesSchema,
|
|
17
17
|
TaskRecordSchema,
|
|
18
|
+
TodoAckSchema,
|
|
18
19
|
isActiveRun,
|
|
19
20
|
parseStrict,
|
|
20
21
|
resolveTaskRecord,
|
|
@@ -27,6 +28,7 @@ import {
|
|
|
27
28
|
MAX_NOTIFICATIONS_PER_PROFILE,
|
|
28
29
|
MAX_RUNS_PER_PROFILE,
|
|
29
30
|
MAX_RUNS_PER_TASK,
|
|
31
|
+
MAX_TODO_ACKS_PER_PROFILE,
|
|
30
32
|
SETTLED_RUN_STATUSES,
|
|
31
33
|
} from './defaults.js'
|
|
32
34
|
import { canonicalTrigger, formatInZone, nextOccurrence } from './time.js'
|
|
@@ -48,6 +50,7 @@ export const domainSpec = {
|
|
|
48
50
|
notifications: { valueSchema: NotificationSchema },
|
|
49
51
|
meta: { valueSchema: OwnerRecordSchema },
|
|
50
52
|
briefs: { valueSchema: TaskBriefSchema },
|
|
53
|
+
todo_acks: { valueSchema: TodoAckSchema },
|
|
51
54
|
},
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -60,6 +63,11 @@ function builtinRecordId(profileKey, builtinId) {
|
|
|
60
63
|
return `bt_${createHash('sha256').update(`${profileKey}:${builtinId}`).digest('hex').slice(0, 24)}`
|
|
61
64
|
}
|
|
62
65
|
|
|
66
|
+
/** Hash the long, user-visible TODO id so the storage key stays bounded and plain. */
|
|
67
|
+
function todoAckRecordId(profileKey, todoId) {
|
|
68
|
+
return `ta_${createHash('sha256').update(`${profileKey}\u0000${todoId}`).digest('hex').slice(0, 32)}`
|
|
69
|
+
}
|
|
70
|
+
|
|
63
71
|
function iso(now) {
|
|
64
72
|
return new Date(now).toISOString()
|
|
65
73
|
}
|
|
@@ -184,6 +192,7 @@ export function createAutomationStore(options) {
|
|
|
184
192
|
notifications: domain.table('notifications'),
|
|
185
193
|
meta: domain.table('meta'),
|
|
186
194
|
briefs: domain.table('briefs'),
|
|
195
|
+
todoAcks: domain.table('todo_acks'),
|
|
187
196
|
}
|
|
188
197
|
})()
|
|
189
198
|
}
|
|
@@ -748,6 +757,40 @@ export function createAutomationStore(options) {
|
|
|
748
757
|
return count
|
|
749
758
|
}
|
|
750
759
|
|
|
760
|
+
async function listTodoAcks() {
|
|
761
|
+
const tables = await ensure()
|
|
762
|
+
const records = []
|
|
763
|
+
for (const [, record] of tables.todoAcks.entries()) {
|
|
764
|
+
if (record.profileKey === profileKey) records.push(record)
|
|
765
|
+
}
|
|
766
|
+
return records
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
async function retainTodoAcks(tables) {
|
|
770
|
+
const records = []
|
|
771
|
+
for (const [key, record] of tables.todoAcks.entries()) {
|
|
772
|
+
if (record.profileKey === profileKey) records.push({ key, record })
|
|
773
|
+
}
|
|
774
|
+
if (records.length <= MAX_TODO_ACKS_PER_PROFILE) return
|
|
775
|
+
records.sort((left, right) =>
|
|
776
|
+
right.record.confirmedAt.localeCompare(left.record.confirmedAt)
|
|
777
|
+
|| right.key.localeCompare(left.key))
|
|
778
|
+
for (const entry of records.slice(MAX_TODO_ACKS_PER_PROFILE)) await tables.todoAcks.delete(entry.key)
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
async function confirmTodo(todoId) {
|
|
782
|
+
const tables = await ensure()
|
|
783
|
+
const record = parseStrict(TodoAckSchema, {
|
|
784
|
+
schemaVersion: 1,
|
|
785
|
+
profileKey,
|
|
786
|
+
todoId,
|
|
787
|
+
confirmedAt: iso(now()),
|
|
788
|
+
}, 'todo ack')
|
|
789
|
+
await tables.todoAcks.put(todoAckRecordId(profileKey, todoId), record)
|
|
790
|
+
await retainTodoAcks(tables)
|
|
791
|
+
return record
|
|
792
|
+
}
|
|
793
|
+
|
|
751
794
|
async function updateBrief(runId, patch) {
|
|
752
795
|
const tables = await ensure()
|
|
753
796
|
const current = tables.briefs.get(runId)
|
|
@@ -949,6 +992,8 @@ export function createAutomationStore(options) {
|
|
|
949
992
|
listBriefsForRuns,
|
|
950
993
|
listBriefsForProfile,
|
|
951
994
|
countBriefs,
|
|
995
|
+
listTodoAcks,
|
|
996
|
+
confirmTodo,
|
|
952
997
|
updateBrief,
|
|
953
998
|
deleteBrief,
|
|
954
999
|
publicBrief,
|