@goodandready/dsh-cron 0.3.35 → 0.3.37
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 +17 -0
- package/README.ru.md +17 -0
- package/README.zh.md +17 -0
- package/lib/client-src/00-open.js +1 -0
- package/lib/client-src/10-locales.js +10 -0
- package/lib/client-src/53-cron-screen-modal-actions.js +7 -0
- package/lib/client-src/75-quick-action-bar.js +142 -0
- package/lib/client-src/90-close.js +12 -1
- package/lib/client.js +158 -1
- package/lib/cron-as-code.js +224 -0
- package/lib/locales.json +6 -1
- package/lib/scheduler/scheduler.js +12 -0
- package/lib/store/task-schema.js +2 -0
- package/lib/store/task-transfer.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -711,3 +711,20 @@ Context is automatically injected into prompts (`{{trigger.type}}`, `{{trigger.f
|
|
|
711
711
|
- **Dedicated Digest Tasks (`type: "digest"`)**: Schedule consolidated summary reports (e.g., daily at 09:00 AM) that aggregate runs, errors, token usage, and cost across all tasks.
|
|
712
712
|
- **REST API**: Inspect digests on-demand via `GET /dsh-cron/digest` or trigger delivery via `POST /dsh-cron/digest/send`.
|
|
713
713
|
- **Channel Routing**: Automatically delivers formatted summaries to Telegram, Feishu, or webhook channels.
|
|
714
|
+
|
|
715
|
+
### Cron-as-Code (`.dsh/cron.yaml`)
|
|
716
|
+
Declare recurring tasks directly in your repository. `dsh-cron` automatically detects and synchronizes `.dsh/cron.yaml`, `.dsh/cron.yml`, or `.dsh/cron.json`:
|
|
717
|
+
```yaml
|
|
718
|
+
tasks:
|
|
719
|
+
- id: nightly-audit
|
|
720
|
+
title: Nightly Security Audit
|
|
721
|
+
schedule: "0 2 * * *"
|
|
722
|
+
command: npm audit
|
|
723
|
+
timeBoxMinutes: 15
|
|
724
|
+
```
|
|
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.
|
package/README.ru.md
CHANGED
|
@@ -665,3 +665,20 @@ MIT © [GooDAnDReaDY](https://github.com/GooDAnDReaDY)
|
|
|
665
665
|
- **Тип задачи `type: "digest"`**: Настройка периодических отчетов (например, каждое утро в 09:00), агрегирующих количество запусков, сбои, токены и затраты в USD.
|
|
666
666
|
- **REST API**: Эндпоинты `GET /dsh-cron/digest` для просмотра статистики и `POST /dsh-cron/digest/send` для отправки в каналы.
|
|
667
667
|
- **Интеграция с каналами**: Доставка форматированного отчета в Telegram, Feishu или вебхуки.
|
|
668
|
+
|
|
669
|
+
### Cron-as-Code (`.dsh/cron.yaml`)
|
|
670
|
+
Декларируйте расписания задач прямо в репозитории проекта. `dsh-cron` автоматически обнаруживает и синхронизирует конфигурацию из `.dsh/cron.yaml`, `.dsh/cron.yml` или `.dsh/cron.json`:
|
|
671
|
+
```yaml
|
|
672
|
+
tasks:
|
|
673
|
+
- id: nightly-audit
|
|
674
|
+
title: Ночной аудит безопасности
|
|
675
|
+
schedule: "0 2 * * *"
|
|
676
|
+
command: npm audit
|
|
677
|
+
timeBoxMinutes: 15
|
|
678
|
+
```
|
|
679
|
+
Задачи из репозитория изолированы и не перезаписывают ручные задачи, созданные в UI.
|
|
680
|
+
|
|
681
|
+
### Контекстная панель в сессиях чата (Quick Action Bar)
|
|
682
|
+
Управляйте регламентными задачами прямо из активного диалога DSH (`conversation.session.header.actions`):
|
|
683
|
+
- **Превращение сессии в регламентную задачу (`+ В крон`)**: сохраняйте текущий диалог или промпт как регулярную задачу с предзаполненными параметрами в один клик.
|
|
684
|
+
- **Индикация статуса и быстрый запуск**: отслеживайте статус выполнения привязанных к сессии фоновых задач и запускайте их немедленно прямо из заголовка чата.
|
package/README.zh.md
CHANGED
|
@@ -658,3 +658,20 @@ MIT © [GooDAnDReaDY](https://github.com/GooDAnDReaDY)
|
|
|
658
658
|
|
|
659
659
|
- **简报专用任务类型 (`type: "digest"`)**: 可定时调度汇总报告(如每日早晨 09:00),聚合所有任务的运行状态、失败诊断、Token 消耗与估算成本。
|
|
660
660
|
- **REST API**: 支持 `GET /dsh-cron/digest` 查询统计报告,以及 `POST /dsh-cron/digest/send` 主动推送到各通知渠道。
|
|
661
|
+
|
|
662
|
+
### 代码化 Cron(`.dsh/cron.yaml`)
|
|
663
|
+
直接在项目仓库中声明定时任务。`dsh-cron` 自动发现并同步 `.dsh/cron.yaml`、`.dsh/cron.yml` 或 `.dsh/cron.json`:
|
|
664
|
+
```yaml
|
|
665
|
+
tasks:
|
|
666
|
+
- id: nightly-audit
|
|
667
|
+
title: 每夜安全检查
|
|
668
|
+
schedule: "0 2 * * *"
|
|
669
|
+
command: npm audit
|
|
670
|
+
timeBoxMinutes: 15
|
|
671
|
+
```
|
|
672
|
+
Git 管理的任务具有隔离标识,绝不影响或覆盖 UI 手动创建的任务。
|
|
673
|
+
|
|
674
|
+
### 会话快捷操作栏(In-Session Quick Action Bar)
|
|
675
|
+
在 DSH 活跃聊天会话中直接管理定时任务(`conversation.session.header.actions`):
|
|
676
|
+
- **一键转为定时任务(`+ 定时任务`)**:将当前对话或提示词一键转换为预填参数的定时周期任务。
|
|
677
|
+
- **关联任务状态与即时触发**:在会话顶部直接显示关联后台任务的执行状态,并支持一键立即执行。
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { logger } from './logger.js';
|
|
4
|
+
import { bestEffort } from './best-effort.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Lightweight, robust parser for .dsh/cron.yaml, .dsh/cron.yml, and .dsh/cron.json files (#416).
|
|
8
|
+
* Handles JSON and standard task list YAML without external dependencies.
|
|
9
|
+
*/
|
|
10
|
+
export function parseCronAsCode(rawContent) {
|
|
11
|
+
if (!rawContent || typeof rawContent !== 'string') return { tasks: [] };
|
|
12
|
+
const trimmed = rawContent.trim();
|
|
13
|
+
if (!trimmed) return { tasks: [] };
|
|
14
|
+
|
|
15
|
+
// 1. Try standard JSON first
|
|
16
|
+
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(trimmed);
|
|
19
|
+
if (Array.isArray(parsed)) return { tasks: parsed };
|
|
20
|
+
if (parsed && Array.isArray(parsed.tasks)) return parsed;
|
|
21
|
+
return { tasks: [] };
|
|
22
|
+
} catch (_err) {
|
|
23
|
+
void _err;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 2. Simple, resilient YAML parser for task documents
|
|
28
|
+
const lines = trimmed.split(/\r?\n/);
|
|
29
|
+
const tasks = [];
|
|
30
|
+
let currentTask = null;
|
|
31
|
+
let inTasksSection = false;
|
|
32
|
+
|
|
33
|
+
for (const rawLine of lines) {
|
|
34
|
+
const line = rawLine.replace(/#.*$/, '').trimEnd();
|
|
35
|
+
if (!line.trim()) continue;
|
|
36
|
+
|
|
37
|
+
if (line.match(/^tasks\s*:/i)) {
|
|
38
|
+
inTasksSection = true;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const itemMatch = line.match(/^(\s*)-\s+(.*)$/);
|
|
43
|
+
if (itemMatch) {
|
|
44
|
+
if (currentTask) tasks.push(currentTask);
|
|
45
|
+
currentTask = {};
|
|
46
|
+
const rest = itemMatch[2].trim();
|
|
47
|
+
if (rest) {
|
|
48
|
+
const kv = parseYamlKeyValue(rest);
|
|
49
|
+
if (kv) currentTask[kv.key] = kv.value;
|
|
50
|
+
}
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (currentTask) {
|
|
55
|
+
const kv = parseYamlKeyValue(line.trim());
|
|
56
|
+
if (kv) {
|
|
57
|
+
currentTask[kv.key] = kv.value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (currentTask) tasks.push(currentTask);
|
|
63
|
+
return { tasks };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function parseYamlKeyValue(line) {
|
|
67
|
+
const match = line.match(/^([a-zA-Z0-9_-]+)\s*:\s*(.*)$/);
|
|
68
|
+
if (!match) return null;
|
|
69
|
+
const key = match[1].trim();
|
|
70
|
+
let valStr = match[2].trim();
|
|
71
|
+
|
|
72
|
+
// Strip wrapping quotes
|
|
73
|
+
if ((valStr.startsWith('"') && valStr.endsWith('"')) || (valStr.startsWith("'") && valStr.endsWith("'"))) {
|
|
74
|
+
valStr = valStr.slice(1, -1);
|
|
75
|
+
return { key, value: valStr };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (valStr.toLowerCase() === 'true') return { key, value: true };
|
|
79
|
+
if (valStr.toLowerCase() === 'false') return { key, value: false };
|
|
80
|
+
if (/^-?\d+$/.test(valStr)) return { key, value: parseInt(valStr, 10) };
|
|
81
|
+
if (/^-?\d+\.\d+$/.test(valStr)) return { key, value: parseFloat(valStr) };
|
|
82
|
+
|
|
83
|
+
return { key, value: valStr };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Reconciles tasks declared in a workspace with the store (#416).
|
|
88
|
+
*/
|
|
89
|
+
export function reconcileWorkspaceCronTasks(store, workspaceId, declaredTasks = []) {
|
|
90
|
+
if (!store || !workspaceId) return { created: 0, updated: 0, deleted: 0 };
|
|
91
|
+
|
|
92
|
+
const currentTasks = store.list ? store.list() : (store.tasks ? Object.values(store.tasks) : []);
|
|
93
|
+
const existingManaged = new Map();
|
|
94
|
+
|
|
95
|
+
for (const t of currentTasks) {
|
|
96
|
+
if (t && t.workspaceId === workspaceId && t.managedBy === 'cron_as_code') {
|
|
97
|
+
existingManaged.set(t.id, t);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let created = 0;
|
|
102
|
+
let updated = 0;
|
|
103
|
+
let deleted = 0;
|
|
104
|
+
const seenIds = new Set();
|
|
105
|
+
|
|
106
|
+
for (const decl of declaredTasks) {
|
|
107
|
+
if (!decl || typeof decl !== 'object') continue;
|
|
108
|
+
const rawId = decl.id || decl.name || Math.random().toString(36).slice(2, 9);
|
|
109
|
+
const taskId = `cac_${workspaceId}_${rawId}`.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
110
|
+
seenIds.add(taskId);
|
|
111
|
+
|
|
112
|
+
const taskRecord = {
|
|
113
|
+
...decl,
|
|
114
|
+
id: taskId,
|
|
115
|
+
title: decl.title || decl.name || rawId,
|
|
116
|
+
schedule: decl.schedule || '0 0 * * *',
|
|
117
|
+
status: decl.status || 'active',
|
|
118
|
+
workspaceId,
|
|
119
|
+
managedBy: 'cron_as_code',
|
|
120
|
+
origin: '.dsh/cron.yaml',
|
|
121
|
+
type: decl.type || 'script',
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
if (existingManaged.has(taskId)) {
|
|
125
|
+
const existing = existingManaged.get(taskId);
|
|
126
|
+
store.set({ ...existing, ...taskRecord });
|
|
127
|
+
updated++;
|
|
128
|
+
} else {
|
|
129
|
+
store.set(taskRecord);
|
|
130
|
+
created++;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Delete tasks removed from declaration
|
|
135
|
+
for (const [id, oldTask] of existingManaged.entries()) {
|
|
136
|
+
if (!seenIds.has(id)) {
|
|
137
|
+
if (typeof store.delete === 'function') {
|
|
138
|
+
store.delete(id);
|
|
139
|
+
} else {
|
|
140
|
+
oldTask.status = 'completed';
|
|
141
|
+
store.set(oldTask);
|
|
142
|
+
}
|
|
143
|
+
deleted++;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return { created, updated, deleted };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* CronAsCodeManager observes workspace directories and auto-synchronizes .dsh/cron.yaml files (#416).
|
|
152
|
+
*/
|
|
153
|
+
export class CronAsCodeManager {
|
|
154
|
+
constructor(scheduler) {
|
|
155
|
+
this.scheduler = scheduler;
|
|
156
|
+
this.watchers = new Map(); // workspaceId -> { watcher, filePath }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
findConfigFile(workspaceDir) {
|
|
160
|
+
if (!workspaceDir || typeof workspaceDir !== 'string') return null;
|
|
161
|
+
const candidates = [
|
|
162
|
+
path.join(workspaceDir, '.dsh', 'cron.yaml'),
|
|
163
|
+
path.join(workspaceDir, '.dsh', 'cron.yml'),
|
|
164
|
+
path.join(workspaceDir, '.dsh', 'cron.json'),
|
|
165
|
+
];
|
|
166
|
+
for (const c of candidates) {
|
|
167
|
+
if (fs.existsSync(c)) return c;
|
|
168
|
+
}
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
syncWorkspace(workspaceId, workspaceDir) {
|
|
173
|
+
if (!workspaceId || !workspaceDir || !this.scheduler) return null;
|
|
174
|
+
const filePath = this.findConfigFile(workspaceDir);
|
|
175
|
+
|
|
176
|
+
if (!filePath) {
|
|
177
|
+
this.unwatchWorkspace(workspaceId);
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
try {
|
|
182
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
183
|
+
const { tasks } = parseCronAsCode(content);
|
|
184
|
+
const res = reconcileWorkspaceCronTasks(this.scheduler.store, workspaceId, tasks);
|
|
185
|
+
logger.info(`[dsh-cron] Cron-as-Code synchronized "${filePath}" for workspace ${workspaceId}: +${res.created} ~${res.updated} -${res.deleted}`);
|
|
186
|
+
|
|
187
|
+
// Arm watcher if not already watching this file
|
|
188
|
+
const current = this.watchers.get(workspaceId);
|
|
189
|
+
if (!current || current.filePath !== filePath) {
|
|
190
|
+
this.unwatchWorkspace(workspaceId);
|
|
191
|
+
try {
|
|
192
|
+
const watcher = fs.watch(filePath, (event) => {
|
|
193
|
+
if (event === 'change') {
|
|
194
|
+
this.syncWorkspace(workspaceId, workspaceDir);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
this.watchers.set(workspaceId, { watcher, filePath });
|
|
198
|
+
} catch (_err) {
|
|
199
|
+
void _err;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return res;
|
|
204
|
+
} catch (err) {
|
|
205
|
+
logger.error(`[dsh-cron] Failed to read Cron-as-Code file "${filePath}": ${err.message}`);
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
unwatchWorkspace(workspaceId) {
|
|
211
|
+
const entry = this.watchers.get(workspaceId);
|
|
212
|
+
if (entry && entry.watcher) {
|
|
213
|
+
bestEffort('cron-as-code-unwatch', () => entry.watcher.close());
|
|
214
|
+
this.watchers.delete(workspaceId);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
stopAll() {
|
|
219
|
+
for (const entry of this.watchers.values()) {
|
|
220
|
+
bestEffort('cron-as-code-stop', () => entry.watcher.close());
|
|
221
|
+
}
|
|
222
|
+
this.watchers.clear();
|
|
223
|
+
}
|
|
224
|
+
}
|
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
|
}
|
|
@@ -5,6 +5,7 @@ import { FileSystemWatcherManager } from '../watcher.js';
|
|
|
5
5
|
import { parseNaturalSchedule } from '../nl-schedule.js';
|
|
6
6
|
import { ScopeLockManager } from '../scope-locks.js';
|
|
7
7
|
import { WakeTriggerManager } from '../wake-triggers.js';
|
|
8
|
+
import { CronAsCodeManager } from '../cron-as-code.js';
|
|
8
9
|
|
|
9
10
|
const MAX_TIMEOUT_MS = 2147483647; // 2^31 - 1 ms (~24.85 days)
|
|
10
11
|
import {
|
|
@@ -342,6 +343,7 @@ export class TaskScheduler {
|
|
|
342
343
|
this.watcherManager = new FileSystemWatcherManager(this);
|
|
343
344
|
this.scopeLocks = new ScopeLockManager();
|
|
344
345
|
this.wakeTriggerManager = new WakeTriggerManager(this);
|
|
346
|
+
this.cronAsCodeManager = new CronAsCodeManager(this);
|
|
345
347
|
this.logger = opts.logger || null;
|
|
346
348
|
this.isStopped = false;
|
|
347
349
|
this.generation = 0;
|
|
@@ -380,6 +382,13 @@ export class TaskScheduler {
|
|
|
380
382
|
this.deferredTimers.set(taskId, timer);
|
|
381
383
|
}
|
|
382
384
|
|
|
385
|
+
syncWorkspaceCronAsCode(workspaceId, workspaceDir) {
|
|
386
|
+
if (this.cronAsCodeManager) {
|
|
387
|
+
return this.cronAsCodeManager.syncWorkspace(workspaceId, workspaceDir);
|
|
388
|
+
}
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
|
|
383
392
|
clearDeferredTimer(taskId) {
|
|
384
393
|
const t = this.deferredTimers.get(taskId);
|
|
385
394
|
if (t) {
|
|
@@ -511,6 +520,9 @@ export class TaskScheduler {
|
|
|
511
520
|
if (this.wakeTriggerManager) {
|
|
512
521
|
this.wakeTriggerManager.stopAll();
|
|
513
522
|
}
|
|
523
|
+
if (this.cronAsCodeManager) {
|
|
524
|
+
this.cronAsCodeManager.stopAll();
|
|
525
|
+
}
|
|
514
526
|
|
|
515
527
|
// Clear concurrency queue (#217)
|
|
516
528
|
this.queue = [];
|
package/lib/store/task-schema.js
CHANGED
|
@@ -102,6 +102,8 @@ export const TaskSchema = z.object({
|
|
|
102
102
|
wakeTrigger: z.any(),
|
|
103
103
|
workWindow: z.any(),
|
|
104
104
|
timeBoxMinutes: z.number().min(0).default(0),
|
|
105
|
+
managedBy: z.string().default(''),
|
|
106
|
+
origin: z.string().default(''),
|
|
105
107
|
maxMemoryMb: z.number().min(0).default(0),
|
|
106
108
|
executionTimeoutMs: z.number().min(0).default(900000),
|
|
107
109
|
maxLogBytesPerRun: z.number().min(0).default(5 * 1024 * 1024),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodandready/dsh-cron",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.37",
|
|
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",
|