@goodandready/dsh-cron 0.3.36 → 0.3.38

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
@@ -723,3 +723,12 @@ tasks:
723
723
  timeBoxMinutes: 15
724
724
  ```
725
725
  Git-managed tasks are isolated with zero interference to manual GUI tasks.
726
+
727
+ ### In-Session Quick Action Bar
728
+ Control scheduled workflows directly within active DSH chat sessions (`conversation.session.header.actions`):
729
+ - **Turn into Recurring Task (`+ Cron`)**: Turn any ongoing discussion or prompt into an automated recurring schedule with pre-populated parameters.
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
@@ -677,3 +677,12 @@ tasks:
677
677
  timeBoxMinutes: 15
678
678
  ```
679
679
  Задачи из репозитория изолированы и не перезаписывают ручные задачи, созданные в UI.
680
+
681
+ ### Контекстная панель в сессиях чата (Quick Action Bar)
682
+ Управляйте регламентными задачами прямо из активного диалога DSH (`conversation.session.header.actions`):
683
+ - **Превращение сессии в регламентную задачу (`+ В крон`)**: сохраняйте текущий диалог или промпт как регулярную задачу с предзаполненными параметрами в один клик.
684
+ - **Индикация статуса и быстрый запуск**: отслеживайте статус выполнения привязанных к сессии фоновых задач и запускайте их немедленно прямо из заголовка чата.
685
+
686
+ ### Безопасность и защита системы
687
+ - **Строгая валидация путей**: Триггеры пробуждения блокируют доступ к системным директориям (`/etc`, `/proc`, `/sys`, `C:\Windows`).
688
+ - **Защита от SSRF**: Блокировка запросов к link-local адресам облачных метаданных (`169.254.169.254`).
package/README.zh.md CHANGED
@@ -670,3 +670,12 @@ tasks:
670
670
  timeBoxMinutes: 15
