@guideai/react-native 0.3.0 → 0.7.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/index.cjs CHANGED
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const setup = require("./setup-Bl0ZLz8B.cjs");
3
+ const useConversations = require("./useConversations-CTbQBTz-.cjs");
4
4
  const jsxRuntime = require("react/jsx-runtime");
5
5
  const React = require("react");
6
- const useOnboarding = require("./useOnboarding-CFxofFst.cjs");
7
6
  function GuideAIScreen({
8
7
  name,
9
8
  path,
@@ -11,8 +10,8 @@ function GuideAIScreen({
11
10
  active = true,
12
11
  children
13
12
  }) {
14
- const runtime = setup.useGuideAIRuntime();
15
- const registry = React.useMemo(() => new setup.ScreenRegistry(), [name, path]);
13
+ const runtime = useConversations.useGuideAIRuntime();
14
+ const registry = React.useMemo(() => new useConversations.ScreenRegistry(), [name, path]);
16
15
  React.useEffect(() => {
17
16
  if (!active) return;
18
17
  runtime.setActiveScreen({ path, title: title != null ? title : name, registry });
@@ -23,10 +22,10 @@ function GuideAIScreen({
23
22
  }
24
23
  };
25
24
  }, [runtime, registry, path, title, name, active]);
26
- return /* @__PURE__ */ jsxRuntime.jsx(setup.RegistryContext.Provider, { value: registry, children });
25
+ return /* @__PURE__ */ jsxRuntime.jsx(useConversations.RegistryContext.Provider, { value: registry, children });
27
26
  }
28
27
  function useGuideAIElement(id, options) {
29
- const registry = setup.useScreenRegistry();
28
+ const registry = useConversations.useScreenRegistry();
30
29
  const handlers = React.useRef({});
31
30
  handlers.current = {
32
31
  press: options.press,
@@ -79,7 +78,7 @@ function useGuideAIElement(id, options) {
79
78
  canScrollTo
80
79
  ]);
81
80
  }
82
- const cut = (text, max = useOnboarding.LIMITS.text) => text.replace(/\s+/g, " ").trim().slice(0, max);
81
+ const cut = (text, max = useConversations.LIMITS.text) => text.replace(/\s+/g, " ").trim().slice(0, max);
83
82
  function minor(value, what) {
84
83
  if (!Number.isFinite(value) || value < 0) throw new RangeError(`${what} must be a number of zero or more.`);
85
84
  return Math.round(value * 100);
@@ -139,7 +138,7 @@ function feeBreakdown(input) {
139
138
  ["Paid", money(paid)],
140
139
  ...fees.map((fee) => [fee.label, `−${money(fee.minor)}`]),
141
140
  ["Received", money(received)]
142
- ].map((row) => row.map((cell) => cut(cell, useOnboarding.LIMITS.cell))),
141
+ ].map((row) => row.map((cell) => cut(cell, useConversations.LIMITS.cell))),
143
142
  at: [56, 56, 38],
144
143
  tone: "ink"
145
144
  },
@@ -147,7 +146,7 @@ function feeBreakdown(input) {
147
146
  ]
148
147
  }
149
148
  ];
150
- return { title: cut(input.title || "Where the money goes", useOnboarding.LIMITS.title), sample: input.sample === true, steps, art: { user: { icon: "user" } } };
149
+ return { title: cut(input.title || "Where the money goes", useConversations.LIMITS.title), sample: input.sample === true, steps, art: { user: { icon: "user" } } };
151
150
  }
152
151
  function processFlow(input) {
153
152
  const stages = input.steps.slice(0, 5);
@@ -161,13 +160,13 @@ function processFlow(input) {
161
160
  { kind: "text", id: `s${i}`, text: cut(stage.label, 16), at: [x + 1.5, 49], size: width < 18 ? "s" : "m", tone: "ink" }
162
161
  ];
163
162
  if (i > 0) draw.unshift({ kind: "ink", ink: "arrow", at: [x - gap + 0.5, 49], to: [x - 0.5, 49], tone: "blue" });
164
- return { say: cut(stage.say || stage.label, useOnboarding.LIMITS.say), clear: false, draw };
163
+ return { say: cut(stage.say || stage.label, useConversations.LIMITS.say), clear: false, draw };
165
164
  });
166
- return { title: cut(input.title, useOnboarding.LIMITS.title), sample: input.sample === true, steps, art: {} };
165
+ return { title: cut(input.title, useConversations.LIMITS.title), sample: input.sample === true, steps, art: {} };
167
166
  }
