loopengine 0.5.8 → 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.
package/dist/index.d.ts CHANGED
@@ -126,7 +126,7 @@ export { startMcpSignIn, finishMcpSignIn, mcpSignInSupport, mcpOAuthEnvName, par
126
126
  export { abilityDetails } from './web/ability-details-admin.js';
127
127
  export { WorkspaceAbilityError, listWorkspaceAbilities, addWorkspaceAbility, removeWorkspaceAbility, workspaceAbilitiesDir, type WorkspaceAbility } from './core/workspace-abilities.js';
128
128
  export { installWorkspaceAbility, installUploadedAbility, MAX_UPLOAD_BYTES, type AbilityUpload } from './web/workspace-abilities-admin.js';
129
- export { callCost, modelPrice, describeModelProviders, describeGateways, setModelProviderKey, clearModelProviderKey, listProviderModels, ModelKeyError, describeTimeZone, setWorkspaceTimeZone, TimeZoneError } from './web/global-config.js';
129
+ export { callCost, modelPrice, describeModelProviders, describeGateways, setModelProviderKey, clearModelProviderKey, listProviderModels, ModelKeyError, describeTimeZone, setWorkspaceTimeZone, TimeZoneError, requireReview, setRequireReview, REQUIRE_REVIEW_ENV } from './web/global-config.js';
130
130
  export { loopengineVersion } from './core/version.js';
131
131
  export { describeUpgrade, runUpgrade, UpgradeError } from './web/upgrade-admin.js';
132
132
  export type { ModelPrice, ModelPrices, ModelProviderInfo, AgentModelUsage, ModelsView, ProviderModelsView, GatewayProviderInfo, GatewaysView, TimeZoneView } from './web/global-config.js';
package/dist/index.js CHANGED
@@ -116,7 +116,7 @@ export { startMcpSignIn, finishMcpSignIn, mcpSignInSupport, mcpOAuthEnvName, par
116
116
  export { abilityDetails } from './web/ability-details-admin.js';
117
117
  export { WorkspaceAbilityError, listWorkspaceAbilities, addWorkspaceAbility, removeWorkspaceAbility, workspaceAbilitiesDir } from './core/workspace-abilities.js';
118
118
  export { installWorkspaceAbility, installUploadedAbility, MAX_UPLOAD_BYTES } from './web/workspace-abilities-admin.js';
119
- export { callCost, modelPrice, describeModelProviders, describeGateways, setModelProviderKey, clearModelProviderKey, listProviderModels, ModelKeyError, describeTimeZone, setWorkspaceTimeZone, TimeZoneError } from './web/global-config.js';
119
+ export { callCost, modelPrice, describeModelProviders, describeGateways, setModelProviderKey, clearModelProviderKey, listProviderModels, ModelKeyError, describeTimeZone, setWorkspaceTimeZone, TimeZoneError, requireReview, setRequireReview, REQUIRE_REVIEW_ENV } from './web/global-config.js';
120
120
  export { loopengineVersion } from './core/version.js';
121
121
  export { describeUpgrade, runUpgrade, UpgradeError } from './web/upgrade-admin.js';
122
122
  export { workspaceTimeZone, serverTimeZone, isValidTimeZone, TIME_ZONE_ENV } from '#core/time-zone.js';
@@ -1080,9 +1080,8 @@ ${renderMarkdownScript}
1080
1080
  var inner = '<span class="le-card-label"><span>' + label + '</span>' + (tab ? '<span aria-hidden="true">&rarr;</span>' : '') + '</span>' +
1081
1081
  '<span class="le-card-value">' + value + '</span>' +
1082
1082
  '<span class="le-card-detail">' + detailText + '</span>';
1083
- var adv = ['tools', 'env'].indexOf(tab) !== -1 ? ' data-advanced' : '';
1084
1083
  return tab
1085
- ? '<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>'
1086
1085
  : '<div class="le-card">' + inner + '</div>';
1087
1086
  }
1088
1087
  return '<div class="le-cards" style="margin-bottom:28px">' +
@@ -1459,7 +1458,7 @@ ${renderMarkdownScript}
1459
1458
  '<button type="button" class="wf-msg-clear-hook" data-trigger="' + escapeHtml(t.trigger_id) + '">Use these instead</button></p>';
1460
1459
  }).join('') + '</div>'
1461
1460
  : '') +
1462
- '<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>' +
1463
1462
  '</form>';
1464
1463
  }
1465
1464
 
@@ -1469,7 +1468,7 @@ ${renderMarkdownScript}
1469
1468
  var schedules = workflowScheduleItemsHtml(w, name);
1470
1469
  var hasHooks = Boolean(w.webhooks || w.webhooksWaiting || w.webhooksOff);
1471
1470
  var way = function (key, title, what, body) {
1472
- 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>';
1473
1472
  };
1474
1473
  return '<div class="wf-ways">' +
1475
1474
  way('run', 'Run now', 'Starts a run right away, from here. Follow it in Activity.', workflowRunBarHtml(w, params)) +
@@ -2004,7 +2003,7 @@ ${renderMarkdownScript}
2004
2003
  '<div class="wf-crit-form" hidden>' +
2005
2004
  '<div class="wf-crit-rows">' + (evals.criteria && evals.criteria.length ? evals.criteria : []).map(critRowHtml).join('') + '</div>' +
2006
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>' +
2007
- '<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>' +
2008
2007
  '<span class="hint wf-crit-status"></span>' +
2009
2008
  '</div>';
2010
2009
  var latest = {};
@@ -2097,10 +2096,6 @@ ${renderMarkdownScript}
2097
2096
  return parts.length ? '<div class="wf-run-evidence">' + parts.join('') + '</div>' : '';
