@floless/app 0.149.0 → 0.150.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.
Files changed (48) hide show
  1. package/dist/floless-server.cjs +102295 -88314
  2. package/dist/schemas/drawing-check.profile.v1.schema.json +45 -2
  3. package/dist/schemas/steel.model.v2.schema.json +9 -0
  4. package/dist/skills/floless-app-approval/SKILL.md +79 -4
  5. package/dist/skills/floless-app-onboarding/SKILL.md +4 -4
  6. package/dist/skills/floless-app-onboarding/references/aware-runtime.md +1 -1
  7. package/dist/skills/floless-app-onboarding/references/floless-app-tour.md +15 -13
  8. package/dist/skills/floless-app-routines/SKILL.md +4 -1
  9. package/dist/skills/floless-app-routines/references/routines-api.md +14 -2
  10. package/dist/skills/floless-app-steel-model/SKILL.md +4 -2
  11. package/dist/skills/floless-app-steel-takeoff/SKILL.md +14 -9
  12. package/dist/skills/floless-app-workflows/SKILL.md +2 -2
  13. package/dist/templates/tekla-parser.flo +13 -3
  14. package/dist/web/agents.js +887 -0
  15. package/dist/web/app.css +458 -23
  16. package/dist/web/app.js +20 -5
  17. package/dist/web/aware.js +1339 -134
  18. package/dist/web/chat.css +68 -4
  19. package/dist/web/chat.js +1770 -55
  20. package/dist/web/commands-drawing-check.js +15 -0
  21. package/dist/web/commands-revit.js +5 -0
  22. package/dist/web/commands-shell.js +785 -50
  23. package/dist/web/commands-tekla-parser.js +8 -1
  24. package/dist/web/connections.js +57 -14
  25. package/dist/web/drawing-check-editor.html +10 -2
  26. package/dist/web/drawing-check-editor.js +569 -40
  27. package/dist/web/drawing-check-overlay.js +45 -2
  28. package/dist/web/index.html +102 -27
  29. package/dist/web/instructor.js +85 -8
  30. package/dist/web/leave-guard.js +1 -0
  31. package/dist/web/left-pane.js +20 -1
  32. package/dist/web/local-discovery.js +12 -2
  33. package/dist/web/model-editor.css +32 -32
  34. package/dist/web/model-panel-bridge.js +11 -3
  35. package/dist/web/model-viewport-lighting.js +4 -2
  36. package/dist/web/model-viewport-revit-adapter.js +3 -0
  37. package/dist/web/model-viewport-toolbar.js +6 -3
  38. package/dist/web/model-viewport.js +11 -1
  39. package/dist/web/revit-editor.css +14 -14
  40. package/dist/web/revit-editor.js +64 -12
  41. package/dist/web/steel-3d-core.js +133 -0
  42. package/dist/web/steel-3d-view.js +10 -0
  43. package/dist/web/steel-editor.html +171 -39
  44. package/dist/web/steel-model-v2-client-validation.js +11 -0
  45. package/dist/web/steel-model-v2-commands.js +80 -5
  46. package/dist/web/tool-updates.js +367 -0
  47. package/dist/web/workspaces.js +679 -59
  48. package/package.json +1 -1
