@floless/app 0.150.0 → 0.151.0
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/floless-server.cjs +7467 -5068
- package/dist/skills/floless-app-onboarding/SKILL.md +200 -87
- package/dist/skills/floless-app-onboarding/references/aware-runtime.md +27 -18
- package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +207 -0
- package/dist/web/agents.js +108 -12
- package/dist/web/app.css +98 -20
- package/dist/web/app.js +14 -107
- package/dist/web/aware.js +459 -59
- package/dist/web/chat.css +12 -0
- package/dist/web/chat.js +95 -18
- package/dist/web/commands-shell.js +198 -10
- package/dist/web/guide.js +675 -0
- package/dist/web/index.html +64 -4
- package/dist/web/instructor.js +8 -2
- package/dist/web/tool-updates.js +175 -9
- package/dist/web/workspaces.js +217 -64
- package/package.json +2 -2
- package/dist/skills/floless-app-onboarding/references/floless-app-tour.md +0 -158
package/dist/web/aware.js
CHANGED
|
@@ -710,6 +710,7 @@
|
|
|
710
710
|
function presentedGateState(app, gateState) {
|
|
711
711
|
if (gateState === 'agent-changed' && app.approvalCheck && app.approvalCheck.remedy === 'publish') return 'needs-publish';
|
|
712
712
|
if (gateState === 'agent-changed' && app.approvalCheck && app.approvalCheck.remedy === 'needs-you') return 'needs-you';
|
|
713
|
+
if (gateState === 'ready' && app.approvalCheck && app.approvalCheck.bridgeWarnings && app.approvalCheck.bridgeWarnings.length) return 'needs-you';
|
|
713
714
|
return recordNeedsCheck(app, gateState) ? 'ready-check-record' : gateState;
|
|
714
715
|
}
|
|
715
716
|
|
|
@@ -757,11 +758,22 @@
|
|
|
757
758
|
function approvalStripState(app) {
|
|
758
759
|
const check = app && app.approvalCheck;
|
|
759
760
|
if (!check) return null;
|
|
760
|
-
if (
|
|
761
|
+
if (gateStateFor(app) === 'agent-changed' && check.remedy === 'needs-you') return 'needs-you';
|
|
761
762
|
if (check.current && check.origin === 'successor' && Array.isArray(check.successors) && check.successors.length) return 'carried';
|
|
763
|
+
if (Array.isArray(check.bridgeWarnings) && check.bridgeWarnings.length) return 'bridge-warning';
|
|
762
764
|
return null;
|
|
763
765
|
}
|
|
764
766
|
|
|
767
|
+
function bridgeWarningRows(check) {
|
|
768
|
+
const warnings = Array.isArray(check.bridgeWarnings) ? check.bridgeWarnings : [];
|
|
769
|
+
if (!warnings.length) return '';
|
|
770
|
+
return '<div class="approval-head">⚠ Needs you · Bridge needs attention</div>'
|
|
771
|
+
+ '<ul class="approval-rows">' + warnings.map((w) => '<li class="approval-row"><div class="approval-row-text">'
|
|
772
|
+
+ `<div><strong>${escapeHtml(w.via ? `${w.via} → ${w.name}` : w.name)}</strong>: ${escapeHtml(w.detail)}</div>`
|
|
773
|
+
+ '<ol>' + w.choices.map((choice) => `<li>${escapeHtml(choice)}</li>`).join('') + '</ol>'
|
|
774
|
+
+ '<div class="approval-row-note">This bridge warning does not block Run workflow. The run record will note this warning.</div></div></li>').join('') + '</ul>';
|
|
775
|
+
}
|
|
776
|
+
|
|
765
777
|
/** "Verbot 1.0.0 → 1.0.1" for every tool this link moved. */
|
|
766
778
|
function carriedMoves(link) {
|
|
767
779
|
return (Array.isArray(link.moved) ? link.moved : [])
|
|
@@ -776,7 +788,7 @@
|
|
|
776
788
|
|
|
777
789
|
function unavailableSentence(u) {
|
|
778
790
|
const tool = `${u.name} ${u.version || ''}`.trim();
|
|
779
|
-
if (u.removedBy === 'gc') return `${tool}
|
|
791
|
+
if (u.removedBy === 'gc') return `${tool} is no longer stored on this computer. AWARE cleaned it up because it did not see this workflow using it. This workflow was approved with exactly that version.`;
|
|
780
792
|
if (u.resolution === 'digest-mismatch') return `${tool} was changed after this workflow was approved with it.`;
|
|
781
793
|
if (u.resolution === 'missing') return `${u.name} is not installed. This workflow was approved with version ${u.version}.`;
|
|
782
794
|
return `${tool} is not installed any more. This workflow was approved with that exact version.`;
|
|
@@ -795,15 +807,25 @@
|
|
|
795
807
|
$approvalStrip.hidden = false;
|
|
796
808
|
$approvalStrip.dataset.state = state;
|
|
797
809
|
$approvalStrip.dataset.appId = app.id;
|
|
810
|
+
const bridgeRows = bridgeWarningRows(check);
|
|
811
|
+
if (state === 'bridge-warning') {
|
|
812
|
+
$approvalStrip.className = 'approval-strip approval-needs-you';
|
|
813
|
+
$approvalStrip.setAttribute('role', 'note');
|
|
814
|
+
$approvalStrip.setAttribute('aria-label', 'Bridge needs attention; this warning does not block Run workflow');
|
|
815
|
+
$approvalStrip.innerHTML = bridgeRows;
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
798
818
|
if (state === 'needs-you') {
|
|
799
819
|
const rows = (check.unavailable || []).filter((u) => u.reinstall);
|
|
800
820
|
$approvalStrip.className = 'approval-strip approval-needs-you';
|
|
801
821
|
$approvalStrip.setAttribute('role', 'group');
|
|
802
822
|
$approvalStrip.setAttribute('aria-label', 'A tool version needs your decision');
|
|
803
|
-
$approvalStrip.innerHTML = `<div class="approval-head">⚠ Needs you</div>`
|
|
823
|
+
$approvalStrip.innerHTML = bridgeRows + `<div class="approval-head">⚠ Needs you</div>`
|
|
804
824
|
+ `<ul class="approval-rows">${rows.map((u) => {
|
|
805
825
|
const busy = approvalStripReinstalling === `${app.id}\u0000${u.agent}`;
|
|
806
|
-
const installedNote = u.
|
|
826
|
+
const installedNote = u.storeOnly
|
|
827
|
+
? `Reinstalling puts ${escapeHtml(u.name)} ${escapeHtml(u.version)} back so this workflow can run.${u.installed ? ` ${escapeHtml(u.name)} ${escapeHtml(u.installed)} stays installed.` : ''}`
|
|
828
|
+
: u.installed
|
|
807
829
|
? `Reinstalling makes ${escapeHtml(u.version)} the installed version again. Workflows approved with ${escapeHtml(u.installed)} keep running as they do now.`
|
|
808
830
|
: `Reinstalling installs ${escapeHtml(u.name)} ${escapeHtml(u.version)}.`;
|
|
809
831
|
return `<li class="approval-row" data-agent="${escapeAttr(u.agent)}">`
|
|
@@ -813,7 +835,7 @@
|
|
|
813
835
|
+ `<div class="approval-row-actions">`
|
|
814
836
|
+ `<button type="button" class="btn primary" data-approval-reinstall data-agent="${escapeAttr(u.agent)}" data-version="${escapeAttr(u.version)}"`
|
|
815
837
|
+ ` data-command-id="workflow.reinstall-approved-tool#${escapeAttr(u.agent)}" data-command-instance-label="${escapeAttr(`${u.name} ${u.version}`)}"`
|
|
816
|
-
+ ` data-tip="${escapeAttr(`Install ${u.name} ${u.version} again, so this workflow runs with the version it was approved with`)}"`
|
|
838
|
+
+ ` data-tip="${escapeAttr(u.storeOnly ? `Put ${u.name} ${u.version} back, so this workflow runs with the version it was approved with. The installed version does not change` : `Install ${u.name} ${u.version} again, so this workflow runs with the version it was approved with`)}"`
|
|
817
839
|
+ `${busy ? ' disabled aria-busy="true"' : ''}>${busy ? 'Reinstalling…' : escapeHtml(`Reinstall ${u.name} ${u.version}`)}</button>`
|
|
818
840
|
+ `<button type="button" class="btn" data-approval-compile data-command-id="workflow.approval-compile-again"`
|
|
819
841
|
+ ` data-tip="Approve this workflow again with the tool versions installed when it compiles"${approvalStripReinstalling ? ' disabled' : ''}>Compile again</button>`
|
|
@@ -827,7 +849,7 @@
|
|
|
827
849
|
$approvalStrip.className = 'approval-strip approval-carried';
|
|
828
850
|
$approvalStrip.setAttribute('role', 'note');
|
|
829
851
|
$approvalStrip.setAttribute('aria-label', 'Where this workflow’s approval came from');
|
|
830
|
-
$approvalStrip.innerHTML = `<details class="approval-details">`
|
|
852
|
+
$approvalStrip.innerHTML = bridgeRows + `<details class="approval-details">`
|
|
831
853
|
+ `<summary data-command-id="workflow.approval-carried-details" data-tip="Show where this approval came from">`
|
|
832
854
|
+ `<span class="approval-carried-label">Approval carried over</span>`
|
|
833
855
|
+ `<span class="approval-carried-sep">·</span><span>${escapeHtml(carriedMoves(last))}</span>`
|
|
@@ -851,9 +873,16 @@
|
|
|
851
873
|
function runStartApprovalNote(ev) {
|
|
852
874
|
const cfg = (ev && (ev.config || ev.run_config)) || null;
|
|
853
875
|
const a = cfg && cfg.approval;
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
876
|
+
const rows = cfg && cfg['agent-resolution'];
|
|
877
|
+
const bridge = rows && typeof rows === 'object' ? Object.entries(rows).map(([agent, row]) => {
|
|
878
|
+
const w = row && row.bridge;
|
|
879
|
+
if (!w || !['bridge-too-old', 'bridge-too-new', 'declaration-invalid'].includes(w.status) || typeof w.detail !== 'string') return '';
|
|
880
|
+
const label = w.status === 'declaration-invalid' ? 'Ran with an invalid bridge declaration' : 'Ran with a bridge mismatch';
|
|
881
|
+
return ` · ${label}: ${escapeHtml(agent.replaceAll('>', ' → '))}. ${escapeHtml(w.detail)}`;
|
|
882
|
+
}).join('') : '';
|
|
883
|
+
if (!a || a.origin === 'original') return bridge;
|
|
884
|
+
if (a.origin !== 'successor') return ` · an approval FloLess does not recognise — AWARE’s record: ${escapeHtml(a.label || 'none')}${bridge}`;
|
|
885
|
+
return ` · approval carried over — AWARE’s record: ${escapeHtml(a.label || 'carried forward')}${bridge}`;
|
|
857
886
|
}
|
|
858
887
|
|
|
859
888
|
if ($approvalStrip) {
|
|
@@ -897,7 +926,7 @@
|
|
|
897
926
|
if (error) {
|
|
898
927
|
repaintShown();
|
|
899
928
|
const row = stillHere() && $approvalStrip.querySelector(`.approval-row[data-agent="${CSS.escape(agent)}"] .approval-row-error`);
|
|
900
|
-
if (row) row.textContent = `${error.message} You can try again, or Compile again
|
|
929
|
+
if (row) row.textContent = (error.body && error.body.code === 'reinstall-failed') ? `${error.message} You can try again, or Compile again.` : error.message;
|
|
901
930
|
else showToast(error.message, 'warn'); // the person moved on: the failure still reaches them
|
|
902
931
|
return;
|
|
903
932
|
}
|
|
@@ -1115,6 +1144,9 @@
|
|
|
1115
1144
|
}
|
|
1116
1145
|
const recordTip = gateState === 'ready' ? approvalRecordTip(app.approvalCheck) : null;
|
|
1117
1146
|
if (recordTip) gateTips.ready = recordTip;
|
|
1147
|
+
if (gateState === 'ready' && app.approvalCheck && app.approvalCheck.bridgeWarnings && app.approvalCheck.bridgeWarnings.length) {
|
|
1148
|
+
gateTips.ready += '\nBridge needs attention. Review the warning and choices above the canvas. Run workflow is still available; the run record will note the warning.';
|
|
1149
|
+
}
|
|
1118
1150
|
$runState.dataset.tip = activeTips[status.label] || gateTips[gateState] || '';
|
|
1119
1151
|
|
|
1120
1152
|
// Push a snapshot to the Instructor band. One-way: the band renders what it
|
|
@@ -1129,6 +1161,7 @@
|
|
|
1129
1161
|
// #1996: what the Instructor says for a not-confirmed carried-forward approval or an incomplete record.
|
|
1130
1162
|
remedy: (app.approvalCheck && app.approvalCheck.remedy) || null,
|
|
1131
1163
|
recordIncomplete: recordNeedsCheck(app, gateState),
|
|
1164
|
+
bridgeWarning: !!(app.approvalCheck && app.approvalCheck.bridgeWarnings && app.approvalCheck.bridgeWarnings.length),
|
|
1132
1165
|
totalInputs: inputs.length,
|
|
1133
1166
|
inputsSet: inputs.filter((i) => {
|
|
1134
1167
|
const v = values[i.name];
|
|
@@ -1447,12 +1480,13 @@
|
|
|
1447
1480
|
const ico = $b.querySelector('.guide-beacon-ico');
|
|
1448
1481
|
const label = $b.querySelector('.guide-beacon-label');
|
|
1449
1482
|
if (ico) ico.textContent = isNew ? '✦' : '?';
|
|
1450
|
-
|
|
1483
|
+
// #2046: "Guide" is the onboarding agent now; at rest this beacon is about the open project.
|
|
1484
|
+
if (label) label.textContent = isNew ? 'Start here' : 'About this project';
|
|
1451
1485
|
// No "workflow"/"Run" vocabulary — this is a document project.
|
|
1452
1486
|
$b.dataset.tip = isNew
|
|
1453
1487
|
? 'New here? See what this project does and how to take it from drawing to export.'
|
|
1454
|
-
: '
|
|
1455
|
-
$b.setAttribute('aria-label', (isNew ? 'Start here —
|
|
1488
|
+
: 'See what this project does and how to use it.';
|
|
1489
|
+
$b.setAttribute('aria-label', (isNew ? 'Start here — about ' : 'About ') + (ctx.name || ctx.displayName || ctx.app));
|
|
1456
1490
|
}
|
|
1457
1491
|
|
|
1458
1492
|
function paintBeacon(app) {
|
|
@@ -1470,11 +1504,12 @@
|
|
|
1470
1504
|
// Monochrome dingbats (✦ / ?), not colour emoji — the locked baseline uses text
|
|
1471
1505
|
// glyphs (★, ▸); the pulse, not an emoji, is the "new" signal.
|
|
1472
1506
|
if (ico) ico.textContent = isNew ? '✦' : '?';
|
|
1473
|
-
|
|
1507
|
+
// #2046: "Guide" is the onboarding agent now; at rest this beacon is about the open workflow.
|
|
1508
|
+
if (label) label.textContent = isNew ? 'Start here' : 'About this workflow';
|
|
1474
1509
|
$b.dataset.tip = isNew
|
|
1475
1510
|
? 'New here? See what this workflow does and how to run it.'
|
|
1476
|
-
: '
|
|
1477
|
-
$b.setAttribute('aria-label', (isNew ? 'Start here —
|
|
1511
|
+
: 'See what this workflow does and how to run it.';
|
|
1512
|
+
$b.setAttribute('aria-label', (isNew ? 'Start here — about ' : 'About ') + (app.displayName || app.id));
|
|
1478
1513
|
}
|
|
1479
1514
|
|
|
1480
1515
|
// Record a completed real run → the workflow is no longer new; calm the beacon (and
|
|
@@ -1797,7 +1832,7 @@
|
|
|
1797
1832
|
// ≡ menu "New workflow…" — create the durable owner BEFORE asking the terminal AI to author.
|
|
1798
1833
|
// The UI chooses only a display name and owner; the server mints the UUID and derives the actual
|
|
1799
1834
|
// directory. That makes a queued request project-safe without turning the browser into an author.
|
|
1800
|
-
async function requestNewWorkflow() {
|
|
1835
|
+
async function requestNewWorkflow(prefill = {}) {
|
|
1801
1836
|
try {
|
|
1802
1837
|
const { projects = [] } = await api('/api/projects');
|
|
1803
1838
|
const ownerOptions = workflowOwnerOptions(projects);
|
|
@@ -1808,6 +1843,8 @@
|
|
|
1808
1843
|
{
|
|
1809
1844
|
name: 'name', label: 'Workflow name', placeholder: 'e.g. Weekly model review',
|
|
1810
1845
|
commandId: 'shell.new-workflow-name', required: true,
|
|
1846
|
+
// #2046: a Guide suggestion opens this with its name filled in; the person still chooses and confirms.
|
|
1847
|
+
...(typeof prefill.name === 'string' && prefill.name ? { value: prefill.name } : {}),
|
|
1811
1848
|
},
|
|
1812
1849
|
{
|
|
1813
1850
|
name: 'owner', label: 'Location', type: 'select', value: 'standalone',
|
|
@@ -1968,6 +2005,7 @@
|
|
|
1968
2005
|
// belong inside it. Set unconditionally (including to undefined) so a workflow that stops being a
|
|
1969
2006
|
// publication clears, rather than keeping the previous answer forever.
|
|
1970
2007
|
await commitPublicationAvailability(id, read, contractState);
|
|
2008
|
+
if (ticket !== selectionTicket) return; // a newer selection also wins during the availability wait
|
|
1971
2009
|
currentId = id;
|
|
1972
2010
|
workflowSelectionGeneration += 1;
|
|
1973
2011
|
if (id === 'tekla-model-report' || id === 'floless-workspace-model-report') {
|
|
@@ -2043,7 +2081,7 @@
|
|
|
2043
2081
|
]).then(() => {});
|
|
2044
2082
|
}
|
|
2045
2083
|
|
|
2046
|
-
async function loadApps() {
|
|
2084
|
+
async function loadApps({ preserveSelection = false } = {}) {
|
|
2047
2085
|
// …and mean it: the trigger said "loading…" but stayed CLICKABLE, so a click during the fetch
|
|
2048
2086
|
// opened the popover onto an empty #wf-list — the exact "picker opens and stays empty, it never
|
|
2049
2087
|
// says loading, it just looks broken" report in #358. buildWorkflowCombo() re-enables it once
|
|
@@ -2054,9 +2092,11 @@
|
|
|
2054
2092
|
// with no re-enable path — worst on delete, which clears the open workflow first. So a failed
|
|
2055
2093
|
// refresh restores what the user had; only a load that never had a list stays disabled.
|
|
2056
2094
|
const wasUsable = !!$wfTrigger && !$wfTrigger.disabled;
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2095
|
+
if (!preserveSelection) {
|
|
2096
|
+
setComboTriggerLabel('loading…');
|
|
2097
|
+
if ($wfTrigger) $wfTrigger.disabled = true;
|
|
2098
|
+
renderCanvasPlaceholder('loading');
|
|
2099
|
+
}
|
|
2060
2100
|
let list;
|
|
2061
2101
|
// #1890 PR 3b-0: the owned workflow open now, read before the owner map is refreshed — if its installed copy is
|
|
2062
2102
|
// gone after this refresh, it shows its own recovery view instead of falling back to another workflow.
|
|
@@ -2066,7 +2106,7 @@
|
|
|
2066
2106
|
let owned = null;
|
|
2067
2107
|
try {
|
|
2068
2108
|
({ apps: list } = await api('/api/workflows/library'));
|
|
2069
|
-
try { ({ workflows: owned } = await api('/api/workflows/owned')); }
|
|
2109
|
+
try { ({ workflows: owned } = await api('/api/workflows/owned?archived=1')); }
|
|
2070
2110
|
catch { /* the owned list is additive here: a failed read keeps the drafts last shown */ }
|
|
2071
2111
|
// An older refresh that finishes after a newer one must not overwrite what the newer one showed.
|
|
2072
2112
|
if (generation !== appsLoadGeneration) return;
|
|
@@ -2077,9 +2117,39 @@
|
|
|
2077
2117
|
} catch (e) {
|
|
2078
2118
|
// Usable before THIS refresh, or built by an earlier one (an overlapping refresh disabled it first, and its
|
|
2079
2119
|
// own success was then superseded): a failed refresh never strands a picker that has workflows in it.
|
|
2080
|
-
if (
|
|
2120
|
+
if (!preserveSelection) {
|
|
2121
|
+
if ((wasUsable || $promptSel.options.length > 0) && $wfTrigger) $wfTrigger.disabled = false;
|
|
2122
|
+
}
|
|
2081
2123
|
throw e;
|
|
2082
2124
|
}
|
|
2125
|
+
if (preserveSelection) {
|
|
2126
|
+
// Read the current selection AFTER the requests: a person may have opened something newer.
|
|
2127
|
+
// Refreshing a restored workflow's catalogue must not change that canvas, label or picker value.
|
|
2128
|
+
const selected = $promptSel.value;
|
|
2129
|
+
const selectedText = Array.from($promptSel.options).find((option) => option.value === selected)?.textContent || selected;
|
|
2130
|
+
$promptSel.innerHTML = '';
|
|
2131
|
+
for (const entry of list) {
|
|
2132
|
+
const option = document.createElement('option');
|
|
2133
|
+
option.value = entry.id;
|
|
2134
|
+
option.textContent = `${entry.ownedWorkflow ? entry.ownedWorkflow.displayName : entry.id} · ${entry.nodes} node${entry.nodes === 1 ? '' : 's'} · ${entry.layout}`;
|
|
2135
|
+
$promptSel.appendChild(option);
|
|
2136
|
+
}
|
|
2137
|
+
if (selected && !list.some((entry) => entry.id === selected)) {
|
|
2138
|
+
const option = document.createElement('option');
|
|
2139
|
+
option.value = selected; option.textContent = selectedText; option.hidden = true;
|
|
2140
|
+
$promptSel.appendChild(option);
|
|
2141
|
+
}
|
|
2142
|
+
$promptSel.value = selected;
|
|
2143
|
+
buildWorkflowCombo(list);
|
|
2144
|
+
// A pending older refresh may have disabled the picker. Its transient flag is not
|
|
2145
|
+
// readiness: this fresh catalogue owns enablement, and a hidden selection is not a choice.
|
|
2146
|
+
if ($wfTrigger) $wfTrigger.disabled = !list.length;
|
|
2147
|
+
setComboSelected(currentId || selected);
|
|
2148
|
+
const count = document.getElementById('apps-count');
|
|
2149
|
+
if (count) count.textContent = list.length;
|
|
2150
|
+
if (wfLanding) renderWorkflowsLanding();
|
|
2151
|
+
return;
|
|
2152
|
+
}
|
|
2083
2153
|
$promptSel.innerHTML = '';
|
|
2084
2154
|
if (!list.length) {
|
|
2085
2155
|
// The guided empty-state panel owns the "install a workflow" message now —
|
|
@@ -2203,6 +2273,7 @@
|
|
|
2203
2273
|
// #1890 PR 3b-0: every owned workflow, drafts included (/api/workflows/owned), and the draft open in the canvas
|
|
2204
2274
|
// area, if any. A draft has no runtime app, so it is never `currentId` and never goes to loadApp.
|
|
2205
2275
|
let wfOwned = [];
|
|
2276
|
+
const restoringWorkflows = new Set();
|
|
2206
2277
|
let draftWorkflow = null;
|
|
2207
2278
|
// Opening anything (a workflow or a draft) takes a new ticket; a workflow load that finishes after a newer open
|
|
2208
2279
|
// is dropped, so a slow load can never land on top of a draft opened meanwhile (#1890 PR 3b-0 review).
|
|
@@ -2266,7 +2337,7 @@
|
|
|
2266
2337
|
const actions = owned
|
|
2267
2338
|
? `<button type="button" class="wf-act act-edit" data-wf-act="rename" data-command-id="workflow.rename-owned#${escapeAttr(ownedId)}" data-command-instance-label="${escapeAttr(workflowName)}" data-id="${aid}" tabindex="-1" data-tip="Rename" aria-label="Rename ${escapeAttr(workflowName)}">✎</button>`
|
|
2268
2339
|
+ `<button type="button" class="wf-act act-dup" data-wf-act="duplicate" data-command-id="workflow.copy-owned#${escapeAttr(ownedId)}" data-command-instance-label="${escapeAttr(workflowName)}" data-id="${aid}" tabindex="-1" data-tip="Copy" aria-label="Copy ${escapeAttr(workflowName)}">⧉</button>`
|
|
2269
|
-
+ `<button type="button" class="wf-act act-del" data-wf-act="delete" data-command-id="workflow.archive#${escapeAttr(ownedId)}" data-command-instance-label="${escapeAttr(workflowName)}" data-id="${aid}" tabindex="-1" data-tip="Archive" aria-label="Archive ${escapeAttr(workflowName)}">×</button>`
|
|
2340
|
+
+ `<button type="button" class="wf-act act-del" data-wf-act="delete" data-command-id="workflow.archive#${escapeAttr(ownedId)}" data-command-instance-label="${escapeAttr(workflowName)}" data-id="${aid}" tabindex="-1" data-tip="Archive — restore from Archived on the Workflows page" aria-label="Archive ${escapeAttr(workflowName)}">×</button>`
|
|
2270
2341
|
: `<button type="button" class="wf-act act-edit" data-wf-act="rename" data-command-id="workflow.rename#${escapeAttr(aid)}" data-id="${aid}" tabindex="-1" data-tip="Rename" aria-label="Rename ${escapeAttr(workflowName)}">✎</button>`
|
|
2271
2342
|
+ `<button type="button" class="wf-act act-dup" data-wf-act="duplicate" data-command-id="workflow.duplicate#${escapeAttr(aid)}" data-id="${aid}" tabindex="-1" data-tip="Duplicate" aria-label="Duplicate ${escapeAttr(workflowName)}">⧉</button>`
|
|
2272
2343
|
+ `<button type="button" class="wf-act act-del" data-wf-act="delete" data-command-id="workflow.delete#${escapeAttr(aid)}" data-id="${aid}" tabindex="-1" data-tip="Delete" aria-label="Delete ${escapeAttr(workflowName)}">×</button>`;
|
|
@@ -2507,7 +2578,7 @@
|
|
|
2507
2578
|
closeCombo(false);
|
|
2508
2579
|
const res = await formModal({
|
|
2509
2580
|
title: 'Archive workflow?',
|
|
2510
|
-
sub: `Hide “${name}” from Workflows and block new runs. Its source, chat, history and publications stay on this computer.`,
|
|
2581
|
+
sub: `Hide “${name}” from Workflows and block new runs. Its source, chat, history and publications stay on this computer. Restore it from Archived on the Workflows page.`,
|
|
2511
2582
|
fields: [], okLabel: 'Archive', safeDefault: true,
|
|
2512
2583
|
});
|
|
2513
2584
|
if (!res) return;
|
|
@@ -4886,6 +4957,10 @@
|
|
|
4886
4957
|
? 'This workflow needs compiling again'
|
|
4887
4958
|
: reinstall ? 'A tool needs reinstalling' : 'The workflow stopped before it finished');
|
|
4888
4959
|
const text = mkEl('div', 'cred-fail-body', message);
|
|
4960
|
+
for (const warning of (body && body.bridgeWarnings) || []) {
|
|
4961
|
+
const label = warning.status === 'declaration-invalid' ? 'Ran with an invalid bridge declaration' : 'Ran with a bridge mismatch';
|
|
4962
|
+
text.append(mkEl('p', '', `${label}: ${warning.via ? warning.via + ' → ' : ''}${warning.name}. ${warning.detail}`));
|
|
4963
|
+
}
|
|
4889
4964
|
const actions = mkEl('div', 'cred-fail-actions');
|
|
4890
4965
|
if (compileFix) {
|
|
4891
4966
|
const compile = mkEl('button', 'primary cred-reconnect run-fail-compile', 'Compile now');
|
|
@@ -9508,6 +9583,7 @@
|
|
|
9508
9583
|
runningRoutines.delete(m.id);
|
|
9509
9584
|
loadRoutinesData();
|
|
9510
9585
|
if (window.flolessPanels) window.flolessPanels.refreshData(); // routine runs also refresh bindings
|
|
9586
|
+
window.flolessAgents?.refreshRuns?.(); // #2035: an open agent page shows the run its routine just started
|
|
9511
9587
|
} else if (m.type === 'trigger-session-changed') {
|
|
9512
9588
|
// A foreground live-run session (▶ Run on a streaming app) shares this SSE
|
|
9513
9589
|
// event with background routines; its server-namespaced id routes it to the
|
|
@@ -12465,20 +12541,26 @@
|
|
|
12465
12541
|
|
|
12466
12542
|
// `focusId` (a connection check's "Update" offer, #1986): open on top of the dialog that asked, showing just that
|
|
12467
12543
|
// tool on the Installed tab, where its own Update button lives — the update itself stays the library's.
|
|
12544
|
+
// `{ tab: 'available' }` (the Guide's install suggestion, #2046): the tool is not installed yet, so show it on the
|
|
12545
|
+
// Available tab, where its Install button lives — the install itself stays the library's.
|
|
12468
12546
|
let libOpener = null; // the offer button that opened the library on top of its dialog, to return focus to
|
|
12469
|
-
openLibrary = function openLibraryReal(focusId) {
|
|
12547
|
+
openLibrary = function openLibraryReal(focusId, opts) {
|
|
12470
12548
|
const focus = typeof focusId === 'string' ? focusId : '';
|
|
12549
|
+
const toAvailable = !!focus && opts?.tab === 'available';
|
|
12471
12550
|
$libModal.classList.toggle('lib-front', !!focus);
|
|
12472
12551
|
libOpener = focus ? document.activeElement : null;
|
|
12473
12552
|
$libSearch.value = '';
|
|
12474
|
-
if ($libAvailSearch) $libAvailSearch.value = '';
|
|
12475
|
-
switchLibTab('installed'); //
|
|
12476
|
-
$libSearch.value = focus;
|
|
12553
|
+
if ($libAvailSearch) $libAvailSearch.value = toAvailable ? focus : '';
|
|
12554
|
+
switchLibTab(toAvailable ? 'available' : 'installed'); // Installed is the primary job, unless asked otherwise
|
|
12555
|
+
if (!toAvailable) $libSearch.value = focus;
|
|
12477
12556
|
renderLibrary();
|
|
12478
12557
|
$libModal.classList.add('show');
|
|
12479
12558
|
// Focus moves into the library NOW (not on the tab switch's next tick), so even an immediate Escape lands on the
|
|
12480
12559
|
// library's own handler instead of the dialog underneath.
|
|
12481
|
-
|
|
12560
|
+
// Focus moves to the open tab's search. On Available, an AWARE too old to list tools hides that search: renderAvailable
|
|
12561
|
+
// then hands focus on to its "Update AWARE" button, whether it knew that already or learns it when the reply lands.
|
|
12562
|
+
if (focus) (toAvailable && $libAvailSearch ? $libAvailSearch : $libSearch).focus();
|
|
12563
|
+
if (toAvailable && $libAvailSearch?.hidden) availableFocusFallback();
|
|
12482
12564
|
if (!agentCatalog.length) loadAgentCatalog().then(renderLibrary).catch(reportErr);
|
|
12483
12565
|
// Load the registry catalog too, so the Installed tab can flag outdated agents
|
|
12484
12566
|
// with an "Update" button (and the Available tab is instant when switched to).
|
|
@@ -12694,9 +12776,16 @@
|
|
|
12694
12776
|
</div>`;
|
|
12695
12777
|
}
|
|
12696
12778
|
|
|
12779
|
+
// The Available search can be hidden while it holds focus (#2049): focus then goes to a visible control in the same
|
|
12780
|
+
// tab, so it never sits on a hidden input outside the library's own Escape handling.
|
|
12781
|
+
function availableFocusFallback() {
|
|
12782
|
+
(document.getElementById('lib-avail-update') || $libTabs.querySelector('[data-libtab="available"]'))?.focus();
|
|
12783
|
+
}
|
|
12784
|
+
|
|
12697
12785
|
function renderAvailable() {
|
|
12698
12786
|
// Degradation (i): CLI predates `agent catalog` entirely — hide search, show notice.
|
|
12699
12787
|
if (availableUnsupported) {
|
|
12788
|
+
const searchHadFocus = document.activeElement === $libAvailSearch;
|
|
12700
12789
|
$libAvailSearch.hidden = true;
|
|
12701
12790
|
$libAvailList.innerHTML =
|
|
12702
12791
|
'<div class="empty-state">Browsing available tools needs AWARE 0.54 or later.' +
|
|
@@ -12709,6 +12798,7 @@
|
|
|
12709
12798
|
else showToast('Update AWARE (@aware-aeco/cli) to 0.54+ to browse available tools', 'info');
|
|
12710
12799
|
};
|
|
12711
12800
|
$libAvailCount.textContent = '';
|
|
12801
|
+
if (searchHadFocus) availableFocusFallback();
|
|
12712
12802
|
return;
|
|
12713
12803
|
}
|
|
12714
12804
|
$libAvailSearch.hidden = false;
|
|
@@ -13593,6 +13683,12 @@
|
|
|
13593
13683
|
let editWorkflows = []; // app list for the workflow <select>, cached per edit-open
|
|
13594
13684
|
let editTriggerSource = null; // picked workflow's triggerSource (null = not trigger-eligible)
|
|
13595
13685
|
let editRoutineMode = 'schedule'; // 'schedule' | 'trigger' — chosen kind in the edit form
|
|
13686
|
+
let editTarget = 'workflow'; // #2035: 'workflow' | 'agent' — what the routine being edited runs
|
|
13687
|
+
let editAgents = []; // #2035: this folder's agents for the Agent <select>, cached per edit-open
|
|
13688
|
+
let editAgentAi = 'claude'; // #2035: the AI an agent routine starts (Claude | Codex), like the Run sheet's choice
|
|
13689
|
+
let editReturnFocus = null; // #2035: where focus goes back when the editor was opened from an agent's page
|
|
13690
|
+
const routineAgentNames = new Map(); // #2035: agentId → name, for "Agent · <name>" rows
|
|
13691
|
+
const routineAgentRunState = new Map(); // #2035: routine id → how its last agent run is going, read from that run
|
|
13596
13692
|
const runningRoutines = new Set(); // ids executing now (SSE start → ended)
|
|
13597
13693
|
|
|
13598
13694
|
function isCompleteReportRoutine(r) {
|
|
@@ -13843,13 +13939,28 @@
|
|
|
13843
13939
|
function lastRunTip(r) {
|
|
13844
13940
|
if (!r.lastRun) return 'Never run yet';
|
|
13845
13941
|
const lr = r.lastRun;
|
|
13942
|
+
// #2035: an agent routine only starts the agent; how that run went is the agent run's own record.
|
|
13943
|
+
if (r.agent) {
|
|
13944
|
+
const when = absTime(lr.at);
|
|
13945
|
+
if (lr.status === 'starting') return `Starting the agent · ${when}`;
|
|
13946
|
+
if (lr.status === 'started') return `Started the agent · ${when}${routineAgentRunState.get(r.id) ? ` · ${routineAgentRunState.get(r.id)}` : ''}`;
|
|
13947
|
+
// A skip reason already begins "Skipped — …" (the server's sentence), so it is shown as is.
|
|
13948
|
+
if (lr.status === 'skipped') return `${lr.reason || 'Skipped'} · ${when}`;
|
|
13949
|
+
return `Didn’t start${lr.reason ? ' — ' + lr.reason : ''} · ${when}`;
|
|
13950
|
+
}
|
|
13846
13951
|
const dur = lr.durationMs != null ? ` · ${(lr.durationMs / 1000).toFixed(1)} s` : '';
|
|
13847
13952
|
// A run that finished on a stated assumption says so with its outcome, never only in the report.
|
|
13848
13953
|
const warnings = Array.isArray(lr.warnings) ? lr.warnings.filter((warning) => typeof warning === 'string' && warning) : [];
|
|
13849
13954
|
// #1998: a run made under an approval carried forward to newer tool versions says so, in AWARE's words.
|
|
13850
13955
|
const carried = lr.approval && lr.approval.origin === 'successor'
|
|
13851
13956
|
? `\nApproval carried over to a newer tool version. AWARE's record: ${lr.approval.label || 'carried forward'}` : '';
|
|
13852
|
-
|
|
13957
|
+
const bridgeWarnings = Array.isArray(lr.bridgeWarnings) ? lr.bridgeWarnings.filter((w) => w && typeof w === 'object'
|
|
13958
|
+
&& ['bridge-too-old', 'bridge-too-new', 'declaration-invalid'].includes(w.status)
|
|
13959
|
+
&& typeof w.agent === 'string' && w.agent.trim() && typeof w.name === 'string' && w.name.trim()
|
|
13960
|
+
&& typeof w.detail === 'string' && w.detail.trim() && (w.via === null || typeof w.via === 'string')
|
|
13961
|
+
&& Array.isArray(w.choices) && w.choices.every((choice) => typeof choice === 'string')) : [];
|
|
13962
|
+
const bridge = bridgeWarnings.map((w) => `\n${w.status === 'declaration-invalid' ? 'Ran with an invalid bridge declaration' : 'Ran with a bridge mismatch'}: ${w.via ? w.via + ' → ' : ''}${w.name}. ${w.detail}`).join('');
|
|
13963
|
+
return `Last run ${lr.status}${lr.reason ? ' — ' + lr.reason : ''}${warnings.length ? ' — ' + warnings.join(' ') : ''} · ${absTime(lr.at)}${dur}${carried}${bridge}`;
|
|
13853
13964
|
}
|
|
13854
13965
|
|
|
13855
13966
|
// ── Trigger-routine row helpers ─────────────────────────────────────────────
|
|
@@ -13924,6 +14035,7 @@
|
|
|
13924
14035
|
completeReportDiscoveryEpoch.set(id, (completeReportDiscoveryEpoch.get(id) || 0) + 1);
|
|
13925
14036
|
}
|
|
13926
14037
|
for (const id of live) void refreshRoutineReportDiscovery(id);
|
|
14038
|
+
if (routinesData.some((r) => r.agent)) void refreshRoutineAgents();
|
|
13927
14039
|
if ($routinesModal.classList.contains('show')) renderRoutinesList();
|
|
13928
14040
|
// Last, and on its own: a landing repaint that throws must not skip the reconcile above.
|
|
13929
14041
|
if (wfLanding && chipsChanged) {
|
|
@@ -13932,6 +14044,33 @@
|
|
|
13932
14044
|
} catch (err) { console.warn('Routines could not be loaded', err); }
|
|
13933
14045
|
}
|
|
13934
14046
|
|
|
14047
|
+
/** #2035: one line on how an agent run is going, from the run the routine started (never a copied count). */
|
|
14048
|
+
function agentRunStateText(run) {
|
|
14049
|
+
if (!run) return '';
|
|
14050
|
+
const lives = run.targets.map((t) => t.live);
|
|
14051
|
+
const declined = run.targets.reduce((sum, t) => sum + (t.declines ? t.declines.list.filter((d) => d.state === 'declined').length + t.declines.moreDeclined : 0), 0);
|
|
14052
|
+
const tail = declined ? ` · ${declined} step${declined === 1 ? '' : 's'} declined — see Questions for you on the Agents page` : '';
|
|
14053
|
+
if (lives.some((l) => l === 'working' || l === 'starting' || l === 'waiting')) return `Running${tail}`;
|
|
14054
|
+
if (lives.some((l) => l === 'failed' || l === 'failed-reply' || l === 'uncertain' || l === 'needs-recovery')) return `Needs a look on the Agents page${tail}`;
|
|
14055
|
+
return `Done${tail}`;
|
|
14056
|
+
}
|
|
14057
|
+
|
|
14058
|
+
async function refreshRoutineAgents() {
|
|
14059
|
+
const agentsApi = window.flolessAgents;
|
|
14060
|
+
if (!agentsApi?.list) return;
|
|
14061
|
+
try {
|
|
14062
|
+
for (const agent of await agentsApi.list()) routineAgentNames.set(agent.agentId, agent.name);
|
|
14063
|
+
} catch (err) { console.warn('Agent names for routines could not be loaded', err); }
|
|
14064
|
+
await Promise.all(routinesData.filter((r) => r.agent && r.lastRun?.agentRunId).map(async (r) => {
|
|
14065
|
+
try {
|
|
14066
|
+
const body = await agentsApi.runs(r.agent.agentId);
|
|
14067
|
+
const run = (body.runs || []).find((row) => row.runId === r.lastRun.agentRunId);
|
|
14068
|
+
routineAgentRunState.set(r.id, run ? agentRunStateText(run) : '');
|
|
14069
|
+
} catch { routineAgentRunState.delete(r.id); }
|
|
14070
|
+
}));
|
|
14071
|
+
if ($routinesModal.classList.contains('show')) renderRoutinesList();
|
|
14072
|
+
}
|
|
14073
|
+
|
|
13935
14074
|
// SSE: a trigger routine's live session snapshot changed. Update the in-memory
|
|
13936
14075
|
// row and re-render; flash the row when its fired count climbs (a real event).
|
|
13937
14076
|
function applyTriggerSnapshot(id, snapshot) {
|
|
@@ -14239,11 +14378,13 @@
|
|
|
14239
14378
|
} else {
|
|
14240
14379
|
statusEl = running
|
|
14241
14380
|
? '<span class="rtn-spinner" data-tip="Running now…"></span>'
|
|
14242
|
-
: `<span class="rtn-status ${escapeAttr(r.lastRun ? r.lastRun.status : '')}" data-tip="${escapeAttr(lastRunTip(r))}"></span>`;
|
|
14381
|
+
: `<span class="rtn-status ${escapeAttr(r.lastRun ? ({ started: 'ok', starting: '' }[r.lastRun.status] ?? r.lastRun.status) : '')}" data-tip="${escapeAttr(lastRunTip(r))}"></span>`;
|
|
14243
14382
|
nextTip = r.nextFireAt ? `Next run: ${absTime(r.nextFireAt)}` : (r.broken ? r.broken.reason : r.enabled ? 'Not scheduled' : 'Disabled');
|
|
14244
14383
|
nextLabel = !r.enabled ? 'disabled' : r.broken ? 'broken' : relTime(r.nextFireAt);
|
|
14245
14384
|
}
|
|
14246
14385
|
const whenText = isTrigger ? triggerWhenText(r) : scheduleText(r.schedule);
|
|
14386
|
+
// #2035: an agent routine names its agent, not a workflow id.
|
|
14387
|
+
const whatText = r.agent ? `Agent · ${routineAgentNames.get(r.agent.agentId) || 'agent'}` : r.workflow;
|
|
14247
14388
|
const toggleTip = isTrigger ? (r.enabled ? 'Stop listening' : 'Start listening') : `${r.enabled ? 'Disable' : 'Enable'} this routine`;
|
|
14248
14389
|
// One sentence for all three surfaces a blocked ▶ speaks through: the hover tip, the `?`
|
|
14249
14390
|
// band (which reads data-blocked-reason), and the toast when a click still reaches the
|
|
@@ -14262,7 +14403,7 @@
|
|
|
14262
14403
|
<div class="rtn-item ${isTrigger ? 'trigger ' : ''}${r.enabled ? '' : 'disabled'} ${running ? 'running' : ''}" data-id="${escapeAttr(r.id)}">
|
|
14263
14404
|
<div class="rtn-main">
|
|
14264
14405
|
<div class="rtn-name">${escapeHtml(r.name)}</div>
|
|
14265
|
-
<div class="rtn-sub"><span class="rtn-wf">${escapeHtml(
|
|
14406
|
+
<div class="rtn-sub"><span class="rtn-wf">${escapeHtml(whatText)}</span><span class="rtn-dot">·</span><span>${escapeHtml(whenText)}</span>${broken}</div>
|
|
14266
14407
|
${reportLine}
|
|
14267
14408
|
</div>
|
|
14268
14409
|
<div class="rtn-meta"${isTrigger ? ' aria-live="polite" aria-atomic="true"' : ''}>
|
|
@@ -14276,6 +14417,7 @@
|
|
|
14276
14417
|
</label>
|
|
14277
14418
|
${isTrigger ? '' : `<button class="rtn-act" data-rtn-run="${escapeAttr(r.id)}" data-command-id="shell.routine-run#${escapeAttr(r.id)}" data-command-instance-label="${escapeAttr(r.name)}" aria-label="Run ${escapeAttr(r.name)} now" data-tip="${escapeAttr(runTip)}"${running ? ` disabled data-blocked-reason="${escapeAttr(RTN_ALREADY_RUNNING)}"` : ''}>▶</button>`}
|
|
14278
14419
|
${isCompleteReport && discovery?.report && !discovery.checking ? `<button class="rtn-act rtn-report-view" data-rtn-report="${escapeAttr(r.id)}" data-command-id="shell.routine-view-report#${escapeAttr(r.id)}" data-command-instance-label="${escapeAttr(r.name)}" aria-label="View saved report for ${escapeAttr(r.name)}" data-tip="View the verified, read-only report">View report</button>` : ''}
|
|
14420
|
+
${r.agent ? `<button class="rtn-act" data-rtn-agent="${escapeAttr(r.agent.agentId)}" data-command-id="shell.routine-open-agent#${escapeAttr(r.id)}" data-command-instance-label="${escapeAttr(r.name)}" aria-label="Open the agent that ${escapeAttr(r.name)} runs" data-tip="Open this agent and its runs on the Agents page">Agent</button>` : ''}
|
|
14279
14421
|
<button class="rtn-act" data-rtn-edit="${escapeAttr(r.id)}" data-tip="Edit">✎</button>
|
|
14280
14422
|
<button class="rtn-act rtn-del-act" data-rtn-del="${escapeAttr(r.id)}" data-tip="Delete">×</button>
|
|
14281
14423
|
</div>
|
|
@@ -14285,6 +14427,7 @@
|
|
|
14285
14427
|
$list.querySelectorAll('[data-rtn-run]').forEach((b) => { b.onclick = () => runRoutineNow(b.dataset.rtnRun); });
|
|
14286
14428
|
$list.querySelectorAll('[data-rtn-report]').forEach((b) => { b.onclick = () => { void viewScheduledCompleteReport(b.dataset.rtnReport); }; });
|
|
14287
14429
|
$list.querySelectorAll('[data-rtn-edit]').forEach((b) => { b.onclick = () => openRoutineEdit(b.dataset.rtnEdit); });
|
|
14430
|
+
$list.querySelectorAll('[data-rtn-agent]').forEach((b) => { b.onclick = () => { hideModal($routinesModal); void window.flolessAgents?.open?.(b.dataset.rtnAgent); }; });
|
|
14288
14431
|
$list.querySelectorAll('[data-rtn-del]').forEach((b) => { b.onclick = () => deleteRoutineUi(b.dataset.rtnDel); });
|
|
14289
14432
|
}
|
|
14290
14433
|
|
|
@@ -14352,6 +14495,89 @@
|
|
|
14352
14495
|
} catch (e) { reportErr(e); }
|
|
14353
14496
|
}
|
|
14354
14497
|
|
|
14498
|
+
/** #2035: what the routine runs — a workflow, or an agent (always on a schedule, no inputs). */
|
|
14499
|
+
function setRoutineTarget(target) {
|
|
14500
|
+
editTarget = target === 'agent' ? 'agent' : 'workflow';
|
|
14501
|
+
const agent = editTarget === 'agent';
|
|
14502
|
+
document.querySelectorAll('#rtn-target-field .rtn-mode-btn').forEach((b) => {
|
|
14503
|
+
const on = b.dataset.target === editTarget;
|
|
14504
|
+
b.classList.toggle('active', on);
|
|
14505
|
+
b.setAttribute('aria-pressed', on ? 'true' : 'false');
|
|
14506
|
+
});
|
|
14507
|
+
document.getElementById('rtn-workflow-field').hidden = agent;
|
|
14508
|
+
document.getElementById('rtn-agent-field').hidden = !agent;
|
|
14509
|
+
document.getElementById('rtn-edit-sub').textContent = agent
|
|
14510
|
+
? 'Pick an agent and when it should run. Nobody watches a scheduled run, so anything that would ask you is declined and listed for you afterwards.'
|
|
14511
|
+
: 'Pick a workflow and when it should run.';
|
|
14512
|
+
if (agent) {
|
|
14513
|
+
document.getElementById('rtn-inputs-field').hidden = true;
|
|
14514
|
+
document.getElementById('rtn-mode-field').hidden = true;
|
|
14515
|
+
setRoutineMode('schedule');
|
|
14516
|
+
paintRoutineAgentNote();
|
|
14517
|
+
} else {
|
|
14518
|
+
// Back to the workflow: what it already loaded comes straight back (#2035 QA), nothing is fetched again.
|
|
14519
|
+
document.getElementById('rtn-inputs-field').hidden = !document.getElementById('rtn-inputs').children.length;
|
|
14520
|
+
applyRoutineModeAvailability();
|
|
14521
|
+
}
|
|
14522
|
+
}
|
|
14523
|
+
|
|
14524
|
+
function setRoutineAgentAi(ai) {
|
|
14525
|
+
editAgentAi = ai === 'codex' ? 'codex' : 'claude';
|
|
14526
|
+
document.querySelectorAll('#rtn-agent-ai .rtn-mode-btn').forEach((b) => {
|
|
14527
|
+
const on = b.dataset.ai === editAgentAi;
|
|
14528
|
+
b.classList.toggle('active', on);
|
|
14529
|
+
b.setAttribute('aria-pressed', on ? 'true' : 'false');
|
|
14530
|
+
});
|
|
14531
|
+
}
|
|
14532
|
+
|
|
14533
|
+
/** The AI a new agent routine starts with: the agent's own, else the one last chosen to run an agent by hand. */
|
|
14534
|
+
function defaultRoutineAgentAi(agent) {
|
|
14535
|
+
if (agent?.provider) return agent.provider;
|
|
14536
|
+
try { const last = localStorage.getItem('floless:agents-provider'); if (last === 'codex' || last === 'claude') return last; } catch { /* private mode */ }
|
|
14537
|
+
return 'claude';
|
|
14538
|
+
}
|
|
14539
|
+
|
|
14540
|
+
function paintRoutineAgentNote() {
|
|
14541
|
+
const $note = document.getElementById('rtn-agent-note');
|
|
14542
|
+
const agent = editAgents.find((a) => a.agentId === document.getElementById('rtn-agent').value);
|
|
14543
|
+
if (!agent) { $note.textContent = ''; return; }
|
|
14544
|
+
const access = agent.allowChanges
|
|
14545
|
+
? 'Can change files, so it runs in Auto. Anything that would ask you is declined and listed afterwards on the Agents page.'
|
|
14546
|
+
: 'Read only. It reads and reports.';
|
|
14547
|
+
$note.textContent = access;
|
|
14548
|
+
}
|
|
14549
|
+
|
|
14550
|
+
async function loadRoutineAgents(selectedId, fixed) {
|
|
14551
|
+
const $agent = document.getElementById('rtn-agent');
|
|
14552
|
+
const $empty = document.getElementById('rtn-agent-empty');
|
|
14553
|
+
try { editAgents = (await window.flolessAgents?.list?.()) || []; }
|
|
14554
|
+
catch { editAgents = null; }
|
|
14555
|
+
const usable = (editAgents || []).filter((a) => !a.archivedAt || a.agentId === selectedId);
|
|
14556
|
+
for (const a of usable) routineAgentNames.set(a.agentId, a.name);
|
|
14557
|
+
// Editing a routine whose agent is gone: say so, never show another agent's name in the locked picker.
|
|
14558
|
+
const gone = fixed && selectedId && editAgents && !usable.some((a) => a.agentId === selectedId);
|
|
14559
|
+
$agent.innerHTML = (gone ? `<option value="${escapeAttr(selectedId)}">This agent no longer exists</option>` : '')
|
|
14560
|
+
+ usable.map((a) => `<option value="${escapeAttr(a.agentId)}">${escapeHtml(a.name)}${a.allowChanges ? '' : ' (read only)'}</option>`).join('');
|
|
14561
|
+
if (selectedId) $agent.value = selectedId;
|
|
14562
|
+
const shown = usable.length > 0 || Boolean(gone);
|
|
14563
|
+
// The select is shown as the shared themed combobox, its next sibling: hide that, not the hidden native control.
|
|
14564
|
+
const combo = $agent.nextElementSibling?.classList.contains('sel-combo') ? $agent.nextElementSibling : null;
|
|
14565
|
+
if (combo) combo.style.display = shown ? '' : 'none';
|
|
14566
|
+
$agent.hidden = !shown;
|
|
14567
|
+
$empty.hidden = shown;
|
|
14568
|
+
if (editAgents === null) {
|
|
14569
|
+
$empty.hidden = false;
|
|
14570
|
+
$empty.firstChild.textContent = 'FloLess couldn’t list your agents just now. Close this and open it again, or ';
|
|
14571
|
+
} else {
|
|
14572
|
+
$empty.firstChild.textContent = 'No agents in this workspace folder yet. ';
|
|
14573
|
+
}
|
|
14574
|
+
document.getElementById('rtn-agent-ai').hidden = !usable.length;
|
|
14575
|
+
$agent.disabled = Boolean(fixed);
|
|
14576
|
+
if (fixed) $agent.setAttribute('data-tip', 'The agent is fixed — create a new routine to run a different one');
|
|
14577
|
+
else $agent.removeAttribute('data-tip');
|
|
14578
|
+
paintRoutineAgentNote();
|
|
14579
|
+
}
|
|
14580
|
+
|
|
14355
14581
|
// Schedule builder: reveal only the fields the chosen kind needs.
|
|
14356
14582
|
// Switch the edit form between schedule and trigger layouts. Hides the schedule
|
|
14357
14583
|
// builder and shows the read-only trigger-source line for 'trigger' (only honored
|
|
@@ -14411,7 +14637,9 @@
|
|
|
14411
14637
|
|
|
14412
14638
|
// Render the chosen workflow's declared inputs (seeded from defaults / the routine's
|
|
14413
14639
|
// saved values). Hidden when the workflow declares none.
|
|
14640
|
+
let routineInputsLoad = 0; // #2035: only the newest load builds the inputs; an older one that returns late is dropped
|
|
14414
14641
|
async function loadRoutineInputs(workflowId, prefill) {
|
|
14642
|
+
const load = ++routineInputsLoad;
|
|
14415
14643
|
const $field = document.getElementById('rtn-inputs-field');
|
|
14416
14644
|
const $inputs = document.getElementById('rtn-inputs');
|
|
14417
14645
|
$inputs.innerHTML = '';
|
|
@@ -14419,8 +14647,9 @@
|
|
|
14419
14647
|
editTriggerSource = null;
|
|
14420
14648
|
if (!workflowId) { applyRoutineModeAvailability(); return; }
|
|
14421
14649
|
let app;
|
|
14422
|
-
try { ({ app } = await api(`/api/app/${encodeURIComponent(workflowId)}`)); } catch { applyRoutineModeAvailability(); return; }
|
|
14650
|
+
try { ({ app } = await api(`/api/app/${encodeURIComponent(workflowId)}`)); } catch { if (editTarget === 'workflow') applyRoutineModeAvailability(); return; }
|
|
14423
14651
|
if (document.getElementById('rtn-workflow').value !== workflowId) return; // a newer workflow selection superseded this fetch
|
|
14652
|
+
if (load !== routineInputsLoad || editTarget !== 'workflow') return; // #2035: superseded, or switched to An agent meanwhile
|
|
14424
14653
|
editTriggerSource = (app && app.triggerSource) || null;
|
|
14425
14654
|
applyRoutineModeAvailability(); // reveal/hide the schedule-vs-trigger chooser
|
|
14426
14655
|
const inps = (app && app.inputs) || [];
|
|
@@ -14430,7 +14659,7 @@
|
|
|
14430
14659
|
const routineModelModule = inps.find((inp) => inp.widget === 'workspace-model-revision')?.workspaceModule === 'tekla' ? 'tekla' : 'revit';
|
|
14431
14660
|
const bootstrap = await bootstrapEditorSession();
|
|
14432
14661
|
routineModelRevisions = bootstrap.ok ? await fetchApprovedModelRevisions(routineModelModule) : unavailableModelRevisionResult(bootstrap.error);
|
|
14433
|
-
if (document.getElementById('rtn-workflow').value !== workflowId) return;
|
|
14662
|
+
if (document.getElementById('rtn-workflow').value !== workflowId || load !== routineInputsLoad || editTarget !== 'workflow') return;
|
|
14434
14663
|
}
|
|
14435
14664
|
$field.hidden = false;
|
|
14436
14665
|
// The DOM id is index-based (not the workflow-controlled input name) so a crafted
|
|
@@ -14496,9 +14725,10 @@
|
|
|
14496
14725
|
return out;
|
|
14497
14726
|
}
|
|
14498
14727
|
|
|
14499
|
-
async function openRoutineEdit(id) {
|
|
14728
|
+
async function openRoutineEdit(id, opts = {}) {
|
|
14500
14729
|
editingRoutineId = id || null;
|
|
14501
14730
|
const r = id ? routinesData.find((x) => x.id === id) : null;
|
|
14731
|
+
editReturnFocus = opts.returnFocus || null;
|
|
14502
14732
|
const $wf = document.getElementById('rtn-workflow');
|
|
14503
14733
|
try {
|
|
14504
14734
|
const { apps: list } = await api('/api/apps');
|
|
@@ -14507,7 +14737,12 @@
|
|
|
14507
14737
|
$wf.innerHTML = editWorkflows.map((a) => `<option value="${escapeAttr(a.id)}">${escapeHtml(a.id)}</option>`).join('');
|
|
14508
14738
|
document.getElementById('rtn-edit-title').textContent = r ? 'Edit routine' : 'New routine';
|
|
14509
14739
|
document.getElementById('rtn-name').value = r ? r.name : '';
|
|
14510
|
-
|
|
14740
|
+
// #2046: a Guide suggestion names the workflow; it is preselected only when it is one of the choices.
|
|
14741
|
+
const suggested = !r && opts.workflowId && editWorkflows.some((a) => a.id === opts.workflowId) ? opts.workflowId : null;
|
|
14742
|
+
if (!r && opts.workflowId && !suggested) {
|
|
14743
|
+
showToast(`${opts.workflowId} can’t be scheduled from here, so no workflow is chosen yet. Pick the one to run in the list.`, 'warn');
|
|
14744
|
+
}
|
|
14745
|
+
const wfId = r ? r.workflow : opts.workflowId && !suggested ? '' : (suggested || (editWorkflows[0] ? editWorkflows[0].id : ''));
|
|
14511
14746
|
$wf.value = wfId;
|
|
14512
14747
|
// Workflow is fixed after create (inputs are coerced against it) — disable on edit.
|
|
14513
14748
|
$wf.disabled = !!r;
|
|
@@ -14524,19 +14759,38 @@
|
|
|
14524
14759
|
renderDayChips(sched.kind === 'weekly' ? (sched.days || []) : []);
|
|
14525
14760
|
applySchedKind(sched.kind);
|
|
14526
14761
|
document.getElementById('rtn-enabled').checked = r ? r.enabled : true;
|
|
14527
|
-
|
|
14762
|
+
// #2035: what it runs is fixed after create, like the workflow.
|
|
14763
|
+
const agentId = r?.agent?.agentId || opts.agentId || null;
|
|
14764
|
+
document.getElementById('rtn-target-field').hidden = Boolean(r);
|
|
14765
|
+
await loadRoutineAgents(agentId, Boolean(r));
|
|
14766
|
+
setRoutineAgentAi(r?.agent?.provider || defaultRoutineAgentAi((editAgents || []).find((a) => a.agentId === document.getElementById('rtn-agent').value)));
|
|
14767
|
+
if (agentId) setRoutineTarget('agent');
|
|
14768
|
+
else {
|
|
14769
|
+
setRoutineTarget('workflow');
|
|
14770
|
+
await loadRoutineInputs(wfId, r ? r.inputs : null);
|
|
14771
|
+
}
|
|
14528
14772
|
showModal($routineEditModal);
|
|
14529
14773
|
setTimeout(() => document.getElementById('rtn-name').focus(), 0);
|
|
14530
14774
|
}
|
|
14531
14775
|
|
|
14776
|
+
function closeRoutineEdit() {
|
|
14777
|
+
hideModal($routineEditModal);
|
|
14778
|
+
const back = editReturnFocus;
|
|
14779
|
+
editReturnFocus = null;
|
|
14780
|
+
if (back && back.isConnected) setTimeout(() => back.focus(), 0);
|
|
14781
|
+
}
|
|
14782
|
+
|
|
14532
14783
|
async function saveRoutine() {
|
|
14533
14784
|
const name = document.getElementById('rtn-name').value.trim();
|
|
14534
14785
|
if (!name) { showToast('Name is required', 'warn'); return; }
|
|
14786
|
+
const asAgent = editTarget === 'agent';
|
|
14787
|
+
const agentId = document.getElementById('rtn-agent').value;
|
|
14788
|
+
if (asAgent && !agentId && !editingRoutineId) { showToast('Pick an agent — or create one on the Agents page first', 'warn'); return; }
|
|
14535
14789
|
const workflow = document.getElementById('rtn-workflow').value;
|
|
14536
|
-
if (!workflow) { showToast('Pick a workflow', 'warn'); return; }
|
|
14537
|
-
const inputs = collectRoutineInputs();
|
|
14790
|
+
if (!asAgent && !workflow) { showToast('Pick a workflow', 'warn'); return; }
|
|
14791
|
+
const inputs = asAgent ? {} : collectRoutineInputs();
|
|
14538
14792
|
const enabled = document.getElementById('rtn-enabled').checked;
|
|
14539
|
-
const asTrigger = editRoutineMode === 'trigger' && !!editTriggerSource;
|
|
14793
|
+
const asTrigger = !asAgent && editRoutineMode === 'trigger' && !!editTriggerSource;
|
|
14540
14794
|
let schedule;
|
|
14541
14795
|
if (!asTrigger) {
|
|
14542
14796
|
const kind = document.getElementById('rtn-kind').value;
|
|
@@ -14560,23 +14814,43 @@
|
|
|
14560
14814
|
}
|
|
14561
14815
|
try {
|
|
14562
14816
|
if (editingRoutineId) {
|
|
14563
|
-
const body = asTrigger ? { name, inputs, enabled } : { name, schedule, inputs, enabled };
|
|
14817
|
+
const body = asAgent ? { name, schedule, enabled, provider: editAgentAi } : asTrigger ? { name, inputs, enabled } : { name, schedule, inputs, enabled };
|
|
14564
14818
|
await api(`/api/routines/${encodeURIComponent(editingRoutineId)}`, { method: 'PATCH', body: JSON.stringify(body) });
|
|
14565
14819
|
showToast('Routine updated', 'ok');
|
|
14566
14820
|
} else {
|
|
14567
|
-
const body =
|
|
14821
|
+
const body = asAgent ? { name, agentId, provider: editAgentAi, schedule, enabled }
|
|
14822
|
+
: asTrigger ? { kind: 'trigger', name, workflow, inputs, enabled } : { name, workflow, schedule, inputs, enabled };
|
|
14568
14823
|
await api('/api/routines', { method: 'POST', body: JSON.stringify(body) });
|
|
14569
14824
|
showToast('Routine created', 'ok');
|
|
14570
14825
|
}
|
|
14571
|
-
|
|
14826
|
+
closeRoutineEdit();
|
|
14572
14827
|
await loadRoutinesData();
|
|
14573
|
-
} catch (e) {
|
|
14828
|
+
} catch (e) {
|
|
14829
|
+
// #2035: the server words an agent routine's refusal for the person (archived, another folder…); say that.
|
|
14830
|
+
const said = asAgent && typeof e?.body?.error === 'string' && e.status < 500 ? e.body.error : null;
|
|
14831
|
+
showToast(said || 'We couldn’t save this routine because FloLess could not save the change. Try again.', 'err');
|
|
14832
|
+
}
|
|
14833
|
+
}
|
|
14834
|
+
|
|
14835
|
+
// #2035 (PR #2045 review): a routine only starts its agent, so "how the run is going" changes long after the routine's
|
|
14836
|
+
// own events. While the dialog is open, and an agent run it started may still be going, ask again every few seconds.
|
|
14837
|
+
let routineAgentPoll = null;
|
|
14838
|
+
function pollRoutineAgents() {
|
|
14839
|
+
clearTimeout(routineAgentPoll);
|
|
14840
|
+
routineAgentPoll = setTimeout(async () => {
|
|
14841
|
+
if (!$routinesModal.classList.contains('show')) return;
|
|
14842
|
+
const going = routinesData.some((r) => r.agent && (r.lastRun?.status === 'starting'
|
|
14843
|
+
|| (r.lastRun?.status === 'started' && !/^(Done|Needs a look)/.test(routineAgentRunState.get(r.id) || ''))));
|
|
14844
|
+
if (going) await refreshRoutineAgents();
|
|
14845
|
+
pollRoutineAgents();
|
|
14846
|
+
}, 8000);
|
|
14574
14847
|
}
|
|
14575
14848
|
|
|
14576
14849
|
openRoutines = function openRoutinesReal() {
|
|
14577
14850
|
renderRoutinesList();
|
|
14578
14851
|
showModal($routinesModal);
|
|
14579
14852
|
loadRoutinesData();
|
|
14853
|
+
pollRoutineAgents();
|
|
14580
14854
|
};
|
|
14581
14855
|
|
|
14582
14856
|
// Wiring (the modal elements are static in index.html, present when this runs).
|
|
@@ -14585,15 +14859,52 @@
|
|
|
14585
14859
|
document.getElementById('routines-close').onclick = () => hideModal($routinesModal);
|
|
14586
14860
|
onBackdropDismiss($routinesModal, () => hideModal($routinesModal));
|
|
14587
14861
|
document.getElementById('rtn-add').onclick = () => openRoutineEdit(null);
|
|
14588
|
-
document.getElementById('rtn-edit-cancel').onclick = () =>
|
|
14862
|
+
document.getElementById('rtn-edit-cancel').onclick = () => closeRoutineEdit();
|
|
14589
14863
|
document.getElementById('rtn-edit-save').onclick = () => saveRoutine();
|
|
14590
|
-
onBackdropDismiss($routineEditModal, () =>
|
|
14864
|
+
onBackdropDismiss($routineEditModal, () => closeRoutineEdit());
|
|
14591
14865
|
document.getElementById('rtn-kind').onchange = (e) => applySchedKind(e.target.value);
|
|
14592
14866
|
document.querySelectorAll('#rtn-mode-field .rtn-mode-btn').forEach((b) => { b.onclick = () => setRoutineMode(b.dataset.mode); });
|
|
14593
14867
|
document.getElementById('rtn-workflow').onchange = (e) => { if (!editingRoutineId) loadRoutineInputs(e.target.value, null); };
|
|
14868
|
+
document.querySelectorAll('#rtn-target-field .rtn-mode-btn').forEach((b) => {
|
|
14869
|
+
b.onclick = () => {
|
|
14870
|
+
setRoutineTarget(b.dataset.target);
|
|
14871
|
+
if (editTarget === 'agent') (document.getElementById('rtn-agent-combo-trigger') || document.getElementById('rtn-agent')).focus();
|
|
14872
|
+
// A load the switch to An agent cut short left nothing to restore: load it now (the newest load wins).
|
|
14873
|
+
else if (!document.getElementById('rtn-inputs').children.length) void loadRoutineInputs(document.getElementById('rtn-workflow').value, null);
|
|
14874
|
+
};
|
|
14875
|
+
});
|
|
14876
|
+
document.getElementById('rtn-agent').onchange = () => {
|
|
14877
|
+
paintRoutineAgentNote();
|
|
14878
|
+
if (!editingRoutineId) setRoutineAgentAi(defaultRoutineAgentAi((editAgents || []).find((a) => a.agentId === document.getElementById('rtn-agent').value)));
|
|
14879
|
+
};
|
|
14880
|
+
document.querySelectorAll('#rtn-agent-ai .rtn-mode-btn').forEach((b) => { b.onclick = () => setRoutineAgentAi(b.dataset.ai); });
|
|
14881
|
+
document.getElementById('rtn-agent-create').onclick = () => {
|
|
14882
|
+
closeRoutineEdit(); hideModal($routinesModal);
|
|
14883
|
+
void window.flolessWorkspaces?.setMode?.('agents');
|
|
14884
|
+
};
|
|
14885
|
+
// #2035: an agent's page opens a new routine with that agent chosen.
|
|
14886
|
+
window.flolessRoutines = {
|
|
14887
|
+
/** #2046: a Guide suggestion — a new routine for this workflow, opened for the person to finish. */
|
|
14888
|
+
async editForWorkflow(workflowId, returnFocus) {
|
|
14889
|
+
await loadRoutinesData();
|
|
14890
|
+
if (routinesData.length >= routinesMax) {
|
|
14891
|
+
showToast(`You already have ${routinesMax} routines. Delete one in Routines (≡ menu), then schedule this workflow.`, 'warn');
|
|
14892
|
+
return;
|
|
14893
|
+
}
|
|
14894
|
+
await openRoutineEdit(null, { workflowId, returnFocus });
|
|
14895
|
+
},
|
|
14896
|
+
async editForAgent(agentId, returnFocus) {
|
|
14897
|
+
await loadRoutinesData();
|
|
14898
|
+
if (routinesData.length >= routinesMax) {
|
|
14899
|
+
showToast(`You already have ${routinesMax} routines. Delete one in Routines (≡ menu), then schedule this agent.`, 'warn');
|
|
14900
|
+
return;
|
|
14901
|
+
}
|
|
14902
|
+
await openRoutineEdit(null, { agentId, returnFocus });
|
|
14903
|
+
},
|
|
14904
|
+
};
|
|
14594
14905
|
document.addEventListener('keydown', (e) => {
|
|
14595
14906
|
if (e.key !== 'Escape') return;
|
|
14596
|
-
if ($routineEditModal.classList.contains('show'))
|
|
14907
|
+
if ($routineEditModal.classList.contains('show')) closeRoutineEdit();
|
|
14597
14908
|
else if ($routinesModal.classList.contains('show')) hideModal($routinesModal);
|
|
14598
14909
|
});
|
|
14599
14910
|
|
|
@@ -15529,6 +15840,57 @@
|
|
|
15529
15840
|
}
|
|
15530
15841
|
|
|
15531
15842
|
// ── Workflows landing (#1890) ─────────────────────────────────────────────────
|
|
15843
|
+
async function restoreOwnedWorkflow(workflowId) {
|
|
15844
|
+
const row = wfOwned.find((item) => item.workflowId === workflowId && item.status === 'archived');
|
|
15845
|
+
if (!row || restoringWorkflows.has(workflowId)) return;
|
|
15846
|
+
const selectionAtStart = selectionTicket;
|
|
15847
|
+
const ownsFocus = (element) => element?.dataset?.wfRestore === workflowId;
|
|
15848
|
+
let returnFocus = ownsFocus(document.activeElement);
|
|
15849
|
+
const trackFocus = (event) => {
|
|
15850
|
+
if (event.target !== document.body && !ownsFocus(event.target)) returnFocus = false;
|
|
15851
|
+
};
|
|
15852
|
+
document.addEventListener('focusin', trackFocus);
|
|
15853
|
+
let restored = false;
|
|
15854
|
+
restoringWorkflows.add(workflowId);
|
|
15855
|
+
renderWorkflowsLanding();
|
|
15856
|
+
try {
|
|
15857
|
+
const { workflow } = await api(`/api/workflows/owned/${encodeURIComponent(workflowId)}/archive`, {
|
|
15858
|
+
method: 'POST', body: JSON.stringify({ archived: false }),
|
|
15859
|
+
});
|
|
15860
|
+
restored = true;
|
|
15861
|
+
appsLoadGeneration += 1; // a listing started before this committed restore cannot erase it
|
|
15862
|
+
if (selectionTicket === selectionAtStart) selectionTicket += 1;
|
|
15863
|
+
const committed = { ...row, ...workflow, restoreRefreshState: 'pending' };
|
|
15864
|
+
wfOwned = wfOwned.filter((item) => item.workflowId !== workflowId).concat(committed);
|
|
15865
|
+
if (wfLanding) renderWorkflowsLanding();
|
|
15866
|
+
let refreshFailed = false;
|
|
15867
|
+
try { await loadApps({ preserveSelection: true }); }
|
|
15868
|
+
catch { refreshFailed = true; }
|
|
15869
|
+
// An unavailable additive owned list is deliberately tolerated by loadApps, but is still
|
|
15870
|
+
// not a fresh confirmation. The POST succeeded regardless of that later read's outcome.
|
|
15871
|
+
if (refreshFailed || wfOwned.some((item) => item.workflowId === workflowId && item.restoreRefreshState)) {
|
|
15872
|
+
wfOwned = wfOwned.map((item) => item.workflowId === workflowId && item.status !== 'archived'
|
|
15873
|
+
? { ...item, restoreRefreshState: 'failed' } : item);
|
|
15874
|
+
showToast(`Restored “${row.displayName}”. The list could not refresh. Reload this page to show it.`, 'warn');
|
|
15875
|
+
} else showToast(`Restored “${row.displayName}”`, 'ok');
|
|
15876
|
+
} catch (error) { reportErr(error); }
|
|
15877
|
+
finally {
|
|
15878
|
+
restoringWorkflows.delete(workflowId);
|
|
15879
|
+
document.removeEventListener('focusin', trackFocus);
|
|
15880
|
+
if (wfLanding) {
|
|
15881
|
+
renderWorkflowsLanding();
|
|
15882
|
+
if (returnFocus && (document.activeElement === document.body || ownsFocus(document.activeElement))
|
|
15883
|
+
&& !document.getElementById('app')?.classList.contains('mode-workspaces')) {
|
|
15884
|
+
const publication = wfLibrary.find((item) => item.ownedWorkflow?.workflowId === workflowId);
|
|
15885
|
+
const target = restored
|
|
15886
|
+
? $wfLanding.querySelector(`[data-wf-restored="${CSS.escape(workflowId)}"]`)
|
|
15887
|
+
|| $wfLanding.querySelector(publication ? `[data-wf-id="${CSS.escape(publication.id)}"]` : `[data-wf-draft="${CSS.escape(workflowId)}"]`)
|
|
15888
|
+
: $wfLanding.querySelector(`[data-wf-restore="${CSS.escape(workflowId)}"]`);
|
|
15889
|
+
(target && !target.hidden ? target : document.getElementById('wf-landing-title'))?.focus();
|
|
15890
|
+
}
|
|
15891
|
+
}
|
|
15892
|
+
}
|
|
15893
|
+
}
|
|
15532
15894
|
// The Workflows tab's home, the counterpart of the Workspaces landing: a create card and one card per workflow. It
|
|
15533
15895
|
// renders AWARE's library listing; it composes nothing.
|
|
15534
15896
|
const $wfLanding = document.getElementById('wf-landing');
|
|
@@ -15573,11 +15935,30 @@
|
|
|
15573
15935
|
const keepCaret = search ? [search.selectionStart, search.selectionEnd] : null;
|
|
15574
15936
|
const clearFocused = document.activeElement?.id === 'wf-search-clear';
|
|
15575
15937
|
const focusedDraft = document.activeElement?.closest?.('#wf-landing [data-wf-draft]')?.dataset.wfDraft || null;
|
|
15938
|
+
const focusedRestore = document.activeElement?.closest?.('[data-wf-restore]')?.dataset.wfRestore || null;
|
|
15939
|
+
const focusedRestored = document.activeElement?.closest?.('[data-wf-restored]')?.dataset.wfRestored || null;
|
|
15576
15940
|
const esc = (s) => String(s ?? '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
15577
|
-
const
|
|
15941
|
+
const restoredRows = wfOwned.filter((row) => row.status !== 'archived' && row.restoreRefreshState);
|
|
15942
|
+
const restoredIds = new Set(restoredRows.map((row) => row.workflowId));
|
|
15943
|
+
const owned = wfLibrary.filter((row) => row.ownedWorkflow && !restoredIds.has(row.ownedWorkflow.workflowId));
|
|
15578
15944
|
const installed = wfLibrary.filter((row) => !row.ownedWorkflow);
|
|
15579
15945
|
// #1890 PR 3b-0: owned workflows the library does not list — drafts, and ones whose installed copy is gone.
|
|
15580
|
-
const unlisted = unlistedOwnedWorkflows();
|
|
15946
|
+
const unlisted = unlistedOwnedWorkflows().filter((row) => !restoredIds.has(row.workflowId));
|
|
15947
|
+
const archived = wfOwned.filter((row) => row.status === 'archived');
|
|
15948
|
+
const restoredCard = (row) => `<div class="ws-card wf-card wf-card-archived" tabindex="-1" data-wf-restored="${esc(row.workflowId)}">`
|
|
15949
|
+
+ `<div class="ws-body"><div class="wf-card-text"><span class="ws-kind wf-kind is-draft">Restored</span>`
|
|
15950
|
+
+ `<div class="ws-name">${esc(row.displayName)}</div><div class="ws-meta">${esc(row.ownerLabel || 'Standalone')}</div>`
|
|
15951
|
+
+ `<p class="wf-draft-body" role="status">${row.restoreRefreshState === 'failed'
|
|
15952
|
+
? 'Workflow restored. The list could not refresh. Reload this page to show it.' : 'Workflow restored. Refreshing workflow list…'}</p>`
|
|
15953
|
+
+ `</div></div></div>`;
|
|
15954
|
+
const archivedCard = (row) => {
|
|
15955
|
+
const busy = restoringWorkflows.has(row.workflowId);
|
|
15956
|
+
return `<div class="ws-card wf-card wf-card-archived" data-wf-archived="${esc(row.workflowId)}">`
|
|
15957
|
+
+ `<div class="ws-body"><div class="wf-card-text"><span class="ws-kind wf-kind is-draft">Archived</span>`
|
|
15958
|
+
+ `<div class="ws-name">${esc(row.displayName)}</div><div class="ws-meta">${esc(row.ownerLabel || 'Standalone')}</div>`
|
|
15959
|
+
+ `<div class="wf-draft-actions"><button type="button" data-wf-restore="${esc(row.workflowId)}" data-command-id="workflow.unarchive#${esc(row.workflowId)}" data-command-instance-label="${esc(row.displayName)}" data-tip="Restore this workflow to the Workflows page with its files, chat and history"${busy ? ' disabled aria-busy="true"' : ''}>${busy ? 'Restoring…' : 'Restore'}</button></div>`
|
|
15960
|
+
+ `</div></div></div>`;
|
|
15961
|
+
};
|
|
15581
15962
|
const draftCard = (row) => {
|
|
15582
15963
|
const recompile = Boolean(row.activePublication);
|
|
15583
15964
|
const name = row.displayName;
|
|
@@ -15601,24 +15982,27 @@
|
|
|
15601
15982
|
};
|
|
15602
15983
|
const group = (title, rows, show) => (rows.length
|
|
15603
15984
|
? `${show ? `<div class="wf-group-label">${esc(title)} (${rows.length})</div>` : ''}<div class="ws-grid">${rows.map(card).join('')}</div>` : '');
|
|
15604
|
-
const yours = unlisted.length + owned.length;
|
|
15985
|
+
const yours = unlisted.length + owned.length + restoredRows.length;
|
|
15605
15986
|
const both = yours > 0 && installed.length > 0;
|
|
15606
15987
|
const yoursGroup = yours
|
|
15607
|
-
? `${both ? `<div class="wf-group-label">Your workflows (${yours})</div>` : ''}<div class="ws-grid">${unlisted.map(draftCard).join('')}${owned.map(card).join('')}</div>`
|
|
15988
|
+
? `${both ? `<div class="wf-group-label">Your workflows (${yours})</div>` : ''}<div class="ws-grid">${unlisted.map(draftCard).join('')}${owned.map(card).join('')}${restoredRows.map(restoredCard).join('')}</div>`
|
|
15608
15989
|
: '';
|
|
15609
15990
|
$wfLanding.innerHTML = `<div class="ws-head"><div class="ws-head-text"><h2 tabindex="-1" id="wf-landing-title">Workflows</h2>`
|
|
15610
15991
|
+ `<p class="ws-sub">Build, run and manage the workflows behind your projects. Ask AI Chat on the left to build one with you.</p></div>`
|
|
15611
|
-
+ (wfLibrary.length || unlisted.length ? `<div class="ws-head-actions"><input type="search" id="wf-landing-search" class="ws-landing-search" data-command-id="shell.workflows-landing-search" placeholder="Search workflows" aria-label="Search workflows by name, project or tool" autocomplete="off" spellcheck="false" value="${esc(wfLandingQuery)}"></div>` : '')
|
|
15992
|
+
+ (wfLibrary.length || unlisted.length || archived.length || restoredRows.length ? `<div class="ws-head-actions"><input type="search" id="wf-landing-search" class="ws-landing-search" data-command-id="shell.workflows-landing-search" placeholder="Search workflows" aria-label="Search workflows by name, project or tool" autocomplete="off" spellcheck="false" value="${esc(wfLandingQuery)}"></div>` : '')
|
|
15612
15993
|
+ `</div>`
|
|
15613
|
-
+ `<div class="ws-create-grid"><div class="ws-card ws-create wf-create" role="button" tabindex="0" data-wf-new="1" data-command-id="shell.workflows-landing-new">`
|
|
15994
|
+
+ `<div class="ws-create-grid"><div class="ws-card ws-create ws-card-create wf-create" role="button" tabindex="0" data-wf-new="1" data-command-id="shell.workflows-landing-new">`
|
|
15614
15995
|
+ `<div class="ws-thumb">+</div><div class="ws-body"><div><div class="ws-name">New workflow</div>`
|
|
15615
15996
|
+ `<div class="ws-meta">Name it and choose where it belongs. AI builds it with you.</div></div></div></div></div>`
|
|
15616
|
-
+ (wfLibrary.length || unlisted.length
|
|
15997
|
+
+ (wfLibrary.length || unlisted.length || archived.length || restoredRows.length
|
|
15617
15998
|
? yoursGroup + group('Installed', installed, both)
|
|
15618
15999
|
+ '<div class="ws-empty-note ws-search-empty" id="wf-search-empty" role="status" aria-live="polite"></div>'
|
|
15619
|
-
: '<div class="ws-empty-note">No workflows yet. Start with New workflow, or ask AI Chat on the left.</div>')
|
|
16000
|
+
: '<div class="ws-empty-note">No active workflows yet. Start with New workflow, or ask AI Chat on the left.</div>')
|
|
16001
|
+
+ (archived.length ? `<div class="wf-group-label">Archived (${archived.length})</div><div class="ws-grid">${archived.map(archivedCard).join('')}</div>` : '');
|
|
15620
16002
|
if (focusedId) $wfLanding.querySelector(`[data-wf-id="${CSS.escape(focusedId)}"]`)?.focus();
|
|
15621
16003
|
if (focusedDraft) $wfLanding.querySelector(`[data-wf-draft="${CSS.escape(focusedDraft)}"]`)?.focus();
|
|
16004
|
+
if (focusedRestore) $wfLanding.querySelector(`[data-wf-restore="${CSS.escape(focusedRestore)}"]:not(:disabled)`)?.focus();
|
|
16005
|
+
if (focusedRestored) $wfLanding.querySelector(`[data-wf-restored="${CSS.escape(focusedRestored)}"]`)?.focus();
|
|
15622
16006
|
if (keepCaret) $wfLanding.querySelector('#wf-landing-search')?.focus();
|
|
15623
16007
|
applyWorkflowsLandingSearch(keepCaret);
|
|
15624
16008
|
if (clearFocused) $wfLanding.querySelector('#wf-search-clear')?.focus(); // it only exists once the filter ran
|
|
@@ -15634,7 +16018,7 @@
|
|
|
15634
16018
|
const terms = wfLandingQuery.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
15635
16019
|
let shownAll = 0;
|
|
15636
16020
|
for (const grid of $wfLanding.querySelectorAll('.ws-grid')) {
|
|
15637
|
-
const cards = grid.querySelectorAll('.wf-card[data-wf-id], .wf-card[data-wf-draft]');
|
|
16021
|
+
const cards = grid.querySelectorAll('.wf-card[data-wf-id], .wf-card[data-wf-draft], .wf-card[data-wf-archived], .wf-card[data-wf-restored]');
|
|
15638
16022
|
let shown = 0;
|
|
15639
16023
|
for (const card of cards) {
|
|
15640
16024
|
const hay = Array.from(card.querySelectorAll('.ws-name, .ws-meta:not(.wf-card-nodes)'), (el) => el.textContent).join(' ').toLowerCase();
|
|
@@ -15671,7 +16055,11 @@
|
|
|
15671
16055
|
landingOpening = true;
|
|
15672
16056
|
// Leave the landing once the workflow has loaded, so the previous one never flashes up in between; a failed
|
|
15673
16057
|
// load keeps the landing and reports why.
|
|
15674
|
-
|
|
16058
|
+
const loading = loadApp(id);
|
|
16059
|
+
const ticket = selectionTicket;
|
|
16060
|
+
loading.then(() => {
|
|
16061
|
+
if (ticket === selectionTicket && currentId === id) showWorkflowsLanding(false);
|
|
16062
|
+
}).catch(reportErr).finally(() => { landingOpening = false; });
|
|
15675
16063
|
}
|
|
15676
16064
|
|
|
15677
16065
|
// ── Draft workflows (#1890 PR 3b-0) ──────────────────────────────────────────────
|
|
@@ -15806,7 +16194,7 @@
|
|
|
15806
16194
|
// #1949: the same Archive the published workflow has in the picker — same command, same confirm — so a draft
|
|
15807
16195
|
// someone no longer wants can leave the Workflows page from its own view. Quiet (not primary): it is the exit,
|
|
15808
16196
|
// not the next step.
|
|
15809
|
-
+ `<div class="wf-draft-actions wf-draft-exit"><button type="button" class="wf-draft-archive" id="wf-draft-archive" data-command-id="workflow.archive#${esc(d.workflowId)}" data-command-instance-label="${esc(d.displayName)}" data-tip="Hide this workflow from the Workflows page. Its files stay on this computer.">Archive</button></div>`
|
|
16197
|
+
+ `<div class="wf-draft-actions wf-draft-exit"><button type="button" class="wf-draft-archive" id="wf-draft-archive" data-command-id="workflow.archive#${esc(d.workflowId)}" data-command-instance-label="${esc(d.displayName)}" data-tip="Hide this workflow from the Workflows page. Its files stay on this computer. Restore it from Archived.">Archive</button></div>`
|
|
15810
16198
|
+ `<div class="sr-only" role="status" aria-live="polite" id="wf-draft-status">${d.compiling ? 'Compiling…' : ''}</div>`
|
|
15811
16199
|
+ `</div>`;
|
|
15812
16200
|
}
|
|
@@ -15887,6 +16275,16 @@
|
|
|
15887
16275
|
|
|
15888
16276
|
if ($wfLanding) {
|
|
15889
16277
|
$wfLanding.addEventListener('click', (event) => {
|
|
16278
|
+
const restore = event.target.closest('[data-wf-restore]');
|
|
16279
|
+
if (restore) {
|
|
16280
|
+
if (!restore.disabled) {
|
|
16281
|
+
// Canvas panning cancels native mouse focus. This activated control owns the return
|
|
16282
|
+
// focus; restoreOwnedWorkflow still yields it if the person moves elsewhere while waiting.
|
|
16283
|
+
restore.focus();
|
|
16284
|
+
void restoreOwnedWorkflow(restore.dataset.wfRestore);
|
|
16285
|
+
}
|
|
16286
|
+
return;
|
|
16287
|
+
}
|
|
15890
16288
|
if (event.target.closest('[data-wf-new]')) { requestNewWorkflow(); return; }
|
|
15891
16289
|
// Clearing empties the message the button sits in, so focus goes back to the search box.
|
|
15892
16290
|
if (event.target.closest('#wf-search-clear')) { setWorkflowsLandingQuery(''); $wfLanding.querySelector('#wf-landing-search')?.focus(); return; }
|
|
@@ -15919,6 +16317,8 @@
|
|
|
15919
16317
|
|
|
15920
16318
|
window.flolessBridge = {
|
|
15921
16319
|
api,
|
|
16320
|
+
/** #2046: the ≡ menu's New workflow, opened from a Guide suggestion with its name filled in. */
|
|
16321
|
+
newWorkflow: (prefill) => requestNewWorkflow(prefill),
|
|
15922
16322
|
requestScopeLabel(projectId) {
|
|
15923
16323
|
return wsRequestScope?.kind === 'project' && wsRequestScope.project === projectId
|
|
15924
16324
|
? wsRequestScope.label : null;
|