@goodandready/dsh-cron 0.3.37 → 0.3.39

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/README.md CHANGED
@@ -728,3 +728,7 @@ Git-managed tasks are isolated with zero interference to manual GUI tasks.
728
728
  Control scheduled workflows directly within active DSH chat sessions (`conversation.session.header.actions`):
729
729
  - **Turn into Recurring Task (`+ Cron`)**: Turn any ongoing discussion or prompt into an automated recurring schedule with pre-populated parameters.
730
730
  - **Live Status & Run Now**: View associated task execution status directly in the conversation header and trigger immediate runs with a single click.
731
+
732
+ ### Security & Safe Execution
733
+ - **Hardened Path Validation**: Wake trigger markers and file watchers strictly disallow access to system directories (`/etc`, `/proc`, `/sys`, `C:\Windows`).
734
+ - **SSRF Guard**: Automated blocking of cloud metadata endpoints (`169.254.169.254`).
package/README.ru.md CHANGED
@@ -682,3 +682,7 @@ tasks:
682
682
  Управляйте регламентными задачами прямо из активного диалога DSH (`conversation.session.header.actions`):
683
683
  - **Превращение сессии в регламентную задачу (`+ В крон`)**: сохраняйте текущий диалог или промпт как регулярную задачу с предзаполненными параметрами в один клик.
684
684
  - **Индикация статуса и быстрый запуск**: отслеживайте статус выполнения привязанных к сессии фоновых задач и запускайте их немедленно прямо из заголовка чата.
685
+
686
+ ### Безопасность и защита системы
687
+ - **Строгая валидация путей**: Триггеры пробуждения блокируют доступ к системным директориям (`/etc`, `/proc`, `/sys`, `C:\Windows`).
688
+ - **Защита от SSRF**: Блокировка запросов к link-local адресам облачных метаданных (`169.254.169.254`).
package/README.zh.md CHANGED
@@ -675,3 +675,7 @@ Git 管理的任务具有隔离标识,绝不影响或覆盖 UI 手动创建的
675
675
  在 DSH 活跃聊天会话中直接管理定时任务(`conversation.session.header.actions`):
676
676
  - **一键转为定时任务(`+ 定时任务`)**:将当前对话或提示词一键转换为预填参数的定时周期任务。
677
677
  - **关联任务状态与即时触发**:在会话顶部直接显示关联后台任务的执行状态,并支持一键立即执行。
