loopengine 0.5.7 → 0.5.9

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.
@@ -254,6 +254,42 @@ export const agentsConfigPageHtml = `<!doctype html>
254
254
  .chg-note { color: var(--ink-muted); font-family: inherit; font-weight: 400; }
255
255
  .chg details summary { cursor: pointer; color: var(--accent-ink); font-family: var(--font-sans, inherit); font-size: 12px; margin-top: 2px; }
256
256
  .wf-page-meta-item[hidden] { display: none; }
257
+ .wf-fb { display: grid; gap: 26px; }
258
+ .wf-fb-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
259
+ .wf-fb-stat { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 2px; }
260
+ .wf-fb-stat b { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
261
+ .wf-fb-stat span { font-size: 12.5px; color: var(--ink-muted); }
262
+ .wf-fb-stat.good b { color: var(--good); }
263
+ .wf-fb-stat.bad b { color: var(--bad); }
264
+ .wf-fb-sources { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; color: var(--ink-muted); }
265
+ .wf-fb-src { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 12px; font-weight: 500; }
266
+ .wf-fb-improve { display: grid; gap: 12px; padding: 18px 20px; border-radius: 14px; border: 1px solid var(--line); background: linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 55%, var(--bg)), var(--bg)); }
267
+ .wf-fb-improve h3 { margin: 0; font-size: 17px; font-weight: 600; }
268
+ .wf-fb-improve p { margin: 0; font-size: 13.5px; color: var(--ink-muted); }
269
+ .wf-fb-improve-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
270
+ .wf-fb-sugg { display: grid; gap: 14px; }
271
+ .wf-fb-sugg[hidden] { display: none; }
272
+ .wf-fb-sugg h4 { margin: 0; font-size: 12px; color: var(--ink-faint); font-family: var(--font-mono); font-weight: 500; }
273
+ .wf-fb-changes { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
274
+ .wf-fb-changes li { display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-size: 13.5px; }
275
+ .wf-fb-changes li span { font-size: 12.5px; color: var(--ink-muted); }
276
+ .wf-fb-crits { display: grid; gap: 6px; }
277
+ .wf-fb-crits label { display: flex; gap: 8px; align-items: baseline; font-size: 13.5px; }
278
+ .wf-fb-open { margin: 0; padding-left: 18px; font-size: 13px; color: var(--warn); }
279
+ .wf-fb-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
280
+ .wf-fb-item { display: grid; gap: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 13.5px; }
281
+ .wf-fb-item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
282
+ .wf-fb-item-head .hint { margin-left: auto; }
283
+ .wf-fb-note { margin: 0; overflow-wrap: anywhere; }
284
+ .wf-fb-item details summary { cursor: pointer; font-size: 12.5px; color: var(--ink-muted); }
285
+ .wf-fb-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-top: 6px; }
286
+ .wf-fb-pair pre { margin: 0; max-height: 220px; overflow: auto; font-size: 12.5px; white-space: pre-wrap; }
287
+ .wf-fb-ways { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
288
+ .wf-fb-way { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 4px; align-content: start; font-size: 13px; }
289
+ .wf-fb-way b { font-size: 13.5px; }
290
+ .wf-fb-way span { color: var(--ink-muted); }
291
+ .wf-fb-way pre { margin: 4px 0 0; font-size: 11.5px; }
292
+ @media (max-width: 760px) { .wf-fb-stats, .wf-fb-ways, .wf-fb-pair { grid-template-columns: minmax(0, 1fr); } }
257
293
  .wf-sub-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
258
294
  .wf-act-main[hidden], .wf-trace[hidden] { display: none; }
259
295
  .wf-act-main > .wf-section + .wf-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
@@ -1044,9 +1080,8 @@ ${renderMarkdownScript}
1044
1080
  var inner = '<span class="le-card-label"><span>' + label + '</span>' + (tab ? '<span aria-hidden="true">&rarr;</span>' : '') + '</span>' +
1045
1081
  '<span class="le-card-value">' + value + '</span>' +
1046
1082
  '<span class="le-card-detail">' + detailText + '</span>';
1047
- var adv = ['tools', 'env'].indexOf(tab) !== -1 ? ' data-advanced' : '';
1048
1083
  return tab
1049
- ? '<a class="le-card" data-tab="' + tab + '" href="' + leShell.tabHref(cfg.name, tab) + '"' + adv + '>' + inner + '</a>'
1084
+ ? '<a class="le-card" data-tab="' + tab + '" href="' + leShell.tabHref(cfg.name, tab) + '">' + inner + '</a>'
1050
1085
  : '<div class="le-card">' + inner + '</div>';
1051
1086
  }
1052
1087
  return '<div class="le-cards" style="margin-bottom:28px">' +
@@ -1423,7 +1458,7 @@ ${renderMarkdownScript}
1423
1458
  '<button type="button" class="wf-msg-clear-hook" data-trigger="' + escapeHtml(t.trigger_id) + '">Use these instead</button></p>';
1424
1459
  }).join('') + '</div>'
1425
1460
  : '') +
1426
- '<div class="wf-msg-foot"><span class="hint wf-msg-result" role="status"></span><button type="submit" class="primary">Save to draft</button></div>' +
1461
+ '<div class="wf-msg-foot"><span class="hint wf-msg-result" role="status">Saved straight away: every run from now on follows it.</span><button type="submit" class="primary">Save</button></div>' +
1427
1462
  '</form>';
1428
1463
  }
1429
1464
 
@@ -1433,7 +1468,7 @@ ${renderMarkdownScript}
1433
1468
  var schedules = workflowScheduleItemsHtml(w, name);
1434
1469
  var hasHooks = Boolean(w.webhooks || w.webhooksWaiting || w.webhooksOff);
1435
1470
  var way = function (key, title, what, body) {
1436
- return '<section class="wf-way wf-way-' + key + '"' + (key === 'api' ? ' data-advanced' : '') + '><h4>' + title + '</h4><p class="wf-way-what">' + what + '</p>' + body + '</section>';
1471
+ return '<section class="wf-way wf-way-' + key + '"' + '><h4>' + title + '</h4><p class="wf-way-what">' + what + '</p>' + body + '</section>';
1437
1472
  };
1438
1473
  return '<div class="wf-ways">' +
1439
1474
  way('run', 'Run now', 'Starts a run right away, from here. Follow it in Activity.', workflowRunBarHtml(w, params)) +
@@ -1968,7 +2003,7 @@ ${renderMarkdownScript}
1968
2003
  '<div class="wf-crit-form" hidden>' +
1969
2004
  '<div class="wf-crit-rows">' + (evals.criteria && evals.criteria.length ? evals.criteria : []).map(critRowHtml).join('') + '</div>' +
1970
2005
  '<div class="wf-crit-bar"><button type="button" class="plain wf-crit-add">+ Add a criterion</button><button type="button" class="plain wf-crit-draft">Suggest from its instructions</button>' +
1971
- '<span style="flex:1"></span><button type="button" class="plain wf-crit-cancel">Cancel</button><button type="button" class="wf-crit-save">Save to draft</button></div>' +
2006
+ '<span style="flex:1"></span><button type="button" class="plain wf-crit-cancel">Cancel</button><button type="button" class="wf-crit-save">Save as draft</button><button type="button" class="primary wf-crit-save wf-crit-publish" data-publish-offer hidden>Save and publish</button></div>' +
1972
2007
  '<span class="hint wf-crit-status"></span>' +
1973
2008
  '</div>';
1974
2009
  var latest = {};
@@ -2061,10 +2096,6 @@ ${renderMarkdownScript}
2061
2096
  return parts.length ? '<div class="wf-run-evidence">' + parts.join('') + '</div>' : '';
2062
2097
  }
2063
2098
 
2064
- // A workflow's tabs for Advanced view only: for whoever builds and
2065
- // audits it, not the operator who runs it.
2066
- var WORKFLOW_ADVANCED_TABS = ['evaluation', 'contract', 'versions'];
2067
-
2068
2099
  function renderWorkflowsHtml(name, workflows) {
2069
2100
  if (workflowPageId) {
2070
2101
  var page = workflows.filter(function (x) { return x.id === workflowPageId; });
@@ -2106,7 +2137,7 @@ ${renderMarkdownScript}
2106
2137
  var tab = workflowTabs[w.id] || 'activity';
2107
2138
  var open = openWorkflowId === w.id;
2108
2139
  var panel = function (key, html) { return '<div class="wf-panel" data-panel="' + key + '"' + (tab === key ? '' : ' hidden') + '>' + html + '</div>'; };
2109
- var tabBtn = function (key, label) { return '<button type="button" role="tab" class="wf-tab" data-tab="' + key + '"' + (WORKFLOW_ADVANCED_TABS.indexOf(key) !== -1 ? ' data-advanced' : '') + ' aria-selected="' + (tab === key) + '">' + label + '</button>'; };
2140
+ var tabBtn = function (key, label) { return '<button type="button" role="tab" class="wf-tab" data-tab="' + key + '" aria-selected="' + (tab === key) + '">' + label + '</button>'; };
2110
2141
  if (workflowPageId) {
2111
2142
  var agentLabel = currentCfg && currentCfg.displayName ? currentCfg.displayName : name;
2112
2143
  document.title = w.title + ' ' + String.fromCharCode(183) + ' ' + agentLabel;
@@ -2128,7 +2159,7 @@ ${renderMarkdownScript}
2128
2159
  '</header>' +
2129
2160
  workflowDraftBannerHtml(w) +
2130
2161
  '<div class="wf-row-body wf-page-body">' +
2131
- '<div class="wf-tabs" role="tablist">' + tabBtn('activity', 'Activity') + tabBtn('brief', 'Prompt') + tabBtn('triggers', 'Triggers') + tabBtn('messages', 'Messaging') + tabBtn('evaluation', 'Evaluation') + tabBtn('contract', 'Contract') + tabBtn('versions', 'Versions') + '</div>' +
2162
+ '<div class="wf-tabs" role="tablist">' + tabBtn('activity', 'Activity') + tabBtn('feedback', 'Feedback') + tabBtn('brief', 'Prompt') + tabBtn('triggers', 'Triggers') + tabBtn('messages', 'Messaging') + tabBtn('evaluation', 'Evaluation') + tabBtn('contract', 'Contract') + tabBtn('versions', 'Versions') + '</div>' +
2132
2163
  panel('brief', workflowBriefHtml(w)) +
2133
2164
  panel('activity', workflowActivityHtml(w, runs, name)) +
2134
2165
  panel('evaluation', workflowEvaluationHtml(w)) +
@@ -2136,6 +2167,7 @@ ${renderMarkdownScript}
2136
2167
  panel('messages', workflowMessagesHtml(w, name)) +
2137
2168
  panel('contract', workflowContractHtml(w, name, params)) +
2138
2169
  panel('versions', workflowVersionsHtml()) +
2170
+ panel('feedback', workflowFeedbackHtml()) +
2139
2171
  '<div class="hint workflow-result"></div>' +
2140
2172
  '<div class="wf-row-foot"><span class="hint">ID <code>' + escapeHtml(w.id) + '</code>, used by the API, schedules and webhooks</span><button type="button" class="wf-remove workflow-forget" title="Its schedules and webhooks go; its instructions stay as a skill for Chat">Remove</button></div>' +
2141
2173
  '</div>' +
@@ -2154,9 +2186,10 @@ ${renderMarkdownScript}
2154
2186
  '<div class="wf-row-body"' + (open ? '' : ' hidden') + '>' +
2155
2187
  // What it does, in full, once it's open (the row shows just its name).
2156
2188
  (w.description && w.description !== w.title ? '<p class="wf-desc">' + escapeHtml(w.description) + '</p>' : '') +
2157
- '<div class="wf-tabs" role="tablist">' + tabBtn('activity', 'Activity') + tabBtn('brief', 'Prompt') + tabBtn('triggers', 'Triggers') + tabBtn('messages', 'Messaging') + tabBtn('evaluation', 'Evaluation') + tabBtn('contract', 'Contract') + tabBtn('versions', 'Versions') + '</div>' +
2189
+ '<div class="wf-tabs" role="tablist">' + tabBtn('activity', 'Activity') + tabBtn('feedback', 'Feedback') + tabBtn('brief', 'Prompt') + tabBtn('triggers', 'Triggers') + tabBtn('messages', 'Messaging') + tabBtn('evaluation', 'Evaluation') + tabBtn('contract', 'Contract') + tabBtn('versions', 'Versions') + '</div>' +
2158
2190
  panel('contract', workflowContractHtml(w, name, params)) +
2159
2191
  panel('versions', workflowVersionsHtml()) +
2192
+ panel('feedback', workflowFeedbackHtml()) +
2160
2193
  panel('triggers', workflowTriggersHtml(w, name, params)) +
2161
2194
  panel('messages', workflowMessagesHtml(w, name)) +
2162
2195
  panel('brief', workflowBriefHtml(w)) +
@@ -2373,7 +2406,10 @@ ${renderMarkdownScript}
2373
2406
  '</select><input name="modelName" aria-label="Model name" placeholder="e.g. gpt-6.1-sol" value="' + escapeHtml((w.model && w.model.model) || '') + '"></div></div>' +
2374
2407
  '<p class="hint workflow-editor-check" style="margin:0"></p>' +
2375
2408
  '<div class="hint workflow-editor-result"></div>' +
2376
- '<div class="ed-actions"><span class="hint">Runs keep using the published workflow until you publish.</span><button type="button" class="wp-cancel">Cancel</button><button type="submit" class="primary">Save draft</button></div></form>';
2409
+ // Save and publish shows once the workspace's Publishing setting is
2410
+ // known not to require review (openWorkflowEditor).
2411
+ '<label class="wp-note-field" hidden>Note <span class="hint">(optional: what changed and why, kept with the version when you publish)</span><input name="publishNote" maxlength="500" placeholder="e.g. Ask for the order number before looking it up"></label>' +
2412
+ '<div class="ed-actions"><span class="hint wp-save-hint">Runs keep using the published workflow until you publish.</span><button type="button" class="wp-cancel">Cancel</button><button type="submit" class="primary wp-save-draft">Save as draft</button><button type="submit" class="primary wp-save-publish" hidden>Save and publish</button></div></form>';
2377
2413
  }
2378
2414
 
2379
2415
  // Placeholders the instructions use that no parameter declares, and
@@ -2500,6 +2536,31 @@ ${renderMarkdownScript}
2500
2536
  });
2501
2537
  }
2502
2538
 
2539
+ // Whether this workspace requires review before publishing (Settings,
2540
+ // Publishing): then changes are only saved as drafts, published from
2541
+ // Review and publish; otherwise Save and publish does both in one step.
2542
+ function reviewRequired() {
2543
+ return Promise.resolve(window.leShell && leShell.settings ? leShell.settings() : null).then(function (st) { return Boolean(st && st.requireReview); });
2544
+ }
2545
+ // Shows the one-step publish buttons in root unless review is required.
2546
+ function offerPublish(root) {
2547
+ reviewRequired().then(function (required) {
2548
+ if (required) return;
2549
+ var list = root.querySelectorAll('[data-publish-offer]');
2550
+ for (var i = 0; i < list.length; i++) list[i].hidden = false;
2551
+ });
2552
+ }
2553
+ // Publishes the draft just saved. A draft the same as the published
2554
+ // workflow isn't kept (or is discarded here): there was nothing to publish.
2555
+ function publishSavedDraft(wfBase, note) {
2556
+ return fetchJsonRetryOnce(wfBase + '/publish', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ note: note || '' }) }).then(function (p) {
2557
+ if (!p.ok && p.body.code === 'no_draft') return { ok: true, body: {} };
2558
+ if (!p.ok && p.body.code === 'unchanged') return fetchJsonRetryOnce(wfBase + '/draft', { method: 'DELETE' }).then(function () { return { ok: true, body: {} }; });
2559
+ if (!p.ok) p.body.error = (p.body.error || 'Could not publish') + ' Your changes are saved as a draft.';
2560
+ return p;
2561
+ });
2562
+ }
2563
+
2503
2564
  function openWorkflowEditor(name, card) {
2504
2565
  var published = workflowsById[card.dataset.workflow];
2505
2566
  if (!published) return;
@@ -2556,8 +2617,29 @@ ${renderMarkdownScript}
2556
2617
  // A preview shown goes stale as the instructions change: hide it.
2557
2618
  form.addEventListener('input', function () { previewBox.hidden = true; });
2558
2619
  form.querySelector('.wp-cancel').addEventListener('click', close);
2620
+ // Save and publish, in one step, unless the workspace requires review
2621
+ // before publishing (Settings, Publishing): then a change is saved as a
2622
+ // draft and published from Review and publish.
2623
+ var draftBtn = form.querySelector('.wp-save-draft');
2624
+ var publishBtn = form.querySelector('.wp-save-publish');
2625
+ var publishing = false;
2626
+ draftBtn.addEventListener('click', function () { publishing = false; });
2627
+ publishBtn.addEventListener('click', function () { publishing = true; });
2628
+ reviewRequired().then(function (required) {
2629
+ if (required) {
2630
+ form.querySelector('.wp-save-hint').textContent = 'This workspace requires review: runs keep using the published workflow until the draft is reviewed and published.';
2631
+ return;
2632
+ }
2633
+ publishBtn.hidden = false;
2634
+ draftBtn.classList.remove('primary');
2635
+ form.querySelector('.wp-note-field').hidden = false;
2636
+ form.querySelector('.wp-save-hint').textContent = published.draft
2637
+ ? 'Publishing includes everything in the draft.'
2638
+ : 'Save as draft to publish later; until then runs keep the published version.';
2639
+ });
2559
2640
  form.addEventListener('submit', function (ev) {
2560
2641
  ev.preventDefault();
2642
+ if (ev.submitter) publishing = ev.submitter === publishBtn;
2561
2643
  var parameters = {};
2562
2644
  var problem = '';
2563
2645
  var list = rows.querySelectorAll('.workflow-param-row');
@@ -2572,14 +2654,22 @@ ${renderMarkdownScript}
2572
2654
  try { JSON.parse(form.outputSchema.value); } catch (e) { problem = 'The output schema isn' + String.fromCharCode(8217) + 't valid JSON: ' + e.message; }
2573
2655
  }
2574
2656
  if (problem) { result.textContent = problem; return; }
2575
- result.textContent = 'Saving the draft' + String.fromCharCode(8230);
2576
- fetchJsonRetryOnce('/agents/' + encodeURIComponent(name) + '/workflows/' + encodeURIComponent(w.id) + '/draft', {
2577
- method: 'PUT', headers: { 'content-type': 'application/json' },
2578
- body: JSON.stringify({ title: form.title.value, description: form.description.value, instructions: form.instructions.value, parameters: parameters, output: form.output.value, outputSchema: form.outputSchema.value, model: form.modelProvider.value && form.modelName.value.trim() ? { provider: form.modelProvider.value, model: form.modelName.value.trim() } : null }),
2579
- }).then(function (r) {
2580
- if (!r.ok) { result.textContent = r.body.error || 'Could not save'; return; }
2657
+ var wfBase = '/agents/' + encodeURIComponent(name) + '/workflows/' + encodeURIComponent(w.id);
2658
+ draftBtn.disabled = publishBtn.disabled = true;
2659
+ var done = function (message) {
2660
+ draftBtn.disabled = publishBtn.disabled = false;
2661
+ if (message) { result.textContent = message; return; }
2581
2662
  close();
2582
2663
  loadWorkflowsSection(name);
2664
+ };
2665
+ result.textContent = (publishing ? 'Publishing' : 'Saving the draft') + String.fromCharCode(8230);
2666
+ fetchJsonRetryOnce(wfBase + '/draft', {
2667
+ method: 'PUT', headers: { 'content-type': 'application/json' },
2668
+ body: JSON.stringify({ title: form.title.value, description: form.description.value, instructions: form.instructions.value, parameters: parameters, output: form.output.value, outputSchema: form.outputSchema.value, model: form.modelProvider.value && form.modelName.value.trim() ? { provider: form.modelProvider.value, model: form.modelName.value.trim() } : null, note: form.publishNote.value }),
2669
+ }).then(function (r) {
2670
+ if (!r.ok) return done(r.body.error || 'Could not save');
2671
+ if (!publishing) return done();
2672
+ return publishSavedDraft(wfBase, form.publishNote.value).then(function (p) { done(p.ok ? '' : p.body.error); });
2583
2673
  });
2584
2674
  });
2585
2675
  check();
@@ -2828,6 +2918,7 @@ ${renderMarkdownScript}
2828
2918
  var addBox = card.querySelector('.workflow-hooks-add');
2829
2919
  if (!w || !box) return;
2830
2920
  var base = '/agents/' + encodeURIComponent(name) + '/workflows/' + encodeURIComponent(w.id) + '/triggers';
2921
+ // A webhook made or changed in a draft before webhooks went live at once.
2831
2922
  var draftBase = '/agents/' + encodeURIComponent(name) + '/workflows/' + encodeURIComponent(w.id) + '/draft/webhooks';
2832
2923
  var hooksById = {};
2833
2924
  function render(shownUrl, shownId) {
@@ -2871,10 +2962,10 @@ ${renderMarkdownScript}
2871
2962
  for (var i = 0; i < rows.length; i++) {
2872
2963
  (function (row) {
2873
2964
  var id = row.dataset.trigger;
2874
- // Editing and deleting go in the draft; on/off, the signing secret
2875
- // and a new URL act now.
2965
+ // A webhook is how the workflow starts, not what it does, so every
2966
+ // change to it is live at once (and in Audit), with no draft.
2876
2967
  row.querySelector('.hook-edit').addEventListener('click', function () {
2877
- if (hooksById[id]) openHookFormDialog(w, draftBase, function () { render(null, null); refreshDraft(name, card); }, hooksById[id]);
2968
+ if (hooksById[id]) openHookFormDialog(w, base, function () { render(null, null); }, hooksById[id]);
2878
2969
  });
2879
2970
  var undo = row.querySelector('.hook-undo');
2880
2971
  if (undo) undo.addEventListener('click', function () {
@@ -2907,10 +2998,9 @@ ${renderMarkdownScript}
2907
2998
  row.querySelector('.hook-delete').addEventListener('click', function (ev) {
2908
2999
  var btn = ev.currentTarget;
2909
3000
  if (btn.dataset.confirming !== '1') { btn.dataset.confirming = '1'; btn.textContent = 'Click again to delete'; return; }
2910
- fetchJsonRetryOnce(draftBase + '/' + encodeURIComponent(id), { method: 'DELETE' }).then(function (r) {
3001
+ fetchJsonRetryOnce(base + '/' + encodeURIComponent(id), { method: 'DELETE' }).then(function (r) {
2911
3002
  if (!r.ok) { alert(r.body.error || 'That didn' + String.fromCharCode(8217) + 't work'); return; }
2912
- render(null, null);
2913
- refreshDraft(name, card);
3003
+ loadWorkflowsSection(name);
2914
3004
  });
2915
3005
  });
2916
3006
  })(rows[i]);
@@ -2925,6 +3015,151 @@ ${renderMarkdownScript}
2925
3015
  // View shows it in full, Compare what changed from the version before
2926
3016
  // it, and Restore makes it the workflow's draft, to review and publish
2927
3017
  // as the next version. Filled by loadWorkflowVersions.
3018
+ // The Feedback tab: what people said about this workflow's results,
3019
+ // from the Inbox, a messaging app's links, an email or another platform
3020
+ // (each piece says where), and Self-Improve: changes to its prompt and
3021
+ // new success criteria suggested from that feedback, to review and add
3022
+ // to its draft. Filled by loadWorkflowFeedback.
3023
+ function workflowFeedbackHtml() {
3024
+ return '<div class="wf-fb"><p class="hint" style="margin:0">Loading' + String.fromCharCode(8230) + '</p></div>';
3025
+ }
3026
+
3027
+ var FB_SOURCES = { inbox: 'Inbox', console: 'Console', slack: 'Slack', telegram: 'Telegram', lark: 'Lark', email: 'Email', webhook: 'Your app (callback)', link: 'Link', api: 'API', unknown: 'Earlier' };
3028
+
3029
+ function feedbackItemHtml(i, name) {
3030
+ var verdict = i.verdict === 'good' ? '<span class="le-pill good">Good</span>' : i.verdict === 'bad' ? '<span class="le-pill bad">Needs work</span>' : '';
3031
+ var edit = i.edit === 'heavy' ? '<span class="le-pill warn">Changed a lot</span>' : i.edit === 'light' ? '<span class="le-pill neutral">Changed a little</span>' : i.edit === 'none' ? '<span class="le-pill neutral">Used as is</span>' : '';
3032
+ var when = new Date(i.at).toLocaleString(undefined, { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' });
3033
+ return '<li class="wf-fb-item"><div class="wf-fb-item-head">' + verdict + edit +
3034
+ '<span class="wf-fb-src">' + escapeHtml(FB_SOURCES[i.source || 'unknown'] || i.source) + '</span>' +
3035
+ (i.by ? '<span class="hint" style="margin-left:0">' + escapeHtml(i.by) + '</span>' : '') +
3036
+ '<span class="hint">' + escapeHtml(when) + (i.workflowVersion ? DOT + 'v' + i.workflowVersion : '') + DOT + '<a href="#" class="wf-link wf-fb-trace" data-run="' + escapeHtml(i.runId) + '">trace</a></span></div>' +
3037
+ (i.note ? '<p class="wf-fb-note">' + String.fromCharCode(8220) + escapeHtml(i.note) + String.fromCharCode(8221) + '</p>' : '') +
3038
+ (i.inputs ? '<span class="hint">' + escapeHtml(i.inputs) + '</span>' : '') +
3039
+ '<details><summary>' + (i.final ? 'Its result, and what was used instead' : 'Its result') + '</summary><div class="wf-fb-pair"' + (i.final ? '' : ' style="grid-template-columns:minmax(0,1fr)"') + '>' +
3040
+ '<pre>' + escapeHtml(i.result || '(none)') + '</pre>' + (i.final ? '<pre>' + escapeHtml(i.final) + '</pre>' : '') + '</div></details></li>';
3041
+ }
3042
+
3043
+ function loadWorkflowFeedback(name, card, base) {
3044
+ var box = card.querySelector('.wf-fb');
3045
+ if (!box) return;
3046
+ var id = card.dataset.workflow;
3047
+ fetchJsonRetryOnce(base + '/feedback').then(function (r) {
3048
+ if (!r.ok) { box.innerHTML = '<p class="error">Could not load its feedback: ' + escapeHtml(r.body.error || 'unknown error') + '</p>'; return; }
3049
+ var f = r.body;
3050
+ var w = workflowsById[id] || {};
3051
+ var toChat = (w.delivery && w.delivery.result_to_chat) || (w.schedules || []).some(function (x) { return x.notify && x.status !== 'cancelled'; });
3052
+ var srcs = Object.keys(f.sources || {}).map(function (k) { return '<span class="wf-fb-src">' + escapeHtml(FB_SOURCES[k] || k) + ' ' + f.sources[k] + '</span>'; }).join('');
3053
+ var stat = function (cls, n, label) { return '<div class="wf-fb-stat ' + cls + '"><b>' + n + '</b><span>' + label + '</span></div>'; };
3054
+ box.innerHTML =
3055
+ '<section class="wf-section"><div class="wf-sub-row"><h4 class="wf-sub">What people said</h4><span class="hint">Last ' + f.days + ' days</span></div>' +
3056
+ '<div class="wf-fb-stats">' + stat('', f.total + '<span class="hint" style="font-size:13px;font-weight:400"> of ' + f.runs + '</span>', 'runs got feedback') + stat('good', f.good, 'Good') + stat('bad', f.bad, 'Needs work') + stat('', f.edited, 'Changed before use') + '</div>' +
3057
+ (srcs ? '<div class="wf-fb-sources">From ' + srcs + '</div>' : '') + '</section>' +
3058
+ '<section class="wf-fb-improve"><h3>Improve this workflow</h3>' +
3059
+ '<p>Reads the results people marked <b>needs work</b>, changed, or commented on, and suggests changes to the prompt and new success criteria. Nothing changes until you add them to the draft and publish it.</p>' +
3060
+ '<div class="wf-fb-improve-bar"><button type="button" class="le-btn-dark wf-fb-go"' + (f.actionable ? '' : ' disabled') + '>Suggest improvements</button>' +
3061
+ '<span class="hint">' + (f.actionable ? f.actionable + ' piece' + (f.actionable === 1 ? '' : 's') + ' of feedback to learn from' : 'Nothing to learn from yet: mark a result as needs work, change it, or add a note.') + '</span></div>' +
3062
+ '<div class="wf-fb-sugg" hidden></div></section>' +
3063
+ '<section class="wf-section"><h4 class="wf-sub">Feedback</h4>' +
3064
+ (f.items.length ? '<ul class="wf-fb-list">' + f.items.map(function (i) { return feedbackItemHtml(i, name); }).join('') + '</ul>' : '<p class="hint" style="margin:0">None yet.</p>') + '</section>' +
3065
+ '<section class="wf-section"><h4 class="wf-sub">Where feedback comes from</h4><div class="wf-fb-ways">' +
3066
+ '<div class="wf-fb-way"><b>Inbox</b><span>Under each finished run' + RSQ + 's conversation: Good or Needs work, a note, and the result as it should have been.</span></div>' +
3067
+ '<div class="wf-fb-way"><b>Messaging apps</b><span>' + (toChat ? 'Each result posted to chat ends with Good and Needs work links.' : 'Turn on ' + String.fromCharCode(8220) + 'result to chat' + String.fromCharCode(8221) + ' in Messaging, and each result posted ends with Good and Needs work links.') + '</span></div>' +
3068
+ '<div class="wf-fb-way"><b>Other platforms</b><span>Each finished run' + RSQ + 's callback has a <code>feedback_url</code> to post to.</span>' +
3069
+ '<span>Or with an API key:</span><pre>POST /agents/' + escapeHtml(name) + '/runs/&lt;runId&gt;/feedback' + String.fromCharCode(10) + '{ "verdict": "bad", "note": "...", "final": "...", "source": "api", "by": "jane@acme.com" }</pre></div>' +
3070
+ '</div></section>';
3071
+ var trace = function (ev) {
3072
+ var a = ev.target.closest('.wf-fb-trace');
3073
+ if (!a) return;
3074
+ ev.preventDefault();
3075
+ showWorkflowTab(card, 'activity');
3076
+ openRunTrace(name, card, a.getAttribute('data-run'));
3077
+ };
3078
+ box.addEventListener('click', trace);
3079
+ var go = box.querySelector('.wf-fb-go');
3080
+ if (go) go.addEventListener('click', function () { suggestImprovements(name, card, base, box); });
3081
+ });
3082
+ }
3083
+
3084
+ // Self-Improve: ask for suggestions, show them (each change and why, the
3085
+ // prompt's diff, new criteria to tick, questions only a person can
3086
+ // answer), and add what's chosen to the draft.
3087
+ function suggestImprovements(name, card, base, box) {
3088
+ var go = box.querySelector('.wf-fb-go');
3089
+ var panel = box.querySelector('.wf-fb-sugg');
3090
+ go.disabled = true;
3091
+ go.textContent = 'Reading the feedback' + String.fromCharCode(8230);
3092
+ panel.hidden = false;
3093
+ panel.innerHTML = '<p class="hint" style="margin:0">This takes a minute: the model reads each result and what people said about it.</p>';
3094
+ fetchJsonRetryOnce(base + '/improve', { method: 'POST' }).then(function (r) {
3095
+ go.disabled = false;
3096
+ go.textContent = 'Suggest again';
3097
+ if (!r.ok) { panel.innerHTML = '<p class="error">' + escapeHtml(r.body.error || 'Could not suggest improvements') + '</p>'; return; }
3098
+ var sg = r.body;
3099
+ var changed = sg.instructions !== sg.from.instructions;
3100
+ if (!changed && !sg.criteria.length) {
3101
+ panel.innerHTML = '<p style="margin:0"><span class="le-pill good">No changes needed</span> ' + escapeHtml(sg.summary || 'The feedback doesn' + RSQ + 't call for changes to the prompt.') + '</p>';
3102
+ return;
3103
+ }
3104
+ panel.innerHTML =
3105
+ (sg.summary ? '<p style="margin:0;color:var(--ink)">' + escapeHtml(sg.summary) + '</p>' : '') +
3106
+ (sg.changes.length ? '<h4>// Suggested changes</h4><ul class="wf-fb-changes">' + sg.changes.map(function (c) { return '<li><strong>' + escapeHtml(c.what) + '</strong>' + (c.why ? '<span>' + escapeHtml(c.why) + '</span>' : '') + '</li>'; }).join('') + '</ul>' : '') +
3107
+ (changed ? '<h4>// The prompt, changed' + (sg.from.drafted ? ' (from its draft)' : '') + '</h4>' + versionDiffHtml(sg.from.instructions, sg.instructions) +
3108
+ '<label style="display:flex;gap:8px;align-items:center;font-size:13.5px"><input type="checkbox" class="wf-fb-take-prompt" checked> Add these prompt changes</label>' : '') +
3109
+ (sg.criteria.length ? '<h4>// New success criteria</h4><div class="wf-fb-crits">' + sg.criteria.map(function (c, i) { return '<label><input type="checkbox" data-crit="' + i + '" checked> <span>' + escapeHtml(c.text) + ' <span class="hint">(' + escapeHtml(critKindText(c)) + ')</span></span></label>'; }).join('') + '</div>' : '') +
3110
+ (sg.open.length ? '<h4>// Only you can answer</h4><ul class="wf-fb-open">' + sg.open.map(function (q) { return '<li>' + escapeHtml(q) + '</li>'; }).join('') + '</ul>' : '') +
3111
+ '<div class="wf-fb-improve-bar"><button type="button" class="wf-fb-add">Add to draft</button><button type="button" class="le-btn-dark wf-fb-add wf-fb-add-publish" data-publish-offer hidden>Add and publish</button><span class="hint wf-fb-add-status">Then Evaluate to check it does better.</span></div>' +
3112
+ '<p class="hint" style="margin:0">Suggested by ' + escapeHtml(sg.model) + ' from ' + sg.basedOn + ' piece' + (sg.basedOn === 1 ? '' : 's') + ' of feedback.</p>';
3113
+ offerPublish(panel);
3114
+ var addButtons = panel.querySelectorAll('.wf-fb-add');
3115
+ for (var ab = 0; ab < addButtons.length; ab++) addButtons[ab].addEventListener('click', function (ev) {
3116
+ var btn = ev.currentTarget;
3117
+ var andPublish = btn.classList.contains('wf-fb-add-publish');
3118
+ var status = panel.querySelector('.wf-fb-add-status');
3119
+ var takePrompt = changed && panel.querySelector('.wf-fb-take-prompt') && panel.querySelector('.wf-fb-take-prompt').checked;
3120
+ var picked = sg.criteria.filter(function (c, i) { var b = panel.querySelector('[data-crit="' + i + '"]'); return b && b.checked; });
3121
+ if (!takePrompt && !picked.length) { status.textContent = 'Tick at least one change to add.'; return; }
3122
+ for (var d = 0; d < addButtons.length; d++) addButtons[d].disabled = true;
3123
+ status.textContent = (andPublish ? 'Publishing' : 'Adding') + String.fromCharCode(8230);
3124
+ var id = card.dataset.workflow;
3125
+ var w = withDraftFields(workflowsById[id]);
3126
+ // The whole editor form, as the workflow stands in its draft, with
3127
+ // the prompt changed: the draft keeps everything else as it is.
3128
+ var steps = [];
3129
+ if (takePrompt) steps.push(function () {
3130
+ return fetchJsonRetryOnce(base + '/draft', { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify({
3131
+ title: w.title, description: w.description, instructions: sg.instructions, parameters: w.parameters || {},
3132
+ output: w.output || '', outputSchema: w.outputSchema ? JSON.stringify(w.outputSchema, null, 2) : '', model: w.model || null,
3133
+ }) });
3134
+ });
3135
+ if (picked.length) steps.push(function () {
3136
+ return fetchJsonRetryOnce(base + '/draft').then(function (d) {
3137
+ var now = d.ok && d.body.draft && d.body.draft.criteria ? d.body.draft.criteria : ((w.evals && w.evals.criteria) || []);
3138
+ var list = now.map(function (c) { return { text: c.text, kind: c.kind, value: c.value }; }).concat(picked.map(function (c) { return { text: c.text, kind: c.kind, value: c.value }; }));
3139
+ return fetchJsonRetryOnce(base + '/draft/criteria', { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ criteria: list }) });
3140
+ });
3141
+ });
3142
+ steps.reduce(function (p, step) {
3143
+ return p.then(function (prev) { if (prev && !prev.ok) return prev; return step(); });
3144
+ }, Promise.resolve(null)).then(function (last) {
3145
+ return last && last.ok && andPublish ? publishSavedDraft(base, ('Self-Improve: ' + (sg.summary || 'changes from feedback')).slice(0, 480)) : last;
3146
+ }).then(function (last) {
3147
+ if (last && !last.ok) { for (var e = 0; e < addButtons.length; e++) addButtons[e].disabled = false; status.textContent = last.body.error || 'Could not add them'; return; }
3148
+ for (var h = 0; h < addButtons.length; h++) addButtons[h].hidden = addButtons[h] !== btn;
3149
+ if (andPublish) {
3150
+ btn.textContent = 'Published';
3151
+ status.innerHTML = 'Every run from now on uses it. Run Evaluate to check it does better.';
3152
+ loadWorkflowsSection(name);
3153
+ return;
3154
+ }
3155
+ btn.textContent = 'Added to the draft';
3156
+ status.innerHTML = 'Review and publish the draft (at the top) to make it live, then run Evaluate to check it does better.';
3157
+ refreshDraft(name, card);
3158
+ });
3159
+ });
3160
+ });
3161
+ }
3162
+
2928
3163
  function workflowVersionsHtml() {
2929
3164
  return '<div class="wf-versions"><p class="hint" style="margin:0">Loading' + String.fromCharCode(8230) + '</p></div>';
2930
3165
  }
@@ -3236,6 +3471,7 @@ ${renderMarkdownScript}
3236
3471
  loadWorkflowHealth(card, base);
3237
3472
  loadCandidates(name, card, base);
3238
3473
  loadWorkflowRuns(name, card, base);
3474
+ loadWorkflowFeedback(name, card, base);
3239
3475
  if (openTraces[id] && card.querySelector('.wf-trace')) openRunTrace(name, card, openTraces[id].run);
3240
3476
  card.querySelector('.workflow-edit').addEventListener('click', function () { openWorkflowEditor(name, card); });
3241
3477
  // Opens the workflow's page on its Triggers tab.
@@ -3287,7 +3523,7 @@ ${renderMarkdownScript}
3287
3523
  if (msgForm.msgNoticeOn && msgForm.msgNoticeOn.checked && msgForm.msgNotice.value.trim()) body.chat_notice = msgForm.msgNotice.value.trim();
3288
3524
  if (msgForm.msgResult && msgForm.msgResult.checked) body.result_to_chat = true;
3289
3525
  msgResult.textContent = 'Saving' + String.fromCharCode(8230);
3290
- fetchJsonRetryOnce(base + '/draft/messages', { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) }).then(function (r) {
3526
+ fetchJsonRetryOnce(base + '/messages', { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) }).then(function (r) {
3291
3527
  if (!r.ok) { msgResult.textContent = r.body.error || 'Could not save'; return; }
3292
3528
  reloadOnMessages();
3293
3529
  });
@@ -3296,7 +3532,7 @@ ${renderMarkdownScript}
3296
3532
  for (var cb = 0; cb < clearButtons.length; cb++) {
3297
3533
  clearButtons[cb].addEventListener('click', function (ev) {
3298
3534
  var tid = ev.currentTarget.dataset.trigger;
3299
- fetchJsonRetryOnce(base + '/draft/webhooks/' + encodeURIComponent(tid), {
3535
+ fetchJsonRetryOnce(base + '/triggers/' + encodeURIComponent(tid), {
3300
3536
  method: 'PUT', headers: { 'content-type': 'application/json' },
3301
3537
  body: JSON.stringify({ callback_url: null, decisions: null, chat_notice: null, result_to_chat: false }),
3302
3538
  }).then(function (r) {
@@ -3325,6 +3561,7 @@ ${renderMarkdownScript}
3325
3561
  if (cbtn.classList.contains('wf-crit-edit')) {
3326
3562
  critForm.hidden = false;
3327
3563
  cbtn.hidden = true;
3564
+ offerPublish(critForm);
3328
3565
  if (!rows.children.length) rows.insertAdjacentHTML('beforeend', critRowHtml({ kind: 'judge' }));
3329
3566
  return;
3330
3567
  }
@@ -3345,8 +3582,12 @@ ${renderMarkdownScript}
3345
3582
  var list = Array.prototype.map.call(rows.querySelectorAll('.wf-crit-row'), function (row) {
3346
3583
  return { id: row.dataset.critId || undefined, kind: row.querySelector('[data-crit-kind]').value, text: row.querySelector('[data-crit-text]').value, value: row.querySelector('[data-crit-value]').value };
3347
3584
  }).filter(function (c) { return c.text.trim() || c.value.trim(); });
3348
- // Saved to the draft: published with the rest of it.
3585
+ // Saved to the draft: published with the rest of it, now with Save
3586
+ // and publish, or later from Review and publish.
3587
+ var andPublish = cbtn.classList.contains('wf-crit-publish');
3349
3588
  fetchJsonRetryOnce(base + '/draft/criteria', { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ criteria: list }) }).then(function (r) {
3589
+ return r.ok && andPublish ? publishSavedDraft(base, 'Changed the success criteria') : r;
3590
+ }).then(function (r) {
3350
3591
  cbtn.disabled = false;
3351
3592
  if (!r.ok) { critStatus.textContent = r.body.error || 'That didn' + String.fromCharCode(8217) + 't save.'; return; }
3352
3593
  workflowTabs[id] = 'evaluation';
@@ -3389,10 +3630,9 @@ ${renderMarkdownScript}
3389
3630
  card.querySelector('.workflow-hooks-btn').addEventListener('click', function () {
3390
3631
  var w = workflowsById[id];
3391
3632
  if (!w) return;
3392
- // Made in the draft: its URL now, live once the draft is published.
3393
- openHookFormDialog(w, base + '/draft/webhooks', function (url, triggerId) {
3633
+ // Live at once: its URL now, to set up in the sending app.
3634
+ openHookFormDialog(w, base + '/triggers', function (url, triggerId) {
3394
3635
  loadWorkflowHooks(name, card, { url: url, id: triggerId });
3395
- refreshDraft(name, card);
3396
3636
  });
3397
3637
  });
3398
3638
  var wf = workflowsById[id];
@@ -3402,8 +3642,7 @@ ${renderMarkdownScript}
3402
3642
  pendingScheduleWorkflow = id;
3403
3643
  switchTab('schedules');
3404
3644
  });
3405
- // Removing a schedule, or undoing that, is part of the draft; pausing
3406
- // and resuming act now.
3645
+ // Undoing a removal drafted before schedules went live at once.
3407
3646
  var draftScheduleBtns = card.querySelectorAll('.workflow-schedule-draft');
3408
3647
  for (var dsb = 0; dsb < draftScheduleBtns.length; dsb++) {
3409
3648
  draftScheduleBtns[dsb].addEventListener('click', function (ev) {
@@ -3420,9 +3659,8 @@ ${renderMarkdownScript}
3420
3659
  var action = btn.dataset.action;
3421
3660
  if (action === 'cancel' && btn.dataset.confirming !== '1') { btn.dataset.confirming = '1'; btn.textContent = 'Click again to remove'; return; }
3422
3661
  btn.disabled = true;
3423
- var request = action === 'cancel'
3424
- ? fetchJsonRetryOnce(base + '/draft/schedules/' + encodeURIComponent(btn.dataset.id), { method: 'DELETE' })
3425
- : fetchJsonRetryOnce('/schedules/' + encodeURIComponent(btn.dataset.id) + '/' + action, { method: 'POST' });
3662
+ // Schedules are live at once (and in Audit): removing one cancels it.
3663
+ var request = fetchJsonRetryOnce('/schedules/' + encodeURIComponent(btn.dataset.id) + '/' + action, { method: 'POST' });
3426
3664
  request.then(function () {
3427
3665
  loadWorkflowsSection(name);
3428
3666
  // The Schedules tab's count, and the Overview's tile.
@@ -3528,7 +3766,7 @@ ${renderMarkdownScript}
3528
3766
  var nameSection =
3529
3767
  '<h3>Name <button type="button" class="edit-btn" id="editDisplayNameBtn">Edit</button></h3>' +
3530
3768
  '<p class="ov-name"><span id="displayNameDisplay">' + escapeHtml(cfg.displayName || cfg.name) + '</span>' +
3531
- ' <span class="muted" data-advanced>&middot; id <code>' + escapeHtml(cfg.name) + '</code></span></p>' +
3769
+ ' <span class="muted">&middot; id <code>' + escapeHtml(cfg.name) + '</code></span></p>' +
3532
3770
  editDialogHtml('<h3>Edit name</h3>', '<p>The name shown in the sidebar and at the top of its pages. Its id, <code>' + escapeHtml(cfg.name) + '</code>, stays the same: its API address and saved runs use it.</p>',
3533
3771
  '<form class="add-source" id="displayNameForm" style="display:none">' +
3534
3772
  '<label>Name<input type="text" name="displayName" maxlength="60" placeholder="' + escapeHtml(cfg.name) + '" value="' + escapeHtml(cfg.displayName || '') + '"></label>' +
@@ -3597,8 +3835,8 @@ ${renderMarkdownScript}
3597
3835
  return renderOverviewCards(cfg) +
3598
3836
  '<section>' + nameSection + '</section>' +
3599
3837
  '<section>' + systemPromptSection + '</section>' +
3600
- '<section data-advanced>' + modelSection + '</section>' +
3601
- '<section data-advanced><h3>Limits <button type="button" class="edit-btn" id="editLimitsBtn">Edit</button></h3>' +
3838
+ '<section>' + modelSection + '</section>' +
3839
+ '<section><h3>Limits <button type="button" class="edit-btn" id="editLimitsBtn">Edit</button></h3>' +
3602
3840
  '<dl class="kv kv-wide" id="limitsDisplay">' +
3603
3841
  '<dt>Model turns per run</dt><dd>' + escapeHtml(cfg.maxTurns) + ' <span class="hint">then the run stops</span></dd>' +
3604
3842
  '<dt>Conversation size</dt><dd>' + escapeHtml(Number(cfg.contextBudgetTokens).toLocaleString()) + ' tokens <span class="hint">older steps are summarised beyond this</span></dd>' +
@@ -4872,11 +5110,7 @@ ${renderMarkdownScript}
4872
5110
  return;
4873
5111
  }
4874
5112
  btn.disabled = true;
4875
- // A workflow's schedule is removed in the workflow's draft.
4876
- var wfId = btn.dataset.workflow;
4877
- var request = wfId && (action === 'cancel' || action === 'delete')
4878
- ? fetchJsonRetryOnce('/agents/' + encodeURIComponent(name) + '/workflows/' + encodeURIComponent(wfId) + '/draft/schedules/' + encodeURIComponent(btn.dataset.id), { method: 'DELETE' })
4879
- : action === 'delete'
5113
+ var request = action === 'delete'
4880
5114
  ? fetchJsonRetryOnce('/schedules/' + encodeURIComponent(btn.dataset.id), { method: 'DELETE' })
4881
5115
  : fetchJsonRetryOnce('/schedules/' + encodeURIComponent(btn.dataset.id) + '/' + action, { method: 'POST' });
4882
5116
  request.then(function () { setTimeout(function () { loadSchedulesTab(name); }, action === 'run' ? 800 : 0); });
@@ -4953,11 +5187,9 @@ ${renderMarkdownScript}
4953
5187
  if (data.get('everyStart')) schedule.start_at = scheduleFormTime(data.get('everyStart'));
4954
5188
  }
4955
5189
  result.textContent = 'Scheduling' + String.fromCharCode(8230);
4956
- // A workflow's schedule goes in the workflow's draft: it starts when
4957
- // the draft is published. A message schedule starts now.
4958
- var target = runsWorkflow
4959
- ? '/agents/' + encodeURIComponent(name) + '/workflows/' + encodeURIComponent(data.get('workflow_id')) + '/draft/schedules'
4960
- : '/agents/' + encodeURIComponent(name) + '/schedules';
5190
+ // Live at once, a workflow's schedule too (it's how the workflow
5191
+ // starts, not what it does), and in Audit.
5192
+ var target = '/agents/' + encodeURIComponent(name) + '/schedules';
4961
5193
  fetchJsonRetryOnce(target, {
4962
5194
  method: 'POST', headers: { 'content-type': 'application/json' },
4963
5195
  body: JSON.stringify(Object.assign(
@@ -4966,10 +5198,6 @@ ${renderMarkdownScript}
4966
5198
  )),
4967
5199
  }).then(function (r) {
4968
5200
  if (!r.ok) { result.textContent = r.body.error || 'Could not schedule'; return; }
4969
- if (runsWorkflow) {
4970
- result.innerHTML = 'Added to the workflow' + String.fromCharCode(8217) + 's draft: it starts when the draft is published. <a href="' + workflowPageHref(name, data.get('workflow_id')) + '">Review and publish</a>';
4971
- return;
4972
- }
4973
5201
  loadSchedulesTab(name);
4974
5202
  });
4975
5203
  });
@@ -156,7 +156,7 @@ ${consoleShellScript}
156
156
  var qs = '?agent=' + encodeURIComponent(agent.name);
157
157
  li.innerHTML =
158
158
  '<div class="le-card agent-card">' +
159
- '<div class="name">' + escapeHtml(agent.displayName || agent.name) + (agent.displayName ? ' <span class="hint" data-advanced style="font-family:var(--font-mono);font-weight:400">' + escapeHtml(agent.name) + '</span>' : '') + '</div>' +
159
+ '<div class="name">' + escapeHtml(agent.displayName || agent.name) + (agent.displayName ? ' <span class="hint" style="font-family:var(--font-mono);font-weight:400">' + escapeHtml(agent.name) + '</span>' : '') + '</div>' +
160
160
  '<div class="does" data-agent-does="' + escapeHtml(agent.name) + '"></div>' +
161
161
  '<div class="prompt">' + escapeHtml(agent.systemPrompt) + '</div>' +
162
162
  '<div class="links">' +