@guideai/react-native 0.2.0 → 0.6.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/README.md +72 -20
- package/dist/GuideAIChat-DLtQYk2N.js +2439 -0
- package/dist/GuideAIChat-DLtQYk2N.js.map +1 -0
- package/dist/GuideAIChat-DQEa_Ff0.cjs +2438 -0
- package/dist/GuideAIChat-DQEa_Ff0.cjs.map +1 -0
- package/dist/index.cjs +116 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +246 -6
- package/dist/index.mjs +112 -4
- package/dist/index.mjs.map +1 -1
- package/dist/ui.cjs +22 -770
- package/dist/ui.cjs.map +1 -1
- package/dist/ui.d.ts +262 -4
- package/dist/ui.mjs +14 -761
- package/dist/ui.mjs.map +1 -1
- package/dist/{useOnboarding-DAEGoYSs.js → useConversations-B4WYG2Qz.js} +703 -77
- package/dist/useConversations-B4WYG2Qz.js.map +1 -0
- package/dist/{useOnboarding-DWkCW5v0.cjs → useConversations-C9ivx2l-.cjs} +700 -74
- package/dist/useConversations-C9ivx2l-.cjs.map +1 -0
- package/dist/voice.cjs +540 -0
- package/dist/voice.cjs.map +1 -0
- package/dist/voice.d.ts +407 -0
- package/dist/voice.mjs +541 -0
- package/dist/voice.mjs.map +1 -0
- package/package.json +30 -11
- package/dist/useOnboarding-DAEGoYSs.js.map +0 -1
- package/dist/useOnboarding-DWkCW5v0.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const useConversations = require("./useConversations-C9ivx2l-.cjs");
|
|
4
4
|
const jsxRuntime = require("react/jsx-runtime");
|
|
5
5
|
const React = require("react");
|
|
6
6
|
function GuideAIScreen({
|
|
@@ -10,8 +10,8 @@ function GuideAIScreen({
|
|
|
10
10
|
active = true,
|
|
11
11
|
children
|
|
12
12
|
}) {
|
|
13
|
-
const runtime =
|
|
14
|
-
const registry = React.useMemo(() => new
|
|
13
|
+
const runtime = useConversations.useGuideAIRuntime();
|
|
14
|
+
const registry = React.useMemo(() => new useConversations.ScreenRegistry(), [name, path]);
|
|
15
15
|
React.useEffect(() => {
|
|
16
16
|
if (!active) return;
|
|
17
17
|
runtime.setActiveScreen({ path, title: title != null ? title : name, registry });
|
|
@@ -22,10 +22,10 @@ function GuideAIScreen({
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
}, [runtime, registry, path, title, name, active]);
|
|
25
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
25
|
+
return /* @__PURE__ */ jsxRuntime.jsx(useConversations.RegistryContext.Provider, { value: registry, children });
|
|
26
26
|
}
|
|
27
27
|
function useGuideAIElement(id, options) {
|
|
28
|
-
const registry =
|
|
28
|
+
const registry = useConversations.useScreenRegistry();
|
|
29
29
|
const handlers = React.useRef({});
|
|
30
30
|
handlers.current = {
|
|
31
31
|
press: options.press,
|
|
@@ -78,9 +78,117 @@ function useGuideAIElement(id, options) {
|
|
|
78
78
|
canScrollTo
|
|
79
79
|
]);
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
const cut = (text, max = useConversations.LIMITS.text) => text.replace(/\s+/g, " ").trim().slice(0, max);
|
|
82
|
+
function minor(value, what) {
|
|
83
|
+
if (!Number.isFinite(value) || value < 0) throw new RangeError(`${what} must be a number of zero or more.`);
|
|
84
|
+
return Math.round(value * 100);
|
|
85
|
+
}
|
|
86
|
+
function formatMoney(minorUnits, money) {
|
|
87
|
+
const value = minorUnits / 100;
|
|
88
|
+
if (/^[A-Z]{3}$/.test(money.currency)) {
|
|
89
|
+
try {
|
|
90
|
+
return new Intl.NumberFormat(money.locale, { style: "currency", currency: money.currency }).format(value);
|
|
91
|
+
} catch {
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return `${money.currency}${value.toFixed(2)}`;
|
|
95
|
+
}
|
|
96
|
+
function feeBreakdown(input) {
|
|
97
|
+
const paid = minor(input.amount, "The amount");
|
|
98
|
+
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") }));
|
|
99
|
+
const taken = fees.reduce((sum, fee) => sum + fee.minor, 0);
|
|
100
|
+
if (taken > paid) throw new RangeError("The fees are more than the amount paid.");
|
|
101
|
+
const received = paid - taken;
|
|
102
|
+
const money = (m) => formatMoney(m, input);
|
|
103
|
+
const feeItems = fees.flatMap((fee, i) => [
|
|
104
|
+
{ kind: "text", id: `fee${i}`, text: cut(`${fee.label} −${money(fee.minor)}`), at: [58, 18 + i * 9], size: "s", tone: "red" }
|
|
105
|
+
]);
|
|
106
|
+
const steps = [
|
|
107
|
+
{
|
|
108
|
+
say: `The customer pays ${money(paid)}.`,
|
|
109
|
+
clear: false,
|
|
110
|
+
draw: [
|
|
111
|
+
{ kind: "art", id: "payer", art: "user", at: [4, 10, 12, 20], tone: "ink" },
|
|
112
|
+
{ kind: "text", id: "paid", text: money(paid), at: [19, 20], size: "l", tone: "ink" },
|
|
113
|
+
{ kind: "ink", ink: "box", at: [17, 13, 26, 14], tone: "ink" }
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
say: fees.length === 1 ? `${fees[0].label} of ${money(fees[0].minor)} is taken out.` : `${fees.length} fees are taken out: ${fees.map((f) => `${f.label}, ${money(f.minor)}`).join("; ")}.`,
|
|
118
|
+
clear: false,
|
|
119
|
+
draw: [{ kind: "ink", ink: "arrow", at: [44, 20], to: [56, 20], tone: "red" }, ...feeItems]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
say: `So ${money(received)} is received.`,
|
|
123
|
+
clear: false,
|
|
124
|
+
draw: [
|
|
125
|
+
{ kind: "ink", ink: "arrow", at: [30, 29], to: [30, 45], tone: "ink" },
|
|
126
|
+
{ kind: "text", id: "received", text: money(received), at: [19, 52], size: "l", tone: "green" },
|
|
127
|
+
{ kind: "ink", ink: "circle", at: [17, 46, 27, 12], tone: "green" }
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
say: "Here it is all together.",
|
|
132
|
+
clear: false,
|
|
133
|
+
draw: [
|
|
134
|
+
{
|
|
135
|
+
kind: "table",
|
|
136
|
+
id: "sum",
|
|
137
|
+
rows: [
|
|
138
|
+
["Paid", money(paid)],
|
|
139
|
+
...fees.map((fee) => [fee.label, `−${money(fee.minor)}`]),
|
|
140
|
+
["Received", money(received)]
|
|
141
|
+
].map((row) => row.map((cell) => cut(cell, useConversations.LIMITS.cell))),
|
|
142
|
+
at: [56, 56, 38],
|
|
143
|
+
tone: "ink"
|
|
144
|
+
},
|
|
145
|
+
{ kind: "mark", mark: "received" }
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
];
|
|
149
|
+
return { title: cut(input.title || "Where the money goes", useConversations.LIMITS.title), sample: input.sample === true, steps, art: { user: { icon: "user" } } };
|
|
150
|
+
}
|
|
151
|
+
function processFlow(input) {
|
|
152
|
+
const stages = input.steps.slice(0, 5);
|
|
153
|
+
if (stages.length < 2) throw new RangeError("A process needs at least two steps.");
|
|
154
|
+
const gap = 4;
|
|
155
|
+
const width = (92 - gap * (stages.length - 1)) / stages.length;
|
|
156
|
+
const steps = stages.map((stage, i) => {
|
|
157
|
+
const x = 4 + i * (width + gap);
|
|
158
|
+
const draw = [
|
|
159
|
+
{ kind: "ink", ink: "box", at: [x, 40, width, 18], tone: "ink" },
|
|
160
|
+
{ kind: "text", id: `s${i}`, text: cut(stage.label, 16), at: [x + 1.5, 49], size: width < 18 ? "s" : "m", tone: "ink" }
|
|
161
|
+
];
|
|
162
|
+
if (i > 0) draw.unshift({ kind: "ink", ink: "arrow", at: [x - gap + 0.5, 49], to: [x - 0.5, 49], tone: "blue" });
|
|
163
|
+
return { say: cut(stage.say || stage.label, useConversations.LIMITS.say), clear: false, draw };
|
|
164
|
+
});
|
|
165
|
+
return { title: cut(input.title, useConversations.LIMITS.title), sample: input.sample === true, steps, art: {} };
|
|
166
|
+
}
|
|
167
|
+
function comparison(input) {
|
|
168
|
+
const column = (side, x, key) => ({
|
|
169
|
+
say: cut(`${side.name}: ${side.points.slice(0, 4).join(", ")}.`, useConversations.LIMITS.say),
|
|
170
|
+
clear: false,
|
|
171
|
+
draw: [
|
|
172
|
+
{ kind: "text", id: `${key}h`, text: cut(side.name, 24), at: [x, 14], size: "l", tone: "blue" },
|
|
173
|
+
{ kind: "ink", ink: "underline", at: [x, 9, 36, 9], tone: "blue" },
|
|
174
|
+
...side.points.slice(0, 4).map((point, i) => ({ kind: "text", text: cut(`• ${point}`, 34), at: [x, 32 + i * 12], size: "s", tone: "ink" }))
|
|
175
|
+
]
|
|
176
|
+
});
|
|
177
|
+
const steps = [
|
|
178
|
+
{ say: cut(input.title, useConversations.LIMITS.say), clear: false, draw: [{ kind: "ink", ink: "line", at: [50, 8], to: [50, 88], tone: "ink" }] },
|
|
179
|
+
column(input.left, 6, "l"),
|
|
180
|
+
column(input.right, 56, "r")
|
|
181
|
+
];
|
|
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: {} };
|
|
184
|
+
}
|
|
185
|
+
const whiteboardLayouts = { feeBreakdown, processFlow, comparison, formatMoney };
|
|
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;
|
|
84
191
|
exports.GuideAIScreen = GuideAIScreen;
|
|
85
192
|
exports.useGuideAIElement = useGuideAIElement;
|
|
193
|
+
exports.whiteboardLayouts = whiteboardLayouts;
|
|
86
194
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/react/GuideAIScreen.tsx","../src/react/useGuideAIElement.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"],"names":["useGuideAIRuntime","useMemo","ScreenRegistry","useEffect","RegistryContext","useScreenRegistry","useRef"],"mappings":";;;;;AA4CO,SAAS,cAAc;AAAA,EAC5B;AAAA,EAAM;AAAA,EAAM;AAAA,EAAO,SAAS;AAAA,EAAM;AACpC,GAA2C;AACzC,QAAM,UAAUA,cAAAA,kBAAA;AAIhB,QAAM,WAAWC,MAAAA,QAAQ,MAAM,IAAIC,cAAAA,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,cAAAA,gBAAgB,UAAhB,EAAyB,OAAO,UAC9B,UACH;AAEJ;AC1CO,SAAS,kBACd,IACA,SACM;AACN,QAAM,WAAWC,cAAAA,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,EAAA,IAC3D;AAMJ,QAAM,WAAW,QAAQ,QAAQ,KAAK;AACtC,QAAM,cAAc,QAAQ,QAAQ,QAAQ;AAC5C,QAAM,cAAc,QAAQ,QAAQ,QAAQ;AAE5CH,QAAAA,UAAU,MAAM;AACd,QAAI,CAAC,SAAU;AAKf,UAAM,QAAyB,CAAA;AAC/B,QAAI,SAAU,OAAM,QAAQ,MAAA;;AAAM,kCAAS,SAAQ,UAAjB;AAAA;AAClC,QAAI,mBAAmB,WAAW,CAAC;;AAAiB,kCAAS,SAAQ,aAAjB,4BAA4B;AAAA;AAChF,QAAI,YAAa,OAAM,WAAW,MAAA;;AAAM,kCAAS,SAAQ,aAAjB;AAAA;AAExC,WAAO,SAAS;AAAA,MACd,EAAE,IAAI,OAAO,MAAM,OAAO,oBAAoB,aAAa,QAAQ,aAAA;AAAA,MACnE;AAAA,IAAA;AAAA,EAEJ,GAAG;AAAA,IACD;AAAA,IAAU;AAAA,IAAI;AAAA,IAAO;AAAA,IAAM;AAAA,IAC3B;AAAA,IAAoB;AAAA,IAAa;AAAA,IAAQ;AAAA,IACzC;AAAA,IAAU;AAAA,IAAa;AAAA,EAAA,CACxB;AACH;;;;;;"}
|
|
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","use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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
|
/**
|
|
@@ -907,12 +930,29 @@ interface GuideAIConfig {
|
|
|
907
930
|
* Sent with every turn; change it with GuideAI.setUserProfile().
|
|
908
931
|
*/
|
|
909
932
|
userProfile?: GuideAIUserProfile;
|
|
933
|
+
/**
|
|
934
|
+
* Follow-ups offered under an answer that came without suggestions of
|
|
935
|
+
* its own, in the app's language: ['Explain it differently', 'Give me an
|
|
936
|
+
* example']. Change them with GuideAI.setFollowUps().
|
|
937
|
+
*/
|
|
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;
|
|
910
945
|
/**
|
|
911
946
|
* Log the full conversation and every request. Development only —
|
|
912
947
|
* it prints message content to the console.
|
|
913
948
|
*/
|
|
914
949
|
debug?: boolean;
|
|
915
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
|
+
}
|
|
916
956
|
/** Short facts about the user: strings, numbers, booleans or short lists of them. */
|
|
917
957
|
type GuideAIUserProfile = Record<string, string | number | boolean | Array<string | number>>;
|
|
918
958
|
/**
|
|
@@ -929,6 +969,8 @@ declare function identify(userId: string | null): void;
|
|
|
929
969
|
declare function setToolContext(values: Record<string, string> | null): void;
|
|
930
970
|
/** Replace what the agent knows about the user (after login, or a profile edit). */
|
|
931
971
|
declare function setUserProfile(profile: GuideAIUserProfile | null): void;
|
|
972
|
+
/** Replace the app's follow-ups (after a language change). */
|
|
973
|
+
declare function setFollowUps(followUps: string[] | null): void;
|
|
932
974
|
/** Whether configure() has run. Lets a host render its own fallback. */
|
|
933
975
|
declare function isConfigured(): boolean;
|
|
934
976
|
/** Test seam, and for hosts that switch sites at runtime. */
|
|
@@ -938,6 +980,7 @@ declare const GuideAI: {
|
|
|
938
980
|
identify: typeof identify;
|
|
939
981
|
setUserProfile: typeof setUserProfile;
|
|
940
982
|
setToolContext: typeof setToolContext;
|
|
983
|
+
setFollowUps: typeof setFollowUps;
|
|
941
984
|
isConfigured: typeof isConfigured;
|
|
942
985
|
reset: typeof reset;
|
|
943
986
|
};
|
|
@@ -978,14 +1021,25 @@ interface GuideAIMessage {
|
|
|
978
1021
|
id: string;
|
|
979
1022
|
role: 'user' | 'assistant';
|
|
980
1023
|
content: string;
|
|
1024
|
+
/** When the message was sent or the answer started (ms since epoch). */
|
|
1025
|
+
createdAt: number;
|
|
1026
|
+
/** On an answer: the user message it replied to. */
|
|
1027
|
+
question?: string;
|
|
981
1028
|
/** True while tokens are still arriving for this message. */
|
|
982
1029
|
streaming?: boolean;
|
|
983
1030
|
error?: boolean;
|
|
984
1031
|
/**
|
|
985
1032
|
* Follow-up suggestions to draw as chips. A tap is just
|
|
986
|
-
* `send(suggestion)`.
|
|
1033
|
+
* `send(suggestion)`. The site's own when the agent offered some,
|
|
1034
|
+
* otherwise the `followUps` the app configured.
|
|
987
1035
|
*/
|
|
988
1036
|
suggestions?: string[];
|
|
1037
|
+
/**
|
|
1038
|
+
* This answer can be explained on the whiteboard (the Blueprint has the
|
|
1039
|
+
* block, and the answer is finished). Draw a button that calls
|
|
1040
|
+
* `explainOnWhiteboard(id)`.
|
|
1041
|
+
*/
|
|
1042
|
+
whiteboard?: boolean;
|
|
989
1043
|
/**
|
|
990
1044
|
* Pictures the agent drew. They are also in `content` as Markdown
|
|
991
1045
|
* images where they belong; use this list to place them yourself.
|
|
@@ -1012,6 +1066,8 @@ interface GuideAIVoiceRecording {
|
|
|
1012
1066
|
interface GuideAIVoiceResult {
|
|
1013
1067
|
/** What was heard, already sent as the next message; null when nothing was. */
|
|
1014
1068
|
text: string | null;
|
|
1069
|
+
/** The answer to it, as shown (Markdown); null when the turn failed. */
|
|
1070
|
+
answer?: string | null;
|
|
1015
1071
|
/** Why nothing was sent, in words to show the user. */
|
|
1016
1072
|
error?: string;
|
|
1017
1073
|
}
|
|
@@ -1024,8 +1080,25 @@ interface GuideAIVoiceResult {
|
|
|
1024
1080
|
* underneath a host's UI without them changing a line.
|
|
1025
1081
|
*/
|
|
1026
1082
|
interface UseGuideAIResult {
|
|
1027
|
-
/**
|
|
1083
|
+
/**
|
|
1084
|
+
* The conversation so far, oldest first, ready to draw. An answer that
|
|
1085
|
+
* has not produced any text yet is left out; `typing` covers it.
|
|
1086
|
+
*/
|
|
1028
1087
|
messages: GuideAIMessage[];
|
|
1088
|
+
/** An answer is on its way but has no text yet: draw a typing indicator. */
|
|
1089
|
+
typing: boolean;
|
|
1090
|
+
/**
|
|
1091
|
+
* Chips to draw under the latest answer: its suggestions, or the app's
|
|
1092
|
+
* `followUps`. Empty while a turn runs and before the first answer.
|
|
1093
|
+
*/
|
|
1094
|
+
followUps: string[];
|
|
1095
|
+
/** The Blueprint has the whiteboard block. */
|
|
1096
|
+
whiteboardAvailable: boolean;
|
|
1097
|
+
/**
|
|
1098
|
+
* Explain an answer on the whiteboard, with the question it answered.
|
|
1099
|
+
* Mount `<GuideAIWhiteboard />` once to show the board.
|
|
1100
|
+
*/
|
|
1101
|
+
explainOnWhiteboard(messageId: string): Promise<boolean>;
|
|
1029
1102
|
/**
|
|
1030
1103
|
* The current input text, and its setter.
|
|
1031
1104
|
*
|
|
@@ -1041,7 +1114,7 @@ interface UseGuideAIResult {
|
|
|
1041
1114
|
* Ignores empty text and calls made while a turn is in flight, so a
|
|
1042
1115
|
* host does not have to guard their send button.
|
|
1043
1116
|
*/
|
|
1044
|
-
send(question?: string): Promise<
|
|
1117
|
+
send(question?: string): Promise<string | null>;
|
|
1045
1118
|
/** True from send() until the turn settles. Drives a disabled state. */
|
|
1046
1119
|
busy: boolean;
|
|
1047
1120
|
/** Whether `send()` would do anything right now. */
|
|
@@ -1050,7 +1123,7 @@ interface UseGuideAIResult {
|
|
|
1050
1123
|
status: string | null;
|
|
1051
1124
|
/** Re-send the last user message. Useful after a failed turn. */
|
|
1052
1125
|
retry(): Promise<void>;
|
|
1053
|
-
/**
|
|
1126
|
+
/** Start a new conversation. The current one stays in the chat history (useConversations). */
|
|
1054
1127
|
clear(): void;
|
|
1055
1128
|
/** Approve the message's `pendingAction`; the agent carries it out. */
|
|
1056
1129
|
confirm(messageId: string): Promise<void>;
|
|
@@ -1076,6 +1149,12 @@ interface UseGuideAIOptions {
|
|
|
1076
1149
|
* so a host never holds a reference to it.
|
|
1077
1150
|
*/
|
|
1078
1151
|
harness?: CopilotHarness;
|
|
1152
|
+
/**
|
|
1153
|
+
* Follow-ups offered under an answer that came without suggestions of
|
|
1154
|
+
* its own ("Explain it differently", "Give me an example"). Defaults to
|
|
1155
|
+
* GuideAI.configure({ followUps }).
|
|
1156
|
+
*/
|
|
1157
|
+
followUps?: string[];
|
|
1079
1158
|
}
|
|
1080
1159
|
declare function useGuideAI(options?: UseGuideAIOptions): UseGuideAIResult;
|
|
1081
1160
|
|
|
@@ -1087,5 +1166,166 @@ declare function useOnboarding(): {
|
|
|
1087
1166
|
dismiss: () => Promise<void>;
|
|
1088
1167
|
};
|
|
1089
1168
|
|
|
1090
|
-
|
|
1091
|
-
|
|
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
|
+
|
|
1183
|
+
declare const INK_KINDS: readonly ["line", "arrow", "poly", "curve", "free", "oval", "corner", "arc", "dot", "circle", "box", "underline", "cross", "tick", "bracket"];
|
|
1184
|
+
/** How a point marks the real page. */
|
|
1185
|
+
declare const POINT_MARKS: readonly ["circle", "underline", "box"];
|
|
1186
|
+
type PointMark = (typeof POINT_MARKS)[number];
|
|
1187
|
+
type InkKind = (typeof INK_KINDS)[number];
|
|
1188
|
+
type Size = 's' | 'm' | 'l';
|
|
1189
|
+
type Tone = 'ink' | 'blue' | 'red' | 'green';
|
|
1190
|
+
type Point = [number, number];
|
|
1191
|
+
type Box = [number, number, number, number];
|
|
1192
|
+
type BoardItem = {
|
|
1193
|
+
kind: 'art';
|
|
1194
|
+
id?: string;
|
|
1195
|
+
art: string;
|
|
1196
|
+
at: Box;
|
|
1197
|
+
tone: Tone;
|
|
1198
|
+
} | {
|
|
1199
|
+
kind: 'text';
|
|
1200
|
+
id?: string;
|
|
1201
|
+
text: string;
|
|
1202
|
+
at: Point;
|
|
1203
|
+
size: Size;
|
|
1204
|
+
tone: Tone;
|
|
1205
|
+
} | {
|
|
1206
|
+
kind: 'ink';
|
|
1207
|
+
id?: string;
|
|
1208
|
+
ink: InkKind;
|
|
1209
|
+
at?: Point | Box;
|
|
1210
|
+
to?: Point;
|
|
1211
|
+
pts?: Point[];
|
|
1212
|
+
closed?: boolean;
|
|
1213
|
+
tone: Tone;
|
|
1214
|
+
} | {
|
|
1215
|
+
kind: 'table';
|
|
1216
|
+
id?: string;
|
|
1217
|
+
rows: string[][];
|
|
1218
|
+
at: [number, number, number];
|
|
1219
|
+
tone: Tone;
|
|
1220
|
+
} | {
|
|
1221
|
+
kind: 'mark';
|
|
1222
|
+
mark: string;
|
|
1223
|
+
} | {
|
|
1224
|
+
kind: 'point';
|
|
1225
|
+
point: string;
|
|
1226
|
+
as: PointMark;
|
|
1227
|
+
} | {
|
|
1228
|
+
kind: 'erase';
|
|
1229
|
+
erase: string;
|
|
1230
|
+
};
|
|
1231
|
+
interface BoardStep {
|
|
1232
|
+
say: string;
|
|
1233
|
+
clear: boolean;
|
|
1234
|
+
draw: BoardItem[];
|
|
1235
|
+
}
|
|
1236
|
+
/** Ink for a picture: traced contours (SVG path data) in their own box. */
|
|
1237
|
+
interface ArtInk {
|
|
1238
|
+
view_box: string;
|
|
1239
|
+
transform: string;
|
|
1240
|
+
contours: string[];
|
|
1241
|
+
}
|
|
1242
|
+
interface BoardScene {
|
|
1243
|
+
/** 3: the even 160 x 100 grid. Absent (a host's board): 0-100 both ways. */
|
|
1244
|
+
v?: 2 | 3;
|
|
1245
|
+
title: string;
|
|
1246
|
+
/** Example numbers: the board says so. */
|
|
1247
|
+
sample: boolean;
|
|
1248
|
+
steps: BoardStep[];
|
|
1249
|
+
/** Pictures by description: a built-in icon, or traced ink. */
|
|
1250
|
+
art: Record<string, {
|
|
1251
|
+
icon: string;
|
|
1252
|
+
} | ArtInk>;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
type WhiteboardStatus = 'closed' | 'loading' | 'playing' | 'error';
|
|
1256
|
+
interface WhiteboardState {
|
|
1257
|
+
status: WhiteboardStatus;
|
|
1258
|
+
scene: BoardScene | null;
|
|
1259
|
+
error: string | null;
|
|
1260
|
+
/** What was asked, for the loading title and Try again. */
|
|
1261
|
+
question: string;
|
|
1262
|
+
answer?: string;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
interface UseWhiteboardResult {
|
|
1266
|
+
/** The Blueprint has "Explain on a whiteboard". False until the server says so. */
|
|
1267
|
+
available: boolean;
|
|
1268
|
+
state: WhiteboardState;
|
|
1269
|
+
/** Explain an answer on the board: the question asked, and the answer given. */
|
|
1270
|
+
explain(question: string, answer?: string): Promise<boolean>;
|
|
1271
|
+
/** Draw a board the host built (see `whiteboardLayouts`). Throws SceneError if it cannot be drawn. */
|
|
1272
|
+
play(scene: unknown): void;
|
|
1273
|
+
retry(): void;
|
|
1274
|
+
close(): void;
|
|
1275
|
+
}
|
|
1276
|
+
declare function useWhiteboard(): UseWhiteboardResult;
|
|
1277
|
+
|
|
1278
|
+
interface Money {
|
|
1279
|
+
/** ISO 4217 code ("GBP") or a symbol ("£"). */
|
|
1280
|
+
currency: string;
|
|
1281
|
+
/** Formatting locale; the browser's by default. */
|
|
1282
|
+
locale?: string;
|
|
1283
|
+
}
|
|
1284
|
+
interface FeeBreakdownInput extends Money {
|
|
1285
|
+
/** What the customer pays. */
|
|
1286
|
+
amount: number;
|
|
1287
|
+
/** Each deduction, in the order it is taken. */
|
|
1288
|
+
fees: {
|
|
1289
|
+
label: string;
|
|
1290
|
+
amount: number;
|
|
1291
|
+
}[];
|
|
1292
|
+
title?: string;
|
|
1293
|
+
/** Example figures: the board is labelled as an example. */
|
|
1294
|
+
sample?: boolean;
|
|
1295
|
+
}
|
|
1296
|
+
declare function formatMoney(minorUnits: number, money: Money): string;
|
|
1297
|
+
/** Amount paid → each fee taken → what is received, with the table to check it. */
|
|
1298
|
+
declare function feeBreakdown(input: FeeBreakdownInput): BoardScene;
|
|
1299
|
+
/** A few stages in a row, each boxed and joined to the next by an arrow. */
|
|
1300
|
+
declare function processFlow(input: {
|
|
1301
|
+
title: string;
|
|
1302
|
+
steps: {
|
|
1303
|
+
label: string;
|
|
1304
|
+
say?: string;
|
|
1305
|
+
}[];
|
|
1306
|
+
sample?: boolean;
|
|
1307
|
+
}): BoardScene;
|
|
1308
|
+
/** Two options side by side, the points of each under its name. */
|
|
1309
|
+
declare function comparison(input: {
|
|
1310
|
+
title: string;
|
|
1311
|
+
left: {
|
|
1312
|
+
name: string;
|
|
1313
|
+
points: string[];
|
|
1314
|
+
};
|
|
1315
|
+
right: {
|
|
1316
|
+
name: string;
|
|
1317
|
+
points: string[];
|
|
1318
|
+
};
|
|
1319
|
+
summary?: string;
|
|
1320
|
+
sample?: boolean;
|
|
1321
|
+
}): BoardScene;
|
|
1322
|
+
|
|
1323
|
+
declare const whiteboardLayouts: {
|
|
1324
|
+
feeBreakdown: typeof feeBreakdown;
|
|
1325
|
+
processFlow: typeof processFlow;
|
|
1326
|
+
comparison: typeof comparison;
|
|
1327
|
+
formatMoney: typeof formatMoney;
|
|
1328
|
+
};
|
|
1329
|
+
|
|
1330
|
+
export { GuideAI, GuideAIScreen, useConversations, useGuideAI, useGuideAIElement, useOnboarding, useWhiteboard, whiteboardLayouts };
|
|
1331
|
+
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 };
|