@akropolys/kiku 1.7.5 → 1.7.7

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 CHANGED
@@ -1162,6 +1162,11 @@ var ArrowUpIcon2 = () => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", {
1162
1162
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M12 19V5" })
1163
1163
  ] });
1164
1164
  var StopIcon = () => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("rect", { x: "5", y: "5", width: "14", height: "14", rx: "2" }) });
1165
+ var ExternalIcon = () => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1166
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
1167
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("polyline", { points: "15 3 21 3 21 9" }),
1168
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
1169
+ ] });
1165
1170
  var ContinueIcon = () => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", { width: "13", height: "13", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M8 5v14l11-7z" }) });
1166
1171
  var CloseIcon = () => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
1167
1172
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
@@ -1604,67 +1609,46 @@ function parseThinking(text) {
1604
1609
  isComplete: true
1605
1610
  };
1606
1611
  }
1607
- function ThinkingBlock({ text, isComplete }) {
1608
- const [isOpen, setIsOpen] = (0, import_react5.useState)(true);
1612
+ function ThinkingBlock({ text, isComplete, seconds: fixedSeconds }) {
1613
+ const startRef = (0, import_react5.useRef)(Date.now());
1614
+ const [seconds, setSeconds] = (0, import_react5.useState)(() => isComplete ? null : 0);
1615
+ const [isOpen, setIsOpen] = (0, import_react5.useState)(!isComplete);
1609
1616
  (0, import_react5.useEffect)(() => {
1610
- if (!isComplete) {
1611
- setIsOpen(true);
1617
+ if (isComplete) {
1618
+ if (seconds !== null) {
1619
+ setSeconds(Math.max(1, Math.round((Date.now() - startRef.current) / 1e3)));
1620
+ setIsOpen(false);
1621
+ }
1622
+ return;
1612
1623
  }
1624
+ setIsOpen(true);
1625
+ const t = setInterval(() => {
1626
+ setSeconds(Math.round((Date.now() - startRef.current) / 1e3));
1627
+ }, 1e3);
1628
+ return () => clearInterval(t);
1613
1629
  }, [isComplete]);
1614
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: {
1615
- marginBottom: "12px",
1616
- borderLeft: "2px solid #e4e4e7",
1617
- paddingLeft: "10px",
1618
- fontSize: "0.825rem",
1619
- backgroundColor: "rgba(244, 244, 245, 0.4)",
1620
- padding: "8px 10px",
1621
- borderRadius: "0 6px 6px 0"
1622
- }, children: [
1630
+ const finalSeconds = fixedSeconds ?? seconds;
1631
+ const label = isComplete ? finalSeconds !== null && finalSeconds !== void 0 ? `Thought for ${finalSeconds}s` : "Thought process" : `Thinking${seconds ? ` \xB7 ${seconds}s` : "\u2026"}`;
1632
+ const expandable = !!text;
1633
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: cn("hsk-cb-think", !isComplete && "hsk-cb-think--live"), children: [
1623
1634
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1624
- "div",
1635
+ "button",
1625
1636
  {
1626
- onClick: () => setIsOpen(!isOpen),
1627
- style: {
1628
- display: "flex",
1629
- alignItems: "center",
1630
- gap: "6px",
1631
- color: "#71717a",
1632
- cursor: "pointer",
1633
- fontWeight: 500,
1634
- userSelect: "none"
1635
- },
1637
+ type: "button",
1638
+ className: cn("hsk-cb-think-head", !expandable && "hsk-cb-think-head--static"),
1639
+ onClick: expandable ? () => setIsOpen((o) => !o) : void 0,
1640
+ "aria-expanded": expandable ? isOpen : void 0,
1636
1641
  children: [
1637
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
1638
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", style: { animation: !isComplete ? "spin 3s linear infinite" : "none" }, children: [
1639
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
1640
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M12 6v6l4 2" })
1641
- ] }),
1642
- "Thinking Process"
1642
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: "13", height: "13", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: !isComplete ? "hsk-cb-think-spin" : void 0, children: [
1643
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
1644
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M12 6v6l4 2" })
1643
1645
  ] }),
1644
- !isComplete && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: {
1645
- width: "6px",
1646
- height: "6px",
1647
- borderRadius: "50%",
1648
- backgroundColor: "#3b82f6",
1649
- display: "inline-block",
1650
- animation: "hsk-pulse 1.2s infinite ease-in-out"
1651
- } }),
1652
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: {
1653
- fontSize: "0.7rem",
1654
- marginLeft: "auto",
1655
- transform: isOpen ? "rotate(90deg)" : "none",
1656
- transition: "transform 0.1s"
1657
- }, children: "\u25B6" })
1646
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: label }),
1647
+ expandable && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: cn("hsk-cb-think-chevron", isOpen && "hsk-cb-think-chevron--open"), children: "\u25B6" })
1658
1648
  ]