671
671
  ```
672
672
  Git 管理的任务具有隔离标识,绝不影响或覆盖 UI 手动创建的任务。
673
+
674
+ ### 会话快捷操作栏(In-Session Quick Action Bar)
675
+ 在 DSH 活跃聊天会话中直接管理定时任务(`conversation.session.header.actions`):
676
+ - **一键转为定时任务(`+ 定时任务`)**:将当前对话或提示词一键转换为预填参数的定时周期任务。
677
+ - **关联任务状态与即时触发**:在会话顶部直接显示关联后台任务的执行状态,并支持一键立即执行。
678
+
679
+ ### 安全性与安全执行
680
+ - **强化路径验证**:事件唤醒触发器严格禁止访问敏感系统路径(`/etc`、`/proc`、`/sys`、`C:\Windows`)。
681
+ - **SSRF 防护**:自动拦截对云平台元数据地址(`169.254.169.254`)的请求。
@@ -21,6 +21,7 @@ window.__ModuleLoader__.load({
21
21
  // Set by the sidebar job list (#34) so the panel can highlight the task the
22
22
  // user clicked; cleared once the panel has scrolled to it.
23
23
  let pendingTaskHighlight = null;
24
+ let pendingTaskPreset = null;
24
25
  const VIEW_ATTR = 'data-dsh-cron-view';
25
26
  const COLUMN_SELECTOR = '[data-pane=conversation], [class*=centerCol]';
26
27
  const PANEL_OWNED_SELECTOR = '[' + VIEW_ATTR + '], [data-dsh-plugin="dsh-cron"]';
@@ -2,6 +2,11 @@
2
2
  en: {
3
3
  'sidebar.label': 'Scheduled tasks', 'sidebar.jobsTitle': 'Active jobs',
4
4
  'sidebar.noActiveJobs': 'No active jobs', 'sidebar.moreJobs': 'and {count} more',
5
+ 'sessionBar.addRecurring': '+ Cron',
6
+ 'sessionBar.addRecurringHint': 'Turn this session into a scheduled recurring task',
7
+ 'sessionBar.run': 'Run',
8
+ 'sessionBar.runNow': 'Trigger execution now',
9
+ 'sessionBar.running': 'Running...',
5
10
  'chip.title': 'Scheduled tasks (Cron)', 'panel.back': 'Back to chat',
6
11
  'panel.title': 'Scheduled tasks',
7
12
  'panel.subtitle': 'Ask DSH to plan tasks, set reminders or track updates',
@@ -292,6 +297,11 @@
292
297
  zh: {
293
298
  'sidebar.label': '定时任务', 'sidebar.jobsTitle': '运行中任务',
294
299
  'sidebar.noActiveJobs': '无运行中任务', 'sidebar.moreJobs': '及另外 {count} 个',
300
+ 'sessionBar.addRecurring': '+ 定时任务',
301
+ 'sessionBar.addRecurringHint': '将当前会话转为定时计划任务',
302
+ 'sessionBar.run': '运行',
303
+ 'sessionBar.runNow': '立即执行',
304
+ 'sessionBar.running': '执行中...',
295
305
  'chip.title': '定时任务 (Cron)', 'panel.back': '返回对话',
296
306
  'panel.title': '定时任务', 'panel.subtitle': '让 DSH 规划任务、设置提醒或跟踪状态',
297
307
  'actions.create': '新建', 'actions.createWithDsh': '💬 让 DSH 创建',
@@ -222,6 +222,13 @@
222
222
  setManualModalOpen(true);
223
223
  };
224
224
 
225
+ React.useEffect(() => {
226
+ if (!pendingTaskPreset) return;
227
+ const p = pendingTaskPreset;
228
+ pendingTaskPreset = null;
229
+ openManualModal(p);
230
+ }, [tasks]);
231
+
225
232
  const handleRetryDelivery = async (taskId, runId) => {
226
233
  setRetryingDeliveryId(runId);
227
234
  try {
@@ -0,0 +1,142 @@
1
+
2
+ // --- IN-SESSION QUICK ACTION BAR (v0.3.37) ---
3
+
4
+ function sessionIdOf(ctx, props) {
5
+ try {
6
+ if (props && props.session && props.session.id) return String(props.session.id);
7
+ if (props && props.session && props.session.sessionId) return String(props.session.sessionId);
8
+ if (props && props.input && props.input.sessionId) return String(props.input.sessionId);
9
+ if (ctx && ctx.scope && ctx.scope.session) return String(ctx.scope.session.id || ctx.scope.session.header?.id || '');
10
+ if (ctx && typeof ctx.scope?.id === 'string') return ctx.scope.id;
11
+ if (ctx && ctx.session) return String(ctx.session.id || ctx.session.header?.id || '');
12
+ } catch (_e) {
13
+ void _e;
14
+ }
15
+ return '';
16
+ }
17
+
18
+ function SessionQuickActionBar(props) {
19
+ const { ctx, toggle } = props;
20
+ const barT = props.t || translate;
21
+ const [tasks, setTasks] = React.useState([]);
22
+ const [isRunning, setIsRunning] = React.useState(false);
23
+ const [runSuccess, setRunSuccess] = React.useState(false);
24
+
25
+ const sessionId = sessionIdOf(ctx, props);
26
+
27
+ React.useEffect(() => {
28
+ let unmounted = false;
29
+ const fetchTasks = async () => {
30
+ try {
31
+ const { res, data } = await fetchJsonWithTimeout('/dsh-cron/tasks');
32
+ void res;
33
+ if (!unmounted && data && Array.isArray(data.tasks)) {
34
+ setTasks(data.tasks);
35
+ }
36
+ } catch (_e) {
37
+ void _e;
38
+ }
39
+ };
40
+ fetchTasks();
41
+ const timer = setInterval(fetchTasks, 15000);
42
+ return () => {
43
+ unmounted = true;
44
+ clearInterval(timer);
45
+ };
46
+ }, [sessionId]);
47
+
48
+ const linkedTask = React.useMemo(() => {
49
+ if (!sessionId || !tasks.length) return null;
50
+ return tasks.find((t) => t.lastSessionId === sessionId || t.targetSessionId === sessionId || t.id === sessionId);
51
+ }, [sessionId, tasks]);
52
+
53
+ const handleOpenLinked = (e) => {
54
+ e.preventDefault();
55
+ e.stopPropagation();
56
+ if (linkedTask) {
57
+ pendingTaskHighlight = linkedTask.id;
58
+ }
59
+ toggle.set(true);
60
+ };
61
+
62
+ const handleCreateRecurring = (e) => {
63
+ e.preventDefault();
64
+ e.stopPropagation();
65
+ const sessionObj = props.session || (ctx && ctx.scope && ctx.scope.session);
66
+ const titleVal = (sessionObj && (sessionObj.title || sessionObj.name)) || '';
67
+ pendingTaskPreset = {
68
+ title: titleVal ? titleVal + ' (Cron)' : '',
69
+ targetSessionId: sessionId || '',
70
+ type: 'llm',
71
+ schedule: '0 9 * * 1-5',
72
+ };
73
+ toggle.set(true);
74
+ };
75
+
76
+ const handleQuickRun = async (e) => {
77
+ e.preventDefault();
78
+ e.stopPropagation();
79
+ if (!linkedTask || isRunning) return;
80
+ setIsRunning(true);
81
+ setRunSuccess(false);
82
+ try {
83
+ const { res, data } = await fetchJsonWithTimeout('/dsh-cron/tasks/' + encodeURIComponent(linkedTask.id) + '/run', {
84
+ method: 'POST',
85
+ });
86
+ void res;
87
+ if (data && data.ok) {
88
+ setRunSuccess(true);
89
+ setTimeout(() => setRunSuccess(false), 3000);
90
+ }
91
+ } catch (_err) {
92
+ void _err;
93
+ } finally {
94
+ setIsRunning(false);
95
+ }
96
+ };
97
+
98
+ if (linkedTask) {
99
+ const running = linkedTask.running || isRunning;
100
+ return React.createElement('div', {
101
+ className: 'dsh-cron-session-bar',
102
+ 'data-dsh-plugin': 'dsh-cron',
103
+ }, [
104
+ React.createElement('span', {
105
+ key: 'icon',
106
+ className: 'dsh-cron-session-bar-icon',
107
+ dangerouslySetInnerHTML: { __html: ICON_TIMER }
108
+ }),
109
+ React.createElement('button', {
110
+ key: 'badge',
111
+ type: 'button',
112
+ className: 'dsh-cron-session-badge' + (running ? ' dsh-cron-pulse' : ''),
113
+ title: linkedTask.title || linkedTask.id,
114
+ onClick: handleOpenLinked,
115
+ }, linkedTask.title || linkedTask.id),
116
+ React.createElement('button', {
117
+ key: 'run-btn',
118
+ type: 'button',
119
+ className: 'dsh-cron-session-run-btn',
120
+ disabled: running,
121
+ title: T_KEY(barT, 'sessionBar.runNow'),
122
+ onClick: handleQuickRun,
123
+ }, running ? '...' : (runSuccess ? '✔' : T_KEY(barT, 'sessionBar.run')))
124
+ ]);
125
+ }
126
+
127
+ return React.createElement('button', {
128
+ type: 'button',
129
+ className: 'dsh-cron-session-add-btn',
130
+ 'data-dsh-plugin': 'dsh-cron',
131
+ title: T_KEY(barT, 'sessionBar.addRecurringHint'),
132
+ 'aria-label': T_KEY(barT, 'sessionBar.addRecurring'),
133
+ onClick: handleCreateRecurring,
134
+ }, [
135
+ React.createElement('span', {
136
+ key: 'icon',
137
+ className: 'dsh-cron-session-bar-icon',
138
+ dangerouslySetInnerHTML: { __html: ICON_TIMER },
139
+ }),
140
+ React.createElement('span', { key: 'label' }, T_KEY(barT, 'sessionBar.addRecurring'))
141
+ ]);
142
+ }
@@ -170,6 +170,17 @@
170
170
  const cardSlot = cardOk ? 'settings.plugin.item' : undefined;
171
171
  const chipSlot = chipOk ? 'conversation.session.header.utilities' : undefined;
172
172
 
173
+ const barOk = registerIntoMount(ctx, 'conversation.session.header.actions', {
174
+ name: 'conversation.session.header.actions',
175
+ id: PLUGIN_ID + '.sessionBar',
176
+ order: 28,
177
+ locale: NS,
178
+ inject: (slotProps) => ({ ctx, toggle, ...slotProps }),
179
+ }, function QuickBarBoundary(props) {
180
+ return React.createElement(ErrorBoundary, null, React.createElement(SessionQuickActionBar, props));
181
+ });
182
+ const barSlot = barOk ? 'conversation.session.header.actions' : undefined;
183
+
173
184
  function CronChip(props) {
174
185
  const chipT = props.t || translate;
175
186
  return React.createElement('button', {
@@ -192,7 +203,7 @@
192
203
  return () => { for (const dispose of off) dispose(); stopStyleSelfHeal(); };
193
204
  }, 'dsh-cron: client overlay');
194
205
 
195
- exports.slots = { card: cardSlot, chip: chipSlot };
206
+ exports.slots = { card: cardSlot, chip: chipSlot, sessionBar: barSlot };
196
207
  module.exports.panelDismissRule = shouldDismissPanel;
197
208
  module.exports.sidebarJobsSeatIsCurrent = sidebarJobsSeatIsCurrent;
198
209
  }
package/lib/client.js CHANGED
@@ -15,6 +15,7 @@ const ACTIVATE_EVENT = 'dsh-panel-activate';
15
15
  const ACTIVE_ATTR = 'data-dsh-cron-active';
16
16
  const ENTRY_ATTR = 'data-dsh-cron-entry';
17
17
  let pendingTaskHighlight = null;
18
+ let pendingTaskPreset = null;
18
19
  const VIEW_ATTR = 'data-dsh-cron-view';
19
20
  const COLUMN_SELECTOR = '[data-pane=conversation], [class*=centerCol]';
20
21
  const PANEL_OWNED_SELECTOR = '[' + VIEW_ATTR + '], [data-dsh-plugin="dsh-cron"]';
@@ -48,6 +49,11 @@ const STRINGS = {
48
49
  en: {
49
50
  'sidebar.label': 'Scheduled tasks', 'sidebar.jobsTitle': 'Active jobs',
50
51
  'sidebar.noActiveJobs': 'No active jobs', 'sidebar.moreJobs': 'and {count} more',
52
+ 'sessionBar.addRecurring': '+ Cron',
53
+ 'sessionBar.addRecurringHint': 'Turn this session into a scheduled recurring task',
54
+ 'sessionBar.run': 'Run',
55
+ 'sessionBar.runNow': 'Trigger execution now',
56
+ 'sessionBar.running': 'Running...',
51
57
  'chip.title': 'Scheduled tasks (Cron)', 'panel.back': 'Back to chat',
52
58
  'panel.title': 'Scheduled tasks',
53
59
  'panel.subtitle': 'Ask DSH to plan tasks, set reminders or track updates',
@@ -337,6 +343,11 @@ en: {
337
343
  zh: {
338
344
  'sidebar.label': '定时任务', 'sidebar.jobsTitle': '运行中任务',
339
345
  'sidebar.noActiveJobs': '无运行中任务', 'sidebar.moreJobs': '及另外 {count} 个',
346
+ 'sessionBar.addRecurring': '+ 定时任务',
347
+ 'sessionBar.addRecurringHint': '将当前会话转为定时计划任务',
348
+ 'sessionBar.run': '运行',
349
+ 'sessionBar.runNow': '立即执行',
350
+ 'sessionBar.running': '执行中...',
340
351
  'chip.title': '定时任务 (Cron)', 'panel.back': '返回对话',
341
352
  'panel.title': '定时任务', 'panel.subtitle': '让 DSH 规划任务、设置提醒或跟踪状态',
342
353
  'actions.create': '新建', 'actions.createWithDsh': '💬 让 DSH 创建',
@@ -2498,6 +2509,12 @@ workflowName: '',
2498
2509
  });
2499
2510
  setManualModalOpen(true);
2500
2511
  };
2512
+ React.useEffect(() => {
2513
+ if (!pendingTaskPreset) return;
2514
+ const p = pendingTaskPreset;
2515
+ pendingTaskPreset = null;
2516
+ openManualModal(p);
2517
+ }, [tasks]);
2501
2518
  const handleRetryDelivery = async (taskId, runId) => {
2502
2519
  setRetryingDeliveryId(runId);
2503
2520
  try {
@@ -5202,6 +5219,136 @@ return entry;
5202
5219
  }
5203
5220
  const SIDEBAR_JOBS_KEY = 'dsh-cron-sidebar-open';
5204
5221
  const SIDEBAR_JOBS_MAX_ROWS = 5;
5222
+ function sessionIdOf(ctx, props) {
5223
+ try {
5224
+ if (props && props.session && props.session.id) return String(props.session.id);
5225
+ if (props && props.session && props.session.sessionId) return String(props.session.sessionId);
5226
+ if (props && props.input && props.input.sessionId) return String(props.input.sessionId);
5227
+ if (ctx && ctx.scope && ctx.scope.session) return String(ctx.scope.session.id || ctx.scope.session.header?.id || '');
5228
+ if (ctx && typeof ctx.scope?.id === 'string') return ctx.scope.id;
5229
+ if (ctx && ctx.session) return String(ctx.session.id || ctx.session.header?.id || '');
5230
+ } catch (_e) {
5231
+ void _e;
5232
+ }
5233
+ return '';
5234
+ }
5235
+ function SessionQuickActionBar(props) {
5236
+ const { ctx, toggle } = props;
5237
+ const barT = props.t || translate;
5238
+ const [tasks, setTasks] = React.useState([]);
5239
+ const [isRunning, setIsRunning] = React.useState(false);
5240
+ const [runSuccess, setRunSuccess] = React.useState(false);
5241
+ const sessionId = sessionIdOf(ctx, props);
5242
+ React.useEffect(() => {
5243
+ let unmounted = false;
5244
+ const fetchTasks = async () => {
5245
+ try {
5246
+ const { res, data } = await fetchJsonWithTimeout('/dsh-cron/tasks');
5247
+ void res;
5248
+ if (!unmounted && data && Array.isArray(data.tasks)) {
5249
+ setTasks(data.tasks);
5250
+ }
5251
+ } catch (_e) {
5252
+ void _e;
5253
+ }
5254
+ };
5255
+ fetchTasks();
5256
+ const timer = setInterval(fetchTasks, 15000);
5257
+ return () => {
5258
+ unmounted = true;
5259
+ clearInterval(timer);
5260
+ };
5261
+ }, [sessionId]);
5262
+ const linkedTask = React.useMemo(() => {
5263
+ if (!sessionId || !tasks.length) return null;
5264
+ return tasks.find((t) => t.lastSessionId === sessionId || t.targetSessionId === sessionId || t.id === sessionId);
5265
+ }, [sessionId, tasks]);
5266
+ const handleOpenLinked = (e) => {
5267
+ e.preventDefault();
5268
+ e.stopPropagation();
5269
+ if (linkedTask) {
5270
+ pendingTaskHighlight = linkedTask.id;
5271
+ }
5272
+ toggle.set(true);
5273
+ };
5274
+ const handleCreateRecurring = (e) => {
5275
+ e.preventDefault();
5276
+ e.stopPropagation();
5277
+ const sessionObj = props.session || (ctx && ctx.scope && ctx.scope.session);
5278
+ const titleVal = (sessionObj && (sessionObj.title || sessionObj.name)) || '';
5279
+ pendingTaskPreset = {
5280
+ title: titleVal ? titleVal + ' (Cron)' : '',
5281
+ targetSessionId: sessionId || '',
5282
+ type: 'llm',
5283
+ schedule: '0 9 * * 1-5',
5284
+ };
5285
+ toggle.set(true);
5286
+ };
5287
+ const handleQuickRun = async (e) => {
5288
+ e.preventDefault();
5289
+ e.stopPropagation();
5290
+ if (!linkedTask || isRunning) return;
5291
+ setIsRunning(true);
5292
+ setRunSuccess(false);
5293
+ try {
5294
+ const { res, data } = await fetchJsonWithTimeout('/dsh-cron/tasks/' + encodeURIComponent(linkedTask.id) + '/run', {
5295
+ method: 'POST',
5296
+ });
5297
+ void res;
5298
+ if (data && data.ok) {
5299
+ setRunSuccess(true);
5300
+ setTimeout(() => setRunSuccess(false), 3000);
5301
+ }
5302
+ } catch (_err) {
5303
+ void _err;
5304
+ } finally {
5305
+ setIsRunning(false);
5306
+ }
5307
+ };
5308
+ if (linkedTask) {
5309
+ const running = linkedTask.running || isRunning;
5310
+ return _h('div', {
5311
+ className: 'dsh-cron-session-bar',
5312
+ 'data-dsh-plugin': 'dsh-cron',
5313
+ }, [
5314
+ _h('span', {
5315
+ key: 'icon',
5316
+ className: 'dsh-cron-session-bar-icon',
5317
+ dangerouslySetInnerHTML: { __html: ICON_TIMER }
5318
+ }),
5319
+ _h('button', {
5320
+ key: 'badge',
5321
+ type: 'button',
5322
+ className: 'dsh-cron-session-badge' + (running ? ' dsh-cron-pulse' : ''),
5323
+ title: linkedTask.title || linkedTask.id,
5324
+ onClick: handleOpenLinked,
5325
+ }, linkedTask.title || linkedTask.id),
5326
+ _h('button', {
5327
+ key: 'run-btn',
5328
+ type: 'button',
5329
+ className: 'dsh-cron-session-run-btn',
5330
+ disabled: running,
5331
+ title: T_KEY(barT, 'sessionBar.runNow'),
5332
+ onClick: handleQuickRun,
5333
+ }, running ? '...' : (runSuccess ? '✔' : T_KEY(barT, 'sessionBar.run')))
5334
+ ]);
5335
+ }
5336
+ return _h('button', {
5337
+ type: 'button',
5338
+ className: 'dsh-cron-session-add-btn',
5339
+ 'data-dsh-plugin': 'dsh-cron',
5340
+ title: T_KEY(barT, 'sessionBar.addRecurringHint'),
5341
+ 'aria-label': T_KEY(barT, 'sessionBar.addRecurring'),
5342
+ onClick: handleCreateRecurring,
5343
+ }, [
5344
+ _h('span', {
5345
+ key: 'icon',
5346
+ className: 'dsh-cron-session-bar-icon',
5347
+ dangerouslySetInnerHTML: { __html: ICON_TIMER },
5348
+ }),
5349
+ _h('span', { key: 'label' }, T_KEY(barT, 'sessionBar.addRecurring'))
5350
+ ]);
5351
+ }
5205
5352
  function buildSidebarJobRow(state, task) {
5206
5353
  const row = document.createElement('button');
5207
5354
  row.type = 'button';
@@ -5505,6 +5652,16 @@ inject: () => ({ ctx, toggle }),
5505
5652
  }, CronChip);
5506
5653
  const cardSlot = cardOk ? 'settings.plugin.item' : undefined;
5507
5654
  const chipSlot = chipOk ? 'conversation.session.header.utilities' : undefined;
5655
+ const barOk = registerIntoMount(ctx, 'conversation.session.header.actions', {
5656
+ name: 'conversation.session.header.actions',
5657
+ id: PLUGIN_ID + '.sessionBar',
5658
+ order: 28,
5659
+ locale: NS,
5660
+ inject: (slotProps) => ({ ctx, toggle, ...slotProps }),
5661
+ }, function QuickBarBoundary(props) {
5662
+ return _h(ErrorBoundary, null, _h(SessionQuickActionBar, props));
5663
+ });
5664
+ const barSlot = barOk ? 'conversation.session.header.actions' : undefined;
5508
5665
  function CronChip(props) {
5509
5666
  const chipT = props.t || translate;
5510
5667
  return _h('button', {
@@ -5525,7 +5682,7 @@ mountCronScreen(ctx, toggle)
5525
5682
  ];
5526
5683
  return () => { for (const dispose of off) dispose(); stopStyleSelfHeal(); };
5527
5684
  }, 'dsh-cron: client overlay');
5528
- exports.slots = { card: cardSlot, chip: chipSlot };
5685
+ exports.slots = { card: cardSlot, chip: chipSlot, sessionBar: barSlot };
5529
5686
  module.exports.panelDismissRule = shouldDismissPanel;
5530
5687
  module.exports.sidebarJobsSeatIsCurrent = sidebarJobsSeatIsCurrent;
5531
5688
  }
@@ -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
@@ -426,6 +426,11 @@
426
426
  "form.workWindowPolicySkip": "跳过本次执行 (record skipped)",
427
427
  "form.workWindowPolicyDefer": "延迟至窗口开启时执行 (defer)",
428
428
  "form.timeBoxMinutesLabel": "Timebox 运行上限 (分钟, 0 = 不限制)",
429
- "form.typeDigest": "每日/定期简报 (Daily Digest)"
429
+ "form.typeDigest": "每日/定期简报 (Daily Digest)",
430
+ "sessionBar.addRecurring": "+ 定时任务",
431
+ "sessionBar.addRecurringHint": "将当前会话转为定时计划任务",
432
+ "sessionBar.run": "运行",
433
+ "sessionBar.runNow": "立即执行",
434
+ "sessionBar.running": "执行中..."
430
435
  }
431
436
  }
@@ -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 });
@@ -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.36",
3
+ "version": "0.3.38",
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",