@floless/app 0.137.4 → 0.138.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 +47618 -26808
- package/dist/internal-workflows/floless-rfi-gmail-send/.floless-owner.json +1 -0
- package/dist/internal-workflows/floless-rfi-gmail-send/floless-rfi-gmail-send.flo +32 -0
- package/dist/schemas/steel.model.v2.schema.json +218 -27
- package/dist/skills/floless-app-knowledge/SKILL.md +5 -2
- package/dist/skills/floless-app-rfi/SKILL.md +410 -0
- package/dist/skills/floless-app-routines/SKILL.md +7 -2
- package/dist/skills/floless-app-routines/references/routines-api.md +14 -5
- package/dist/skills/floless-app-steel-model/SKILL.md +34 -32
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +498 -34
- package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +6 -6
- package/dist/skills/floless-app-tweak-contract/SKILL.md +6 -2
- package/dist/templates/floless-workspace-knowledge.flo +20 -4
- package/dist/templates/steel-model.flo +27 -15
- package/dist/web/app.css +559 -131
- package/dist/web/app.js +216 -54
- package/dist/web/aware.js +982 -128
- package/dist/web/checkpoint-standard.js +218 -0
- package/dist/web/commands-filter.js +23 -0
- package/dist/web/commands-shell.js +237 -5
- package/dist/web/commands-steel.js +172 -47
- package/dist/web/connection-review-client.js +2 -2
- package/dist/web/display-units.js +243 -0
- package/dist/web/grid-core.js +470 -56
- package/dist/web/grid-display.js +344 -0
- package/dist/web/index.html +106 -66
- package/dist/web/instructor-reporter.js +5 -0
- package/dist/web/instructor.js +175 -33
- package/dist/web/json-schema-subset.js +145 -25
- package/dist/web/steel-3d-core.js +124 -140
- package/dist/web/steel-3d-view.js +352 -100
- package/dist/web/steel-catalog-picker.js +98 -15
- package/dist/web/steel-detail-refs.js +1 -1
- package/dist/web/steel-editor.html +6458 -915
- package/dist/web/steel-filter.html +404 -57
- package/dist/web/steel-model-adapter.js +1 -1
- package/dist/web/steel-model-commands.js +71 -64
- package/dist/web/steel-model-v2-client-validation.js +10 -3
- package/dist/web/steel-model-v2-commands.js +268 -76
- package/dist/web/steel-model-v2-projection.js +18 -17
- package/dist/web/steel-plan-transform.js +13 -13
- package/dist/web/steel-plan-view-id.js +1 -7
- package/dist/web/steel-read-confidence.js +454 -5
- package/dist/web/steel-units.js +17 -3
- package/dist/web/steel-view-generation.js +21 -7
- package/dist/web/workspaces.js +2178 -497
- package/package.json +4 -1
package/dist/web/instructor.js
CHANGED
|
@@ -159,13 +159,42 @@
|
|
|
159
159
|
return 'Next: Run';
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
/* accessibleName() falls back to the control's own tip when it has no text of
|
|
163
|
+
its own, so on an icon-only control the chip and the tip are the SAME words.
|
|
164
|
+
Offering that tip as a fact would be the echo this band exists to avoid, so
|
|
165
|
+
it is compared against the label the way accessibleName derives it — the
|
|
166
|
+
whole first line, and the clause before the em dash it takes.
|
|
167
|
+
|
|
168
|
+
DELIBERATELY NARROWER than build/verify-no-echo.mjs, which fails an authored
|
|
169
|
+
`actsOn` whose every significant token already appears in the label. That is
|
|
170
|
+
the right bar for registry prose, where an author can rewrite the sentence
|
|
171
|
+
until it earns its place. A `data-tip` has no such author on hand and is the
|
|
172
|
+
ONLY description these controls have, so the token rule would silence some of
|
|
173
|
+
them back into the state #1035 reported. This one suppresses exactly the
|
|
174
|
+
duplicate accessibleName() itself manufactures, and nothing else. */
|
|
175
|
+
function restatesLabel(tip, label) {
|
|
176
|
+
if (!tip || !label) return false;
|
|
177
|
+
var norm = function (s) { return String(s).toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim(); };
|
|
178
|
+
var l = norm(label);
|
|
179
|
+
if (!l) return false;
|
|
180
|
+
return norm(tip) === l || norm(tip.split('—')[0]) === l;
|
|
181
|
+
}
|
|
182
|
+
|
|
162
183
|
/* A control's entry. Returns null-ish guidance when every fact it could show
|
|
163
184
|
is already visible on screen — the No-Echo rule, enforced here rather than
|
|
164
185
|
left to the caller. */
|
|
165
186
|
function controlGuidance(focus, wf) {
|
|
166
187
|
var facts = [];
|
|
167
188
|
|
|
168
|
-
|
|
189
|
+
/* WHAT IT DOES leads, and for most controls the authored tip is the only
|
|
190
|
+
answer there is. A registered command carries `actsOn`; a control whose
|
|
191
|
+
only authored help is its `data-tip` used to lose it entirely, because
|
|
192
|
+
WHERE it sits was counted as fact enough and the tip branch below was
|
|
193
|
+
then unreachable. Reported as #1035: `?` on `↵ Wrap` read "In the Inspect
|
|
194
|
+
panel · Available now" and never said that it wraps long lines. Location,
|
|
195
|
+
keyboard route and availability stay — as the secondary detail they are. */
|
|
196
|
+
var does = focus.acts || (restatesLabel(focus.tip, focus.label) ? '' : focus.tip);
|
|
197
|
+
if (does) facts.push(does);
|
|
169
198
|
if (focus.group) facts.push(focus.group);
|
|
170
199
|
if (focus.key) facts.push(focus.key);
|
|
171
200
|
|
|
@@ -240,7 +269,26 @@
|
|
|
240
269
|
|
|
241
270
|
function focusFor(el) {
|
|
242
271
|
if (!el || el === document.body) return null;
|
|
243
|
-
|
|
272
|
+
// A semantic divider is not a control. Only focusable separators (the panel
|
|
273
|
+
// resize handles) belong in Instructor's interaction stream.
|
|
274
|
+
var target = el.closest('button, summary, [role="button"], [role="treeitem"], [role="separator"][tabindex], a[href], input, select, textarea');
|
|
275
|
+
/* A switch paints `.rtn-toggle-track` over an input that is `opacity:0; width:0;
|
|
276
|
+
height:0`, so the pointer NEVER lands on the input — it lands on the track, or
|
|
277
|
+
on the <label> around it, and neither is in the list above. Hovering "Start on
|
|
278
|
+
startup" in the ≡ menu therefore resolved to NOTHING, and `?` fell back to the
|
|
279
|
+
focused element, which is the ≡ button that opened the menu: the band explained
|
|
280
|
+
the menu opener instead of the toggle under the cursor (#1035). A <label> is not
|
|
281
|
+
itself a control, but it names one — so resolve to the control it labels. */
|
|
282
|
+
if (!target) {
|
|
283
|
+
var labelled = el.closest('label');
|
|
284
|
+
var named = labelled && (labelled.control || labelled.querySelector('input, select, textarea'));
|
|
285
|
+
/* Only when the app has REGISTERED something to say about it. An ordinary form
|
|
286
|
+
label names an input with no tip and no accessible name of its own, and
|
|
287
|
+
accessibleName()'s last resort is the element id — so resolving those would
|
|
288
|
+
trade a silent `?` for one that reads `app-name-input` aloud. Silence is the
|
|
289
|
+
better of those two, and it is also what today already does. */
|
|
290
|
+
if (named && resolveCommand(named)) target = named;
|
|
291
|
+
}
|
|
244
292
|
if (!target) return null;
|
|
245
293
|
|
|
246
294
|
var tip = target.getAttribute('data-tip') || '';
|
|
@@ -347,7 +395,7 @@
|
|
|
347
395
|
if ($band) $band.hidden = !enabled;
|
|
348
396
|
|
|
349
397
|
var item = document.getElementById('menu-instructor-toggle');
|
|
350
|
-
if (item) item.
|
|
398
|
+
if (item) item.checked = enabled;
|
|
351
399
|
|
|
352
400
|
// Restoring must not need a reload: repaint from the state we kept while off.
|
|
353
401
|
if (enabled) paint();
|
|
@@ -370,12 +418,56 @@
|
|
|
370
418
|
|
|
371
419
|
var lastHovered = null;
|
|
372
420
|
var lastHoveredAt = 0;
|
|
421
|
+
var lastHoveredOrder = 0;
|
|
422
|
+
var lastFocused = null;
|
|
423
|
+
var lastFocusedOrder = 0;
|
|
424
|
+
var intentOrder = 0;
|
|
425
|
+
var intentDocuments = typeof WeakSet === 'function' ? new WeakSet() : [];
|
|
426
|
+
|
|
427
|
+
function remembersIntentDocument(doc) {
|
|
428
|
+
if (intentDocuments instanceof Array) return intentDocuments.indexOf(doc) !== -1;
|
|
429
|
+
return intentDocuments.has(doc);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function rememberIntentDocument(doc) {
|
|
433
|
+
if (intentDocuments instanceof Array) intentDocuments.push(doc);
|
|
434
|
+
else intentDocuments.add(doc);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
function recordHoverIntent(e) {
|
|
438
|
+
lastHovered = e && e.target;
|
|
439
|
+
lastHoveredAt = Date.now();
|
|
440
|
+
lastHoveredOrder = ++intentOrder;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
function recordFocusIntent(e) {
|
|
444
|
+
lastFocused = e && e.target;
|
|
445
|
+
lastFocusedOrder = ++intentOrder;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/* Iframe events do not bubble into the shell document. Watch the current
|
|
449
|
+
same-origin surface as well as the shell so target arbitration is based on
|
|
450
|
+
what the person actually did, not on whichever document owns Instructor.
|
|
451
|
+
Re-adopting a reporter is common, hence the per-document deduplication. */
|
|
452
|
+
function watchIntentDocument(doc) {
|
|
453
|
+
if (!doc || typeof doc.addEventListener !== 'function' || remembersIntentDocument(doc)) return;
|
|
454
|
+
rememberIntentDocument(doc);
|
|
455
|
+
doc.addEventListener('mouseover', recordHoverIntent, true);
|
|
456
|
+
doc.addEventListener('focusin', recordFocusIntent, true);
|
|
457
|
+
}
|
|
373
458
|
|
|
374
459
|
function isTyping(el) {
|
|
375
460
|
if (!el) return false;
|
|
376
461
|
if (el.isContentEditable) return true;
|
|
377
462
|
var tag = el.tagName;
|
|
378
|
-
|
|
463
|
+
if (tag === 'INPUT') {
|
|
464
|
+
// A switch is keyboard-operated, not a text-entry surface. Let `?` explain
|
|
465
|
+
// it just like a button while still yielding to literal typing in text fields.
|
|
466
|
+
var type = String(el.type || 'text').toLowerCase();
|
|
467
|
+
return type !== 'checkbox' && type !== 'radio' && type !== 'range'
|
|
468
|
+
&& type !== 'button' && type !== 'submit' && type !== 'reset';
|
|
469
|
+
}
|
|
470
|
+
return tag === 'TEXTAREA' || tag === 'SELECT';
|
|
379
471
|
}
|
|
380
472
|
|
|
381
473
|
/* Which target does the user mean — the focused control, or the one under the
|
|
@@ -391,6 +483,20 @@
|
|
|
391
483
|
mean; otherwise they are navigating by keyboard and focus wins. */
|
|
392
484
|
var HOVER_INTENT_MS = 3000;
|
|
393
485
|
|
|
486
|
+
function currentActiveElement() {
|
|
487
|
+
/* The shell's activeElement is only the iframe; the meaningful focus target
|
|
488
|
+
is inside its same-origin document. A torn-down or not-yet-ready child
|
|
489
|
+
simply falls back to the shell. */
|
|
490
|
+
if (activeReporterWindow && snapshot.child) {
|
|
491
|
+
try {
|
|
492
|
+
var childDoc = activeReporterWindow.document;
|
|
493
|
+
var childActive = childDoc && childDoc.activeElement;
|
|
494
|
+
if (childActive && childActive !== childDoc.body) return childActive;
|
|
495
|
+
} catch (e) { /* frame changed while the key was being handled */ }
|
|
496
|
+
}
|
|
497
|
+
return document.activeElement;
|
|
498
|
+
}
|
|
499
|
+
|
|
394
500
|
function explainCurrent() {
|
|
395
501
|
// The band is the only thing that renders an explanation, so with the
|
|
396
502
|
// Instructor off `?` and F1 must do nothing at all — and must not swallow
|
|
@@ -398,12 +504,23 @@
|
|
|
398
504
|
// whether the handler calls preventDefault).
|
|
399
505
|
if (!enabled) return false;
|
|
400
506
|
|
|
401
|
-
var active =
|
|
507
|
+
var active = currentActiveElement();
|
|
402
508
|
var hasActive = active && active !== document.body;
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
509
|
+
/* A control can disappear while the pointer remains parked at its old coordinates. The revision
|
|
510
|
+
result does exactly that: Apply is hidden, then focus moves to Close. Treating the hidden Apply
|
|
511
|
+
as fresh pointer intent makes `?` narrate an action that is no longer on screen. */
|
|
512
|
+
var hoveredIsRendered = lastHovered && lastHovered.isConnected
|
|
513
|
+
&& lastHovered.getClientRects && lastHovered.getClientRects().length;
|
|
514
|
+
var pointerIsFresh = hoveredIsRendered && (Date.now() - lastHoveredAt) < HOVER_INTENT_MS;
|
|
515
|
+
var focusedOrder = lastFocused === active ? lastFocusedOrder : 0;
|
|
516
|
+
|
|
517
|
+
var el = hasActive ? active : (pointerIsFresh ? lastHovered : null);
|
|
518
|
+
/* Most recent intentional target wins. This keeps pointer-over-another-control
|
|
519
|
+
useful, but a later Tab/Shift+Tab transition must beat the still-fresh hover
|
|
520
|
+
left by a prior click. Programmatic focus in the browser emits focusin too,
|
|
521
|
+
so replacements that restore focus participate in the same ordering. */
|
|
522
|
+
if (pointerIsFresh && lastHovered !== active && focusFor(lastHovered)
|
|
523
|
+
&& (!hasActive || !focusedOrder || lastHoveredOrder > focusedOrder)) {
|
|
407
524
|
el = lastHovered;
|
|
408
525
|
}
|
|
409
526
|
|
|
@@ -494,7 +611,7 @@
|
|
|
494
611
|
});
|
|
495
612
|
}
|
|
496
613
|
|
|
497
|
-
/* A command-sheet row for a
|
|
614
|
+
/* A command-sheet row for a rendered control must retain the exact instance it describes.
|
|
498
615
|
Otherwise two request rows sharing one template both navigate to whichever carrier happens to
|
|
499
616
|
appear first in the DOM. Read attributes instead of interpolating instance data into a selector:
|
|
500
617
|
request ids and member labels are data, and may legitimately contain selector punctuation. */
|
|
@@ -577,20 +694,23 @@
|
|
|
577
694
|
a static array cannot express that, because "active" is runtime state. */
|
|
578
695
|
var GROUP_ORDER = [
|
|
579
696
|
// the shell
|
|
580
|
-
'In the header', 'In the workflow picker', 'In the project picker',
|
|
697
|
+
'In the header', 'In the workflow picker', 'In the project picker', 'In the project list',
|
|
581
698
|
'In the project workspace', 'On the workflow canvas',
|
|
582
|
-
|
|
699
|
+
// The Informed by row sits at the top of the canvas column, so it is read right after the canvas.
|
|
700
|
+
'In the Informed by row',
|
|
701
|
+
'In the Narrative panel', 'At the edge of the Narrative or Inspect panel',
|
|
702
|
+
'In the AI answers tab', 'On a saved AI session', 'In the node Inspect panel', 'In the Instructor strip',
|
|
583
703
|
'In the ≡ menu', 'In the footer',
|
|
584
|
-
'In the contract editor', 'In the report viewer', 'In the guide',
|
|
585
|
-
'In the agent library', 'In the requests list', 'In the revision review', 'In the run request dialog', 'In the Routines dialog',
|
|
586
|
-
'In the Report an issue dialog', 'In the Build an agent dialog', 'In the Bake dialog',
|
|
704
|
+
'In the contract editor', 'In the report viewer', 'In the Knowledge Base viewer', 'In the guide',
|
|
705
|
+
'In the agent library', 'In the requests list', 'In the revision review', 'In the run request dialog', 'In the Integrations dialog', 'In the Routines dialog',
|
|
706
|
+
'In the Report an issue dialog', 'In the Build an agent dialog', 'In the Bake dialog', 'In the CAD send review',
|
|
587
707
|
'In the FloLess dialogs',
|
|
588
708
|
/* the steel editor — read top-left down, then the menus, then the dialogs.
|
|
589
709
|
The ⋯ menu is six groups rather than one because it is six accordion
|
|
590
710
|
sections on screen: a single 'In the ⋯ menu' would have been about thirty
|
|
591
711
|
rows under one heading, which is a scroll rather than a list. */
|
|
592
712
|
'In the steel editor header', 'On the steel canvas', 'On the drawing canvas', 'In the Copy panel', 'In the Copy array panel', 'On the 2D zoom bar',
|
|
593
|
-
'In the 3D toolbar', 'In the 3D side panel', 'On the snap bar',
|
|
713
|
+
'In the 3D toolbar', 'In the label menus', 'In the 3D side panel', 'On the snap bar',
|
|
594
714
|
'In the grid panel', 'In the Inspect panel',
|
|
595
715
|
'In the Properties popup', 'In the snap override menu', 'In the dimension value popup', 'In the selection filter',
|
|
596
716
|
'In the review list', // the connection-review popover — a sibling of the selection filter, and it hangs off the header stats above
|
|
@@ -814,7 +934,7 @@
|
|
|
814
934
|
focusFor() resolves upward through
|
|
815
935
|
`closest('button, [role="button"], [role="treeitem"], a[href], input, select, textarea')`, and
|
|
816
936
|
a registered command can carry its id on a <label> whose <input> is a
|
|
817
|
-
DESCENDANT
|
|
937
|
+
DESCENDANT. Several carriers still do:
|
|
818
938
|
shell.open-at-startup and shell.routine-enabled (index.html),
|
|
819
939
|
steel.show-labels and steel.work-plane-show (steel-editor.html),
|
|
820
940
|
vector.show-kind and vector.isolate-weak (vector-editor.html). For every one
|
|
@@ -826,7 +946,7 @@
|
|
|
826
946
|
surfaces, and moving them is not that slice's to do. Putting the id on the
|
|
827
947
|
input costs no accessible name — `accessibleNameOf` names a form control
|
|
828
948
|
from its wrapping label — and it is what makes Enter here actually go to the
|
|
829
|
-
control. The remaining
|
|
949
|
+
control. The remaining cases are a known, recorded gap, not a design.
|
|
830
950
|
|
|
831
951
|
Returning here on a null entry would have left the PREVIOUS entry standing,
|
|
832
952
|
since setFocusEntry declines rather than assigning — reintroducing exactly
|
|
@@ -1070,7 +1190,17 @@
|
|
|
1070
1190
|
|
|
1071
1191
|
var activeReporterWindow = null;
|
|
1072
1192
|
|
|
1193
|
+
// Loaded workspace siblings keep reporting after their tab is hidden. Neither
|
|
1194
|
+
// a late ready event nor a report may replace the frame the user is looking at.
|
|
1195
|
+
function hiddenReporter(childWin) {
|
|
1196
|
+
try {
|
|
1197
|
+
var frame = childWin && childWin.frameElement;
|
|
1198
|
+
return !!frame && (frame.hidden || !frame.getClientRects().length);
|
|
1199
|
+
} catch (e) { return true; }
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1073
1202
|
window.__instructorReady = function (childWin) {
|
|
1203
|
+
if (hiddenReporter(childWin)) return;
|
|
1074
1204
|
/* Drop the outgoing frame's snapshot in the SAME step as adopting the new
|
|
1075
1205
|
reporter, so `activeReporterWindow` and `snapshot.child` always describe the
|
|
1076
1206
|
same document. In practice the old frame's pagehide has already cleared it —
|
|
@@ -1081,9 +1211,11 @@
|
|
|
1081
1211
|
Nothing is lost: the new reporter's first report is one macrotask away. */
|
|
1082
1212
|
if (childWin !== activeReporterWindow) snapshot.child = null;
|
|
1083
1213
|
activeReporterWindow = childWin;
|
|
1214
|
+
try { watchIntentDocument(childWin && childWin.document); } catch (e) { /* frame changed mid-adoption */ }
|
|
1084
1215
|
};
|
|
1085
1216
|
|
|
1086
1217
|
window.__instructorReport = function (childSnap, childWin) {
|
|
1218
|
+
if (hiddenReporter(childWin)) return;
|
|
1087
1219
|
// A stale frame must never narrate. Ignore anything that is no longer the
|
|
1088
1220
|
// live reporter, or whose document has been torn down / replaced.
|
|
1089
1221
|
if (activeReporterWindow && childWin !== activeReporterWindow) return;
|
|
@@ -1112,8 +1244,9 @@
|
|
|
1112
1244
|
window.__instructorKey = function (key) {
|
|
1113
1245
|
if (!enabled) return false;
|
|
1114
1246
|
if (key !== '?' && key !== 'F1') return false;
|
|
1115
|
-
//
|
|
1116
|
-
//
|
|
1247
|
+
// An armed command already owns the band. Otherwise explain the control in
|
|
1248
|
+
// the live child before falling back to the complete command sheet.
|
|
1249
|
+
if (!(snapshot.child && snapshot.child.armed) && explainCurrent()) return true;
|
|
1117
1250
|
return openSheet();
|
|
1118
1251
|
};
|
|
1119
1252
|
|
|
@@ -1172,6 +1305,11 @@
|
|
|
1172
1305
|
setCollapsed(collapsed);
|
|
1173
1306
|
applyEnabled();
|
|
1174
1307
|
|
|
1308
|
+
var enabledToggle = document.getElementById('menu-instructor-toggle');
|
|
1309
|
+
if (enabledToggle) {
|
|
1310
|
+
enabledToggle.addEventListener('change', function () { setEnabled(enabledToggle.checked); });
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1175
1313
|
$toggle.addEventListener('click', function () { setCollapsed(!collapsed); });
|
|
1176
1314
|
|
|
1177
1315
|
function currentAskContext(subjectButton) {
|
|
@@ -1193,29 +1331,31 @@
|
|
|
1193
1331
|
var bridge = window.flolessBridge;
|
|
1194
1332
|
if (!bridge || typeof bridge.requestInstructorHelp !== 'function') return;
|
|
1195
1333
|
var context = currentAskContext(button);
|
|
1196
|
-
var
|
|
1334
|
+
var idleMarkup = button.innerHTML;
|
|
1197
1335
|
var askControls = [$ask, $askQueue, $askOptions].concat(Array.from($askMenu.querySelectorAll('button')));
|
|
1198
|
-
var
|
|
1336
|
+
var priorAriaDisabled = askControls.map(function (control) { return control.getAttribute('aria-disabled'); });
|
|
1199
1337
|
askBusy = true;
|
|
1200
|
-
askControls.forEach(function (control) { control.disabled
|
|
1338
|
+
askControls.forEach(function (control) { control.setAttribute('aria-disabled', 'true'); });
|
|
1201
1339
|
button.setAttribute('aria-busy', 'true');
|
|
1202
|
-
button.setAttribute('data-blocked-reason', '
|
|
1203
|
-
button.
|
|
1204
|
-
button.textContent = label;
|
|
1340
|
+
button.setAttribute('data-blocked-reason', 'Sending this question…');
|
|
1341
|
+
button.innerHTML = '<span class="rtn-spinner" aria-hidden="true"></span>' + label;
|
|
1205
1342
|
try {
|
|
1206
1343
|
await action(bridge, context);
|
|
1207
1344
|
} finally {
|
|
1208
|
-
askControls.forEach(function (control, index) {
|
|
1345
|
+
askControls.forEach(function (control, index) {
|
|
1346
|
+
if (priorAriaDisabled[index] == null) control.removeAttribute('aria-disabled');
|
|
1347
|
+
else control.setAttribute('aria-disabled', priorAriaDisabled[index]);
|
|
1348
|
+
});
|
|
1209
1349
|
askBusy = false;
|
|
1210
1350
|
button.removeAttribute('aria-busy');
|
|
1211
1351
|
button.removeAttribute('data-blocked-reason');
|
|
1212
|
-
button.
|
|
1352
|
+
button.innerHTML = idleMarkup;
|
|
1213
1353
|
try { button.focus(); } catch (e) { /* focus restoration is best-effort */ }
|
|
1214
1354
|
}
|
|
1215
1355
|
}
|
|
1216
1356
|
|
|
1217
1357
|
$ask.addEventListener('click', function () {
|
|
1218
|
-
return withAskBusy($ask, '
|
|
1358
|
+
return withAskBusy($ask, 'Sending…', function (bridge, context) {
|
|
1219
1359
|
return bridge.requestInstructorHelp(context, { mode: 'direct' });
|
|
1220
1360
|
});
|
|
1221
1361
|
});
|
|
@@ -1281,10 +1421,7 @@
|
|
|
1281
1421
|
}).catch(function () { directAskAvailable = false; paint(); });
|
|
1282
1422
|
}
|
|
1283
1423
|
|
|
1284
|
-
document
|
|
1285
|
-
var t = e.target instanceof Element ? e.target : null;
|
|
1286
|
-
if (t) { lastHovered = t; lastHoveredAt = Date.now(); }
|
|
1287
|
-
}, true);
|
|
1424
|
+
watchIntentDocument(document);
|
|
1288
1425
|
|
|
1289
1426
|
document.addEventListener('keydown', function (e) {
|
|
1290
1427
|
// `?` is the everyday route, but it MUST yield to typing — this is a
|
|
@@ -1322,6 +1459,11 @@
|
|
|
1322
1459
|
if (bridge && typeof bridge.getWorkspaceContext === 'function') {
|
|
1323
1460
|
Instructor.setWorkspace(bridge.getWorkspaceContext());
|
|
1324
1461
|
}
|
|
1462
|
+
// Workspaces may already have shown a loaded child before this seam existed.
|
|
1463
|
+
// Replay the shell's visible-tab handoff once, using that child's own snapshot.
|
|
1464
|
+
if (window.flolessWorkspaces && typeof window.flolessWorkspaces.syncWorkspaceReporter === 'function') {
|
|
1465
|
+
window.flolessWorkspaces.syncWorkspaceReporter();
|
|
1466
|
+
}
|
|
1325
1467
|
paint();
|
|
1326
1468
|
}
|
|
1327
1469
|
|
|
@@ -1,71 +1,191 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* THE dependency-free JSON Schema subset interpreter — one implementation, both callers.
|
|
3
|
+
*
|
|
4
|
+
* It interprets only the subset of JSON Schema 2020-12 that the files under `schemas/` actually use:
|
|
5
|
+
* `type` (incl. `["x","null"]`), `const`, `enum`, `required`, `properties`, `additionalProperties`
|
|
6
|
+
* (boolean | schema), `items`, numeric bounds, `minProperties`, `minLength`/`maxLength`, string
|
|
7
|
+
* `pattern`, `oneOf`, and local `$ref` (`#/$defs/Name`).
|
|
8
|
+
*
|
|
9
|
+
* IT LIVES HERE, in `web/`, because the server can import a browser module and the browser cannot
|
|
10
|
+
* import a `.ts` one — the same direction 106 other `server/*.ts → ../web/*.js` import lines, across
|
|
11
|
+
* 27 non-test modules, already take. `server/contract-schema.ts` keeps the typed surface (`SchemaNode`, `ValidationResult`,
|
|
12
|
+
* `loadContractSchema`, `validateContract`) and delegates the walk to this.
|
|
13
|
+
*
|
|
14
|
+
* IT IS ONE IMPLEMENTATION because it had been two, and they had already drifted apart in ways that
|
|
15
|
+
* MATTERED. The browser twin never learned `pattern` or `minProperties`, both of which
|
|
16
|
+
* `steel.model.v2.schema.json` uses and the server enforces:
|
|
17
|
+
*
|
|
18
|
+
* - `$defs.plan.properties.id` carries `pattern: "\\S"`, and that pattern is load-bearing: its own
|
|
19
|
+
* description records that `minLength` alone admitted `" "`, which the resolvers read as
|
|
20
|
+
* stating no identity and silently fell back to `sheet` — so a whitespace id collided with a
|
|
21
|
+
* sibling instead of being refused. The browser accepted exactly that id.
|
|
22
|
+
* - `$defs.referenceFilter` carries `minProperties: 1`, which is the only thing making `{}` — "the
|
|
23
|
+
* whole file" — invalid. The browser accepted `{}`.
|
|
24
|
+
* - `reference_models[].versions[].sha256` carries `pattern: "^[0-9a-f]{64}$"`. The browser accepted
|
|
25
|
+
* any string.
|
|
26
|
+
*
|
|
27
|
+
* That drift was not merely latent. `web/steel-editor.html`'s draft restore filters rows through this
|
|
28
|
+
* interpreter under the banner "ASK THE SCHEMA, DO NOT RESTATE IT … through the same subset
|
|
29
|
+
* interpreter the server validates with", and `web/steel-model-v2-client-validation.js` says its
|
|
30
|
+
* "shape uses the same schema artifact and subset interpreter as the server". Both sentences were
|
|
31
|
+
* false while two interpreters existed, and nothing in the suite tied them together.
|
|
32
|
+
*
|
|
33
|
+
* The surviving BEHAVIOUR is the server's in every particular, because the server is the persistence
|
|
34
|
+
* authority and a client that refuses what the server accepts is a new bug, not a fix. So the browser
|
|
35
|
+
* gains `pattern`, `minProperties` and the `non-finite number` wording; the server's oneOf
|
|
36
|
+
* branch-selection (first of the fewest-error branches, no sort) and its "compute the string length
|
|
37
|
+
* only when a bound asks" gating are kept verbatim. Not every LINE is the server's — `typeMatches` is
|
|
38
|
+
* the browser's eager object literal rather than the server's `switch` — and the two are swept against
|
|
39
|
+
* each other over every keyword in `server/json-schema-subset-parity.test.ts`, which keeps the deleted
|
|
40
|
+
* walker executable rather than asking anyone to take the equivalence on trust.
|
|
41
|
+
*
|
|
42
|
+
* TWO LIMITS IT INHERITS AND DOES NOT FIX, because fixing either is a behaviour change on the server:
|
|
43
|
+
* an invalid `pattern` throws a `SyntaxError` straight out of the walk (and the `u` flag widens that —
|
|
44
|
+
* `\-` and `[a-\w]` are legal patterns without it), and an UNSUPPORTED keyword is silently ignored, so
|
|
45
|
+
* an `allOf` added to a file under `schemas/` would constrain nothing in either runtime. Both are
|
|
46
|
+
* pinned as `LIMIT` cases in the parity suite so they are known rather than discovered.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/** @typedef {{ path: string, message: string }} SubsetValidationError */
|
|
2
50
|
|
|
3
51
|
const plain = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
52
|
+
|
|
4
53
|
const equal = (a, b) => a === b || (Array.isArray(a) && Array.isArray(b)
|
|
5
54
|
&& a.length === b.length && a.every((v, i) => equal(v, b[i])));
|
|
6
|
-
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The type name a value REPORTS as in an error message. `non-finite number` is its own answer so the
|
|
58
|
+
* tightened `number` check below reads "expected number, got non-finite number" (a `1e400` literal
|
|
59
|
+
* JSON-parses to Infinity, which `JSON.stringify` then writes back as `null`) rather than the
|
|
60
|
+
* baffling "expected number, got number".
|
|
61
|
+
*/
|
|
62
|
+
const kind = (v) => {
|
|
63
|
+
if (v === null) return 'null';
|
|
64
|
+
if (Array.isArray(v)) return 'array';
|
|
65
|
+
if (typeof v === 'number' && !Number.isFinite(v)) return 'non-finite number';
|
|
66
|
+
return typeof v;
|
|
67
|
+
};
|
|
68
|
+
|
|
7
69
|
const typeMatches = (v, t) => ({
|
|
8
|
-
object: plain(v),
|
|
9
|
-
|
|
70
|
+
object: plain(v),
|
|
71
|
+
array: Array.isArray(v),
|
|
72
|
+
string: typeof v === 'string',
|
|
73
|
+
number: typeof v === 'number' && Number.isFinite(v), // reject ±Infinity — see `kind` above
|
|
10
74
|
integer: typeof v === 'number' && Number.isInteger(v),
|
|
11
|
-
boolean: typeof v === 'boolean',
|
|
75
|
+
boolean: typeof v === 'boolean',
|
|
76
|
+
null: v === null,
|
|
12
77
|
})[t] === true;
|
|
13
78
|
|
|
79
|
+
/** Only local `#/$defs/Name` is supported — the form every schema in this repo uses. */
|
|
80
|
+
function resolveRef(root, ref) {
|
|
81
|
+
const match = /^#\/\$defs\/(.+)$/.exec(ref);
|
|
82
|
+
if (!match) return null;
|
|
83
|
+
// `?? null`, not `|| null`: a falsy-but-present `$defs` entry must be walked, not reported as an
|
|
84
|
+
// unresolved `$ref`. That is the server's rule, and this module may not change server behaviour.
|
|
85
|
+
return root.$defs?.[match[1]] ?? null;
|
|
86
|
+
}
|
|
87
|
+
|
|
14
88
|
function walk(value, node, root, path, errors) {
|
|
15
89
|
if (node.$ref) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
else walk(value, target, root, path, errors);
|
|
90
|
+
const target = resolveRef(root, node.$ref);
|
|
91
|
+
if (!target) { errors.push({ path, message: `unresolved $ref ${node.$ref}` }); return; }
|
|
92
|
+
walk(value, target, root, path, errors);
|
|
20
93
|
return;
|
|
21
94
|
}
|
|
95
|
+
|
|
22
96
|
if (node.oneOf) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
97
|
+
let matches = 0;
|
|
98
|
+
let closest = null;
|
|
99
|
+
for (const candidate of node.oneOf) {
|
|
100
|
+
const candidateErrors = [];
|
|
101
|
+
walk(value, candidate, root, path, candidateErrors);
|
|
102
|
+
if (candidateErrors.length === 0) matches++;
|
|
103
|
+
else if (!closest || candidateErrors.length < closest.length) closest = candidateErrors;
|
|
104
|
+
}
|
|
27
105
|
if (matches !== 1) {
|
|
28
106
|
errors.push({ path, message: `must match exactly one oneOf branch (matched ${matches})` });
|
|
29
|
-
if (matches === 0) errors.push(...
|
|
107
|
+
if (matches === 0 && closest) errors.push(...closest);
|
|
30
108
|
}
|
|
31
109
|
}
|
|
32
|
-
|
|
33
|
-
if (node
|
|
110
|
+
|
|
111
|
+
if ('const' in node && !equal(value, node.const)) {
|
|
112
|
+
errors.push({ path, message: `must equal ${JSON.stringify(node.const)}` });
|
|
113
|
+
}
|
|
114
|
+
if (node.enum && !node.enum.some((v) => equal(value, v))) {
|
|
115
|
+
errors.push({ path, message: `must be one of ${JSON.stringify(node.enum)}` });
|
|
116
|
+
}
|
|
117
|
+
|
|
34
118
|
if (node.type) {
|
|
35
119
|
const types = Array.isArray(node.type) ? node.type : [node.type];
|
|
36
120
|
if (!types.some((t) => typeMatches(value, t))) {
|
|
37
121
|
errors.push({ path, message: `expected ${types.join(' | ')}, got ${kind(value)}` });
|
|
38
|
-
return;
|
|
122
|
+
return; // wrong type — deeper structural checks would only add cascade noise
|
|
39
123
|
}
|
|
40
124
|
}
|
|
125
|
+
|
|
41
126
|
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
42
127
|
if (typeof node.minimum === 'number' && value < node.minimum) errors.push({ path, message: `must be >= ${node.minimum}` });
|
|
43
128
|
if (typeof node.maximum === 'number' && value > node.maximum) errors.push({ path, message: `must be <= ${node.maximum}` });
|
|
44
129
|
if (typeof node.exclusiveMinimum === 'number' && value <= node.exclusiveMinimum) errors.push({ path, message: `must be > ${node.exclusiveMinimum}` });
|
|
45
130
|
if (typeof node.exclusiveMaximum === 'number' && value >= node.exclusiveMaximum) errors.push({ path, message: `must be < ${node.exclusiveMaximum}` });
|
|
46
131
|
}
|
|
47
|
-
|
|
132
|
+
|
|
133
|
+
if (typeof value === 'string' && (typeof node.maxLength === 'number' || typeof node.minLength === 'number')) {
|
|
48
134
|
const length = Array.from(value).length;
|
|
49
|
-
if (typeof node.minLength === 'number' && length < node.minLength) errors.push({ path, message: `expected at least ${node.minLength} characters, got ${length}` });
|
|
50
135
|
if (typeof node.maxLength === 'number' && length > node.maxLength) errors.push({ path, message: `expected at most ${node.maxLength} characters, got ${length}` });
|
|
136
|
+
// minLength exists for steel.model/v2, where ids/hashes/sheets are load-bearing references: without it
|
|
137
|
+
// `"": {type:"string"}` satisfies a required id and the referential-integrity pass inherits an empty key.
|
|
138
|
+
if (typeof node.minLength === 'number' && length < node.minLength) errors.push({ path, message: `expected at least ${node.minLength} characters, got ${length}` });
|
|
139
|
+
}
|
|
140
|
+
if (typeof value === 'string' && typeof node.pattern === 'string' && !(new RegExp(node.pattern, 'u')).test(value)) {
|
|
141
|
+
errors.push({ path, message: `must match pattern ${node.pattern}` });
|
|
51
142
|
}
|
|
143
|
+
|
|
52
144
|
if (plain(value)) {
|
|
53
|
-
|
|
54
|
-
|
|
145
|
+
// Object.hasOwn, not `in`: a document key (or required name) that collides with an
|
|
146
|
+
// Object.prototype member — `constructor`, `valueOf`, `__proto__` — must not be treated
|
|
147
|
+
// as a declared property of the schema's own `properties`, or it bypasses the
|
|
148
|
+
// additionalProperties guard. JSON.parse can produce such keys, so this is a real gap.
|
|
149
|
+
for (const required of node.required ?? []) {
|
|
150
|
+
if (!Object.hasOwn(value, required)) errors.push({ path: `${path}.${required}`, message: 'required' });
|
|
151
|
+
}
|
|
152
|
+
// `required` cannot express "at least one of these", and `oneOf` is the wrong tool for it —
|
|
153
|
+
// it demands EXACTLY one branch match, so a filter naming both a storey and a type would be
|
|
154
|
+
// refused. `reference_models[].filter` needs {} to be invalid while {storeys}, {ifcTypes} and
|
|
155
|
+
// both are all valid, which is precisely minProperties.
|
|
156
|
+
if (typeof node.minProperties === 'number' && Object.keys(value).length < node.minProperties) {
|
|
157
|
+
errors.push({ path, message: `expected at least ${node.minProperties} propert${node.minProperties === 1 ? 'y' : 'ies'}` });
|
|
158
|
+
}
|
|
159
|
+
const properties = node.properties ?? {};
|
|
160
|
+
const additional = node.additionalProperties;
|
|
55
161
|
for (const key of Object.keys(value)) {
|
|
56
162
|
if (Object.hasOwn(properties, key)) walk(value[key], properties[key], root, `${path}.${key}`, errors);
|
|
57
|
-
else if (
|
|
58
|
-
|
|
163
|
+
else if (additional === false) errors.push({ path: `${path}.${key}`, message: 'additional property not allowed' });
|
|
164
|
+
// `typeof === 'object'`, not `plain(…)`: the server walked an array here too, and matching it
|
|
165
|
+
// exactly is the point — see `?? null` above.
|
|
166
|
+
else if (additional && typeof additional === 'object') walk(value[key], additional, root, `${path}.${key}`, errors);
|
|
59
167
|
}
|
|
60
168
|
}
|
|
169
|
+
|
|
61
170
|
if (Array.isArray(value)) {
|
|
62
|
-
if (typeof node.minItems === 'number' && value.length < node.minItems)
|
|
63
|
-
|
|
171
|
+
if (typeof node.minItems === 'number' && value.length < node.minItems) {
|
|
172
|
+
errors.push({ path, message: `expected at least ${node.minItems} items, got ${value.length}` });
|
|
173
|
+
}
|
|
174
|
+
if (typeof node.maxItems === 'number' && value.length > node.maxItems) {
|
|
175
|
+
errors.push({ path, message: `expected at most ${node.maxItems} items, got ${value.length}` });
|
|
176
|
+
}
|
|
64
177
|
if (node.items) value.forEach((item, i) => walk(item, node.items, root, `${path}[${i}]`, errors));
|
|
65
178
|
}
|
|
66
179
|
}
|
|
67
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Validate `value` against `schema`. `schema` is also the `$ref` root, so pass a node that carries
|
|
183
|
+
* `$defs` when validating one row against a definition.
|
|
184
|
+
*
|
|
185
|
+
* @returns {{ valid: boolean, errors: SubsetValidationError[] }}
|
|
186
|
+
*/
|
|
68
187
|
export function validateSchemaSubset(value, schema) {
|
|
188
|
+
/** @type {SubsetValidationError[]} */
|
|
69
189
|
const errors = [];
|
|
70
190
|
walk(value, schema, schema, '$', errors);
|
|
71
191
|
return { valid: errors.length === 0, errors };
|