1659
1649
  }
1660
1650
  ),
1661
- isOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
1662
- marginTop: "6px",
1663
- color: "#52525b",
1664
- whiteSpace: "pre-wrap",
1665
- lineHeight: "1.4",
1666
- fontStyle: "italic"
1667
- }, children: text })
1651
+ expandable && isOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-think-body", children: text })
1668
1652
  ] });
1669
1653
  }
1670
1654
  function ChatModal({
@@ -1684,7 +1668,7 @@ function ChatModal({
1684
1668
  visionCategoryHint
1685
1669
  }) {
1686
1670
  const client = (0, import_sdk6.useAkropolysContext)();
1687
- const { messages, sources, loading, streaming, error, lastAction, lastIntent, send, stop, stopped, continueGenerating, reset, referencedIds } = (0, import_sdk5.useKiku)();
1671
+ const { messages, sources, loading, streaming, error, lastAction, lastIntent, send, stop, stopped, interrupted, continueGenerating, reset, referencedIds } = (0, import_sdk5.useKiku)();
1688
1672
  const [input, setInput] = (0, import_react5.useState)("");
1689
1673
  const [shopperName, setShopperNameState] = (0, import_react5.useState)(() => {
1690
1674
  try {
@@ -1774,6 +1758,15 @@ function ChatModal({
1774
1758
  const [keyPhase, setKeyPhase] = (0, import_react5.useState)("idle");
1775
1759
  const [mintedKey, setMintedKey] = (0, import_react5.useState)(null);
1776
1760
  const [mintedPub, setMintedPub] = (0, import_react5.useState)(null);
1761
+ const [copied, setCopied] = (0, import_react5.useState)(null);
1762
+ const copyValue = (value, which) => {
1763
+ try {
1764
+ navigator.clipboard?.writeText(value);
1765
+ } catch {
1766
+ }
1767
+ setCopied(which);
1768
+ setTimeout(() => setCopied((c) => c === which ? null : c), 1600);
1769
+ };
1777
1770
  const [keyCountdown, setKeyCountdown] = (0, import_react5.useState)(KIKU_KEY_REVEAL_SECONDS);
1778
1771
  const [minting, setMinting] = (0, import_react5.useState)(false);
1779
1772
  const [showKikuPicker, setShowKikuPicker] = (0, import_react5.useState)(false);
@@ -2097,9 +2090,12 @@ function ChatModal({
2097
2090
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SparkleIcon2, {}) }),
2098
2091
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-ai-body", children: [
2099
2092
  (() => {
2100
- const { thinking, content, isComplete } = parseThinking(displayContent);
2093
+ const parsed = parseThinking(displayContent);
2094
+ const thinking = msg.thinking || parsed.thinking;
2095
+ const content = parsed.content;
2096
+ const isComplete = msg.thinking ? content.length > 0 || !(isLast && streaming) : parsed.isComplete;
2101
2097
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
2102
- thinking && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ThinkingBlock, { text: thinking, isComplete }),
2098
+ (thinking || msg.thoughtForSeconds != null) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ThinkingBlock, { text: thinking, isComplete, seconds: msg.thoughtForSeconds }),
2103
2099
  content && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-ai-text", children: [
2104
2100
  renderMarkdown(content, isLast && streaming),
2105
2101
  isLast && streaming && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: { display: "inline-block", width: "0.5em", height: "1.05em", marginLeft: "2px", verticalAlign: "text-bottom", background: "currentColor", opacity: 0.55, borderRadius: "1px" } })
@@ -2192,11 +2188,24 @@ function ChatModal({
2192
2188
  ] }),
2193
2189
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hsk-cb-thinking-text", children: "Thinking\u2026" })
2194
2190
  ] }),
2195
- stopped && !loading && !streaming && messages[messages.length - 1]?.role === "assistant" && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-stopped", children: [
2196
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hsk-cb-stopped-label", children: "You stopped this response." }),
2191
+ lastAction?.type === "open_memory" && lastAction.url && !loading && !streaming && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
2192
+ "a",
2193
+ {
2194
+ className: "hsk-cb-memory-pill",
2195
+ href: String(lastAction.url),
2196
+ target: "_blank",
2197
+ rel: "noopener noreferrer",
2198
+ children: [
2199
+ "Open my memory on mimi",
2200
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ExternalIcon, {})
2201
+ ]
2202
+ }
2203
+ ),
2204
+ (stopped || interrupted) && !loading && !streaming && messages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-stopped", children: [
2205
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hsk-cb-stopped-label", children: stopped ? "You stopped this response." : "This response was interrupted." }),
2197
2206
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("button", { className: "hsk-cb-continue", onClick: continueGenerating, children: [
2198
2207
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ContinueIcon, {}),
2199
- "Continue generating"
2208
+ messages[messages.length - 1]?.role === "assistant" ? "Continue generating" : "Generate response"
2200
2209
  ] })
