@floless/app 0.156.0 → 0.158.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/cli-actions.mjs +28 -5
- package/dist/floless-server.cjs +110947 -67461
- package/dist/schemas/drawing-check.profile.v1.schema.json +15 -2
- package/dist/schemas/steel.model.v2.schema.json +25 -1
- package/dist/skills/floless-app-actions/SKILL.md +82 -17
- package/dist/skills/floless-app-knowledge/SKILL.md +34 -2
- package/dist/skills/floless-app-knowledge/references/schema.md +4 -1
- package/dist/skills/floless-app-new-workflow/SKILL.md +23 -7
- package/dist/skills/floless-app-onboarding/SKILL.md +31 -1
- package/dist/skills/floless-app-report-issue/SKILL.md +3 -3
- package/dist/skills/floless-app-rfi/SKILL.md +40 -6
- package/dist/skills/floless-app-routines/SKILL.md +9 -2
- package/dist/skills/floless-app-steel-model/SKILL.md +35 -1
- package/dist/skills/floless-app-steel-model/references/detail-from-a-screenshot.md +4 -2
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +51 -1
- package/dist/skills/floless-app-tweak-contract/SKILL.md +25 -5
- package/dist/skills/floless-app-workflows/SKILL.md +46 -10
- package/dist/skills/floless-app-workflows/references/agent-steps.md +119 -0
- package/dist/web/agent-steps.js +864 -47
- package/dist/web/agents.js +28 -8
- package/dist/web/app.css +620 -17
- package/dist/web/app.js +110 -11
- package/dist/web/aware-update-client.js +1 -0
- package/dist/web/aware.js +921 -220
- package/dist/web/chat-landing-scene.js +372 -0
- package/dist/web/chat.css +263 -1
- package/dist/web/chat.js +2660 -86
- package/dist/web/commands-drawing-check.js +17 -0
- package/dist/web/commands-shell.js +1059 -8
- package/dist/web/commands-steel.js +6 -0
- package/dist/web/connections.js +1 -0
- package/dist/web/drawing-check-editor.html +33 -5
- package/dist/web/drawing-check-editor.js +538 -22
- package/dist/web/drawing-check-overlay.js +13 -0
- package/dist/web/flo-avatar.js +28 -3
- package/dist/web/guide.js +7 -2
- package/dist/web/index.html +143 -8
- package/dist/web/instructor.js +4 -4
- package/dist/web/kb-categories.js +351 -0
- package/dist/web/kb-graph-worker.js +73 -0
- package/dist/web/model-view-query.js +12 -2
- package/dist/web/pages.js +978 -39
- package/dist/web/panels.js +5 -2
- package/dist/web/parser-setup-recovery.js +12 -4
- package/dist/web/project-access.js +549 -0
- package/dist/web/run-page-view.js +353 -0
- package/dist/web/startup-admission.js +132 -0
- package/dist/web/steel-3d-core.js +9 -0
- package/dist/web/steel-editor.html +681 -22
- package/dist/web/steel-model-v2-commands.js +63 -5
- package/dist/web/step-rename.js +287 -0
- package/dist/web/tab-signal.js +323 -0
- package/dist/web/terminal-requests.js +103 -13
- package/dist/web/tool-updates.js +1 -0
- package/dist/web/workspace-root-management.js +39 -0
- package/dist/web/workspaces.js +2883 -146
- package/launch-starting-page.mjs +181 -0
- package/launch.mjs +97 -12
- package/package.json +5 -1
package/dist/web/agent-steps.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* exact block the server wrote, into the chat composer for the person to send. It never edits a workflow, never calls an
|
|
7
7
|
* AI and never sends anything for the person: the UI is not the brain.
|
|
8
8
|
*
|
|
9
|
-
* Everything is hidden until the server says the feature is on (GET /api/agent-steps/status answers
|
|
9
|
+
* Everything is hidden until the server says the feature is on (GET /api/agent-steps/status answers `enabled: false` while it
|
|
10
|
+
* is off; an older server answered 404, which still reads as off).
|
|
10
11
|
* Loaded before aware.js and agents.js, which call window.flolessAgentSteps.
|
|
11
12
|
*/
|
|
12
13
|
(() => {
|
|
@@ -24,7 +25,12 @@
|
|
|
24
25
|
probing: null,
|
|
25
26
|
checks: new Map(), // appId -> Map(nodeId -> check), the server's last answer
|
|
26
27
|
generation: new Map(), // appId -> the newest check ask, so an older answer cannot overwrite a newer one
|
|
27
|
-
|
|
28
|
+
notes: new Map(), // #2448: appId -> { enabled, global, shown, off }, the AI note in that workflow's reports
|
|
29
|
+
noteSync: new Map(), // #2461: appId -> how its AI-note reads and saves are kept in order (see noteSyncOf)
|
|
30
|
+
triggers: new Map(), // S8 (#2495): appId -> the watcher's waits ({ steps, version, ... }), or null when it waits for no trigger
|
|
31
|
+
fires: new Map(), // S8: appId -> the watcher's latest events that reached an AI step (newest first)
|
|
32
|
+
firesState: new Map(), // S8: appId -> null, 'unreadable' (the log could not be read) or 'stale' (the last refresh failed)
|
|
33
|
+
context: { currentApp: () => null, openAgent: () => {}, openAgents: () => {}, toast: () => {}, repaint: () => {}, runRecordChanged: () => {} },
|
|
28
34
|
};
|
|
29
35
|
|
|
30
36
|
// ── is the feature on ───────────────────────────────────────────────────────────────────────────────────────
|
|
@@ -33,8 +39,20 @@
|
|
|
33
39
|
function probe() {
|
|
34
40
|
if (model.enabled !== null) return Promise.resolve(model.enabled);
|
|
35
41
|
if (!model.probing) {
|
|
36
|
-
model.probing =
|
|
37
|
-
.
|
|
42
|
+
model.probing = Promise.resolve().then(async () => {
|
|
43
|
+
await globalThis.flolessStartupAdmission?.admit('/api/agent-steps/status');
|
|
44
|
+
return fetch('/api/agent-steps/status', { credentials: 'same-origin', ...(typeof AbortSignal !== 'undefined' && AbortSignal.timeout ? { signal: AbortSignal.timeout(4000) } : {}) });
|
|
45
|
+
})
|
|
46
|
+
.then(async (response) => {
|
|
47
|
+
if (response.status === 404) model.enabled = false;
|
|
48
|
+
else if (response.ok) {
|
|
49
|
+
const body = await response.json().catch(() => null);
|
|
50
|
+
// `pending`: FloLess does not know the AWARE version yet (start-up). Not an answer: left unknown, asked again.
|
|
51
|
+
if (!(isRecord(body) && body.pending === true)) model.enabled = !(isRecord(body) && body.enabled === false);
|
|
52
|
+
}
|
|
53
|
+
if (model.enabled === true) { startGateWatch(); void initGlobalNote(); }
|
|
54
|
+
return model.enabled === true;
|
|
55
|
+
})
|
|
38
56
|
.catch(() => false)
|
|
39
57
|
.finally(() => { model.probing = null; });
|
|
40
58
|
}
|
|
@@ -72,6 +90,12 @@
|
|
|
72
90
|
scopeCount: Array.isArray(body.scope) ? body.scope.length : 0,
|
|
73
91
|
context: typeof body.context === 'string' ? body.context : '',
|
|
74
92
|
timeoutMinutes: Number.isSafeInteger(body['timeout-minutes']) ? body['timeout-minutes'] : null,
|
|
93
|
+
// S7: the pinned Knowledge block as the source writes it (null without one).
|
|
94
|
+
kb: isRecord(body.kb) && typeof body.kb.q === 'string' ? {
|
|
95
|
+
project: typeof body.kb.project === 'string' ? body.kb.project : '',
|
|
96
|
+
q: body.kb.q,
|
|
97
|
+
maxPages: Number.isSafeInteger(body.kb['max-pages']) ? body.kb['max-pages'] : null,
|
|
98
|
+
} : null,
|
|
75
99
|
};
|
|
76
100
|
}
|
|
77
101
|
|
|
@@ -110,7 +134,8 @@
|
|
|
110
134
|
// Only the "newer revision" notice can be kept. Every other finding (a deleted Agent, an unavailable project, a different scope,
|
|
111
135
|
// instructions that differ at the same revision, an archived Agent) is independent of which revision is kept and stays visible.
|
|
112
136
|
const keepable = new Set(['newer-revision']);
|
|
113
|
-
|
|
137
|
+
// S7: the Knowledge notes are shown under the step's Knowledge facts; an AI update would not fix them.
|
|
138
|
+
const shown = check.issues.filter((issue) => !(kept && keepable.has(issue.kind)) && !KB_NOTE_KINDS.has(issue.kind));
|
|
114
139
|
const lines = shown.map((issue) => issue.message);
|
|
115
140
|
if (!lines.length) return null;
|
|
116
141
|
const missing = check.issues.some((issue) => issue.kind === 'agent-missing');
|
|
@@ -125,6 +150,22 @@
|
|
|
125
150
|
};
|
|
126
151
|
}
|
|
127
152
|
|
|
153
|
+
const KB_NOTE_KINDS = new Set(['kb-no-knowledge', 'kb-no-search-words']);
|
|
154
|
+
|
|
155
|
+
/** S7: the "Knowledge it is given" section of a step's Inspect, or '' for a step that reads none. */
|
|
156
|
+
function kbInspectHtml(facts, check) {
|
|
157
|
+
const pinned = check && check.pinned && isRecord(check.pinned.kb) ? check.pinned.kb : null;
|
|
158
|
+
if (!facts.kb && !pinned) return '';
|
|
159
|
+
const project = pinned && pinned.projectLabel ? pinned.projectLabel : ((facts.kb && /^project:([^@]*)@/.exec(facts.kb.project)) || [])[1] || 'Not recorded';
|
|
160
|
+
const q = pinned ? pinned.q : facts.kb.q;
|
|
161
|
+
const pages = facts.kb && facts.kb.maxPages === null ? 'Up to 4 (the default)' : `Up to ${pinned ? pinned.maxPages : facts.kb.maxPages}`;
|
|
162
|
+
const rows = [['Project', project], ['Looks for', `“${q}”`], ['Pages given', pages]];
|
|
163
|
+
const notes = (check && Array.isArray(check.issues) ? check.issues : []).filter((issue) => KB_NOTE_KINDS.has(issue.kind) && typeof issue.message === 'string');
|
|
164
|
+
return `<h3>Knowledge it is given</h3><dl class="as-facts">${rows.map(([k, v]) => `<dt>${esc(k)}</dt><dd>${esc(v)}</dd>`).join('')}</dl>`
|
|
165
|
+
+ '<p class="dim-note">FloLess picks the best-matching pages before the Agent starts and gives them to it to check against. The Agent is not given a Knowledge search of its own.</p>'
|
|
166
|
+
+ notes.map((issue) => `<p class="dim-note" role="note">${esc(issue.message)}</p>`).join('');
|
|
167
|
+
}
|
|
168
|
+
|
|
128
169
|
// ── what a card and Inspect show ───────────────────────────────────────────────────────────────────────────
|
|
129
170
|
|
|
130
171
|
const BADGE_TIP = 'An Agent writes this step’s answer each time the workflow runs, so the answer can differ from run to run. Steps that use the answer can differ too.';
|
|
@@ -150,6 +191,80 @@
|
|
|
150
191
|
};
|
|
151
192
|
}
|
|
152
193
|
|
|
194
|
+
// ── #2374: what FloLess found using an Agent step's answer ─────────────────────────────────────────────────
|
|
195
|
+
|
|
196
|
+
/** The analysis the server sent with the app, or null when it cannot be relied on node by node. */
|
|
197
|
+
function answerUse(app) {
|
|
198
|
+
const use = app && isRecord(app.aiAnswerUse) ? app.aiAnswerUse : null;
|
|
199
|
+
if (!use || use.readable !== true || !isRecord(use.marks)) return null;
|
|
200
|
+
return Array.isArray(use.duplicateIds) && use.duplicateIds.length ? null : use;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const quoteList = (ids) => ids.map((id) => `“${id}”`).join(', ');
|
|
204
|
+
/** "“a”, “b”, “c” and 2 more": names stay readable however many there are. */
|
|
205
|
+
const shortList = (ids, max = 4) => (ids.length > max ? `${quoteList(ids.slice(0, max - 1))} and ${ids.length - (max - 1)} more` : quoteList(ids));
|
|
206
|
+
|
|
207
|
+
const USE_TEXT = { uses: 'Uses an AI answer', decided: 'Decided by an AI answer' };
|
|
208
|
+
function useSentence(how, steps) {
|
|
209
|
+
const of = `the answer of the AI step${steps.length === 1 ? '' : 's'} ${shortList(steps, 3)}`;
|
|
210
|
+
return how === 'uses'
|
|
211
|
+
? `Its result is built from ${of}, so it can differ each run.`
|
|
212
|
+
: `Whether and how this runs depends on ${of}, so it can differ each run.`;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* The mark on a node that is not itself an Agent step, or null. A container whose body holds marked steps (they are not cards of their
|
|
217
|
+
* own) says so. Marks are what FloLess FOUND; an unmarked node is never presented as fixed.
|
|
218
|
+
*/
|
|
219
|
+
function useParts(app, node) {
|
|
220
|
+
const use = answerUse(app);
|
|
221
|
+
if (!use || !node || isStepNode(node)) return null;
|
|
222
|
+
const mark = isRecord(use.marks[node.id]) ? use.marks[node.id] : null;
|
|
223
|
+
const inside = Object.entries(use.marks).filter(([, m]) => isRecord(m) && m.container === node.id).map(([id]) => id);
|
|
224
|
+
if (!mark && !inside.length) return null;
|
|
225
|
+
const steps = (list) => [...new Set(list.flatMap((m) => (Array.isArray(m.steps) ? m.steps.map(String) : [])))];
|
|
226
|
+
let chip; let line;
|
|
227
|
+
if (mark && (mark.how === 'uses' || mark.how === 'decided')) {
|
|
228
|
+
line = useSentence(mark.how, steps([mark]));
|
|
229
|
+
chip = { text: USE_TEXT[mark.how], tip: line, how: mark.how };
|
|
230
|
+
} else {
|
|
231
|
+
line = `Some steps inside use the answer of the AI step ${shortList(steps(inside.map((id) => use.marks[id])), 3)}: ${shortList(inside)}.`;
|
|
232
|
+
chip = { text: 'Contains steps that use an AI answer', tip: line, how: 'container' };
|
|
233
|
+
}
|
|
234
|
+
const insideLine = mark && inside.length ? `<p class="as-use-line">${esc(`Inside it, FloLess found ${shortList(inside)} using the answer too.`)}</p>` : '';
|
|
235
|
+
return { chip, descriptionHtml: `<p class="as-use-line">${esc(line)}</p>${insideLine}` };
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** The Agent step's standing Inspect sentence, from what was found (never "the rest is fixed"). */
|
|
239
|
+
function standingSentence(app, node) {
|
|
240
|
+
const lead = 'This step’s answer is written by an AI and may differ each time the workflow runs.';
|
|
241
|
+
const raw = app && isRecord(app.aiAnswerUse) ? app.aiAnswerUse : null;
|
|
242
|
+
const use = answerUse(app);
|
|
243
|
+
if (!use) {
|
|
244
|
+
return raw ? `${lead} Steps that use the answer can differ too, but FloLess couldn’t work out which ones for this workflow.`
|
|
245
|
+
: `${lead} Steps that use the answer can differ too.`;
|
|
246
|
+
}
|
|
247
|
+
const found = Object.entries(use.marks).filter(([, m]) => isRecord(m) && Array.isArray(m.steps) && m.steps.includes(node.id)).map(([id]) => id);
|
|
248
|
+
return found.length
|
|
249
|
+
? `${lead} Steps that use the answer can differ too. Found: ${shortList(found)} (marked on the canvas). Other steps may use it in ways FloLess can’t trace.`
|
|
250
|
+
: `${lead} No step using the answer was found. Steps may still use it in ways FloLess can’t trace.`;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* The trace's label on an output a found step produced, read from THAT run's own record (the snapshot taken when it was launched),
|
|
255
|
+
* never from the workflow as it is today: a replayed older run, or a run whose record has not arrived yet, gets no label.
|
|
256
|
+
*/
|
|
257
|
+
function usePillHtml(nodeId, runId) {
|
|
258
|
+
const app = model.context.currentApp();
|
|
259
|
+
const record = app && runId ? runs.get(app.id) : null;
|
|
260
|
+
if (!record || record.runId !== runId || !Array.isArray(record.dependents)) return '';
|
|
261
|
+
const mark = record.dependents.find((row) => isRecord(row) && row.nodeId === nodeId) || null;
|
|
262
|
+
if (!mark || (mark.how !== 'uses' && mark.how !== 'decided')) return '';
|
|
263
|
+
const tip = useSentence(mark.how, Array.isArray(mark.steps) ? mark.steps.map(String) : []);
|
|
264
|
+
const words = mark.how === 'uses' ? 'uses an AI answer' : 'decided by an AI answer';
|
|
265
|
+
return `<span class="ai-pill is-uses" data-tip="${esc(tip)}" aria-label="${esc(tip)}">${esc(words)}</span>`;
|
|
266
|
+
}
|
|
267
|
+
|
|
153
268
|
function scopeWords(check, facts) {
|
|
154
269
|
if (check && check.pinned && Array.isArray(check.pinned.scope) && check.pinned.scope.length) {
|
|
155
270
|
return check.pinned.scope.map((item) => esc(item.label)).join(', ');
|
|
@@ -175,7 +290,7 @@
|
|
|
175
290
|
}
|
|
176
291
|
const sentence = plainDescription(node);
|
|
177
292
|
html += `<p>${esc(sentence || `This step asks the Agent “${facts.name}” a question and uses its answer.`)}</p>`;
|
|
178
|
-
html +=
|
|
293
|
+
html += `<p class="as-standing">${esc(standingSentence(app, node))}</p>`;
|
|
179
294
|
if (app.runState && app.runState !== 'ready') {
|
|
180
295
|
html += '<p class="dim-note">These settings are read from the workflow file. It has not been approved in this form yet, so the approved version may differ.</p>';
|
|
181
296
|
}
|
|
@@ -190,9 +305,120 @@
|
|
|
190
305
|
['Answer format', esc(answerWords(facts.output))],
|
|
191
306
|
];
|
|
192
307
|
html += `<h3>The Agent</h3><dl class="as-facts">${rows.map(([k, v]) => `<dt>${esc(k)}</dt><dd>${v}</dd>`).join('')}</dl>`;
|
|
308
|
+
html += kbInspectHtml(facts, check);
|
|
309
|
+
html += triggerInspectHtml(model.triggers.get(app.id), node.id, model.fires.get(app.id), model.firesState.get(app.id));
|
|
310
|
+
html += noteHtml(model.notes.get(app.id));
|
|
311
|
+
return html;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* S8 (#2495): a watcher step's wait between answers and what it did for each event, or '' when the workflow waits for no trigger.
|
|
316
|
+
* Pure. `view` is the server's trigger view, `fires` the newest events first.
|
|
317
|
+
*/
|
|
318
|
+
function triggerInspectHtml(view, nodeId, fires, firesState = null) {
|
|
319
|
+
if (!isRecord(view) || !Array.isArray(view.steps)) return '';
|
|
320
|
+
const step = view.steps.find((s) => s.nodeId === nodeId);
|
|
321
|
+
if (!step) return '';
|
|
322
|
+
const id = esc(nodeId);
|
|
323
|
+
const on = step.minutes > 0;
|
|
324
|
+
let html = '<h3>When the trigger fires</h3>'
|
|
325
|
+
+ `<div class="as-note-row"><span>Wait between answers</span><span class="as-wait-value">${esc(waitWords(step.minutes))}</span>`
|
|
326
|
+
+ `<button type="button" class="as-btn" data-as-wait-change="${id}" data-command-id="shell.agent-step-wait-change" aria-expanded="false">Change</button></div>`
|
|
327
|
+
+ `<div class="as-wait-edit" data-as-wait-edit="${id}" hidden>`
|
|
328
|
+
+ `<span class="ac-wait-field"${on ? '' : ' hidden'}><input type="number" class="ac-wait-input" data-as-wait-input="${id}" min="1" max="1440" step="1" inputmode="numeric" value="${on ? esc(step.minutes) : 1}" aria-label="Minutes between AI answers" data-command-id="shell.agent-step-wait-minutes"><span class="ac-wait-unit">minutes</span></span>`
|
|
329
|
+
+ `<label class="rtn-toggle" data-tip="Off: the AI answers every time the trigger fires, one at a time."><input type="checkbox" role="switch" data-as-wait-on="${id}"${on ? ' checked' : ''} aria-label="Limit how often this AI step runs" data-command-id="shell.agent-step-wait-limit"><span class="rtn-toggle-track"></span></label>`
|
|
330
|
+
+ `<button type="button" class="as-btn primary" data-as-wait-save="${id}" data-command-id="shell.agent-step-wait-save">Save</button>`
|
|
331
|
+
+ `<button type="button" class="as-btn" data-as-wait-cancel="${id}" data-command-id="shell.agent-step-wait-cancel">Cancel</button></div>`
|
|
332
|
+
+ '<p class="as-note-hint">The AI step answers at most once in this time. An event inside the wait skips the AI step and is listed below. A shorter wait asks you to confirm again.</p>';
|
|
333
|
+
if (step.unreadable ?? view.unreadable) html += '<p class="as-note-hint is-global-off">FloLess could not read this step’s wait, so it waits at least an hour between answers until you set it again.</p>';
|
|
334
|
+
const mine = (Array.isArray(fires) ? fires : []).filter((f) => !Array.isArray(f.steps) || !f.steps.length || f.steps.some((s) => s.nodeId === nodeId)).slice(0, 10);
|
|
335
|
+
html += '<h3>What it did for each event</h3>';
|
|
336
|
+
if (firesState === 'unreadable') html += '<p class="as-note-hint is-global-off">FloLess could not read this watcher’s history, so events may be missing below. It tries again as new events land.</p>';
|
|
337
|
+
else if (firesState === 'stale') html += '<p class="as-note-hint is-global-off">FloLess couldn’t refresh this history just now, so it may be out of date. It tries again as new events land.</p>';
|
|
338
|
+
if (!mine.length) return `${html}<p class="dim-note">Nothing yet. Each time the trigger fires and reaches this AI step, it is listed here.</p>`;
|
|
339
|
+
html += `<ul class="as-fires">${mine.map((f) => {
|
|
340
|
+
const items = (Array.isArray(f.needsYou) ? f.needsYou : []).slice(0, 4).map((n) => `<li>${esc(n.text)}</li>`).join('');
|
|
341
|
+
return `<li class="as-fire"><span class="as-fire-when">${esc(whenWords(f.startedAt) || `Event ${f.fire}`)}</span> <span class="as-fire-outcome">${esc(f.outcome)}</span>${items ? `<ul class="as-fire-needs">${items}</ul>` : ''}</li>`;
|
|
342
|
+
}).join('')}</ul>`;
|
|
193
343
|
return html;
|
|
194
344
|
}
|
|
195
345
|
|
|
346
|
+
/** S8: the words a watcher routine's card adds from its events (`aiEvents` from /api/routines), or null. */
|
|
347
|
+
function watcherCardParts(aiEvents) {
|
|
348
|
+
if (!isRecord(aiEvents) || !Number.isSafeInteger(aiEvents.events) || aiEvents.events < 1) return null;
|
|
349
|
+
const q = Number.isSafeInteger(aiEvents.needsYou) && aiEvents.needsYou > 0 ? aiEvents.needsYou : 0;
|
|
350
|
+
return {
|
|
351
|
+
ai: 'AI answer',
|
|
352
|
+
aiTip: `This watcher has an AI step. Its answer can differ each time. Latest event: ${String(aiEvents.latest || 'recorded')}.`,
|
|
353
|
+
questions: q ? plural(q, 'question for you', 'questions for you') : '',
|
|
354
|
+
questionsTip: q ? 'The AI step left questions, skipped events or changes that were not made. Open the workflow and select its AI step to read them.' : '',
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** S8: read a watcher's waits and its latest events, for Inspect. Never claims anything when a read fails. */
|
|
359
|
+
async function refreshTrigger(appId, opts = {}) {
|
|
360
|
+
try {
|
|
361
|
+
const waitsPath = `/api/app/${encodeURIComponent(appId)}/agent-step-waits`;
|
|
362
|
+
await globalThis.flolessStartupAdmission?.admit(waitsPath);
|
|
363
|
+
const response = await fetch(waitsPath, { credentials: 'same-origin' });
|
|
364
|
+
const body = response.ok ? await response.json() : null;
|
|
365
|
+
if (!body || body.ok !== true) return;
|
|
366
|
+
model.triggers.set(appId, body.trigger || null);
|
|
367
|
+
if (body.trigger) {
|
|
368
|
+
const firesResponse = await fetch(`/api/app/${encodeURIComponent(appId)}/agent-step-fires`, { credentials: 'same-origin' });
|
|
369
|
+
const fires = firesResponse.ok ? await firesResponse.json().catch(() => null) : null;
|
|
370
|
+
if (fires && fires.ok === true && Array.isArray(fires.fires)) {
|
|
371
|
+
model.fires.set(appId, fires.fires);
|
|
372
|
+
model.firesState.set(appId, fires.unreadable === true ? 'unreadable' : null);
|
|
373
|
+
} else model.firesState.set(appId, 'stale');
|
|
374
|
+
}
|
|
375
|
+
if (model.context.currentApp()?.id !== appId) return;
|
|
376
|
+
// A wait editor the person has open is never closed under them by an event landing: the repaint waits until it closes.
|
|
377
|
+
if (!opts.closeEditor && document.querySelector('[data-as-wait-edit]:not([hidden])')) { model.repaintAfterEdit = appId; return; }
|
|
378
|
+
model.context.repaint(appId);
|
|
379
|
+
} catch { /* not known: Inspect shows what it had */ }
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** S8: a watcher event was recorded for `appId` (SSE): read its history again when that workflow is open (at most every 1.5 s). */
|
|
383
|
+
let watcherTimer = null;
|
|
384
|
+
function watcherChanged(appId) {
|
|
385
|
+
if (!appId || model.context.currentApp()?.id !== appId || !model.triggers.get(appId)) return;
|
|
386
|
+
if (watcherTimer) return;
|
|
387
|
+
watcherTimer = setTimeout(() => { watcherTimer = null; void refreshTrigger(appId); }, 1500);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/** S8: the person saved a new wait in Inspect. Longer: saved. Shorter or off: the confirmation asks the second tick again. */
|
|
391
|
+
async function saveWait(appId, nodeId, minutes) {
|
|
392
|
+
const current = model.triggers.get(appId)?.steps?.find((s) => s.nodeId === nodeId)?.minutes;
|
|
393
|
+
const longer = Number.isInteger(current) && (minutes === 0 ? current === 0 : current === 0 || minutes >= current);
|
|
394
|
+
if (longer) {
|
|
395
|
+
try {
|
|
396
|
+
const response = await fetch(`/api/app/${encodeURIComponent(appId)}/agent-step-waits`, {
|
|
397
|
+
method: 'PUT', credentials: 'same-origin', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ nodeId, minutes }),
|
|
398
|
+
});
|
|
399
|
+
const body = await response.json().catch(() => null);
|
|
400
|
+
if (response.ok && body && body.ok) {
|
|
401
|
+
model.context.toast(`Saved. The AI step now waits ${minutes === 0 ? 'nothing' : minutesWords(minutes)} between answers.`, 'ok');
|
|
402
|
+
await refreshTrigger(appId, { closeEditor: true });
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (!body || body.code !== 'needs-confirmation') {
|
|
406
|
+
model.context.toast(body && body.error ? body.error : 'FloLess couldn’t save the wait. Try again.', 'warn');
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
} catch { model.context.toast('FloLess couldn’t save the wait. Check that FloLess is running and try again.', 'warn'); return; }
|
|
410
|
+
}
|
|
411
|
+
const app = model.context.currentApp();
|
|
412
|
+
const opened = await consentFetch('open', { app: appId }).catch(() => null);
|
|
413
|
+
if (!app || !opened || opened.status !== 200 || !opened.data.ok) {
|
|
414
|
+
model.context.toast('FloLess couldn’t open the confirmation for the shorter wait. Nothing was changed. Try again.', 'warn');
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
const outcome = await consentDialog(app, 'wait', opened.data, { [nodeId]: minutes });
|
|
418
|
+
if (outcome === 'confirmed' && !lastWaitNotSaved) model.context.toast('Confirmed. The AI step can now answer more often.', 'ok');
|
|
419
|
+
await refreshTrigger(appId, { closeEditor: true });
|
|
420
|
+
}
|
|
421
|
+
|
|
196
422
|
// ── checks ──────────────────────────────────────────────────────────────────────────────────────────────────
|
|
197
423
|
|
|
198
424
|
/**
|
|
@@ -209,9 +435,14 @@
|
|
|
209
435
|
const on = await probe();
|
|
210
436
|
if (!current()) return;
|
|
211
437
|
if (!on || !Array.isArray(app.nodes) || !app.nodes.some(isStepNode)) { model.checks.delete(app.id); return; }
|
|
438
|
+
void refreshNote(app.id);
|
|
439
|
+
void refreshTrigger(app.id);
|
|
212
440
|
let steps = null;
|
|
213
441
|
try {
|
|
214
|
-
const
|
|
442
|
+
const path = `/api/agent-steps/check?app=${encodeURIComponent(app.id)}`;
|
|
443
|
+
await globalThis.flolessStartupAdmission?.admit(path);
|
|
444
|
+
if (!current()) return;
|
|
445
|
+
const response = await fetch(path, { credentials: 'same-origin' });
|
|
215
446
|
const body = response.ok ? await response.json() : null;
|
|
216
447
|
if (body && body.ok === true && Array.isArray(body.steps)) steps = body.steps;
|
|
217
448
|
} catch { steps = null; }
|
|
@@ -392,8 +623,10 @@ ${WARN_LINE}`);
|
|
|
392
623
|
}
|
|
393
624
|
|
|
394
625
|
async function loadAgents() {
|
|
626
|
+
await globalThis.flolessStartupAdmission?.admit('/api/chat/session');
|
|
395
627
|
const session = await fetch('/api/chat/session', { credentials: 'same-origin' });
|
|
396
628
|
if (!session.ok) throw new Error('FloLess could not open AI Chat’s session, so the Agents could not load. Reload FloLess and try again.');
|
|
629
|
+
await globalThis.flolessStartupAdmission?.admit('/api/chat/agents');
|
|
397
630
|
const response = await fetch('/api/chat/agents', { credentials: 'same-origin' });
|
|
398
631
|
const body = await response.json().catch(() => null);
|
|
399
632
|
if (!response.ok || !body || !Array.isArray(body.agents)) throw new Error('FloLess could not load your Agents just now. Try again.');
|
|
@@ -491,6 +724,8 @@ ${WARN_LINE}`);
|
|
|
491
724
|
['Can read', (step.scope && step.scope.length ? step.scope : ['Nothing was pinned']).join(', ')],
|
|
492
725
|
['Answer format', step.answerFormat === 'json' ? 'A structured answer' : 'Plain text'],
|
|
493
726
|
['Time limit', `${step.timeoutMinutes} min`],
|
|
727
|
+
// S7: the Knowledge FloLess gives the step is part of what the person confirms.
|
|
728
|
+
...(typeof step.knowledge === 'string' && step.knowledge ? [['Reads Knowledge', step.knowledge]] : []),
|
|
494
729
|
];
|
|
495
730
|
const long = String(step.instructions || '').trim().length > String(step.firstLine || '').length;
|
|
496
731
|
return `<div class="ac-step" data-ac-node="${esc(step.nodeId)}">`
|
|
@@ -524,8 +759,36 @@ ${WARN_LINE}`);
|
|
|
524
759
|
return `${html}</div>`;
|
|
525
760
|
}
|
|
526
761
|
|
|
762
|
+
// ── S8 (#2495): the wait between a watcher's AI answers, and the second tick ─────────────────────────────────────
|
|
763
|
+
|
|
764
|
+
const minutesWords = (minutes) => (minutes === 1 ? '1 minute' : `${minutes} minutes`);
|
|
765
|
+
const waitWords = (minutes) => (minutes === 0 ? 'No wait' : minutesWords(minutes));
|
|
766
|
+
|
|
767
|
+
/** The second tick's words for these waits — the server's own sentence (agent-step-consent-service.ts `triggerSentence`). */
|
|
768
|
+
function triggerSentenceFor(waits) {
|
|
769
|
+
const distinct = [...new Set(waits)];
|
|
770
|
+
const many = waits.length > 1;
|
|
771
|
+
const who = `Its AI step${many ? 's' : ''} can run on ${many ? 'their' : 'its'} own`;
|
|
772
|
+
if (distinct.length === 1 && distinct[0] === 0) {
|
|
773
|
+
return `This workflow waits for a trigger. ${who} every time the trigger fires, with no wait between answers, using your AI subscription. I understand.`;
|
|
774
|
+
}
|
|
775
|
+
const how = distinct.length === 1 ? `at most once every ${minutesWords(distinct[0])}` : 'at most as often as the wait set for each step';
|
|
776
|
+
return `This workflow waits for a trigger. ${who} each time the trigger fires — ${how} — using your AI subscription. I understand.`;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/** One AI step's wait control in the dialog: a whole number of minutes and a switch for "no wait". Pure. */
|
|
780
|
+
function waitRowHtml(step, many) {
|
|
781
|
+
const id = esc(step.nodeId);
|
|
782
|
+
const on = step.minutes > 0;
|
|
783
|
+
return `<div class="ac-wait-row" data-ac-wait-row="${id}">`
|
|
784
|
+
+ `<label class="ac-wait-label" for="ac-wait-${id}">Wait between AI answers${many ? ` <span class="ac-wait-step">· ${id}</span>` : ''}</label>`
|
|
785
|
+
+ `<span class="ac-wait-field"${on ? '' : ' hidden'}><input type="number" class="ac-wait-input" id="ac-wait-${id}" data-ac-wait="${id}" min="1" max="1440" step="1" inputmode="numeric" value="${on ? esc(step.minutes) : 1}" data-command-id="shell.agent-consent-wait#${esc(step.nodeId)}" data-command-instance-label="${esc(step.nodeId)}"><span class="ac-wait-unit">minutes</span></span>`
|
|
786
|
+
+ `<label class="rtn-toggle ac-wait-switch" data-tip="Off: the AI answers every time the trigger fires, one at a time."><input type="checkbox" role="switch" data-ac-wait-on="${id}"${on ? ' checked' : ''} aria-label="Limit how often the AI step ${id} runs" data-command-id="shell.agent-consent-wait-limit#${esc(step.nodeId)}" data-command-instance-label="${esc(step.nodeId)}"><span class="rtn-toggle-track"></span></label>`
|
|
787
|
+
+ `<span class="ac-wait-state">${on ? 'Limited' : 'No wait — every event'}</span></div>`;
|
|
788
|
+
}
|
|
789
|
+
|
|
527
790
|
/** The words and markup of the dialog for one server model. Pure: no DOM, so it is testable on its own. */
|
|
528
|
-
function consentView(model, via) {
|
|
791
|
+
function consentView(model, via, presetWaits = null) {
|
|
529
792
|
const changed = model.state === 'changed' && Array.isArray(model.changes) && model.changes.length > 0;
|
|
530
793
|
const steps = Array.isArray(model.steps) ? model.steps : [];
|
|
531
794
|
let body;
|
|
@@ -539,13 +802,38 @@ ${WARN_LINE}`);
|
|
|
539
802
|
if (model.unreadableSteps) body += `<p class="ac-unchanged">${esc(model.unreadableSteps)} AI step${model.unreadableSteps === 1 ? '' : 's'} could not be read, so ${model.unreadableSteps === 1 ? 'it' : 'they'} will not run until fixed.</p>`;
|
|
540
803
|
const nameOf = (name) => (/^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(String(name)) ? 'You' : name);
|
|
541
804
|
const who = model.latest ? `${nameOf(model.latest.confirmedBy)}${whenWords(model.latest.confirmedAt) ? ` on ${whenWords(model.latest.confirmedAt)}` : ''}` : '';
|
|
805
|
+
// S8: a workflow that waits for a trigger adds each step's wait and the second tick.
|
|
806
|
+
const trigRaw = isRecord(model.trigger) && Array.isArray(model.trigger.steps) ? model.trigger : null;
|
|
807
|
+
// S8: from Inspect ('wait'), the dialog shows the shorter wait the person asked for, and says that is what they confirm.
|
|
808
|
+
const preset = (step) => (isRecord(presetWaits) && Number.isInteger(presetWaits[step.nodeId]) ? presetWaits[step.nodeId] : step.minutes);
|
|
809
|
+
const trig = trigRaw ? { ...trigRaw, steps: trigRaw.steps.map((step) => ({ ...step, was: step.minutes, minutes: preset(step) })) } : null;
|
|
810
|
+
let heading = changed ? 'The AI step changed since you last confirmed' : 'This workflow includes an AI step';
|
|
811
|
+
let sub = changed ? `${who ? `Last confirmed by ${who}. ` : ''}Look at what changed, then confirm again. ${CONSENT_FIRST_SUB}` : CONSENT_FIRST_SUB;
|
|
812
|
+
const shortening = trig && via === 'wait' ? trig.steps.filter((s) => s.minutes !== s.was) : [];
|
|
813
|
+
if (shortening.length) {
|
|
814
|
+
heading = 'You are shortening the wait between AI answers';
|
|
815
|
+
sub = `Your AI step will be able to run more often. ${shortening.map((s) => `Wait: ${waitWords(s.was)} → ${waitWords(s.minutes)}`).join('. ')}. Confirm that you are fine with that.`;
|
|
816
|
+
} else if (trig && model.state === 'changed' && !changed) {
|
|
817
|
+
const shortened = trig.steps.filter((s) => Number.isInteger(s.confirmedMinutes) && !s.covered);
|
|
818
|
+
if (shortened.length) {
|
|
819
|
+
heading = 'You shortened the wait between AI answers';
|
|
820
|
+
sub = `Your AI step will be able to run more often. ${shortened.map((s) => `Wait: ${waitWords(s.confirmedMinutes)} → ${waitWords(s.minutes)}`).join('. ')}. Confirm that you are fine with that.`;
|
|
821
|
+
} else {
|
|
822
|
+
heading = 'This workflow now waits for a trigger';
|
|
823
|
+
sub = `${who ? `Last confirmed by ${who}, ` : 'It was confirmed '}when the workflow only ran when started. Its AI step can now run by itself each time the trigger fires, so FloLess needs one more confirmation. ${CONSENT_FIRST_SUB}`;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
542
826
|
return {
|
|
543
|
-
title:
|
|
544
|
-
sub: changed ? `${who ? `Last confirmed by ${who}. ` : ''}Look at what changed, then confirm again. ${CONSENT_FIRST_SUB}` : CONSENT_FIRST_SUB,
|
|
545
|
-
body,
|
|
827
|
+
title: heading, sub, body,
|
|
546
828
|
warning: model.warning || '',
|
|
547
829
|
sentence: model.sentence,
|
|
548
|
-
primary: via === 'run-dialog' ? 'Confirm and run' : 'Approve workflow',
|
|
830
|
+
primary: via === 'wait' ? 'Confirm the new wait' : via === 'run-dialog' ? 'Confirm and run' : 'Approve workflow',
|
|
831
|
+
trigger: trig ? {
|
|
832
|
+
html: trig.steps.map((step) => waitRowHtml(step, trig.steps.length > 1)).join(''),
|
|
833
|
+
steps: trig.steps.map((step) => ({ nodeId: step.nodeId, minutes: step.minutes })),
|
|
834
|
+
sentence: triggerSentenceFor(trig.steps.map((step) => step.minutes)),
|
|
835
|
+
unreadable: trig.unreadable === true,
|
|
836
|
+
} : null,
|
|
549
837
|
};
|
|
550
838
|
}
|
|
551
839
|
|
|
@@ -568,29 +856,59 @@ ${WARN_LINE}`);
|
|
|
568
856
|
}
|
|
569
857
|
|
|
570
858
|
let consentOpen = false;
|
|
859
|
+
/** #2314: the rename ask the confirmation was answered with, handed to the Compile button once. */
|
|
860
|
+
let pendingRenameAsk = null;
|
|
861
|
+
/** S8: the last confirmation was recorded but its new wait could not be saved (the dialog already said so). */
|
|
862
|
+
let lastWaitNotSaved = false;
|
|
863
|
+
function takeRenameAsk() { const ask = pendingRenameAsk; pendingRenameAsk = null; return ask; }
|
|
571
864
|
|
|
572
865
|
/**
|
|
573
866
|
* Show the dialog. Resolves 'confirmed' once the server recorded it (and, from Approve, approved those exact bytes), else 'cancel'.
|
|
574
|
-
* `via` is 'approve'
|
|
867
|
+
* `via` is 'approve', 'run-dialog' or (S8) 'wait' — a shorter wait from Inspect, `presetWaits` the waits it asks for. Never records
|
|
868
|
+
* anything itself.
|
|
575
869
|
*/
|
|
576
|
-
function consentDialog(app, via, initialModel) {
|
|
870
|
+
function consentDialog(app, via, initialModel, presetWaits = null) {
|
|
577
871
|
const root = document.getElementById('agent-consent-modal');
|
|
578
872
|
if (!root || consentOpen) return Promise.resolve('cancel');
|
|
579
873
|
consentOpen = true;
|
|
580
874
|
const $ = (id) => document.getElementById(id);
|
|
581
875
|
const tick = $('ac-tick'); const ok = $('ac-ok'); const hint = $('ac-hint'); const err = $('ac-error');
|
|
876
|
+
// S8: the second tick and the waits, for a workflow that waits for a trigger.
|
|
877
|
+
const trigBox = $('ac-trigger'); const tick2 = $('ac-tick2'); const waitsBox = $('ac-waits');
|
|
878
|
+
let waits = {};
|
|
582
879
|
const returnTo = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
583
880
|
let current = initialModel;
|
|
584
881
|
let busy = false;
|
|
585
882
|
return new Promise((resolve) => {
|
|
883
|
+
const needsTick2 = () => !!(trigBox && !trigBox.hidden && tick2);
|
|
884
|
+
const allTicked = () => tick.checked && (!needsTick2() || tick2.checked);
|
|
586
885
|
const syncOk = () => {
|
|
587
|
-
ok.setAttribute('aria-disabled',
|
|
588
|
-
hint.hidden =
|
|
886
|
+
ok.setAttribute('aria-disabled', allTicked() && !busy ? 'false' : 'true');
|
|
887
|
+
hint.hidden = allTicked();
|
|
888
|
+
const missing = (tick.checked ? 0 : 1) + (needsTick2() && !tick2.checked ? 1 : 0);
|
|
889
|
+
hint.textContent = missing === 2 ? 'Tick both boxes to continue.' : needsTick2() && tick.checked ? 'Tick the second box to continue.' : 'Tick the box to continue.';
|
|
589
890
|
hint.classList.remove('nudge');
|
|
590
891
|
};
|
|
892
|
+
/** S8: the waits as the dialog now shows them; a field that does not hold a whole number keeps the last good value. */
|
|
893
|
+
const readWaits = () => {
|
|
894
|
+
for (const row of waitsBox ? waitsBox.querySelectorAll('[data-ac-wait-row]') : []) {
|
|
895
|
+
const id = row.getAttribute('data-ac-wait-row');
|
|
896
|
+
const on = row.querySelector('[data-ac-wait-on]');
|
|
897
|
+
const input = row.querySelector('[data-ac-wait]');
|
|
898
|
+
const field = row.querySelector('.ac-wait-field');
|
|
899
|
+
const state = row.querySelector('.ac-wait-state');
|
|
900
|
+
if (field) field.hidden = !(on && on.checked);
|
|
901
|
+
if (state) state.textContent = on && on.checked ? 'Limited' : 'No wait — every event';
|
|
902
|
+
if (on && !on.checked) { waits[id] = 0; continue; }
|
|
903
|
+
const value = input ? Number(input.value) : NaN;
|
|
904
|
+
if (Number.isInteger(value) && value >= 1 && value <= 1440) waits[id] = value;
|
|
905
|
+
else if (!waits[id]) waits[id] = 1;
|
|
906
|
+
}
|
|
907
|
+
if (tick2) $('ac-tick2-label').textContent = triggerSentenceFor(Object.values(waits));
|
|
908
|
+
};
|
|
591
909
|
const showError = (text) => { err.textContent = text || ''; err.hidden = !text; };
|
|
592
910
|
const paint = () => {
|
|
593
|
-
const view = consentView(current, via);
|
|
911
|
+
const view = consentView(current, via, presetWaits);
|
|
594
912
|
$('ac-title').textContent = view.title;
|
|
595
913
|
$('ac-sub').textContent = view.sub;
|
|
596
914
|
$('ac-body').innerHTML = view.body;
|
|
@@ -598,13 +916,46 @@ ${WARN_LINE}`);
|
|
|
598
916
|
warning.hidden = !view.warning;
|
|
599
917
|
warning.innerHTML = view.warning ? `<b>Heads up.</b> ${esc(view.warning)}` : '';
|
|
600
918
|
$('ac-tick-label').textContent = view.sentence;
|
|
919
|
+
if (trigBox) {
|
|
920
|
+
trigBox.hidden = !view.trigger;
|
|
921
|
+
waits = {};
|
|
922
|
+
if (view.trigger) {
|
|
923
|
+
for (const step of view.trigger.steps) waits[step.nodeId] = presetWaits && Number.isInteger(presetWaits[step.nodeId]) ? presetWaits[step.nodeId] : step.minutes;
|
|
924
|
+
waitsBox.innerHTML = view.trigger.html;
|
|
925
|
+
for (const row of waitsBox.querySelectorAll('[data-ac-wait-row]')) {
|
|
926
|
+
const id = row.getAttribute('data-ac-wait-row');
|
|
927
|
+
const on = row.querySelector('[data-ac-wait-on]'); const input = row.querySelector('[data-ac-wait]');
|
|
928
|
+
if (on) on.checked = waits[id] > 0;
|
|
929
|
+
if (input && waits[id] > 0) input.value = String(waits[id]);
|
|
930
|
+
}
|
|
931
|
+
readWaits();
|
|
932
|
+
}
|
|
933
|
+
}
|
|
601
934
|
ok.textContent = view.primary;
|
|
602
935
|
syncOk();
|
|
603
936
|
};
|
|
937
|
+
/** S8: a changed wait changes the sentence the person ticks, so the second tick is asked again. */
|
|
938
|
+
const onWaitChange = (event) => {
|
|
939
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
940
|
+
if (!target || !target.closest('[data-ac-wait-row]')) return;
|
|
941
|
+
const input = target.closest('[data-ac-wait]');
|
|
942
|
+
if (input && event.type === 'change') {
|
|
943
|
+
const value = Number(input.value);
|
|
944
|
+
if (!(Number.isInteger(value) && value >= 1 && value <= 1440)) {
|
|
945
|
+
showError('Enter a whole number of minutes from 1 to 1440, or turn the limit off. The wait stays as it was.');
|
|
946
|
+
input.value = String(waits[input.getAttribute('data-ac-wait')] || 1);
|
|
947
|
+
} else showError('');
|
|
948
|
+
}
|
|
949
|
+
readWaits();
|
|
950
|
+
if (tick2) tick2.checked = false;
|
|
951
|
+
syncOk();
|
|
952
|
+
};
|
|
604
953
|
const close = (result) => {
|
|
605
954
|
document.removeEventListener('keydown', onKey, true);
|
|
606
955
|
root.removeEventListener('click', onClick);
|
|
607
956
|
tick.removeEventListener('change', syncOk);
|
|
957
|
+
if (tick2) tick2.removeEventListener('change', syncOk);
|
|
958
|
+
if (waitsBox) { waitsBox.removeEventListener('input', onWaitChange); waitsBox.removeEventListener('change', onWaitChange); }
|
|
608
959
|
root.classList.remove('show');
|
|
609
960
|
consentOpen = false;
|
|
610
961
|
if (returnTo && returnTo.isConnected) returnTo.focus();
|
|
@@ -624,17 +975,32 @@ ${WARN_LINE}`);
|
|
|
624
975
|
}
|
|
625
976
|
async function confirm() {
|
|
626
977
|
if (busy) return;
|
|
627
|
-
if (!
|
|
978
|
+
if (!allTicked()) { hint.hidden = false; hint.classList.add('nudge'); (tick.checked ? tick2 : tick).focus(); return; }
|
|
628
979
|
busy = true; syncOk(); showError('');
|
|
629
980
|
ok.textContent = 'Working…';
|
|
630
981
|
try {
|
|
631
|
-
const
|
|
632
|
-
|
|
633
|
-
|
|
982
|
+
const trigger = needsTick2() ? { triggerTick: tick2.checked, waits: { ...waits }, waitsVersion: current.trigger ? current.trigger.version : 0 } : {};
|
|
983
|
+
const { status, data } = await consentFetch('confirm', { app: app.id, reviewedSourceHash: current.reviewedSourceHash, checkbox: true,
|
|
984
|
+
via: via === 'wait' ? 'run-dialog' : via, ...trigger });
|
|
985
|
+
if (status === 200 && data.ok) {
|
|
986
|
+
busy = false;
|
|
987
|
+
// S8: the confirmation is in the record, but the wait itself could not be saved, so the step waits as it did before.
|
|
988
|
+
lastWaitNotSaved = !!data.waitNotSaved;
|
|
989
|
+
if (lastWaitNotSaved) model.context.toast('Your confirmation was saved, but FloLess couldn’t save the new wait, so the AI step still waits as it did before. Change the wait again to retry.', 'warn');
|
|
990
|
+
close('confirmed'); return;
|
|
991
|
+
}
|
|
992
|
+
// #2314: two steps share one name, so nothing was approved. Close and hand over the rename ask; after a rename the
|
|
993
|
+
// caller compiles again and this dialog asks the person again.
|
|
994
|
+
if (data && data.code === 'ambiguous-step-name' && data.ask) { busy = false; pendingRenameAsk = data.ask; close('rename-step'); return; }
|
|
995
|
+
if (status === 409 && (data.code === 'source-changed-while-open' || data.code === 'waits-changed-while-open')) {
|
|
634
996
|
if (data.model) current = data.model;
|
|
635
997
|
tick.checked = false;
|
|
998
|
+
if (tick2) tick2.checked = false;
|
|
999
|
+
presetWaits = null;
|
|
636
1000
|
paint();
|
|
637
|
-
showError(
|
|
1001
|
+
showError(data.code === 'waits-changed-while-open'
|
|
1002
|
+
? 'The wait between AI answers was changed while this window was open, so nothing was approved. The wait above is what it is now. Look it over, then confirm again.'
|
|
1003
|
+
: 'This workflow changed while this window was open, so nothing was approved. The details above are what it says now. Look them over, then confirm again.');
|
|
638
1004
|
} else {
|
|
639
1005
|
showError(data && data.error ? data.error : 'FloLess could not record your confirmation, so nothing was approved. Try again.');
|
|
640
1006
|
}
|
|
@@ -673,11 +1039,14 @@ ${WARN_LINE}`);
|
|
|
673
1039
|
}
|
|
674
1040
|
}
|
|
675
1041
|
tick.checked = false;
|
|
1042
|
+
if (tick2) tick2.checked = false;
|
|
676
1043
|
showError('');
|
|
677
1044
|
paint();
|
|
678
1045
|
document.addEventListener('keydown', onKey, true);
|
|
679
1046
|
root.addEventListener('click', onClick);
|
|
680
1047
|
tick.addEventListener('change', syncOk);
|
|
1048
|
+
if (tick2) tick2.addEventListener('change', syncOk);
|
|
1049
|
+
if (waitsBox) { waitsBox.addEventListener('input', onWaitChange); waitsBox.addEventListener('change', onWaitChange); }
|
|
681
1050
|
root.classList.add('show');
|
|
682
1051
|
tick.focus();
|
|
683
1052
|
});
|
|
@@ -685,14 +1054,16 @@ ${WARN_LINE}`);
|
|
|
685
1054
|
|
|
686
1055
|
/**
|
|
687
1056
|
* Before Approve: 'approved' (the dialog confirmed AND approved the bytes it showed - the caller only reloads), 'cancel', or
|
|
688
|
-
* 'proceed' (nothing to ask: no AI step, already confirmed, feature off, or the server cannot be asked - the normal path goes on)
|
|
1057
|
+
* 'proceed' (nothing to ask: no AI step, already confirmed, feature off, or the server cannot be asked - the normal path goes on),
|
|
1058
|
+
* or 'rename-step' (#2314: two steps share one name, nothing was approved; `takeRenameAsk()` hands over the ask).
|
|
689
1059
|
*/
|
|
690
1060
|
async function confirmBeforeApprove(app) {
|
|
691
1061
|
const status = await consentStatus(app.id);
|
|
692
1062
|
if (!status || (status.state !== 'needed' && status.state !== 'changed')) return 'proceed';
|
|
693
1063
|
const opened = await consentFetch('open', { app: app.id }).catch(() => null);
|
|
694
1064
|
if (!opened || opened.status !== 200 || !opened.data.ok) return 'proceed';
|
|
695
|
-
|
|
1065
|
+
const outcome = await consentDialog(app, 'approve', opened.data);
|
|
1066
|
+
return outcome === 'confirmed' ? 'approved' : outcome === 'rename-step' ? 'rename-step' : 'cancel';
|
|
696
1067
|
}
|
|
697
1068
|
|
|
698
1069
|
/** Before Run: 'proceed' once confirmed or when nothing needs asking, else 'cancel' (nothing started). */
|
|
@@ -701,7 +1072,15 @@ ${WARN_LINE}`);
|
|
|
701
1072
|
if (!status || (status.state !== 'needed' && status.state !== 'changed')) return 'proceed';
|
|
702
1073
|
const opened = await consentFetch('open', { app: app.id }).catch(() => null);
|
|
703
1074
|
if (!opened || opened.status !== 200 || !opened.data.ok) return 'proceed';
|
|
704
|
-
|
|
1075
|
+
const outcome = await consentDialog(app, 'run-dialog', opened.data);
|
|
1076
|
+
if (outcome === 'rename-step') {
|
|
1077
|
+
// #2314: two steps share a name, so the workflow could not be approved. Ask to rename; the run waits for a Compile.
|
|
1078
|
+
const ask = takeRenameAsk();
|
|
1079
|
+
const renamed = globalThis.flolessStepRename && ask ? await globalThis.flolessStepRename.open(ask) : { renamed: false };
|
|
1080
|
+
model.context.toast(renamed.renamed ? 'Renamed. Compile the workflow, then run it.' : `${ask && ask.sentence ? `${ask.sentence} ` : ''}Nothing was renamed, so it can’t run yet.`, 'warn');
|
|
1081
|
+
return 'cancel';
|
|
1082
|
+
}
|
|
1083
|
+
return outcome === 'confirmed' ? 'proceed' : 'cancel';
|
|
705
1084
|
}
|
|
706
1085
|
|
|
707
1086
|
// ── S5: the run record, the held-change card and the routine row words ──────────────────────────────────────
|
|
@@ -726,13 +1105,98 @@ ${WARN_LINE}`);
|
|
|
726
1105
|
const needs = Array.isArray(rec.needsYou) ? rec.needsYou.filter((item) => isRecord(item) && typeof item.text === 'string') : [];
|
|
727
1106
|
const steps = rec.aiSteps.filter(isRecord).map((step) => {
|
|
728
1107
|
const answered = step.ok === true;
|
|
729
|
-
const outcome = answered ? 'Answered' : (OUTCOME_WORDS[step.outcome] || (step.ok === false ? 'Did not answer' : 'Ran'));
|
|
1108
|
+
const outcome = answered ? 'Answered' : step.reason === 'cooldown' ? 'Skipped — the wait between answers' : (OUTCOME_WORDS[step.outcome] || (step.ok === false ? 'Did not answer' : 'Ran'));
|
|
730
1109
|
const agent = step.agentName ? `Agent ${step.agentName}${Number.isSafeInteger(step.agentRevision) ? `, revision ${step.agentRevision}` : ''}` : (Number.isSafeInteger(step.agentRevision) ? `Revision ${step.agentRevision}` : '');
|
|
731
1110
|
const who = [agent, [step.provider, step.model].filter(Boolean).join(' / '), Number.isFinite(step.durationMs) ? `${(step.durationMs / 1000).toFixed(1)} s` : ''].filter(Boolean).join(' · ');
|
|
732
|
-
return {
|
|
1111
|
+
return {
|
|
1112
|
+
nodeId: String(step.nodeId), answered, outcome, who, agentId: typeof step.agentId === 'string' ? step.agentId : '',
|
|
1113
|
+
agentName: typeof step.agentName === 'string' ? step.agentName : '',
|
|
1114
|
+
stepRunId: typeof step.stepRunId === 'string' ? step.stepRunId : '',
|
|
1115
|
+
conversationId: typeof step.conversationId === 'string' ? step.conversationId : '',
|
|
1116
|
+
knowledge: runKbView(step.knowledge),
|
|
1117
|
+
};
|
|
733
1118
|
});
|
|
734
1119
|
const summary = `Last run · ${plural(steps.length, 'AI step', 'AI steps')}${needs.length ? ` · ${plural(needs.length, 'question for you', 'questions for you')}` : ''}`;
|
|
735
|
-
return { summary, steps, needsCount: needs.length, groups: needsYouGroups(needs), open: needs.length > 0 };
|
|
1120
|
+
return { summary, steps, needsCount: needs.length, groups: needsYouGroups(needs), open: needs.length > 0, uses: usesView(rec) };
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
const KB_NONE_WORDS = {
|
|
1124
|
+
'no-match': (q) => `No pages matched the search “${q}”.`,
|
|
1125
|
+
'no-generation': () => 'This project has no published Knowledge.',
|
|
1126
|
+
busy: () => 'The Knowledge was being organized, so none was given.',
|
|
1127
|
+
'no-search-words': () => 'The search had no words to look up.',
|
|
1128
|
+
incomplete: () => 'FloLess couldn’t look through all of the Knowledge, and found no page it could use.',
|
|
1129
|
+
'project-replaced': () => 'The project was replaced by another project with the same name, so no pages were given.',
|
|
1130
|
+
unreadable: () => 'FloLess couldn’t read the Knowledge.',
|
|
1131
|
+
};
|
|
1132
|
+
const SHORTENED_TIP = 'Only part of this page was given: the part that matched the search, cut to fit.';
|
|
1133
|
+
|
|
1134
|
+
/** S7: the Knowledge a step was given in this run, as words (cited pages first), or null for a step that reads none. */
|
|
1135
|
+
function runKbView(kb) {
|
|
1136
|
+
if (!isRecord(kb) || (kb.status !== 'supplied' && kb.status !== 'none') || !Array.isArray(kb.pages)) return null;
|
|
1137
|
+
const pages = kb.pages.filter((page) => isRecord(page) && typeof page.title === 'string')
|
|
1138
|
+
.map((page) => ({ title: page.title, cited: page.cited === true, shortened: page.shortened === true }));
|
|
1139
|
+
const ordered = [...pages.filter((page) => page.cited), ...pages.filter((page) => !page.cited)];
|
|
1140
|
+
const none = kb.status !== 'supplied' || !ordered.length;
|
|
1141
|
+
const reason = none ? (KB_NONE_WORDS[kb.reason] || KB_NONE_WORDS.unreadable)(typeof kb.query === 'string' ? kb.query : '') : null;
|
|
1142
|
+
const day = typeof kb.publishedAt === 'string' && /^\d{4}-\d{2}-\d{2}/.test(kb.publishedAt) ? kb.publishedAt.slice(0, 10) : null;
|
|
1143
|
+
const notes = none ? [] : [
|
|
1144
|
+
...(kb.incomplete === true ? ['FloLess couldn’t look through all of the Knowledge, so a page that matters may be missing.'] : []),
|
|
1145
|
+
...(kb.moreMatches === true ? ['More pages matched than this step reads.'] : []),
|
|
1146
|
+
];
|
|
1147
|
+
return { pages: none ? [] : ordered, reason, published: none ? null : day, notes };
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
function runKbHtml(nodeId, kb) {
|
|
1151
|
+
if (!kb) return '';
|
|
1152
|
+
const id = `as-kb-${esc(nodeId)}`;
|
|
1153
|
+
const head = `<div class="as-use-title" id="${id}">Knowledge it was given</div>`;
|
|
1154
|
+
if (kb.reason) return `<div class="as-run-kb" role="group" aria-labelledby="${id}">${head}<p class="as-use-note">${esc(kb.reason)}</p></div>`;
|
|
1155
|
+
const items = kb.pages.map((page) => (page.cited
|
|
1156
|
+
? `<li><span aria-hidden="true">✓</span> <b>${esc(page.title)}</b> <span class="ai-pill is-uses">cited</span>`
|
|
1157
|
+
: `<li>${esc(page.title)}`)
|
|
1158
|
+
+ `${page.shortened ? ` <span class="as-use-note" data-tip="${esc(SHORTENED_TIP)}">shortened to fit</span>` : ''}</li>`).join('');
|
|
1159
|
+
return `<div class="as-run-kb" role="group" aria-labelledby="${id}">${head}<ul class="as-use-list">${items}</ul>`
|
|
1160
|
+
+ `${kb.published ? `<p class="as-use-note">Knowledge as published on ${esc(kb.published)}.</p>` : ''}`
|
|
1161
|
+
+ kb.notes.map((note) => `<p class="as-use-note">${esc(note)}</p>`).join('') + '</div>';
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
const NOT_LISTED = {
|
|
1165
|
+
'no-snapshot': 'This run started before FloLess recorded which steps use the answer.',
|
|
1166
|
+
'changed-since-compile': 'The workflow had changed since it was approved when this run started.',
|
|
1167
|
+
unreadable: 'FloLess couldn’t read the workflow, so it can’t say which steps use the answer.',
|
|
1168
|
+
'duplicate-ids': 'Two steps share a name, so FloLess couldn’t tell which steps use the answer.',
|
|
1169
|
+
};
|
|
1170
|
+
const TRACE_NOTE = 'Other steps may use the answer in ways FloLess can’t trace.';
|
|
1171
|
+
|
|
1172
|
+
/** #2374: the parts of this run FloLess found using the answer (from the run's own record), or why they are not listed. */
|
|
1173
|
+
function usesView(rec) {
|
|
1174
|
+
if (Array.isArray(rec.dependents)) {
|
|
1175
|
+
const rows = rec.dependents.filter((row) => isRecord(row) && typeof row.nodeId === 'string' && (row.how === 'uses' || row.how === 'decided'));
|
|
1176
|
+
return {
|
|
1177
|
+
listed: true,
|
|
1178
|
+
ran: rows.filter((row) => row.ran === true).map((row) => ({ nodeId: row.nodeId, how: row.how })),
|
|
1179
|
+
notRun: rows.filter((row) => row.ran !== true).map((row) => row.nodeId),
|
|
1180
|
+
note: TRACE_NOTE,
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
if (typeof rec.dependentsUnknown === 'string') return { listed: false, reason: NOT_LISTED[rec.dependentsUnknown] || NOT_LISTED['no-snapshot'] };
|
|
1184
|
+
return null;
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
function usesHtml(uses) {
|
|
1188
|
+
if (!uses) return '';
|
|
1189
|
+
const head = '<div class="as-use-title" id="as-use-title">Parts FloLess found using the answer</div>';
|
|
1190
|
+
if (!uses.listed) return `<div class="as-use" role="group" aria-labelledby="as-use-title">${head}<p class="as-use-note">Not listed for this run. ${esc(uses.reason)}</p></div>`;
|
|
1191
|
+
const words = { uses: 'uses it', decided: 'decided by it' };
|
|
1192
|
+
const list = uses.ran.length
|
|
1193
|
+
? `<ul class="as-use-list">${uses.ran.map((row) => `<li><b>${esc(row.nodeId)}</b> <span class="ai-pill is-uses">${words[row.how]}</span></li>`).join('')}</ul>`
|
|
1194
|
+
: '<p class="as-use-note">None of them ran in this run.</p>';
|
|
1195
|
+
const notRun = uses.notRun.length ? `<p class="as-use-skipped">Not run this time: ${esc(uses.notRun.join(', '))}</p>` : '';
|
|
1196
|
+
if (!uses.ran.length && !uses.notRun.length) {
|
|
1197
|
+
return `<div class="as-use" role="group" aria-labelledby="as-use-title">${head}<p class="as-use-note">No step using the answer was found. ${esc(uses.note)}</p></div>`;
|
|
1198
|
+
}
|
|
1199
|
+
return `<div class="as-use" role="group" aria-labelledby="as-use-title">${head}${list}${notRun}<p class="as-use-note">${esc(uses.note)}</p></div>`;
|
|
736
1200
|
}
|
|
737
1201
|
|
|
738
1202
|
const runs = new Map(); // appId -> the last run's record (kept only when it had an AI step)
|
|
@@ -750,11 +1214,14 @@ ${WARN_LINE}`);
|
|
|
750
1214
|
document.getElementById('as-run-sum').innerHTML = `${aiPillHtml()}<span class="as-run-sum-text">${esc(view.summary)}</span>`;
|
|
751
1215
|
const stepHtml = view.steps.map((step) => `<div class="as-run-step"><div class="as-run-line"><b>${esc(step.nodeId)}</b>${aiPillHtml()}<span class="as-run-out ${step.answered ? 'ok' : 'warn'}">${step.answered ? '✓' : '△'} ${esc(step.outcome)}</span></div>`
|
|
752
1216
|
+ `${step.who ? `<div class="as-run-who">${esc(step.who)}</div>` : ''}`
|
|
753
|
-
+
|
|
1217
|
+
+ runKbHtml(step.nodeId, step.knowledge)
|
|
1218
|
+
+ `<div class="as-run-links">${step.conversationId && step.stepRunId && step.agentId ? `<button type="button" class="as-btn as-link" data-as-run-convo="${esc(step.nodeId)}" aria-label="Open its conversation, step ${esc(step.nodeId)}" data-command-id="shell.agent-run-open-conversation">Open its conversation ▸</button>` : ''}`
|
|
1219
|
+
+ `${step.agentId ? `<button type="button" class="as-btn as-link" data-as-run-agent="${esc(step.agentId)}" aria-label="Open the Agent’s runs, step ${esc(step.nodeId)}" data-command-id="shell.agent-run-open-agent">Open the Agent’s runs ▸</button>` : ''}</div></div>`).join('');
|
|
754
1220
|
const needsHtml = view.groups.length
|
|
755
1221
|
? `<div class="as-needs" role="group" aria-label="Questions for you"><div class="as-needs-title">Questions for you (${view.needsCount})</div>${view.groups.map((group) => `<div class="as-needs-group"><div class="as-needs-kind">${esc(group.title)}</div><ul>${group.items.map((item) => `<li><b>${esc(item.nodeId)}</b>: ${esc(item.text)}</li>`).join('')}</ul></div>`).join('')}</div>`
|
|
756
1222
|
: '';
|
|
757
|
-
|
|
1223
|
+
const note = noteOffLine(model.notes.get(app.id));
|
|
1224
|
+
document.getElementById('as-run-body').innerHTML = stepHtml + usesHtml(view.uses) + (note ? `<p class="as-use-note">${esc(note)}</p>` : '') + needsHtml;
|
|
758
1225
|
box.hidden = false;
|
|
759
1226
|
box.open = open;
|
|
760
1227
|
}
|
|
@@ -770,20 +1237,295 @@ ${WARN_LINE}`);
|
|
|
770
1237
|
if (!on) { runs.delete(appId); paintRunRecord(); return; }
|
|
771
1238
|
let body = null;
|
|
772
1239
|
try {
|
|
773
|
-
const
|
|
1240
|
+
const path = `/api/latest-run/${encodeURIComponent(appId)}`;
|
|
1241
|
+
await globalThis.flolessStartupAdmission?.admit(path);
|
|
1242
|
+
if (runGeneration.get(appId) !== mine) return;
|
|
1243
|
+
const response = await fetch(path, { credentials: 'same-origin' });
|
|
774
1244
|
body = response.ok ? await response.json() : null;
|
|
775
1245
|
} catch { body = null; }
|
|
776
1246
|
if (runGeneration.get(appId) !== mine || !body || body.ok !== true) return;
|
|
777
|
-
if (Array.isArray(body.aiSteps) && body.aiSteps.length)
|
|
1247
|
+
if (Array.isArray(body.aiSteps) && body.aiSteps.length) {
|
|
1248
|
+
runs.set(appId, {
|
|
1249
|
+
runId: body.runId, aiSteps: body.aiSteps, needsYou: Array.isArray(body.needsYou) ? body.needsYou : [],
|
|
1250
|
+
...(Array.isArray(body.dependents) ? { dependents: body.dependents } : {}),
|
|
1251
|
+
...(typeof body.dependentsUnknown === 'string' ? { dependentsUnknown: body.dependentsUnknown } : {}),
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
778
1254
|
else runs.delete(appId);
|
|
779
1255
|
paintRunRecord();
|
|
1256
|
+
model.context.runRecordChanged(appId); // the trace's labels read this record, so they repaint with it
|
|
780
1257
|
void checkGates();
|
|
781
1258
|
}
|
|
782
1259
|
|
|
1260
|
+
/** “a”, “a” and “b”, “a”, “b” and “c”, or “a”, “b”, “c” and 2 more. */
|
|
1261
|
+
function quotedList(names) {
|
|
1262
|
+
const q = names.map((name) => `“${name}”`);
|
|
1263
|
+
if (q.length <= 1) return q.join('');
|
|
1264
|
+
if (q.length <= 3) return `${q.slice(0, -1).join(', ')} and ${q[q.length - 1]}`;
|
|
1265
|
+
return `${q.slice(0, 3).join(', ')} and ${q.length - 3} more`;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* #2415: what to say when a run made no report and an AI step in it did not answer (its `-ok` check stops the run, by design).
|
|
1270
|
+
* Pure: the run's own answer in (`aiSteps`, `needsYou`, `dependents`), plain words out; null when no AI step failed to answer, so the caller
|
|
1271
|
+
* keeps its own words. It says the step STOPPED the report only when the run record shows the report is built on that step's answer and
|
|
1272
|
+
* did not run; otherwise it says only that the step did not answer and no report was made.
|
|
1273
|
+
*/
|
|
1274
|
+
function stoppedReportView(res, reportNodeId) {
|
|
1275
|
+
if (!isRecord(res) || !Array.isArray(res.aiSteps)) return null;
|
|
1276
|
+
const stopped = [...new Set(res.aiSteps.filter((step) => isRecord(step) && step.ok === false && typeof step.nodeId === 'string').map((step) => step.nodeId))];
|
|
1277
|
+
if (!stopped.length) return null;
|
|
1278
|
+
const needs = Array.isArray(res.needsYou) ? res.needsYou.filter(isRecord) : [];
|
|
1279
|
+
const asks = stopped.filter((id) => needs.some((item) => item.nodeId === id && item.kind === 'question'));
|
|
1280
|
+
const silent = stopped.filter((id) => !asks.includes(id));
|
|
1281
|
+
const row = Array.isArray(res.dependents) ? res.dependents.find((r) => isRecord(r) && r.nodeId === reportNodeId) : null;
|
|
1282
|
+
const causal = !!row && row.ran !== true && Array.isArray(row.steps) && row.steps.some((id) => stopped.includes(id));
|
|
1283
|
+
// Questions for you lists something only when the record left an item for a stopped step; otherwise the way on is Last run itself.
|
|
1284
|
+
const listed = needs.some((item) => stopped.includes(item.nodeId));
|
|
1285
|
+
const named = (ids) => `the AI ${ids.length === 1 ? 'step' : 'steps'} ${quotedList(ids)}`;
|
|
1286
|
+
const parts = [];
|
|
1287
|
+
if (asks.length) parts.push(`${named(asks)} ${asks.length === 1 ? 'has' : 'have'} questions for you`);
|
|
1288
|
+
if (silent.length) parts.push(`${named(silent)} did not give an answer the workflow could use`);
|
|
1289
|
+
const what = parts.join(', and ');
|
|
1290
|
+
const why = causal ? ', so the run stopped before the report.' : ', and the run made no report.';
|
|
1291
|
+
const whose = stopped.length === 1 ? 'the step’s' : 'the steps’';
|
|
1292
|
+
const where = listed ? 'Questions for you' : 'Last run above the canvas';
|
|
1293
|
+
const next = asks.length
|
|
1294
|
+
? ` Read them in ${where}, then adjust the inputs or ${whose} instructions and run it again.`
|
|
1295
|
+
: ` Open ${where} to see what happened, then adjust ${whose} instructions or inputs and run it again.`;
|
|
1296
|
+
return {
|
|
1297
|
+
status: 'Needs you', headline: causal ? 'The run stopped before the report' : 'No report was made',
|
|
1298
|
+
sub: causal ? 'The run stopped before the report.' : 'The run ended without a report.',
|
|
1299
|
+
body: what.charAt(0).toUpperCase() + what.slice(1) + why + next, steps: stopped, causal, listed,
|
|
1300
|
+
runId: typeof res.runId === 'string' ? res.runId : null,
|
|
1301
|
+
button: listed ? 'Open Questions for you' : 'Open Last run',
|
|
1302
|
+
commandId: listed ? 'shell.report-ai-stop-questions' : 'shell.report-ai-stop-last-run',
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
/**
|
|
1307
|
+
* #2415: open the canvas's Last run panel on its Questions for you and move focus there. The record is read again unless the panel
|
|
1308
|
+
* already holds this very run (`runId`), so it never shows an earlier run's questions. False when it cannot show this run, so the
|
|
1309
|
+
* caller keeps the viewer open and says so. `beforeFocus` runs once the panel is shown and before focus moves, so the caller can close
|
|
1310
|
+
* a modal first: focus that lands while a modal is still up is not announced as the new place.
|
|
1311
|
+
*/
|
|
1312
|
+
async function openQuestions(appId, runId, beforeFocus) {
|
|
1313
|
+
if (!appId) return false;
|
|
1314
|
+
const current = () => (runId ? runs.get(appId)?.runId === runId : runs.has(appId));
|
|
1315
|
+
if (!current()) await refreshRunRecord(appId);
|
|
1316
|
+
const box = document.getElementById('as-run');
|
|
1317
|
+
if (!current() || !box || box.hidden || box.dataset.for !== appId) return false;
|
|
1318
|
+
box.open = true;
|
|
1319
|
+
box.scrollIntoView?.({ block: 'nearest' });
|
|
1320
|
+
// The panel scrolls inside itself, and the questions come after the steps: bring them into view, not just the panel's top.
|
|
1321
|
+
box.querySelector?.('.as-needs')?.scrollIntoView?.({ block: 'nearest' });
|
|
1322
|
+
beforeFocus?.();
|
|
1323
|
+
document.getElementById('as-run-sum')?.focus?.({ preventScroll: true });
|
|
1324
|
+
return true;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
// ── #2448: the AI note in reports, which the person may turn off (per workflow, and for all workflows) ───────────
|
|
1328
|
+
|
|
1329
|
+
const NOTE_HINT = 'Adds a note to this workflow’s reports saying part of the report was written by an AI. A change applies to reports made from now on.';
|
|
1330
|
+
const NOTE_GLOBAL_OFF = 'Off for all reports in the ≡ menu (AI note in reports). This switch counts again once that is back on.';
|
|
1331
|
+
|
|
1332
|
+
/** Pure: what the Inspect switch shows for a workflow's note state (`{ enabled, global }`), or null when it is not known yet. */
|
|
1333
|
+
function noteView(state) {
|
|
1334
|
+
if (!isRecord(state) || typeof state.enabled !== 'boolean') return null;
|
|
1335
|
+
const globalOff = state.global === false;
|
|
1336
|
+
return { checked: state.enabled, hint: globalOff ? NOTE_GLOBAL_OFF : NOTE_HINT, globalOff };
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
function noteHtml(state) {
|
|
1340
|
+
const view = noteView(state);
|
|
1341
|
+
if (!view) return '';
|
|
1342
|
+
return '<h3>Its reports</h3><div class="as-note-row"><span>AI note in this workflow’s reports</span>'
|
|
1343
|
+
+ '<label class="rtn-toggle">'
|
|
1344
|
+
+ `<input type="checkbox" role="switch" data-as-report-note aria-label="AI note in this workflow’s reports" aria-describedby="as-note-hint" data-command-id="shell.agent-report-note"${view.checked ? ' checked' : ''}>`
|
|
1345
|
+
+ '<span class="rtn-toggle-track"></span></label></div>'
|
|
1346
|
+
+ `<p class="as-note-hint${view.globalOff ? ' is-global-off' : ''}" id="as-note-hint">${esc(view.hint)}</p>`;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
/**
|
|
1350
|
+
* Pure: the Last run panel's line when reports made NOW leave the note out, or '' when they carry it (or it is not known). It names the
|
|
1351
|
+
* current setting, never the run the panel shows: that run's report was made under whatever the setting was then.
|
|
1352
|
+
*/
|
|
1353
|
+
function noteOffLine(state) {
|
|
1354
|
+
if (!isRecord(state) || state.shown !== false) return '';
|
|
1355
|
+
return state.off === 'global'
|
|
1356
|
+
? 'Reports made now leave out the AI note: it is turned off for all reports.'
|
|
1357
|
+
: 'This workflow’s reports made now leave out the AI note: it is turned off for this workflow.';
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
/**
|
|
1361
|
+
* #2461: one workflow's AI-note reads and saves, kept in order. The server's answers are the truth, with two rules on top:
|
|
1362
|
+
* - While saves are out, Inspect shows the person's latest choice. Saves run one at a time in the order they were made;
|
|
1363
|
+
* each answer only updates what the server is known to hold, and only the newest one is shown, announced or reverted.
|
|
1364
|
+
* - A read stores its answer only if it is the newest read and no save started or answered since it began. A read that
|
|
1365
|
+
* a save overtook is made again once no save is out, so a change made elsewhere (the ≡ switch) is never lost.
|
|
1366
|
+
*/
|
|
1367
|
+
function noteSyncOf(appId) {
|
|
1368
|
+
let sync = model.noteSync.get(appId);
|
|
1369
|
+
if (!sync) {
|
|
1370
|
+
sync = { reads: 0, saves: 0, epoch: 0, latest: 0, queue: Promise.resolve(), confirmed: undefined, reread: false };
|
|
1371
|
+
model.noteSync.set(appId, sync);
|
|
1372
|
+
}
|
|
1373
|
+
return sync;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
function noteOf(body) {
|
|
1377
|
+
return { enabled: body.enabled === true, global: body.global !== false, shown: body.shown !== false, off: body.off || null };
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
/** The note as it will be once the person's choice is saved: the switch, and what reports will then do. */
|
|
1381
|
+
function noteWithChoice(note, enabled) {
|
|
1382
|
+
if (!note) return note;
|
|
1383
|
+
return { ...note, enabled, shown: enabled && note.global, off: !note.global ? 'global' : enabled ? null : 'workflow' };
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
function repaintNote(appId) {
|
|
1387
|
+
if (model.context.currentApp()?.id === appId) { model.context.repaint(appId); paintRunRecord(); }
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
async function refreshNote(appId) {
|
|
1391
|
+
if (!appId) return;
|
|
1392
|
+
const sync = noteSyncOf(appId);
|
|
1393
|
+
const read = ++sync.reads;
|
|
1394
|
+
const epoch = sync.epoch;
|
|
1395
|
+
let note = null;
|
|
1396
|
+
try {
|
|
1397
|
+
const path = `/api/app/${encodeURIComponent(appId)}/report-ai-label`;
|
|
1398
|
+
// A selected-workflow read like the checks: it waits for the server's startup recovery before it goes out.
|
|
1399
|
+
await globalThis.flolessStartupAdmission?.admit(path);
|
|
1400
|
+
const response = await fetch(path, { credentials: 'same-origin' });
|
|
1401
|
+
const body = response.ok ? await response.json() : null;
|
|
1402
|
+
if (body && body.ok === true) note = noteOf(body); // otherwise not known: the switch stays as it is rather than guess
|
|
1403
|
+
} catch { note = null; }
|
|
1404
|
+
if (read !== sync.reads) return; // a newer read decides
|
|
1405
|
+
if (sync.saves > 0 || sync.epoch !== epoch) {
|
|
1406
|
+
// A save overtook this read (answered or not), so what it saw may be older than the save: read again once no save is out.
|
|
1407
|
+
sync.reread = true;
|
|
1408
|
+
if (sync.saves === 0) { sync.reread = false; void refreshNote(appId); }
|
|
1409
|
+
return;
|
|
1410
|
+
}
|
|
1411
|
+
if (!note) return;
|
|
1412
|
+
sync.confirmed = note;
|
|
1413
|
+
model.notes.set(appId, note);
|
|
1414
|
+
repaintNote(appId);
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
/** The person's choice for one workflow: shown at once, saved in order after any save still out. */
|
|
1418
|
+
function setNote(appId, enabled) {
|
|
1419
|
+
const sync = noteSyncOf(appId);
|
|
1420
|
+
if (sync.saves === 0) sync.confirmed = model.notes.get(appId);
|
|
1421
|
+
const mine = ++sync.latest;
|
|
1422
|
+
sync.saves += 1;
|
|
1423
|
+
sync.epoch += 1;
|
|
1424
|
+
const shown = noteWithChoice(model.notes.get(appId), enabled);
|
|
1425
|
+
if (shown) { model.notes.set(appId, shown); repaintNote(appId); }
|
|
1426
|
+
const run = sync.queue.then(() => saveNote(appId, enabled, sync, () => sync.latest === mine)).finally(() => {
|
|
1427
|
+
sync.saves -= 1;
|
|
1428
|
+
sync.epoch += 1;
|
|
1429
|
+
if (sync.saves === 0 && sync.reread) { sync.reread = false; void refreshNote(appId); }
|
|
1430
|
+
});
|
|
1431
|
+
sync.queue = run.catch(() => undefined);
|
|
1432
|
+
return run;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
async function saveNote(appId, enabled, sync, newest) {
|
|
1436
|
+
try {
|
|
1437
|
+
const response = await fetch(`/api/app/${encodeURIComponent(appId)}/report-ai-label`, {
|
|
1438
|
+
method: 'PUT', credentials: 'same-origin', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ enabled }),
|
|
1439
|
+
});
|
|
1440
|
+
const body = response.ok ? await response.json() : null;
|
|
1441
|
+
if (!body || body.ok !== true) throw new Error('not saved');
|
|
1442
|
+
sync.confirmed = noteOf(body); // saves answer in order, so this is what the server holds now
|
|
1443
|
+
if (!newest()) return; // a newer choice is queued: it is what Inspect keeps showing, and what is announced
|
|
1444
|
+
model.notes.set(appId, sync.confirmed);
|
|
1445
|
+
model.context.toast(enabled ? 'This workflow’s next report will include the AI note.' : 'This workflow’s next report will leave out the AI note.', 'ok');
|
|
1446
|
+
} catch {
|
|
1447
|
+
if (!newest()) return; // the newer choice decides what is shown and said
|
|
1448
|
+
if (sync.confirmed) model.notes.set(appId, sync.confirmed); // back to what the server is known to hold
|
|
1449
|
+
model.context.toast('FloLess couldn’t save the AI note setting. Try again.', 'warn');
|
|
1450
|
+
}
|
|
1451
|
+
repaintNote(appId);
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
/** The ≡ menu row: shown once the feature is known to be on, set from the server, and saved on change. */
|
|
1455
|
+
async function initGlobalNote() {
|
|
1456
|
+
const row = document.getElementById('menu-ai-note');
|
|
1457
|
+
const toggle = document.getElementById('menu-ai-note-toggle');
|
|
1458
|
+
if (!row || !toggle) return;
|
|
1459
|
+
try {
|
|
1460
|
+
// Read once the server's startup recovery is done, like every protected read the page makes while opening.
|
|
1461
|
+
await globalThis.flolessStartupAdmission?.admit('/api/report-ai-label');
|
|
1462
|
+
const response = await fetch('/api/report-ai-label', { credentials: 'same-origin' });
|
|
1463
|
+
const body = response.ok ? await response.json() : null;
|
|
1464
|
+
if (!body || body.ok !== true) return; // unknown: the row stays hidden, never a switch in the wrong position
|
|
1465
|
+
toggle.checked = body.enabled !== false;
|
|
1466
|
+
row.hidden = !enabled();
|
|
1467
|
+
} catch { return; }
|
|
1468
|
+
if (toggle.dataset.wired) return;
|
|
1469
|
+
toggle.dataset.wired = '1';
|
|
1470
|
+
toggle.addEventListener('change', async () => {
|
|
1471
|
+
const want = toggle.checked;
|
|
1472
|
+
toggle.disabled = true;
|
|
1473
|
+
try {
|
|
1474
|
+
const response = await fetch('/api/report-ai-label', {
|
|
1475
|
+
method: 'PUT', credentials: 'same-origin', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ enabled: want }),
|
|
1476
|
+
});
|
|
1477
|
+
const body = response.ok ? await response.json() : null;
|
|
1478
|
+
if (!body || body.ok !== true) throw new Error('not saved');
|
|
1479
|
+
toggle.checked = body.enabled !== false;
|
|
1480
|
+
model.context.toast(want ? 'Reports made from now on include the AI note again.' : 'Reports made from now on leave out the AI note, for every workflow.', 'ok');
|
|
1481
|
+
} catch {
|
|
1482
|
+
toggle.checked = !want;
|
|
1483
|
+
model.context.toast('FloLess couldn’t save the AI note setting. Try again.', 'warn');
|
|
1484
|
+
} finally { toggle.disabled = false; }
|
|
1485
|
+
const app = model.context.currentApp();
|
|
1486
|
+
if (app) void refreshNote(app.id); // the workflow's own switch says what this one now means for it
|
|
1487
|
+
});
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
document.addEventListener('change', (event) => {
|
|
1491
|
+
const input = event.target instanceof Element ? event.target.closest('[data-as-report-note]') : null;
|
|
1492
|
+
if (!input) return;
|
|
1493
|
+
const app = model.context.currentApp();
|
|
1494
|
+
if (app) void setNote(app.id, input.checked === true);
|
|
1495
|
+
});
|
|
1496
|
+
|
|
1497
|
+
const CONVO_FAILED = 'FloLess couldn’t open this step’s conversation. Open the Agent’s runs to check this run.';
|
|
1498
|
+
|
|
1499
|
+
/**
|
|
1500
|
+
* #2375: open the conversation an Agent step ran in. Its owner (the Agent's first pinned place, not this workflow) lives on the Agent's
|
|
1501
|
+
* run, so the run is looked up first; the conversation is opened only when that run names this exact conversation.
|
|
1502
|
+
*/
|
|
1503
|
+
async function openStepConversation(step) {
|
|
1504
|
+
try {
|
|
1505
|
+
const response = await fetch(`/api/chat/agents/${encodeURIComponent(step.agentId)}/runs`, { credentials: 'same-origin' });
|
|
1506
|
+
const body = response.ok ? await response.json() : null;
|
|
1507
|
+
const list = Array.isArray(body) ? body : body && Array.isArray(body.runs) ? body.runs : [];
|
|
1508
|
+
const run = list.find((row) => isRecord(row) && row.runId === step.stepRunId);
|
|
1509
|
+
const target = run && Array.isArray(run.targets)
|
|
1510
|
+
? run.targets.find((t) => isRecord(t) && isRecord(t.owner) && t.chatId === step.conversationId) : null;
|
|
1511
|
+
if (!target) { model.context.toast(CONVO_FAILED, 'warn'); return false; }
|
|
1512
|
+
const label = `Agent “${step.agentName || 'Agent'}” · step “${step.nodeId}”`;
|
|
1513
|
+
if (document.getElementById('app')?.classList.contains('left-collapsed')) {
|
|
1514
|
+
document.querySelector('.pane-rail-left .panel-toggle[data-side="left"]')?.click();
|
|
1515
|
+
}
|
|
1516
|
+
const opened = await window.flolessChat?.openConversationIn?.({ owner: target.owner, label }, target.chatId);
|
|
1517
|
+
if (opened !== true) { model.context.toast(CONVO_FAILED, 'warn'); return false; }
|
|
1518
|
+
return true;
|
|
1519
|
+
} catch {
|
|
1520
|
+
model.context.toast(CONVO_FAILED, 'warn');
|
|
1521
|
+
return false;
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
|
|
783
1525
|
// ── the held change ("Waiting for your approval") ──────────────────────────────────────────────────────────
|
|
784
1526
|
|
|
785
1527
|
const GATE_API = '/api/chat/agent-steps/gates';
|
|
786
|
-
const gateModel = { shown: null, timer: null, deciding: false, delay: 2000 };
|
|
1528
|
+
const gateModel = { shown: null, timer: null, deciding: false, delay: 2000, checking: null };
|
|
787
1529
|
|
|
788
1530
|
/** Pure: how the card words a pending gate. `now` is a Date, `gate.expiresAt` an ISO time. */
|
|
789
1531
|
function gateView(gate, now = new Date()) {
|
|
@@ -798,6 +1540,8 @@ ${WARN_LINE}`);
|
|
|
798
1540
|
values,
|
|
799
1541
|
time: clock ? `This step stops at ${clock}. If nobody decides, the change is not made.` : 'If nobody decides, the change is not made.',
|
|
800
1542
|
expired: Number.isFinite(until.getTime()) && now.getTime() >= until.getTime(),
|
|
1543
|
+
// S8: a watcher's confirmation (it carries its fire) holds up that watcher's next events, never the run queue.
|
|
1544
|
+
queue: Number.isInteger(gate.fire) ? 'The watcher waits for your decision; its next events wait behind it.' : 'This run holds the queue; other runs wait.',
|
|
801
1545
|
};
|
|
802
1546
|
}
|
|
803
1547
|
|
|
@@ -811,6 +1555,8 @@ ${WARN_LINE}`);
|
|
|
811
1555
|
document.getElementById('as-gate-label').hidden = !view.values;
|
|
812
1556
|
document.getElementById('as-gate-values').hidden = !view.values;
|
|
813
1557
|
document.getElementById('as-gate-time').textContent = view.time;
|
|
1558
|
+
const queue = document.getElementById('as-gate-queue');
|
|
1559
|
+
if (queue) queue.textContent = view.queue;
|
|
814
1560
|
// The announcement is set once when the card appears, never again on a re-poll (no repeated interruptions).
|
|
815
1561
|
if (!same) document.getElementById('as-gate-live').innerHTML = `<b>${esc(view.title)}.</b> ${esc(view.summary)}`;
|
|
816
1562
|
if (!same) document.getElementById('as-gate-error').hidden = true;
|
|
@@ -819,20 +1565,54 @@ ${WARN_LINE}`);
|
|
|
819
1565
|
card.hidden = false;
|
|
820
1566
|
}
|
|
821
1567
|
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
1568
|
+
/**
|
|
1569
|
+
* #2421: the gates route answers 404 while the server has Agent steps off. The page learnt "on" once and kept it, so a server that
|
|
1570
|
+
* was restarted with the feature off (or an older AWARE) drew a 404 on every look. Ask the same switch the page started from; when it
|
|
1571
|
+
* now says off, stop looking (the watch ends at its next tick) and take down anything the feature showed. Anything else is not an
|
|
1572
|
+
* answer, and the next look asks again.
|
|
1573
|
+
*/
|
|
1574
|
+
async function recheckSwitch(signal) {
|
|
825
1575
|
try {
|
|
826
|
-
const response = await fetch(
|
|
1576
|
+
const response = await fetch('/api/agent-steps/status', { credentials: 'same-origin', signal });
|
|
827
1577
|
const body = response.ok ? await response.json() : null;
|
|
828
|
-
if (body && body.
|
|
829
|
-
} catch {
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
1578
|
+
if (!(isRecord(body) && body.enabled === false) || body.pending === true) return;
|
|
1579
|
+
} catch { return; }
|
|
1580
|
+
model.enabled = false;
|
|
1581
|
+
paintGate(null);
|
|
1582
|
+
const row = document.getElementById('menu-ai-note');
|
|
1583
|
+
if (row) row.hidden = true;
|
|
1584
|
+
paintRunRecord();
|
|
1585
|
+
model.context.repaint();
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
function checkGates() {
|
|
1589
|
+
if (!enabled()) return Promise.resolve();
|
|
1590
|
+
if (gateModel.checking) return gateModel.checking;
|
|
1591
|
+
gateModel.checking = Promise.resolve().then(async () => {
|
|
1592
|
+
let deadline;
|
|
1593
|
+
let gates = null;
|
|
1594
|
+
try {
|
|
1595
|
+
await globalThis.flolessStartupAdmission?.admit(GATE_API);
|
|
1596
|
+
const controller = new AbortController();
|
|
1597
|
+
deadline = setTimeout(() => controller.abort(), 30000);
|
|
1598
|
+
// This watcher can start before Chat: establish its person cookie and wait for project recovery first.
|
|
1599
|
+
const session = await fetch('/api/chat/session', { credentials: 'same-origin', signal: controller.signal });
|
|
1600
|
+
if (!session.ok || (await session.json())?.ready !== true) return;
|
|
1601
|
+
const response = await fetch(GATE_API, { credentials: 'same-origin', signal: controller.signal });
|
|
1602
|
+
// Still under the look's deadline: a status read that never answers cannot hold the watch.
|
|
1603
|
+
if (response.status === 404) { await recheckSwitch(controller.signal); return; }
|
|
1604
|
+
const body = response.ok ? await response.json() : null;
|
|
1605
|
+
if (body && body.ok === true && Array.isArray(body.gates)) gates = body.gates;
|
|
1606
|
+
} catch { gates = null; }
|
|
1607
|
+
finally { clearTimeout(deadline); }
|
|
1608
|
+
if (!gates) return; // a failed look says nothing: the card that was up stays, nothing new is invented
|
|
1609
|
+
const next = gates[0] || null;
|
|
1610
|
+
if (!next && gateModel.shown && !gateModel.deciding) {
|
|
1611
|
+
model.context.toast('A change that was waiting for you is no longer waiting. Open the last run to see whether it was made.', 'warn');
|
|
1612
|
+
}
|
|
1613
|
+
paintGate(next);
|
|
1614
|
+
}).finally(() => { gateModel.checking = null; });
|
|
1615
|
+
return gateModel.checking;
|
|
836
1616
|
}
|
|
837
1617
|
|
|
838
1618
|
/**
|
|
@@ -913,6 +1693,40 @@ ${WARN_LINE}`);
|
|
|
913
1693
|
if (!target) return;
|
|
914
1694
|
const open = target.closest('[data-as-run-agent]');
|
|
915
1695
|
if (open) { model.context.openAgent(open.getAttribute('data-as-run-agent')); return; }
|
|
1696
|
+
const convo = target.closest('[data-as-run-convo]');
|
|
1697
|
+
if (convo) {
|
|
1698
|
+
const app = model.context.currentApp();
|
|
1699
|
+
const view = app ? runRecordView(runs.get(app.id)) : null;
|
|
1700
|
+
const step = view && view.steps.find((row) => row.nodeId === convo.getAttribute('data-as-run-convo'));
|
|
1701
|
+
if (step) void openStepConversation(step);
|
|
1702
|
+
return;
|
|
1703
|
+
}
|
|
1704
|
+
// S8: the wait between a watcher step's answers, changed from Inspect.
|
|
1705
|
+
const change = target.closest('[data-as-wait-change]');
|
|
1706
|
+
if (change) {
|
|
1707
|
+
const edit = document.querySelector(`[data-as-wait-edit="${CSS.escape(change.getAttribute('data-as-wait-change'))}"]`);
|
|
1708
|
+
if (edit) { edit.hidden = !edit.hidden; change.setAttribute('aria-expanded', String(!edit.hidden)); if (!edit.hidden) edit.querySelector('input')?.focus(); }
|
|
1709
|
+
return;
|
|
1710
|
+
}
|
|
1711
|
+
const limit = target.closest('[data-as-wait-on]');
|
|
1712
|
+
if (limit) { const field = limit.closest('[data-as-wait-edit]')?.querySelector('.ac-wait-field'); if (field) field.hidden = !limit.checked; return; }
|
|
1713
|
+
const cancel = target.closest('[data-as-wait-cancel]');
|
|
1714
|
+
if (cancel) { const app = model.context.currentApp(); model.repaintAfterEdit = null; if (app) model.context.repaint(app.id); return; }
|
|
1715
|
+
const save = target.closest('[data-as-wait-save]');
|
|
1716
|
+
if (save) {
|
|
1717
|
+
const app = model.context.currentApp();
|
|
1718
|
+
const nodeId = save.getAttribute('data-as-wait-save');
|
|
1719
|
+
const edit = save.closest('[data-as-wait-edit]');
|
|
1720
|
+
if (!app || !edit) return;
|
|
1721
|
+
const on = edit.querySelector('[data-as-wait-on]');
|
|
1722
|
+
const value = Number(edit.querySelector('[data-as-wait-input]')?.value);
|
|
1723
|
+
if (on && on.checked && !(Number.isInteger(value) && value >= 1 && value <= 1440)) {
|
|
1724
|
+
model.context.toast('Enter a whole number of minutes from 1 to 1440, or turn the limit off. Nothing was changed.', 'warn');
|
|
1725
|
+
return;
|
|
1726
|
+
}
|
|
1727
|
+
void saveWait(app.id, nodeId, on && !on.checked ? 0 : value);
|
|
1728
|
+
return;
|
|
1729
|
+
}
|
|
916
1730
|
if (target.closest('#as-gate-approve')) void decideGate('approved');
|
|
917
1731
|
else if (target.closest('#as-gate-skip')) void decideGate('skipped');
|
|
918
1732
|
});
|
|
@@ -921,8 +1735,11 @@ ${WARN_LINE}`);
|
|
|
921
1735
|
|
|
922
1736
|
window.flolessAgentSteps = {
|
|
923
1737
|
probe, enabled, isStepNode, entryParts, refreshChecks, checkFor, stepCount, headerText, markTip, draftAdd, draftUpdate, paintCanvasControl,
|
|
924
|
-
BADGE_TIP, answerWords, bannerModel, stepFacts, consentView, consentStatus, consentDialog, confirmBeforeApprove, confirmBeforeRun,
|
|
925
|
-
aiPillHtml, runRecordView, refreshRunRecord, paintRunRecord, gateView, checkGates, noteTrace, routineAiParts,
|
|
1738
|
+
BADGE_TIP, answerWords, bannerModel, stepFacts, consentView, consentStatus, consentDialog, confirmBeforeApprove, confirmBeforeRun, takeRenameAsk,
|
|
1739
|
+
aiPillHtml, runRecordView, refreshRunRecord, kbInspectHtml, runKbView, paintRunRecord, gateView, checkGates, noteTrace, routineAiParts,
|
|
1740
|
+
useParts, standingSentence, usePillHtml, usesView, openStepConversation, stoppedReportView, openQuestions,
|
|
1741
|
+
noteView, noteHtml, noteOffLine, refreshNote, setNote, initGlobalNote,
|
|
1742
|
+
triggerSentenceFor, triggerInspectHtml, watcherCardParts, refreshTrigger, saveWait, watcherChanged,
|
|
926
1743
|
configure(context) { Object.assign(model.context, context); },
|
|
927
1744
|
forgetChecks(appId) {
|
|
928
1745
|
const ids = appId === undefined ? [...model.checks.keys(), ...model.generation.keys()] : [appId];
|