loopengine 0.5.5 → 0.5.6

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.
@@ -0,0 +1,559 @@
1
+ // The console's Schedules page (/schedules): every workflow on a timer,
2
+ // across agents, in two views under its top bar.
3
+ //
4
+ // - Schedules: a card for each schedule, in a hairline grid: what it
5
+ // runs, how often, its agent, when it runs next, and a switch to pause
6
+ // or resume it (POST /schedules/:id/pause|resume), with Run now and
7
+ // its workflow in a menu. Then the workflows with no schedule yet, to
8
+ // add one to.
9
+ // - Calendar: a week, day by day: the runs that happened (from each
10
+ // schedule's history, by outcome) and those to come (worked out from
11
+ // each schedule's rule and its next run).
12
+ //
13
+ // + Add schedule opens Create schedule: which workflow, its name, how
14
+ // often (an interval, daily at a time, weekly on a day, or once), whether
15
+ // each result goes to the messaging app, and the workflow's inputs for
16
+ // every run. A schedule is part of its workflow, so it's added to that
17
+ // workflow's draft (POST .../draft/schedules); when that's all the draft
18
+ // holds, it can be published right there.
19
+ //
20
+ // Its data is each agent's /agents/:name/schedules. Like the other
21
+ // console pages, its inline script avoids backslashes and template
22
+ // placeholders, since it lives inside a template literal.
23
+ import { devUiCss } from './dev-ui-styles.js';
24
+ import { consoleShellScript, consoleSidebarHtml } from './console-shell.js';
25
+ import { MASCOT_CSS, mascotSvg } from './mascot.js';
26
+ export const schedulesPageHtml = `<!doctype html>
27
+ <html lang="en">
28
+ <head>
29
+ <meta charset="utf-8">
30
+ <meta name="viewport" content="width=device-width, initial-scale=1">
31
+ <title>Schedules</title>
32
+ <style>${devUiCss}${MASCOT_CSS}
33
+ .sc { max-width: 1120px; display: grid; gap: 0; }
34
+ .sc-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 36px 32px 28px; border: 1px solid var(--line); border-bottom: 0; }
35
+ .sc-hero .le-mascot { flex: none; margin-bottom: -6px; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .12)); }
36
+ .sc-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
37
+ .sc-card { display: grid; gap: 14px; padding: 20px 22px; background: var(--bg); }
38
+ .sc-card.is-off .sc-card-text { opacity: .55; }
39
+ .sc-card-head { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto; gap: 12px; align-items: start; }
40
+ .sc-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); color: var(--ink-muted); box-shadow: 0 1px 2px rgba(0, 0, 0, .05); }
41
+ .sc-icon svg { width: 16px; height: 16px; }
42
+ .sc-card-text { display: grid; gap: 2px; min-width: 0; }
43
+ .sc-card-title { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
44
+ .sc-card-desc { font-size: 13px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
45
+ .sc-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
46
+ .sc-chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line); font-size: 12px; color: var(--ink-muted); white-space: nowrap; text-decoration: none; }
47
+ .sc-chip.strong { background: var(--surface); border-color: transparent; color: var(--ink); font-weight: 500; }
48
+ a.sc-chip:hover { color: var(--ink); border-color: var(--ink-faint); }
49
+ .sc-chip.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); font-weight: 600; }
50
+ .sc-chip.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
51
+ .sc-next { font-size: 12px; color: var(--ink-faint); margin-left: 4px; white-space: nowrap; }
52
+ .sc-menu { position: relative; }
53
+ .sc-menu summary { list-style: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; cursor: pointer; color: var(--ink-muted); }
54
+ .sc-menu summary::-webkit-details-marker { display: none; }
55
+ .sc-menu summary:hover { background: var(--surface); color: var(--ink); }
56
+ .sc-menu[open] .sc-menu-list { display: grid; }
57
+ .sc-menu-list { display: none; position: absolute; right: 0; top: 32px; z-index: 20; min-width: 170px; padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); box-shadow: 0 8px 24px rgba(0, 0, 0, .12); }
58
+ .sc-menu-list a, .sc-menu-list button { display: block; width: 100%; text-align: left; height: auto; padding: 7px 10px; border: 0; border-radius: 7px; background: none; font-size: 13px; color: var(--ink); text-decoration: none; }
59
+ .sc-menu-list a:hover, .sc-menu-list button:hover:not(:disabled) { background: var(--surface); }
60
+ .sc-section-title { margin: 0; padding: 30px 32px 16px; font-size: 22px; font-weight: 400; letter-spacing: -0.02em; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
61
+ .sc-adds { grid-template-columns: repeat(3, minmax(0, 1fr)); }
62
+ .sc-add { display: grid; gap: 6px; align-content: start; padding: 22px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0; background: var(--bg); text-align: left; height: auto; cursor: pointer; transition: background .15s; }
63
+ .sc-add:hover:not(:disabled) { background: var(--surface); }
64
+ .sc-add b { font-size: 15px; font-weight: 600; color: var(--ink); }
65
+ .sc-add span { font-size: 13px; color: var(--ink-muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
66
+ .sc-add small { font-size: 12px; color: var(--ink-faint); }
67
+ .sc-empty { padding: 40px 32px; text-align: center; color: var(--ink-muted); font-size: 14px; background: var(--bg); grid-column: 1 / -1; }
68
+ /* Calendar: a week, a column a day. */
69
+ .sc-week-bar { display: flex; align-items: center; gap: 10px; padding: 18px 32px; border: 1px solid var(--line); border-bottom: 0; }
70
+ .sc-week-bar h2 { margin: 0 auto 0 0; font-size: 22px; font-weight: 400; letter-spacing: -0.02em; }
71
+ .sc-week-bar button { height: 32px; padding: 0 12px; border-radius: 9px; font-size: 13px; }
72
+ .sc-week { grid-template-columns: repeat(7, minmax(0, 1fr)); }
73
+ .sc-day { display: grid; align-content: start; gap: 6px; min-height: 360px; padding: 12px 10px; background: var(--bg); }
74
+ .sc-day.is-today { background: color-mix(in srgb, var(--accent-soft) 45%, var(--bg)); }
75
+ .sc-day-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 4px; font-size: 12px; color: var(--ink-faint); }
76
+ .sc-day-head b { font-size: 18px; font-weight: 500; color: var(--ink); }
77
+ .sc-day.is-today .sc-day-head b { color: var(--accent-ink); }
78
+ .sc-ev { display: grid; gap: 1px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); font-size: 12px; color: var(--ink); text-decoration: none; min-width: 0; }
79
+ .sc-ev b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
80
+ .sc-ev span { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
81
+ .sc-ev.ok { background: var(--good-soft); border-color: transparent; }
82
+ .sc-ev.ok span { color: var(--good); }
83
+ .sc-ev.error { background: var(--bad-soft); border-color: transparent; }
84
+ .sc-ev.error span { color: var(--bad); }
85
+ .sc-ev.next { border-style: dashed; }
86
+ a.sc-ev:hover { border-color: var(--ink-faint); }
87
+ .sc-more { font-size: 11.5px; color: var(--ink-faint); padding: 0 4px; }
88
+ .sc-legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 12px 2px 0; font-size: 12px; color: var(--ink-faint); }
89
+ .sc-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--line); }
90
+ .sc-legend i.ok { background: var(--good-soft); border-color: transparent; }
91
+ .sc-legend i.error { background: var(--bad-soft); border-color: transparent; }
92
+ .sc-legend i.next { border-style: dashed; }
93
+ /* Create schedule */
94
+ .sc-dialog { width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--bg); color: var(--ink); box-shadow: 0 24px 60px rgba(0, 0, 0, .22); overflow: hidden; }
95
+ .sc-dialog::backdrop { background: rgba(20, 24, 25, .35); backdrop-filter: blur(3px); }
96
+ .sc-dialog form { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: calc(100vh - 50px); }
97
+ .sc-dlg-head { display: flex; align-items: center; gap: 8px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
98
+ .sc-dlg-head h2 { margin: 0 auto 0 0; font-size: 18px; font-weight: 500; }
99
+ .sc-dlg-head button { height: 34px; padding: 0 14px; border-radius: 9px; font-size: 13px; }
100
+ .sc-dlg-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); overflow: auto; }
101
+ .sc-dlg-col { display: grid; align-content: start; }
102
+ .sc-dlg-col + .sc-dlg-col { border-left: 1px solid var(--line); background: var(--surface); }
103
+ .sc-field { display: grid; gap: 9px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
104
+ .sc-field > label, .sc-field-k { font-size: 14px; font-weight: 500; }
105
+ .sc-field .hint { margin: 0; }
106
+ .sc-field input, .sc-field select { height: 38px; border-radius: 9px; font-size: 13.5px; width: 100%; }
107
+ .sc-field .le-seg { display: flex; }
108
+ .sc-field .le-seg button { flex: 1; justify-content: center; }
109
+ .sc-row { display: flex; gap: 8px; }
110
+ .sc-row > * { flex: 1; min-width: 0; }
111
+ .sc-row[hidden], .sc-field .le-seg[hidden] { display: none; }
112
+ .sc-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
113
+ .sc-inputs { display: grid; gap: 12px; }
114
+ .sc-inputs label { display: grid; gap: 5px; font-size: 13px; font-weight: 500; }
115
+ .sc-inputs textarea { min-height: 70px; border-radius: 9px; font-size: 13.5px; }
116
+ .sc-dlg-foot { padding: 12px 22px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-muted); min-height: 46px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
117
+ .sc-dlg-foot:empty { display: none; }
118
+ .sc-dlg-foot .error { color: var(--bad); }
119
+ .hint { font-size: 12.5px; color: var(--ink-muted); }
120
+ .error { font-size: 13px; color: var(--bad); margin: 0; }
121
+ @media (max-width: 860px) {
122
+ .sc-hero { padding: 24px 18px 20px; }
123
+ .sc-cards, .sc-adds { grid-template-columns: minmax(0, 1fr); }
124
+ .sc-week { grid-template-columns: minmax(0, 1fr); }
125
+ .sc-day { min-height: 0; }
126
+ .sc-dlg-body { grid-template-columns: minmax(0, 1fr); }
127
+ .sc-dlg-col + .sc-dlg-col { border-left: 0; border-top: 1px solid var(--line); }
128
+ .le-search { display: none; }
129
+ }
130
+ </style>
131
+ </head>
132
+ <body data-le-page="schedules">
133
+ <div class="le-app">
134
+ ${consoleSidebarHtml}
135
+ <main class="le-main">
136
+ <header class="le-topbar">
137
+ <button type="button" class="le-menu-btn" data-le-menu aria-label="Open navigation">&#9776;</button>
138
+ <h1 class="le-topbar-title">Schedules</h1>
139
+ <span class="le-seg" role="tablist" aria-label="View">
140
+ <button type="button" role="tab" data-view="list" aria-selected="true">Schedules</button>
141
+ <button type="button" role="tab" data-view="calendar" aria-selected="false">Calendar</button>
142
+ </span>
143
+ <span class="le-topbar-gap"></span>
144
+ <label class="le-search"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="11" cy="11" r="7"/><path d="M20 20l-3.5-3.5"/></svg><input type="search" id="scSearch" placeholder="Search schedules" aria-label="Search schedules"></label>
145
+ <button type="button" class="le-btn-dark" id="scAdd">+ Add schedule</button>
146
+ </header>
147
+ <div class="le-scroll"><div class="le-page">
148
+ <div class="sc" id="scPage"><p class="hint">Loading&hellip;</p></div>
149
+ </div></div>
150
+ </main>
151
+ </div>
152
+ <template id="scMascot">${mascotSvg(92)}</template>
153
+ <dialog class="sc-dialog" id="scDialog" aria-labelledby="scDlgTitle">
154
+ <form method="dialog" id="scForm">
155
+ <div class="sc-dlg-head"><h2 id="scDlgTitle">Create schedule</h2><button type="button" id="scCancel">Cancel</button><button type="submit" class="primary" id="scSave">Save</button></div>
156
+ <div class="sc-dlg-body">
157
+ <div class="sc-dlg-col">
158
+ <div class="sc-field"><label for="scWorkflow">Workflow</label><select id="scWorkflow" required></select></div>
159
+ <div class="sc-field"><label for="scName">Name <span class="hint">(optional)</span></label><input id="scName" maxlength="80" placeholder="e.g. Monday sales summary"></div>
160
+ <div class="sc-field">
161
+ <span class="sc-field-k">Schedule</span>
162
+ <span class="le-seg" id="scKind"><button type="button" data-kind="repeat" aria-pressed="true">Recurring</button><button type="button" data-kind="once" aria-pressed="false">One time</button></span>
163
+ <span class="le-seg" id="scFreq"><button type="button" data-freq="interval" aria-pressed="false">Interval</button><button type="button" data-freq="daily" aria-pressed="true">Daily</button><button type="button" data-freq="weekly" aria-pressed="false">Weekly</button></span>
164
+ <div class="sc-row" id="scWhenInterval" hidden><input type="number" id="scEvery" min="1" step="1" value="1" aria-label="Every"><select id="scUnit" aria-label="Unit"><option value="m">minutes</option><option value="h" selected>hours</option><option value="d">days</option></select></div>
165
+ <div class="sc-row" id="scWhenDaily"><input type="time" id="scAt" value="09:00" aria-label="At"></div>
166
+ <div class="sc-row" id="scWhenWeekly" hidden><select id="scWeekday" aria-label="On"><option value="monday">Monday</option><option value="tuesday">Tuesday</option><option value="wednesday">Wednesday</option><option value="thursday">Thursday</option><option value="friday">Friday</option><option value="saturday">Saturday</option><option value="sunday">Sunday</option></select><input type="time" id="scAtWeekly" value="09:00" aria-label="At"></div>
167
+ <div class="sc-row" id="scWhenOnce" hidden><input type="date" id="scDate" aria-label="Date"><input type="time" id="scAtOnce" value="09:00" aria-label="At"></div>
168
+ <p class="hint" id="scZone"></p>
169
+ </div>
170
+ <div class="sc-field">
171
+ <div class="sc-switch-row"><span class="sc-field-k">Send each result to chat</span><button type="button" class="le-switch" id="scNotify" role="switch" aria-checked="false" aria-label="Send each result to chat"></button></div>
172
+ <p class="hint">After every run, its result goes to the agent's messaging app (Slack, Telegram or Lark), if it has one.</p>
173
+ </div>
174
+ </div>
175
+ <div class="sc-dlg-col">
176
+ <div class="sc-field"><span class="sc-field-k">Inputs for every run</span><div class="sc-inputs" id="scInputs"></div></div>
177
+ <div class="sc-field"><span class="sc-field-k">Before it starts</span><p class="hint">A schedule is part of its workflow, so it goes into the workflow's draft. Publish the draft and it starts running; until then nothing runs.</p></div>
178
+ </div>
179
+ </div>
180
+ <div class="sc-dlg-foot" id="scFoot"></div>
181
+ </form>
182
+ </dialog>
183
+ ${consoleShellScript}
184
+ <script>
185
+ (function () {
186
+ var esc = window.leShell.esc;
187
+ var page = document.getElementById('scPage');
188
+ var params = new URLSearchParams(location.search);
189
+ var view = params.get('view') === 'calendar' ? 'calendar' : 'list';
190
+ var weekOffset = 0;
191
+ var data = { tasks: [], workflows: [], zone: '' };
192
+ var DAY = 86400000;
193
+ var UNIT_MS = { s: 1000, m: 60000, h: 3600000, d: DAY };
194
+ var WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
195
+ var ICON_REPEAT = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 0 1-15.5 6.2"/><path d="M3 12A9 9 0 0 1 18.5 5.8"/><path d="M18 2v4h-4"/><path d="M6 22v-4h4"/></svg>';
196
+ var ICON_ONCE = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="18" height="16" rx="2"/><path d="M16 3v4"/><path d="M8 3v4"/><path d="M3 11h18"/></svg>';
197
+ var mascot = document.getElementById('scMascot').innerHTML;
198
+ var ICON_DOTS = '<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="5" r="1.7"/><circle cx="12" cy="12" r="1.7"/><circle cx="12" cy="19" r="1.7"/></svg>';
199
+
200
+ function api(method, path, body) {
201
+ return fetch(path, { method: method, headers: body ? { 'content-type': 'application/json', accept: 'application/json' } : { accept: 'application/json' }, body: body ? JSON.stringify(body) : undefined, cache: 'no-store' })
202
+ .then(function (r) { return r.json().then(function (j) { return { ok: r.ok, body: j }; }); });
203
+ }
204
+ function wfHref(agent, id, tab) {
205
+ return '/agents/config?agent=' + encodeURIComponent(agent) + '&tab=workflows&workflow=' + encodeURIComponent(id) + (tab ? '&wtab=' + tab : '');
206
+ }
207
+ // A time of day in the workspace's time zone: 09:00.
208
+ function clock(ms) {
209
+ try { return new Date(ms).toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit', timeZone: data.zone || undefined }); }
210
+ catch (e) { return new Date(ms).toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' }); }
211
+ }
212
+ function weekdayOf(ms) {
213
+ try { return new Date(ms).toLocaleDateString('en-US', { weekday: 'long', timeZone: data.zone || undefined }); }
214
+ catch (e) { return WEEKDAYS[new Date(ms).getDay()]; }
215
+ }
216
+ function everyMs(every) {
217
+ var m = String(every || '').trim().match(/^([0-9]+)([smhd])$/);
218
+ return m ? Number(m[1]) * UNIT_MS[m[2]] : 0;
219
+ }
220
+ // How often, in words: Every 2 hours, Daily at 09:00, Weekly on Monday
221
+ // at 09:00, Once on 3 Dec, 09:00.
222
+ function describe(t) {
223
+ var s = t.schedule || {};
224
+ if (s.run_at) return 'Once, ' + new Date(s.run_at).toLocaleString(undefined, { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', timeZone: data.zone || undefined });
225
+ var m = String(s.every || '').match(/^([0-9]+)([smhd])$/);
226
+ if (!m) return String(s.every || '');
227
+ var n = Number(m[1]);
228
+ var at = t.next_run_at ? Date.parse(t.next_run_at) : (s.anchor ? Date.parse(s.anchor) : 0);
229
+ if (m[2] === 'd' && n === 1 && at) return 'Daily at ' + clock(at);
230
+ if (m[2] === 'd' && n === 7 && at) return 'Weekly on ' + weekdayOf(at) + ' at ' + clock(at);
231
+ if (m[2] === 'd') return 'Every ' + n + ' days' + (at ? ' at ' + clock(at) : '');
232
+ var unit = { s: 'second', m: 'minute', h: 'hour' }[m[2]];
233
+ return n === 1 ? 'Every ' + unit : 'Every ' + n + ' ' + unit + 's';
234
+ }
235
+ // In 7h 36m, in 3 days, or now.
236
+ function untilText(iso) {
237
+ var ms = Date.parse(iso) - Date.now();
238
+ if (!(ms > 0)) return 'any moment';
239
+ var min = Math.round(ms / 60000);
240
+ if (min < 60) return 'in ' + min + 'm';
241
+ var h = Math.floor(min / 60);
242
+ if (h < 48) return 'in ' + h + 'h ' + (min % 60) + 'm';
243
+ return 'in ' + Math.round(h / 24) + ' days';
244
+ }
245
+
246
+ function isLive(t) { return t.status !== 'cancelled' && t.status !== 'done'; }
247
+
248
+ // Every agent's schedules, with its workflows.
249
+ function load() {
250
+ return window.leShell.ready.then(function (agents) {
251
+ return Promise.all((agents || []).map(function (a) {
252
+ return api('GET', '/agents/' + encodeURIComponent(a.name) + '/schedules').then(function (r) {
253
+ if (!r.ok) return null;
254
+ var label = a.displayName || a.name;
255
+ return {
256
+ tasks: (r.body.tasks || []).map(function (t) { t.agentLabel = label; return t; }),
257
+ workflows: (r.body.workflows || []).map(function (w) { return { agent: a.name, agentLabel: label, id: w.id, title: w.title, description: w.description, parameters: w.parameters || {} }; }),
258
+ zone: r.body.time_zone || '',
259
+ };
260
+ }).catch(function () { return null; });
261
+ }));
262
+ }).then(function (all) {
263
+ data = { tasks: [], workflows: [], zone: '' };
264
+ all.forEach(function (x) { if (!x) return; data.tasks = data.tasks.concat(x.tasks); data.workflows = data.workflows.concat(x.workflows); data.zone = data.zone || x.zone; });
265
+ render();
266
+ });
267
+ }
268
+
269
+ function cardHtml(t) {
270
+ var on = t.status !== 'paused';
271
+ var wf = t.workflow;
272
+ var title = t.task_name || (wf && wf.title) || String(t.message || '').split(String.fromCharCode(10))[0] || 'Schedule';
273
+ var desc = (wf && (wf.description && wf.description !== wf.title ? wf.description : wf.start_message)) || t.message || '';
274
+ var state = t.status === 'awaiting_approval' || t.pending ? '<a class="sc-chip warn" href="/inbox?view=needs">Waiting for you</a>'
275
+ : t.status === 'running' ? '<span class="sc-chip strong">Running now</span>'
276
+ : t.last_status === 'error' ? '<span class="sc-chip bad" title="' + esc(t.last_error || '') + '">Last run failed</span>' : '';
277
+ var next = !on ? 'Paused' : t.next_run_at ? 'Next run ' + untilText(t.next_run_at) : '';
278
+ return '<div class="sc-card' + (on ? '' : ' is-off') + '" data-task="' + esc(t.task_id) + '">' +
279
+ '<div class="sc-card-head"><span class="sc-icon">' + (t.schedule && t.schedule.run_at ? ICON_ONCE : ICON_REPEAT) + '</span>' +
280
+ '<span class="sc-card-text"><span class="sc-card-title">' + esc(title) + '</span>' + (desc ? '<span class="sc-card-desc">' + esc(desc) + '</span>' : '') + '</span>' +
281
+ '<button type="button" class="le-switch" role="switch" aria-checked="' + on + '" aria-label="' + (on ? 'Pause ' : 'Resume ') + esc(title) + '" data-toggle="' + esc(t.task_id) + '"' + (t.status === 'running' ? ' disabled' : '') + '></button>' +
282
+ '<details class="sc-menu"><summary aria-label="More">' + ICON_DOTS + '</summary><div class="sc-menu-list">' +
283
+ '<button type="button" data-run="' + esc(t.task_id) + '">Run now</button>' +
284
+ (t.workflow_id ? '<a href="' + wfHref(t.agent, t.workflow_id, 'activity') + '">Open its workflow</a><a href="' + wfHref(t.agent, t.workflow_id, 'triggers') + '">Change or remove</a>' : '') +
285
+ '</div></details></div>' +
286
+ '<div class="sc-chips"><span class="sc-chip strong">' + esc(describe(t)) + '</span>' +
287
+ '<a class="sc-chip" href="/agents/config?agent=' + encodeURIComponent(t.agent) + '">' + esc(t.agentLabel) + '</a>' +
288
+ (t.notify ? '<span class="sc-chip">Result to chat</span>' : '') + state +
289
+ (next ? '<span class="sc-next">' + esc(next) + '</span>' : '') + '</div>' +
290
+ '</div>';
291
+ }
292
+
293
+ function matches(t, q) {
294
+ if (!q) return true;
295
+ var wf = t.workflow || {};
296
+ return [t.task_name, wf.title, wf.description, t.message, t.agentLabel, describe(t)].join(' ').toLowerCase().indexOf(q) !== -1;
297
+ }
298
+
299
+ function listHtml() {
300
+ var q = (document.getElementById('scSearch').value || '').trim().toLowerCase();
301
+ var live = data.tasks.filter(isLive).filter(function (t) { return matches(t, q); })
302
+ .sort(function (a, b) { return (a.status === 'paused') - (b.status === 'paused') || String(a.next_run_at || '').localeCompare(String(b.next_run_at || '')); });
303
+ var scheduled = {};
304
+ data.tasks.filter(isLive).forEach(function (t) { if (t.workflow_id) scheduled[t.agent + '/' + t.workflow_id] = true; });
305
+ var free = data.workflows.filter(function (w) { return !scheduled[w.agent + '/' + w.id]; });
306
+ var count = data.tasks.filter(isLive).length;
307
+ var paused = data.tasks.filter(function (t) { return t.status === 'paused'; }).length;
308
+ return '<div class="sc-hero"><div><h2 class="le-display">Scheduled runs</h2><p class="le-display-sub">' +
309
+ (count ? count + (count === 1 ? ' schedule' : ' schedules') + (paused ? ', ' + paused + ' paused' : '') + '. Switch one off to pause it.' : 'Put a workflow on a timer, and your agents run it for you.') + '</p></div>' +
310
+ mascot + '</div>' +
311
+ '<div class="le-grid sc-cards">' + (live.length ? live.map(cardHtml).join('') + (live.length % 2 ? '<div class="sc-card" aria-hidden="true"></div>' : '')
312
+ : '<p class="sc-empty">' + (q ? 'No schedule matches.' : 'No schedules yet. Add one to run a workflow every day, every week, or once.') + '</p>') + '</div>' +
313
+ (free.length ? '<h3 class="sc-section-title">Put a workflow on a timer</h3><div class="le-grid sc-adds">' +
314
+ free.slice(0, 9).map(function (w) {
315
+ return '<button type="button" class="sc-add" data-add="' + esc(w.agent + '/' + w.id) + '"><b>' + esc(w.title) + '</b>' + (w.description && w.description !== w.title ? '<span>' + esc(w.description) + '</span>' : '') + '<small>' + esc(w.agentLabel) + '</small></button>';
316
+ }).join('') + (free.length % 3 ? new Array(3 - (free.length % 3) + 1).join('<div class="sc-add" aria-hidden="true" style="cursor:default"></div>') : '') + '</div>' : '');
317
+ }
318
+
319
+ // The week shown: Monday to Sunday, weekOffset weeks from this one.
320
+ function weekStart() {
321
+ var d = new Date(); d.setHours(0, 0, 0, 0);
322
+ var back = (d.getDay() + 6) % 7;
323
+ return d.getTime() - back * DAY + weekOffset * 7 * DAY;
324
+ }
325
+ // Each schedule's runs in the week: those that happened (its history),
326
+ // and those to come (its next run, then every interval after).
327
+ function weekEvents(from, to) {
328
+ var out = [];
329
+ data.tasks.forEach(function (t) {
330
+ var wf = t.workflow;
331
+ var title = t.task_name || (wf && wf.title) || 'Schedule';
332
+ var href = t.workflow_id ? wfHref(t.agent, t.workflow_id, 'activity') : '/agents/config?agent=' + encodeURIComponent(t.agent) + '&tab=schedules';
333
+ (t.history || []).forEach(function (h) {
334
+ var at = Date.parse(h.ran_at);
335
+ if (at >= from && at < to) out.push({ at: at, title: title, kind: h.status === 'error' ? 'error' : 'ok', href: href, task: t.task_id });
336
+ });
337
+ if (t.status !== 'scheduled' || !t.next_run_at) return;
338
+ var next = Date.parse(t.next_run_at);
339
+ var step = t.schedule && t.schedule.every ? everyMs(t.schedule.every) : 0;
340
+ var n = 0;
341
+ while (next < to && n < 400) {
342
+ if (next >= from && next > Date.now()) out.push({ at: next, title: title, kind: 'next', href: href, task: t.task_id });
343
+ if (!step) break;
344
+ next += step; n++;
345
+ }
346
+ });
347
+ return out.sort(function (a, b) { return a.at - b.at; });
348
+ }
349
+
350
+ function calendarHtml() {
351
+ var from = weekStart(), to = from + 7 * DAY;
352
+ var events = weekEvents(from, to);
353
+ var today = new Date(); today.setHours(0, 0, 0, 0);
354
+ var label = new Date(from).toLocaleDateString(undefined, { month: 'long', day: 'numeric' }) + ' ' + String.fromCharCode(8211) + ' ' + new Date(to - DAY).toLocaleDateString(undefined, { month: 'long', day: 'numeric' });
355
+ var days = [];
356
+ for (var i = 0; i < 7; i++) {
357
+ var dayFrom = from + i * DAY, dayTo = dayFrom + DAY;
358
+ var mine = events.filter(function (e) { return e.at >= dayFrom && e.at < dayTo; });
359
+ var d = new Date(dayFrom);
360
+ days.push('<div class="sc-day' + (dayFrom === today.getTime() ? ' is-today' : '') + '"><div class="sc-day-head"><b>' + d.getDate() + '</b>' + esc(d.toLocaleDateString(undefined, { weekday: 'short' })) + '</div>' +
361
+ mine.slice(0, 8).map(function (e) { return '<a class="sc-ev ' + e.kind + '" href="' + e.href + '" title="' + esc(e.title) + '"><b>' + esc(e.title) + '</b><span>' + esc(clock(e.at)) + (e.kind === 'error' ? ' ' + String.fromCharCode(183) + ' failed' : e.kind === 'ok' ? ' ' + String.fromCharCode(183) + ' done' : '') + '</span></a>'; }).join('') +
362
+ (mine.length > 8 ? '<span class="sc-more">+' + (mine.length - 8) + ' more</span>' : '') + '</div>');
363
+ }
364
+ return '<div class="sc-week-bar"><h2>' + esc(label) + '</h2><button type="button" data-week="-1" aria-label="Previous week">' + String.fromCharCode(8249) + '</button><button type="button" data-week="0">This week</button><button type="button" data-week="1" aria-label="Next week">' + String.fromCharCode(8250) + '</button></div>' +
365
+ '<div class="le-grid sc-week">' + days.join('') + '</div>' +
366
+ '<div class="sc-legend"><span><i class="next"></i>Coming up</span><span><i class="ok"></i>Ran</span><span><i class="error"></i>Failed</span>' + (data.zone ? '<span>Times in ' + esc(data.zone) + '</span>' : '') + '</div>';
367
+ }
368
+
369
+ function render() {
370
+ var tabs = document.querySelectorAll('.le-topbar [data-view]');
371
+ for (var i = 0; i < tabs.length; i++) tabs[i].setAttribute('aria-selected', String(tabs[i].getAttribute('data-view') === view));
372
+ document.querySelector('.le-search').style.visibility = view === 'list' ? '' : 'hidden';
373
+ page.innerHTML = view === 'calendar' ? calendarHtml() : listHtml();
374
+ }
375
+
376
+ document.querySelector('.le-topbar .le-seg').addEventListener('click', function (ev) {
377
+ var b = ev.target.closest('[data-view]');
378
+ if (!b) return;
379
+ view = b.getAttribute('data-view');
380
+ var u = new URL(location.href);
381
+ if (view === 'calendar') u.searchParams.set('view', 'calendar'); else u.searchParams.delete('view');
382
+ history.replaceState(null, '', u);
383
+ render();
384
+ });
385
+ document.getElementById('scSearch').addEventListener('input', function () { if (view === 'list') render(); });
386
+
387
+ page.addEventListener('click', function (ev) {
388
+ var toggle = ev.target.closest('[data-toggle]');
389
+ if (toggle) {
390
+ var on = toggle.getAttribute('aria-checked') === 'true';
391
+ toggle.disabled = true;
392
+ api('POST', '/schedules/' + encodeURIComponent(toggle.getAttribute('data-toggle')) + '/' + (on ? 'pause' : 'resume')).then(function (r) {
393
+ if (!r.ok) { toggle.disabled = false; alertIn(toggle, r.body.error || 'That did not work'); return; }
394
+ load();
395
+ });
396
+ return;
397
+ }
398
+ var run = ev.target.closest('[data-run]');
399
+ if (run) {
400
+ run.disabled = true;
401
+ run.textContent = 'Starting' + String.fromCharCode(8230);
402
+ api('POST', '/schedules/' + encodeURIComponent(run.getAttribute('data-run')) + '/run').then(function (r) {
403
+ run.textContent = r.ok ? 'Started: follow it in the Inbox' : (r.body.error || 'Could not start it');
404
+ setTimeout(load, 1500);
405
+ });
406
+ return;
407
+ }
408
+ var week = ev.target.closest('[data-week]');
409
+ if (week) {
410
+ var w = Number(week.getAttribute('data-week'));
411
+ weekOffset = w === 0 ? 0 : weekOffset + w;
412
+ render();
413
+ return;
414
+ }
415
+ var add = ev.target.closest('[data-add]');
416
+ if (add) openDialog(add.getAttribute('data-add'));
417
+ });
418
+ // Clicking elsewhere closes an open menu.
419
+ document.addEventListener('click', function (ev) {
420
+ var open = document.querySelectorAll('.sc-menu[open]');
421
+ for (var i = 0; i < open.length; i++) if (!open[i].contains(ev.target)) open[i].removeAttribute('open');
422
+ });
423
+ function alertIn(el, text) {
424
+ var card = el.closest('.sc-card');
425
+ if (!card) return;
426
+ var p = card.querySelector('.error') || card.appendChild(document.createElement('p'));
427
+ p.className = 'error';
428
+ p.textContent = text;
429
+ }
430
+
431
+ // ---- Create schedule ----
432
+ var dlg = document.getElementById('scDialog');
433
+ var form = document.getElementById('scForm');
434
+ var foot = document.getElementById('scFoot');
435
+ var kind = 'repeat', freq = 'daily';
436
+ function pressIn(groupId, attr, value) {
437
+ var all = document.querySelectorAll('#' + groupId + ' [' + attr + ']');
438
+ for (var i = 0; i < all.length; i++) all[i].setAttribute('aria-pressed', String(all[i].getAttribute(attr) === value));
439
+ }
440
+ function showWhen() {
441
+ document.getElementById('scFreq').hidden = kind !== 'repeat';
442
+ document.getElementById('scWhenInterval').hidden = !(kind === 'repeat' && freq === 'interval');
443
+ document.getElementById('scWhenDaily').hidden = !(kind === 'repeat' && freq === 'daily');
444
+ document.getElementById('scWhenWeekly').hidden = !(kind === 'repeat' && freq === 'weekly');
445
+ document.getElementById('scWhenOnce').hidden = kind !== 'once';
446
+ }
447
+ document.getElementById('scKind').addEventListener('click', function (ev) {
448
+ var b = ev.target.closest('[data-kind]');
449
+ if (!b) return;
450
+ kind = b.getAttribute('data-kind'); pressIn('scKind', 'data-kind', kind); showWhen();
451
+ });
452
+ document.getElementById('scFreq').addEventListener('click', function (ev) {
453
+ var b = ev.target.closest('[data-freq]');
454
+ if (!b) return;
455
+ freq = b.getAttribute('data-freq'); pressIn('scFreq', 'data-freq', freq); showWhen();
456
+ });
457
+ var notify = document.getElementById('scNotify');
458
+ notify.addEventListener('click', function () { notify.setAttribute('aria-checked', String(notify.getAttribute('aria-checked') !== 'true')); });
459
+ var pick = document.getElementById('scWorkflow');
460
+ function chosen() {
461
+ var v = pick.value.split('/');
462
+ return data.workflows.filter(function (w) { return w.agent === v[0] && w.id === v.slice(1).join('/'); })[0];
463
+ }
464
+ // The chosen workflow's inputs, each a field to fill for every run.
465
+ function fillInputs() {
466
+ var w = chosen();
467
+ var box = document.getElementById('scInputs');
468
+ var names = w ? Object.keys(w.parameters || {}) : [];
469
+ box.innerHTML = !w ? '<p class="hint">Choose a workflow.</p>'
470
+ : !names.length ? '<p class="hint">This workflow takes no inputs: every run is the same.</p>'
471
+ : names.map(function (n) {
472
+ var spec = w.parameters[n] || {};
473
+ return '<label>' + esc(n) + (spec.required ? '' : ' <span class="hint">(optional)</span>') + (spec.description ? '<span class="hint" style="font-weight:400">' + esc(spec.description) + '</span>' : '') +
474
+ '<textarea data-param="' + esc(n) + '" rows="2"' + (spec.required ? ' required' : '') + '>' + esc(spec.default != null ? String(spec.default) : '') + '</textarea></label>';
475
+ }).join('');
476
+ }
477
+ pick.addEventListener('change', fillInputs);
478
+ function openDialog(preset) {
479
+ if (!data.workflows.length) { page.insertAdjacentHTML('afterbegin', '<p class="error" style="margin:0 0 12px">There are no workflows to schedule yet. Build one first, from Home or Workflows.</p>'); return; }
480
+ var groups = {};
481
+ data.workflows.forEach(function (w) { (groups[w.agentLabel] = groups[w.agentLabel] || []).push(w); });
482
+ pick.innerHTML = Object.keys(groups).sort().map(function (g) {
483
+ return '<optgroup label="' + esc(g) + '">' + groups[g].map(function (w) { return '<option value="' + esc(w.agent + '/' + w.id) + '">' + esc(w.title) + '</option>'; }).join('') + '</optgroup>';
484
+ }).join('');
485
+ if (preset) pick.value = preset;
486
+ form.reset();
487
+ if (preset) pick.value = preset;
488
+ kind = 'repeat'; freq = 'daily'; pressIn('scKind', 'data-kind', kind); pressIn('scFreq', 'data-freq', freq); showWhen();
489
+ notify.setAttribute('aria-checked', 'false');
490
+ var t = new Date(Date.now() + DAY);
491
+ document.getElementById('scDate').value = t.getFullYear() + '-' + String(t.getMonth() + 1).padStart(2, '0') + '-' + String(t.getDate()).padStart(2, '0');
492
+ document.getElementById('scZone').textContent = data.zone ? 'Times are in ' + data.zone + ', the workspace' + String.fromCharCode(8217) + 's time zone.' : '';
493
+ foot.innerHTML = '';
494
+ document.getElementById('scSave').disabled = false;
495
+ fillInputs();
496
+ dlg.showModal();
497
+ }
498
+ document.getElementById('scAdd').addEventListener('click', function () { openDialog(''); });
499
+ document.getElementById('scCancel').addEventListener('click', function () { dlg.close(); });
500
+ dlg.addEventListener('click', function (ev) { if (ev.target === dlg) dlg.close(); });
501
+
502
+ function scheduleBody() {
503
+ if (kind === 'once') {
504
+ var date = document.getElementById('scDate').value, at = document.getElementById('scAtOnce').value;
505
+ if (!date || !at) return null;
506
+ return { run_at: date + 'T' + at };
507
+ }
508
+ if (freq === 'interval') {
509
+ var n = Math.max(1, Number(document.getElementById('scEvery').value) || 1);
510
+ return { every: n + document.getElementById('scUnit').value };
511
+ }
512
+ if (freq === 'weekly') return { every: '7d', at: document.getElementById('scAtWeekly').value || '09:00', weekday: document.getElementById('scWeekday').value };
513
+ return { every: '1d', at: document.getElementById('scAt').value || '09:00' };
514
+ }
515
+
516
+ form.addEventListener('submit', function (ev) {
517
+ ev.preventDefault();
518
+ var w = chosen();
519
+ var schedule = scheduleBody();
520
+ if (!w) { foot.innerHTML = '<span class="error">Choose a workflow.</span>'; return; }
521
+ if (!schedule) { foot.innerHTML = '<span class="error">Choose a date and time.</span>'; return; }
522
+ var values = {};
523
+ var fields = document.querySelectorAll('#scInputs [data-param]');
524
+ for (var i = 0; i < fields.length; i++) if (fields[i].value.trim()) values[fields[i].getAttribute('data-param')] = fields[i].value.trim();
525
+ var body = { schedule: schedule };
526
+ if (Object.keys(values).length) body.params = values;
527
+ var name = document.getElementById('scName').value.trim();
528
+ if (name) body.task_name = name;
529
+ if (notify.getAttribute('aria-checked') === 'true') body.notify = true;
530
+ var save = document.getElementById('scSave');
531
+ save.disabled = true;
532
+ foot.textContent = 'Saving' + String.fromCharCode(8230);
533
+ var base = '/agents/' + encodeURIComponent(w.agent) + '/workflows/' + encodeURIComponent(w.id);
534
+ api('POST', base + '/draft/schedules', body).then(function (r) {
535
+ if (!r.ok) { save.disabled = false; foot.innerHTML = '<span class="error">' + esc(r.body.error || 'Could not add it') + '</span>'; return; }
536
+ var only = (r.body.changes || []).length === 1;
537
+ // On its own in the draft, it can go live now; with other changes,
538
+ // they're reviewed together on the workflow's page.
539
+ foot.innerHTML = only
540
+ ? '<span>Added to ' + esc(w.title) + String.fromCharCode(8217) + 's draft. Publish it to start the schedule.</span><span style="flex:1"></span><button type="button" class="le-btn-dark" id="scPublish">Publish now</button>'
541
+ : '<span>Added to ' + esc(w.title) + String.fromCharCode(8217) + 's draft, with its other changes.</span><span style="flex:1"></span><a class="le-btn-dark" href="' + wfHref(w.agent, w.id, 'triggers') + '">Review and publish</a>';
542
+ var pub = document.getElementById('scPublish');
543
+ if (pub) pub.addEventListener('click', function () {
544
+ pub.disabled = true;
545
+ pub.textContent = 'Publishing' + String.fromCharCode(8230);
546
+ api('POST', base + '/publish', { note: 'Added a schedule' + (name ? ': ' + name : '') }).then(function (p) {
547
+ if (!p.ok) { pub.disabled = false; pub.textContent = 'Publish now'; foot.insertAdjacentHTML('beforeend', '<span class="error">' + esc(p.body.error || 'Could not publish') + '</span>'); return; }
548
+ dlg.close();
549
+ load();
550
+ });
551
+ });
552
+ });
553
+ });
554
+
555
+ load().catch(function (err) { page.innerHTML = '<p class="error">Could not load schedules: ' + esc(err.message) + '</p>'; });
556
+ })();
557
+ </script>
558
+ </body>
559
+ </html>`;
@@ -122,9 +122,9 @@ export function addEvalCase(agentDir, workflowId, input) {
122
122
  const reference = (typeof input.reference === 'string' && input.reference.trim() ? input.reference.trim() : (input.run?.feedback?.final?.trim() || input.run?.result?.trim())) ?? '';
123
123
  const params = input.run?.params ?? input.params ?? {};
124
124
  if (!reference && !Object.keys(params).length)
125
- throw new EvidenceError('A case needs its inputs, a good result, or both.');
125
+ throw new EvidenceError('An eval case needs its inputs, a good result, or both.');
126
126
  if (input.run && evals.cases.some((c) => c.fromRun === input.run.run_id))
127
- throw new EvidenceError('That run is already a case.');
127
+ throw new EvidenceError('That run is already an eval case.');
128
128
  const c = { id: randomUUID().slice(0, 8), params, reference: reference.slice(0, 50000), ...(input.run ? { fromRun: input.run.run_id } : {}), createdAt: new Date().toISOString() };
129
129
  writeEvals(agentDir, workflowId, { ...evals, cases: [...evals.cases, c] });
130
130
  return c;
@@ -134,7 +134,7 @@ export function updateEvalCase(agentDir, workflowId, caseId, reference) {
134
134
  if (typeof reference !== 'string')
135
135
  throw new EvidenceError('reference must be text; send "" for none.');
136
136
  if (!evals.cases.some((c) => c.id === caseId))
137
- throw new EvidenceError('No such case.');
137
+ throw new EvidenceError('No such eval case.');
138
138
  writeEvals(agentDir, workflowId, { ...evals, cases: evals.cases.map((c) => (c.id === caseId ? { ...c, reference: reference.trim().slice(0, 50000) } : c)) });
139
139
  }
140
140
  export function removeEvalCase(agentDir, workflowId, caseId) {
@@ -87,12 +87,12 @@ export const workflowPageHtml = `<!doctype html>
87
87
  ${WORKFLOW_SECTIONS_CSS}
88
88
  .wf-skill { white-space: pre-wrap; font-family: var(--font-mono); font-size: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; max-height: 280px; overflow: auto; }
89
89
  .wf-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
90
- .wf-btn { display: inline-block; padding: 7px 14px; border-radius: 6px; text-decoration: none; font-size: 13px; font-weight: 600; background: var(--accent); color: var(--on-accent); border: 0; cursor: pointer; }
90
+ .wf-btn { display: inline-block; padding: 7px 14px; border-radius: 6px; text-decoration: none; font-size: 13px; font-weight: 600; background: var(--primary); color: var(--on-primary); border: 0; cursor: pointer; }
91
91
  .wf-btn.plain { background: none; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
92
92
  .wf-btn:disabled { opacity: 0.6; cursor: progress; }
93
93
  /* The console's own button hover turns any button grey; these keep their
94
94
  colours and just brighten (or, plain ones, get a soft fill). */
95
- .wf-btn:hover:not(:disabled) { background: var(--accent); color: var(--on-accent); filter: brightness(1.08); }
95
+ .wf-btn:hover:not(:disabled) { background: var(--primary); color: var(--on-primary); filter: brightness(1.08); }
96
96
  .wf-btn.plain:hover:not(:disabled) { background: var(--surface); color: var(--ink); filter: none; }
97
97
  .wf-agent { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13.5px; }
98
98
  .wf-agent select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); max-width: 100%; }
@@ -591,7 +591,7 @@ ${consoleShellScript}
591
591
  : '') +
592
592
  paramsSectionHtml(p) +
593
593
  '<h3>What it will use</h3>' +
594
- '<p class="hint" style="margin:0">The tools for each step, and where you decide. The agent works out the order for each case from its instructions, below.</p>' +
594
+ '<p class="hint" style="margin:0">The tools for each step, and where you decide. The agent works out the order for each run from its instructions, below.</p>' +
595
595
  '<div class="le-table-wrap"><table class="wf-steps"><thead><tr><th>Step</th><th>Uses</th><th>Checkpoint</th></tr></thead><tbody>' + p.steps.map(stepRow).join('') + '</tbody></table></div>' +
596
596
  (p.abilities.length ? '<h3>Abilities it uses</h3><ul class="wf-list">' + p.abilities.map(function (a) { return '<li><code>' + esc(a) + '</code></li>'; }).join('') + '</ul>' + (state.canInstall ? '' : '<p class="hint">Installing abilities needs LOOPENGINE_ADMIN_AUTH set; otherwise they head the checklist.</p>') : '') +
597
597
  (p.skills && p.skills.length ? '<h3>Skills it comes with</h3><ul class="wf-list">' + p.skills.map(function (sk) { return '<li><code>' + esc(sk.id) + '</code> <span class="hint">' + esc(sk.description) + '</span></li>'; }).join('') + '</ul><p class="hint" style="margin:0">An agent that already has one keeps its own.</p>' : '') +
@@ -35,7 +35,7 @@ export const workflowsOverviewPageHtml = `<!doctype html>
35
35
  .wo-pill.good { background: var(--good-soft); color: var(--good); }
36
36
  .wo-pill.bad { background: var(--bad-soft); color: var(--bad); }
37
37
  .wo-pill.run { background: var(--accent-soft); color: var(--accent-ink); }
38
- .wo-new { display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 8px; font-size: 13.5px; font-weight: 600; background: var(--accent); color: var(--on-accent); text-decoration: none; white-space: nowrap; }
38
+ .wo-new { display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 8px; font-size: 13.5px; font-weight: 600; background: var(--primary); color: var(--on-primary); text-decoration: none; white-space: nowrap; }
39
39
  .wo-empty { border: 1px dashed var(--line); border-radius: 12px; padding: 28px 24px; display: grid; gap: 14px; }
40
40
  .wo-empty h2 { margin: 0; font-size: 17px; }
41
41
  .wo-ways { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }