loopengine 0.3.92 → 0.3.94
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/core/workflow-runs.d.ts +1 -1
- package/dist/core/workflow-runs.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/web/agents-config-page.js +102 -197
- package/dist/web/console-shell.js +29 -19
- package/dist/web/inbox-page.js +28 -11
- package/dist/web/markdown-script.d.ts +1 -0
- package/dist/web/markdown-script.js +170 -0
- package/dist/web/response-compression.d.ts +6 -0
- package/dist/web/response-compression.js +177 -0
- package/dist/web/workflows-overview-page.js +4 -2
- package/package.json +1 -1
|
@@ -174,7 +174,7 @@ export declare class WorkflowRunner {
|
|
|
174
174
|
task_name?: string;
|
|
175
175
|
message: string;
|
|
176
176
|
session_id: string;
|
|
177
|
-
} & Pick<StartRunInput, 'callback_url' | 'decisions_to' | 'chat_notice' | 'warnings'>): Promise<RunOutcome>;
|
|
177
|
+
} & Pick<StartRunInput, 'result_to_chat' | 'callback_url' | 'decisions_to' | 'chat_notice' | 'warnings'>): Promise<RunOutcome>;
|
|
178
178
|
/** Waits for the runs this process has started (tests, shutdown). */
|
|
179
179
|
idle(): Promise<void>;
|
|
180
180
|
/** How many runs are executing right now (for idle-shutdown checks). */
|
|
@@ -163,6 +163,7 @@ export class WorkflowRunner {
|
|
|
163
163
|
source: 'schedule',
|
|
164
164
|
task_id: input.task_id,
|
|
165
165
|
...(input.task_name ? { task_name: input.task_name } : {}),
|
|
166
|
+
...(input.result_to_chat ? { result_to_chat: true } : {}),
|
|
166
167
|
...(input.callback_url ? { callback_url: input.callback_url } : {}),
|
|
167
168
|
...(input.decisions_to ? { decisions_to: input.decisions_to } : {}),
|
|
168
169
|
...(input.chat_notice ? { chat_notice: input.chat_notice } : {}),
|
package/dist/index.d.ts
CHANGED
|
@@ -136,6 +136,7 @@ export { LEVERS, PLAYBOOK_VERSION, activePlaybook, setPlaybookProjectDir, type L
|
|
|
136
136
|
export { startPlaybookSync, syncPlaybook, playbookSyncConfig } from './core/playbook-sync.js';
|
|
137
137
|
export { workspaceRole, canDecide, inboxOnly, inboxOnlyAllows, roleLabel, agentsFor, type WorkspaceRole } from './core/workspace-roles.js';
|
|
138
138
|
export { inboxPageHtml, renderInboxOnlyPage } from './web/inbox-page.js';
|
|
139
|
+
export { compressResponses, serveConsoleAsset } from './web/response-compression.js';
|
|
139
140
|
export { workflowsOverviewPageHtml } from './web/workflows-overview-page.js';
|
|
140
141
|
export { workflowsOverview, startsOf, type WorkflowsOverview, type WorkflowOverviewRow } from './web/workflows-overview.js';
|
|
141
142
|
export { listInbox, getInboxCase, timelineOf, type InboxDeps, type InboxItem, type InboxCase, type InboxPending, type InboxStep } from './web/inbox-admin.js';
|
package/dist/index.js
CHANGED
|
@@ -127,6 +127,7 @@ export { LEVERS, PLAYBOOK_VERSION, activePlaybook, setPlaybookProjectDir } from
|
|
|
127
127
|
export { startPlaybookSync, syncPlaybook, playbookSyncConfig } from './core/playbook-sync.js';
|
|
128
128
|
export { workspaceRole, canDecide, inboxOnly, inboxOnlyAllows, roleLabel, agentsFor } from './core/workspace-roles.js';
|
|
129
129
|
export { inboxPageHtml, renderInboxOnlyPage } from './web/inbox-page.js';
|
|
130
|
+
export { compressResponses, serveConsoleAsset } from './web/response-compression.js';
|
|
130
131
|
export { workflowsOverviewPageHtml } from './web/workflows-overview-page.js';
|
|
131
132
|
export { workflowsOverview, startsOf } from './web/workflows-overview.js';
|
|
132
133
|
export { listInbox, getInboxCase, timelineOf } from './web/inbox-admin.js';
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
import { WORKFLOW_SECTIONS_CSS, WORKFLOW_SECTIONS_SCRIPT } from './workflow-sections.js';
|
|
29
29
|
import { devUiCss } from './dev-ui-styles.js';
|
|
30
30
|
import { MESSAGING_ICONS } from './messaging-icons.js';
|
|
31
|
+
import { renderMarkdownScript } from './markdown-script.js';
|
|
31
32
|
import { consoleShellScript, consoleSidebarHtml } from './console-shell.js';
|
|
32
33
|
import { REASONING_PROVIDERS } from './agent-file-admin.js';
|
|
33
34
|
export const agentsConfigPageHtml = `<!doctype html>
|
|
@@ -120,14 +121,27 @@ export const agentsConfigPageHtml = `<!doctype html>
|
|
|
120
121
|
.wf-tab:hover:not(:disabled) { background: none; color: var(--ink); }
|
|
121
122
|
.wf-tab[aria-selected="true"] { color: var(--accent-ink); border-bottom-color: var(--accent); }
|
|
122
123
|
.wf-msg-form { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
|
|
123
|
-
.wf-msg-
|
|
124
|
-
.wf-msg-
|
|
125
|
-
.wf-msg-
|
|
126
|
-
.wf-msg-
|
|
127
|
-
.wf-msg-
|
|
124
|
+
.wf-msg-dests { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
|
|
125
|
+
.wf-msg-dest { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
|
|
126
|
+
.wf-msg-dest-k { font-weight: 600; font-size: 13px; }
|
|
127
|
+
.wf-msg-dest input[name="msgUrl"] { margin-top: 4px; }
|
|
128
|
+
.wf-msg-grid-wrap { overflow-x: auto; }
|
|
129
|
+
.wf-msg-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
130
|
+
.wf-msg-grid th, .wf-msg-grid td { padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: top; }
|
|
131
|
+
.wf-msg-grid thead th { border-top: 0; font-weight: 600; text-align: center; }
|
|
132
|
+
.wf-msg-grid th { background: none; }
|
|
133
|
+
.wf-msg-grid tbody th { text-align: left; font-weight: 600; }
|
|
134
|
+
.wf-msg-grid tbody th .hint { font-weight: 400; }
|
|
135
|
+
.wf-msg-grid td { text-align: center; width: 110px; }
|
|
136
|
+
.wf-msg-cell { display: inline-flex; justify-content: center; }
|
|
137
|
+
.wf-msg-cell input { width: auto; margin: 0; }
|
|
138
|
+
.wf-msg-appcell.is-off { opacity: .35; }
|
|
139
|
+
.wf-msg-notice { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; font-weight: 400; }
|
|
140
|
+
.wf-msg-notice[hidden] { display: none; }
|
|
141
|
+
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
128
142
|
.wf-msg-own { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
|
|
129
143
|
.wf-msg-foot { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
|
|
130
|
-
@media (max-width: 640px) { .wf-msg-
|
|
144
|
+
@media (max-width: 640px) { .wf-msg-dests { grid-template-columns: 1fr; } .wf-msg-grid td { width: 64px; } }
|
|
131
145
|
.wf-tab-count { margin-left: 4px; font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--ink-muted); }
|
|
132
146
|
.wf-row .workflow-steps-text { margin: 0; padding: 12px 14px; border-radius: 8px; background: var(--surface); font-size: 13px; line-height: 1.6; max-height: 420px; overflow: auto; white-space: pre-wrap; }
|
|
133
147
|
.wf-original { margin-top: 10px; }
|
|
@@ -686,162 +700,7 @@ ${consoleShellScript}
|
|
|
686
700
|
return attempt().catch(function () { return attempt(); });
|
|
687
701
|
}
|
|
688
702
|
|
|
689
|
-
|
|
690
|
-
// the skill Body field's Preview toggle (see wireSkillsHandlers) — this
|
|
691
|
-
// page stays a self-contained string, no build step, no CDN (same
|
|
692
|
-
// reasoning as devUiCss's own header comment), so pulling in a real
|
|
693
|
-
// markdown library isn't an option without breaking that. Covers what
|
|
694
|
-
// an actual SKILL.md body realistically uses (headings, bold/italic,
|
|
695
|
-
// inline code, fenced code blocks, links, lists, rules, paragraphs) —
|
|
696
|
-
// good enough for "does this read the way it will on GitHub", not a
|
|
697
|
-
// spec-complete parser. Escapes first, so no markdown source can inject
|
|
698
|
-
// raw HTML into the preview.
|
|
699
|
-
function renderMarkdownPreview(md) {
|
|
700
|
-
var lines = escapeHtml(md).split('\\n');
|
|
701
|
-
var html = '';
|
|
702
|
-
var inCode = false;
|
|
703
|
-
var codeBuffer = '';
|
|
704
|
-
var listType = null;
|
|
705
|
-
var paragraph = [];
|
|
706
|
-
|
|
707
|
-
// This whole page is one outer TS template literal AND its output is
|
|
708
|
-
// itself served as JS source text a browser then parses again — two
|
|
709
|
-
// layers of "escape sequences get processed", not one. The unicode
|
|
710
|
-
// escape used for the backtick patterns below survives both layers fine, since
|
|
711
|
-
// it's a real, recognized escape at both of them. A star/bracket/
|
|
712
|
-
// paren/s/d/dot escape (\*, \[, \s, \d, \.) is *not* a recognized
|
|
713
|
-
// escape at either layer, so each layer that touches it silently
|
|
714
|
-
// drops the backslash and keeps just the character — confirmed by
|
|
715
|
-
// extracting and executing the actually-served page during
|
|
716
|
-
// development, where every regex built the "obvious" way here ended
|
|
717
|
-
// up with its escapes stripped entirely, sometimes still parsing
|
|
718
|
-
// (silently wrong) and sometimes throwing ("nothing to repeat").
|
|
719
|
-
// Building these particular patterns from a runtime backslash
|
|
720
|
-
// character instead sidesteps the whole problem: there is no
|
|
721
|
-
// backslash-followed-by-letter sequence anywhere in this source for
|
|
722
|
-
// either layer to misinterpret.
|
|
723
|
-
var bs = String.fromCharCode(92);
|
|
724
|
-
var inlineCodePattern = new RegExp('\\u0060([^\\u0060]+)\\u0060', 'g');
|
|
725
|
-
var fencePattern = new RegExp('^\\u0060\\u0060\\u0060');
|
|
726
|
-
var boldPattern = new RegExp(bs + '*' + bs + '*([^*]+)' + bs + '*' + bs + '*', 'g');
|
|
727
|
-
var italicPattern = new RegExp(bs + '*([^*]+)' + bs + '*', 'g');
|
|
728
|
-
var linkPattern = new RegExp(bs + '[([^' + bs + ']]+)' + bs + ']' + bs + '(([^)]+)' + bs + ')', 'g');
|
|
729
|
-
var headingPattern = new RegExp('^(#{1,6})' + bs + 's+(.*)$');
|
|
730
|
-
var hrPattern = new RegExp('^(---|' + bs + '*' + bs + '*' + bs + '*)' + bs + 's*$');
|
|
731
|
-
var ulPattern = new RegExp('^[-*]' + bs + 's+(.*)$');
|
|
732
|
-
var olPattern = new RegExp('^' + bs + 'd+' + bs + '.' + bs + 's+(.*)$');
|
|
733
|
-
function inlineFormat(text) {
|
|
734
|
-
return text
|
|
735
|
-
.replace(inlineCodePattern, '<code>$1</code>')
|
|
736
|
-
.replace(boldPattern, '<strong>$1</strong>')
|
|
737
|
-
.replace(italicPattern, '<em>$1</em>')
|
|
738
|
-
.replace(linkPattern, function (_, label, href) {
|
|
739
|
-
var lowerHref = href.toLowerCase();
|
|
740
|
-
var safeHref = lowerHref.indexOf('https://') === 0 || lowerHref.indexOf('http://') === 0 || lowerHref.indexOf('mailto:') === 0;
|
|
741
|
-
return safeHref ? '<a href="' + href + '" target="_blank" rel="noopener noreferrer">' + label + '</a>' : label;
|
|
742
|
-
});
|
|
743
|
-
}
|
|
744
|
-
function flushParagraph() {
|
|
745
|
-
if (paragraph.length) {
|
|
746
|
-
html += '<p>' + inlineFormat(paragraph.join(' ')) + '</p>';
|
|
747
|
-
paragraph = [];
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
function closeList() {
|
|
751
|
-
if (listType) {
|
|
752
|
-
html += '</' + listType + '>';
|
|
753
|
-
listType = null;
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
function tableCells(line) {
|
|
757
|
-
var value = line.trim();
|
|
758
|
-
if (value.charAt(0) === '|') value = value.slice(1);
|
|
759
|
-
if (value.charAt(value.length - 1) === '|') value = value.slice(0, -1);
|
|
760
|
-
return value.split('|').map(function (cell) { return cell.trim(); });
|
|
761
|
-
}
|
|
762
|
-
function isTableDivider(line) {
|
|
763
|
-
if (line.indexOf('|') < 0) return false;
|
|
764
|
-
var cells = tableCells(line);
|
|
765
|
-
return cells.length > 0 && cells.every(function (cell) {
|
|
766
|
-
var value = cell.replace(/:/g, '').replace(/-/g, '').trim();
|
|
767
|
-
return cell.indexOf('-') >= 0 && value === '';
|
|
768
|
-
});
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
for (var i = 0; i < lines.length; i++) {
|
|
772
|
-
var line = lines[i];
|
|
773
|
-
if (fencePattern.test(line)) {
|
|
774
|
-
if (!inCode) {
|
|
775
|
-
flushParagraph();
|
|
776
|
-
closeList();
|
|
777
|
-
inCode = true;
|
|
778
|
-
codeBuffer = '';
|
|
779
|
-
} else {
|
|
780
|
-
html += '<pre><code>' + codeBuffer + '</code></pre>';
|
|
781
|
-
inCode = false;
|
|
782
|
-
}
|
|
783
|
-
continue;
|
|
784
|
-
}
|
|
785
|
-
if (inCode) {
|
|
786
|
-
codeBuffer += line + '\\n';
|
|
787
|
-
continue;
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
if (line.indexOf('|') >= 0 && i + 1 < lines.length && isTableDivider(lines[i + 1])) {
|
|
791
|
-
flushParagraph();
|
|
792
|
-
closeList();
|
|
793
|
-
var headers = tableCells(line);
|
|
794
|
-
html += '<div class="workflow-markdown-table"><table><thead><tr>' + headers.map(function (cell) { return '<th>' + inlineFormat(cell) + '</th>'; }).join('') + '</tr></thead><tbody>';
|
|
795
|
-
i += 2;
|
|
796
|
-
while (i < lines.length && lines[i].indexOf('|') >= 0 && lines[i].trim() !== '') {
|
|
797
|
-
var cells = tableCells(lines[i]);
|
|
798
|
-
html += '<tr>' + headers.map(function (_, index) { return '<td>' + inlineFormat(cells[index] || '') + '</td>'; }).join('') + '</tr>';
|
|
799
|
-
i++;
|
|
800
|
-
}
|
|
801
|
-
html += '</tbody></table></div>';
|
|
802
|
-
i--;
|
|
803
|
-
continue;
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
var heading = line.match(headingPattern);
|
|
807
|
-
if (heading) {
|
|
808
|
-
flushParagraph();
|
|
809
|
-
closeList();
|
|
810
|
-
var level = heading[1].length;
|
|
811
|
-
html += '<h' + level + '>' + inlineFormat(heading[2]) + '</h' + level + '>';
|
|
812
|
-
continue;
|
|
813
|
-
}
|
|
814
|
-
if (hrPattern.test(line)) {
|
|
815
|
-
flushParagraph();
|
|
816
|
-
closeList();
|
|
817
|
-
html += '<hr>';
|
|
818
|
-
continue;
|
|
819
|
-
}
|
|
820
|
-
var ul = line.match(ulPattern);
|
|
821
|
-
var ol = line.match(olPattern);
|
|
822
|
-
if (ul || ol) {
|
|
823
|
-
flushParagraph();
|
|
824
|
-
var wantType = ul ? 'ul' : 'ol';
|
|
825
|
-
if (listType !== wantType) {
|
|
826
|
-
closeList();
|
|
827
|
-
html += '<' + wantType + '>';
|
|
828
|
-
listType = wantType;
|
|
829
|
-
}
|
|
830
|
-
html += '<li>' + inlineFormat((ul || ol)[1]) + '</li>';
|
|
831
|
-
continue;
|
|
832
|
-
}
|
|
833
|
-
closeList();
|
|
834
|
-
|
|
835
|
-
if (line.trim() === '') {
|
|
836
|
-
flushParagraph();
|
|
837
|
-
continue;
|
|
838
|
-
}
|
|
839
|
-
paragraph.push(line.trim());
|
|
840
|
-
}
|
|
841
|
-
flushParagraph();
|
|
842
|
-
closeList();
|
|
843
|
-
return html || '<p class="hint">Nothing to preview yet.</p>';
|
|
844
|
-
}
|
|
703
|
+
${renderMarkdownScript}
|
|
845
704
|
|
|
846
705
|
// ---- Overview tab ----
|
|
847
706
|
|
|
@@ -970,7 +829,7 @@ ${consoleShellScript}
|
|
|
970
829
|
'</div>';
|
|
971
830
|
}
|
|
972
831
|
|
|
973
|
-
var APP_NAMES = { slack: 'Slack', lark: 'Lark', webhook: 'Webhook', email: 'Email', database: 'Database', redis: 'Redis' };
|
|
832
|
+
var APP_NAMES = { slack: 'Slack', telegram: 'Telegram', lark: 'Lark', webhook: 'Webhook', email: 'Email', database: 'Database', redis: 'Redis' };
|
|
974
833
|
|
|
975
834
|
// Messaging and Schedules come from their own endpoints, so their
|
|
976
835
|
// cards are filled in once those answer. Called after every render of
|
|
@@ -1148,34 +1007,58 @@ ${consoleShellScript}
|
|
|
1148
1007
|
return ['slack', 'telegram', 'lark'].indexOf(workflowsMeta.messaging) !== -1 ? workflowChatName() : null;
|
|
1149
1008
|
}
|
|
1150
1009
|
|
|
1151
|
-
// Its Messages tab: where every run's
|
|
1152
|
-
//
|
|
1153
|
-
//
|
|
1010
|
+
// Its Messages tab: where every run's messages go, however it starts,
|
|
1011
|
+
// as a grid of what happens in a run (rows) by where it can go
|
|
1012
|
+
// (columns): the agent's messaging app, the Inbox and your app's
|
|
1013
|
+
// address. What can't be turned off is shown ticked and locked: the
|
|
1014
|
+
// Inbox keeps every run (web/inbox-admin.ts); your app gets nothing
|
|
1015
|
+
// without an address, and with one gets every decision, finish and
|
|
1016
|
+
// failure (adapters/http.ts, reportWorkflowRun).
|
|
1154
1017
|
function workflowMessagesHtml(w, agentName) {
|
|
1155
1018
|
var d = w.delivery || {};
|
|
1156
|
-
var chat = workflowChatAppName();
|
|
1157
|
-
var chatLabel = escapeHtml(chat || 'chat');
|
|
1158
|
-
// With no messaging app, an unattended run's approvals and questions
|
|
1159
|
-
// wait in the Inbox (adapters/http.ts, executeUnattendedRun).
|
|
1160
|
-
var decisionsLabel = workflowChatName() ? escapeHtml(workflowChatName())
|
|
1161
|
-
: 'The Inbox <span class="hint">(no messaging app is set up, so they wait in the Inbox)</span>';
|
|
1162
|
-
var noChat = chat ? '' : ' disabled';
|
|
1163
1019
|
var RSQ = String.fromCharCode(8217);
|
|
1164
|
-
var
|
|
1020
|
+
var chatName = workflowChatName();
|
|
1021
|
+
var chat = workflowChatAppName();
|
|
1022
|
+
var chatCol = escapeHtml(chatName || 'Messaging app');
|
|
1023
|
+
var toApp = d.decisions_to === 'callback';
|
|
1024
|
+
var box = function (name, checked, locked, label, extra) {
|
|
1025
|
+
return '<label class="wf-msg-cell"><input type="checkbox"' + (name ? ' name="' + name + '"' : '') + (checked ? ' checked' : '') + (locked ? ' disabled' : '') + ' aria-label="' + label + '"' + (extra || '') + '></label>';
|
|
1026
|
+
};
|
|
1027
|
+
var none = '<span class="wf-msg-cell hint" aria-label="Not sent">' + String.fromCharCode(8212) + '</span>';
|
|
1028
|
+
var always = function (label) { return box('', true, true, label + ': always'); };
|
|
1029
|
+
var appCell = function (key, label) { return '<span class="wf-msg-appcell" data-app="' + key + '">' + box('', Boolean(d.callback_url), true, label + ', when an address is set') + '</span>'; };
|
|
1030
|
+
var row = function (what, hint, chatCell, inboxCell, appCellHtml, below) {
|
|
1031
|
+
return '<tr><th scope="row"><div>' + what + '</div><div class="hint">' + hint + '</div>' + (below || '') + '</th>' +
|
|
1032
|
+
'<td>' + chatCell + '</td><td>' + inboxCell + '</td><td>' + appCellHtml + '</td></tr>';
|
|
1033
|
+
};
|
|
1165
1034
|
// Webhooks saved with settings of their own: their runs use those.
|
|
1166
1035
|
var own = (w.triggers || []).filter(function (t) { return t.callback || t.decisions_to || t.chat_notice || t.result_to_chat; });
|
|
1167
1036
|
return '<form class="wf-msg-form">' +
|
|
1168
|
-
'<p class="hint" style="margin:0
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
'<
|
|
1174
|
-
'<
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
'
|
|
1037
|
+
'<p class="hint" style="margin:0">Where this workflow' + RSQ + 's messages go, for every run: started by Run now, a schedule, a webhook or the API. A ticked, greyed box can' + RSQ + 't be turned off. Your app gets nothing until you give it an address.</p>' +
|
|
1038
|
+
'<div class="wf-msg-dests">' +
|
|
1039
|
+
'<div class="wf-msg-dest"><div class="wf-msg-dest-k">' + chatCol + '</div><div class="hint">' +
|
|
1040
|
+
(chatName ? 'The agent' + RSQ + 's messaging app, set in its <a href="?agent=' + encodeURIComponent(agentName) + '&tab=messaging">Messaging</a> tab.'
|
|
1041
|
+
: 'Not set up. <a href="?agent=' + encodeURIComponent(agentName) + '&tab=messaging">Set one up in Messaging</a> (Slack, Telegram or Lark) to post to chat.') + '</div></div>' +
|
|
1042
|
+
'<div class="wf-msg-dest"><div class="wf-msg-dest-k">Inbox</div><div class="hint">Always. Every run is kept as a case, and approvals and questions can be answered there.</div></div>' +
|
|
1043
|
+
'<div class="wf-msg-dest"><div class="wf-msg-dest-k">Your app</div><div class="hint">Optional. Only when you set an address: it then gets each update as signed JSON (a webhook).</div>' +
|
|
1044
|
+
'<input name="msgUrl" inputmode="url" placeholder="https://example.com/hooks/loopengine" value="' + escapeHtml(d.callback_url || '') + '"></div>' +
|
|
1045
|
+
'</div>' +
|
|
1046
|
+
'<div class="wf-msg-grid-wrap"><table class="wf-msg-grid"><thead><tr><th scope="col"><span class="sr-only">When</span></th><th scope="col">' + chatCol + '</th><th scope="col">Inbox</th><th scope="col">Your app</th></tr></thead><tbody>' +
|
|
1047
|
+
row('A run starts', 'A short note that it began.',
|
|
1048
|
+
chat ? box('msgNoticeOn', Boolean(d.chat_notice), false, 'Post a start note to ' + chatCol) : none,
|
|
1049
|
+
always('Shown in the Inbox'),
|
|
1050
|
+
'<span class="wf-msg-appcell" data-app="start">' + box('', toApp, true, 'Sent to your app when it answers approvals and questions') + '</span>',
|
|
1051
|
+
chat ? '<div class="wf-msg-notice"' + (d.chat_notice ? '' : ' hidden') + '><input name="msgNotice" maxlength="1000" placeholder="Run started" value="' + escapeHtml(d.chat_notice || '') + '"><span class="hint">{{name}} puts in an input' + RSQ + 's value.</span></div>' : '') +
|
|
1052
|
+
row('Approvals and questions', 'Someone answers in one place; the Inbox can always answer too.',
|
|
1053
|
+
chatName ? box('msgDecisionsChat', !toApp, !d.callback_url, 'Send approvals and questions to ' + chatCol, ' data-locked-without-app="1"') : none,
|
|
1054
|
+
always('Approvals and questions in the Inbox'),
|
|
1055
|
+
appCell('decisions', 'Approvals and questions sent to your app')) +
|
|
1056
|
+
row('A run finishes or fails', 'Its result, or what went wrong.',
|
|
1057
|
+
chatName ? box('msgResult', Boolean(d.result_to_chat), false, 'Post the result to ' + chatCol) : none,
|
|
1058
|
+
always('Results in the Inbox'),
|
|
1059
|
+
appCell('finish', 'Results sent to your app')) +
|
|
1060
|
+
'</tbody></table></div>' +
|
|
1061
|
+
'<p class="hint wf-msg-decide-note" style="margin:0"></p>' +
|
|
1179
1062
|
(own.length
|
|
1180
1063
|
? '<div class="wf-msg-own">' + own.map(function (t) {
|
|
1181
1064
|
return '<p class="hint" style="margin:0">The ' + escapeHtml(t.name) + ' webhook has settings of its own, so its runs use those instead. ' +
|
|
@@ -1196,7 +1079,7 @@ ${consoleShellScript}
|
|
|
1196
1079
|
};
|
|
1197
1080
|
return '<div class="wf-ways">' +
|
|
1198
1081
|
way('run', 'Run now', 'Starts a run right away, from here. It shows under Evidence as it goes.', workflowRunBarHtml(w, params)) +
|
|
1199
|
-
way('schedule', 'Schedule', 'Runs it on a timer, like every day at 9:00. Approvals and questions go
|
|
1082
|
+
way('schedule', 'Schedule', 'Runs it on a timer, like every day at 9:00. Approvals and questions go where its Messages tab says.',
|
|
1200
1083
|
(schedules || '<p class="hint" style="margin:0">None yet.</p>') +
|
|
1201
1084
|
'<div><button type="button" class="workflow-add-schedule">+ Schedule</button></div>') +
|
|
1202
1085
|
way('webhook', 'Webhook', 'Another app (Stripe, GitHub, Shopify or your own) calls a private address when something happens, and each call starts a run.',
|
|
@@ -1957,25 +1840,47 @@ ${consoleShellScript}
|
|
|
1957
1840
|
var msgForm = card.querySelector('.wf-msg-form');
|
|
1958
1841
|
if (msgForm) {
|
|
1959
1842
|
var msgResult = msgForm.querySelector('.wf-msg-result');
|
|
1960
|
-
var
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1843
|
+
var decideChat = msgForm.msgDecisionsChat || null;
|
|
1844
|
+
var decideNote = msgForm.querySelector('.wf-msg-decide-note');
|
|
1845
|
+
var hasChat = Boolean(decideChat);
|
|
1846
|
+
// Your app's column follows its address; approvals and questions
|
|
1847
|
+
// can leave the chat app only for an address that's given, and
|
|
1848
|
+
// your app hears of a run starting only when it answers them.
|
|
1849
|
+
var syncMsgForm = function () {
|
|
1850
|
+
var url = msgForm.msgUrl.value.trim();
|
|
1851
|
+
var toApp = Boolean(url) && (!hasChat || !decideChat.checked);
|
|
1852
|
+
if (decideChat) {
|
|
1853
|
+
decideChat.disabled = !url;
|
|
1854
|
+
if (!url) decideChat.checked = true;
|
|
1855
|
+
}
|
|
1856
|
+
msgForm.querySelectorAll('.wf-msg-appcell').forEach(function (cell) {
|
|
1857
|
+
var input = cell.querySelector('input');
|
|
1858
|
+
var on = Boolean(url) && (cell.dataset.app !== 'start' || toApp);
|
|
1859
|
+
input.checked = on;
|
|
1860
|
+
cell.classList.toggle('is-off', !url);
|
|
1861
|
+
});
|
|
1862
|
+
decideNote.textContent = !url
|
|
1863
|
+
? (hasChat ? 'Add your app' + String.fromCharCode(8217) + 's address to answer approvals and questions there instead.' : 'With no messaging app, approvals and questions wait in the Inbox.')
|
|
1864
|
+
: toApp ? 'Your app answers approvals and questions (through the API), and gets a note when each run starts.' + (hasChat ? ' Nothing goes to chat for them.' : '')
|
|
1865
|
+
: 'Approvals and questions are answered in chat; your app is told about them too.';
|
|
1866
|
+
};
|
|
1867
|
+
msgForm.msgUrl.addEventListener('input', syncMsgForm);
|
|
1868
|
+
if (decideChat) decideChat.addEventListener('change', syncMsgForm);
|
|
1869
|
+
if (msgForm.msgNoticeOn) msgForm.msgNoticeOn.addEventListener('change', function () {
|
|
1870
|
+
var notice = msgForm.querySelector('.wf-msg-notice');
|
|
1871
|
+
notice.hidden = !msgForm.msgNoticeOn.checked;
|
|
1968
1872
|
if (msgForm.msgNoticeOn.checked) msgForm.msgNotice.focus();
|
|
1969
1873
|
});
|
|
1874
|
+
syncMsgForm();
|
|
1970
1875
|
var reloadOnMessages = function () { workflowTabs[id] = 'messages'; loadWorkflowsSection(name); };
|
|
1971
1876
|
msgForm.addEventListener('submit', function (ev) {
|
|
1972
1877
|
ev.preventDefault();
|
|
1973
1878
|
var url = msgForm.msgUrl.value.trim();
|
|
1974
1879
|
var body = {};
|
|
1975
1880
|
if (url) body.callback_url = url;
|
|
1976
|
-
if (url &&
|
|
1977
|
-
if (msgForm.msgNoticeOn.checked && msgForm.msgNotice.value.trim()) body.chat_notice = msgForm.msgNotice.value.trim();
|
|
1978
|
-
if (msgForm.msgResult.checked) body.result_to_chat = true;
|
|
1881
|
+
if (url && (!decideChat || !decideChat.checked)) body.decisions = 'callback';
|
|
1882
|
+
if (msgForm.msgNoticeOn && msgForm.msgNoticeOn.checked && msgForm.msgNotice.value.trim()) body.chat_notice = msgForm.msgNotice.value.trim();
|
|
1883
|
+
if (msgForm.msgResult && msgForm.msgResult.checked) body.result_to_chat = true;
|
|
1979
1884
|
msgResult.textContent = 'Saving' + String.fromCharCode(8230);
|
|
1980
1885
|
fetchJsonRetryOnce(base + '/messages', { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) }).then(function (r) {
|
|
1981
1886
|
if (!r.ok) { msgResult.textContent = r.body.error || 'Could not save'; return; }
|
|
@@ -96,11 +96,25 @@ export const consoleShellScript = `<script>
|
|
|
96
96
|
function remember(key, value) {
|
|
97
97
|
try { sessionStorage.setItem('le-side:' + key, JSON.stringify(value)); } catch (e) {}
|
|
98
98
|
}
|
|
99
|
+
// A list asked for again while it's still loading, or within a couple
|
|
100
|
+
// of seconds of arriving (a page reloading the sidebar as it opens),
|
|
101
|
+
// reuses that answer instead of another round trip.
|
|
102
|
+
var recent = {};
|
|
103
|
+
function getJson(url) {
|
|
104
|
+
var hit = recent[url];
|
|
105
|
+
if (hit && (!hit.at || Date.now() - hit.at < 2000)) return hit.promise;
|
|
106
|
+
var entry = { at: 0, promise: null };
|
|
107
|
+
entry.promise = fetch(url, { headers: { accept: 'application/json' } })
|
|
108
|
+
.then(function (r) { return r.ok ? r.json() : null; })
|
|
109
|
+
.catch(function () { return null; })
|
|
110
|
+
.then(function (data) { entry.at = Date.now(); return data; });
|
|
111
|
+
recent[url] = entry;
|
|
112
|
+
return entry.promise;
|
|
113
|
+
}
|
|
99
114
|
function cachedFetch(key, url, render) {
|
|
100
115
|
var seen = recall(key);
|
|
101
116
|
if (seen) { try { render(seen); } catch (e) {} }
|
|
102
|
-
return
|
|
103
|
-
.then(function (r) { return r.ok ? r.json() : null; })
|
|
117
|
+
return getJson(url)
|
|
104
118
|
.then(function (data) {
|
|
105
119
|
if (!data) return;
|
|
106
120
|
if (!seen || JSON.stringify(seen) !== JSON.stringify(data)) render(data);
|
|
@@ -109,10 +123,9 @@ export const consoleShellScript = `<script>
|
|
|
109
123
|
.catch(function () {});
|
|
110
124
|
}
|
|
111
125
|
|
|
112
|
-
// Who is signed in and their role (GET /config/settings), read once
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
.catch(function () { return null; });
|
|
126
|
+
// Who is signed in and their role (GET /config/settings), read once;
|
|
127
|
+
// pages read it through leShell.settings() rather than asking again.
|
|
128
|
+
var settings = getJson('/config/settings');
|
|
116
129
|
// On the Inbox, the lists wait for the role: an approver or viewer sees
|
|
117
130
|
// the Inbox only, and the rest of the sidebar is hidden. Other pages
|
|
118
131
|
// are only open to the roles that see everything.
|
|
@@ -168,20 +181,17 @@ export const consoleShellScript = `<script>
|
|
|
168
181
|
return n ? '<span class="le-count warn">' + n + ' to set</span>' : '';
|
|
169
182
|
}
|
|
170
183
|
|
|
184
|
+
// Each agent's count comes with GET /agents (toSet).
|
|
171
185
|
function loadToSet() {
|
|
186
|
+
var next = {};
|
|
187
|
+
agents.forEach(function (a) { next[a.name] = a.toSet || 0; });
|
|
188
|
+
var changed = JSON.stringify(next) !== JSON.stringify(toSet);
|
|
189
|
+
toSet = next;
|
|
190
|
+
remember('toSet', toSet);
|
|
191
|
+
if (changed) renderList();
|
|
172
192
|
agents.forEach(function (a) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
.then(function (vars) {
|
|
176
|
-
var n = (vars || []).filter(function (v) { return v.slot === 'agent' && v.scope === 'agent' && !v.set; }).length;
|
|
177
|
-
var changed = toSet[a.name] !== n;
|
|
178
|
-
toSet[a.name] = n;
|
|
179
|
-
remember('toSet', toSet);
|
|
180
|
-
if (changed) renderList();
|
|
181
|
-
var slots = document.querySelectorAll('[data-le-env-count="' + a.name + '"]');
|
|
182
|
-
for (var i = 0; i < slots.length; i++) slots[i].innerHTML = envCountHtml(a.name);
|
|
183
|
-
})
|
|
184
|
-
.catch(function () {});
|
|
193
|
+
var slots = document.querySelectorAll('[data-le-env-count="' + a.name + '"]');
|
|
194
|
+
for (var i = 0; i < slots.length; i++) slots[i].innerHTML = envCountHtml(a.name);
|
|
185
195
|
});
|
|
186
196
|
}
|
|
187
197
|
|
|
@@ -628,6 +638,6 @@ export const consoleShellScript = `<script>
|
|
|
628
638
|
}
|
|
629
639
|
|
|
630
640
|
|
|
631
|
-
window.leShell = { loadError: function () { return loadError; }, ready: ready, 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 };
|
|
641
|
+
window.leShell = { 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 };
|
|
632
642
|
})();
|
|
633
643
|
</script>`;
|
package/dist/web/inbox-page.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// The console's Inbox: /inbox lists every workflow run as a case, the ones
|
|
2
|
-
// waiting on a person first; /inbox?case=<id> opens one, with what it was
|
|
2
|
+
// waiting on a person first (?open=1 shows only those); /inbox?case=<id> opens one, with what it was
|
|
3
3
|
// given, what the agent did, what it asks now (answer, approve, approve
|
|
4
4
|
// as changed, deny) and who decided what (web/inbox-admin.ts behind
|
|
5
5
|
// /inbox/*). An approver or viewer sees only this page; a viewer can't
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// literal.
|
|
9
9
|
import { devUiCss } from './dev-ui-styles.js';
|
|
10
10
|
import { consoleShellScript, consoleSidebarHtml } from './console-shell.js';
|
|
11
|
+
import { renderMarkdownScript } from './markdown-script.js';
|
|
11
12
|
export const inboxPageHtml = `<!doctype html>
|
|
12
13
|
<html lang="en">
|
|
13
14
|
<head>
|
|
@@ -45,7 +46,7 @@ export const inboxPageHtml = `<!doctype html>
|
|
|
45
46
|
.ib-kv dt { color: var(--ink-muted); font-family: var(--font-mono); font-size: 12.5px; padding-top: 1px; }
|
|
46
47
|
.ib-kv dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
47
48
|
.ib-pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; background: var(--surface); padding: 10px 12px; border-radius: 8px; max-height: 360px; overflow: auto; }
|
|
48
|
-
.ib-question { margin: 0; font-size: 14.5px;
|
|
49
|
+
.ib-question { margin: 0; font-size: 14.5px; }
|
|
49
50
|
.ib-card textarea { width: 100%; box-sizing: border-box; min-height: 80px; font: inherit; font-size: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); resize: vertical; }
|
|
50
51
|
.ib-card textarea.mono { font-family: var(--font-mono); font-size: 12.5px; min-height: 200px; }
|
|
51
52
|
.ib-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
|
|
@@ -60,6 +61,22 @@ export const inboxPageHtml = `<!doctype html>
|
|
|
60
61
|
.ib-step details summary { cursor: pointer; font-size: 12.5px; color: var(--ink-muted); }
|
|
61
62
|
.ib-who { font-size: 13px; display: grid; gap: 4px; }
|
|
62
63
|
.hint { font-size: 12.5px; color: var(--ink-muted); }
|
|
64
|
+
.ib-md { font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
|
|
65
|
+
.ib-md > :first-child { margin-top: 0; }
|
|
66
|
+
.ib-md > :last-child { margin-bottom: 0; }
|
|
67
|
+
.ib-md p, .ib-md ul, .ib-md ol, .ib-md pre { margin: 0 0 .6em; }
|
|
68
|
+
.ib-md ul, .ib-md ol { padding-left: 1.4em; }
|
|
69
|
+
.ib-md li + li { margin-top: .25em; }
|
|
70
|
+
.ib-md h1, .ib-md h2, .ib-md h3, .ib-md h4, .ib-md h5, .ib-md h6 { margin: .8em 0 .4em; font-size: 15px; line-height: 1.35; }
|
|
71
|
+
.ib-md h1, .ib-md h2 { font-size: 16px; }
|
|
72
|
+
.ib-md a { color: var(--accent-ink); }
|
|
73
|
+
.ib-md code { font-family: var(--font-mono); font-size: .9em; background: var(--code-bg); padding: 1px 4px; border-radius: 4px; }
|
|
74
|
+
.ib-md pre { background: var(--code-bg); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
|
|
75
|
+
.ib-md pre code { background: none; padding: 0; }
|
|
76
|
+
.ib-md hr { border: 0; border-top: 1px solid var(--line); margin: .8em 0; }
|
|
77
|
+
.ib-md .workflow-markdown-table { overflow-x: auto; margin: 0 0 .6em; }
|
|
78
|
+
.ib-md table { border-collapse: collapse; font-size: 13px; }
|
|
79
|
+
.ib-md th, .ib-md td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
|
|
63
80
|
.error { font-size: 13px; color: var(--bad); margin: 0; }
|
|
64
81
|
@media (max-width: 640px) { .ib-row { grid-template-columns: 12px minmax(0, 1fr); } .ib-row-side { grid-column: 2; align-items: flex-start; flex-direction: row; gap: 8px; } .ib-kv { grid-template-columns: 1fr; } }
|
|
65
82
|
</style>
|
|
@@ -81,11 +98,12 @@ ${consoleSidebarHtml}
|
|
|
81
98
|
${consoleShellScript}
|
|
82
99
|
<script>
|
|
83
100
|
(function () {
|
|
101
|
+
${renderMarkdownScript}
|
|
84
102
|
var page = document.getElementById('ibPage');
|
|
85
103
|
var ELLIPSIS = String.fromCharCode(8230);
|
|
86
104
|
var DOT = ' ' + String.fromCharCode(183) + ' ';
|
|
87
105
|
var params = new URLSearchParams(location.search);
|
|
88
|
-
var state = { open: params.get('
|
|
106
|
+
var state = { open: params.get('open') === '1', q: params.get('q') || '', workflow: params.get('workflow') || '' };
|
|
89
107
|
var role = 'owner';
|
|
90
108
|
var workflows = {};
|
|
91
109
|
|
|
@@ -122,7 +140,7 @@ ${consoleShellScript}
|
|
|
122
140
|
}
|
|
123
141
|
function pageUrl() {
|
|
124
142
|
var q = new URLSearchParams();
|
|
125
|
-
if (
|
|
143
|
+
if (state.open) q.set('open', '1');
|
|
126
144
|
if (state.q) q.set('q', state.q);
|
|
127
145
|
if (state.workflow) q.set('workflow', state.workflow);
|
|
128
146
|
var s = q.toString();
|
|
@@ -142,7 +160,7 @@ ${consoleShellScript}
|
|
|
142
160
|
}).join('');
|
|
143
161
|
page.innerHTML =
|
|
144
162
|
'<div class="ib-bar">' +
|
|
145
|
-
'<span class="ib-filter" role="group" aria-label="Show"><button type="button" data-open="
|
|
163
|
+
'<span class="ib-filter" role="group" aria-label="Show"><button type="button" data-open="0" aria-pressed="' + !state.open + '">All</button><button type="button" data-open="1" aria-pressed="' + state.open + '">Needs you (' + (data.open || 0) + ')</button></span>' +
|
|
146
164
|
'<select id="ibWorkflow" aria-label="Workflow"><option value="">All workflows</option>' + options + '</select>' +
|
|
147
165
|
'<input id="ibSearch" type="search" placeholder="Search cases, inputs or people" value="' + esc(state.q) + '" aria-label="Search">' +
|
|
148
166
|
'</div>' +
|
|
@@ -186,7 +204,7 @@ ${consoleShellScript}
|
|
|
186
204
|
var locked = canDecide() ? '' : '<p class="hint" style="margin:0">Your role can see this but not decide.</p>';
|
|
187
205
|
if (p.kind === 'question') {
|
|
188
206
|
return '<div class="ib-card needs" data-pending="' + esc(p.pendingId) + '" data-kind="question"><h3>Question for you</h3>' +
|
|
189
|
-
'<
|
|
207
|
+
'<div class="ib-question ib-md">' + renderMarkdownPreview(p.question || '') + '</div>' +
|
|
190
208
|
(canDecide()
|
|
191
209
|
? (p.options && p.options.length ? '<div class="ib-actions">' + p.options.map(function (o) { return '<button type="button" class="ib-btn opt" data-option="' + esc(o) + '">' + esc(o) + '</button>'; }).join('') + '</div>' : '') +
|
|
192
210
|
'<textarea class="ib-answer" placeholder="Your answer"></textarea>' +
|
|
@@ -206,8 +224,8 @@ ${consoleShellScript}
|
|
|
206
224
|
}
|
|
207
225
|
|
|
208
226
|
function stepHtml(s) {
|
|
209
|
-
if (s.kind === 'text') return '<li class="ib-step"><span class="ib-step-k">Agent</span><div
|
|
210
|
-
if (s.kind === 'question') return '<li class="ib-step q"><span class="ib-step-k">Asked</span><div
|
|
227
|
+
if (s.kind === 'text') return '<li class="ib-step"><span class="ib-step-k">Agent</span><div class="ib-md">' + renderMarkdownPreview(s.text) + '</div></li>';
|
|
228
|
+
if (s.kind === 'question') return '<li class="ib-step q"><span class="ib-step-k">Asked</span><div class="ib-md">' + renderMarkdownPreview(s.question) + '</div>' +
|
|
211
229
|
(s.answer != null ? '<span class="ib-step-k">Answer</span><div style="white-space:pre-wrap">' + esc(s.answer) + '</div>' : '<span class="hint">Waiting for an answer</span>') + '</li>';
|
|
212
230
|
return '<li class="ib-step"><span class="ib-step-k">Used ' + esc(s.tool) + (s.failed ? ' (failed)' : '') + '</span>' +
|
|
213
231
|
'<details><summary>What it sent' + (s.result != null ? ' and got back' : '') + '</summary><pre class="ib-pre">' + esc(JSON.stringify(s.args, null, 2)) + '</pre>' +
|
|
@@ -235,7 +253,7 @@ ${consoleShellScript}
|
|
|
235
253
|
(run && run.params ? '<div class="ib-card"><h3>Inputs</h3>' + kvHtml(run.params) + '</div>' : '') +
|
|
236
254
|
(c.steps.length ? '<div class="ib-card"><h3>What the agent did</h3><ol class="ib-steps">' + c.steps.map(stepHtml).join('') + '</ol></div>' : '') +
|
|
237
255
|
(run ? decidedHtml(run) : '') +
|
|
238
|
-
(run && run.result ? '<div class="ib-card"><h3>Result</h3><div
|
|
256
|
+
(run && run.result ? '<div class="ib-card"><h3>Result</h3><div class="ib-md">' + renderMarkdownPreview(run.result) + '</div></div>' : '') +
|
|
239
257
|
(run && run.error ? '<div class="ib-card"><h3>Failed</h3><p class="error">' + esc(run.error) + '</p></div>' : '');
|
|
240
258
|
wireCase(c);
|
|
241
259
|
}
|
|
@@ -321,8 +339,7 @@ ${consoleShellScript}
|
|
|
321
339
|
}, 15000);
|
|
322
340
|
}
|
|
323
341
|
|
|
324
|
-
fetch('/config/settings')
|
|
325
|
-
.then(function (r) { return r.ok ? r.json() : null; })
|
|
342
|
+
(window.leShell && window.leShell.settings ? window.leShell.settings() : fetch('/config/settings').then(function (r) { return r.ok ? r.json() : null; }))
|
|
326
343
|
.then(function (s) { if (s && s.signIn && s.signIn.role) role = s.signIn.role; })
|
|
327
344
|
.catch(function () {})
|
|
328
345
|
.then(start);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const renderMarkdownScript: string;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// The console pages' markdown renderer, as inline script: the
|
|
2
|
+
// workflow pages and the Inbox put it in their own <script>, inside their
|
|
3
|
+
// template literal, so it's kept here as a string of browser JS with the
|
|
4
|
+
// same escaping rules as those pages (no backslash-letter sequences, no
|
|
5
|
+
// template placeholders). renderMarkdownPreview(md) returns HTML; it
|
|
6
|
+
// escapes first, so no markdown can inject raw HTML.
|
|
7
|
+
export const renderMarkdownScript = `
|
|
8
|
+
function markdownEscapeHtml(s) {
|
|
9
|
+
return String(s).replace(/[&<>"']/g, function (c) {
|
|
10
|
+
return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c];
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// A small, deliberately non-CommonMark markdown-to-HTML renderer for
|
|
15
|
+
// the skill Body field's Preview toggle (see wireSkillsHandlers) — this
|
|
16
|
+
// page stays a self-contained string, no build step, no CDN (same
|
|
17
|
+
// reasoning as devUiCss's own header comment), so pulling in a real
|
|
18
|
+
// markdown library isn't an option without breaking that. Covers what
|
|
19
|
+
// an actual SKILL.md body realistically uses (headings, bold/italic,
|
|
20
|
+
// inline code, fenced code blocks, links, lists, rules, paragraphs) —
|
|
21
|
+
// good enough for "does this read the way it will on GitHub", not a
|
|
22
|
+
// spec-complete parser. Escapes first, so no markdown source can inject
|
|
23
|
+
// raw HTML into the preview.
|
|
24
|
+
function renderMarkdownPreview(md) {
|
|
25
|
+
var lines = markdownEscapeHtml(md).split('\\n');
|
|
26
|
+
var html = '';
|
|
27
|
+
var inCode = false;
|
|
28
|
+
var codeBuffer = '';
|
|
29
|
+
var listType = null;
|
|
30
|
+
var paragraph = [];
|
|
31
|
+
|
|
32
|
+
// This whole page is one outer TS template literal AND its output is
|
|
33
|
+
// itself served as JS source text a browser then parses again — two
|
|
34
|
+
// layers of "escape sequences get processed", not one. The unicode
|
|
35
|
+
// escape used for the backtick patterns below survives both layers fine, since
|
|
36
|
+
// it's a real, recognized escape at both of them. A star/bracket/
|
|
37
|
+
// paren/s/d/dot escape (\*, \[, \s, \d, \.) is *not* a recognized
|
|
38
|
+
// escape at either layer, so each layer that touches it silently
|
|
39
|
+
// drops the backslash and keeps just the character — confirmed by
|
|
40
|
+
// extracting and executing the actually-served page during
|
|
41
|
+
// development, where every regex built the "obvious" way here ended
|
|
42
|
+
// up with its escapes stripped entirely, sometimes still parsing
|
|
43
|
+
// (silently wrong) and sometimes throwing ("nothing to repeat").
|
|
44
|
+
// Building these particular patterns from a runtime backslash
|
|
45
|
+
// character instead sidesteps the whole problem: there is no
|
|
46
|
+
// backslash-followed-by-letter sequence anywhere in this source for
|
|
47
|
+
// either layer to misinterpret.
|
|
48
|
+
var bs = String.fromCharCode(92);
|
|
49
|
+
var inlineCodePattern = new RegExp('\\u0060([^\\u0060]+)\\u0060', 'g');
|
|
50
|
+
var fencePattern = new RegExp('^\\u0060\\u0060\\u0060');
|
|
51
|
+
var boldPattern = new RegExp(bs + '*' + bs + '*([^*]+)' + bs + '*' + bs + '*', 'g');
|
|
52
|
+
var italicPattern = new RegExp(bs + '*([^*]+)' + bs + '*', 'g');
|
|
53
|
+
var linkPattern = new RegExp(bs + '[([^' + bs + ']]+)' + bs + ']' + bs + '(([^)]+)' + bs + ')', 'g');
|
|
54
|
+
var headingPattern = new RegExp('^(#{1,6})' + bs + 's+(.*)$');
|
|
55
|
+
var hrPattern = new RegExp('^(---|' + bs + '*' + bs + '*' + bs + '*)' + bs + 's*$');
|
|
56
|
+
var ulPattern = new RegExp('^[-*]' + bs + 's+(.*)$');
|
|
57
|
+
var olPattern = new RegExp('^' + bs + 'd+' + bs + '.' + bs + 's+(.*)$');
|
|
58
|
+
function inlineFormat(text) {
|
|
59
|
+
return text
|
|
60
|
+
.replace(inlineCodePattern, '<code>$1</code>')
|
|
61
|
+
.replace(boldPattern, '<strong>$1</strong>')
|
|
62
|
+
.replace(italicPattern, '<em>$1</em>')
|
|
63
|
+
.replace(linkPattern, function (_, label, href) {
|
|
64
|
+
var lowerHref = href.toLowerCase();
|
|
65
|
+
var safeHref = lowerHref.indexOf('https://') === 0 || lowerHref.indexOf('http://') === 0 || lowerHref.indexOf('mailto:') === 0;
|
|
66
|
+
return safeHref ? '<a href="' + href + '" target="_blank" rel="noopener noreferrer">' + label + '</a>' : label;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function flushParagraph() {
|
|
70
|
+
if (paragraph.length) {
|
|
71
|
+
html += '<p>' + inlineFormat(paragraph.join(' ')) + '</p>';
|
|
72
|
+
paragraph = [];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function closeList() {
|
|
76
|
+
if (listType) {
|
|
77
|
+
html += '</' + listType + '>';
|
|
78
|
+
listType = null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function tableCells(line) {
|
|
82
|
+
var value = line.trim();
|
|
83
|
+
if (value.charAt(0) === '|') value = value.slice(1);
|
|
84
|
+
if (value.charAt(value.length - 1) === '|') value = value.slice(0, -1);
|
|
85
|
+
return value.split('|').map(function (cell) { return cell.trim(); });
|
|
86
|
+
}
|
|
87
|
+
function isTableDivider(line) {
|
|
88
|
+
if (line.indexOf('|') < 0) return false;
|
|
89
|
+
var cells = tableCells(line);
|
|
90
|
+
return cells.length > 0 && cells.every(function (cell) {
|
|
91
|
+
var value = cell.replace(/:/g, '').replace(/-/g, '').trim();
|
|
92
|
+
return cell.indexOf('-') >= 0 && value === '';
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
for (var i = 0; i < lines.length; i++) {
|
|
97
|
+
var line = lines[i];
|
|
98
|
+
if (fencePattern.test(line)) {
|
|
99
|
+
if (!inCode) {
|
|
100
|
+
flushParagraph();
|
|
101
|
+
closeList();
|
|
102
|
+
inCode = true;
|
|
103
|
+
codeBuffer = '';
|
|
104
|
+
} else {
|
|
105
|
+
html += '<pre><code>' + codeBuffer + '</code></pre>';
|
|
106
|
+
inCode = false;
|
|
107
|
+
}
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (inCode) {
|
|
111
|
+
codeBuffer += line + '\\n';
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (line.indexOf('|') >= 0 && i + 1 < lines.length && isTableDivider(lines[i + 1])) {
|
|
116
|
+
flushParagraph();
|
|
117
|
+
closeList();
|
|
118
|
+
var headers = tableCells(line);
|
|
119
|
+
html += '<div class="workflow-markdown-table"><table><thead><tr>' + headers.map(function (cell) { return '<th>' + inlineFormat(cell) + '</th>'; }).join('') + '</tr></thead><tbody>';
|
|
120
|
+
i += 2;
|
|
121
|
+
while (i < lines.length && lines[i].indexOf('|') >= 0 && lines[i].trim() !== '') {
|
|
122
|
+
var cells = tableCells(lines[i]);
|
|
123
|
+
html += '<tr>' + headers.map(function (_, index) { return '<td>' + inlineFormat(cells[index] || '') + '</td>'; }).join('') + '</tr>';
|
|
124
|
+
i++;
|
|
125
|
+
}
|
|
126
|
+
html += '</tbody></table></div>';
|
|
127
|
+
i--;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
var heading = line.match(headingPattern);
|
|
132
|
+
if (heading) {
|
|
133
|
+
flushParagraph();
|
|
134
|
+
closeList();
|
|
135
|
+
var level = heading[1].length;
|
|
136
|
+
html += '<h' + level + '>' + inlineFormat(heading[2]) + '</h' + level + '>';
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (hrPattern.test(line)) {
|
|
140
|
+
flushParagraph();
|
|
141
|
+
closeList();
|
|
142
|
+
html += '<hr>';
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
var ul = line.match(ulPattern);
|
|
146
|
+
var ol = line.match(olPattern);
|
|
147
|
+
if (ul || ol) {
|
|
148
|
+
flushParagraph();
|
|
149
|
+
var wantType = ul ? 'ul' : 'ol';
|
|
150
|
+
if (listType !== wantType) {
|
|
151
|
+
closeList();
|
|
152
|
+
html += '<' + wantType + '>';
|
|
153
|
+
listType = wantType;
|
|
154
|
+
}
|
|
155
|
+
html += '<li>' + inlineFormat((ul || ol)[1]) + '</li>';
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
closeList();
|
|
159
|
+
|
|
160
|
+
if (line.trim() === '') {
|
|
161
|
+
flushParagraph();
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
paragraph.push(line.trim());
|
|
165
|
+
}
|
|
166
|
+
flushParagraph();
|
|
167
|
+
closeList();
|
|
168
|
+
return html || '<p class="hint">Nothing to preview yet.</p>';
|
|
169
|
+
}
|
|
170
|
+
`;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
/** Answers GET /_le/assets/<name> from the pages' moved-out code; false
|
|
3
|
+
* for any other request. An asset's name is its content hash, so it's
|
|
4
|
+
* cached for good. */
|
|
5
|
+
export declare function serveConsoleAsset(req: IncomingMessage, res: ServerResponse): boolean;
|
|
6
|
+
export declare function compressResponses(req: IncomingMessage, res: ServerResponse): void;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { gzipSync } from 'node:zlib';
|
|
3
|
+
const MIN_BYTES = 1024;
|
|
4
|
+
const COMPRESSIBLE = /^(text\/|application\/(json|javascript)|image\/svg\+xml)/i;
|
|
5
|
+
// The pages are the same few strings sent again and again: their
|
|
6
|
+
// gzipped copies are kept, by content hash.
|
|
7
|
+
const gzipped = new Map();
|
|
8
|
+
const MAX_CACHED = 64;
|
|
9
|
+
function gzipOf(body, hash) {
|
|
10
|
+
const hit = gzipped.get(hash);
|
|
11
|
+
if (hit)
|
|
12
|
+
return hit;
|
|
13
|
+
const out = gzipSync(body, { level: 6 });
|
|
14
|
+
if (gzipped.size >= MAX_CACHED)
|
|
15
|
+
gzipped.delete(gzipped.keys().next().value);
|
|
16
|
+
gzipped.set(hash, out);
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
// Page code moved out of the pages, by content hash. The pages are
|
|
20
|
+
// strings fixed at start, so this holds a few dozen blocks; the cap only
|
|
21
|
+
// guards against a page that changes on every request.
|
|
22
|
+
const ASSET_MIN_BYTES = 2048;
|
|
23
|
+
const MAX_ASSETS = 512;
|
|
24
|
+
const assets = new Map();
|
|
25
|
+
const leanPages = new Map();
|
|
26
|
+
function keepAsset(text, ext) {
|
|
27
|
+
const body = Buffer.from(text, 'utf8');
|
|
28
|
+
const name = createHash('sha1').update(body).digest('base64url').slice(0, 20) + '.' + ext;
|
|
29
|
+
if (!assets.has(name)) {
|
|
30
|
+
if (assets.size >= MAX_ASSETS)
|
|
31
|
+
assets.delete(assets.keys().next().value);
|
|
32
|
+
assets.set(name, { type: ext === 'js' ? 'text/javascript; charset=utf-8' : 'text/css; charset=utf-8', body });
|
|
33
|
+
}
|
|
34
|
+
return '/_le/assets/' + name;
|
|
35
|
+
}
|
|
36
|
+
// A page with its large plain <script> and <style> blocks as files. They
|
|
37
|
+
// run in the same order and block the page the same way they did inline.
|
|
38
|
+
function leanPage(html, hash) {
|
|
39
|
+
const hit = leanPages.get(hash);
|
|
40
|
+
if (hit !== undefined)
|
|
41
|
+
return hit;
|
|
42
|
+
const out = html
|
|
43
|
+
.replace(/<script>([\s\S]*?)<\/script>/g, (whole, code) => (code.length >= ASSET_MIN_BYTES ? `<script src="${keepAsset(code, 'js')}"></script>` : whole))
|
|
44
|
+
.replace(/<style>([\s\S]*?)<\/style>/g, (whole, css) => (css.length >= ASSET_MIN_BYTES ? `<link rel="stylesheet" href="${keepAsset(css, 'css')}">` : whole));
|
|
45
|
+
if (leanPages.size >= MAX_CACHED)
|
|
46
|
+
leanPages.delete(leanPages.keys().next().value);
|
|
47
|
+
leanPages.set(hash, out);
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
/** Answers GET /_le/assets/<name> from the pages' moved-out code; false
|
|
51
|
+
* for any other request. An asset's name is its content hash, so it's
|
|
52
|
+
* cached for good. */
|
|
53
|
+
export function serveConsoleAsset(req, res) {
|
|
54
|
+
const path = (req.url ?? '').split('?')[0];
|
|
55
|
+
if (!path.startsWith('/_le/assets/') || (req.method !== 'GET' && req.method !== 'HEAD'))
|
|
56
|
+
return false;
|
|
57
|
+
const asset = assets.get(path.slice('/_le/assets/'.length));
|
|
58
|
+
if (!asset) {
|
|
59
|
+
res.writeHead(404, { 'content-type': 'text/plain', 'cache-control': 'no-store' }).end('Not found');
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
res.writeHead(200, { 'content-type': asset.type, 'cache-control': 'public, max-age=31536000, immutable' });
|
|
63
|
+
res.end(req.method === 'HEAD' ? undefined : asset.body);
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
function headerValue(headers, name) {
|
|
67
|
+
const key = Object.keys(headers).find((k) => k.toLowerCase() === name);
|
|
68
|
+
const v = key ? headers[key] : undefined;
|
|
69
|
+
return v === undefined ? undefined : Array.isArray(v) ? v.join(', ') : String(v);
|
|
70
|
+
}
|
|
71
|
+
function dropHeader(headers, name) {
|
|
72
|
+
for (const k of Object.keys(headers))
|
|
73
|
+
if (k.toLowerCase() === name)
|
|
74
|
+
delete headers[k];
|
|
75
|
+
}
|
|
76
|
+
export function compressResponses(req, res) {
|
|
77
|
+
const acceptsGzip = /\bgzip\b/i.test(String(req.headers['accept-encoding'] ?? ''));
|
|
78
|
+
const isGet = req.method === 'GET';
|
|
79
|
+
if (!acceptsGzip && !isGet)
|
|
80
|
+
return;
|
|
81
|
+
const writeHead = res.writeHead.bind(res);
|
|
82
|
+
const write = res.write.bind(res);
|
|
83
|
+
const end = res.end.bind(res);
|
|
84
|
+
// writeHead is held back until the body is known; a write sends it as given.
|
|
85
|
+
let held;
|
|
86
|
+
let streaming = false;
|
|
87
|
+
const release = () => {
|
|
88
|
+
if (!held)
|
|
89
|
+
return;
|
|
90
|
+
const h = held;
|
|
91
|
+
held = undefined;
|
|
92
|
+
if (h.message !== undefined)
|
|
93
|
+
writeHead(h.status, h.message, h.headers);
|
|
94
|
+
else
|
|
95
|
+
writeHead(h.status, h.headers);
|
|
96
|
+
};
|
|
97
|
+
res.writeHead = function (status, ...rest) {
|
|
98
|
+
const message = typeof rest[0] === 'string' ? rest.shift() : undefined;
|
|
99
|
+
const given = rest[0];
|
|
100
|
+
const headers = {};
|
|
101
|
+
if (Array.isArray(given)) {
|
|
102
|
+
for (let i = 0; i + 1 < given.length; i += 2)
|
|
103
|
+
headers[String(given[i])] = given[i + 1];
|
|
104
|
+
}
|
|
105
|
+
else if (given && typeof given === 'object')
|
|
106
|
+
Object.assign(headers, given);
|
|
107
|
+
held = { status, ...(message !== undefined ? { message } : {}), headers };
|
|
108
|
+
// An event stream's head goes out at once, before its first event.
|
|
109
|
+
if (/^text\/event-stream/i.test(headerValue(headers, 'content-type') ?? '')) {
|
|
110
|
+
streaming = true;
|
|
111
|
+
release();
|
|
112
|
+
}
|
|
113
|
+
return res;
|
|
114
|
+
};
|
|
115
|
+
res.write = function (...args) {
|
|
116
|
+
streaming = true;
|
|
117
|
+
release();
|
|
118
|
+
return write(...args);
|
|
119
|
+
};
|
|
120
|
+
res.end = function (...args) {
|
|
121
|
+
const chunk = args[0];
|
|
122
|
+
if (streaming || (chunk !== undefined && chunk !== null && typeof chunk !== 'string' && !Buffer.isBuffer(chunk) && !(chunk instanceof Uint8Array))) {
|
|
123
|
+
release();
|
|
124
|
+
return end(...args);
|
|
125
|
+
}
|
|
126
|
+
const encoding = typeof args[1] === 'string' ? args[1] : 'utf8';
|
|
127
|
+
const callback = args.find((a) => typeof a === 'function');
|
|
128
|
+
const status = held?.status ?? res.statusCode;
|
|
129
|
+
// Headers set with setHeader, overlaid by writeHead's own.
|
|
130
|
+
const headers = { ...res.getHeaders(), ...(held?.headers ?? {}) };
|
|
131
|
+
for (const name of res.getHeaderNames())
|
|
132
|
+
res.removeHeader(name);
|
|
133
|
+
const message = held?.message;
|
|
134
|
+
held = undefined;
|
|
135
|
+
const body = chunk === undefined || chunk === null ? Buffer.alloc(0) : typeof chunk === 'string' ? Buffer.from(chunk, encoding) : Buffer.from(chunk);
|
|
136
|
+
const type = headerValue(headers, 'content-type') ?? '';
|
|
137
|
+
const cacheControl = headerValue(headers, 'cache-control') ?? '';
|
|
138
|
+
const already = headerValue(headers, 'content-encoding');
|
|
139
|
+
const hash = body.length ? createHash('sha1').update(body).digest('base64url').slice(0, 27) : '';
|
|
140
|
+
let out = body;
|
|
141
|
+
if (isGet && status === 200 && /^text\/html/i.test(type) && !/no-store/i.test(cacheControl) && !headerValue(headers, 'etag') && body.length) {
|
|
142
|
+
out = Buffer.from(leanPage(body.toString('utf8'), hash), 'utf8');
|
|
143
|
+
const etag = `W/"${hash}"`;
|
|
144
|
+
headers.etag = etag;
|
|
145
|
+
dropHeader(headers, 'cache-control');
|
|
146
|
+
headers['cache-control'] = 'no-cache';
|
|
147
|
+
dropHeader(headers, 'vary');
|
|
148
|
+
headers.vary = 'Accept, Accept-Encoding';
|
|
149
|
+
const asked = String(req.headers['if-none-match'] ?? '');
|
|
150
|
+
if (asked.split(',').some((t) => t.trim() === etag)) {
|
|
151
|
+
dropHeader(headers, 'content-type');
|
|
152
|
+
dropHeader(headers, 'content-length');
|
|
153
|
+
if (message !== undefined)
|
|
154
|
+
writeHead(304, message, headers);
|
|
155
|
+
else
|
|
156
|
+
writeHead(304, headers);
|
|
157
|
+
return end(callback);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (acceptsGzip && !already && body.length >= MIN_BYTES && COMPRESSIBLE.test(type) && req.method !== 'HEAD' && status !== 204 && status !== 304) {
|
|
161
|
+
out = gzipOf(out, out === body ? hash : hash + ':lean');
|
|
162
|
+
headers['content-encoding'] = 'gzip';
|
|
163
|
+
const vary = headerValue(headers, 'vary');
|
|
164
|
+
if (!vary || !/accept-encoding/i.test(vary)) {
|
|
165
|
+
dropHeader(headers, 'vary');
|
|
166
|
+
headers.vary = vary ? `${vary}, Accept-Encoding` : 'Accept-Encoding';
|
|
167
|
+
}
|
|
168
|
+
dropHeader(headers, 'content-length');
|
|
169
|
+
headers['content-length'] = String(out.length);
|
|
170
|
+
}
|
|
171
|
+
if (message !== undefined)
|
|
172
|
+
writeHead(status, message, headers);
|
|
173
|
+
else
|
|
174
|
+
writeHead(status, headers);
|
|
175
|
+
return end(out, callback);
|
|
176
|
+
};
|
|
177
|
+
}
|
|
@@ -132,8 +132,10 @@ ${consoleShellScript}
|
|
|
132
132
|
PLAN;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
// The sidebar asks for the same list as the page opens: one request.
|
|
136
|
+
(window.leShell && window.leShell.getJson
|
|
137
|
+
? window.leShell.getJson('/workflows/overview').then(function (d) { if (!d) throw new Error('could not reach the server'); return d; })
|
|
138
|
+
: fetch('/workflows/overview', { cache: 'no-store' }).then(function (r) { if (!r.ok) throw new Error('HTTP ' + r.status); return r.json(); }))
|
|
137
139
|
.then(render)
|
|
138
140
|
.catch(function (err) { page.innerHTML = '<p class="error">Couldn' + String.fromCharCode(8217) + 't load your workflows: ' + esc(err.message) + '</p>'; });
|
|
139
141
|
})();
|