2098
2097
  }
2099
2098
 
2100
- // A workflow's tabs for Advanced view only: for whoever builds and
2101
- // audits it, not the operator who runs it.
2102
- var WORKFLOW_ADVANCED_TABS = ['evaluation', 'contract', 'versions'];
2103
-
2104
2099
  function renderWorkflowsHtml(name, workflows) {
2105
2100
  if (workflowPageId) {
2106
2101
  var page = workflows.filter(function (x) { return x.id === workflowPageId; });
@@ -2142,7 +2137,7 @@ ${renderMarkdownScript}
2142
2137
  var tab = workflowTabs[w.id] || 'activity';
2143
2138
  var open = openWorkflowId === w.id;
2144
2139
  var panel = function (key, html) { return '<div class="wf-panel" data-panel="' + key + '"' + (tab === key ? '' : ' hidden') + '>' + html + '</div>'; };
2145
- 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>'; };
2146
2141
  if (workflowPageId) {
2147
2142
  var agentLabel = currentCfg && currentCfg.displayName ? currentCfg.displayName : name;
2148
2143
  document.title = w.title + ' ' + String.fromCharCode(183) + ' ' + agentLabel;
@@ -2411,7 +2406,10 @@ ${renderMarkdownScript}
2411
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>' +
2412
2407
  '<p class="hint workflow-editor-check" style="margin:0"></p>' +
2413
2408
  '<div class="hint workflow-editor-result"></div>' +
2414
- '<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>';
2415
2413
  }
2416
2414
 
2417
2415
  // Placeholders the instructions use that no parameter declares, and
@@ -2538,6 +2536,31 @@ ${renderMarkdownScript}
2538
2536
  });
2539
2537
  }
2540
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
+
2541
2564
  function openWorkflowEditor(name, card) {
2542
2565
  var published = workflowsById[card.dataset.workflow];
2543
2566
  if (!published) return;
@@ -2594,8 +2617,29 @@ ${renderMarkdownScript}
2594
2617
  // A preview shown goes stale as the instructions change: hide it.
2595
2618
  form.addEventListener('input', function () { previewBox.hidden = true; });
2596
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
+ });
2597
2640
  form.addEventListener('submit', function (ev) {
2598
2641
  ev.preventDefault();
2642
+ if (ev.submitter) publishing = ev.submitter === publishBtn;
2599
2643
  var parameters = {};
2600
2644
  var problem = '';
2601
2645
  var list = rows.querySelectorAll('.workflow-param-row');
@@ -2610,14 +2654,22 @@ ${renderMarkdownScript}
2610
2654
  try { JSON.parse(form.outputSchema.value); } catch (e) { problem = 'The output schema isn' + String.fromCharCode(8217) + 't valid JSON: ' + e.message; }
2611
2655
  }
2612
2656
  if (problem) { result.textContent = problem; return; }
2613
- result.textContent = 'Saving the draft' + String.fromCharCode(8230);
2614
- fetchJsonRetryOnce('/agents/' + encodeURIComponent(name) + '/workflows/' + encodeURIComponent(w.id) + '/draft', {
2615
- method: 'PUT', headers: { 'content-type': 'application/json' },
2616
- 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 }),
2617
- }).then(function (r) {
2618
- 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; }
2619
2662
  close();
2620
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); });
2621
2673
  });
2622
2674
  });
2623
2675
  check();
@@ -2866,6 +2918,7 @@ ${renderMarkdownScript}
2866
2918
  var addBox = card.querySelector('.workflow-hooks-add');
2867
2919
  if (!w || !box) return;
2868
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.
2869
2922
  var draftBase = '/agents/' + encodeURIComponent(name) + '/workflows/' + encodeURIComponent(w.id) + '/draft/webhooks';
2870
2923
  var hooksById = {};
