@goodandready/dsh-cron 0.3.42 โ 0.3.44
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/lib/client.js +998 -3987
- package/lib/llm-ask.js +2 -1
- package/lib/routes/api-actions.js +36 -6
- package/lib/routes/api-item.js +1 -1
- package/lib/routes/api-webhook.js +2 -4
- package/lib/runtimes/runner-external.js +2 -3
- package/lib/runtimes/runner-session.js +385 -0
- package/lib/runtimes/runner-turn.js +255 -0
- package/lib/runtimes/runner.js +43 -616
- package/lib/scheduler/scheduler-execution.js +4 -1
- package/lib/scheduler/scheduler-lifecycle.js +65 -0
- package/lib/scheduler/scheduler-parser.js +261 -0
- package/lib/scheduler/scheduler.js +24 -319
- package/lib/store/store-archive.js +195 -0
- package/lib/store/store-io.js +331 -0
- package/lib/store/store-loader.js +165 -0
- package/lib/store/store-migration.js +38 -0
- package/lib/store/store-settings.js +126 -0
- package/lib/store/store-stats.js +55 -0
- package/lib/store/store.js +127 -810
- package/package.json +8 -6
- package/lib/client-src/00-open.js +0 -63
- package/lib/client-src/10-locales.js +0 -540
- package/lib/client-src/20-styles.js +0 -64
- package/lib/client-src/30-utils.js +0 -372
- package/lib/client-src/40-delivery-settings.js +0 -96
- package/lib/client-src/45-dag-graph-view.js +0 -287
- package/lib/client-src/46-live-logs-modal.js +0 -108
- package/lib/client-src/47-analytics-digest-modal.js +0 -166
- package/lib/client-src/48-timeline-heatmap-view.js +0 -176
- package/lib/client-src/50-cron-screen-state.js +0 -457
- package/lib/client-src/52-cron-screen-actions.js +0 -330
- package/lib/client-src/53-cron-screen-modal-actions.js +0 -677
- package/lib/client-src/54-cron-screen-analytics-actions.js +0 -68
- package/lib/client-src/55-cron-screen-view.js +0 -378
- package/lib/client-src/60-modal-task-form-head.js +0 -581
- package/lib/client-src/62-modal-task-form-tail.js +0 -563
- package/lib/client-src/65-modal-dialogs.js +0 -350
- package/lib/client-src/70-settings-card.js +0 -453
- package/lib/client-src/75-quick-action-bar.js +0 -146
- package/lib/client-src/80-sidebar-jobs.js +0 -200
- package/lib/client-src/90-close.js +0 -219
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Interactive Visual Chain Graph & Checkpoint Inspector (#334)
|
|
3
|
-
* Pure CSS/SVG layout showing DAG steps, statuses, checkpoints and 1-click retry.
|
|
4
|
-
*/
|
|
5
|
-
function parseChainTargets(raw) {
|
|
6
|
-
if (!raw) return [];
|
|
7
|
-
if (Array.isArray(raw)) return raw.filter((x) => typeof x === 'string' && x.trim().length > 0);
|
|
8
|
-
if (typeof raw === 'string') return raw.split(',').map((s) => s.trim()).filter((s) => s.length > 0);
|
|
9
|
-
return [];
|
|
10
|
-
}
|
|
11
|
-
const sanitizeDependsOn = parseChainTargets;
|
|
12
|
-
const sanitizeJoinPolicy = (raw) => (raw === 'any_success' ? 'any_success' : 'all_success');
|
|
13
|
-
|
|
14
|
-
function buildTaskGraphModel(tasks = [], snapshots = [], focusTaskId = null) {
|
|
15
|
-
const taskMap = new Map();
|
|
16
|
-
for (const t of tasks) if (t?.id) taskMap.set(t.id, t);
|
|
17
|
-
const snapMap = new Map();
|
|
18
|
-
for (const s of snapshots) if (s?.stepTaskId) snapMap.set(s.stepTaskId, s);
|
|
19
|
-
const nodes = [], edges = [];
|
|
20
|
-
let hasFailure = false;
|
|
21
|
-
for (const [id, task] of taskMap.entries()) {
|
|
22
|
-
const snap = snapMap.get(id);
|
|
23
|
-
let nodeStatus = 'pending', durationMs = 0, outputSnippet = '', retryCount = 0;
|
|
24
|
-
if (snap) {
|
|
25
|
-
nodeStatus = snap.status === 'completed' || snap.status === 'success' ? 'success' : 'failed';
|
|
26
|
-
durationMs = snap.durationMs || 0;
|
|
27
|
-
retryCount = snap.retryCount || 0;
|
|
28
|
-
if (snap.output) outputSnippet = String(snap.output).slice(0, 200);
|
|
29
|
-
if (nodeStatus === 'failed') hasFailure = true;
|
|
30
|
-
} else if (task.status === 'running') {
|
|
31
|
-
nodeStatus = 'running';
|
|
32
|
-
}
|
|
33
|
-
const deps = sanitizeDependsOn(task.dependsOn);
|
|
34
|
-
const hasBranches = Array.isArray(task.branchRules) && task.branchRules.length > 0;
|
|
35
|
-
nodes.push({
|
|
36
|
-
id,
|
|
37
|
-
title: task.title || id,
|
|
38
|
-
type: task.type || 'prompt',
|
|
39
|
-
status: nodeStatus,
|
|
40
|
-
durationMs,
|
|
41
|
-
retryCount,
|
|
42
|
-
outputSnippet,
|
|
43
|
-
isFocus: Boolean(focusTaskId && id === focusTaskId),
|
|
44
|
-
isRetryable: nodeStatus === 'failed',
|
|
45
|
-
isDecisionNode: hasBranches,
|
|
46
|
-
branchRulesCount: hasBranches ? task.branchRules.length : 0,
|
|
47
|
-
elseTask: task.elseTask || null,
|
|
48
|
-
dependsOn: deps,
|
|
49
|
-
joinPolicy: sanitizeJoinPolicy(task.joinPolicy)
|
|
50
|
-
});
|
|
51
|
-
for (const d of deps) edges.push({ from: d, to: id, type: 'dependsOn', label: task.joinPolicy === 'any_success' ? 'join:any' : 'join:all' });
|
|
52
|
-
if (hasBranches) {
|
|
53
|
-
for (const rule of task.branchRules) {
|
|
54
|
-
if (rule && rule.targetTask) {
|
|
55
|
-
edges.push({
|
|
56
|
-
from: id,
|
|
57
|
-
to: String(rule.targetTask).trim(),
|
|
58
|
-
type: 'branch',
|
|
59
|
-
label: rule.label || ('[if: ' + rule.field + ' ' + rule.operator + ' ' + (rule.value != null ? rule.value : '') + ']').trim(),
|
|
60
|
-
condition: { field: rule.field, operator: rule.operator, value: rule.value }
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (task.elseTask) {
|
|
66
|
-
edges.push({
|
|
67
|
-
from: id,
|
|
68
|
-
to: String(task.elseTask).trim(),
|
|
69
|
-
type: 'branch_else',
|
|
70
|
-
label: '[else]',
|
|
71
|
-
isElse: true
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
if (!hasBranches) {
|
|
75
|
-
for (const t of parseChainTargets(task.onSuccess)) edges.push({ from: id, to: t, type: 'onSuccess', label: 'onSuccess' });
|
|
76
|
-
}
|
|
77
|
-
for (const f of parseChainTargets(task.onFailure)) edges.push({ from: id, to: f, type: 'onFailure', label: 'onFailure' });
|
|
78
|
-
}
|
|
79
|
-
return { nodes, edges, hasFailure };
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function renderChainGraphModal({ isOpen, onClose, data, loading, onRetry, t }) {
|
|
83
|
-
if (!isOpen) return null;
|
|
84
|
-
|
|
85
|
-
const graph = data?.graph || { nodes: [], edges: [], hasFailure: false };
|
|
86
|
-
const chainRunId = data?.chainRunId || '';
|
|
87
|
-
const nodes = graph.nodes || [];
|
|
88
|
-
|
|
89
|
-
return React.createElement('div', {
|
|
90
|
-
className: 'dsh-cron-modal-overlay',
|
|
91
|
-
onClick: onClose
|
|
92
|
-
},
|
|
93
|
-
React.createElement('div', {
|
|
94
|
-
className: 'dsh-cron-modal',
|
|
95
|
-
style: { maxWidth: '820px', width: '92vw', maxHeight: '88vh', display: 'flex', flexDirection: 'column' },
|
|
96
|
-
role: 'dialog',
|
|
97
|
-
'aria-modal': 'true',
|
|
98
|
-
onClick: (e) => e.stopPropagation()
|
|
99
|
-
},
|
|
100
|
-
// Header
|
|
101
|
-
React.createElement('div', {
|
|
102
|
-
className: 'dsh-cron-modal-head',
|
|
103
|
-
style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', borderBottom: '1px solid var(--dsw-alias-border-l2)', paddingBottom: '12px' }
|
|
104
|
-
},
|
|
105
|
-
React.createElement('div', null,
|
|
106
|
-
React.createElement('div', {
|
|
107
|
-
className: 'dsh-cron-modal-title',
|
|
108
|
-
style: { margin: 0, display: 'flex', alignItems: 'center', gap: '8px' }
|
|
109
|
-
},
|
|
110
|
-
React.createElement('span', { style: { fontSize: '18px' } }, '๐ธ๏ธ'),
|
|
111
|
-
T_KEY(t, 'chainGraph.modalTitle')
|
|
112
|
-
),
|
|
113
|
-
chainRunId && React.createElement('div', {
|
|
114
|
-
style: { fontSize: '11px', color: 'var(--dsw-alias-label-secondary, #888)', marginTop: '4px', fontFamily: 'monospace' }
|
|
115
|
-
}, 'Run ID: ' + chainRunId)
|
|
116
|
-
),
|
|
117
|
-
React.createElement('button', {
|
|
118
|
-
type: 'button',
|
|
119
|
-
className: 'dsh-cron-icon-btn',
|
|
120
|
-
onClick: onClose
|
|
121
|
-
}, 'โ')
|
|
122
|
-
),
|
|
123
|
-
|
|
124
|
-
// Body
|
|
125
|
-
React.createElement('div', {
|
|
126
|
-
style: { flex: 1, overflowY: 'auto', padding: '16px 0', minHeight: '260px' }
|
|
127
|
-
},
|
|
128
|
-
loading && React.createElement('div', {
|
|
129
|
-
className: 'dsh-cron-history-empty'
|
|
130
|
-
}, T_KEY(t, 'history.loading')),
|
|
131
|
-
|
|
132
|
-
!loading && nodes.length === 0 && React.createElement('div', {
|
|
133
|
-
className: 'dsh-cron-history-empty'
|
|
134
|
-
}, T_KEY(t, 'chainGraph.noNodes')),
|
|
135
|
-
|
|
136
|
-
!loading && nodes.length > 0 && React.createElement('div', {
|
|
137
|
-
style: { display: 'flex', flexDirection: 'column', gap: '16px' }
|
|
138
|
-
},
|
|
139
|
-
// Legend
|
|
140
|
-
React.createElement('div', {
|
|
141
|
-
style: { display: 'flex', gap: '12px', fontSize: '11px', color: 'var(--dsw-alias-label-secondary, #888)', padding: '0 4px' }
|
|
142
|
-
},
|
|
143
|
-
React.createElement('span', { style: { display: 'inline-flex', alignItems: 'center', gap: '4px' } },
|
|
144
|
-
React.createElement('span', { style: { width: '8px', height: '8px', borderRadius: '50%', background: 'var(--dsh-cron-success)' } }),
|
|
145
|
-
T_KEY(t, 'chainGraph.stepSuccess')
|
|
146
|
-
),
|
|
147
|
-
React.createElement('span', { style: { display: 'inline-flex', alignItems: 'center', gap: '4px' } },
|
|
148
|
-
React.createElement('span', { style: { width: '8px', height: '8px', borderRadius: '50%', background: 'var(--dsh-cron-danger)' } }),
|
|
149
|
-
T_KEY(t, 'chainGraph.stepFailed')
|
|
150
|
-
),
|
|
151
|
-
React.createElement('span', { style: { display: 'inline-flex', alignItems: 'center', gap: '4px' } },
|
|
152
|
-
React.createElement('span', { style: { width: '8px', height: '8px', borderRadius: '50%', background: 'var(--dsw-alias-label-tertiary, #888)' } }),
|
|
153
|
-
T_KEY(t, 'chainGraph.stepPending')
|
|
154
|
-
)
|
|
155
|
-
),
|
|
156
|
-
|
|
157
|
-
// Horizontal / Flow layout of nodes
|
|
158
|
-
React.createElement('div', {
|
|
159
|
-
style: {
|
|
160
|
-
display: 'flex',
|
|
161
|
-
flexWrap: 'wrap',
|
|
162
|
-
gap: '12px',
|
|
163
|
-
alignItems: 'stretch',
|
|
164
|
-
background: 'var(--dsw-alias-bg-layer-2)',
|
|
165
|
-
border: '1px solid var(--dsw-alias-border-l2)',
|
|
166
|
-
borderRadius: '8px',
|
|
167
|
-
padding: '16px'
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
nodes.map((n, idx) => {
|
|
171
|
-
const isOk = n.status === 'success';
|
|
172
|
-
const isFailed = n.status === 'failed';
|
|
173
|
-
const borderColor = isOk
|
|
174
|
-
? 'var(--dsh-cron-success)'
|
|
175
|
-
: isFailed
|
|
176
|
-
? 'var(--dsh-cron-danger)'
|
|
177
|
-
: 'var(--dsw-alias-border-l2)';
|
|
178
|
-
|
|
179
|
-
return React.createElement('div', {
|
|
180
|
-
key: n.id || idx,
|
|
181
|
-
style: {
|
|
182
|
-
flex: '1 1 220px',
|
|
183
|
-
maxWidth: '260px',
|
|
184
|
-
background: 'var(--dsw-alias-bg-layer-1)',
|
|
185
|
-
border: '1px solid ' + borderColor,
|
|
186
|
-
borderRadius: '6px',
|
|
187
|
-
padding: '12px',
|
|
188
|
-
display: 'flex',
|
|
189
|
-
flexDirection: 'column',
|
|
190
|
-
gap: '8px',
|
|
191
|
-
boxShadow: isFailed ? '0 0 0 1px var(--dsh-cron-danger)' : 'none'
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
// Node header
|
|
195
|
-
React.createElement('div', {
|
|
196
|
-
style: { display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', gap: '6px' }
|
|
197
|
-
},
|
|
198
|
-
React.createElement('div', {
|
|
199
|
-
style: { fontWeight: '600', fontSize: '13px', color: 'var(--dsw-alias-label-primary)' }
|
|
200
|
-
}, n.title || n.id),
|
|
201
|
-
React.createElement('span', {
|
|
202
|
-
style: {
|
|
203
|
-
fontSize: '10px',
|
|
204
|
-
padding: '2px 6px',
|
|
205
|
-
borderRadius: '10px',
|
|
206
|
-
fontWeight: '600',
|
|
207
|
-
background: isOk ? 'var(--dsh-cron-success-bg)' : isFailed ? 'var(--dsh-cron-danger-bg)' : 'var(--dsw-alias-bg-layer-3)',
|
|
208
|
-
color: isOk ? 'var(--dsh-cron-success)' : isFailed ? 'var(--dsh-cron-danger)' : 'var(--dsw-alias-label-secondary)'
|
|
209
|
-
}
|
|
210
|
-
}, isOk ? 'โ ' + T_KEY(t, 'chainGraph.stepSuccess') : isFailed ? 'โ ' + T_KEY(t, 'chainGraph.stepFailed') : 'โณ ' + T_KEY(t, 'chainGraph.stepPending'))
|
|
211
|
-
),
|
|
212
|
-
|
|
213
|
-
// Meta: duration, retryCount, type
|
|
214
|
-
React.createElement('div', {
|
|
215
|
-
style: { fontSize: '11px', color: 'var(--dsw-alias-label-secondary)', display: 'flex', gap: '8px', flexWrap: 'wrap' }
|
|
216
|
-
},
|
|
217
|
-
n.durationMs > 0 && React.createElement('span', null, n.durationMs + 'ms'),
|
|
218
|
-
n.retryCount > 0 && React.createElement('span', { style: { color: 'var(--dsh-cron-warning)' } }, 'โป ' + n.retryCount),
|
|
219
|
-
n.joinPolicy && n.dependsOn?.length > 0 && React.createElement('span', {
|
|
220
|
-
style: { background: 'var(--dsw-alias-bg-layer-3)', padding: '1px 4px', borderRadius: '4px' }
|
|
221
|
-
}, n.joinPolicy === 'any_success' ? 'join:any' : 'join:all')
|
|
222
|
-
),
|
|
223
|
-
|
|
224
|
-
// Decision Node info (#352)
|
|
225
|
-
n.isDecisionNode && React.createElement('div', {
|
|
226
|
-
style: { fontSize: '11px', color: 'var(--dsh-cron-warning)', fontWeight: '600', display: 'flex', alignItems: 'center', gap: '4px' }
|
|
227
|
-
}, '๐ ' + T_KEY(t, 'chainGraph.decisionNode') + ' (' + n.branchRulesCount + ')'),
|
|
228
|
-
|
|
229
|
-
// Dependencies info
|
|
230
|
-
n.dependsOn?.length > 0 && React.createElement('div', {
|
|
231
|
-
style: { fontSize: '11px', color: 'var(--dsw-alias-label-tertiary)' }
|
|
232
|
-
}, 'โ ' + n.dependsOn.join(', ')),
|
|
233
|
-
|
|
234
|
-
// Output snippet
|
|
235
|
-
n.outputSnippet && React.createElement('div', {
|
|
236
|
-
style: {
|
|
237
|
-
background: 'var(--dsw-alias-bg-layer-2)',
|
|
238
|
-
border: '1px solid var(--dsw-alias-border-l2)',
|
|
239
|
-
borderRadius: '4px',
|
|
240
|
-
padding: '6px',
|
|
241
|
-
fontSize: '11px',
|
|
242
|
-
color: 'var(--dsw-alias-label-secondary)',
|
|
243
|
-
fontFamily: 'monospace',
|
|
244
|
-
whiteSpace: 'pre-wrap',
|
|
245
|
-
wordBreak: 'break-all',
|
|
246
|
-
maxHeight: '60px',
|
|
247
|
-
overflowY: 'auto'
|
|
248
|
-
}
|
|
249
|
-
}, n.outputSnippet),
|
|
250
|
-
|
|
251
|
-
// One-click Retry from step button (#319, #328, #334)
|
|
252
|
-
isFailed && chainRunId && React.createElement('button', {
|
|
253
|
-
type: 'button',
|
|
254
|
-
className: 'dsh-cron-btn-secondary',
|
|
255
|
-
style: {
|
|
256
|
-
marginTop: 'auto',
|
|
257
|
-
display: 'flex',
|
|
258
|
-
alignItems: 'center',
|
|
259
|
-
justifyContent: 'center',
|
|
260
|
-
gap: '6px',
|
|
261
|
-
fontSize: '12px',
|
|
262
|
-
padding: '6px 10px',
|
|
263
|
-
color: 'var(--dsh-cron-danger)',
|
|
264
|
-
borderColor: 'var(--dsh-cron-danger)'
|
|
265
|
-
},
|
|
266
|
-
onClick: () => onRetry && onRetry(n.id)
|
|
267
|
-
}, '๐ ' + T_KEY(t, 'chainGraph.retryStep'))
|
|
268
|
-
);
|
|
269
|
-
})
|
|
270
|
-
)
|
|
271
|
-
)
|
|
272
|
-
),
|
|
273
|
-
|
|
274
|
-
// Footer
|
|
275
|
-
React.createElement('div', {
|
|
276
|
-
className: 'dsh-cron-modal-foot',
|
|
277
|
-
style: { borderTop: '1px solid var(--dsw-alias-border-l2)', paddingTop: '12px', marginTop: 'auto' }
|
|
278
|
-
},
|
|
279
|
-
React.createElement('button', {
|
|
280
|
-
type: 'button',
|
|
281
|
-
className: 'dsh-cron-btn-primary',
|
|
282
|
-
onClick: onClose
|
|
283
|
-
}, T_KEY(t, 'chainGraph.close'))
|
|
284
|
-
)
|
|
285
|
-
)
|
|
286
|
-
);
|
|
287
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Real-time Task Execution Log Streaming Modal (SSE) (#336)
|
|
3
|
-
* Terminal console with live chunk append, auto-scroll, status indicator, and disconnect.
|
|
4
|
-
* Complies with Audit #203 (zero 6-digit hex colors, use theme variables or 3-digit hex).
|
|
5
|
-
*/
|
|
6
|
-
function renderLiveLogsModal({ isOpen, onClose, taskId, taskTitle, logs, autoScroll, onToggleAutoScroll, completed, status, t }) {
|
|
7
|
-
if (!isOpen) return null;
|
|
8
|
-
|
|
9
|
-
const terminalRef = (el) => {
|
|
10
|
-
if (el && autoScroll) {
|
|
11
|
-
el.scrollTop = el.scrollHeight;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const isLive = status === 'running' || status === 'connecting';
|
|
16
|
-
const statusColor = isLive ? 'var(--dsh-cron-success, #2a2)' : (status === 'completed' ? 'var(--dsw-alias-label-secondary, #888)' : 'var(--dsh-cron-danger, #e33)');
|
|
17
|
-
|
|
18
|
-
return React.createElement('div', {
|
|
19
|
-
className: 'dsh-cron-modal-overlay',
|
|
20
|
-
onClick: onClose
|
|
21
|
-
},
|
|
22
|
-
React.createElement('div', {
|
|
23
|
-
className: 'dsh-cron-modal',
|
|
24
|
-
style: { maxWidth: '860px', width: '92vw', height: '80vh', display: 'flex', flexDirection: 'column', background: 'var(--dsw-alias-bg-base, #111)', color: 'var(--dsw-alias-label-primary, #ddd)', border: '1px solid var(--dsw-alias-border-l2, #333)', borderRadius: '8px' },
|
|
25
|
-
role: 'dialog',
|
|
26
|
-
'aria-modal': 'true',
|
|
27
|
-
onClick: (e) => e.stopPropagation()
|
|
28
|
-
},
|
|
29
|
-
// Header
|
|
30
|
-
React.createElement('div', {
|
|
31
|
-
style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '12px 16px', borderBottom: '1px solid var(--dsw-alias-border-l2, #333)', background: 'var(--dsw-alias-bg-layer-2, #111)' }
|
|
32
|
-
},
|
|
33
|
-
React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: '10px' } },
|
|
34
|
-
React.createElement('span', { style: { fontSize: '18px' } }, '๐บ'),
|
|
35
|
-
React.createElement('div', null,
|
|
36
|
-
React.createElement('div', { style: { fontWeight: '600', fontSize: '14px', color: 'var(--dsw-alias-label-primary, #fff)', display: 'flex', alignItems: 'center', gap: '8px' } },
|
|
37
|
-
T_KEY(t, 'liveLog.modalTitle'),
|
|
38
|
-
React.createElement('span', {
|
|
39
|
-
style: {
|
|
40
|
-
display: 'inline-block',
|
|
41
|
-
width: '8px',
|
|
42
|
-
height: '8px',
|
|
43
|
-
borderRadius: '50%',
|
|
44
|
-
background: statusColor,
|
|
45
|
-
boxShadow: isLive ? '0 0 8px ' + statusColor : 'none'
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
),
|
|
49
|
-
React.createElement('div', { style: { fontSize: '11px', color: 'var(--dsw-alias-label-secondary, #888)', marginTop: '2px', fontFamily: 'monospace' } },
|
|
50
|
-
(taskTitle || taskId) + ' ยท ' + (isLive ? T_KEY(t, 'liveLog.connecting') : (completed ? T_KEY(t, 'liveLog.completed') : status))
|
|
51
|
-
)
|
|
52
|
-
)
|
|
53
|
-
),
|
|
54
|
-
React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: '12px' } },
|
|
55
|
-
React.createElement('label', { style: { fontSize: '12px', color: 'var(--dsw-alias-label-secondary, #888)', display: 'flex', alignItems: 'center', gap: '4px', cursor: 'pointer' } },
|
|
56
|
-
React.createElement('input', {
|
|
57
|
-
type: 'checkbox',
|
|
58
|
-
checked: Boolean(autoScroll),
|
|
59
|
-
onChange: onToggleAutoScroll,
|
|
60
|
-
style: { cursor: 'pointer' }
|
|
61
|
-
}),
|
|
62
|
-
T_KEY(t, 'liveLog.autoScroll')
|
|
63
|
-
),
|
|
64
|
-
React.createElement('button', {
|
|
65
|
-
type: 'button',
|
|
66
|
-
className: 'dsh-cron-icon-btn',
|
|
67
|
-
style: { color: 'var(--dsw-alias-label-secondary, #888)', background: 'transparent', border: 'none', cursor: 'pointer', fontSize: '16px' },
|
|
68
|
-
onClick: onClose
|
|
69
|
-
}, 'โ')
|
|
70
|
-
)
|
|
71
|
-
),
|
|
72
|
-
|
|
73
|
-
// Terminal console body
|
|
74
|
-
React.createElement('div', {
|
|
75
|
-
ref: terminalRef,
|
|
76
|
-
style: { flex: 1, overflowY: 'auto', padding: '14px 16px', fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace', fontSize: '12px', lineHeight: '1.5', background: 'var(--dsw-alias-bg-base, #000)' }
|
|
77
|
-
},
|
|
78
|
-
(!logs || logs.length === 0) && React.createElement('div', {
|
|
79
|
-
style: { color: 'var(--dsw-alias-label-secondary, #888)', fontStyle: 'italic', padding: '20px 0', textAlign: 'center' }
|
|
80
|
-
}, isLive ? T_KEY(t, 'liveLog.waiting') : 'No output captured for this run.'),
|
|
81
|
-
|
|
82
|
-
logs && logs.length > 0 && logs.map((item, idx) => {
|
|
83
|
-
const isErr = item.stream === 'stderr';
|
|
84
|
-
const timeStr = item.ts ? new Date(item.ts).toLocaleTimeString() : '';
|
|
85
|
-
return React.createElement('div', {
|
|
86
|
-
key: idx,
|
|
87
|
-
style: { display: 'flex', gap: '8px', color: isErr ? 'var(--dsh-cron-danger, #f55)' : 'var(--dsh-cron-success, #5f5)', wordBreak: 'break-all', whiteSpace: 'pre-wrap' }
|
|
88
|
-
},
|
|
89
|
-
timeStr && React.createElement('span', { style: { color: 'var(--dsw-alias-label-secondary, #555)', userSelect: 'none', flexShrink: 0 } }, '[' + timeStr + ']'),
|
|
90
|
-
React.createElement('span', { style: { flex: 1 } }, item.chunk || item.text || String(item))
|
|
91
|
-
);
|
|
92
|
-
})
|
|
93
|
-
),
|
|
94
|
-
|
|
95
|
-
// Footer
|
|
96
|
-
React.createElement('div', {
|
|
97
|
-
style: { display: 'flex', justifyContent: 'flex-end', padding: '10px 16px', borderTop: '1px solid var(--dsw-alias-border-l2, #333)', background: 'var(--dsw-alias-bg-layer-2, #111)' }
|
|
98
|
-
},
|
|
99
|
-
React.createElement('button', {
|
|
100
|
-
type: 'button',
|
|
101
|
-
className: 'dsh-cron-btn dsh-cron-btn-secondary',
|
|
102
|
-
style: { padding: '6px 14px', fontSize: '12px' },
|
|
103
|
-
onClick: onClose
|
|
104
|
-
}, T_KEY(t, 'liveLog.close'))
|
|
105
|
-
)
|
|
106
|
-
)
|
|
107
|
-
);
|
|
108
|
-
}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Weekly AI Analytics & Cost Digest Modal (#330)
|
|
3
|
-
* Displays 7-day or 30-day KPI cards, top unstable & expensive tasks,
|
|
4
|
-
* one-click Telegram dispatch, and Markdown preview.
|
|
5
|
-
* Complies strictly with Audit #203 (0 raw rgba, 0 6-digit hex colors).
|
|
6
|
-
*/
|
|
7
|
-
function renderAnalyticsDigestModal({ isOpen, onClose, digestData, isLoading, periodDays, onSelectPeriod, onSendTelegram, sendStatus, t }) {
|
|
8
|
-
if (!isOpen) return null;
|
|
9
|
-
|
|
10
|
-
const digest = digestData || {
|
|
11
|
-
totalRuns: 0,
|
|
12
|
-
successfulRuns: 0,
|
|
13
|
-
failedRuns: 0,
|
|
14
|
-
successRate: 100,
|
|
15
|
-
totalTokens: 0,
|
|
16
|
-
totalCostUsd: 0,
|
|
17
|
-
healedCount: 0,
|
|
18
|
-
activeTasksCount: 0,
|
|
19
|
-
pausedTasksCount: 0,
|
|
20
|
-
topUnstableTasks: [],
|
|
21
|
-
topExpensiveTasks: []
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const copyMarkdown = () => {
|
|
25
|
-
if (!digestData) return;
|
|
26
|
-
const text = [
|
|
27
|
-
'# ' + (T_KEY(t, 'digest.modalTitle')),
|
|
28
|
-
'Period: Last ' + (periodDays || 7) + ' days',
|
|
29
|
-
'Total Runs: ' + digest.totalRuns + ' (' + digest.successRate + '% SR)',
|
|
30
|
-
'Tokens: ' + digest.totalTokens + ' (~$' + digest.totalCostUsd + ' USD)',
|
|
31
|
-
'Active Tasks: ' + digest.activeTasksCount + ' active / ' + digest.pausedTasksCount + ' paused'
|
|
32
|
-
].join(String.fromCharCode(10));
|
|
33
|
-
navigator.clipboard.writeText(text).catch(() => {});
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
return React.createElement('div', {
|
|
37
|
-
className: 'dsh-cron-modal-overlay',
|
|
38
|
-
onClick: onClose
|
|
39
|
-
},
|
|
40
|
-
React.createElement('div', {
|
|
41
|
-
className: 'dsh-cron-modal',
|
|
42
|
-
style: { maxWidth: '780px', width: '92vw', maxHeight: '86vh', display: 'flex', flexDirection: 'column', background: 'var(--dsw-alias-bg-base, #111)', color: 'var(--dsw-alias-label-primary, #ddd)', border: '1px solid var(--dsw-alias-border-l2, #333)', borderRadius: '8px' },
|
|
43
|
-
role: 'dialog',
|
|
44
|
-
'aria-modal': 'true',
|
|
45
|
-
onClick: (e) => e.stopPropagation()
|
|
46
|
-
},
|
|
47
|
-
// Header
|
|
48
|
-
React.createElement('div', {
|
|
49
|
-
style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '14px 18px', borderBottom: '1px solid var(--dsw-alias-border-l2, #333)', background: 'var(--dsw-alias-bg-layer-2, #111)' }
|
|
50
|
-
},
|
|
51
|
-
React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: '10px' } },
|
|
52
|
-
React.createElement('span', { style: { fontSize: '20px' } }, '๐'),
|
|
53
|
-
React.createElement('div', null,
|
|
54
|
-
React.createElement('div', { style: { fontWeight: '600', fontSize: '15px', color: 'var(--dsw-alias-label-primary, #fff)' } },
|
|
55
|
-
T_KEY(t, 'digest.modalTitle')
|
|
56
|
-
),
|
|
57
|
-
React.createElement('div', { style: { fontSize: '11.5px', color: 'var(--dsw-alias-label-secondary, #888)', marginTop: '2px' } },
|
|
58
|
-
(T_KEY(t, 'digest.buttonTitle')) + ' ยท ' + (periodDays || 7) + 'd'
|
|
59
|
-
)
|
|
60
|
-
)
|
|
61
|
-
),
|
|
62
|
-
React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: '8px' } },
|
|
63
|
-
React.createElement('button', {
|
|
64
|
-
type: 'button',
|
|
65
|
-
className: 'dsh-cron-btn-secondary',
|
|
66
|
-
style: { padding: '4px 10px', fontSize: '12px', fontWeight: periodDays === 7 ? '600' : '400', background: periodDays === 7 ? 'var(--dsw-alias-bg-layer-3, #222)' : 'transparent' },
|
|
67
|
-
onClick: () => onSelectPeriod && onSelectPeriod(7)
|
|
68
|
-
}, T_KEY(t, 'digest.period7')),
|
|
69
|
-
React.createElement('button', {
|
|
70
|
-
type: 'button',
|
|
71
|
-
className: 'dsh-cron-btn-secondary',
|
|
72
|
-
style: { padding: '4px 10px', fontSize: '12px', fontWeight: periodDays === 30 ? '600' : '400', background: periodDays === 30 ? 'var(--dsw-alias-bg-layer-3, #222)' : 'transparent' },
|
|
73
|
-
onClick: () => onSelectPeriod && onSelectPeriod(30)
|
|
74
|
-
}, T_KEY(t, 'digest.period30')),
|
|
75
|
-
React.createElement('button', {
|
|
76
|
-
type: 'button',
|
|
77
|
-
className: 'dsh-cron-icon-btn',
|
|
78
|
-
onClick: onClose,
|
|
79
|
-
style: { marginLeft: '8px' }
|
|
80
|
-
}, React.createElement('span', null, 'โ'))
|
|
81
|
-
)
|
|
82
|
-
),
|
|
83
|
-
|
|
84
|
-
// Body
|
|
85
|
-
React.createElement('div', {
|
|
86
|
-
style: { padding: '16px 18px', overflowY: 'auto', flex: 1, display: 'flex', flexDirection: 'column', gap: '16px' }
|
|
87
|
-
},
|
|
88
|
-
isLoading ? React.createElement('div', { style: { padding: '30px', textAlign: 'center', color: 'var(--dsw-alias-label-secondary, #888)' } }, 'Loading digest metrics...') : React.createElement(React.Fragment, null,
|
|
89
|
-
// KPI Grid
|
|
90
|
-
(() => {
|
|
91
|
-
const renderKpi = (label, val, sub, subCol) => React.createElement('div', { style: { background: 'var(--dsw-alias-bg-layer-2, #111)', border: '1px solid var(--dsw-alias-border-l2, #333)', borderRadius: '6px', padding: '10px 12px' } },
|
|
92
|
-
React.createElement('div', { style: { fontSize: '11px', color: 'var(--dsw-alias-label-secondary, #888)' } }, label),
|
|
93
|
-
React.createElement('div', { style: { fontSize: '18px', fontWeight: '700', color: 'var(--dsw-alias-label-primary, #fff)', marginTop: '4px' } }, val),
|
|
94
|
-
React.createElement('div', { style: { fontSize: '11px', color: subCol || 'var(--dsw-alias-label-secondary, #888)', marginTop: '2px' } }, sub)
|
|
95
|
-
);
|
|
96
|
-
return React.createElement('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: '10px' } },
|
|
97
|
-
renderKpi(T_KEY(t, 'digest.executions'), digest.totalRuns, digest.successRate + '% SR', digest.successRate >= 90 ? 'var(--dsh-cron-success, #2a2)' : 'var(--dsh-cron-warning, #fa0)'),
|
|
98
|
-
renderKpi(T_KEY(t, 'digest.tokens'), Number(digest.totalTokens || 0).toLocaleString(), 'LLM prompt+out'),
|
|
99
|
-
renderKpi(T_KEY(t, 'digest.cost'), '$' + Number(digest.totalCostUsd || 0).toFixed(4), 'USD estimated'),
|
|
100
|
-
renderKpi(T_KEY(t, 'digest.fleet'), digest.activeTasksCount, digest.pausedTasksCount + ' paused')
|
|
101
|
-
);
|
|
102
|
-
})(),
|
|
103
|
-
|
|
104
|
-
// Unstable TasksUnstable Tasks
|
|
105
|
-
React.createElement('div', { style: { background: 'var(--dsw-alias-bg-layer-2, #111)', border: '1px solid var(--dsw-alias-border-l2, #333)', borderRadius: '6px', padding: '12px' } },
|
|
106
|
-
React.createElement('div', { style: { fontWeight: '600', fontSize: '13px', color: 'var(--dsh-cron-warning, #fa0)', marginBottom: '8px' } },
|
|
107
|
-
'โ ๏ธ ' + (T_KEY(t, 'digest.unstableTitle'))
|
|
108
|
-
),
|
|
109
|
-
(digest.topUnstableTasks && digest.topUnstableTasks.length > 0) ? React.createElement('div', { style: { display: 'flex', flexDirection: 'column', gap: '6px' } },
|
|
110
|
-
digest.topUnstableTasks.map((tItem, idx) => React.createElement('div', {
|
|
111
|
-
key: tItem.id || idx,
|
|
112
|
-
style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', fontSize: '12px', padding: '6px 8px', background: 'var(--dsw-alias-bg-base, #111)', borderRadius: '4px', border: '1px solid var(--dsw-alias-border-l2, #222)' }
|
|
113
|
-
},
|
|
114
|
-
React.createElement('span', { style: { fontFamily: 'monospace' } }, (idx + 1) + '. ' + (tItem.name || tItem.id)),
|
|
115
|
-
React.createElement('span', { style: { color: 'var(--dsh-cron-danger, #e33)', fontWeight: '600' } },
|
|
116
|
-
tItem.failures + ' fail (' + tItem.successRate + '% SR)'
|
|
117
|
-
)
|
|
118
|
-
))
|
|
119
|
-
) : React.createElement('div', { style: { fontSize: '12px', color: 'var(--dsw-alias-label-secondary, #888)' } }, 'โ All tasks healthy โ 0 failures in window!')
|
|
120
|
-
),
|
|
121
|
-
|
|
122
|
-
// Expensive Tasks
|
|
123
|
-
React.createElement('div', { style: { background: 'var(--dsw-alias-bg-layer-2, #111)', border: '1px solid var(--dsw-alias-border-l2, #333)', borderRadius: '6px', padding: '12px' } },
|
|
124
|
-
React.createElement('div', { style: { fontWeight: '600', fontSize: '13px', color: 'var(--dsh-cron-info, #4af)', marginBottom: '8px' } },
|
|
125
|
-
'๐ฐ ' + (T_KEY(t, 'digest.expensiveTitle'))
|
|
126
|
-
),
|
|
127
|
-
(digest.topExpensiveTasks && digest.topExpensiveTasks.length > 0) ? React.createElement('div', { style: { display: 'flex', flexDirection: 'column', gap: '6px' } },
|
|
128
|
-
digest.topExpensiveTasks.map((tItem, idx) => React.createElement('div', {
|
|
129
|
-
key: tItem.id || idx,
|
|
130
|
-
style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', fontSize: '12px', padding: '6px 8px', background: 'var(--dsw-alias-bg-base, #111)', borderRadius: '4px', border: '1px solid var(--dsw-alias-border-l2, #222)' }
|
|
131
|
-
},
|
|
132
|
-
React.createElement('span', { style: { fontFamily: 'monospace' } }, (idx + 1) + '. ' + (tItem.name || tItem.id)),
|
|
133
|
-
React.createElement('span', { style: { color: 'var(--dsw-alias-label-primary, #ddd)' } },
|
|
134
|
-
Number(tItem.tokens || 0).toLocaleString() + ' tok ($' + Number(tItem.costUsd || 0).toFixed(4) + ')'
|
|
135
|
-
)
|
|
136
|
-
))
|
|
137
|
-
) : React.createElement('div', { style: { fontSize: '12px', color: 'var(--dsw-alias-label-secondary, #888)' } }, 'No significant token consumption recorded.')
|
|
138
|
-
)
|
|
139
|
-
)
|
|
140
|
-
),
|
|
141
|
-
|
|
142
|
-
// Footer
|
|
143
|
-
React.createElement('div', {
|
|
144
|
-
style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '12px 18px', borderTop: '1px solid var(--dsw-alias-border-l2, #333)', background: 'var(--dsw-alias-bg-layer-2, #111)' }
|
|
145
|
-
},
|
|
146
|
-
React.createElement('div', { style: { fontSize: '12px', color: 'var(--dsw-alias-label-secondary, #888)' } },
|
|
147
|
-
sendStatus || ''
|
|
148
|
-
),
|
|
149
|
-
React.createElement('div', { style: { display: 'flex', gap: '8px' } },
|
|
150
|
-
React.createElement('button', {
|
|
151
|
-
type: 'button',
|
|
152
|
-
className: 'dsh-cron-btn-secondary',
|
|
153
|
-
onClick: copyMarkdown,
|
|
154
|
-
style: { padding: '6px 14px', fontSize: '12px' }
|
|
155
|
-
}, T_KEY(t, 'digest.copyMarkdown')),
|
|
156
|
-
React.createElement('button', {
|
|
157
|
-
type: 'button',
|
|
158
|
-
className: 'dsh-cron-btn-primary',
|
|
159
|
-
onClick: onSendTelegram,
|
|
160
|
-
style: { padding: '6px 14px', fontSize: '12px' }
|
|
161
|
-
}, T_KEY(t, 'digest.sendTelegram'))
|
|
162
|
-
)
|
|
163
|
-
)
|
|
164
|
-
)
|
|
165
|
-
);
|
|
166
|
-
}
|