@floless/app 0.169.0 → 0.170.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 +71580 -59849
- package/dist/schemas/drawing-check.profile.v1.schema.json +12 -2
- package/dist/schemas/steel.model.v2.schema.json +2 -1
- package/dist/skills/floless-app-knowledge/SKILL.md +43 -13
- package/dist/skills/floless-app-new-workflow/SKILL.md +8 -1
- package/dist/skills/floless-app-routines/SKILL.md +2 -2
- package/dist/skills/floless-app-routines/references/routines-api.md +20 -8
- package/dist/skills/floless-app-steel-model/SKILL.md +8 -5
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +31 -1
- package/dist/skills/floless-app-workflows/SKILL.md +22 -3
- package/dist/skills/floless-app-workflows/references/agent-steps.md +40 -6
- package/dist/skills/floless-app-workflows/references/exec-contract.md +27 -0
- package/dist/skills/floless-app-workflows/references/script-runner.md +105 -0
- package/dist/web/agent-steps.js +89 -18
- package/dist/web/agents.js +32 -22
- package/dist/web/app.css +223 -1
- package/dist/web/app.js +24 -3
- package/dist/web/aware.js +877 -189
- package/dist/web/chat.js +184 -95
- package/dist/web/checkpoint-standard.js +5 -3
- package/dist/web/commands-drawing-check.js +1 -0
- package/dist/web/commands-shell.js +440 -11
- package/dist/web/commands-steel.js +60 -1
- package/dist/web/drawing-check-editor.js +352 -88
- package/dist/web/failure-copy.js +32 -2
- package/dist/web/filter-ai-proposal.js +11 -8
- package/dist/web/flo-3d.js +1 -1
- package/dist/web/guide.js +33 -26
- package/dist/web/index.html +69 -1
- package/dist/web/instructor.js +99 -15
- package/dist/web/left-pane.js +4 -1
- package/dist/web/local-discovery.js +8 -7
- package/dist/web/missed-routines.js +239 -0
- package/dist/web/model-measure.js +6 -0
- package/dist/web/model-spatial-panel.js +19 -4
- package/dist/web/model-spatial-tools.js +3 -3
- package/dist/web/model-viewport-revit-adapter.js +3 -3
- package/dist/web/origin-rule.js +155 -0
- package/dist/web/project-access.js +1 -1
- package/dist/web/project-modules.js +2 -2
- package/dist/web/project-rfis.js +6 -1
- package/dist/web/project-workflows.js +2 -2
- package/dist/web/revit-editor.js +22 -8
- package/dist/web/run-history.js +12 -1
- package/dist/web/steel-3d-core.js +39 -9
- package/dist/web/steel-3d-flo.js +26 -4
- package/dist/web/steel-3d-view.js +8 -3
- package/dist/web/steel-ai-marks.js +3 -1
- package/dist/web/steel-editor.html +455 -122
- package/dist/web/steel-environments.js +297 -0
- package/dist/web/steel-filter.html +3 -2
- package/dist/web/steel-model-v2-client-validation.js +8 -1
- package/dist/web/steel-model-v2-commands.js +23 -9
- package/dist/web/steel-model-v2-projection.js +1 -1
- package/dist/web/step-rename.js +3 -2
- package/dist/web/terminal-requests.js +1 -1
- package/dist/web/tool-updates.js +7 -6
- package/dist/web/workspaces.js +1714 -119
- package/package.json +4 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# The host-neutral runner: `script/run` (JavaScript, no host)
|
|
2
|
+
|
|
3
|
+
Use `agent: script, command: run` for every step that touches **no host model**: comparing two data files,
|
|
4
|
+
filtering or totalling rows, shaping a schedule, building the report HTML. Use a host's own `exec`
|
|
5
|
+
(`tekla/exec`, `blender/exec`, …) only in the step that really reads or changes that host's model. A step
|
|
6
|
+
that only builds HTML on a host bridge ties the whole workflow to that host for nothing: the workflow then
|
|
7
|
+
needs the host installed and open, its card names the host, and it cannot run beside a live watcher on it.
|
|
8
|
+
|
|
9
|
+
`script` is built into AWARE (no bridge, no install of a host tool). It needs AWARE 0.175.0 or newer.
|
|
10
|
+
**Run `aware --version` before you choose a runner.** On an older AWARE there is no `script` runner and a
|
|
11
|
+
workflow that uses it is refused. There, a workflow that already uses a host keeps those steps on that host's
|
|
12
|
+
`exec` as before; a workflow with no host uses AWARE's other built-ins where they fit (`file`, `html-report`), and
|
|
13
|
+
if a step can only be written as `script/run`, tell the person it needs AWARE 0.175.0 or newer. FloLess's card and
|
|
14
|
+
canvas then tell the person that a newer AWARE is needed if they open a `script` workflow there.
|
|
15
|
+
|
|
16
|
+
## The node
|
|
17
|
+
|
|
18
|
+
```yaml
|
|
19
|
+
requires:
|
|
20
|
+
- script@0.1.x
|
|
21
|
+
nodes:
|
|
22
|
+
- id: compare
|
|
23
|
+
agent: script
|
|
24
|
+
command: run
|
|
25
|
+
config:
|
|
26
|
+
language: javascript
|
|
27
|
+
files:
|
|
28
|
+
design: "C:/Projects/ADNOC/exports/design.json" # literal, absolute
|
|
29
|
+
contract: "C:/Projects/ADNOC/exports/contract.json"
|
|
30
|
+
args:
|
|
31
|
+
phase: "{{ inputs.phase }}"
|
|
32
|
+
tolerance: 0.5
|
|
33
|
+
code: |
|
|
34
|
+
// Compares the design export with the contract quantities and lists every member
|
|
35
|
+
// whose weight differs by more than the tolerance.
|
|
36
|
+
const design = files.design.json;
|
|
37
|
+
const contract = files.contract.json;
|
|
38
|
+
const rows = design.members.filter((m) => m.phase === args.phase);
|
|
39
|
+
return { ok: true, count: rows.length, rows };
|
|
40
|
+
- id: report
|
|
41
|
+
agent: script
|
|
42
|
+
command: run
|
|
43
|
+
config:
|
|
44
|
+
language: javascript
|
|
45
|
+
args: { rows: "{{ compare.result.rows }}", at: "{{ compare.result.count }}" }
|
|
46
|
+
code: |
|
|
47
|
+
// Builds the HTML report from the compared rows.
|
|
48
|
+
const esc = (s) => String(s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' })[c]);
|
|
49
|
+
const body = args.rows.map((r) => `<tr><td>${esc(r.mark)}</td><td>${esc(r.weight)}</td></tr>`).join('');
|
|
50
|
+
return { ok: true, html: `<!doctype html><style>:root{color-scheme:light}html,body{background:#fff;color:#111}</style><table>${body}</table>` };
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- **`code`** is the body of a function; its `return` value is the node's `result`, so a later step reads
|
|
54
|
+
`compare.result.rows` (templated as in every other node). A `result.html` is the report, exactly as from
|
|
55
|
+
`exec`. Open it with a one or two sentence `//` comment: that comment is the node's Description.
|
|
56
|
+
- **`code` is literal.** No `{{ … }}` anywhere in it, not even in a comment: data goes in through `args`.
|
|
57
|
+
- **`args`** is data only, templatable, handed over as a frozen copy.
|
|
58
|
+
- **`files`** maps a name to a **literal absolute path**. Templates, `inputs.*` and relative paths are
|
|
59
|
+
refused at validate, compile and run, so the approved lock pins exactly what is read and the person sees
|
|
60
|
+
it at approval. AWARE reads each file once, read-only, before the script starts: `files.<name>.text`, and
|
|
61
|
+
`files.<name>.json` (parsed on first use). At most 16 files and 128 MB in all by default
|
|
62
|
+
(`max-input-mb`, up to 512). The trace keeps a receipt per file (path, size, sha256), never its contents.
|
|
63
|
+
A path the person picks at Run is not supported yet: bake the path, or ask the person for it while
|
|
64
|
+
authoring.
|
|
65
|
+
- **Limits:** `timeout-seconds` (default 60, at most 600), `memory-mb` (default 1024, at most 4096).
|
|
66
|
+
|
|
67
|
+
## What the script can and cannot do
|
|
68
|
+
|
|
69
|
+
- Globals: `args`, `files`, `run.startedAt` (ISO 8601, UTC) and `run.startedAtMs`, and `console.log`
|
|
70
|
+
(into the trace, capped). Nothing else: no `require`/`import`, no `fetch`, no timers, no file system.
|
|
71
|
+
- **No clock, no randomness, no locale.** There is no `Date` global; use `run.startedAt` for "today".
|
|
72
|
+
`Math.random`, `toLocaleString`, `localeCompare` and `Intl` throw or are absent: format numbers with
|
|
73
|
+
`toFixed` and sort with `<`/`>`. That is what makes the output a function of the code, `args`, the file
|
|
74
|
+
bytes and the run start, for a given AWARE CLI version (the trace records the CLI and engine versions).
|
|
75
|
+
- **No `eval`, no `Function`.** Data handed in can never be run as code, an AI answer included.
|
|
76
|
+
- **The result must be plain JSON:** objects, arrays, strings, finite numbers, booleans, `null`.
|
|
77
|
+
`undefined`, `NaN`, a `Date`, a `Map`, a function or a cycle is an error naming what it found. `toJSON` is
|
|
78
|
+
not called.
|
|
79
|
+
- It **writes nothing.** Write files with a `file/write` step after it, behind `safety:` as usual.
|
|
80
|
+
|
|
81
|
+
## Failure fails the step
|
|
82
|
+
|
|
83
|
+
A throw, a timeout, the memory limit, an unreadable file or an invalid result **fails the node** with a
|
|
84
|
+
plain-English error, and the steps after it do not run. This differs from `tekla/exec`, which returns
|
|
85
|
+
`ok: false` as data: a report or a write must never run on a broken comparison.
|
|
86
|
+
|
|
87
|
+
## With an Agent step
|
|
88
|
+
|
|
89
|
+
A `script` step that uses an Agent step's answer (through `args`) is marked as using it, like any other
|
|
90
|
+
step, and so is every step after it that uses its result. Its `report_folder` is never read into the
|
|
91
|
+
Page, and a `file/write` after it is named in the approval warning: put a `floless-agent-step/confirm` step
|
|
92
|
+
before the write so the person holds it (`agent-steps.md`). Never take a file path from an answer.
|
|
93
|
+
|
|
94
|
+
## Where the step shows
|
|
95
|
+
|
|
96
|
+
The Code tab shows a `script` step's source coloured as JavaScript. Debug in VS is offered only for a
|
|
97
|
+
`tekla/exec` step. The Workflows card names what the workflow needs, not its runner: a workflow whose
|
|
98
|
+
steps are all `script` names no host. To say what it works on, add up to three short phrases:
|
|
99
|
+
|
|
100
|
+
```yaml
|
|
101
|
+
floless:
|
|
102
|
+
needs: [Steel model, HTML report]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
They describe; they never hide what FloLess finds itself (a host step, a Workspace project, an AI step).
|
package/dist/web/agent-steps.js
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
generation: new Map(), // appId -> the newest check ask, so an older answer cannot overwrite a newer one
|
|
28
28
|
notes: new Map(), // #2448: appId -> { enabled, global, shown, off }, the AI note in that workflow's reports
|
|
29
29
|
noteSync: new Map(), // #2461: appId -> how its AI-note reads and saves are kept in order (see noteSyncOf)
|
|
30
|
+
carried: new Map(), // #3284: appId -> the write warning of a version resting on a tick given on another version, or null
|
|
30
31
|
triggers: new Map(), // S8 (#2495): appId -> the watcher's waits ({ steps, version, ... }), or null when it waits for no trigger
|
|
31
32
|
fires: new Map(), // S8: appId -> the watcher's latest events that reached an AI step (newest first)
|
|
32
33
|
firesState: new Map(), // S8: appId -> null, 'unreadable' (the log could not be read) or 'stale' (the last refresh failed)
|
|
@@ -291,6 +292,8 @@
|
|
|
291
292
|
const sentence = plainDescription(node);
|
|
292
293
|
html += `<p>${esc(sentence || `This step asks the Agent “${facts.name}” a question and uses its answer.`)}</p>`;
|
|
293
294
|
html += `<p class="as-standing">${esc(standingSentence(app, node))}</p>`;
|
|
295
|
+
const carried = model.carried.get(app.id);
|
|
296
|
+
if (carried) html += `<p class="as-carried" data-as-carried>This step is unchanged since the confirmation that its answer may differ each run, so it is not asked again. ${esc(carried)}</p>`;
|
|
294
297
|
if (app.runState && app.runState !== 'ready') {
|
|
295
298
|
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>';
|
|
296
299
|
}
|
|
@@ -355,6 +358,27 @@
|
|
|
355
358
|
};
|
|
356
359
|
}
|
|
357
360
|
|
|
361
|
+
/**
|
|
362
|
+
* #3284: the heads-up a publish made from chat would otherwise hide. The line says a confirmation still holds, so a status
|
|
363
|
+
* that cannot be read removes it rather than leaving the last answer standing, and an answer a newer check replaced is dropped.
|
|
364
|
+
*/
|
|
365
|
+
async function refreshCarried(appId, current = () => true) {
|
|
366
|
+
let status = null;
|
|
367
|
+
try {
|
|
368
|
+
// Like every read of the open workflow, it waits until FloLess has finished starting.
|
|
369
|
+
await globalThis.flolessStartupAdmission?.admit(`${CONSENT_API}/status?app=${encodeURIComponent(appId)}`);
|
|
370
|
+
if (current()) status = await consentStatus(appId);
|
|
371
|
+
} catch { status = null; }
|
|
372
|
+
if (!current()) return;
|
|
373
|
+
const carried = status?.carriedWarning || null;
|
|
374
|
+
if ((model.carried.get(appId) || null) === carried) return;
|
|
375
|
+
model.carried.set(appId, carried);
|
|
376
|
+
if (model.context.currentApp()?.id !== appId) return;
|
|
377
|
+
// A wait editor the person has open is never closed under them: the repaint waits until it closes, as refreshTrigger does.
|
|
378
|
+
if (document.querySelector('[data-as-wait-edit]:not([hidden])')) { model.repaintAfterEdit = appId; return; }
|
|
379
|
+
model.context.repaint(appId);
|
|
380
|
+
}
|
|
381
|
+
|
|
358
382
|
/** S8: read a watcher's waits and its latest events, for Inspect. Never claims anything when a read fails. */
|
|
359
383
|
async function refreshTrigger(appId, opts = {}) {
|
|
360
384
|
try {
|
|
@@ -434,9 +458,10 @@
|
|
|
434
458
|
// The status probe is awaited HERE, in the detached check, never in loadApp: opening a workflow must not wait on it.
|
|
435
459
|
const on = await probe();
|
|
436
460
|
if (!current()) return;
|
|
437
|
-
if (!on || !Array.isArray(app.nodes) || !app.nodes.some(isStepNode)) { model.checks.delete(app.id); return; }
|
|
461
|
+
if (!on || !Array.isArray(app.nodes) || !app.nodes.some(isStepNode)) { model.checks.delete(app.id); model.carried.delete(app.id); return; }
|
|
438
462
|
void refreshNote(app.id);
|
|
439
463
|
void refreshTrigger(app.id);
|
|
464
|
+
void refreshCarried(app.id, current);
|
|
440
465
|
let steps = null;
|
|
441
466
|
try {
|
|
442
467
|
const path = `/api/agent-steps/check?app=${encodeURIComponent(app.id)}`;
|
|
@@ -477,11 +502,15 @@
|
|
|
477
502
|
for (const [key, value] of Object.entries(extra)) if (value) query.set(key, value);
|
|
478
503
|
let response;
|
|
479
504
|
try { response = await fetch(`/api/agent-steps/block?${query}`, { credentials: 'same-origin' }); }
|
|
480
|
-
catch { throw new Error('FloLess could not be reached to load the Agent’s step. Make sure it is still running, then try again.'); }
|
|
505
|
+
catch { throw Object.assign(new Error('FloLess could not be reached to load the Agent’s step. Make sure it is still running, then try again.'), { forPerson: true }); }
|
|
481
506
|
let body = null;
|
|
482
507
|
try { body = await response.json(); } catch { body = null; }
|
|
483
508
|
if (!response.ok || !body || body.ok !== true) {
|
|
484
|
-
|
|
509
|
+
// #3097 3b: the reply rides on the error, so errorText says the server's sentence, or the access, busy or
|
|
510
|
+
// connection sentence for it; an answer that was not FloLess's JSON is marked unreadable.
|
|
511
|
+
const reply = body && typeof body === 'object' ? body : { code: 'response-unreadable' };
|
|
512
|
+
throw Object.assign(new Error(personText(reply) || 'the Agent step block was refused'),
|
|
513
|
+
{ code: typeof reply.code === 'string' ? reply.code : '', status: response.status, body: reply });
|
|
485
514
|
}
|
|
486
515
|
return body;
|
|
487
516
|
}
|
|
@@ -520,7 +549,7 @@
|
|
|
520
549
|
}
|
|
521
550
|
|
|
522
551
|
async function openDraft(text) {
|
|
523
|
-
if (typeof window.flolessChat?.openDraft !== 'function') throw new Error('AI Chat is still starting. Try again in a moment.');
|
|
552
|
+
if (typeof window.flolessChat?.openDraft !== 'function') throw Object.assign(new Error('AI Chat is still starting. Try again in a moment.'), { forPerson: true });
|
|
524
553
|
await window.flolessChat.openDraft(text);
|
|
525
554
|
}
|
|
526
555
|
|
|
@@ -536,7 +565,7 @@
|
|
|
536
565
|
model.context.toast('Drafted in AI Chat. Review it and send it there.', 'ok');
|
|
537
566
|
return true;
|
|
538
567
|
} catch (error) {
|
|
539
|
-
const message = error
|
|
568
|
+
const message = errorText(error, { action: 'draft that', retrySafe: true });
|
|
540
569
|
// Nothing valid to pin (no instructions, nothing to read, instructions beyond what a step can carry): the person is not left at a
|
|
541
570
|
// dead end. The reason goes to AI Chat as a drafted question, to be sent or not, and the Agent is never changed from here.
|
|
542
571
|
if (error && ['cannot-pin', 'agent-no-instructions', 'agent-no-scope'].includes(error.code)) {
|
|
@@ -585,7 +614,7 @@ ${WARN_LINE}`);
|
|
|
585
614
|
model.context.toast('Drafted in AI Chat. Review it and send it there.', 'ok');
|
|
586
615
|
return true;
|
|
587
616
|
} catch (error) {
|
|
588
|
-
model.context.toast(error
|
|
617
|
+
model.context.toast(errorText(error, { action: 'draft that', retrySafe: true }), 'warn');
|
|
589
618
|
return false;
|
|
590
619
|
}
|
|
591
620
|
}
|
|
@@ -625,11 +654,11 @@ ${WARN_LINE}`);
|
|
|
625
654
|
async function loadAgents() {
|
|
626
655
|
await globalThis.flolessStartupAdmission?.admit('/api/chat/session');
|
|
627
656
|
const session = await fetch('/api/chat/session', { credentials: 'same-origin' });
|
|
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.');
|
|
657
|
+
if (!session.ok) throw Object.assign(new Error('FloLess could not open AI Chat’s session, so the Agents could not load. Reload FloLess and try again.'), { forPerson: true });
|
|
629
658
|
await globalThis.flolessStartupAdmission?.admit('/api/chat/agents');
|
|
630
659
|
const response = await fetch('/api/chat/agents', { credentials: 'same-origin' });
|
|
631
660
|
const body = await response.json().catch(() => null);
|
|
632
|
-
if (!response.ok || !body || !Array.isArray(body.agents)) throw new Error('FloLess could not load your Agents just now. Try again.');
|
|
661
|
+
if (!response.ok || !body || !Array.isArray(body.agents)) throw Object.assign(new Error('FloLess could not load your Agents just now. Try again.'), { forPerson: true });
|
|
633
662
|
return body.agents.filter((agent) => !agent.archivedAt && agent.instructions && agent.scope && agent.scope.length);
|
|
634
663
|
}
|
|
635
664
|
|
|
@@ -658,7 +687,7 @@ ${WARN_LINE}`);
|
|
|
658
687
|
try { agents = await loadAgents(); }
|
|
659
688
|
catch (error) {
|
|
660
689
|
if (chooser?.root !== root) return;
|
|
661
|
-
list.innerHTML = `<div class="wf-empty-search" role="alert">${esc(error
|
|
690
|
+
list.innerHTML = `<div class="wf-empty-search" role="alert">${esc(errorText(error, { action: 'load your Agents', retrySafe: true }))}</div>`;
|
|
662
691
|
return;
|
|
663
692
|
}
|
|
664
693
|
if (chooser?.root !== root) return;
|
|
@@ -711,6 +740,8 @@ ${WARN_LINE}`);
|
|
|
711
740
|
|
|
712
741
|
const CONSENT_API = '/api/chat/agent-steps/consent';
|
|
713
742
|
const CONSENT_FIRST_SUB = 'The AI writes its answer each time the workflow runs, so that answer can differ from run to run. Everything else in the workflow stays exactly as approved.';
|
|
743
|
+
/** #3229: the fields the tick covers (agent-step-contract.ts ConsentStep). Which steps use the answer is the workflow, approved as a whole. */
|
|
744
|
+
const CONSENT_COVERS = 'Your tick covers the AI step itself: its Agent and instructions, what it can read, its answer format and time limit, and what the workflow gives it. Which steps use its answer is part of the workflow you approve, not of this tick.';
|
|
714
745
|
|
|
715
746
|
function whenWords(iso) {
|
|
716
747
|
const date = new Date(iso);
|
|
@@ -800,6 +831,8 @@ ${WARN_LINE}`);
|
|
|
800
831
|
body = steps.map((step) => stepCardHtml(step, '')).join('');
|
|
801
832
|
}
|
|
802
833
|
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>`;
|
|
834
|
+
// #3229: what the tick is about (the server's ConsentStep), so a person who sees it again knows the step itself is what it asks about.
|
|
835
|
+
body += `<p class="ac-unchanged ac-covers">${esc(CONSENT_COVERS)}</p>`;
|
|
803
836
|
const nameOf = (name) => (/^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(String(name)) ? 'You' : name);
|
|
804
837
|
const who = model.latest ? `${nameOf(model.latest.confirmedBy)}${whenWords(model.latest.confirmedAt) ? ` on ${whenWords(model.latest.confirmedAt)}` : ''}` : '';
|
|
805
838
|
// S8: a workflow that waits for a trigger adds each step's wait and the second tick.
|
|
@@ -1116,8 +1149,11 @@ ${WARN_LINE}`);
|
|
|
1116
1149
|
knowledge: runKbView(step.knowledge),
|
|
1117
1150
|
};
|
|
1118
1151
|
});
|
|
1119
|
-
|
|
1120
|
-
|
|
1152
|
+
// #3229: a run its AI step's check stopped ended "ok"; the panel says it stopped, and where.
|
|
1153
|
+
const stopped = stoppedRunView(rec);
|
|
1154
|
+
const summary = `Last run · ${plural(steps.length, 'AI step', 'AI steps')}${needs.length ? ` · ${plural(needs.length, 'question for you', 'questions for you')}` : ''}${stopped ? ` · ${stopped.summary}` : ''}`;
|
|
1155
|
+
return { summary, steps, needsCount: needs.length, groups: needsYouGroups(needs), open: needs.length > 0 || !!stopped, uses: usesView(rec),
|
|
1156
|
+
stoppedLine: stopped ? stopped.line : '', stoppedStep: stopped ? stopped.stepId : '' };
|
|
1121
1157
|
}
|
|
1122
1158
|
|
|
1123
1159
|
const KB_NONE_WORDS = {
|
|
@@ -1127,6 +1163,7 @@ ${WARN_LINE}`);
|
|
|
1127
1163
|
'no-search-words': () => 'The search had no words to look up.',
|
|
1128
1164
|
incomplete: () => 'FloLess couldn’t look through all of the Knowledge, and found no page it could use.',
|
|
1129
1165
|
'project-replaced': () => 'The project was replaced by another project with the same name, so no pages were given.',
|
|
1166
|
+
erased: () => 'The Knowledge was erased by the person before the Agent read it, so no pages were given.',
|
|
1130
1167
|
unreadable: () => 'FloLess couldn’t read the Knowledge.',
|
|
1131
1168
|
};
|
|
1132
1169
|
const SHORTENED_TIP = 'Only part of this page was given: the part that matched the search, cut to fit.';
|
|
@@ -1211,7 +1248,7 @@ ${WARN_LINE}`);
|
|
|
1211
1248
|
// Open when the run left something for the person; otherwise whatever the person last chose for this workflow.
|
|
1212
1249
|
const open = view.open || (box.dataset.for === app.id && box.open);
|
|
1213
1250
|
box.dataset.for = app.id;
|
|
1214
|
-
document.getElementById('as-run-sum').innerHTML = `${aiPillHtml()}<span class="as-run-sum-text">${esc(view.summary)}</span>`;
|
|
1251
|
+
document.getElementById('as-run-sum').innerHTML = `${aiPillHtml()}<span class="as-run-sum-text"${view.stoppedStep.length > 40 ? ` data-tip="${esc(`Stopped at “${view.stoppedStep}”`)}"` : ''}>${esc(view.summary)}</span>`;
|
|
1215
1252
|
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>`
|
|
1216
1253
|
+ `${step.who ? `<div class="as-run-who">${esc(step.who)}</div>` : ''}`
|
|
1217
1254
|
+ runKbHtml(step.nodeId, step.knowledge)
|
|
@@ -1221,7 +1258,8 @@ ${WARN_LINE}`);
|
|
|
1221
1258
|
? `<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>`
|
|
1222
1259
|
: '';
|
|
1223
1260
|
const note = noteOffLine(model.notes.get(app.id));
|
|
1224
|
-
|
|
1261
|
+
const stoppedHtml = view.stoppedLine ? `<p class="as-run-stopped" role="note">${esc(view.stoppedLine)}</p>` : '';
|
|
1262
|
+
document.getElementById('as-run-body').innerHTML = stoppedHtml + stepHtml + usesHtml(view.uses) + (note ? `<p class="as-use-note">${esc(note)}</p>` : '') + needsHtml;
|
|
1225
1263
|
box.hidden = false;
|
|
1226
1264
|
box.open = open;
|
|
1227
1265
|
}
|
|
@@ -1249,6 +1287,7 @@ ${WARN_LINE}`);
|
|
|
1249
1287
|
runId: body.runId, aiSteps: body.aiSteps, needsYou: Array.isArray(body.needsYou) ? body.needsYou : [],
|
|
1250
1288
|
...(Array.isArray(body.dependents) ? { dependents: body.dependents } : {}),
|
|
1251
1289
|
...(typeof body.dependentsUnknown === 'string' ? { dependentsUnknown: body.dependentsUnknown } : {}),
|
|
1290
|
+
...(isRecord(body.stoppedAt) ? { stoppedAt: body.stoppedAt } : {}),
|
|
1252
1291
|
});
|
|
1253
1292
|
}
|
|
1254
1293
|
else runs.delete(appId);
|
|
@@ -1303,6 +1342,33 @@ ${WARN_LINE}`);
|
|
|
1303
1342
|
};
|
|
1304
1343
|
}
|
|
1305
1344
|
|
|
1345
|
+
/** A step name for a sentence: at most 40 characters, so a long id never pushes the rest of the words out. */
|
|
1346
|
+
const shortName = (id) => (id.length > 40 ? `${id.slice(0, 39)}…` : id);
|
|
1347
|
+
|
|
1348
|
+
/**
|
|
1349
|
+
* #3229: what to say when the run stopped at an AI step's `-ok` check (`res.stoppedAt`, read by the server from the check's own
|
|
1350
|
+
* output). The run ended "ok", so without this it reads as complete. Pure: the run's answer in, plain words out; null when it did
|
|
1351
|
+
* not stop there. `button` opens the step's questions when the record left some for it, otherwise Last run itself.
|
|
1352
|
+
*/
|
|
1353
|
+
function stoppedRunView(res) {
|
|
1354
|
+
const at = isRecord(res) && isRecord(res.stoppedAt) ? res.stoppedAt : null;
|
|
1355
|
+
if (!at || typeof at.stepId !== 'string' || !at.stepId) return null;
|
|
1356
|
+
const step = `“${shortName(at.stepId)}”`;
|
|
1357
|
+
const needs = Array.isArray(res.needsYou) ? res.needsYou.filter(isRecord) : [];
|
|
1358
|
+
const asks = needs.some((item) => item.nodeId === at.stepId && item.kind === 'question');
|
|
1359
|
+
const listed = needs.some((item) => item.nodeId === at.stepId);
|
|
1360
|
+
const what = asks ? 'It has questions for you' : 'It gave no answer the workflow could use';
|
|
1361
|
+
return {
|
|
1362
|
+
stepId: at.stepId, asks, listed, runId: typeof res.runId === 'string' ? res.runId : null,
|
|
1363
|
+
toast: `Stopped at the AI step ${step}. ${what}, so the steps after it did not run. ${asks ? 'Open Last run to read them.' : 'Open Last run to see why.'}`,
|
|
1364
|
+
banner: `This report was made before the run stopped at the AI step ${step}, which ${asks ? 'has questions for you' : 'gave no answer the workflow could use'}. The steps after it did not run, so the report may be incomplete.`,
|
|
1365
|
+
summary: `stopped at ${step}`,
|
|
1366
|
+
line: `The run stopped at ${step} because ${asks ? 'it has questions for you' : 'it gave no answer the workflow could use'}. The steps after it did not run.`,
|
|
1367
|
+
button: listed ? 'Open Questions for you' : 'Open Last run',
|
|
1368
|
+
commandId: listed ? 'shell.report-ai-stop-questions' : 'shell.report-ai-stop-last-run',
|
|
1369
|
+
};
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1306
1372
|
/**
|
|
1307
1373
|
* #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
1374
|
* already holds this very run (`runId`), so it never shows an earlier run's questions. False when it cannot show this run, so the
|
|
@@ -1680,9 +1746,13 @@ ${WARN_LINE}`);
|
|
|
1680
1746
|
function routineAiParts(lastRun) {
|
|
1681
1747
|
if (!isRecord(lastRun) || lastRun.aiAnswer !== true) return null;
|
|
1682
1748
|
const q = Number.isSafeInteger(lastRun.questionsForYou) && lastRun.questionsForYou > 0 ? lastRun.questionsForYou : 0;
|
|
1749
|
+
// #3229: the run stopped at its AI step's check; one chip says so (an "AI answer" chip beside it would read as an answer it used).
|
|
1750
|
+
const stoppedAt = typeof lastRun.stoppedAtAiStep === 'string' && lastRun.stoppedAtAiStep ? lastRun.stoppedAtAiStep : '';
|
|
1683
1751
|
return {
|
|
1684
|
-
ai: 'AI answer',
|
|
1685
|
-
aiTip:
|
|
1752
|
+
ai: stoppedAt ? 'Stopped at AI step' : 'AI answer',
|
|
1753
|
+
aiTip: stoppedAt ? `The run stopped at the AI step “${shortName(stoppedAt)}”, so the steps after it did not run. Open the workflow to see why.`
|
|
1754
|
+
: 'This run used an AI step. Its answer can differ each run.',
|
|
1755
|
+
stoppedAt,
|
|
1686
1756
|
questions: q ? plural(q, 'question for you', 'questions for you') : '',
|
|
1687
1757
|
questionsTip: q ? 'The AI step left questions, assumptions or changes that were not made. Open the workflow to read them.' : '',
|
|
1688
1758
|
};
|
|
@@ -1737,13 +1807,14 @@ ${WARN_LINE}`);
|
|
|
1737
1807
|
probe, enabled, isStepNode, entryParts, refreshChecks, checkFor, stepCount, headerText, markTip, draftAdd, draftUpdate, paintCanvasControl,
|
|
1738
1808
|
BADGE_TIP, answerWords, bannerModel, stepFacts, consentView, consentStatus, consentDialog, confirmBeforeApprove, confirmBeforeRun, takeRenameAsk,
|
|
1739
1809
|
aiPillHtml, runRecordView, refreshRunRecord, kbInspectHtml, runKbView, paintRunRecord, gateView, checkGates, noteTrace, routineAiParts,
|
|
1740
|
-
useParts, standingSentence, usePillHtml, usesView, openStepConversation, stoppedReportView, openQuestions,
|
|
1810
|
+
useParts, standingSentence, usePillHtml, usesView, openStepConversation, stoppedReportView, stoppedRunView, openQuestions,
|
|
1741
1811
|
noteView, noteHtml, noteOffLine, refreshNote, setNote, initGlobalNote,
|
|
1742
1812
|
triggerSentenceFor, triggerInspectHtml, watcherCardParts, refreshTrigger, saveWait, watcherChanged,
|
|
1743
1813
|
configure(context) { Object.assign(model.context, context); },
|
|
1744
1814
|
forgetChecks(appId) {
|
|
1745
|
-
const ids = appId === undefined ? [...model.checks.keys(), ...model.generation.keys()] : [appId];
|
|
1746
|
-
|
|
1815
|
+
const ids = appId === undefined ? [...model.checks.keys(), ...model.generation.keys(), ...model.carried.keys()] : [appId];
|
|
1816
|
+
// #3284: the carried line claims a confirmation still holds, so it is as stale as a check until the new status lands.
|
|
1817
|
+
for (const id of ids) { model.checks.delete(id); model.carried.delete(id); model.generation.set(id, (model.generation.get(id) || 0) + 1); }
|
|
1747
1818
|
},
|
|
1748
1819
|
_model: model,
|
|
1749
1820
|
};
|
package/dist/web/agents.js
CHANGED
|
@@ -102,10 +102,10 @@
|
|
|
102
102
|
}
|
|
103
103
|
catch {
|
|
104
104
|
const failure = new Error('FloLess could not be reached. Make sure it is still running, then try again.');
|
|
105
|
-
failure.code = 'local-unreachable';
|
|
105
|
+
failure.code = 'local-unreachable'; failure.forPerson = true;
|
|
106
106
|
throw failure;
|
|
107
107
|
}
|
|
108
|
-
if (!response.ok) throw new Error('FloLess could not open AI Chat’s session, so agents could not load. Reload FloLess and try again.');
|
|
108
|
+
if (!response.ok) throw Object.assign(new Error('FloLess could not open AI Chat’s session, so agents could not load. Reload FloLess and try again.'), { forPerson: true });
|
|
109
109
|
state.sessionReady = true;
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
const failure = new Error(error?.name === 'TimeoutError'
|
|
122
122
|
? 'FloLess took too long to answer, most likely because it is busy. Try again in a moment.'
|
|
123
123
|
: 'FloLess could not be reached. Make sure it is still running, then try again.');
|
|
124
|
-
failure.code = 'local-unreachable';
|
|
124
|
+
failure.code = 'local-unreachable'; failure.forPerson = true;
|
|
125
125
|
throw failure;
|
|
126
126
|
}
|
|
127
127
|
let body = null;
|
|
@@ -136,8 +136,11 @@
|
|
|
136
136
|
if (!body?.error) console.warn(`[agents] ${path} answered ${response.status} with no explanation`);
|
|
137
137
|
// #2868: with no sentence from the server, the shared failure copy names the kind of failure (busy, signed out, an
|
|
138
138
|
// answer that was not FloLess's) instead of "try again, restart FloLess", which fixes none of them.
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
// #3097 3b: the reply rides on the error, so errorText works the sentence out again from it; an answer that was
|
|
140
|
+
// not FloLess's JSON is marked unreadable rather than shown.
|
|
141
|
+
const reply = body && typeof body === 'object' ? body : { code: 'response-unreadable' };
|
|
142
|
+
const failure = new Error(personText(reply) || failureCopy({ status: response.status, body: reply }).text);
|
|
143
|
+
failure.code = body?.code || null; failure.body = reply; failure.status = response.status;
|
|
141
144
|
throw failure;
|
|
142
145
|
}
|
|
143
146
|
return body;
|
|
@@ -209,7 +212,7 @@
|
|
|
209
212
|
const opened = await window.flolessChat?.openConversationIn?.(state.chatScope, target.chatId);
|
|
210
213
|
if (opened === false) toast('This run’s conversation could not be opened. Use Open in project to find it.', 'warn');
|
|
211
214
|
} catch (error) {
|
|
212
|
-
toast(error
|
|
215
|
+
toast(errorText(error, { action: 'open this run’s conversation', retrySafe: true }), 'warn');
|
|
213
216
|
}
|
|
214
217
|
// #2764: told afterwards, once AI Chat shows this run's conversation, so whatever is bound to the conversation before
|
|
215
218
|
// it (a compile refusal's Ask AI to fix) lets go. AI Chat itself already has this scope, so it does not reload.
|
|
@@ -339,7 +342,7 @@
|
|
|
339
342
|
state.agent = body.agent; state.draft = draftOf(body.agent); state.dirty = false; state.view = 'page';
|
|
340
343
|
} catch (error) {
|
|
341
344
|
if (generation !== state.pageGeneration) return; // a newer page was opened meanwhile: this answer is stale either way
|
|
342
|
-
toast(error
|
|
345
|
+
toast(errorText(error, { action: 'open this agent', retrySafe: true }), 'warn'); state.view = 'list'; await loadAgents(); return;
|
|
343
346
|
}
|
|
344
347
|
paint();
|
|
345
348
|
$surface.querySelector('#ag-name')?.focus();
|
|
@@ -394,13 +397,14 @@
|
|
|
394
397
|
if (created) void loadRuns();
|
|
395
398
|
return { ok: true, here: true, agent: body.agent };
|
|
396
399
|
} catch (error) {
|
|
397
|
-
|
|
400
|
+
const said = errorText(error, { action: 'save this agent', unsure: 'Check the agent before saving it again.' });
|
|
401
|
+
if (!here()) toast(`Couldn’t save “${draft.name.trim()}”. ${said}`, 'err');
|
|
398
402
|
else if (error.code === 'agent-revision-stale' && error.body?.agent) {
|
|
399
403
|
const current = error.body.agent;
|
|
400
|
-
state.banner = { text:
|
|
404
|
+
state.banner = { text: said, action: { label: 'Load the current version', commandId: 'shell.agents-reload', run: () => {
|
|
401
405
|
state.agent = current; state.draft = draftOf(current); state.dirty = false; state.banner = null; paint();
|
|
402
406
|
} } };
|
|
403
|
-
} else state.banner = { text:
|
|
407
|
+
} else state.banner = { text: said };
|
|
404
408
|
return { ok: false };
|
|
405
409
|
} finally { state.saving = false; paint(); }
|
|
406
410
|
}
|
|
@@ -447,8 +451,9 @@
|
|
|
447
451
|
toast(archived ? 'Agent archived.' : 'Agent restored.', 'ok');
|
|
448
452
|
} else toast(archived ? `Agent “${name}” archived.` : `Agent “${name}” restored.`, 'ok');
|
|
449
453
|
} catch (error) {
|
|
450
|
-
|
|
451
|
-
|
|
454
|
+
const said = errorText(error, { action: archived ? 'archive this agent' : 'restore this agent' });
|
|
455
|
+
if (stillHere()) state.banner = { text: said };
|
|
456
|
+
else toast(`Couldn’t ${archived ? 'archive' : 'restore'} “${name}”. ${said}`, 'err');
|
|
452
457
|
}
|
|
453
458
|
paint();
|
|
454
459
|
if (!stillHere()) void loadAgents();
|
|
@@ -468,7 +473,10 @@
|
|
|
468
473
|
const body = await api(`/api/chat/agents/${encodeURIComponent(agentId)}/pause`, { method: 'POST', body: { paused } });
|
|
469
474
|
if (stillHere()) { state.agent = { ...state.agent, pausedAt: body.agent.pausedAt }; state.banner = null; }
|
|
470
475
|
toast(paused ? 'Agent paused. Its routines won’t start it until you resume it.' : 'Agent resumed. Its routines run on their schedule again.', 'ok');
|
|
471
|
-
} catch (error) {
|
|
476
|
+
} catch (error) {
|
|
477
|
+
const said = errorText(error, { action: paused ? 'pause this agent' : 'resume this agent' });
|
|
478
|
+
if (stillHere()) state.banner = { text: said }; else toast(said, 'err');
|
|
479
|
+
}
|
|
472
480
|
state.pausing = false;
|
|
473
481
|
paint();
|
|
474
482
|
void loadAgents();
|
|
@@ -616,11 +624,12 @@
|
|
|
616
624
|
await loadRuns();
|
|
617
625
|
$surface.querySelector('#ag-runs-title')?.focus();
|
|
618
626
|
} catch (failure) {
|
|
619
|
-
|
|
627
|
+
const said = errorText(failure, { action: 'start this run', unsure: 'Check the runs below before starting it again.' });
|
|
628
|
+
if (failure.code === 'agent-run-preview-changed' && failure.body?.preview) { preview = failure.body.preview; error = said; }
|
|
620
629
|
// #2061: a run of this agent started meanwhile — ask, with the sheet's own "Start another run".
|
|
621
630
|
// The server's own sentence is kept: it says whether the run is going or FloLess can't tell.
|
|
622
|
-
else if (failure.code === 'agent-run-overlap') { preview = { ...preview, alreadyRunning: { ...(preview.alreadyRunning || { startedAt: null }), message:
|
|
623
|
-
else error =
|
|
631
|
+
else if (failure.code === 'agent-run-overlap') { preview = { ...preview, alreadyRunning: { ...(preview.alreadyRunning || { startedAt: null }), message: said } }; error = null; }
|
|
632
|
+
else error = said;
|
|
624
633
|
busy = false; render();
|
|
625
634
|
}
|
|
626
635
|
};
|
|
@@ -746,21 +755,21 @@
|
|
|
746
755
|
try {
|
|
747
756
|
await api(`/api/chat/agents/${encodeURIComponent(state.agent.agentId)}/runs/${encodeURIComponent(run.runId)}/targets/${target.index}/retry`,
|
|
748
757
|
{ method: 'POST', body: { confirmed: Boolean(target.retryNeedsConfirm) } });
|
|
749
|
-
} catch (error) { toast(error.
|
|
758
|
+
} catch (error) { toast(errorText(error, { action: 'start it again', unsure: 'Check its row below before starting it again.' }), 'warn'); }
|
|
750
759
|
await loadRuns();
|
|
751
760
|
}
|
|
752
761
|
|
|
753
762
|
async function cancelTarget(run, target) {
|
|
754
763
|
try {
|
|
755
764
|
await api(`/api/chat/agents/${encodeURIComponent(state.agent.agentId)}/runs/${encodeURIComponent(run.runId)}/targets/${target.index}/cancel`, { method: 'POST', body: {} });
|
|
756
|
-
} catch (error) { toast(error.
|
|
765
|
+
} catch (error) { toast(errorText(error, { action: 'cancel it', unsure: 'Check its row below before cancelling it again.' }), 'warn'); }
|
|
757
766
|
await loadRuns();
|
|
758
767
|
}
|
|
759
768
|
|
|
760
769
|
/** #2106: a project's Knowledge step. A missing Workspaces bridge is said, never a silent no-op. */
|
|
761
770
|
async function openKnowledgeStepOf(projectId) {
|
|
762
771
|
const open = window.flolessWorkspaces?.openKnowledgeStep;
|
|
763
|
-
if (typeof open !== 'function') throw new Error('FloLess couldn’t open that project’s Knowledge step. Open it from Workspaces.');
|
|
772
|
+
if (typeof open !== 'function') throw Object.assign(new Error('FloLess couldn’t open that project’s Knowledge step. Open it from Workspaces.'), { forPerson: true });
|
|
764
773
|
await open(projectId);
|
|
765
774
|
}
|
|
766
775
|
|
|
@@ -770,7 +779,7 @@
|
|
|
770
779
|
if (holder?.kind === 'knowledge') {
|
|
771
780
|
if (!(await confirmLeave())) return;
|
|
772
781
|
try { await openKnowledgeStepOf(holder.projectId); }
|
|
773
|
-
catch (error) { toast(error
|
|
782
|
+
catch (error) { toast(errorText(error, { action: 'open that project’s Knowledge step', retrySafe: true }), 'warn'); }
|
|
774
783
|
return;
|
|
775
784
|
}
|
|
776
785
|
if (holder?.kind === 'chat' && holder.owner && holder.chatId) { await openInProject({ owner: holder.owner, chatId: holder.chatId, label: holder.title }); return; }
|
|
@@ -788,7 +797,8 @@
|
|
|
788
797
|
}
|
|
789
798
|
toast(`Stopped ${holder?.kind === 'chat' ? `“${holder.title}”` : holder?.title || 'that work'}.`, 'ok');
|
|
790
799
|
} catch (error) {
|
|
791
|
-
toast(error?.code === 'stop-stale' ? 'That work had already finished, so nothing was stopped.'
|
|
800
|
+
toast(error?.code === 'stop-stale' ? 'That work had already finished, so nothing was stopped.'
|
|
801
|
+
: errorText(error, { action: 'stop that work', unsure: 'Check whether it is still running before stopping it again.' }), 'warn');
|
|
792
802
|
}
|
|
793
803
|
}
|
|
794
804
|
|
|
@@ -798,7 +808,7 @@
|
|
|
798
808
|
try {
|
|
799
809
|
await window.flolessWorkspaces.openChatOwner(target.owner);
|
|
800
810
|
await window.flolessChat?.openConversationIn?.({ owner: target.owner, label: target.label }, target.chatId);
|
|
801
|
-
} catch (error) { toast(error
|
|
811
|
+
} catch (error) { toast(errorText(error, { action: 'open that project', retrySafe: true }), 'warn'); }
|
|
802
812
|
}
|
|
803
813
|
|
|
804
814
|
// ── a small themed dialog (no native confirm: it would leak the OS theme) ──────────────────────────────────────
|