2871
2924
  function render(shownUrl, shownId) {
@@ -2909,10 +2962,10 @@ ${renderMarkdownScript}
2909
2962
  for (var i = 0; i < rows.length; i++) {
2910
2963
  (function (row) {
2911
2964
  var id = row.dataset.trigger;
2912
- // Editing and deleting go in the draft; on/off, the signing secret
2913
- // 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.
2914
2967
  row.querySelector('.hook-edit').addEventListener('click', function () {
2915
- 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]);
2916
2969
  });
2917
2970
  var undo = row.querySelector('.hook-undo');
2918
2971
  if (undo) undo.addEventListener('click', function () {
@@ -2945,10 +2998,9 @@ ${renderMarkdownScript}
2945
2998
  row.querySelector('.hook-delete').addEventListener('click', function (ev) {
2946
2999
  var btn = ev.currentTarget;
2947
3000
  if (btn.dataset.confirming !== '1') { btn.dataset.confirming = '1'; btn.textContent = 'Click again to delete'; return; }
2948
- fetchJsonRetryOnce(draftBase + '/' + encodeURIComponent(id), { method: 'DELETE' }).then(function (r) {
3001
+ fetchJsonRetryOnce(base + '/' + encodeURIComponent(id), { method: 'DELETE' }).then(function (r) {
2949
3002
  if (!r.ok) { alert(r.body.error || 'That didn' + String.fromCharCode(8217) + 't work'); return; }
2950
- render(null, null);
2951
- refreshDraft(name, card);
3003
+ loadWorkflowsSection(name);
2952
3004
  });
2953
3005
  });
2954
3006
  })(rows[i]);
@@ -3014,7 +3066,7 @@ ${renderMarkdownScript}
3014
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>' +
3015
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>' +
3016
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>' +
3017
- '<span data-advanced>Or with an API key:</span><pre data-advanced>POST /agents/' + escapeHtml(name) + '/runs/&lt;runId&gt;/feedback' + String.fromCharCode(10) + '{ "verdict": "bad", "note": "...", "final": "...", "source": "api", "by": "jane@acme.com" }</pre></div>' +
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>' +
3018
3070
  '</div></section>';
3019
3071
  var trace = function (ev) {
3020
3072
  var a = ev.target.closest('.wf-fb-trace');
@@ -3056,16 +3108,19 @@ ${renderMarkdownScript}
3056
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>' : '') +
3057
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>' : '') +
3058
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>' : '') +
3059
- '<div class="wf-fb-improve-bar"><button type="button" class="le-btn-dark wf-fb-add">Add to draft</button><span class="hint wf-fb-add-status">Then review and publish it, and Evaluate to check it does better.</span></div>' +
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>' +
3060
3112
  '<p class="hint" style="margin:0">Suggested by ' + escapeHtml(sg.model) + ' from ' + sg.basedOn + ' piece' + (sg.basedOn === 1 ? '' : 's') + ' of feedback.</p>';
3061
- panel.querySelector('.wf-fb-add').addEventListener('click', function (ev) {
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) {
3062
3116
  var btn = ev.currentTarget;
3117
+ var andPublish = btn.classList.contains('wf-fb-add-publish');
3063
3118
  var status = panel.querySelector('.wf-fb-add-status');
3064
3119
  var takePrompt = changed && panel.querySelector('.wf-fb-take-prompt') && panel.querySelector('.wf-fb-take-prompt').checked;
3065
3120
  var picked = sg.criteria.filter(function (c, i) { var b = panel.querySelector('[data-crit="' + i + '"]'); return b && b.checked; });
3066
3121
  if (!takePrompt && !picked.length) { status.textContent = 'Tick at least one change to add.'; return; }
3067
- btn.disabled = true;
3068
- status.textContent = 'Adding' + String.fromCharCode(8230);
3122
+ for (var d = 0; d < addButtons.length; d++) addButtons[d].disabled = true;
3123
+ status.textContent = (andPublish ? 'Publishing' : 'Adding') + String.fromCharCode(8230);
3069
3124
  var id = card.dataset.workflow;
3070
3125
  var w = withDraftFields(workflowsById[id]);
3071
3126
  // The whole editor form, as the workflow stands in its draft, with
@@ -3087,7 +3142,16 @@ ${renderMarkdownScript}
3087
3142
  steps.reduce(function (p, step) {
3088
3143
  return p.then(function (prev) { if (prev && !prev.ok) return prev; return step(); });
3089
3144
  }, Promise.resolve(null)).then(function (last) {
3090
- if (last && !last.ok) { btn.disabled = false; status.textContent = last.body.error || 'Could not add them'; return; }
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
+ }
3091
3155
  btn.textContent = 'Added to the draft';
3092
3156
  status.innerHTML = 'Review and publish the draft (at the top) to make it live, then run Evaluate to check it does better.';
3093
3157
  refreshDraft(name, card);
@@ -3459,7 +3523,7 @@ ${renderMarkdownScript}
3459
3523
  if (msgForm.msgNoticeOn && msgForm.msgNoticeOn.checked && msgForm.msgNotice.value.trim()) body.chat_notice = msgForm.msgNotice.value.trim();
3460
3524
  if (msgForm.msgResult && msgForm.msgResult.checked) body.result_to_chat = true;
3461
3525
  msgResult.textContent = 'Saving' + String.fromCharCode(8230);
3462
- 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) {
3463
3527
  if (!r.ok) { msgResult.textContent = r.body.error || 'Could not save'; return; }
3464
3528
  reloadOnMessages();
3465
3529
  });
@@ -3468,7 +3532,7 @@ ${renderMarkdownScript}
3468
3532
  for (var cb = 0; cb < clearButtons.length; cb++) {
3469
3533
  clearButtons[cb].addEventListener('click', function (ev) {
3470
3534
  var tid = ev.currentTarget.dataset.trigger;
3471
- fetchJsonRetryOnce(base + '/draft/webhooks/' + encodeURIComponent(tid), {
3535
+ fetchJsonRetryOnce(base + '/triggers/' + encodeURIComponent(tid), {
3472
3536
  method: 'PUT', headers: { 'content-type': 'application/json' },
3473
3537
  body: JSON.stringify({ callback_url: null, decisions: null, chat_notice: null, result_to_chat: false }),
3474
3538
  }).then(function (r) {
@@ -3497,6 +3561,7 @@ ${renderMarkdownScript}
3497
3561
  if (cbtn.classList.contains('wf-crit-edit')) {
3498
3562
  critForm.hidden = false;
3499
3563
  cbtn.hidden = true;
3564
+ offerPublish(critForm);
3500
3565
  if (!rows.children.length) rows.insertAdjacentHTML('beforeend', critRowHtml({ kind: 'judge' }));
3501
3566
  return;
3502
3567
  }
@@ -3517,8 +3582,12 @@ ${renderMarkdownScript}
3517
3582
  var list = Array.prototype.map.call(rows.querySelectorAll('.wf-crit-row'), function (row) {
3518
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 };
3519
3584
  }).filter(function (c) { return c.text.trim() || c.value.trim(); });
3520
- // 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');
3521
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) {
3522
3591
  cbtn.disabled = false;
3523
3592
  if (!r.ok) { critStatus.textContent = r.body.error || 'That didn' + String.fromCharCode(8217) + 't save.'; return; }
3524
3593
  workflowTabs[id] = 'evaluation';
@@ -3561,10 +3630,9 @@ ${renderMarkdownScript}
3561
3630
  card.querySelector('.workflow-hooks-btn').addEventListener('click', function () {
3562
3631
  var w = workflowsById[id];
3563
3632
  if (!w) return;
3564
- // Made in the draft: its URL now, live once the draft is published.
3565
- 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) {
3566
3635
  loadWorkflowHooks(name, card, { url: url, id: triggerId });
3567
- refreshDraft(name, card);
3568
3636
  });
3569
3637
  });
3570
3638
  var wf = workflowsById[id];
@@ -3574,8 +3642,7 @@ ${renderMarkdownScript}
3574
3642
  pendingScheduleWorkflow = id;
3575
3643
  switchTab('schedules');
3576
3644
  });
3577
- // Removing a schedule, or undoing that, is part of the draft; pausing
3578
- // and resuming act now.
3645
+ // Undoing a removal drafted before schedules went live at once.
3579
3646
  var draftScheduleBtns = card.querySelectorAll('.workflow-schedule-draft');
3580
3647
  for (var dsb = 0; dsb < draftScheduleBtns.length; dsb++) {
3581
3648
  draftScheduleBtns[dsb].addEventListener('click', function (ev) {
@@ -3592,9 +3659,8 @@ ${renderMarkdownScript}
3592
3659
  var action = btn.dataset.action;
3593
3660
  if (action === 'cancel' && btn.dataset.confirming !== '1') { btn.dataset.confirming = '1'; btn.textContent = 'Click again to remove'; return; }
3594
3661
  btn.disabled = true;
3595
- var request = action === 'cancel'
3596
- ? fetchJsonRetryOnce(base + '/draft/schedules/' + encodeURIComponent(btn.dataset.id), { method: 'DELETE' })
3597
- : 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' });
3598
3664
  request.then(function () {
3599
3665
  loadWorkflowsSection(name);
3600
3666
  // The Schedules tab's count, and the Overview's tile.
@@ -3700,7 +3766,7 @@ ${renderMarkdownScript}
3700
3766
  var nameSection =
3701
3767
  '<h3>Name <button type="button" class="edit-btn" id="editDisplayNameBtn">Edit</button></h3>' +
3702
3768
  '<p class="ov-name"><span id="displayNameDisplay">' + escapeHtml(cfg.displayName || cfg.name) + '</span>' +
3703
- ' <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>' +
3704
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>',
3705
3771
  '<form class="add-source" id="displayNameForm" style="display:none">' +
3706
3772
  '<label>Name<input type="text" name="displayName" maxlength="60" placeholder="' + escapeHtml(cfg.name) + '" value="' + escapeHtml(cfg.displayName || '') + '"></label>' +
@@ -3769,8 +3835,8 @@ ${renderMarkdownScript}
3769
3835
  return renderOverviewCards(cfg) +
3770
3836
  '<section>' + nameSection + '</section>' +
3771
3837
  '<section>' + systemPromptSection + '</section>' +
3772
- '<section data-advanced>' + modelSection + '</section>' +
3773
- '<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>' +
3774
3840
  '<dl class="kv kv-wide" id="limitsDisplay">' +
3775
3841
  '<dt>Model turns per run</dt><dd>' + escapeHtml(cfg.maxTurns) + ' <span class="hint">then the run stops</span></dd>' +
3776
3842
  '<dt>Conversation size</dt><dd>' + escapeHtml(Number(cfg.contextBudgetTokens).toLocaleString()) + ' tokens <span class="hint">older steps are summarised beyond this</span></dd>' +
@@ -5044,11 +5110,7 @@ ${renderMarkdownScript}
5044
5110
  return;
5045
5111
  }
5046
5112
  btn.disabled = true;
5047
- // A workflow's schedule is removed in the workflow's draft.
5048
- var wfId = btn.dataset.workflow;
5049
- var request = wfId && (action === 'cancel' || action === 'delete')
5050
- ? fetchJsonRetryOnce('/agents/' + encodeURIComponent(name) + '/workflows/' + encodeURIComponent(wfId) + '/draft/schedules/' + encodeURIComponent(btn.dataset.id), { method: 'DELETE' })
5051
- : action === 'delete'
5113
+ var request = action === 'delete'
5052
5114
  ? fetchJsonRetryOnce('/schedules/' + encodeURIComponent(btn.dataset.id), { method: 'DELETE' })
5053
5115
  : fetchJsonRetryOnce('/schedules/' + encodeURIComponent(btn.dataset.id) + '/' + action, { method: 'POST' });
5054
5116
  request.then(function () { setTimeout(function () { loadSchedulesTab(name); }, action === 'run' ? 800 : 0); });
@@ -5125,11 +5187,9 @@ ${renderMarkdownScript}
5125
5187
  if (data.get('everyStart')) schedule.start_at = scheduleFormTime(data.get('everyStart'));
5126
5188
  }
5127
5189
  result.textContent = 'Scheduling' + String.fromCharCode(8230);
5128
- // A workflow's schedule goes in the workflow's draft: it starts when
5129
- // the draft is published. A message schedule starts now.
5130
- var target = runsWorkflow
5131
- ? '/agents/' + encodeURIComponent(name) + '/workflows/' + encodeURIComponent(data.get('workflow_id')) + '/draft/schedules'
5132
- : '/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';
5133
5193
  fetchJsonRetryOnce(target, {
5134
5194
  method: 'POST', headers: { 'content-type': 'application/json' },
5135
5195
  body: JSON.stringify(Object.assign(
@@ -5138,10 +5198,6 @@ ${renderMarkdownScript}
5138
5198
  )),
5139
5199
  }).then(function (r) {
5140
5200
  if (!r.ok) { result.textContent = r.body.error || 'Could not schedule'; return; }
5141
- if (runsWorkflow) {
5142
- 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>';
5143
- return;
5144
- }
5145
5201
  loadSchedulesTab(name);
5146
5202
  });
5147
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">' +
@@ -19,16 +19,8 @@
19
19
  // leShell.applyProviderKeys(form, keys, keep) only providers with a key
20
20
  // leShell.abilityOriginBadge(origin) Official/Public/Private badge for an ability
21
21
  // leShell.toggleAbilityDetails(btn) an ability's tools, skills and settings
22
- // leShell.advanced() whether this person has Advanced view on
23
22
  // leShell.adminNote(tech) "Only your workspace admin can change this",
24
- // with the technical how-to in Advanced view
25
- //
26
- // Simple and Advanced view: the console is for operators first, so what
27
- // only a developer or the workspace's admin needs (version history,
28
- // evaluations, the contract, the API, environment, limits) is marked
29
- // data-advanced and hidden until a person turns on Advanced in the
30
- // sidebar (kept in this browser). data-simple marks what shows only
31
- // without it.
23
+ // with the technical how-to
32
24
  // Same embedded-string conventions as the pages themselves: plain
33
25
  // string concatenation and no backslashes inside the script, so nothing
34
26
  // here needs double-escaping in the template literal.
@@ -48,7 +40,6 @@ const GOALS_ICON = '<svg class="le-nav-icon" viewBox="0 0 24 24" fill="none" str
48
40
  const AUDIT_ICON = '<svg class="le-nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="5" y="4" width="14" height="17" rx="2"/><path d="M9 4V3h6v1"/><path d="m9 13 2 2 4-4"/></svg>';
49
41
  // A gear, for Settings.
50
42
  const SCHEDULES_ICON = '<svg class="le-nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg>';
51
- const ADVANCED_ICON = '<svg class="le-nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="4" y1="21" x2="4" y2="14"/><line x1="4" y1="10" x2="4" y2="3"/><line x1="12" y1="21" x2="12" y2="12"/><line x1="12" y1="8" x2="12" y2="3"/><line x1="20" y1="21" x2="20" y2="16"/><line x1="20" y1="12" x2="20" y2="3"/><line x1="1" y1="14" x2="7" y2="14"/><line x1="9" y1="8" x2="15" y2="8"/><line x1="17" y1="16" x2="23" y2="16"/></svg>';
52
43
  const SETTINGS_ICON = '<svg class="le-nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>';
53
44
  // Two columns: the sections (Inbox, Goals, Agents, Workflows, Audit,
54
45
  // Settings), and beside them what's in the current one. A goal holds the
@@ -64,9 +55,8 @@ export const consoleSidebarHtml = `<aside class="le-sidebar" aria-label="Console
64
55
  <a class="le-rail-item" href="/agents" data-le-nav-head="agents" data-le-section="agents">${AGENTS_ICON}<span>Agents</span></a>
65
56
  <a class="le-rail-item" href="/workflows" data-le-nav-head="workflows" data-le-section="workflows">${WORKFLOWS_ICON}<span>Workflows</span></a>
66
57
  <a class="le-rail-item" href="/schedules" data-le-nav-head="schedules" data-le-section="schedules">${SCHEDULES_ICON}<span>Schedules</span></a>
67
- <a class="le-rail-item" href="/audit" data-le-nav-head="audit" data-le-section="audit">${AUDIT_ICON}<span>Audit</span></a>
68
58
  <span class="le-rail-gap"></span>
69
- <button type="button" class="le-rail-item le-adv-toggle" id="leAdvToggle" aria-pressed="false" title="Advanced view: also show version history, evaluations, the contract, the API and agent internals">${ADVANCED_ICON}<span>Advanced</span></button>
59
+ <a class="le-rail-item" href="/audit" data-le-nav-head="audit" data-le-section="audit">${AUDIT_ICON}<span>Audit</span></a>
70
60
  <a class="le-rail-item" href="/config?section=settings" data-le-nav-head="settings" data-le-section="settings">${SETTINGS_ICON}<span>Settings</span></a>
71
61
  <div class="le-who" id="leWho" hidden></div>
72
62
  </nav>
@@ -89,7 +79,7 @@ export const consoleSidebarHtml = `<aside class="le-sidebar" aria-label="Console
89
79
  <nav class="le-settings-menu" aria-label="Settings">
90
80
  <a href="/config?section=models" data-le-nav="models">Models</a>
91
81
  <a href="/config?section=apps" data-le-nav="apps">Apps</a>
92
- <a href="/config?section=abilities" data-le-nav="abilities" data-advanced>Abilities</a>
82
+ <a href="/config?section=abilities" data-le-nav="abilities">Abilities</a>
93
83
  <a href="/config?section=settings" data-le-nav="settings">General settings</a>
94
84
  </nav>
95
85
  </section>
@@ -97,25 +87,10 @@ export const consoleSidebarHtml = `<aside class="le-sidebar" aria-label="Console
97
87
  </aside>`;
98
88
  export const consoleShellScript = `<script>
99
89
  (function () {
100
- // Simple view unless this person turned Advanced on.
101
- var advancedOn = false;
102
- try { advancedOn = localStorage.getItem('le-advanced') === '1'; } catch (e) {}
103
- document.documentElement.classList.toggle('le-simple', !advancedOn);
104
- var advToggle = document.getElementById('leAdvToggle');
105
- if (advToggle) {
106
- advToggle.setAttribute('aria-pressed', String(advancedOn));
107
- advToggle.addEventListener('click', function () {
108
- advancedOn = !advancedOn;
109
- try { localStorage.setItem('le-advanced', advancedOn ? '1' : '0'); } catch (e) {}
110
- document.documentElement.classList.toggle('le-simple', !advancedOn);
111
- advToggle.setAttribute('aria-pressed', String(advancedOn));
112
- document.dispatchEvent(new CustomEvent('le-advanced', { detail: advancedOn }));
113
- });
114
- }
115
90
  // A setting only the workspace's admin can change: said plainly, with
116
- // the technical how-to for Advanced view.
91
+ // the technical how-to.
117
92
  function adminNote(tech) {
118
- return '<p class="hint le-admin-note"><span data-simple>Only your workspace admin can change this.</span><span data-advanced>' + tech + '</span></p>';
93
+ return '<p class="hint le-admin-note">Only your workspace admin can change this. ' + tech + '</p>';
119
94
  }
120
95
  var page = document.body.getAttribute('data-le-page') || '';
121
96
  var params = new URLSearchParams(location.search);
@@ -137,9 +112,6 @@ export const consoleShellScript = `<script>
137
112
  ['schedules', 'Schedules'], ['chat', 'Chat'], ['actauth', 'Permissions'], ['env', 'Environment'], ['advanced', 'Advanced']
138
113
  ];
139
114
 
140
- // The agent tabs for Advanced view only.
141
- var ADVANCED_TABS = ['env', 'advanced'];
142
-
143
115
  function esc(s) {
144
116
  return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) {
145
117
  return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c];
@@ -351,12 +323,12 @@ export const consoleShellScript = `<script>
351
323
  var count = t[0] === 'env'
352
324
  ? '<span data-le-env-count="' + esc(opts.name) + '">' + envCountHtml(opts.name) + '</span>'
353
325
  : (counts[t[0]] != null ? '<span class="le-count">' + counts[t[0]] + '</span>' : '');
354
- return '<a class="le-tab" data-tab="' + t[0] + '" href="' + tabHref(opts.name, t[0]) + '" aria-selected="' + (t[0] === opts.tab) + '"' + (ADVANCED_TABS.indexOf(t[0]) !== -1 ? ' data-advanced' : '') + '>' + t[1] + count + '</a>';
326
+ return '<a class="le-tab" data-tab="' + t[0] + '" href="' + tabHref(opts.name, t[0]) + '" aria-selected="' + (t[0] === opts.tab) + '">' + t[1] + count + '</a>';
355
327
  }).join('');
356
328
  return '<div class="le-head"><div class="le-head-row">' +
357
329
  '<div class="le-title"><button type="button" class="le-menu-btn" data-le-menu aria-label="Open navigation">&#9776;</button>' +
358
330
  '<div style="min-width:0"><h1><span data-le-head-name>' + esc(opts.displayName || opts.name) + '</span>' +
359
- '<span class="le-head-id" data-le-head-id data-advanced' + (opts.displayName ? '' : ' hidden') + '>' + esc(opts.name) + '</span></h1>' + (opts.prompt ? '<p>' + esc(opts.prompt) + '</p>' : '') + '</div></div>' +
331
+ '<span class="le-head-id" data-le-head-id' + (opts.displayName ? '' : ' hidden') + '>' + esc(opts.name) + '</span></h1>' + (opts.prompt ? '<p>' + esc(opts.prompt) + '</p>' : '') + '</div></div>' +
360
332
  '<div class="le-chips">' + chips + '</div></div>' +
361
333
  '<nav class="le-tabs" aria-label="Agent sections">' + tabs + '</nav></div>';
362
334
  }
@@ -708,6 +680,6 @@ export const consoleShellScript = `<script>
708
680
  }
709
681
 
710
682
 
711
- window.leShell = { advanced: function () { return advancedOn; }, adminNote: adminNote, loadError: function () { return loadError; }, ready: ready, settings: function () { return settings; }, getJson: getJson, reloadGoals: reloadGoals, reloadJobs: reloadJobs, reloadWorkflows: reloadWorkflows, reloadInboxCount: reloadInboxCount, renderHead: renderHead, setTab: setTab, setActive: setActive, setDisplayName: setDisplayName, displayNameOf: displayNameOf, esc: esc, tabHref: tabHref, envCountHtml: envCountHtml, setCount: setCount, wireModelPicker: wireModelPicker, loadProviderKeys: loadProviderKeys, applyProviderKeys: applyProviderKeys, abilityOriginBadge: abilityOriginBadge, toggleAbilityDetails: toggleAbilityDetails };
683
+ window.leShell = { adminNote: adminNote, loadError: function () { return loadError; }, ready: ready, settings: function () { return settings; }, getJson: getJson, reloadGoals: reloadGoals, reloadJobs: reloadJobs, reloadWorkflows: reloadWorkflows, reloadInboxCount: reloadInboxCount, renderHead: renderHead, setTab: setTab, setActive: setActive, setDisplayName: setDisplayName, displayNameOf: displayNameOf, esc: esc, tabHref: tabHref, envCountHtml: envCountHtml, setCount: setCount, wireModelPicker: wireModelPicker, loadProviderKeys: loadProviderKeys, applyProviderKeys: applyProviderKeys, abilityOriginBadge: abilityOriginBadge, toggleAbilityDetails: toggleAbilityDetails };
712
684
  })();
713
685
  </script>`;
@@ -151,10 +151,6 @@ export const devUiCss = `
151
151
  .le-rail-item .le-inbox-count { position: absolute; top: 2px; right: 4px; margin: 0; padding: 0 5px; font-size: 10px; }
152
152
  .le-inbox-count[hidden] { display: none; }
153
153
  .le-rail-gap { flex: 1; }
154
- button.le-rail-item { border: 0; background: none; height: 40px; font: inherit; font-size: 11px; font-weight: 600; cursor: pointer; width: 100%; }
155
- .le-adv-toggle[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); }
156
- .le-simple [data-advanced] { display: none !important; }
157
- html:not(.le-simple) [data-simple] { display: none !important; }
158
154
  .le-nav-icon { width: 15px; height: 15px; flex-shrink: 0; }
159
155
  .le-panel { width: 228px; flex: none; display: flex; flex-direction: column; min-height: 0; padding-top: 14px; }
160
156
  .le-panel[hidden] { display: none; }
@@ -1024,7 +1024,7 @@ ${consoleShellScript}
1024
1024
  (si.dashboardUrl ? ' &middot; <a href="' + escapeHtml(si.dashboardUrl) + '">Dashboard</a>' : '')
1025
1025
  : si.mode === 'basic'
1026
1026
  ? 'Basic Auth (<code>LOOPENGINE_ADMIN_AUTH</code>)'
1027
- : '<span class="error">None: anyone who can reach this workspace can use it.</span><span class="hint" data-advanced> Set <code>LOOPENGINE_ADMIN_AUTH</code>.</span>';
1027
+ : '<span class="error">None: anyone who can reach this workspace can use it.</span><span class="hint"> Set <code>LOOPENGINE_ADMIN_AUTH</code>.</span>';
1028
1028
  var rows = [
1029
1029
  ['Admin sign-in', signIn],
1030
1030
  ['LoopEngine version', '<code>' + escapeHtml(d.version) + '</code>'],
@@ -1036,11 +1036,12 @@ ${consoleShellScript}
1036
1036
  ['Theme', 'Follows your system'],
1037
1037
  ];
1038
1038
  return '<section><table><thead><tr><th>Setting</th><th>Value</th></tr></thead><tbody>' +
1039
- rows.filter(Boolean).map(function (r) { return '<tr' + (r[2] ? ' data-advanced' : '') + '><td>' + r[0] + '</td><td>' + r[1] + '</td></tr>'; }).join('') +
1039
+ rows.filter(Boolean).map(function (r) { return '<tr><td>' + r[0] + '</td><td>' + r[1] + '</td></tr>'; }).join('') +
1040
1040
  '</tbody></table></section>' +
1041
1041
  (d.timeZone ? '<section><h3>Time zone</h3><div class="source" id="timeZoneBox"><p class="hint">Loading' + String.fromCharCode(8230) + '</p></div></section>' : '') +
1042
+ '<section><h3>Publishing</h3><div class="source" id="publishingBox"></div></section>' +
1042
1043
  '<section><h3>Shared policies</h3><div class="source" id="policiesBox"><p class="hint">Loading' + String.fromCharCode(8230) + '</p></div></section>' +
1043
- '<section data-advanced><h3>Private ability sources</h3><p class="muted" style="margin:0 0 10px">Where your own abilities come from, listed under Private on the Abilities page next to LoopEngine&#39;s official ones.</p><div class="source" id="abilitySourcesBox"><p class="hint">Loading' + String.fromCharCode(8230) + '</p></div></section>' +
1044
+ '<section><h3>Private ability sources</h3><p class="muted" style="margin:0 0 10px">Where your own abilities come from, listed under Private on the Abilities page next to LoopEngine&#39;s official ones.</p><div class="source" id="abilitySourcesBox"><p class="hint">Loading' + String.fromCharCode(8230) + '</p></div></section>' +
1044
1045
  '<section><h3>Updates</h3><div class="source" id="upgradeBox"><p class="hint">Checking for a newer LoopEngine' + String.fromCharCode(8230) + '</p></div></section>';
1045
1046
  }
1046
1047
 
@@ -1192,6 +1193,46 @@ ${consoleShellScript}
1192
1193
  });
1193
1194
  }
1194
1195
 
1196
+ // ---- Publishing: whether a change to what a workflow's runs do (its
1197
+ // prompt, inputs, model, result format, success criteria) can be
1198
+ // published in one click from the editor, or must be saved as a draft
1199
+ // and published after its review. Schedules, webhooks and where messages
1200
+ // go change straight away either way. ----
1201
+ function renderPublishing(d) {
1202
+ var box = document.getElementById('publishingBox');
1203
+ if (!box) return;
1204
+ var on = d.requireReview === true;
1205
+ var intro = '<p>Changes to what a workflow does (its prompt, inputs, model, result format and success criteria) become a new version when they' + String.fromCharCode(8217) + 're published. Schedules, webhooks and where messages go change straight away, and are recorded in Audit.</p>';
1206
+ if (!d.canChangeSettings) {
1207
+ box.innerHTML = intro + '<p>' + (on ? 'Review is required before publishing.' : 'Changes can be saved and published in one step.') + '</p>' +
1208
+ leShell.adminNote('Set <code>LOOPENGINE_ADMIN_AUTH</code> to change it here, or put <code>LOOPENGINE_REQUIRE_REVIEW=1</code> in .env.');
1209
+ return;
1210
+ }
1211
+ box.innerHTML = intro +
1212
+ '<label style="display:flex;gap:8px;align-items:flex-start;max-width:560px"><input type="checkbox" id="requireReview"' + (on ? ' checked' : '') + ' style="margin-top:3px">' +
1213
+ '<span><strong>Require review before publishing</strong><br><span class="hint">Every change is saved as a draft first, then published from Review and publish. Off, the editor also offers Save and publish.</span></span></label>' +
1214
+ '<div id="publishingMsg" class="hint" style="margin-top:8px"></div>';
1215
+ var box2 = document.getElementById('requireReview');
1216
+ box2.addEventListener('change', function () {
1217
+ var msg = document.getElementById('publishingMsg');
1218
+ box2.disabled = true;
1219
+ msg.textContent = 'Saving' + String.fromCharCode(8230);
1220
+ fetch('/config/publishing', {
1221
+ method: 'PUT',
1222
+ headers: { 'content-type': 'application/json' },
1223
+ body: JSON.stringify({ requireReview: box2.checked }),
1224
+ })
1225
+ .then(function (r) { return r.json().then(function (b) { return { ok: r.ok, body: b }; }); })
1226
+ .then(function (r) {
1227
+ box2.disabled = false;
1228
+ if (!r.ok) { box2.checked = !box2.checked; msg.innerHTML = '<span class="error">' + escapeHtml(r.body.error || 'Could not save') + '</span>'; return; }
1229
+ box2.checked = r.body.requireReview === true;
1230
+ msg.textContent = r.body.requireReview ? 'Saved: changes now wait for review.' : 'Saved: changes can be published in one step.';
1231
+ })
1232
+ .catch(function (err) { box2.disabled = false; box2.checked = !box2.checked; msg.innerHTML = '<span class="error">' + escapeHtml(err.message) + '</span>'; });
1233
+ });
1234
+ }
1235
+
1195
1236
  // ---- Shared policies: the business's rules every workflow run reads,
1196
1237
  // above its own instructions (policies.md in the project). ----
1197
1238
  function renderPolicies(p) {
@@ -1416,6 +1457,7 @@ ${consoleShellScript}
1416
1457
  .then(function (d) {
1417
1458
  content.innerHTML = renderSettings(d);
1418
1459
  loadedSections.settings = true;
1460
+ renderPublishing(d);
1419
1461
  loadTimeZone();
1420
1462
  loadPolicies();
1421
1463
  loadAbilitySources();
@@ -160,3 +160,11 @@ export declare function setWorkspaceTimeZone(value: unknown, options?: {
160
160
  timeZone: string;
161
161
  moved: number;
162
162
  }>;
163
+ /** Settings → Publishing: whether a workflow's changes must go through
164
+ * Review and publish. Off (the default), the editor, the success
165
+ * criteria and Self-Improve also offer Save and publish in one click; on,
166
+ * every change to what a run does is saved as a draft and published only
167
+ * after its review. Saved like the time zone (the project's .env). */
168
+ export declare const REQUIRE_REVIEW_ENV = "LOOPENGINE_REQUIRE_REVIEW";
169
+ export declare function requireReview(): boolean;
170
+ export declare function setRequireReview(on: boolean): Promise<boolean>;
@@ -328,3 +328,19 @@ export async function setWorkspaceTimeZone(value, options = {}) {
328
328
  const moved = options.moveSchedules && timeZone !== before ? await moveScheduledTasksToTimeZone(before, timeZone) : 0;
329
329
  return { timeZone, moved };
330
330
  }
331
+ /** Settings → Publishing: whether a workflow's changes must go through
332
+ * Review and publish. Off (the default), the editor, the success
333
+ * criteria and Self-Improve also offer Save and publish in one click; on,
334
+ * every change to what a run does is saved as a draft and published only
335
+ * after its review. Saved like the time zone (the project's .env). */
336
+ export const REQUIRE_REVIEW_ENV = 'LOOPENGINE_REQUIRE_REVIEW';
337
+ export function requireReview() {
338
+ return /^(1|true|yes|on)$/i.test(process.env[REQUIRE_REVIEW_ENV]?.trim() ?? '');
339
+ }
340
+ export async function setRequireReview(on) {
341
+ if (on)
342
+ await setEnvVar(REQUIRE_REVIEW_ENV, '1');
343
+ else
344
+ await unsetEnvVar(REQUIRE_REVIEW_ENV);
345
+ return requireReview();
346
+ }
@@ -13,9 +13,9 @@
13
13
  // + Add schedule opens Create schedule: which workflow, its name, how
14
14
  // often (an interval, daily at a time, weekly on a day, or once), whether
15
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.
16
+ // every run. It starts at once (POST /agents/:name/schedules): a schedule
17
+ // is how a workflow starts, not what it does, so it has no draft, and the
18
+ // change is in Audit.
19
19
  //
20
20
  // Its data is each agent's /agents/:name/schedules. Like the other
21
21
  // console pages, its inline script avoids backslashes and template
@@ -174,7 +174,7 @@ ${consoleSidebarHtml}
174
174
  </div>
175
175
  <div class="sc-dlg-col">
176
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>
177
+ <div class="sc-field"><span class="sc-field-k">When it starts</span><p class="hint">Right away: the first run is at the next time you chose. Switch it off on its card to pause it.</p></div>
178
178
  </div>
179
179
  </div>
180
180
  <div class="sc-dlg-foot" id="scFoot"></div>
@@ -530,25 +530,13 @@ ${consoleShellScript}
530
530
  var save = document.getElementById('scSave');
531
531
  save.disabled = true;
532
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) {
533
+ // Live at once: a schedule is how a workflow starts, not what it does,
534
+ // so it needs no draft (and is in Audit).
535
+ body.workflow_id = w.id;
536
+ api('POST', '/agents/' + encodeURIComponent(w.agent) + '/schedules', body).then(function (r) {
535
537
  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
- });
538
+ dlg.close();
539
+ load();
552
540
  });
553
541
  });
554
542
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loopengine",
3
- "version": "0.5.8",
3
+ "version": "0.5.9",
4
4
  "type": "module",
5
5
  "description": "Runtime for tool-using AI agents with a transparent ReAct loop.",
6
6
  "license": "MIT",