@goodandready/dsh-cron 0.3.38 → 0.3.40
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-src/10-locales.js +5 -1
- package/lib/client-src/30-utils.js +110 -0
- package/lib/client-src/70-settings-card.js +33 -0
- package/lib/client-src/75-quick-action-bar.js +4 -0
- package/lib/client-src/90-close.js +5 -0
- package/lib/client.js +148 -1
- package/lib/locales.json +3 -1
- package/lib/log-streamer.js +0 -1
- package/lib/routes/api-collection.js +1 -1
- package/lib/routes/api-item.js +2 -2
- package/lib/routes/routes.js +7 -1
- package/lib/runtimes/runtimes.js +19 -6
- package/lib/scheduler/scheduler-preflight.js +2 -1
- package/lib/settings.js +4 -0
- package/lib/store/store.js +4 -0
- package/package.json +1 -1
|
@@ -182,6 +182,8 @@
|
|
|
182
182
|
'settings.globalOnlyFailure': 'Global mode: only on failures (silent on success)',
|
|
183
183
|
'settings.dynamicCredentials': 'Dynamic Credentials Resolution (credential://...)',
|
|
184
184
|
'settings.dynamicCredentialsHint': 'Resolve credential://... in memory from harness credentials at runtime (#335)',
|
|
185
|
+
'settings.showChatHeaderButton': 'Show schedule button in chat header',
|
|
186
|
+
'settings.showChatHeaderActions': 'Show quick create action in chat header',
|
|
185
187
|
'settings.testTelegram': '🔔 Test Telegram delivery', 'settings.testKanban': '📋 Test Kanban',
|
|
186
188
|
'settings.sending': 'Sending...', 'settings.checkingKanban': 'Checking Kanban...',
|
|
187
189
|
'settings.testOk': '✅ Test message delivered to Telegram!', 'settings.testFail': '❌ {error}',
|
|
@@ -423,7 +425,9 @@
|
|
|
423
425
|
'settings.chatIdLabel': 'Telegram Chat ID', 'settings.chatIdPlaceholder': '例如: 345678901',
|
|
424
426
|
'settings.kanbanUrlLabel': 'Kanban 服务基础地址', 'settings.globalNotify': '全局开启所有任务结果推送至 Telegram',
|
|
425
427
|
'settings.globalOnlyFailure': '全局模式:仅在失败时推送 (成功静默)', 'settings.dynamicCredentials': '动态凭据解析 (credential://...)',
|
|
426
|
-
'settings.dynamicCredentialsHint': '运行时从凭据服务动态解析 credential://... 且不泄露到存储 (#335)',
|
|
428
|
+
'settings.dynamicCredentialsHint': '运行时从凭据服务动态解析 credential://... 且不泄露到存储 (#335)',
|
|
429
|
+
'settings.showChatHeaderButton': '在聊天标题栏显示定时任务按钮',
|
|
430
|
+
'settings.showChatHeaderActions': '在聊天标题栏显示快速创建操作', 'settings.testTelegram': '🔔 测试 Telegram 发送',
|
|
427
431
|
'settings.testKanban': '📋 测试 Kanban', 'settings.sending': '正在发送...',
|
|
428
432
|
'settings.checkingKanban': '正在连接 Kanban...', 'settings.testOk': '✅ 测试消息已成功发送至 Telegram!',
|
|
429
433
|
'settings.testFail': '❌ 发送失败: {error}', 'settings.kanbanOk': '✅ Kanban 卡片创建成功',
|
|
@@ -260,3 +260,113 @@
|
|
|
260
260
|
return { res, data };
|
|
261
261
|
};
|
|
262
262
|
|
|
263
|
+
|
|
264
|
+
// --- CHAT HEADER VISIBILITY SETTINGS (Issue #422) ---
|
|
265
|
+
const HEADER_SETTINGS_STORAGE_KEY = 'dsh-cron:header-settings';
|
|
266
|
+
|
|
267
|
+
let currentHeaderSettings = (function initHeaderSettings() {
|
|
268
|
+
try {
|
|
269
|
+
if (typeof window !== 'undefined' && window.localStorage) {
|
|
270
|
+
const raw = window.localStorage.getItem(HEADER_SETTINGS_STORAGE_KEY);
|
|
271
|
+
if (raw) {
|
|
272
|
+
const parsed = JSON.parse(raw);
|
|
273
|
+
return {
|
|
274
|
+
showChatHeaderButton: parsed.showChatHeaderButton !== false,
|
|
275
|
+
showChatHeaderActions: parsed.showChatHeaderActions !== false,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
} catch (_e) {
|
|
280
|
+
void _e;
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
showChatHeaderButton: true,
|
|
284
|
+
showChatHeaderActions: true,
|
|
285
|
+
};
|
|
286
|
+
})();
|
|
287
|
+
|
|
288
|
+
const headerSettingsListeners = new Set();
|
|
289
|
+
|
|
290
|
+
function updateHeaderSettings(patch) {
|
|
291
|
+
if (!patch || typeof patch !== 'object') return currentHeaderSettings;
|
|
292
|
+
let changed = false;
|
|
293
|
+
const next = Object.assign({}, currentHeaderSettings);
|
|
294
|
+
if (patch.showChatHeaderButton !== undefined) {
|
|
295
|
+
const val = Boolean(patch.showChatHeaderButton);
|
|
296
|
+
if (next.showChatHeaderButton !== val) {
|
|
297
|
+
next.showChatHeaderButton = val;
|
|
298
|
+
changed = true;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (patch.showChatHeaderActions !== undefined) {
|
|
302
|
+
const val = Boolean(patch.showChatHeaderActions);
|
|
303
|
+
if (next.showChatHeaderActions !== val) {
|
|
304
|
+
next.showChatHeaderActions = val;
|
|
305
|
+
changed = true;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (changed) {
|
|
309
|
+
currentHeaderSettings = next;
|
|
310
|
+
try {
|
|
311
|
+
if (typeof window !== 'undefined' && window.localStorage) {
|
|
312
|
+
window.localStorage.setItem(HEADER_SETTINGS_STORAGE_KEY, JSON.stringify(next));
|
|
313
|
+
}
|
|
314
|
+
} catch (_e) {
|
|
315
|
+
void _e;
|
|
316
|
+
}
|
|
317
|
+
for (const fn of headerSettingsListeners) {
|
|
318
|
+
try {
|
|
319
|
+
fn(currentHeaderSettings);
|
|
320
|
+
} catch (_err) {
|
|
321
|
+
void _err;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return currentHeaderSettings;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
let headerSettingsSynced = false;
|
|
329
|
+
let headerSettingsSyncing = null;
|
|
330
|
+
|
|
331
|
+
function syncHeaderSettingsFromServer() {
|
|
332
|
+
if (headerSettingsSyncing) return headerSettingsSyncing;
|
|
333
|
+
headerSettingsSyncing = fetchJsonWithTimeout('/dsh-cron/settings')
|
|
334
|
+
.then(({ data }) => {
|
|
335
|
+
headerSettingsSynced = true;
|
|
336
|
+
if (data && data.ok && data.settings) {
|
|
337
|
+
updateHeaderSettings({
|
|
338
|
+
showChatHeaderButton: data.settings.showChatHeaderButton !== false,
|
|
339
|
+
showChatHeaderActions: data.settings.showChatHeaderActions !== false,
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
})
|
|
343
|
+
.catch((_err) => {
|
|
344
|
+
void _err;
|
|
345
|
+
})
|
|
346
|
+
.finally(() => {
|
|
347
|
+
headerSettingsSyncing = null;
|
|
348
|
+
});
|
|
349
|
+
return headerSettingsSyncing;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function useHeaderVisibility(key) {
|
|
353
|
+
if (typeof React === 'undefined' || typeof React.useState !== 'function') {
|
|
354
|
+
return Boolean(currentHeaderSettings[key] !== false);
|
|
355
|
+
}
|
|
356
|
+
const [visible, setVisible] = React.useState(Boolean(currentHeaderSettings[key] !== false));
|
|
357
|
+
if (typeof React.useEffect === 'function') {
|
|
358
|
+
React.useEffect(() => {
|
|
359
|
+
if (!headerSettingsSynced) {
|
|
360
|
+
syncHeaderSettingsFromServer();
|
|
361
|
+
}
|
|
362
|
+
const listener = (newSettings) => {
|
|
363
|
+
setVisible(Boolean(newSettings[key] !== false));
|
|
364
|
+
};
|
|
365
|
+
headerSettingsListeners.add(listener);
|
|
366
|
+
return () => {
|
|
367
|
+
headerSettingsListeners.delete(listener);
|
|
368
|
+
};
|
|
369
|
+
}, [key]);
|
|
370
|
+
}
|
|
371
|
+
return visible;
|
|
372
|
+
}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
const [onlyFailure, setOnlyFailure] = React.useState(false);
|
|
8
8
|
const [llmActionsEnabled, setLlmActionsEnabled] = React.useState(false);
|
|
9
9
|
const [enableDynamicCredentials, setEnableDynamicCredentials] = React.useState(false);
|
|
10
|
+
const [showChatHeaderButton, setShowChatHeaderButton] = React.useState(Boolean(currentHeaderSettings.showChatHeaderButton !== false));
|
|
11
|
+
const [showChatHeaderActions, setShowChatHeaderActions] = React.useState(Boolean(currentHeaderSettings.showChatHeaderActions !== false));
|
|
10
12
|
const [kanbanUrl, setKanbanUrl] = React.useState('http://127.0.0.1:3000');
|
|
11
13
|
const [delivery, setDelivery] = React.useState({});
|
|
12
14
|
const [sections, setSections] = React.useState({ channels: true });
|
|
@@ -91,6 +93,11 @@
|
|
|
91
93
|
setOnlyFailure(Boolean(data.settings.onlyOnFailure));
|
|
92
94
|
setLlmActionsEnabled(Boolean(data.settings.llmActionsEnabled));
|
|
93
95
|
setEnableDynamicCredentials(Boolean(data.settings.enableDynamicCredentials));
|
|
96
|
+
const btnVis = data.settings.showChatHeaderButton !== false;
|
|
97
|
+
const actVis = data.settings.showChatHeaderActions !== false;
|
|
98
|
+
setShowChatHeaderButton(btnVis);
|
|
99
|
+
setShowChatHeaderActions(actVis);
|
|
100
|
+
updateHeaderSettings({ showChatHeaderButton: btnVis, showChatHeaderActions: actVis });
|
|
94
101
|
setKanbanUrl(data.settings.kanbanBaseUrl || 'http://127.0.0.1:3000');
|
|
95
102
|
setDelivery(pickDeliverySettings(data.settings));
|
|
96
103
|
setHasDefault(Boolean(data.settings.hasDefaultCredentials));
|
|
@@ -119,6 +126,8 @@
|
|
|
119
126
|
onlyOnFailure: onlyFailure,
|
|
120
127
|
llmActionsEnabled: llmActionsEnabled,
|
|
121
128
|
enableDynamicCredentials: enableDynamicCredentials,
|
|
129
|
+
showChatHeaderButton: showChatHeaderButton,
|
|
130
|
+
showChatHeaderActions: showChatHeaderActions,
|
|
122
131
|
kanbanBaseUrl: kanbanUrl
|
|
123
132
|
}, delivery))
|
|
124
133
|
});
|
|
@@ -270,6 +279,30 @@
|
|
|
270
279
|
onChange: (e) => setEnableDynamicCredentials(e.target.checked)
|
|
271
280
|
}),
|
|
272
281
|
React.createElement('span', null, T_KEY(t, 'settings.dynamicCredentials'))
|
|
282
|
+
),
|
|
283
|
+
React.createElement('label', { className: 'dsh-cron-checkbox-row' },
|
|
284
|
+
React.createElement('input', {
|
|
285
|
+
type: 'checkbox',
|
|
286
|
+
checked: showChatHeaderButton,
|
|
287
|
+
onChange: (e) => {
|
|
288
|
+
const val = e.target.checked;
|
|
289
|
+
setShowChatHeaderButton(val);
|
|
290
|
+
updateHeaderSettings({ showChatHeaderButton: val });
|
|
291
|
+
}
|
|
292
|
+
}),
|
|
293
|
+
React.createElement('span', null, T_KEY(t, 'settings.showChatHeaderButton'))
|
|
294
|
+
),
|
|
295
|
+
React.createElement('label', { className: 'dsh-cron-checkbox-row' },
|
|
296
|
+
React.createElement('input', {
|
|
297
|
+
type: 'checkbox',
|
|
298
|
+
checked: showChatHeaderActions,
|
|
299
|
+
onChange: (e) => {
|
|
300
|
+
const val = e.target.checked;
|
|
301
|
+
setShowChatHeaderActions(val);
|
|
302
|
+
updateHeaderSettings({ showChatHeaderActions: val });
|
|
303
|
+
}
|
|
304
|
+
}),
|
|
305
|
+
React.createElement('span', null, T_KEY(t, 'settings.showChatHeaderActions'))
|
|
273
306
|
)
|
|
274
307
|
),
|
|
275
308
|
...renderDeliverySettings({
|
|
@@ -16,6 +16,7 @@ function sessionIdOf(ctx, props) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function SessionQuickActionBar(props) {
|
|
19
|
+
const visible = useHeaderVisibility('showChatHeaderActions');
|
|
19
20
|
const { ctx, toggle } = props;
|
|
20
21
|
const barT = props.t || translate;
|
|
21
22
|
const [tasks, setTasks] = React.useState([]);
|
|
@@ -25,6 +26,7 @@ function SessionQuickActionBar(props) {
|
|
|
25
26
|
const sessionId = sessionIdOf(ctx, props);
|
|
26
27
|
|
|
27
28
|
React.useEffect(() => {
|
|
29
|
+
if (!visible) return;
|
|
28
30
|
let unmounted = false;
|
|
29
31
|
const fetchTasks = async () => {
|
|
30
32
|
try {
|
|
@@ -95,6 +97,8 @@ function SessionQuickActionBar(props) {
|
|
|
95
97
|
}
|
|
96
98
|
};
|
|
97
99
|
|
|
100
|
+
if (!visible) return null;
|
|
101
|
+
|
|
98
102
|
if (linkedTask) {
|
|
99
103
|
const running = linkedTask.running || isRunning;
|
|
100
104
|
return React.createElement('div', {
|
|
@@ -182,6 +182,8 @@
|
|
|
182
182
|
const barSlot = barOk ? 'conversation.session.header.actions' : undefined;
|
|
183
183
|
|
|
184
184
|
function CronChip(props) {
|
|
185
|
+
const visible = useHeaderVisibility('showChatHeaderButton');
|
|
186
|
+
if (!visible) return null;
|
|
185
187
|
const chipT = props.t || translate;
|
|
186
188
|
return React.createElement('button', {
|
|
187
189
|
type: 'button',
|
|
@@ -206,6 +208,9 @@
|
|
|
206
208
|
exports.slots = { card: cardSlot, chip: chipSlot, sessionBar: barSlot };
|
|
207
209
|
module.exports.panelDismissRule = shouldDismissPanel;
|
|
208
210
|
module.exports.sidebarJobsSeatIsCurrent = sidebarJobsSeatIsCurrent;
|
|
211
|
+
module.exports.updateHeaderSettings = updateHeaderSettings;
|
|
212
|
+
module.exports.useHeaderVisibility = useHeaderVisibility;
|
|
213
|
+
module.exports.getHeaderSettings = () => currentHeaderSettings;
|
|
209
214
|
}
|
|
210
215
|
|
|
211
216
|
module.exports = { apply, inject: ['slots', 'locale'] };
|
package/lib/client.js
CHANGED
|
@@ -229,6 +229,8 @@ en: {
|
|
|
229
229
|
'settings.globalOnlyFailure': 'Global mode: only on failures (silent on success)',
|
|
230
230
|
'settings.dynamicCredentials': 'Dynamic Credentials Resolution (credential://...)',
|
|
231
231
|
'settings.dynamicCredentialsHint': 'Resolve credential://... in memory from harness credentials at runtime (#335)',
|
|
232
|
+
'settings.showChatHeaderButton': 'Show schedule button in chat header',
|
|
233
|
+
'settings.showChatHeaderActions': 'Show quick create action in chat header',
|
|
232
234
|
'settings.testTelegram': '🔔 Test Telegram delivery', 'settings.testKanban': '📋 Test Kanban',
|
|
233
235
|
'settings.sending': 'Sending...', 'settings.checkingKanban': 'Checking Kanban...',
|
|
234
236
|
'settings.testOk': '✅ Test message delivered to Telegram!', 'settings.testFail': '❌ {error}',
|
|
@@ -469,7 +471,9 @@ zh: {
|
|
|
469
471
|
'settings.chatIdLabel': 'Telegram Chat ID', 'settings.chatIdPlaceholder': '例如: 345678901',
|
|
470
472
|
'settings.kanbanUrlLabel': 'Kanban 服务基础地址', 'settings.globalNotify': '全局开启所有任务结果推送至 Telegram',
|
|
471
473
|
'settings.globalOnlyFailure': '全局模式:仅在失败时推送 (成功静默)', 'settings.dynamicCredentials': '动态凭据解析 (credential://...)',
|
|
472
|
-
'settings.dynamicCredentialsHint': '运行时从凭据服务动态解析 credential://... 且不泄露到存储 (#335)',
|
|
474
|
+
'settings.dynamicCredentialsHint': '运行时从凭据服务动态解析 credential://... 且不泄露到存储 (#335)',
|
|
475
|
+
'settings.showChatHeaderButton': '在聊天标题栏显示定时任务按钮',
|
|
476
|
+
'settings.showChatHeaderActions': '在聊天标题栏显示快速创建操作', 'settings.testTelegram': '🔔 测试 Telegram 发送',
|
|
473
477
|
'settings.testKanban': '📋 测试 Kanban', 'settings.sending': '正在发送...',
|
|
474
478
|
'settings.checkingKanban': '正在连接 Kanban...', 'settings.testOk': '✅ 测试消息已成功发送至 Telegram!',
|
|
475
479
|
'settings.testFail': '❌ 发送失败: {error}', 'settings.kanbanOk': '✅ Kanban 卡片创建成功',
|
|
@@ -848,6 +852,108 @@ throw jsonErr;
|
|
|
848
852
|
}
|
|
849
853
|
return { res, data };
|
|
850
854
|
};
|
|
855
|
+
const HEADER_SETTINGS_STORAGE_KEY = 'dsh-cron:header-settings';
|
|
856
|
+
let currentHeaderSettings = (function initHeaderSettings() {
|
|
857
|
+
try {
|
|
858
|
+
if (typeof window !== 'undefined' && window.localStorage) {
|
|
859
|
+
const raw = window.localStorage.getItem(HEADER_SETTINGS_STORAGE_KEY);
|
|
860
|
+
if (raw) {
|
|
861
|
+
const parsed = JSON.parse(raw);
|
|
862
|
+
return {
|
|
863
|
+
showChatHeaderButton: parsed.showChatHeaderButton !== false,
|
|
864
|
+
showChatHeaderActions: parsed.showChatHeaderActions !== false,
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
} catch (_e) {
|
|
869
|
+
void _e;
|
|
870
|
+
}
|
|
871
|
+
return {
|
|
872
|
+
showChatHeaderButton: true,
|
|
873
|
+
showChatHeaderActions: true,
|
|
874
|
+
};
|
|
875
|
+
})();
|
|
876
|
+
const headerSettingsListeners = new Set();
|
|
877
|
+
function updateHeaderSettings(patch) {
|
|
878
|
+
if (!patch || typeof patch !== 'object') return currentHeaderSettings;
|
|
879
|
+
let changed = false;
|
|
880
|
+
const next = Object.assign({}, currentHeaderSettings);
|
|
881
|
+
if (patch.showChatHeaderButton !== undefined) {
|
|
882
|
+
const val = Boolean(patch.showChatHeaderButton);
|
|
883
|
+
if (next.showChatHeaderButton !== val) {
|
|
884
|
+
next.showChatHeaderButton = val;
|
|
885
|
+
changed = true;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
if (patch.showChatHeaderActions !== undefined) {
|
|
889
|
+
const val = Boolean(patch.showChatHeaderActions);
|
|
890
|
+
if (next.showChatHeaderActions !== val) {
|
|
891
|
+
next.showChatHeaderActions = val;
|
|
892
|
+
changed = true;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
if (changed) {
|
|
896
|
+
currentHeaderSettings = next;
|
|
897
|
+
try {
|
|
898
|
+
if (typeof window !== 'undefined' && window.localStorage) {
|
|
899
|
+
window.localStorage.setItem(HEADER_SETTINGS_STORAGE_KEY, JSON.stringify(next));
|
|
900
|
+
}
|
|
901
|
+
} catch (_e) {
|
|
902
|
+
void _e;
|
|
903
|
+
}
|
|
904
|
+
for (const fn of headerSettingsListeners) {
|
|
905
|
+
try {
|
|
906
|
+
fn(currentHeaderSettings);
|
|
907
|
+
} catch (_err) {
|
|
908
|
+
void _err;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
return currentHeaderSettings;
|
|
913
|
+
}
|
|
914
|
+
let headerSettingsSynced = false;
|
|
915
|
+
let headerSettingsSyncing = null;
|
|
916
|
+
function syncHeaderSettingsFromServer() {
|
|
917
|
+
if (headerSettingsSyncing) return headerSettingsSyncing;
|
|
918
|
+
headerSettingsSyncing = fetchJsonWithTimeout('/dsh-cron/settings')
|
|
919
|
+
.then(({ data }) => {
|
|
920
|
+
headerSettingsSynced = true;
|
|
921
|
+
if (data && data.ok && data.settings) {
|
|
922
|
+
updateHeaderSettings({
|
|
923
|
+
showChatHeaderButton: data.settings.showChatHeaderButton !== false,
|
|
924
|
+
showChatHeaderActions: data.settings.showChatHeaderActions !== false,
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
})
|
|
928
|
+
.catch((_err) => {
|
|
929
|
+
void _err;
|
|
930
|
+
})
|
|
931
|
+
.finally(() => {
|
|
932
|
+
headerSettingsSyncing = null;
|
|
933
|
+
});
|
|
934
|
+
return headerSettingsSyncing;
|
|
935
|
+
}
|
|
936
|
+
function useHeaderVisibility(key) {
|
|
937
|
+
if (typeof React === 'undefined' || typeof React.useState !== 'function') {
|
|
938
|
+
return Boolean(currentHeaderSettings[key] !== false);
|
|
939
|
+
}
|
|
940
|
+
const [visible, setVisible] = React.useState(Boolean(currentHeaderSettings[key] !== false));
|
|
941
|
+
if (typeof React.useEffect === 'function') {
|
|
942
|
+
React.useEffect(() => {
|
|
943
|
+
if (!headerSettingsSynced) {
|
|
944
|
+
syncHeaderSettingsFromServer();
|
|
945
|
+
}
|
|
946
|
+
const listener = (newSettings) => {
|
|
947
|
+
setVisible(Boolean(newSettings[key] !== false));
|
|
948
|
+
};
|
|
949
|
+
headerSettingsListeners.add(listener);
|
|
950
|
+
return () => {
|
|
951
|
+
headerSettingsListeners.delete(listener);
|
|
952
|
+
};
|
|
953
|
+
}, [key]);
|
|
954
|
+
}
|
|
955
|
+
return visible;
|
|
956
|
+
}
|
|
851
957
|
function pickDeliverySettings(source) {
|
|
852
958
|
const out = {};
|
|
853
959
|
for (const key of DELIVERY_SETTING_KEYS.concat(TEMPLATE_SETTING_KEYS)) {
|
|
@@ -4838,6 +4944,8 @@ const [notify, setNotify] = React.useState(false);
|
|
|
4838
4944
|
const [onlyFailure, setOnlyFailure] = React.useState(false);
|
|
4839
4945
|
const [llmActionsEnabled, setLlmActionsEnabled] = React.useState(false);
|
|
4840
4946
|
const [enableDynamicCredentials, setEnableDynamicCredentials] = React.useState(false);
|
|
4947
|
+
const [showChatHeaderButton, setShowChatHeaderButton] = React.useState(Boolean(currentHeaderSettings.showChatHeaderButton !== false));
|
|
4948
|
+
const [showChatHeaderActions, setShowChatHeaderActions] = React.useState(Boolean(currentHeaderSettings.showChatHeaderActions !== false));
|
|
4841
4949
|
const [kanbanUrl, setKanbanUrl] = React.useState('http://127.0.0.1:3000');
|
|
4842
4950
|
const [delivery, setDelivery] = React.useState({});
|
|
4843
4951
|
const [sections, setSections] = React.useState({ channels: true });
|
|
@@ -4915,6 +5023,11 @@ setNotify(Boolean(data.settings.notifyTelegram));
|
|
|
4915
5023
|
setOnlyFailure(Boolean(data.settings.onlyOnFailure));
|
|
4916
5024
|
setLlmActionsEnabled(Boolean(data.settings.llmActionsEnabled));
|
|
4917
5025
|
setEnableDynamicCredentials(Boolean(data.settings.enableDynamicCredentials));
|
|
5026
|
+
const btnVis = data.settings.showChatHeaderButton !== false;
|
|
5027
|
+
const actVis = data.settings.showChatHeaderActions !== false;
|
|
5028
|
+
setShowChatHeaderButton(btnVis);
|
|
5029
|
+
setShowChatHeaderActions(actVis);
|
|
5030
|
+
updateHeaderSettings({ showChatHeaderButton: btnVis, showChatHeaderActions: actVis });
|
|
4918
5031
|
setKanbanUrl(data.settings.kanbanBaseUrl || 'http://127.0.0.1:3000');
|
|
4919
5032
|
setDelivery(pickDeliverySettings(data.settings));
|
|
4920
5033
|
setHasDefault(Boolean(data.settings.hasDefaultCredentials));
|
|
@@ -4942,6 +5055,8 @@ notifyTelegram: notify,
|
|
|
4942
5055
|
onlyOnFailure: onlyFailure,
|
|
4943
5056
|
llmActionsEnabled: llmActionsEnabled,
|
|
4944
5057
|
enableDynamicCredentials: enableDynamicCredentials,
|
|
5058
|
+
showChatHeaderButton: showChatHeaderButton,
|
|
5059
|
+
showChatHeaderActions: showChatHeaderActions,
|
|
4945
5060
|
kanbanBaseUrl: kanbanUrl
|
|
4946
5061
|
}, delivery))
|
|
4947
5062
|
});
|
|
@@ -5087,6 +5202,30 @@ checked: enableDynamicCredentials,
|
|
|
5087
5202
|
onChange: (e) => setEnableDynamicCredentials(e.target.checked)
|
|
5088
5203
|
}),
|
|
5089
5204
|
_h('span', null, T_KEY(t, 'settings.dynamicCredentials'))
|
|
5205
|
+
),
|
|
5206
|
+
_h('label', { className: 'dsh-cron-checkbox-row' },
|
|
5207
|
+
_h('input', {
|
|
5208
|
+
type: 'checkbox',
|
|
5209
|
+
checked: showChatHeaderButton,
|
|
5210
|
+
onChange: (e) => {
|
|
5211
|
+
const val = e.target.checked;
|
|
5212
|
+
setShowChatHeaderButton(val);
|
|
5213
|
+
updateHeaderSettings({ showChatHeaderButton: val });
|
|
5214
|
+
}
|
|
5215
|
+
}),
|
|
5216
|
+
_h('span', null, T_KEY(t, 'settings.showChatHeaderButton'))
|
|
5217
|
+
),
|
|
5218
|
+
_h('label', { className: 'dsh-cron-checkbox-row' },
|
|
5219
|
+
_h('input', {
|
|
5220
|
+
type: 'checkbox',
|
|
5221
|
+
checked: showChatHeaderActions,
|
|
5222
|
+
onChange: (e) => {
|
|
5223
|
+
const val = e.target.checked;
|
|
5224
|
+
setShowChatHeaderActions(val);
|
|
5225
|
+
updateHeaderSettings({ showChatHeaderActions: val });
|
|
5226
|
+
}
|
|
5227
|
+
}),
|
|
5228
|
+
_h('span', null, T_KEY(t, 'settings.showChatHeaderActions'))
|
|
5090
5229
|
)
|
|
5091
5230
|
),
|
|
5092
5231
|
...renderDeliverySettings({
|
|
@@ -5233,6 +5372,7 @@ void _e;
|
|
|
5233
5372
|
return '';
|
|
5234
5373
|
}
|
|
5235
5374
|
function SessionQuickActionBar(props) {
|
|
5375
|
+
const visible = useHeaderVisibility('showChatHeaderActions');
|
|
5236
5376
|
const { ctx, toggle } = props;
|
|
5237
5377
|
const barT = props.t || translate;
|
|
5238
5378
|
const [tasks, setTasks] = React.useState([]);
|
|
@@ -5240,6 +5380,7 @@ const [isRunning, setIsRunning] = React.useState(false);
|
|
|
5240
5380
|
const [runSuccess, setRunSuccess] = React.useState(false);
|
|
5241
5381
|
const sessionId = sessionIdOf(ctx, props);
|
|
5242
5382
|
React.useEffect(() => {
|
|
5383
|
+
if (!visible) return;
|
|
5243
5384
|
let unmounted = false;
|
|
5244
5385
|
const fetchTasks = async () => {
|
|
5245
5386
|
try {
|
|
@@ -5305,6 +5446,7 @@ void _err;
|
|
|
5305
5446
|
setIsRunning(false);
|
|
5306
5447
|
}
|
|
5307
5448
|
};
|
|
5449
|
+
if (!visible) return null;
|
|
5308
5450
|
if (linkedTask) {
|
|
5309
5451
|
const running = linkedTask.running || isRunning;
|
|
5310
5452
|
return _h('div', {
|
|
@@ -5663,6 +5805,8 @@ return _h(ErrorBoundary, null, _h(SessionQuickActionBar, props));
|
|
|
5663
5805
|
});
|
|
5664
5806
|
const barSlot = barOk ? 'conversation.session.header.actions' : undefined;
|
|
5665
5807
|
function CronChip(props) {
|
|
5808
|
+
const visible = useHeaderVisibility('showChatHeaderButton');
|
|
5809
|
+
if (!visible) return null;
|
|
5666
5810
|
const chipT = props.t || translate;
|
|
5667
5811
|
return _h('button', {
|
|
5668
5812
|
type: 'button',
|
|
@@ -5685,6 +5829,9 @@ return () => { for (const dispose of off) dispose(); stopStyleSelfHeal(); };
|
|
|
5685
5829
|
exports.slots = { card: cardSlot, chip: chipSlot, sessionBar: barSlot };
|
|
5686
5830
|
module.exports.panelDismissRule = shouldDismissPanel;
|
|
5687
5831
|
module.exports.sidebarJobsSeatIsCurrent = sidebarJobsSeatIsCurrent;
|
|
5832
|
+
module.exports.updateHeaderSettings = updateHeaderSettings;
|
|
5833
|
+
module.exports.useHeaderVisibility = useHeaderVisibility;
|
|
5834
|
+
module.exports.getHeaderSettings = () => currentHeaderSettings;
|
|
5688
5835
|
}
|
|
5689
5836
|
module.exports = { apply, inject: ['slots', 'locale'] };
|
|
5690
5837
|
return module.exports;
|
package/lib/locales.json
CHANGED
|
@@ -431,6 +431,8 @@
|
|
|
431
431
|
"sessionBar.addRecurringHint": "将当前会话转为定时计划任务",
|
|
432
432
|
"sessionBar.run": "运行",
|
|
433
433
|
"sessionBar.runNow": "立即执行",
|
|
434
|
-
"sessionBar.running": "执行中..."
|
|
434
|
+
"sessionBar.running": "执行中...",
|
|
435
|
+
"settings.showChatHeaderButton": "在聊天标题栏显示定时任务按钮",
|
|
436
|
+
"settings.showChatHeaderActions": "在聊天标题栏显示快速创建操作"
|
|
435
437
|
}
|
|
436
438
|
}
|
package/lib/log-streamer.js
CHANGED
|
@@ -38,7 +38,7 @@ export async function handleTaskCollection({ store, scheduler, collection, req,
|
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
if (req.method === 'POST') {
|
|
41
|
-
await createOrUpdateTask({ store, scheduler, req, res, apiToken, ctx
|
|
41
|
+
await createOrUpdateTask({ store, scheduler, req, res, apiToken, ctx });
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
sendJson(res, 405, NOT_ALLOWED);
|
package/lib/routes/api-item.js
CHANGED
|
@@ -21,12 +21,12 @@ export async function handleTaskItem({ store, scheduler, req, res, url, id, acti
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
if (req.method === 'GET') {
|
|
24
|
-
|
|
24
|
+
if (rejectCrossOrigin(req, res, { apiToken, ctx })) return;
|
|
25
|
+
// Both /dsh-cron/tasks/:id/stream and /dsh-cron/tasks/:id/logs/stream (#392, #424)
|
|
25
26
|
if (action === 'stream' || (action === 'logs' && subAction === 'stream')) {
|
|
26
27
|
logStreamer.handleSseRequest(id, req, res);
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
29
|
-
if (rejectCrossOrigin(req, res, { apiToken, ctx })) return;
|
|
30
30
|
if (action === 'archive') {
|
|
31
31
|
const limit = parseInt(url.searchParams.get('limit') || '50', 10);
|
|
32
32
|
const offset = parseInt(url.searchParams.get('offset') || '0', 10);
|
package/lib/routes/routes.js
CHANGED
|
@@ -33,6 +33,9 @@ export function registerRoutes(ctx, { store, scheduler, recommendations }) {
|
|
|
33
33
|
res.end('GET only');
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
+
const settings = store && typeof store.getSettings === 'function' ? store.getSettings() : {};
|
|
37
|
+
const apiToken = settings.apiToken;
|
|
38
|
+
if (rejectCrossOrigin(req, res, { apiToken, ctx })) return;
|
|
36
39
|
res.writeHead(200, {
|
|
37
40
|
'content-type': 'application/json; charset=utf-8',
|
|
38
41
|
'cache-control': 'no-store',
|
|
@@ -52,6 +55,9 @@ export function registerRoutes(ctx, { store, scheduler, recommendations }) {
|
|
|
52
55
|
res.end('GET only');
|
|
53
56
|
return;
|
|
54
57
|
}
|
|
58
|
+
const settings = store && typeof store.getSettings === 'function' ? store.getSettings() : {};
|
|
59
|
+
const apiToken = settings.apiToken;
|
|
60
|
+
if (rejectCrossOrigin(req, res, { apiToken, ctx })) return;
|
|
55
61
|
const url = new URL(req.url, 'http://127.0.0.1');
|
|
56
62
|
const month = url.pathname.replace(/^\/dsh-cron\/history\/archive\//, '').replace(/\/$/, '');
|
|
57
63
|
if (!/^\d{4}-\d{2}$/.test(month)) {
|
|
@@ -67,7 +73,7 @@ export function registerRoutes(ctx, { store, scheduler, recommendations }) {
|
|
|
67
73
|
}
|
|
68
74
|
res.writeHead(200, {
|
|
69
75
|
'content-type': 'application/json; charset=utf-8',
|
|
70
|
-
'cache-control': '
|
|
76
|
+
'cache-control': 'no-store',
|
|
71
77
|
});
|
|
72
78
|
res.end(JSON.stringify({ ok: true, month, archive }));
|
|
73
79
|
}
|
package/lib/runtimes/runtimes.js
CHANGED
|
@@ -90,6 +90,24 @@ export function buildPythonInvocation(task, cwd) {
|
|
|
90
90
|
return { file: interpreter, args: ['-c', String(task.prompt || '')] };
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
/** #427: Validate hostnames against cloud provider metadata and link-local IP addresses. */
|
|
94
|
+
export function isCloudMetadataHost(hostname) {
|
|
95
|
+
if (!hostname || typeof hostname !== 'string') return false;
|
|
96
|
+
const h = hostname.toLowerCase().replace(/^\[|\]$/g, '');
|
|
97
|
+
if (
|
|
98
|
+
h === '169.254.169.254' ||
|
|
99
|
+
h.startsWith('169.254.') ||
|
|
100
|
+
h === '100.100.100.200' ||
|
|
101
|
+
h === 'fd00:ec2::254' ||
|
|
102
|
+
h === 'metadata.google.internal' ||
|
|
103
|
+
h === 'metadata.azure.com' ||
|
|
104
|
+
h.endsWith('.internal.cloudapp.net')
|
|
105
|
+
) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
|
|
93
111
|
/** #7: build the HTTP trigger request description. */
|
|
94
112
|
export function buildHttpRequest(task) {
|
|
95
113
|
const raw = String(task.httpUrl || task.prompt || '').trim();
|
|
@@ -101,12 +119,7 @@ export function buildHttpRequest(task) {
|
|
|
101
119
|
throw new Error(`Invalid HTTP URL: ${raw}`);
|
|
102
120
|
}
|
|
103
121
|
const hostname = url.hostname.toLowerCase();
|
|
104
|
-
if (
|
|
105
|
-
hostname === '169.254.169.254' ||
|
|
106
|
-
hostname === 'metadata.google.internal' ||
|
|
107
|
-
hostname === 'metadata.azure.com' ||
|
|
108
|
-
hostname.endsWith('.internal.cloudapp.net')
|
|
109
|
-
) {
|
|
122
|
+
if (isCloudMetadataHost(hostname)) {
|
|
110
123
|
throw new Error(`Access to cloud metadata endpoint "${hostname}" is restricted`);
|
|
111
124
|
}
|
|
112
125
|
let headers = {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isCloudMetadataHost } from '../runtimes/runtimes.js';
|
|
1
2
|
import { collectDigestMetrics, formatDigestReport } from '../digest.js';
|
|
2
3
|
import { exec } from 'node:child_process';
|
|
3
4
|
import fs from 'node:fs';
|
|
@@ -42,7 +43,7 @@ export async function executePreflight(task) {
|
|
|
42
43
|
try {
|
|
43
44
|
const u = new URL(target);
|
|
44
45
|
const host = u.hostname.toLowerCase();
|
|
45
|
-
if (host
|
|
46
|
+
if (isCloudMetadataHost(host)) {
|
|
46
47
|
return { ok: false, reason: `HTTP check to cloud metadata endpoint "${host}" is restricted` };
|
|
47
48
|
}
|
|
48
49
|
} catch (_e) {
|
package/lib/settings.js
CHANGED
|
@@ -53,6 +53,9 @@ export const Config = z.object({
|
|
|
53
53
|
prReviewerEnabled: z.boolean().default(false).description('Enable automated PR Reviewer scheduled agent (#33)').volatile(),
|
|
54
54
|
// --- Dynamic credentials resolution (#335) ---
|
|
55
55
|
enableDynamicCredentials: z.boolean().default(false).description('Enable dynamic credential://... reference resolution at runtime (#335)').volatile(),
|
|
56
|
+
// --- Chat header visibility settings (#422) ---
|
|
57
|
+
showChatHeaderButton: z.boolean().default(true).description('Show schedule button in chat header utilities').volatile(),
|
|
58
|
+
showChatHeaderActions: z.boolean().default(true).description('Show quick task action in chat header actions').volatile(),
|
|
56
59
|
// --- Global Budgets (#320) ---
|
|
57
60
|
globalDailyCostLimitUsd: z.number().default(0).description('Global daily expenditure limit in USD across all tasks (0 = unlimited)').volatile(),
|
|
58
61
|
providerHourlyRunLimits: z.object({}).default({}).description('Max runs per hour keyed by provider').volatile(),
|
|
@@ -94,6 +97,7 @@ export const SETTINGS_SYNC_KEYS = [
|
|
|
94
97
|
'ttsBaseUrl',
|
|
95
98
|
'giteaBaseUrl', 'giteaRepo', 'giteaTokenRef', 'giteaLabels', 'giteaLabelIds', 'prReviewerEnabled', 'enableDynamicCredentials',
|
|
96
99
|
'apiToken',
|
|
100
|
+
'showChatHeaderButton', 'showChatHeaderActions',
|
|
97
101
|
'globalDailyCostLimitUsd', 'providerHourlyRunLimits', 'modelHourlyRunLimits',
|
|
98
102
|
];
|
|
99
103
|
|
package/lib/store/store.js
CHANGED
|
@@ -557,6 +557,8 @@ export class TaskStore {
|
|
|
557
557
|
base.kanbanBaseUrl = base.kanbanBaseUrl || 'http://127.0.0.1:3000';
|
|
558
558
|
base.hasDefaultCredentials = Boolean(defaults.botToken && defaults.chatId);
|
|
559
559
|
base.llmActionsEnabled = Boolean(base.llmActionsEnabled);
|
|
560
|
+
base.showChatHeaderButton = base.showChatHeaderButton !== undefined ? Boolean(base.showChatHeaderButton) : true;
|
|
561
|
+
base.showChatHeaderActions = base.showChatHeaderActions !== undefined ? Boolean(base.showChatHeaderActions) : true;
|
|
560
562
|
return base;
|
|
561
563
|
}
|
|
562
564
|
|
|
@@ -648,6 +650,8 @@ export class TaskStore {
|
|
|
648
650
|
notifyTelegram: patch.notifyTelegram !== undefined ? Boolean(patch.notifyTelegram) : Boolean(this.settings.notifyTelegram),
|
|
649
651
|
onlyOnFailure: patch.onlyOnFailure !== undefined ? Boolean(patch.onlyOnFailure) : Boolean(this.settings.onlyOnFailure),
|
|
650
652
|
llmActionsEnabled: patch.llmActionsEnabled !== undefined ? Boolean(patch.llmActionsEnabled) : Boolean(this.settings.llmActionsEnabled),
|
|
653
|
+
showChatHeaderButton: patch.showChatHeaderButton !== undefined ? Boolean(patch.showChatHeaderButton) : (this.settings.showChatHeaderButton !== undefined ? Boolean(this.settings.showChatHeaderButton) : true),
|
|
654
|
+
showChatHeaderActions: patch.showChatHeaderActions !== undefined ? Boolean(patch.showChatHeaderActions) : (this.settings.showChatHeaderActions !== undefined ? Boolean(this.settings.showChatHeaderActions) : true),
|
|
651
655
|
};
|
|
652
656
|
try {
|
|
653
657
|
this.save();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodandready/dsh-cron",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.40",
|
|
4
4
|
"description": "Background automation runner for DSH: isolated agent runs, script/HTTP/SSH/Docker runtimes, cost guard, notifications, heartbeats.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|