@@ -0,0 +1,367 @@
1
+ /* ──────────────────────────────────────────────────────────────────────────
2
+ Approve updated workflows (#1997) — the footer pill and its dialog.
3
+
4
+ The browser owns no decision here. The server (tool-updates-service.ts)
5
+ downloads new tool versions, asks AWARE which approved workflows they
6
+ affect, prepares each one, and words what changed. This file renders that
7
+ view and sends ONE thing back: the person's click, naming the batch it
8
+ showed. Every string shown is the server's, set with textContent.
9
+
10
+ States: a pill only when something is offered or needs the person; the
11
+ dialog lists "Ready to approve" cards, "Needs you" rows, the downloads
12
+ line and the consequence footnote; after the click, the results replace
13
+ the cards in a live region.
14
+ ────────────────────────────────────────────────────────────────────────── */
15
+ (function () {
16
+ 'use strict';
17
+
18
+ var $pill = document.getElementById('tool-updates');
19
+ var $modal = document.getElementById('tool-updates-modal');
20
+ if (!$pill || !$modal) return;
21
+ var $dialog = $modal.querySelector('.tool-updates-dialog');
22
+ var $title = document.getElementById('tool-updates-title');
23
+ var $body = document.getElementById('tool-updates-body');
24
+ var $live = document.getElementById('tool-updates-live');
25
+ var $foot = document.getElementById('tool-updates-foot');
26
+ var $check = document.getElementById('tool-updates-check');
27
+ var $cancel = document.getElementById('tool-updates-cancel');
28
+ var $approve = document.getElementById('tool-updates-approve');
29
+
30
+ var view = null;
31
+ var results = null;
32
+ var busy = false;
33
+ var returnFocus = null;
34
+
35
+ function el(tag, cls, text) {
36
+ var node = document.createElement(tag);
37
+ if (cls) node.className = cls;
38
+ if (text != null) node.textContent = text;
39
+ return node;
40
+ }
41
+
42
+ function plural(n, one, many) { return n + ' ' + (n === 1 ? one : many); }
43
+
44
+ async function call(path, method, payload) {
45
+ var res = await fetch(path, { method: method || 'GET', headers: { 'content-type': 'application/json' }, body: payload });
46
+ var body = await res.json().catch(function () { return { ok: false, error: 'FloLess received an unreadable answer (HTTP ' + res.status + ').' }; });
47
+ if (!res.ok && body.ok !== true && !body.results) {
48
+ var error = new Error(body.error || ('HTTP ' + res.status));
49
+ error.body = body;
50
+ throw error;
51
+ }
52
+ return body;
53
+ }
54
+
55
+ // ── The footer pill ────────────────────────────────────────────────────────
56
+ function paintPill() {
57
+ var offers = view && view.supported ? view.offers || [] : [];
58
+ var needs = view && view.supported ? view.needsYou || [] : [];
59
+ var urgent = offers.filter(function (o) { return !!o.advisory; }).length;
60
+ if (!offers.length && !needs.length) {
61
+ $pill.hidden = true;
62
+ $pill.removeAttribute('data-state');
63
+ if ($modal.classList.contains('show') && !results) paint();
64
+ return;
65
+ }
66
+ var text;
67
+ var state = 'offer';
68
+ if (offers.length) {
69
+ text = plural(offers.length, 'workflow update', 'workflow updates');
70
+ if (urgent) {
71
+ state = 'urgent';
72
+ // AWARE's notice says "urgent", never what kind: the pill does not call it a security fix.
73
+ text = urgent === offers.length && offers.length === 1 ? 'Urgent update · 1 workflow' : text + ' · ' + urgent + ' urgent';
74
+ } else if (view.nudge) {
75
+ state = 'nudge';
76
+ var days = Math.max.apply(null, offers.map(function (o) { return o.waitingDays || 0; }));
77
+ text += ' · waiting ' + plural(days, 'day', 'days');
78
+ }
79
+ } else {
80
+ state = 'needs';
81
+ text = plural(needs.length, 'workflow needs you', 'workflows need you');
82
+ }
83
+ $pill.textContent = text;
84
+ $pill.setAttribute('data-state', state);
85
+ $pill.hidden = false;
86
+ if ($modal.classList.contains('show') && !busy && !results) paint();
87
+ }
88
+
89
+ // ── The dialog ─────────────────────────────────────────────────────────────
90
+ function toolLine(change) {
91
+ var row = el('div', 'tool-updates-change');
92
+ var name = el('span', 'tool-updates-change-line', change.line);
93
+ row.appendChild(name);
94
+ return row;
95
+ }
96
+
97
+ function offerCard(offer) {
98
+ var card = el('div', 'tool-updates-card');
99
+ card.setAttribute('data-app', offer.app);
100
+ var head = el('div', 'tool-updates-card-head');
101
+ head.appendChild(el('span', 'tool-updates-card-name', offer.workflowName));
102
+ if (offer.waitingDays >= 1) head.appendChild(el('span', 'tool-updates-waiting', 'waiting ' + plural(offer.waitingDays, 'day', 'days')));
103
+ card.appendChild(head);
104
+ (offer.changes || []).forEach(function (change) { card.appendChild(toolLine(change)); });
105
+ if (offer.effect) {
106
+ var effect = el('div', 'tool-updates-effect', offer.effect);
107
+ effect.setAttribute('data-effect', /^Only reads/.test(offer.effect) ? 'read' : 'write');
108
+ card.appendChild(effect);
109
+ }
110
+ var details = [];
111
+ (offer.changes || []).forEach(function (change) { (change.details || []).forEach(function (d) { details.push(d); }); });
112
+ if (offer.comparison) details.push(offer.comparison);
113
+ if (details.length) {
114
+ var more = el('details', 'tool-updates-more');
115
+ more.appendChild(el('summary', null, 'What changed for this workflow'));
116
+ details.forEach(function (line) { more.appendChild(el('div', 'tool-updates-more-line', line)); });
117
+ card.appendChild(more);
118
+ }
119
+ return card;
120
+ }
121
+
122
+ function needsRow(item) {
123
+ var row = el('div', 'tool-updates-needs');
124
+ row.setAttribute('data-app', item.app);
125
+ row.setAttribute('data-kind', item.kind);
126
+ var text = el('div', 'tool-updates-needs-text');
127
+ text.appendChild(el('span', 'tool-updates-needs-name', item.workflowName));
128
+ text.appendChild(el('span', 'tool-updates-needs-sentence', item.sentence));
129
+ row.appendChild(text);
130
+ var bridge = window.flolessBridge;
131
+ // Offered only for a workflow the Workflows page lists — one installed from a terminal cannot be opened here.
132
+ if (item.action === 'open-workflow' && bridge && typeof bridge.openApp === 'function'
133
+ && typeof bridge.canOpenApp === 'function' && bridge.canOpenApp(item.app)) {
134
+ var openButton = el('button', 'tool-updates-open', 'Open workflow');
135
+ openButton.type = 'button';
136
+ openButton.setAttribute('data-command-id', 'shell.tool-updates-open-workflow');
137
+ openButton.setAttribute('data-tip', 'Open ' + item.workflowName + ' to do this');
138
+ openButton.addEventListener('click', function () {
139
+ close();
140
+ Promise.resolve(bridge.openApp(item.app)).catch(function (error) {
141
+ console.warn('could not open the workflow', error);
142
+ // Back to the dialog, with the reason in its live line (open() clears that line, so it is set after).
143
+ open($pill.hidden ? null : $pill);
144
+ $live.textContent = error.message;
145
+ });
146
+ });
147
+ row.appendChild(openButton);
148
+ }
149
+ return row;
150
+ }
151
+
152
+ function section(title, count) {
153
+ var wrap = el('div', 'tool-updates-section');
154
+ wrap.appendChild(el('div', 'tool-updates-section-head', title + ' (' + count + ')'));
155
+ return wrap;
156
+ }
157
+
158
+ function resultRow(result) {
159
+ var row = el('div', 'tool-updates-result');
160
+ row.setAttribute('data-outcome', result.outcome);
161
+ row.setAttribute('data-app', result.app);
162
+ row.appendChild(el('span', 'tool-updates-result-mark', result.outcome === 'moved' ? '✓' : '!')).setAttribute('aria-hidden', 'true');
163
+ var text = el('div', 'tool-updates-result-text');
164
+ text.appendChild(el('span', 'tool-updates-result-name', result.workflowName));
165
+ text.appendChild(el('span', 'tool-updates-result-sentence', result.sentence));
166
+ if (result.label) text.appendChild(el('span', 'tool-updates-result-label', result.label));
167
+ row.appendChild(text);
168
+ return row;
169
+ }
170
+
171
+ function lastChecked() {
172
+ if (!view || !view.checkedAt) return '';
173
+ var at = new Date(view.checkedAt);
174
+ if (isNaN(at.getTime())) return '';
175
+ return 'Last checked ' + at.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) + '.';
176
+ }
177
+
178
+ function downloadsLine() {
179
+ var d = view && view.downloads;
180
+ if (!d) return '';
181
+ if (d.error) return d.error;
182
+ if (d.waitingForRuns) return 'Waiting for ' + plural(d.waitingForRuns, 'run', 'runs') + ' to finish before downloading new tool versions (at most a day).';
183
+ // The same version downloaded again (after a manual downgrade, say) is named once.
184
+ var names = [];
185
+ (d.recent || []).forEach(function (r) {
186
+ var name = r.tool + ' ' + r.to;
187
+ if (names.indexOf(name) < 0) names.push(name);
188
+ });
189
+ names = names.slice(-3);
190
+ if (!names.length) return '';
191
+ return 'Downloaded in the background: ' + names.join(', ') + '.';
192
+ }
193
+
194
+ function paint() {
195
+ $body.textContent = '';
196
+ $foot.textContent = '';
197
+ var offers = (view && view.offers) || [];
198
+ var needs = (view && view.needsYou) || [];
199
+ if (view && !view.supported) {
200
+ $body.appendChild(el('div', 'tool-updates-summary', view.sentence || 'Tool updates are not available on this computer.'));
201
+ } else if (view && view.sentence) {
202
+ $body.appendChild(el('div', 'tool-updates-summary', view.sentence));
203
+ }
204
+ if (results) {
205
+ var done = section('Results', results.length);
206
+ done.querySelector('.tool-updates-section-head').id = 'tool-updates-results-head';
207
+ done.querySelector('.tool-updates-section-head').tabIndex = -1;
208
+ results.forEach(function (r) { done.appendChild(resultRow(r)); });
209
+ $body.appendChild(done);
210
+ } else {
211
+ var urgent = offers.filter(function (o) { return !!o.advisory; });
212
+ if (urgent.length) {
213
+ var banner = el('div', 'tool-updates-urgent');
214
+ banner.setAttribute('role', 'note');
215
+ banner.appendChild(el('div', 'tool-updates-urgent-head', 'AWARE marked ' + (urgent.length === 1 ? 'this update' : 'these updates') + ' urgent'));
216
+ urgent.forEach(function (o) { banner.appendChild(el('div', 'tool-updates-urgent-text', o.workflowName + ': ' + o.advisory)); });
217
+ banner.appendChild(el('div', 'tool-updates-urgent-note', 'Approving is still your decision.'));
218
+ $body.appendChild(banner);
219
+ }
220
+ if (offers.length) {
221
+ var ready = section('Ready to approve', offers.length);
222
+ offers.forEach(function (o) { ready.appendChild(offerCard(o)); });
223
+ $body.appendChild(ready);
224
+ }
225
+ }
226
+ if (needs.length) {
227
+ var needsSection = section('Needs you', needs.length);
228
+ needs.forEach(function (n) { needsSection.appendChild(needsRow(n)); });
229
+ $body.appendChild(needsSection);
230
+ }
231
+ if (!results && !offers.length && !needs.length && view && view.supported && !view.sentence) {
232
+ $body.appendChild(el('div', 'tool-updates-summary', view.checking
233
+ ? 'Checking which workflows a tool update affects…'
234
+ : 'All your workflows are on the tool versions you approved.'));
235
+ }
236
+ var dl = downloadsLine();
237
+ if (dl) $foot.appendChild(el('div', 'tool-updates-downloads', dl));
238
+ var checked = lastChecked();
239
+ if (checked) $foot.appendChild(el('div', 'tool-updates-downloads', checked));
240
+ if (!results && offers.length) {
241
+ $foot.appendChild(el('div', 'tool-updates-note', 'Approving moves these workflows to the new tool versions. Each workflow’s own steps stay exactly as you approved them. AWARE records this as your approval, made here in FloLess.'));
242
+ }
243
+ var canApprove = !results && offers.length > 0 && !!(view && view.batchId);
244
+ $approve.hidden = !canApprove;
245
+ if (canApprove) $approve.textContent = 'Approve ' + plural(offers.length, 'workflow', 'workflows');
246
+ $check.hidden = !!results || !(view && view.supported);
247
+ $cancel.textContent = results ? 'Done' : 'Not now';
248
+ }
249
+
250
+ function setBusy(on, label) {
251
+ busy = on;
252
+ $modal.setAttribute('aria-busy', on ? 'true' : 'false');
253
+ [$check, $cancel, $approve].forEach(function (b) { b.disabled = on; });
254
+ if (on && label) $approve.textContent = label;
255
+ }
256
+
257
+ async function refresh() {
258
+ try {
259
+ var body = await call('/api/tool-updates');
260
+ view = body;
261
+ } catch (error) {
262
+ // Keep the last answer on screen (and its pill): a dropped request is not "nothing to update".
263
+ console.warn('tool updates unavailable', error);
264
+ if ($modal.classList.contains('show') && !busy) $live.textContent = 'FloLess could not check for tool updates just now. What is shown is from the last check.';
265
+ }
266
+ paintPill();
267
+ }
268
+
269
+ function open(fromEl) {
270
+ returnFocus = fromEl || (document.activeElement instanceof HTMLElement ? document.activeElement : null);
271
+ results = null;
272
+ $live.textContent = '';
273
+ paint();
274
+ $modal.classList.add('show');
275
+ // Focus the title, not the primary: approving is consequential and Enter on open must not do it.
276
+ setTimeout(function () { $title.focus(); }, 0);
277
+ void refresh().then(function () { if ($modal.classList.contains('show') && !busy && !results) paint(); });
278
+ }
279
+
280
+ function close() {
281
+ if (busy) return;
282
+ $modal.classList.remove('show');
283
+ if (results) { results = null; }
284
+ if (returnFocus && document.contains(returnFocus)) returnFocus.focus();
285
+ returnFocus = null;
286
+ }
287
+
288
+ $pill.addEventListener('click', function () { open($pill); });
289
+ $cancel.addEventListener('click', close);
290
+ $modal.addEventListener('mousedown', function (e) { if (e.target === $modal) close(); });
291
+ $modal.addEventListener('keydown', function (e) {
292
+ if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); close(); return; }
293
+ if (e.key !== 'Tab') return;
294
+ var focusables = Array.prototype.filter.call(
295
+ $dialog.querySelectorAll('button, summary, [href], [tabindex]:not([tabindex="-1"])'),
296
+ function (n) { return !n.disabled && !n.hidden && n.offsetParent !== null; },
297
+ );
298
+ if (!focusables.length) return;
299
+ var first = focusables[0];
300
+ var last = focusables[focusables.length - 1];
301
+ if (e.shiftKey && (document.activeElement === first || document.activeElement === $title)) { e.preventDefault(); last.focus(); }
302
+ else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus(); }
303
+ });
304
+
305
+ $check.addEventListener('click', async function () {
306
+ setBusy(true);
307
+ $live.textContent = 'Checking for new tool versions…';
308
+ try {
309
+ view = await call('/api/tool-updates/check', 'POST');
310
+ var n = (view.offers || []).length;
311
+ $live.textContent = n ? plural(n, 'workflow is', 'workflows are') + ' ready to approve.' : 'No workflows to approve.';
312
+ } catch (error) {
313
+ $live.textContent = error.message;
314
+ } finally {
315
+ setBusy(false);
316
+ paint();
317
+ paintPill();
318
+ // The button was disabled while busy, which drops focus to the page: put it back where the person was.
319
+ if (!$check.hidden) $check.focus(); else $title.focus();
320
+ }
321
+ });
322
+
323
+ $approve.addEventListener('click', async function () {
324
+ if (!view || !view.batchId) return;
325
+ var apps = (view.offers || []).map(function (o) { return o.app; });
326
+ setBusy(true, 'Approving…');
327
+ $live.textContent = 'Approving ' + plural(apps.length, 'workflow', 'workflows') + '…';
328
+ try {
329
+ var body = await call('/api/tool-updates/approve', 'POST', JSON.stringify({ batchId: view.batchId, apps: apps }));
330
+ if (body.view) view = body.view;
331
+ if (body.ok) {
332
+ results = body.results || [];
333
+ var moved = results.filter(function (r) { return r.outcome === 'moved'; }).length;
334
+ $live.textContent = moved === results.length
335
+ ? plural(moved, 'workflow now runs', 'workflows now run') + ' on the new tool versions.'
336
+ : moved + ' of ' + results.length + ' moved. The others say why below.';
337
+ } else {
338
+ $live.textContent = body.sentence || body.error || 'Nothing was moved. Review it again.';
339
+ }
340
+ } catch (error) {
341
+ // The answer was lost on the way back: the server may have moved some workflows. Ask again rather than guess.
342
+ console.warn('approve answer not received', error);
343
+ await refresh();
344
+ $live.textContent = 'FloLess did not hear back after your approval, so it cannot say yet which workflows moved. The list below is what is still waiting.';
345
+ } finally {
346
+ setBusy(false);
347
+ paint();
348
+ paintPill();
349
+ var head = document.getElementById('tool-updates-results-head');
350
+ if (head) head.focus(); else $title.focus();
351
+ }
352
+ });
353
+
354
+ // The ≡ menu's "Tool updates…" — the way in when the pill has nothing to show (to check for new versions now).
355
+ if (typeof window.handleMenuAction === 'function') {
356
+ var previousMenuAction = window.handleMenuAction;
357
+ window.handleMenuAction = function (action) {
358
+ if (action === 'tool-updates') { open(document.getElementById('menu-btn')); return; }
359
+ previousMenuAction(action);
360
+ };
361
+ }
362
+
363
+ window.addEventListener('floless:tool-updates-changed', function () { void refresh(); });
364
+ window.addEventListener('floless:apps-changed', function () { void refresh(); });
365
+ window.flolessToolUpdates = { refresh: refresh, open: open };
366
+ void refresh();
367
+ })();