168
167
  function comparison(input) {
169
168
  const column = (side, x, key) => ({
170
- say: cut(`${side.name}: ${side.points.slice(0, 4).join(", ")}.`, useOnboarding.LIMITS.say),
169
+ say: cut(`${side.name}: ${side.points.slice(0, 4).join(", ")}.`, useConversations.LIMITS.say),
171
170
  clear: false,
172
171
  draw: [
173
172
  { kind: "text", id: `${key}h`, text: cut(side.name, 24), at: [x, 14], size: "l", tone: "blue" },
@@ -176,18 +175,19 @@ function comparison(input) {
176
175
  ]
177
176
  });
178
177
  const steps = [
179
- { say: cut(input.title, useOnboarding.LIMITS.say), clear: false, draw: [{ kind: "ink", ink: "line", at: [50, 8], to: [50, 88], tone: "ink" }] },
178
+ { say: cut(input.title, useConversations.LIMITS.say), clear: false, draw: [{ kind: "ink", ink: "line", at: [50, 8], to: [50, 88], tone: "ink" }] },
180
179
  column(input.left, 6, "l"),
181
180
  column(input.right, 56, "r")
182
181
  ];
183
- if (input.summary) steps.push({ say: cut(input.summary, useOnboarding.LIMITS.say), clear: false, draw: [] });
184
- return { title: cut(input.title, useOnboarding.LIMITS.title), sample: input.sample === true, steps, art: {} };
182
+ if (input.summary) steps.push({ say: cut(input.summary, useConversations.LIMITS.say), clear: false, draw: [] });
183
+ return { title: cut(input.title, useConversations.LIMITS.title), sample: input.sample === true, steps, art: {} };
185
184
  }
186
185
  const whiteboardLayouts = { feeBreakdown, processFlow, comparison, formatMoney };
187
- exports.GuideAI = setup.GuideAI;
188
- exports.useGuideAI = useOnboarding.useGuideAI;
189
- exports.useOnboarding = useOnboarding.useOnboarding;
190
- exports.useWhiteboard = useOnboarding.useWhiteboard;
186
+ exports.GuideAI = useConversations.GuideAI;
187
+ exports.useConversations = useConversations.useConversations;
188
+ exports.useGuideAI = useConversations.useGuideAI;
189
+ exports.useOnboarding = useConversations.useOnboarding;
190
+ exports.useWhiteboard = useConversations.useWhiteboard;
191
191
  exports.GuideAIScreen = GuideAIScreen;
192
192
  exports.useGuideAIElement = useGuideAIElement;
193
193
  exports.whiteboardLayouts = whiteboardLayouts;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/react/GuideAIScreen.tsx","../src/react/useGuideAIElement.ts","../../sdk/src/whiteboard/layouts.ts","../src/whiteboard/layouts.ts"],"sourcesContent":["// ============================================================\n// @guideai/react-native — screen declaration\n// ============================================================\n//\n// Wraps a screen once. Everything inside can then register itself with\n// useGuideAIElement() from any depth.\n//\n// Two identities per screen, and they are not interchangeable:\n//\n// path — \"/share\" what the mobile scanner emitted. Grounding on\n// the backend is EXACT STRING EQUALITY against\n// this, so a mismatch silently loses all\n// route-level knowledge for the screen.\n// name — \"ShareForm\" the React Navigation screen name, which is what\n// navigate() takes.\n//\n// Mixing them up produces no error — just an assistant that stops\n// knowing anything about the screen. Hence both are required.\n// ============================================================\n\nimport React, { useEffect, useMemo } from 'react';\nimport { RegistryContext, useGuideAIRuntime } from './context';\nimport { ScreenRegistry } from '../screen/screen-registry';\n\nexport interface GuideAIScreenProps {\n /** React Navigation screen name, e.g. \"ShareForm\". Used by navigate(). */\n name: string;\n /** Scanner route path, e.g. \"/share\". Used for grounding. */\n path: string;\n /** Human title shown to the model. Defaults to `name`. */\n title?: string;\n /**\n * Whether this screen is the one currently on top.\n *\n * Defaults to true. React Navigation keeps previous screens MOUNTED in\n * the stack, so without this a backgrounded screen would keep claiming\n * to be active and the model would be told about controls the user\n * cannot see. Hosts using React Navigation should pass\n * `useIsFocused()`.\n */\n active?: boolean;\n children: React.ReactNode;\n}\n\nexport function GuideAIScreen({\n name, path, title, active = true, children,\n}: GuideAIScreenProps): React.ReactElement {\n const runtime = useGuideAIRuntime();\n\n // One registry per mounted screen. Recreated only if the identity\n // changes, so elements registered by children survive re-renders.\n const registry = useMemo(() => new ScreenRegistry(), [name, path]);\n\n useEffect(() => {\n if (!active) return;\n\n runtime.setActiveScreen({ path, title: title ?? name, registry });\n\n return () => {\n // Only stand down if still the active screen. During a transition\n // the next screen's effect may run before this one's cleanup, and\n // clearing then would blank a screen that just became active.\n if (runtime.getActiveScreen()?.registry === registry) {\n runtime.setActiveScreen(undefined);\n }\n };\n }, [runtime, registry, path, title, name, active]);\n\n return (\n <RegistryContext.Provider value={registry}>\n {children}\n </RegistryContext.Provider>\n );\n}\n","// ============================================================\n// @guideai/react-native — element declaration hook\n// ============================================================\n//\n// The manual path: a component declares itself so the assistant can see\n// and act on it.\n//\n// KNOWN LIMIT, stated rather than hidden: this is per-element work. On a\n// screen with 200 controls that is 200 calls, and an element nobody\n// declares is INVISIBLE to the assistant — it does not degrade, it is\n// simply not there, with no warning and no failing test. Automatic\n// harvesting (instrumented components, accessibility props, static\n// extraction) is the intended answer and is being explored separately.\n// Until then this is the escape hatch, and it is honest about being one.\n// ============================================================\n\nimport { useEffect, useRef } from 'react';\nimport { useScreenRegistry } from './context';\nimport type { DeclaredElement, ElementHandlers } from '../screen/screen-registry';\n\nexport type UseGuideAIElementOptions =\n Omit<DeclaredElement, 'id'> & ElementHandlers;\n\n/**\n * Declare one element to the assistant.\n *\n * Registration is an effect, so it runs after mount and unwinds on\n * unmount. Handlers are kept in a ref and read through a stable wrapper:\n * without that, an inline `press={() => …}` would be a new function on\n * every render and re-register the element on every render with it.\n */\nexport function useGuideAIElement(\n id: string,\n options: UseGuideAIElementOptions,\n): void {\n const registry = useScreenRegistry();\n\n // Latest handlers, without making them a dependency of registration.\n const handlers = useRef<ElementHandlers>({});\n handlers.current = {\n press: options.press,\n setValue: options.setValue,\n scrollTo: options.scrollTo,\n };\n\n const {\n label, kind, value, accessibilityLabel, placeholder, hidden, sectionTitle,\n } = options;\n\n // WHICH capabilities exist must be part of registration, not just their\n // implementations. Always installing a wrapper would make every element\n // report itself as pressable, so `element_not_pressable` could never\n // fire and the model would be told a static label is a button.\n const canPress = Boolean(options.press);\n const canSetValue = Boolean(options.setValue);\n const canScrollTo = Boolean(options.scrollTo);\n\n useEffect(() => {\n if (!registry) return;\n\n // Stable indirection: the registry holds these for the element's\n // lifetime, and they read whatever the latest render supplied — so an\n // inline arrow function does not re-register on every render.\n const bound: ElementHandlers = {};\n if (canPress) bound.press = () => handlers.current.press?.();\n if (canSetValue) bound.setValue = (next: string) => handlers.current.setValue?.(next);\n if (canScrollTo) bound.scrollTo = () => handlers.current.scrollTo?.();\n\n return registry.register(\n { id, label, kind, value, accessibilityLabel, placeholder, hidden, sectionTitle },\n bound,\n );\n }, [\n registry, id, label, kind, value,\n accessibilityLabel, placeholder, hidden, sectionTitle,\n canPress, canSetValue, canScrollTo,\n ]);\n}\n","// ============================================================\n// @guideai/sdk — Whiteboard layouts: boards from the host's own data\n// ============================================================\n//\n// For figures that must be right — what a payment costs, what a customer\n// receives — the host builds the board from its own data and plays it\n// (`GuideAI.whiteboard.play(GuideAI.whiteboard.layouts.feeBreakdown(...))`).\n// No model sees the numbers and none writes them: the sums are done here,\n// in minor units, so the board can only show what the host's data says.\n\nimport type { BoardItem, BoardScene, BoardStep } from './scene';\nimport { LIMITS } from './scene';\n\nexport interface Money {\n /** ISO 4217 code (\"GBP\") or a symbol (\"£\"). */\n currency: string;\n /** Formatting locale; the browser's by default. */\n locale?: string;\n}\n\nexport interface FeeBreakdownInput extends Money {\n /** What the customer pays. */\n amount: number;\n /** Each deduction, in the order it is taken. */\n fees: { label: string; amount: number }[];\n title?: string;\n /** Example figures: the board is labelled as an example. */\n sample?: boolean;\n}\n\nconst cut = (text: string, max: number = LIMITS.text): string => text.replace(/\\s+/g, ' ').trim().slice(0, max);\n\nfunction minor(value: number, what: string): number {\n if (!Number.isFinite(value) || value < 0) throw new RangeError(`${what} must be a number of zero or more.`);\n return Math.round(value * 100);\n}\n\nexport function formatMoney(minorUnits: number, money: Money): string {\n const value = minorUnits / 100;\n if (/^[A-Z]{3}$/.test(money.currency)) {\n try {\n return new Intl.NumberFormat(money.locale, { style: 'currency', currency: money.currency }).format(value);\n } catch {\n // An unknown code falls through to the plain form.\n }\n }\n return `${money.currency}${value.toFixed(2)}`;\n}\n\n/** Amount paid → each fee taken → what is received, with the table to check it. */\nexport function feeBreakdown(input: FeeBreakdownInput): BoardScene {\n const paid = minor(input.amount, 'The amount');\n const fees = input.fees.slice(0, 4).map((fee, i) => ({ label: cut(fee.label || `Fee ${i + 1}`, 18), minor: minor(fee.amount, fee.label || 'A fee') }));\n const taken = fees.reduce((sum, fee) => sum + fee.minor, 0);\n if (taken > paid) throw new RangeError('The fees are more than the amount paid.');\n const received = paid - taken;\n const money = (m: number) => formatMoney(m, input);\n\n const feeItems: BoardItem[] = fees.flatMap((fee, i): BoardItem[] => [\n { kind: 'text', id: `fee${i}`, text: cut(`${fee.label} −${money(fee.minor)}`), at: [58, 18 + i * 9], size: 's', tone: 'red' },\n ]);\n const steps: BoardStep[] = [\n {\n say: `The customer pays ${money(paid)}.`,\n clear: false,\n draw: [\n { kind: 'art', id: 'payer', art: 'user', at: [4, 10, 12, 20], tone: 'ink' },\n { kind: 'text', id: 'paid', text: money(paid), at: [19, 20], size: 'l', tone: 'ink' },\n { kind: 'ink', ink: 'box', at: [17, 13, 26, 14], tone: 'ink' },\n ],\n },\n {\n say: fees.length === 1\n ? `${fees[0].label} of ${money(fees[0].minor)} is taken out.`\n : `${fees.length} fees are taken out: ${fees.map((f) => `${f.label}, ${money(f.minor)}`).join('; ')}.`,\n clear: false,\n draw: [{ kind: 'ink', ink: 'arrow', at: [44, 20], to: [56, 20], tone: 'red' }, ...feeItems],\n },\n {\n say: `So ${money(received)} is received.`,\n clear: false,\n draw: [\n { kind: 'ink', ink: 'arrow', at: [30, 29], to: [30, 45], tone: 'ink' },\n { kind: 'text', id: 'received', text: money(received), at: [19, 52], size: 'l', tone: 'green' },\n { kind: 'ink', ink: 'circle', at: [17, 46, 27, 12], tone: 'green' },\n ],\n },\n {\n say: 'Here it is all together.',\n clear: false,\n draw: [\n {\n kind: 'table',\n id: 'sum',\n rows: [\n ['Paid', money(paid)],\n ...fees.map((fee) => [fee.label, `−${money(fee.minor)}`]),\n ['Received', money(received)],\n ].map((row) => row.map((cell) => cut(cell, LIMITS.cell))),\n at: [56, 56, 38],\n tone: 'ink',\n },\n { kind: 'mark', mark: 'received' },\n ],\n },\n ];\n return { title: cut(input.title || 'Where the money goes', LIMITS.title), sample: input.sample === true, steps, art: { user: { icon: 'user' } } };\n}\n\n/** A few stages in a row, each boxed and joined to the next by an arrow. */\nexport function processFlow(input: { title: string; steps: { label: string; say?: string }[]; sample?: boolean }): BoardScene {\n const stages = input.steps.slice(0, 5);\n if (stages.length < 2) throw new RangeError('A process needs at least two steps.');\n const gap = 4;\n const width = (92 - gap * (stages.length - 1)) / stages.length;\n const steps: BoardStep[] = stages.map((stage, i) => {\n const x = 4 + i * (width + gap);\n const draw: BoardItem[] = [\n { kind: 'ink', ink: 'box', at: [x, 40, width, 18], tone: 'ink' },\n { kind: 'text', id: `s${i}`, text: cut(stage.label, 16), at: [x + 1.5, 49], size: width < 18 ? 's' : 'm', tone: 'ink' },\n ];\n if (i > 0) draw.unshift({ kind: 'ink', ink: 'arrow', at: [x - gap + 0.5, 49], to: [x - 0.5, 49], tone: 'blue' });\n return { say: cut(stage.say || stage.label, LIMITS.say), clear: false, draw };\n });\n return { title: cut(input.title, LIMITS.title), sample: input.sample === true, steps, art: {} };\n}\n\n/** Two options side by side, the points of each under its name. */\nexport function comparison(input: {\n title: string;\n left: { name: string; points: string[] };\n right: { name: string; points: string[] };\n summary?: string;\n sample?: boolean;\n}): BoardScene {\n const column = (side: { name: string; points: string[] }, x: number, key: string): BoardStep => ({\n say: cut(`${side.name}: ${side.points.slice(0, 4).join(', ')}.`, LIMITS.say),\n clear: false,\n draw: [\n { kind: 'text', id: `${key}h`, text: cut(side.name, 24), at: [x, 14], size: 'l', tone: 'blue' },\n { kind: 'ink', ink: 'underline', at: [x, 9, 36, 9], tone: 'blue' },\n ...side.points.slice(0, 4).map((point, i): BoardItem => ({ kind: 'text', text: cut(`• ${point}`, 34), at: [x, 32 + i * 12], size: 's', tone: 'ink' })),\n ],\n });\n const steps: BoardStep[] = [\n { say: cut(input.title, LIMITS.say), clear: false, draw: [{ kind: 'ink', ink: 'line', at: [50, 8], to: [50, 88], tone: 'ink' }] },\n column(input.left, 6, 'l'),\n column(input.right, 56, 'r'),\n ];\n if (input.summary) steps.push({ say: cut(input.summary, LIMITS.say), clear: false, draw: [] });\n return { title: cut(input.title, LIMITS.title), sample: input.sample === true, steps, art: {} };\n}\n","// Boards an app builds from its own data and plays with useWhiteboard().play:\n// the sums are done here, in minor units, and no model sees the figures.\nimport { comparison, feeBreakdown, formatMoney, processFlow } from '@guideai/whiteboard/layouts';\n\nexport const whiteboardLayouts = { feeBreakdown, processFlow, comparison, formatMoney };\n"],"names":["useGuideAIRuntime","useMemo","ScreenRegistry","useEffect","RegistryContext","useScreenRegistry","useRef","LIMITS"],"mappings":";;;;;;AA4CO,SAAS,cAAc;AAAA,EAC5B;AAAA,EAAM;AAAA,EAAM;AAAA,EAAO,SAAS;AAAA,EAAM;AACpC,GAA2C;AACzC,QAAM,UAAUA,MAAAA,kBAAA;AAIhB,QAAM,WAAWC,MAAAA,QAAQ,MAAM,IAAIC,MAAAA,kBAAkB,CAAC,MAAM,IAAI,CAAC;AAEjEC,QAAAA,UAAU,MAAM;AACd,QAAI,CAAC,OAAQ;AAEb,YAAQ,gBAAgB,EAAE,MAAM,OAAO,wBAAS,MAAM,UAAU;AAEhE,WAAO,MAAM;;AAIX,YAAI,aAAQ,sBAAR,mBAA2B,cAAa,UAAU;AACpD,gBAAQ,gBAAgB,MAAS;AAAA,MACnC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,SAAS,UAAU,MAAM,OAAO,MAAM,MAAM,CAAC;AAEjD,wCACGC,MAAAA,gBAAgB,UAAhB,EAAyB,OAAO,UAC9B,UACH;AAEJ;AC1CO,SAAS,kBACd,IACA,SACM;AACN,QAAM,WAAWC,MAAAA,kBAAA;AAGjB,QAAM,WAAWC,MAAAA,OAAwB,EAAE;AAC3C,WAAS,UAAU;AAAA,IACjB,OAAO,QAAQ;AAAA,IACf,UAAU,QAAQ;AAAA,IAClB,UAAU,QAAQ;AAAA,EAAA;AAGpB,QAAM;AAAA,IACJ;AAAA,IAAO;AAAA,IAAM;AAAA,IAAO;AAAA,IAAoB;AAAA,IAAa;AAAA,IAAQ;AAAA,E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AG;AAAA,EAAA;AAE7B,MAAI,MAAM,QAAS,OAAM,KAAK,EAAE,KAAK,IAAI,MAAM,SAASA,cAAAA,OAAO,GAAG,GAAG,OAAO,OAAO,MAAM,CAAA,GAAI;AAC7F,SAAO,EAAE,OAAO,IAAI,MAAM,OAAOA,cAAAA,OAAO,KAAK,GAAG,QAAQ,MAAM,WAAW,MAAM,OAAO,KAAK,CAAA,EAAC;AAC9F;ACnJO,MAAM,oBAAoB,EAAE,cAAc,aAAa,YAAY,YAAA;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/react/GuideAIScreen.tsx","../src/react/useGuideAIElement.ts","../../sdk/src/whiteboard/layouts.ts","../src/whiteboard/layouts.ts"],"sourcesContent":["// ============================================================\n// @guideai/react-native — screen declaration\n// ============================================================\n//\n// Wraps a screen once. Everything inside can then register itself with\n// useGuideAIElement() from any depth.\n//\n// Two identities per screen, and they are not interchangeable:\n//\n// path — \"/share\" what the mobile scanner emitted. Grounding on\n// the backend is EXACT STRING EQUALITY against\n// this, so a mismatch silently loses all\n// route-level knowledge for the screen.\n// name — \"ShareForm\" the React Navigation screen name, which is what\n// navigate() takes.\n//\n// Mixing them up produces no error — just an assistant that stops\n// knowing anything about the screen. Hence both are required.\n// ============================================================\n\nimport React, { useEffect, useMemo } from 'react';\nimport { RegistryContext, useGuideAIRuntime } from './context';\nimport { ScreenRegistry } from '../screen/screen-registry';\n\nexport interface GuideAIScreenProps {\n /** React Navigation screen name, e.g. \"ShareForm\". Used by navigate(). */\n name: string;\n /** Scanner route path, e.g. \"/share\". Used for grounding. */\n path: string;\n /** Human title shown to the model. Defaults to `name`. */\n title?: string;\n /**\n * Whether this screen is the one currently on top.\n *\n * Defaults to true. React Navigation keeps previous screens MOUNTED in\n * the stack, so without this a backgrounded screen would keep claiming\n * to be active and the model would be told about controls the user\n * cannot see. Hosts using React Navigation should pass\n * `useIsFocused()`.\n */\n active?: boolean;\n children: React.ReactNode;\n}\n\nexport function GuideAIScreen({\n name, path, title, active = true, children,\n}: GuideAIScreenProps): React.ReactElement {\n const runtime = useGuideAIRuntime();\n\n // One registry per mounted screen. Recreated only if the identity\n // changes, so elements registered by children survive re-renders.\n const registry = useMemo(() => new ScreenRegistry(), [name, path]);\n\n useEffect(() => {\n if (!active) return;\n\n runtime.setActiveScreen({ path, title: title ?? name, registry });\n\n return () => {\n // Only stand down if still the active screen. During a transition\n // the next screen's effect may run before this one's cleanup, and\n // clearing then would blank a screen that just became active.\n if (runtime.getActiveScreen()?.registry === registry) {\n runtime.setActiveScreen(undefined);\n }\n };\n }, [runtime, registry, path, title, name, active]);\n\n return (\n <RegistryContext.Provider value={registry}>\n {children}\n </RegistryContext.Provider>\n );\n}\n","// ============================================================\n// @guideai/react-native — element declaration hook\n// ============================================================\n//\n// The manual path: a component declares itself so the assistant can see\n// and act on it.\n//\n// KNOWN LIMIT, stated rather than hidden: this is per-element work. On a\n// screen with 200 controls that is 200 calls, and an element nobody\n// declares is INVISIBLE to the assistant — it does not degrade, it is\n// simply not there, with no warning and no failing test. Automatic\n// harvesting (instrumented components, accessibility props, static\n// extraction) is the intended answer and is being explored separately.\n// Until then this is the escape hatch, and it is honest about being one.\n// ============================================================\n\nimport { useEffect, useRef } from 'react';\nimport { useScreenRegistry } from './context';\nimport type { DeclaredElement, ElementHandlers } from '../screen/screen-registry';\n\nexport type UseGuideAIElementOptions =\n Omit<DeclaredElement, 'id'> & ElementHandlers;\n\n/**\n * Declare one element to the assistant.\n *\n * Registration is an effect, so it runs after mount and unwinds on\n * unmount. Handlers are kept in a ref and read through a stable wrapper:\n * without that, an inline `press={() => …}` would be a new function on\n * every render and re-register the element on every render with it.\n */\nexport function useGuideAIElement(\n id: string,\n options: UseGuideAIElementOptions,\n): void {\n const registry = useScreenRegistry();\n\n // Latest handlers, without making them a dependency of registration.\n const handlers = useRef<ElementHandlers>({});\n handlers.current = {\n press: options.press,\n setValue: options.setValue,\n scrollTo: options.scrollTo,\n };\n\n const {\n label, kind, value, accessibilityLabel, placeholder, hidden, sectionTitle,\n } = options;\n\n // WHICH capabilities exist must be part of registration, not just their\n // implementations. Always installing a wrapper would make every element\n // report itself as pressable, so `element_not_pressable` could never\n // fire and the model would be told a static label is a button.\n const canPress = Boolean(options.press);\n const canSetValue = Boolean(options.setValue);\n const canScrollTo = Boolean(options.scrollTo);\n\n useEffect(() => {\n if (!registry) return;\n\n // Stable indirection: the registry holds these for the element's\n // lifetime, and they read whatever the latest render supplied — so an\n // inline arrow function does not re-register on every render.\n const bound: ElementHandlers = {};\n if (canPress) bound.press = () => handlers.current.press?.();\n if (canSetValue) bound.setValue = (next: string) => handlers.current.setValue?.(next);\n if (canScrollTo) bound.scrollTo = () => handlers.current.scrollTo?.();\n\n return registry.register(\n { id, label, kind, value, accessibilityLabel, placeholder, hidden, sectionTitle },\n bound,\n );\n }, [\n registry, id, label, kind, value,\n accessibilityLabel, placeholder, hidden, sectionTitle,\n canPress, canSetValue, canScrollTo,\n ]);\n}\n","// ============================================================\n// @guideai/sdk — Whiteboard layouts: boards from the host's own data\n// ============================================================\n//\n// For figures that must be right — what a payment costs, what a customer\n// receives — the host builds the board from its own data and plays it\n// (`GuideAI.whiteboard.play(GuideAI.whiteboard.layouts.feeBreakdown(...))`).\n// No model sees the numbers and none writes them: the sums are done here,\n// in minor units, so the board can only show what the host's data says.\n\nimport type { BoardItem, BoardScene, BoardStep } from './scene';\nimport { LIMITS } from './scene';\n\nexport interface Money {\n /** ISO 4217 code (\"GBP\") or a symbol (\"£\"). */\n currency: string;\n /** Formatting locale; the browser's by default. */\n locale?: string;\n}\n\nexport interface FeeBreakdownInput extends Money {\n /** What the customer pays. */\n amount: number;\n /** Each deduction, in the order it is taken. */\n fees: { label: string; amount: number }[];\n title?: string;\n /** Example figures: the board is labelled as an example. */\n sample?: boolean;\n}\n\nconst cut = (text: string, max: number = LIMITS.text): string => text.replace(/\\s+/g, ' ').trim().slice(0, max);\n\nfunction minor(value: number, what: string): number {\n if (!Number.isFinite(value) || value < 0) throw new RangeError(`${what} must be a number of zero or more.`);\n return Math.round(value * 100);\n}\n\nexport function formatMoney(minorUnits: number, money: Money): string {\n const value = minorUnits / 100;\n if (/^[A-Z]{3}$/.test(money.currency)) {\n try {\n return new Intl.NumberFormat(money.locale, { style: 'currency', currency: money.currency }).format(value);\n } catch {\n // An unknown code falls through to the plain form.\n }\n }\n return `${money.currency}${value.toFixed(2)}`;\n}\n\n/** Amount paid → each fee taken → what is received, with the table to check it. */\nexport function feeBreakdown(input: FeeBreakdownInput): BoardScene {\n const paid = minor(input.amount, 'The amount');\n const fees = input.fees.slice(0, 4).map((fee, i) => ({ label: cut(fee.label || `Fee ${i + 1}`, 18), minor: minor(fee.amount, fee.label || 'A fee') }));\n const taken = fees.reduce((sum, fee) => sum + fee.minor, 0);\n if (taken > paid) throw new RangeError('The fees are more than the amount paid.');\n const received = paid - taken;\n const money = (m: number) => formatMoney(m, input);\n\n const feeItems: BoardItem[] = fees.flatMap((fee, i): BoardItem[] => [\n { kind: 'text', id: `fee${i}`, text: cut(`${fee.label} −${money(fee.minor)}`), at: [58, 18 + i * 9], size: 's', tone: 'red' },\n ]);\n const steps: BoardStep[] = [\n {\n say: `The customer pays ${money(paid)}.`,\n clear: false,\n draw: [\n { kind: 'art', id: 'payer', art: 'user', at: [4, 10, 12, 20], tone: 'ink' },\n { kind: 'text', id: 'paid', text: money(paid), at: [19, 20], size: 'l', tone: 'ink' },\n { kind: 'ink', ink: 'box', at: [17, 13, 26, 14], tone: 'ink' },\n ],\n },\n {\n say: fees.length === 1\n ? `${fees[0].label} of ${money(fees[0].minor)} is taken out.`\n : `${fees.length} fees are taken out: ${fees.map((f) => `${f.label}, ${money(f.minor)}`).join('; ')}.`,\n clear: false,\n draw: [{ kind: 'ink', ink: 'arrow', at: [44, 20], to: [56, 20], tone: 'red' }, ...feeItems],\n },\n {\n say: `So ${money(received)} is received.`,\n clear: false,\n draw: [\n { kind: 'ink', ink: 'arrow', at: [30, 29], to: [30, 45], tone: 'ink' },\n { kind: 'text', id: 'received', text: money(received), at: [19, 52], size: 'l', tone: 'green' },\n { kind: 'ink', ink: 'circle', at: [17, 46, 27, 12], tone: 'green' },\n ],\n },\n {\n say: 'Here it is all together.',\n clear: false,\n draw: [\n {\n kind: 'table',\n id: 'sum',\n rows: [\n ['Paid', money(paid)],\n ...fees.map((fee) => [fee.label, `−${money(fee.minor)}`]),\n ['Received', money(received)],\n ].map((row) => row.map((cell) => cut(cell, LIMITS.cell))),\n at: [56, 56, 38],\n tone: 'ink',\n },\n { kind: 'mark', mark: 'received' },\n ],\n },\n ];\n return { title: cut(input.title || 'Where the money goes', LIMITS.title), sample: input.sample === true, steps, art: { user: { icon: 'user' } } };\n}\n\n/** A few stages in a row, each boxed and joined to the next by an arrow. */\nexport function processFlow(input: { title: string; steps: { label: string; say?: string }[]; sample?: boolean }): BoardScene {\n const stages = input.steps.slice(0, 5);\n if (stages.length < 2) throw new RangeError('A process needs at least two steps.');\n const gap = 4;\n const width = (92 - gap * (stages.length - 1)) / stages.length;\n const steps: BoardStep[] = stages.map((stage, i) => {\n const x = 4 + i * (width + gap);\n const draw: BoardItem[] = [\n { kind: 'ink', ink: 'box', at: [x, 40, width, 18], tone: 'ink' },\n { kind: 'text', id: `s${i}`, text: cut(stage.label, 16), at: [x + 1.5, 49], size: width < 18 ? 's' : 'm', tone: 'ink' },\n ];\n if (i > 0) draw.unshift({ kind: 'ink', ink: 'arrow', at: [x - gap + 0.5, 49], to: [x - 0.5, 49], tone: 'blue' });\n return { say: cut(stage.say || stage.label, LIMITS.say), clear: false, draw };\n });\n return { title: cut(input.title, LIMITS.title), sample: input.sample === true, steps, art: {} };\n}\n\n/** Two options side by side, the points of each under its name. */\nexport function comparison(input: {\n title: string;\n left: { name: string; points: string[] };\n right: { name: string; points: string[] };\n summary?: string;\n sample?: boolean;\n}): BoardScene {\n const column = (side: { name: string; points: string[] }, x: number, key: string): BoardStep => ({\n say: cut(`${side.name}: ${side.points.slice(0, 4).join(', ')}.`, LIMITS.say),\n clear: false,\n draw: [\n { kind: 'text', id: `${key}h`, text: cut(side.name, 24), at: [x, 14], size: 'l', tone: 'blue' },\n { kind: 'ink', ink: 'underline', at: [x, 9, 36, 9], tone: 'blue' },\n ...side.points.slice(0, 4).map((point, i): BoardItem => ({ kind: 'text', text: cut(`• ${point}`, 34), at: [x, 32 + i * 12], size: 's', tone: 'ink' })),\n ],\n });\n const steps: BoardStep[] = [\n { say: cut(input.title, LIMITS.say), clear: false, draw: [{ kind: 'ink', ink: 'line', at: [50, 8], to: [50, 88], tone: 'ink' }] },\n column(input.left, 6, 'l'),\n column(input.right, 56, 'r'),\n ];\n if (input.summary) steps.push({ say: cut(input.summary, LIMITS.say), clear: false, draw: [] });\n return { title: cut(input.title, LIMITS.title), sample: input.sample === true, steps, art: {} };\n}\n","// Boards an app builds from its own data and plays with useWhiteboard().play:\n// the sums are done here, in minor units, and no model sees the figures.\nimport { comparison, feeBreakdown, formatMoney, processFlow } from '@guideai/whiteboard/layouts';\n\nexport const whiteboardLayouts = { feeBreakdown, processFlow, comparison, formatMoney };\n"],"names":["useGuideAIRuntime","useMemo","ScreenRegistry","useEffect","RegistryContext","useScreenRegistry","useRef","LIMITS"],"mappings":";;;;;AA4CO,SAAS,cAAc;AAAA,EAC5B;AAAA,EAAM;AAAA,EAAM;AAAA,EAAO,SAAS;AAAA,EAAM;AACpC,GAA2C;AACzC,QAAM,UAAUA,iBAAAA,kBAAA;AAIhB,QAAM,WAAWC,MAAAA,QAAQ,MAAM,IAAIC,iBAAAA,kBAAkB,CAAC,MAAM,IAAI,CAAC;AAEjEC,QAAAA,UAAU,MAAM;AACd,QAAI,CAAC,OAAQ;AAEb,YAAQ,gBAAgB,EAAE,MAAM,OAAO,wBAAS,MAAM,UAAU;AAEhE,WAAO,MAAM;;AAIX,YAAI,aAAQ,sBAAR,mBAA2B,cAAa,UAAU;AACpD,gBAAQ,gBAAgB,MAAS;AAAA,MACnC;AAAA,IACF;AAAA,EACF,GAAG,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AM,IAAI,KAAK,KAAK,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,KAAK,IAAI,EAAE,GAAG,MAAM,KAAK,MAAM,QAAQ;AAAA,IAAA;AAAA,EACvJ;AAEF,QAAM,QAAqB;AAAA,IACzB,EAAE,KAAK,IAAI,MAAM,OAAOA,iBAAAA,OAAO,GAAG,GAAG,OAAO,OAAO,MAAM,CAAC,EAAE,MAAM,OAAO,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,MAAM,MAAA,CAAO,EAAA;AAAA,IAC9H,OAAO,MAAM,MAAM,GAAG,GAAG;AAAA,IACzB,OAAO,MAAM,OAAO,IAAI,GAAG;AAAA,EAAA;AAE7B,MAAI,MAAM,QAAS,OAAM,KAAK,EAAE,KAAK,IAAI,MAAM,SAASA,iBAAAA,OAAO,GAAG,GAAG,OAAO,OAAO,MAAM,CAAA,GAAI;AAC7F,SAAO,EAAE,OAAO,IAAI,MAAM,OAAOA,iBAAAA,OAAO,KAAK,GAAG,QAAQ,MAAM,WAAW,MAAM,OAAO,KAAK,CAAA,EAAC;AAC9F;ACnJO,MAAM,oBAAoB,EAAE,cAAc,aAAa,YAAY,YAAA;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -829,6 +829,23 @@ interface NavigationRefLike {
829
829
  canGoBack?(): boolean;
830
830
  }