678
+
679
+ ### 安全性与安全执行
680
+ - **强化路径验证**:事件唤醒触发器严格禁止访问敏感系统路径(`/etc`、`/proc`、`/sys`、`C:\Windows`)。
681
+ - **SSRF 防护**:自动拦截对云平台元数据地址(`169.254.169.254`)的请求。
@@ -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)', 'settings.testTelegram': '🔔 测试 Telegram 发送',
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)', 'settings.testTelegram': '🔔 测试 Telegram 发送',
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;
@@ -109,6 +109,9 @@ export function reconcileWorkspaceCronTasks(store, workspaceId, declaredTasks =
109
109
  const taskId = `cac_${workspaceId}_${rawId}`.replace(/[^a-zA-Z0-9_-]/g, '_');
110
110
  seenIds.add(taskId);
111
111
 
112
+ const taskType = decl.type || (decl.command ? 'script' : 'llm');
113
+ const taskPrompt = decl.prompt !== undefined ? decl.prompt : (decl.command || '');
114
+
112
115
  const taskRecord = {
113
116
  ...decl,
114
117
  id: taskId,
@@ -118,7 +121,8 @@ export function reconcileWorkspaceCronTasks(store, workspaceId, declaredTasks =
118
121
  workspaceId,
119
122
  managedBy: 'cron_as_code',
120
123
  origin: '.dsh/cron.yaml',
121
- type: decl.type || 'script',
124
+ type: taskType,
125
+ prompt: taskPrompt,
122
126
  };
123
127
 
124
128
  if (existingManaged.has(taskId)) {
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
  }
@@ -100,6 +100,15 @@ export function buildHttpRequest(task) {
100
100
  } catch {
101
101
  throw new Error(`Invalid HTTP URL: ${raw}`);
102
102
  }
103
+ 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
+ ) {
110
+ throw new Error(`Access to cloud metadata endpoint "${hostname}" is restricted`);
111
+ }
103
112
  let headers = {};
104
113
  if (task.httpHeaders) {
105
114
  if (typeof task.httpHeaders === 'object') {
@@ -39,6 +39,15 @@ export async function executePreflight(task) {
39
39
  if (type === 'http') {
40
40
  let timeout;
41
41
  try {
42
+ try {
43
+ const u = new URL(target);
44
+ const host = u.hostname.toLowerCase();
45
+ if (host === '169.254.169.254' || host === 'metadata.google.internal' || host === 'metadata.azure.com') {
46
+ return { ok: false, reason: `HTTP check to cloud metadata endpoint "${host}" is restricted` };
47
+ }
48
+ } catch (_e) {
49
+ void _e;
50
+ }
42
51
  const controller = new AbortController();
43
52
  timeout = setTimeout(() => controller.abort(), 5000);
44
53
  const res = await fetch(target, { signal: controller.signal });
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
 
@@ -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();
@@ -4,7 +4,6 @@ import { logger } from './logger.js';
4
4
  import { bestEffort } from './best-effort.js';
5
5
 
6
6
  const DISALLOWED_ROOTS = [
7
- '/',
8
7
  '/proc',
9
8
  '/sys',
10
9
  '/dev',
@@ -12,7 +11,6 @@ const DISALLOWED_ROOTS = [
12
11
  '/boot',
13
12
  '/run',
14
13
  '/var/run',
15
- 'c:\\',
16
14
  'c:\\windows',
17
15
  'c:\\windows\\system32',
18
16
  'c:\\program files',
@@ -27,22 +25,36 @@ export function isSafeWakePath(targetPath) {
27
25
  return { safe: false, error: 'Path must be a non-empty string' };
28
26
  }
29
27
  const trimmed = targetPath.trim();
30
- if (trimmed.includes('\0')) {
28
+ if (trimmed.indexOf('\0') !== -1) {
31
29
  return { safe: false, error: 'Path must not contain null bytes' };
32
30
  }
33
- const resolved = path.resolve(trimmed);
34
- const lower = resolved.toLowerCase();
35
-
36
- for (const root of DISALLOWED_ROOTS) {
37
- if (lower === root || lower === root.replace(/\\/g, '/')) {
38
- return { safe: false, error: `Path "${resolved}" targets a disallowed system root directory` };
39
- }
31
+ const rawLower = trimmed.toLowerCase().split('\\').join('/');
32
+ if (
33
+ rawLower === 'c:' ||
34
+ rawLower === 'c:/' ||
35
+ rawLower.startsWith('c:/windows') ||
36
+ rawLower.startsWith('c:/program files')
37
+ ) {
38
+ return { safe: false, error: `Path "${targetPath}" targets a disallowed system location` };
40
39
  }
41
40
 
41
+ const resolved = path.resolve(trimmed);
42
+
43
+ // Filesystem root check ('/' on POSIX, 'C:\' on Windows)
42
44
  if (resolved === path.parse(resolved).root) {
43
45
  return { safe: false, error: `Path "${resolved}" is a filesystem root` };
44
46
  }
45
47
 
48
+ const lower = resolved.toLowerCase().split('\\').join('/');
49
+
50
+ for (const root of DISALLOWED_ROOTS) {
51
+ const normRoot = root.toLowerCase().split('\\').join('/');
52
+ const rootWithSlash = normRoot.endsWith('/') ? normRoot : normRoot + '/';
53
+ if (lower === normRoot || lower.startsWith(rootWithSlash)) {
54
+ return { safe: false, error: `Path "${resolved}" targets a disallowed system location` };
55
+ }
56
+ }
57
+
46
58
  return { safe: true, resolved };
47
59
  }
48
60
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-cron",
3
- "version": "0.3.37",
3
+ "version": "0.3.39",
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",