@akropolys/kiku 1.5.15 → 1.5.17
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.js +76 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1507,6 +1507,18 @@ var getFriendlyError = (err) => {
|
|
|
1507
1507
|
return str;
|
|
1508
1508
|
}
|
|
1509
1509
|
};
|
|
1510
|
+
var MK_ADJ = ["flying", "silent", "golden", "lucky", "brave", "swift", "royal", "cosmic"];
|
|
1511
|
+
var MK_NOUN = ["thunder", "falcon", "river", "ember", "tiger", "comet", "willow", "onyx"];
|
|
1512
|
+
function generateMagicWord() {
|
|
1513
|
+
return MK_ADJ[Math.floor(Math.random() * MK_ADJ.length)] + MK_NOUN[Math.floor(Math.random() * MK_NOUN.length)];
|
|
1514
|
+
}
|
|
1515
|
+
function parseMemoryKey(raw) {
|
|
1516
|
+
const cleaned = raw.trim().replace(/\s+/g, "");
|
|
1517
|
+
const m = cleaned.match(/^(\d{6,})([a-zA-Z].*)?$/);
|
|
1518
|
+
const phone = m?.[1] || cleaned.replace(/\D/g, "");
|
|
1519
|
+
const word = (m?.[2] || "").toLowerCase() || generateMagicWord();
|
|
1520
|
+
return { phone, word };
|
|
1521
|
+
}
|
|
1510
1522
|
function parseThinking(text) {
|
|
1511
1523
|
const openMatch = text.match(/<\s*thinking\s*>/i);
|
|
1512
1524
|
if (!openMatch) {
|
|
@@ -1648,17 +1660,34 @@ function ChatModal({
|
|
|
1648
1660
|
const SR = window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
1649
1661
|
const recognition = new SR();
|
|
1650
1662
|
recognition.lang = "en-US";
|
|
1651
|
-
recognition.interimResults =
|
|
1663
|
+
recognition.interimResults = true;
|
|
1652
1664
|
recognition.maxAlternatives = 1;
|
|
1653
1665
|
recognitionRef.current = recognition;
|
|
1654
1666
|
recognition.onstart = () => setVoiceState("listening");
|
|
1655
1667
|
recognition.onresult = (event) => {
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1668
|
+
let finalText = "";
|
|
1669
|
+
let interimText = "";
|
|
1670
|
+
for (let i = 0; i < event.results.length; i++) {
|
|
1671
|
+
const seg = event.results[i][0].transcript;
|
|
1672
|
+
if (event.results[i].isFinal) finalText += seg;
|
|
1673
|
+
else interimText += seg;
|
|
1674
|
+
}
|
|
1675
|
+
const live = (finalText + " " + interimText).trim();
|
|
1676
|
+
if (live) setInput(live);
|
|
1677
|
+
if (finalText.trim()) {
|
|
1678
|
+
pendingVoiceRef.current = finalText.trim();
|
|
1679
|
+
setVoiceState("processing");
|
|
1680
|
+
}
|
|
1681
|
+
};
|
|
1682
|
+
recognition.onerror = (event) => {
|
|
1683
|
+
const err = event?.error;
|
|
1684
|
+
if (err === "not-allowed" || err === "service-not-allowed") {
|
|
1685
|
+
setInput("Microphone access was blocked \u2014 enable it in your browser to use voice.");
|
|
1686
|
+
} else if (err === "no-speech") {
|
|
1687
|
+
setInput("Didn't catch that \u2014 tap the mic and try again.");
|
|
1688
|
+
}
|
|
1689
|
+
setVoiceState("idle");
|
|
1660
1690
|
};
|
|
1661
|
-
recognition.onerror = () => setVoiceState("idle");
|
|
1662
1691
|
recognition.onend = () => {
|
|
1663
1692
|
setVoiceState((prev) => prev === "listening" ? "idle" : prev);
|
|
1664
1693
|
};
|
|
@@ -1686,6 +1715,7 @@ function ChatModal({
|
|
|
1686
1715
|
});
|
|
1687
1716
|
const [merchantRef, setMerchantRef] = useState5(null);
|
|
1688
1717
|
const [paymentPhase, setPaymentPhase] = useState5("idle");
|
|
1718
|
+
const [memoryKey, setMemoryKey] = useState5(null);
|
|
1689
1719
|
const [sessions, setSessions] = useState5(() => loadSessions());
|
|
1690
1720
|
const [sidebarOpen, setSidebarOpen] = useState5(false);
|
|
1691
1721
|
const [replayMessages, setReplayMessages] = useState5(null);
|
|
@@ -1727,6 +1757,10 @@ function ChatModal({
|
|
|
1727
1757
|
}
|
|
1728
1758
|
const isHistoryIntent = lastIntent === "capture" || lastIntent === "delete" || lastIntent === "view_history";
|
|
1729
1759
|
if (isHistoryIntent) {
|
|
1760
|
+
const { phone, word } = parseMemoryKey(phoneInput);
|
|
1761
|
+
if (!phone) return;
|
|
1762
|
+
client.setShopperIdentity(phone, word);
|
|
1763
|
+
setMemoryKey(phone + word);
|
|
1730
1764
|
setPaymentPhase("idle");
|
|
1731
1765
|
const lastUserMsg = [...messages].reverse().find((m) => m.role === "user");
|
|
1732
1766
|
if (lastUserMsg) {
|
|
@@ -2032,7 +2066,25 @@ function ChatModal({
|
|
|
2032
2066
|
!replayMessages && paymentPhase === "prompt_phone" && (() => {
|
|
2033
2067
|
const isHistoryIntent = lastIntent === "capture" || lastIntent === "delete" || lastIntent === "view_history";
|
|
2034
2068
|
if (isHistoryIntent) {
|
|
2035
|
-
return
|
|
2069
|
+
return /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-ai-msg", children: [
|
|
2070
|
+
/* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsx7(SparkleIcon2, {}) }),
|
|
2071
|
+
/* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-body", children: /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-text", children: /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-phone-form", children: [
|
|
2072
|
+
/* @__PURE__ */ jsx7("label", { className: "hsk-cb-phone-label", children: "Your phone number \u2014 or paste your memory key" }),
|
|
2073
|
+
/* @__PURE__ */ jsx7(
|
|
2074
|
+
"input",
|
|
2075
|
+
{
|
|
2076
|
+
type: "text",
|
|
2077
|
+
className: "hsk-cb-phone-input",
|
|
2078
|
+
placeholder: "0712345678 or 0712345678flyingthunder",
|
|
2079
|
+
value: phoneInput,
|
|
2080
|
+
onChange: (e) => setPhoneInput(e.target.value.replace(/[^0-9a-zA-Z]/g, "")),
|
|
2081
|
+
onKeyDown: (e) => e.key === "Enter" && handlePhoneSubmit(),
|
|
2082
|
+
autoFocus: true
|
|
2083
|
+
}
|
|
2084
|
+
),
|
|
2085
|
+
/* @__PURE__ */ jsx7("button", { className: "hsk-cb-phone-submit", onClick: handlePhoneSubmit, children: "Save & sync my items" })
|
|
2086
|
+
] }) }) })
|
|
2087
|
+
] });
|
|
2036
2088
|
}
|
|
2037
2089
|
return /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-ai-msg", children: [
|
|
2038
2090
|
/* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsx7(SparkleIcon2, {}) }),
|
|
@@ -2054,6 +2106,22 @@ function ChatModal({
|
|
|
2054
2106
|
] }) }) })
|
|
2055
2107
|
] });
|
|
2056
2108
|
})(),
|
|
2109
|
+
!replayMessages && memoryKey && /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-ai-msg", children: [
|
|
2110
|
+
/* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsx7(SparkleIcon2, {}) }),
|
|
2111
|
+
/* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-body", children: /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-text", children: /* @__PURE__ */ jsxs6("div", { style: { padding: "10px 12px", border: "1px solid var(--hsk-border, #e5e5e5)", borderRadius: 8 }, children: [
|
|
2112
|
+
/* @__PURE__ */ jsx7("div", { style: { fontSize: 12, fontWeight: 600, marginBottom: 4 }, children: "\u{1F511} Your memory key" }),
|
|
2113
|
+
/* @__PURE__ */ jsx7("code", { style: { display: "block", fontSize: 14, fontWeight: 700, marginBottom: 6, wordBreak: "break-all" }, children: memoryKey }),
|
|
2114
|
+
/* @__PURE__ */ jsxs6("div", { style: { display: "flex", gap: 8, alignItems: "center" }, children: [
|
|
2115
|
+
/* @__PURE__ */ jsx7("button", { className: "hsk-cb-phone-submit", style: { padding: "4px 10px" }, onClick: () => {
|
|
2116
|
+
try {
|
|
2117
|
+
navigator.clipboard?.writeText(memoryKey);
|
|
2118
|
+
} catch {
|
|
2119
|
+
}
|
|
2120
|
+
}, children: "Copy" }),
|
|
2121
|
+
/* @__PURE__ */ jsx7("span", { style: { fontSize: 11, opacity: 0.7 }, children: "Save it \u2014 enter it on any site to get your items back." })
|
|
2122
|
+
] })
|
|
2123
|
+
] }) }) })
|
|
2124
|
+
] }),
|
|
2057
2125
|
!replayMessages && paymentPhase === "awaiting" && /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-payment-prompt hsk-cb-payment-prompt--awaiting", children: [
|
|
2058
2126
|
/* @__PURE__ */ jsx7("div", { className: "hsk-cb-payment-pulse-ring" }),
|
|
2059
2127
|
/* @__PURE__ */ jsx7("div", { className: "hsk-cb-payment-icon-wrap", children: /* @__PURE__ */ jsx7("span", { style: { fontSize: "2rem" }, children: "\u{1F4F1}" }) }),
|
|
@@ -2150,7 +2218,7 @@ function ChatModal({
|
|
|
2150
2218
|
value: input,
|
|
2151
2219
|
onChange: handleInput,
|
|
2152
2220
|
onKeyDown: handleKeyDown,
|
|
2153
|
-
placeholder: activePlaceholder,
|
|
2221
|
+
placeholder: voiceState === "listening" ? "\u{1F399}\uFE0F Listening\u2026 tap the mic to stop" : voiceState === "processing" ? "Got it \u2014 sending\u2026" : activePlaceholder,
|
|
2154
2222
|
rows: 1,
|
|
2155
2223
|
disabled: loading,
|
|
2156
2224
|
autoFocus: true
|