831
831
 
832
+ /** AsyncStorage's shape (@react-native-async-storage/async-storage), or any store like it. */
833
+ interface AsyncKeyValueStorage {
834
+ getItem(key: string): Promise<string | null>;
835
+ setItem(key: string, value: string): Promise<void>;
836
+ removeItem(key: string): Promise<void>;
837
+ getAllKeys(): Promise<readonly string[]>;
838
+ multiGet(keys: readonly string[]): Promise<ReadonlyArray<readonly [string, string | null]>>;
839
+ }
840
+
841
+ interface GuideAIConversation {
842
+ id: string;
843
+ /** The first thing the user asked, shortened. */
844
+ title: string;
845
+ /** Last activity, ms since epoch. */
846
+ updatedAt: number;
847
+ }
848
+
832
849
  interface GuideAIConfig {
833
850
  /**
834
851
  * The site's public token, from the dashboard. The only required
@@ -867,6 +884,12 @@ interface GuideAIConfig {
867
884
  * memory and resets on relaunch.
868
885
  */
869
886
  store?: SyncNativeStore;
887
+ /**
888
+ * AsyncStorage (@react-native-async-storage/async-storage), for apps
889
+ * without a sync store: conversations and chat history survive a
890
+ * relaunch. Ignored when `store` is given.
891
+ */
892
+ storage?: AsyncKeyValueStorage;
870
893
  /** The assistant's visible name in its own replies. */
871
894
  assistantName?: string;
872
895
  /**
@@ -913,12 +936,23 @@ interface GuideAIConfig {
913
936
  * example']. Change them with GuideAI.setFollowUps().
914
937
  */
915
938
  followUps?: string[];
939
+ /**
940
+ * How the assistant speaks: the whiteboard reads each step aloud with it.
941
+ * `createSpeech()` from '@guideai/react-native/voice' (expo-audio).
942
+ * Omitted: captions only.
943
+ */
944
+ speech?: GuideAISpeech;
916
945
  /**
917
946
  * Log the full conversation and every request. Development only —
918
947
  * it prints message content to the console.
919
948
  */
920
949
  debug?: boolean;
921
950
  }
