@floless/app 0.168.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.
Files changed (80) hide show
  1. package/cli-actions.mjs +8 -1
  2. package/dist/floless-server.cjs +125533 -99597
  3. package/dist/schemas/drawing-check.profile.v1.schema.json +12 -2
  4. package/dist/schemas/steel.model.v2.schema.json +2 -1
  5. package/dist/skills/floless-app-knowledge/SKILL.md +43 -13
  6. package/dist/skills/floless-app-new-workflow/SKILL.md +8 -1
  7. package/dist/skills/floless-app-rfi/SKILL.md +4 -2
  8. package/dist/skills/floless-app-routines/SKILL.md +2 -2
  9. package/dist/skills/floless-app-routines/references/routines-api.md +20 -8
  10. package/dist/skills/floless-app-steel-model/SKILL.md +8 -5
  11. package/dist/skills/floless-app-steel-takeoff/SKILL.md +31 -1
  12. package/dist/skills/floless-app-workflows/SKILL.md +22 -3
  13. package/dist/skills/floless-app-workflows/references/agent-steps.md +40 -6
  14. package/dist/skills/floless-app-workflows/references/exec-contract.md +27 -0
  15. package/dist/skills/floless-app-workflows/references/script-runner.md +105 -0
  16. package/dist/templates/college-phase-exporter.flo +7 -2
  17. package/dist/templates/trimble-list-projects.flo +10 -2
  18. package/dist/web/agent-steps.js +90 -19
  19. package/dist/web/agents.js +77 -31
  20. package/dist/web/app.css +267 -4
  21. package/dist/web/app.js +71 -7
  22. package/dist/web/aware-update-client.js +4 -4
  23. package/dist/web/aware.js +1277 -219
  24. package/dist/web/chat.css +10 -0
  25. package/dist/web/chat.js +407 -117
  26. package/dist/web/checkpoint-standard.js +5 -3
  27. package/dist/web/commands-drawing-check.js +4 -0
  28. package/dist/web/commands-shell.js +551 -15
  29. package/dist/web/commands-steel.js +68 -2
  30. package/dist/web/commands-vector.js +69 -0
  31. package/dist/web/drawing-check-editor.html +10 -0
  32. package/dist/web/drawing-check-editor.js +821 -237
  33. package/dist/web/failure-copy.js +50 -2
  34. package/dist/web/filter-ai-proposal.js +11 -8
  35. package/dist/web/flo-3d.js +310 -0
  36. package/dist/web/flo-card.js +72 -0
  37. package/dist/web/guide.js +33 -24
  38. package/dist/web/index.html +95 -5
  39. package/dist/web/instructor.js +102 -15
  40. package/dist/web/left-pane.js +4 -1
  41. package/dist/web/local-discovery.js +8 -7
  42. package/dist/web/missed-routines.js +239 -0
  43. package/dist/web/model-editor-steel-adapter.js +41 -1
  44. package/dist/web/model-measure.js +6 -0
  45. package/dist/web/model-spatial-panel.js +19 -4
  46. package/dist/web/model-spatial-tools.js +3 -3
  47. package/dist/web/model-viewport-revit-adapter.js +3 -3
  48. package/dist/web/model-viewport-toolbar.js +11 -0
  49. package/dist/web/origin-rule.js +155 -0
  50. package/dist/web/pages.js +17 -14
  51. package/dist/web/panels.js +1 -1
  52. package/dist/web/project-access.js +1 -1
  53. package/dist/web/project-history.js +2 -2
  54. package/dist/web/project-modules.js +5 -5
  55. package/dist/web/project-reconciliation.js +1 -1
  56. package/dist/web/project-rfis.js +8 -3
  57. package/dist/web/project-workflows.js +8 -6
  58. package/dist/web/renderers.js +6 -0
  59. package/dist/web/report-csp.js +68 -0
  60. package/dist/web/revit-editor.js +22 -8
  61. package/dist/web/run-history.js +14 -4
  62. package/dist/web/steel-3d-core.js +39 -9
  63. package/dist/web/steel-3d-flo.js +331 -0
  64. package/dist/web/steel-3d-view.js +164 -0
  65. package/dist/web/steel-ai-marks.js +3 -1
  66. package/dist/web/steel-editor.html +583 -129
  67. package/dist/web/steel-environments.js +297 -0
  68. package/dist/web/steel-filter.html +3 -2
  69. package/dist/web/steel-model-v2-client-validation.js +8 -1
  70. package/dist/web/steel-model-v2-commands.js +23 -9
  71. package/dist/web/steel-model-v2-projection.js +1 -1
  72. package/dist/web/step-rename.js +3 -2
  73. package/dist/web/terminal-requests.js +79 -1
  74. package/dist/web/tool-updates.js +9 -7
  75. package/dist/web/vector-3d.html +1 -1
  76. package/dist/web/vector-editor.html +50 -8
  77. package/dist/web/workspace-root-management.js +1 -1
  78. package/dist/web/workspaces.js +2334 -253
  79. package/launch.mjs +5 -0
  80. package/package.json +11 -8