2201
2210
  ] }),
2202
2211
  error && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-error", children: getFriendlyError(error) }),
@@ -2229,12 +2238,7 @@ function ChatModal({
2229
2238
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { fontSize: 12, fontWeight: 600, marginBottom: 4 }, children: "Your secret \u2014 shown only once" }),
2230
2239
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { style: { display: "block", fontSize: 14, fontWeight: 700, marginBottom: 6, wordBreak: "break-all" }, children: mintedKey }),
2231
2240
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", gap: 8, alignItems: "center" }, children: [
2232
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: "hsk-cb-phone-submit", style: { padding: "4px 10px" }, onClick: () => {
2233
- try {
2234
- navigator.clipboard?.writeText(mintedKey);
2235
- } catch {
2236
- }
2237
- }, children: "Copy secret" }),
2241
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: "hsk-cb-phone-submit", style: { padding: "4px 10px" }, onClick: () => copyValue(mintedKey, "secret"), children: copied === "secret" ? "Copied" : "Copy secret" }),
2238
2242
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: { fontSize: 11, opacity: 0.7 }, children: "Keep it private \u2014 use it to unlock your memory at mimi.akropolys.cloud. If lost, the memory is lost with it." })
2239
2243
  ] })
2240
2244
  ] }),
@@ -2242,12 +2246,7 @@ function ChatModal({
2242
2246
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { fontSize: 12, fontWeight: 600, marginBottom: 4 }, children: "Your public id" }),
2243
2247
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { style: { display: "block", fontSize: 13, fontWeight: 600, marginBottom: 6, wordBreak: "break-all", opacity: 0.85 }, children: mintedPub }),
2244
2248
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", gap: 8, alignItems: "center" }, children: [
2245
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: "hsk-cb-phone-submit", style: { padding: "4px 10px" }, onClick: () => {
2246
- try {
2247
- navigator.clipboard?.writeText(mintedPub);
2248
- } catch {
2249
- }
2250
- }, children: "Copy id" }),
2249
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: "hsk-cb-phone-submit", style: { padding: "4px 10px" }, onClick: () => copyValue(mintedPub, "pub"), children: copied === "pub" ? "Copied" : "Copy id" }),
2251
2250
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: { fontSize: 11, opacity: 0.7 }, children: "Paste this on any site to keep saving to the same memory." })
2252
2251
  ] })
2253
2252
  ] }),