951
+ /** Something that says a line aloud. `say` resolves when it finishes: true if it was heard. */
952
+ interface GuideAISpeech {
953
+ say(text: string): Promise<boolean>;
954
+ stop(): void;
955
+ }
922
956
  /** Short facts about the user: strings, numbers, booleans or short lists of them. */
923
957
  type GuideAIUserProfile = Record<string, string | number | boolean | Array<string | number>>;
924
958
  /**
@@ -1032,6 +1066,8 @@ interface GuideAIVoiceRecording {
1032
1066
  interface GuideAIVoiceResult {
1033
1067
  /** What was heard, already sent as the next message; null when nothing was. */
1034
1068
  text: string | null;
1069
+ /** The answer to it, as shown (Markdown); null when the turn failed. */
1070
+ answer?: string | null;
1035
1071
  /** Why nothing was sent, in words to show the user. */
1036
1072
  error?: string;
1037
1073
  }
@@ -1078,7 +1114,7 @@ interface UseGuideAIResult {
1078
1114
  * Ignores empty text and calls made while a turn is in flight, so a
1079
1115
  * host does not have to guard their send button.
1080
1116
  */
1081
- send(question?: string): Promise<void>;
1117
+ send(question?: string): Promise<string | null>;
1082
1118
  /** True from send() until the turn settles. Drives a disabled state. */
1083
1119
  busy: boolean;
1084
1120
  /** Whether `send()` would do anything right now. */
@@ -1087,7 +1123,7 @@ interface UseGuideAIResult {
1087
1123
  status: string | null;
1088
1124
  /** Re-send the last user message. Useful after a failed turn. */
1089
1125
  retry(): Promise<void>;
1090
- /** Drop the conversation and start over. */
1126
+ /** Start a new conversation. The current one stays in the chat history (useConversations). */
1091
1127
  clear(): void;
1092
1128
  /** Approve the message's `pendingAction`; the agent carries it out. */
1093
1129
  confirm(messageId: string): Promise<void>;
@@ -1130,6 +1166,20 @@ declare function useOnboarding(): {
1130
1166
  dismiss: () => Promise<void>;
1131
1167
  };
1132
1168
 
1169
+ interface UseConversationsResult {
1170
+ /** Saved conversations, newest first. The open one is included once it has a message. */
1171
+ conversations: GuideAIConversation[];
1172
+ /** The conversation useGuideAI() is showing. */
1173
+ activeId: string;
1174
+ /** Start an empty conversation; the current one stays in the list. */
1175
+ newConversation(): void;
1176
+ /** Show a saved conversation in useGuideAI(). */
1177
+ openConversation(id: string): void;
1178
+ /** Delete one. Deleting the open conversation starts an empty one. */
1179
+ deleteConversation(id: string): void;
1180
+ }
1181
+ declare function useConversations(): UseConversationsResult;
1182
+
1133
1183
  declare const INK_KINDS: readonly ["line", "arrow", "poly", "curve", "free", "oval", "corner", "arc", "dot", "circle", "box", "underline", "cross", "tick", "bracket"];
1134
1184
  /** How a point marks the real page. */
1135
1185
  declare const POINT_MARKS: readonly ["circle", "underline", "box"];
@@ -1145,6 +1195,11 @@ type BoardItem = {
1145
1195
  art: string;
1146
1196
  at: Box;
1147
1197
  tone: Tone;
1198
+ } | {
1199
+ kind: 'photo';
1200
+ id?: string;
1201
+ photo: string;
1202
+ at: Box;
1148
1203
  } | {
1149
1204
  kind: 'text';
1150
1205
  id?: string;
@@ -1189,6 +1244,13 @@ interface ArtInk {
1189
1244
  transform: string;
1190
1245
  contours: string[];
1191
1246
  }
1247
+ /** A real picture: our re-hosted copy, its shape, and the site it came from. */
1248
+ interface Photo {
1249
+ url: string;
1250
+ w: number;
1251
+ h: number;
1252
+ credit?: string;
1253
+ }
1192
1254
  interface BoardScene {
1193
1255
  /** 3: the even 160 x 100 grid. Absent (a host's board): 0-100 both ways. */
1194
1256
  v?: 2 | 3;
@@ -1200,6 +1262,8 @@ interface BoardScene {
1200
1262
  art: Record<string, {
1201
1263
  icon: string;
1202
1264
  } | ArtInk>;
1265
+ /** Real pictures by description. Absent on boards built before photos. */
1266
+ photos?: Record<string, Photo>;
1203
1267
  }
1204
1268
 
1205
1269
  type WhiteboardStatus = 'closed' | 'loading' | 'playing' | 'error';
@@ -1277,5 +1341,5 @@ declare const whiteboardLayouts: {
1277
1341
  formatMoney: typeof formatMoney;
1278
1342
  };
1279
1343
 
1280
- export { GuideAI, GuideAIScreen, useGuideAI, useGuideAIElement, useOnboarding, useWhiteboard, whiteboardLayouts };
1281
- export type { AuthTokenGetter, DeclaredElement, ElementHandlers, GuideAIConfig, HeadlessImage as GuideAIImage, GuideAIMessage, GuideAIScreenProps, GuideAIUserProfile, GuideAIVoiceRecording, GuideAIVoiceResult, NavigationRefLike, OnboardingState, OnboardingStepState, RequestHeadersGetter, SyncNativeStore, UseGuideAIElementOptions, UseGuideAIResult, UseWhiteboardResult, WhiteboardState, WhiteboardStatus };
1344
+ export { GuideAI, GuideAIScreen, useConversations, useGuideAI, useGuideAIElement, useOnboarding, useWhiteboard, whiteboardLayouts };
1345
+ export type { AsyncKeyValueStorage, AuthTokenGetter, DeclaredElement, ElementHandlers, GuideAIConfig, GuideAIConversation, HeadlessImage as GuideAIImage, GuideAIMessage, GuideAIScreenProps, GuideAISpeech, GuideAIUserProfile, GuideAIVoiceRecording, GuideAIVoiceResult, NavigationRefLike, OnboardingState, OnboardingStepState, RequestHeadersGetter, SyncNativeStore, UseConversationsResult, UseGuideAIElementOptions, UseGuideAIResult, UseWhiteboardResult, WhiteboardState, WhiteboardStatus };
package/dist/index.mjs CHANGED
@@ -1,9 +1,7 @@
1
- import { u as useGuideAIRuntime, S as ScreenRegistry, R as RegistryContext, a as useScreenRegistry } from "./setup-CkXajERE.js";
2
- import { G } from "./setup-CkXajERE.js";
1
+ import { u as useGuideAIRuntime, S as ScreenRegistry, R as RegistryContext, a as useScreenRegistry, L as LIMITS } from "./useConversations-B_7km_uH.js";
2
+ import { G, b, c, d, e } from "./useConversations-B_7km_uH.js";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import { useMemo, useEffect, useRef } from "react";
5
- import { L as LIMITS } from "./useOnboarding-BAKQq8T_.js";
6
- import { u, a, b } from "./useOnboarding-BAKQq8T_.js";
7
5
  function GuideAIScreen({
8
6
  name,
9
7
  path,
@@ -187,10 +185,11 @@ const whiteboardLayouts = { feeBreakdown, processFlow, comparison, formatMoney }
187
185
  export {
188
186
  G as GuideAI,
189
187
  GuideAIScreen,
190
- u as useGuideAI,
188
+ b as useConversations,
189
+ c as useGuideAI,
191
190
  useGuideAIElement,
192
- a as useOnboarding,
193
- b as useWhiteboard,
191
+ d as useOnboarding,
192
+ e as useWhiteboard,
194
193
  whiteboardLayouts
195
194
  };
196
195
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/react/GuideAIScreen.tsx","../src/react/useGuideAIElement.ts","../../sdk/src/whiteboard/layouts.ts","../src/whiteboard/layouts.ts"],"sourcesContent":["// ============================================================\n// @guideai/react-native — screen declaration\n// ============================================================\n//\n// Wraps a screen once. Everything inside can then register itself with\n// useGuideAIElement() from any depth.\n//\n// Two identities per screen, and they are not interchangeable:\n//\n// path — \"/share\" what the mobile scanner emitted. Grounding on\n// the backend is EXACT STRING EQUALITY against\n// this, so a mismatch silently loses all\n// route-level knowledge for the screen.\n// name — \"ShareForm\" the React Navigation screen name, which is what\n// navigate() takes.\n//\n// Mixing them up produces no error — just an assistant that stops\n// knowing anything about the screen. Hence both are required.\n// ============================================================\n\nimport React, { useEffect, useMemo } from 'react';\nimport { RegistryContext, useGuideAIRuntime } from './context';\nimport { ScreenRegistry } from '../screen/screen-registry';\n\nexport interface GuideAIScreenProps {\n /** React Navigation screen name, e.g. \"ShareForm\". Used by navigate(). */\n name: string;\n /** Scanner route path, e.g. \"/share\". Used for grounding. */\n path: string;\n /** Human title shown to the model. Defaults to `name`. */\n title?: string;\n /**\n * Whether this screen is the one currently on top.\n *\n * Defaults to true. React Navigation keeps previous screens MOUNTED in\n * the stack, so without this a backgrounded screen would keep claiming\n * to be active and the model would be told about controls the user\n * cannot see. Hosts using React Navigation should pass\n * `useIsFocused()`.\n */\n active?: boolean;\n children: React.ReactNode;\n}\n\nexport function GuideAIScreen({\n name, path, title, active = true, children,\n}: GuideAIScreenProps): React.ReactElement {\n const runtime = useGuideAIRuntime();\n\n // One registry per mounted screen. Recreated only if the identity\n // changes, so elements registered by children survive re-renders.\n const registry = useMemo(() => new ScreenRegistry(), [name, path]);\n\n useEffect(() => {\n if (!active) return;\n\n runtime.setActiveScreen({ path, title: title ?? name, registry });\n\n return () => {\n // Only stand down if still the active screen. During a transition\n // the next screen's effect may run before this one's cleanup, and\n // clearing then would blank a screen that just became active.\n if (runtime.getActiveScreen()?.registry === registry) {\n runtime.setActiveScreen(undefined);\n }\n };\n }, [runtime, registry, path, title, name, active]);\n\n return (\n <RegistryContext.Provider value={registry}>\n {children}\n </RegistryContext.Provider>\n );\n}\n","// ============================================================\n// @guideai/react-native — element declaration hook\n// ============================================================\n//\n// The manual path: a component declares itself so the assistant can see\n// and act on it.\n//\n// KNOWN LIMIT, stated rather than hidden: this is per-element work. On a\n// screen with 200 controls that is 200 calls, and an element nobody\n// declares is INVISIBLE to the assistant — it does not degrade, it is\n// simply not there, with no warning and no failing test. Automatic\n// harvesting (instrumented components, accessibility props, static\n// extraction) is the intended answer and is being explored separately.\n// Until then this is the escape hatch, and it is honest about being one.\n// ============================================================\n\nimport { useEffect, useRef } from 'react';\nimport { useScreenRegistry } from './context';\nimport type { DeclaredElement, ElementHandlers } from '../screen/screen-registry';\n\nexport type UseGuideAIElementOptions =\n Omit<DeclaredElement, 'id'> & ElementHandlers;\n\n/**\n * Declare one element to the assistant.\n *\n * Registration is an effect, so it runs after mount and unwinds on\n * unmount. Handlers are kept in a ref and read through a stable wrapper:\n * without that, an inline `press={() => …}` would be a new function on\n * every render and re-register the element on every render with it.\n */\nexport function useGuideAIElement(\n id: string,\n options: UseGuideAIElementOptions,\n): void {\n const registry = useScreenRegistry();\n\n // Latest handlers, without making them a dependency of registration.\n const handlers = useRef<ElementHandlers>({});\n handlers.current = {\n press: options.press,\n setValue: options.setValue,\n scrollTo: options.scrollTo,\n };\n\n const {\n label, kind, value, accessibilityLabel, placeholder, hidden, sectionTitle,\n } = options;\n\n // WHICH capabilities exist must be part of registration, not just their\n // implementations. Always installing a wrapper would make every element\n // report itself as pressable, so `element_not_pressable` could never\n // fire and the model would be told a static label is a button.\n const canPress = Boolean(options.press);\n const canSetValue = Boolean(options.setValue);\n const canScrollTo = Boolean(options.scrollTo);\n\n useEffect(() => {\n if (!registry) return;\n\n // Stable indirection: the registry holds these for the element's\n // lifetime, and they read whatever the latest render supplied — so an\n // inline arrow function does not re-register on every render.\n const bound: ElementHandlers = {};\n if (canPress) bound.press = () => handlers.current.press?.();\n if (canSetValue) bound.setValue = (next: string) => handlers.current.setValue?.(next);\n if (canScrollTo) bound.scrollTo = () => handlers.current.scrollTo?.();\n\n return registry.register(\n { id, label, kind, value, accessibilityLabel, placeholder, hidden, sectionTitle },\n bound,\n );\n }, [\n registry, id, label, kind, value,\n accessibilityLabel, placeholder, hidden, sectionTitle,\n canPress, canSetValue, canScrollTo,\n ]);\n}\n","// ============================================================\n// @guideai/sdk — Whiteboard layouts: boards from the host's own data\n// ============================================================\n//\n// For figures that must be right — what a payment costs, what a customer\n// receives — the host builds the board from its own data and plays it\n// (`GuideAI.whiteboard.play(GuideAI.whiteboard.layouts.feeBreakdown(...))`).\n// No model sees the numbers and none writes them: the sums are done here,\n// in minor units, so the board can only show what the host's data says.\n\nimport type { BoardItem, BoardScene, BoardStep } from './scene';\nimport { LIMITS } from './scene';\n\nexport interface Money {\n /** ISO 4217 code (\"GBP\") or a symbol (\"£\"). */\n currency: string;\n /** Formatting locale; the browser's by default. */\n locale?: string;\n}\n\nexport interface FeeBreakdownInput extends Money {\n /** What the customer pays. */\n amount: number;\n /** Each deduction, in the order it is taken. */\n fees: { label: string; amount: number }[];\n title?: string;\n /** Example figures: the board is labelled as an example. */\n sample?: boolean;\n}\n\nconst cut = (text: string, max: number = LIMITS.text): string => text.replace(/\\s+/g, ' ').trim().slice(0, max);\n\nfunction minor(value: number, what: string): number {\n if (!Number.isFinite(value) || value < 0) throw new RangeError(`${what} must be a number of zero or more.`);\n return Math.round(value * 100);\n}\n\nexport function formatMoney(minorUnits: number, money: Money): string {\n const value = minorUnits / 100;\n if (/^[A-Z]{3}$/.test(money.currency)) {\n try {\n return new Intl.NumberFormat(money.locale, { style: 'currency', currency: money.currency }).format(value);\n } catch {\n // An unknown code falls through to the plain form.\n }\n }\n return `${money.currency}${value.toFixed(2)}`;\n}\n\n/** Amount paid → each fee taken → what is received, with the table to check it. */\nexport function feeBreakdown(input: FeeBreakdownInput): BoardScene {\n const paid = minor(input.amount, 'The amount');\n const fees = input.fees.slice(0, 4).map((fee, i) => ({ label: cut(fee.label || `Fee ${i + 1}`, 18), minor: minor(fee.amount, fee.label || 'A fee') }));\n const taken = fees.reduce((sum, fee) => sum + fee.minor, 0);\n if (taken > paid) throw new RangeError('The fees are more than the amount paid.');\n const received = paid - taken;\n const money = (m: number) => formatMoney(m, input);\n\n const feeItems: BoardItem[] = fees.flatMap((fee, i): BoardItem[] => [\n { kind: 'text', id: `fee${i}`, text: cut(`${fee.label} −${money(fee.minor)}`), at: [58, 18 + i * 9], size: 's', tone: 'red' },\n ]);\n const steps: BoardStep[] = [\n {\n say: `The customer pays ${money(paid)}.`,\n clear: false,\n draw: [\n { kind: 'art', id: 'payer', art: 'user', at: [4, 10, 12, 20], tone: 'ink' },\n { kind: 'text', id: 'paid', text: money(paid), at: [19, 20], size: 'l', tone: 'ink' },\n { kind: 'ink', ink: 'box', at: [17, 13, 26, 14], tone: 'ink' },\n ],\n },\n {\n say: fees.length === 1\n ? `${fees[0].label} of ${money(fees[0].minor)} is taken out.`\n : `${fees.length} fees are taken out: ${fees.map((f) => `${f.label}, ${money(f.minor)}`).join('; ')}.`,\n clear: false,\n draw: [{ kind: 'ink', ink: 'arrow', at: [44, 20], to: [56, 20], tone: 'red' }, ...feeItems],\n },\n {\n say: `So ${money(received)} is received.`,\n clear: false,\n draw: [\n { kind: 'ink', ink: 'arrow', at: [30, 29], to: [30, 45], tone: 'ink' },\n { kind: 'text', id: 'received', text: money(received), at: [19, 52], size: 'l', tone: 'green' },\n { kind: 'ink', ink: 'circle', at: [17, 46, 27, 12], tone: 'green' },\n ],\n },\n {\n say: 'Here it is all together.',\n clear: false,\n draw: [\n {\n kind: 'table',\n id: 'sum',\n rows: [\n ['Paid', money(paid)],\n ...fees.map((fee) => [fee.label, `−${money(fee.minor)}`]),\n ['Received', money(received)],\n ].map((row) => row.map((cell) => cut(cell, LIMITS.cell))),\n at: [56, 56, 38],\n tone: 'ink',\n },\n { kind: 'mark', mark: 'received' },\n ],\n },\n ];\n return { title: cut(input.title || 'Where the money goes', LIMITS.title), sample: input.sample === true, steps, art: { user: { icon: 'user' } } };\n}\n\n/** A few stages in a row, each boxed and joined to the next by an arrow. */\nexport function processFlow(input: { title: string; steps: { label: string; say?: string }[]; sample?: boolean }): BoardScene {\n const stages = input.steps.slice(0, 5);\n if (stages.length < 2) throw new RangeError('A process needs at least two steps.');\n const gap = 4;\n const width = (92 - gap * (stages.length - 1)) / stages.length;\n const steps: BoardStep[] = stages.map((stage, i) => {\n const x = 4 + i * (width + gap);\n const draw: BoardItem[] = [\n { kind: 'ink', ink: 'box', at: [x, 40, width, 18], tone: 'ink' },\n { kind: 'text', id: `s${i}`, text: cut(stage.label, 16), at: [x + 1.5, 49], size: width < 18 ? 's' : 'm', tone: 'ink' },\n ];\n if (i > 0) draw.unshift({ kind: 'ink', ink: 'arrow', at: [x - gap + 0.5, 49], to: [x - 0.5, 49], tone: 'blue' });\n return { say: cut(stage.say || stage.label, LIMITS.say), clear: false, draw };\n });\n return { title: cut(input.title, LIMITS.title), sample: input.sample === true, steps, art: {} };\n}\n\n/** Two options side by side, the points of each under its name. */\nexport function comparison(input: {\n title: string;\n left: { name: string; points: string[] };\n right: { name: string; points: string[] };\n summary?: string;\n sample?: boolean;\n}): BoardScene {\n const column = (side: { name: string; points: string[] }, x: number, key: string): BoardStep => ({\n say: cut(`${side.name}: ${side.points.slice(0, 4).join(', ')}.`, LIMITS.say),\n clear: false,\n draw: [\n { kind: 'text', id: `${key}h`, text: cut(side.name, 24), at: [x, 14], size: 'l', tone: 'blue' },\n { kind: 'ink', ink: 'underline', at: [x, 9, 36, 9], tone: 'blue' },\n ...side.points.slice(0, 4).map((point, i): BoardItem => ({ kind: 'text', text: cut(`• ${point}`, 34), at: [x, 32 + i * 12], size: 's', tone: 'ink' })),\n ],\n });\n const steps: BoardStep[] = [\n { say: cut(input.title, LIMITS.say), clear: false, draw: [{ kind: 'ink', ink: 'line', at: [50, 8], to: [50, 88], tone: 'ink' }] },\n column(input.left, 6, 'l'),\n column(input.right, 56, 'r'),\n ];\n if (input.summary) steps.push({ say: cut(input.summary, LIMITS.say), clear: false, draw: [] });\n return { title: cut(input.title, LIMITS.title), sample: input.sample === true, steps, art: {} };\n}\n","// Boards an app builds from its own data and plays with useWhiteboard().play:\n// the sums are done here, in minor units, and no model sees the figures.\nimport { comparison, feeBreakdown, formatMoney, processFlow } from '@guideai/whiteboard/layouts';\n\nexport const whiteboardLayouts = { feeBreakdown, processFlow, comparison, formatMoney };\n"],"names":[],"mappings":";;;;;;AA4CO,SAAS,cAAc;AAAA,EAC5B;AAAA,EAAM;AAAA,EAAM;AAAA,EAAO,SAAS;AAAA,EAAM;AACpC,GAA2C;AACzC,QAAM,UAA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AE,GAAG,MAAM,KAAK,MAAM,OAAA;AAAA,MACvF,EAAE,MAAM,OAAO,KAAK,aAAa,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,MAAM,OAAA;AAAA,MAC1D,GAAG,KAAK,OAAO,MAAM,GAAG,CAAC,EAAE,IAAI,CAAC,OAAO,OAAkB,EAAE,MAAM,QAAQ,MAAM,IAAI,KAAK,KAAK,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,KAAK,IAAI,EAAE,GAAG,MAAM,KAAK,MAAM,QAAQ;AAAA,IAAA;AAAA,EACvJ;AAEF,QAAM,QAAqB;AAAA,IACzB,EAAE,KAAK,IAAI,MAAM,OAAO,OAAO,GAAG,GAAG,OAAO,OAAO,MAAM,CAAC,EAAE,MAAM,OAAO,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,MAAM,MAAA,CAAO,EAAA;AAAA,IAC9H,OAAO,MAAM,MAAM,GAAG,GAAG;AAAA,IACzB,OAAO,MAAM,OAAO,IAAI,GAAG;AAAA,EAAA;AAE7B,MAAI,MAAM,QAAS,OAAM,KAAK,EAAE,KAAK,IAAI,MAAM,SAAS,OAAO,GAAG,GAAG,OAAO,OAAO,MAAM,CAAA,GAAI;AAC7F,SAAO,EAAE,OAAO,IAAI,MAAM,OAAO,OAAO,KAAK,GAAG,QAAQ,MAAM,WAAW,MAAM,OAAO,KAAK,CAAA,EAAC;AAC9F;ACnJO,MAAM,oBAAoB,EAAE,cAAc,aAAa,YAAY,YAAA;"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/react/GuideAIScreen.tsx","../src/react/useGuideAIElement.ts","../../sdk/src/whiteboard/layouts.ts","../src/whiteboard/layouts.ts"],"sourcesContent":["// ============================================================\n// @guideai/react-native — screen declaration\n// ============================================================\n//\n// Wraps a screen once. Everything inside can then register itself with\n// useGuideAIElement() from any depth.\n//\n// Two identities per screen, and they are not interchangeable:\n//\n// path — \"/share\" what the mobile scanner emitted. Grounding on\n// the backend is EXACT STRING EQUALITY against\n// this, so a mismatch silently loses all\n// route-level knowledge for the screen.\n// name — \"ShareForm\" the React Navigation screen name, which is what\n// navigate() takes.\n//\n// Mixing them up produces no error — just an assistant that stops\n// knowing anything about the screen. Hence both are required.\n// ============================================================\n\nimport React, { useEffect, useMemo } from 'react';\nimport { RegistryContext, useGuideAIRuntime } from './context';\nimport { ScreenRegistry } from '../screen/screen-registry';\n\nexport interface GuideAIScreenProps {\n /** React Navigation screen name, e.g. \"ShareForm\". Used by navigate(). */\n name: string;\n /** Scanner route path, e.g. \"/share\". Used for grounding. */\n path: string;\n /** Human title shown to the model. Defaults to `name`. */\n title?: string;\n /**\n * Whether this screen is the one currently on top.\n *\n * Defaults to true. React Navigation keeps previous screens MOUNTED in\n * the stack, so without this a backgrounded screen would keep claiming\n * to be active and the model would be told about controls the user\n * cannot see. Hosts using React Navigation should pass\n * `useIsFocused()`.\n */\n active?: boolean;\n children: React.ReactNode;\n}\n\nexport function GuideAIScreen({\n name, path, title, active = true, children,\n}: GuideAIScreenProps): React.ReactElement {\n const runtime = useGuideAIRuntime();\n\n // One registry per mounted screen. Recreated only if the identity\n // changes, so elements registered by children survive re-renders.\n const registry = useMemo(() => new ScreenRegistry(), [name, path]);\n\n useEffect(() => {\n if (!active) return;\n\n runtime.setActiveScreen({ path, title: title ?? name, registry });\n\n return () => {\n // Only stand down if still the active screen. During a transition\n // the next screen's effect may run before this one's cleanup, and\n // clearing then would blank a screen that just became active.\n if (runtime.getActiveScreen()?.registry === registry) {\n runtime.setActiveScreen(undefined);\n }\n };\n }, [runtime, registry, path, title, name, active]);\n\n return (\n <RegistryContext.Provider value={registry}>\n {children}\n </RegistryContext.Provider>\n );\n}\n","// ============================================================\n// @guideai/react-native — element declaration hook\n// ============================================================\n//\n// The manual path: a component declares itself so the assistant can see\n// and act on it.\n//\n// KNOWN LIMIT, stated rather than hidden: this is per-element work. On a\n// screen with 200 controls that is 200 calls, and an element nobody\n// declares is INVISIBLE to the assistant — it does not degrade, it is\n// simply not there, with no warning and no failing test. Automatic\n// harvesting (instrumented components, accessibility props, static\n// extraction) is the intended answer and is being explored separately.\n// Until then this is the escape hatch, and it is honest about being one.\n// ============================================================\n\nimport { useEffect, useRef } from 'react';\nimport { useScreenRegistry } from './context';\nimport type { DeclaredElement, ElementHandlers } from '../screen/screen-registry';\n\nexport type UseGuideAIElementOptions =\n Omit<DeclaredElement, 'id'> & ElementHandlers;\n\n/**\n * Declare one element to the assistant.\n *\n * Registration is an effect, so it runs after mount and unwinds on\n * unmount. Handlers are kept in a ref and read through a stable wrapper:\n * without that, an inline `press={() => …}` would be a new function on\n * every render and re-register the element on every render with it.\n */\nexport function useGuideAIElement(\n id: string,\n options: UseGuideAIElementOptions,\n): void {\n const registry = useScreenRegistry();\n\n // Latest handlers, without making them a dependency of registration.\n const handlers = useRef<ElementHandlers>({});\n handlers.current = {\n press: options.press,\n setValue: options.setValue,\n scrollTo: options.scrollTo,\n };\n\n const {\n label, kind, value, accessibilityLabel, placeholder, hidden, sectionTitle,\n } = options;\n\n // WHICH capabilities exist must be part of registration, not just their\n // implementations. Always installing a wrapper would make every element\n // report itself as pressable, so `element_not_pressable` could never\n // fire and the model would be told a static label is a button.\n const canPress = Boolean(options.press);\n const canSetValue = Boolean(options.setValue);\n const canScrollTo = Boolean(options.scrollTo);\n\n useEffect(() => {\n if (!registry) return;\n\n // Stable indirection: the registry holds these for the element's\n // lifetime, and they read whatever the latest render supplied — so an\n // inline arrow function does not re-register on every render.\n const bound: ElementHandlers = {};\n if (canPress) bound.press = () => handlers.current.press?.();\n if (canSetValue) bound.setValue = (next: string) => handlers.current.setValue?.(next);\n if (canScrollTo) bound.scrollTo = () => handlers.current.scrollTo?.();\n\n return registry.register(\n { id, label, kind, value, accessibilityLabel, placeholder, hidden, sectionTitle },\n bound,\n );\n }, [\n registry, id, label, kind, value,\n accessibilityLabel, placeholder, hidden, sectionTitle,\n canPress, canSetValue, canScrollTo,\n ]);\n}\n","// ============================================================\n// @guideai/sdk — Whiteboard layouts: boards from the host's own data\n// ============================================================\n//\n// For figures that must be right — what a payment costs, what a customer\n// receives — the host builds the board from its own data and plays it\n// (`GuideAI.whiteboard.play(GuideAI.whiteboard.layouts.feeBreakdown(...))`).\n// No model sees the numbers and none writes them: the sums are done here,\n// in minor units, so the board can only show what the host's data says.\n\nimport type { BoardItem, BoardScene, BoardStep } from './scene';\nimport { LIMITS } from './scene';\n\nexport interface Money {\n /** ISO 4217 code (\"GBP\") or a symbol (\"£\"). */\n currency: string;\n /** Formatting locale; the browser's by default. */\n locale?: string;\n}\n\nexport interface FeeBreakdownInput extends Money {\n /** What the customer pays. */\n amount: number;\n /** Each deduction, in the order it is taken. */\n fees: { label: string; amount: number }[];\n title?: string;\n /** Example figures: the board is labelled as an example. */\n sample?: boolean;\n}\n\nconst cut = (text: string, max: number = LIMITS.text): string => text.replace(/\\s+/g, ' ').trim().slice(0, max);\n\nfunction minor(value: number, what: string): number {\n if (!Number.isFinite(value) || value < 0) throw new RangeError(`${what} must be a number of zero or more.`);\n return Math.round(value * 100);\n}\n\nexport function formatMoney(minorUnits: number, money: Money): string {\n const value = minorUnits / 100;\n if (/^[A-Z]{3}$/.test(money.currency)) {\n try {\n return new Intl.NumberFormat(money.locale, { style: 'currency', currency: money.currency }).format(value);\n } catch {\n // An unknown code falls through to the plain form.\n }\n }\n return `${money.currency}${value.toFixed(2)}`;\n}\n\n/** Amount paid → each fee taken → what is received, with the table to check it. */\nexport function feeBreakdown(input: FeeBreakdownInput): BoardScene {\n const paid = minor(input.amount, 'The amount');\n const fees = input.fees.slice(0, 4).map((fee, i) => ({ label: cut(fee.label || `Fee ${i + 1}`, 18), minor: minor(fee.amount, fee.label || 'A fee') }));\n const taken = fees.reduce((sum, fee) => sum + fee.minor, 0);\n if (taken > paid) throw new RangeError('The fees are more than the amount paid.');\n const received = paid - taken;\n const money = (m: number) => formatMoney(m, input);\n\n const feeItems: BoardItem[] = fees.flatMap((fee, i): BoardItem[] => [\n { kind: 'text', id: `fee${i}`, text: cut(`${fee.label} −${money(fee.minor)}`), at: [58, 18 + i * 9], size: 's', tone: 'red' },\n ]);\n const steps: BoardStep[] = [\n {\n say: `The customer pays ${money(paid)}.`,\n clear: false,\n draw: [\n { kind: 'art', id: 'payer', art: 'user', at: [4, 10, 12, 20], tone: 'ink' },\n { kind: 'text', id: 'paid', text: money(paid), at: [19, 20], size: 'l', tone: 'ink' },\n { kind: 'ink', ink: 'box', at: [17, 13, 26, 14], tone: 'ink' },\n ],\n },\n {\n say: fees.length === 1\n ? `${fees[0].label} of ${money(fees[0].minor)} is taken out.`\n : `${fees.length} fees are taken out: ${fees.map((f) => `${f.label}, ${money(f.minor)}`).join('; ')}.`,\n clear: false,\n draw: [{ kind: 'ink', ink: 'arrow', at: [44, 20], to: [56, 20], tone: 'red' }, ...feeItems],\n },\n {\n say: `So ${money(received)} is received.`,\n clear: false,\n draw: [\n { kind: 'ink', ink: 'arrow', at: [30, 29], to: [30, 45], tone: 'ink' },\n { kind: 'text', id: 'received', text: money(received), at: [19, 52], size: 'l', tone: 'green' },\n { kind: 'ink', ink: 'circle', at: [17, 46, 27, 12], tone: 'green' },\n ],\n },\n {\n say: 'Here it is all together.',\n clear: false,\n draw: [\n {\n kind: 'table',\n id: 'sum',\n rows: [\n ['Paid', money(paid)],\n ...fees.map((fee) => [fee.label, `−${money(fee.minor)}`]),\n ['Received', money(received)],\n ].map((row) => row.map((cell) => cut(cell, LIMITS.cell))),\n at: [56, 56, 38],\n tone: 'ink',\n },\n { kind: 'mark', mark: 'received' },\n ],\n },\n ];\n return { title: cut(input.title || 'Where the money goes', LIMITS.title), sample: input.sample === true, steps, art: { user: { icon: 'user' } } };\n}\n\n/** A few stages in a row, each boxed and joined to the next by an arrow. */\nexport function processFlow(input: { title: string; steps: { label: string; say?: string }[]; sample?: boolean }): BoardScene {\n const stages = input.steps.slice(0, 5);\n if (stages.length < 2) throw new RangeError('A process needs at least two steps.');\n const gap = 4;\n const width = (92 - gap * (stages.length - 1)) / stages.length;\n const steps: BoardStep[] = stages.map((stage, i) => {\n const x = 4 + i * (width + gap);\n const draw: BoardItem[] = [\n { kind: 'ink', ink: 'box', at: [x, 40, width, 18], tone: 'ink' },\n { kind: 'text', id: `s${i}`, text: cut(stage.label, 16), at: [x + 1.5, 49], size: width < 18 ? 's' : 'm', tone: 'ink' },\n ];\n if (i > 0) draw.unshift({ kind: 'ink', ink: 'arrow', at: [x - gap + 0.5, 49], to: [x - 0.5, 49], tone: 'blue' });\n return { say: cut(stage.say || stage.label, LIMITS.say), clear: false, draw };\n });\n return { title: cut(input.title, LIMITS.title), sample: input.sample === true, steps, art: {} };\n}\n\n/** Two options side by side, the points of each under its name. */\nexport function comparison(input: {\n title: string;\n left: { name: string; points: string[] };\n right: { name: string; points: string[] };\n summary?: string;\n sample?: boolean;\n}): BoardScene {\n const column = (side: { name: string; points: string[] }, x: number, key: string): BoardStep => ({\n say: cut(`${side.name}: ${side.points.slice(0, 4).join(', ')}.`, LIMITS.say),\n clear: false,\n draw: [\n { kind: 'text', id: `${key}h`, text: cut(side.name, 24), at: [x, 14], size: 'l', tone: 'blue' },\n { kind: 'ink', ink: 'underline', at: [x, 9, 36, 9], tone: 'blue' },\n ...side.points.slice(0, 4).map((point, i): BoardItem => ({ kind: 'text', text: cut(`• ${point}`, 34), at: [x, 32 + i * 12], size: 's', tone: 'ink' })),\n ],\n });\n const steps: BoardStep[] = [\n { say: cut(input.title, LIMITS.say), clear: false, draw: [{ kind: 'ink', ink: 'line', at: [50, 8], to: [50, 88], tone: 'ink' }] },\n column(input.left, 6, 'l'),\n column(input.right, 56, 'r'),\n ];\n if (input.summary) steps.push({ say: cut(input.summary, LIMITS.say), clear: false, draw: [] });\n return { title: cut(input.title, LIMITS.title), sample: input.sample === true, steps, art: {} };\n}\n","// Boards an app builds from its own data and plays with useWhiteboard().play:\n// the sums are done here, in minor units, and no model sees the figures.\nimport { comparison, feeBreakdown, format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