@@ -108,7 +108,9 @@ function failureCopy(error, ctx) {
108
108
  const refused = failureSentence(c.nothingDone) || lead;
109
109
  const said = (s) => s.filter(Boolean).join(' ');
110
110
  const userMessage = typeof body.userMessage === 'string' ? body.userMessage.trim() : '';
111
- const reason = typeof body.reason === 'string' ? body.reason.trim() : '';
111
+ // #3097: a `diagnostic` reply's `reason` is what a tool printed (AWARE's stderr), kept for Technical details and the
112
+ // AI, never for the person's sentence.
113
+ const reason = typeof body.reason === 'string' && !body.diagnostic ? body.reason.trim() : '';
112
114
  if (kind === 'busy') {
113
115
  if (body.code === 'maintenance-busy' && typeof body.message === 'string' && body.message.trim()) {
114
116
  return { kind, type: 'warn', text: said([refused, failureSentence(body.message)]) };
@@ -134,6 +136,10 @@ function failureCopy(error, ctx) {
134
136
  // A refusal the server wrote for the person. Not for an unexpected failure: a 5xx is not a considered answer, and
135
137
  // the person is told the reason is unknown rather than a sentence that may describe something else (#2764).
136
138
  if (userMessage && kind !== 'unexpected') return { kind, type: 'warn', text: said([refused, failureSentence(userMessage)]) };
139
+ // #3097: a 4xx FloLess does not class (409 with no stale code, 412, 428, 429) is still a considered refusal, so its
140
+ // sentence is shown. The status alone proves no outcome, so it leads with what could not be done, not `nothingDone`.
141
+ const status = Number(error && error.status) || 0;
142
+ if (userMessage && status >= 400 && status < 500) return { kind, type: 'warn', text: said([lead, failureSentence(userMessage)]) };
137
143
  if (kind === 'outdated') {
138
144
  return { kind, type: 'err', text: said([refused, 'The AWARE runtime on this computer is too old for it.', 'Update AWARE, then try again.']) };
139
145
  }
@@ -176,6 +182,48 @@ function failureParts(error, ctx) {
176
182
  return { kind: copy.kind, type: copy.type, headline: copy.text.slice(0, cut + 1), detail: copy.text.slice(cut + 1).trim() };
177
183
  }
178
184
 
185
+ /**
186
+ * #3097 slice 2: the server's own sentence for the person, when it wrote one. `userMessage` is always for a person;
187
+ * `error` is too, unless the server marked it `diagnostic` (raw exception text on a 5xx, written for a developer).
188
+ * '' means the server said nothing a person should read, and the caller falls back to failureCopy.
189
+ */
190
+ function personText(body) {
191
+ if (!body || typeof body !== 'object') return '';
192
+ if (typeof body.userMessage === 'string' && body.userMessage.trim()) return body.userMessage.trim();
193
+ // A one-word `error` is a code (`model_module_unavailable`, `forbidden`), not a sentence for a person; nor is the
194
+ // subscription gate's "subscription required", whose sentence is the shell's (failureCopy's `account`).
195
+ const error = typeof body.error === 'string' ? body.error.trim() : '';
196
+ if (!body.diagnostic && /\S\s+\S/.test(error) && error !== 'subscription required') return error;
197
+ return '';
198
+ }
199
+
200
+ /**
201
+ * #3097 slice 3b: the sentence for a caught error, so no page writes `err.message` into what a person reads.
202
+ * - An error a request helper threw carries the server's reply as `body`: the sentence is worked out again from that
203
+ * reply (personText, else failureCopy), never taken from `message`, which a helper may have built from anything.
204
+ * - An error the page threw FOR a person (`forPerson: true`, its message a sentence the page wrote) is said as written.
205
+ * - Anything else (the browser's "Failed to fetch", a reply that was not JSON, a library or a check that threw) was
206
+ * written for a developer: it goes to the console and the person gets the shared sentence.
207
+ * `ctx` is failureCopy's (`action`, `nothingDone`, `unsure`, `retrySafe`, …).
208
+ * @returns {string}
209
+ */
210
+ function errorText(err, ctx) {
211
+ if (err && err.body && typeof err.body === 'object') {
212
+ // A busy lock, a sign-in or access refusal, a lost answer and an outdated AWARE have their own sentences here, which
213
+ // already say the server's userMessage where it wrote one; the server's `error` for them is "subscription required"
214
+ // or a lock's time estimate, which failureCopy deliberately does not repeat.
215
+ const kind = failureKind(err);
216
+ // The sign-in sentence is the shell's (aware.js accountAccessText), so a renewal or an update is not answered with
217
+ // "sign in again", and every surface says the same as the toast does.
218
+ const account = (ctx && ctx.account) || (globalThis.flolessBridge && globalThis.flolessBridge.accountAccessText);
219
+ if (kind === 'busy' || kind === 'access' || kind === 'connection' || kind === 'outdated') return failureCopy(err, { ...ctx, account }).text;
220
+ return personText(err.body) || failureCopy(err, ctx).text;
221
+ }
222
+ if (err && err.forPerson === true && typeof err.message === 'string' && err.message.trim()) return failureSentence(err.message);
223
+ console.warn(`FloLess: couldn’t ${(ctx && ctx.action) || 'finish that'}`, err);
224
+ return failureCopy(err, ctx).text;
225
+ }
226
+
179
227
  if (typeof module !== 'undefined' && module.exports) {
180
- module.exports = { failureKind, failureCopy, failureParts, FAILURE_BUSY_CODES, FAILURE_BUSY_WORK };
228
+ module.exports = { failureKind, failureCopy, failureParts, personText, errorText, FAILURE_BUSY_CODES, FAILURE_BUSY_WORK };
181
229
  }
@@ -59,10 +59,13 @@ export function filterAiKnownControls(filter) {
59
59
  return known;
60
60
  }
61
61
 
62
+ /** #3097: the parser's refusals are sentences it wrote for the person, so a surface may say them (`forPerson`). */
63
+ const refusal = (sentence) => Object.assign(new Error(sentence), { forPerson: true });
64
+
62
65
  /** Reject malformed or contradictory suggestions before any surface presents them. */
63
66
  export function parseFilterAiProposalShape(answer) {
64
67
  // Sized for MAX_FILTER_CHANGES changes of the longest names a snapshot carries, so no suggestion it allows is refused here.
65
- if (typeof answer !== 'string' || answer.length > 2_000_000) throw new Error('AI returned a suggestion that is too large. Ask about fewer layers.');
68
+ if (typeof answer !== 'string' || answer.length > 2_000_000) throw refusal('AI returned a suggestion that is too large. Ask about fewer layers.');
66
69
  let value;
67
70
  // A model that wraps the envelope in a ```json fence produced the envelope; the fence is packaging,
68
71
  // not a different answer, so unwrap it before deciding anything.
@@ -84,7 +87,7 @@ export function parseFilterAiProposalShape(answer) {
84
87
  // a change was proposed and lost. Only text that never attempted the envelope is prose.
85
88
  const text = unfenced.trim();
86
89
  if (!text || text.startsWith('{') || text.startsWith('[')) {
87
- throw new Error('AI did not return a usable selection. Ask it to try again.');
90
+ throw refusal('AI did not return a usable selection. Ask it to try again.');
88
91
  }
89
92
  return { explanation: text.slice(0, MAX_FILTER_EXPLANATION), changes: [], mode: null };
90
93
  }
@@ -94,26 +97,26 @@ export function parseFilterAiProposalShape(answer) {
94
97
  || !Array.isArray(value.changes) || value.changes.length > MAX_FILTER_CHANGES
95
98
  || (value.mode !== null && (typeof value.mode !== 'string'
96
99
  || !value.mode || value.mode !== canonicalMode(value.mode.split('+'))))) {
97
- throw new Error('AI returned a suggestion this filter cannot use. Ask it to try again.');
100
+ throw refusal('AI returned a suggestion this filter cannot use. Ask it to try again.');
98
101
  }
99
102
  const seen = new Set();
100
103
  for (const item of value.changes) {
101
104
  if (!item || Array.isArray(item) || typeof item !== 'object'
102
105
  || Object.keys(item).sort().join(',') !== 'dimension,on,value'
103
106
  || !MODE_ORDER.includes(item.dimension) || typeof item.on !== 'boolean') {
104
- throw new Error('AI named a change this filter cannot use. Ask it to try again.');
107
+ throw refusal('AI named a change this filter cannot use. Ask it to try again.');
105
108
  }
106
109
  if (item.dimension === 'thickness' && (typeof item.value !== 'number' || !Number.isFinite(item.value))) {
107
- throw new Error('AI named a value that is missing from this filter. Ask it to try again.');
110
+ throw refusal('AI named a value that is missing from this filter. Ask it to try again.');
108
111
  }
109
112
  if (item.dimension !== 'thickness' && typeof item.value !== 'string') {
110
- throw new Error('AI named a value that is missing from this filter. Ask it to try again.');
113
+ throw refusal('AI named a value that is missing from this filter. Ask it to try again.');
111
114
  }
112
115
  const key = item.value;
113
116
  const canonical = facetKey(item.dimension, key);
114
117
  const identity = item.dimension + '\0' + String(canonical);
115
118
  if (canonical === undefined || seen.has(identity)) {
116
- throw new Error('AI named a value that is missing from this filter. Ask it to try again.');
119
+ throw refusal('AI named a value that is missing from this filter. Ask it to try again.');
117
120
  }
118
121
  seen.add(identity);
119
122
  }
@@ -134,7 +137,7 @@ export function parseFilterAiProposal(answer, filter, allowedControls = null) {
134
137
  const canonical = facetKey(item.dimension, item.value);
135
138
  const identity = item.dimension + '\0' + String(canonical);
136
139
  if (!known.has(identity) || (allowedControls && !allowedControls.has(identity))) {
137
- throw new Error('AI named a value that is missing from this filter. Ask it to try again.');
140
+ throw refusal('AI named a value that is missing from this filter. Ask it to try again.');
138
141
  }
139
142
  changes.push({ dimension:item.dimension, value:known.get(identity), on:item.on });
140
143
  }
@@ -0,0 +1,310 @@
1
+ // Flo in 3D: the same Flo web/flo.js draws (the icon's node with pill eyes and the white hard hat), built as a
2
+ // small lacquered object that stands on a model and moves by hopping, with squash and stretch, as the design
3
+ // says it must (no body, no legs: docs/superpowers/specs/2026-10-07-flo-avatar-and-explainer-design.md).
4
+ // Everything Flo's face does (blink, glance, mood, hat tip) comes from floPose(), so the 2D and 3D Flo cannot
5
+ // drift. This module builds and moves Flo and nothing else: where Flo goes and which mood it shows is the
6
+ // caller's (web/steel-3d-flo.js), and it decides nothing about the model.
7
+ //
8
+ // Proportions are in units of r, the ring's centre-line radius, exactly as flo.js has them. Flo's own frame is
9
+ // Y up and faces +Z; the root group turns that into the scene's up axis, so a Z-up model works unchanged.
10
+
11
+ const HOP_MIN_S = 0.42, HOP_MAX_S = 0.95; // airtime, from a step to a leap across the model
12
+ const CROUCH_S = 0.12, LAND_S = 0.2; // anticipation before take-off, the settle after landing
13
+ const HELLO_S = 0.9; // one hat tip, as flo-avatar.js's Hello plays it
14
+ const STROKE = 0.29; // ring width / r (flo.js default)
15
+ const EYE_Z = 0.07; // how far the eyes stand proud of the face
16
+
17
+ // Flo in 3D wears the brand navy of the logo and the end cards (ring, eyes and hat ridge on a light face), not
18
+ // the 2D dark theme's lighter blue: the light face and white hat carry its outline on the dark 3D stage.
19
+ export const FLO_3D_COLORS = Object.freeze({ line: '#1e3a5f', fill: '#f1f5f9', hat: '#f1f5f9', pulse: '#c7d9ef' });
20
+
21
+ const clamp = (v, a = 0, b = 1) => Math.max(a, Math.min(b, v));
22
+ const easeOut = (u) => 1 - (1 - u) * (1 - u);
23
+ const bump = (u) => Math.sin(Math.PI * clamp(u));
24
+
25
+ // The hop as data, so it can be tested without a renderer: where Flo is (0..1 along the way, height in r) and
26
+ // how it squashes at time `s` into a hop that lasts `air` seconds. Before take-off it crouches, in the air it
27
+ // stretches along the way it is going, and on landing it squashes and springs back once.
28
+ export function floHopPose(s, air, rise) {
29
+ if (s < 0) {
30
+ const u = clamp(1 + s / CROUCH_S); // -CROUCH_S..0
31
+ const k = 0.22 * bump(u * 0.5 + 0.25) * u; // dips, holds, releases into the jump
32
+ return { along: 0, lift: 0, sx: 1 + k * 0.6, sy: 1 - k };
33
+ }
34
+ if (s < air) {
35
+ const u = s / air;
36
+ const stretch = 0.16 * bump(u) * (1 - Math.abs(2 * u - 1) * 0.6);
37
+ return { along: u, lift: 4 * rise * u * (1 - u), sx: 1 - stretch * 0.55, sy: 1 + stretch };
38
+ }
39
+ const u = clamp((s - air) / LAND_S);
40
+ const k = 0.26 * Math.exp(-5 * u) * Math.cos(u * Math.PI * 1.6);
41
+ return { along: 1, lift: 0, sx: 1 + k * 0.7, sy: 1 - k };
42
+ }
43
+
44
+ // How long a hop takes and how high it goes, from the distance in r. Short steps are quick and low; a leap
45
+ // across the model takes longer but never so long that the person waits for it.
46
+ // A step shorter than SHORT_R stays low and quick, so moving to the next member along reads as a shuffle
47
+ // rather than a leap; nothing rises more than 5 r, so a long hop stays in the frame it started in.
48
+ const SHORT_R = 4;
49
+ export function floHopShape(distR) {
50
+ const d = Math.max(0, distR);
51
+ if (d < SHORT_R) return { air: HOP_MIN_S * 0.75, rise: 0.4 + d * 0.15 };
52
+ const air = clamp(0.3 + 0.07 * Math.sqrt(d), HOP_MIN_S, HOP_MAX_S);
53
+ const rise = clamp(1.4 + d * 0.18, 1.4, 5);
54
+ return { air, rise };
55
+ }
56
+
57
+ export function createFlo3D(THREE, opts = {}) {
58
+ const pose = opts.floPose;
59
+ if (typeof pose !== 'function') throw new Error('createFlo3D needs flo.js floPose');
60
+ const up = (opts.up ?? new THREE.Vector3(0, 1, 0)).clone().normalize();
61
+ let r = opts.r ?? 300;
62
+ let mood = 'idle', hat = true, reduced = !!opts.reducedMotion;
63
+ const seed = opts.seed ?? 0;
64
+
65
+ // root: placed in the world, turned so its +Y is the scene's up. body: yaw toward the camera.
66
+ // squash: scales about Flo's feet (the bottom of the ring). Everything inside is built at r = 1 and scaled.
67
+ const root = new THREE.Group(); root.name = 'flo-3d'; root.userData.flo = true;
68
+ root.quaternion.setFromUnitVectors(new THREE.Vector3(0, 1, 0), up);
69
+ const body = new THREE.Group(); root.add(body);
70
+ const squash = new THREE.Group(); body.add(squash);
71
+ const unit = new THREE.Group(); unit.position.y = 1 + STROKE / 2; squash.add(unit); // the ring's outer edge rests on the feet
72
+
73
+ const mats = {
74
+ line: new THREE.MeshPhysicalMaterial({ roughness: 0.32, metalness: 0.05, clearcoat: 1, clearcoatRoughness: 0.18 }),
75
+ eye: new THREE.MeshPhysicalMaterial({ roughness: 0.22, metalness: 0, clearcoat: 1, clearcoatRoughness: 0.08 }),
76
+ face: new THREE.MeshStandardMaterial({ roughness: 0.75, metalness: 0 }),
77
+ hat: new THREE.MeshPhysicalMaterial({ roughness: 0.38, metalness: 0, clearcoat: 0.9, clearcoatRoughness: 0.25, transparent: true }),
78
+ ridge: new THREE.MeshPhysicalMaterial({ roughness: 0.32, metalness: 0.05, clearcoat: 1, transparent: true }),
79
+ pulse: new THREE.MeshBasicMaterial({ toneMapped: false }),
80
+ shadow: new THREE.MeshBasicMaterial({ transparent: true, depthWrite: false, opacity: 0.45, color: 0x000000 }),
81
+ ripple: new THREE.MeshBasicMaterial({ transparent: true, depthWrite: false, opacity: 0, side: THREE.DoubleSide, toneMapped: false }),
82
+ };
83
+ const geos = [];
84
+ const mesh = (g, m) => { geos.push(g); const o = new THREE.Mesh(g, m); o.userData.flo = true; return o; };
85
+
86
+ // The ring: a torus as thick as flo.js's stroke, with the face set just inside it in the background colour.
87
+ const tube = STROKE / 2, inner = 1 - tube;
88
+ unit.add(mesh(new THREE.TorusGeometry(1, tube, 28, 96), mats.line));
89
+ const face = mesh(new THREE.CylinderGeometry(inner + 0.01, inner + 0.01, 0.16, 64), mats.face);
90
+ face.rotation.x = Math.PI / 2; unit.add(face);
91
+
92
+ // Eyes: pills on both faces, so Flo never shows a blank back while it turns. Their size, gap and blink are
93
+ // floPose's numbers. The happy arc (success) is a half torus that replaces the pill.
94
+ const eyes = [];
95
+ for (const side of [1, -1]) for (const sx of [-1, 1]) {
96
+ const pill = mesh(new THREE.CapsuleGeometry(0.5, 1, 6, 18), mats.eye);
97
+ const arc = mesh(new THREE.TorusGeometry(1, 0.38, 10, 24, Math.PI), mats.eye);
98
+ const g = new THREE.Group(); g.add(pill, arc);
99
+ g.position.z = side * (0.08 + EYE_Z * 0.5);
100
+ if (side < 0) g.rotation.y = Math.PI;
101
+ unit.add(g); eyes.push({ g, pill, arc, sx: side * sx });
102
+ }
103
+
104
+ // The hard hat: dome, brim and the ridge over the top, sized to the ring as floDrawHat sizes it. It pivots
105
+ // near the brim's left end, so a tip reads as a tip.
106
+ const hatPivot = new THREE.Group(); hatPivot.position.set(-0.9, 0.8, 0); unit.add(hatPivot);
107
+ const hatG = new THREE.Group(); hatG.position.set(0.9, -0.8, 0); hatPivot.add(hatG);
108
+ const dome = mesh(new THREE.SphereGeometry(1, 48, 24, 0, Math.PI * 2, 0, Math.PI / 2), mats.hat);
109
+ dome.scale.set(0.958, 0.95, 0.9); dome.position.y = 0.96; hatG.add(dome);
110
+ const brim = mesh(new THREE.CylinderGeometry(1, 1, 1, 64), mats.hat);
111
+ brim.scale.set(1.25, 0.13, 1.08); brim.position.set(0, 0.95, 0.06); hatG.add(brim);
112
+ const ridge = mesh(new THREE.TorusGeometry(0.93, 0.085, 10, 40, Math.PI * 0.62), mats.ridge);
113
+ ridge.rotation.set(0, Math.PI / 2, Math.PI * 0.19); ridge.position.y = 0.96; ridge.scale.set(1, 1.02, 0.96);
114
+ hatG.add(ridge);
115
+
116
+ // Working / Thinking: a short arc of light that runs round the ring, as the 2D one does.
117
+ const orbitGeos = {};
118
+ const orbit = mesh(new THREE.BufferGeometry(), mats.pulse);
119
+ orbit.position.z = 0; unit.add(orbit);
120
+ function orbitArc(len) {
121
+ const key = len.toFixed(3);
122
+ if (!orbitGeos[key]) { orbitGeos[key] = new THREE.TorusGeometry(1, tube * 0.62, 10, 48, len); geos.push(orbitGeos[key]); }
123
+ return orbitGeos[key];
124
+ }
125
+
126
+ // Contact shadow and the landing ripple sit on the surface Flo stands on, outside the squash.
127
+ const shadowTex = radialTexture(THREE, [[0, 'rgba(0,0,0,0.55)'], [0.55, 'rgba(0,0,0,0.22)'], [1, 'rgba(0,0,0,0)']]);
128
+ mats.shadow.map = shadowTex; mats.shadow.color.set(0xffffff);
129
+ const shadow = mesh(new THREE.PlaneGeometry(2.6, 2.6), mats.shadow);
130
+ shadow.rotation.x = -Math.PI / 2; shadow.position.y = 0.01; shadow.renderOrder = 1; root.add(shadow);
131
+ const ripple = mesh(new THREE.RingGeometry(0.92, 1, 64), mats.ripple);
132
+ ripple.rotation.x = -Math.PI / 2; ripple.position.y = 0.012; ripple.renderOrder = 1; root.add(ripple);
133
+
134
+ for (const m of [shadow, ripple]) m.raycast = () => {};
135
+
136
+ const here = new THREE.Vector3(); // where Flo stands (world)
137
+ let hop = null; // { from, to, t0, air, rise, onLand, heading }
138
+ let hello = null; // t0 of a hat tip
139
+ let landAt = -Infinity; // when the last hop landed (ripple)
140
+ let lookYaw = 0, faceYaw = 0, lastTick = null;
141
+ const tmp = new THREE.Vector3(), tmp2 = new THREE.Vector3(), inv = new THREE.Quaternion();
142
+
143
+ function setColors(c) {
144
+ mats.line.color.set(c.line); mats.eye.color.set(c.line); mats.ridge.color.set(c.line);
145
+ mats.face.color.set(c.fill); mats.hat.color.set(c.hat); mats.pulse.color.set(c.pulse);
146
+ mats.ripple.color.set(c.pulse);
147
+ // A little of each colour as its own light, so under the model's lights the hat still reads as the brand's
148
+ // white and the ring as its blue, not as grey and navy (the shading stays: it is what makes Flo solid).
149
+ mats.line.emissive.set(c.line).multiplyScalar(0.3); mats.eye.emissive.set(c.line).multiplyScalar(0.35);
150
+ mats.ridge.emissive.set(c.line).multiplyScalar(0.3); mats.hat.emissive.set(c.hat).multiplyScalar(0.42);
151
+ mats.face.emissive.set(c.fill).multiplyScalar(0.3);
152
+ }
153
+ setColors(opts.colors ?? FLO_3D_COLORS);
154
+
155
+ function setSize(next) { r = next; root.scale.setScalar(r); }
156
+ setSize(r);
157
+
158
+ // Turn a world direction into Flo's upright frame and return its heading about up (0 = facing +Z).
159
+ function headingOf(worldDir) {
160
+ inv.copy(root.quaternion).invert();
161
+ tmp2.copy(worldDir).applyQuaternion(inv);
162
+ return Math.atan2(tmp2.x, tmp2.z);
163
+ }
164
+
165
+ function placeAt(p) { hop = null; here.copy(p); root.position.copy(p); }
166
+
167
+ // Hop to a world point. A hop already under way finishes where Flo is now, so a second click mid-air turns
168
+ // it in the air rather than snapping it back.
169
+ // o.drop: fall straight onto the point under gravity (Flo arriving from above) instead of an arc.
170
+ function hopTo(p, onLand, now, o = {}) {
171
+ const from = hop ? root.position.clone() : here.clone();
172
+ const distR = from.distanceTo(p) / r;
173
+ if (distR < 0.05) { if (onLand) onLand(); return; }
174
+ if (reduced) { placeAt(p); landAt = now; if (onLand) onLand(); return; }
175
+ const { air, rise } = floHopShape(distR);
176
+ // a hop that starts mid-air skips the crouch
177
+ hop = o.drop
178
+ ? { from, to: p.clone(), t0: now, air: clamp(Math.sqrt(distR) * 0.16, 0.25, 0.7), rise: 0, drop: true, onLand, heading: lookYaw }
179
+ : { from, to: p.clone(), t0: now + (hop ? 0 : CROUCH_S), air, rise, onLand, heading: headingOf(tmp.copy(p).sub(from)) };
180
+ }
181
+
182
+ function sayHello(now) { if (!reduced) hello = now; }
183
+
184
+ // Advance to `now` (seconds) for this camera. Returns how soon Flo next changes: 0 while it is moving, the
185
+ // seconds to its next blink or glance while it is idle, Infinity when nothing will change on its own.
186
+ function tick(now, camera) {
187
+ let sx = 1, sy = 1, moving = false;
188
+ if (hop) {
189
+ const s = now - hop.t0;
190
+ const hp = hop.drop && s < hop.air ? { along: s < 0 ? 0 : (s / hop.air) ** 2, lift: 0, sx: 0.9, sy: 1.12 } : floHopPose(s, hop.air, hop.rise);
191
+ tmp.lerpVectors(hop.from, hop.to, hp.along);
192
+ root.position.copy(tmp).addScaledVector(up, hp.lift * r);
193
+ sx = hp.sx; sy = hp.sy;
194
+ // the shadow stays on the line between the two ends; falling, it waits on the landing point
195
+ const above = hop.drop ? (1 - hp.along) * hop.from.distanceTo(hop.to) / r : hp.lift;
196
+ shadow.position.y = 0.01 - above;
197
+ const fade = 1 / (1 + above * 0.6);
198
+ shadow.scale.setScalar(0.6 + 0.4 * fade); mats.shadow.opacity = 0.45 * fade;
199
+ if (s >= hop.air && !hop.landed) {
200
+ hop.landed = true; here.copy(hop.to); landAt = now;
201
+ const cb = hop.onLand; if (cb) cb();
202
+ }
203
+ if (s >= hop.air + LAND_S) { hop = null; root.position.copy(here); shadow.position.y = 0.01; }
204
+ moving = true;
205
+ } else { shadow.position.y = 0.01; shadow.scale.setScalar(1); mats.shadow.opacity = 0.45; }
206
+ squash.scale.set(sx, sy, sx);
207
+
208
+ // Face the camera, turning about up only: Flo stands upright on the model. In the air it faces where it is going.
209
+ if (camera) {
210
+ camera.getWorldPosition(tmp); tmp.sub(root.position);
211
+ faceYaw = headingOf(tmp);
212
+ }
213
+ const want = hop && now >= hop.t0 && now < hop.t0 + hop.air ? hop.heading : faceYaw;
214
+ let d = want - lookYaw; d = Math.atan2(Math.sin(d), Math.cos(d));
215
+ // turn by time, not by frame, so a 144 Hz screen turns Flo no faster than a 60 Hz one (~90% in 0.15 s)
216
+ const dt = lastTick == null ? 1 : clamp(now - lastTick, 0, 0.25); lastTick = now;
217
+ lookYaw = reduced ? want : lookYaw + d * (1 - Math.exp(-dt * 16));
218
+ body.rotation.y = lookYaw;
219
+ if (Math.abs(d) > 0.01 && !reduced) moving = true;
220
+
221
+ const saying = hello != null && now - hello < HELLO_S;
222
+ if (hello != null && !saying) hello = null;
223
+ const m = saying ? 'hello' : mood;
224
+ const t = reduced ? 0.6 : saying ? now - hello : now;
225
+ const p = pose({ r: 1, stroke: STROKE, mood: m, t, hat, seed });
226
+ applyFace(p);
227
+
228
+ const ru = clamp((now - landAt) / 0.5);
229
+ mats.ripple.opacity = ru < 1 && !reduced ? 0.3 * (1 - ru) : 0;
230
+ ripple.scale.setScalar(0.9 + ru * 1.4);
231
+ if (ru < 1 && !reduced) moving = true;
232
+
233
+ if (moving || saying || (!reduced && (m === 'thinking' || m === 'working' || m === 'yourcall'))) return 0;
234
+ if (reduced) return Infinity;
235
+ return nextChange(now);
236
+ }
237
+
238
+ function applyFace(p) {
239
+ const e = p.eyes;
240
+ for (const eye of eyes) {
241
+ eye.g.position.x = eye.sx * e.sep + e.dx * Math.sign(eye.g.position.z);
242
+ eye.g.position.y = -e.dy; // canvas y grows down
243
+ const arc = e.kind === 'arc';
244
+ eye.pill.visible = !arc; eye.arc.visible = arc;
245
+ if (arc) { eye.arc.scale.setScalar(e.w * 0.9); eye.arc.position.y = -e.h * 0.1; }
246
+ else {
247
+ const h = Math.max(e.h, e.w * 0.3);
248
+ // a capsule of radius 0.5 and length 1 is 2 tall and 1 wide
249
+ eye.pill.scale.set(e.w, h / 2, e.w * 0.55);
250
+ }
251
+ }
252
+ const h = p.hat;
253
+ hatPivot.visible = !!h;
254
+ if (h) {
255
+ hatPivot.rotation.z = -h.rot;
256
+ hatPivot.position.y = 0.8 - h.dy + h.lift * 2.2;
257
+ const a = 1 - clamp((h.lift - 0.5) / 0.5);
258
+ mats.hat.opacity = a; mats.ridge.opacity = a;
259
+ }
260
+ orbit.visible = !!p.orbit;
261
+ if (p.orbit) { orbit.geometry = orbitArc(p.orbit.len); orbit.rotation.z = -p.orbit.a - p.orbit.len; }
262
+ }
263
+
264
+ // The idle face changes only at a blink or a glance (flo.js: blink every 3.4 s at 1.6 s, glance every 1.5 s
265
+ // of a 5 s cycle), so between those the caller need not draw at all.
266
+ function nextChange(now) {
267
+ const cands = [];
268
+ const b = ((now + seed - 1.6) % 3.4 + 3.4) % 3.4; // seconds since the blink began
269
+ cands.push(b < 0.14 ? 0 : 3.4 - b);
270
+ const g = ((now % 5) + 5) % 5;
271
+ cands.push(g < 1.5 ? 1.5 - g : g < 3 ? 3 - g : g < 4.5 ? 4.5 - g : 5 - g);
272
+ return Math.max(0, Math.min(...cands));
273
+ }
274
+
275
+ function setMood(m) { mood = m; }
276
+ function setHat(on) { hat = !!on; }
277
+ function setReducedMotion(on) {
278
+ reduced = !!on;
279
+ if (on && hop) { const cb = hop.landed ? null : hop.onLand; placeAt(hop.to); if (cb) cb(); } // land now, and say so once
280
+ }
281
+ function isBusy() { return !!hop || hello != null; }
282
+
283
+ // Did the pointer hit Flo? The caller owns picking; this lets it give a click on Flo to Flo.
284
+ function hit(raycaster) {
285
+ const hits = raycaster.intersectObject(squash, true);
286
+ return hits.length > 0;
287
+ }
288
+
289
+ function dispose() {
290
+ root.removeFromParent();
291
+ for (const g of geos) g.dispose();
292
+ for (const m of Object.values(mats)) m.dispose();
293
+ shadowTex.dispose();
294
+ }
295
+
296
+ return {
297
+ object: root, body: squash, get r() { return r; }, get position() { return here; }, // body: Flo without its ground shadow
298
+ setColors, setSize, setMood, setHat, setReducedMotion, placeAt, hopTo, sayHello, tick, hit, isBusy, dispose,
299
+ get mood() { return mood; },
300
+ };
301
+ }
302
+
303
+ function radialTexture(THREE, stops) {
304
+ const n = 128, cv = document.createElement('canvas'); cv.width = cv.height = n;
305
+ const c = cv.getContext('2d'), g = c.createRadialGradient(n / 2, n / 2, 0, n / 2, n / 2, n / 2);
306
+ for (const [at, col] of stops) g.addColorStop(at, col);
307
+ c.fillStyle = g; c.fillRect(0, 0, n, n);
308
+ const tex = new THREE.CanvasTexture(cv); tex.colorSpace = THREE.SRGBColorSpace;
309
+ return tex;
310
+ }
@@ -0,0 +1,72 @@
1
+ // Flo's card on the steel model (3D): when Flo lands on a member, a small card beside Flo's head says what that
2
+ // member is. The person chooses which details it shows (3D toolbar → Labels → Flo); this decides what the card says
3
+ // from those choices and the member's already-formatted values, and nothing else. The 3D view draws it
4
+ // (web/steel-3d-view.js) and the editor supplies the values from its property registry (PROP_DEFS), so a value on
5
+ // the card is always the one Properties and the property labels show.
6
+ //
7
+ // The card's shape: a caption (type · mark), a headline (the profile), then one row per other detail. A detail the
8
+ // member has no value for is left out rather than printed as a dash, which would read as missing data.
9
+ //
10
+ // With several members selected the card speaks for the whole selection, as the Properties pane does: a detail
11
+ // they all share shows its value, one that differs shows Varies, and one none of them has is left out. The caption
12
+ // then leads with how many are selected, so the card is never read as being about the one member Flo stands on.
13
+ (function (root) {
14
+ // The details on offer, in the order the card shows them. Keys are PROP_DEFS keys.
15
+ const FLO_CARD_FIELDS = ['type', 'mark', 'profile', 'length', 'weight', 'col_tos', 'col_bos', 'tos_start', 'tos_end', 'verified', 'id'];
16
+ const FLO_CARD_DEFAULT = ['type', 'mark', 'profile', 'length', 'weight'];
17
+ const CAPTION = ['type', 'mark'];
18
+ const STORE_KEY = 'steel:floCard:v2';
19
+ const VARIES = 'Varies';
20
+
21
+ // A stored choice, kept to the details this build offers and in the card's own order. Anything that is not a
22
+ // list (nothing stored yet, or a damaged value) is the default; an empty list is a real choice (an empty card
23
+ // is simply not shown).
24
+ function sanitizeFloCardFields(v) {
25
+ if (!Array.isArray(v)) return FLO_CARD_DEFAULT.slice();
26
+ return FLO_CARD_FIELDS.filter((k) => v.includes(k));
27
+ }
28
+
29
+ function readFloCardFields(storage) {
30
+ try { const raw = storage && storage.getItem(STORE_KEY); return sanitizeFloCardFields(raw ? JSON.parse(raw) : null); }
31
+ catch { return FLO_CARD_DEFAULT.slice(); }
32
+ }
33
+
34
+ function writeFloCardFields(storage, fields) {
35
+ try { storage && storage.setItem(STORE_KEY, JSON.stringify(sanitizeFloCardFields(fields))); } catch { /* private mode: this page only */ }
36
+ }
37
+
38
+ // One detail across the selection, by the Properties pane's own rule (steel-editor.html propAggRow): each entry is
39
+ // the member's formatted text, or undefined where the detail does not apply to it. Returns the shared text,
40
+ // VARIES, or undefined when no member has a value (the card then leaves the detail out). A member with an empty
41
+ // value beside one with a value is a difference, as it is in the pane.
42
+ function aggregateFloCardValue(texts) {
43
+ const applicable = texts.filter((t) => t !== undefined);
44
+ const nonEmpty = [...new Set(applicable.filter((t) => t !== ''))];
45
+ if (!nonEmpty.length) return undefined;
46
+ return nonEmpty.length === 1 && applicable.every((t) => t === nonEmpty[0]) ? nonEmpty[0] : VARIES;
47
+ }
48
+
49
+ // values: { key: { label, text, varies? } } for the details the member (or the selection) HAS, text non-empty;
50
+ // count: how many members the card speaks for. Returns { caption, headline, headlineVaries, rows: [{ label,
51
+ // value, varies }] }, or null when nothing chosen has a value.
52
+ function floCardModel(values, fields, { count = 1 } = {}) {
53
+ const want = sanitizeFloCardFields(fields);
54
+ const has = (k) => want.includes(k) && values && values[k] && typeof values[k].text === 'string' && values[k].text !== '';
55
+ if (!want.some(has)) return null; // "3 selected" alone says nothing about the members
56
+ // In the caption a differing type or mark is simply not named: "3 selected" already says they are several.
57
+ const named = CAPTION.filter((k) => has(k) && !values[k].varies).map((k) => values[k].text);
58
+ const caption = [...(count > 1 ? [count + ' selected'] : []), ...named].join(' · ');
59
+ const rows = want.filter((k) => !CAPTION.includes(k) && k !== 'profile' && has(k))
60
+ .map((k) => ({ label: values[k].label, value: values[k].text, varies: !!values[k].varies }));
61
+ // No profile, no headline: a lone "25.0 ft" in large type would not say what it measures, so the rows keep
62
+ // their labels instead.
63
+ const headline = has('profile') ? values.profile.text : '';
64
+ const headlineVaries = has('profile') && !!values.profile.varies;
65
+ if (!caption && !headline && !rows.length) return null;
66
+ return { caption, headline, headlineVaries, rows };
67
+ }
68
+
69
+ const api = { FLO_CARD_FIELDS, FLO_CARD_DEFAULT, VARIES, sanitizeFloCardFields, readFloCardFields, writeFloCardFields, aggregateFloCardValue, floCardModel };
70
+ if (typeof module === 'object' && module.exports) module.exports = api;
71
+ else root.FloCard = api;
72
+ })(globalThis);