@v587d/capital-generation 2.18.0 → 2.19.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.
- package/CHANGELOG.md +35 -0
- package/README.md +2 -2
- package/automation/board.js +18 -2
- package/automation/brief.js +3 -13
- package/automation/client.js +10 -11
- package/automation/client.src.cjs +128 -50
- 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/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
|
@@ -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: '收起依据',
|
|
@@ -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 }),
|
|
@@ -3859,38 +3860,44 @@ function boardRelativeTime(value, now = Date.now()) {
|
|
|
3859
3860
|
return `${Math.floor(diff / year)}年前`
|
|
3860
3861
|
}
|
|
3861
3862
|
|
|
3862
|
-
function boardTodoPeriod(item) {
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3863
|
+
function boardTodoPeriod(item, now = new Date()) {
|
|
3864
|
+
const today = localDateKey(now)
|
|
3865
|
+
if (typeof item.dueAt === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(item.dueAt)) {
|
|
3866
|
+
if (item.dueAt < today) return 'expired'
|
|
3867
|
+
if (item.dueAt === today) return 'today'
|
|
3868
|
+
// Future dates are not today's action items; they become today on the date itself.
|
|
3869
|
+
return 'future'
|
|
3870
|
+
}
|
|
3871
|
+
const label = typeof item.dueLabel === 'string' ? item.dueLabel.trim() : ''
|
|
3872
|
+
const seen = typeof item.finishedAt === 'string' ? new Date(item.finishedAt) : null
|
|
3873
|
+
const seenToday = seen !== null && !Number.isNaN(seen.getTime()) && localDateKey(seen) === today
|
|
3874
|
+
if (['尽快', '马上', '现在'].includes(label)) return seenToday ? 'today' : 'future'
|
|
3875
|
+
if (['今天', '今日'].includes(label)) return seenToday ? 'today' : 'expired'
|
|
3876
|
+
return 'future'
|
|
3877
|
+
}
|
|
3878
|
+
|
|
3879
|
+
function boardTodoTodayCount(todos, now = new Date()) {
|
|
3880
|
+
return todos.filter((item) => boardTodoPeriod(item, now) === 'today').length
|
|
3871
3881
|
}
|
|
3872
3882
|
|
|
3873
3883
|
function boardTodoGroupLabel(period) {
|
|
3874
|
-
if (period === 'all') return zh.board.todoFilterAll
|
|
3875
3884
|
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
3885
|
if (period === 'expired') return zh.board.dueExpired
|
|
3880
|
-
return zh.board.
|
|
3886
|
+
return zh.board.dueFuture
|
|
3881
3887
|
}
|
|
3882
3888
|
|
|
3883
3889
|
function boardTodoFilterOptions() {
|
|
3884
|
-
return
|
|
3890
|
+
return BOARD_TODO_PERIODS.map((period) => ({ value: period, label: boardTodoGroupLabel(period) }))
|
|
3885
3891
|
}
|
|
3886
3892
|
|
|
3887
3893
|
function boardTodoDueLabel(item, period) {
|
|
3888
|
-
const
|
|
3889
|
-
if (period === 'today')
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
return
|
|
3894
|
+
const date = typeof item.dueAt === 'string' && item.dueAt.length >= 10 ? item.dueAt.slice(5) : ''
|
|
3895
|
+
if (period === 'today') {
|
|
3896
|
+
const label = typeof item.dueLabel === 'string' ? item.dueLabel.trim() : ''
|
|
3897
|
+
return ['尽快', '马上', '现在'].includes(label) && date.length === 0 ? zh.board.dueAsap : zh.board.dueToday
|
|
3898
|
+
}
|
|
3899
|
+
if (period === 'expired') return date ? `${zh.board.dueExpired} · ${date}` : zh.board.dueExpired
|
|
3900
|
+
return date || zh.board.dueNoDate
|
|
3894
3901
|
}
|
|
3895
3902
|
|
|
3896
3903
|
function boardTodoKindLabel(kind) {
|
|
@@ -4048,8 +4055,19 @@ function BriefCard(props) {
|
|
|
4048
4055
|
const status = brief?.status ?? 'pending'
|
|
4049
4056
|
const titleId = `capital-automation-brief-${card.runId}`
|
|
4050
4057
|
const sessionId = card.sessionId
|
|
4051
|
-
const
|
|
4052
|
-
|
|
4058
|
+
const openSession = sessionId ? () => onOpenSession(sessionId) : null
|
|
4059
|
+
const openIcon = openSession
|
|
4060
|
+
? h('button', {
|
|
4061
|
+
type: 'button',
|
|
4062
|
+
className: 'capital-automation-btn',
|
|
4063
|
+
'data-size': 'icon',
|
|
4064
|
+
title: zh.openSession,
|
|
4065
|
+
'aria-label': zh.openSession,
|
|
4066
|
+
onClick: openSession,
|
|
4067
|
+
}, h(IconRightUpOutlineRegular, { size: 14 }))
|
|
4068
|
+
: null
|
|
4069
|
+
const openLink = openSession
|
|
4070
|
+
? h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', onClick: openSession }, zh.openSession)
|
|
4053
4071
|
: null
|
|
4054
4072
|
const trigger = card.trigger === 'manual' ? zh.triggerManual : zh.triggerScheduled
|
|
4055
4073
|
const relativeTime = boardRelativeTime(card.finishedAt)
|
|
@@ -4074,11 +4092,11 @@ function BriefCard(props) {
|
|
|
4074
4092
|
disabled: retrying === true,
|
|
4075
4093
|
onClick: () => onRetry(card.runId),
|
|
4076
4094
|
}, retrying === true ? zh.processing : zh.board.retry),
|
|
4077
|
-
|
|
4095
|
+
openLink))
|
|
4078
4096
|
} else if (status === 'skipped') {
|
|
4079
4097
|
body = h('div', { className: 'capital-automation-briefstate' },
|
|
4080
4098
|
h('p', null, zh.board.briefSkipped),
|
|
4081
|
-
h('div', { className: 'capital-automation-briefactions' },
|
|
4099
|
+
h('div', { className: 'capital-automation-briefactions' }, openLink))
|
|
4082
4100
|
} else {
|
|
4083
4101
|
body = h('div', { className: 'capital-automation-briefstate' },
|
|
4084
4102
|
h(SkeletonBlock, { width: '72%', height: 14 }),
|
|
@@ -4097,7 +4115,7 @@ function BriefCard(props) {
|
|
|
4097
4115
|
dateTime: card.finishedAt,
|
|
4098
4116
|
title: exactTime,
|
|
4099
4117
|
}, relativeTime)),
|
|
4100
|
-
|
|
4118
|
+
openIcon),
|
|
4101
4119
|
body)
|
|
4102
4120
|
}
|
|
4103
4121
|
|
|
@@ -4163,7 +4181,7 @@ function BriefFeed(props) {
|
|
|
4163
4181
|
}
|
|
4164
4182
|
|
|
4165
4183
|
function TodoRow(props) {
|
|
4166
|
-
const { item, period, showDue = true, onOpenSession } = props
|
|
4184
|
+
const { item, period, showDue = true, onOpenSession, onAck, acking = false, ackDisabled = false } = props
|
|
4167
4185
|
const [open, setOpen] = useState(false)
|
|
4168
4186
|
const quote = item.sourceQuote ?? item.sources?.[0]?.sourceQuote
|
|
4169
4187
|
const due = showDue === true ? boardTodoDueLabel(item, period) : ''
|
|
@@ -4179,7 +4197,17 @@ function TodoRow(props) {
|
|
|
4179
4197
|
const basisCaret = h('span', { className: 'capital-automation-basiscaret', 'aria-hidden': 'true' }, h(IconChevronDownOutlineRegular, { size: 12 }))
|
|
4180
4198
|
return h('li', { className: 'capital-automation-todoitem' },
|
|
4181
4199
|
h('div', { className: 'capital-automation-todoline' },
|
|
4182
|
-
h('
|
|
4200
|
+
h('div', { className: 'capital-automation-todotop' },
|
|
4201
|
+
h('span', { className: 'capital-automation-todokind', 'data-kind': item.kind }, boardTodoKindLabel(item.kind)),
|
|
4202
|
+
h('button', {
|
|
4203
|
+
type: 'button',
|
|
4204
|
+
className: 'capital-automation-btn',
|
|
4205
|
+
'data-size': 'sm',
|
|
4206
|
+
title: zh.board.todoAckTitle,
|
|
4207
|
+
'aria-label': `${zh.board.todoAckTitle}:${item.title}`,
|
|
4208
|
+
disabled: ackDisabled === true,
|
|
4209
|
+
onClick: () => onAck(item),
|
|
4210
|
+
}, acking === true ? zh.processing : zh.board.todoAck)),
|
|
4183
4211
|
h('button', {
|
|
4184
4212
|
type: 'button',
|
|
4185
4213
|
className: 'capital-automation-todotitle',
|
|
@@ -4240,13 +4268,14 @@ function BoardPanel(props) {
|
|
|
4240
4268
|
}
|
|
4241
4269
|
|
|
4242
4270
|
function TodoPanel(props) {
|
|
4243
|
-
const { todos, onOpenSession, open, onToggle } = props
|
|
4244
|
-
const [filter, setFilter] = useState('
|
|
4245
|
-
const
|
|
4271
|
+
const { todos, onOpenSession, onAckTodo, ackingTodoId, open, onToggle } = props
|
|
4272
|
+
const [filter, setFilter] = useState('today')
|
|
4273
|
+
const now = new Date()
|
|
4274
|
+
const entries = todos.map((item) => ({ item, period: boardTodoPeriod(item, now) }))
|
|
4246
4275
|
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.
|
|
4276
|
+
const visible = entries.filter((entry) => entry.period === filter)
|
|
4277
|
+
const emptyText = filter === 'today'
|
|
4278
|
+
? zh.board.todoEmptyToday
|
|
4250
4279
|
: zh.board.todoEmptyGroup.replace('{label}', boardTodoGroupLabel(filter))
|
|
4251
4280
|
return h(BoardPanel, {
|
|
4252
4281
|
id: 'capital-automation-todo',
|
|
@@ -4268,8 +4297,11 @@ function TodoPanel(props) {
|
|
|
4268
4297
|
key: entry.item.id,
|
|
4269
4298
|
item: entry.item,
|
|
4270
4299
|
period: entry.period,
|
|
4271
|
-
showDue:
|
|
4300
|
+
showDue: true,
|
|
4272
4301
|
onOpenSession,
|
|
4302
|
+
onAck: onAckTodo,
|
|
4303
|
+
acking: ackingTodoId === entry.item.id,
|
|
4304
|
+
ackDisabled: ackingTodoId !== null && ackingTodoId !== undefined,
|
|
4273
4305
|
}))))
|
|
4274
4306
|
}
|
|
4275
4307
|
|
|
@@ -4439,7 +4471,7 @@ function BoardPage(props) {
|
|
|
4439
4471
|
const {
|
|
4440
4472
|
board, loading, error, range, category, onRange, onCategory, onRefresh,
|
|
4441
4473
|
onOpenSession, onRetryBrief, retryingRunId, onLoadMore, loadingMore, onGoTasks, onNewTask, onGoRuns,
|
|
4442
|
-
hasActiveTasks, storageReady,
|
|
4474
|
+
onAckTodo, ackingTodoId, hasActiveTasks, storageReady,
|
|
4443
4475
|
} = props
|
|
4444
4476
|
const [railOpen, setRailOpen] = useState(() => readBoardUi().rail !== false)
|
|
4445
4477
|
const [openPanels, setOpenPanels] = useState(() => boardPanelFlags(readBoardUi().panels))
|
|
@@ -4500,6 +4532,9 @@ function BoardPage(props) {
|
|
|
4500
4532
|
error.length > 0 ? h('div', { className: 'capital-automation-banner', 'data-tone': 'error', role: 'alert' }, error) : null,
|
|
4501
4533
|
h(BoardEmpty, { hasActiveTasks, storageReady, onGoTasks, onNewTask }))
|
|
4502
4534
|
}
|
|
4535
|
+
const boardStats = board?.stats === undefined
|
|
4536
|
+
? undefined
|
|
4537
|
+
: { ...board.stats, todos: boardTodoTodayCount(board?.todos ?? []) }
|
|
4503
4538
|
return h('div', { className: 'capital-automation-board' },
|
|
4504
4539
|
h(BoardToolbar, {
|
|
4505
4540
|
range,
|
|
@@ -4512,7 +4547,7 @@ function BoardPage(props) {
|
|
|
4512
4547
|
onToggleRail: toggleRail,
|
|
4513
4548
|
}),
|
|
4514
4549
|
error.length > 0 ? h('div', { className: 'capital-automation-banner', 'data-tone': 'error', role: 'alert' }, error) : null,
|
|
4515
|
-
h(BoardStats, { stats:
|
|
4550
|
+
h(BoardStats, { stats: boardStats, onJump: jumpTo }),
|
|
4516
4551
|
h('div', {
|
|
4517
4552
|
className: 'capital-automation-boardgrid',
|
|
4518
4553
|
'data-rail': railOpen === true ? 'open' : 'closed',
|
|
@@ -4536,7 +4571,14 @@ function BoardPage(props) {
|
|
|
4536
4571
|
className: 'capital-automation-boardrail',
|
|
4537
4572
|
hidden: railOpen !== true,
|
|
4538
4573
|
},
|
|
4539
|
-
h(TodoPanel, {
|
|
4574
|
+
h(TodoPanel, {
|
|
4575
|
+
todos: board?.todos ?? [],
|
|
4576
|
+
onOpenSession,
|
|
4577
|
+
onAckTodo,
|
|
4578
|
+
ackingTodoId,
|
|
4579
|
+
open: openPanels.todo,
|
|
4580
|
+
onToggle: () => togglePanel('todo'),
|
|
4581
|
+
}),
|
|
4540
4582
|
h(StockRadar, {
|
|
4541
4583
|
stocks: board?.stocks ?? [],
|
|
4542
4584
|
todos: board?.todos ?? [],
|
|
@@ -4574,6 +4616,7 @@ function AutomationPage(props) {
|
|
|
4574
4616
|
const [boardRange, setBoardRange] = useState('14')
|
|
4575
4617
|
const [boardCategory, setBoardCategory] = useState('all')
|
|
4576
4618
|
const [retryingBriefId, setRetryingBriefId] = useState(null)
|
|
4619
|
+
const [ackingTodoId, setAckingTodoId] = useState(null)
|
|
4577
4620
|
const [boardLoadingMore, setBoardLoadingMore] = useState(false)
|
|
4578
4621
|
const [unread, setUnread] = useState(0)
|
|
4579
4622
|
const [selectedId, setSelectedId] = useState(null)
|
|
@@ -4696,6 +4739,39 @@ function AutomationPage(props) {
|
|
|
4696
4739
|
}
|
|
4697
4740
|
}
|
|
4698
4741
|
|
|
4742
|
+
async function ackTodo(item) {
|
|
4743
|
+
if (ackingTodoId !== null) return
|
|
4744
|
+
setAckingTodoId(item.id)
|
|
4745
|
+
setBoardError('')
|
|
4746
|
+
try {
|
|
4747
|
+
await api.confirmTodo(item.id)
|
|
4748
|
+
setBoard((current) => {
|
|
4749
|
+
if (current === null) return current
|
|
4750
|
+
const removed = (current.todos ?? []).find((entry) => entry.id === item.id)
|
|
4751
|
+
if (removed === undefined) return current
|
|
4752
|
+
const todos = current.todos.filter((entry) => entry.id !== item.id)
|
|
4753
|
+
const stocks = (current.stocks ?? []).map((stock) =>
|
|
4754
|
+
removed.symbol !== undefined && stock.symbol === removed.symbol
|
|
4755
|
+
? { ...stock, todoCount: Math.max(0, (stock.todoCount ?? 0) - 1) }
|
|
4756
|
+
: stock)
|
|
4757
|
+
return {
|
|
4758
|
+
...current,
|
|
4759
|
+
todos,
|
|
4760
|
+
stocks,
|
|
4761
|
+
stats: current.stats === undefined
|
|
4762
|
+
? current.stats
|
|
4763
|
+
: { ...current.stats, todos: Math.max(0, (current.stats.todos ?? 0) - 1) },
|
|
4764
|
+
}
|
|
4765
|
+
})
|
|
4766
|
+
setNotice(zh.board.todoAcked)
|
|
4767
|
+
void loadBoard(boardRange, boardCategory)
|
|
4768
|
+
} catch (error) {
|
|
4769
|
+
setBoardError(error.message ?? zh.errorGeneric)
|
|
4770
|
+
} finally {
|
|
4771
|
+
setAckingTodoId(null)
|
|
4772
|
+
}
|
|
4773
|
+
}
|
|
4774
|
+
|
|
4699
4775
|
async function loadDetail(id) {
|
|
4700
4776
|
const requestSequence = detailSequenceRef.current + 1
|
|
4701
4777
|
detailSequenceRef.current = requestSequence
|
|
@@ -4917,6 +4993,8 @@ function AutomationPage(props) {
|
|
|
4917
4993
|
onOpenSession: openSession,
|
|
4918
4994
|
onRetryBrief: (runId) => { void retryBrief(runId) },
|
|
4919
4995
|
retryingRunId: retryingBriefId,
|
|
4996
|
+
onAckTodo: (item) => { void ackTodo(item) },
|
|
4997
|
+
ackingTodoId,
|
|
4920
4998
|
onLoadMore: () => { void loadMoreBoard() },
|
|
4921
4999
|
loadingMore: boardLoadingMore,
|
|
4922
5000
|
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,
|
package/chart-ui/package.json
CHANGED
package/config/package.json
CHANGED
|
@@ -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.
|
|
6
|
+
export declare const LOCAL_FETCH_CLIENT_VERSION = "2.19.0";
|
|
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.
|
|
7
|
+
export const LOCAL_FETCH_CLIENT_VERSION = '2.19.0';
|
|
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.
|
|
38
|
+
export declare const WIND_CLIENT_VERSION = "2.19.0";
|
|
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.
|
|
22
|
+
export const WIND_CLIENT_VERSION = '2.19.0';
|
|
23
23
|
function errorText(error) {
|
|
24
24
|
return error instanceof Error ? error.message : String(error);
|
|
25
25
|
}
|
package/package.json
CHANGED
package/watchlist/package.json
CHANGED