Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Use the dsh-deep-ui core and scope show_view per session

Fei2411ef14620bb338
diff --git a/docs/plans/2026-10-20-widget-views.md b/docs/plans/2026-10-20-widget-views.md
index a31d8d44..4fb0cce3 100644
--- a/docs/plans/2026-10-20-widget-views.md
+++ b/docs/plans/2026-10-20-widget-views.md
@@ -130,9 +130,12 @@ Bot 的回答现在只有 Markdown 文本。有些回答天生是结构化的:
- 已答视图在会话压缩后只剩一行摘要,Bot 看不到当时的完整蓝图。
- 8 KiB 上限是按 DSH 会话日志里 `ask_user_question` 参数的现有形状定的起点,未在真实持久化日志里验证过 DSH/供应商的硬上限;冒烟测试要实测接近上限和超限的调用。
+蓝图、公式、回复格式和卡片组件的实现收在独立的 `dsh-deep-ui` 包里,ds-bot 依赖它,不再自带一份。ds-bot 也不再全局注册 `show_view`:每个 Bot 自己的会话和群会话都在自己的 Agent 作用域里注册同名工具(作用域注册压过全局注册),所以另一个插件的全局 `show_view`(比如 Deep UI)只管 ds-bot 不管的会话;群里调用照样被 ds-bot 的注册拦下,回「只能在自己的会话里画视图」。
+
## 变更
- 2026-10-20:初稿(声明式目录,第二版)。评审:Antigravity 否决第一版 iframe 方案;Codex 一审(ship with changes):state.views 独立、已答视图在回复节点、交互组合规则、未提交输入的限制、摘要带关键值。
- 2026-10-20:Codex 二审(ship with changes):concludeTurn 绑定生效后的 await_reply;回复格式改判别字段双分支;标识唯一性和 values 形状定死;首次提交结算整张卡;views 与 questions 共存规则写明。
- 2026-10-20:Codex 三审签字(ship,无需再改)。
- 2026-10-23:第三版(#468):图表、输入控件和公式、row/callout/sources、沙箱 html;只展示的视图去掉外框和「视图」标签,标题可选。
+- 2026-10-27:核心代码移入独立的 dsh-deep-ui 包;show_view 改为按会话在 Agent 作用域注册,让位给全局注册的同名工具。
diff --git a/ds-bot/client.js b/ds-bot/client.js
index f6327bbc..2e1aae27 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -689,6 +689,7 @@ var ZH = {
"Copy data": "复制数据",
"Download image": "下载图片",
"This view tried to open a page and was stopped.": "这个视图想打开一个网页,已被拦下。",
+ "Send to Bot": "发给 Bot",
// Secrets
"All Bots": "所有 Bot",
"No Bot": "没有 Bot",
@@ -1422,8 +1423,8 @@ function bodyOf(def, paint, flat = false) {
return "";
}
}
-var eyeMarkup = ([cx, cy, w, h44, tilt]) => `<g transform="translate(${cx} ${cy}) rotate(${tilt})"><rect class="bt-eye" x="${-w / 2}" y="${-h44 / 2}" width="${w}" height="${h44}" rx="${w / 2}"/></g>`;
-var happyEyeMarkup = ([cx, cy, w, h44, tilt]) => `<g transform="translate(${cx} ${cy}) rotate(${tilt})"><path class="bt-eye-happy" opacity="0" d="M${-w * 0.62} ${h44 * 0.14}Q0 ${-h44 * 0.42} ${w * 0.62} ${h44 * 0.14}" fill="none" stroke="#000" stroke-width="${w * 0.5}" stroke-linecap="round"/></g>`;
+var eyeMarkup = ([cx, cy, w, h46, tilt]) => `<g transform="translate(${cx} ${cy}) rotate(${tilt})"><rect class="bt-eye" x="${-w / 2}" y="${-h46 / 2}" width="${w}" height="${h46}" rx="${w / 2}"/></g>`;
+var happyEyeMarkup = ([cx, cy, w, h46, tilt]) => `<g transform="translate(${cx} ${cy}) rotate(${tilt})"><path class="bt-eye-happy" opacity="0" d="M${-w * 0.62} ${h46 * 0.14}Q0 ${-h46 * 0.42} ${w * 0.62} ${h46 * 0.14}" fill="none" stroke="#000" stroke-width="${w * 0.5}" stroke-linecap="round"/></g>`;
var maskBox = (size) => `maskUnits="userSpaceOnUse" x="${-size}" y="${-size}" width="${size * 3}" height="${size * 3}"`;
var holes = (def, eyes) => `<rect x="${-def.size}" y="${-def.size}" width="${def.size * 3}" height="${def.size * 3}" fill="#fff"/>${eyes}`;
var MASK_ID = "%MASK%";
@@ -2165,12 +2166,12 @@ function liveSprings(apply2) {
const dt = Math.min(0.5, Math.max(1e-3, (now - last) / 1e3));
last = now;
const steps = Math.ceil(dt * 240);
- const h44 = dt / steps;
+ const h46 = dt / steps;
let moving = false;
for (const value of values.values()) {
for (let index = 0; index < steps; index += 1) {
- value.v += (-value.k * (value.x - value.to) - value.c * value.v) * h44;
- value.x += value.v * h44;
+ value.v += (-value.k * (value.x - value.to) - value.c * value.v) * h46;
+ value.x += value.v * h46;
}
if (Math.abs(value.x - value.to) < 0.05 && Math.abs(value.v) < 1) {
value.x = value.to;
@@ -4245,7 +4246,74 @@ var HANDOFF_CSS = `
.bt-handoff .bt-q-foot{flex-wrap:wrap}
`;
-// src/shared/formula.js
+// ../../../DeepSeek Bot/deep-ui/src/react/ui.js
+var import_react7 = require("react");
+var FallbackMarkdown = ({ text }) => (0, import_react7.createElement)("span", null, String(text ?? ""));
+var ViewUi = (0, import_react7.createContext)({ t: (key) => key, Markdown: FallbackMarkdown });
+var useViewUi = () => (0, import_react7.useContext)(ViewUi);
+var lineIcon2 = (paths) => function LineIcon() {
+ return (0, import_react7.createElement)(
+ "svg",
+ { width: 15, height: 15, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },
+ paths.map((d, index) => (0, import_react7.createElement)("path", { key: index, d }))
+ );
+};
+var DotsIcon2 = lineIcon2(["M5 10h.01M10 10h.01M15 10h.01"]);
+var CheckIcon2 = lineIcon2(["M4.5 10.5l3.5 3.5 7.5-8"]);
+var DownloadIcon2 = lineIcon2(["M10 3.5v9", "M6.5 9.5L10 13l3.5-3.5", "M4 16h12"]);
+var CopyIcon2 = lineIcon2(["M8.5 7h6A1.5 1.5 0 0 1 16 8.5v6a1.5 1.5 0 0 1-1.5 1.5h-6A1.5 1.5 0 0 1 7 14.5v-6A1.5 1.5 0 0 1 8.5 7z", "M4 12.5V5.5A1.5 1.5 0 0 1 5.5 4H13"]);
+var InfoIcon2 = lineIcon2(["M10 3.5a6.5 6.5 0 1 1 0 13 6.5 6.5 0 0 1 0-13z", "M10 9.25v4", "M10 6.6h.01"]);
+function CloseIcon2() {
+ return (0, import_react7.createElement)("svg", { width: 16, height: 16, viewBox: "0 0 20 20", "aria-hidden": true }, (0, import_react7.createElement)("path", { d: "M5 5l10 10M15 5L5 15", stroke: "currentColor", strokeWidth: 1.6, strokeLinecap: "round" }));
+}
+function Segmented2({ label, value, className, children }) {
+ return (0, import_react7.createElement)("div", { className: className ? `dui-seg ${className}` : "dui-seg", role: "group", "aria-label": label, "data-active": value }, children);
+}
+var keyLetter2 = (index) => String.fromCharCode(65 + index);
+var isTypingTarget2 = (node) => node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement || node instanceof HTMLSelectElement || node instanceof HTMLElement && node.isContentEditable;
+var keyCards = /* @__PURE__ */ (() => {
+ let count = 0;
+ const listeners2 = /* @__PURE__ */ new Set();
+ return {
+ subscribe: (fn) => (listeners2.add(fn), () => listeners2.delete(fn)),
+ getSnapshot: () => count,
+ set: (change) => {
+ count = change(count);
+ for (const fn of listeners2) fn();
+ }
+ };
+})();
+function useOptionKeys2(count, onPick, ownRef) {
+ const pick2 = (0, import_react7.useRef)(onPick);
+ pick2.current = onPick;
+ const listening = (0, import_react7.useSyncExternalStore)(keyCards.subscribe, keyCards.getSnapshot);
+ (0, import_react7.useEffect)(() => {
+ if (count === 0) return void 0;
+ keyCards.set((value) => value + 1);
+ const onKey = (event) => {
+ if (event.defaultPrevented || event.metaKey || event.ctrlKey || event.altKey || event.shiftKey || event.key.length !== 1) return;
+ if (isTypingTarget2(event.target) || isTypingTarget2(document.activeElement)) return;
+ if (document.querySelector('[role="dialog"], [aria-modal="true"]') !== null) return;
+ if (keyCards.getSnapshot() !== 1) return;
+ const index = event.key.toUpperCase().charCodeAt(0) - 65;
+ if (index >= 0 && index < count) {
+ event.preventDefault();
+ pick2.current(index);
+ } else if (index === count && ownRef.current) {
+ event.preventDefault();
+ ownRef.current.focus();
+ }
+ };
+ document.addEventListener("keydown", onKey, true);
+ return () => {
+ document.removeEventListener("keydown", onKey, true);
+ keyCards.set((value) => value - 1);
+ };
+ }, [count, ownRef]);
+ return count > 0 && listening <= 1;
+}
+
+// ../../../DeepSeek Bot/deep-ui/src/core/formula.js
var FUNCTIONS = {
min: { args: [1, Infinity], run: (...values) => Math.min(...values.map(num)) },
max: { args: [1, Infinity], run: (...values) => Math.max(...values.map(num)) },
@@ -4526,7 +4594,7 @@ function evaluate(tree, lookup) {
}
}
-// src/shared/views.js
+// ../../../DeepSeek Bot/deep-ui/src/core/views.js
var LAYOUT = ["stack", "row"];
var DISPLAY = ["text", "metric", "table", "chart", "progress", "callout", "sources", "html"];
var INPUT_TYPES = ["slider", "choice", "toggle", "number"];
@@ -5146,9 +5214,9 @@ function validateForm(node, values) {
return { fields };
}
-// src/client/widget-chart.js
-var import_react7 = require("react");
-var PALETTE = ["var(--bt-accent)", "var(--bt-ink-tangerine)", "var(--bt-ink-green)", "var(--bt-ink-violet)", "var(--bt-ink-sky)", "var(--bt-ink-rose)", "var(--bt-ink-yellow)", "var(--bt-ink-cyan)", "var(--bt-ink-magenta)"];
+// ../../../DeepSeek Bot/deep-ui/src/react/chart.js
+var import_react8 = require("react");
+var PALETTE = ["var(--dui-accent)", "var(--dui-ink-tangerine)", "var(--dui-ink-green)", "var(--dui-ink-violet)", "var(--dui-ink-sky)", "var(--dui-ink-rose)", "var(--dui-ink-yellow)", "var(--dui-ink-cyan)", "var(--dui-ink-magenta)"];
var colorAt = (index) => PALETTE[index % PALETTE.length];
var TICK = 10;
var LABEL = 11;
@@ -5199,8 +5267,8 @@ function chartData(node, lookup) {
return { kind: node.kind ?? "bar", categories, series, unit: typeof node.unit === "string" ? node.unit : "" };
}
var csvCell = (value) => /[",\n]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value;
-function chartCsv({ categories, series, unit }) {
- const head = ["", ...series.map((item, index) => item.name || (series.length === 1 ? unit || t("Value") : `${t("Series")} ${index + 1}`))];
+function chartCsv({ categories, series, unit }, t2 = (key) => key) {
+ const head = ["", ...series.map((item, index) => item.name || (series.length === 1 ? unit || t2("Value") : `${t2("Series")} ${index + 1}`))];
const rows2 = categories.map((label, at) => [label, ...series.map((item) => String(item.values[at]))]);
return [head, ...rows2].map((row) => row.map((cell) => csvCell(String(cell))).join(",")).join("\n");
}
@@ -5226,13 +5294,13 @@ function columns({ categories, series, unit, kind }, width, active, shown) {
const band = plot.w / categories.length;
const parts = [];
for (const tick of ticks) {
- parts.push((0, import_react7.createElement)("line", { key: `g${tick}`, className: "bt-chart-grid", x1: plot.x, x2: plot.x + plot.w, y1: y(tick), y2: y(tick) }));
- parts.push((0, import_react7.createElement)("text", { key: `t${tick}`, className: "bt-chart-tick", x: plot.x - 8, y: y(tick) + 3, textAnchor: "end" }, withUnit(tick, unit)));
+ parts.push((0, import_react8.createElement)("line", { key: `g${tick}`, className: "dui-chart-grid", x1: plot.x, x2: plot.x + plot.w, y1: y(tick), y2: y(tick) }));
+ parts.push((0, import_react8.createElement)("text", { key: `t${tick}`, className: "dui-chart-tick", x: plot.x - 8, y: y(tick) + 3, textAnchor: "end" }, withUnit(tick, unit)));
}
const points = [];
categories.forEach((label, at) => {
const cx = plot.x + band * at + band / 2;
- parts.push((0, import_react7.createElement)("text", { key: `c${at}`, className: "bt-chart-label", x: cx, y: height - 7, textAnchor: "middle" }, fit(label, band - 4, LABEL)));
+ parts.push((0, import_react8.createElement)("text", { key: `c${at}`, className: "dui-chart-label", x: cx, y: height - 7, textAnchor: "middle" }, fit(label, band - 4, LABEL)));
points.push({ x: cx, y: y(Math.max(...visible.map((item) => item.values[at]), lo)) });
});
if (kind === "bar") {
@@ -5249,7 +5317,7 @@ function columns({ categories, series, unit, kind }, width, active, shown) {
const r = Math.min(4, barW / 2, tall);
const up = value >= 0;
const d = up ? `M${x},${top2 + tall}V${top2 + r}q0,-${r} ${r},-${r}h${barW - 2 * r}q${r},0 ${r},${r}V${top2 + tall}z` : `M${x},${top2}V${top2 + tall - r}q0,${r} ${r},${r}h${barW - 2 * r}q${r},0 ${r},-${r}V${top2}z`;
- parts.push((0, import_react7.createElement)("path", { key: `b${at}-${row}`, className: "bt-chart-mark", "data-dim": active !== null && active !== at ? "" : void 0, d, style: { fill: item.color } }));
+ parts.push((0, import_react8.createElement)("path", { key: `b${at}-${row}`, className: "dui-chart-mark", "data-dim": active !== null && active !== at ? "" : void 0, d, style: { fill: item.color } }));
});
});
} else {
@@ -5258,14 +5326,14 @@ function columns({ categories, series, unit, kind }, width, active, shown) {
const line = item.values.map((value, at) => `${at === 0 ? "M" : "L"}${xs[at]},${y(value)}`).join("");
if (kind === "area") {
const base = y(Math.max(lo, Math.min(0, hi)));
- parts.push((0, import_react7.createElement)("path", { key: `a${row}`, className: "bt-chart-area", d: `${line}L${xs.at(-1)},${base}L${xs[0]},${base}z`, style: { fill: item.color } }));
+ parts.push((0, import_react8.createElement)("path", { key: `a${row}`, className: "dui-chart-area", d: `${line}L${xs.at(-1)},${base}L${xs[0]},${base}z`, style: { fill: item.color } }));
}
- parts.push((0, import_react7.createElement)("path", { key: `l${row}`, className: "bt-chart-line", d: line, style: { stroke: item.color } }));
+ parts.push((0, import_react8.createElement)("path", { key: `l${row}`, className: "dui-chart-line", d: line, style: { stroke: item.color } }));
item.values.forEach((value, at) => {
- parts.push((0, import_react7.createElement)("circle", { key: `p${row}-${at}`, className: "bt-chart-dot", cx: xs[at], cy: y(value), r: active === at ? 4 : 2.5, style: { fill: item.color } }));
+ parts.push((0, import_react8.createElement)("circle", { key: `p${row}-${at}`, className: "dui-chart-dot", cx: xs[at], cy: y(value), r: active === at ? 4 : 2.5, style: { fill: item.color } }));
});
});
- if (active !== null) parts.unshift((0, import_react7.createElement)("line", { key: "guide", className: "bt-chart-guide", x1: xs[active], x2: xs[active], y1: plot.y, y2: plot.y + plot.h }));
+ if (active !== null) parts.unshift((0, import_react8.createElement)("line", { key: "guide", className: "dui-chart-guide", x1: xs[active], x2: xs[active], y1: plot.y, y2: plot.y + plot.h }));
}
const hits = categories.map((_, at) => ({ x: plot.x + band * at, y: plot.y, w: band, h: plot.h }));
return { parts, height, points, hits };
@@ -5285,21 +5353,21 @@ function rows({ categories, series, unit }, width, active, shown) {
const x = (value) => plot.x + (value - lo) / (hi - lo) * plot.w;
const parts = [];
for (const tick of ticks) {
- parts.push((0, import_react7.createElement)("line", { key: `g${tick}`, className: "bt-chart-grid", x1: x(tick), x2: x(tick), y1: plot.y, y2: plot.y + plot.h }));
- parts.push((0, import_react7.createElement)("text", { key: `t${tick}`, className: "bt-chart-tick", x: x(tick), y: height - 6, textAnchor: "middle" }, withUnit(tick, unit)));
+ parts.push((0, import_react8.createElement)("line", { key: `g${tick}`, className: "dui-chart-grid", x1: x(tick), x2: x(tick), y1: plot.y, y2: plot.y + plot.h }));
+ parts.push((0, import_react8.createElement)("text", { key: `t${tick}`, className: "dui-chart-tick", x: x(tick), y: height - 6, textAnchor: "middle" }, withUnit(tick, unit)));
}
const points = [];
const zero = x(Math.max(lo, Math.min(0, hi)));
categories.forEach((label, at) => {
const rowY = plot.y + rowH * at + 5;
- parts.push((0, import_react7.createElement)("text", { key: `c${at}`, className: "bt-chart-label", x: labelW - 10, y: rowY + (rowH - 10) / 2 + 4, textAnchor: "end" }, fit(label, labelW - 12, LABEL)));
+ parts.push((0, import_react8.createElement)("text", { key: `c${at}`, className: "dui-chart-label", x: labelW - 10, y: rowY + (rowH - 10) / 2 + 4, textAnchor: "end" }, fit(label, labelW - 12, LABEL)));
visible.forEach((item, row) => {
const value = item.values[at];
const by = rowY + row * (barH + 2);
const left = Math.min(x(value), zero);
const long = Math.max(1, Math.abs(x(value) - zero));
- parts.push((0, import_react7.createElement)("rect", { key: `b${at}-${row}`, className: "bt-chart-mark", "data-dim": active !== null && active !== at ? "" : void 0, x: left, y: by, width: long, height: barH, rx: Math.min(4, long / 2), style: { fill: item.color } }));
- parts.push((0, import_react7.createElement)("text", { key: `v${at}-${row}`, className: "bt-chart-value", x: left + long + 6, y: by + barH - 3 }, withUnit(value, unit)));
+ parts.push((0, import_react8.createElement)("rect", { key: `b${at}-${row}`, className: "dui-chart-mark", "data-dim": active !== null && active !== at ? "" : void 0, x: left, y: by, width: long, height: barH, rx: Math.min(4, long / 2), style: { fill: item.color } }));
+ parts.push((0, import_react8.createElement)("text", { key: `v${at}-${row}`, className: "dui-chart-value", x: left + long + 6, y: by + barH - 3 }, withUnit(value, unit)));
});
points.push({ x: Math.max(...visible.map((item) => x(item.values[at])), zero), y: rowY });
});
@@ -5327,15 +5395,15 @@ function donut({ categories, series }, width, active, hover) {
const full2 = sweep >= Math.PI * 2 - 1e-6;
const p = (radius, theta) => `${cx + Math.cos(theta) * radius},${cy + Math.sin(theta) * radius}`;
const d = full2 ? `M${p(r, angle)}A${r},${r} 0 1 1 ${p(r, angle + Math.PI)}A${r},${r} 0 1 1 ${p(r, angle)}M${p(inner, angle)}A${inner},${inner} 0 1 0 ${p(inner, angle + Math.PI)}A${inner},${inner} 0 1 0 ${p(inner, angle)}z` : `M${p(r, angle)}A${r},${r} 0 ${large} 1 ${p(r, end)}L${p(inner, end)}A${inner},${inner} 0 ${large} 0 ${p(inner, angle)}z`;
- parts.push((0, import_react7.createElement)("path", { key: `s${at}`, className: "bt-chart-mark", "data-dim": active !== null && active !== at ? "" : void 0, d, fillRule: "evenodd", style: { fill: colorAt(at) }, onPointerEnter: () => hover(at) }));
+ parts.push((0, import_react8.createElement)("path", { key: `s${at}`, className: "dui-chart-mark", "data-dim": active !== null && active !== at ? "" : void 0, d, fillRule: "evenodd", style: { fill: colorAt(at) }, onPointerEnter: () => hover(at) }));
}
angle = end;
});
return { parts, height: size, size, points, total, values, categories };
}
function useWidth(box, initial) {
- const [width, setWidth] = (0, import_react7.useState)(initial);
- (0, import_react7.useLayoutEffect)(() => {
+ const [width, setWidth] = (0, import_react8.useState)(initial);
+ (0, import_react8.useLayoutEffect)(() => {
const node = box.current;
if (!node || typeof ResizeObserver !== "function") return void 0;
const measure = () => {
@@ -5362,7 +5430,7 @@ function saveImage(svg, name) {
const height = Number(svg.getAttribute("height"));
clone.setAttribute("xmlns", "http://www.w3.org/2000/svg");
const page = getComputedStyle(document.body);
- const background = page.getPropertyValue("--bt-main").trim() || page.backgroundColor;
+ const background = page.getPropertyValue("--dui-main").trim() || page.backgroundColor;
const url = URL.createObjectURL(new Blob([new XMLSerializer().serializeToString(clone)], { type: "image/svg+xml" }));
const image = new Image();
image.onload = () => {
@@ -5389,51 +5457,53 @@ function saveImage(svg, name) {
image.onerror = () => URL.revokeObjectURL(url);
image.src = url;
}
-var TableIcon = () => (0, import_react7.createElement)(
+var TableIcon = () => (0, import_react8.createElement)(
"svg",
{ width: 16, height: 16, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.6, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },
- (0, import_react7.createElement)("path", { d: "M4.5 4h11A1.5 1.5 0 0 1 17 5.5v9a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 14.5v-9A1.5 1.5 0 0 1 4.5 4z" }),
- (0, import_react7.createElement)("path", { d: "M3 8.5h14M8 8.5V16" })
+ (0, import_react8.createElement)("path", { d: "M4.5 4h11A1.5 1.5 0 0 1 17 5.5v9a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 14.5v-9A1.5 1.5 0 0 1 4.5 4z" }),
+ (0, import_react8.createElement)("path", { d: "M3 8.5h14M8 8.5V16" })
);
function ChartTable({ data }) {
+ const ui2 = useViewUi();
const { categories, series, unit } = data;
- const heads = series.map((item, index) => item.name || (series.length === 1 ? unit || t("Value") : `${t("Series")} ${index + 1}`));
- return (0, import_react7.createElement)(
+ const heads = series.map((item, index) => item.name || (series.length === 1 ? unit || ui2.t("Value") : `${ui2.t("Series")} ${index + 1}`));
+ return (0, import_react8.createElement)(
"div",
- { className: "bt-widget-table" },
- (0, import_react7.createElement)(
+ { className: "dui-widget-table" },
+ (0, import_react8.createElement)(
"table",
null,
- (0, import_react7.createElement)("thead", null, (0, import_react7.createElement)("tr", null, (0, import_react7.createElement)("th", { scope: "col" }), heads.map((head, index) => (0, import_react7.createElement)("th", { key: index, scope: "col", className: "bt-num" }, head)))),
- (0, import_react7.createElement)("tbody", null, categories.map((label, at) => (0, import_react7.createElement)(
+ (0, import_react8.createElement)("thead", null, (0, import_react8.createElement)("tr", null, (0, import_react8.createElement)("th", { scope: "col" }), heads.map((head, index) => (0, import_react8.createElement)("th", { key: index, scope: "col", className: "dui-num" }, head)))),
+ (0, import_react8.createElement)("tbody", null, categories.map((label, at) => (0, import_react8.createElement)(
"tr",
{ key: at },
- (0, import_react7.createElement)("th", { scope: "row" }, label),
- series.map((item, index) => (0, import_react7.createElement)("td", { key: index, className: "bt-num" }, withUnit(item.values[at], series.length === 1 && !item.name ? "" : unit)))
+ (0, import_react8.createElement)("th", { scope: "row" }, label),
+ series.map((item, index) => (0, import_react8.createElement)("td", { key: index, className: "dui-num" }, withUnit(item.values[at], series.length === 1 && !item.name ? "" : unit)))
)))
)
);
}
function WidgetChart({ node, lookup, registerChart, refreshCharts }) {
+ const ui2 = useViewUi();
const data = chartData(node, lookup);
const { kind, categories, series, unit } = data;
- const box = (0, import_react7.useRef)(null);
- const svg = (0, import_react7.useRef)(null);
+ const box = (0, import_react8.useRef)(null);
+ const svg = (0, import_react8.useRef)(null);
const width = useWidth(box, 520);
- const [active, setActive] = (0, import_react7.useState)(null);
- const [hidden, setHidden] = (0, import_react7.useState)([]);
- const [asTable, setAsTable] = (0, import_react7.useState)(false);
- const [copied, setCopied] = (0, import_react7.useState)(false);
- const labelId = (0, import_react7.useId)();
- const menuKey = (0, import_react7.useId)();
- const table = (0, import_react7.useRef)(asTable);
+ const [active, setActive] = (0, import_react8.useState)(null);
+ const [hidden, setHidden] = (0, import_react8.useState)([]);
+ const [asTable, setAsTable] = (0, import_react8.useState)(false);
+ const [copied, setCopied] = (0, import_react8.useState)(false);
+ const labelId = (0, import_react8.useId)();
+ const menuKey = (0, import_react8.useId)();
+ const table = (0, import_react8.useRef)(asTable);
table.current = asTable;
const shown = series.map((_, index) => !hidden.includes(index));
const toggle = (index) => {
if (hidden.includes(index)) setHidden(hidden.filter((item) => item !== index));
else if (shown.filter(Boolean).length > 1) setHidden([...hidden, index]);
};
- const label = typeof node.caption === "string" && node.caption !== "" ? node.caption : t("Chart");
+ const label = typeof node.caption === "string" && node.caption !== "" ? node.caption : ui2.t("Chart");
const isDonut = kind === "donut";
const legendBeside = isDonut && width >= 360;
const drawn = isDonut ? donut(data, legendBeside ? width - 200 : width, active, setActive) : kind === "hbar" ? rows(data, width, active, shown) : columns(data, width, active, shown);
@@ -5452,7 +5522,7 @@ function WidgetChart({ node, lookup, registerChart, refreshCharts }) {
const share = (at) => unit === "%" ? withUnit(drawn.values[at], unit) : `${withUnit(drawn.values[at], unit)} · ${drawn.total > 0 ? Math.round(drawn.values[at] / drawn.total * 100) : 0}%`;
const tipRows = active === null || isDonut ? [] : series.filter((_, index) => shown[index]).map((item) => ({ color: item.color, name: item.name, value: withUnit(item.values[active], unit) }));
const copy2 = () => {
- void navigator.clipboard?.writeText(chartCsv(data)).then(() => {
+ void navigator.clipboard?.writeText(chartCsv(data, ui2.t)).then(() => {
setCopied(true);
setTimeout(() => setCopied(false), 1200);
});
@@ -5462,11 +5532,11 @@ function WidgetChart({ node, lookup, registerChart, refreshCharts }) {
setAsTable(table.current);
};
const menuLabel = typeof node.caption === "string" && node.caption !== "" ? node.caption : null;
- const action = (0, import_react7.useRef)(null);
+ const action = (0, import_react8.useRef)(null);
action.current = { label: menuLabel, copy: copy2, save: () => {
if (svg.current) saveImage(svg.current, "chart.png");
}, toggleTable };
- (0, import_react7.useEffect)(() => registerChart?.(menuKey, {
+ (0, import_react8.useEffect)(() => registerChart?.(menuKey, {
get label() {
return action.current.label;
},
@@ -5477,34 +5547,34 @@ function WidgetChart({ node, lookup, registerChart, refreshCharts }) {
copy: () => action.current.copy(),
save: () => action.current.save()
}), [registerChart, menuKey]);
- (0, import_react7.useEffect)(() => refreshCharts?.(), [refreshCharts, asTable, menuLabel]);
- const legend = isDonut ? (0, import_react7.createElement)("div", { className: "bt-chart-legend bt-chart-legend-list" }, categories.map((name, at) => (0, import_react7.createElement)(
+ (0, import_react8.useEffect)(() => refreshCharts?.(), [refreshCharts, asTable, menuLabel]);
+ const legend = isDonut ? (0, import_react8.createElement)("div", { className: "dui-chart-legend dui-chart-legend-list" }, categories.map((name, at) => (0, import_react8.createElement)(
"div",
{
key: at,
- className: "bt-chart-key",
+ className: "dui-chart-key",
"data-dim": active !== null && active !== at ? "" : void 0,
onPointerEnter: () => setActive(at),
onPointerLeave: () => setActive(null)
},
- (0, import_react7.createElement)("i", { style: { background: colorAt(at) } }),
- (0, import_react7.createElement)("span", { className: "bt-chart-key-name" }, name),
- (0, import_react7.createElement)("span", { className: "bt-chart-key-value" }, share(at))
- ))) : series.length > 1 ? (0, import_react7.createElement)("div", { className: "bt-chart-legend" }, series.map((item, index) => (0, import_react7.createElement)("button", {
+ (0, import_react8.createElement)("i", { style: { background: colorAt(at) } }),
+ (0, import_react8.createElement)("span", { className: "dui-chart-key-name" }, name),
+ (0, import_react8.createElement)("span", { className: "dui-chart-key-value" }, share(at))
+ ))) : series.length > 1 ? (0, import_react8.createElement)("div", { className: "dui-chart-legend" }, series.map((item, index) => (0, import_react8.createElement)("button", {
key: index,
type: "button",
- className: "bt-chart-key",
+ className: "dui-chart-key",
"aria-pressed": shown[index],
onClick: () => toggle(index)
- }, (0, import_react7.createElement)("i", { style: { background: item.color } }), item.name || `${t("Series")} ${index + 1}`))) : null;
- const plot = (0, import_react7.createElement)(
+ }, (0, import_react8.createElement)("i", { style: { background: item.color } }), item.name || `${ui2.t("Series")} ${index + 1}`))) : null;
+ const plot = (0, import_react8.createElement)(
"div",
- { className: "bt-chart-plot", style: isDonut ? { width: svgWidth } : void 0 },
- (0, import_react7.createElement)(
+ { className: "dui-chart-plot", style: isDonut ? { width: svgWidth } : void 0 },
+ (0, import_react8.createElement)(
"svg",
{
ref: svg,
- className: "bt-chart-svg",
+ className: "dui-chart-svg",
width: svgWidth,
height: drawn.height,
viewBox: `0 0 ${svgWidth} ${drawn.height}`,
@@ -5516,87 +5586,103 @@ function WidgetChart({ node, lookup, registerChart, refreshCharts }) {
onPointerLeave: () => setActive(null)
},
drawn.parts,
- isDonut ? active === null ? (0, import_react7.createElement)("text", { className: "bt-chart-center", x: svgWidth / 2, y: drawn.height / 2 + 5, textAnchor: "middle" }, unit === "%" ? "" : withUnit(drawn.total, unit)) : (0, import_react7.createElement)(
- import_react7.Fragment,
+ isDonut ? active === null ? (0, import_react8.createElement)("text", { className: "dui-chart-center", x: svgWidth / 2, y: drawn.height / 2 + 5, textAnchor: "middle" }, unit === "%" ? "" : withUnit(drawn.total, unit)) : (0, import_react8.createElement)(
+ import_react8.Fragment,
null,
- (0, import_react7.createElement)("text", { className: "bt-chart-center-name", x: svgWidth / 2, y: drawn.height / 2 - 4, textAnchor: "middle" }, fit(categories[active], drawn.size * 0.56, LABEL)),
- (0, import_react7.createElement)("text", { className: "bt-chart-center", x: svgWidth / 2, y: drawn.height / 2 + 14, textAnchor: "middle" }, share(active))
- ) : drawn.hits.map((hit, at) => (0, import_react7.createElement)("rect", { key: `h${at}`, className: "bt-chart-hit", x: hit.x, y: hit.y, width: hit.w, height: hit.h, onPointerEnter: () => setActive(at) }))
+ (0, import_react8.createElement)("text", { className: "dui-chart-center-name", x: svgWidth / 2, y: drawn.height / 2 - 4, textAnchor: "middle" }, fit(categories[active], drawn.size * 0.56, LABEL)),
+ (0, import_react8.createElement)("text", { className: "dui-chart-center", x: svgWidth / 2, y: drawn.height / 2 + 14, textAnchor: "middle" }, share(active))
+ ) : drawn.hits.map((hit, at) => (0, import_react8.createElement)("rect", { key: `h${at}`, className: "dui-chart-hit", x: hit.x, y: hit.y, width: hit.w, height: hit.h, onPointerEnter: () => setActive(at) }))
),
- point && !asTable && !isDonut ? (0, import_react7.createElement)(
+ point && !asTable && !isDonut ? (0, import_react8.createElement)(
"div",
- { className: "bt-chart-tip", role: "status", style: { left: point.x, top: point.y } },
- (0, import_react7.createElement)("b", null, categories[active]),
- tipRows.map((row, index) => (0, import_react7.createElement)("span", { key: index }, (0, import_react7.createElement)("i", { style: { background: row.color } }), row.name ? `${row.name} ` : "", row.value))
+ { className: "dui-chart-tip", role: "status", style: { left: point.x, top: point.y } },
+ (0, import_react8.createElement)("b", null, categories[active]),
+ tipRows.map((row, index) => (0, import_react8.createElement)("span", { key: index }, (0, import_react8.createElement)("i", { style: { background: row.color } }), row.name ? `${row.name} ` : "", row.value))
) : null
);
- const body = asTable ? (0, import_react7.createElement)(ChartTable, { data }) : isDonut ? (0, import_react7.createElement)("div", { className: legendBeside ? "bt-chart-donut bt-chart-donut-beside" : "bt-chart-donut", onPointerLeave: () => setActive(null) }, plot, legend) : (0, import_react7.createElement)(import_react7.Fragment, null, legend, plot);
- return (0, import_react7.createElement)(
+ const body = asTable ? (0, import_react8.createElement)(ChartTable, { data }) : isDonut ? (0, import_react8.createElement)("div", { className: legendBeside ? "dui-chart-donut dui-chart-donut-beside" : "dui-chart-donut", onPointerLeave: () => setActive(null) }, plot, legend) : (0, import_react8.createElement)(import_react8.Fragment, null, legend, plot);
+ return (0, import_react8.createElement)(
"figure",
- { ref: box, className: "bt-chart", "data-kind": kind },
- (0, import_react7.createElement)("span", { id: labelId, hidden: true }, label),
+ { ref: box, className: "dui-chart", "data-kind": kind },
+ (0, import_react8.createElement)("span", { id: labelId, hidden: true }, label),
body,
// The SVG stays mounted under the table, so the image can still be saved from it.
- asTable ? (0, import_react7.createElement)("div", { hidden: true }, plot) : null,
- copied ? (0, import_react7.createElement)("span", { className: "bt-chart-copied", role: "status" }, t("Copied")) : null,
- typeof node.caption === "string" && node.caption !== "" ? (0, import_react7.createElement)("figcaption", { className: "bt-view-caption" }, node.caption) : null
+ asTable ? (0, import_react8.createElement)("div", { hidden: true }, plot) : null,
+ copied ? (0, import_react8.createElement)("span", { className: "dui-chart-copied", role: "status" }, ui2.t("Copied")) : null,
+ typeof node.caption === "string" && node.caption !== "" ? (0, import_react8.createElement)("figcaption", { className: "dui-view-caption" }, node.caption) : null
);
}
var CHART_CSS = `
-.bt-chart{position:relative;margin:0;min-width:0;display:flex;flex-direction:column;gap:8px}
-.bt-chart-plot{position:relative;min-width:0}
-.bt-chart-svg{display:block;overflow:visible;outline:none;font-family:inherit}
-.bt-chart-svg text{pointer-events:none}
-.bt-chart-svg:focus-visible{outline:2px solid var(--bt-accent);outline-offset:4px;border-radius:4px}
-.bt-chart-grid{stroke:var(--bt-line);stroke-width:1;stroke-dasharray:3 3}
-.bt-chart-tick{font-size:${TICK}px;fill:var(--bt-ink-3);font-variant-numeric:tabular-nums}
-.bt-chart-label{font-size:${LABEL}px;fill:var(--bt-ink-2)}
-.bt-chart-value{font-size:${LABEL}px;fill:var(--bt-ink-2);font-variant-numeric:tabular-nums}
-.bt-chart-center{font-size:15px;font-weight:600;fill:var(--bt-ink);font-variant-numeric:tabular-nums}
-.bt-chart-center-name{font-size:${LABEL}px;fill:var(--bt-ink-2)}
-.bt-chart-mark{transition:opacity .12s ease}
-.bt-chart-mark[data-dim]{opacity:.28}
-.bt-chart-line{fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
-.bt-chart-area{opacity:.14}
-.bt-chart-dot{transition:r .12s ease}
-.bt-chart-guide{stroke:var(--bt-line-2);stroke-width:1}
-.bt-chart-hit{fill:transparent}
-.bt-chart-tip{position:absolute;z-index:4;pointer-events:none;transform:translate(-50%,calc(-100% - 8px));display:flex;flex-direction:column;gap:2px;padding:6px 10px;border-radius:10px;background:var(--bt-main);border:.5px solid var(--bt-line-2);box-shadow:0 10px 20px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);font-size:12px;line-height:16px;color:var(--bt-ink);white-space:nowrap;font-variant-numeric:tabular-nums;animation:bt-veil-in .12s ease-out}
-.bt-chart-tip b{font-weight:600}
-.bt-chart-tip span{display:flex;align-items:center;gap:6px;color:var(--bt-ink-2)}
-.bt-chart-tip i,.bt-chart-key i{flex:none;width:8px;height:8px;border-radius:50%;corner-shape:round}
-.bt-chart-legend{display:flex;flex-wrap:wrap;gap:4px 12px;padding-right:32px}
-.bt-chart-key{display:inline-flex;align-items:center;gap:6px;min-height:20px;padding:0;border:0;background:none;font:inherit;font-size:12px;line-height:16px;color:var(--bt-ink-2);cursor:pointer;transition:opacity .12s ease}
-.bt-chart-key[aria-pressed=false]{opacity:.4}
-.bt-chart-key:focus-visible{outline:2px solid var(--bt-accent);outline-offset:2px;border-radius:4px}
-.bt-chart-legend-list{flex-direction:column;flex-wrap:nowrap;gap:6px;padding:0;min-width:0}
-.bt-chart-legend-list .bt-chart-key{cursor:default;width:100%}
-.bt-chart-legend-list .bt-chart-key[data-dim]{opacity:.4}
-.bt-chart-key-name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--bt-ink)}
-.bt-chart-key-value{flex:none;font-variant-numeric:tabular-nums}
-.bt-chart-donut{display:flex;flex-direction:column;align-items:center;gap:12px}
-.bt-chart-donut-beside{flex-direction:row;align-items:center;gap:24px}
-.bt-chart-donut-beside .bt-chart-legend-list{flex:1 1 auto;max-width:280px}
-.bt-chart-copied{position:absolute;top:2px;right:36px;font-size:12px;line-height:16px;color:var(--bt-ink-2);animation:bt-veil-in .16s ease-out}
-.bt-widget-table .bt-num{text-align:end;font-variant-numeric:tabular-nums}
-.bt-widget-table tbody th{padding:6px 10px;font-weight:400;text-align:start;color:var(--bt-ink);border-bottom:0}
-@media (prefers-reduced-motion:reduce){.bt-chart-mark,.bt-chart-dot{transition:none}.bt-chart-tip{animation:none}}
+.dui-chart{position:relative;margin:0;min-width:0;display:flex;flex-direction:column;gap:8px}
+.dui-chart-plot{position:relative;min-width:0}
+.dui-chart-svg{display:block;overflow:visible;outline:none;font-family:inherit}
+.dui-chart-svg text{pointer-events:none}
+.dui-chart-svg:focus-visible{outline:2px solid var(--dui-accent);outline-offset:4px;border-radius:4px}
+.dui-chart-grid{stroke:var(--dui-line);stroke-width:1;stroke-dasharray:3 3}
+.dui-chart-tick{font-size:${TICK}px;fill:var(--dui-ink-3);font-variant-numeric:tabular-nums}
+.dui-chart-label{font-size:${LABEL}px;fill:var(--dui-ink-2)}
+.dui-chart-value{font-size:${LABEL}px;fill:var(--dui-ink-2);font-variant-numeric:tabular-nums}
+.dui-chart-center{font-size:15px;font-weight:600;fill:var(--dui-ink);font-variant-numeric:tabular-nums}
+.dui-chart-center-name{font-size:${LABEL}px;fill:var(--dui-ink-2)}
+.dui-chart-mark{transition:opacity .12s ease}
+.dui-chart-mark[data-dim]{opacity:.28}
+.dui-chart-line{fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
+.dui-chart-area{opacity:.14}
+.dui-chart-dot{transition:r .12s ease}
+.dui-chart-guide{stroke:var(--dui-line-2);stroke-width:1}
+.dui-chart-hit{fill:transparent}
+.dui-chart-tip{position:absolute;z-index:4;pointer-events:none;transform:translate(-50%,calc(-100% - 8px));display:flex;flex-direction:column;gap:2px;padding:6px 10px;border-radius:10px;background:var(--dui-main);border:.5px solid var(--dui-line-2);box-shadow:0 10px 20px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);font-size:12px;line-height:16px;color:var(--dui-ink);white-space:nowrap;font-variant-numeric:tabular-nums;animation:dui-veil-in .12s ease-out}
+.dui-chart-tip b{font-weight:600}
+.dui-chart-tip span{display:flex;align-items:center;gap:6px;color:var(--dui-ink-2)}
+.dui-chart-tip i,.dui-chart-key i{flex:none;width:8px;height:8px;border-radius:50%;corner-shape:round}
+.dui-chart-legend{display:flex;flex-wrap:wrap;gap:4px 12px;padding-right:32px}
+.dui-chart-key{display:inline-flex;align-items:center;gap:6px;min-height:20px;padding:0;border:0;background:none;font:inherit;font-size:12px;line-height:16px;color:var(--dui-ink-2);cursor:pointer;transition:opacity .12s ease}
+.dui-chart-key[aria-pressed=false]{opacity:.4}
+.dui-chart-key:focus-visible{outline:2px solid var(--dui-accent);outline-offset:2px;border-radius:4px}
+.dui-chart-legend-list{flex-direction:column;flex-wrap:nowrap;gap:6px;padding:0;min-width:0}
+.dui-chart-legend-list .dui-chart-key{cursor:default;width:100%}
+.dui-chart-legend-list .dui-chart-key[data-dim]{opacity:.4}
+.dui-chart-key-name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dui-ink)}
+.dui-chart-key-value{flex:none;font-variant-numeric:tabular-nums}
+.dui-chart-donut{display:flex;flex-direction:column;align-items:center;gap:12px}
+.dui-chart-donut-beside{flex-direction:row;align-items:center;gap:24px}
+.dui-chart-donut-beside .dui-chart-legend-list{flex:1 1 auto;max-width:280px}
+.dui-chart-copied{position:absolute;top:2px;right:36px;font-size:12px;line-height:16px;color:var(--dui-ink-2);animation:dui-veil-in .16s ease-out}
+.dui-widget-table .dui-num{text-align:end;font-variant-numeric:tabular-nums}
+.dui-widget-table tbody th{padding:6px 10px;font-weight:400;text-align:start;color:var(--dui-ink);border-bottom:0}
+@media (prefers-reduced-motion:reduce){.dui-chart-mark,.dui-chart-dot{transition:none}.dui-chart-tip{animation:none}}
`;
-// src/client/widget-html.js
-var import_react8 = require("react");
-var FRAME_VARS = ["--bt-ink", "--bt-ink-2", "--bt-ink-3", "--bt-line", "--bt-line-2", "--bt-card", "--bt-main", "--bt-hover", "--bt-accent", "--bt-accent-ink", "--bt-green", "--bt-star", "--bt-danger"];
+// ../../../DeepSeek Bot/deep-ui/src/react/frame.js
+var import_react9 = require("react");
+var THEME_VARS = [
+ ["--view-ink", "--bt-ink", "--dui-ink"],
+ ["--view-ink-2", "--bt-ink-2", "--dui-ink-2"],
+ ["--view-ink-3", "--bt-ink-3", "--dui-ink-3"],
+ ["--view-line", "--bt-line", "--dui-line"],
+ ["--view-line-2", "--bt-line-2", "--dui-line-2"],
+ ["--view-card", "--bt-card", "--dui-card"],
+ ["--view-main", "--bt-main", "--dui-main"],
+ ["--view-hover", "--bt-hover", "--dui-hover"],
+ ["--view-accent", "--bt-accent", "--dui-accent"],
+ ["--view-accent-ink", "--bt-accent-ink", "--dui-accent-ink"],
+ ["--view-green", "--bt-green", "--dui-green"],
+ ["--view-star", "--bt-star", "--dui-star"],
+ ["--view-danger", "--bt-danger", "--dui-danger"]
+];
var FRAME_POLICY = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; media-src data: blob:; form-action 'none'; base-uri 'none'";
-var HEIGHT = "bt-view-height";
-var THEME = "bt-view-theme";
+var HEIGHT = "dui-view-height";
+var THEME = "dui-view-theme";
var MIN_HEIGHT = 24;
function themeVars2() {
if (typeof getComputedStyle !== "function" || typeof document === "undefined" || !document.body) return {};
const style = getComputedStyle(document.body);
const vars = {};
- for (const name of FRAME_VARS) {
- const value = style.getPropertyValue(name).trim();
- if (value !== "") vars[name] = value;
+ for (const [view, legacy, source] of THEME_VARS) {
+ const value = style.getPropertyValue(source).trim();
+ if (value === "") continue;
+ vars[view] = value;
+ vars[legacy] = value;
}
vars["color-scheme"] = style.getPropertyValue("color-scheme").trim() || "normal";
return vars;
@@ -5605,15 +5691,16 @@ var cssValue = (value) => String(value).replace(/[<>{};]/g, "");
function frameDocument(html, vars = {}) {
const root = Object.entries(vars).map(([name, value]) => `${name}:${cssValue(value)}`).join(";");
const report = `(()=>{const send=()=>parent.postMessage({type:${JSON.stringify(HEIGHT)},height:Math.ceil(document.documentElement.getBoundingClientRect().height)},'*');new ResizeObserver(send).observe(document.documentElement);addEventListener('load',send);addEventListener('message',e=>{if(e.source!==parent||!e.data||e.data.type!==${JSON.stringify(THEME)})return;for(const[k,v]of Object.entries(e.data.vars||{}))document.documentElement.style.setProperty(k,String(v))})})()`;
- return `<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${FRAME_POLICY}"><style>:root{${root}}html,body{margin:0;padding:0;background:transparent;color:var(--bt-ink);font:14px/22px -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}*{box-sizing:border-box}</style><script>${report}<\/script></head><body>${html}</body></html>`;
+ return `<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${FRAME_POLICY}"><style>:root{${root}}html,body{margin:0;padding:0;background:transparent;color:var(--view-ink,var(--bt-ink));font:14px/22px -apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif}*{box-sizing:border-box}</style><script>${report}<\/script></head><body>${html}</body></html>`;
}
function HtmlFrame({ node }) {
- const frame = (0, import_react8.useRef)(null);
- const loads = (0, import_react8.useRef)(0);
- const [height, setHeight] = (0, import_react8.useState)(Number.isFinite(node.height) ? node.height : 120);
- const [stopped, setStopped] = (0, import_react8.useState)(false);
- const doc = (0, import_react8.useMemo)(() => frameDocument(String(node.html ?? ""), themeVars2()), [node.html]);
- (0, import_react8.useEffect)(() => {
+ const ui2 = useViewUi();
+ const frame = (0, import_react9.useRef)(null);
+ const loads = (0, import_react9.useRef)(0);
+ const [height, setHeight] = (0, import_react9.useState)(Number.isFinite(node.height) ? node.height : 120);
+ const [stopped, setStopped] = (0, import_react9.useState)(false);
+ const doc = (0, import_react9.useMemo)(() => frameDocument(String(node.html ?? ""), themeVars2()), [node.html]);
+ (0, import_react9.useEffect)(() => {
const onMessage = (event) => {
if (event.source !== frame.current?.contentWindow || event.data?.type !== HEIGHT) return;
const next = Number(event.data.height);
@@ -5628,10 +5715,10 @@ function HtmlFrame({ node }) {
observer?.disconnect();
};
}, []);
- if (stopped) return (0, import_react8.createElement)("p", { className: "bt-view-frame-stopped" }, t("This view tried to open a page and was stopped."));
- return (0, import_react8.createElement)("iframe", {
+ if (stopped) return (0, import_react9.createElement)("p", { className: "dui-view-frame-stopped" }, ui2.t("This view tried to open a page and was stopped."));
+ return (0, import_react9.createElement)("iframe", {
ref: frame,
- className: "bt-view-frame",
+ className: "dui-view-frame",
title: String(node.summary ?? ""),
sandbox: "allow-scripts",
srcDoc: doc,
@@ -5644,13 +5731,13 @@ function HtmlFrame({ node }) {
});
}
var HTML_CSS = `
-.bt-view-frame{display:block;width:100%;border:0;background:transparent}
-.bt-view-frame-stopped{margin:0;font-size:13px;line-height:18px;color:var(--bt-ink-2)}
+.dui-view-frame{display:block;width:100%;border:0;background:transparent}
+.dui-view-frame-stopped{margin:0;font-size:13px;line-height:18px;color:var(--dui-ink-2)}
`;
-// src/client/widget-cell.js
-var import_react9 = require("react");
-var mdLabels = () => ({ code: { copyLabel: t("Copy"), copiedLabel: t("Copied") }, footnotes: t("Footnotes") });
+// ../../../DeepSeek Bot/deep-ui/src/react/card.js
+var import_react10 = require("react");
+var mdLabels = (ui2) => ({ code: { copyLabel: ui2.t("Copy"), copiedLabel: ui2.t("Copied") }, footnotes: ui2.t("Footnotes") });
var TONES2 = ["good", "warn", "bad"];
var CALLOUT_TONES2 = ["info", "good", "warn", "bad"];
var optionsOf2 = (node) => (Array.isArray(node?.options) ? node.options : []).map((option) => typeof option === "string" ? { label: option } : option).filter((option) => option !== null && typeof option === "object" && option.label !== void 0);
@@ -5670,7 +5757,8 @@ var hasControls = (node) => {
};
var answerValues = (answer, node) => answer?.action === node.id ? answer.values : void 0;
function OptionsInput({ node, onSubmit, keys, busy = false }) {
- const [picked, setPicked] = (0, import_react9.useState)([]);
+ const ui2 = useViewUi();
+ const [picked, setPicked] = (0, import_react10.useState)([]);
const options = optionsOf2(node);
const multi = node.multi === true;
const choose = (label) => {
@@ -5684,105 +5772,109 @@ function OptionsInput({ node, onSubmit, keys, busy = false }) {
const submit = () => {
if (!busy && picked.length > 0) onSubmit?.(node.id, { selected: picked });
};
- const ownRef = (0, import_react9.useRef)(null);
- const hints = useOptionKeys(busy || !keys ? 0 : options.length, (index) => choose(options[index].label), ownRef);
- return (0, import_react9.createElement)(
- import_react9.Fragment,
+ const ownRef = (0, import_react10.useRef)(null);
+ const hints = useOptionKeys2(busy || !keys ? 0 : options.length, (index) => choose(options[index].label), ownRef);
+ return (0, import_react10.createElement)(
+ import_react10.Fragment,
null,
- (0, import_react9.createElement)("div", { className: "bt-q-list", role: "group" }, options.map((option, index) => {
+ (0, import_react10.createElement)("div", { className: "dui-q-list", role: "group" }, options.map((option, index) => {
const selected = multi && picked.includes(option.label);
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"button",
{
key: option.label,
type: "button",
- className: "bt-q-opt",
+ className: "dui-q-opt",
disabled: busy,
"aria-pressed": multi ? selected : void 0,
- "aria-keyshortcuts": hints ? keyLetter(index).toLowerCase() : void 0,
+ "aria-keyshortcuts": hints ? keyLetter2(index).toLowerCase() : void 0,
onClick: () => choose(option.label)
},
- hints ? (0, import_react9.createElement)("span", { className: "bt-key", "aria-hidden": true }, keyLetter(index)) : null,
- (0, import_react9.createElement)(
+ hints ? (0, import_react10.createElement)("span", { className: "dui-key", "aria-hidden": true }, keyLetter2(index)) : null,
+ (0, import_react10.createElement)(
"span",
- { className: "bt-q-body" },
- (0, import_react9.createElement)("span", { className: "bt-q-label" }, option.label),
- option.description ? (0, import_react9.createElement)("span", { className: "bt-q-desc" }, option.description) : null
+ { className: "dui-q-body" },
+ (0, import_react10.createElement)("span", { className: "dui-q-label" }, option.label),
+ option.description ? (0, import_react10.createElement)("span", { className: "dui-q-desc" }, option.description) : null
),
- selected ? (0, import_react9.createElement)("span", { className: "bt-q-check", title: t("Selected") }, (0, import_react9.createElement)(CheckIcon)) : null
+ selected ? (0, import_react10.createElement)("span", { className: "dui-q-check", title: ui2.t("Selected") }, (0, import_react10.createElement)(CheckIcon2)) : null
);
})),
- multi ? (0, import_react9.createElement)(
+ multi ? (0, import_react10.createElement)(
"div",
- { className: "bt-q-foot" },
- (0, import_react9.createElement)("button", { type: "button", className: "bt-q-submit", disabled: busy || picked.length === 0, onClick: submit }, t("Submit"))
+ { className: "dui-q-foot" },
+ (0, import_react10.createElement)("button", { type: "button", className: "dui-q-submit", disabled: busy || picked.length === 0, onClick: submit }, ui2.t("Submit"))
) : null
);
}
function SettledOptions({ node, answer }) {
+ const ui2 = useViewUi();
const selected = answerValues(answer, node)?.selected;
const chosen = Array.isArray(selected) ? selected : [];
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
- { className: "bt-q-list", role: "group", "aria-label": t("Your answer") },
- optionsOf2(node).map((option) => (0, import_react9.createElement)(
+ { className: "dui-q-list", role: "group", "aria-label": ui2.t("Your answer") },
+ optionsOf2(node).map((option) => (0, import_react10.createElement)(
"div",
- { key: option.label, className: "bt-q-opt" },
- (0, import_react9.createElement)(
+ { key: option.label, className: "dui-q-opt" },
+ (0, import_react10.createElement)(
"span",
- { className: "bt-q-body" },
- (0, import_react9.createElement)("span", { className: "bt-q-label" }, option.label),
- option.description ? (0, import_react9.createElement)("span", { className: "bt-q-desc" }, option.description) : null
+ { className: "dui-q-body" },
+ (0, import_react10.createElement)("span", { className: "dui-q-label" }, option.label),
+ option.description ? (0, import_react10.createElement)("span", { className: "dui-q-desc" }, option.description) : null
),
- chosen.includes(option.label) ? (0, import_react9.createElement)("span", { className: "bt-q-check", title: t("Selected") }, (0, import_react9.createElement)(CheckIcon)) : null
+ chosen.includes(option.label) ? (0, import_react10.createElement)("span", { className: "dui-q-check", title: ui2.t("Selected") }, (0, import_react10.createElement)(CheckIcon2)) : null
))
);
}
function ConfirmInput({ node, onSubmit, busy = false }) {
- return (0, import_react9.createElement)(
+ const ui2 = useViewUi();
+ return (0, import_react10.createElement)(
"div",
- { className: "bt-q-foot" },
- (0, import_react9.createElement)("button", { type: "button", className: "bt-q-btn", disabled: busy, onClick: () => onSubmit?.(node.id, { confirmed: false }) }, node.cancelLabel ?? t("Cancel")),
- (0, import_react9.createElement)("button", { type: "button", className: "bt-q-submit", disabled: busy, onClick: () => onSubmit?.(node.id, { confirmed: true }) }, node.confirmLabel ?? t("Confirm"))
+ { className: "dui-q-foot" },
+ (0, import_react10.createElement)("button", { type: "button", className: "dui-q-btn", disabled: busy, onClick: () => onSubmit?.(node.id, { confirmed: false }) }, node.cancelLabel ?? ui2.t("Cancel")),
+ (0, import_react10.createElement)("button", { type: "button", className: "dui-q-submit", disabled: busy, onClick: () => onSubmit?.(node.id, { confirmed: true }) }, node.confirmLabel ?? ui2.t("Confirm"))
);
}
function SettledConfirm({ node, answer }) {
+ const ui2 = useViewUi();
const confirmed = answerValues(answer, node)?.confirmed;
if (confirmed !== true && confirmed !== false) {
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
- { className: "bt-q-foot" },
- (0, import_react9.createElement)("button", { type: "button", className: "bt-q-btn", disabled: true }, node.cancelLabel ?? t("Cancel")),
- (0, import_react9.createElement)("button", { type: "button", className: "bt-q-submit", disabled: true }, node.confirmLabel ?? t("Confirm"))
+ { className: "dui-q-foot" },
+ (0, import_react10.createElement)("button", { type: "button", className: "dui-q-btn", disabled: true }, node.cancelLabel ?? ui2.t("Cancel")),
+ (0, import_react10.createElement)("button", { type: "button", className: "dui-q-submit", disabled: true }, node.confirmLabel ?? ui2.t("Confirm"))
);
}
- const label = confirmed ? node.confirmLabel ?? t("Confirm") : node.cancelLabel ?? t("Cancel");
- return (0, import_react9.createElement)("span", { className: "bt-q-badge" }, label);
+ const label = confirmed ? node.confirmLabel ?? ui2.t("Confirm") : node.cancelLabel ?? ui2.t("Cancel");
+ return (0, import_react10.createElement)("span", { className: "dui-q-badge" }, label);
}
function FormInput({ node, onSubmit, busy = false }) {
+ const ui2 = useViewUi();
const fields = fieldsOf(node);
- const [draft, setDraft] = (0, import_react9.useState)({});
+ const [draft, setDraft] = (0, import_react10.useState)({});
const submit = () => {
if (!busy) onSubmit?.(node.id, { fields: Object.fromEntries(fields.map((field) => [field.id, draft[field.id] ?? ""])) });
};
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"form",
{
- className: "bt-widget-form",
+ className: "dui-widget-form",
onSubmit: (event) => {
event.preventDefault();
submit();
}
},
- fields.map((field) => (0, import_react9.createElement)(
+ fields.map((field) => (0, import_react10.createElement)(
"label",
- { key: field.id, className: "bt-widget-field" },
- (0, import_react9.createElement)("span", { className: "bt-widget-field-label" }, field.label),
- (0, import_react9.createElement)(
+ { key: field.id, className: "dui-widget-field" },
+ (0, import_react10.createElement)("span", { className: "dui-widget-field-label" }, field.label),
+ (0, import_react10.createElement)(
"span",
- { className: "bt-q-field" },
- (0, import_react9.createElement)("input", {
- className: "bt-q-input",
+ { className: "dui-q-field" },
+ (0, import_react10.createElement)("input", {
+ className: "dui-q-input",
type: "text",
value: draft[field.id] ?? "",
autoComplete: "off",
@@ -5801,33 +5893,34 @@ function FormInput({ node, onSubmit, busy = false }) {
})
)
)),
- (0, import_react9.createElement)("div", { className: "bt-q-foot" }, (0, import_react9.createElement)("button", { type: "submit", className: "bt-q-submit", disabled: busy }, node.submitLabel ?? t("Submit")))
+ (0, import_react10.createElement)("div", { className: "dui-q-foot" }, (0, import_react10.createElement)("button", { type: "submit", className: "dui-q-submit", disabled: busy }, node.submitLabel ?? ui2.t("Submit")))
);
}
function SettledForm({ node, answer }) {
const fields = answerValues(answer, node)?.fields;
const values = fields !== null && typeof fields === "object" ? fields : {};
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
- { className: "bt-widget-form" },
- fieldsOf(node).map((field) => (0, import_react9.createElement)(
+ { className: "dui-widget-form" },
+ fieldsOf(node).map((field) => (0, import_react10.createElement)(
"label",
- { key: field.id, className: "bt-widget-field" },
- (0, import_react9.createElement)("span", { className: "bt-widget-field-label" }, field.label),
- (0, import_react9.createElement)(
+ { key: field.id, className: "dui-widget-field" },
+ (0, import_react10.createElement)("span", { className: "dui-widget-field-label" }, field.label),
+ (0, import_react10.createElement)(
"span",
- { className: "bt-q-field" },
- (0, import_react9.createElement)("input", { className: "bt-q-input", type: "text", value: values[field.id] ?? "", disabled: true, readOnly: true, "aria-label": field.label })
+ { className: "dui-q-field" },
+ (0, import_react10.createElement)("input", { className: "dui-q-input", type: "text", value: values[field.id] ?? "", disabled: true, readOnly: true, "aria-label": field.label })
)
))
);
}
function SubmitInput({ node, ctx }) {
+ const ui2 = useViewUi();
if (ctx.settled) return null;
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
- { className: "bt-q-foot" },
- (0, import_react9.createElement)("button", { type: "button", className: "bt-q-submit", disabled: ctx.busy, onClick: () => ctx.onSubmit?.(node.id, {}) }, node.label || t("Send"))
+ { className: "dui-q-foot" },
+ (0, import_react10.createElement)("button", { type: "button", className: "dui-q-submit", disabled: ctx.busy, onClick: () => ctx.onSubmit?.(node.id, {}) }, node.label || ui2.t("Send"))
);
}
function WidgetTable({ node, lookup }) {
@@ -5837,22 +5930,23 @@ function WidgetTable({ node, lookup }) {
const cells = rows2.map((row) => row[index]).filter((cell) => cell !== void 0 && cell !== "");
return cells.length > 0 && cells.every((cell) => typeof cell === "number" || typeof cell === "string" && NUMERIC_CELL.test(cell.trim()));
});
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
- { className: "bt-widget-table" },
- (0, import_react9.createElement)(
+ { className: "dui-widget-table" },
+ (0, import_react10.createElement)(
"table",
null,
- (0, import_react9.createElement)("thead", null, (0, import_react9.createElement)("tr", null, columns2.map((column, index) => (0, import_react9.createElement)("th", { key: column.key ?? index, scope: "col", className: numeric2[index] ? "bt-num" : void 0 }, column.label)))),
- (0, import_react9.createElement)("tbody", null, rows2.map((row, rowIndex) => (0, import_react9.createElement)(
+ (0, import_react10.createElement)("thead", null, (0, import_react10.createElement)("tr", null, columns2.map((column, index) => (0, import_react10.createElement)("th", { key: column.key ?? index, scope: "col", className: numeric2[index] ? "dui-num" : void 0 }, column.label)))),
+ (0, import_react10.createElement)("tbody", null, rows2.map((row, rowIndex) => (0, import_react10.createElement)(
"tr",
{ key: rowIndex },
- columns2.map((column, columnIndex) => (0, import_react9.createElement)("td", { key: column.key ?? columnIndex, className: numeric2[columnIndex] ? "bt-num" : void 0 }, cellText2(row[columnIndex])))
+ columns2.map((column, columnIndex) => (0, import_react10.createElement)("td", { key: column.key ?? columnIndex, className: numeric2[columnIndex] ? "dui-num" : void 0 }, cellText2(row[columnIndex])))
)))
)
);
}
function WidgetProgress({ node, lookup }) {
+ const ui2 = useViewUi();
let percent3;
if (node.percent !== void 0) percent3 = Number(resolve(node.percent, lookup, 0));
else {
@@ -5862,91 +5956,93 @@ function WidgetProgress({ node, lookup }) {
percent3 = Math.max(0, Math.min(100, Number.isFinite(percent3) ? percent3 : 0));
const tone = resolve(node.tone, lookup);
const right = node.valueLabel !== void 0 ? asText(resolve(node.valueLabel, lookup, "")) : `${Math.round(percent3)}%`;
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
- { className: "bt-widget-progress", "data-tone": TONES2.includes(tone) ? tone : void 0 },
- (0, import_react9.createElement)("span", { className: "bt-widget-progress-label" }, (0, import_react9.createElement)("span", { className: "bt-widget-progress-name" }, node.label), (0, import_react9.createElement)("span", null, right)),
- (0, import_react9.createElement)("div", {
- className: "bt-widget-progress-track",
+ { className: "dui-widget-progress", "data-tone": TONES2.includes(tone) ? tone : void 0 },
+ (0, import_react10.createElement)("span", { className: "dui-widget-progress-label" }, (0, import_react10.createElement)("span", { className: "dui-widget-progress-name" }, node.label), (0, import_react10.createElement)("span", null, right)),
+ (0, import_react10.createElement)("div", {
+ className: "dui-widget-progress-track",
role: "progressbar",
"aria-valuenow": Math.round(percent3),
"aria-valuemin": 0,
"aria-valuemax": 100,
- "aria-label": node.label ?? t("Progress"),
+ "aria-label": node.label ?? ui2.t("Progress"),
"aria-valuetext": right
- }, (0, import_react9.createElement)("div", { className: "bt-widget-progress-fill", style: { width: `${percent3}%` } }))
+ }, (0, import_react10.createElement)("div", { className: "dui-widget-progress-fill", style: { width: `${percent3}%` } }))
);
}
function WidgetMetric({ node, lookup }) {
const tone = resolve(node.tone, lookup);
const caption = node.caption === void 0 ? "" : asText(resolve(node.caption, lookup, ""));
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
- { className: "bt-widget-metric", "data-tone": TONES2.includes(tone) ? tone : void 0 },
- (0, import_react9.createElement)("span", { className: "bt-widget-metric-label" }, node.label),
- (0, import_react9.createElement)("span", { className: "bt-widget-metric-value" }, asText(resolve(node.value, lookup, "—"))),
- caption !== "" ? (0, import_react9.createElement)("span", { className: "bt-view-caption" }, caption) : null
+ { className: "dui-widget-metric", "data-tone": TONES2.includes(tone) ? tone : void 0 },
+ (0, import_react10.createElement)("span", { className: "dui-widget-metric-label" }, node.label),
+ (0, import_react10.createElement)("span", { className: "dui-widget-metric-value" }, asText(resolve(node.value, lookup, "—"))),
+ caption !== "" ? (0, import_react10.createElement)("span", { className: "dui-view-caption" }, caption) : null
);
}
function WidgetCallout({ node, lookup }) {
+ const ui2 = useViewUi();
const tone = resolve(node.tone, lookup);
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
- { className: "bt-view-callout", "data-tone": CALLOUT_TONES2.includes(tone) ? tone : "info" },
- (0, import_react9.createElement)("span", { className: "bt-view-callout-icon", "aria-hidden": true }, (0, import_react9.createElement)(InfoIcon)),
- (0, import_react9.createElement)("div", { className: "bt-view-callout-text" }, (0, import_react9.createElement)(import_dsh_client_ui_primitives.MarkdownText, { text: asText(resolve(node.text, lookup, "")), labels: mdLabels(), variant: "compact" }))
+ { className: "dui-view-callout", "data-tone": CALLOUT_TONES2.includes(tone) ? tone : "info" },
+ (0, import_react10.createElement)("span", { className: "dui-view-callout-icon", "aria-hidden": true }, (0, import_react10.createElement)(InfoIcon2)),
+ (0, import_react10.createElement)("div", { className: "dui-view-callout-text" }, (0, import_react10.createElement)(ui2.Markdown, { text: asText(resolve(node.text, lookup, "")), labels: mdLabels(ui2), variant: "compact" }))
);
}
-var LinkIcon = () => (0, import_react9.createElement)(
+var LinkIcon = () => (0, import_react10.createElement)(
"svg",
{ width: 12, height: 12, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },
- (0, import_react9.createElement)("path", { d: "M8.5 11.5l3-3" }),
- (0, import_react9.createElement)("path", { d: "M7 9.5L5.5 11a2.5 2.5 0 0 0 3.5 3.5L10.5 13" }),
- (0, import_react9.createElement)("path", { d: "M13 10.5l1.5-1.5A2.5 2.5 0 0 0 11 5.5L9.5 7" })
+ (0, import_react10.createElement)("path", { d: "M8.5 11.5l3-3" }),
+ (0, import_react10.createElement)("path", { d: "M7 9.5L5.5 11a2.5 2.5 0 0 0 3.5 3.5L10.5 13" }),
+ (0, import_react10.createElement)("path", { d: "M13 10.5l1.5-1.5A2.5 2.5 0 0 0 11 5.5L9.5 7" })
);
function WidgetSources({ node }) {
+ const ui2 = useViewUi();
const items = (Array.isArray(node.items) ? node.items : []).filter((item) => typeof item?.url === "string" && /^https?:\/\//i.test(item.url));
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
- { className: "bt-view-sources", role: "list", "aria-label": t("Sources") },
- items.map((item, index) => (0, import_react9.createElement)("a", { key: index, role: "listitem", className: "bt-view-source", href: item.url, target: "_blank", rel: "noopener noreferrer", title: item.url }, (0, import_react9.createElement)(LinkIcon), item.label))
+ { className: "dui-view-sources", role: "list", "aria-label": ui2.t("Sources") },
+ items.map((item, index) => (0, import_react10.createElement)("a", { key: index, role: "listitem", className: "dui-view-source", href: item.url, target: "_blank", rel: "noopener noreferrer", title: item.url }, (0, import_react10.createElement)(LinkIcon), item.label))
);
}
function InputHead({ id, label, value }) {
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
- { className: "bt-view-input-head" },
- (0, import_react9.createElement)("label", { htmlFor: id, className: "bt-view-input-label" }, label),
- value !== void 0 ? (0, import_react9.createElement)("output", { htmlFor: id, className: "bt-view-input-value" }, value) : null
+ { className: "dui-view-input-head" },
+ (0, import_react10.createElement)("label", { htmlFor: id, className: "dui-view-input-label" }, label),
+ value !== void 0 ? (0, import_react10.createElement)("output", { htmlFor: id, className: "dui-view-input-value" }, value) : null
);
}
var withUnit2 = (value, unit) => `${asText(value)}${unit ? ` ${unit}` : ""}`;
var grouped2 = (value) => typeof value === "number" && Number.isFinite(value) ? value.toLocaleString("en-US", { maximumFractionDigits: 6 }) : asText(value);
function SliderInput({ node, ctx }) {
- const id = (0, import_react9.useId)();
+ const id = (0, import_react10.useId)();
const value = Number(ctx.values[node.id]);
const percent3 = node.max > node.min ? (value - node.min) / (node.max - node.min) * 100 : 0;
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
- { className: "bt-view-input" },
- (0, import_react9.createElement)(InputHead, { id, label: node.label, value: withUnit2(grouped2(value), node.unit) }),
- (0, import_react9.createElement)("input", {
+ { className: "dui-view-input" },
+ (0, import_react10.createElement)(InputHead, { id, label: node.label, value: withUnit2(grouped2(value), node.unit) }),
+ (0, import_react10.createElement)("input", {
id,
type: "range",
- className: "bt-view-range",
+ className: "dui-view-range",
min: node.min,
max: node.max,
step: node.step ?? "any",
value,
disabled: ctx.locked,
- style: { "--bt-fill": `${percent3}%` },
+ style: { "--dui-fill": `${percent3}%` },
onChange: (event) => ctx.setInput(node.id, Number(event.target.value))
})
);
}
function NumberInput({ node, ctx }) {
- const id = (0, import_react9.useId)();
- const [draft, setDraft] = (0, import_react9.useState)(null);
+ const id = (0, import_react10.useId)();
+ const [draft, setDraft] = (0, import_react10.useState)(null);
const value = ctx.values[node.id];
const accept = (raw) => {
setDraft(raw);
@@ -5955,16 +6051,16 @@ function NumberInput({ node, ctx }) {
if (node.min !== void 0 && next < node.min || node.max !== void 0 && next > node.max) return;
ctx.setInput(node.id, next);
};
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
- { className: "bt-view-input" },
- (0, import_react9.createElement)(InputHead, { id, label: node.label }),
- (0, import_react9.createElement)(
+ { className: "dui-view-input" },
+ (0, import_react10.createElement)(InputHead, { id, label: node.label }),
+ (0, import_react10.createElement)(
"span",
- { className: "bt-q-field bt-view-number" },
- (0, import_react9.createElement)("input", {
+ { className: "dui-q-field dui-view-number" },
+ (0, import_react10.createElement)("input", {
id,
- className: "bt-q-input",
+ className: "dui-q-input",
type: "number",
inputMode: "decimal",
value: draft ?? asText(value),
@@ -5975,108 +6071,109 @@ function NumberInput({ node, ctx }) {
onChange: (event) => accept(event.target.value),
onBlur: () => setDraft(null)
}),
- node.unit ? (0, import_react9.createElement)("span", { className: "bt-view-unit" }, node.unit) : null
+ node.unit ? (0, import_react10.createElement)("span", { className: "dui-view-unit" }, node.unit) : null
)
);
}
function ChoiceInput({ node, ctx }) {
- const labelId = (0, import_react9.useId)();
+ const labelId = (0, import_react10.useId)();
const options = optionsOf2(node);
const current = ctx.values[node.id];
const side = options.length <= 4 && options.every((option) => [...option.label].length <= 14);
const pick2 = (option) => () => {
if (!ctx.locked) ctx.setInput(node.id, choiceValue(option));
};
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
- { className: "bt-view-input" },
- (0, import_react9.createElement)("span", { className: "bt-view-input-label", id: labelId }, node.label),
- side ? (0, import_react9.createElement)(
- Segmented,
- { label: node.label, value: options.findIndex((option) => choiceValue(option) === current), className: "bt-view-seg" },
- options.map((option) => (0, import_react9.createElement)("button", { key: option.label, type: "button", "aria-pressed": choiceValue(option) === current, disabled: ctx.locked, onClick: pick2(option) }, option.label))
- ) : (0, import_react9.createElement)(
+ { className: "dui-view-input" },
+ (0, import_react10.createElement)("span", { className: "dui-view-input-label", id: labelId }, node.label),
+ side ? (0, import_react10.createElement)(
+ Segmented2,
+ { label: node.label, value: options.findIndex((option) => choiceValue(option) === current), className: "dui-view-seg" },
+ options.map((option) => (0, import_react10.createElement)("button", { key: option.label, type: "button", "aria-pressed": choiceValue(option) === current, disabled: ctx.locked, onClick: pick2(option) }, option.label))
+ ) : (0, import_react10.createElement)(
"div",
- { className: "bt-view-radios", role: "radiogroup", "aria-labelledby": labelId },
- options.map((option) => (0, import_react9.createElement)("button", {
+ { className: "dui-view-radios", role: "radiogroup", "aria-labelledby": labelId },
+ options.map((option) => (0, import_react10.createElement)("button", {
key: option.label,
type: "button",
role: "radio",
- className: "bt-view-radio",
+ className: "dui-view-radio",
"aria-checked": choiceValue(option) === current,
disabled: ctx.locked,
onClick: pick2(option)
- }, (0, import_react9.createElement)("span", { className: "bt-view-radio-dot", "aria-hidden": true }), option.label))
+ }, (0, import_react10.createElement)("span", { className: "dui-view-radio-dot", "aria-hidden": true }), option.label))
)
);
}
function ToggleInput({ node, ctx }) {
const on = ctx.values[node.id] === true;
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
- { className: "bt-view-toggle" },
- (0, import_react9.createElement)("span", { className: "bt-view-input-label" }, node.label),
- (0, import_react9.createElement)(
+ { className: "dui-view-toggle" },
+ (0, import_react10.createElement)("span", { className: "dui-view-input-label" }, node.label),
+ (0, import_react10.createElement)(
"button",
- { type: "button", role: "switch", className: "bt-switch", "aria-checked": on, "aria-label": node.label, disabled: ctx.locked, onClick: () => ctx.setInput(node.id, !on) },
- (0, import_react9.createElement)("span", { className: "bt-switch-knob", "aria-hidden": true })
+ { type: "button", role: "switch", className: "dui-switch", "aria-checked": on, "aria-label": node.label, disabled: ctx.locked, onClick: () => ctx.setInput(node.id, !on) },
+ (0, import_react10.createElement)("span", { className: "dui-switch-knob", "aria-hidden": true })
)
);
}
function WidgetNode({ node, ctx }) {
+ const ui2 = useViewUi();
if (node === null || typeof node !== "object") return null;
const { lookup } = ctx;
switch (node.type) {
case "stack":
case "row": {
const children = Array.isArray(node.children) ? node.children : [];
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
- { className: node.type === "row" ? "bt-view-row" : "bt-widget-stack" },
- children.map((child, index) => (0, import_react9.createElement)(WidgetNode, { key: child?.id ?? index, node: child, ctx }))
+ { className: node.type === "row" ? "dui-view-row" : "dui-widget-stack" },
+ children.map((child, index) => (0, import_react10.createElement)(WidgetNode, { key: child?.id ?? index, node: child, ctx }))
);
}
case "text": {
- const text = (0, import_react9.createElement)(import_dsh_client_ui_primitives.MarkdownText, { text: asText(resolve(node.text, lookup, "")), labels: mdLabels(), variant: "compact" });
- return node.tone === "muted" ? (0, import_react9.createElement)("div", { className: "bt-view-muted" }, text) : text;
+ const text = (0, import_react10.createElement)(ui2.Markdown, { text: asText(resolve(node.text, lookup, "")), labels: mdLabels(ui2), variant: "compact" });
+ return node.tone === "muted" ? (0, import_react10.createElement)("div", { className: "dui-view-muted" }, text) : text;
}
case "metric":
- return (0, import_react9.createElement)(WidgetMetric, { node, lookup });
+ return (0, import_react10.createElement)(WidgetMetric, { node, lookup });
case "table":
- return (0, import_react9.createElement)(WidgetTable, { node, lookup });
+ return (0, import_react10.createElement)(WidgetTable, { node, lookup });
case "chart":
- return (0, import_react9.createElement)(WidgetChart, { node, lookup, registerChart: ctx.registerChart, refreshCharts: ctx.refreshCharts });
+ return (0, import_react10.createElement)(WidgetChart, { node, lookup, registerChart: ctx.registerChart, refreshCharts: ctx.refreshCharts });
case "progress":
- return (0, import_react9.createElement)(WidgetProgress, { node, lookup });
+ return (0, import_react10.createElement)(WidgetProgress, { node, lookup });
case "callout":
- return (0, import_react9.createElement)(WidgetCallout, { node, lookup });
+ return (0, import_react10.createElement)(WidgetCallout, { node, lookup });
case "sources":
- return (0, import_react9.createElement)(WidgetSources, { node });
+ return (0, import_react10.createElement)(WidgetSources, { node });
case "html":
- return (0, import_react9.createElement)(HtmlFrame, { node });
+ return (0, import_react10.createElement)(HtmlFrame, { node });
case "slider":
- return (0, import_react9.createElement)(SliderInput, { node, ctx });
+ return (0, import_react10.createElement)(SliderInput, { node, ctx });
case "number":
- return (0, import_react9.createElement)(NumberInput, { node, ctx });
+ return (0, import_react10.createElement)(NumberInput, { node, ctx });
case "choice":
- return (0, import_react9.createElement)(ChoiceInput, { node, ctx });
+ return (0, import_react10.createElement)(ChoiceInput, { node, ctx });
case "toggle":
- return (0, import_react9.createElement)(ToggleInput, { node, ctx });
+ return (0, import_react10.createElement)(ToggleInput, { node, ctx });
case "submit":
- return (0, import_react9.createElement)(SubmitInput, { node, ctx });
+ return (0, import_react10.createElement)(SubmitInput, { node, ctx });
case "options":
- return ctx.settled ? (0, import_react9.createElement)(SettledOptions, { node, answer: ctx.answer }) : (0, import_react9.createElement)(OptionsInput, { node, onSubmit: ctx.onSubmit, keys: ctx.keys, busy: ctx.busy });
+ return ctx.settled ? (0, import_react10.createElement)(SettledOptions, { node, answer: ctx.answer }) : (0, import_react10.createElement)(OptionsInput, { node, onSubmit: ctx.onSubmit, keys: ctx.keys, busy: ctx.busy });
case "confirm":
- return ctx.settled ? (0, import_react9.createElement)(SettledConfirm, { node, answer: ctx.answer }) : (0, import_react9.createElement)(ConfirmInput, { node, onSubmit: ctx.onSubmit, busy: ctx.busy });
+ return ctx.settled ? (0, import_react10.createElement)(SettledConfirm, { node, answer: ctx.answer }) : (0, import_react10.createElement)(ConfirmInput, { node, onSubmit: ctx.onSubmit, busy: ctx.busy });
case "form":
- return ctx.settled ? (0, import_react9.createElement)(SettledForm, { node, answer: ctx.answer }) : (0, import_react9.createElement)(FormInput, { node, onSubmit: ctx.onSubmit, busy: ctx.busy });
+ return ctx.settled ? (0, import_react10.createElement)(SettledForm, { node, answer: ctx.answer }) : (0, import_react10.createElement)(FormInput, { node, onSubmit: ctx.onSubmit, busy: ctx.busy });
default:
return null;
}
}
function WidgetView({ view, onSubmit, settled = false, answer = null, busy = false, registerChart, refreshCharts }) {
const inputs = viewInputs(view);
- const [values, setValues] = (0, import_react9.useState)(() => Object.fromEntries(inputs.map((node) => [node.id, inputDefault(node)])));
+ const [values, setValues] = (0, import_react10.useState)(() => Object.fromEntries(inputs.map((node) => [node.id, inputDefault(node)])));
const sent = answer?.values?.inputs;
const current = settled && sent !== null && typeof sent === "object" ? { ...values, ...sent } : values;
const submit = (action, extra) => onSubmit?.(action, inputs.length > 0 ? { ...extra, inputs: current } : extra);
@@ -6093,12 +6190,12 @@ function WidgetView({ view, onSubmit, settled = false, answer = null, busy = fal
registerChart,
refreshCharts
};
- return (0, import_react9.createElement)(WidgetNode, { node: view, ctx });
+ return (0, import_react10.createElement)(WidgetNode, { node: view, ctx });
}
function useChartHandles() {
- const [, bump] = (0, import_react9.useState)(0);
- const charts = (0, import_react9.useRef)(/* @__PURE__ */ new Map());
- const fns = (0, import_react9.useRef)(null);
+ const [, bump] = (0, import_react10.useState)(0);
+ const charts = (0, import_react10.useRef)(/* @__PURE__ */ new Map());
+ const fns = (0, import_react10.useRef)(null);
if (fns.current === null) {
const refresh = () => bump((value) => value + 1);
fns.current = {
@@ -6116,28 +6213,30 @@ function useChartHandles() {
return { charts: [...charts.current.values()], ...fns.current };
}
function ViewMenuList({ charts, pick: pick2 }) {
- return (0, import_react9.createElement)(
+ const ui2 = useViewUi();
+ return (0, import_react10.createElement)(
"div",
- { className: "bt-menu bt-view-menu", role: "menu" },
- charts.map((chart, index) => (0, import_react9.createElement)(
- import_react9.Fragment,
+ { className: "dui-menu dui-view-menu", role: "menu" },
+ charts.map((chart, index) => (0, import_react10.createElement)(
+ import_react10.Fragment,
{ key: index },
- charts.length > 1 ? (0, import_react9.createElement)(
- import_react9.Fragment,
+ charts.length > 1 ? (0, import_react10.createElement)(
+ import_react10.Fragment,
null,
- index > 0 ? (0, import_react9.createElement)("div", { className: "bt-menu-sep", role: "separator" }) : null,
- (0, import_react9.createElement)("div", { className: "bt-view-menu-label" }, chart.label ?? t("Chart {n}", { n: index + 1 }))
+ index > 0 ? (0, import_react10.createElement)("div", { className: "dui-menu-sep", role: "separator" }) : null,
+ (0, import_react10.createElement)("div", { className: "dui-view-menu-label" }, chart.label ?? ui2.t("Chart {n}", { n: index + 1 }))
) : null,
- (0, import_react9.createElement)("button", { type: "button", role: "menuitem", onClick: pick2(chart.toggleTable) }, (0, import_react9.createElement)(TableIcon), chart.asTable ? t("View as chart") : t("View as table")),
- (0, import_react9.createElement)("button", { type: "button", role: "menuitem", onClick: pick2(chart.copy) }, (0, import_react9.createElement)(CopyIcon), t("Copy data")),
- (0, import_react9.createElement)("button", { type: "button", role: "menuitem", onClick: pick2(chart.save) }, (0, import_react9.createElement)(DownloadIcon), t("Download image"))
+ (0, import_react10.createElement)("button", { type: "button", role: "menuitem", onClick: pick2(chart.toggleTable) }, (0, import_react10.createElement)(TableIcon), chart.asTable ? ui2.t("View as chart") : ui2.t("View as table")),
+ (0, import_react10.createElement)("button", { type: "button", role: "menuitem", onClick: pick2(chart.copy) }, (0, import_react10.createElement)(CopyIcon2), ui2.t("Copy data")),
+ (0, import_react10.createElement)("button", { type: "button", role: "menuitem", onClick: pick2(chart.save) }, (0, import_react10.createElement)(DownloadIcon2), ui2.t("Download image"))
))
);
}
function ViewMenu({ charts }) {
- const [open, setOpen] = (0, import_react9.useState)(false);
- const root = (0, import_react9.useRef)(null);
- (0, import_react9.useEffect)(() => {
+ const ui2 = useViewUi();
+ const [open, setOpen] = (0, import_react10.useState)(false);
+ const root = (0, import_react10.useRef)(null);
+ (0, import_react10.useEffect)(() => {
if (!open) return void 0;
const away = (event) => {
if (!root.current?.contains(event.target)) setOpen(false);
@@ -6156,41 +6255,378 @@ function ViewMenu({ charts }) {
setOpen(false);
run2();
};
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
- { ref: root, className: "bt-view-tools", "data-open": open ? "" : void 0 },
- (0, import_react9.createElement)("button", { type: "button", className: "bt-view-more", "aria-label": t("Chart options"), "aria-haspopup": "menu", "aria-expanded": open, onClick: () => setOpen((value) => !value) }, (0, import_react9.createElement)(DotsIcon)),
- open ? (0, import_react9.createElement)(ViewMenuList, { charts, pick: pick2 }) : null
+ { ref: root, className: "dui-view-tools", "data-open": open ? "" : void 0 },
+ (0, import_react10.createElement)("button", { type: "button", className: "dui-view-more", "aria-label": ui2.t("Chart options"), "aria-haspopup": "menu", "aria-expanded": open, onClick: () => setOpen((value) => !value) }, (0, import_react10.createElement)(DotsIcon2)),
+ open ? (0, import_react10.createElement)(ViewMenuList, { charts, pick: pick2 }) : null
);
}
function WidgetCard({ title, view, onSubmit, onDismiss, busy = false, raised = false, settled = false, answer = null }) {
- const titleId = (0, import_react9.useId)();
+ const ui2 = useViewUi();
+ const titleId = (0, import_react10.useId)();
const { charts, registerChart, refreshCharts } = useChartHandles();
const framed = raised || hasControls(view);
- const className = ["bt-view", framed ? "bt-q" : "bt-view-bare", settled ? "bt-q-settled" : "", raised ? "bt-q-raised" : ""].filter(Boolean).join(" ");
- const head = title || onDismiss || countType(view, "chart") > 0 ? (0, import_react9.createElement)(
+ const className = ["dui-view", framed ? "dui-q" : "dui-view-bare", settled ? "dui-q-settled" : "", raised ? "dui-q-raised" : ""].filter(Boolean).join(" ");
+ const head = title || onDismiss || countType(view, "chart") > 0 ? (0, import_react10.createElement)(
"div",
- { className: "bt-view-head" },
- title ? (0, import_react9.createElement)("p", { className: "bt-view-title", id: titleId }, title) : (0, import_react9.createElement)("span", { className: "bt-view-title" }),
- countType(view, "chart") > 0 ? (0, import_react9.createElement)(ViewMenu, { charts }) : null,
- onDismiss ? (0, import_react9.createElement)("button", { type: "button", className: "bt-q-x", "aria-label": t("Dismiss view"), title: t("Dismiss"), onClick: onDismiss, disabled: busy }, (0, import_react9.createElement)(CloseIcon)) : null
+ { className: "dui-view-head" },
+ title ? (0, import_react10.createElement)("p", { className: "dui-view-title", id: titleId }, title) : (0, import_react10.createElement)("span", { className: "dui-view-title" }),
+ countType(view, "chart") > 0 ? (0, import_react10.createElement)(ViewMenu, { charts }) : null,
+ onDismiss ? (0, import_react10.createElement)("button", { type: "button", className: "dui-q-x", "aria-label": ui2.t("Dismiss view"), title: ui2.t("Dismiss"), onClick: onDismiss, disabled: busy }, (0, import_react10.createElement)(CloseIcon2)) : null
) : null;
- return (0, import_react9.createElement)(
+ return (0, import_react10.createElement)(
"div",
{
className,
role: "group",
"aria-labelledby": title ? titleId : void 0,
- "aria-label": title ? void 0 : t("View"),
+ "aria-label": title ? void 0 : ui2.t("View"),
"aria-busy": busy || void 0
},
head,
- (0, import_react9.createElement)("div", { className: "bt-view-body" }, (0, import_react9.createElement)(WidgetView, { view, onSubmit, settled, answer, busy, registerChart, refreshCharts }))
+ (0, import_react10.createElement)("div", { className: "dui-view-body" }, (0, import_react10.createElement)(WidgetView, { view, onSubmit, settled, answer, busy, registerChart, refreshCharts }))
);
}
+function AnsweredView({ node }) {
+ const data = node.data ?? {};
+ let payload = null;
+ if (Array.isArray(data.views)) payload = data;
+ else {
+ try {
+ payload = typeof data.text === "string" ? JSON.parse(data.text) : null;
+ } catch {
+ payload = null;
+ }
+ if (payload?.kind !== "answer_to_pending_view") payload = null;
+ }
+ const view = payload?.views?.[0];
+ if (view === null || typeof view !== "object" || view.view === void 0) return null;
+ const answers = Array.isArray(payload.answers) ? payload.answers : [];
+ const answer = answers.find((entry) => entry?.id === view.id) ?? answers[0] ?? null;
+ return (0, import_react10.createElement)("div", { className: "dui-q-inline" }, (0, import_react10.createElement)(WidgetCard, { title: view.title ?? "", view: view.view, settled: true, answer }));
+}
+var WIDGET_CSS = `
+.dui-view{min-width:0}
+.dui-view-bare{display:flex;flex-direction:column;gap:8px;width:100%;color:var(--dui-ink);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;animation:dui-veil-in .2s ease-out backwards}
+.dui-view-head{display:flex;align-items:flex-start;gap:8px;min-width:0}
+.dui-view-title{flex:1 1 0;min-width:0;margin:0;font-size:13px;line-height:18px;font-weight:500;color:var(--dui-ink);overflow-wrap:anywhere}
+.dui-q-settled .dui-view-title{color:var(--dui-ink-2)}
+.dui-view-tools{position:relative;flex:none;align-self:flex-start;opacity:0;transition:opacity .12s ease}
+.dui-view:hover .dui-view-tools,.dui-view-tools:focus-within,.dui-view-tools[data-open]{opacity:1}
+@media (hover:none){.dui-view-tools{opacity:1}}
+.dui-view-more{width:28px;height:28px;padding:0;border:0;border-radius:50%;background:none;color:var(--dui-ink-2);display:flex;align-items:center;justify-content:center;cursor:pointer;transition:background-color .12s ease,color .12s ease}
+.dui-view-more:hover,.dui-view-tools[data-open] .dui-view-more{background:var(--dui-hover);color:var(--dui-ink)}
+.dui-view-more:focus-visible{outline:2px solid var(--dui-accent);outline-offset:1px}
+.dui-view-more svg{width:16px;height:16px}
+.dui-menu.dui-view-menu{position:absolute;top:32px;right:0;--dui-origin:top right;min-width:180px}
+.dui-menu.dui-view-menu button{gap:8px}
+.dui-view-menu-label{padding:2px 8px;font-size:11px;line-height:14px;color:var(--dui-ink-3);white-space:nowrap}
+.dui-view-body{min-width:0}
+.dui-widget-stack{display:flex;flex-direction:column;gap:12px;min-width:0}
+.dui-view-row{display:flex;flex-wrap:wrap;gap:12px 24px;min-width:0}
+.dui-view-row>*{flex:1 1 160px;min-width:0}
+.dui-widget-metric{display:flex;flex-direction:column;gap:1px;min-width:0}
+.dui-widget-metric-label{font-size:12px;line-height:16px;color:var(--dui-ink-2)}
+.dui-widget-metric-value{font-size:22px;line-height:28px;font-weight:600;font-variant-numeric:tabular-nums;color:var(--dui-ink);overflow-wrap:anywhere}
+.dui-widget-metric[data-tone=good] .dui-widget-metric-value{color:var(--dui-green)}
+.dui-widget-metric[data-tone=warn] .dui-widget-metric-value{color:var(--dui-star)}
+.dui-widget-metric[data-tone=bad] .dui-widget-metric-value{color:var(--dui-danger)}
+.dui-view-caption{font-size:12px;line-height:16px;color:var(--dui-ink-2);overflow-wrap:anywhere}
+.dui-view-muted{font-size:12px;line-height:16px;color:var(--dui-ink-2)}
+.dui-view-muted *{font-size:inherit!important;line-height:inherit!important;color:inherit!important}
+.dui-widget-table{max-width:100%;overflow-x:auto;border:.5px solid var(--dui-line-2);border-radius:10px}
+.dui-widget-table table{border-collapse:collapse;min-width:100%;font-size:13px;line-height:18px}
+.dui-widget-table th{padding:6px 10px;font-weight:500;text-align:start;white-space:nowrap;color:var(--dui-ink-2);border-bottom:.5px solid var(--dui-line-2)}
+.dui-widget-table td{padding:6px 10px;max-width:280px;color:var(--dui-ink);overflow-wrap:anywhere}
+.dui-widget-table tbody tr+tr>*{border-top:.5px solid var(--dui-line)}
+.dui-widget-table .dui-num{text-align:end;font-variant-numeric:tabular-nums}
+.dui-widget-form{display:flex;flex-direction:column;gap:8px;margin:0}
+.dui-widget-field{display:flex;flex-direction:column;gap:4px;min-width:0}
+.dui-widget-field-label{font-size:12px;line-height:16px;color:var(--dui-ink-2)}
+.dui-widget-field .dui-q-field:has(.dui-q-input:disabled){cursor:default;opacity:.75}
+.dui-widget-progress{display:flex;flex-direction:column;gap:5px;min-width:0}
+.dui-widget-progress-label{display:flex;justify-content:space-between;gap:8px;font-size:12px;line-height:16px;color:var(--dui-ink-2);font-variant-numeric:tabular-nums}
+.dui-widget-progress-name{color:var(--dui-ink);font-weight:500}
+.dui-widget-progress-track{height:6px;border-radius:999px;background:var(--dui-hover);overflow:hidden}
+.dui-widget-progress-fill{height:100%;border-radius:inherit;background:var(--dui-accent);transition:width .12s ease,background-color .12s ease}
+.dui-widget-progress[data-tone=good] .dui-widget-progress-fill{background:var(--dui-green)}
+.dui-widget-progress[data-tone=warn] .dui-widget-progress-fill{background:var(--dui-star)}
+.dui-widget-progress[data-tone=bad] .dui-widget-progress-fill{background:var(--dui-danger)}
+.dui-widget-progress[data-tone=bad] .dui-widget-progress-label>span:last-child{color:var(--dui-danger)}
+.dui-view-callout{display:flex;gap:8px;padding:8px 12px;border-radius:10px;--dui-tone:var(--dui-accent);background:color-mix(in srgb,var(--dui-tone) 8%,transparent);color:var(--dui-ink)}
+.dui-view-callout[data-tone=good]{--dui-tone:var(--dui-green)}
+.dui-view-callout[data-tone=warn]{--dui-tone:var(--dui-star)}
+.dui-view-callout[data-tone=bad]{--dui-tone:var(--dui-danger)}
+.dui-view-callout-icon{flex:none;display:flex;padding-top:3px;color:var(--dui-tone)}
+.dui-view-callout-icon svg{width:16px;height:16px}
+.dui-view-callout-text{flex:1 1 auto;min-width:0}
+.dui-view-sources{display:flex;flex-wrap:wrap;gap:6px}
+.dui-view-source{display:inline-flex;align-items:center;gap:4px;max-width:100%;height:20px;padding:0 6px;border-radius:4px;background:var(--dui-tag-bg,var(--dui-hover));color:var(--dui-ink-2);font-size:11px;line-height:16px;text-decoration:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:background-color .12s ease,color .12s ease}
+.dui-view-source:hover{background:var(--dui-hover);color:var(--dui-ink)}
+.dui-view-source:focus-visible{outline:2px solid var(--dui-accent);outline-offset:1px}
+.dui-view-input{display:flex;flex-direction:column;gap:6px;min-width:0}
+.dui-view-input-head{display:flex;justify-content:space-between;align-items:baseline;gap:8px}
+.dui-view-input-label{font-size:12px;line-height:16px;color:var(--dui-ink-2)}
+.dui-view-input-value{font-size:15px;line-height:20px;font-weight:600;color:var(--dui-ink);font-variant-numeric:tabular-nums}
+.dui-view-range{-webkit-appearance:none;appearance:none;width:100%;height:20px;margin:0;background:transparent;cursor:pointer}
+.dui-view-range:disabled{cursor:default;opacity:.6}
+.dui-view-range::-webkit-slider-runnable-track{height:6px;border-radius:999px;background:linear-gradient(to right,var(--dui-accent) var(--dui-fill,0%),var(--dui-hover) var(--dui-fill,0%))}
+.dui-view-range::-moz-range-track{height:6px;border-radius:999px;background:var(--dui-hover)}
+.dui-view-range::-moz-range-progress{height:6px;border-radius:999px;background:var(--dui-accent)}
+.dui-view-range::-webkit-slider-thumb{-webkit-appearance:none;width:16px;height:16px;margin-top:-5px;border-radius:50%;corner-shape:round;background:var(--dui-knob);box-shadow:0 1px 3px rgba(0,0,0,.25),0 0 0 .5px rgba(0,0,0,.12)}
+.dui-view-range::-moz-range-thumb{width:16px;height:16px;border:0;border-radius:50%;background:var(--dui-knob);box-shadow:0 1px 3px rgba(0,0,0,.25),0 0 0 .5px rgba(0,0,0,.12)}
+.dui-view-range:focus-visible{outline:2px solid var(--dui-accent);outline-offset:2px;border-radius:6px}
+.dui-view-number{max-width:200px;align-items:center;gap:6px}
+.dui-view-number .dui-q-input{font-variant-numeric:tabular-nums}
+.dui-view-unit{flex:none;font-size:13px;color:var(--dui-ink-2)}
+.dui-seg.dui-view-seg{align-self:flex-start;max-width:100%}
+.dui-seg.dui-view-seg button{flex:none;padding:0 12px;white-space:nowrap}
+.dui-view-radios{display:flex;flex-direction:column;gap:2px}
+.dui-view-radio{display:flex;align-items:center;gap:8px;min-height:30px;padding:4px 8px;margin:0 -8px;border:0;border-radius:8px;background:none;font:inherit;font-size:14px;line-height:20px;color:var(--dui-ink);text-align:start;cursor:pointer;transition:background-color .12s ease}
+.dui-view-radio:hover:not(:disabled){background:var(--dui-hover)}
+.dui-view-radio:disabled{cursor:default}
+.dui-view-radio:focus-visible{outline:2px solid var(--dui-accent);outline-offset:-2px}
+.dui-view-radio-dot{flex:none;width:16px;height:16px;border-radius:50%;corner-shape:round;box-shadow:inset 0 0 0 1.5px var(--dui-line-2);transition:box-shadow .12s ease}
+.dui-view-radio[aria-checked=true] .dui-view-radio-dot{box-shadow:inset 0 0 0 5px var(--dui-accent)}
+.dui-view-toggle{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:28px}
+.dui-view-toggle .dui-view-input-label{font-size:14px;line-height:20px;color:var(--dui-ink)}
+.dui-q.dui-view{gap:10px}
+.dui-q.dui-view:not(.dui-q-raised):not(.dui-q-settled)>.dui-view-head:has(.dui-view-title:empty){margin-bottom:-6px}
+.dui-q-raised .dui-view-head{padding:14px 16px 4px 20px}
+.dui-q-raised .dui-view-body{padding:0 16px 14px 20px}
+.dui-q-raised .dui-view-body .dui-q-list{padding:0;margin:0 -8px}
+.dui-q-inline .dui-view{margin:0;width:100%;max-width:min(100%,max(calc(var(--dui-msg-w,.8) * 100%),560px));order:0}
+body[data-dui-layout=flat] .dui-q-inline .dui-view{max-width:calc(var(--dui-flat-w,1) * 100%)}
+.dui-q-inline:has(>.dui-view-bare){margin:8px 0 12px}
+@media (prefers-reduced-motion:reduce){.dui-widget-progress-fill,.dui-view-radio-dot,.dui-view-tools,.dui-view-more{transition:none}.dui-view-bare{animation:none}}
+${CHART_CSS}
+${HTML_CSS}
+`;
+
+// ../../../DeepSeek Bot/deep-ui/src/react/styles.js
+var THEME_CSS = `
+body{
+--dui-ink:var(--dsw-alias-label-primary);
+--dui-ink-2:var(--dsw-alias-label-secondary);
+--dui-ink-3:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-caption));
+--dui-line:color-mix(in srgb,var(--dsw-alias-label-primary) 8%,transparent);
+--dui-line-2:color-mix(in srgb,var(--dsw-alias-label-primary) 15%,transparent);
+--dui-card:var(--dsw-specific-menu,var(--dsw-alias-bg-layer-1,var(--dsw-alias-bg-base)));
+--dui-main:var(--dsw-alias-bg-base);
+--dui-hover:var(--dsw-alias-interactive-bg-hover);
+--dui-active:var(--dsw-alias-interactive-bg-active,var(--dsw-alias-interactive-bg-hover));
+--dui-accent:var(--dsw-alias-state-business-primary);
+--dui-accent-ink:var(--dsw-alias-label-primary-inverted,#fff);
+--dui-green:var(--dsw-alias-state-success-primary);
+--dui-star:var(--dsw-alias-state-warn-primary,var(--dsw-alias-state-warn-label));
+--dui-danger:var(--dsw-alias-state-error-primary);
+--dui-knob:var(--dsw-alias-label-primary-inverted,#fff);
+--dui-tag-bg:var(--dsw-alias-interactive-bg-hover);
+--dui-ink-tangerine:var(--dsw-alias-brand-text,var(--dsw-alias-state-warn-primary));
+--dui-ink-green:var(--dsw-alias-state-success-primary);
+--dui-ink-violet:color-mix(in srgb,var(--dsw-alias-state-business-primary) 60%,var(--dsw-alias-state-error-primary));
+--dui-ink-sky:var(--dsw-alias-link,var(--dsw-alias-state-business-primary));
+--dui-ink-rose:var(--dsw-alias-state-error-primary);
+--dui-ink-yellow:var(--dsw-alias-state-warn-label,var(--dsw-alias-state-warn-primary));
+--dui-ink-cyan:var(--dsw-alias-state-success-tertiary,var(--dsw-alias-state-success-primary));
+--dui-ink-magenta:var(--dsw-alias-state-error-secondary,var(--dsw-alias-state-error-primary));
+color-scheme:light}
+body[data-ds-dark-theme]{color-scheme:dark}
+.dui-q-inline .dui-view{max-width:100%}
+`;
+var QUESTION_CSS = `
+.dui-q{margin:0 auto 8px;width:100%;max-width:var(--dsh-chat-content-width,748px);display:flex;flex-direction:column;gap:12px;--dui-q-edge:color-mix(in srgb,var(--dui-ink) 10%,transparent);--dui-q-rule:color-mix(in srgb,var(--dui-ink) 8%,transparent);--dui-q-rule-2:color-mix(in srgb,var(--dui-ink) 5%,transparent);background:var(--dui-card);box-shadow:0 1px 3px rgba(20,20,20,.04),inset 0 0 0 1px var(--dui-q-edge);border-radius:16px;padding:14px 16px;box-sizing:border-box;color:var(--dui-ink);font-family:var(--dsw-font-family,-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif);animation:dui-veil-in .2s ease-out backwards}
+body[data-ds-dark-theme] .dui-q{--dui-q-edge:rgba(255,255,255,.16);--dui-q-rule:rgba(255,255,255,.12);--dui-q-rule-2:rgba(255,255,255,.08)}
+.dui-q-settled{animation:none}
+.dui-q-x{flex:none;width:20px;height:20px;border:0;padding:0;border-radius:6px;background:none;color:var(--dui-ink-2);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:background-color .12s ease,color .12s ease}
+.dui-q-x svg{width:14px;height:14px}
+.dui-q-x:hover{background:var(--dui-hover);color:var(--dui-ink)}
+.dui-q-x:focus-visible,.dui-q-opt:focus-visible{outline:2px solid var(--dui-accent);outline-offset:-2px}
+.dui-q-list{display:flex;flex-direction:column;gap:1px;min-width:0;box-sizing:border-box;margin:0 -8px}
+.dui-q-opt{position:relative;display:flex;align-items:flex-start;gap:16px;width:100%;min-width:0;box-sizing:border-box;margin:0;border:0;border-radius:12px;background:transparent;padding:10px 8px;font:inherit;color:var(--dui-ink);text-align:start;cursor:pointer;transition:background-color .12s ease}
+.dui-q-opt+.dui-q-opt::before{content:"";position:absolute;left:calc(var(--dui-key,24px) + 24px);right:8px;top:-1px;height:1px;background:var(--dui-q-rule-2);pointer-events:none}
+button.dui-q-opt:hover::before,button.dui-q-opt:hover+.dui-q-opt::before,.dui-q-opt[aria-pressed=true]::before,.dui-q-opt[aria-pressed=true]+.dui-q-opt::before{opacity:0}
+button.dui-q-opt:hover{background:var(--dui-hover)}
+button.dui-q-opt:active{background:var(--dui-active)}
+.dui-q-opt[aria-pressed=true]{background:var(--dui-active)}
+.dui-key{flex:none;box-sizing:border-box;width:var(--dui-key,24px);height:var(--dui-key,24px);border-radius:8px;background:var(--dui-hover);color:var(--dui-ink-2);font-size:12px;line-height:var(--dui-key,24px);font-weight:500;text-align:center;font-variant-numeric:tabular-nums;transition:background-color .12s ease,color .12s ease}
+.dui-q-body{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:1px;padding-top:2px}
+.dui-q-opt:has(.dui-q-desc){--dui-key:34px}
+.dui-q-opt:has(.dui-q-desc) .dui-key{margin-top:2px;border-radius:10px;font-size:13px}
+.dui-q-opt:has(.dui-q-desc) .dui-q-body{padding-top:0}
+.dui-q-label{font-size:14px;line-height:20px;font-weight:500;white-space:normal;overflow-wrap:anywhere}
+.dui-q-desc{font-size:12px;line-height:17px;color:var(--dui-ink-2);overflow-wrap:anywhere}
+.dui-q-check{flex:none;display:inline-flex;align-items:center;color:var(--dui-ink-2);animation:dui-check-pop .18s ease-out backwards}
+.dui-q-settled .dui-q-check{animation:none}
+.dui-q-check svg{width:16px;height:16px}
+.dui-q-settled .dui-key{opacity:.4}
+.dui-q-settled .dui-q-label{color:color-mix(in srgb,var(--dui-ink) 45%,transparent)}
+.dui-q.dui-q-settled{gap:6px;padding:12px 16px}
+.dui-q-settled .dui-q-opt{padding:4px 8px}
+.dui-q-badge{flex:none;height:20px;padding:0 7px;border-radius:999px;border:1px dotted var(--dui-line-2);color:var(--dui-ink-2);font-size:12px;line-height:18px;box-sizing:border-box}
+.dui-q-field{flex:1 1 0;min-width:0;display:flex;box-sizing:border-box;min-height:32px;padding:5px 11px;border-radius:8px;border:.5px solid var(--dui-line-2);background:none;cursor:text;transition:border-color .12s ease}
+.dui-q-field:focus-within{border-color:color-mix(in srgb,var(--dui-ink) 30%,transparent)}
+.dui-q-input{flex:1;width:100%;min-width:0;max-height:120px;margin:0;padding:0;border:0;outline:none;background:transparent;color:var(--dui-ink);font:inherit;font-size:14px;line-height:20px;resize:none;overflow-y:hidden;white-space:pre-wrap;overflow-wrap:anywhere}
+.dui-q-input::placeholder{color:var(--dui-ink-3)}
+.dui-q-submit,.dui-q-btn{flex:none;height:36px;padding:0 14px;border:0;border-radius:999px;font:inherit;font-size:14px;font-weight:500;cursor:pointer;transition:opacity .12s ease,background-color .12s ease}
+.dui-q-submit{background:var(--dui-accent);color:var(--dui-accent-ink,#fff);animation:dui-veil-in .16s ease-out backwards}
+.dui-q-submit:hover:not(:disabled){opacity:.86}
+.dui-q-submit:disabled{opacity:.4;cursor:default}
+.dui-q-btn{background:var(--dui-hover);color:var(--dui-ink)}
+.dui-q-btn:hover{background:var(--dui-active)}
+.dui-q-foot{display:flex;justify-content:flex-end;gap:8px}
+.dui-menu{position:fixed;pointer-events:auto;z-index:60;min-width:200px;padding:6px;border-radius:12px;background:var(--dui-main);border:.5px solid var(--dui-line-2);box-shadow:0 10px 20px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1),0 0 0 1px rgba(228,228,228,.04);display:flex;flex-direction:column;gap:2px;transform-origin:var(--dui-origin,top left);animation:dui-veil-in .14s ease-out;font-family:var(--dsw-font-family,-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif);box-sizing:border-box}
+.dui-menu.dui-view-menu{position:absolute;z-index:4}
+.dui-menu button{display:flex;align-items:center;gap:4px;width:100%;min-height:30px;text-align:left;border:0;background:none;border-radius:6px;padding:6px 8px;font:inherit;font-size:13px;line-height:18px;color:var(--dui-ink);cursor:pointer;box-sizing:border-box}
+.dui-menu button:hover{background:var(--dui-hover)}
+.dui-menu
+.dui-menu button{display:flex;align-items:center;gap:4px;width:100%;min-height:30px;text-align:left;border:0;background:none;border-radius:6px;padding:6px 8px;font:inherit;font-size:13px;line-height:18px;color:var(--dui-ink);cursor:pointer;box-sizing:border-box}
+.dui-menu button:hover{background:var(--dui-hover)}
+.dui-menu button svg{flex:none;width:16px;height:16px;margin:0 1px}
+.dui-menu-sep{height:.5px;flex:none;background:var(--dui-line-2);margin:4px 8px}
+.dui-seg{position:relative;display:flex;gap:2px;padding:2px;border-radius:10px;background:var(--dui-hover)}
+.dui-seg button{position:relative;z-index:1;flex:1;height:30px;border:0;border-radius:8px;background:none;font:inherit;font-size:13px;color:var(--dui-ink-2);cursor:pointer;transition:background-color .15s ease,color .15s ease,box-shadow .15s ease}
+.dui-seg button[aria-pressed=true]{background:var(--dui-card);color:var(--dui-ink);box-shadow:0 1px 3px rgba(0,0,0,.08)}
+.dui-seg button:disabled{opacity:.4;cursor:default}
+.dui-switch{position:relative;flex:none;width:36px;height:20px;padding:0;border:0;border-radius:999px;background:var(--dui-line-2);cursor:pointer;transition:background-color .15s ease}
+.dui-switch[aria-checked=true]{background:var(--dui-accent)}
+.dui-switch:disabled{opacity:.4;cursor:default}
+.dui-switch-knob{position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:var(--dui-knob);box-shadow:0 1px 3px rgba(0,0,0,.2);transition:transform .15s ease}
+.dui-switch[aria-checked=true] .dui-switch-knob{transform:translateX(16px)}
+.dui-switch:focus-visible{outline:2px solid var(--dui-accent);outline-offset:2px}
+.dui-gone{display:none}
+@keyframes dui-veil-in{from{opacity:0;filter:blur(6px)}}
+@keyframes dui-check-pop{from{opacity:0;scale:.4}}
+@media (prefers-reduced-motion:reduce){.dui-q,.dui-view-bare,.dui-q-submit,.dui-menu,.dui-q-check{animation:none}}
+`;
+
+// ../../../DeepSeek Bot/deep-ui/src/react/index.js
+var DEEP_UI_CSS = THEME_CSS + QUESTION_CSS + WIDGET_CSS;
+
+// ../../../DeepSeek Bot/deep-ui/src/core/reply.js
+var REPLY_KIND = "user-question-reply";
+function viewCardText(args) {
+ let card = args;
+ if (typeof card === "string") {
+ try {
+ card = JSON.parse(card);
+ } catch {
+ return "";
+ }
+ }
+ const shown = checkShownView(card?.title, card?.view);
+ if (shown.error !== void 0) return "";
+ if (!shown.interactive && card?.await_reply === true) return "";
+ if (shown.interactive && card?.await_reply === false) return "";
+ const summary = viewSummary(shown.view);
+ const head = shown.title === "" ? "[View card]" : `[View card] ${shown.title}`;
+ return summary === "" ? head : `${head}
+${summary}`;
+}
+function viewReply(record, action, values, sourceKind = REPLY_KIND) {
+ const checked = validateViewAnswer(record?.view, action, values);
+ if (checked.error !== void 0) return void 0;
+ const callId = record.callId ?? record.id;
+ const shown = { id: record.id, title: record.title, view: record.view };
+ const given = { id: record.id, action, values: checked };
+ return {
+ text: JSON.stringify({ kind: "answer_to_pending_view", tool: "show_view", callId, views: [shown], answers: [given] }),
+ source: { kind: sourceKind, callId, outcome: "answered" }
+ };
+}
+var isRecord2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
+function eachNode(view, visit) {
+ if (!isRecord2(view)) return;
+ visit(view);
+ for (const child of Array.isArray(view.children) ? view.children : []) eachNode(child, visit);
+}
+function viewAnswerText(view, answer) {
+ const values = answer?.values;
+ if (!isRecord2(values)) return "";
+ const parts = [];
+ if (Array.isArray(values.selected)) {
+ const labels = /* @__PURE__ */ new Map();
+ eachNode(view, (node) => {
+ for (const option of Array.isArray(node.options) ? node.options : []) for (const key of [option?.label, option?.value]) if (key !== void 0) labels.set(key, option?.label);
+ });
+ parts.push(...values.selected.map((value) => labels.get(value) ?? String(value)));
+ } else if (typeof values.confirmed === "boolean") {
+ let confirmLabel, cancelLabel;
+ eachNode(view, (node) => {
+ if (node.id === answer.action) {
+ confirmLabel = node.confirmLabel;
+ cancelLabel = node.cancelLabel;
+ }
+ });
+ parts.push(values.confirmed ? confirmLabel ?? "Confirmed" : cancelLabel ?? "Cancelled");
+ } else if (isRecord2(values.fields)) {
+ const labels = /* @__PURE__ */ new Map();
+ eachNode(view, (node) => {
+ for (const field of Array.isArray(node.fields) ? node.fields : []) labels.set(field?.id, field?.label ?? field?.id);
+ });
+ parts.push(...Object.entries(values.fields).map(([key, value]) => `${labels.get(key) ?? key}: ${value}`));
+ }
+ if (isRecord2(values.inputs)) {
+ const labels = /* @__PURE__ */ new Map();
+ eachNode(view, (node) => {
+ if (typeof node.id === "string" && node.label !== void 0) labels.set(node.id, node.label);
+ });
+ parts.push(...Object.entries(values.inputs).map(([key, value]) => `${labels.get(key) ?? key}=${value}`));
+ }
+ const text = parts.join("; ");
+ return text.length > 200 ? `${text.slice(0, 200)}…` : text;
+}
+function readViewReply(text) {
+ let value;
+ try {
+ value = JSON.parse(text);
+ } catch {
+ return void 0;
+ }
+ if (value?.kind === "answer_to_pending_view" || Array.isArray(value?.views) && value.views.length > 0 && value?.kind !== "answer_to_pending_question") {
+ const views = (Array.isArray(value.views) ? value.views : []).filter((item) => typeof item?.id === "string" && typeof item.title === "string" && isRecord2(item.view));
+ if (views.length === 0) return void 0;
+ const answers = (Array.isArray(value.answers) ? value.answers : []).filter((item) => typeof item?.id === "string" && typeof item.action === "string" && isRecord2(item.values));
+ return { views, answers };
+ }
+ return void 0;
+}
+function actionSummary(answer, view) {
+ const values = answer?.values;
+ if (!isRecord2(values)) return "(skipped)";
+ const inputs = inputsSummary(view, values.inputs);
+ let text;
+ if (Array.isArray(values.selected)) text = `selected: ${values.selected.join(", ")}`;
+ else if (typeof values.confirmed === "boolean") text = values.confirmed ? "confirmed" : "cancelled";
+ else if (isRecord2(values.fields)) text = Object.entries(values.fields).map(([key, value]) => `${key}: ${value}`).join("; ");
+ else if (inputs !== "") text = "";
+ else text = typeof answer.action === "string" && answer.action !== "" ? answer.action : "(skipped)";
+ if (inputs !== "") text = text === "" ? inputs : `${text}; ${inputs}`;
+ if (text === "") text = "(empty)";
+ return text.length > 500 ? text.slice(0, 500) : text;
+}
+function viewReplyText(text) {
+ const reply = readViewReply(text);
+ if (reply === void 0) return text;
+ return reply.views.map((view) => {
+ const answer = reply.answers.find((item) => item.id === view.id);
+ return `${view.title === "" ? "[Answer to view card]" : `[Answer to view card] ${view.title}`}
+Answer: ${actionSummary(answer, view.view)}`;
+ }).join("\n\n");
+}
+
+// src/client/widget-cell.js
+var import_react11 = require("react");
+var viewT = (key, params) => key === "Send" ? t("Send to Bot") : t(key, params);
+var VIEW_UI = { t: viewT, Markdown: import_dsh_client_ui_primitives.MarkdownText };
+var Card = (props) => (0, import_react11.createElement)(ViewUi.Provider, { value: VIEW_UI }, (0, import_react11.createElement)(WidgetCard, props));
+var withUi = (Component) => (props) => (0, import_react11.createElement)(ViewUi.Provider, { value: VIEW_UI }, (0, import_react11.createElement)(Component, props));
+var WidgetView2 = withUi(WidgetView);
+var ViewMenuList2 = withUi(ViewMenuList);
function PendingView({ sessionId, view, actions, inline }) {
- const [answered, setAnswered] = (0, import_react9.useState)(null);
- const busyRef = (0, import_react9.useRef)(false);
+ const [answered, setAnswered] = (0, import_react11.useState)(null);
+ const busyRef = (0, import_react11.useRef)(false);
const hold = useDockHold(sessionId, "view", view.id, actions, inline);
const flying = answered === view.id;
const run2 = (make) => {
@@ -6204,33 +6640,33 @@ function PendingView({ sessionId, view, actions, inline }) {
};
const onSubmit = (action, values) => run2(() => actions.answerView(sessionId, view.id, action, values));
const onDismiss = () => run2(() => actions.dismissView(sessionId));
- return (0, import_react9.createElement)(
+ return (0, import_react11.createElement)(
"div",
{ className: inline ? "bt-q-inline" : "bt-q-dock", style: flying ? { display: "none" } : void 0, onFocusCapture: hold, onPointerDownCapture: hold },
- (0, import_react9.createElement)(WidgetCard, { key: view.id, title: view.title ?? "", view: view.view, onSubmit, onDismiss, busy: flying, raised: !inline })
+ (0, import_react11.createElement)(Card, { key: view.id, title: view.title ?? "", view: view.view, onSubmit, onDismiss, busy: flying, raised: !inline })
);
}
function WidgetCell({ sessionId, callId, args, done, isError, roster, actions, heldCards }) {
const record = roster.views?.[sessionId];
if (record !== void 0 && record.callId === callId) {
if (heldCards?.[heldCardKey("view", record.id)] > 0) return null;
- return (0, import_react9.createElement)(PendingView, { sessionId, view: record, actions, inline: true });
+ return (0, import_react11.createElement)(PendingView, { sessionId, view: record, actions, inline: true });
}
- if (done && isError) return (0, import_react9.createElement)("span", { className: "bt-q-gone", hidden: true });
+ if (done && isError) return (0, import_react11.createElement)("span", { className: "bt-q-gone", hidden: true });
const shown = checkShownView(args?.text?.("title"), args?.value?.("view"));
if (shown.error !== void 0 || shown.interactive || args?.value?.("await_reply") === true) {
- return (0, import_react9.createElement)("span", { className: "bt-q-gone", hidden: true });
+ return (0, import_react11.createElement)("span", { className: "bt-q-gone", hidden: true });
}
- return (0, import_react9.createElement)("div", { className: "bt-q-inline" }, (0, import_react9.createElement)(WidgetCard, { title: shown.title, view: shown.view }));
+ return (0, import_react11.createElement)("div", { className: "bt-q-inline" }, (0, import_react11.createElement)(Card, { title: shown.title, view: shown.view }));
}
function WidgetDock({ sessionId, useRoster, useCards, useHeldCards, actions }) {
const view = useRoster((value) => value.views?.[sessionId]);
const drawn = useCards?.((state) => state[sessionId]?.[view?.callId] > 0) === true;
const held = useHeldCards?.((state) => state[sessionId]?.[heldCardKey("view", view?.id)] > 0) === true;
if (view === void 0 || view.callId && drawn && !held) return null;
- return (0, import_react9.createElement)(PendingView, { sessionId, view, actions, inline: false });
+ return (0, import_react11.createElement)(PendingView, { sessionId, view, actions, inline: false });
}
-function AnsweredView({ node }) {
+function AnsweredView2({ node }) {
const data = node.data ?? {};
let payload = null;
if (Array.isArray(data.views)) payload = data;
@@ -6246,12 +6682,12 @@ function AnsweredView({ node }) {
if (view === null || typeof view !== "object" || view.view === void 0) return null;
const answers = Array.isArray(payload.answers) ? payload.answers : [];
const answer = answers.find((entry) => entry?.id === view.id) ?? answers[0] ?? null;
- return (0, import_react9.createElement)("div", { className: "bt-q-inline" }, (0, import_react9.createElement)(WidgetCard, { title: view.title ?? "", view: view.view, settled: true, answer }));
+ return (0, import_react11.createElement)("div", { className: "bt-q-inline" }, (0, import_react11.createElement)(Card, { title: view.title ?? "", view: view.view, settled: true, answer }));
}
function AnsweredReply({ node }) {
const data = node?.data ?? {};
- if (Array.isArray(data.views) && data.views.length > 0) return (0, import_react9.createElement)(AnsweredView, { node });
- if (typeof data.handoff?.reason === "string") return (0, import_react9.createElement)(SettledHandoff, { handoff: data.handoff });
+ if (Array.isArray(data.views) && data.views.length > 0) return (0, import_react11.createElement)(AnsweredView2, { node });
+ if (typeof data.handoff?.reason === "string") return (0, import_react11.createElement)(SettledHandoff, { handoff: data.handoff });
if (!Array.isArray(data.questions) || data.questions.length === 0) {
let parsed = null;
try {
@@ -6259,132 +6695,50 @@ function AnsweredReply({ node }) {
} catch {
parsed = null;
}
- if (parsed?.kind === "answer_to_pending_view") return (0, import_react9.createElement)(AnsweredView, { node });
+ if (parsed?.kind === "answer_to_pending_view") return (0, import_react11.createElement)(AnsweredView2, { node });
if (parsed?.kind === "answer_to_pending_handoff" && typeof parsed.reason === "string") {
- return (0, import_react9.createElement)(SettledHandoff, { handoff: { reason: parsed.reason, note: parsed.note ?? "", outcome: parsed.outcome } });
+ return (0, import_react11.createElement)(SettledHandoff, { handoff: { reason: parsed.reason, note: parsed.note ?? "", outcome: parsed.outcome } });
}
}
- return (0, import_react9.createElement)(AnsweredCell, { node });
-}
-var WIDGET_CSS = `
-.bt-view{min-width:0}
-.bt-view-bare{display:flex;flex-direction:column;gap:8px;width:100%;color:var(--bt-ink);font-family:var(--bt-font);animation:bt-veil-in .2s ease-out backwards}
-.bt-view-head{display:flex;align-items:flex-start;gap:8px;min-width:0}
-.bt-view-title{flex:1 1 0;min-width:0;margin:0;font-size:13px;line-height:18px;font-weight:500;color:var(--bt-ink);overflow-wrap:anywhere}
-.bt-q-settled .bt-view-title{color:var(--bt-ink-2)}
-.bt-view-tools{position:relative;flex:none;align-self:flex-start;opacity:0;transition:opacity .12s ease}
-.bt-view:hover .bt-view-tools,.bt-view-tools:focus-within,.bt-view-tools[data-open]{opacity:1}
-@media (hover:none){.bt-view-tools{opacity:1}}
-.bt-view-more{width:28px;height:28px;padding:0;border:0;border-radius:50%;background:none;color:var(--bt-ink-2);display:flex;align-items:center;justify-content:center;cursor:pointer;transition:background-color .12s ease,color .12s ease}
-.bt-view-more:hover,.bt-view-tools[data-open] .bt-view-more{background:var(--bt-hover);color:var(--bt-ink)}
-.bt-view-more:focus-visible{outline:2px solid var(--bt-accent);outline-offset:1px}
-.bt-view-more svg{width:16px;height:16px}
-.bt-menu.bt-view-menu{position:absolute;top:32px;right:0;--bt-origin:top right;min-width:180px}
-.bt-menu.bt-view-menu button{gap:8px}
-.bt-view-menu-label{padding:2px 8px;font-size:11px;line-height:14px;color:var(--bt-ink-3);white-space:nowrap}
-.bt-view-body{min-width:0}
-.bt-widget-stack{display:flex;flex-direction:column;gap:12px;min-width:0}
-.bt-view-row{display:flex;flex-wrap:wrap;gap:12px 24px;min-width:0}
-.bt-view-row>*{flex:1 1 160px;min-width:0}
-.bt-widget-metric{display:flex;flex-direction:column;gap:1px;min-width:0}
-.bt-widget-metric-label{font-size:12px;line-height:16px;color:var(--bt-ink-2)}
-.bt-widget-metric-value{font-size:22px;line-height:28px;font-weight:600;font-variant-numeric:tabular-nums;color:var(--bt-ink);overflow-wrap:anywhere}
-.bt-widget-metric[data-tone=good] .bt-widget-metric-value{color:var(--bt-green)}
-.bt-widget-metric[data-tone=warn] .bt-widget-metric-value{color:var(--bt-star)}
-.bt-widget-metric[data-tone=bad] .bt-widget-metric-value{color:var(--bt-danger)}
-.bt-view-caption{font-size:12px;line-height:16px;color:var(--bt-ink-2);overflow-wrap:anywhere}
-.bt-view-muted{font-size:12px;line-height:16px;color:var(--bt-ink-2)}
-.bt-view-muted *{font-size:inherit!important;line-height:inherit!important;color:inherit!important}
-.bt-widget-table{max-width:100%;overflow-x:auto;border:.5px solid var(--bt-line-2);border-radius:10px}
-.bt-widget-table table{border-collapse:collapse;min-width:100%;font-size:13px;line-height:18px}
-.bt-widget-table th{padding:6px 10px;font-weight:500;text-align:start;white-space:nowrap;color:var(--bt-ink-2);border-bottom:.5px solid var(--bt-line-2)}
-.bt-widget-table td{padding:6px 10px;max-width:280px;color:var(--bt-ink);overflow-wrap:anywhere}
-.bt-widget-table tbody tr+tr>*{border-top:.5px solid var(--bt-line)}
-.bt-widget-table .bt-num{text-align:end;font-variant-numeric:tabular-nums}
-.bt-widget-form{display:flex;flex-direction:column;gap:8px;margin:0}
-.bt-widget-field{display:flex;flex-direction:column;gap:4px;min-width:0}
-.bt-widget-field-label{font-size:12px;line-height:16px;color:var(--bt-ink-2)}
-.bt-widget-field .bt-q-field:has(.bt-q-input:disabled){cursor:default;opacity:.75}
-.bt-widget-progress{display:flex;flex-direction:column;gap:5px;min-width:0}
-.bt-widget-progress-label{display:flex;justify-content:space-between;gap:8px;font-size:12px;line-height:16px;color:var(--bt-ink-2);font-variant-numeric:tabular-nums}
-.bt-widget-progress-name{color:var(--bt-ink);font-weight:500}
-.bt-widget-progress-track{height:6px;border-radius:999px;background:var(--bt-hover);overflow:hidden}
-.bt-widget-progress-fill{height:100%;border-radius:inherit;background:var(--bt-accent);transition:width .12s ease,background-color .12s ease}
-.bt-widget-progress[data-tone=good] .bt-widget-progress-fill{background:var(--bt-green)}
-.bt-widget-progress[data-tone=warn] .bt-widget-progress-fill{background:var(--bt-star)}
-.bt-widget-progress[data-tone=bad] .bt-widget-progress-fill{background:var(--bt-danger)}
-.bt-widget-progress[data-tone=bad] .bt-widget-progress-label>span:last-child{color:var(--bt-danger)}
-.bt-view-callout{display:flex;gap:8px;padding:8px 12px;border-radius:10px;--bt-tone:var(--bt-accent);background:color-mix(in srgb,var(--bt-tone) 8%,transparent);color:var(--bt-ink)}
-.bt-view-callout[data-tone=good]{--bt-tone:var(--bt-green)}
-.bt-view-callout[data-tone=warn]{--bt-tone:var(--bt-star)}
-.bt-view-callout[data-tone=bad]{--bt-tone:var(--bt-danger)}
-.bt-view-callout-icon{flex:none;display:flex;padding-top:3px;color:var(--bt-tone)}
-.bt-view-callout-icon svg{width:16px;height:16px}
-.bt-view-callout-text{flex:1 1 auto;min-width:0}
-.bt-view-sources{display:flex;flex-wrap:wrap;gap:6px}
-.bt-view-source{display:inline-flex;align-items:center;gap:4px;max-width:100%;height:20px;padding:0 6px;border-radius:4px;background:var(--bt-tag-bg,var(--bt-hover));color:var(--bt-ink-2);font-size:11px;line-height:16px;text-decoration:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:background-color .12s ease,color .12s ease}
-.bt-view-source:hover{background:var(--bt-hover);color:var(--bt-ink)}
-.bt-view-source:focus-visible{outline:2px solid var(--bt-accent);outline-offset:1px}
-.bt-view-input{display:flex;flex-direction:column;gap:6px;min-width:0}
-.bt-view-input-head{display:flex;justify-content:space-between;align-items:baseline;gap:8px}
-.bt-view-input-label{font-size:12px;line-height:16px;color:var(--bt-ink-2)}
-.bt-view-input-value{font-size:15px;line-height:20px;font-weight:600;color:var(--bt-ink);font-variant-numeric:tabular-nums}
-.bt-view-range{-webkit-appearance:none;appearance:none;width:100%;height:20px;margin:0;background:transparent;cursor:pointer}
-.bt-view-range:disabled{cursor:default;opacity:.6}
-.bt-view-range::-webkit-slider-runnable-track{height:6px;border-radius:999px;background:linear-gradient(to right,var(--bt-accent) var(--bt-fill,0%),var(--bt-hover) var(--bt-fill,0%))}
-.bt-view-range::-moz-range-track{height:6px;border-radius:999px;background:var(--bt-hover)}
-.bt-view-range::-moz-range-progress{height:6px;border-radius:999px;background:var(--bt-accent)}
-.bt-view-range::-webkit-slider-thumb{-webkit-appearance:none;width:16px;height:16px;margin-top:-5px;border-radius:50%;corner-shape:round;background:var(--bt-knob);box-shadow:0 1px 3px rgba(0,0,0,.25),0 0 0 .5px rgba(0,0,0,.12)}
-.bt-view-range::-moz-range-thumb{width:16px;height:16px;border:0;border-radius:50%;background:var(--bt-knob);box-shadow:0 1px 3px rgba(0,0,0,.25),0 0 0 .5px rgba(0,0,0,.12)}
-.bt-view-range:focus-visible{outline:2px solid var(--bt-accent);outline-offset:2px;border-radius:6px}
-.bt-view-number{max-width:200px;align-items:center;gap:6px}
-.bt-view-number .bt-q-input{font-variant-numeric:tabular-nums}
-.bt-view-unit{flex:none;font-size:13px;color:var(--bt-ink-2)}
-.bt-seg.bt-view-seg{align-self:flex-start;max-width:100%}
-.bt-seg.bt-view-seg button{flex:none;padding:0 12px;white-space:nowrap}
-.bt-view-radios{display:flex;flex-direction:column;gap:2px}
-.bt-view-radio{display:flex;align-items:center;gap:8px;min-height:30px;padding:4px 8px;margin:0 -8px;border:0;border-radius:8px;background:none;font:inherit;font-size:14px;line-height:20px;color:var(--bt-ink);text-align:start;cursor:pointer;transition:background-color .12s ease}
-.bt-view-radio:hover:not(:disabled){background:var(--bt-hover)}
-.bt-view-radio:disabled{cursor:default}
-.bt-view-radio:focus-visible{outline:2px solid var(--bt-accent);outline-offset:-2px}
-.bt-view-radio-dot{flex:none;width:16px;height:16px;border-radius:50%;corner-shape:round;box-shadow:inset 0 0 0 1.5px var(--bt-line-2);transition:box-shadow .12s ease}
-.bt-view-radio[aria-checked=true] .bt-view-radio-dot{box-shadow:inset 0 0 0 5px var(--bt-accent)}
-.bt-view-toggle{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:28px}
-.bt-view-toggle .bt-view-input-label{font-size:14px;line-height:20px;color:var(--bt-ink)}
-.bt-q.bt-view{gap:10px}
-.bt-q.bt-view:not(.bt-q-raised):not(.bt-q-settled)>.bt-view-head:has(.bt-view-title:empty){margin-bottom:-6px}
-.bt-q-raised .bt-view-head{padding:14px 16px 4px 20px}
-.bt-q-raised .bt-view-body{padding:0 16px 14px 20px}
-.bt-q-raised .bt-view-body .bt-q-list{padding:0;margin:0 -8px}
-.bt-q-inline .bt-view{margin:0;width:100%;max-width:min(100%,max(calc(var(--bt-msg-w,.8) * 100%),560px));order:0}
-body[data-bt-layout=flat] .bt-q-inline .bt-view{max-width:calc(var(--bt-flat-w,1) * 100%)}
-.bt-q-inline:has(>.bt-view-bare){margin:8px 0 12px}
-@media (prefers-reduced-motion:reduce){.bt-widget-progress-fill,.bt-view-radio-dot,.bt-view-tools,.bt-view-more{transition:none}.bt-view-bare{animation:none}}
-${CHART_CSS}
-${HTML_CSS}
+ return (0, import_react11.createElement)(AnsweredCell, { node });
+}
+var WIDGET_CSS2 = `${DEEP_UI_CSS}
+body{
+--dui-ink:var(--bt-ink);--dui-ink-2:var(--bt-ink-2);--dui-ink-3:var(--bt-ink-3);
+--dui-line:var(--bt-line);--dui-line-2:var(--bt-line-2);
+--dui-card:var(--bt-card);--dui-main:var(--bt-main);
+--dui-hover:var(--bt-hover);--dui-active:var(--bt-active);
+--dui-accent:var(--bt-accent);--dui-accent-ink:var(--bt-accent-ink);
+--dui-green:var(--bt-green);--dui-star:var(--bt-star);--dui-danger:var(--bt-danger);
+--dui-knob:var(--bt-knob);--dui-tag-bg:var(--bt-tag-bg);
+--dui-ink-tangerine:var(--bt-ink-tangerine);--dui-ink-green:var(--bt-ink-green);
+--dui-ink-violet:var(--bt-ink-violet);--dui-ink-sky:var(--bt-ink-sky);
+--dui-ink-rose:var(--bt-ink-rose);--dui-ink-yellow:var(--bt-ink-yellow);
+--dui-ink-cyan:var(--bt-ink-cyan);--dui-ink-magenta:var(--bt-ink-magenta)}
+.bt-q-inline .dui-view{max-width:100%}
`;
// src/client/secret-card.js
-var import_react10 = require("react");
+var import_react14 = require("react");
var MIN_VALUE = 4;
var NONE = {};
-var KeyIcon = () => (0, import_react10.createElement)(
+var KeyIcon = () => (0, import_react14.createElement)(
"svg",
{ width: 15, height: 15, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },
- (0, import_react10.createElement)("path", { d: "M7 9.5a3.5 3.5 0 1 1 0 .01z" }),
- (0, import_react10.createElement)("path", { d: "M10.4 10.6L17 10.6M14.5 10.6v2.4M16.6 10.6v1.8" })
+ (0, import_react14.createElement)("path", { d: "M7 9.5a3.5 3.5 0 1 1 0 .01z" }),
+ (0, import_react14.createElement)("path", { d: "M10.4 10.6L17 10.6M14.5 10.6v2.4M16.6 10.6v1.8" })
);
-var LockIcon = () => (0, import_react10.createElement)(
+var LockIcon = () => (0, import_react14.createElement)(
"svg",
{ width: 14, height: 14, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },
- (0, import_react10.createElement)("path", { d: "M6.5 9V7a3.5 3.5 0 0 1 7 0v2" }),
- (0, import_react10.createElement)("rect", { x: 4.5, y: 9, width: 11, height: 8, rx: 2 })
+ (0, import_react14.createElement)("path", { d: "M6.5 9V7a3.5 3.5 0 0 1 7 0v2" }),
+ (0, import_react14.createElement)("rect", { x: 4.5, y: 9, width: 11, height: 8, rx: 2 })
);
-var WarnIcon = () => (0, import_react10.createElement)(
+var WarnIcon = () => (0, import_react14.createElement)(
"svg",
{ width: 14, height: 14, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },
- (0, import_react10.createElement)("path", { d: "M10 3.5l7 12.5H3z" }),
- (0, import_react10.createElement)("path", { d: "M10 8.5v3.5M10 14.2h.01" })
+ (0, import_react14.createElement)("path", { d: "M10 3.5l7 12.5H3z" }),
+ (0, import_react14.createElement)("path", { d: "M10 8.5v3.5M10 14.2h.01" })
);
var MASK_BY_CSS = typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("-webkit-text-security", "disc");
var insecure = () => typeof location !== "undefined" && location.protocol === "http:" && !/^(localhost|127(?:\.\d{1,3}){3}|\[::1\])$/.test(location.hostname);
@@ -6395,7 +6749,7 @@ var scopeLabel = (scope, roster) => {
};
var when = (time) => Number.isFinite(time) ? new Date(time).toLocaleString(dateLocale(), { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit" }) : "";
function MaskedInput({ value, onChange, onEnter, label, autoFocus = false }) {
- return (0, import_react10.createElement)("input", {
+ return (0, import_react14.createElement)("input", {
className: "bt-secret-input",
type: MASK_BY_CSS ? "text" : "password",
"data-masked": MASK_BY_CSS ? "" : void 0,
@@ -6421,11 +6775,11 @@ function MaskedInput({ value, onChange, onEnter, label, autoFocus = false }) {
}
function ScopeSwitch({ value, onChange, bot }) {
const options = [["all", t("All Bots")], ["bot", t("Only {name}", { name: bot.name })]];
- return (0, import_react10.createElement)(
+ return (0, import_react14.createElement)(
"div",
{ className: "bt-secret-scope", role: "radiogroup", "aria-label": t("Who may use it") },
- (0, import_react10.createElement)("span", { className: "bt-secret-glide", "data-at": value === "all" ? 0 : 1, "aria-hidden": true }),
- options.map(([id, text]) => (0, import_react10.createElement)("button", {
+ (0, import_react14.createElement)("span", { className: "bt-secret-glide", "data-at": value === "all" ? 0 : 1, "aria-hidden": true }),
+ options.map(([id, text]) => (0, import_react14.createElement)("button", {
key: id,
type: "button",
role: "radio",
@@ -6436,28 +6790,28 @@ function ScopeSwitch({ value, onChange, bot }) {
);
}
function SecretHead({ bot, title, detail, name, onClose }) {
- return (0, import_react10.createElement)(
+ return (0, import_react14.createElement)(
"div",
{ className: "bt-q-head bt-secret-head" },
- (0, import_react10.createElement)("span", { className: "bt-secret-who" }, (0, import_react10.createElement)(BotMark, { bot, size: 28 }), (0, import_react10.createElement)("span", { className: "bt-secret-lock" }, (0, import_react10.createElement)(LockIcon))),
- (0, import_react10.createElement)(
+ (0, import_react14.createElement)("span", { className: "bt-secret-who" }, (0, import_react14.createElement)(BotMark, { bot, size: 28 }), (0, import_react14.createElement)("span", { className: "bt-secret-lock" }, (0, import_react14.createElement)(LockIcon))),
+ (0, import_react14.createElement)(
"div",
{ className: "bt-q-text" },
- (0, import_react10.createElement)("p", { className: "bt-q-title" }, title),
- (0, import_react10.createElement)("div", { className: "bt-q-detail" }, (0, import_react10.createElement)("code", { className: "bt-secret-name" }, name), detail ? ` · ${detail}` : "")
+ (0, import_react14.createElement)("p", { className: "bt-q-title" }, title),
+ (0, import_react14.createElement)("div", { className: "bt-q-detail" }, (0, import_react14.createElement)("code", { className: "bt-secret-name" }, name), detail ? ` · ${detail}` : "")
),
- onClose ? (0, import_react10.createElement)("button", { type: "button", className: "bt-q-x", "aria-label": t("Cancel the request"), title: t("Cancel"), onClick: onClose }, (0, import_react10.createElement)(CloseIcon)) : null
+ onClose ? (0, import_react14.createElement)("button", { type: "button", className: "bt-q-x", "aria-label": t("Cancel the request"), title: t("Cancel"), onClick: onClose }, (0, import_react14.createElement)(CloseIcon)) : null
);
}
function SecretCard({ sessionId, bot, request, roster, actions, inline = false }) {
- const [value, setValue] = (0, import_react10.useState)("");
- const [scope, setScope] = (0, import_react10.useState)("all");
- const [replacing, setReplacing] = (0, import_react10.useState)(false);
- const [busy, setBusy] = (0, import_react10.useState)(false);
- const [error, setError] = (0, import_react10.useState)("");
- const busyRef = (0, import_react10.useRef)(false);
+ const [value, setValue] = (0, import_react14.useState)("");
+ const [scope, setScope] = (0, import_react14.useState)("all");
+ const [replacing, setReplacing] = (0, import_react14.useState)(false);
+ const [busy, setBusy] = (0, import_react14.useState)(false);
+ const [error, setError] = (0, import_react14.useState)("");
+ const busyRef = (0, import_react14.useRef)(false);
const hold = useDockHold(sessionId, "secret", request.id, actions, inline);
- const noteId = (0, import_react10.useId)();
+ const noteId = (0, import_react14.useId)();
const secret = (roster.secrets ?? []).find((entry) => entry.name === request.name);
const run2 = (make) => {
if (busyRef.current) return void 0;
@@ -6479,86 +6833,86 @@ function SecretCard({ sessionId, bot, request, roster, actions, inline = false }
if (!busy) void run2(() => actions.secretAllow(request.id));
};
const filling = request.kind === "fill" || replacing;
- const warn = insecure() ? (0, import_react10.createElement)("div", { className: "bt-secret-warn", role: "note" }, (0, import_react10.createElement)(WarnIcon), t("This page is not on HTTPS: the key crosses the network unencrypted.")) : null;
- return (0, import_react10.createElement)(
+ const warn = insecure() ? (0, import_react14.createElement)("div", { className: "bt-secret-warn", role: "note" }, (0, import_react14.createElement)(WarnIcon), t("This page is not on HTTPS: the key crosses the network unencrypted.")) : null;
+ return (0, import_react14.createElement)(
"div",
{ className: "bt-q bt-secret", role: "group", "aria-describedby": noteId, "data-kind": request.kind, onFocusCapture: hold, onPointerDownCapture: hold },
- (0, import_react10.createElement)(SecretHead, {
+ (0, import_react14.createElement)(SecretHead, {
bot,
title: request.kind === "allow" ? t("Let {bot} use {name}?", { bot: bot.name, name: request.name }) : t("{name} needs a key", { name: bot.name }),
detail: request.purpose,
name: request.name,
onClose: busy ? void 0 : cancel
}),
- request.kind === "allow" ? (0, import_react10.createElement)("div", { className: "bt-secret-saved" }, (0, import_react10.createElement)(KeyIcon), t("Saved for {scope}", { scope: scopeLabel(secret?.scope, roster) })) : null,
- filling ? (0, import_react10.createElement)(
+ request.kind === "allow" ? (0, import_react14.createElement)("div", { className: "bt-secret-saved" }, (0, import_react14.createElement)(KeyIcon), t("Saved for {scope}", { scope: scopeLabel(secret?.scope, roster) })) : null,
+ filling ? (0, import_react14.createElement)(
"div",
{ className: "bt-secret-body" },
- (0, import_react10.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react10.createElement)(MaskedInput, { value, onChange: (next) => {
+ (0, import_react14.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react14.createElement)(MaskedInput, { value, onChange: (next) => {
hold();
setValue(next);
}, onEnter: save, label: t("Value of {name}", { name: request.name }), autoFocus: replacing })),
- request.kind === "fill" ? (0, import_react10.createElement)(ScopeSwitch, { value: scope, onChange: (next) => {
+ request.kind === "fill" ? (0, import_react14.createElement)(ScopeSwitch, { value: scope, onChange: (next) => {
hold();
setScope(next);
}, bot }) : null
) : null,
- (0, import_react10.createElement)(
+ (0, import_react14.createElement)(
"div",
{ className: "bt-secret-note", id: noteId },
t("{bot} never sees the value. It reaches {bot}'s shell as ", { bot: bot.name }),
- (0, import_react10.createElement)("code", null, `$DSH_SECRET_${request.name}`),
+ (0, import_react14.createElement)("code", null, `$DSH_SECRET_${request.name}`),
".",
filling && value !== "" && !long ? t(" At least {count} characters.", { count: MIN_VALUE }) : ""
),
warn,
- error ? (0, import_react10.createElement)("div", { className: "bt-secret-error", role: "alert" }, error) : null,
- (0, import_react10.createElement)(
+ error ? (0, import_react14.createElement)("div", { className: "bt-secret-error", role: "alert" }, error) : null,
+ (0, import_react14.createElement)(
"div",
{ className: "bt-q-foot" },
- request.kind === "allow" && !replacing ? (0, import_react10.createElement)("button", { type: "button", className: "bt-q-btn", disabled: busy, onClick: () => {
+ request.kind === "allow" && !replacing ? (0, import_react14.createElement)("button", { type: "button", className: "bt-q-btn", disabled: busy, onClick: () => {
hold();
setReplacing(true);
} }, t("Replace value")) : null,
- (0, import_react10.createElement)("button", { type: "button", className: "bt-q-btn", disabled: busy, onClick: cancel }, t("Cancel")),
- filling ? (0, import_react10.createElement)("button", { type: "button", className: "bt-q-submit", disabled: !long || busy, onClick: save }, busy ? t("Saving…") : t("Save")) : (0, import_react10.createElement)("button", { type: "button", className: "bt-q-submit", disabled: busy, onClick: allow }, busy ? t("Allowing…") : t("Allow"))
+ (0, import_react14.createElement)("button", { type: "button", className: "bt-q-btn", disabled: busy, onClick: cancel }, t("Cancel")),
+ filling ? (0, import_react14.createElement)("button", { type: "button", className: "bt-q-submit", disabled: !long || busy, onClick: save }, busy ? t("Saving…") : t("Save")) : (0, import_react14.createElement)("button", { type: "button", className: "bt-q-submit", disabled: busy, onClick: allow }, busy ? t("Allowing…") : t("Allow"))
)
);
}
function SettledSecret({ bot, request, roster }) {
const canceled = request.status === "canceled";
const text = canceled ? t("{bot} asked for {name}", { bot: bot.name, name: request.name }) : request.status === "allowed" ? t("Allowed {bot} to use {name}", { bot: bot.name, name: request.name }) : t("Saved {name}", { name: request.name });
- return (0, import_react10.createElement)(
+ return (0, import_react14.createElement)(
"div",
{ className: "bt-q bt-q-settled bt-secret bt-secret-done", role: "group", "aria-label": text, "data-status": request.status },
- (0, import_react10.createElement)(
+ (0, import_react14.createElement)(
"div",
{ className: "bt-q-head" },
- (0, import_react10.createElement)("span", { className: "bt-secret-who" }, (0, import_react10.createElement)(BotMark, { bot, size: 22 })),
- (0, import_react10.createElement)("div", { className: "bt-q-text" }, (0, import_react10.createElement)(
+ (0, import_react14.createElement)("span", { className: "bt-secret-who" }, (0, import_react14.createElement)(BotMark, { bot, size: 22 })),
+ (0, import_react14.createElement)("div", { className: "bt-q-text" }, (0, import_react14.createElement)(
"p",
{ className: "bt-q-title" },
text,
- canceled ? null : (0, import_react10.createElement)("span", { className: "bt-secret-scope-tag" }, ` · ${scopeLabel(request.scope, roster)}`)
+ canceled ? null : (0, import_react14.createElement)("span", { className: "bt-secret-scope-tag" }, ` · ${scopeLabel(request.scope, roster)}`)
)),
- canceled ? (0, import_react10.createElement)("span", { className: "bt-q-badge" }, t("Canceled")) : (0, import_react10.createElement)("span", { className: "bt-q-check bt-secret-check", title: t("Done") }, (0, import_react10.createElement)(CheckIcon))
+ canceled ? (0, import_react14.createElement)("span", { className: "bt-q-badge" }, t("Canceled")) : (0, import_react14.createElement)("span", { className: "bt-q-check bt-secret-check", title: t("Done") }, (0, import_react14.createElement)(CheckIcon))
)
);
}
function RequestView({ sessionId, bot, request, roster, actions }) {
- return request.status === "pending" ? (0, import_react10.createElement)(SecretCard, { key: JSON.stringify([sessionId, request.id, request.kind]), sessionId, bot, request, roster, actions, inline: true }) : (0, import_react10.createElement)(SettledSecret, { bot, request, roster });
+ return request.status === "pending" ? (0, import_react14.createElement)(SecretCard, { key: JSON.stringify([sessionId, request.id, request.kind]), sessionId, bot, request, roster, actions, inline: true }) : (0, import_react14.createElement)(SettledSecret, { bot, request, roster });
}
function SecretToolCell({ sessionId, callId, name, done, content, roster, actions, heldCards = NONE }) {
const bot = roster.byId[sessionId];
if (!bot) return null;
const request = (roster.secretRequests?.[bot.id] ?? []).find((entry) => entry.callId === callId && (entry.sessionId ?? sessionId) === sessionId);
if (request?.status === "pending" && heldCards[heldCardKey("secret", request.id)] > 0) return null;
- if (request) return (0, import_react10.createElement)("div", { className: "bt-q-inline" }, (0, import_react10.createElement)(RequestView, { sessionId, bot, request, roster, actions }));
+ if (request) return (0, import_react14.createElement)("div", { className: "bt-q-inline" }, (0, import_react14.createElement)(RequestView, { sessionId, bot, request, roster, actions }));
if (done && /already saved/.test(contentText(content))) {
- return (0, import_react10.createElement)("div", { className: "bt-event" }, (0, import_react10.createElement)("span", { className: "bt-secret-event" }, (0, import_react10.createElement)(KeyIcon), t("{bot} is using {name}", { bot: bot.name, name: name ?? t("a saved key") })));
+ return (0, import_react14.createElement)("div", { className: "bt-event" }, (0, import_react14.createElement)("span", { className: "bt-secret-event" }, (0, import_react14.createElement)(KeyIcon), t("{bot} is using {name}", { bot: bot.name, name: name ?? t("a saved key") })));
}
if (done && contentText(content).startsWith("No card can be shown now")) {
- return (0, import_react10.createElement)("div", { className: "bt-event" }, (0, import_react10.createElement)("span", { className: "bt-secret-event" }, (0, import_react10.createElement)(KeyIcon), t("{bot} could not ask for a key: this window can only view the team", { bot: bot.name })));
+ return (0, import_react14.createElement)("div", { className: "bt-event" }, (0, import_react14.createElement)("span", { className: "bt-secret-event" }, (0, import_react14.createElement)(KeyIcon), t("{bot} could not ask for a key: this window can only view the team", { bot: bot.name })));
}
return null;
}
@@ -6571,59 +6925,59 @@ function SecretDock({ sessionId, useRoster, useCards, useHeldCards, actions }) {
const drawn = (entry) => entry.callId && entry.sessionId === sessionId && shown[entry.callId] > 0 && !(held[heldCardKey("secret", entry.id)] > 0);
const waiting = (roster.secretRequests?.[bot.id] ?? []).filter((entry) => entry.status === "pending" && !drawn(entry));
if (waiting.length === 0) return null;
- return (0, import_react10.createElement)("div", { className: "bt-q-dock bt-secret-dock" }, waiting.map((request) => (0, import_react10.createElement)(SecretCard, { key: JSON.stringify([sessionId, request.id, request.kind]), sessionId, bot, request, roster, actions })));
+ return (0, import_react14.createElement)("div", { className: "bt-q-dock bt-secret-dock" }, waiting.map((request) => (0, import_react14.createElement)(SecretCard, { key: JSON.stringify([sessionId, request.id, request.kind]), sessionId, bot, request, roster, actions })));
}
function ScopeEditor({ secret, roster, onSave }) {
- const [mode, setMode] = (0, import_react10.useState)(secret.scope === "all" ? "all" : "some");
- const [picked, setPicked] = (0, import_react10.useState)(secret.scope === "all" ? [] : secret.scope);
+ const [mode, setMode] = (0, import_react14.useState)(secret.scope === "all" ? "all" : "some");
+ const [picked, setPicked] = (0, import_react14.useState)(secret.scope === "all" ? [] : secret.scope);
const toggle = (id) => setPicked((list) => list.includes(id) ? list.filter((item) => item !== id) : [...list, id]);
const same = mode === "all" ? secret.scope === "all" : secret.scope !== "all" && [...picked].sort().join() === [...secret.scope].sort().join();
- return (0, import_react10.createElement)(
+ return (0, import_react14.createElement)(
"div",
{ className: "bt-secret-edit-block" },
- (0, import_react10.createElement)("div", { className: "bt-secret-edit-label" }, t("Who may use it")),
- (0, import_react10.createElement)(
+ (0, import_react14.createElement)("div", { className: "bt-secret-edit-label" }, t("Who may use it")),
+ (0, import_react14.createElement)(
"div",
{ className: "bt-secret-radios", role: "radiogroup", "aria-label": t("Who may use {name}", { name: secret.name }) },
- [["all", t("All Bots")], ["some", t("Chosen Bots")]].map(([id, text]) => (0, import_react10.createElement)(
+ [["all", t("All Bots")], ["some", t("Chosen Bots")]].map(([id, text]) => (0, import_react14.createElement)(
"label",
{ key: id, className: "bt-secret-radio" },
- (0, import_react10.createElement)("input", { type: "radio", name: `scope-${secret.name}`, checked: mode === id, onChange: () => setMode(id) }),
+ (0, import_react14.createElement)("input", { type: "radio", name: `scope-${secret.name}`, checked: mode === id, onChange: () => setMode(id) }),
text
))
),
- mode === "some" ? (0, import_react10.createElement)("div", { className: "bt-secret-bots" }, roster.bots.map((bot) => (0, import_react10.createElement)("button", {
+ mode === "some" ? (0, import_react14.createElement)("div", { className: "bt-secret-bots" }, roster.bots.map((bot) => (0, import_react14.createElement)("button", {
key: bot.id,
type: "button",
className: "bt-secret-bot",
"aria-pressed": picked.includes(bot.id),
onClick: () => toggle(bot.id)
- }, (0, import_react10.createElement)(BotAvatar, { bot, size: 20, badge: false, live: false }), bot.name, picked.includes(bot.id) ? (0, import_react10.createElement)(CheckIcon) : null))) : null,
- (0, import_react10.createElement)(
+ }, (0, import_react14.createElement)(BotAvatar, { bot, size: 20, badge: false, live: false }), bot.name, picked.includes(bot.id) ? (0, import_react14.createElement)(CheckIcon) : null))) : null,
+ (0, import_react14.createElement)(
"div",
{ className: "bt-secret-row-actions" },
- (0, import_react10.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: same, onClick: () => onSave(mode === "all" ? "all" : picked) }, t("Save access"))
+ (0, import_react14.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: same, onClick: () => onSave(mode === "all" ? "all" : picked) }, t("Save access"))
)
);
}
function PurposeEditor({ secret, onSave }) {
- const [purpose, setPurpose] = (0, import_react10.useState)(secret.purpose ?? "");
+ const [purpose, setPurpose] = (0, import_react14.useState)(secret.purpose ?? "");
const same = purpose.trim() === (secret.purpose ?? "");
- return (0, import_react10.createElement)(
+ return (0, import_react14.createElement)(
"div",
{ className: "bt-secret-edit-block" },
- (0, import_react10.createElement)("div", { className: "bt-secret-edit-label" }, t("What it is for")),
- (0, import_react10.createElement)(
+ (0, import_react14.createElement)("div", { className: "bt-secret-edit-label" }, t("What it is for")),
+ (0, import_react14.createElement)(
"div",
{ className: "bt-secret-inline" },
- (0, import_react10.createElement)("input", { className: "bt-input", "aria-label": t("What it is for"), placeholder: t("What it is for"), value: purpose, spellCheck: false, autoComplete: "off", onChange: (event) => setPurpose(event.target.value) }),
- (0, import_react10.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: same, onClick: () => onSave(purpose.trim()) }, t("Save"))
+ (0, import_react14.createElement)("input", { className: "bt-input", "aria-label": t("What it is for"), placeholder: t("What it is for"), value: purpose, spellCheck: false, autoComplete: "off", onChange: (event) => setPurpose(event.target.value) }),
+ (0, import_react14.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: same, onClick: () => onSave(purpose.trim()) }, t("Save"))
)
);
}
function ValueEditor({ secret, onSave }) {
- const [value, setValue] = (0, import_react10.useState)("");
- const [replaced, setReplaced] = (0, import_react10.useState)(false);
+ const [value, setValue] = (0, import_react14.useState)("");
+ const [replaced, setReplaced] = (0, import_react14.useState)(false);
const long = value.trim().length >= MIN_VALUE;
const save = () => {
if (!long) return;
@@ -6638,67 +6992,67 @@ function ValueEditor({ secret, onSave }) {
setValue(next);
setReplaced(false);
};
- return (0, import_react10.createElement)(
+ return (0, import_react14.createElement)(
"div",
{ className: "bt-secret-edit-block" },
- (0, import_react10.createElement)("div", { className: "bt-secret-edit-label" }, t("Replace the value")),
- (0, import_react10.createElement)(
+ (0, import_react14.createElement)("div", { className: "bt-secret-edit-label" }, t("Replace the value")),
+ (0, import_react14.createElement)(
"div",
{ className: "bt-secret-inline" },
- (0, import_react10.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react10.createElement)(MaskedInput, { value, onChange: edit, onEnter: save, label: t("New value of {name}", { name: secret.name }) })),
- (0, import_react10.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: !long, onClick: save }, t("Replace"))
+ (0, import_react14.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react14.createElement)(MaskedInput, { value, onChange: edit, onEnter: save, label: t("New value of {name}", { name: secret.name }) })),
+ (0, import_react14.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: !long, onClick: save }, t("Replace"))
),
- value !== "" && !long ? (0, import_react10.createElement)("div", { className: "bt-set-hint" }, t("At least {count} characters.", { count: MIN_VALUE })) : replaced ? (0, import_react10.createElement)("div", { className: "bt-set-hint bt-secret-ok", role: "status" }, (0, import_react10.createElement)(CheckIcon), t("Replaced. Bots get the new value from their next command.")) : null
+ value !== "" && !long ? (0, import_react14.createElement)("div", { className: "bt-set-hint" }, t("At least {count} characters.", { count: MIN_VALUE })) : replaced ? (0, import_react14.createElement)("div", { className: "bt-set-hint bt-secret-ok", role: "status" }, (0, import_react14.createElement)(CheckIcon), t("Replaced. Bots get the new value from their next command.")) : null
);
}
function SecretRow({ secret, roster, actions, run: run2, open, onToggle }) {
- const [confirm, setConfirm] = (0, import_react10.useState)(false);
- (0, import_react10.useEffect)(() => {
+ const [confirm, setConfirm] = (0, import_react14.useState)(false);
+ (0, import_react14.useEffect)(() => {
if (!open) setConfirm(false);
}, [open]);
const asker = secret.requestedBy ? roster.byId[secret.requestedBy]?.name ?? t("a deleted Bot") : t("you");
const allowed2 = secret.scope === "all" ? [] : secret.scope.map((id) => roster.byId[id]).filter(Boolean);
const meta = [t("Asked by {name}", { name: asker }), t("added {time}", { time: when(secret.createdAt) }), secret.lastUsedAt ? t("last used {time}", { time: when(secret.lastUsedAt) }) : t("not used yet")].join(" · ");
- return (0, import_react10.createElement)(
+ return (0, import_react14.createElement)(
"div",
{ className: "bt-secret-item", "data-open": open ? "" : void 0 },
- (0, import_react10.createElement)(
+ (0, import_react14.createElement)(
"button",
{ type: "button", className: "bt-set-row bt-secret-summary", "aria-expanded": open, onClick: onToggle },
- (0, import_react10.createElement)(
+ (0, import_react14.createElement)(
"span",
{ className: "bt-set-copy" },
- (0, import_react10.createElement)("span", { className: "bt-secret-title" }, (0, import_react10.createElement)(KeyIcon), (0, import_react10.createElement)("code", { className: "bt-secret-name" }, secret.name), secret.purpose ? (0, import_react10.createElement)("span", { className: "bt-secret-purpose" }, secret.purpose) : null),
- (0, import_react10.createElement)("span", { className: "bt-set-hint" }, meta)
+ (0, import_react14.createElement)("span", { className: "bt-secret-title" }, (0, import_react14.createElement)(KeyIcon), (0, import_react14.createElement)("code", { className: "bt-secret-name" }, secret.name), secret.purpose ? (0, import_react14.createElement)("span", { className: "bt-secret-purpose" }, secret.purpose) : null),
+ (0, import_react14.createElement)("span", { className: "bt-set-hint" }, meta)
),
- (0, import_react10.createElement)(
+ (0, import_react14.createElement)(
"span",
{ className: "bt-set-control" },
- secret.scope === "all" ? (0, import_react10.createElement)("span", { className: "bt-tag" }, t("All Bots")) : allowed2.length === 0 ? (0, import_react10.createElement)("span", { className: "bt-tag" }, t("No Bot")) : (0, import_react10.createElement)("span", { className: "bt-secret-faces", title: allowed2.map((bot) => bot.name).join(", ") }, allowed2.slice(0, 5).map((bot) => (0, import_react10.createElement)(BotAvatar, { key: bot.id, bot, size: 20, badge: false, live: false })))
+ secret.scope === "all" ? (0, import_react14.createElement)("span", { className: "bt-tag" }, t("All Bots")) : allowed2.length === 0 ? (0, import_react14.createElement)("span", { className: "bt-tag" }, t("No Bot")) : (0, import_react14.createElement)("span", { className: "bt-secret-faces", title: allowed2.map((bot) => bot.name).join(", ") }, allowed2.slice(0, 5).map((bot) => (0, import_react14.createElement)(BotAvatar, { key: bot.id, bot, size: 20, badge: false, live: false })))
)
),
- open ? (0, import_react10.createElement)(
+ open ? (0, import_react14.createElement)(
"div",
{ className: "bt-secret-edit" },
- (0, import_react10.createElement)(ScopeEditor, { key: JSON.stringify(secret.scope), secret, roster, onSave: (scope) => run2(actions.secretUpdate(secret.name, { scope })) }),
- (0, import_react10.createElement)(PurposeEditor, { key: secret.purpose ?? "", secret, onSave: (purpose) => run2(actions.secretUpdate(secret.name, { purpose })) }),
- (0, import_react10.createElement)(ValueEditor, { secret, onSave: (value) => run2(actions.secretSet({ name: secret.name, value })) }),
- (0, import_react10.createElement)(
+ (0, import_react14.createElement)(ScopeEditor, { key: JSON.stringify(secret.scope), secret, roster, onSave: (scope) => run2(actions.secretUpdate(secret.name, { scope })) }),
+ (0, import_react14.createElement)(PurposeEditor, { key: secret.purpose ?? "", secret, onSave: (purpose) => run2(actions.secretUpdate(secret.name, { purpose })) }),
+ (0, import_react14.createElement)(ValueEditor, { secret, onSave: (value) => run2(actions.secretSet({ name: secret.name, value })) }),
+ (0, import_react14.createElement)(
"div",
{ className: "bt-secret-row-actions" },
confirm ? [
- (0, import_react10.createElement)("span", { key: "q", className: "bt-set-hint" }, t("Delete {name}? Bots lose it at once.", { name: secret.name })),
- (0, import_react10.createElement)("button", { key: "no", type: "button", className: "bt-soft bt-soft-sm", onClick: () => setConfirm(false) }, t("Keep")),
- (0, import_react10.createElement)("button", { key: "yes", type: "button", className: "bt-soft bt-soft-sm bt-secret-danger", onClick: () => run2(actions.secretDelete(secret.name)) }, t("Delete"))
- ] : (0, import_react10.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-secret-danger", onClick: () => setConfirm(true) }, (0, import_react10.createElement)(TrashIcon), t("Delete"))
+ (0, import_react14.createElement)("span", { key: "q", className: "bt-set-hint" }, t("Delete {name}? Bots lose it at once.", { name: secret.name })),
+ (0, import_react14.createElement)("button", { key: "no", type: "button", className: "bt-soft bt-soft-sm", onClick: () => setConfirm(false) }, t("Keep")),
+ (0, import_react14.createElement)("button", { key: "yes", type: "button", className: "bt-soft bt-soft-sm bt-secret-danger", onClick: () => run2(actions.secretDelete(secret.name)) }, t("Delete"))
+ ] : (0, import_react14.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-secret-danger", onClick: () => setConfirm(true) }, (0, import_react14.createElement)(TrashIcon), t("Delete"))
)
) : null
);
}
function AddSecret({ actions, run: run2, onDone }) {
- const [name, setName] = (0, import_react10.useState)("");
- const [purpose, setPurpose] = (0, import_react10.useState)("");
- const [value, setValue] = (0, import_react10.useState)("");
+ const [name, setName] = (0, import_react14.useState)("");
+ const [purpose, setPurpose] = (0, import_react14.useState)("");
+ const [value, setValue] = (0, import_react14.useState)("");
const ready = /^[A-Za-z][\w-]{0,63}$/.test(name.trim()) && value.trim().length >= MIN_VALUE;
const save = () => {
if (!ready) return;
@@ -6709,43 +7063,43 @@ function AddSecret({ actions, run: run2, onDone }) {
}
});
};
- return (0, import_react10.createElement)(
+ return (0, import_react14.createElement)(
"div",
{ className: "bt-set-row bt-set-paste bt-secret-add" },
- (0, import_react10.createElement)("input", { className: "bt-input", "aria-label": t("Key name"), placeholder: t("NAME, e.g. GITHUB_TOKEN"), value: name, spellCheck: false, autoComplete: "off", autoFocus: true, onChange: (event) => setName(event.target.value.toUpperCase()) }),
- (0, import_react10.createElement)("input", { className: "bt-input", "aria-label": t("What it is for"), placeholder: t("What it is for"), value: purpose, autoComplete: "off", onChange: (event) => setPurpose(event.target.value) }),
- (0, import_react10.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react10.createElement)(MaskedInput, { value, onChange: setValue, onEnter: save, label: t("Value") })),
- (0, import_react10.createElement)(
+ (0, import_react14.createElement)("input", { className: "bt-input", "aria-label": t("Key name"), placeholder: t("NAME, e.g. GITHUB_TOKEN"), value: name, spellCheck: false, autoComplete: "off", autoFocus: true, onChange: (event) => setName(event.target.value.toUpperCase()) }),
+ (0, import_react14.createElement)("input", { className: "bt-input", "aria-label": t("What it is for"), placeholder: t("What it is for"), value: purpose, autoComplete: "off", onChange: (event) => setPurpose(event.target.value) }),
+ (0, import_react14.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react14.createElement)(MaskedInput, { value, onChange: setValue, onEnter: save, label: t("Value") })),
+ (0, import_react14.createElement)(
"div",
{ className: "bt-secret-row-actions" },
- (0, import_react10.createElement)("span", { className: "bt-set-hint" }, t("New keys are for all Bots; narrow it down afterwards.")),
- (0, import_react10.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onDone }, t("Cancel")),
- (0, import_react10.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: !ready, onClick: save }, t("Save key"))
+ (0, import_react14.createElement)("span", { className: "bt-set-hint" }, t("New keys are for all Bots; narrow it down afterwards.")),
+ (0, import_react14.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onDone }, t("Cancel")),
+ (0, import_react14.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: !ready, onClick: save }, t("Save key"))
)
);
}
function SecretsPage({ roster, actions, run: run2, Section }) {
- const [open, setOpen] = (0, import_react10.useState)(null);
- const [adding, setAdding] = (0, import_react10.useState)(false);
+ const [open, setOpen] = (0, import_react14.useState)(null);
+ const [adding, setAdding] = (0, import_react14.useState)(false);
const secrets = roster.secrets ?? [];
return [
- (0, import_react10.createElement)(
+ (0, import_react14.createElement)(
"p",
{ key: "about", className: "bt-secret-about" },
t("Keys your Bots asked for. Bots never see the values: they use them as "),
- (0, import_react10.createElement)("code", null, "$DSH_SECRET_NAME"),
+ (0, import_react14.createElement)("code", null, "$DSH_SECRET_NAME"),
t(" in their shell, and every value is replaced by "),
- (0, import_react10.createElement)("code", null, "[secret:NAME]"),
+ (0, import_react14.createElement)("code", null, "[secret:NAME]"),
t(" before anything goes to a model.")
),
- (0, import_react10.createElement)(
+ (0, import_react14.createElement)(
Section,
{ key: "list", title: t("Secrets · {count}", { count: secrets.length }) },
- secrets.length === 0 && !adding ? (0, import_react10.createElement)("div", { className: "bt-set-row" }, (0, import_react10.createElement)("span", { className: "bt-set-hint" }, t("No keys yet. When a Bot needs one, it shows a card in its chat."))) : null,
- secrets.map((secret) => (0, import_react10.createElement)(SecretRow, { key: secret.name, secret, roster, actions, run: run2, open: open === secret.name, onToggle: () => setOpen(open === secret.name ? null : secret.name) })),
- adding ? (0, import_react10.createElement)(AddSecret, { actions, run: run2, onDone: () => setAdding(false) }) : null
+ secrets.length === 0 && !adding ? (0, import_react14.createElement)("div", { className: "bt-set-row" }, (0, import_react14.createElement)("span", { className: "bt-set-hint" }, t("No keys yet. When a Bot needs one, it shows a card in its chat."))) : null,
+ secrets.map((secret) => (0, import_react14.createElement)(SecretRow, { key: secret.name, secret, roster, actions, run: run2, open: open === secret.name, onToggle: () => setOpen(open === secret.name ? null : secret.name) })),
+ adding ? (0, import_react14.createElement)(AddSecret, { actions, run: run2, onDone: () => setAdding(false) }) : null
),
- adding ? null : (0, import_react10.createElement)("div", { key: "add", className: "bt-actions" }, (0, import_react10.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setAdding(true) }, t("Add a key")))
+ adding ? null : (0, import_react14.createElement)("div", { key: "add", className: "bt-actions" }, (0, import_react14.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setAdding(true) }, t("Add a key")))
];
}
var SECRET_CSS = `
@@ -6830,7 +7184,7 @@ var texts = (step) => step.blocks.filter((block) => block.kind === "text" && blo
var stepReasoning = (step) => step.blocks.filter((block) => block.kind === "reasoning").map((block) => block.text).join("\n").trim();
// src/client/fold.js
-var import_react11 = require("react");
+var import_react15 = require("react");
var FOLD_AT = { chars: 1500, lines: 25 };
var FOLD_HUGE = { chars: 2e4, lines: Infinity };
var ALWAYS = { chars: -1, lines: 0 };
@@ -6891,10 +7245,10 @@ ${open}`;
}
var stripLongNote = (text) => text.replace(/^\[A long message: \d+ characters\.[^\]\n]*\]\n/, "");
function useFold(text, { limit = FOLD_AT, whole, live = false, markdown = true } = {}) {
- const [open, setOpen] = (0, import_react11.useState)(false);
- const [read, setRead] = (0, import_react11.useState)();
+ const [open, setOpen] = (0, import_react15.useState)(false);
+ const [read, setRead] = (0, import_react15.useState)();
const cut = whole !== void 0 && whole.length > text.length;
- const preview = (0, import_react11.useMemo)(() => live ? null : foldPreview(text, cut ? ALWAYS : limit, markdown), [text, live, limit, markdown, cut]);
+ const preview = (0, import_react15.useMemo)(() => live ? null : foldPreview(text, cut ? ALWAYS : limit, markdown), [text, live, limit, markdown, cut]);
if (preview === null) return { shown: text, control: null };
const count = (cut ? whole.length : text.length).toLocaleString();
if (!open) {
@@ -6904,17 +7258,17 @@ function useFold(text, { limit = FOLD_AT, whole, live = false, markdown = true }
setRead("loading");
setRead(await whole.load() ?? { whole: false });
};
- return { shown: preview, folded: true, control: (0, import_react11.createElement)("span", { className: "bt-fold" }, (0, import_react11.createElement)("button", { type: "button", className: "bt-more", onClick: show2 }, t("Show all · {count} characters", { count }))) };
+ return { shown: preview, folded: true, control: (0, import_react15.createElement)("span", { className: "bt-fold" }, (0, import_react15.createElement)("button", { type: "button", className: "bt-more", onClick: show2 }, t("Show all · {count} characters", { count }))) };
}
const loaded = typeof read?.text === "string" ? read : void 0;
const note = !cut || read === void 0 || read === "loading" || loaded?.whole ? null : loaded !== void 0 && loaded.text.length > text.length ? t("Showing the first {count} characters", { count: loaded.text.length.toLocaleString() }) : t("Only the start of this message is kept here");
return {
shown: loaded?.text ?? text,
- control: (0, import_react11.createElement)(
+ control: (0, import_react15.createElement)(
"span",
{ className: "bt-fold" },
- note ? (0, import_react11.createElement)("span", { className: "bt-fold-note" }, note) : null,
- (0, import_react11.createElement)("button", { type: "button", className: "bt-more", onClick: () => setOpen(false) }, t("Show less"))
+ note ? (0, import_react15.createElement)("span", { className: "bt-fold-note" }, note) : null,
+ (0, import_react15.createElement)("button", { type: "button", className: "bt-more", onClick: () => setOpen(false) }, t("Show less"))
)
};
}
@@ -7118,7 +7472,7 @@ function withBtwRows(items, cards) {
}
// src/client/btw.js
-var import_react12 = require("react");
+var import_react16 = require("react");
var mdLabels2 = () => ({ code: { copyLabel: t("Copy"), copiedLabel: t("Copied") }, footnotes: t("Footnotes") });
function failureText(card) {
const raw = typeof card.error === "string" ? card.error : card.error?.message;
@@ -7130,8 +7484,8 @@ function stampOf(card) {
return Number.isFinite(time) ? time : void 0;
}
function BtwCardView({ card, compact: compact2 = false }) {
- const [open, setOpen] = (0, import_react12.useState)(card?.status !== "answering");
- (0, import_react12.useEffect)(() => {
+ const [open, setOpen] = (0, import_react16.useState)(card?.status !== "answering");
+ (0, import_react16.useEffect)(() => {
if (card?.status && card.status !== "answering") setOpen(true);
}, [card?.status]);
if (!card) return null;
@@ -7139,7 +7493,7 @@ function BtwCardView({ card, compact: compact2 = false }) {
const answer = typeof card.answer === "string" ? card.answer : "";
const when3 = stampOf(card);
const answering = card.status === "answering";
- return (0, import_react12.createElement)(
+ return (0, import_react16.createElement)(
"div",
{
className: compact2 ? "bt-btw bt-btw-compact" : "bt-btw",
@@ -7148,10 +7502,10 @@ function BtwCardView({ card, compact: compact2 = false }) {
role: "region",
"aria-label": t("Side question")
},
- (0, import_react12.createElement)(
+ (0, import_react16.createElement)(
"div",
{ className: "bt-btw-head" },
- (0, import_react12.createElement)(
+ (0, import_react16.createElement)(
"button",
{
type: "button",
@@ -7159,25 +7513,25 @@ function BtwCardView({ card, compact: compact2 = false }) {
"aria-expanded": open,
onClick: () => setOpen((value) => !value)
},
- (0, import_react12.createElement)("span", { className: "bt-btw-chevron", "aria-hidden": true }),
- (0, import_react12.createElement)("span", { className: "bt-btw-q" }, question)
+ (0, import_react16.createElement)("span", { className: "bt-btw-chevron", "aria-hidden": true }),
+ (0, import_react16.createElement)("span", { className: "bt-btw-q" }, question)
),
- when3 !== void 0 ? (0, import_react12.createElement)("time", { className: "bt-btw-time", dateTime: new Date(when3).toISOString() }, messageClock(when3)) : null,
- answering ? (0, import_react12.createElement)("span", { className: "bt-shimmer" }, t("Answering…")) : null,
- card.status === "cancelled" ? (0, import_react12.createElement)("span", { className: "bt-btw-status" }, t("Cancelled")) : null
+ when3 !== void 0 ? (0, import_react16.createElement)("time", { className: "bt-btw-time", dateTime: new Date(when3).toISOString() }, messageClock(when3)) : null,
+ answering ? (0, import_react16.createElement)("span", { className: "bt-shimmer" }, t("Answering…")) : null,
+ card.status === "cancelled" ? (0, import_react16.createElement)("span", { className: "bt-btw-status" }, t("Cancelled")) : null
),
- (0, import_react12.createElement)("p", { className: "bt-btw-note" }, t("Answered from progress so far; nothing was run")),
- open ? (0, import_react12.createElement)(
+ (0, import_react16.createElement)("p", { className: "bt-btw-note" }, t("Answered from progress so far; nothing was run")),
+ open ? (0, import_react16.createElement)(
"div",
{ className: "bt-btw-body" },
- card.status === "failed" ? (0, import_react12.createElement)("p", { className: "bt-btw-fail" }, failureText(card)) : null,
- answer !== "" ? (0, import_react12.createElement)("div", { className: "bt-btw-answer" }, (0, import_react12.createElement)(import_dsh_client_ui_primitives.MarkdownText, { text: answer, labels: mdLabels2(), variant: "compact" })) : null
+ card.status === "failed" ? (0, import_react16.createElement)("p", { className: "bt-btw-fail" }, failureText(card)) : null,
+ answer !== "" ? (0, import_react16.createElement)("div", { className: "bt-btw-answer" }, (0, import_react16.createElement)(import_dsh_client_ui_primitives.MarkdownText, { text: answer, labels: mdLabels2(), variant: "compact" })) : null
) : null
);
}
function useTurnFacts(sessionId, actions) {
- const [facts, setFacts] = (0, import_react12.useState)(() => actions.turnFacts(sessionId));
- (0, import_react12.useEffect)(() => {
+ const [facts, setFacts] = (0, import_react16.useState)(() => actions.turnFacts(sessionId));
+ (0, import_react16.useEffect)(() => {
let live = true;
const read = () => {
if (!live) return;
@@ -7198,18 +7552,18 @@ function BtwDock({ sessionId, useRoster, actions }) {
const facts = useTurnFacts(sessionId, actions);
const cards = dockCards(sessionCards(roster, sessionId), facts);
if (cards.length === 0) return null;
- return (0, import_react12.createElement)("div", { className: "bt-btw-dock" }, cards.map((card) => (0, import_react12.createElement)(BtwCardView, { key: card.id, card, compact: true })));
+ return (0, import_react16.createElement)("div", { className: "bt-btw-dock" }, cards.map((card) => (0, import_react16.createElement)(BtwCardView, { key: card.id, card, compact: true })));
}
function BtwTurnTail({ turn, sessionId, useRoster, actions }) {
const roster = useRoster((value) => value);
const facts = useTurnFacts(sessionId, actions);
const cards = tailCards(sessionCards(roster, sessionId), turn, facts?.turns);
if (cards.length === 0) return null;
- return (0, import_react12.createElement)("div", { className: "bt-btw-stack" }, cards.map((card) => (0, import_react12.createElement)(BtwCardView, { key: card.id, card })));
+ return (0, import_react16.createElement)("div", { className: "bt-btw-stack" }, cards.map((card) => (0, import_react16.createElement)(BtwCardView, { key: card.id, card })));
}
// src/client/cells.js
-var import_react13 = require("react");
+var import_react17 = require("react");
var import_react_dom = require("react-dom");
var mdLabels3 = () => ({ code: { copyLabel: t("Copy"), copiedLabel: t("Copied") }, footnotes: t("Footnotes") });
function Bubbles({ texts: texts2, roster, selfId, actions, streaming, sessionId, msgKey, useUi, lead, mentions, fold = FOLD_AT, whole }) {
@@ -7221,12 +7575,12 @@ function Bubbles({ texts: texts2, roster, selfId, actions, streaming, sessionId,
actions.openSession(target);
};
const reactions = useUi ? useUi((state) => msgKey ? state.reactions?.[msgKey] ?? null : null) : null;
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"div",
{ className: "bt-astack", "data-lead": lead ? "" : void 0, onClickCapture: onClick },
texts2.map((text, index) => {
const last = index === texts2.length - 1;
- return (0, import_react13.createElement)(Bubble, {
+ return (0, import_react17.createElement)(Bubble, {
key: index,
text,
index,
@@ -7248,30 +7602,30 @@ function Bubbles({ texts: texts2, roster, selfId, actions, streaming, sessionId,
function Bubble({ text, index, roster, selfId, actions, sessionId, msgKey, mentions, fold, picked, live, lead, whole }) {
const { shown, folded, control } = useFold(text, { limit: fold, whole, live });
const key = msgKey ? `${msgKey}:${index}` : void 0;
- const body = (0, import_react13.createElement)(import_dsh_client_ui_primitives.MarkdownText, { text: linkMentions(shown, roster.bots, selfId), streaming: live, labels: mdLabels3(), variant: "compact", fileMentions: mentions });
- const row = (0, import_react13.useRef)(null);
- const [toolsOpen, setToolsOpen] = (0, import_react13.useState)(false);
+ const body = (0, import_react17.createElement)(import_dsh_client_ui_primitives.MarkdownText, { text: linkMentions(shown, roster.bots, selfId), streaming: live, labels: mdLabels3(), variant: "compact", fileMentions: mentions });
+ const row = (0, import_react17.useRef)(null);
+ const [toolsOpen, setToolsOpen] = (0, import_react17.useState)(false);
useDismiss(toolsOpen, () => setToolsOpen(false), [row]);
const tapTools = (event) => {
if (!noHover() || event.target instanceof Element && event.target.closest("a,button,input,textarea,select,pre,code,[role=button],[role=link]")) return;
setToolsOpen((value) => !value);
};
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"div",
{ ref: row, className: "bt-msg", onClick: tapTools },
- (0, import_react13.createElement)(
+ (0, import_react17.createElement)(
"div",
{ className: "bt-msg-line" },
lead,
- (0, import_react13.createElement)(
+ (0, import_react17.createElement)(
"div",
{ className: "bt-bubble", "data-folded": folded || void 0 },
- control ? (0, import_react13.createElement)("div", { className: "bt-fold-body" }, body) : body,
+ control ? (0, import_react17.createElement)("div", { className: "bt-fold-body" }, body) : body,
control
),
- live ? null : (0, import_react13.createElement)(MessageTools, { text: folded ? text : shown, name: roster.byId[selfId]?.name ?? t("Bot"), sessionId, react: key ? (emoji) => actions.toggleReaction(msgKey, index, emoji) : void 0, actions, open: toolsOpen })
+ live ? null : (0, import_react17.createElement)(MessageTools, { text: folded ? text : shown, name: roster.byId[selfId]?.name ?? t("Bot"), sessionId, react: key ? (emoji) => actions.toggleReaction(msgKey, index, emoji) : void 0, actions, open: toolsOpen })
),
- picked.length ? (0, import_react13.createElement)("div", { className: "bt-reacts" }, picked.map((emoji) => (0, import_react13.createElement)("button", {
+ picked.length ? (0, import_react17.createElement)("div", { className: "bt-reacts" }, picked.map((emoji) => (0, import_react17.createElement)("button", {
key: emoji,
type: "button",
className: "bt-react",
@@ -7283,7 +7637,7 @@ function Bubble({ text, index, roster, selfId, actions, sessionId, msgKey, menti
var REACTIONS = ["👍", "❤️", "😂", "😮", "😢", "🙏"];
var STRIP_HALF = (REACTIONS.length * 34 + 10) / 2 + 8;
function useDismiss(open, close, refs) {
- (0, import_react13.useEffect)(() => {
+ (0, import_react17.useEffect)(() => {
if (!open) return void 0;
const onDown = (event) => {
if (refs.some((ref) => ref.current?.contains(event.target))) return;
@@ -7306,10 +7660,10 @@ function useDismiss(open, close, refs) {
}, [open]);
}
function MessageTools({ text, name, sessionId, react, actions, open: tapped }) {
- const [panel, setPanel] = (0, import_react13.useState)(null);
- const [copied, setCopied] = (0, import_react13.useState)(false);
- const tools = (0, import_react13.useRef)(null);
- const pop = (0, import_react13.useRef)(null);
+ const [panel, setPanel] = (0, import_react17.useState)(null);
+ const [copied, setCopied] = (0, import_react17.useState)(false);
+ const tools = (0, import_react17.useRef)(null);
+ const pop = (0, import_react17.useRef)(null);
const tick = useViewport();
const close = () => setPanel(null);
useDismiss(panel !== null, close, [tools, pop]);
@@ -7320,7 +7674,7 @@ function MessageTools({ text, name, sessionId, react, actions, open: tapped }) {
}
setPanel({ kind, node: event.currentTarget });
};
- const place = (0, import_react13.useMemo)(() => {
+ const place = (0, import_react17.useMemo)(() => {
if (!panel) return null;
const rect = panel.node.getBoundingClientRect();
const below = rect.bottom + 220 < viewBottom();
@@ -7338,25 +7692,25 @@ function MessageTools({ text, name, sessionId, react, actions, open: tapped }) {
link.click();
setTimeout(() => URL.revokeObjectURL(url), 1e3);
};
- const item = (label, Icon, run2) => (0, import_react13.createElement)("button", { key: label, type: "button", role: "menuitem", onClick: () => {
+ const item = (label, Icon, run2) => (0, import_react17.createElement)("button", { key: label, type: "button", role: "menuitem", onClick: () => {
close();
run2();
- } }, (0, import_react13.createElement)(Icon), label);
- return (0, import_react13.createElement)(
+ } }, (0, import_react17.createElement)(Icon), label);
+ return (0, import_react17.createElement)(
"div",
{ ref: tools, className: "bt-tools", "data-open": panel !== null || tapped || void 0 },
- react ? (0, import_react13.createElement)("button", { type: "button", className: "bt-tool", "aria-label": t("Add reaction"), title: t("Add reaction"), "aria-expanded": panel?.kind === "react", onClick: (event) => open("react", event) }, (0, import_react13.createElement)(SmileIcon)) : null,
- sessionId ? (0, import_react13.createElement)("button", { type: "button", className: "bt-tool", "aria-label": t("Reply"), title: t("Reply"), onClick: () => actions.quote(sessionId, text) }, (0, import_react13.createElement)(ReplyIcon)) : null,
- (0, import_react13.createElement)("button", { type: "button", className: "bt-tool", "aria-label": t("More message actions"), title: t("More"), "aria-haspopup": "menu", "aria-expanded": panel?.kind === "more", onClick: (event) => open("more", event) }, copied ? (0, import_react13.createElement)(CheckIcon) : (0, import_react13.createElement)(DotsIcon)),
- panel?.kind === "react" ? (0, import_react_dom.createPortal)((0, import_react13.createElement)(
+ react ? (0, import_react17.createElement)("button", { type: "button", className: "bt-tool", "aria-label": t("Add reaction"), title: t("Add reaction"), "aria-expanded": panel?.kind === "react", onClick: (event) => open("react", event) }, (0, import_react17.createElement)(SmileIcon)) : null,
+ sessionId ? (0, import_react17.createElement)("button", { type: "button", className: "bt-tool", "aria-label": t("Reply"), title: t("Reply"), onClick: () => actions.quote(sessionId, text) }, (0, import_react17.createElement)(ReplyIcon)) : null,
+ (0, import_react17.createElement)("button", { type: "button", className: "bt-tool", "aria-label": t("More message actions"), title: t("More"), "aria-haspopup": "menu", "aria-expanded": panel?.kind === "more", onClick: (event) => open("more", event) }, copied ? (0, import_react17.createElement)(CheckIcon) : (0, import_react17.createElement)(DotsIcon)),
+ panel?.kind === "react" ? (0, import_react_dom.createPortal)((0, import_react17.createElement)(
"div",
{ ref: pop, className: "bt-react-strip", role: "menu", "aria-label": t("Reactions"), style: place },
- REACTIONS.map((emoji) => (0, import_react13.createElement)("button", { key: emoji, type: "button", role: "menuitem", "aria-label": emoji, onClick: () => {
+ REACTIONS.map((emoji) => (0, import_react17.createElement)("button", { key: emoji, type: "button", role: "menuitem", "aria-label": emoji, onClick: () => {
close();
react(emoji);
} }, emoji))
), document.body) : null,
- panel?.kind === "more" ? (0, import_react_dom.createPortal)((0, import_react13.createElement)(
+ panel?.kind === "more" ? (0, import_react_dom.createPortal)((0, import_react17.createElement)(
"div",
{ ref: pop, className: "bt-menu", role: "menu", "aria-label": t("Message actions"), style: place },
item(t("Copy"), CopyIcon, copy2),
@@ -7367,8 +7721,8 @@ function MessageTools({ text, name, sessionId, react, actions, open: tapped }) {
var thinkingTimes = /* @__PURE__ */ new Map();
function useThinkingMs({ sessionId, turn, settledSteps, skip }) {
const key = `${sessionId}:${turn}:${settledSteps}`;
- const [ms, setMs] = (0, import_react13.useState)(() => thinkingTimes.get(key));
- (0, import_react13.useEffect)(() => {
+ const [ms, setMs] = (0, import_react17.useState)(() => thinkingTimes.get(key));
+ (0, import_react17.useEffect)(() => {
if (skip || thinkingTimes.has(key)) {
setMs(thinkingTimes.get(key));
return void 0;
@@ -7385,11 +7739,11 @@ function useThinkingMs({ sessionId, turn, settledSteps, skip }) {
}
var rowViews = /* @__PURE__ */ new Map();
function ThinkingRow({ text, live, at, ms, viewKey }) {
- const box = (0, import_react13.useRef)(null);
- const view = (0, import_react13.useRef)(rowViews.get(viewKey));
- const atEnd = (0, import_react13.useRef)(view.current?.atEnd ?? true);
- const [open, setOpen] = (0, import_react13.useState)(view.current?.open ?? false);
- const [fade, setFade] = (0, import_react13.useState)(void 0);
+ const box = (0, import_react17.useRef)(null);
+ const view = (0, import_react17.useRef)(rowViews.get(viewKey));
+ const atEnd = (0, import_react17.useRef)(view.current?.atEnd ?? true);
+ const [open, setOpen] = (0, import_react17.useState)(view.current?.open ?? false);
+ const [fade, setFade] = (0, import_react17.useState)(void 0);
const remember = (patch) => {
if (viewKey !== void 0) rowViews.set(viewKey, { ...rowViews.get(viewKey), ...patch });
};
@@ -7406,7 +7760,7 @@ function ThinkingRow({ text, live, at, ms, viewKey }) {
remember({ open: next });
setOpen(next);
};
- (0, import_react13.useLayoutEffect)(() => {
+ (0, import_react17.useLayoutEffect)(() => {
if (!open) return;
const el = box.current;
const restore = view.current;
@@ -7416,17 +7770,17 @@ function ThinkingRow({ text, live, at, ms, viewKey }) {
measure();
}, [text, open]);
const title = live ? t("Thinking") : t("Thought it through");
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"details",
{ className: "bt-think", open, onToggle: toggle },
- (0, import_react13.createElement)(
+ (0, import_react17.createElement)(
"summary",
null,
title,
- live && at !== void 0 ? (0, import_react13.createElement)(Elapsed, { at, className: "bt-think-time" }) : null,
- !live && ms !== void 0 ? (0, import_react13.createElement)("span", { className: "bt-think-time" }, `· ${elapsedLabel(Math.max(1e3, ms))}`) : null
+ live && at !== void 0 ? (0, import_react17.createElement)(Elapsed, { at, className: "bt-think-time" }) : null,
+ !live && ms !== void 0 ? (0, import_react17.createElement)("span", { className: "bt-think-time" }, `· ${elapsedLabel(Math.max(1e3, ms))}`) : null
),
- (0, import_react13.createElement)("div", { ref: box, className: "bt-think-text", role: "region", "aria-label": title, tabIndex: 0, "data-fade": fade, onScroll: measure }, text)
+ (0, import_react17.createElement)("div", { ref: box, className: "bt-think-text", role: "region", "aria-label": title, tabIndex: 0, "data-fade": fade, onScroll: measure }, text)
);
}
function useFileMentions({ node, openFile, fileMentions, useTurnData }) {
@@ -7434,7 +7788,7 @@ function useFileMentions({ node, openFile, fileMentions, useTurnData }) {
const location2 = node.location;
const turn = location2?.kind === "turn" || location2?.kind === "step" ? location2.turn : void 0;
const seq = node.data.finalNode?.seq;
- return (0, import_react13.useMemo)(() => {
+ return (0, import_react17.useMemo)(() => {
if (typeof fileMentions !== "function" || turn?.status !== "closed" || seq === void 0) return void 0;
return tail?.closing?.finalNode.seq === seq ? fileMentions({ turn, seq, openFile }) : void 0;
}, [fileMentions, openFile, seq, tail, turn]);
@@ -7460,13 +7814,13 @@ function AssistantCell({ node, groupPart, sessionId, openFile, fileMentions, use
const selfId = roster.byId[sessionId]?.id ?? sessionId;
const speaker = layoutOf(roster.prefs) === "flat" ? roster.byId[sessionId] : void 0;
const head = speaker !== void 0 && opensReply(steps, data, shown) && (reasoning !== "" || texts2.length > 0 && !(groupPart === "response" && shown && turnReasoning(steps, data) !== ""));
- return (0, import_react13.createElement)(
- import_react13.Fragment,
+ return (0, import_react17.createElement)(
+ import_react17.Fragment,
null,
relays.map((relay) => {
const source = relay.source;
const sender = roster.byId[source.senderSessionId] ?? { id: source.senderSessionId, name: source.senderName ?? t("a Bot"), color: "gray" };
- return (0, import_react13.createElement)(EventLine, {
+ return (0, import_react17.createElement)(EventLine, {
key: relay.seq,
prefix: source.role === "stopped" ? t("Stopped by") : source.role === "reply" ? t("Reply from") : t("Message from"),
bots: [sender],
@@ -7476,8 +7830,8 @@ function AssistantCell({ node, groupPart, sessionId, openFile, fileMentions, use
whole: true
});
}),
- head ? (0, import_react13.createElement)(SpeakerHead, { bot: speaker, time: data.time }) : null,
- reasoning ? (0, import_react13.createElement)(ThinkingRow, {
+ head ? (0, import_react17.createElement)(SpeakerHead, { bot: speaker, time: data.time }) : null,
+ reasoning ? (0, import_react17.createElement)(ThinkingRow, {
text: reasoning,
live: thinking !== void 0,
viewKey: `${sessionId}:${data.turn}`,
@@ -7485,66 +7839,66 @@ function AssistantCell({ node, groupPart, sessionId, openFile, fileMentions, use
// time makes one Elapsed show settled + running.
...thinking !== void 0 ? { at: typeof thinking.time === "number" ? thinking.time - (ms ?? 0) : void 0 } : { ms }
}) : null,
- texts2.length ? (0, import_react13.createElement)(Bubbles, { texts: texts2, roster, selfId, actions, streaming: running, sessionId, msgKey: `${sessionId}:${data.turn}:${node.key ?? data.seq ?? ""}`, useUi, mentions, fold: FOLD_HUGE }) : null
+ texts2.length ? (0, import_react17.createElement)(Bubbles, { texts: texts2, roster, selfId, actions, streaming: running, sessionId, msgKey: `${sessionId}:${data.turn}:${node.key ?? data.seq ?? ""}`, useUi, mentions, fold: FOLD_HUGE }) : null
);
}
function EventLine({ prefix, bots, joiner = t("and"), onOpen, whole = false }) {
if (whole && bots.length === 1) {
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"div",
{ className: "bt-event" },
- (0, import_react13.createElement)(
+ (0, import_react17.createElement)(
"button",
{ type: "button", className: "bt-event-whole", title: bots[0].name, onClick: () => onOpen?.(bots[0]) },
- (0, import_react13.createElement)("span", null, prefix),
- (0, import_react13.createElement)(BotMark, { bot: bots[0], size: 16 }),
- (0, import_react13.createElement)("span", { className: "bt-event-name" }, bots[0].name)
+ (0, import_react17.createElement)("span", null, prefix),
+ (0, import_react17.createElement)(BotMark, { bot: bots[0], size: 16 }),
+ (0, import_react17.createElement)("span", { className: "bt-event-name" }, bots[0].name)
)
);
}
const parts = [];
- parts.push((0, import_react13.createElement)("span", { key: "p" }, prefix));
+ parts.push((0, import_react17.createElement)("span", { key: "p" }, prefix));
bots.forEach((bot, index) => {
- if (index > 0) parts.push((0, import_react13.createElement)("span", { key: `j${index}` }, joiner));
- parts.push((0, import_react13.createElement)(
+ if (index > 0) parts.push((0, import_react17.createElement)("span", { key: `j${index}` }, joiner));
+ parts.push((0, import_react17.createElement)(
"button",
{ key: bot.id ?? index, type: "button", onClick: () => onOpen?.(bot) },
- (0, import_react13.createElement)(BotMark, { bot, size: 16 }),
+ (0, import_react17.createElement)(BotMark, { bot, size: 16 }),
bot.name
));
});
- return (0, import_react13.createElement)("div", { className: "bt-event" }, parts);
+ return (0, import_react17.createElement)("div", { className: "bt-event" }, parts);
}
function SpeakerHead({ bot, time }) {
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"div",
{ className: "bt-group-name" },
- (0, import_react13.createElement)("span", { className: "bt-lead" }, (0, import_react13.createElement)(BotMark, { bot, size: 22 })),
+ (0, import_react17.createElement)("span", { className: "bt-lead" }, (0, import_react17.createElement)(BotMark, { bot, size: 22 })),
bot.name,
- Number.isFinite(time) ? (0, import_react13.createElement)("span", { className: "bt-group-time", title: clockLabel(time) }, messageClock(time)) : null
+ Number.isFinite(time) ? (0, import_react17.createElement)("span", { className: "bt-group-time", title: clockLabel(time) }, messageClock(time)) : null
);
}
function GroupMessage({ bot, text, texts: texts2 = [text], room: room2, roster, actions, msgKey, useUi, whole, time, duration }) {
- const lead = (0, import_react13.createElement)(
+ const lead = (0, import_react17.createElement)(
"button",
{ type: "button", className: "bt-lead", "aria-label": t("Open {name}'s chat", { name: bot.name }), onClick: () => actions.openSession(bot.id) },
- (0, import_react13.createElement)(BotMark, { bot, size: 22 })
+ (0, import_react17.createElement)(BotMark, { bot, size: 22 })
);
const flat = layoutOf(roster.prefs) === "flat";
const took = Number.isFinite(duration) ? elapsedLabel(duration) : void 0;
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"div",
{ className: "bt-group-msg" },
- (0, import_react13.createElement)(
+ (0, import_react17.createElement)(
"span",
{ className: "bt-group-name", style: flat ? void 0 : { color: inkText(colorOf(bot)) } },
flat ? lead : null,
bot.name,
- room2?.admin === bot.id ? (0, import_react13.createElement)("span", { className: "bt-group-role" }, t("Admin")) : null,
- Number.isFinite(time) ? (0, import_react13.createElement)("span", { className: "bt-group-time", title: clockLabel(time) }, messageClock(time)) : null,
- took ? (0, import_react13.createElement)("span", { className: "bt-group-took", title: t("Ran for {duration}", { duration: took }) }, took) : null
+ room2?.admin === bot.id ? (0, import_react17.createElement)("span", { className: "bt-group-role" }, t("Admin")) : null,
+ Number.isFinite(time) ? (0, import_react17.createElement)("span", { className: "bt-group-time", title: clockLabel(time) }, messageClock(time)) : null,
+ took ? (0, import_react17.createElement)("span", { className: "bt-group-took", title: t("Ran for {duration}", { duration: took }) }, took) : null
),
- (0, import_react13.createElement)(Bubbles, { texts: texts2, roster, selfId: bot.id, actions, sessionId: room2?.id, msgKey, useUi, lead: flat ? null : lead, whole })
+ (0, import_react17.createElement)(Bubbles, { texts: texts2, roster, selfId: bot.id, actions, sessionId: room2?.id, msgKey, useUi, lead: flat ? null : lead, whole })
);
}
function stackReplies(replies) {
@@ -7560,11 +7914,11 @@ function stackReplies(replies) {
return items;
}
function GroupEvent({ prefix, room: room2, name, roster, actions }) {
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"div",
{ className: "bt-event" },
- (0, import_react13.createElement)("span", null, prefix),
- room2 ? (0, import_react13.createElement)("button", { type: "button", onClick: () => actions.openSession(room2.id) }, (0, import_react13.createElement)(RoomAvatar, { room: room2, roster, size: 16 }), room2.name) : name ? (0, import_react13.createElement)("span", null, name) : null
+ (0, import_react17.createElement)("span", null, prefix),
+ room2 ? (0, import_react17.createElement)("button", { type: "button", onClick: () => actions.openSession(room2.id) }, (0, import_react17.createElement)(RoomAvatar, { room: room2, roster, size: 16 }), room2.name) : name ? (0, import_react17.createElement)("span", null, name) : null
);
}
var MEMORY_SAVED = /^(Saved to|Updated in|Removed from) /;
@@ -7596,33 +7950,33 @@ function MemoryEvent({ sessionId, scope, tool, result, failed, code, roster, act
const target = other && other.id !== self?.id ? other : self;
const panel = team ? self?.id : MEMORY_OWN.test(named) ? self?.id : MEMORY_GROUP.test(named) ? room2?.id : named === "" ? room2?.id ?? self?.id : other?.id;
if (!failed && MEMORY_ALREADY.test(result)) {
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"div",
{ className: "bt-event" },
- panel === void 0 ? (0, import_react13.createElement)("span", null, (0, import_react13.createElement)(MemoryIcon), t("Already saved")) : (0, import_react13.createElement)("button", { type: "button", onClick: () => actions.openMemory(panel) }, (0, import_react13.createElement)(MemoryIcon), t("Already saved"))
+ panel === void 0 ? (0, import_react17.createElement)("span", null, (0, import_react17.createElement)(MemoryIcon), t("Already saved")) : (0, import_react17.createElement)("button", { type: "button", onClick: () => actions.openMemory(panel) }, (0, import_react17.createElement)(MemoryIcon), t("Already saved"))
);
}
if (!failed && MEMORY_SAVED.test(result)) {
if (!target) return null;
const label2 = team ? t("Team memory updated") : target === self ? t("Memory updated") : t("Updated {name}'s memory", { name: target.name });
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"div",
{ className: "bt-event" },
- (0, import_react13.createElement)("button", { type: "button", title: result, onClick: () => actions.openMemory(target.id) }, (0, import_react13.createElement)(MemoryIcon), label2)
+ (0, import_react17.createElement)("button", { type: "button", title: result, onClick: () => actions.openMemory(target.id) }, (0, import_react17.createElement)(MemoryIcon), label2)
);
}
const reason = memoryFailure(code);
const label = failed ? tool === "forget" ? t("Couldn't remove from memory") : t("Couldn't save to memory") : t("Memory not changed");
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"div",
{ className: "bt-event bt-event-error", role: "status", title: code },
- (0, import_react13.createElement)("span", null, (0, import_react13.createElement)(MemoryIcon), label),
- reason ? (0, import_react13.createElement)("span", null, ` · ${reason}`) : null,
- panel === void 0 ? null : (0, import_react13.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.openMemory(panel) }, t("Manage"))
+ (0, import_react17.createElement)("span", null, (0, import_react17.createElement)(MemoryIcon), label),
+ reason ? (0, import_react17.createElement)("span", null, ` · ${reason}`) : null,
+ panel === void 0 ? null : (0, import_react17.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.openMemory(panel) }, t("Manage"))
);
}
function PartLine({ time }) {
- return (0, import_react13.createElement)("div", { className: "bt-part-line", role: "separator" }, Number.isFinite(time) ? (0, import_react13.createElement)("span", null, dayLabel(time)) : null);
+ return (0, import_react17.createElement)("div", { className: "bt-part-line", role: "separator" }, Number.isFinite(time) ? (0, import_react17.createElement)("span", null, dayLabel(time)) : null);
}
var scrollParent = (node) => {
for (let at = node.parentElement; at; at = at.parentElement) {
@@ -7632,21 +7986,21 @@ var scrollParent = (node) => {
};
function EarlierUser({ row }) {
const { shown, folded, control } = useFold(row.text ?? "");
- const body = row.text ? (0, import_react13.createElement)(import_dsh_client_ui_primitives.MarkdownText, { text: shown, labels: mdLabels3(), variant: "compact" }) : null;
- return (0, import_react13.createElement)("div", { className: "bt-urow" }, (0, import_react13.createElement)(
+ const body = row.text ? (0, import_react17.createElement)(import_dsh_client_ui_primitives.MarkdownText, { text: shown, labels: mdLabels3(), variant: "compact" }) : null;
+ return (0, import_react17.createElement)("div", { className: "bt-urow" }, (0, import_react17.createElement)(
"div",
{ className: "bt-ububble", "data-folded": folded || void 0 },
- control ? (0, import_react13.createElement)("div", { className: "bt-fold-body" }, body) : body,
+ control ? (0, import_react17.createElement)("div", { className: "bt-fold-body" }, body) : body,
control,
- row.images ? (0, import_react13.createElement)("span", { className: "bt-uimages" }, row.images === 1 ? t("1 image") : t("{count} images", { count: row.images })) : null
+ row.images ? (0, import_react17.createElement)("span", { className: "bt-uimages" }, row.images === 1 ? t("1 image") : t("{count} images", { count: row.images })) : null
));
}
function EarlierParts({ sessionId, roster, actions }) {
- const [view, setView] = (0, import_react13.useState)({ pages: [], cursor: void 0, loading: true, failed: false, startedAt: null });
- const top = (0, import_react13.useRef)(null);
- const busy = (0, import_react13.useRef)(false);
- const generation = (0, import_react13.useRef)(0);
- const restore = (0, import_react13.useRef)(null);
+ const [view, setView] = (0, import_react17.useState)({ pages: [], cursor: void 0, loading: true, failed: false, startedAt: null });
+ const top = (0, import_react17.useRef)(null);
+ const busy = (0, import_react17.useRef)(false);
+ const generation = (0, import_react17.useRef)(0);
+ const restore = (0, import_react17.useRef)(null);
const load = (cursor) => {
if (busy.current) return;
const mine = generation.current;
@@ -7674,7 +8028,7 @@ function EarlierParts({ sessionId, roster, actions }) {
setView((current) => ({ ...current, loading: false, failed: true }));
});
};
- (0, import_react13.useEffect)(() => {
+ (0, import_react17.useEffect)(() => {
generation.current += 1;
busy.current = false;
setView({ pages: [], cursor: void 0, loading: true, failed: false, startedAt: null });
@@ -7683,12 +8037,12 @@ function EarlierParts({ sessionId, roster, actions }) {
generation.current += 1;
};
}, [sessionId]);
- (0, import_react13.useLayoutEffect)(() => {
+ (0, import_react17.useLayoutEffect)(() => {
const pending = restore.current;
restore.current = null;
if (pending) pending.scroller.scrollTop = pending.scroller.scrollHeight - pending.fromEnd;
}, [view.pages]);
- (0, import_react13.useEffect)(() => {
+ (0, import_react17.useEffect)(() => {
const node = top.current;
if (!node || view.loading || view.failed || !view.cursor || typeof IntersectionObserver !== "function") return void 0;
const observer = new IntersectionObserver((entries2) => {
@@ -7699,16 +8053,16 @@ function EarlierParts({ sessionId, roster, actions }) {
}, [view.cursor, view.loading, view.failed]);
const items = [];
for (const page of view.pages) items.push(...withBtwRows(page.items, page.btw));
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"div",
{ className: "bt-earlier", role: "feed", "aria-label": t("Earlier messages"), "aria-busy": view.loading },
- (0, import_react13.createElement)(
+ (0, import_react17.createElement)(
"div",
{ ref: top, className: "bt-earlier-top" },
- view.loading ? (0, import_react13.createElement)(Shimmer, null, t("Loading earlier messages…")) : view.failed ? (0, import_react13.createElement)("button", { type: "button", className: "bt-soft", onClick: () => load(view.cursor) }, t("Couldn’t load earlier messages · Retry")) : view.cursor ? (0, import_react13.createElement)("button", { type: "button", className: "bt-soft", onClick: () => load(view.cursor) }, t("Load earlier")) : null
+ view.loading ? (0, import_react17.createElement)(Shimmer, null, t("Loading earlier messages…")) : view.failed ? (0, import_react17.createElement)("button", { type: "button", className: "bt-soft", onClick: () => load(view.cursor) }, t("Couldn’t load earlier messages · Retry")) : view.cursor ? (0, import_react17.createElement)("button", { type: "button", className: "bt-soft", onClick: () => load(view.cursor) }, t("Load earlier")) : null
),
- (0, import_react13.createElement)(ChatRows, { items, sessionId, roster, actions }),
- (0, import_react13.createElement)(PartLine, { time: view.startedAt })
+ (0, import_react17.createElement)(ChatRows, { items, sessionId, roster, actions }),
+ (0, import_react17.createElement)(PartLine, { time: view.startedAt })
);
}
function ChatRows({ items, sessionId, roster, actions, useUi, clock: clock4 = false }) {
@@ -7731,32 +8085,32 @@ function ChatRows({ items, sessionId, roster, actions, useUi, clock: clock4 = fa
}
const pause = clock4 && Number.isFinite(row.time) && (before === void 0 || row.time - before >= SEPARATOR_GAP_MS);
if (Number.isFinite(row.end ?? row.time)) before = row.end ?? row.time;
- return pause ? [(0, import_react13.createElement)("div", { key: `${key}:clock`, className: "bt-time-sep", role: "separator" }, clockLabel(row.time)), shown] : [shown];
+ return pause ? [(0, import_react17.createElement)("div", { key: `${key}:clock`, className: "bt-time-sep", role: "separator" }, clockLabel(row.time)), shown] : [shown];
});
}
function chatRow(row, key, { sessionId, selfId, roster, actions, useUi }) {
switch (row.kind) {
case "divider":
- return (0, import_react13.createElement)(PartLine, { key, time: row.time });
+ return (0, import_react17.createElement)(PartLine, { key, time: row.time });
case "user":
- return (0, import_react13.createElement)(EarlierUser, { key, row });
+ return (0, import_react17.createElement)(EarlierUser, { key, row });
case "answer":
- return (0, import_react13.createElement)(AnsweredReply, { key, node: { data: row } });
+ return (0, import_react17.createElement)(AnsweredReply, { key, node: { data: row } });
// A display-only view replays from the blueprint the host kept on the call.
case "view":
- return (0, import_react13.createElement)(WidgetCell, { key, sessionId, callId: row.callId, args: { text: (name) => name === "title" ? row.title : void 0, value: (name) => name === "view" ? row.view : void 0 }, done: true, isError: false, roster, actions });
+ return (0, import_react17.createElement)(WidgetCell, { key, sessionId, callId: row.callId, args: { text: (name) => name === "title" ? row.title : void 0, value: (name) => name === "view" ? row.view : void 0 }, done: true, isError: false, roster, actions });
case "bot": {
- const bubbles = (0, import_react13.createElement)(Bubbles, { key, texts: row.texts, roster, selfId, actions, sessionId: useUi ? sessionId : void 0, msgKey: useUi ? `${sessionId}:${row.time}` : void 0, useUi, fold: FOLD_HUGE });
+ const bubbles = (0, import_react17.createElement)(Bubbles, { key, texts: row.texts, roster, selfId, actions, sessionId: useUi ? sessionId : void 0, msgKey: useUi ? `${sessionId}:${row.time}` : void 0, useUi, fold: FOLD_HUGE });
const speaker = layoutOf(roster.prefs) === "flat" ? roster.byId[selfId] : void 0;
- return speaker ? (0, import_react13.createElement)(import_react13.Fragment, { key }, (0, import_react13.createElement)(SpeakerHead, { bot: speaker, time: row.time }), bubbles) : bubbles;
+ return speaker ? (0, import_react17.createElement)(import_react17.Fragment, { key }, (0, import_react17.createElement)(SpeakerHead, { bot: speaker, time: row.time }), bubbles) : bubbles;
}
case "btw":
- return (0, import_react13.createElement)(BtwCardView, { key, card: row.card, actions });
+ return (0, import_react17.createElement)(BtwCardView, { key, card: row.card, actions });
case "event": {
- if (row.role === "report") return (0, import_react13.createElement)(GroupEvent, { key, prefix: t("Replies from"), room: roster.roomsById[row.roomId], name: t("a group chat"), roster, actions });
+ if (row.role === "report") return (0, import_react17.createElement)(GroupEvent, { key, prefix: t("Replies from"), room: roster.roomsById[row.roomId], name: t("a group chat"), roster, actions });
const other = roster.byId[row.botId] ?? { id: row.botId, name: row.name ?? t("a Bot"), color: "gray" };
const prefix = { stopped: t("Stopped by"), reply: t("Reply from") }[row.role] ?? t("Message from");
- return (0, import_react13.createElement)(EventLine, { key, prefix, bots: [other], onOpen: () => {
+ return (0, import_react17.createElement)(EventLine, { key, prefix, bots: [other], onOpen: () => {
if (selfId && other.id) actions.openExchange(selfId, other.id);
}, whole: true });
}
@@ -7772,7 +8126,7 @@ function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnClock, us
const deferred = source.kind === "bot" && source.deferred === true;
const relayed = isRelayContext(data);
const turn = node.location?.turn?.turn ?? data.turn;
- (0, import_react13.useLayoutEffect)(() => {
+ (0, import_react17.useLayoutEffect)(() => {
if (relayed) actions.noteTurnPeer(sessionId, turn, source.senderSessionId);
}, [relayed, sessionId, turn, source.senderSessionId]);
const order = useSessions((list) => {
@@ -7791,13 +8145,13 @@ function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnClock, us
return first?.turn === turn && unseenSince(visit, first.start) ? clockLabel(first.start) : "";
});
const body = triggerBody();
- return unreadOpening ? (0, import_react13.createElement)(import_react13.Fragment, null, (0, import_react13.createElement)("div", { className: "bt-open-new" }, (0, import_react13.createElement)(NewDivider), (0, import_react13.createElement)("div", { className: "bt-time-sep", role: "separator" }, unreadOpening)), body) : body;
+ return unreadOpening ? (0, import_react17.createElement)(import_react17.Fragment, null, (0, import_react17.createElement)("div", { className: "bt-open-new" }, (0, import_react17.createElement)(NewDivider), (0, import_react17.createElement)("div", { className: "bt-time-sep", role: "separator" }, unreadOpening)), body) : body;
function triggerBody() {
if (source.kind === "bot") {
- if (source.handoff === true) return roster.roomsById[sessionId] ? null : (0, import_react13.createElement)(EarlierParts, { sessionId, roster, actions });
+ if (source.handoff === true) return roster.roomsById[sessionId] ? null : (0, import_react17.createElement)(EarlierParts, { sessionId, roster, actions });
if (source.role === "kickoff" || source.role === "room") return null;
if (source.role === "secret" || deferred) return null;
- if (source.role === "update") return (0, import_react12.createElement)("div", { className: "bt-event" }, t("Profile updated"));
+ if (source.role === "update") return (0, import_react17.createElement)("div", { className: "bt-event" }, t("Profile updated"));
if (source.role === "post") {
if (source.logged !== void 0) return null;
if (source.failed !== void 0 || source.resumed === true || source.stopped === true || source.done === true) return null;
@@ -7805,7 +8159,7 @@ function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnClock, us
const poster = roster.byId[source.senderSessionId] ?? { id: source.senderSessionId, name: source.senderName ?? t("a Bot"), color: "gray" };
const file = source.length === void 0 ? void 0 : (data.content ?? []).find((block) => block?.type === "file")?.attachment;
const text = stripHeader(contentText(data.content));
- return (0, import_react13.createElement)(GroupMessage, {
+ return (0, import_react17.createElement)(GroupMessage, {
bot: poster,
text: file ? stripLongNote(text) : text,
room: room2,
@@ -7818,10 +8172,10 @@ function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnClock, us
});
}
if (source.role === "report") {
- return (0, import_react13.createElement)(GroupEvent, { prefix: t("Replies from"), room: roster.roomsById[source.roomId], name: t("a group chat"), roster, actions });
+ return (0, import_react17.createElement)(GroupEvent, { prefix: t("Replies from"), room: roster.roomsById[source.roomId], name: t("a group chat"), roster, actions });
}
- if (source.role === "resume" || source.resumed === true) return (0, import_react13.createElement)("div", { className: "bt-event" }, t("Picked up its work after a restart"));
- if (source.role === "retry" || source.retried === true) return (0, import_react13.createElement)("div", { className: "bt-event" }, t("Asked to make the tool call it wrote as text"));
+ if (source.role === "resume" || source.resumed === true) return (0, import_react17.createElement)("div", { className: "bt-event" }, t("Picked up its work after a restart"));
+ if (source.role === "retry" || source.retried === true) return (0, import_react17.createElement)("div", { className: "bt-event" }, t("Asked to make the tool call it wrote as text"));
const run2 = relayed ? commRunOf(
order.split(",").filter(Boolean).map(Number),
Object.fromEntries(peers.split(",").filter(Boolean).map((pair) => [Number(pair.slice(0, pair.indexOf(":"))), pair.slice(pair.indexOf(":") + 1)])),
@@ -7835,7 +8189,7 @@ function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnClock, us
for (const peer of (run2?.peerIds ?? []).map((id) => roster.byId[id]).filter(Boolean)) {
if (!bots.some((bot) => bot.id === peer.id)) bots.push(peer);
}
- return (0, import_react13.createElement)(EventLine, {
+ return (0, import_react17.createElement)(EventLine, {
prefix: source.role === "stopped" ? t("Stopped by") : count > 1 ? t("{count} messages with", { count }) : t("Message from"),
bots,
onOpen: (bot) => actions.openExchange(selfId, bot.id),
@@ -7844,24 +8198,24 @@ function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnClock, us
}
if (source.kind === "schedule") {
const prompts = reminderPrompts(contentText(data.content));
- return (0, import_react13.createElement)("div", { className: "bt-event" }, prompts.length > 0 ? t("Scheduled task: {text}", { text: prompts.join(" · ").slice(0, 80) }) : t("Routine started"));
+ return (0, import_react17.createElement)("div", { className: "bt-event" }, prompts.length > 0 ? t("Scheduled task: {text}", { text: prompts.join(" · ").slice(0, 80) }) : t("Routine started"));
}
if (source.kind === "user-question-reply" || source.kind === "goal") return null;
- return (0, import_react13.createElement)("div", { className: "bt-event" }, contentText(data.content).slice(0, 80) || t("Update"));
+ return (0, import_react17.createElement)("div", { className: "bt-event" }, contentText(data.content).slice(0, 80) || t("Update"));
}
}
function NewDivider() {
- return (0, import_react13.createElement)("div", { className: "bt-new-sep", role: "separator", "aria-label": t("New messages") }, (0, import_react13.createElement)("span", null, t("New")));
+ return (0, import_react17.createElement)("div", { className: "bt-new-sep", role: "separator", "aria-label": t("New messages") }, (0, import_react17.createElement)("span", null, t("New")));
}
function TurnProcessCell({ node, sessionId, turnProcess, useRoster, useUi, useTurnClock, actions }) {
const open = turnProcess === void 0 || !turnProcess.foldable || turnProcess.open;
- (0, import_react13.useEffect)(() => {
+ (0, import_react17.useEffect)(() => {
if (!open) turnProcess.setOpen(true);
}, [open, turnProcess]);
const turn = node?.location?.turn?.turn ?? node?.data?.turn;
const start = node?.location?.turn?.start?.time;
const hidden = useRoster((roster) => isHiddenTurn(roster, sessionId, turn));
- (0, import_react13.useEffect)(() => {
+ (0, import_react17.useEffect)(() => {
actions.noteTurnTime(sessionId, turn, "first", start);
}, [sessionId, turn, start]);
const visit = useUi((state) => state.visits?.[sessionId]);
@@ -7869,7 +8223,7 @@ function TurnProcessCell({ node, sessionId, turnProcess, useRoster, useUi, useTu
const own = state[sessionId]?.[turn];
return !hidden && typeof visit?.seen === "number" && own?.first !== void 0 && own.first <= visit.seen && own.end !== void 0 && own.end > visit.seen && own.end <= visit.entered;
});
- return fresh ? (0, import_react13.createElement)(NewDivider) : null;
+ return fresh ? (0, import_react17.createElement)(NewDivider) : null;
}
function Nothing() {
return null;
@@ -7896,7 +8250,7 @@ var unseenSince = (visit, time) => typeof visit?.seen === "number" && time > vis
function TurnTailCell({ turn: location2, sessionId, useTurnClock, useUi, actions }) {
const turn = location2.turn;
const time = location2.end.time;
- (0, import_react13.useEffect)(() => {
+ (0, import_react17.useEffect)(() => {
actions.noteTurnTime(sessionId, turn, "end", time);
}, [sessionId, turn, time]);
const label = useTurnClock((state) => {
@@ -7910,19 +8264,19 @@ function TurnTailCell({ turn: location2, sessionId, useTurnClock, useUi, actions
return start !== void 0 && start > visit.seen && start <= visit.entered;
});
if (!label && !fresh) return null;
- return (0, import_react13.createElement)(
- import_react13.Fragment,
+ return (0, import_react17.createElement)(
+ import_react17.Fragment,
null,
- label ? (0, import_react13.createElement)("div", { className: "bt-time-sep", role: "separator" }, label) : null,
- fresh ? (0, import_react13.createElement)(NewDivider) : null
+ label ? (0, import_react17.createElement)("div", { className: "bt-time-sep", role: "separator" }, label) : null,
+ fresh ? (0, import_react17.createElement)(NewDivider) : null
);
}
function Shimmer({ children }) {
- return (0, import_react13.createElement)("span", { className: "bt-shimmer" }, children);
+ return (0, import_react17.createElement)("span", { className: "bt-shimmer" }, children);
}
function Elapsed({ at, className }) {
- const [now, setNow] = (0, import_react13.useState)(Date.now);
- (0, import_react13.useEffect)(() => {
+ const [now, setNow] = (0, import_react17.useState)(Date.now);
+ (0, import_react17.useEffect)(() => {
let timer = 0;
const tick = () => {
const time = Date.now();
@@ -7932,7 +8286,7 @@ function Elapsed({ at, className }) {
tick();
return () => clearTimeout(timer);
}, [at]);
- return (0, import_react13.createElement)("span", { className }, `· ${elapsedLabel(Math.max(1e3, now - at))}`);
+ return (0, import_react17.createElement)("span", { className }, `· ${elapsedLabel(Math.max(1e3, now - at))}`);
}
var PHRASES = {
thinking: ["Thinking about it", "Weighing the options", "Working out a plan", "Sorting out the details"],
@@ -8003,7 +8357,7 @@ function workPhrase(doing) {
}
function useLiveNote(actions, sessionId, id, entry) {
const key = entry ? JSON.stringify(entry) : "";
- (0, import_react13.useEffect)(() => {
+ (0, import_react17.useEffect)(() => {
if (!key) return void 0;
actions.noteLive(sessionId, id, JSON.parse(key));
return () => actions.noteLive(sessionId, id, null);
@@ -8059,8 +8413,8 @@ function scanReplies(text, start, replies) {
}
}
function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi, useWork }) {
- const [live, setLive] = (0, import_react13.useState)({ replies: [], speaking: null });
- (0, import_react13.useEffect)(() => {
+ const [live, setLive] = (0, import_react17.useState)({ replies: [], speaking: null });
+ (0, import_react17.useEffect)(() => {
if (done) return void 0;
let stop = false;
let timer;
@@ -8093,81 +8447,81 @@ function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi
const speakerTool = useWork?.((work) => work.bots?.[live.speaking]?.tool) ?? void 0;
const speakerDoing = useWork?.((work) => work.bots?.[live.speaking]?.tool ? workPhrase(work.bots[live.speaking]) : void 0) ?? void 0;
if (replies.length === 0 && pending.length === 0) {
- return broken ? (0, import_react12.createElement)("div", { className: "bt-group-replies" }, (0, import_react12.createElement)("div", { className: "bt-event" }, t("The group replies could not be shown"))) : null;
+ return broken ? (0, import_react17.createElement)("div", { className: "bt-group-replies" }, (0, import_react17.createElement)("div", { className: "bt-event" }, t("The group replies could not be shown"))) : null;
}
const room2 = roster.roomsById[sessionId];
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"div",
{ className: "bt-group-replies" },
stackReplies(replies).map(({ reply, index, texts: texts2, time, duration }) => {
const bot = roster.byId[reply.botId] ?? { id: reply.botId, name: reply.name, color: reply.color ?? "gray" };
if (reply.kind === "user") {
- return (0, import_react13.createElement)("div", { key: `user-${index}`, className: "bt-urow" }, (0, import_react13.createElement)(
+ return (0, import_react17.createElement)("div", { key: `user-${index}`, className: "bt-urow" }, (0, import_react17.createElement)(
"div",
{ className: "bt-ububble" },
- (0, import_react13.createElement)(import_dsh_client_ui_primitives.MarkdownText, { text: reply.text, labels: mdLabels3(), variant: "compact" }),
- Number.isFinite(time) ? (0, import_react13.createElement)("div", { className: "bt-utime", title: clockLabel(time) }, messageClock(time)) : null
+ (0, import_react17.createElement)(import_dsh_client_ui_primitives.MarkdownText, { text: reply.text, labels: mdLabels3(), variant: "compact" }),
+ Number.isFinite(time) ? (0, import_react17.createElement)("div", { className: "bt-utime", title: clockLabel(time) }, messageClock(time)) : null
));
}
if (reply.kind === "failed") {
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"div",
{ key: `${reply.botId}-${index}`, className: "bt-event bt-event-error", role: "status", title: [reply.code, reply.status, reply.text].filter(Boolean).join(" · ") },
t("{name} could not answer: {reason}", { name: bot.name, reason: failureLabel(reply.code, reply.text) })
);
}
if (reply.kind === "lookup") {
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"div",
{ key: `${reply.botId}-${index}`, className: "bt-event" },
reply.text ? t("{name} looked up its own chat for “{text}”", { name: bot.name, text: reply.text }) : t("{name} looked up its own chat", { name: bot.name })
);
}
if (reply.kind === "missed") {
- return (0, import_react13.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("{name} didn't answer in time", { name: bot.name }));
+ return (0, import_react17.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("{name} didn't answer in time", { name: bot.name }));
}
if (reply.kind === "paused") {
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"div",
{ key: `paused-${index}`, className: "bt-event" },
- (0, import_react13.createElement)("span", null, t("Paused after {count} Bot relays. Waiting: {names}", { count: reply.count, names: (reply.names ?? []).join(t(" and ")) })),
- room2?.paused?.length > 0 ? (0, import_react13.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.continueRoom(sessionId) }, t("Continue")) : null
+ (0, import_react17.createElement)("span", null, t("Paused after {count} Bot relays. Waiting: {names}", { count: reply.count, names: (reply.names ?? []).join(t(" and ")) })),
+ room2?.paused?.length > 0 ? (0, import_react17.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.continueRoom(sessionId) }, t("Continue")) : null
);
}
if (reply.kind === "resumed") {
- return (0, import_react13.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("{name} was cut off by a restart and picked its work back up", { name: bot.name }));
+ return (0, import_react17.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("{name} was cut off by a restart and picked its work back up", { name: bot.name }));
}
if (reply.kind === "cut") {
- return (0, import_react13.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("{name} was cut off by a restart again and stopped", { name: bot.name }));
+ return (0, import_react17.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("{name} was cut off by a restart again and stopped", { name: bot.name }));
}
if (reply.kind === "approval" || reply.kind === "working") {
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"div",
{ key: `${reply.botId}-${index}`, className: "bt-event" },
- (0, import_react13.createElement)(
+ (0, import_react17.createElement)(
"button",
{ type: "button", className: "bt-event-whole", onClick: () => actions.showDetails(sessionId) },
- (0, import_react13.createElement)(BotMark, { bot, size: 16 }),
- (0, import_react13.createElement)("span", { className: "bt-event-name" }, t(reply.kind === "working" ? "{name} started on it" : "{name} paused for your approval", { name: bot.name }))
+ (0, import_react17.createElement)(BotMark, { bot, size: 16 }),
+ (0, import_react17.createElement)("span", { className: "bt-event-name" }, t(reply.kind === "working" ? "{name} started on it" : "{name} paused for your approval", { name: bot.name }))
)
);
}
if (reply.kind === "stopped") {
- return (0, import_react13.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("You stopped {name}'s work", { name: bot.name }));
+ return (0, import_react17.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("You stopped {name}'s work", { name: bot.name }));
}
if (reply.kind === "done") {
- return (0, import_react13.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("{name} finished its work", { name: bot.name }));
+ return (0, import_react17.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("{name} finished its work", { name: bot.name }));
}
- return (0, import_react13.createElement)(GroupMessage, { key: `${reply.botId}-${index}`, bot, texts: texts2, room: room2, roster, actions, msgKey: callId ? `${sessionId}:${callId}:${index}` : void 0, useUi, time, duration });
+ return (0, import_react17.createElement)(GroupMessage, { key: `${reply.botId}-${index}`, bot, texts: texts2, room: room2, roster, actions, msgKey: callId ? `${sessionId}:${callId}:${index}` : void 0, useUi, time, duration });
}),
pending.map((id) => {
const bot = roster.byId[id];
if (!bot) return null;
- return (0, import_react13.createElement)(
+ return (0, import_react17.createElement)(
"div",
{ key: `pending-${id}`, className: "bt-activity" },
- (0, import_react13.createElement)(BotMark, { bot, size: 22, state: speakerTool ? toolState(speakerTool) : "thinking" }),
- (0, import_react13.createElement)(Shimmer, null, speakerDoing ? `${bot.name} · ${speakerDoing}…` : t("{name} is typing…", { name: bot.name }))
+ (0, import_react17.createElement)(BotMark, { bot, size: 22, state: speakerTool ? toolState(speakerTool) : "thinking" }),
+ (0, import_react17.createElement)(Shimmer, null, speakerDoing ? `${bot.name} · ${speakerDoing}…` : t("{name} is typing…", { name: bot.name }))
);
})
);
@@ -8189,7 +8543,7 @@ function callTree(root) {
}
function useShownCards(actions, sessionId, callIds) {
const key = JSON.stringify(callIds);
- (0, import_react13.useLayoutEffect)(() => {
+ (0, import_react17.useLayoutEffect)(() => {
const ids = JSON.parse(key);
if (ids.length === 0 || !actions.noteCards) return void 0;
actions.noteCards(sessionId, ids, 1);
@@ -8204,25 +8558,25 @@ function renderCall(call2, { sessionId, roster, actions, useUi, useWork, findBot
switch (tool) {
case "message_bot": {
const target = findBot(arg("to")) ?? { name: arg("to") ?? "…", color: "gray" };
- if (done && call2.isError) return (0, import_react13.createElement)("div", { className: "bt-event" }, t("Couldn't message {name}", { name: target.name }));
- return (0, import_react13.createElement)(EventLine, { prefix: t("Messaged"), bots: [target], onOpen: (bot) => bot.id && actions.openExchange(self?.id ?? sessionId, bot.id), whole: true });
+ if (done && call2.isError) return (0, import_react17.createElement)("div", { className: "bt-event" }, t("Couldn't message {name}", { name: target.name }));
+ return (0, import_react17.createElement)(EventLine, { prefix: t("Messaged"), bots: [target], onOpen: (bot) => bot.id && actions.openExchange(self?.id ?? sessionId, bot.id), whole: true });
}
case "stop_bot": {
const target = findBot(arg("bot")) ?? { name: arg("bot") ?? "…", color: "gray" };
- if (done && call2.isError) return (0, import_react13.createElement)("div", { className: "bt-event" }, t("Couldn't stop {name}", { name: target.name }));
- return (0, import_react13.createElement)(EventLine, { prefix: t("Stopped"), bots: [target], onOpen: (bot) => bot.id && actions.openExchange(self?.id ?? sessionId, bot.id), whole: true });
+ if (done && call2.isError) return (0, import_react17.createElement)("div", { className: "bt-event" }, t("Couldn't stop {name}", { name: target.name }));
+ return (0, import_react17.createElement)(EventLine, { prefix: t("Stopped"), bots: [target], onOpen: (bot) => bot.id && actions.openExchange(self?.id ?? sessionId, bot.id), whole: true });
}
case "create_bot": {
const created = findBot(arg("name"));
if (!done || created === void 0) return null;
- return (0, import_react13.createElement)(EventLine, { prefix: t("Created"), bots: [created], onOpen: (bot) => actions.openSession(bot.id) });
+ return (0, import_react17.createElement)(EventLine, { prefix: t("Created"), bots: [created], onOpen: (bot) => actions.openSession(bot.id) });
}
case "update_bot": {
const target = findBot(arg("name")) ?? findBot(arg("bot")) ?? (arg("bot") ? void 0 : self);
- return done && target ? (0, import_react13.createElement)(EventLine, { prefix: t("Updated"), bots: [target], onOpen: (bot) => actions.openSession(bot.id) }) : null;
+ return done && target ? (0, import_react17.createElement)(EventLine, { prefix: t("Updated"), bots: [target], onOpen: (bot) => actions.openSession(bot.id) }) : null;
}
case "group_relay":
- return (0, import_react13.createElement)(GroupReplies, { sessionId, callId: call2.callId, done, content: call2.content, roster, actions, useUi, useWork });
+ return (0, import_react17.createElement)(GroupReplies, { sessionId, callId: call2.callId, done, content: call2.content, roster, actions, useUi, useWork });
case "create_group":
case "update_group":
case "delete_group":
@@ -8236,23 +8590,23 @@ function renderCall(call2, { sessionId, roster, actions, useUi, useWork, findBot
if (!done) return null;
const result = contentText(call2.content);
const named = /^(Created group|Updated|Nothing changed in|Deleted|Posted in) "([^"]+)"/.exec(result);
- if (call2.isError || !named) return (0, import_react13.createElement)("div", { className: "bt-event", title: result }, t(verbs[1]));
+ if (call2.isError || !named) return (0, import_react17.createElement)("div", { className: "bt-event", title: result }, t(verbs[1]));
const name = named[2];
const room2 = roster.rooms.find((entry) => entry.name === name);
- return (0, import_react13.createElement)(GroupEvent, { prefix: t(verbs[0]), room: tool === "delete_group" ? void 0 : room2, name, roster, actions });
+ return (0, import_react17.createElement)(GroupEvent, { prefix: t(verbs[0]), room: tool === "delete_group" ? void 0 : room2, name, roster, actions });
}
case "ask_user": {
const question = roster.questions?.[sessionId];
- if (!question || question.callId !== call2.callId) return (0, import_react13.createElement)("span", { className: "bt-q-gone", hidden: true });
+ if (!question || question.callId !== call2.callId) return (0, import_react17.createElement)("span", { className: "bt-q-gone", hidden: true });
if (heldCards?.[heldCardKey("question", question.id)] > 0) return null;
- return (0, import_react13.createElement)(PendingQuestion, { key: JSON.stringify([sessionId, question.id]), sessionId, question, actions, inline: true });
+ return (0, import_react17.createElement)(PendingQuestion, { key: JSON.stringify([sessionId, question.id]), sessionId, question, actions, inline: true });
}
case "show_view":
- return (0, import_react13.createElement)(WidgetCell, { sessionId, callId: call2.callId, args: { text: arg, value: argValue }, done, isError: call2.isError, roster, actions, heldCards });
+ return (0, import_react17.createElement)(WidgetCell, { sessionId, callId: call2.callId, args: { text: arg, value: argValue }, done, isError: call2.isError, roster, actions, heldCards });
case "request_secret":
- return (0, import_react13.createElement)(SecretToolCell, { sessionId, callId: call2.callId, name: arg("name"), done, content: call2.content, roster, actions, heldCards });
+ return (0, import_react17.createElement)(SecretToolCell, { sessionId, callId: call2.callId, name: arg("name"), done, content: call2.content, roster, actions, heldCards });
case "browser_handoff":
- return (0, import_react13.createElement)(HandoffCall, { sessionId, callId: call2.callId, roster, actions, heldCards, hooks });
+ return (0, import_react17.createElement)(HandoffCall, { sessionId, callId: call2.callId, roster, actions, heldCards, hooks });
case "ask_user_question": {
if (!done) return null;
let parsed = null;
@@ -8264,16 +8618,16 @@ function renderCall(call2, { sessionId, roster, actions, useUi, useWork, findBot
const answer = parsed?.answers?.[0];
const question = argValue("questions")?.[0];
if (!answer) return null;
- return (0, import_react13.createElement)("div", { className: "bt-q-inline" }, (0, import_react13.createElement)(SettledQuestion, { question, answer }));
+ return (0, import_react17.createElement)("div", { className: "bt-q-inline" }, (0, import_react17.createElement)(SettledQuestion, { question, answer }));
}
case "read_group_chat": {
if (!done) return null;
const room2 = roster.rooms.find((entry) => entry.name === arg("group"));
- return room2 ? (0, import_react13.createElement)(GroupEvent, { prefix: t("Read"), room: room2, roster, actions }) : null;
+ return room2 ? (0, import_react17.createElement)(GroupEvent, { prefix: t("Read"), room: room2, roster, actions }) : null;
}
case "remember":
case "forget":
- return done ? (0, import_react13.createElement)(MemoryEvent, { sessionId, scope: arg("scope"), tool, result: contentText(call2.content), failed: call2.isError === true, code: call2.error?.code, roster, actions, findBot }) : null;
+ return done ? (0, import_react17.createElement)(MemoryEvent, { sessionId, scope: arg("scope"), tool, result: contentText(call2.content), failed: call2.isError === true, code: call2.error?.code, roster, actions, findBot }) : null;
default:
return null;
}
@@ -8293,11 +8647,11 @@ function ToolCell({ node, sessionId, useRoster, useUi, useWork, useHeldCards, us
useShownCards(actions, sessionId, drawn.filter((call2) => CARDS.has(toolName(call2)) && call2.callId).map((call2) => call2.callId));
if (drawn.length === 0) return null;
const env = { sessionId, roster, actions, useUi, useWork, findBot, heldCards, hooks: { useBrowserHolds, useBrowserTabs, useBrowserPages } };
- return (0, import_react13.createElement)(import_react13.Fragment, null, drawn.map((call2, index) => (0, import_react13.createElement)(import_react13.Fragment, { key: call2.callId ?? index }, renderCall(call2, env))));
+ return (0, import_react17.createElement)(import_react17.Fragment, null, drawn.map((call2, index) => (0, import_react17.createElement)(import_react17.Fragment, { key: call2.callId ?? index }, renderCall(call2, env))));
}
// src/client/activity-row.js
-var import_react14 = require("react");
+var import_react18 = require("react");
var import_react_dom2 = require("react-dom");
var PHRASE_HOLD_MS = 800;
var drawPhrase = (pool) => t(pool[Math.min(pool.length - 1, Math.floor(Math.random() * pool.length))]);
@@ -8317,8 +8671,8 @@ function findHost() {
return node;
}
function useRunningHost(active) {
- const [host, setHost] = (0, import_react14.useState)(null);
- (0, import_react14.useEffect)(() => {
+ const [host, setHost] = (0, import_react18.useState)(null);
+ (0, import_react18.useEffect)(() => {
if (!active) {
setHost(null);
return void 0;
@@ -8344,9 +8698,9 @@ function useRunningHost(active) {
return host;
}
function useRowEntrances(replacing) {
- const check = (0, import_react14.useRef)(replacing);
+ const check = (0, import_react18.useRef)(replacing);
check.current = replacing;
- (0, import_react14.useEffect)(() => {
+ (0, import_react18.useEffect)(() => {
const seen = /* @__PURE__ */ new WeakSet();
const started = Date.now();
let column = null;
@@ -8394,7 +8748,7 @@ function ActivityIndicator({ sessionId, useRoster, useSessionStatus, useLive, us
const roster = useRoster((value) => value);
const running = useSessionStatus((map) => map.get(sessionId)?.running === true);
const turnAt = useWork?.((work) => work.turns?.[sessionId]);
- const runAt = (0, import_react14.useRef)(0);
+ const runAt = (0, import_react18.useRef)(0);
if (!running) runAt.current = 0;
else if (runAt.current === 0) runAt.current = Date.now();
const liveKey = useLive((state) => JSON.stringify(state[sessionId] ?? {}));
@@ -8406,21 +8760,21 @@ function ActivityIndicator({ sessionId, useRoster, useSessionStatus, useLive, us
const entry = bot === void 0 ? void 0 : work.bots?.[bot.id];
return entry?.switching === true && entry.folder === true && entry.roomId === void 0 ? entry.since : 0;
}) ?? 0;
- const entries2 = (0, import_react14.useMemo)(() => Object.values(JSON.parse(liveKey)), [liveKey]);
+ const entries2 = (0, import_react18.useMemo)(() => Object.values(JSON.parse(liveKey)), [liveKey]);
const streaming = entries2.some((entry) => entry.text);
const tools = entries2.filter((entry) => !entry.text).sort((a, b) => a.at - b.at);
const relaying = tools.some((entry) => entry.relay);
const visible = moveAt !== 0 || rowVisible({ running, streaming, tools, relaying, bot, room: room2 });
const tool = tools.at(-1);
- const inputRef = (0, import_react14.useRef)(0);
+ const inputRef = (0, import_react18.useRef)(0);
const inputAt = Math.max(inputRef.current, pendingInput);
inputRef.current = inputAt;
const want = !visible ? null : moveAt !== 0 ? { key: "move", label: t("Switching working folder"), state: "thinking" } : inputAt > (tool?.at ?? 0) ? { key: `input:${inputAt}`, pool: PHRASES.thinking, state: "thinking" } : tool ? { key: tool.label ? `tool:${tool.label}` : "working", label: tool.label, pool: PHRASES.working, state: tool.state ?? "working" } : { key: "thinking", pool: PHRASES.thinking, state: "thinking" };
- const [shown, setShown] = (0, import_react14.useState)(null);
+ const [shown, setShown] = (0, import_react18.useState)(null);
const wantKey = want?.key ?? null;
- const markState = (0, import_react14.useRef)("thinking");
+ const markState = (0, import_react18.useRef)("thinking");
if (want) markState.current = want.state;
- (0, import_react14.useEffect)(() => {
+ (0, import_react18.useEffect)(() => {
if (wantKey === null || shown?.key === wantKey) return void 0;
const make = () => setShown({ key: wantKey, text: want.label ?? drawPhrase(want.pool), at: Date.now() });
const wait = shown ? shown.at + PHRASE_HOLD_MS - Date.now() : 0;
@@ -8431,12 +8785,12 @@ function ActivityIndicator({ sessionId, useRoster, useSessionStatus, useLive, us
const timer = setTimeout(make, wait);
return () => clearTimeout(timer);
}, [wantKey, shown]);
- const [phase, setPhase] = (0, import_react14.useState)(null);
- const endedAt = (0, import_react14.useRef)(0);
- const shift = (0, import_react14.useRef)(null);
- const leaving = (0, import_react14.useRef)(false);
+ const [phase, setPhase] = (0, import_react18.useState)(null);
+ const endedAt = (0, import_react18.useRef)(0);
+ const shift = (0, import_react18.useRef)(null);
+ const leaving = (0, import_react18.useRef)(false);
leaving.current = phase !== null && !visible;
- (0, import_react14.useEffect)(() => {
+ (0, import_react18.useEffect)(() => {
if (visible) {
setPhase("in");
return void 0;
@@ -8448,7 +8802,7 @@ function ActivityIndicator({ sessionId, useRoster, useSessionStatus, useLive, us
}, 140);
return () => clearTimeout(timer);
}, [visible]);
- (0, import_react14.useLayoutEffect)(() => {
+ (0, import_react18.useLayoutEffect)(() => {
if (phase !== null) return;
endedAt.current = Date.now();
setShown(null);
@@ -8459,21 +8813,21 @@ function ActivityIndicator({ sessionId, useRoster, useSessionStatus, useLive, us
const delta = before - scroller.scrollTop;
if (delta > 0) scroller.querySelector("[data-chat-flow]")?.animate([{ transform: `translateY(${-delta}px)` }, { transform: "none" }], { duration: 140, easing: "cubic-bezier(.23,1,.32,1)" });
}, [phase]);
- (0, import_react14.useEffect)(() => {
+ (0, import_react18.useEffect)(() => {
if (!running) actions.clearLive(sessionId);
}, [running, sessionId]);
useRowEntrances(() => leaving.current || Date.now() - endedAt.current < 300);
const host = useRunningHost(running || moveAt !== 0);
if (!host || phase === null || !shown) return null;
- return (0, import_react_dom2.createPortal)((0, import_react14.createElement)(
+ return (0, import_react_dom2.createPortal)((0, import_react18.createElement)(
"div",
{ className: "bt-typing", "data-exiting": phase === "out" ? "" : void 0, "aria-hidden": true },
- bot ? (0, import_react14.createElement)(BotMark, { bot, size: 28, state: markState.current, live: true, pokeable: true }) : (0, import_react14.createElement)(RoomAvatar, { room: room2, roster, size: 28 }),
- (0, import_react14.createElement)(
+ bot ? (0, import_react18.createElement)(BotMark, { bot, size: 28, state: markState.current, live: true, pokeable: true }) : (0, import_react18.createElement)(RoomAvatar, { room: room2, roster, size: 28 }),
+ (0, import_react18.createElement)(
"span",
{ className: "bt-typing-text" },
- (0, import_react14.createElement)("span", { key: `${shown.key}:${shown.at}`, className: "bt-typing-label" }, (0, import_react14.createElement)(Shimmer, null, `${shown.text}…`)),
- (0, import_react14.createElement)(Elapsed, { at: moveAt !== 0 ? moveAt : Math.max(turnAt ?? runAt.current, inputAt), className: "bt-typing-time" })
+ (0, import_react18.createElement)("span", { key: `${shown.key}:${shown.at}`, className: "bt-typing-label" }, (0, import_react18.createElement)(Shimmer, null, `${shown.text}…`)),
+ (0, import_react18.createElement)(Elapsed, { at: moveAt !== 0 ? moveAt : Math.max(turnAt ?? runAt.current, inputAt), className: "bt-typing-time" })
)
), host);
}
@@ -8489,20 +8843,20 @@ function showsDshRow(dsh, app) {
}
// src/client/sidebar.js
-var import_react15 = require("react");
+var import_react19 = require("react");
var import_react_dom3 = require("react-dom");
function useMarkedUnread(id, active, marked, actions) {
- (0, import_react15.useEffect)(() => {
+ (0, import_react19.useEffect)(() => {
if (active && marked) actions.clearUnread(id);
}, [active, marked]);
}
-var PinMark = () => (0, import_react15.createElement)("span", { className: "bt-pin", "aria-hidden": true }, (0, import_react15.createElement)(PinMarkIcon));
+var PinMark = () => (0, import_react19.createElement)("span", { className: "bt-pin", "aria-hidden": true }, (0, import_react19.createElement)(PinMarkIcon));
var useApproval = (useWork, match) => useWork ? useWork((work) => (work.approvals ?? []).some(match)) : false;
var useGroupWork = (useWork, pick2) => useWork ? useWork((work) => JSON.stringify(pick2(work.rooms ?? {}))) : "[]";
var workKeys = (text) => JSON.parse(text);
var doingOf = ({ tool, said, note, target, switching }) => ({ tool, said, note, target, switching });
-var workLine = (lead, doing, more) => (0, import_react15.createElement)(Shimmer, null, `${lead} · ${workPhrase(doing)}…${more > 0 ? ` +${more}` : ""}`);
-var doingLine = (doing) => (0, import_react15.createElement)(Shimmer, null, `${workPhrase(doing)}…`);
+var workLine = (lead, doing, more) => (0, import_react19.createElement)(Shimmer, null, `${lead} · ${workPhrase(doing)}…${more > 0 ? ` +${more}` : ""}`);
+var doingLine = (doing) => (0, import_react19.createElement)(Shimmer, null, `${workPhrase(doing)}…`);
var waitingFor = (roster, waits) => {
const names = [...(waits?.bots ?? []).map((id) => roster.byId[id]?.name), ...(waits?.rooms ?? []).map((id) => roster.roomsById[id]?.name)].filter(Boolean);
return names.length === 0 ? "" : t("Waiting for {names}", { names: names.join(t(" and ")) });
@@ -8535,7 +8889,7 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessio
const pinned = bot.pinned === true && !tile;
const label = [bot.name, main ? t("Main Bot") : "", pinned ? t("Pinned") : "", running || away ? t("Working") : "", waitsFor, approval ? t("Waiting for your approval") : alert ? t("Waiting for your answer") : "", unread ? t("Unread activity") : ""].filter(Boolean).join(", ");
if (tile && wide) {
- return (0, import_react15.createElement)("div", { className: "bt-tile-wrap" }, (0, import_react15.createElement)(
+ return (0, import_react19.createElement)("div", { className: "bt-tile-wrap" }, (0, import_react19.createElement)(
"button",
{
type: "button",
@@ -8547,12 +8901,12 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessio
onClick: () => actions.openSession(id),
onContextMenu
},
- (0, import_react15.createElement)(BotAvatar, { bot, size: 60, state, main: true }),
- (0, import_react15.createElement)("span", { className: "bt-tile-name" }, bot.name),
- bot.role ? (0, import_react15.createElement)("span", { className: "bt-chip" }, bot.role) : null
+ (0, import_react19.createElement)(BotAvatar, { bot, size: 60, state, main: true }),
+ (0, import_react19.createElement)("span", { className: "bt-tile-name" }, bot.name),
+ bot.role ? (0, import_react19.createElement)("span", { className: "bt-chip" }, bot.role) : null
));
}
- return (0, import_react15.createElement)(
+ return (0, import_react19.createElement)(
"button",
{
type: "button",
@@ -8564,15 +8918,15 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessio
onClick: () => actions.openSession(id),
onContextMenu
},
- (0, import_react15.createElement)(BotAvatar, { bot, size: 36, state, main }),
- pinned && !wide ? (0, import_react15.createElement)(PinMark) : null,
- wide ? (0, import_react15.createElement)(
+ (0, import_react19.createElement)(BotAvatar, { bot, size: 36, state, main }),
+ pinned && !wide ? (0, import_react19.createElement)(PinMark) : null,
+ wide ? (0, import_react19.createElement)(
"span",
{ className: "bt-row-body" },
- (0, import_react15.createElement)("span", { className: "bt-row-name" }, (0, import_react15.createElement)("span", { className: "bt-row-title" }, bot.name), pinned ? (0, import_react15.createElement)(PinMark) : null),
- runningLine ? (0, import_react15.createElement)("span", { className: "bt-row-preview" }, runningLine) : awayLine ? (0, import_react15.createElement)("span", { className: "bt-row-preview" }, awayLine) : waitsFor ? (0, import_react15.createElement)("span", { className: "bt-row-preview" }, waitsFor) : preview ? (0, import_react15.createElement)("span", { className: "bt-row-preview" }, preview) : null
+ (0, import_react19.createElement)("span", { className: "bt-row-name" }, (0, import_react19.createElement)("span", { className: "bt-row-title" }, bot.name), pinned ? (0, import_react19.createElement)(PinMark) : null),
+ runningLine ? (0, import_react19.createElement)("span", { className: "bt-row-preview" }, runningLine) : awayLine ? (0, import_react19.createElement)("span", { className: "bt-row-preview" }, awayLine) : waitsFor ? (0, import_react19.createElement)("span", { className: "bt-row-preview" }, waitsFor) : preview ? (0, import_react19.createElement)("span", { className: "bt-row-preview" }, preview) : null
) : null,
- wide && unread && !active ? (0, import_react15.createElement)("span", { className: "bt-unread", "aria-hidden": true }) : null
+ wide && unread && !active ? (0, import_react19.createElement)("span", { className: "bt-unread", "aria-hidden": true }) : null
);
}
function RoomRow({ room: room2, roster, actions, useSessions, useSessionStatus, useSessionRetainInfo, useWork, wide, marked }) {
@@ -8589,7 +8943,7 @@ function RoomRow({ room: room2, roster, actions, useSessions, useSessionStatus,
if (room2.hidden && !active) return null;
const pinned = room2.pinned === true;
const label = [room2.name, pinned ? t("Pinned") : "", members.length > 0 ? t("Working") : "", approval ? t("Waiting for your approval") : ""].filter(Boolean).join(", ");
- return (0, import_react15.createElement)(
+ return (0, import_react19.createElement)(
"button",
{
type: "button",
@@ -8603,20 +8957,20 @@ function RoomRow({ room: room2, roster, actions, useSessions, useSessionStatus,
actions.openMenu({ kind: "room", id, x: event.clientX, y: event.clientY });
}
},
- (0, import_react15.createElement)(RoomAvatar, { room: room2, roster, size: 36 }),
- pinned && !wide ? (0, import_react15.createElement)(PinMark) : null,
- wide ? (0, import_react15.createElement)(
+ (0, import_react19.createElement)(RoomAvatar, { room: room2, roster, size: 36 }),
+ pinned && !wide ? (0, import_react19.createElement)(PinMark) : null,
+ wide ? (0, import_react19.createElement)(
"span",
{ className: "bt-row-body" },
- (0, import_react15.createElement)("span", { className: "bt-row-name" }, (0, import_react15.createElement)("span", { className: "bt-row-title" }, room2.name), pinned ? (0, import_react15.createElement)(PinMark) : null),
- workingLine ? (0, import_react15.createElement)("span", { className: "bt-row-preview" }, workingLine) : preview ? (0, import_react15.createElement)("span", { className: "bt-row-preview" }, preview) : null
+ (0, import_react19.createElement)("span", { className: "bt-row-name" }, (0, import_react19.createElement)("span", { className: "bt-row-title" }, room2.name), pinned ? (0, import_react19.createElement)(PinMark) : null),
+ workingLine ? (0, import_react19.createElement)("span", { className: "bt-row-preview" }, workingLine) : preview ? (0, import_react19.createElement)("span", { className: "bt-row-preview" }, preview) : null
) : null,
- wide && approval && !active ? (0, import_react15.createElement)("span", { className: "bt-unread bt-unread-wait", "aria-hidden": true }) : wide && unread && !active ? (0, import_react15.createElement)("span", { className: "bt-unread", "aria-hidden": true }) : null
+ wide && approval && !active ? (0, import_react19.createElement)("span", { className: "bt-unread bt-unread-wait", "aria-hidden": true }) : wide && unread && !active ? (0, import_react19.createElement)("span", { className: "bt-unread", "aria-hidden": true }) : null
);
}
function AgentSessionRow({ session, agent, actions, renaming, index }) {
- const input = (0, import_react15.useRef)(null);
- (0, import_react15.useLayoutEffect)(() => {
+ const input = (0, import_react19.useRef)(null);
+ (0, import_react19.useLayoutEffect)(() => {
if (!renaming) return;
input.current?.focus();
input.current?.select();
@@ -8637,10 +8991,10 @@ function AgentSessionRow({ session, agent, actions, renaming, index }) {
}
})();
};
- return (0, import_react15.createElement)(
+ return (0, import_react19.createElement)(
"div",
{ className: "bt-agent-sub-row bt-agent-edit", style: { "--i": index } },
- (0, import_react15.createElement)("input", {
+ (0, import_react19.createElement)("input", {
ref: input,
defaultValue: session.title,
"aria-label": t("Rename"),
@@ -8653,7 +9007,7 @@ function AgentSessionRow({ session, agent, actions, renaming, index }) {
})
);
}
- return (0, import_react15.createElement)(
+ return (0, import_react19.createElement)(
"button",
{
type: "button",
@@ -8667,8 +9021,8 @@ function AgentSessionRow({ session, agent, actions, renaming, index }) {
actions.openMenu({ kind: "agent-session", id: session.id, agentId: agent.id, x: event.clientX, y: event.clientY });
}
},
- (0, import_react15.createElement)("span", { className: "bt-agent-sub-title" }, session.title),
- (0, import_react15.createElement)("span", { className: "bt-agent-sub-time" }, session.at > 0 ? relativeShort(session.at) : "")
+ (0, import_react19.createElement)("span", { className: "bt-agent-sub-title" }, session.title),
+ (0, import_react19.createElement)("span", { className: "bt-agent-sub-time" }, session.at > 0 ? relativeShort(session.at) : "")
);
}
function AgentRow({ agent, actions, useSessions, useSessionStatus, useUi, wide, marked }) {
@@ -8703,10 +9057,10 @@ function AgentRow({ agent, actions, useSessions, useSessionStatus, useUi, wide,
const preview = sessions[0]?.title ?? t("New session");
const label = ["DSH Agent", running ? t("Working") : "", unread ? t("Unread activity") : ""].filter(Boolean).join(", ");
const open = active && wide;
- return (0, import_react15.createElement)(
+ return (0, import_react19.createElement)(
"div",
{ className: "bt-agent" },
- (0, import_react15.createElement)(
+ (0, import_react19.createElement)(
"button",
{
type: "button",
@@ -8721,30 +9075,30 @@ function AgentRow({ agent, actions, useSessions, useSessionStatus, useUi, wide,
actions.openMenu({ kind: "agent", id: agent.id, x: event.clientX, y: event.clientY });
}
},
- (0, import_react15.createElement)("span", { className: `bt-agent-ava${running ? " bt-run" : ""}` }, (0, import_react15.createElement)(import_dsh_client_ui_primitives.FishLogo, { size: 22 })),
- wide ? (0, import_react15.createElement)(
+ (0, import_react19.createElement)("span", { className: `bt-agent-ava${running ? " bt-run" : ""}` }, (0, import_react19.createElement)(import_dsh_client_ui_primitives.FishLogo, { size: 22 })),
+ wide ? (0, import_react19.createElement)(
"span",
{ className: "bt-row-body" },
- (0, import_react15.createElement)("span", { className: "bt-row-name" }, "DSH Agent"),
- preview ? (0, import_react15.createElement)("span", { className: "bt-row-preview" }, preview) : null
+ (0, import_react19.createElement)("span", { className: "bt-row-name" }, "DSH Agent"),
+ preview ? (0, import_react19.createElement)("span", { className: "bt-row-preview" }, preview) : null
) : null,
- wide && unread && !active ? (0, import_react15.createElement)("span", { className: "bt-unread", "aria-hidden": true }) : null
+ wide && unread && !active ? (0, import_react19.createElement)("span", { className: "bt-unread", "aria-hidden": true }) : null
),
- (0, import_react15.createElement)(
+ (0, import_react19.createElement)(
"div",
{ className: "bt-agent-sub", "data-open": open || void 0 },
- (0, import_react15.createElement)(
+ (0, import_react19.createElement)(
"div",
{ className: "bt-agent-sub-in" },
- (0, import_react15.createElement)(
+ (0, import_react19.createElement)(
"button",
{ type: "button", className: "bt-agent-sub-row bt-agent-new", style: { "--i": 0 }, onClick: () => {
void actions.newAgentSession(agent.id).catch((error) => actions.reportError(error, "agent-session"));
} },
- (0, import_react15.createElement)(PlusIcon),
- (0, import_react15.createElement)("span", { className: "bt-agent-sub-title" }, t("New session"))
+ (0, import_react19.createElement)(PlusIcon),
+ (0, import_react19.createElement)("span", { className: "bt-agent-sub-title" }, t("New session"))
),
- sessions.map((session, index) => (0, import_react15.createElement)(AgentSessionRow, {
+ sessions.map((session, index) => (0, import_react19.createElement)(AgentSessionRow, {
key: session.id,
session,
agent,
@@ -8758,8 +9112,8 @@ function AgentRow({ agent, actions, useSessions, useSessionStatus, useUi, wide,
}
var GLIDE = springEasing(1e3, 63);
function useListGlide(listRef, layout, key) {
- const tops = (0, import_react15.useRef)({ layout, map: /* @__PURE__ */ new Map() });
- (0, import_react15.useLayoutEffect)(() => {
+ const tops = (0, import_react19.useRef)({ layout, map: /* @__PURE__ */ new Map() });
+ (0, import_react19.useLayoutEffect)(() => {
const list = listRef.current;
if (!list) return;
const next = /* @__PURE__ */ new Map();
@@ -8778,9 +9132,9 @@ function useListGlide(listRef, layout, key) {
}
function TeamSidebar(props) {
const { wide, expandSidebar, useRoster, useUi, useSessions, actions } = props;
- const listRef = (0, import_react15.useRef)(null);
- const closing = (0, import_react15.useRef)(false);
- (0, import_react15.useLayoutEffect)(() => {
+ const listRef = (0, import_react19.useRef)(null);
+ const closing = (0, import_react19.useRef)(false);
+ (0, import_react19.useLayoutEffect)(() => {
closing.current = false;
});
const roster = useRoster((value) => value);
@@ -8791,7 +9145,7 @@ function TeamSidebar(props) {
for (const id of list.ids) stamps[id] = list.byId[id]?.updatedAt ?? 0;
return JSON.stringify(stamps);
});
- const order = (0, import_react15.useMemo)(() => {
+ const order = (0, import_react19.useMemo)(() => {
const stamps = JSON.parse(updated);
const entries2 = [
...roster.bots.filter((bot) => bot.id !== roster.mainBotId).map((bot) => ({ kind: "bot", item: bot, at: stamps[currentPart(bot)] ?? bot.createdAt })),
@@ -8827,40 +9181,40 @@ function TeamSidebar(props) {
event.preventDefault();
actions.openPalette(event.key);
};
- return (0, import_react15.createElement)(
+ return (0, import_react19.createElement)(
"div",
{ className: wide ? "bt-side" : "bt-side bt-rail", onKeyDown: typeToSearch },
- wide ? (0, import_react15.createElement)(
+ wide ? (0, import_react19.createElement)(
"div",
{ className: "bt-side-top" },
- (0, import_react15.createElement)("span", { className: "bt-brand" }, (0, import_react15.createElement)(BrandMark, { size: 22 }), (0, import_react15.createElement)(BrandName)),
- (0, import_react15.createElement)(UpdateButton, { useUpdate: props.useUpdate, actions }),
- (0, import_react15.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("Search"), title: t("Search"), onClick: () => actions.openPalette() }, (0, import_react15.createElement)(SearchIcon)),
- (0, import_react15.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("New…"), title: t("New…"), onClick: () => actions.openNewChat("new") }, (0, import_react15.createElement)(PlusIcon)),
- (0, import_react15.createElement)("button", { type: "button", className: "bt-round bt-side-collapse", "aria-label": t("Collapse sidebar"), title: t("Collapse sidebar"), onClick: () => actions.toggleSidebar() }, (0, import_react15.createElement)(SidebarIcon))
- ) : (0, import_react15.createElement)(
- import_react15.Fragment,
+ (0, import_react19.createElement)("span", { className: "bt-brand" }, (0, import_react19.createElement)(BrandMark, { size: 22 }), (0, import_react19.createElement)(BrandName)),
+ (0, import_react19.createElement)(UpdateButton, { useUpdate: props.useUpdate, actions }),
+ (0, import_react19.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("Search"), title: t("Search"), onClick: () => actions.openPalette() }, (0, import_react19.createElement)(SearchIcon)),
+ (0, import_react19.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("New…"), title: t("New…"), onClick: () => actions.openNewChat("new") }, (0, import_react19.createElement)(PlusIcon)),
+ (0, import_react19.createElement)("button", { type: "button", className: "bt-round bt-side-collapse", "aria-label": t("Collapse sidebar"), title: t("Collapse sidebar"), onClick: () => actions.toggleSidebar() }, (0, import_react19.createElement)(SidebarIcon))
+ ) : (0, import_react19.createElement)(
+ import_react19.Fragment,
null,
- (0, import_react15.createElement)(UpdateButton, { useUpdate: props.useUpdate, actions }),
- (0, import_react15.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("New…"), title: t("New…"), onClick: () => actions.openNewChat("new") }, (0, import_react15.createElement)(PlusIcon))
+ (0, import_react19.createElement)(UpdateButton, { useUpdate: props.useUpdate, actions }),
+ (0, import_react19.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("New…"), title: t("New…"), onClick: () => actions.openNewChat("new") }, (0, import_react19.createElement)(PlusIcon))
),
- wide && roster.readOnly ? (0, import_react15.createElement)("div", { className: "bt-hint bt-read-only", role: "status" }, hostText(roster.readOnly)) : null,
- (0, import_react15.createElement)(
+ wide && roster.readOnly ? (0, import_react19.createElement)("div", { className: "bt-hint bt-read-only", role: "status" }, hostText(roster.readOnly)) : null,
+ (0, import_react19.createElement)(
"div",
{ ref: listRef, className: "bt-list", role: "region", "aria-label": t("Bot list") },
- main ? (0, import_react15.createElement)(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : (0, import_react15.createElement)("div", { className: "bt-hint" }, t("Setting up your Main Bot…")),
- order.map((entry) => entry.kind === "bot" ? (0, import_react15.createElement)(BotRow, { key: entry.item.id, ...rowProps, bot: entry.item, marked: markedUnread[entry.item.id] === true }) : entry.kind === "room" ? (0, import_react15.createElement)(RoomRow, { key: entry.item.id, ...rowProps, room: entry.item, marked: markedUnread[entry.item.id] === true }) : (0, import_react15.createElement)(AgentRow, { key: entry.item.id, ...rowProps, agent: entry.item, marked: markedUnread[entry.item.id] === true }))
+ main ? (0, import_react19.createElement)(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : (0, import_react19.createElement)("div", { className: "bt-hint" }, t("Setting up your Main Bot…")),
+ order.map((entry) => entry.kind === "bot" ? (0, import_react19.createElement)(BotRow, { key: entry.item.id, ...rowProps, bot: entry.item, marked: markedUnread[entry.item.id] === true }) : entry.kind === "room" ? (0, import_react19.createElement)(RoomRow, { key: entry.item.id, ...rowProps, room: entry.item, marked: markedUnread[entry.item.id] === true }) : (0, import_react19.createElement)(AgentRow, { key: entry.item.id, ...rowProps, agent: entry.item, marked: markedUnread[entry.item.id] === true }))
)
);
}
function UpdateButton({ useUpdate, actions }) {
const update = useUpdate((value) => value);
- const [open, setOpen] = (0, import_react15.useState)(false);
- const [box, setBox] = (0, import_react15.useState)(null);
- const [error, setError] = (0, import_react15.useState)("");
- const [dshError, setDshError] = (0, import_react15.useState)("");
- const button = (0, import_react15.useRef)(null);
- (0, import_react15.useEffect)(() => {
+ const [open, setOpen] = (0, import_react19.useState)(false);
+ const [box, setBox] = (0, import_react19.useState)(null);
+ const [error, setError] = (0, import_react19.useState)("");
+ const [dshError, setDshError] = (0, import_react19.useState)("");
+ const button = (0, import_react19.useRef)(null);
+ (0, import_react19.useEffect)(() => {
if (!open) return void 0;
const onDown = (event) => {
if (event.target instanceof Element && (event.target.closest(".bt-update-pop") || button.current?.contains(event.target))) return;
@@ -8885,7 +9239,7 @@ function UpdateButton({ useUpdate, actions }) {
const dshPhase = dsh?.phase ?? "idle";
const dshRow = showsDshRow(dsh, update?.app);
const tick = useViewport();
- (0, import_react15.useLayoutEffect)(() => {
+ (0, import_react19.useLayoutEffect)(() => {
if (!open) return;
const rect = button.current?.getBoundingClientRect();
if (rect) setBox({ left: Math.max(8, Math.min(rect.left, window.innerWidth - 288)), top: rect.bottom + 6 });
@@ -8905,10 +9259,10 @@ function UpdateButton({ useUpdate, actions }) {
const message = error || (phase === "failed" ? update.error : "");
const dshMessage = dshError || (dshPhase === "failed" ? dsh?.error : "");
const dshText = dshPhase === "installed" ? t("Restart DSH to start using DSH {version}.", { version: dsh.installed ?? dsh.verified }) : dsh?.available === false && dsh?.blockedBy ? t("Update DS Bot {version} first.", { version: dsh.blockedBy }) : t("You have {version}.", { version: dsh?.current });
- return (0, import_react15.createElement)(
- import_react15.Fragment,
+ return (0, import_react19.createElement)(
+ import_react19.Fragment,
null,
- (0, import_react15.createElement)("button", {
+ (0, import_react19.createElement)("button", {
ref: button,
type: "button",
className: "bt-round bt-update",
@@ -8918,21 +9272,21 @@ function UpdateButton({ useUpdate, actions }) {
"aria-haspopup": "dialog",
"aria-expanded": open,
onClick: toggle
- }, (0, import_react15.createElement)(CloudDownloadIcon, { done: phase === "installed" || phase === "updated" }), phase === "failed" || dshPhase === "failed" ? (0, import_react15.createElement)("span", { className: "bt-update-dot", "aria-hidden": true }) : null),
- open && box ? (0, import_react_dom3.createPortal)((0, import_react15.createElement)(
+ }, (0, import_react19.createElement)(CloudDownloadIcon, { done: phase === "installed" || phase === "updated" }), phase === "failed" || dshPhase === "failed" ? (0, import_react19.createElement)("span", { className: "bt-update-dot", "aria-hidden": true }) : null),
+ open && box ? (0, import_react_dom3.createPortal)((0, import_react19.createElement)(
"div",
{ className: "bt-update-pop", role: "dialog", "aria-label": update?.available || phase !== "idle" ? t("DS Bot update") : t("DSH update"), style: box },
- update?.available || phase !== "idle" ? (0, import_react15.createElement)(
- import_react15.Fragment,
+ update?.available || phase !== "idle" ? (0, import_react19.createElement)(
+ import_react19.Fragment,
null,
- (0, import_react15.createElement)("div", { className: "bt-update-title" }, phase === "installed" || phase === "updated" ? t("Update installed") : t("DS Bot {version}", { version: update.latest })),
- (0, import_react15.createElement)("div", { className: "bt-update-text" }, phase === "installed" ? t("Restart DSH to start using DS Bot {version}.", { version: update.installed ?? update.latest }) : phase === "updated" ? t("DS Bot {version} is installed.", { version: update.installed ?? update.latest }) : t("You have {version}.", { version: update.current })),
- message ? (0, import_react15.createElement)("div", { className: "bt-update-error", role: "alert" }, t("The update did not finish: {reason}", { reason: message })) : null,
- (0, import_react15.createElement)(
+ (0, import_react19.createElement)("div", { className: "bt-update-title" }, phase === "installed" || phase === "updated" ? t("Update installed") : t("DS Bot {version}", { version: update.latest })),
+ (0, import_react19.createElement)("div", { className: "bt-update-text" }, phase === "installed" ? t("Restart DSH to start using DS Bot {version}.", { version: update.installed ?? update.latest }) : phase === "updated" ? t("DS Bot {version} is installed.", { version: update.installed ?? update.latest }) : t("You have {version}.", { version: update.current })),
+ message ? (0, import_react19.createElement)("div", { className: "bt-update-error", role: "alert" }, t("The update did not finish: {reason}", { reason: message })) : null,
+ (0, import_react19.createElement)(
"div",
{ className: "bt-update-actions" },
- update.notesUrl ? (0, import_react15.createElement)("a", { className: "bt-update-notes", href: update.notesUrl, target: "_blank", rel: "noopener noreferrer" }, t("What's new")) : null,
- phase === "installed" || phase === "updated" ? null : (0, import_react15.createElement)("button", {
+ update.notesUrl ? (0, import_react19.createElement)("a", { className: "bt-update-notes", href: update.notesUrl, target: "_blank", rel: "noopener noreferrer" }, t("What's new")) : null,
+ phase === "installed" || phase === "updated" ? null : (0, import_react19.createElement)("button", {
type: "button",
className: "bt-update-go",
disabled: phase === "installing",
@@ -8940,17 +9294,17 @@ function UpdateButton({ useUpdate, actions }) {
}, phase === "installing" ? t("Updating…") : phase === "failed" ? t("Try again") : t("Update"))
)
) : null,
- dshRow ? (0, import_react15.createElement)(
+ dshRow ? (0, import_react19.createElement)(
"div",
{ className: "bt-update-dsh" },
- (0, import_react15.createElement)("div", { className: "bt-update-title" }, t("DSH {version}", { version: dsh.verified })),
- (0, import_react15.createElement)("div", { className: "bt-update-text" }, dshText),
- dshMessage ? (0, import_react15.createElement)("div", { className: "bt-update-error", role: "alert" }, t("The update did not finish: {reason}", { reason: dshMessage })) : null,
- (0, import_react15.createElement)(
+ (0, import_react19.createElement)("div", { className: "bt-update-title" }, t("DSH {version}", { version: dsh.verified })),
+ (0, import_react19.createElement)("div", { className: "bt-update-text" }, dshText),
+ dshMessage ? (0, import_react19.createElement)("div", { className: "bt-update-error", role: "alert" }, t("The update did not finish: {reason}", { reason: dshMessage })) : null,
+ (0, import_react19.createElement)(
"div",
{ className: "bt-update-actions" },
- dsh.kind === "app" ? dsh.available ? (0, import_react15.createElement)("button", { type: "button", className: "bt-update-go", onClick: () => void actions.openAppUpdates(dsh.verified).catch(() => {
- }) }, t("Open updates")) : null : !dsh.available && dshPhase === "idle" ? null : dshPhase === "installed" ? null : (0, import_react15.createElement)("button", {
+ dsh.kind === "app" ? dsh.available ? (0, import_react19.createElement)("button", { type: "button", className: "bt-update-go", onClick: () => void actions.openAppUpdates(dsh.verified).catch(() => {
+ }) }, t("Open updates")) : null : !dsh.available && dshPhase === "idle" ? null : dshPhase === "installed" ? null : (0, import_react19.createElement)("button", {
type: "button",
className: "bt-update-go",
disabled: dshPhase === "installing",
@@ -8963,27 +9317,27 @@ function UpdateButton({ useUpdate, actions }) {
}
function ConnectPlugins({ wide, actions }) {
if (!wide) return null;
- return (0, import_react15.createElement)(
+ return (0, import_react19.createElement)(
"span",
{ className: "bt-connect-wrap" },
- (0, import_react15.createElement)(
+ (0, import_react19.createElement)(
"button",
{
type: "button",
className: "bt-connect bt-connect-foot",
onClick: () => actions.selectPanel("plugins")
},
- (0, import_react15.createElement)(PlugIcon),
+ (0, import_react19.createElement)(PlugIcon),
t("Connect plugins")
)
);
}
function YouAvatar() {
- return (0, import_react15.createElement)(
+ return (0, import_react19.createElement)(
"span",
{ className: "bt-you-wrap" },
- (0, import_react15.createElement)("span", { className: "bt-you", "aria-hidden": true }, (0, import_react15.createElement)(BotMark, { look: MAIN_LOOK, size: 24 })),
- (0, import_react15.createElement)("span", { style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)" } }, t("Settings"))
+ (0, import_react19.createElement)("span", { className: "bt-you", "aria-hidden": true }, (0, import_react19.createElement)(BotMark, { look: MAIN_LOOK, size: 24 })),
+ (0, import_react19.createElement)("span", { style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)" } }, t("Settings"))
);
}
var openShellSettings = null;
@@ -9044,32 +9398,32 @@ var NO_SUBSCRIBE = () => () => {
};
var NO_SNAPSHOT = () => null;
function AccountLauncher({ seat = true, settingsOpen, openSettings, openOnboarding, actions }) {
- const [open, setOpen] = (0, import_react15.useState)(false);
- (0, import_react15.useLayoutEffect)(() => {
+ const [open, setOpen] = (0, import_react19.useState)(false);
+ (0, import_react19.useLayoutEffect)(() => {
if (!seat) return void 0;
actions.seatAccount(true);
return () => actions.seatAccount(false);
}, [seat]);
- const [box, setBox] = (0, import_react15.useState)(null);
- const button = (0, import_react15.useRef)(null);
- (0, import_react15.useEffect)(() => {
+ const [box, setBox] = (0, import_react19.useState)(null);
+ const button = (0, import_react19.useRef)(null);
+ (0, import_react19.useEffect)(() => {
if (settingsOpen) setOpen(false);
}, [settingsOpen]);
- (0, import_react15.useEffect)(() => {
+ (0, import_react19.useEffect)(() => {
if (!openSettings) return void 0;
openShellSettings = openSettings;
return () => {
if (openShellSettings === openSettings) openShellSettings = null;
};
}, [openSettings]);
- (0, import_react15.useEffect)(() => {
+ (0, import_react19.useEffect)(() => {
if (!openOnboarding) return void 0;
openShellOnboarding = openOnboarding;
return () => {
if (openShellOnboarding === openOnboarding) openShellOnboarding = null;
};
}, [openOnboarding]);
- (0, import_react15.useEffect)(() => {
+ (0, import_react19.useEffect)(() => {
if (!open) return void 0;
const onDown = (event) => {
if (event.target instanceof Element && (event.target.closest(".bt-account-menu") || button.current?.contains(event.target))) return;
@@ -9090,14 +9444,14 @@ function AccountLauncher({ seat = true, settingsOpen, openSettings, openOnboardi
};
}, [open]);
const signIn = actions.signInEntry?.() ?? null;
- const ops = (0, import_react15.useMemo)(() => signIn?.inject?.() ?? {}, [signIn]);
+ const ops = (0, import_react19.useMemo)(() => signIn?.inject?.() ?? {}, [signIn]);
const accountSource = ops.hooks?.account;
- const account = (0, import_react15.useSyncExternalStore)(accountSource?.subscribe ?? NO_SUBSCRIBE, accountSource ? () => accountSource.getSnapshot() : NO_SNAPSHOT);
+ const account = (0, import_react19.useSyncExternalStore)(accountSource?.subscribe ?? NO_SUBSCRIBE, accountSource ? () => accountSource.getSnapshot() : NO_SNAPSHOT);
const signedIn = signIn !== null && typeof ops.signOut === "function" && account?.view?.status === "credential-stored";
const accountT = actions.accountT?.() ?? ((key) => key);
- const [confirm, setConfirm] = (0, import_react15.useState)(null);
- const [busy, setBusy] = (0, import_react15.useState)(false);
- const [signOutError, setSignOutError] = (0, import_react15.useState)("");
+ const [confirm, setConfirm] = (0, import_react19.useState)(null);
+ const [busy, setBusy] = (0, import_react19.useState)(false);
+ const [signOutError, setSignOutError] = (0, import_react19.useState)("");
const askSignOut = async () => {
setSignOutError("");
let state = "none";
@@ -9130,14 +9484,14 @@ function AccountLauncher({ seat = true, settingsOpen, openSettings, openOnboardi
const rect = button.current?.getBoundingClientRect();
if (rect) setBox({ left: rect.left, bottom: viewBottom() - rect.top + 5 });
};
- (0, import_react15.useLayoutEffect)(() => {
+ (0, import_react19.useLayoutEffect)(() => {
if (open) anchor();
}, [open, tick]);
const toggle = () => {
if (!open) anchor();
setOpen((value) => !value);
};
- (0, import_react15.useEffect)(() => {
+ (0, import_react19.useEffect)(() => {
if (open) return;
setConfirm(null);
setSignOutError("");
@@ -9155,35 +9509,35 @@ function AccountLauncher({ seat = true, settingsOpen, openSettings, openOnboardi
]
];
if (signedIn) groups.push([[accountT("signOut"), SignOutIcon, askSignOut, void 0, true]]);
- return (0, import_react15.createElement)(
- import_react15.Fragment,
+ return (0, import_react19.createElement)(
+ import_react19.Fragment,
null,
- (0, import_react15.createElement)(
+ (0, import_react19.createElement)(
"button",
{ ref: button, type: "button", className: "bt-account", "aria-label": t("Account"), "aria-haspopup": "menu", "aria-expanded": open, onClick: toggle },
- (0, import_react15.createElement)("span", { className: "bt-you", "aria-hidden": true }, (0, import_react15.createElement)(BotMark, { look: MAIN_LOOK, size: 24 }))
+ (0, import_react19.createElement)("span", { className: "bt-you", "aria-hidden": true }, (0, import_react19.createElement)(BotMark, { look: MAIN_LOOK, size: 24 }))
),
- open && box ? (0, import_react_dom3.createPortal)((0, import_react15.createElement)(
+ open && box ? (0, import_react_dom3.createPortal)((0, import_react19.createElement)(
"div",
{ className: "bt-menu bt-menu-up bt-account-menu", role: "menu", "aria-label": t("Account"), style: box },
- confirm !== null ? (0, import_react15.createElement)(
+ confirm !== null ? (0, import_react19.createElement)(
"div",
{ className: "bt-confirm", role: "alertdialog", "aria-label": accountT("signOut") },
- (0, import_react15.createElement)("p", { className: "bt-confirm-text" }, accountT(confirm === "running" ? "signOutRunningDescription" : confirm === "unknown" ? "signOutUnknownDescription" : "signOutDescription")),
- signOutError !== "" ? (0, import_react15.createElement)("p", { className: "bt-confirm-error", role: "alert" }, signOutError) : null,
- (0, import_react15.createElement)(
+ (0, import_react19.createElement)("p", { className: "bt-confirm-text" }, accountT(confirm === "running" ? "signOutRunningDescription" : confirm === "unknown" ? "signOutUnknownDescription" : "signOutDescription")),
+ signOutError !== "" ? (0, import_react19.createElement)("p", { className: "bt-confirm-error", role: "alert" }, signOutError) : null,
+ (0, import_react19.createElement)(
"div",
{ className: "bt-confirm-row" },
- (0, import_react15.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: cancelSignOut }, t("Cancel")),
- (0, import_react15.createElement)("button", { type: "button", className: "bt-confirm-go", disabled: busy, onClick: () => {
+ (0, import_react19.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: cancelSignOut }, t("Cancel")),
+ (0, import_react19.createElement)("button", { type: "button", className: "bt-confirm-go", disabled: busy, onClick: () => {
void runSignOut();
} }, accountT("signOut"))
)
- ) : groups.map((group, index) => (0, import_react15.createElement)(
- import_react15.Fragment,
+ ) : groups.map((group, index) => (0, import_react19.createElement)(
+ import_react19.Fragment,
{ key: index },
- index > 0 ? (0, import_react15.createElement)("div", { className: "bt-menu-sep", role: "separator" }) : null,
- group.map(([label, Icon, run2, hint, stay]) => (0, import_react15.createElement)("button", {
+ index > 0 ? (0, import_react19.createElement)("div", { className: "bt-menu-sep", role: "separator" }) : null,
+ group.map(([label, Icon, run2, hint, stay]) => (0, import_react19.createElement)("button", {
key: label,
type: "button",
role: "menuitem",
@@ -9191,7 +9545,7 @@ function AccountLauncher({ seat = true, settingsOpen, openSettings, openOnboardi
if (stay !== true) setOpen(false);
void Promise.resolve(run2()).catch((error) => actions.reportError(error, "menu"));
}
- }, (0, import_react15.createElement)(Icon), (0, import_react15.createElement)("span", { className: "bt-menu-label" }, label), hint ? (0, import_react15.createElement)("span", { className: "bt-menu-hint" }, hint) : null))
+ }, (0, import_react19.createElement)(Icon), (0, import_react19.createElement)("span", { className: "bt-menu-label" }, label), hint ? (0, import_react19.createElement)("span", { className: "bt-menu-hint" }, hint) : null))
))
), document.body) : null
);
@@ -9201,8 +9555,8 @@ function useLandOnMainBot(roster, useSessions, actions) {
const row = Object.values(list.byId).find((session) => (session?.retainedBy?.mainView ?? 0) > 0);
return row ? `${row.id}|${row.blank ? 1 : 0}` : "";
});
- const lastBot = (0, import_react15.useRef)(null);
- (0, import_react15.useEffect)(() => {
+ const lastBot = (0, import_react19.useRef)(null);
+ (0, import_react19.useEffect)(() => {
if (!roster.ready || !roster.mainBotId) return void 0;
const [id, blank3] = mainView.split("|");
const bot = id === "" ? void 0 : roster.byId[id];
@@ -9223,16 +9577,16 @@ function useLandOnMainBot(roster, useSessions, actions) {
function FooterAccount(props) {
const seated = props.useUi((value) => value.accountSeated === true);
if (seated) return null;
- return (0, import_react15.createElement)("span", { className: "bt-foot-account" }, (0, import_react15.createElement)(AccountLauncher, { ...props, seat: false }));
+ return (0, import_react19.createElement)("span", { className: "bt-foot-account" }, (0, import_react19.createElement)(AccountLauncher, { ...props, seat: false }));
}
function BotReturn({ wide, useSurface, actions }) {
const mode = useSurface((value) => value.mode);
if (mode !== "agent") return null;
- return (0, import_react15.createElement)(
+ return (0, import_react19.createElement)(
"button",
{ type: "button", className: "bt-return", "aria-label": t("DS Bot"), title: t("DS Bot"), onClick: () => actions.setSurface("bot") },
- (0, import_react15.createElement)(BotMark, { look: MAIN_LOOK, size: 20 }),
- wide ? (0, import_react15.createElement)("span", { className: "bt-return-name" }, t("DS Bot")) : null
+ (0, import_react19.createElement)(BotMark, { look: MAIN_LOOK, size: 20 }),
+ wide ? (0, import_react19.createElement)("span", { className: "bt-return-name" }, t("DS Bot")) : null
);
}
var RETURN_CSS = `
@@ -9246,10 +9600,10 @@ var RETURN_CSS = `
.bt-return-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
`;
function BrandMark({ size = 24 }) {
- return (0, import_react15.createElement)("span", { className: "bt-brand-whale" }, (0, import_react15.createElement)(BotMark, { look: MAIN_LOOK, size }));
+ return (0, import_react19.createElement)("span", { className: "bt-brand-whale" }, (0, import_react19.createElement)(BotMark, { look: MAIN_LOOK, size }));
}
function BrandName() {
- return (0, import_react15.createElement)("span", { style: { fontWeight: 600, fontSize: 14 } }, "DS Bot");
+ return (0, import_react19.createElement)("span", { style: { fontWeight: 600, fontSize: 14 } }, "DS Bot");
}
var SIDEBAR_CSS = `
.bt-confirm{width:260px;max-width:72vw;padding:10px 12px 12px;display:flex;flex-direction:column;gap:10px}
@@ -9320,15 +9674,15 @@ var SIDEBAR_CSS = `
`;
// src/client/header.js
-var import_react16 = require("react");
+var import_react20 = require("react");
var import_react_dom4 = require("react-dom");
-var GoArrow = () => (0, import_react16.createElement)("svg", { width: 14, height: 14, viewBox: "-12 -12 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true }, (0, import_react16.createElement)("path", { d: "M-7 0H7M2 -5L7 0L2 5" }));
+var GoArrow = () => (0, import_react20.createElement)("svg", { width: 14, height: 14, viewBox: "-12 -12 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true }, (0, import_react20.createElement)("path", { d: "M-7 0H7M2 -5L7 0L2 5" }));
var MEMORY_NOTICE_MS = 3200;
var noNews = (select) => select({});
function useMemoryNotice(ids, useMemoryNews) {
const seen = useMemoryNews((map) => Math.max(0, ...ids.map((id) => map?.[id]?.seen ?? 0)));
- const [shown, setShown] = (0, import_react16.useState)(false);
- (0, import_react16.useEffect)(() => {
+ const [shown, setShown] = (0, import_react20.useState)(false);
+ (0, import_react20.useEffect)(() => {
const left = seen + MEMORY_NOTICE_MS - Date.now();
setShown(seen > 0 && left > 0);
if (seen === 0 || left <= 0) return void 0;
@@ -9338,16 +9692,16 @@ function useMemoryNotice(ids, useMemoryNews) {
return shown;
}
function MemoryNotice({ shown }) {
- const inner = (0, import_react16.useRef)(null);
- const [width, setWidth] = (0, import_react16.useState)(0);
+ const inner = (0, import_react20.useRef)(null);
+ const [width, setWidth] = (0, import_react20.useState)(0);
const label = t("Memory updated");
- (0, import_react16.useLayoutEffect)(() => {
+ (0, import_react20.useLayoutEffect)(() => {
if (shown) setWidth(inner.current?.scrollWidth ?? 0);
}, [label, shown]);
- return (0, import_react16.createElement)(
+ return (0, import_react20.createElement)(
"span",
{ className: "bt-pill-mem", "aria-hidden": true, style: { "--bt-mem-w": `${width}px` } },
- (0, import_react16.createElement)("span", { className: "bt-pill-mem-in", ref: inner }, (0, import_react16.createElement)("span", { className: "bt-pill-mem-ico" }, (0, import_react16.createElement)(MemoryIcon)), label)
+ (0, import_react20.createElement)("span", { className: "bt-pill-mem-in", ref: inner }, (0, import_react20.createElement)("span", { className: "bt-pill-mem-ico" }, (0, import_react20.createElement)(MemoryIcon)), label)
);
}
function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatus, useSession, useActivity, useMemoryNews, useTurnClock, useUi, useLive, useWork, useStore, useConversationViews, selectView, actions }) {
@@ -9365,7 +9719,7 @@ function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatus, useSe
const first = openingTurn(state[sessionId], firstTurns, hiddenTurns);
return first && !unseenSince(visit, first.start) ? clockLabel(first.start) : "";
});
- (0, import_react16.useEffect)(() => {
+ (0, import_react20.useEffect)(() => {
if (opening) document.body.style.setProperty("--bt-first-sep", JSON.stringify(opening));
else document.body.style.removeProperty("--bt-first-sep");
return () => document.body.style.removeProperty("--bt-first-sep");
@@ -9381,17 +9735,17 @@ function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatus, useSe
const memoryIds = bot ? [bot.id] : room2 ? [room2.id, ...room2.members] : [];
const notice = useMemoryNotice(memoryIds, useNews);
const changed = useNews((map) => latestMemoryChange(map, memoryIds));
- (0, import_react16.useEffect)(() => {
+ (0, import_react20.useEffect)(() => {
document.body.style.setProperty("--bt-placeholder", JSON.stringify(name ? t("Message {name}", { name }) : t("Message")));
}, [name, t("Message")]);
- (0, import_react16.useEffect)(() => {
+ (0, import_react20.useEffect)(() => {
document.body.style.setProperty("--bt-steer-unread", JSON.stringify(t("Not read yet")));
}, [t("Not read yet")]);
- (0, import_react16.useEffect)(() => {
+ (0, import_react20.useEffect)(() => {
actions.beginVisit(sessionId);
return () => actions.endVisit(sessionId);
}, [sessionId]);
- (0, import_react16.useEffect)(() => {
+ (0, import_react20.useEffect)(() => {
if (room2) document.body.dataset.btRoom = "";
else delete document.body.dataset.btRoom;
return () => {
@@ -9399,10 +9753,10 @@ function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatus, useSe
};
}, [Boolean(room2)]);
const memoryNotice = !away && notice && changed !== null && roster.memory !== false;
- return (0, import_react16.createElement)(
+ return (0, import_react20.createElement)(
"div",
{ className: "bt-head" },
- (0, import_react16.createElement)(
+ (0, import_react20.createElement)(
"button",
{
type: "button",
@@ -9413,19 +9767,19 @@ function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatus, useSe
title: away ? name : void 0,
onClick: () => away ? selectView("chat") : memoryNotice ? actions.openMemory(changed) : actions.toggleDetails(sessionId)
},
- bot ? (0, import_react16.createElement)(BotAvatar, { bot, size: 24, state: botState(running, doing, roster.questions?.[currentPart(bot)] !== void 0), badge: false }) : room2 ? (0, import_react16.createElement)(RoomAvatar, { room: room2, roster, size: 24 }) : null,
- (0, import_react16.createElement)("span", { className: "bt-pill-name" }, away ? t("Back to chat") : bot?.name ?? room2?.name ?? (title || t("New chat"))),
- (0, import_react16.createElement)(MemoryNotice, { shown: memoryNotice }),
- (0, import_react16.createElement)("span", { className: "bt-pill-go", "aria-hidden": true }, (0, import_react16.createElement)(GoArrow))
+ bot ? (0, import_react20.createElement)(BotAvatar, { bot, size: 24, state: botState(running, doing, roster.questions?.[currentPart(bot)] !== void 0), badge: false }) : room2 ? (0, import_react20.createElement)(RoomAvatar, { room: room2, roster, size: 24 }) : null,
+ (0, import_react20.createElement)("span", { className: "bt-pill-name" }, away ? t("Back to chat") : bot?.name ?? room2?.name ?? (title || t("New chat"))),
+ (0, import_react20.createElement)(MemoryNotice, { shown: memoryNotice }),
+ (0, import_react20.createElement)("span", { className: "bt-pill-go", "aria-hidden": true }, (0, import_react20.createElement)(GoArrow))
),
- (0, import_react16.createElement)("span", { className: "bt-sr", role: "status" }, memoryNotice ? t("Memory updated") : ""),
- (0, import_react16.createElement)(NewMessagePills, { key: sessionId, sessionId, useSessions, useUi, useTurnClock }),
- (0, import_react16.createElement)(ActivityIndicator, { key: `activity:${sessionId}`, sessionId, useRoster, useSessionStatus, useSession, useLive, useWork, actions })
+ (0, import_react20.createElement)("span", { className: "bt-sr", role: "status" }, memoryNotice ? t("Memory updated") : ""),
+ (0, import_react20.createElement)(NewMessagePills, { key: sessionId, sessionId, useSessions, useUi, useTurnClock }),
+ (0, import_react20.createElement)(ActivityIndicator, { key: `activity:${sessionId}`, sessionId, useRoster, useSessionStatus, useSession, useLive, useWork, actions })
);
}
function useTranscriptView() {
- const [view, setView] = (0, import_react16.useState)(null);
- (0, import_react16.useEffect)(() => {
+ const [view, setView] = (0, import_react20.useState)(null);
+ (0, import_react20.useEffect)(() => {
let frame = 0;
let watched = null;
const observer = new MutationObserver(() => schedule());
@@ -9494,18 +9848,18 @@ function NewMessagePills({ sessionId, useSessions, useUi, useTurnClock }) {
});
const view = useTranscriptView();
const unpinned = view?.unpinned === true;
- const [release, setRelease] = (0, import_react16.useState)({ base: null, dismissed: false });
- const [above, setAbove] = (0, import_react16.useState)({ seen: false, dismissed: false });
- (0, import_react16.useEffect)(() => {
+ const [release, setRelease] = (0, import_react20.useState)({ base: null, dismissed: false });
+ const [above, setAbove] = (0, import_react20.useState)({ seen: false, dismissed: false });
+ (0, import_react20.useEffect)(() => {
setRelease({ base: unpinned ? replies : null, dismissed: false });
}, [unpinned]);
- (0, import_react16.useEffect)(() => {
+ (0, import_react20.useEffect)(() => {
if (view?.divider === "in-view") setAbove((state) => state.seen ? state : { ...state, seen: true });
}, [view?.divider]);
const fresh = release.base === null ? 0 : replies - release.base;
const showDown = unpinned && fresh > 0 && !release.dismissed;
const showUp = view?.divider === "above" && !above.seen && !above.dismissed;
- (0, import_react16.useEffect)(() => {
+ (0, import_react20.useEffect)(() => {
const scroller = document.querySelector("[data-conversation-scroll]");
if (!scroller) return void 0;
scroller.toggleAttribute("data-bt-news", showDown);
@@ -9513,16 +9867,16 @@ function NewMessagePills({ sessionId, useSessions, useUi, useTurnClock }) {
}, [showDown]);
if (!view || !showDown && !showUp) return null;
const label = (count) => count === 1 ? t("1 new message") : count > 0 ? t("{count} new messages", { count }) : t("New messages");
- const pill = (direction, count, style, onJump, onDismiss) => (0, import_react16.createElement)(
+ const pill = (direction, count, style, onJump, onDismiss) => (0, import_react20.createElement)(
"div",
{ className: "bt-news", "data-direction": direction, style },
- (0, import_react16.createElement)(
+ (0, import_react20.createElement)(
"button",
{ type: "button", className: "bt-news-jump", onClick: onJump },
- (0, import_react16.createElement)("span", { className: "bt-news-ico" }, (0, import_react16.createElement)(direction === "up" ? ArrowUpIcon : ArrowDownIcon)),
+ (0, import_react20.createElement)("span", { className: "bt-news-ico" }, (0, import_react20.createElement)(direction === "up" ? ArrowUpIcon : ArrowDownIcon)),
label(count)
),
- (0, import_react16.createElement)("button", {
+ (0, import_react20.createElement)("button", {
type: "button",
className: "bt-news-x",
"aria-label": t("Dismiss new messages"),
@@ -9530,7 +9884,7 @@ function NewMessagePills({ sessionId, useSessions, useUi, useTurnClock }) {
event.stopPropagation();
onDismiss();
}
- }, (0, import_react16.createElement)(CloseIcon))
+ }, (0, import_react20.createElement)(CloseIcon))
);
const toLatest = () => {
const scroller = document.querySelector("[data-conversation-scroll]");
@@ -9540,8 +9894,8 @@ function NewMessagePills({ sessionId, useSessions, useUi, useTurnClock }) {
};
const toDivider = () => document.querySelector("[data-conversation-scroll] .bt-new-sep")?.scrollIntoView({ block: "center", behavior: "smooth" });
return (0, import_react_dom4.createPortal)(
- (0, import_react16.createElement)(
- import_react16.Fragment,
+ (0, import_react20.createElement)(
+ import_react20.Fragment,
null,
showUp ? pill("up", unread, { left: view.center, top: view.top }, toDivider, () => setAbove((state) => ({ ...state, dismissed: true }))) : null,
showDown ? pill("down", fresh, { left: view.center, bottom: view.bottom }, toLatest, () => setRelease((state) => ({ ...state, dismissed: true }))) : null
@@ -9551,18 +9905,18 @@ function NewMessagePills({ sessionId, useSessions, useUi, useTurnClock }) {
}
// src/client/composer.js
-var import_react17 = require("react");
+var import_react21 = require("react");
var import_react_dom5 = require("react-dom");
var speechApi = () => window.SpeechRecognition ?? window.webkitSpeechRecognition;
var keepComposerFocus = (event) => event.preventDefault();
function useDictation(onText) {
- const [listening, setListening] = (0, import_react17.useState)(false);
- const [note, setNote] = (0, import_react17.useState)("");
- const recognition = (0, import_react17.useRef)(null);
- const latest = (0, import_react17.useRef)(onText);
+ const [listening, setListening] = (0, import_react21.useState)(false);
+ const [note, setNote] = (0, import_react21.useState)("");
+ const recognition = (0, import_react21.useRef)(null);
+ const latest = (0, import_react21.useRef)(onText);
latest.current = onText;
- (0, import_react17.useEffect)(() => () => recognition.current?.abort(), []);
- (0, import_react17.useEffect)(() => {
+ (0, import_react21.useEffect)(() => () => recognition.current?.abort(), []);
+ (0, import_react21.useEffect)(() => {
if (!note) return void 0;
const timer = setTimeout(() => setNote(""), 2600);
return () => clearTimeout(timer);
@@ -9615,7 +9969,7 @@ function ComposerVoice({ sessionId, inputActions, actions, useUi }) {
if (final && inputActions) inputActions.insertText(text, inputActions.captureInsertion());
});
const quote = useUi((state) => state.quote?.sessionId === sessionId ? state.quote : null);
- (0, import_react17.useEffect)(() => {
+ (0, import_react21.useEffect)(() => {
if (!quote || !inputActions) return;
actions.clearQuote(quote.token);
const excerpt = quote.text.replace(/\s+/g, " ").trim();
@@ -9633,10 +9987,10 @@ function ComposerVoice({ sessionId, inputActions, actions, useUi }) {
}, [quote?.token]);
if (sessionId === void 0) return null;
const pluginMic = actions.speech() !== void 0;
- return (0, import_react17.createElement)(
- import_react17.Fragment,
+ return (0, import_react21.createElement)(
+ import_react21.Fragment,
null,
- pluginMic ? null : (0, import_react17.createElement)("button", {
+ pluginMic ? null : (0, import_react21.createElement)("button", {
type: "button",
className: "bt-mic",
"aria-label": dictation.listening ? t("Stop dictation") : t("Dictate"),
@@ -9644,16 +9998,16 @@ function ComposerVoice({ sessionId, inputActions, actions, useUi }) {
title: dictation.listening ? t("Stop dictation") : t("Dictate"),
onMouseDown: keepComposerFocus,
onClick: () => dictation.listening ? dictation.stop() : dictation.start()
- }, (0, import_react17.createElement)(MicIcon)),
- (0, import_react17.createElement)("button", {
+ }, (0, import_react21.createElement)(MicIcon)),
+ (0, import_react21.createElement)("button", {
type: "button",
className: "bt-voice",
"aria-label": t("Start voice chat"),
title: t("Voice chat"),
onMouseDown: keepComposerFocus,
onClick: () => actions.openVoice(sessionId)
- }, (0, import_react17.createElement)(WaveIcon, { size: 18 })),
- dictation.note ? (0, import_react17.createElement)("span", { className: "bt-mic-note", role: "status" }, dictation.note) : null
+ }, (0, import_react21.createElement)(WaveIcon, { size: 18 })),
+ dictation.note ? (0, import_react21.createElement)("span", { className: "bt-mic-note", role: "status" }, dictation.note) : null
);
}
function menuIcons(roster) {
@@ -9661,18 +10015,18 @@ function menuIcons(roster) {
return (row) => {
if (!row.bot) return PeopleIcon;
const id = row.bot.id;
- if (!marks.has(id)) marks.set(id, ({ size = 14 }) => (0, import_react17.createElement)(BotMark, { bot: roster.getSnapshot().byId[id] ?? row.bot, size }));
+ if (!marks.has(id)) marks.set(id, ({ size = 14 }) => (0, import_react21.createElement)(BotMark, { bot: roster.getSnapshot().byId[id] ?? row.bot, size }));
return marks.get(id);
};
}
function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {
const roster = useRoster((value) => value);
- const [open, setOpen] = (0, import_react17.useState)(null);
+ const [open, setOpen] = (0, import_react21.useState)(null);
const [shown, leaving] = useLinger(open, 120);
- const button = (0, import_react17.useRef)(null);
- const menu = (0, import_react17.useRef)(null);
+ const button = (0, import_react21.useRef)(null);
+ const menu = (0, import_react21.useRef)(null);
const tick = useViewport();
- (0, import_react17.useEffect)(() => {
+ (0, import_react21.useEffect)(() => {
if (!open) return void 0;
const onDown = (event) => {
if (![button.current, menu.current].some((node) => node?.contains(event.target))) setOpen(null);
@@ -9713,15 +10067,15 @@ function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {
actions.referenceChat(sessionId, inputActions?.captureInsertion?.());
};
const canReference = typeof inputActions?.captureInsertion === "function" && actions.canReferenceChat();
- const place = (0, import_react17.useMemo)(() => {
+ const place = (0, import_react21.useMemo)(() => {
if (!shown || !button.current) return null;
const rect = button.current.getBoundingClientRect();
return { left: rect.left, bottom: viewBottom() - rect.top + 8 };
}, [shown, open, tick]);
- return (0, import_react17.createElement)(
- import_react17.Fragment,
+ return (0, import_react21.createElement)(
+ import_react21.Fragment,
null,
- (0, import_react17.createElement)("button", {
+ (0, import_react21.createElement)("button", {
ref: button,
type: "button",
className: "bt-plus",
@@ -9731,8 +10085,8 @@ function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {
"aria-expanded": Boolean(open),
onMouseDown: keepComposerFocus,
onClick: toggle
- }, (0, import_react17.createElement)(PlusIcon)),
- shown ? (0, import_react_dom5.createPortal)((0, import_react17.createElement)(
+ }, (0, import_react21.createElement)(PlusIcon)),
+ shown ? (0, import_react_dom5.createPortal)((0, import_react21.createElement)(
"div",
{
ref: menu,
@@ -9742,9 +10096,9 @@ function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {
style: place ?? {},
"data-leaving": leaving || void 0
},
- shown.files ? (0, import_react17.createElement)("button", { type: "button", role: "menuitem", onClick: attach }, (0, import_react17.createElement)(PaperclipIcon), (0, import_react17.createElement)("span", { className: "bt-menu-label" }, t("Add files"))) : null,
- canReference ? (0, import_react17.createElement)("button", { type: "button", role: "menuitem", onMouseDown: keepComposerFocus, onClick: reference }, (0, import_react17.createElement)(ChatsIcon), (0, import_react17.createElement)("span", { className: "bt-menu-label" }, t("Reference a chat"))) : null,
- (0, import_react17.createElement)("button", { type: "button", role: "menuitem", onClick: schedule }, (0, import_react17.createElement)(ClockIcon), (0, import_react17.createElement)("span", { className: "bt-menu-label" }, t("Scheduled task")))
+ shown.files ? (0, import_react21.createElement)("button", { type: "button", role: "menuitem", onClick: attach }, (0, import_react21.createElement)(PaperclipIcon), (0, import_react21.createElement)("span", { className: "bt-menu-label" }, t("Add files"))) : null,
+ canReference ? (0, import_react21.createElement)("button", { type: "button", role: "menuitem", onMouseDown: keepComposerFocus, onClick: reference }, (0, import_react21.createElement)(ChatsIcon), (0, import_react21.createElement)("span", { className: "bt-menu-label" }, t("Reference a chat"))) : null,
+ (0, import_react21.createElement)("button", { type: "button", role: "menuitem", onClick: schedule }, (0, import_react21.createElement)(ClockIcon), (0, import_react21.createElement)("span", { className: "bt-menu-label" }, t("Scheduled task")))
), document.body) : null
);
}
@@ -9970,9 +10324,9 @@ function drawerMenuKeys({ bot, room: room2, canBrowse, canTerminal, canFiles })
}
// src/client/side-chat.js
-var import_react18 = require("react");
+var import_react22 = require("react");
function SideEntry({ chatId, entry, actions }) {
- const [cancelling, setCancelling] = (0, import_react18.useState)(false);
+ const [cancelling, setCancelling] = (0, import_react22.useState)(false);
const question = typeof entry.question === "string" ? entry.question : "";
const answer = typeof entry.answer === "string" ? entry.answer : "";
const cancel = () => {
@@ -9981,15 +10335,15 @@ function SideEntry({ chatId, entry, actions }) {
Promise.resolve(actions.cancelSide(chatId, entry.id)).catch(() => {
}).finally(() => setCancelling(false));
};
- return (0, import_react18.createElement)(
+ return (0, import_react22.createElement)(
"div",
{ className: "bt-side-pair", "data-status": entry.status },
- (0, import_react18.createElement)("div", { className: "bt-side-qrow" }, (0, import_react18.createElement)("div", { className: "bt-side-q" }, question)),
- entry.status === "answering" ? (0, import_react18.createElement)(
+ (0, import_react22.createElement)("div", { className: "bt-side-qrow" }, (0, import_react22.createElement)("div", { className: "bt-side-q" }, question)),
+ entry.status === "answering" ? (0, import_react22.createElement)(
"div",
{ className: "bt-side-a" },
- (0, import_react18.createElement)("span", { className: "bt-shimmer" }, t("Answering…")),
- (0, import_react18.createElement)("button", {
+ (0, import_react22.createElement)("span", { className: "bt-shimmer" }, t("Answering…")),
+ (0, import_react22.createElement)("button", {
type: "button",
className: "bt-soft bt-soft-sm",
disabled: cancelling,
@@ -9997,23 +10351,23 @@ function SideEntry({ chatId, entry, actions }) {
"aria-label": t("Cancel this side question"),
onClick: cancel
}, t("Cancel"))
- ) : (0, import_react18.createElement)(
+ ) : (0, import_react22.createElement)(
"div",
{ className: "bt-side-a" },
- entry.status === "cancelled" ? (0, import_react18.createElement)("p", { className: "bt-side-status" }, t("Cancelled")) : null,
- entry.status === "failed" ? (0, import_react18.createElement)("p", { className: "bt-side-fail" }, failureText(entry)) : null,
- answer !== "" ? (0, import_react18.createElement)(import_dsh_client_ui_primitives.MarkdownText, { text: answer, labels: mdLabels2(), variant: "compact" }) : null
+ entry.status === "cancelled" ? (0, import_react22.createElement)("p", { className: "bt-side-status" }, t("Cancelled")) : null,
+ entry.status === "failed" ? (0, import_react22.createElement)("p", { className: "bt-side-fail" }, failureText(entry)) : null,
+ answer !== "" ? (0, import_react22.createElement)(import_dsh_client_ui_primitives.MarkdownText, { text: answer, labels: mdLabels2(), variant: "compact" }) : null
)
);
}
function SideChatView({ subject, chat, actions }) {
- const scroll = (0, import_react18.useRef)(null);
- const [draft, setDraft] = (0, import_react18.useState)("");
- const [fail2, setFail] = (0, import_react18.useState)(null);
+ const scroll = (0, import_react22.useRef)(null);
+ const [draft, setDraft] = (0, import_react22.useState)("");
+ const [fail2, setFail] = (0, import_react22.useState)(null);
const entries2 = Array.isArray(chat?.entries) ? chat.entries : [];
const busy = entries2.some((entry) => entry?.status === "answering");
const last = entries2.at(-1);
- (0, import_react18.useEffect)(() => {
+ (0, import_react22.useEffect)(() => {
const node = scroll.current;
if (node) node.scrollTop = node.scrollHeight;
}, [chat?.id, entries2.length, last?.status]);
@@ -10028,19 +10382,19 @@ function SideChatView({ subject, chat, actions }) {
setFail(hostText(error?.message ?? ""));
});
};
- return (0, import_react18.createElement)(
+ return (0, import_react22.createElement)(
"div",
{ className: "bt-side" },
- (0, import_react18.createElement)("p", { className: "bt-side-note" }, t("Answered from progress so far; nothing was run")),
- (0, import_react18.createElement)(
+ (0, import_react22.createElement)("p", { className: "bt-side-note" }, t("Answered from progress so far; nothing was run")),
+ (0, import_react22.createElement)(
"div",
{ className: "bt-side-scroll", ref: scroll },
- entries2.map((entry) => (0, import_react18.createElement)(SideEntry, { key: entry.id, chatId: chat.id, entry, actions }))
+ entries2.map((entry) => (0, import_react22.createElement)(SideEntry, { key: entry.id, chatId: chat.id, entry, actions }))
),
- (0, import_react18.createElement)(
+ (0, import_react22.createElement)(
"div",
{ className: "bt-side-form" },
- (0, import_react18.createElement)("textarea", {
+ (0, import_react22.createElement)("textarea", {
className: "bt-side-input",
rows: 1,
value: draft,
@@ -10057,7 +10411,7 @@ function SideChatView({ subject, chat, actions }) {
ask();
}
}),
- fail2 !== null ? (0, import_react18.createElement)("p", { className: "bt-side-fail" }, fail2) : null
+ fail2 !== null ? (0, import_react22.createElement)("p", { className: "bt-side-fail" }, fail2) : null
)
);
}
@@ -10444,15 +10798,15 @@ function installHeaderNavigation(slots, face, component, priority) {
}
// src/client/overlay-hooks.js
-var import_react19 = require("react");
+var import_react23 = require("react");
var escapeLayers = [];
var onEscapeKey = (event) => {
if (event.key === "Escape") escapeLayers.at(-1)?.current();
};
function useEscape(onClose) {
- const ref = (0, import_react19.useRef)(onClose);
+ const ref = (0, import_react23.useRef)(onClose);
ref.current = onClose;
- (0, import_react19.useEffect)(() => {
+ (0, import_react23.useEffect)(() => {
if (escapeLayers.length === 0) window.addEventListener("keydown", onEscapeKey);
escapeLayers.push(ref);
return () => {
@@ -10462,8 +10816,8 @@ function useEscape(onClose) {
}, []);
}
function usePaneLeft() {
- const [paneLeft, setPaneLeft] = (0, import_react19.useState)(280);
- (0, import_react19.useLayoutEffect)(() => {
+ const [paneLeft, setPaneLeft] = (0, import_react23.useState)(280);
+ (0, import_react23.useLayoutEffect)(() => {
const column = document.querySelector('[class*="_footArea"]')?.parentElement;
if (column) setPaneLeft(Math.round(column.getBoundingClientRect().right));
}, []);
@@ -10471,12 +10825,12 @@ function usePaneLeft() {
}
// src/client/palette.js
-var import_react20 = require("react");
+var import_react24 = require("react");
var PALETTE_EXIT_MS = 160;
function CommandPalette({ start, token, roster, actions, useSessions }) {
- const [query, setQuery] = (0, import_react20.useState)(start ?? "");
- const [cursor, setCursor] = (0, import_react20.useState)(0);
- const [leaving, setLeaving] = (0, import_react20.useState)(false);
+ const [query, setQuery] = (0, import_react24.useState)(start ?? "");
+ const [cursor, setCursor] = (0, import_react24.useState)(0);
+ const [leaving, setLeaving] = (0, import_react24.useState)(false);
const wanted = query.trim().toLowerCase();
const close = () => {
if (leaving) return;
@@ -10512,7 +10866,7 @@ function CommandPalette({ start, token, roster, actions, useSessions }) {
const people = [
...roster.bots.filter((bot) => matchesName(bot.name, bot.role)).map((bot) => ({
key: bot.id,
- avatar: (0, import_react20.createElement)(BotAvatar, { bot, size: 24, badge: false, live: false }),
+ avatar: (0, import_react24.createElement)(BotAvatar, { bot, size: 24, badge: false, live: false }),
title: bot.name,
subtitle: [bot.role, isMainOf(roster, bot.id) ? t("Main Bot") : ""].filter(Boolean).join(" · "),
badge: bot.hidden ? t("Hidden") : void 0,
@@ -10523,7 +10877,7 @@ function CommandPalette({ start, token, roster, actions, useSessions }) {
})),
...roster.rooms.filter((room2) => matchesName(room2.name)).map((room2) => ({
key: room2.id,
- avatar: (0, import_react20.createElement)(RoomAvatar, { room: room2, roster, size: 24 }),
+ avatar: (0, import_react24.createElement)(RoomAvatar, { room: room2, roster, size: 24 }),
title: room2.name,
subtitle: t("{count} members", { count: room2.members.length }),
badge: room2.hidden ? t("Hidden") : void 0,
@@ -10536,7 +10890,7 @@ function CommandPalette({ start, token, roster, actions, useSessions }) {
if (people.length) sections.push([t("Bots"), people]);
const agents = (roster.agents ?? []).filter(() => matchesName("DSH Agent")).map((agent) => ({
key: agent.id,
- avatar: (0, import_react20.createElement)("span", { className: "bt-palette-agent" }, (0, import_react20.createElement)(import_dsh_client_ui_primitives.FishLogo, { size: 18 })),
+ avatar: (0, import_react24.createElement)("span", { className: "bt-palette-agent" }, (0, import_react24.createElement)(import_dsh_client_ui_primitives.FishLogo, { size: 18 })),
title: "DSH Agent",
subtitle: t("Plain dsh session"),
run: () => actions.openAgent(agent.id)
@@ -10549,16 +10903,16 @@ function CommandPalette({ start, token, roster, actions, useSessions }) {
key: `${id}:${turn}`,
title: bot?.name ?? room2?.name ?? t("Bot"),
subtitle: snippet,
- avatar: bot ? (0, import_react20.createElement)(BotAvatar, { bot, size: 24, badge: false, live: false }) : (0, import_react20.createElement)(RoomAvatar, { room: room2, roster, size: 24 }),
+ avatar: bot ? (0, import_react24.createElement)(BotAvatar, { bot, size: 24, badge: false, live: false }) : (0, import_react24.createElement)(RoomAvatar, { room: room2, roster, size: 24 }),
run: () => actions.openSession(id)
};
});
if (messages.length) sections.push([t("Messages"), messages]);
const commands = [
- { key: "cmd:new", icon: (0, import_react20.createElement)(PlusIcon), title: t("New chat"), run: () => actions.openNewChat("new") },
- { key: "cmd:bot", icon: (0, import_react20.createElement)(PlusIcon), title: t("Create Bot"), run: () => actions.openNewChat("create") },
- { key: "cmd:group", icon: (0, import_react20.createElement)(PeopleIcon), title: t("Create group chat"), run: () => actions.openNewChat("group") },
- { key: "cmd:settings", icon: (0, import_react20.createElement)(GearIcon), title: t("Bot settings"), run: () => actions.openSettings("general") }
+ { key: "cmd:new", icon: (0, import_react24.createElement)(PlusIcon), title: t("New chat"), run: () => actions.openNewChat("new") },
+ { key: "cmd:bot", icon: (0, import_react24.createElement)(PlusIcon), title: t("Create Bot"), run: () => actions.openNewChat("create") },
+ { key: "cmd:group", icon: (0, import_react24.createElement)(PeopleIcon), title: t("Create group chat"), run: () => actions.openNewChat("group") },
+ { key: "cmd:settings", icon: (0, import_react24.createElement)(GearIcon), title: t("Bot settings"), run: () => actions.openSettings("general") }
].filter((command) => matchesName(command.title));
if (commands.length) sections.push([t("Commands"), commands]);
const rows2 = sections.flatMap(([, items]) => items);
@@ -10568,7 +10922,7 @@ function CommandPalette({ start, token, roster, actions, useSessions }) {
${shown}`, { axis: "y", ...QUICK_EDGES });
const listRef = glide.box;
useFlip(listRef, shown, "[data-flip]");
- (0, import_react20.useEffect)(() => {
+ (0, import_react24.useEffect)(() => {
listRef.current?.querySelector("[aria-selected=true]")?.scrollIntoView({ block: "nearest" });
}, [active, query]);
const choose = (row) => {
@@ -10577,18 +10931,18 @@ ${shown}`, { axis: "y", ...QUICK_EDGES });
close();
};
let index = -1;
- return (0, import_react20.createElement)(
+ return (0, import_react24.createElement)(
"div",
{ className: "bt-palette-layer", "data-leaving": leaving || void 0 },
- (0, import_react20.createElement)("div", { className: "bt-backdrop", onMouseDown: close }),
- (0, import_react20.createElement)(
+ (0, import_react24.createElement)("div", { className: "bt-backdrop", onMouseDown: close }),
+ (0, import_react24.createElement)(
"div",
{ className: "bt-palette", role: "dialog", "aria-label": t("Search"), "aria-modal": true },
- (0, import_react20.createElement)(
+ (0, import_react24.createElement)(
"div",
{ className: "bt-palette-head" },
- (0, import_react20.createElement)("span", { className: "bt-palette-glyph", "aria-hidden": true }, (0, import_react20.createElement)(SearchIcon)),
- (0, import_react20.createElement)("input", {
+ (0, import_react24.createElement)("span", { className: "bt-palette-glyph", "aria-hidden": true }, (0, import_react24.createElement)(SearchIcon)),
+ (0, import_react24.createElement)("input", {
autoFocus: true,
value: query,
placeholder: t("Search Bots, chats and messages"),
@@ -10614,29 +10968,29 @@ ${shown}`, { axis: "y", ...QUICK_EDGES });
}
}
}),
- query ? (0, import_react20.createElement)("button", { type: "button", className: "bt-palette-clear", "aria-label": t("Clear search"), onClick: () => {
+ query ? (0, import_react24.createElement)("button", { type: "button", className: "bt-palette-clear", "aria-label": t("Clear search"), onClick: () => {
setQuery("");
setCursor(0);
- } }, (0, import_react20.createElement)(CloseIcon)) : null
+ } }, (0, import_react24.createElement)(CloseIcon)) : null
),
- (0, import_react20.createElement)(
+ (0, import_react24.createElement)(
"div",
{ ref: listRef, id: "bt-palette-list", className: "bt-palette-list", role: "listbox", "aria-label": t("Results") },
- (0, import_react20.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),
- rows2.length === 0 ? (0, import_react20.createElement)(
+ (0, import_react24.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),
+ rows2.length === 0 ? (0, import_react24.createElement)(
"div",
{ className: "bt-palette-empty" },
- (0, import_react20.createElement)("span", { className: "bt-palette-empty-icon", "aria-hidden": true }, (0, import_react20.createElement)(SearchIcon)),
- (0, import_react20.createElement)("span", { className: "bt-palette-empty-label" }, t("No results")),
- (0, import_react20.createElement)("span", { className: "bt-palette-empty-hint" }, t("Try a Bot name or words from a message"))
- ) : sections.map(([title, items]) => (0, import_react20.createElement)(
- import_react20.Fragment,
+ (0, import_react24.createElement)("span", { className: "bt-palette-empty-icon", "aria-hidden": true }, (0, import_react24.createElement)(SearchIcon)),
+ (0, import_react24.createElement)("span", { className: "bt-palette-empty-label" }, t("No results")),
+ (0, import_react24.createElement)("span", { className: "bt-palette-empty-hint" }, t("Try a Bot name or words from a message"))
+ ) : sections.map(([title, items]) => (0, import_react24.createElement)(
+ import_react24.Fragment,
{ key: title },
- (0, import_react20.createElement)("div", { className: "bt-palette-section", role: "presentation", "data-flip": `section:${title}` }, title),
+ (0, import_react24.createElement)("div", { className: "bt-palette-section", role: "presentation", "data-flip": `section:${title}` }, title),
items.map((row) => {
index += 1;
const at = index;
- return (0, import_react20.createElement)(
+ return (0, import_react24.createElement)(
"button",
{
key: row.key,
@@ -10650,14 +11004,14 @@ ${shown}`, { axis: "y", ...QUICK_EDGES });
},
onClick: () => choose(row)
},
- (0, import_react20.createElement)("span", { className: "bt-palette-lead" }, row.avatar ?? (0, import_react20.createElement)("span", { className: "bt-palette-cmd" }, row.icon)),
- (0, import_react20.createElement)(
+ (0, import_react24.createElement)("span", { className: "bt-palette-lead" }, row.avatar ?? (0, import_react24.createElement)("span", { className: "bt-palette-cmd" }, row.icon)),
+ (0, import_react24.createElement)(
"span",
{ className: "bt-palette-text" },
- (0, import_react20.createElement)("span", { className: "bt-palette-title" }, row.title),
- row.subtitle ? (0, import_react20.createElement)("span", { className: "bt-palette-sub" }, row.subtitle) : null
+ (0, import_react24.createElement)("span", { className: "bt-palette-title" }, row.title),
+ row.subtitle ? (0, import_react24.createElement)("span", { className: "bt-palette-sub" }, row.subtitle) : null
),
- row.badge ? (0, import_react20.createElement)("span", { className: "bt-palette-badge" }, row.badge) : null
+ row.badge ? (0, import_react24.createElement)("span", { className: "bt-palette-badge" }, row.badge) : null
);
})
))
@@ -10667,7 +11021,7 @@ ${shown}`, { axis: "y", ...QUICK_EDGES });
}
// src/client/model-menu.js
-var import_react21 = require("react");
+var import_react25 = require("react");
var import_react_dom6 = require("react-dom");
var MENU_EXIT_MS = 120;
function groupModels(models) {
@@ -10697,8 +11051,8 @@ function modelOf(bot, roster) {
}
var effortCache = /* @__PURE__ */ new Map();
function useEfforts(served, ref, actions) {
- const [fetched, setFetched] = (0, import_react21.useState)(void 0);
- (0, import_react21.useEffect)(() => {
+ const [fetched, setFetched] = (0, import_react25.useState)(void 0);
+ (0, import_react25.useEffect)(() => {
setFetched(void 0);
if (ref === void 0 || served?.reasoning !== void 0 || actions?.efforts === void 0) return void 0;
let live = true;
@@ -10723,12 +11077,12 @@ function effortRows(reasoning) {
];
}
function EffortRows({ reasoning, current, onPick }) {
- return (0, import_react21.createElement)(
- import_react21.Fragment,
+ return (0, import_react25.createElement)(
+ import_react25.Fragment,
null,
- (0, import_react21.createElement)("div", { className: "bt-menu-sep", role: "separator" }),
- (0, import_react21.createElement)("div", { className: "bt-model-group", role: "presentation" }, t("Thinking level")),
- effortRows(reasoning).map((row) => (0, import_react21.createElement)(
+ (0, import_react25.createElement)("div", { className: "bt-menu-sep", role: "separator" }),
+ (0, import_react25.createElement)("div", { className: "bt-model-group", role: "presentation" }, t("Thinking level")),
+ effortRows(reasoning).map((row) => (0, import_react25.createElement)(
"button",
{
key: row.effort ?? "default",
@@ -10737,17 +11091,17 @@ function EffortRows({ reasoning, current, onPick }) {
"aria-checked": (row.effort ?? null) === (current ?? null),
onClick: () => onPick(row.effort)
},
- (0, import_react21.createElement)("span", { className: "bt-menu-label" }, row.label),
- (0, import_react21.createElement)("span", { className: "bt-model-tick", "aria-hidden": true }, (row.effort ?? null) === (current ?? null) ? (0, import_react21.createElement)(CheckIcon) : null)
+ (0, import_react25.createElement)("span", { className: "bt-menu-label" }, row.label),
+ (0, import_react25.createElement)("span", { className: "bt-model-tick", "aria-hidden": true }, (row.effort ?? null) === (current ?? null) ? (0, import_react25.createElement)(CheckIcon) : null)
))
);
}
function ModelRows({ roster, current, onPick }) {
- return groupModels(roster.models).map(([provider, list]) => (0, import_react21.createElement)(
- import_react21.Fragment,
+ return groupModels(roster.models).map(([provider, list]) => (0, import_react25.createElement)(
+ import_react25.Fragment,
{ key: list[0].provider ?? provider },
- (0, import_react21.createElement)("div", { className: "bt-model-group", role: "presentation" }, provider),
- list.map((model) => (0, import_react21.createElement)(
+ (0, import_react25.createElement)("div", { className: "bt-model-group", role: "presentation" }, provider),
+ list.map((model) => (0, import_react25.createElement)(
"button",
{
key: model.ref,
@@ -10757,25 +11111,25 @@ function ModelRows({ roster, current, onPick }) {
title: model.ref,
onClick: () => onPick(model.ref)
},
- (0, import_react21.createElement)("span", { className: "bt-menu-label" }, model.name),
- model.ref === roster.defaultModel ? (0, import_react21.createElement)("span", { className: "bt-menu-hint" }, t("Default")) : null,
- (0, import_react21.createElement)("span", { className: "bt-model-tick", "aria-hidden": true }, model.ref === current ? (0, import_react21.createElement)(CheckIcon) : null)
+ (0, import_react25.createElement)("span", { className: "bt-menu-label" }, model.name),
+ model.ref === roster.defaultModel ? (0, import_react25.createElement)("span", { className: "bt-menu-hint" }, t("Default")) : null,
+ (0, import_react25.createElement)("span", { className: "bt-model-tick", "aria-hidden": true }, model.ref === current ? (0, import_react25.createElement)(CheckIcon) : null)
))
));
}
-var Caret = () => (0, import_react21.createElement)("svg", { className: "bt-model-caret", width: 12, height: 12, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true }, (0, import_react21.createElement)("path", { d: "M5.5 8l4.5 4.5L14.5 8" }));
+var Caret = () => (0, import_react25.createElement)("svg", { className: "bt-model-caret", width: 12, height: 12, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true }, (0, import_react25.createElement)("path", { d: "M5.5 8l4.5 4.5L14.5 8" }));
function useAnchoredMenu() {
- const [anchor, setAnchor] = (0, import_react21.useState)(null);
- const [place, setPlace] = (0, import_react21.useState)(null);
+ const [anchor, setAnchor] = (0, import_react25.useState)(null);
+ const [place, setPlace] = (0, import_react25.useState)(null);
const [shownPlace, leaving] = useLinger(place, MENU_EXIT_MS);
- const button = (0, import_react21.useRef)(null);
- const menu = (0, import_react21.useRef)(null);
+ const button = (0, import_react25.useRef)(null);
+ const menu = (0, import_react25.useRef)(null);
const tick = useViewport();
const close = () => {
setAnchor(null);
setPlace(null);
};
- (0, import_react21.useEffect)(() => {
+ (0, import_react25.useEffect)(() => {
if (place === null) return void 0;
const onDown = (event) => {
if (menu.current?.contains(event.target) || button.current?.contains(event.target)) return;
@@ -10801,7 +11155,7 @@ function useAnchoredMenu() {
};
}, [place]);
const open = () => setAnchor({});
- (0, import_react21.useLayoutEffect)(() => {
+ (0, import_react25.useLayoutEffect)(() => {
if (anchor === null || !button.current) return;
const rect = button.current.getBoundingClientRect();
const width = Math.max(240, rect.width);
@@ -10840,10 +11194,10 @@ function ModelMenu({ bot, roster, actions, run: run2, wide = false, onPick, onPi
};
const models = roster.models ?? [];
const manage = manageModels(actions);
- return (0, import_react21.createElement)(
- import_react21.Fragment,
+ return (0, import_react25.createElement)(
+ import_react25.Fragment,
null,
- (0, import_react21.createElement)(
+ (0, import_react25.createElement)(
"button",
{
ref: button,
@@ -10856,34 +11210,34 @@ function ModelMenu({ bot, roster, actions, run: run2, wide = false, onPick, onPi
"data-missing": shown !== void 0 && !shown.served && models.length > 0 ? "" : void 0,
onClick: toggle
},
- (0, import_react21.createElement)(
+ (0, import_react25.createElement)(
"span",
{ className: "bt-model-copy" },
- (0, import_react21.createElement)("span", { className: "bt-model-name" }, shown?.name ?? t("Choose a model")),
- shown ? (0, import_react21.createElement)("span", { className: "bt-model-provider" }, shown.served || models.length === 0 ? effortLabel === void 0 ? shown.provider : `${shown.provider} · ${effortLabel}` : t("{provider} · not available", { provider: shown.provider })) : null
+ (0, import_react25.createElement)("span", { className: "bt-model-name" }, shown?.name ?? t("Choose a model")),
+ shown ? (0, import_react25.createElement)("span", { className: "bt-model-provider" }, shown.served || models.length === 0 ? effortLabel === void 0 ? shown.provider : `${shown.provider} · ${effortLabel}` : t("{provider} · not available", { provider: shown.provider })) : null
),
- (0, import_react21.createElement)(Caret)
+ (0, import_react25.createElement)(Caret)
),
- shownPlace ? (0, import_react_dom6.createPortal)((0, import_react21.createElement)(
+ shownPlace ? (0, import_react_dom6.createPortal)((0, import_react25.createElement)(
"div",
{ ref: menu, className: `bt-menu bt-model-menu${shownPlace.bottom !== void 0 ? " bt-menu-up" : ""}`, role: "menu", "aria-label": t("Model for {name}", { name: bot.name }), style: shownPlace, "data-leaving": leaving || void 0 },
- models.length > 0 ? (0, import_react21.createElement)(ModelRows, { roster, current, onPick: pick2 }) : (0, import_react21.createElement)("div", { className: "bt-model-none" }, t("No models are set up in DeepSeek Harness yet.")),
- effortRows(reasoning).length > 0 ? (0, import_react21.createElement)(EffortRows, { reasoning, current: picked, onPick: pickEffort }) : null,
- manage ? (0, import_react21.createElement)("div", { className: "bt-menu-sep", role: "separator" }) : null,
- manage ? (0, import_react21.createElement)("button", { type: "button", role: "menuitem", onClick: () => {
+ models.length > 0 ? (0, import_react25.createElement)(ModelRows, { roster, current, onPick: pick2 }) : (0, import_react25.createElement)("div", { className: "bt-model-none" }, t("No models are set up in DeepSeek Harness yet.")),
+ effortRows(reasoning).length > 0 ? (0, import_react25.createElement)(EffortRows, { reasoning, current: picked, onPick: pickEffort }) : null,
+ manage ? (0, import_react25.createElement)("div", { className: "bt-menu-sep", role: "separator" }) : null,
+ manage ? (0, import_react25.createElement)("button", { type: "button", role: "menuitem", onClick: () => {
close();
manage();
- } }, (0, import_react21.createElement)(SlidersIcon), (0, import_react21.createElement)("span", { className: "bt-menu-label" }, t("Models and providers…"))) : null
+ } }, (0, import_react25.createElement)(SlidersIcon), (0, import_react25.createElement)("span", { className: "bt-menu-label" }, t("Models and providers…"))) : null
), document.body) : null
);
}
function ModelChoiceDock({ sessionId, useRoster, actions }) {
const roster = useRoster((value) => value);
const bot = roster.byId[sessionId];
- const [busy, setBusy] = (0, import_react21.useState)("");
- const [error, setError] = (0, import_react21.useState)("");
+ const [busy, setBusy] = (0, import_react25.useState)("");
+ const [error, setError] = (0, import_react25.useState)("");
const shown = Boolean(bot) && currentPart(bot) === sessionId && roster.ready;
- (0, import_react21.useEffect)(() => {
+ (0, import_react25.useEffect)(() => {
if (shown) void actions.refreshModels?.();
}, [shown, sessionId]);
if (!bot || currentPart(bot) !== sessionId || !roster.ready) return null;
@@ -10902,12 +11256,12 @@ function ModelChoiceDock({ sessionId, useRoster, actions }) {
}).finally(() => setBusy(""));
};
const text = lost ? t("{model} is not available anymore. Pick another model for me.", { model: bot.model.split("/").slice(1).join("/") }) : keyFor ? t("Hi, I'm {name}. I need a {provider} API key before I can start.", { name: bot.name, provider: keyFor.providerName ?? keyFor.provider }) : usable.length === 0 ? t("Hi, I'm {name}. I don't have a model yet. How do you want to set one up?", { name: bot.name }) : t("Hi, I'm {name}. Pick a model for me first. You can change it later in my details.", { name: bot.name });
- const choices = usable.length === 0 ? setupChoices(actions).map(([label, run2]) => (0, import_react21.createElement)("button", { key: label, type: "button", className: "bt-model-chip", onClick: run2 }, label)) : [
- ...groupModels(usable).map(([provider, list]) => (0, import_react21.createElement)(
+ const choices = usable.length === 0 ? setupChoices(actions).map(([label, run2]) => (0, import_react25.createElement)("button", { key: label, type: "button", className: "bt-model-chip", onClick: run2 }, label)) : [
+ ...groupModels(usable).map(([provider, list]) => (0, import_react25.createElement)(
"div",
{ key: list[0].provider ?? provider, className: "bt-model-choice-group", role: "group", "aria-label": provider },
- (0, import_react21.createElement)("div", { className: "bt-model-choice-provider", "aria-hidden": true }, provider),
- (0, import_react21.createElement)("div", { className: "bt-model-choice-chips" }, list.map((model) => (0, import_react21.createElement)("button", {
+ (0, import_react25.createElement)("div", { className: "bt-model-choice-provider", "aria-hidden": true }, provider),
+ (0, import_react25.createElement)("div", { className: "bt-model-choice-chips" }, list.map((model) => (0, import_react25.createElement)("button", {
key: model.ref,
type: "button",
className: "bt-model-chip",
@@ -10916,35 +11270,35 @@ function ModelChoiceDock({ sessionId, useRoster, actions }) {
"aria-label": `${model.name} · ${provider}`,
title: model.ref === roster.defaultModel ? `${model.ref} · ${t("Harness default")}` : model.ref,
onClick: () => pick2(model.ref)
- }, model.name, busy === model.ref ? (0, import_react21.createElement)("span", { className: "bt-model-spin", "aria-label": t("Saving…") }) : null)))
+ }, model.name, busy === model.ref ? (0, import_react25.createElement)("span", { className: "bt-model-spin", "aria-label": t("Saving…") }) : null)))
)),
- manage ? (0, import_react21.createElement)("button", { key: "manage", type: "button", className: "bt-model-chip bt-model-chip-quiet", onClick: manage }, (0, import_react21.createElement)(SlidersIcon), t("Manage models")) : null
+ manage ? (0, import_react25.createElement)("button", { key: "manage", type: "button", className: "bt-model-chip bt-model-chip-quiet", onClick: manage }, (0, import_react25.createElement)(SlidersIcon), t("Manage models")) : null
];
- return (0, import_react21.createElement)(
+ return (0, import_react25.createElement)(
"div",
{ className: "bt-model-dock" },
- (0, import_react21.createElement)(
+ (0, import_react25.createElement)(
"div",
{ className: "bt-astack", "data-lead": "" },
- (0, import_react21.createElement)(
+ (0, import_react25.createElement)(
"div",
{ className: "bt-msg" },
- (0, import_react21.createElement)(
+ (0, import_react25.createElement)(
"div",
{ className: "bt-msg-line" },
- (0, import_react21.createElement)(BotMark, { bot, size: 22 }),
- (0, import_react21.createElement)("div", { className: "bt-bubble" }, text)
+ (0, import_react25.createElement)(BotMark, { bot, size: 22 }),
+ (0, import_react25.createElement)("div", { className: "bt-bubble" }, text)
)
)
),
- keyFor ? (0, import_react21.createElement)(ModelKeyCard, { key: keyFor.provider, model: keyFor, actions }) : (0, import_react21.createElement)("div", { className: "bt-model-chips", role: "group", "aria-label": t("Choose a model") }, choices),
- error ? (0, import_react21.createElement)("div", { className: "bt-secret-error bt-model-error", role: "alert" }, error) : null
+ keyFor ? (0, import_react25.createElement)(ModelKeyCard, { key: keyFor.provider, model: keyFor, actions }) : (0, import_react25.createElement)("div", { className: "bt-model-chips", role: "group", "aria-label": t("Choose a model") }, choices),
+ error ? (0, import_react25.createElement)("div", { className: "bt-secret-error bt-model-error", role: "alert" }, error) : null
);
}
function ModelKeyCard({ model, actions }) {
- const [value, setValue] = (0, import_react21.useState)("");
- const [busy, setBusy] = (0, import_react21.useState)(false);
- const [error, setError] = (0, import_react21.useState)("");
+ const [value, setValue] = (0, import_react25.useState)("");
+ const [busy, setBusy] = (0, import_react25.useState)(false);
+ const [error, setError] = (0, import_react25.useState)("");
const label = t("{provider} API key", { provider: model.providerName ?? model.provider });
const ready = value.trim() !== "" && !busy;
const save = () => {
@@ -10953,17 +11307,17 @@ function ModelKeyCard({ model, actions }) {
setError("");
void Promise.resolve(actions.setProviderKey(model.provider, value)).then(() => setValue(""), (failure) => setError(hostText(failure?.message ?? String(failure)))).finally(() => setBusy(false));
};
- return (0, import_react21.createElement)(
+ return (0, import_react25.createElement)(
"div",
{ className: "bt-q bt-model-key", role: "group", "aria-label": label },
- (0, import_react21.createElement)("div", { className: "bt-model-key-title" }, (0, import_react21.createElement)(KeyIcon), label),
- (0, import_react21.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react21.createElement)(MaskedInput, { value, onChange: setValue, onEnter: save, label, autoFocus: true })),
- error ? (0, import_react21.createElement)("div", { className: "bt-secret-error", role: "alert" }, error) : null,
- (0, import_react21.createElement)(
+ (0, import_react25.createElement)("div", { className: "bt-model-key-title" }, (0, import_react25.createElement)(KeyIcon), label),
+ (0, import_react25.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react25.createElement)(MaskedInput, { value, onChange: setValue, onEnter: save, label, autoFocus: true })),
+ error ? (0, import_react25.createElement)("div", { className: "bt-secret-error", role: "alert" }, error) : null,
+ (0, import_react25.createElement)(
"div",
{ className: "bt-q-foot" },
- actions.openModels ? (0, import_react21.createElement)("button", { type: "button", className: "bt-q-btn bt-model-key-other", onClick: actions.openModels }, t("Another provider")) : null,
- (0, import_react21.createElement)("button", { type: "button", className: "bt-q-submit", disabled: !ready, onClick: save }, busy ? t("Saving…") : t("Save"))
+ actions.openModels ? (0, import_react25.createElement)("button", { type: "button", className: "bt-q-btn bt-model-key-other", onClick: actions.openModels }, t("Another provider")) : null,
+ (0, import_react25.createElement)("button", { type: "button", className: "bt-q-submit", disabled: !ready, onClick: save }, busy ? t("Saving…") : t("Save"))
)
);
}
@@ -10979,14 +11333,14 @@ function DeepSeekSignIn({ useUi, actions }) {
const open = useUi((state) => state.signIn);
const entry = open ? actions.signInEntry?.() : null;
if (!entry) return null;
- return (0, import_react21.createElement)(SignInHost, { key: open, entry, actions });
+ return (0, import_react25.createElement)(SignInHost, { key: open, entry, actions });
}
function SignInHost({ entry, actions }) {
- const [ops] = (0, import_react21.useState)(() => entry.inject?.() ?? {});
+ const [ops] = (0, import_react25.useState)(() => entry.inject?.() ?? {});
const close = () => actions.closeSignIn();
- const useHook = (source) => (selector) => (0, import_react21.useSyncExternalStore)(source.subscribe, () => selector(source.getSnapshot()));
- const [hooks] = (0, import_react21.useState)(() => ({ useAccount: useHook(ops.hooks.account), useTheme: useHook(ops.hooks.theme) }));
- return (0, import_react21.createElement)(entry.component, {
+ const useHook = (source) => (selector) => (0, import_react25.useSyncExternalStore)(source.subscribe, () => selector(source.getSnapshot()));
+ const [hooks] = (0, import_react25.useState)(() => ({ useAccount: useHook(ops.hooks.account), useTheme: useHook(ops.hooks.theme) }));
+ return (0, import_react25.createElement)(entry.component, {
...ops,
...hooks,
t: actions.accountT(),
@@ -11040,17 +11394,17 @@ var MODEL_CSS = `
`;
// src/client/folder-menu.js
-var import_react22 = require("react");
+var import_react26 = require("react");
var import_react_dom7 = require("react-dom");
var folderName = (path) => String(path).replace(/[\\/]+$/, "").split(/[\\/]/).pop() || String(path);
-var Tick = ({ on }) => (0, import_react22.createElement)("span", { className: "bt-model-tick", "aria-hidden": true }, on ? (0, import_react22.createElement)(CheckIcon) : null);
+var Tick = ({ on }) => (0, import_react26.createElement)("span", { className: "bt-model-tick", "aria-hidden": true }, on ? (0, import_react26.createElement)(CheckIcon) : null);
function FolderMenu({ value, group = false, team = false, actions, run: run2, onPick, wide = false, disabled = false }) {
const { isOpen, shownPlace, leaving, button, menu, open, close } = useAnchoredMenu();
- const [info, setInfo] = (0, import_react22.useState)(null);
- const [view, setView] = (0, import_react22.useState)("list");
- const [draft, setDraft] = (0, import_react22.useState)("");
- const [listing, setListing] = (0, import_react22.useState)(null);
- const [problem, setProblem] = (0, import_react22.useState)("");
+ const [info, setInfo] = (0, import_react26.useState)(null);
+ const [view, setView] = (0, import_react26.useState)("list");
+ const [draft, setDraft] = (0, import_react26.useState)("");
+ const [listing, setListing] = (0, import_react26.useState)(null);
+ const [problem, setProblem] = (0, import_react26.useState)("");
const fallback = group ? t("Each Bot's own folder") : t("Team workspace");
const toggle = () => {
if (isOpen) {
@@ -11083,35 +11437,35 @@ function FolderMenu({ value, group = false, team = false, actions, run: run2, on
};
const known = info?.folders ?? [];
const folders = value && !known.some((folder) => folder.path === value) ? [{ path: value, title: folderName(value) }, ...known] : known;
- const listView = (0, import_react22.createElement)(
+ const listView = (0, import_react26.createElement)(
"div",
{ key: "list", className: "bt-folder-view" },
- team ? null : (0, import_react22.createElement)(
+ team ? null : (0, import_react26.createElement)(
"button",
{ type: "button", role: "menuitemradio", "aria-checked": !value, title: group ? void 0 : info?.team ?? void 0, onClick: () => choose("") },
- (0, import_react22.createElement)("span", { className: "bt-menu-label" }, fallback),
- (0, import_react22.createElement)(Tick, { on: !value })
+ (0, import_react26.createElement)("span", { className: "bt-menu-label" }, fallback),
+ (0, import_react26.createElement)(Tick, { on: !value })
),
- folders.length > 0 ? (0, import_react22.createElement)("div", { className: "bt-model-group", role: "presentation" }, t("Folders")) : null,
- folders.map((folder) => (0, import_react22.createElement)(
+ folders.length > 0 ? (0, import_react26.createElement)("div", { className: "bt-model-group", role: "presentation" }, t("Folders")) : null,
+ folders.map((folder) => (0, import_react26.createElement)(
"button",
{ key: folder.path, type: "button", role: "menuitemradio", "aria-checked": folder.path === value, title: folder.path, onClick: () => choose(folder.path) },
- (0, import_react22.createElement)("span", { className: "bt-folder-copy" }, (0, import_react22.createElement)("span", { className: "bt-menu-label" }, folder.title), (0, import_react22.createElement)("span", { className: "bt-folder-path" }, folder.path)),
- (0, import_react22.createElement)(Tick, { on: folder.path === value })
+ (0, import_react26.createElement)("span", { className: "bt-folder-copy" }, (0, import_react26.createElement)("span", { className: "bt-menu-label" }, folder.title), (0, import_react26.createElement)("span", { className: "bt-folder-path" }, folder.path)),
+ (0, import_react26.createElement)(Tick, { on: folder.path === value })
)),
- (0, import_react22.createElement)("div", { className: "bt-menu-sep", role: "separator" }),
- info?.picker === "native" ? (0, import_react22.createElement)("button", { type: "button", role: "menuitem", onClick: pickNative }, (0, import_react22.createElement)(FolderIcon), (0, import_react22.createElement)("span", { className: "bt-menu-label" }, t("Choose a folder…"))) : null,
- info?.picker === "browse" ? (0, import_react22.createElement)("button", { type: "button", role: "menuitem", onClick: () => browse(value) }, (0, import_react22.createElement)(FolderIcon), (0, import_react22.createElement)("span", { className: "bt-menu-label" }, t("Browse folders…"))) : null,
- (0, import_react22.createElement)("button", { type: "button", role: "menuitem", onClick: () => {
+ (0, import_react26.createElement)("div", { className: "bt-menu-sep", role: "separator" }),
+ info?.picker === "native" ? (0, import_react26.createElement)("button", { type: "button", role: "menuitem", onClick: pickNative }, (0, import_react26.createElement)(FolderIcon), (0, import_react26.createElement)("span", { className: "bt-menu-label" }, t("Choose a folder…"))) : null,
+ info?.picker === "browse" ? (0, import_react26.createElement)("button", { type: "button", role: "menuitem", onClick: () => browse(value) }, (0, import_react26.createElement)(FolderIcon), (0, import_react26.createElement)("span", { className: "bt-menu-label" }, t("Browse folders…"))) : null,
+ (0, import_react26.createElement)("button", { type: "button", role: "menuitem", onClick: () => {
setDraft(value ?? "");
setView("type");
- } }, (0, import_react22.createElement)(PencilIcon), (0, import_react22.createElement)("span", { className: "bt-menu-label" }, t("Enter a path…")))
+ } }, (0, import_react26.createElement)(PencilIcon), (0, import_react26.createElement)("span", { className: "bt-menu-label" }, t("Enter a path…")))
);
- const typeView = (0, import_react22.createElement)(
+ const typeView = (0, import_react26.createElement)(
"div",
{ key: "type", className: "bt-folder-view" },
- (0, import_react22.createElement)("button", { type: "button", className: "bt-folder-back", onClick: () => setView("list") }, (0, import_react22.createElement)(ChevronLeftIcon), (0, import_react22.createElement)("span", { className: "bt-menu-label" }, t("Back"))),
- (0, import_react22.createElement)("input", {
+ (0, import_react26.createElement)("button", { type: "button", className: "bt-folder-back", onClick: () => setView("list") }, (0, import_react26.createElement)(ChevronLeftIcon), (0, import_react26.createElement)("span", { className: "bt-menu-label" }, t("Back"))),
+ (0, import_react26.createElement)("input", {
className: "bt-folder-input",
autoFocus: true,
value: draft,
@@ -11123,33 +11477,33 @@ function FolderMenu({ value, group = false, team = false, actions, run: run2, on
if (event.key === "Enter" && !event.nativeEvent.isComposing) typed();
}
}),
- (0, import_react22.createElement)("button", { type: "button", className: "bt-folder-use", disabled: draft.trim() === "", onClick: typed }, t("Use this folder"))
+ (0, import_react26.createElement)("button", { type: "button", className: "bt-folder-use", disabled: draft.trim() === "", onClick: typed }, t("Use this folder"))
);
const parent = listing?.crumbs?.length > 1 ? listing.crumbs.at(-2) : void 0;
const inside = listing?.entries?.filter((entry) => !entry.hidden) ?? [];
- const browseView = listing ? (0, import_react22.createElement)(
+ const browseView = listing ? (0, import_react26.createElement)(
"div",
{ key: `browse:${listing.path}`, className: "bt-folder-view" },
- (0, import_react22.createElement)("button", { type: "button", className: "bt-folder-back", onClick: () => setView("list") }, (0, import_react22.createElement)(ChevronLeftIcon), (0, import_react22.createElement)("span", { className: "bt-menu-label" }, t("Back"))),
- (0, import_react22.createElement)("div", { className: "bt-folder-path bt-folder-here" }, listing.path),
- parent ? (0, import_react22.createElement)("button", { type: "button", role: "menuitem", title: parent.path, onClick: () => browse(parent.path) }, (0, import_react22.createElement)(FolderIcon), (0, import_react22.createElement)("span", { className: "bt-menu-label" }, t("Up one level"))) : null,
- inside.map((entry) => (0, import_react22.createElement)(
+ (0, import_react26.createElement)("button", { type: "button", className: "bt-folder-back", onClick: () => setView("list") }, (0, import_react26.createElement)(ChevronLeftIcon), (0, import_react26.createElement)("span", { className: "bt-menu-label" }, t("Back"))),
+ (0, import_react26.createElement)("div", { className: "bt-folder-path bt-folder-here" }, listing.path),
+ parent ? (0, import_react26.createElement)("button", { type: "button", role: "menuitem", title: parent.path, onClick: () => browse(parent.path) }, (0, import_react26.createElement)(FolderIcon), (0, import_react26.createElement)("span", { className: "bt-menu-label" }, t("Up one level"))) : null,
+ inside.map((entry) => (0, import_react26.createElement)(
"button",
{ key: entry.path, type: "button", role: "menuitem", onClick: () => browse(entry.path) },
- (0, import_react22.createElement)(FolderIcon),
- (0, import_react22.createElement)("span", { className: "bt-menu-label" }, entry.name),
- (0, import_react22.createElement)(ChevronRightIcon)
+ (0, import_react26.createElement)(FolderIcon),
+ (0, import_react26.createElement)("span", { className: "bt-menu-label" }, entry.name),
+ (0, import_react26.createElement)(ChevronRightIcon)
)),
- inside.length === 0 ? (0, import_react22.createElement)("div", { className: "bt-model-none" }, t("No folders inside.")) : null,
- listing.truncated ? (0, import_react22.createElement)("div", { className: "bt-folder-path bt-folder-here" }, t("Some folders are not shown.")) : null,
- (0, import_react22.createElement)("div", { className: "bt-menu-sep", role: "separator" }),
- (0, import_react22.createElement)("button", { type: "button", className: "bt-folder-use", onClick: () => choose(listing.path) }, t("Use this folder"))
+ inside.length === 0 ? (0, import_react26.createElement)("div", { className: "bt-model-none" }, t("No folders inside.")) : null,
+ listing.truncated ? (0, import_react26.createElement)("div", { className: "bt-folder-path bt-folder-here" }, t("Some folders are not shown.")) : null,
+ (0, import_react26.createElement)("div", { className: "bt-menu-sep", role: "separator" }),
+ (0, import_react26.createElement)("button", { type: "button", className: "bt-folder-use", onClick: () => choose(listing.path) }, t("Use this folder"))
) : null;
const shownView = view === "type" ? typeView : view === "browse" && browseView ? browseView : listView;
- return (0, import_react22.createElement)(
- import_react22.Fragment,
+ return (0, import_react26.createElement)(
+ import_react26.Fragment,
null,
- (0, import_react22.createElement)(
+ (0, import_react26.createElement)(
"button",
{
ref: button,
@@ -11163,19 +11517,19 @@ function FolderMenu({ value, group = false, team = false, actions, run: run2, on
onClick: toggle,
disabled
},
- (0, import_react22.createElement)(
+ (0, import_react26.createElement)(
"span",
{ className: "bt-model-copy" },
- (0, import_react22.createElement)("span", { className: "bt-model-name" }, value ? folderName(value) : fallback),
- value ? (0, import_react22.createElement)("span", { className: "bt-model-provider" }, value) : null
+ (0, import_react26.createElement)("span", { className: "bt-model-name" }, value ? folderName(value) : fallback),
+ value ? (0, import_react26.createElement)("span", { className: "bt-model-provider" }, value) : null
),
- (0, import_react22.createElement)(Caret)
+ (0, import_react26.createElement)(Caret)
),
- shownPlace ? (0, import_react_dom7.createPortal)((0, import_react22.createElement)(
+ shownPlace ? (0, import_react_dom7.createPortal)((0, import_react26.createElement)(
"div",
{ ref: menu, className: `bt-menu bt-model-menu bt-folder-menu${shownPlace.bottom !== void 0 ? " bt-menu-up" : ""}`, role: "menu", "aria-label": team ? t("Team workspace") : t("Working folder"), style: shownPlace, "data-leaving": leaving || void 0 },
shownView,
- problem ? (0, import_react22.createElement)("div", { className: "bt-folder-error", role: "alert" }, problem) : null
+ problem ? (0, import_react26.createElement)("div", { className: "bt-folder-error", role: "alert" }, problem) : null
), document.body) : null
);
}
@@ -11196,7 +11550,7 @@ var FOLDER_CSS = `
`;
// src/client/schedules.js
-var import_react23 = require("react");
+var import_react27 = require("react");
var POLL_MS = 3e4;
var shared = null;
var listeners = /* @__PURE__ */ new Set();
@@ -11205,8 +11559,8 @@ function publish(view) {
for (const listener of listeners) listener(view);
}
function useSchedules(actions) {
- const [view, setView] = (0, import_react23.useState)(shared);
- (0, import_react23.useEffect)(() => {
+ const [view, setView] = (0, import_react27.useState)(shared);
+ (0, import_react27.useEffect)(() => {
listeners.add(setView);
let stopped = false;
let timer;
@@ -11264,9 +11618,9 @@ function timingText(task) {
}
var nextText = (task) => task.status === "active" ? t("Next: {time}", { time: dayAndTime(Date.parse(task.scheduledAt)) }) : t("Finished");
function TaskRow({ task, actions, onView, showBot, roster }) {
- const [confirming, setConfirming] = (0, import_react23.useState)(false);
- const [busy, setBusy] = (0, import_react23.useState)(false);
- (0, import_react23.useEffect)(() => {
+ const [confirming, setConfirming] = (0, import_react27.useState)(false);
+ const [busy, setBusy] = (0, import_react27.useState)(false);
+ (0, import_react27.useEffect)(() => {
if (!confirming) return void 0;
const timer = setTimeout(() => setConfirming(false), 3e3);
return () => clearTimeout(timer);
@@ -11280,19 +11634,19 @@ function TaskRow({ task, actions, onView, showBot, roster }) {
void actions.scheduleDelete(task.sessionId, task.id).then(onView, () => setBusy(false));
};
const room2 = task.roomId ? roster.roomsById[task.roomId] : void 0;
- return (0, import_react23.createElement)(
+ return (0, import_react27.createElement)(
"div",
{ className: "bt-set-row bt-task", "data-done": task.status === "active" ? void 0 : "", "data-busy": busy || void 0 },
- showBot ? (0, import_react23.createElement)(BotAvatar, { bot: roster.byId[task.botId], size: 28, badge: false, live: false }) : null,
- (0, import_react23.createElement)(
+ showBot ? (0, import_react27.createElement)(BotAvatar, { bot: roster.byId[task.botId], size: 28, badge: false, live: false }) : null,
+ (0, import_react27.createElement)(
"span",
{ className: "bt-set-copy" },
- (0, import_react23.createElement)("span", { className: "bt-task-title" }, task.title),
- (0, import_react23.createElement)("span", { className: "bt-set-hint" }, [timingText(task), room2 ? t("in {name}", { name: room2.name }) : ""].filter(Boolean).join(" · ")),
- task.prompt && task.prompt !== task.title ? (0, import_react23.createElement)("span", { className: "bt-task-prompt" }, task.prompt) : null
+ (0, import_react27.createElement)("span", { className: "bt-task-title" }, task.title),
+ (0, import_react27.createElement)("span", { className: "bt-set-hint" }, [timingText(task), room2 ? t("in {name}", { name: room2.name }) : ""].filter(Boolean).join(" · ")),
+ task.prompt && task.prompt !== task.title ? (0, import_react27.createElement)("span", { className: "bt-task-prompt" }, task.prompt) : null
),
- (0, import_react23.createElement)("span", { className: "bt-task-next" }, nextText(task)),
- (0, import_react23.createElement)("button", {
+ (0, import_react27.createElement)("span", { className: "bt-task-next" }, nextText(task)),
+ (0, import_react27.createElement)("button", {
type: "button",
className: "bt-mini bt-task-remove",
"data-confirm": confirming || void 0,
@@ -11300,7 +11654,7 @@ function TaskRow({ task, actions, onView, showBot, roster }) {
"aria-label": confirming ? t("Click again to delete") : t("Delete task"),
title: confirming ? void 0 : t("Delete task"),
onClick: remove
- }, confirming ? t("Delete") : (0, import_react23.createElement)(TrashIcon))
+ }, confirming ? t("Delete") : (0, import_react27.createElement)(TrashIcon))
);
}
var pad = (number) => String(number).padStart(2, "0");
@@ -11312,17 +11666,17 @@ function inAnHour() {
var KINDS = [["at", "Once"], ["daily", "Every day"], ["weekly", "Every week"], ["every", "Repeat"]];
var UNITS = [["minutes", 1, "minutes"], ["hours", 60, "hours"], ["days", 1440, "days"]];
function TaskForm({ roster, actions, start, onDone, onCancel }) {
- const [target, setTarget] = (0, import_react23.useState)(start ?? roster.bots[0]?.id ?? "");
- const [title, setTitle] = (0, import_react23.useState)("");
- const [prompt, setPrompt] = (0, import_react23.useState)("");
- const [kind, setKind] = (0, import_react23.useState)("daily");
- const [at, setAt] = (0, import_react23.useState)(inAnHour);
- const [time, setTime] = (0, import_react23.useState)("09:00");
- const [weekdays, setWeekdays] = (0, import_react23.useState)([1, 2, 3, 4, 5]);
- const [count, setCount] = (0, import_react23.useState)(1);
- const [unit, setUnit] = (0, import_react23.useState)("hours");
- const [busy, setBusy] = (0, import_react23.useState)(false);
- const [error, setError] = (0, import_react23.useState)("");
+ const [target, setTarget] = (0, import_react27.useState)(start ?? roster.bots[0]?.id ?? "");
+ const [title, setTitle] = (0, import_react27.useState)("");
+ const [prompt, setPrompt] = (0, import_react27.useState)("");
+ const [kind, setKind] = (0, import_react27.useState)("daily");
+ const [at, setAt] = (0, import_react27.useState)(inAnHour);
+ const [time, setTime] = (0, import_react27.useState)("09:00");
+ const [weekdays, setWeekdays] = (0, import_react27.useState)([1, 2, 3, 4, 5]);
+ const [count, setCount] = (0, import_react27.useState)(1);
+ const [unit, setUnit] = (0, import_react27.useState)("hours");
+ const [busy, setBusy] = (0, import_react27.useState)(false);
+ const [error, setError] = (0, import_react27.useState)("");
const timing = () => {
if (kind === "at") return { kind, at: new Date(at).toISOString() };
if (kind === "every") return { kind, minutes: Math.round(Number(count) * UNITS.find(([id]) => id === unit)[1]) };
@@ -11347,101 +11701,101 @@ function TaskForm({ roster, actions, start, onDone, onCancel }) {
});
};
const toggleDay = (day) => setWeekdays((days) => days.includes(day) ? days.filter((item) => item !== day) : [...days, day].sort());
- return (0, import_react23.createElement)(
+ return (0, import_react27.createElement)(
"form",
{ className: "bt-set-card bt-task-form", onSubmit: submit },
- (0, import_react23.createElement)(
+ (0, import_react27.createElement)(
"label",
{ className: "bt-set-row bt-bs-row" },
- (0, import_react23.createElement)("span", { className: "bt-set-copy" }, (0, import_react23.createElement)("span", { className: "bt-bs-label" }, t("Send to"))),
- (0, import_react23.createElement)(
+ (0, import_react27.createElement)("span", { className: "bt-set-copy" }, (0, import_react27.createElement)("span", { className: "bt-bs-label" }, t("Send to"))),
+ (0, import_react27.createElement)(
"select",
{ className: "bt-select bt-task-bot", value: target, onChange: (event) => setTarget(event.target.value) },
- (0, import_react23.createElement)("optgroup", { label: t("Bots") }, roster.bots.map((bot) => (0, import_react23.createElement)("option", { key: bot.id, value: bot.id }, bot.name))),
- roster.rooms.length > 0 ? (0, import_react23.createElement)("optgroup", { label: t("Group chats") }, roster.rooms.map((room2) => (0, import_react23.createElement)("option", { key: room2.id, value: room2.id }, room2.name))) : null
+ (0, import_react27.createElement)("optgroup", { label: t("Bots") }, roster.bots.map((bot) => (0, import_react27.createElement)("option", { key: bot.id, value: bot.id }, bot.name))),
+ roster.rooms.length > 0 ? (0, import_react27.createElement)("optgroup", { label: t("Group chats") }, roster.rooms.map((room2) => (0, import_react27.createElement)("option", { key: room2.id, value: room2.id }, room2.name))) : null
)
),
- (0, import_react23.createElement)(
+ (0, import_react27.createElement)(
"label",
{ className: "bt-set-row bt-bs-row" },
- (0, import_react23.createElement)("span", { className: "bt-set-copy" }, (0, import_react23.createElement)("span", { className: "bt-bs-label" }, t("Name"))),
- (0, import_react23.createElement)("input", { className: "bt-bs-input", value: title, maxLength: 120, placeholder: t("Morning briefing"), autoFocus: true, onChange: (event) => setTitle(event.target.value) })
+ (0, import_react27.createElement)("span", { className: "bt-set-copy" }, (0, import_react27.createElement)("span", { className: "bt-bs-label" }, t("Name"))),
+ (0, import_react27.createElement)("input", { className: "bt-bs-input", value: title, maxLength: 120, placeholder: t("Morning briefing"), autoFocus: true, onChange: (event) => setTitle(event.target.value) })
),
- (0, import_react23.createElement)(
+ (0, import_react27.createElement)(
"label",
{ className: "bt-set-row bt-bs-row bt-bs-stack" },
- (0, import_react23.createElement)("span", { className: "bt-set-copy" }, (0, import_react23.createElement)("span", { className: "bt-bs-label" }, t("What to do"))),
- (0, import_react23.createElement)("textarea", { className: "bt-bs-input bt-bs-area", value: prompt, rows: 3, placeholder: t("Sum up what changed since yesterday and what needs me today."), onChange: (event) => setPrompt(event.target.value) })
+ (0, import_react27.createElement)("span", { className: "bt-set-copy" }, (0, import_react27.createElement)("span", { className: "bt-bs-label" }, t("What to do"))),
+ (0, import_react27.createElement)("textarea", { className: "bt-bs-input bt-bs-area", value: prompt, rows: 3, placeholder: t("Sum up what changed since yesterday and what needs me today."), onChange: (event) => setPrompt(event.target.value) })
),
- (0, import_react23.createElement)(
+ (0, import_react27.createElement)(
"div",
{ className: "bt-set-row bt-bs-row bt-bs-stack" },
- (0, import_react23.createElement)("span", { className: "bt-set-copy" }, (0, import_react23.createElement)("span", { className: "bt-bs-label" }, t("When"))),
- (0, import_react23.createElement)(Segmented, { label: t("When"), value: kind }, KINDS.map(([id, label]) => (0, import_react23.createElement)("button", { key: id, type: "button", "aria-pressed": kind === id, onClick: () => setKind(id) }, t(label)))),
- (0, import_react23.createElement)(
+ (0, import_react27.createElement)("span", { className: "bt-set-copy" }, (0, import_react27.createElement)("span", { className: "bt-bs-label" }, t("When"))),
+ (0, import_react27.createElement)(Segmented, { label: t("When"), value: kind }, KINDS.map(([id, label]) => (0, import_react27.createElement)("button", { key: id, type: "button", "aria-pressed": kind === id, onClick: () => setKind(id) }, t(label)))),
+ (0, import_react27.createElement)(
"div",
{ key: kind, className: "bt-task-when bt-veil" },
- kind === "at" ? (0, import_react23.createElement)("input", { className: "bt-input", type: "datetime-local", value: at, "aria-label": t("Date and time"), onChange: (event) => setAt(event.target.value) }) : null,
- kind === "weekly" ? (0, import_react23.createElement)("div", { className: "bt-task-days", role: "group", "aria-label": t("Days") }, [1, 2, 3, 4, 5, 6, 7].map((day) => (0, import_react23.createElement)("button", {
+ kind === "at" ? (0, import_react27.createElement)("input", { className: "bt-input", type: "datetime-local", value: at, "aria-label": t("Date and time"), onChange: (event) => setAt(event.target.value) }) : null,
+ kind === "weekly" ? (0, import_react27.createElement)("div", { className: "bt-task-days", role: "group", "aria-label": t("Days") }, [1, 2, 3, 4, 5, 6, 7].map((day) => (0, import_react27.createElement)("button", {
key: day,
type: "button",
className: "bt-task-day",
"aria-pressed": weekdays.includes(day),
onClick: () => toggleDay(day)
}, when2(Date.UTC(2024, 0, day), { weekday: "narrow", timeZone: "UTC" })))) : null,
- kind === "daily" || kind === "weekly" ? (0, import_react23.createElement)("input", { className: "bt-input bt-task-time", type: "time", value: time, "aria-label": t("Time"), onChange: (event) => setTime(event.target.value) }) : null,
- kind === "every" ? (0, import_react23.createElement)(
- import_react23.Fragment,
+ kind === "daily" || kind === "weekly" ? (0, import_react27.createElement)("input", { className: "bt-input bt-task-time", type: "time", value: time, "aria-label": t("Time"), onChange: (event) => setTime(event.target.value) }) : null,
+ kind === "every" ? (0, import_react27.createElement)(
+ import_react27.Fragment,
null,
- (0, import_react23.createElement)("span", { className: "bt-task-every" }, t("Every")),
- (0, import_react23.createElement)("input", { className: "bt-input bt-task-count", type: "number", min: 1, value: count, "aria-label": t("How many"), onChange: (event) => setCount(event.target.value) }),
- (0, import_react23.createElement)(
+ (0, import_react27.createElement)("span", { className: "bt-task-every" }, t("Every")),
+ (0, import_react27.createElement)("input", { className: "bt-input bt-task-count", type: "number", min: 1, value: count, "aria-label": t("How many"), onChange: (event) => setCount(event.target.value) }),
+ (0, import_react27.createElement)(
"select",
{ className: "bt-select bt-task-unit", value: unit, "aria-label": t("Unit"), onChange: (event) => setUnit(event.target.value) },
- UNITS.map(([id, , label]) => (0, import_react23.createElement)("option", { key: id, value: id }, t(label)))
+ UNITS.map(([id, , label]) => (0, import_react27.createElement)("option", { key: id, value: id }, t(label)))
)
) : null
)
),
- error ? (0, import_react23.createElement)("div", { className: "bt-set-row" }, (0, import_react23.createElement)("span", { className: "bt-danger bt-set-hint" }, error)) : null,
- (0, import_react23.createElement)(
+ error ? (0, import_react27.createElement)("div", { className: "bt-set-row" }, (0, import_react27.createElement)("span", { className: "bt-danger bt-set-hint" }, error)) : null,
+ (0, import_react27.createElement)(
"div",
{ className: "bt-set-row bt-task-foot" },
- (0, import_react23.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onCancel }, t("Cancel")),
- (0, import_react23.createElement)("button", { type: "submit", className: "bt-send bt-soft-sm", disabled: busy || !target || title.trim() === "" || prompt.trim() === "" }, busy ? t("Creating…") : t("Create task"))
+ (0, import_react27.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onCancel }, t("Cancel")),
+ (0, import_react27.createElement)("button", { type: "submit", className: "bt-send bt-soft-sm", disabled: busy || !target || title.trim() === "" || prompt.trim() === "" }, busy ? t("Creating…") : t("Create task"))
)
);
}
function AutomationOff({ actions }) {
- return (0, import_react23.createElement)(
+ return (0, import_react27.createElement)(
"div",
{ className: "bt-set-card bt-task-off" },
- (0, import_react23.createElement)("span", { className: "bt-task-off-mark" }, (0, import_react23.createElement)(ClockIcon)),
- (0, import_react23.createElement)("span", { className: "bt-task-off-title" }, t("Turn on Automation tasks in DSH")),
- (0, import_react23.createElement)("span", { className: "bt-set-hint" }, t("Switch on Automation tasks on the Plugins page in Harness settings.")),
- actions.openHarnessSettings ? (0, import_react23.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: actions.openHarnessSettings }, t("Open Harness settings")) : null
+ (0, import_react27.createElement)("span", { className: "bt-task-off-mark" }, (0, import_react27.createElement)(ClockIcon)),
+ (0, import_react27.createElement)("span", { className: "bt-task-off-title" }, t("Turn on Automation tasks in DSH")),
+ (0, import_react27.createElement)("span", { className: "bt-set-hint" }, t("Switch on Automation tasks on the Plugins page in Harness settings.")),
+ actions.openHarnessSettings ? (0, import_react27.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: actions.openHarnessSettings }, t("Open Harness settings")) : null
);
}
function SchedulesPage({ roster, actions, start }) {
const view = useSchedules(actions);
- const [adding, setAdding] = (0, import_react23.useState)(Boolean(start));
- if (view === null) return (0, import_react23.createElement)("div", { className: "bt-set-hint" }, t("Loading…"));
- if (!view.available) return (0, import_react23.createElement)(AutomationOff, { actions });
+ const [adding, setAdding] = (0, import_react27.useState)(Boolean(start));
+ if (view === null) return (0, import_react27.createElement)("div", { className: "bt-set-hint" }, t("Loading…"));
+ if (!view.available) return (0, import_react27.createElement)(AutomationOff, { actions });
const shown = (next) => {
publish(next);
setAdding(false);
};
const byChat = [
- ...roster.bots.map((bot) => [bot.id, (0, import_react23.createElement)(BotAvatar, { bot, size: 18, badge: false, live: false }), bot.name, view.tasks.filter((task) => task.botId === bot.id)]),
- ...roster.rooms.map((room2) => [room2.id, (0, import_react23.createElement)(RoomAvatar, { room: room2, roster, size: 18 }), room2.name, view.tasks.filter((task) => task.botId === void 0 && task.roomId === room2.id)])
+ ...roster.bots.map((bot) => [bot.id, (0, import_react27.createElement)(BotAvatar, { bot, size: 18, badge: false, live: false }), bot.name, view.tasks.filter((task) => task.botId === bot.id)]),
+ ...roster.rooms.map((room2) => [room2.id, (0, import_react27.createElement)(RoomAvatar, { room: room2, roster, size: 18 }), room2.name, view.tasks.filter((task) => task.botId === void 0 && task.roomId === room2.id)])
].filter(([, , , tasks]) => tasks.length > 0);
return [
- adding ? (0, import_react23.createElement)(TaskForm, { key: "form", roster, actions, start, onDone: shown, onCancel: () => setAdding(false) }) : (0, import_react23.createElement)("div", { key: "add", className: "bt-actions" }, (0, import_react23.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-with-icon", onClick: () => setAdding(true) }, (0, import_react23.createElement)(PlusIcon), t("New task"))),
- byChat.length === 0 && !adding ? (0, import_react23.createElement)("div", { key: "none", className: "bt-set-card" }, (0, import_react23.createElement)("div", { className: "bt-set-row" }, (0, import_react23.createElement)("span", { className: "bt-set-hint" }, t("No scheduled tasks yet.")))) : byChat.map(([id, avatar, name, tasks]) => (0, import_react23.createElement)(
+ adding ? (0, import_react27.createElement)(TaskForm, { key: "form", roster, actions, start, onDone: shown, onCancel: () => setAdding(false) }) : (0, import_react27.createElement)("div", { key: "add", className: "bt-actions" }, (0, import_react27.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-with-icon", onClick: () => setAdding(true) }, (0, import_react27.createElement)(PlusIcon), t("New task"))),
+ byChat.length === 0 && !adding ? (0, import_react27.createElement)("div", { key: "none", className: "bt-set-card" }, (0, import_react27.createElement)("div", { className: "bt-set-row" }, (0, import_react27.createElement)("span", { className: "bt-set-hint" }, t("No scheduled tasks yet.")))) : byChat.map(([id, avatar, name, tasks]) => (0, import_react27.createElement)(
"section",
{ key: id, className: "bt-set-section" },
- (0, import_react23.createElement)("h3", { className: "bt-task-head" }, avatar, name),
- (0, import_react23.createElement)("div", { className: "bt-set-card" }, tasks.map((task) => (0, import_react23.createElement)(TaskRow, { key: task.id, task, actions, roster, onView: publish })))
+ (0, import_react27.createElement)("h3", { className: "bt-task-head" }, avatar, name),
+ (0, import_react27.createElement)("div", { className: "bt-set-card" }, tasks.map((task) => (0, import_react27.createElement)(TaskRow, { key: task.id, task, actions, roster, onView: publish })))
))
];
}
@@ -11449,21 +11803,21 @@ function BotSchedules({ bot, roster, actions }) {
const view = useSchedules(actions);
if (view === null) return null;
const tasks = view.available ? view.tasks.filter((task) => task.botId === bot.id) : [];
- return (0, import_react23.createElement)(
+ return (0, import_react27.createElement)(
"section",
{ className: "bt-set-section" },
- (0, import_react23.createElement)("h3", null, t("Scheduled tasks")),
- (0, import_react23.createElement)(
+ (0, import_react27.createElement)("h3", null, t("Scheduled tasks")),
+ (0, import_react27.createElement)(
"div",
{ className: "bt-set-card" },
- !view.available ? (0, import_react23.createElement)(
+ !view.available ? (0, import_react27.createElement)(
"div",
{ className: "bt-set-row bt-bs-row" },
- (0, import_react23.createElement)("span", { className: "bt-set-copy" }, (0, import_react23.createElement)("span", { className: "bt-set-hint" }, t("Switch on Automation tasks on the Plugins page in Harness settings."))),
- actions.openHarnessSettings ? (0, import_react23.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: actions.openHarnessSettings }, t("Open Harness settings")) : null
+ (0, import_react27.createElement)("span", { className: "bt-set-copy" }, (0, import_react27.createElement)("span", { className: "bt-set-hint" }, t("Switch on Automation tasks on the Plugins page in Harness settings."))),
+ actions.openHarnessSettings ? (0, import_react27.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: actions.openHarnessSettings }, t("Open Harness settings")) : null
) : [
- ...tasks.map((task) => (0, import_react23.createElement)(TaskRow, { key: task.id, task, actions, roster, onView: publish })),
- (0, import_react23.createElement)("button", { key: "new", type: "button", className: "bt-set-row bt-bs-row bt-gs-add", onClick: () => actions.openSettings("schedules", bot.id) }, (0, import_react23.createElement)(PlusIcon), t("New task"))
+ ...tasks.map((task) => (0, import_react27.createElement)(TaskRow, { key: task.id, task, actions, roster, onView: publish })),
+ (0, import_react27.createElement)("button", { key: "new", type: "button", className: "bt-set-row bt-bs-row bt-gs-add", onClick: () => actions.openSettings("schedules", bot.id) }, (0, import_react27.createElement)(PlusIcon), t("New task"))
]
)
);
@@ -11471,16 +11825,16 @@ function BotSchedules({ bot, roster, actions }) {
function ScheduleSummary({ bot, actions }) {
const view = useSchedules(actions);
const tasks = view?.available ? view.tasks.filter((task) => task.botId === bot.id && task.status === "active") : [];
- return (0, import_react23.createElement)(
+ return (0, import_react27.createElement)(
"div",
null,
- (0, import_react23.createElement)("div", { className: "bt-section-title" }, t("Scheduled tasks")),
- tasks.length === 0 ? (0, import_react23.createElement)("button", { type: "button", className: "bt-more", onClick: () => actions.openSettings("schedules", bot.id) }, view?.available === false ? t("Switch on Automation tasks on the Plugins page in Harness settings.") : t("No scheduled tasks yet. Add one")) : (0, import_react23.createElement)("div", { className: "bt-task-list" }, tasks.slice(0, 3).map((task) => (0, import_react23.createElement)(
+ (0, import_react27.createElement)("div", { className: "bt-section-title" }, t("Scheduled tasks")),
+ tasks.length === 0 ? (0, import_react27.createElement)("button", { type: "button", className: "bt-more", onClick: () => actions.openSettings("schedules", bot.id) }, view?.available === false ? t("Switch on Automation tasks on the Plugins page in Harness settings.") : t("No scheduled tasks yet. Add one")) : (0, import_react27.createElement)("div", { className: "bt-task-list" }, tasks.slice(0, 3).map((task) => (0, import_react27.createElement)(
"button",
{ key: task.id, type: "button", className: "bt-task-line", onClick: () => actions.openSettings("schedules") },
- (0, import_react23.createElement)(ClockIcon),
- (0, import_react23.createElement)("span", { className: "bt-task-line-title" }, task.title),
- (0, import_react23.createElement)("span", { className: "bt-task-line-when" }, timingText(task))
+ (0, import_react27.createElement)(ClockIcon),
+ (0, import_react27.createElement)("span", { className: "bt-task-line-title" }, task.title),
+ (0, import_react27.createElement)("span", { className: "bt-task-line-when" }, timingText(task))
)))
);
}
@@ -11531,7 +11885,7 @@ var SCHEDULE_CSS = `
`;
// src/client/capability-settings.js
-var import_react24 = require("react");
+var import_react28 = require("react");
var blank = () => ({ name: "", kind: "mcp", description: "", transport: "stdio", command: "", argsText: "", envText: "{}", url: "", headersText: "{}", content: "", items: [] });
var parseMap = (text, label) => {
let value;
@@ -11545,11 +11899,11 @@ var parseMap = (text, label) => {
};
var statusText = (status) => !status ? void 0 : status.state === "ready" ? t("Ready") : status.state === "needs-approval" ? t("Needs approval") : status.state === "error" ? t("Could not connect: {error}", { error: status.error ?? "" }) : t("Connecting…");
function Field({ label, value, onChange, multiline = false, disabled = false, placeholder }) {
- return (0, import_react24.createElement)(
+ return (0, import_react28.createElement)(
"label",
{ className: "bt-set-row bt-bs-row bt-bs-stack" },
- (0, import_react24.createElement)("span", { className: "bt-set-copy" }, (0, import_react24.createElement)("span", { className: "bt-bs-label" }, t(label))),
- (0, import_react24.createElement)(multiline ? "textarea" : "input", {
+ (0, import_react28.createElement)("span", { className: "bt-set-copy" }, (0, import_react28.createElement)("span", { className: "bt-bs-label" }, t(label))),
+ (0, import_react28.createElement)(multiline ? "textarea" : "input", {
className: multiline ? "bt-input bt-input-area" : "bt-input",
value,
disabled,
@@ -11561,7 +11915,7 @@ function Field({ label, value, onChange, multiline = false, disabled = false, pl
);
}
function CapabilityForm({ draft, setDraft, items, actions, onClose }) {
- const [error, setError] = (0, import_react24.useState)("");
+ const [error, setError] = (0, import_react28.useState)("");
const set = (key, value) => setDraft((previous) => ({ ...previous, [key]: value }));
const submit = async (event) => {
event.preventDefault();
@@ -11592,95 +11946,95 @@ function CapabilityForm({ draft, setDraft, items, actions, onClose }) {
}
};
const available = items.filter((item) => item.name !== draft.name && ["mcp", "skill"].includes(item.kind));
- return (0, import_react24.createElement)(
+ return (0, import_react28.createElement)(
"form",
{ className: "bt-connector-form", onSubmit: submit },
- (0, import_react24.createElement)(Field, { label: "Name", value: draft.name, disabled: draft.originalName !== void 0, onChange: (value) => set("name", value), placeholder: "my-tool" }),
- (0, import_react24.createElement)(
+ (0, import_react28.createElement)(Field, { label: "Name", value: draft.name, disabled: draft.originalName !== void 0, onChange: (value) => set("name", value), placeholder: "my-tool" }),
+ (0, import_react28.createElement)(
"label",
{ className: "bt-set-row bt-bs-row bt-bs-stack" },
- (0, import_react24.createElement)("span", { className: "bt-set-copy" }, (0, import_react24.createElement)("span", { className: "bt-bs-label" }, t("Type"))),
- (0, import_react24.createElement)(
+ (0, import_react28.createElement)("span", { className: "bt-set-copy" }, (0, import_react28.createElement)("span", { className: "bt-bs-label" }, t("Type"))),
+ (0, import_react28.createElement)(
"select",
{ className: "bt-input", value: draft.kind, disabled: draft.originalName !== void 0, onChange: (event) => set("kind", event.target.value) },
- ["mcp", "skill", "pack"].map((kind) => (0, import_react24.createElement)("option", { key: kind, value: kind }, t(kind === "mcp" ? "MCP server" : kind === "skill" ? "Skill" : "Pack")))
+ ["mcp", "skill", "pack"].map((kind) => (0, import_react28.createElement)("option", { key: kind, value: kind }, t(kind === "mcp" ? "MCP server" : kind === "skill" ? "Skill" : "Pack")))
)
),
- (0, import_react24.createElement)(Field, { label: "Description", value: draft.description, onChange: (value) => set("description", value) }),
- draft.kind === "mcp" ? (0, import_react24.createElement)(
+ (0, import_react28.createElement)(Field, { label: "Description", value: draft.description, onChange: (value) => set("description", value) }),
+ draft.kind === "mcp" ? (0, import_react28.createElement)(
"label",
{ className: "bt-set-row bt-bs-row bt-bs-stack" },
- (0, import_react24.createElement)("span", { className: "bt-set-copy" }, (0, import_react24.createElement)("span", { className: "bt-bs-label" }, t("Connection"))),
- (0, import_react24.createElement)(
+ (0, import_react28.createElement)("span", { className: "bt-set-copy" }, (0, import_react28.createElement)("span", { className: "bt-bs-label" }, t("Connection"))),
+ (0, import_react28.createElement)(
"select",
{ className: "bt-input", value: draft.transport, onChange: (event) => set("transport", event.target.value) },
- (0, import_react24.createElement)("option", { value: "stdio" }, t("Local command")),
- (0, import_react24.createElement)("option", { value: "streamable-http" }, t("HTTP server"))
+ (0, import_react28.createElement)("option", { value: "stdio" }, t("Local command")),
+ (0, import_react28.createElement)("option", { value: "streamable-http" }, t("HTTP server"))
)
) : null,
- draft.kind === "mcp" && draft.transport === "stdio" ? (0, import_react24.createElement)(
+ draft.kind === "mcp" && draft.transport === "stdio" ? (0, import_react28.createElement)(
"div",
null,
- (0, import_react24.createElement)(Field, { label: "Command", value: draft.command, onChange: (value) => set("command", value) }),
- (0, import_react24.createElement)(Field, { label: "Arguments (one per line)", value: draft.argsText, onChange: (value) => set("argsText", value), multiline: true }),
- (0, import_react24.createElement)(Field, { label: "Environment (JSON)", value: draft.envText, onChange: (value) => set("envText", value), multiline: true, placeholder: t('{"API_KEY": "$DSH_SECRET_MY_KEY"}') })
+ (0, import_react28.createElement)(Field, { label: "Command", value: draft.command, onChange: (value) => set("command", value) }),
+ (0, import_react28.createElement)(Field, { label: "Arguments (one per line)", value: draft.argsText, onChange: (value) => set("argsText", value), multiline: true }),
+ (0, import_react28.createElement)(Field, { label: "Environment (JSON)", value: draft.envText, onChange: (value) => set("envText", value), multiline: true, placeholder: t('{"API_KEY": "$DSH_SECRET_MY_KEY"}') })
) : null,
- draft.kind === "mcp" && draft.transport === "streamable-http" ? (0, import_react24.createElement)(
+ draft.kind === "mcp" && draft.transport === "streamable-http" ? (0, import_react28.createElement)(
"div",
null,
- (0, import_react24.createElement)(Field, { label: "URL", value: draft.url, onChange: (value) => set("url", value) }),
- (0, import_react24.createElement)(Field, { label: "Headers (JSON)", value: draft.headersText, onChange: (value) => set("headersText", value), multiline: true, placeholder: t('{"API_KEY": "$DSH_SECRET_MY_KEY"}') })
+ (0, import_react28.createElement)(Field, { label: "URL", value: draft.url, onChange: (value) => set("url", value) }),
+ (0, import_react28.createElement)(Field, { label: "Headers (JSON)", value: draft.headersText, onChange: (value) => set("headersText", value), multiline: true, placeholder: t('{"API_KEY": "$DSH_SECRET_MY_KEY"}') })
) : null,
- draft.kind === "skill" ? (0, import_react24.createElement)(Field, { label: "Skill instructions", value: draft.content, onChange: (value) => set("content", value), multiline: true }) : null,
- draft.kind === "pack" ? (0, import_react24.createElement)(
+ draft.kind === "skill" ? (0, import_react28.createElement)(Field, { label: "Skill instructions", value: draft.content, onChange: (value) => set("content", value), multiline: true }) : null,
+ draft.kind === "pack" ? (0, import_react28.createElement)(
"div",
{ className: "bt-set-card" },
- available.length === 0 ? (0, import_react24.createElement)("div", { className: "bt-set-row" }, (0, import_react24.createElement)("span", { className: "bt-set-hint" }, t("Save an MCP server or skill first."))) : available.map((item) => (0, import_react24.createElement)(
+ available.length === 0 ? (0, import_react28.createElement)("div", { className: "bt-set-row" }, (0, import_react28.createElement)("span", { className: "bt-set-hint" }, t("Save an MCP server or skill first."))) : available.map((item) => (0, import_react28.createElement)(
"label",
{ key: item.name, className: "bt-set-row bt-bs-row" },
- (0, import_react24.createElement)("span", { className: "bt-set-copy" }, (0, import_react24.createElement)("span", { className: "bt-bs-label" }, item.name)),
- (0, import_react24.createElement)("input", { type: "checkbox", checked: draft.items.includes(item.name), onChange: (event) => set("items", event.target.checked ? [...draft.items, item.name] : draft.items.filter((name) => name !== item.name)) })
+ (0, import_react28.createElement)("span", { className: "bt-set-copy" }, (0, import_react28.createElement)("span", { className: "bt-bs-label" }, item.name)),
+ (0, import_react28.createElement)("input", { type: "checkbox", checked: draft.items.includes(item.name), onChange: (event) => set("items", event.target.checked ? [...draft.items, item.name] : draft.items.filter((name) => name !== item.name)) })
))
) : null,
- error ? (0, import_react24.createElement)("div", { className: "bt-connector-error", role: "alert" }, error) : null,
- (0, import_react24.createElement)(
+ error ? (0, import_react28.createElement)("div", { className: "bt-connector-error", role: "alert" }, error) : null,
+ (0, import_react28.createElement)(
"div",
{ className: "bt-connector-form-row" },
- (0, import_react24.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onClose }, t("Cancel")),
- (0, import_react24.createElement)("button", { type: "submit", className: "bt-soft bt-soft-sm" }, draft.originalName ? t("Save changes") : t("Add capability"))
+ (0, import_react28.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onClose }, t("Cancel")),
+ (0, import_react28.createElement)("button", { type: "submit", className: "bt-soft bt-soft-sm" }, draft.originalName ? t("Save changes") : t("Add capability"))
)
);
}
function CapabilityRow({ item, onEdit, onDelete, onApprove, confirming }) {
const detail = item.kind === "pack" ? `${t("Pack")}: ${(item.items ?? []).join(", ") || t("No items")}` : item.kind === "mcp" ? item.transport === "stdio" ? t("Local command") : t("HTTP server") : t("Skill");
const secondary = item.kind === "pack" ? [item.description, (item.items ?? []).join(", ") || t("No items")].filter(Boolean).join(" · ") : item.description || detail;
- return (0, import_react24.createElement)(
+ return (0, import_react28.createElement)(
"div",
{ className: "bt-connector" },
- (0, import_react24.createElement)(
+ (0, import_react28.createElement)(
"div",
{ className: "bt-connector-head" },
- (0, import_react24.createElement)(
+ (0, import_react28.createElement)(
"span",
{ className: "bt-connector-text" },
- (0, import_react24.createElement)("span", { className: "bt-connector-name" }, item.name),
- (0, import_react24.createElement)("span", { className: "bt-connector-status" }, secondary)
+ (0, import_react28.createElement)("span", { className: "bt-connector-name" }, item.name),
+ (0, import_react28.createElement)("span", { className: "bt-connector-status" }, secondary)
),
- (0, import_react24.createElement)(
+ (0, import_react28.createElement)(
"span",
{ className: "bt-connector-actions" },
- item.kind === "mcp" && item.transport === "stdio" && !item.approved ? (0, import_react24.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onApprove }, t("Allow")) : null,
- (0, import_react24.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onEdit }, t("Edit")),
- (0, import_react24.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onDelete }, confirming ? t("Click again to delete.") : t("Delete"))
+ item.kind === "mcp" && item.transport === "stdio" && !item.approved ? (0, import_react28.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onApprove }, t("Allow")) : null,
+ (0, import_react28.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onEdit }, t("Edit")),
+ (0, import_react28.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onDelete }, confirming ? t("Click again to delete.") : t("Delete"))
)
)
);
}
function CapabilitiesPage({ roster, actions, run: run2 }) {
const items = [...roster.capabilities ?? []].sort((a, b) => a.name.localeCompare(b.name));
- const [draft, setDraft] = (0, import_react24.useState)(null);
- const [confirming, setConfirming] = (0, import_react24.useState)("");
- (0, import_react24.useEffect)(() => {
+ const [draft, setDraft] = (0, import_react28.useState)(null);
+ const [confirming, setConfirming] = (0, import_react28.useState)("");
+ (0, import_react28.useEffect)(() => {
if (!confirming) return void 0;
const timer = setTimeout(() => setConfirming(""), 4e3);
return () => clearTimeout(timer);
@@ -11703,20 +12057,20 @@ function CapabilitiesPage({ roster, actions, run: run2 }) {
setConfirming("");
void run2(actions.deleteCapability(item.name));
};
- return (0, import_react24.createElement)(
+ return (0, import_react28.createElement)(
"section",
{ className: "bt-set-section" },
- (0, import_react24.createElement)("h3", null, t("Shared capabilities")),
- (0, import_react24.createElement)(
+ (0, import_react28.createElement)("h3", null, t("Shared capabilities")),
+ (0, import_react28.createElement)(
"div",
{ className: "bt-actions" },
- (0, import_react24.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: startNew }, t("Add capability"))
+ (0, import_react28.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: startNew }, t("Add capability"))
),
- draft ? (0, import_react24.createElement)(CapabilityForm, { draft, setDraft, items, actions, onClose: () => setDraft(null) }) : null,
- (0, import_react24.createElement)(
+ draft ? (0, import_react28.createElement)(CapabilityForm, { draft, setDraft, items, actions, onClose: () => setDraft(null) }) : null,
+ (0, import_react28.createElement)(
"div",
{ className: "bt-set-card bt-connectors-card" },
- items.length === 0 ? (0, import_react24.createElement)("div", { className: "bt-set-row" }, (0, import_react24.createElement)("span", { className: "bt-set-hint" }, t("No capabilities saved"))) : items.map((item) => (0, import_react24.createElement)(CapabilityRow, {
+ items.length === 0 ? (0, import_react28.createElement)("div", { className: "bt-set-row" }, (0, import_react28.createElement)("span", { className: "bt-set-hint" }, t("No capabilities saved"))) : items.map((item) => (0, import_react28.createElement)(CapabilityRow, {
key: item.name,
item,
confirming: confirming === item.name,
@@ -11727,15 +12081,15 @@ function CapabilitiesPage({ roster, actions, run: run2 }) {
)
);
}
-function BotCapabilitiesCard({ bot, roster, actions, run: run2, Card: Card2, SwitchRow: SwitchRow2 }) {
+function BotCapabilitiesCard({ bot, roster, actions, run: run2, Card: Card3, SwitchRow: SwitchRow2 }) {
const items = [...roster.capabilities ?? []].sort((a, b) => Number(b.kind === "pack") - Number(a.kind === "pack") || a.name.localeCompare(b.name));
const attached = new Set(bot.capabilities ?? []);
const statuses = roster.capabilityStatuses?.[bot.id] ?? {};
if (items.length === 0) return null;
- return (0, import_react24.createElement)(
- Card2,
+ return (0, import_react28.createElement)(
+ Card3,
{ title: t("Capabilities") },
- items.map((item) => (0, import_react24.createElement)(SwitchRow2, {
+ items.map((item) => (0, import_react28.createElement)(SwitchRow2, {
key: item.name,
label: item.name,
hint: attached.has(item.name) ? statusText(statuses[item.name]) : void 0,
@@ -11746,7 +12100,7 @@ function BotCapabilitiesCard({ bot, roster, actions, run: run2, Card: Card2, Swi
}
// src/client/memory-panel.js
-var import_react25 = require("react");
+var import_react29 = require("react");
var POLL_MS2 = 1500;
var MENU_EXIT_MS2 = 120;
var counts = /* @__PURE__ */ new Map();
@@ -11757,8 +12111,8 @@ function noteCount(id, count) {
for (const listener of countListeners) listener();
}
function useMemoryCount(id, actions) {
- const [count, setCount] = (0, import_react25.useState)(counts.get(id) ?? null);
- (0, import_react25.useEffect)(() => {
+ const [count, setCount] = (0, import_react29.useState)(counts.get(id) ?? null);
+ (0, import_react29.useEffect)(() => {
const listener = () => setCount(counts.get(id) ?? null);
countListeners.add(listener);
listener();
@@ -11777,16 +12131,16 @@ function useMemoryCount(id, actions) {
function MemoryRow({ owner, actions }) {
const count = useMemoryCount(owner.id, actions);
const label = count === null ? t("Loading…") : count === 0 ? t("Nothing saved yet") : count === 1 ? t("1 entry") : t("{count} entries", { count });
- return (0, import_react25.createElement)(
+ return (0, import_react29.createElement)(
"div",
null,
- (0, import_react25.createElement)("div", { className: "bt-section-title" }, t("Memory")),
- (0, import_react25.createElement)(
+ (0, import_react29.createElement)("div", { className: "bt-section-title" }, t("Memory")),
+ (0, import_react29.createElement)(
"button",
{ type: "button", className: "bt-mem-row", "aria-label": t("Manage {name}'s memory", { name: owner.name }), onClick: () => actions.openMemory(owner.id) },
- (0, import_react25.createElement)(MemoryIcon),
- (0, import_react25.createElement)("span", { className: "bt-mem-row-copy" }, label),
- (0, import_react25.createElement)("span", { className: "bt-mem-row-go" }, t("Manage"), (0, import_react25.createElement)(ChevronRightIcon))
+ (0, import_react29.createElement)(MemoryIcon),
+ (0, import_react29.createElement)("span", { className: "bt-mem-row-copy" }, label),
+ (0, import_react29.createElement)("span", { className: "bt-mem-row-go" }, t("Manage"), (0, import_react29.createElement)(ChevronRightIcon))
)
);
}
@@ -11801,45 +12155,45 @@ function ago(at, now) {
return format.format(-Math.round(hours / 24), "day");
}
function Skeleton({ label }) {
- return (0, import_react25.createElement)(
+ return (0, import_react29.createElement)(
"div",
{ className: "bt-mem-skel", "aria-busy": true },
- [0, 1].map((block) => (0, import_react25.createElement)(
+ [0, 1].map((block) => (0, import_react29.createElement)(
"div",
{ key: block, className: "bt-mem-skel-block" },
- (0, import_react25.createElement)("span", { className: "bt-mem-skel-head" }),
- (0, import_react25.createElement)("span", null),
- (0, import_react25.createElement)("span", null),
- (0, import_react25.createElement)("span", { style: { width: block === 0 ? "62%" : "48%" } })
+ (0, import_react29.createElement)("span", { className: "bt-mem-skel-head" }),
+ (0, import_react29.createElement)("span", null),
+ (0, import_react29.createElement)("span", null),
+ (0, import_react29.createElement)("span", { style: { width: block === 0 ? "62%" : "48%" } })
)),
- label ? (0, import_react25.createElement)("div", { className: "bt-mem-skel-label" }, label) : null
+ label ? (0, import_react29.createElement)("div", { className: "bt-mem-skel-label" }, label) : null
);
}
function Summary({ owner, view, regenerate }) {
if (view.entries.length === 0) {
- return (0, import_react25.createElement)(
+ return (0, import_react29.createElement)(
"div",
{ className: "bt-mem-empty" },
- (0, import_react25.createElement)("div", { className: "bt-mem-empty-mark" }, (0, import_react25.createElement)(MemoryIcon)),
- (0, import_react25.createElement)("div", { className: "bt-mem-empty-title" }, owner.group ? t("Nothing is saved for this group yet") : t("{name} has not saved anything yet", { name: owner.name })),
- (0, import_react25.createElement)("div", { className: "bt-mem-empty-text" }, owner.group ? t("A group keeps the decisions, rules, and facts its work needs, for its members to read here. Tell it below, or in the group.") : t("Bots keep lasting preferences, decisions, and what you ask them to remember. Tell {name} below, or in its chat.", { name: owner.name }))
+ (0, import_react29.createElement)("div", { className: "bt-mem-empty-mark" }, (0, import_react29.createElement)(MemoryIcon)),
+ (0, import_react29.createElement)("div", { className: "bt-mem-empty-title" }, owner.group ? t("Nothing is saved for this group yet") : t("{name} has not saved anything yet", { name: owner.name })),
+ (0, import_react29.createElement)("div", { className: "bt-mem-empty-text" }, owner.group ? t("A group keeps the decisions, rules, and facts its work needs, for its members to read here. Tell it below, or in the group.") : t("Bots keep lasting preferences, decisions, and what you ask them to remember. Tell {name} below, or in its chat.", { name: owner.name }))
);
}
- const failed = view.error && !view.summarizing ? (0, import_react25.createElement)(
+ const failed = view.error && !view.summarizing ? (0, import_react29.createElement)(
"div",
{ className: "bt-mem-failed", role: "alert" },
- (0, import_react25.createElement)("span", null, view.summary ? t("The summary is out of date: {reason}", { reason: hostText(view.error) }) : t("The summary could not be written: {reason}", { reason: hostText(view.error) })),
- (0, import_react25.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: regenerate }, t("Try again"))
+ (0, import_react29.createElement)("span", null, view.summary ? t("The summary is out of date: {reason}", { reason: hostText(view.error) }) : t("The summary could not be written: {reason}", { reason: hostText(view.error) })),
+ (0, import_react29.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: regenerate }, t("Try again"))
) : null;
- if (!view.summary) return (0, import_react25.createElement)(import_react25.Fragment, null, failed, failed ? null : (0, import_react25.createElement)(Skeleton, { label: t("Writing the summary…") }));
- return (0, import_react25.createElement)(
- import_react25.Fragment,
+ if (!view.summary) return (0, import_react29.createElement)(import_react29.Fragment, null, failed, failed ? null : (0, import_react29.createElement)(Skeleton, { label: t("Writing the summary…") }));
+ return (0, import_react29.createElement)(
+ import_react29.Fragment,
null,
failed,
- (0, import_react25.createElement)(
+ (0, import_react29.createElement)(
"div",
{ key: view.summary.at, className: "bt-mem-summary", "data-stale": !view.fresh || void 0 },
- summaryBlocks(view.summary.text).map((block, index) => block.kind === "h" ? (0, import_react25.createElement)("h3", { key: index }, block.text) : (0, import_react25.createElement)("p", { key: index }, block.text))
+ summaryBlocks(view.summary.text).map((block, index) => block.kind === "h" ? (0, import_react29.createElement)("h3", { key: index }, block.text) : (0, import_react29.createElement)("p", { key: index }, block.text))
)
);
}
@@ -11851,9 +12205,9 @@ var groupEntries = (entries2) => entries2.reduce((groups, entry) => {
return groups;
}, []);
function EntryRow({ entry, remove }) {
- const [confirming, setConfirming] = (0, import_react25.useState)(false);
- const [busy, setBusy] = (0, import_react25.useState)(false);
- (0, import_react25.useEffect)(() => {
+ const [confirming, setConfirming] = (0, import_react29.useState)(false);
+ const [busy, setBusy] = (0, import_react29.useState)(false);
+ (0, import_react29.useEffect)(() => {
if (!confirming) return void 0;
const timer = setTimeout(() => setConfirming(false), 3e3);
return () => clearTimeout(timer);
@@ -11868,16 +12222,16 @@ function EntryRow({ entry, remove }) {
setBusy(true);
if (!await remove(entry)) setBusy(false);
};
- return (0, import_react25.createElement)(
+ return (0, import_react29.createElement)(
"li",
{ className: "bt-mem-entry", "data-busy": busy || void 0 },
- (0, import_react25.createElement)(
+ (0, import_react29.createElement)(
"div",
{ className: "bt-mem-entry-copy" },
- (0, import_react25.createElement)("span", { className: "bt-mem-entry-text" }, entry.text),
- meta ? (0, import_react25.createElement)("span", { className: "bt-mem-entry-meta" }, meta) : null
+ (0, import_react29.createElement)("span", { className: "bt-mem-entry-text" }, entry.text),
+ meta ? (0, import_react29.createElement)("span", { className: "bt-mem-entry-meta" }, meta) : null
),
- (0, import_react25.createElement)("button", {
+ (0, import_react29.createElement)("button", {
type: "button",
className: "bt-mem-remove",
"data-confirm": confirming || void 0,
@@ -11885,7 +12239,7 @@ function EntryRow({ entry, remove }) {
"aria-label": confirming ? t("Click again to remove") : t("Remove from memory"),
title: confirming ? void 0 : t("Remove from memory"),
onClick: click
- }, confirming ? t("Remove") : (0, import_react25.createElement)(TrashIcon))
+ }, confirming ? t("Remove") : (0, import_react29.createElement)(TrashIcon))
);
}
function Entries({ owner, view, remove }) {
@@ -11894,25 +12248,25 @@ function Entries({ owner, view, remove }) {
{ scope: "own", title: t("{name}'s memory", { name: owner.name }), size: view.sizes.own },
{ scope: "team", title: t("Team memory"), hint: t("Every Bot reads it"), size: view.sizes.team }
];
- return (0, import_react25.createElement)(
+ return (0, import_react29.createElement)(
"div",
{ className: "bt-mem-entries" },
- sections.map((section) => (0, import_react25.createElement)(
+ sections.map((section) => (0, import_react29.createElement)(
"section",
{ key: section.scope, className: "bt-mem-section" },
- (0, import_react25.createElement)(
+ (0, import_react29.createElement)(
"div",
{ className: "bt-mem-section-head" },
- (0, import_react25.createElement)("h3", null, section.title),
- section.hint ? (0, import_react25.createElement)("span", null, section.hint) : null,
- (0, import_react25.createElement)("span", { className: "bt-mem-size", title: t("MEMORY.md, which every conversation reads") }, t("{used} of {limit} characters", { used: section.size.toLocaleString(dateLocale()), limit: view.limits.main.toLocaleString(dateLocale()) }))
+ (0, import_react29.createElement)("h3", null, section.title),
+ section.hint ? (0, import_react29.createElement)("span", null, section.hint) : null,
+ (0, import_react29.createElement)("span", { className: "bt-mem-size", title: t("MEMORY.md, which every conversation reads") }, t("{used} of {limit} characters", { used: section.size.toLocaleString(dateLocale()), limit: view.limits.main.toLocaleString(dateLocale()) }))
),
- groups.some((group) => group.scope === section.scope) ? groups.filter((group) => group.scope === section.scope).map((group) => (0, import_react25.createElement)(
- import_react25.Fragment,
+ groups.some((group) => group.scope === section.scope) ? groups.filter((group) => group.scope === section.scope).map((group) => (0, import_react29.createElement)(
+ import_react29.Fragment,
{ key: group.key },
- group.topic ? (0, import_react25.createElement)("div", { className: "bt-mem-topic" }, group.topic) : null,
- (0, import_react25.createElement)("ul", { className: "bt-mem-list" }, group.entries.map((entry) => (0, import_react25.createElement)(EntryRow, { key: `${entry.topic ?? ""}:${entry.text}`, entry, remove })))
- )) : (0, import_react25.createElement)("div", { className: "bt-mem-none" }, t("Nothing saved yet"))
+ group.topic ? (0, import_react29.createElement)("div", { className: "bt-mem-topic" }, group.topic) : null,
+ (0, import_react29.createElement)("ul", { className: "bt-mem-list" }, group.entries.map((entry) => (0, import_react29.createElement)(EntryRow, { key: `${entry.topic ?? ""}:${entry.text}`, entry, remove })))
+ )) : (0, import_react29.createElement)("div", { className: "bt-mem-none" }, t("Nothing saved yet"))
))
);
}
@@ -11924,40 +12278,40 @@ function changeLine(change) {
return change.scope === "team" ? t("Added to team memory: {text}", { text }) : t("Added: {text}", { text });
}
function Reply({ answer, dismiss }) {
- return (0, import_react25.createElement)(
+ return (0, import_react29.createElement)(
"div",
{ className: "bt-mem-reply", role: "status" },
- (0, import_react25.createElement)(
+ (0, import_react29.createElement)(
"div",
{ className: "bt-mem-reply-head" },
- (0, import_react25.createElement)("span", { className: "bt-mem-reply-asked" }, answer.asked),
- answer.pending ? null : (0, import_react25.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Dismiss"), onClick: dismiss }, (0, import_react25.createElement)(CloseIcon))
+ (0, import_react29.createElement)("span", { className: "bt-mem-reply-asked" }, answer.asked),
+ answer.pending ? null : (0, import_react29.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Dismiss"), onClick: dismiss }, (0, import_react29.createElement)(CloseIcon))
),
- answer.pending ? (0, import_react25.createElement)("div", { className: "bt-mem-reply-text bt-shimmer" }, t("Thinking…")) : answer.error ? (0, import_react25.createElement)("div", { className: "bt-mem-reply-text bt-danger" }, hostText(answer.error)) : (0, import_react25.createElement)(
- import_react25.Fragment,
+ answer.pending ? (0, import_react29.createElement)("div", { className: "bt-mem-reply-text bt-shimmer" }, t("Thinking…")) : answer.error ? (0, import_react29.createElement)("div", { className: "bt-mem-reply-text bt-danger" }, hostText(answer.error)) : (0, import_react29.createElement)(
+ import_react29.Fragment,
null,
- answer.reply ? (0, import_react25.createElement)("div", { className: "bt-mem-reply-text" }, answer.reply) : null,
- answer.changes.length > 0 ? (0, import_react25.createElement)("ul", { className: "bt-mem-changes" }, answer.changes.map((change, index) => (0, import_react25.createElement)(
+ answer.reply ? (0, import_react29.createElement)("div", { className: "bt-mem-reply-text" }, answer.reply) : null,
+ answer.changes.length > 0 ? (0, import_react29.createElement)("ul", { className: "bt-mem-changes" }, answer.changes.map((change, index) => (0, import_react29.createElement)(
"li",
{ key: index, "data-ok": change.ok || void 0 },
- change.ok ? (0, import_react25.createElement)(CheckIcon) : (0, import_react25.createElement)(CloseIcon),
- (0, import_react25.createElement)("span", null, changeLine(change))
+ change.ok ? (0, import_react29.createElement)(CheckIcon) : (0, import_react29.createElement)(CloseIcon),
+ (0, import_react29.createElement)("span", null, changeLine(change))
))) : null
)
);
}
function useMemoryView(id, actions) {
- const [view, setView] = (0, import_react25.useState)(null);
- const [error, setError] = (0, import_react25.useState)("");
- const timer = (0, import_react25.useRef)(0);
- const latest = (0, import_react25.useRef)(0);
- const alive = (0, import_react25.useRef)(true);
- const show2 = (0, import_react25.useCallback)((next) => {
+ const [view, setView] = (0, import_react29.useState)(null);
+ const [error, setError] = (0, import_react29.useState)("");
+ const timer = (0, import_react29.useRef)(0);
+ const latest = (0, import_react29.useRef)(0);
+ const alive = (0, import_react29.useRef)(true);
+ const show2 = (0, import_react29.useCallback)((next) => {
setView(next);
setError("");
noteCount(id, next.entries.length);
}, [id]);
- const load = (0, import_react25.useCallback)(async (flags = {}) => {
+ const load = (0, import_react29.useCallback)(async (flags = {}) => {
clearTimeout(timer.current);
const ticket = ++latest.current;
try {
@@ -11969,7 +12323,7 @@ function useMemoryView(id, actions) {
if (alive.current && ticket === latest.current) setError(failure?.message ?? String(failure));
}
}, [id]);
- (0, import_react25.useEffect)(() => {
+ (0, import_react29.useEffect)(() => {
alive.current = true;
void load({ summarize: true });
return () => {
@@ -11980,8 +12334,8 @@ function useMemoryView(id, actions) {
return { view, error, load, show: show2 };
}
function useNow(every) {
- const [now, setNow] = (0, import_react25.useState)(Date.now());
- (0, import_react25.useEffect)(() => {
+ const [now, setNow] = (0, import_react29.useState)(Date.now());
+ (0, import_react29.useEffect)(() => {
const id = setInterval(() => setNow(Date.now()), every);
return () => clearInterval(id);
}, [every]);
@@ -11989,18 +12343,18 @@ function useNow(every) {
}
function MemoryDialog({ owner, actions, leaving = false }) {
const { view, error, load, show: show2 } = useMemoryView(owner.id, actions);
- const [page, setPage] = (0, import_react25.useState)("summary");
- const [menu, setMenu] = (0, import_react25.useState)(false);
+ const [page, setPage] = (0, import_react29.useState)("summary");
+ const [menu, setMenu] = (0, import_react29.useState)(false);
const [menuShown, menuLeaving] = useLinger(menu, MENU_EXIT_MS2);
- const [text, setText] = (0, import_react25.useState)("");
- const [answer, setAnswer] = (0, import_react25.useState)(null);
- const menuRef = (0, import_react25.useRef)(null);
- const dotsRef = (0, import_react25.useRef)(null);
- const inputRef = (0, import_react25.useRef)(null);
+ const [text, setText] = (0, import_react29.useState)("");
+ const [answer, setAnswer] = (0, import_react29.useState)(null);
+ const menuRef = (0, import_react29.useRef)(null);
+ const dotsRef = (0, import_react29.useRef)(null);
+ const inputRef = (0, import_react29.useRef)(null);
const now = useNow(3e4);
- const close = (0, import_react25.useCallback)(() => actions.closeMemory(), []);
+ const close = (0, import_react29.useCallback)(() => actions.closeMemory(), []);
useEscape(close);
- (0, import_react25.useEffect)(() => {
+ (0, import_react29.useEffect)(() => {
if (!menu) return void 0;
const onDown = (event) => {
if (menuRef.current?.contains(event.target) || dotsRef.current?.contains(event.target)) return;
@@ -12062,52 +12416,52 @@ function MemoryDialog({ owner, actions, leaving = false }) {
const when3 = view?.summary ? ago(view.summary.at, now) : null;
const status = view === null ? "" : page === "entries" ? count === 1 ? t("1 entry") : t("{count} entries", { count }) : view.summarizing && view.summary ? t("Updating…") : view.summary && view.fresh ? when3 ? t("Updated {time}", { time: when3 }) : t("Updated just now") : "";
const busy = answer?.pending === true;
- return (0, import_react25.createElement)(
+ return (0, import_react29.createElement)(
"div",
{ className: "bt-mem-layer", "data-leaving": leaving || void 0 },
- (0, import_react25.createElement)("div", { className: "bt-scrim bt-mem-scrim", onMouseDown: close }),
- (0, import_react25.createElement)(
+ (0, import_react29.createElement)("div", { className: "bt-scrim bt-mem-scrim", onMouseDown: close }),
+ (0, import_react29.createElement)(
"div",
{ className: "bt-mem", role: "dialog", "aria-modal": true, "aria-label": t("{name}'s memory", { name: owner.name }) },
- (0, import_react25.createElement)(
+ (0, import_react29.createElement)(
"div",
{ className: "bt-mem-head" },
- page === "entries" ? (0, import_react25.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Back to the summary"), onClick: backToSummary }, (0, import_react25.createElement)(ChevronLeftIcon)) : null,
- (0, import_react25.createElement)("h2", null, page === "entries" ? t("All entries") : t("Memory summary")),
- (0, import_react25.createElement)("span", { className: "bt-mem-status" }, page === "summary" ? [owner.name, status].filter(Boolean).join(" · ") : status),
- (0, import_react25.createElement)("span", { className: "bt-mem-head-gap" }),
- (0, import_react25.createElement)("button", { ref: dotsRef, type: "button", className: "bt-icon-btn", "aria-label": t("Memory options"), "aria-haspopup": "menu", "aria-expanded": menu, onClick: () => setMenu((value) => !value) }, (0, import_react25.createElement)(DotsIcon)),
- (0, import_react25.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Close memory"), onClick: close }, (0, import_react25.createElement)(CloseIcon)),
- menuShown ? (0, import_react25.createElement)(
+ page === "entries" ? (0, import_react29.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Back to the summary"), onClick: backToSummary }, (0, import_react29.createElement)(ChevronLeftIcon)) : null,
+ (0, import_react29.createElement)("h2", null, page === "entries" ? t("All entries") : t("Memory summary")),
+ (0, import_react29.createElement)("span", { className: "bt-mem-status" }, page === "summary" ? [owner.name, status].filter(Boolean).join(" · ") : status),
+ (0, import_react29.createElement)("span", { className: "bt-mem-head-gap" }),
+ (0, import_react29.createElement)("button", { ref: dotsRef, type: "button", className: "bt-icon-btn", "aria-label": t("Memory options"), "aria-haspopup": "menu", "aria-expanded": menu, onClick: () => setMenu((value) => !value) }, (0, import_react29.createElement)(DotsIcon)),
+ (0, import_react29.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Close memory"), onClick: close }, (0, import_react29.createElement)(CloseIcon)),
+ menuShown ? (0, import_react29.createElement)(
"div",
{ ref: menuRef, className: "bt-menu bt-mem-menu", role: "menu", "aria-label": t("Memory options"), "data-leaving": menuLeaving || void 0 },
- (0, import_react25.createElement)(
+ (0, import_react29.createElement)(
"button",
{ type: "button", role: "menuitem", onClick: openEntries },
- (0, import_react25.createElement)("span", { className: "bt-menu-label" }, t("All entries")),
- (0, import_react25.createElement)("span", { className: "bt-menu-hint" }, String(count))
+ (0, import_react29.createElement)("span", { className: "bt-menu-label" }, t("All entries")),
+ (0, import_react29.createElement)("span", { className: "bt-menu-hint" }, String(count))
),
- (0, import_react25.createElement)(
+ (0, import_react29.createElement)(
"button",
{ type: "button", role: "menuitem", disabled: count === 0 || view?.summarizing, onClick: regenerate },
- (0, import_react25.createElement)("span", { className: "bt-menu-label" }, t("Regenerate summary"))
+ (0, import_react29.createElement)("span", { className: "bt-menu-label" }, t("Regenerate summary"))
)
) : null
),
- (0, import_react25.createElement)(
+ (0, import_react29.createElement)(
"div",
{ className: "bt-mem-body" },
- error ? (0, import_react25.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, hostText(error)) : null,
- view === null ? error ? null : (0, import_react25.createElement)(Skeleton) : page === "entries" ? (0, import_react25.createElement)(Entries, { owner, view, remove }) : (0, import_react25.createElement)(Summary, { owner, view, regenerate })
+ error ? (0, import_react29.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, hostText(error)) : null,
+ view === null ? error ? null : (0, import_react29.createElement)(Skeleton) : page === "entries" ? (0, import_react29.createElement)(Entries, { owner, view, remove }) : (0, import_react29.createElement)(Summary, { owner, view, regenerate })
),
- (0, import_react25.createElement)(
+ (0, import_react29.createElement)(
"div",
{ className: "bt-mem-foot" },
- answer ? (0, import_react25.createElement)(Reply, { answer, dismiss: () => setAnswer(null) }) : null,
- (0, import_react25.createElement)(
+ answer ? (0, import_react29.createElement)(Reply, { answer, dismiss: () => setAnswer(null) }) : null,
+ (0, import_react29.createElement)(
"form",
{ className: "bt-mem-ask", onSubmit: ask },
- (0, import_react25.createElement)("input", {
+ (0, import_react29.createElement)("input", {
ref: inputRef,
className: "bt-mem-input",
value: text,
@@ -12117,10 +12471,10 @@ function MemoryDialog({ owner, actions, leaving = false }) {
"aria-label": t("Ask about or update {name}'s memory", { name: owner.name }),
onChange: (event) => setText(event.target.value)
}),
- (0, import_react25.createElement)(
+ (0, import_react29.createElement)(
"button",
{ type: "submit", className: "bt-mem-send", disabled: busy || text.trim() === "", "aria-label": t("Send") },
- busy ? (0, import_react25.createElement)("span", { className: "bt-mem-spin", "aria-hidden": true }) : (0, import_react25.createElement)(ArrowUpIcon)
+ busy ? (0, import_react29.createElement)("span", { className: "bt-mem-spin", "aria-hidden": true }) : (0, import_react29.createElement)(ArrowUpIcon)
)
)
)
@@ -12129,7 +12483,7 @@ function MemoryDialog({ owner, actions, leaving = false }) {
}
// src/client/bot-settings.js
-var import_react26 = require("react");
+var import_react30 = require("react");
var capitalize = (word) => word[0].toUpperCase() + word.slice(1);
async function avatarImage(file) {
if (!/^image\/(png|jpeg|webp|gif)$/.test(file.type)) throw new Error(t("Choose a PNG, JPEG, WebP, or GIF image"));
@@ -12153,8 +12507,8 @@ async function avatarImage(file) {
throw new Error(t("That image is too large"));
}
function InlineText({ label, value, placeholder, required = false, maxLength, multiline = false, onSave }) {
- const [draft, setDraft] = (0, import_react26.useState)(null);
- const reverting = (0, import_react26.useRef)(false);
+ const [draft, setDraft] = (0, import_react30.useState)(null);
+ const reverting = (0, import_react30.useRef)(false);
const commit = () => {
const next = draft?.trim();
setDraft(null);
@@ -12165,7 +12519,7 @@ function InlineText({ label, value, placeholder, required = false, maxLength, mu
if (next === void 0 || next === (value ?? "") || required && next === "") return;
void onSave(next);
};
- return (0, import_react26.createElement)(multiline ? "textarea" : "input", {
+ return (0, import_react30.createElement)(multiline ? "textarea" : "input", {
className: multiline ? "bt-bs-input bt-bs-area" : "bt-bs-input",
value: draft ?? value ?? "",
placeholder,
@@ -12186,29 +12540,29 @@ function InlineText({ label, value, placeholder, required = false, maxLength, mu
});
}
function Row({ label, hint, stack = false, children }) {
- return (0, import_react26.createElement)(
+ return (0, import_react30.createElement)(
"label",
{ className: stack ? "bt-set-row bt-bs-row bt-bs-stack" : "bt-set-row bt-bs-row" },
- (0, import_react26.createElement)("span", { className: "bt-set-copy" }, (0, import_react26.createElement)("span", { className: "bt-bs-label" }, label), hint ? (0, import_react26.createElement)("span", { className: "bt-set-hint" }, hint) : null),
+ (0, import_react30.createElement)("span", { className: "bt-set-copy" }, (0, import_react30.createElement)("span", { className: "bt-bs-label" }, label), hint ? (0, import_react30.createElement)("span", { className: "bt-set-hint" }, hint) : null),
children
);
}
-function Card({ title, children }) {
- return (0, import_react26.createElement)("section", { className: "bt-set-section" }, title ? (0, import_react26.createElement)("h3", null, title) : null, (0, import_react26.createElement)("div", { className: "bt-set-card" }, children));
+function Card2({ title, children }) {
+ return (0, import_react30.createElement)("section", { className: "bt-set-section" }, title ? (0, import_react30.createElement)("h3", null, title) : null, (0, import_react30.createElement)("div", { className: "bt-set-card" }, children));
}
function Switch({ on, label, disabled, onChange }) {
- return (0, import_react26.createElement)(
+ return (0, import_react30.createElement)(
"button",
{ type: "button", role: "switch", className: "bt-switch", "aria-checked": on, "aria-label": label, disabled, onClick: () => onChange(!on) },
- (0, import_react26.createElement)("span", { className: "bt-switch-knob", "aria-hidden": true })
+ (0, import_react30.createElement)("span", { className: "bt-switch-knob", "aria-hidden": true })
);
}
function SwitchRow({ label, hint, on, disabled, onChange }) {
- return (0, import_react26.createElement)(
+ return (0, import_react30.createElement)(
"div",
{ className: "bt-set-row bt-bs-row" },
- (0, import_react26.createElement)("span", { className: "bt-set-copy" }, (0, import_react26.createElement)("span", { className: "bt-bs-label" }, label), hint ? (0, import_react26.createElement)("span", { className: "bt-set-hint" }, hint) : null),
- (0, import_react26.createElement)(Switch, { on, label, disabled, onChange })
+ (0, import_react30.createElement)("span", { className: "bt-set-copy" }, (0, import_react30.createElement)("span", { className: "bt-bs-label" }, label), hint ? (0, import_react30.createElement)("span", { className: "bt-set-hint" }, hint) : null),
+ (0, import_react30.createElement)(Switch, { on, label, disabled, onChange })
);
}
function modelHint(bot, roster) {
@@ -12219,22 +12573,22 @@ function modelHint(bot, roster) {
return t("Applies from the next message.");
}
function ShapeRing({ shape, size }) {
- const maskId = (0, import_react26.useRef)("");
+ const maskId = (0, import_react30.useRef)("");
if (maskId.current === "") maskId.current = `bt-ring-${nextMarkSerial()}`;
const def = shapeOf(shape);
const unit = def.size / size;
const markup = `<defs><mask id="${maskId.current}" ${maskBox(def.size)}>${holes(def, `<g stroke="#000" stroke-width="${6 * unit}" stroke-linejoin="round">${bodyOf(def, "#000", true)}</g>`)}</mask></defs><g mask="url(#${maskId.current})" stroke="currentColor" stroke-width="${8 * unit}" stroke-linejoin="round">${bodyOf(def, "currentColor", true)}</g>`;
- return (0, import_react26.createElement)("svg", { className: "bt-ring", viewBox: `0 0 ${def.size} ${def.size}`, "aria-hidden": true, dangerouslySetInnerHTML: { __html: markup } });
+ return (0, import_react30.createElement)("svg", { className: "bt-ring", viewBox: `0 0 ${def.size} ${def.size}`, "aria-hidden": true, dangerouslySetInnerHTML: { __html: markup } });
}
function CharacterGrid({ look, hasPhoto = false, onShape, onColor }) {
const shapes = [...PICKER_SHAPES, ...Object.keys(SHAPES).filter((id) => !Object.hasOwn(CHARACTERS, id))];
if (!shapes.includes(look.shape)) shapes.push(look.shape);
const rows2 = [];
for (let index = 0; index < shapes.length; index += PICKER_COLUMNS) rows2.push(shapes.slice(index, index + PICKER_COLUMNS));
- return (0, import_react26.createElement)(
- import_react26.Fragment,
+ return (0, import_react30.createElement)(
+ import_react30.Fragment,
null,
- (0, import_react26.createElement)("div", { className: "bt-shapes", role: "group", "aria-label": t("Character shape") }, rows2.map((row, index) => (0, import_react26.createElement)("div", { key: index, className: "bt-shape-row" }, row.map((id) => (0, import_react26.createElement)("button", {
+ (0, import_react30.createElement)("div", { className: "bt-shapes", role: "group", "aria-label": t("Character shape") }, rows2.map((row, index) => (0, import_react30.createElement)("div", { key: index, className: "bt-shape-row" }, row.map((id) => (0, import_react30.createElement)("button", {
key: id,
type: "button",
className: "bt-shape",
@@ -12242,8 +12596,8 @@ function CharacterGrid({ look, hasPhoto = false, onShape, onColor }) {
title: t(shapeOf(id).label),
"aria-pressed": !hasPhoto && look.shape === id,
onClick: () => onShape(id)
- }, (0, import_react26.createElement)(ShapeRing, { shape: id, size: 36 }), (0, import_react26.createElement)(BotMark, { look: { shape: id, color: look.color }, size: 36 })))))),
- (0, import_react26.createElement)("div", { className: "bt-colors", role: "group", "aria-label": t("Character color") }, CHARACTER_COLORS.map((color) => (0, import_react26.createElement)("button", {
+ }, (0, import_react30.createElement)(ShapeRing, { shape: id, size: 36 }), (0, import_react30.createElement)(BotMark, { look: { shape: id, color: look.color }, size: 36 })))))),
+ (0, import_react30.createElement)("div", { className: "bt-colors", role: "group", "aria-label": t("Character color") }, CHARACTER_COLORS.map((color) => (0, import_react30.createElement)("button", {
key: color,
type: "button",
className: "bt-color",
@@ -12251,19 +12605,19 @@ function CharacterGrid({ look, hasPhoto = false, onShape, onColor }) {
title: t(capitalize(color)),
"aria-pressed": look.color === color,
onClick: () => onColor(color)
- }, (0, import_react26.createElement)("span", { style: { background: paintCss(color) } }))))
+ }, (0, import_react30.createElement)("span", { style: { background: paintCss(color) } }))))
);
}
function AvatarEditor({ bot, actions, run: run2, onClose }) {
const look = lookOf(bot);
- const [tab, setTab] = (0, import_react26.useState)(look.image ? "upload" : "bot");
- const [over, setOver] = (0, import_react26.useState)(false);
- const ref = (0, import_react26.useRef)(null);
- const fileRef = (0, import_react26.useRef)(null);
+ const [tab, setTab] = (0, import_react30.useState)(look.image ? "upload" : "bot");
+ const [over, setOver] = (0, import_react30.useState)(false);
+ const ref = (0, import_react30.useRef)(null);
+ const fileRef = (0, import_react30.useRef)(null);
const upload = (file) => {
if (file) void run2(avatarImage(file).then((image) => actions.updateBot(bot.id, { avatar: { ...bot.avatar ?? {}, image } })));
};
- (0, import_react26.useEffect)(() => {
+ (0, import_react30.useEffect)(() => {
const onDown = (event) => {
if (!(event.target instanceof Element) || ref.current?.contains(event.target) || event.target.closest(".bt-avatar-trigger")) return;
onClose();
@@ -12281,7 +12635,7 @@ function AvatarEditor({ bot, actions, run: run2, onClose }) {
window.removeEventListener("keydown", onKey, true);
};
}, [onClose]);
- (0, import_react26.useEffect)(() => {
+ (0, import_react30.useEffect)(() => {
if (tab !== "upload") return void 0;
const onPaste = (event) => {
const file = [...event.clipboardData?.files ?? []].find((item) => item.type.startsWith("image/"));
@@ -12295,32 +12649,32 @@ function AvatarEditor({ bot, actions, run: run2, onClose }) {
}, [tab, bot]);
const hasPhoto = Boolean(look.image);
const glide = useGlide(tab);
- return (0, import_react26.createElement)(
+ return (0, import_react30.createElement)(
"div",
{ ref, className: "bt-avedit", role: "dialog", "aria-label": t("Avatar editor") },
- (0, import_react26.createElement)(
+ (0, import_react30.createElement)(
"div",
{ className: "bt-avedit-top" },
- (0, import_react26.createElement)(
+ (0, import_react30.createElement)(
"div",
{ ref: glide.box, role: "tablist", "aria-label": t("Avatar source"), className: "bt-avedit-tabs" },
- (0, import_react26.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),
- [["bot", "Bot"], ["upload", "Upload"]].map(([id, label]) => (0, import_react26.createElement)("button", { key: id, type: "button", role: "tab", className: "bt-avedit-tab", "aria-selected": tab === id, onClick: () => setTab(id) }, t(label)))
+ (0, import_react30.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),
+ [["bot", "Bot"], ["upload", "Upload"]].map(([id, label]) => (0, import_react30.createElement)("button", { key: id, type: "button", role: "tab", className: "bt-avedit-tab", "aria-selected": tab === id, onClick: () => setTab(id) }, t(label)))
),
- (0, import_react26.createElement)("button", {
+ (0, import_react30.createElement)("button", {
type: "button",
className: "bt-avedit-tab bt-avedit-reset",
title: t("Reset character to default"),
onClick: () => run2(actions.updateBot(bot.id, { avatar: null, color: null }))
}, t("Reset"))
),
- tab === "bot" ? (0, import_react26.createElement)(CharacterGrid, {
+ tab === "bot" ? (0, import_react30.createElement)(CharacterGrid, {
look,
hasPhoto,
onShape: (shape) => run2(actions.updateBot(bot.id, { avatar: { shape } })),
onColor: (color) => run2(actions.updateBot(bot.id, { color }))
}) : null,
- tab === "upload" ? (0, import_react26.createElement)(
+ tab === "upload" ? (0, import_react30.createElement)(
"div",
{
className: "bt-dropzone",
@@ -12336,15 +12690,15 @@ function AvatarEditor({ bot, actions, run: run2, onClose }) {
upload(event.dataTransfer.files?.[0]);
}
},
- hasPhoto ? (0, import_react26.createElement)("img", { src: look.image, alt: "" }) : null,
- (0, import_react26.createElement)("div", null, t("Drag, drop, or paste an image")),
- (0, import_react26.createElement)(
+ hasPhoto ? (0, import_react30.createElement)("img", { src: look.image, alt: "" }) : null,
+ (0, import_react30.createElement)("div", null, t("Drag, drop, or paste an image")),
+ (0, import_react30.createElement)(
"div",
{ className: "bt-actions", style: { justifyContent: "center" } },
- (0, import_react26.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => fileRef.current?.click() }, hasPhoto ? t("Replace") : t("Browse files")),
- hasPhoto ? (0, import_react26.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.updateBot(bot.id, { avatar: hasShape(bot.avatar?.shape) ? { shape: bot.avatar.shape } : null })) }, t("Remove photo")) : null
+ (0, import_react30.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => fileRef.current?.click() }, hasPhoto ? t("Replace") : t("Browse files")),
+ hasPhoto ? (0, import_react30.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.updateBot(bot.id, { avatar: hasShape(bot.avatar?.shape) ? { shape: bot.avatar.shape } : null })) }, t("Remove photo")) : null
),
- (0, import_react26.createElement)("input", { ref: fileRef, type: "file", accept: "image/png,image/jpeg,image/webp,image/gif", hidden: true, onChange: (event) => {
+ (0, import_react30.createElement)("input", { ref: fileRef, type: "file", accept: "image/png,image/jpeg,image/webp,image/gif", hidden: true, onChange: (event) => {
const file = event.target.files?.[0];
event.target.value = "";
upload(file);
@@ -12355,22 +12709,22 @@ function AvatarEditor({ bot, actions, run: run2, onClose }) {
function MemoryCard({ bot, actions }) {
const count = useMemoryCount(bot.id, actions);
const label = count === null ? t("Loading…") : count === 0 ? t("Nothing saved yet") : count === 1 ? t("1 entry") : t("{count} entries", { count });
- return (0, import_react26.createElement)(
- Card,
+ return (0, import_react30.createElement)(
+ Card2,
{ title: t("Memory") },
- (0, import_react26.createElement)(
+ (0, import_react30.createElement)(
"button",
{ type: "button", className: "bt-set-row bt-bs-row", "aria-label": t("Manage {name}'s memory", { name: bot.name }), onClick: () => actions.openMemory(bot.id) },
- (0, import_react26.createElement)("span", { className: "bt-set-copy" }, (0, import_react26.createElement)("span", { className: "bt-bs-label" }, label)),
- (0, import_react26.createElement)("span", { className: "bt-mem-row-go" }, t("Manage"), (0, import_react26.createElement)(ChevronRightIcon))
+ (0, import_react30.createElement)("span", { className: "bt-set-copy" }, (0, import_react30.createElement)("span", { className: "bt-bs-label" }, label)),
+ (0, import_react30.createElement)("span", { className: "bt-mem-row-go" }, t("Manage"), (0, import_react30.createElement)(ChevronRightIcon))
)
);
}
function BotSettingsForm({ bot, roster, actions, run: run2 }) {
- const [editing, setEditing] = (0, import_react26.useState)(false);
- const [confirming, setConfirming] = (0, import_react26.useState)(false);
- const closeEditor = (0, import_react26.useCallback)(() => setEditing(false), []);
- (0, import_react26.useEffect)(() => {
+ const [editing, setEditing] = (0, import_react30.useState)(false);
+ const [confirming, setConfirming] = (0, import_react30.useState)(false);
+ const closeEditor = (0, import_react30.useCallback)(() => setEditing(false), []);
+ (0, import_react30.useEffect)(() => {
if (!confirming) return void 0;
const timer = setTimeout(() => setConfirming(false), 4e3);
return () => clearTimeout(timer);
@@ -12384,112 +12738,112 @@ function BotSettingsForm({ bot, roster, actions, run: run2 }) {
if (confirming) void run2(actions.deleteBot(bot.id));
else setConfirming(true);
};
- (0, import_react26.useEffect)(() => {
+ (0, import_react30.useEffect)(() => {
void actions.refreshModels?.();
}, [bot.id]);
- return (0, import_react26.createElement)(
+ return (0, import_react30.createElement)(
"div",
{ className: "bt-bs" },
- (0, import_react26.createElement)(
+ (0, import_react30.createElement)(
"div",
{ className: "bt-bs-hero" },
- (0, import_react26.createElement)(
+ (0, import_react30.createElement)(
"div",
{ className: "bt-avatar-anchor" },
- (0, import_react26.createElement)(
+ (0, import_react30.createElement)(
"button",
{ type: "button", className: "bt-avatar-trigger", "aria-label": t("Edit Bot avatar"), "aria-expanded": editing, onClick: () => setEditing((value) => !value) },
- (0, import_react26.createElement)(BotMark, { bot, size: 64, live: true }),
- (0, import_react26.createElement)("span", { className: "bt-avatar-pencil", "aria-hidden": true }, (0, import_react26.createElement)(PencilIcon))
+ (0, import_react30.createElement)(BotMark, { bot, size: 64, live: true }),
+ (0, import_react30.createElement)("span", { className: "bt-avatar-pencil", "aria-hidden": true }, (0, import_react30.createElement)(PencilIcon))
),
- editing ? (0, import_react26.createElement)(AvatarEditor, { bot, actions, run: run2, onClose: closeEditor }) : null
+ editing ? (0, import_react30.createElement)(AvatarEditor, { bot, actions, run: run2, onClose: closeEditor }) : null
),
- (0, import_react26.createElement)(
+ (0, import_react30.createElement)(
"div",
{ className: "bt-bs-who" },
- (0, import_react26.createElement)("span", { className: "bt-bs-name" }, bot.name),
- (0, import_react26.createElement)("span", { className: "bt-bs-sub" }, [bot.role, isMainBot ? t("Main Bot") : ""].filter(Boolean).join(" · ") || t("Bot"))
+ (0, import_react30.createElement)("span", { className: "bt-bs-name" }, bot.name),
+ (0, import_react30.createElement)("span", { className: "bt-bs-sub" }, [bot.role, isMainBot ? t("Main Bot") : ""].filter(Boolean).join(" · ") || t("Bot"))
)
),
- (0, import_react26.createElement)(
- Card,
+ (0, import_react30.createElement)(
+ Card2,
{ title: t("Profile") },
- (0, import_react26.createElement)(Row, { label: t("Name") }, (0, import_react26.createElement)(InlineText, { label: t("Name"), value: bot.name, placeholder: "Bob", required: true, maxLength: 40, onSave: (name) => save({ name }) })),
- (0, import_react26.createElement)(Row, { label: t("Label"), hint: t("Optional. Shown under the name.") }, (0, import_react26.createElement)(InlineText, { label: t("Label"), value: bot.role, placeholder: t("Research, admin…"), maxLength: 24, onSave: (role) => save({ role }) }))
+ (0, import_react30.createElement)(Row, { label: t("Name") }, (0, import_react30.createElement)(InlineText, { label: t("Name"), value: bot.name, placeholder: "Bob", required: true, maxLength: 40, onSave: (name) => save({ name }) })),
+ (0, import_react30.createElement)(Row, { label: t("Label"), hint: t("Optional. Shown under the name.") }, (0, import_react30.createElement)(InlineText, { label: t("Label"), value: bot.role, placeholder: t("Research, admin…"), maxLength: 24, onSave: (role) => save({ role }) }))
),
- (0, import_react26.createElement)(
- Card,
+ (0, import_react30.createElement)(
+ Card2,
{ title: t("Model") },
- (0, import_react26.createElement)(
+ (0, import_react30.createElement)(
"div",
{ className: "bt-set-row bt-bs-row" },
- (0, import_react26.createElement)("span", { className: "bt-set-copy" }, (0, import_react26.createElement)("span", { className: "bt-bs-label" }, t("Model")), (0, import_react26.createElement)("span", { className: "bt-set-hint" }, modelHint(bot, roster))),
- (0, import_react26.createElement)(ModelMenu, { bot, roster, actions, run: run2 })
+ (0, import_react30.createElement)("span", { className: "bt-set-copy" }, (0, import_react30.createElement)("span", { className: "bt-bs-label" }, t("Model")), (0, import_react30.createElement)("span", { className: "bt-set-hint" }, modelHint(bot, roster))),
+ (0, import_react30.createElement)(ModelMenu, { bot, roster, actions, run: run2 })
)
),
- (0, import_react26.createElement)(
- Card,
+ (0, import_react30.createElement)(
+ Card2,
{ title: t("Working folder") },
- (0, import_react26.createElement)(
+ (0, import_react30.createElement)(
"div",
{ className: "bt-set-row bt-bs-row" },
- (0, import_react26.createElement)("span", { className: "bt-set-copy" }, (0, import_react26.createElement)("span", { className: "bt-bs-label" }, t("Folder"))),
- (0, import_react26.createElement)(FolderMenu, { value: bot.workDir, actions, run: run2, onPick: (workDir) => save({ workDir }) })
+ (0, import_react30.createElement)("span", { className: "bt-set-copy" }, (0, import_react30.createElement)("span", { className: "bt-bs-label" }, t("Folder"))),
+ (0, import_react30.createElement)(FolderMenu, { value: bot.workDir, actions, run: run2, onPick: (workDir) => save({ workDir }) })
)
),
- (0, import_react26.createElement)(
- Card,
+ (0, import_react30.createElement)(
+ Card2,
{ title: t("Instructions") },
- (0, import_react26.createElement)(
+ (0, import_react30.createElement)(
Row,
{ label: t("What this Bot does"), hint: t("Its job on the team. Part of the Bot's system prompt."), stack: true },
- (0, import_react26.createElement)(InlineText, { label: t("Instructions"), value: bot.instructions, multiline: true, placeholder: t("What this Bot is responsible for…"), onSave: (instructions) => save({ instructions }) })
+ (0, import_react30.createElement)(InlineText, { label: t("Instructions"), value: bot.instructions, multiline: true, placeholder: t("What this Bot is responsible for…"), onSave: (instructions) => save({ instructions }) })
)
),
- (0, import_react26.createElement)(BotCapabilitiesCard, { bot, roster, actions, run: run2, Card, SwitchRow }),
- roster.memory === false ? null : (0, import_react26.createElement)(MemoryCard, { bot, actions }),
- (0, import_react26.createElement)(BotSchedules, { bot, roster, actions }),
- (0, import_react26.createElement)(
- Card,
+ (0, import_react30.createElement)(BotCapabilitiesCard, { bot, roster, actions, run: run2, Card: Card2, SwitchRow }),
+ roster.memory === false ? null : (0, import_react30.createElement)(MemoryCard, { bot, actions }),
+ (0, import_react30.createElement)(BotSchedules, { bot, roster, actions }),
+ (0, import_react30.createElement)(
+ Card2,
{ title: t("Main Bot") },
- onlyMain ? (0, import_react26.createElement)(
+ onlyMain ? (0, import_react30.createElement)(
"div",
{ className: "bt-set-row bt-bs-row" },
- (0, import_react26.createElement)(
+ (0, import_react30.createElement)(
"span",
{ className: "bt-set-copy" },
- (0, import_react26.createElement)("span", { className: "bt-bs-label" }, t("Main Bot")),
- (0, import_react26.createElement)("span", { className: "bt-set-hint" }, t("The only Main Bot. To hand the role to another Bot, use Main Bot on the Bots page."))
+ (0, import_react30.createElement)("span", { className: "bt-bs-label" }, t("Main Bot")),
+ (0, import_react30.createElement)("span", { className: "bt-set-hint" }, t("The only Main Bot. To hand the role to another Bot, use Main Bot on the Bots page."))
),
- (0, import_react26.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.openSettings("bots") }, t("Change"))
- ) : (0, import_react26.createElement)(SwitchRow, { label: t("Main Bot"), hint: t("Can create and change Bots, and runs every group chat."), on: isMainBot, onChange: (on) => run2(actions.setMain(bot.id, on)) })
+ (0, import_react30.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.openSettings("bots") }, t("Change"))
+ ) : (0, import_react30.createElement)(SwitchRow, { label: t("Main Bot"), hint: t("Can create and change Bots, and runs every group chat."), on: isMainBot, onChange: (on) => run2(actions.setMain(bot.id, on)) })
),
// The Main Bot tile is always first and always shown, like in the context menu.
- isTile ? null : (0, import_react26.createElement)(
- Card,
+ isTile ? null : (0, import_react30.createElement)(
+ Card2,
{ title: t("Sidebar") },
- (0, import_react26.createElement)(SwitchRow, { label: t("Pin"), hint: t("Kept above the other chats."), on: bot.pinned === true, onChange: (pinned) => run2(actions.setFlags(bot.id, { pinned })) }),
- isMainBot ? null : (0, import_react26.createElement)(SwitchRow, { label: t("Hide from sidebar"), hint: t("Search still finds it."), on: bot.hidden === true, onChange: (hidden) => run2(actions.setFlags(bot.id, { hidden })) })
+ (0, import_react30.createElement)(SwitchRow, { label: t("Pin"), hint: t("Kept above the other chats."), on: bot.pinned === true, onChange: (pinned) => run2(actions.setFlags(bot.id, { pinned })) }),
+ isMainBot ? null : (0, import_react30.createElement)(SwitchRow, { label: t("Hide from sidebar"), hint: t("Search still finds it."), on: bot.hidden === true, onChange: (hidden) => run2(actions.setFlags(bot.id, { hidden })) })
),
- (0, import_react26.createElement)(
- Card,
+ (0, import_react30.createElement)(
+ Card2,
{ title: t("Manage") },
- (0, import_react26.createElement)(
+ (0, import_react30.createElement)(
"button",
{ type: "button", className: "bt-set-row bt-bs-row", onClick: duplicate },
- (0, import_react26.createElement)("span", { className: "bt-set-copy" }, (0, import_react26.createElement)("span", { className: "bt-bs-label" }, t("Duplicate")), (0, import_react26.createElement)("span", { className: "bt-set-hint" }, t("A copy with the same job and model, and fresh memory."))),
- (0, import_react26.createElement)("span", { className: "bt-chevron" }, (0, import_react26.createElement)(ChevronRightIcon))
+ (0, import_react30.createElement)("span", { className: "bt-set-copy" }, (0, import_react30.createElement)("span", { className: "bt-bs-label" }, t("Duplicate")), (0, import_react30.createElement)("span", { className: "bt-set-hint" }, t("A copy with the same job and model, and fresh memory."))),
+ (0, import_react30.createElement)("span", { className: "bt-chevron" }, (0, import_react30.createElement)(ChevronRightIcon))
),
- isMainBot ? null : (0, import_react26.createElement)(
+ isMainBot ? null : (0, import_react30.createElement)(
"button",
{ type: "button", className: "bt-set-row bt-bs-row bt-bs-danger", "data-confirm": confirming || void 0, onClick: remove },
- (0, import_react26.createElement)(
+ (0, import_react30.createElement)(
"span",
{ className: "bt-set-copy" },
- (0, import_react26.createElement)("span", { className: "bt-bs-label" }, confirming ? t("Delete {name}?", { name: bot.name }) : t("Delete Bot")),
- (0, import_react26.createElement)("span", { className: "bt-set-hint" }, confirming ? t("Click again to delete. Its chats are archived.") : t("Removes the Bot from the team."))
+ (0, import_react30.createElement)("span", { className: "bt-bs-label" }, confirming ? t("Delete {name}?", { name: bot.name }) : t("Delete Bot")),
+ (0, import_react30.createElement)("span", { className: "bt-set-hint" }, confirming ? t("Click again to delete. Its chats are archived.") : t("Removes the Bot from the team."))
),
- (0, import_react26.createElement)("span", { className: "bt-chevron" }, (0, import_react26.createElement)(ChevronRightIcon))
+ (0, import_react30.createElement)("span", { className: "bt-chevron" }, (0, import_react30.createElement)(ChevronRightIcon))
)
)
);
@@ -12550,7 +12904,7 @@ function createPayload({ name, look, image, model, effort, brief }) {
}
// src/client/create-bot.js
-var import_react27 = require("react");
+var import_react31 = require("react");
var pick = (list) => list[Math.floor(Math.random() * list.length)];
var randomLook = (avoid = {}) => {
const shapes = DEFAULT_SHAPES.filter((shape) => shape !== avoid.shape);
@@ -12558,17 +12912,17 @@ var randomLook = (avoid = {}) => {
return { shape: pick(shapes), color: pick(colors) };
};
function CreateBot({ roster, actions, start, brief = "", onBack, canGoBack, onCreated, inline = false }) {
- const [look, setLook] = (0, import_react27.useState)(() => randomLook());
- const [image, setImage] = (0, import_react27.useState)(null);
- const [name, setName] = (0, import_react27.useState)(start?.name ?? "");
- const [model, setModel] = (0, import_react27.useState)(() => startModel(roster));
- const [effort, setEffort] = (0, import_react27.useState)(void 0);
- const [busy, setBusy] = (0, import_react27.useState)(false);
- const [error, setError] = (0, import_react27.useState)("");
- const fileRef = (0, import_react27.useRef)(null);
- const frame = (0, import_react27.useRef)(null);
+ const [look, setLook] = (0, import_react31.useState)(() => randomLook());
+ const [image, setImage] = (0, import_react31.useState)(null);
+ const [name, setName] = (0, import_react31.useState)(start?.name ?? "");
+ const [model, setModel] = (0, import_react31.useState)(() => startModel(roster));
+ const [effort, setEffort] = (0, import_react31.useState)(void 0);
+ const [busy, setBusy] = (0, import_react31.useState)(false);
+ const [error, setError] = (0, import_react31.useState)("");
+ const fileRef = (0, import_react31.useRef)(null);
+ const frame = (0, import_react31.useRef)(null);
useEscape(onBack);
- (0, import_react27.useEffect)(() => {
+ (0, import_react31.useEffect)(() => {
if (inline) frame.current?.scrollIntoView({ block: "start", behavior: "smooth" });
}, []);
const fallbackName = freshBotName(roster, t("New Bot"));
@@ -12593,25 +12947,25 @@ function CreateBot({ roster, actions, start, brief = "", onBack, canGoBack, onCr
avatarImage(file).then(setImage, (failure) => setError(failure?.message ?? String(failure)));
};
const previewLook = image ? { ...look, image } : look;
- const card = (0, import_react27.createElement)(
+ const card = (0, import_react31.createElement)(
"div",
{ className: "bt-create-card" },
- (0, import_react27.createElement)(
+ (0, import_react31.createElement)(
"div",
{ className: "bt-create-preview" },
// The key remounts the mark, so every new pick plays the pop.
- (0, import_react27.createElement)(
+ (0, import_react31.createElement)(
"span",
{ key: `${look.shape}:${look.color}:${image ? "photo" : ""}`, className: "bt-create-pop" },
- (0, import_react27.createElement)(BotMark, { look: previewLook, bot: { id: "new-bot" }, size: 88, live: true, gaze: true, pokeable: true })
+ (0, import_react31.createElement)(BotMark, { look: previewLook, bot: { id: "new-bot" }, size: 88, live: true, gaze: true, pokeable: true })
),
- (0, import_react27.createElement)("span", { className: "bt-create-name" }, finalName)
+ (0, import_react31.createElement)("span", { className: "bt-create-name" }, finalName)
),
- (0, import_react27.createElement)("div", { className: "bt-create-step" }, t("Look")),
- (0, import_react27.createElement)(
+ (0, import_react31.createElement)("div", { className: "bt-create-step" }, t("Look")),
+ (0, import_react31.createElement)(
"div",
{ className: "bt-create-looks" },
- (0, import_react27.createElement)(CharacterGrid, {
+ (0, import_react31.createElement)(CharacterGrid, {
look,
hasPhoto: Boolean(image),
onShape: (shape) => {
@@ -12623,27 +12977,27 @@ function CreateBot({ roster, actions, start, brief = "", onBack, canGoBack, onCr
setLook((current) => ({ ...current, color }));
}
}),
- (0, import_react27.createElement)(
+ (0, import_react31.createElement)(
"div",
{ className: "bt-actions bt-create-lookbar" },
- (0, import_react27.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => {
+ (0, import_react31.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => {
setImage(null);
setLook((current) => randomLook(current));
} }, t("Shuffle")),
- (0, import_react27.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => fileRef.current?.click() }, image ? t("Replace photo") : t("Upload photo")),
- image ? (0, import_react27.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setImage(null) }, t("Remove photo")) : null,
- (0, import_react27.createElement)("input", { ref: fileRef, type: "file", accept: "image/png,image/jpeg,image/webp,image/gif", hidden: true, onChange: (event) => {
+ (0, import_react31.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => fileRef.current?.click() }, image ? t("Replace photo") : t("Upload photo")),
+ image ? (0, import_react31.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setImage(null) }, t("Remove photo")) : null,
+ (0, import_react31.createElement)("input", { ref: fileRef, type: "file", accept: "image/png,image/jpeg,image/webp,image/gif", hidden: true, onChange: (event) => {
const file = event.target.files?.[0];
event.target.value = "";
upload(file);
} })
)
),
- (0, import_react27.createElement)(
+ (0, import_react31.createElement)(
"label",
{ className: "bt-field" },
- (0, import_react27.createElement)("span", { className: "bt-field-label" }, t("Name")),
- (0, import_react27.createElement)("input", {
+ (0, import_react31.createElement)("span", { className: "bt-field-label" }, t("Name")),
+ (0, import_react31.createElement)("input", {
className: "bt-input",
autoFocus: !inline,
value: name,
@@ -12658,54 +13012,54 @@ function CreateBot({ roster, actions, start, brief = "", onBack, canGoBack, onCr
}
}
}),
- problem ? (0, import_react27.createElement)("span", { className: "bt-note bt-danger" }, hostText(problem)) : clash ? (0, import_react27.createElement)("span", { className: "bt-note bt-danger" }, t("A Bot named {name} already exists", { name: finalName })) : null
+ problem ? (0, import_react31.createElement)("span", { className: "bt-note bt-danger" }, hostText(problem)) : clash ? (0, import_react31.createElement)("span", { className: "bt-note bt-danger" }, t("A Bot named {name} already exists", { name: finalName })) : null
),
- (0, import_react27.createElement)(
+ (0, import_react31.createElement)(
"div",
{ className: "bt-field" },
- (0, import_react27.createElement)("span", { className: "bt-field-label" }, t("Model")),
- (0, import_react27.createElement)(ModelMenu, { bot: { id: "new-bot", name: finalName, model: model || void 0, effort }, roster, actions, wide: true, onPick: (ref) => {
+ (0, import_react31.createElement)("span", { className: "bt-field-label" }, t("Model")),
+ (0, import_react31.createElement)(ModelMenu, { bot: { id: "new-bot", name: finalName, model: model || void 0, effort }, roster, actions, wide: true, onPick: (ref) => {
setModel(ref);
setEffort(void 0);
}, onPickEffort: (picked) => setEffort(picked ?? null) }),
- (0, import_react27.createElement)("span", { className: "bt-note" }, (roster.models ?? []).length > 0 ? t("The Bot runs on this model. You can change it later in its details.") : t("Add a provider and a model in DeepSeek Harness first, or pick one in the Bot's chat later."))
+ (0, import_react31.createElement)("span", { className: "bt-note" }, (roster.models ?? []).length > 0 ? t("The Bot runs on this model. You can change it later in its details.") : t("Add a provider and a model in DeepSeek Harness first, or pick one in the Bot's chat later."))
),
- error ? (0, import_react27.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : null,
- (0, import_react27.createElement)(
+ error ? (0, import_react31.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : null,
+ (0, import_react31.createElement)(
"div",
{ className: "bt-create-foot" },
- (0, import_react27.createElement)("button", { type: "button", className: "bt-soft", onClick: onBack }, canGoBack ? t("Back") : t("Cancel")),
- (0, import_react27.createElement)("button", { type: "button", className: "bt-send bt-create-go", disabled: busy || clash || Boolean(problem), onClick: () => void create() }, busy ? t("Creating…") : t("Create"))
+ (0, import_react31.createElement)("button", { type: "button", className: "bt-soft", onClick: onBack }, canGoBack ? t("Back") : t("Cancel")),
+ (0, import_react31.createElement)("button", { type: "button", className: "bt-send bt-create-go", disabled: busy || clash || Boolean(problem), onClick: () => void create() }, busy ? t("Creating…") : t("Create"))
)
);
- if (inline) return (0, import_react27.createElement)("div", { ref: frame, className: "bt-create-inline", role: "group", "aria-label": t("Create Bot") }, card);
- return (0, import_react27.createElement)(
+ if (inline) return (0, import_react31.createElement)("div", { ref: frame, className: "bt-create-inline", role: "group", "aria-label": t("Create Bot") }, card);
+ return (0, import_react31.createElement)(
"div",
{ className: "bt-create", role: "dialog", "aria-label": t("Create Bot") },
- (0, import_react27.createElement)(
+ (0, import_react31.createElement)(
"div",
{ className: "bt-create-head" },
- canGoBack ? (0, import_react27.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Back to new chat"), onClick: onBack }, (0, import_react27.createElement)(ChevronLeftIcon)) : (0, import_react27.createElement)("span", { className: "bt-create-gap" }),
- (0, import_react27.createElement)("span", { className: "bt-create-title" }, t("Create Bot")),
- (0, import_react27.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Close"), onClick: () => actions.closeOverlay() }, (0, import_react27.createElement)(CloseIcon))
+ canGoBack ? (0, import_react31.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Back to new chat"), onClick: onBack }, (0, import_react31.createElement)(ChevronLeftIcon)) : (0, import_react31.createElement)("span", { className: "bt-create-gap" }),
+ (0, import_react31.createElement)("span", { className: "bt-create-title" }, t("Create Bot")),
+ (0, import_react31.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Close"), onClick: () => actions.closeOverlay() }, (0, import_react31.createElement)(CloseIcon))
),
- (0, import_react27.createElement)("div", { className: "bt-create-body" }, card)
+ (0, import_react31.createElement)("div", { className: "bt-create-body" }, card)
);
}
// src/client/new-chat.js
-var import_react28 = require("react");
+var import_react32 = require("react");
function NewChat({ mode, roster, actions }) {
- const [query, setQuery] = (0, import_react28.useState)("");
- const [picked, setPicked] = (0, import_react28.useState)([]);
- const [group, setGroup] = (0, import_react28.useState)(mode === "group");
- const [admin, setAdmin] = (0, import_react28.useState)(null);
- const [message, setMessage] = (0, import_react28.useState)("");
- const [busy, setBusy] = (0, import_react28.useState)(false);
- const [error, setError] = (0, import_react28.useState)("");
- const [cursor, setCursor] = (0, import_react28.useState)(0);
- const [draft, setDraft] = (0, import_react28.useState)(mode === "create" ? { name: "", fromList: false } : null);
- const inputRef = (0, import_react28.useRef)(null);
+ const [query, setQuery] = (0, import_react32.useState)("");
+ const [picked, setPicked] = (0, import_react32.useState)([]);
+ const [group, setGroup] = (0, import_react32.useState)(mode === "group");
+ const [admin, setAdmin] = (0, import_react32.useState)(null);
+ const [message, setMessage] = (0, import_react32.useState)("");
+ const [busy, setBusy] = (0, import_react32.useState)(false);
+ const [error, setError] = (0, import_react32.useState)("");
+ const [cursor, setCursor] = (0, import_react32.useState)(0);
+ const [draft, setDraft] = (0, import_react32.useState)(mode === "create" ? { name: "", fromList: false } : null);
+ const inputRef = (0, import_react32.useRef)(null);
const close = () => actions.closeOverlay();
useEscape(close);
const paneLeft = usePaneLeft();
@@ -12791,14 +13145,14 @@ function NewChat({ mode, roster, actions }) {
});
const options = [];
if (!group && picked.length === 0 && mode !== "search" && wanted === "") {
- options.push({ key: "new", icon: (0, import_react28.createElement)(PlusIcon), label: t("Create new Bot"), run: createBot });
- options.push({ key: "group", icon: (0, import_react28.createElement)(PeopleIcon), label: t("Create group chat"), run: () => {
+ options.push({ key: "new", icon: (0, import_react32.createElement)(PlusIcon), label: t("Create new Bot"), run: createBot });
+ options.push({ key: "group", icon: (0, import_react32.createElement)(PeopleIcon), label: t("Create group chat"), run: () => {
setGroup(true);
setCursor(0);
inputRef.current?.focus();
} });
if ((roster.agents ?? []).length === 0 && actions.addAgent) {
- options.push({ key: "agent", icon: (0, import_react28.createElement)(import_dsh_client_ui_primitives.FishLogo, { size: 16 }), label: t("Add DSH Agent"), run: () => run2(async () => {
+ options.push({ key: "agent", icon: (0, import_react32.createElement)(import_dsh_client_ui_primitives.FishLogo, { size: 16 }), label: t("Add DSH Agent"), run: () => run2(async () => {
await actions.addAgent();
close();
}) });
@@ -12807,19 +13161,19 @@ function NewChat({ mode, roster, actions }) {
for (const bot of matches) {
options.push({ key: bot.id, bot, label: bot.name, hint: choosingAdmin ? t("Make admin") : group || picked.length > 0 ? t("Add to group chat") : void 0, run: () => openBot(bot) });
}
- if (wanted !== "" && !exact && mode !== "search") options.push({ key: "create", icon: (0, import_react28.createElement)(PlusIcon), label: t("Create new Bot “{name}”", { name: query.trim() }), run: createBot });
+ if (wanted !== "" && !exact && mode !== "search") options.push({ key: "create", icon: (0, import_react32.createElement)(PlusIcon), label: t("Create new Bot “{name}”", { name: query.trim() }), run: createBot });
const active = Math.min(cursor, Math.max(options.length - 1, 0));
const listed = options.map((option) => option.key).join("\n");
const glide = useGlide(`${active}
${listed}`, { axis: "y", ...QUICK_EDGES });
useFlip(glide.box, listed, "[data-flip]");
- const drop = (0, import_react28.useRef)(null);
+ const drop = (0, import_react32.useRef)(null);
useMorph(drop, listed);
if (draft) {
- return (0, import_react28.createElement)(
+ return (0, import_react32.createElement)(
"div",
{ className: "bt-pane", style: { left: paneLeft } },
- (0, import_react28.createElement)(CreateBot, {
+ (0, import_react32.createElement)(CreateBot, {
roster,
actions,
start: draft,
@@ -12840,33 +13194,33 @@ ${listed}`, { axis: "y", ...QUICK_EDGES });
if (picked.length > 0) setPicked((current) => current.slice(0, -1));
else if (admin !== null) setAdmin(null);
};
- return (0, import_react28.createElement)(
+ return (0, import_react32.createElement)(
"div",
{ className: "bt-pane", style: { left: paneLeft } },
- (0, import_react28.createElement)(
+ (0, import_react32.createElement)(
"div",
{ className: "bt-newchat", role: "dialog", "aria-label": mode === "search" ? t("Search") : t("New chat") },
- (0, import_react28.createElement)(
+ (0, import_react32.createElement)(
"div",
{ className: "bt-to" },
- (0, import_react28.createElement)("span", { className: "bt-to-label" }, t("To:")),
- adminBot ? (0, import_react28.createElement)(
+ (0, import_react32.createElement)("span", { className: "bt-to-label" }, t("To:")),
+ adminBot ? (0, import_react32.createElement)(
"span",
{ key: adminBot.id, className: "bt-token bt-token-admin", title: t("Admin") },
- (0, import_react28.createElement)(BotMark, { bot: adminBot, size: 16 }),
+ (0, import_react32.createElement)(BotMark, { bot: adminBot, size: 16 }),
adminBot.name,
- (0, import_react28.createElement)(AdminStar),
- (0, import_react28.createElement)("button", { type: "button", "aria-label": t("Remove {name}", { name: adminBot.name }), onClick: () => setAdmin(null) }, "×")
+ (0, import_react32.createElement)(AdminStar),
+ (0, import_react32.createElement)("button", { type: "button", "aria-label": t("Remove {name}", { name: adminBot.name }), onClick: () => setAdmin(null) }, "×")
) : null,
- choosingAdmin ? (0, import_react28.createElement)("span", { className: "bt-to-star", "aria-hidden": true }, (0, import_react28.createElement)(AdminStar)) : null,
- pickedBots.map((bot) => (0, import_react28.createElement)(
+ choosingAdmin ? (0, import_react32.createElement)("span", { className: "bt-to-star", "aria-hidden": true }, (0, import_react32.createElement)(AdminStar)) : null,
+ pickedBots.map((bot) => (0, import_react32.createElement)(
"span",
{ key: bot.id, className: "bt-token" },
- (0, import_react28.createElement)(BotMark, { bot, size: 16 }),
+ (0, import_react32.createElement)(BotMark, { bot, size: 16 }),
bot.name,
- (0, import_react28.createElement)("button", { type: "button", "aria-label": t("Remove {name}", { name: bot.name }), onClick: () => setPicked((current) => current.filter((id) => id !== bot.id)) }, "×")
+ (0, import_react32.createElement)("button", { type: "button", "aria-label": t("Remove {name}", { name: bot.name }), onClick: () => setPicked((current) => current.filter((id) => id !== bot.id)) }, "×")
)),
- (0, import_react28.createElement)("input", {
+ (0, import_react32.createElement)("input", {
ref: inputRef,
autoFocus: true,
value: query,
@@ -12890,20 +13244,20 @@ ${listed}`, { axis: "y", ...QUICK_EDGES });
} else if (event.key === "Backspace" && query === "") unpick();
}
}),
- group && admin !== null ? (0, import_react28.createElement)("button", {
+ group && admin !== null ? (0, import_react32.createElement)("button", {
type: "button",
className: "bt-send bt-to-create",
disabled: busy || picked.length === 0,
title: picked.length === 0 ? t("Add at least one more Bot") : void 0,
onClick: createGroup
}, t("Create group chat")) : null,
- (0, import_react28.createElement)("button", { type: "button", className: "bt-x", "aria-label": t("Close new chat"), onClick: close }, "×")
+ (0, import_react32.createElement)("button", { type: "button", className: "bt-x", "aria-label": t("Close new chat"), onClick: close }, "×")
),
- (0, import_react28.createElement)("div", { ref: drop, className: "bt-drop" }, (0, import_react28.createElement)(
+ (0, import_react32.createElement)("div", { ref: drop, className: "bt-drop" }, (0, import_react32.createElement)(
"div",
{ ref: glide.box, role: "listbox", "aria-label": t("Recipients"), className: "bt-drop-list" },
- (0, import_react28.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),
- options.length === 0 ? (0, import_react28.createElement)("div", { className: "bt-hint" }, mode === "search" ? t("No Bots match") : t("Type a name to create a Bot")) : options.map((option, index) => (0, import_react28.createElement)(
+ (0, import_react32.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),
+ options.length === 0 ? (0, import_react32.createElement)("div", { className: "bt-hint" }, mode === "search" ? t("No Bots match") : t("Type a name to create a Bot")) : options.map((option, index) => (0, import_react32.createElement)(
"button",
{
key: option.key,
@@ -12915,21 +13269,21 @@ ${listed}`, { axis: "y", ...QUICK_EDGES });
onMouseEnter: () => setCursor(index),
onClick: option.run
},
- option.bot ? (0, import_react28.createElement)(BotMark, { bot: option.bot, size: 22 }) : (0, import_react28.createElement)("span", { className: "bt-option-icon" }, option.icon),
- (0, import_react28.createElement)("span", { className: "bt-option-label" }, option.label),
- option.hint && index === active ? (0, import_react28.createElement)("span", { className: "bt-option-hint" }, option.hint) : null
+ option.bot ? (0, import_react32.createElement)(BotMark, { bot: option.bot, size: 22 }) : (0, import_react32.createElement)("span", { className: "bt-option-icon" }, option.icon),
+ (0, import_react32.createElement)("span", { className: "bt-option-label" }, option.label),
+ option.hint && index === active ? (0, import_react32.createElement)("span", { className: "bt-option-hint" }, option.hint) : null
))
)),
- (0, import_react28.createElement)("div", { className: "bt-nc-spacer" }),
- error ? (0, import_react28.createElement)("div", { className: "bt-error" }, error) : null,
- (0, import_react28.createElement)(
+ (0, import_react32.createElement)("div", { className: "bt-nc-spacer" }),
+ error ? (0, import_react32.createElement)("div", { className: "bt-error" }, error) : null,
+ (0, import_react32.createElement)(
"div",
{ className: "bt-nc-compose" },
- (0, import_react28.createElement)(
+ (0, import_react32.createElement)(
"div",
{ className: "bt-nc-card" },
- (0, import_react28.createElement)("span", { className: "bt-nc-plus", "aria-hidden": true }, (0, import_react28.createElement)(PlusIcon)),
- (0, import_react28.createElement)("textarea", {
+ (0, import_react32.createElement)("span", { className: "bt-nc-plus", "aria-hidden": true }, (0, import_react32.createElement)(PlusIcon)),
+ (0, import_react32.createElement)("textarea", {
rows: 1,
value: message,
placeholder,
@@ -12942,7 +13296,7 @@ ${listed}`, { axis: "y", ...QUICK_EDGES });
}
}
}),
- (0, import_react28.createElement)("button", { type: "button", className: "bt-nc-send", "aria-label": t("Send message"), disabled: busy || message.trim() === "" || picked.length === 0, onClick: sendMessage }, (0, import_react28.createElement)(ArrowUpIcon))
+ (0, import_react32.createElement)("button", { type: "button", className: "bt-nc-send", "aria-label": t("Send message"), disabled: busy || message.trim() === "" || picked.length === 0, onClick: sendMessage }, (0, import_react32.createElement)(ArrowUpIcon))
)
)
)
@@ -12950,14 +13304,14 @@ ${listed}`, { axis: "y", ...QUICK_EDGES });
}
// src/client/exchange.js
-var import_react29 = require("react");
+var import_react33 = require("react");
var SHEET_EXIT_MS = 220;
function ExchangeDialog({ pair, roster, actions }) {
- const [entries2, setEntries] = (0, import_react29.useState)(null);
- const [leaving, setLeaving] = (0, import_react29.useState)(false);
- const log = (0, import_react29.useRef)(null);
- const atEnd = (0, import_react29.useRef)(true);
- (0, import_react29.useLayoutEffect)(() => {
+ const [entries2, setEntries] = (0, import_react33.useState)(null);
+ const [leaving, setLeaving] = (0, import_react33.useState)(false);
+ const log = (0, import_react33.useRef)(null);
+ const atEnd = (0, import_react33.useRef)(true);
+ (0, import_react33.useLayoutEffect)(() => {
if (entries2 !== null && atEnd.current && log.current) log.current.scrollTop = log.current.scrollHeight;
}, [entries2]);
const close = () => {
@@ -12966,7 +13320,7 @@ function ExchangeDialog({ pair, roster, actions }) {
setTimeout(() => actions.closeOverlay(), SHEET_EXIT_MS);
};
useEscape(close);
- (0, import_react29.useEffect)(() => {
+ (0, import_react33.useEffect)(() => {
let stop = false;
let timer;
let seen = null;
@@ -12993,53 +13347,53 @@ function ExchangeDialog({ pair, roster, actions }) {
const flat = layoutOf(roster.prefs) === "flat";
let lastDay = 0;
const paneLeft = usePaneLeft();
- return (0, import_react29.createElement)(
+ return (0, import_react33.createElement)(
"div",
{ className: "bt-pane bt-exchange", style: { left: paneLeft }, "data-leaving": leaving || void 0 },
- (0, import_react29.createElement)(
+ (0, import_react33.createElement)(
"div",
{ className: "bt-dialog", role: "dialog", "aria-label": t("Bot exchange") },
- (0, import_react29.createElement)("div", { className: "bt-head" }, (0, import_react29.createElement)(
+ (0, import_react33.createElement)("div", { className: "bt-head" }, (0, import_react33.createElement)(
"span",
{ className: "bt-pill", style: { cursor: "default" } },
- left ? (0, import_react29.createElement)(BotMark, { bot: left, size: 22 }) : null,
+ left ? (0, import_react33.createElement)(BotMark, { bot: left, size: 22 }) : null,
left?.name ?? "?",
- (0, import_react29.createElement)("span", { className: "bt-swap" }, "⇄"),
- right ? (0, import_react29.createElement)(BotMark, { bot: right, size: 22 }) : null,
+ (0, import_react33.createElement)("span", { className: "bt-swap" }, "⇄"),
+ right ? (0, import_react33.createElement)(BotMark, { bot: right, size: 22 }) : null,
right?.name ?? "?"
)),
- (0, import_react29.createElement)(
+ (0, import_react33.createElement)(
"div",
{ ref: log, className: "bt-dialog-log", role: "log", "aria-label": t("Bot exchange transcript"), onScroll: (event) => {
const node = event.currentTarget;
atEnd.current = node.scrollHeight - node.scrollTop - node.clientHeight < 2;
} },
- entries2 === null ? (0, import_react29.createElement)("div", { className: "bt-hint" }, t("Loading…")) : entries2.length === 0 ? (0, import_react29.createElement)("div", { className: "bt-hint" }, t("No messages yet")) : entries2.map((entry) => {
+ entries2 === null ? (0, import_react33.createElement)("div", { className: "bt-hint" }, t("Loading…")) : entries2.length === 0 ? (0, import_react33.createElement)("div", { className: "bt-hint" }, t("No messages yet")) : entries2.map((entry) => {
const bot = roster.byId[entry.from] ?? { id: entry.from, name: t("You"), color: "gray" };
const showDay = entry.time - lastDay > 30 * 60 * 1e3;
lastDay = entry.time;
const whole = entry.length === void 0 ? void 0 : { length: entry.length, load: () => actions.exchangeText(entry.id) };
- const lead = (0, import_react29.createElement)("span", { className: "bt-lead" }, (0, import_react29.createElement)(BotMark, { bot, size: 22 }));
- return (0, import_react29.createElement)(
- import_react29.Fragment,
+ const lead = (0, import_react33.createElement)("span", { className: "bt-lead" }, (0, import_react33.createElement)(BotMark, { bot, size: 22 }));
+ return (0, import_react33.createElement)(
+ import_react33.Fragment,
{ key: entry.id },
- showDay ? (0, import_react29.createElement)("time", { className: "bt-time" }, dayLabel(entry.time)) : null,
- (0, import_react29.createElement)(
+ showDay ? (0, import_react33.createElement)("time", { className: "bt-time" }, dayLabel(entry.time)) : null,
+ (0, import_react33.createElement)(
"div",
{ className: "bt-group-msg" },
- (0, import_react29.createElement)("span", { className: "bt-group-name", style: flat ? void 0 : { color: inkText(colorOf(bot)) } }, flat ? lead : null, bot.name),
- (0, import_react29.createElement)(Bubbles, { texts: [stripLongNote(entry.text)], roster, selfId: bot.id, actions, whole, lead: flat ? null : lead })
+ (0, import_react33.createElement)("span", { className: "bt-group-name", style: flat ? void 0 : { color: inkText(colorOf(bot)) } }, flat ? lead : null, bot.name),
+ (0, import_react33.createElement)(Bubbles, { texts: [stripLongNote(entry.text)], roster, selfId: bot.id, actions, whole, lead: flat ? null : lead })
)
);
})
),
- (0, import_react29.createElement)("div", { className: "bt-dialog-foot" }, (0, import_react29.createElement)("button", { type: "button", className: "bt-soft", onClick: close }, t("Close Chat")))
+ (0, import_react33.createElement)("div", { className: "bt-dialog-foot" }, (0, import_react33.createElement)("button", { type: "button", className: "bt-soft", onClick: close }, t("Close Chat")))
)
);
}
// src/client/voice.js
-var import_react30 = require("react");
+var import_react34 = require("react");
var plainSpeech = (text) => stripHeader(text).replace(/```[\s\S]*?```/g, " ").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/[*_`#>|~-]+/g, " ").replace(/\s+/g, " ").trim();
var VOICE_LABELS = {
listening: "Listening",
@@ -13051,8 +13405,8 @@ var VOICE_LABELS = {
};
var CAPTURE_NOTES = { blocked: "Microphone access is blocked", unavailable: "Voice chat is not available in this browser", "too-long": "That was too long to recognize" };
function useMicLevel(enabled) {
- const [level, setLevel] = (0, import_react30.useState)(0);
- (0, import_react30.useEffect)(() => {
+ const [level, setLevel] = (0, import_react34.useState)(0);
+ (0, import_react34.useEffect)(() => {
if (!enabled || !navigator.mediaDevices?.getUserMedia) return void 0;
let stream = null;
let audio = null;
@@ -13102,18 +13456,18 @@ function VoiceMode({ sessionId, roster, actions, useSessions, useSessionStatus }
const entry = Array.isArray(outline) ? outline[outline.length - 1] : void 0;
return entry ? `${outline.length}|${entry.response ?? ""}` : "0|";
});
- const [speech] = (0, import_react30.useState)(() => actions.speech());
- const [phase, setPhase] = (0, import_react30.useState)(speech ? "starting" : speechApi() ? "listening" : "unsupported");
- const [catalog, setCatalog] = (0, import_react30.useState)(null);
- const [heard, setHeard] = (0, import_react30.useState)("");
- const [said, setSaid] = (0, import_react30.useState)("");
- const [note, setNote] = (0, import_react30.useState)("");
- const [serviceLevel, setServiceLevel] = (0, import_react30.useState)(0);
- const [cycle, setCycle] = (0, import_react30.useState)(0);
- const waiting = (0, import_react30.useRef)(null);
- const reply = (0, import_react30.useRef)(lastReply);
+ const [speech] = (0, import_react34.useState)(() => actions.speech());
+ const [phase, setPhase] = (0, import_react34.useState)(speech ? "starting" : speechApi() ? "listening" : "unsupported");
+ const [catalog, setCatalog] = (0, import_react34.useState)(null);
+ const [heard, setHeard] = (0, import_react34.useState)("");
+ const [said, setSaid] = (0, import_react34.useState)("");
+ const [note, setNote] = (0, import_react34.useState)("");
+ const [serviceLevel, setServiceLevel] = (0, import_react34.useState)(0);
+ const [cycle, setCycle] = (0, import_react34.useState)(0);
+ const waiting = (0, import_react34.useRef)(null);
+ const reply = (0, import_react34.useRef)(lastReply);
reply.current = lastReply;
- const turn = (0, import_react30.useRef)(0);
+ const turn = (0, import_react34.useRef)(0);
const paneLeft = usePaneLeft();
const close = () => {
turn.current += 1;
@@ -13133,12 +13487,12 @@ function VoiceMode({ sessionId, roster, actions, useSessions, useSessionStatus }
dictation.stop();
submit(text);
});
- (0, import_react30.useEffect)(() => {
+ (0, import_react34.useEffect)(() => {
if (!note) return void 0;
const timer = setTimeout(() => setNote(""), 2600);
return () => clearTimeout(timer);
}, [note]);
- (0, import_react30.useEffect)(() => {
+ (0, import_react34.useEffect)(() => {
if (!speech) return void 0;
let live = true;
speechCatalog(speech).then(({ catalog: next, usable }) => {
@@ -13153,16 +13507,16 @@ function VoiceMode({ sessionId, roster, actions, useSessions, useSessionStatus }
};
}, [speech]);
const listen = phase === "listening";
- (0, import_react30.useEffect)(() => {
+ (0, import_react34.useEffect)(() => {
if (speech || !listen || dictation.listening) return void 0;
const timer = setTimeout(() => dictation.start({ continuous: false, onEnd: () => {
} }), 250);
return () => clearTimeout(timer);
}, [listen, dictation.listening]);
- (0, import_react30.useEffect)(() => {
+ (0, import_react34.useEffect)(() => {
if (phase !== "listening") dictation.stop();
}, [phase]);
- (0, import_react30.useEffect)(() => {
+ (0, import_react34.useEffect)(() => {
if (!speech || !catalog || !listen) return void 0;
const own = turn.current;
let capture = null;
@@ -13224,7 +13578,7 @@ function VoiceMode({ sessionId, roster, actions, useSessions, useSessionStatus }
setServiceLevel(0);
};
}, [speech, catalog, listen, cycle]);
- (0, import_react30.useEffect)(() => {
+ (0, import_react34.useEffect)(() => {
if (phase !== "thinking" || running || waiting.current === null) return;
const [count, text] = [lastReply.slice(0, lastReply.indexOf("|")), lastReply.slice(lastReply.indexOf("|") + 1)];
if (count === waiting.current || !text.trim()) return;
@@ -13244,7 +13598,7 @@ function VoiceMode({ sessionId, roster, actions, useSessions, useSessionStatus }
window.speechSynthesis.cancel();
window.speechSynthesis.speak(utterance);
}, [phase, running, lastReply]);
- (0, import_react30.useEffect)(() => () => window.speechSynthesis?.cancel(), []);
+ (0, import_react34.useEffect)(() => () => window.speechSynthesis?.cancel(), []);
const micLevel = useMicLevel(!speech && phase === "listening" && dictation.listening);
const level = speech ? serviceLevel : micLevel;
const markState = phase === "thinking" || phase === "transcribing" ? "thinking" : phase === "speaking" ? "sending" : "idle";
@@ -13261,58 +13615,58 @@ function VoiceMode({ sessionId, roster, actions, useSessions, useSessionStatus }
const openSetup = phase === "setup" ? actions.voiceSetup() : null;
const caption = phase === "speaking" ? said : heard;
const shownNote = note || dictation.note;
- return (0, import_react30.createElement)(
+ return (0, import_react34.createElement)(
"div",
{ className: "bt-pane bt-voice-pane", style: { left: paneLeft } },
- (0, import_react30.createElement)(
+ (0, import_react34.createElement)(
"div",
{ className: "bt-voice-stage", role: "dialog", "aria-label": t("Voice chat with {name}", { name }), "data-phase": phase === "transcribing" ? "thinking" : phase },
- (0, import_react30.createElement)(
+ (0, import_react34.createElement)(
"div",
{ className: "bt-voice-orb", style: { "--bt-level": level } },
- (0, import_react30.createElement)("span", { className: "bt-voice-ring", "aria-hidden": true }),
- (0, import_react30.createElement)("span", { className: "bt-voice-ring bt-voice-ring-2", "aria-hidden": true }),
- bot ? (0, import_react30.createElement)(BotMark, { bot, size: 112, state: markState, live: true, gaze: phase === "listening" }) : room2 ? (0, import_react30.createElement)(RoomAvatar, { room: room2, roster, size: 112 }) : null
+ (0, import_react34.createElement)("span", { className: "bt-voice-ring", "aria-hidden": true }),
+ (0, import_react34.createElement)("span", { className: "bt-voice-ring bt-voice-ring-2", "aria-hidden": true }),
+ bot ? (0, import_react34.createElement)(BotMark, { bot, size: 112, state: markState, live: true, gaze: phase === "listening" }) : room2 ? (0, import_react34.createElement)(RoomAvatar, { room: room2, roster, size: 112 }) : null
),
- (0, import_react30.createElement)("div", { className: "bt-voice-name" }, name),
- (0, import_react30.createElement)(
+ (0, import_react34.createElement)("div", { className: "bt-voice-name" }, name),
+ (0, import_react34.createElement)(
"div",
{ className: "bt-voice-status", role: "status" },
- phase === "thinking" ? (0, import_react30.createElement)(Shimmer, null, t("Thinking…")) : phase === "transcribing" ? (0, import_react30.createElement)(Shimmer, null, t("Recognizing…")) : VOICE_LABELS[phase] ? t(VOICE_LABELS[phase]) : ""
+ phase === "thinking" ? (0, import_react34.createElement)(Shimmer, null, t("Thinking…")) : phase === "transcribing" ? (0, import_react34.createElement)(Shimmer, null, t("Recognizing…")) : VOICE_LABELS[phase] ? t(VOICE_LABELS[phase]) : ""
),
- (0, import_react30.createElement)("div", { className: "bt-voice-caption", key: `${phase}:${caption.slice(0, 12)}` }, caption),
- openSetup ? (0, import_react30.createElement)("button", { type: "button", className: "bt-voice-setup", onClick: () => {
+ (0, import_react34.createElement)("div", { className: "bt-voice-caption", key: `${phase}:${caption.slice(0, 12)}` }, caption),
+ openSetup ? (0, import_react34.createElement)("button", { type: "button", className: "bt-voice-setup", onClick: () => {
close();
openSetup();
} }, t("Set up voice input")) : null,
- shownNote ? (0, import_react30.createElement)("div", { className: "bt-voice-note" }, shownNote) : null
+ shownNote ? (0, import_react34.createElement)("div", { className: "bt-voice-note" }, shownNote) : null
),
- (0, import_react30.createElement)(
+ (0, import_react34.createElement)(
"div",
{ className: "bt-voice-bar" },
- (0, import_react30.createElement)("button", {
+ (0, import_react34.createElement)("button", {
type: "button",
className: "bt-voice-btn",
"aria-pressed": phase === "paused",
disabled: blocked,
"aria-label": phase === "paused" ? t("Resume listening") : t("Pause"),
onClick: togglePause
- }, (0, import_react30.createElement)(MicIcon, { size: 20 }), phase === "paused" ? (0, import_react30.createElement)("span", { className: "bt-voice-slash", "aria-hidden": true }) : null),
- (0, import_react30.createElement)("button", { type: "button", className: "bt-voice-btn bt-voice-end", "aria-label": t("End voice chat"), onClick: close }, (0, import_react30.createElement)(CloseIcon))
+ }, (0, import_react34.createElement)(MicIcon, { size: 20 }), phase === "paused" ? (0, import_react34.createElement)("span", { className: "bt-voice-slash", "aria-hidden": true }) : null),
+ (0, import_react34.createElement)("button", { type: "button", className: "bt-voice-btn bt-voice-end", "aria-label": t("End voice chat"), onClick: close }, (0, import_react34.createElement)(CloseIcon))
)
);
}
// src/client/permission-picker.js
-var import_react31 = require("react");
+var import_react35 = require("react");
var LABELS = { "read-only": "Read only", "workspace-write": "Workspace", "danger-full-access": "Full access" };
var DANGER = /* @__PURE__ */ new Set(["danger-full-access"]);
var presetDanger = (value) => DANGER.has(value);
var presetName = (value, catalog) => LABELS[value] ? t(LABELS[value]) : catalog?.options?.find((option) => option.value === value)?.name ?? value;
function PermissionPicker({ catalog, saved, onPick, repick = false }) {
- const [pending, setPending] = (0, import_react31.useState)(null);
- const flight = (0, import_react31.useRef)({ value: void 0, latest: void 0 });
- (0, import_react31.useEffect)(() => {
+ const [pending, setPending] = (0, import_react35.useState)(null);
+ const flight = (0, import_react35.useRef)({ value: void 0, latest: void 0 });
+ (0, import_react35.useEffect)(() => {
const flying = flight.current.value;
if (pending === saved && (flying === void 0 || flying === pending)) setPending(null);
}, [pending, saved]);
@@ -13339,10 +13693,10 @@ function PermissionPicker({ catalog, saved, onPick, repick = false }) {
}
send(value);
};
- return (0, import_react31.createElement)(
+ return (0, import_react35.createElement)(
Segmented,
{ label: t("Permissions"), value: current },
- catalog.options.map((option) => (0, import_react31.createElement)("button", {
+ catalog.options.map((option) => (0, import_react35.createElement)("button", {
key: option.value,
type: "button",
"aria-pressed": option.value === current,
@@ -13354,7 +13708,7 @@ function PermissionPicker({ catalog, saved, onPick, repick = false }) {
}
// src/client/group-settings.js
-var import_react32 = require("react");
+var import_react36 = require("react");
var ROOM_MODES = [
["admin", "Admin leads", "Plain messages go to the admin, who calls others with @Name."],
["everyone", "Everyone", "Every member answers in turn, admin first."]
@@ -13365,8 +13719,8 @@ function roomSubtitle(room2, roster) {
return [t("{count} members", { count: room2.members.length }), admin ? t("Admin {name}", { name: admin.name }) : t("No admin")].join(" · ");
}
function RelayLimitRow({ room: room2, update }) {
- const [draft, setDraft] = (0, import_react32.useState)(room2.relayLimit ?? "");
- (0, import_react32.useEffect)(() => setDraft(room2.relayLimit ?? ""), [room2.relayLimit]);
+ const [draft, setDraft] = (0, import_react36.useState)(room2.relayLimit ?? "");
+ (0, import_react36.useEffect)(() => setDraft(room2.relayLimit ?? ""), [room2.relayLimit]);
const save = () => {
const text = String(draft).trim();
if (text === "") {
@@ -13380,10 +13734,10 @@ function RelayLimitRow({ room: room2, update }) {
}
update({ relayLimit: limit });
};
- return (0, import_react32.createElement)(
+ return (0, import_react36.createElement)(
Row,
{ label: t("Pause Bot relays after"), hint: t("Counted since your last message in this group.") },
- (0, import_react32.createElement)("input", {
+ (0, import_react36.createElement)("input", {
className: "bt-bs-input bt-bs-num",
type: "number",
min: 1,
@@ -13405,26 +13759,26 @@ function RelayLimitRow({ room: room2, update }) {
function GroupPermission({ room: room2, catalog, update }) {
if (!catalog?.options?.length) return null;
const shared2 = room2.permission !== void 0;
- return (0, import_react32.createElement)(
- Card,
+ return (0, import_react36.createElement)(
+ Card2,
{ title: t("Permissions") },
- (0, import_react32.createElement)(SwitchRow, {
+ (0, import_react36.createElement)(SwitchRow, {
label: t("Same for every member"),
hint: t("Replaces each member's own permissions in this group."),
on: shared2,
onChange: (on) => update({ permission: on ? catalog.defaultPreset ?? catalog.options[0].value : null })
}),
- shared2 ? (0, import_react32.createElement)(
+ shared2 ? (0, import_react36.createElement)(
"div",
{ className: "bt-set-row bt-bs-row bt-bs-stack bt-gs-perm bt-veil" },
- (0, import_react32.createElement)(PermissionPicker, { catalog, saved: room2.permission, onPick: (permission) => update({ permission }) })
+ (0, import_react36.createElement)(PermissionPicker, { catalog, saved: room2.permission, onPick: (permission) => update({ permission }) })
) : null
);
}
function GroupSettingsForm({ room: room2, roster, actions, run: run2, onDeleted }) {
- const [adding, setAdding] = (0, import_react32.useState)(false);
- const [confirming, setConfirming] = (0, import_react32.useState)(false);
- (0, import_react32.useEffect)(() => {
+ const [adding, setAdding] = (0, import_react36.useState)(false);
+ const [confirming, setConfirming] = (0, import_react36.useState)(false);
+ (0, import_react36.useEffect)(() => {
if (!confirming) return void 0;
const timer = setTimeout(() => setConfirming(false), 4e3);
return () => clearTimeout(timer);
@@ -13448,41 +13802,41 @@ function GroupSettingsForm({ room: room2, roster, actions, run: run2, onDeleted
if (done) onDeleted?.();
});
};
- return (0, import_react32.createElement)(
+ return (0, import_react36.createElement)(
"div",
{ className: "bt-bs" },
- (0, import_react32.createElement)(
+ (0, import_react36.createElement)(
"div",
{ className: "bt-bs-hero" },
- (0, import_react32.createElement)(RoomAvatar, { room: room2, roster, size: 64 }),
- (0, import_react32.createElement)(
+ (0, import_react36.createElement)(RoomAvatar, { room: room2, roster, size: 64 }),
+ (0, import_react36.createElement)(
"div",
{ className: "bt-bs-who" },
- (0, import_react32.createElement)("span", { className: "bt-bs-name" }, room2.name),
- (0, import_react32.createElement)("span", { className: "bt-bs-sub" }, roomSubtitle(room2, roster))
+ (0, import_react36.createElement)("span", { className: "bt-bs-name" }, room2.name),
+ (0, import_react36.createElement)("span", { className: "bt-bs-sub" }, roomSubtitle(room2, roster))
)
),
- (0, import_react32.createElement)(
- Card,
+ (0, import_react36.createElement)(
+ Card2,
{ title: t("Profile") },
- (0, import_react32.createElement)(
+ (0, import_react36.createElement)(
Row,
{ label: t("Name"), hint: t("Leave it empty to name the group after its members.") },
- (0, import_react32.createElement)(InlineText, { label: t("Group name"), value: room2.named ? room2.name : "", placeholder: t("Name after members"), maxLength: 60, onSave: (name) => update({ name }) })
+ (0, import_react36.createElement)(InlineText, { label: t("Group name"), value: room2.named ? room2.name : "", placeholder: t("Name after members"), maxLength: 60, onSave: (name) => update({ name }) })
),
- (0, import_react32.createElement)(
+ (0, import_react36.createElement)(
Row,
{ label: t("Notice"), hint: t("Every member reads it before speaking in this group."), stack: true },
- (0, import_react32.createElement)(InlineText, { label: t("Group notice"), value: room2.notice, multiline: true, maxLength: 2e3, placeholder: t("Shared instructions every member reads before speaking…"), onSave: (notice) => update({ notice }) })
+ (0, import_react36.createElement)(InlineText, { label: t("Group notice"), value: room2.notice, multiline: true, maxLength: 2e3, placeholder: t("Shared instructions every member reads before speaking…"), onSave: (notice) => update({ notice }) })
)
),
- (0, import_react32.createElement)(
- Card,
+ (0, import_react36.createElement)(
+ Card2,
{ title: t("Who answers") },
- (0, import_react32.createElement)(
+ (0, import_react36.createElement)(
"div",
{ className: "bt-set-row bt-bs-row bt-bs-stack" },
- (0, import_react32.createElement)(Segmented, { label: t("Who answers"), value: mode }, ROOM_MODES.map(([id, label]) => (0, import_react32.createElement)("button", {
+ (0, import_react36.createElement)(Segmented, { label: t("Who answers"), value: mode }, ROOM_MODES.map(([id, label]) => (0, import_react36.createElement)("button", {
key: id,
type: "button",
"aria-pressed": mode === id,
@@ -13492,88 +13846,88 @@ function GroupSettingsForm({ room: room2, roster, actions, run: run2, onDeleted
if (mode !== id) void update({ mode: id });
}
}, t(label)))),
- (0, import_react32.createElement)("span", { key: mode, className: "bt-set-hint bt-veil" }, `${t(modeHint)} ${t("@mentions always pick who answers.")}`)
+ (0, import_react36.createElement)("span", { key: mode, className: "bt-set-hint bt-veil" }, `${t(modeHint)} ${t("@mentions always pick who answers.")}`)
),
- (0, import_react32.createElement)(RelayLimitRow, { room: room2, update })
+ (0, import_react36.createElement)(RelayLimitRow, { room: room2, update })
),
- (0, import_react32.createElement)(
- Card,
+ (0, import_react36.createElement)(
+ Card2,
{ title: t("Working folder") },
- (0, import_react32.createElement)(
+ (0, import_react36.createElement)(
"div",
{ className: "bt-set-row bt-bs-row" },
- (0, import_react32.createElement)("span", { className: "bt-set-copy" }, (0, import_react32.createElement)("span", { className: "bt-bs-label" }, t("Folder"))),
- (0, import_react32.createElement)(FolderMenu, { value: room2.workDir, group: true, actions, run: run2, onPick: (workDir) => update({ workDir }) })
+ (0, import_react36.createElement)("span", { className: "bt-set-copy" }, (0, import_react36.createElement)("span", { className: "bt-bs-label" }, t("Folder"))),
+ (0, import_react36.createElement)(FolderMenu, { value: room2.workDir, group: true, actions, run: run2, onPick: (workDir) => update({ workDir }) })
)
),
- (0, import_react32.createElement)(GroupPermission, { room: room2, catalog: roster.permissions, update }),
- (0, import_react32.createElement)(
- Card,
+ (0, import_react36.createElement)(GroupPermission, { room: room2, catalog: roster.permissions, update }),
+ (0, import_react36.createElement)(
+ Card2,
{ title: t("Members · {count}", { count: members.length }) },
members.map((member) => {
const leads = room2.admin === member.id;
- return (0, import_react32.createElement)(
+ return (0, import_react36.createElement)(
"div",
{ key: member.id, className: "bt-set-row bt-bs-row bt-gs-member" },
- (0, import_react32.createElement)(
+ (0, import_react36.createElement)(
"button",
{ type: "button", className: "bt-gs-who", title: t("Open {name}'s chat", { name: member.name }), onClick: () => openBot(member.id) },
- (0, import_react32.createElement)(BotAvatar, { bot: member, size: 26, main: isMainOf(roster, member.id), admin: leads, live: false }),
- (0, import_react32.createElement)("span", { className: "bt-row-title" }, member.name),
- leads ? (0, import_react32.createElement)("span", { className: "bt-tag" }, t("Admin")) : null
+ (0, import_react36.createElement)(BotAvatar, { bot: member, size: 26, main: isMainOf(roster, member.id), admin: leads, live: false }),
+ (0, import_react36.createElement)("span", { className: "bt-row-title" }, member.name),
+ leads ? (0, import_react36.createElement)("span", { className: "bt-tag" }, t("Admin")) : null
),
- leads ? (0, import_react32.createElement)("button", { type: "button", className: "bt-mini", title: t("Leave the group without an admin"), onClick: () => update({ admin: null }) }, t("Unset")) : (0, import_react32.createElement)("button", { type: "button", className: "bt-mini", onClick: () => update({ admin: member.id }) }, t("Make admin")),
- members.length > 2 ? (0, import_react32.createElement)("button", { type: "button", className: "bt-x", "aria-label": t("Remove {name} from the group", { name: member.name }), title: t("Remove from group"), onClick: () => update({ remove: [member.id] }) }, "×") : null
+ leads ? (0, import_react36.createElement)("button", { type: "button", className: "bt-mini", title: t("Leave the group without an admin"), onClick: () => update({ admin: null }) }, t("Unset")) : (0, import_react36.createElement)("button", { type: "button", className: "bt-mini", onClick: () => update({ admin: member.id }) }, t("Make admin")),
+ members.length > 2 ? (0, import_react36.createElement)("button", { type: "button", className: "bt-x", "aria-label": t("Remove {name} from the group", { name: member.name }), title: t("Remove from group"), onClick: () => update({ remove: [member.id] }) }, "×") : null
);
}),
adding ? [
- ...outside.map((bot) => (0, import_react32.createElement)(
+ ...outside.map((bot) => (0, import_react36.createElement)(
"button",
{ key: bot.id, type: "button", className: "bt-set-row bt-bs-row bt-gs-pick", onClick: () => {
setAdding(false);
void update({ add: [bot.id] });
} },
- (0, import_react32.createElement)(BotMark, { bot, size: 22 }),
- (0, import_react32.createElement)("span", { className: "bt-set-copy" }, (0, import_react32.createElement)("span", { className: "bt-bs-label" }, bot.name)),
- (0, import_react32.createElement)("span", { className: "bt-set-hint" }, t("Add"))
+ (0, import_react36.createElement)(BotMark, { bot, size: 22 }),
+ (0, import_react36.createElement)("span", { className: "bt-set-copy" }, (0, import_react36.createElement)("span", { className: "bt-bs-label" }, bot.name)),
+ (0, import_react36.createElement)("span", { className: "bt-set-hint" }, t("Add"))
)),
- (0, import_react32.createElement)("button", { key: "cancel", type: "button", className: "bt-set-row bt-bs-row bt-gs-add", onClick: () => setAdding(false) }, t("Cancel"))
- ] : outside.length > 0 ? (0, import_react32.createElement)("button", { type: "button", className: "bt-set-row bt-bs-row bt-gs-add", onClick: () => setAdding(true) }, (0, import_react32.createElement)(PlusIcon), t("Add member")) : null,
- (0, import_react32.createElement)("div", { className: "bt-set-row bt-gs-note" }, (0, import_react32.createElement)(
+ (0, import_react36.createElement)("button", { key: "cancel", type: "button", className: "bt-set-row bt-bs-row bt-gs-add", onClick: () => setAdding(false) }, t("Cancel"))
+ ] : outside.length > 0 ? (0, import_react36.createElement)("button", { type: "button", className: "bt-set-row bt-bs-row bt-gs-add", onClick: () => setAdding(true) }, (0, import_react36.createElement)(PlusIcon), t("Add member")) : null,
+ (0, import_react36.createElement)("div", { className: "bt-set-row bt-gs-note" }, (0, import_react36.createElement)(
"span",
{ className: "bt-set-hint" },
// The host checks for two members on every change, even a rename.
members.length < 2 ? t("Add a Bot first: a group chat needs at least two.") : admin ? t("{name} leads this group: it can call members with @Name, change the group, and post here.", { name: admin.name }) : t("No admin yet. An admin can call members with @Name, change the group, and post here.")
))
),
- (0, import_react32.createElement)(
- Card,
+ (0, import_react36.createElement)(
+ Card2,
{ title: t("Sidebar") },
- (0, import_react32.createElement)(SwitchRow, { label: t("Pin"), hint: t("Kept above the other chats."), on: room2.pinned === true, onChange: (pinned) => run2(actions.setFlags(room2.id, { pinned })) }),
- (0, import_react32.createElement)(SwitchRow, { label: t("Hide from sidebar"), hint: t("Search still finds it."), on: room2.hidden === true, onChange: (hidden) => run2(actions.setFlags(room2.id, { hidden })) })
+ (0, import_react36.createElement)(SwitchRow, { label: t("Pin"), hint: t("Kept above the other chats."), on: room2.pinned === true, onChange: (pinned) => run2(actions.setFlags(room2.id, { pinned })) }),
+ (0, import_react36.createElement)(SwitchRow, { label: t("Hide from sidebar"), hint: t("Search still finds it."), on: room2.hidden === true, onChange: (hidden) => run2(actions.setFlags(room2.id, { hidden })) })
),
- (0, import_react32.createElement)(
- Card,
+ (0, import_react36.createElement)(
+ Card2,
{ title: t("Manage") },
- (0, import_react32.createElement)(
+ (0, import_react36.createElement)(
"button",
{ type: "button", className: "bt-set-row bt-bs-row bt-bs-danger", "data-confirm": confirming || void 0, onClick: remove },
- (0, import_react32.createElement)(
+ (0, import_react36.createElement)(
"span",
{ className: "bt-set-copy" },
- (0, import_react32.createElement)("span", { className: "bt-bs-label" }, confirming ? t("Delete {name}?", { name: room2.name }) : t("Delete group")),
- (0, import_react32.createElement)("span", { className: "bt-set-hint" }, confirming ? t("Click again to delete. Its history is archived.") : t("Removes the group chat. Its members stay on the team."))
+ (0, import_react36.createElement)("span", { className: "bt-bs-label" }, confirming ? t("Delete {name}?", { name: room2.name }) : t("Delete group")),
+ (0, import_react36.createElement)("span", { className: "bt-set-hint" }, confirming ? t("Click again to delete. Its history is archived.") : t("Removes the group chat. Its members stay on the team."))
),
- (0, import_react32.createElement)("span", { className: "bt-chevron" }, (0, import_react32.createElement)(ChevronRightIcon))
+ (0, import_react36.createElement)("span", { className: "bt-chevron" }, (0, import_react36.createElement)(ChevronRightIcon))
)
)
);
}
function NewGroupForm({ roster, actions, run: run2, onCreated, onCancel }) {
- const [admin, setAdmin] = (0, import_react32.useState)(null);
- const [members, setMembers] = (0, import_react32.useState)([]);
- const [name, setName] = (0, import_react32.useState)("");
- const [busy, setBusy] = (0, import_react32.useState)(false);
+ const [admin, setAdmin] = (0, import_react36.useState)(null);
+ const [members, setMembers] = (0, import_react36.useState)([]);
+ const [name, setName] = (0, import_react36.useState)("");
+ const [busy, setBusy] = (0, import_react36.useState)(false);
const toggle = (id) => setMembers((list) => list.includes(id) ? list.filter((item) => item !== id) : [...list, id]);
const pickAdmin = (id) => {
setAdmin(id);
@@ -13589,48 +13943,48 @@ function NewGroupForm({ roster, actions, run: run2, onCreated, onCancel }) {
if (done && room2) onCreated(room2);
else setBusy(false);
};
- const chip = (bot, on, onClick, role) => (0, import_react32.createElement)("button", {
+ const chip = (bot, on, onClick, role) => (0, import_react36.createElement)("button", {
key: bot.id,
type: "button",
role,
className: "bt-ng-chip",
"aria-checked": on,
onClick
- }, (0, import_react32.createElement)(BotAvatar, { bot, size: 22, badge: false, live: false }), (0, import_react32.createElement)("span", { className: "bt-ng-name" }, bot.name), on && role === "radio" ? (0, import_react32.createElement)(AdminStar) : null);
- return (0, import_react32.createElement)(
+ }, (0, import_react36.createElement)(BotAvatar, { bot, size: 22, badge: false, live: false }), (0, import_react36.createElement)("span", { className: "bt-ng-name" }, bot.name), on && role === "radio" ? (0, import_react36.createElement)(AdminStar) : null);
+ return (0, import_react36.createElement)(
"div",
{ className: "bt-set-card bt-ng" },
- (0, import_react32.createElement)(
+ (0, import_react36.createElement)(
"div",
{ className: "bt-set-row bt-bs-row bt-bs-stack" },
- (0, import_react32.createElement)("span", { className: "bt-set-copy" }, (0, import_react32.createElement)("span", { className: "bt-bs-label bt-ng-label" }, (0, import_react32.createElement)(AdminStar), t("Choose the group admin"))),
- (0, import_react32.createElement)(
+ (0, import_react36.createElement)("span", { className: "bt-set-copy" }, (0, import_react36.createElement)("span", { className: "bt-bs-label bt-ng-label" }, (0, import_react36.createElement)(AdminStar), t("Choose the group admin"))),
+ (0, import_react36.createElement)(
"div",
{ className: "bt-ng-picks", role: "radiogroup", "aria-label": t("Group admin") },
roster.bots.map((bot) => chip(bot, admin === bot.id, () => pickAdmin(bot.id), "radio"))
)
),
- admin === null ? null : (0, import_react32.createElement)(
+ admin === null ? null : (0, import_react36.createElement)(
"div",
{ className: "bt-set-row bt-bs-row bt-bs-stack bt-ng-step" },
- (0, import_react32.createElement)("span", { className: "bt-set-copy" }, (0, import_react32.createElement)("span", { className: "bt-bs-label" }, t("Who to chat with…"))),
- (0, import_react32.createElement)(
+ (0, import_react36.createElement)("span", { className: "bt-set-copy" }, (0, import_react36.createElement)("span", { className: "bt-bs-label" }, t("Who to chat with…"))),
+ (0, import_react36.createElement)(
"div",
{ className: "bt-ng-picks", role: "group", "aria-label": t("Members") },
roster.bots.filter((bot) => bot.id !== admin).map((bot) => chip(bot, members.includes(bot.id), () => toggle(bot.id), "checkbox"))
)
),
- admin === null || members.length === 0 ? null : (0, import_react32.createElement)(
+ admin === null || members.length === 0 ? null : (0, import_react36.createElement)(
"label",
{ className: "bt-set-row bt-bs-row bt-ng-step" },
- (0, import_react32.createElement)("span", { className: "bt-set-copy" }, (0, import_react32.createElement)("span", { className: "bt-bs-label" }, t("Name"))),
- (0, import_react32.createElement)("input", { className: "bt-bs-input", value: name, maxLength: 60, placeholder: t("Name after members"), onChange: (event) => setName(event.target.value) })
+ (0, import_react36.createElement)("span", { className: "bt-set-copy" }, (0, import_react36.createElement)("span", { className: "bt-bs-label" }, t("Name"))),
+ (0, import_react36.createElement)("input", { className: "bt-bs-input", value: name, maxLength: 60, placeholder: t("Name after members"), onChange: (event) => setName(event.target.value) })
),
- (0, import_react32.createElement)(
+ (0, import_react36.createElement)(
"div",
{ className: "bt-set-row bt-task-foot" },
- (0, import_react32.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onCancel }, t("Cancel")),
- (0, import_react32.createElement)("button", { type: "button", className: "bt-send bt-soft-sm", disabled: busy || admin === null || members.length === 0, onClick: () => void create() }, t("Create group chat"))
+ (0, import_react36.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onCancel }, t("Cancel")),
+ (0, import_react36.createElement)("button", { type: "button", className: "bt-send bt-soft-sm", disabled: busy || admin === null || members.length === 0, onClick: () => void create() }, t("Create group chat"))
)
);
}
@@ -13790,7 +14144,7 @@ function percent2(part, whole) {
}
// src/client/usage-page.js
-var import_react33 = require("react");
+var import_react37 = require("react");
var HEAT_WEEKS = 53;
var TOP_SERIES = 7;
var RING_R = 42;
@@ -13837,9 +14191,9 @@ function titleOf2(range, bucket) {
return dates({ year: "numeric", month: "long" }).format(bucket.start);
}
function useTween(value) {
- const [shown, setShown] = (0, import_react33.useState)(0);
- const from = (0, import_react33.useRef)(0);
- (0, import_react33.useEffect)(() => {
+ const [shown, setShown] = (0, import_react37.useState)(0);
+ const from = (0, import_react37.useRef)(0);
+ (0, import_react37.useEffect)(() => {
if (reducedMotion() || typeof requestAnimationFrame !== "function") {
from.current = value;
setShown(value);
@@ -13859,9 +14213,9 @@ function useTween(value) {
}, [value]);
return shown;
}
-var glyphBox = (size, icon2) => (0, import_react33.createElement)("span", { className: "bt-us-glyph", style: { width: size, height: size } }, (0, import_react33.createElement)(icon2));
+var glyphBox = (size, icon2) => (0, import_react37.createElement)("span", { className: "bt-us-glyph", style: { width: size, height: size } }, (0, import_react37.createElement)(icon2));
function ModelGlyph({ name, paint, size }) {
- return (0, import_react33.createElement)("span", {
+ return (0, import_react37.createElement)("span", {
className: "bt-us-model",
"aria-hidden": true,
style: { width: size, height: size, fontSize: Math.round(size * 0.42), background: `color-mix(in srgb, ${paint} 20%, var(--bt-card))`, color: `color-mix(in srgb, ${paint} 72%, var(--bt-ink))` }
@@ -13878,7 +14232,7 @@ function ownerFace(owner, roster) {
sub: owner.deleted ? t("Deleted") : role.toLowerCase() === name.toLowerCase() ? "" : role,
paint: paintCss(colorOf(bot)),
stops: GRADIENTS[colorOf(bot)],
- glyph: (size) => (0, import_react33.createElement)(BotAvatar, { bot, size, badge: false, live: false })
+ glyph: (size) => (0, import_react37.createElement)(BotAvatar, { bot, size, badge: false, live: false })
};
}
if (owner.kind === "room") {
@@ -13888,7 +14242,7 @@ function ownerFace(owner, roster) {
name: owner.name || t("Deleted group chat"),
sub: owner.deleted ? t("Deleted") : t("Group chat"),
paint: "var(--bt-us-rest)",
- glyph: (size) => room2 ? (0, import_react33.createElement)(RoomAvatar, { room: room2, roster, size }) : glyphBox(size, ChatsIcon)
+ glyph: (size) => room2 ? (0, import_react37.createElement)(RoomAvatar, { room: room2, roster, size }) : glyphBox(size, ChatsIcon)
};
}
if (owner.kind === "agent") {
@@ -13910,30 +14264,30 @@ function Tabs({ label, value, options, onChange, boxRef }) {
const names = options.map(([, text]) => text).join("\n");
const glide = useGlide(`${value}
${names}`, { box: boxRef });
- return (0, import_react33.createElement)(
+ return (0, import_react37.createElement)(
"div",
{ ref: glide.box, className: "bt-us-tabs", role: "group", "aria-label": label },
- (0, import_react33.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),
- options.map(([id, text, icon2]) => (0, import_react33.createElement)("button", { key: id, type: "button", "aria-pressed": value === id, onClick: () => onChange(id) }, icon2 ? (0, import_react33.createElement)(icon2) : null, text))
+ (0, import_react37.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),
+ options.map(([id, text, icon2]) => (0, import_react37.createElement)("button", { key: id, type: "button", "aria-pressed": value === id, onClick: () => onChange(id) }, icon2 ? (0, import_react37.createElement)(icon2) : null, text))
);
}
function Stats({ range, total, previous }) {
const shown = useTween(total.total);
const change = previous > 0 ? Math.round((total.total - previous) / previous * 100) : null;
- const cell = (label, value) => (0, import_react33.createElement)("div", { className: "bt-us-stat" }, (0, import_react33.createElement)("span", { className: "bt-us-stat-label" }, label), (0, import_react33.createElement)("span", { className: "bt-us-stat-value" }, value));
- return (0, import_react33.createElement)(
+ const cell = (label, value) => (0, import_react37.createElement)("div", { className: "bt-us-stat" }, (0, import_react37.createElement)("span", { className: "bt-us-stat-label" }, label), (0, import_react37.createElement)("span", { className: "bt-us-stat-value" }, value));
+ return (0, import_react37.createElement)(
"section",
{ className: "bt-us-stats", style: { "--i": 0 } },
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(
"div",
{ className: "bt-us-stat bt-us-stat-main" },
- (0, import_react33.createElement)("span", { className: "bt-us-stat-label" }, lastText(range)),
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)("span", { className: "bt-us-stat-label" }, lastText(range)),
+ (0, import_react37.createElement)(
"span",
{ className: "bt-us-stat-value" },
compact(shown),
- (0, import_react33.createElement)("small", null, t("tokens")),
- change === null ? null : (0, import_react33.createElement)(
+ (0, import_react37.createElement)("small", null, t("tokens")),
+ change === null ? null : (0, import_react37.createElement)(
"span",
{ className: "bt-us-delta", title: compareText(range) },
`${change >= 0 ? "↑" : "↓"} ${Math.abs(change)}%`
@@ -13951,83 +14305,83 @@ function niceTop(max) {
return [1, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10].map((scale) => scale * step).find((value) => value >= max);
}
function Chart({ range, columns: columns2, series, tipSeries, by, onBy, onPick }) {
- const [hover, setHover] = (0, import_react33.useState)(null);
+ const [hover, setHover] = (0, import_react37.useState)(null);
const top = niceTop(Math.max(0, ...columns2.map((column) => column.total)));
const count = columns2.length;
const fillOf = new Map(series.map((entry) => [entry.key, entry.fill]));
const tipOf = new Map(tipSeries.map((entry) => [entry.key, entry]));
const tip = hover === null ? null : columns2[hover];
const tipSide = hover !== null && hover >= count / 2 ? { right: `calc(${(count - hover) / count * 100}% + 8px)` } : { left: `calc(${(hover + 1) / count * 100}% + 8px)` };
- return (0, import_react33.createElement)(
+ return (0, import_react37.createElement)(
"section",
{ className: "bt-us-card bt-us-chart", style: { "--i": 1 } },
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(
"div",
{ className: "bt-us-card-head" },
- (0, import_react33.createElement)("h3", null, t("Tokens over time"), (0, import_react33.createElement)("span", null, unitLabel(range.unit))),
- onBy ? (0, import_react33.createElement)(Tabs, { label: t("Group usage by"), value: by, onChange: onBy, options: [["bot", t("By Bot")], ["model", t("By model")]] }) : null
+ (0, import_react37.createElement)("h3", null, t("Tokens over time"), (0, import_react37.createElement)("span", null, unitLabel(range.unit))),
+ onBy ? (0, import_react37.createElement)(Tabs, { label: t("Group usage by"), value: by, onChange: onBy, options: [["bot", t("By Bot")], ["model", t("By model")]] }) : null
),
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(
"div",
{ className: "bt-us-chart-body" },
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(
"div",
{ className: "bt-us-plot", "data-hover": hover === null ? void 0 : "", onMouseLeave: () => setHover(null) },
- [1, 0.5].map((level) => (0, import_react33.createElement)("div", { key: level, className: "bt-us-grid", style: { bottom: `${level * 100}%` } }, (0, import_react33.createElement)("span", null, compact(top * level)))),
- (0, import_react33.createElement)("div", { className: "bt-us-grid bt-us-base", style: { bottom: 0 } }, (0, import_react33.createElement)("span", null, "0")),
- (0, import_react33.createElement)(
+ [1, 0.5].map((level) => (0, import_react37.createElement)("div", { key: level, className: "bt-us-grid", style: { bottom: `${level * 100}%` } }, (0, import_react37.createElement)("span", null, compact(top * level)))),
+ (0, import_react37.createElement)("div", { className: "bt-us-grid bt-us-base", style: { bottom: 0 } }, (0, import_react37.createElement)("span", null, "0")),
+ (0, import_react37.createElement)(
"div",
{ className: "bt-us-cols" },
- columns2.map((column, at) => (0, import_react33.createElement)("div", {
+ columns2.map((column, at) => (0, import_react37.createElement)("div", {
key: `${range.from ? `${range.from}~${range.to}` : range.id}:${column.key}`,
className: "bt-us-col",
"data-on": hover === at ? "" : void 0,
onMouseEnter: () => setHover(at)
- }, column.total > 0 ? (0, import_react33.createElement)(
+ }, column.total > 0 ? (0, import_react37.createElement)(
"div",
{ className: "bt-us-stack", style: { height: `${column.total / top * 100}%`, "--i": at } },
- column.parts.map(([key, value]) => value > 0 ? (0, import_react33.createElement)("i", { key, style: { flexGrow: value, background: fillOf.get(key) } }) : null)
- ) : (0, import_react33.createElement)("div", { className: "bt-us-stub" })))
+ column.parts.map(([key, value]) => value > 0 ? (0, import_react37.createElement)("i", { key, style: { flexGrow: value, background: fillOf.get(key) } }) : null)
+ ) : (0, import_react37.createElement)("div", { className: "bt-us-stub" })))
),
- tip ? (0, import_react33.createElement)(
+ tip ? (0, import_react37.createElement)(
"div",
{ className: "bt-us-tip", style: tipSide },
- (0, import_react33.createElement)("div", { className: "bt-us-tip-title" }, tip.title),
- (0, import_react33.createElement)("div", { className: "bt-us-tip-total" }, t("{count} tokens", { count: full(tip.total) })),
- tip.tip.filter(([, value]) => value > 0).sort((a, b) => b[1] - a[1]).map(([key, value]) => (0, import_react33.createElement)(
+ (0, import_react37.createElement)("div", { className: "bt-us-tip-title" }, tip.title),
+ (0, import_react37.createElement)("div", { className: "bt-us-tip-total" }, t("{count} tokens", { count: full(tip.total) })),
+ tip.tip.filter(([, value]) => value > 0).sort((a, b) => b[1] - a[1]).map(([key, value]) => (0, import_react37.createElement)(
"div",
{ key, className: "bt-us-tip-row" },
- (0, import_react33.createElement)("i", { className: "bt-us-dot", style: { background: tipOf.get(key)?.fill } }),
- (0, import_react33.createElement)("span", null, tipOf.get(key)?.name),
- (0, import_react33.createElement)("b", null, compact(value))
+ (0, import_react37.createElement)("i", { className: "bt-us-dot", style: { background: tipOf.get(key)?.fill } }),
+ (0, import_react37.createElement)("span", null, tipOf.get(key)?.name),
+ (0, import_react37.createElement)("b", null, compact(value))
))
) : null
),
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(
"div",
{ className: "bt-us-ticks", "aria-hidden": true },
// A preset counts its labels back from now; a picked span forward from its first day.
- columns2.map((column, at) => (0, import_react33.createElement)(
+ columns2.map((column, at) => (0, import_react37.createElement)(
"span",
{ key: column.key, "data-now": at === count - 1 && range.ends !== false ? "" : void 0 },
(range.from ? at : count - 1 - at) % range.stride === 0 ? column.tick : ""
))
)
),
- series.length > 1 || series[0]?.pick ? (0, import_react33.createElement)(
+ series.length > 1 || series[0]?.pick ? (0, import_react37.createElement)(
"div",
{ className: "bt-us-legend" },
- series.map((entry) => (0, import_react33.createElement)(entry.pick ? "button" : "span", {
+ series.map((entry) => (0, import_react37.createElement)(entry.pick ? "button" : "span", {
key: entry.key,
className: "bt-us-key",
...entry.pick ? { type: "button", onClick: () => onPick(entry.pick) } : {}
- }, (0, import_react33.createElement)("i", { className: "bt-us-dot", style: { background: entry.fill } }), entry.name))
+ }, (0, import_react37.createElement)("i", { className: "bt-us-dot", style: { background: entry.fill } }), entry.name))
) : null
);
}
function Row2({ kind, glyph, name, sub, sum, whole, fill: fill2, index, onClick }) {
const width = whole > 0 ? Math.max(sum.total > 0 ? 2 : 0, sum.total / whole * 100) : 0;
- return (0, import_react33.createElement)(
+ return (0, import_react37.createElement)(
onClick ? "button" : "div",
{
className: "bt-us-row",
@@ -14036,69 +14390,69 @@ function Row2({ kind, glyph, name, sub, sum, whole, fill: fill2, index, onClick
title: t("{tokens} tokens · {calls} calls", { tokens: full(sum.total), calls: full(sum.calls) }),
...onClick ? { type: "button", onClick } : {}
},
- glyph ? (0, import_react33.createElement)("span", { className: "bt-us-row-glyph" }, glyph) : null,
- (0, import_react33.createElement)(
+ glyph ? (0, import_react37.createElement)("span", { className: "bt-us-row-glyph" }, glyph) : null,
+ (0, import_react37.createElement)(
"span",
{ className: "bt-us-row-body" },
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(
"span",
{ className: "bt-us-row-line" },
- (0, import_react33.createElement)("span", { className: "bt-us-row-name" }, name),
- sub ? (0, import_react33.createElement)("span", { className: "bt-us-row-sub" }, sub) : null
+ (0, import_react37.createElement)("span", { className: "bt-us-row-name" }, name),
+ sub ? (0, import_react37.createElement)("span", { className: "bt-us-row-sub" }, sub) : null
),
- (0, import_react33.createElement)("span", { className: "bt-us-track" }, (0, import_react33.createElement)("span", { style: { width: `${width}%`, background: fill2 } }))
+ (0, import_react37.createElement)("span", { className: "bt-us-track" }, (0, import_react37.createElement)("span", { style: { width: `${width}%`, background: fill2 } }))
),
- (0, import_react33.createElement)("span", { className: "bt-us-row-num" }, (0, import_react33.createElement)("b", null, compact(sum.total)), (0, import_react33.createElement)("small", null, `${percent2(sum.total, whole)}%`))
+ (0, import_react37.createElement)("span", { className: "bt-us-row-num" }, (0, import_react37.createElement)("b", null, compact(sum.total)), (0, import_react37.createElement)("small", null, `${percent2(sum.total, whole)}%`))
);
}
function ListCard({ title, count, index, children }) {
- return (0, import_react33.createElement)(
+ return (0, import_react37.createElement)(
"section",
{ className: "bt-us-card", style: { "--i": index } },
- (0, import_react33.createElement)("div", { className: "bt-us-card-head" }, (0, import_react33.createElement)("h3", null, title, count === void 0 ? null : (0, import_react33.createElement)("span", null, count))),
- (0, import_react33.createElement)("div", { className: "bt-us-rows" }, children)
+ (0, import_react37.createElement)("div", { className: "bt-us-card-head" }, (0, import_react37.createElement)("h3", null, title, count === void 0 ? null : (0, import_react37.createElement)("span", null, count))),
+ (0, import_react37.createElement)("div", { className: "bt-us-rows" }, children)
);
}
function Profile({ face, share, range }) {
const arc = Math.max(0, Math.min(1, share)) * RING;
- return (0, import_react33.createElement)(
+ return (0, import_react37.createElement)(
"section",
{ className: "bt-us-profile" },
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(
"span",
{ className: "bt-us-ring" },
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(
"svg",
{ viewBox: "0 0 96 96", "aria-hidden": true },
- face.stops ? (0, import_react33.createElement)("defs", null, (0, import_react33.createElement)(
+ face.stops ? (0, import_react37.createElement)("defs", null, (0, import_react37.createElement)(
"linearGradient",
{ id: "bt-us-ring-paint", x1: 0, y1: 1, x2: 1, y2: 0 },
- face.stops.map(([offset, color]) => (0, import_react33.createElement)("stop", { key: offset, offset, stopColor: color }))
+ face.stops.map(([offset, color]) => (0, import_react37.createElement)("stop", { key: offset, offset, stopColor: color }))
)) : null,
- (0, import_react33.createElement)("circle", { className: "bt-us-ring-track", cx: 48, cy: 48, r: RING_R }),
- arc > 0 ? (0, import_react33.createElement)("circle", { className: "bt-us-ring-arc", cx: 48, cy: 48, r: RING_R, style: { stroke: face.stops ? "url(#bt-us-ring-paint)" : face.paint, strokeDasharray: `${arc} ${RING}` } }) : null
+ (0, import_react37.createElement)("circle", { className: "bt-us-ring-track", cx: 48, cy: 48, r: RING_R }),
+ arc > 0 ? (0, import_react37.createElement)("circle", { className: "bt-us-ring-arc", cx: 48, cy: 48, r: RING_R, style: { stroke: face.stops ? "url(#bt-us-ring-paint)" : face.paint, strokeDasharray: `${arc} ${RING}` } }) : null
),
- (0, import_react33.createElement)("span", { className: "bt-us-ring-face" }, face.glyph(64))
+ (0, import_react37.createElement)("span", { className: "bt-us-ring-face" }, face.glyph(64))
),
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(
"div",
{ className: "bt-us-profile-copy" },
- (0, import_react33.createElement)("h3", null, face.name),
- face.sub ? (0, import_react33.createElement)("span", { className: "bt-us-profile-sub" }, face.sub) : null,
- (0, import_react33.createElement)("span", { className: "bt-us-profile-share" }, range.from ? t("{share}% of all usage from {span}", { share: percent2(share, 1), span: spanText(range.from, range.to) }) : t("{share}% of all usage in the last {range}", { share: percent2(share, 1), range: rangeLabel(range.id) }))
+ (0, import_react37.createElement)("h3", null, face.name),
+ face.sub ? (0, import_react37.createElement)("span", { className: "bt-us-profile-sub" }, face.sub) : null,
+ (0, import_react37.createElement)("span", { className: "bt-us-profile-share" }, range.from ? t("{share}% of all usage from {span}", { share: percent2(share, 1), span: spanText(range.from, range.to) }) : t("{share}% of all usage in the last {range}", { share: percent2(share, 1), range: rangeLabel(range.id) }))
)
);
}
var monthOf = (ms) => Date.UTC(yearOf(ms), new Date(ms).getUTCMonth(), 1);
var addMonths = (ms, count) => Date.UTC(yearOf(ms), new Date(ms).getUTCMonth() + count, 1);
function SpanPicker({ span, today, oldest, active, near, onPick, onClose }) {
- const box = (0, import_react33.useRef)(null);
+ const box = (0, import_react37.useRef)(null);
const todayMs = hourMs(today);
const thisMonth = monthOf(todayMs);
- const [right, setRight] = (0, import_react33.useState)(() => Math.max(addMonths(oldest, 1), monthOf(hourMs(span?.to ?? today))));
- const [anchor, setAnchor] = (0, import_react33.useState)(null);
- const [hover, setHover] = (0, import_react33.useState)(null);
- (0, import_react33.useEffect)(() => {
+ const [right, setRight] = (0, import_react37.useState)(() => Math.max(addMonths(oldest, 1), monthOf(hourMs(span?.to ?? today))));
+ const [anchor, setAnchor] = (0, import_react37.useState)(null);
+ const [hover, setHover] = (0, import_react37.useState)(null);
+ (0, import_react37.useEffect)(() => {
const onDown = (event) => {
if (![box, near].some((ref) => ref.current?.contains(event.target))) onClose();
};
@@ -14124,17 +14478,17 @@ function SpanPicker({ span, today, oldest, active, near, onPick, onClose }) {
const [from, to] = [anchor, key].sort();
onPick(from, to);
};
- const weekdays = (0, import_react33.useMemo)(() => Array.from({ length: 7 }, (_, at) => dates({ weekday: "narrow" }).format(Date.UTC(2024, 0, 1 + at))), []);
+ const weekdays = (0, import_react37.useMemo)(() => Array.from({ length: 7 }, (_, at) => dates({ weekday: "narrow" }).format(Date.UTC(2024, 0, 1 + at))), []);
const month = (start, side) => {
const length = new Date(addMonths(start, 1) - DAY_MS).getUTCDate();
const lead = (new Date(start).getUTCDay() + 6) % 7;
- const cells = Array.from({ length: lead }, (_, at) => (0, import_react33.createElement)("span", { key: `b${at}` }));
+ const cells = Array.from({ length: lead }, (_, at) => (0, import_react37.createElement)("span", { key: `b${at}` }));
for (let day = 1; day <= length; day += 1) {
const ms = start + (day - 1) * DAY_MS;
const key = dayKey(ms);
const weekday = (lead + day - 1) % 7;
const flag = (on) => on ? "" : void 0;
- cells.push((0, import_react33.createElement)("button", {
+ cells.push((0, import_react37.createElement)("button", {
key,
type: "button",
className: "bt-us-day",
@@ -14150,15 +14504,15 @@ function SpanPicker({ span, today, oldest, active, near, onPick, onClose }) {
"data-has": flag(active.has(key)),
onMouseEnter: () => setHover(key),
onClick: () => press(key)
- }, (0, import_react33.createElement)("b", null, day)));
+ }, (0, import_react37.createElement)("b", null, day)));
}
- const nav = side === "left" ? (0, import_react33.createElement)("button", { type: "button", className: "bt-us-month-nav", "data-side": "left", "aria-label": t("Previous month"), disabled: start <= oldest, onClick: () => setRight(addMonths(right, -1)) }, (0, import_react33.createElement)(ChevronLeftIcon)) : (0, import_react33.createElement)("button", { type: "button", className: "bt-us-month-nav", "data-side": "right", "aria-label": t("Next month"), disabled: start >= thisMonth, onClick: () => setRight(addMonths(right, 1)) }, (0, import_react33.createElement)(ChevronRightIcon));
- return (0, import_react33.createElement)(
+ const nav = side === "left" ? (0, import_react37.createElement)("button", { type: "button", className: "bt-us-month-nav", "data-side": "left", "aria-label": t("Previous month"), disabled: start <= oldest, onClick: () => setRight(addMonths(right, -1)) }, (0, import_react37.createElement)(ChevronLeftIcon)) : (0, import_react37.createElement)("button", { type: "button", className: "bt-us-month-nav", "data-side": "right", "aria-label": t("Next month"), disabled: start >= thisMonth, onClick: () => setRight(addMonths(right, 1)) }, (0, import_react37.createElement)(ChevronRightIcon));
+ return (0, import_react37.createElement)(
"div",
{ key: start, className: "bt-us-month" },
- (0, import_react33.createElement)("div", { className: "bt-us-month-head" }, nav, (0, import_react33.createElement)("span", null, dates({ year: "numeric", month: "long" }).format(start))),
- (0, import_react33.createElement)("div", { className: "bt-us-weekdays", "aria-hidden": true }, weekdays.map((name, at) => (0, import_react33.createElement)("span", { key: at }, name))),
- (0, import_react33.createElement)("div", { className: "bt-us-days", onMouseLeave: () => setHover(null) }, cells)
+ (0, import_react37.createElement)("div", { className: "bt-us-month-head" }, nav, (0, import_react37.createElement)("span", null, dates({ year: "numeric", month: "long" }).format(start))),
+ (0, import_react37.createElement)("div", { className: "bt-us-weekdays", "aria-hidden": true }, weekdays.map((name, at) => (0, import_react37.createElement)("span", { key: at }, name))),
+ (0, import_react37.createElement)("div", { className: "bt-us-days", onMouseLeave: () => setHover(null) }, cells)
);
};
const shortcuts = [
@@ -14167,30 +14521,30 @@ function SpanPicker({ span, today, oldest, active, near, onPick, onClose }) {
["year", t("This year"), `${today.slice(0, 4)}-01-01`, today]
];
const count = low === null ? 0 : Math.round((hourMs(high) - hourMs(low)) / DAY_MS) + 1;
- return (0, import_react33.createElement)(
+ return (0, import_react37.createElement)(
"div",
{ ref: box, className: "bt-us-pick", role: "dialog", "aria-label": t("Custom range") },
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(
"div",
{ className: "bt-us-pick-quick" },
- shortcuts.map(([id, label, from, to]) => (0, import_react33.createElement)("button", {
+ shortcuts.map(([id, label, from, to]) => (0, import_react37.createElement)("button", {
key: id,
type: "button",
"aria-pressed": span?.from === from && span?.to === to,
onClick: () => onPick(from, to)
}, label))
),
- (0, import_react33.createElement)("div", { className: "bt-us-pick-months" }, month(addMonths(right, -1), "left"), month(right, "right")),
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)("div", { className: "bt-us-pick-months" }, month(addMonths(right, -1), "left"), month(right, "right")),
+ (0, import_react37.createElement)(
"div",
{ className: "bt-us-pick-foot", role: "status" },
- (0, import_react33.createElement)("span", null, anchor ? t("Pick the last day") : t("Pick the first day")),
- low === null ? null : (0, import_react33.createElement)("span", null, (0, import_react33.createElement)("b", null, spanText(low, high)), ` · ${daysText(count)}`)
+ (0, import_react37.createElement)("span", null, anchor ? t("Pick the last day") : t("Pick the first day")),
+ low === null ? null : (0, import_react37.createElement)("span", null, (0, import_react37.createElement)("b", null, spanText(low, high)), ` · ${daysText(count)}`)
)
);
}
function Heat({ view, keep, paint, index }) {
- const [hover, setHover] = (0, import_react33.useState)(null);
+ const [hover, setHover] = (0, import_react37.useState)(null);
const today = hourMs(`${view.now.slice(0, 10)} 00`);
const first = mondayOf(today) - (HEAT_WEEKS - 1) * 7 * DAY_MS;
const from = dayKey(first);
@@ -14206,13 +14560,13 @@ function Heat({ view, keep, paint, index }) {
for (let week = 0; week < HEAT_WEEKS; week += 1) {
const monday = first + week * 7 * DAY_MS;
if (week > 0 && new Date(monday).getUTCMonth() !== new Date(monday - 7 * DAY_MS).getUTCMonth()) {
- months.push((0, import_react33.createElement)("span", { key: week, style: { gridColumn: week + 1 } }, dates({ month: "short" }).format(monday)));
+ months.push((0, import_react37.createElement)("span", { key: week, style: { gridColumn: week + 1 } }, dates({ month: "short" }).format(monday)));
}
for (let day = 0; day < 7; day += 1) {
const ms = monday + day * DAY_MS;
const value = daily.get(dayKey(ms)) ?? 0;
const level = value > 0 ? Math.max(1, Math.ceil(4 * Math.sqrt(value / most))) : 0;
- cells.push((0, import_react33.createElement)("span", {
+ cells.push((0, import_react37.createElement)("span", {
key: ms,
className: "bt-us-cell",
style: { "--w": week },
@@ -14220,7 +14574,7 @@ function Heat({ view, keep, paint, index }) {
"data-future": ms > today ? "" : void 0,
"data-today": ms === today ? "" : void 0,
onMouseEnter: ms > today ? void 0 : () => setHover({ ms, week, day })
- }, level > 0 ? (0, import_react33.createElement)("i", { style: { background: soften(paint, levels[level - 1]) } }) : null));
+ }, level > 0 ? (0, import_react37.createElement)("i", { style: { background: soften(paint, levels[level - 1]) } }) : null));
}
}
const tipSide = hover ? {
@@ -14229,68 +14583,68 @@ function Heat({ view, keep, paint, index }) {
} : null;
const active = [...daily.values()].filter((value) => value > 0).length;
const summary = active === 1 ? t("Active on 1 day in the last year") : t("Active on {count} days in the last year", { count: active });
- return (0, import_react33.createElement)(
+ return (0, import_react37.createElement)(
"section",
{ className: "bt-us-card bt-us-heat", style: { "--i": index } },
- (0, import_react33.createElement)("div", { className: "bt-us-card-head" }, (0, import_react33.createElement)("h3", null, t("Activity")), (0, import_react33.createElement)("span", { className: "bt-us-head-note" }, summary)),
- (0, import_react33.createElement)("div", { className: "bt-us-heat-months", "aria-hidden": true }, months),
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)("div", { className: "bt-us-card-head" }, (0, import_react37.createElement)("h3", null, t("Activity")), (0, import_react37.createElement)("span", { className: "bt-us-head-note" }, summary)),
+ (0, import_react37.createElement)("div", { className: "bt-us-heat-months", "aria-hidden": true }, months),
+ (0, import_react37.createElement)(
"div",
{ className: "bt-us-heat-plot", onMouseLeave: () => setHover(null) },
- (0, import_react33.createElement)("div", { className: "bt-us-heat-grid", role: "img", "aria-label": summary }, cells),
- hover ? (0, import_react33.createElement)(
+ (0, import_react37.createElement)("div", { className: "bt-us-heat-grid", role: "img", "aria-label": summary }, cells),
+ hover ? (0, import_react37.createElement)(
"div",
{ className: "bt-us-tip bt-us-heat-tip", style: tipSide },
- (0, import_react33.createElement)("div", { className: "bt-us-tip-title" }, dates({ month: "long", day: "numeric", weekday: "short" }).format(hover.ms)),
- (0, import_react33.createElement)("div", { className: "bt-us-tip-total" }, t("{count} tokens", { count: full(daily.get(dayKey(hover.ms)) ?? 0) }))
+ (0, import_react37.createElement)("div", { className: "bt-us-tip-title" }, dates({ month: "long", day: "numeric", weekday: "short" }).format(hover.ms)),
+ (0, import_react37.createElement)("div", { className: "bt-us-tip-total" }, t("{count} tokens", { count: full(daily.get(dayKey(hover.ms)) ?? 0) }))
) : null
),
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(
"div",
{ className: "bt-us-heat-scale", "aria-hidden": true },
t("Light"),
- levels.map((level) => (0, import_react33.createElement)("span", { key: level, className: "bt-us-cell" }, (0, import_react33.createElement)("i", { style: { background: soften(paint, level) } }))),
+ levels.map((level) => (0, import_react37.createElement)("span", { key: level, className: "bt-us-cell" }, (0, import_react37.createElement)("i", { style: { background: soften(paint, level) } }))),
t("Heavy")
)
);
}
function Skeleton2() {
- return (0, import_react33.createElement)(
+ return (0, import_react37.createElement)(
"div",
{ className: "bt-us", "aria-busy": true },
- (0, import_react33.createElement)("div", { className: "bt-us-skel", style: { height: 32, width: 320, borderRadius: 999 } }),
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)("div", { className: "bt-us-skel", style: { height: 32, width: 320, borderRadius: 999 } }),
+ (0, import_react37.createElement)(
"div",
{ className: "bt-us-sheet bt-us-skel-sheet" },
- (0, import_react33.createElement)("div", { className: "bt-us-skel", style: { height: 94 } }),
- (0, import_react33.createElement)("div", { className: "bt-us-skel", style: { height: 318 } }),
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)("div", { className: "bt-us-skel", style: { height: 94 } }),
+ (0, import_react37.createElement)("div", { className: "bt-us-skel", style: { height: 318 } }),
+ (0, import_react37.createElement)(
"div",
{ className: "bt-us-pair" },
- (0, import_react33.createElement)("div", { className: "bt-us-skel", style: { height: 200 } }),
- (0, import_react33.createElement)("div", { className: "bt-us-skel", style: { height: 200 } })
+ (0, import_react37.createElement)("div", { className: "bt-us-skel", style: { height: 200 } }),
+ (0, import_react37.createElement)("div", { className: "bt-us-skel", style: { height: 200 } })
)
)
);
}
var focusOf = (id) => typeof id !== "string" ? null : id.startsWith("model:") ? { kind: "model", key: id.slice("model:".length) } : id.startsWith("owner:") ? { kind: "owner", key: id.slice("owner:".length) } : null;
function UsagePage({ roster, actions, focusId }) {
- const [view, setView] = (0, import_react33.useState)(null);
- const [error, setError] = (0, import_react33.useState)("");
- const [rangeId, setRangeId] = (0, import_react33.useState)("7d");
- const [span, setSpan] = (0, import_react33.useState)(null);
- const [picking, setPicking] = (0, import_react33.useState)(false);
- const [by, setBy] = (0, import_react33.useState)("bot");
- const tabs = (0, import_react33.useRef)(null);
+ const [view, setView] = (0, import_react37.useState)(null);
+ const [error, setError] = (0, import_react37.useState)("");
+ const [rangeId, setRangeId] = (0, import_react37.useState)("7d");
+ const [span, setSpan] = (0, import_react37.useState)(null);
+ const [picking, setPicking] = (0, import_react37.useState)(false);
+ const [by, setBy] = (0, import_react37.useState)("bot");
+ const tabs = (0, import_react37.useRef)(null);
const focus = focusOf(focusId);
- (0, import_react33.useEffect)(() => {
+ (0, import_react37.useEffect)(() => {
let stopped = false;
let timer;
const load = async () => {
try {
const value = await actions.usage();
if (stopped) return;
- (0, import_react33.startTransition)(() => setView(value));
+ (0, import_react37.startTransition)(() => setView(value));
setError("");
timer = setTimeout(load, value.scanning ? 3e3 : 2e4);
} catch (failure) {
@@ -14307,7 +14661,7 @@ function UsagePage({ roster, actions, focusId }) {
}, []);
const today = view?.now.slice(0, 10);
const range = rangeId === "custom" && span ? { ...spanRange(span.from, span.to), ends: span.to >= today } : RANGES.find((item) => item.id === rangeId);
- const shaped = (0, import_react33.useMemo)(() => {
+ const shaped = (0, import_react37.useMemo)(() => {
if (!view) return null;
const faces2 = view.owners.map((owner) => ownerFace(owner, roster));
const lifetime = /* @__PURE__ */ new Map();
@@ -14316,7 +14670,7 @@ function UsagePage({ roster, actions, focusId }) {
const models2 = view.models.map((model, at) => {
const name = model.name || model.model || t("Unknown model");
const paint = modelPaint.get(at) ?? "var(--bt-us-rest)";
- return { kind: "model", name, sub: model.providerName ?? model.provider, paint, glyph: (size) => (0, import_react33.createElement)(ModelGlyph, { name, paint, size }) };
+ return { kind: "model", name, sub: model.providerName ?? model.provider, paint, glyph: (size) => (0, import_react37.createElement)(ModelGlyph, { name, paint, size }) };
});
const ownerAt2 = focus?.kind === "owner" ? view.owners.findIndex((owner) => owner.key === focus.key) : -1;
const modelAt = focus?.kind === "model" ? view.models.findIndex((model) => model.key === focus.key) : -1;
@@ -14364,23 +14718,23 @@ function UsagePage({ roster, actions, focusId }) {
});
return { faces: faces2, models: models2, ownerAt: ownerAt2, modelAt, face: face2, keep: keep2, all: all2, part: part2, series: series2, tipSeries: tipSeries2, fillOf: fillOf2, columns: columns3, ranked: ranked2, isBot: isBot2, activeDays: activeDays2, oldest: oldest2 };
}, [view, rangeId, span, by, focusId, roster]);
- const root = (0, import_react33.useRef)(null);
- (0, import_react33.useEffect)(() => {
+ const root = (0, import_react37.useRef)(null);
+ (0, import_react37.useEffect)(() => {
root.current?.closest(".bt-settings-scroll")?.scrollTo?.({ top: 0 });
}, [focusId]);
if (!view) {
- return error ? (0, import_react33.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : (0, import_react33.createElement)(Skeleton2);
+ return error ? (0, import_react37.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : (0, import_react37.createElement)(Skeleton2);
}
if (view.rows.length === 0) {
- return (0, import_react33.createElement)(
+ return (0, import_react37.createElement)(
"div",
{ className: "bt-us" },
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(
"div",
{ className: "bt-us-empty" },
- (0, import_react33.createElement)(BotMark, { look: MAIN_LOOK, size: 56, live: true }),
- (0, import_react33.createElement)("b", null, view.scanning ? t("Reading your chats…") : t("No usage yet.")),
- (0, import_react33.createElement)("span", null, t("Token usage shows up here after a model is called."))
+ (0, import_react37.createElement)(BotMark, { look: MAIN_LOOK, size: 56, live: true }),
+ (0, import_react37.createElement)("b", null, view.scanning ? t("Reading your chats…") : t("No usage yet.")),
+ (0, import_react37.createElement)("span", null, t("Token usage shows up here after a model is called."))
)
);
}
@@ -14405,7 +14759,7 @@ function UsagePage({ roster, actions, focusId }) {
["custom", rangeId === "custom" && span ? spanText(span.from, span.to) : t("Custom"), CalendarIcon]
];
const whole = part.total.total;
- const ownerRow = ([at, sum], index, total = whole) => (0, import_react33.createElement)(Row2, {
+ const ownerRow = ([at, sum], index, total = whole) => (0, import_react37.createElement)(Row2, {
key: `o${at}`,
kind: faces[at].kind,
glyph: faces[at].glyph(32),
@@ -14417,7 +14771,7 @@ function UsagePage({ roster, actions, focusId }) {
fill: face ? soften(face.paint, 0.8) : fillOf.get(`o${at}`) ?? soften(faces[at].paint),
onClick: () => pick2({ kind: "owner", key: view.owners[at].key })
});
- const modelRow = ([at, sum], index) => (0, import_react33.createElement)(Row2, {
+ const modelRow = ([at, sum], index) => (0, import_react37.createElement)(Row2, {
key: `m${at}`,
kind: "model",
glyph: models[at].glyph(32),
@@ -14429,30 +14783,30 @@ function UsagePage({ roster, actions, focusId }) {
fill: face ? soften(face.paint, 0.8) : fillOf.get(`m${at}`) ?? soften(models[at].paint),
onClick: () => pick2({ kind: "model", key: view.models[at].key })
});
- const nothing = (0, import_react33.createElement)("div", { className: "bt-us-none" }, t("Nothing in this range."));
+ const nothing = (0, import_react37.createElement)("div", { className: "bt-us-none" }, t("Nothing in this range."));
let body;
if (face) {
const kinds = ranked(part.kinds);
const usedModels = ranked(part.models);
const owners = ranked(part.owners);
body = [
- (0, import_react33.createElement)(Profile, { key: "profile", face, range, share: all.total.total > 0 ? whole / all.total.total : 0 }),
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(Profile, { key: "profile", face, range, share: all.total.total > 0 ? whole / all.total.total : 0 }),
+ (0, import_react37.createElement)(
"div",
{ key: "sheet", className: "bt-us-sheet" },
- (0, import_react33.createElement)(Stats, { key: "stats", range, total: part.total, previous: part.previous }),
- (0, import_react33.createElement)(Chart, { key: "chart", range, columns: columns2, series, tipSeries, onPick: pick2 }),
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(Stats, { key: "stats", range, total: part.total, previous: part.previous }),
+ (0, import_react37.createElement)(Chart, { key: "chart", range, columns: columns2, series, tipSeries, onPick: pick2 }),
+ (0, import_react37.createElement)(
"div",
{ key: "pair", className: "bt-us-pair" },
- ownerAt >= 0 ? (0, import_react33.createElement)(ListCard, { title: t("Models"), count: usedModels.length, index: 2 }, usedModels.length > 0 ? usedModels.map(modelRow) : nothing) : (0, import_react33.createElement)(ListCard, { title: t("Who used it"), count: owners.length, index: 2 }, owners.length > 0 ? owners.map((entry, index) => ownerRow(entry, index)) : nothing),
- (0, import_react33.createElement)(
+ ownerAt >= 0 ? (0, import_react37.createElement)(ListCard, { title: t("Models"), count: usedModels.length, index: 2 }, usedModels.length > 0 ? usedModels.map(modelRow) : nothing) : (0, import_react37.createElement)(ListCard, { title: t("Who used it"), count: owners.length, index: 2 }, owners.length > 0 ? owners.map((entry, index) => ownerRow(entry, index)) : nothing),
+ (0, import_react37.createElement)(
ListCard,
{ title: t("What for"), index: 3 },
- kinds.length > 0 ? kinds.map(([at, sum], index) => (0, import_react33.createElement)(Row2, { key: at, name: kindLabel(view.kinds[at], ownerAt >= 0 && isBot(ownerAt)), sum, whole, index, fill: soften(face.paint, 0.8) })) : nothing
+ kinds.length > 0 ? kinds.map(([at, sum], index) => (0, import_react37.createElement)(Row2, { key: at, name: kindLabel(view.kinds[at], ownerAt >= 0 && isBot(ownerAt)), sum, whole, index, fill: soften(face.paint, 0.8) })) : nothing
)
),
- (0, import_react33.createElement)(Heat, { key: "heat", view, keep, paint: face.paint, index: 4 })
+ (0, import_react37.createElement)(Heat, { key: "heat", view, keep, paint: face.paint, index: 4 })
)
];
} else {
@@ -14461,39 +14815,39 @@ function UsagePage({ roster, actions, focusId }) {
const rest = owners.filter(([at]) => !isBot(at));
const usedModels = ranked(all.models);
body = [
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(
"div",
{ key: "sheet", className: "bt-us-sheet" },
- (0, import_react33.createElement)(Stats, { key: "stats", range, total: all.total, previous: all.previous }),
- (0, import_react33.createElement)(Chart, { key: "chart", range, columns: columns2, series, tipSeries, by, onBy: setBy, onPick: pick2 }),
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(Stats, { key: "stats", range, total: all.total, previous: all.previous }),
+ (0, import_react37.createElement)(Chart, { key: "chart", range, columns: columns2, series, tipSeries, by, onBy: setBy, onPick: pick2 }),
+ (0, import_react37.createElement)(
"div",
{ key: "pair", className: "bt-us-pair" },
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(
ListCard,
{ title: t("Bots"), count: bots.length, index: 2 },
owners.length > 0 ? null : nothing,
bots.map((entry, index) => ownerRow(entry, index)),
- bots.length > 0 && rest.length > 0 ? (0, import_react33.createElement)("div", { className: "bt-us-split", role: "separator" }) : null,
+ bots.length > 0 && rest.length > 0 ? (0, import_react37.createElement)("div", { className: "bt-us-split", role: "separator" }) : null,
rest.map((entry, index) => ownerRow(entry, bots.length + index))
),
- (0, import_react33.createElement)(ListCard, { title: t("Models"), count: usedModels.length, index: 3 }, usedModels.length > 0 ? usedModels.map(modelRow) : nothing)
+ (0, import_react37.createElement)(ListCard, { title: t("Models"), count: usedModels.length, index: 3 }, usedModels.length > 0 ? usedModels.map(modelRow) : nothing)
),
- (0, import_react33.createElement)(Heat, { key: "heat", view, keep, paint: "var(--bt-accent)", index: 4 })
+ (0, import_react37.createElement)(Heat, { key: "heat", view, keep, paint: "var(--bt-accent)", index: 4 })
)
];
}
- return (0, import_react33.createElement)(
+ return (0, import_react37.createElement)(
"div",
{ ref: root, className: "bt-us", key: focusId ?? "all" },
- (0, import_react33.createElement)(
+ (0, import_react37.createElement)(
"div",
{ className: "bt-us-top" },
- (0, import_react33.createElement)(Tabs, { label: t("Time range"), value: rangeId, onChange: chooseRange, options: rangeOptions, boxRef: tabs }),
- view.scanning ? (0, import_react33.createElement)("span", { className: "bt-us-note", role: "status" }, t("Still reading older chats; totals may grow.")) : null,
- picking ? (0, import_react33.createElement)(SpanPicker, { span, today, oldest, active: activeDays, near: tabs, onPick: pickSpan, onClose: () => setPicking(false) }) : null
+ (0, import_react37.createElement)(Tabs, { label: t("Time range"), value: rangeId, onChange: chooseRange, options: rangeOptions, boxRef: tabs }),
+ view.scanning ? (0, import_react37.createElement)("span", { className: "bt-us-note", role: "status" }, t("Still reading older chats; totals may grow.")) : null,
+ picking ? (0, import_react37.createElement)(SpanPicker, { span, today, oldest, active: activeDays, near: tabs, onPick: pickSpan, onClose: () => setPicking(false) }) : null
),
- error ? (0, import_react33.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : null,
+ error ? (0, import_react37.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : null,
body
);
}
@@ -14664,12 +15018,12 @@ button.bt-us-row:hover{background:var(--bt-hover)}
`;
// src/client/connectors.js
-var import_react34 = require("react");
+var import_react38 = require("react");
var TOKEN_URL = "https://github.com/settings/personal-access-tokens/new";
-var GitHubMark = () => (0, import_react34.createElement)(
+var GitHubMark = () => (0, import_react38.createElement)(
"svg",
{ width: 20, height: 20, viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": true },
- (0, import_react34.createElement)("path", { d: "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z" })
+ (0, import_react38.createElement)("path", { d: "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z" })
);
var MARKS = { github: GitHubMark };
var ABOUT = { github: () => t("Repositories, issues, and pull requests") };
@@ -14680,10 +15034,10 @@ function statusText2(connector) {
return ABOUT[connector.id]?.() ?? "";
}
function ConnectorRow({ connector, actions }) {
- const [form, setForm] = (0, import_react34.useState)(false);
- const [token, setToken] = (0, import_react34.useState)("");
- const [busy, setBusy] = (0, import_react34.useState)(false);
- const [error, setError] = (0, import_react34.useState)(null);
+ const [form, setForm] = (0, import_react38.useState)(false);
+ const [token, setToken] = (0, import_react38.useState)("");
+ const [busy, setBusy] = (0, import_react38.useState)(false);
+ const [error, setError] = (0, import_react38.useState)(null);
const run2 = (task, after) => {
setBusy(true);
setError(null);
@@ -14700,58 +15054,58 @@ function ConnectorRow({ connector, actions }) {
};
const on = connector.state !== "off";
const Mark = MARKS[connector.id];
- const row = (0, import_react34.useRef)(null);
+ const row = (0, import_react38.useRef)(null);
useMorph(row, `${form}:${error !== null}:${connector.state}`);
- return (0, import_react34.createElement)(
+ return (0, import_react38.createElement)(
"div",
{ ref: row, className: "bt-connector", "data-state": connector.state },
- (0, import_react34.createElement)(
+ (0, import_react38.createElement)(
"div",
{ className: "bt-connector-head" },
- (0, import_react34.createElement)("span", { className: "bt-connector-mark" }, Mark ? (0, import_react34.createElement)(Mark) : null),
- (0, import_react34.createElement)(
+ (0, import_react38.createElement)("span", { className: "bt-connector-mark" }, Mark ? (0, import_react38.createElement)(Mark) : null),
+ (0, import_react38.createElement)(
"span",
{ className: "bt-connector-text" },
- (0, import_react34.createElement)("span", { className: "bt-connector-name" }, connector.name),
- (0, import_react34.createElement)("span", { className: "bt-connector-status" }, statusText2(connector))
+ (0, import_react38.createElement)("span", { className: "bt-connector-name" }, connector.name),
+ (0, import_react38.createElement)("span", { className: "bt-connector-status" }, statusText2(connector))
),
- (0, import_react34.createElement)(
+ (0, import_react38.createElement)(
"span",
{ className: "bt-connector-actions" },
- connector.state === "error" ? (0, import_react34.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: busy, onClick: () => void run2(actions.connectorRetry(connector.id)) }, t("Try again")) : null,
- on ? (0, import_react34.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: busy, onClick: () => void run2(actions.connectorDisconnect(connector.id)) }, t("Disconnect")) : form ? null : (0, import_react34.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setForm(true) }, t("Connect"))
+ connector.state === "error" ? (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: busy, onClick: () => void run2(actions.connectorRetry(connector.id)) }, t("Try again")) : null,
+ on ? (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: busy, onClick: () => void run2(actions.connectorDisconnect(connector.id)) }, t("Disconnect")) : form ? null : (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setForm(true) }, t("Connect"))
)
),
- !on && form ? (0, import_react34.createElement)(
+ !on && form ? (0, import_react38.createElement)(
"div",
{ className: "bt-connector-form" },
- (0, import_react34.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react34.createElement)(MaskedInput, { value: token, onChange: setToken, onEnter: connect, label: t("GitHub token"), autoFocus: true })),
- (0, import_react34.createElement)(
+ (0, import_react38.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react38.createElement)(MaskedInput, { value: token, onChange: setToken, onEnter: connect, label: t("GitHub token"), autoFocus: true })),
+ (0, import_react38.createElement)(
"div",
{ className: "bt-connector-form-row" },
- (0, import_react34.createElement)("a", { className: "bt-connector-link", href: TOKEN_URL, target: "_blank", rel: "noopener noreferrer" }, t("Create a token on GitHub")),
- (0, import_react34.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: busy, onClick: () => {
+ (0, import_react38.createElement)("a", { className: "bt-connector-link", href: TOKEN_URL, target: "_blank", rel: "noopener noreferrer" }, t("Create a token on GitHub")),
+ (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: busy, onClick: () => {
setForm(false);
setToken("");
setError(null);
} }, t("Cancel")),
- (0, import_react34.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: busy || token.trim() === "", onClick: connect }, busy ? t("Connecting…") : t("Connect"))
+ (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: busy || token.trim() === "", onClick: connect }, busy ? t("Connecting…") : t("Connect"))
)
) : null,
- error ? (0, import_react34.createElement)("div", { className: "bt-connector-error", role: "alert" }, error) : null
+ error ? (0, import_react38.createElement)("div", { className: "bt-connector-error", role: "alert" }, error) : null
);
}
function ConnectorsPage({ roster, actions }) {
const list = roster?.connectors ?? [];
- return (0, import_react34.createElement)(
+ return (0, import_react38.createElement)(
"section",
{ className: "bt-set-section" },
- (0, import_react34.createElement)("div", { className: "bt-set-card bt-connectors-card" }, list.length === 0 ? (0, import_react34.createElement)("div", { className: "bt-set-row" }, (0, import_react34.createElement)("span", { className: "bt-set-hint" }, t("No connectors"))) : list.map((connector) => (0, import_react34.createElement)(ConnectorRow, { key: connector.id, connector, actions })))
+ (0, import_react38.createElement)("div", { className: "bt-set-card bt-connectors-card" }, list.length === 0 ? (0, import_react38.createElement)("div", { className: "bt-set-row" }, (0, import_react38.createElement)("span", { className: "bt-set-hint" }, t("No connectors"))) : list.map((connector) => (0, import_react38.createElement)(ConnectorRow, { key: connector.id, connector, actions })))
);
}
// src/client/browser-settings.js
-var import_react35 = require("react");
+var import_react39 = require("react");
var ACTIONS = [["post", "Post"], ["upload", "Upload"], ["download", "Download"], ["delete", "Delete"]];
var DURATIONS = [["hour", "1 hour"], ["today", "Today"], ["week", "7 days"], ["permanent", "Permanent"]];
var expired = (grant) => Number.isFinite(grant.until) && grant.until <= Date.now();
@@ -14770,13 +15124,13 @@ function grantKinds(grant) {
}
function BrowserPage({ roster, actions, run: run2, Section, Row: Row3 }) {
const bots = roster.bots ?? [];
- const [botId, setBotId] = (0, import_react35.useState)(bots[0]?.id ?? "");
- const [site, setSite] = (0, import_react35.useState)("");
- const [kinds, setKinds] = (0, import_react35.useState)(["post"]);
- const [duration, setDuration] = (0, import_react35.useState)("hour");
- const [busy, setBusy] = (0, import_react35.useState)(false);
+ const [botId, setBotId] = (0, import_react39.useState)(bots[0]?.id ?? "");
+ const [site, setSite] = (0, import_react39.useState)("");
+ const [kinds, setKinds] = (0, import_react39.useState)(["post"]);
+ const [duration, setDuration] = (0, import_react39.useState)("hour");
+ const [busy, setBusy] = (0, import_react39.useState)(false);
const selectedBot = bots.find((bot) => bot.id === botId);
- (0, import_react35.useEffect)(() => {
+ (0, import_react39.useEffect)(() => {
if (!bots.some((bot) => bot.id === botId)) setBotId(bots[0]?.id ?? "");
}, [bots, botId]);
const grants = bots.flatMap((bot) => (bot.browserGrants ?? []).map((grant, index) => ({
@@ -14809,37 +15163,37 @@ function BrowserPage({ roster, actions, run: run2, Section, Row: Row3 }) {
const toggleKind = (kind, checked) => {
setKinds((current) => checked ? current.includes(kind) ? current : [...current, kind] : current.filter((value) => value !== kind));
};
- return (0, import_react35.createElement)(
+ return (0, import_react39.createElement)(
"div",
{ className: "bt-browser-settings" },
- (0, import_react35.createElement)(
+ (0, import_react39.createElement)(
Section,
{ title: t("Browser access") },
- (0, import_react35.createElement)("p", { className: "bt-browser-note" }, t("Bots browse, click and fill in forms freely. Posting, uploading, downloading and deleting ask you first unless you allow them here. Payments are always yours: the Bot hands the page to you."))
+ (0, import_react39.createElement)("p", { className: "bt-browser-note" }, t("Bots browse, click and fill in forms freely. Posting, uploading, downloading and deleting ask you first unless you allow them here. Payments are always yours: the Bot hands the page to you."))
),
- (0, import_react35.createElement)(
+ (0, import_react39.createElement)(
Section,
{ title: t("Allowed actions") },
- grants.length === 0 ? (0, import_react35.createElement)(Row3, { label: t("Nothing allowed yet.") }) : grants.map(({ bot, grant, index, expired: expired2 }) => (0, import_react35.createElement)(
+ grants.length === 0 ? (0, import_react39.createElement)(Row3, { label: t("Nothing allowed yet.") }) : grants.map(({ bot, grant, index, expired: expired2 }) => (0, import_react39.createElement)(
"div",
{
key: `${bot.id}:${index}`,
className: `bt-browser-grant${expired2 ? " bt-browser-grant-expired" : ""}`
},
- (0, import_react35.createElement)(
+ (0, import_react39.createElement)(
"div",
{ className: "bt-browser-grant-who" },
- (0, import_react35.createElement)(BotAvatar, { bot, size: 28 }),
- (0, import_react35.createElement)("span", null, bot.name)
+ (0, import_react39.createElement)(BotAvatar, { bot, size: 28 }),
+ (0, import_react39.createElement)("span", null, bot.name)
),
- (0, import_react35.createElement)(
+ (0, import_react39.createElement)(
"div",
{ className: "bt-browser-grant-meta" },
- (0, import_react35.createElement)("span", { className: "bt-browser-grant-site" }, grant.site === "*" ? t("All sites") : grant.site),
- (0, import_react35.createElement)("div", { className: "bt-browser-grant-kinds" }, grantKinds(grant).map((label) => (0, import_react35.createElement)("span", { key: label, className: "bt-chip" }, label))),
- (0, import_react35.createElement)("span", { className: "bt-set-hint" }, grantTime(grant))
+ (0, import_react39.createElement)("span", { className: "bt-browser-grant-site" }, grant.site === "*" ? t("All sites") : grant.site),
+ (0, import_react39.createElement)("div", { className: "bt-browser-grant-kinds" }, grantKinds(grant).map((label) => (0, import_react39.createElement)("span", { key: label, className: "bt-chip" }, label))),
+ (0, import_react39.createElement)("span", { className: "bt-set-hint" }, grantTime(grant))
),
- (0, import_react35.createElement)("button", {
+ (0, import_react39.createElement)("button", {
type: "button",
className: "bt-soft bt-soft-sm",
onClick: () => remove(bot, index),
@@ -14847,25 +15201,25 @@ function BrowserPage({ roster, actions, run: run2, Section, Row: Row3 }) {
}, t("Remove grant"))
))
),
- (0, import_react35.createElement)(
+ (0, import_react39.createElement)(
Section,
{ title: t("Allow an action") },
- (0, import_react35.createElement)(
+ (0, import_react39.createElement)(
"form",
{ className: "bt-browser-form", onSubmit: add },
- (0, import_react35.createElement)(
+ (0, import_react39.createElement)(
Row3,
{ label: t("Bot") },
- (0, import_react35.createElement)(
+ (0, import_react39.createElement)(
"select",
{ className: "bt-select", value: botId, onChange: (event) => setBotId(event.target.value), disabled: bots.length === 0 },
- bots.map((bot) => (0, import_react35.createElement)("option", { key: bot.id, value: bot.id }, bot.name))
+ bots.map((bot) => (0, import_react39.createElement)("option", { key: bot.id, value: bot.id }, bot.name))
)
),
- (0, import_react35.createElement)(
+ (0, import_react39.createElement)(
Row3,
{ label: t("Site") },
- (0, import_react35.createElement)("input", {
+ (0, import_react39.createElement)("input", {
className: "bt-select bt-browser-site",
type: "text",
value: site,
@@ -14873,16 +15227,16 @@ function BrowserPage({ roster, actions, run: run2, Section, Row: Row3 }) {
onChange: (event) => setSite(event.target.value)
})
),
- (0, import_react35.createElement)(
+ (0, import_react39.createElement)(
Row3,
{ label: t("Actions") },
- (0, import_react35.createElement)(
+ (0, import_react39.createElement)(
"div",
{ className: "bt-browser-action-list" },
- ACTIONS.map(([kind, label]) => (0, import_react35.createElement)(
+ ACTIONS.map(([kind, label]) => (0, import_react39.createElement)(
"label",
{ key: kind, className: "bt-browser-action-choice" },
- (0, import_react35.createElement)("input", {
+ (0, import_react39.createElement)("input", {
type: "checkbox",
checked: kinds.includes(kind),
onChange: (event) => toggleKind(kind, event.target.checked)
@@ -14891,13 +15245,13 @@ function BrowserPage({ roster, actions, run: run2, Section, Row: Row3 }) {
))
)
),
- (0, import_react35.createElement)(
+ (0, import_react39.createElement)(
Row3,
{ label: t("Duration") },
- (0, import_react35.createElement)(
+ (0, import_react39.createElement)(
"div",
{ className: "bt-browser-duration", role: "group", "aria-label": t("Duration") },
- DURATIONS.map(([key, label]) => (0, import_react35.createElement)("button", {
+ DURATIONS.map(([key, label]) => (0, import_react39.createElement)("button", {
key,
type: "button",
className: "bt-browser-duration-choice",
@@ -14906,10 +15260,10 @@ function BrowserPage({ roster, actions, run: run2, Section, Row: Row3 }) {
}, t(label)))
)
),
- (0, import_react35.createElement)(
+ (0, import_react39.createElement)(
"div",
{ className: "bt-browser-form-foot" },
- (0, import_react35.createElement)("button", {
+ (0, import_react39.createElement)("button", {
type: "submit",
className: "bt-soft",
disabled: busy || !selectedBot || kinds.length === 0
@@ -14921,12 +15275,12 @@ function BrowserPage({ roster, actions, run: run2, Section, Row: Row3 }) {
}
// src/client/feedback.js
-var import_react36 = require("react");
-var FeedbackIcon = () => (0, import_react36.createElement)(
+var import_react40 = require("react");
+var FeedbackIcon = () => (0, import_react40.createElement)(
"svg",
{ width: 15, height: 15, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },
- (0, import_react36.createElement)("path", { d: "M4 4.5h12a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H9l-3.5 3v-3H4a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1z" }),
- (0, import_react36.createElement)("path", { d: "M10 7v2.6M10 11.4h.01" })
+ (0, import_react40.createElement)("path", { d: "M4 4.5h12a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H9l-3.5 3v-3H4a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1z" }),
+ (0, import_react40.createElement)("path", { d: "M10 7v2.6M10 11.4h.01" })
);
function download(name, text) {
const url = URL.createObjectURL(new Blob([text], { type: "text/plain;charset=utf-8" }));
@@ -14964,16 +15318,16 @@ function issueWindow() {
};
}
function FeedbackPage({ actions, run: run2, Section, Row: Row3 }) {
- const [what, setWhat] = (0, import_react36.useState)("");
- const [report, setReport] = (0, import_react36.useState)(null);
- const [preview, setPreview] = (0, import_react36.useState)(false);
- const [note, setNote] = (0, import_react36.useState)("");
+ const [what, setWhat] = (0, import_react40.useState)("");
+ const [report, setReport] = (0, import_react40.useState)(null);
+ const [preview, setPreview] = (0, import_react40.useState)(false);
+ const [note, setNote] = (0, import_react40.useState)("");
const fetchReport = () => actions.diagnostics({ client: clientFacts(), clientErrors: clientErrors() }).then((next) => {
setReport(next);
return next;
});
const load = () => fetchReport().then(() => void 0);
- (0, import_react36.useEffect)(() => {
+ (0, import_react40.useEffect)(() => {
void run2(load());
}, []);
const copyReport = () => run2(fetchReport().then(async (next) => {
@@ -14981,7 +15335,7 @@ function FeedbackPage({ actions, run: run2, Section, Row: Row3 }) {
setNote(copied ? t("Copied the diagnostics.") : t("Could not copy. Select the text below and copy it."));
if (!copied) setPreview(true);
}));
- const [issueLink, setIssueLink] = (0, import_react36.useState)(null);
+ const [issueLink, setIssueLink] = (0, import_react40.useState)(null);
const openIssue = () => {
const target = issueWindow();
run2(fetchReport().then(async (next) => {
@@ -15007,59 +15361,59 @@ function FeedbackPage({ actions, run: run2, Section, Row: Row3 }) {
const total = (report?.total ?? 0) + browserErrors.length;
const shown = entries2.slice(0, 8);
return [
- (0, import_react36.createElement)(
+ (0, import_react40.createElement)(
Section,
{ key: "report", title: t("Report a problem") },
- (0, import_react36.createElement)(
+ (0, import_react40.createElement)(
"div",
{ className: "bt-set-row bt-set-paste bt-fb-what" },
- (0, import_react36.createElement)(
+ (0, import_react40.createElement)(
"label",
{ className: "bt-set-copy", htmlFor: "bt-fb-what" },
- (0, import_react36.createElement)("span", null, t("What happened?")),
- (0, import_react36.createElement)("span", { className: "bt-set-hint" }, t("What you did, what you expected, and what happened instead. It goes into the issue."))
+ (0, import_react40.createElement)("span", null, t("What happened?")),
+ (0, import_react40.createElement)("span", { className: "bt-set-hint" }, t("What you did, what you expected, and what happened instead. It goes into the issue."))
),
- (0, import_react36.createElement)("textarea", { id: "bt-fb-what", className: "bt-input bt-input-area", value: what, maxLength: WHAT_MAX, placeholder: t("For example: I asked Writer in the group chat and it showed an error."), onChange: (event) => setWhat(event.target.value) })
+ (0, import_react40.createElement)("textarea", { id: "bt-fb-what", className: "bt-input bt-input-area", value: what, maxLength: WHAT_MAX, placeholder: t("For example: I asked Writer in the group chat and it showed an error."), onChange: (event) => setWhat(event.target.value) })
),
- (0, import_react36.createElement)(
+ (0, import_react40.createElement)(
Row3,
{ label: t("Diagnostics"), hint: t("Versions, system, models, and the latest errors. Saved keys, tokens, and your home folder are hidden.") },
- (0, import_react36.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setPreview(!preview), "aria-expanded": preview }, preview ? t("Hide") : t("Show")),
- (0, import_react36.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: copyReport }, t("Copy"))
+ (0, import_react40.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setPreview(!preview), "aria-expanded": preview }, preview ? t("Hide") : t("Show")),
+ (0, import_react40.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: copyReport }, t("Copy"))
),
- preview ? (0, import_react36.createElement)("div", { className: "bt-set-row bt-fb-preview" }, (0, import_react36.createElement)("pre", { tabIndex: 0, "aria-label": t("Diagnostics") }, report?.markdown || t("Loading…"))) : null,
- (0, import_react36.createElement)(
+ preview ? (0, import_react40.createElement)("div", { className: "bt-set-row bt-fb-preview" }, (0, import_react40.createElement)("pre", { tabIndex: 0, "aria-label": t("Diagnostics") }, report?.markdown || t("Loading…"))) : null,
+ (0, import_react40.createElement)(
Row3,
{ label: t("GitHub issue"), hint: t("Opens a new issue in the DS Bot repository with all of this filled in. Nothing is sent until you submit it there.") },
- (0, import_react36.createElement)("button", { type: "button", className: "bt-fb-primary", onClick: openIssue }, t("Report on GitHub"))
+ (0, import_react40.createElement)("button", { type: "button", className: "bt-fb-primary", onClick: openIssue }, t("Report on GitHub"))
)
),
- note ? (0, import_react36.createElement)(
+ note ? (0, import_react40.createElement)(
"div",
{ key: "note", className: "bt-note bt-fb-note", role: "status" },
note,
- issueLink ? [" ", (0, import_react36.createElement)("a", { key: "link", href: issueLink, target: "_blank", rel: "noopener noreferrer" }, t("Open the issue"))] : null
+ issueLink ? [" ", (0, import_react40.createElement)("a", { key: "link", href: issueLink, target: "_blank", rel: "noopener noreferrer" }, t("Open the issue"))] : null
) : null,
- (0, import_react36.createElement)(
+ (0, import_react40.createElement)(
Section,
{ key: "errors", title: report ? t("Recent errors · {count}", { count: total }) : t("Recent errors") },
- shown.length === 0 ? (0, import_react36.createElement)(Row3, { label: t("No errors recorded."), hint: t("Failed model calls and DS Bot problems show here, newest first.") }) : shown.map((entry, index) => (0, import_react36.createElement)(
+ shown.length === 0 ? (0, import_react40.createElement)(Row3, { label: t("No errors recorded."), hint: t("Failed model calls and DS Bot problems show here, newest first.") }) : shown.map((entry, index) => (0, import_react40.createElement)(
"div",
{ key: `${entry.time}-${index}`, className: "bt-set-row bt-fb-entry", title: entry.text },
- (0, import_react36.createElement)("span", { className: "bt-fb-dot", "data-level": entry.level, "aria-hidden": true }),
- (0, import_react36.createElement)(
+ (0, import_react40.createElement)("span", { className: "bt-fb-dot", "data-level": entry.level, "aria-hidden": true }),
+ (0, import_react40.createElement)(
"div",
{ className: "bt-set-copy" },
- (0, import_react36.createElement)("span", { className: "bt-fb-text" }, entrySummary(entry)),
- (0, import_react36.createElement)("span", { className: "bt-set-hint" }, [whenText(entry.time), entry.bot, entry.where, t(SOURCES[entry.source] ?? "DS Bot")].filter(Boolean).join(" · "))
+ (0, import_react40.createElement)("span", { className: "bt-fb-text" }, entrySummary(entry)),
+ (0, import_react40.createElement)("span", { className: "bt-set-hint" }, [whenText(entry.time), entry.bot, entry.where, t(SOURCES[entry.source] ?? "DS Bot")].filter(Boolean).join(" · "))
),
- entry.code ? (0, import_react36.createElement)("span", { className: "bt-tag bt-fb-code" }, entry.status ? `${entry.code} ${entry.status}` : entry.code) : null
+ entry.code ? (0, import_react40.createElement)("span", { className: "bt-tag bt-fb-code" }, entry.status ? `${entry.code} ${entry.status}` : entry.code) : null
)),
- (0, import_react36.createElement)(
+ (0, import_react40.createElement)(
Row3,
{ label: t("Error log"), hint: t("Kept on this computer across restarts, up to about 1 MB.") },
- (0, import_react36.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: downloadLog }, t("Download")),
- (0, import_react36.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: clearLog, disabled: !report || total === 0 }, t("Clear"))
+ (0, import_react40.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: downloadLog }, t("Download")),
+ (0, import_react40.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: clearLog, disabled: !report || total === 0 }, t("Clear"))
)
)
];
@@ -15067,8 +15421,8 @@ function FeedbackPage({ actions, run: run2, Section, Row: Row3 }) {
var TOAST_MS = 6e3;
function ErrorToast({ useUi, actions }) {
const toast = useUi((state) => state.toast);
- const [leaving, setLeaving] = (0, import_react36.useState)(false);
- (0, import_react36.useEffect)(() => {
+ const [leaving, setLeaving] = (0, import_react40.useState)(false);
+ (0, import_react40.useEffect)(() => {
if (!toast) return void 0;
setLeaving(false);
const fade = setTimeout(() => setLeaving(true), TOAST_MS);
@@ -15079,15 +15433,15 @@ function ErrorToast({ useUi, actions }) {
};
}, [toast?.token]);
if (!toast) return null;
- return (0, import_react36.createElement)(
+ return (0, import_react40.createElement)(
"div",
{ className: "bt-toast", role: "alert", "data-leaving": leaving || void 0 },
- (0, import_react36.createElement)("span", { className: "bt-toast-text" }, toast.text),
- (0, import_react36.createElement)("button", { type: "button", className: "bt-toast-link", onClick: () => {
+ (0, import_react40.createElement)("span", { className: "bt-toast-text" }, toast.text),
+ (0, import_react40.createElement)("button", { type: "button", className: "bt-toast-link", onClick: () => {
actions.dismissToast(toast.token);
actions.openSettings("feedback");
} }, t("Details")),
- (0, import_react36.createElement)("button", { type: "button", className: "bt-icon-btn bt-toast-close", "aria-label": t("Dismiss"), onClick: () => actions.dismissToast(toast.token) }, (0, import_react36.createElement)(CloseIcon))
+ (0, import_react40.createElement)("button", { type: "button", className: "bt-icon-btn bt-toast-close", "aria-label": t("Dismiss"), onClick: () => actions.dismissToast(toast.token) }, (0, import_react40.createElement)(CloseIcon))
);
}
var FEEDBACK_CSS = `
@@ -15119,7 +15473,7 @@ var FEEDBACK_CSS = `
`;
// src/client/about.js
-var import_react37 = require("react");
+var import_react41 = require("react");
var CHEER_MS = 1800;
var starCount = (count) => new Intl.NumberFormat(dateLocale(), { notation: "compact", maximumFractionDigits: 1 }).format(count);
function botHint(update) {
@@ -15167,9 +15521,9 @@ function dshHint(dsh, shown) {
var linkProps = (href) => ({ className: "bt-soft bt-soft-sm bt-about-link", href, target: "_blank", rel: "noopener noreferrer" });
function AboutPage({ useUpdate, actions, run: run2, Section, Row: Row3 }) {
const update = useUpdate((value) => value) ?? {};
- const [checking, setChecking] = (0, import_react37.useState)(false);
- const [stars, setStars] = (0, import_react37.useState)(null);
- (0, import_react37.useEffect)(() => {
+ const [checking, setChecking] = (0, import_react41.useState)(false);
+ const [stars, setStars] = (0, import_react41.useState)(null);
+ (0, import_react41.useEffect)(() => {
let live = true;
actions.repoStars().then((count) => {
if (live && Number.isInteger(count)) setStars(count);
@@ -15179,8 +15533,8 @@ function AboutPage({ useUpdate, actions, run: run2, Section, Row: Row3 }) {
live = false;
};
}, []);
- const [cheer, setCheer] = (0, import_react37.useState)(true);
- (0, import_react37.useEffect)(() => {
+ const [cheer, setCheer] = (0, import_react41.useState)(true);
+ (0, import_react41.useEffect)(() => {
if (!cheer) return void 0;
const timer = setTimeout(() => setCheer(false), CHEER_MS);
return () => clearTimeout(timer);
@@ -15195,37 +15549,37 @@ function AboutPage({ useUpdate, actions, run: run2, Section, Row: Row3 }) {
const phase = update.phase ?? "idle";
const dsh = update.dsh;
const dshPhase = dsh?.phase ?? "idle";
- (0, import_react37.useEffect)(() => {
+ (0, import_react41.useEffect)(() => {
if (phase === "installed" || phase === "updated" || dshPhase === "installed") setCheer(true);
}, [phase, dshPhase]);
const markState = checking ? "searching" : phase === "installing" || dshPhase === "installing" ? "working" : cheer ? "done" : "idle";
const dshNew = showsDshRow(dsh, update.app);
const dshShown = dshNew && dsh.available;
const ownRow = update.source === "app" ? ownAppRow(update.ownApp) : null;
- const ownControl = ownRow?.button === "restart" ? (0, import_react37.createElement)("button", { type: "button", className: "bt-fb-primary", onClick: () => run2(actions.installOwnApp()) }, t("Restart to update")) : ownRow?.button === "check" ? (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.checkOwnApp()) }, t("Check for updates")) : ownRow?.button === "open" ? (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.openOwnApp()) }, t("Download")) : null;
- const botControl = ownRow !== null ? ownControl : phase === "installed" || phase === "updated" || update.source === "app" ? null : update.available || phase === "installing" ? (0, import_react37.createElement)(
+ const ownControl = ownRow?.button === "restart" ? (0, import_react41.createElement)("button", { type: "button", className: "bt-fb-primary", onClick: () => run2(actions.installOwnApp()) }, t("Restart to update")) : ownRow?.button === "check" ? (0, import_react41.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.checkOwnApp()) }, t("Check for updates")) : ownRow?.button === "open" ? (0, import_react41.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.openOwnApp()) }, t("Download")) : null;
+ const botControl = ownRow !== null ? ownControl : phase === "installed" || phase === "updated" || update.source === "app" ? null : update.available || phase === "installing" ? (0, import_react41.createElement)(
"button",
{ type: "button", className: "bt-fb-primary", disabled: phase === "installing", onClick: () => run2(actions.installUpdate()) },
phase === "installing" ? t("Updating…") : phase === "failed" ? t("Try again") : t("Update")
- ) : (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: checking || update.enabled === false, onClick: check }, checking ? t("Checking…") : t("Check for updates"));
- const dshControl = !dshNew || dshPhase === "installed" ? null : dsh.kind === "app" ? dsh.available ? (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.openAppUpdates(dsh.verified)) }, t("Open updates")) : null : dsh.available || dshPhase !== "idle" ? (0, import_react37.createElement)(
+ ) : (0, import_react41.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: checking || update.enabled === false, onClick: check }, checking ? t("Checking…") : t("Check for updates"));
+ const dshControl = !dshNew || dshPhase === "installed" ? null : dsh.kind === "app" ? dsh.available ? (0, import_react41.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.openAppUpdates(dsh.verified)) }, t("Open updates")) : null : dsh.available || dshPhase !== "idle" ? (0, import_react41.createElement)(
"button",
{ type: "button", className: "bt-fb-primary", disabled: dshPhase === "installing", onClick: () => run2(actions.installDshUpdate()) },
dshPhase === "installing" ? t("Updating…") : dshPhase === "failed" ? t("Try again") : t("Update")
) : null;
const repo = update.repoUrl;
return [
- (0, import_react37.createElement)(
+ (0, import_react41.createElement)(
"div",
{ key: "hero", className: "bt-about-hero" },
- (0, import_react37.createElement)("span", { className: "bt-about-mark" }, (0, import_react37.createElement)(BotMark, { look: MAIN_LOOK, bot: { id: "about" }, size: 52, state: markState, live: true, gaze: true, pokeable: true })),
- (0, import_react37.createElement)(
+ (0, import_react41.createElement)("span", { className: "bt-about-mark" }, (0, import_react41.createElement)(BotMark, { look: MAIN_LOOK, bot: { id: "about" }, size: 52, state: markState, live: true, gaze: true, pokeable: true })),
+ (0, import_react41.createElement)(
"div",
{ className: "bt-about-copy" },
- (0, import_react37.createElement)("span", { className: "bt-about-name" }, "DS Bot"),
- update.current ? (0, import_react37.createElement)("span", { className: "bt-about-version" }, t("Version {version}", { version: update.current })) : null
+ (0, import_react41.createElement)("span", { className: "bt-about-name" }, "DS Bot"),
+ update.current ? (0, import_react41.createElement)("span", { className: "bt-about-version" }, t("Version {version}", { version: update.current })) : null
),
- repo ? (0, import_react37.createElement)(
+ repo ? (0, import_react41.createElement)(
"a",
{
className: "bt-star",
@@ -15235,23 +15589,23 @@ function AboutPage({ useUpdate, actions, run: run2, Section, Row: Row3 }) {
title: t("Star DS Bot on GitHub"),
"aria-label": stars === null ? t("Star DS Bot on GitHub") : `${t("Star DS Bot on GitHub")} · ${t("{count} stars", { count: stars })}`
},
- (0, import_react37.createElement)("span", { className: "bt-star-main" }, (0, import_react37.createElement)("span", { className: "bt-star-icon" }, (0, import_react37.createElement)(StarLineIcon)), "Star"),
- stars === null ? null : (0, import_react37.createElement)("span", { className: "bt-star-count" }, starCount(stars))
+ (0, import_react41.createElement)("span", { className: "bt-star-main" }, (0, import_react41.createElement)("span", { className: "bt-star-icon" }, (0, import_react41.createElement)(StarLineIcon)), "Star"),
+ stars === null ? null : (0, import_react41.createElement)("span", { className: "bt-star-count" }, starCount(stars))
) : null
),
- repo ? (0, import_react37.createElement)("p", { key: "ask", className: "bt-about-ask" }, t("If DS Bot helps you, a star on GitHub helps more people find it.")) : null,
- (0, import_react37.createElement)(
+ repo ? (0, import_react41.createElement)("p", { key: "ask", className: "bt-about-ask" }, t("If DS Bot helps you, a star on GitHub helps more people find it.")) : null,
+ (0, import_react41.createElement)(
Section,
{ key: "updates", title: t("Updates") },
- (0, import_react37.createElement)(Row3, { label: "DS Bot", hint: ownRow?.hint ?? botHint(update) }, botControl, update.available && update.notesUrl ? (0, import_react37.createElement)("a", linkProps(update.notesUrl), t("What's new")) : null),
- dsh?.current ? (0, import_react37.createElement)(Row3, { label: "DeepSeek Harness", hint: dshHint(dsh, dshShown) }, dshControl) : null
+ (0, import_react41.createElement)(Row3, { label: "DS Bot", hint: ownRow?.hint ?? botHint(update) }, botControl, update.available && update.notesUrl ? (0, import_react41.createElement)("a", linkProps(update.notesUrl), t("What's new")) : null),
+ dsh?.current ? (0, import_react41.createElement)(Row3, { label: "DeepSeek Harness", hint: dshHint(dsh, dshShown) }, dshControl) : null
),
- (0, import_react37.createElement)(
+ (0, import_react41.createElement)(
Section,
{ key: "links", title: t("Links") },
- repo ? (0, import_react37.createElement)(Row3, { label: t("Source code"), hint: repo.replace(/^https:\/\//, "") }, (0, import_react37.createElement)("a", linkProps(repo), (0, import_react37.createElement)(GitHubMark), t("Open"))) : null,
- update.notesUrl ? (0, import_react37.createElement)(Row3, { label: t("Release notes") }, (0, import_react37.createElement)("a", linkProps(update.notesUrl), t("Open"))) : null,
- (0, import_react37.createElement)(Row3, { label: t("Report a problem") }, (0, import_react37.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.openSettings("feedback") }, t("Open")))
+ repo ? (0, import_react41.createElement)(Row3, { label: t("Source code"), hint: repo.replace(/^https:\/\//, "") }, (0, import_react41.createElement)("a", linkProps(repo), (0, import_react41.createElement)(GitHubMark), t("Open"))) : null,
+ update.notesUrl ? (0, import_react41.createElement)(Row3, { label: t("Release notes") }, (0, import_react41.createElement)("a", linkProps(update.notesUrl), t("Open"))) : null,
+ (0, import_react41.createElement)(Row3, { label: t("Report a problem") }, (0, import_react41.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.openSettings("feedback") }, t("Open")))
)
];
}
@@ -15284,7 +15638,7 @@ body:not([data-bt-motion=quiet]) .bt-about-mark:hover .bt-mark[data-live][data-s
`;
// src/client/providers-page.js
-var import_react38 = require("react");
+var import_react42 = require("react");
var PROTOCOL_NAMES = { "openai-completions": "OpenAI Chat Completions", "openai-responses": "OpenAI Responses", "anthropic-messages": "Anthropic Messages" };
var ENDPOINT_HINTS = { "anthropic-messages": "https://gateway.example" };
var SHOWN_MODELS = 8;
@@ -15292,22 +15646,22 @@ var translated = (promise) => Promise.resolve(promise).catch((failure) => {
throw new Error(hostText(failure?.message ?? String(failure)));
});
function ProvidersPage({ actions, run: run2, Section }) {
- const [view, setView] = (0, import_react38.useState)(null);
- const [open, setOpen] = (0, import_react38.useState)(null);
- const [adding, setAdding] = (0, import_react38.useState)(false);
+ const [view, setView] = (0, import_react42.useState)(null);
+ const [open, setOpen] = (0, import_react42.useState)(null);
+ const [adding, setAdding] = (0, import_react42.useState)(false);
const apply2 = (promise) => run2(translated(promise).then((next) => {
if (next?.providers) setView(next);
}));
- (0, import_react38.useEffect)(() => {
+ (0, import_react42.useEffect)(() => {
void apply2(actions.providers());
}, []);
if (view === null) return null;
- if (!view.available) return (0, import_react38.createElement)("p", { className: "bt-set-hint" }, t("This DSH cannot set up model providers."));
+ if (!view.available) return (0, import_react42.createElement)("p", { className: "bt-set-hint" }, t("This DSH cannot set up model providers."));
return [
- (0, import_react38.createElement)(
+ (0, import_react42.createElement)(
Section,
{ key: "list", title: t("Model providers · {count}", { count: view.providers.length }) },
- view.providers.map((provider) => (0, import_react38.createElement)(ProviderRow, {
+ view.providers.map((provider) => (0, import_react42.createElement)(ProviderRow, {
key: provider.id,
provider,
apply: apply2,
@@ -15315,9 +15669,9 @@ function ProvidersPage({ actions, run: run2, Section }) {
open: open === provider.id,
onToggle: () => setOpen(open === provider.id ? null : provider.id)
})),
- adding ? (0, import_react38.createElement)(AddProvider, { key: "add", view, apply: apply2, actions, onDone: () => setAdding(false) }) : null
+ adding ? (0, import_react42.createElement)(AddProvider, { key: "add", view, apply: apply2, actions, onDone: () => setAdding(false) }) : null
),
- adding ? null : (0, import_react38.createElement)("div", { key: "add", className: "bt-actions" }, (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setAdding(true) }, t("Add a provider")))
+ adding ? null : (0, import_react42.createElement)("div", { key: "add", className: "bt-actions" }, (0, import_react42.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => setAdding(true) }, t("Add a provider")))
];
}
function keyState(key) {
@@ -15326,58 +15680,58 @@ function keyState(key) {
return key.writable ? ["set", t("Key set")] : ["outside", t("Key set outside DS Bot")];
}
function ProviderRow({ provider, apply: apply2, actions, open, onToggle }) {
- const [confirm, setConfirm] = (0, import_react38.useState)(false);
- (0, import_react38.useEffect)(() => {
+ const [confirm, setConfirm] = (0, import_react42.useState)(false);
+ (0, import_react42.useEffect)(() => {
if (!open) setConfirm(false);
}, [open]);
const state = keyState(provider.key);
const shown = provider.models.slice(0, SHOWN_MODELS);
const hint = provider.error ?? (provider.models.length === 0 ? t("No models") : t("{count} models", { count: provider.models.length }));
- return (0, import_react38.createElement)(
+ return (0, import_react42.createElement)(
"div",
{ className: "bt-secret-item bt-provider", "data-open": open ? "" : void 0 },
- (0, import_react38.createElement)(
+ (0, import_react42.createElement)(
"button",
{ type: "button", className: "bt-set-row bt-secret-summary", "aria-expanded": open, onClick: onToggle },
- (0, import_react38.createElement)(
+ (0, import_react42.createElement)(
"span",
{ className: "bt-set-copy" },
- (0, import_react38.createElement)("span", { className: "bt-secret-title" }, provider.name, provider.name !== provider.id ? (0, import_react38.createElement)("span", { className: "bt-provider-id" }, provider.id) : null),
- (0, import_react38.createElement)("span", { className: "bt-set-hint", "data-error": provider.error ? "" : void 0 }, hint)
+ (0, import_react42.createElement)("span", { className: "bt-secret-title" }, provider.name, provider.name !== provider.id ? (0, import_react42.createElement)("span", { className: "bt-provider-id" }, provider.id) : null),
+ (0, import_react42.createElement)("span", { className: "bt-set-hint", "data-error": provider.error ? "" : void 0 }, hint)
),
- state ? (0, import_react38.createElement)("span", { className: "bt-set-control" }, (0, import_react38.createElement)("span", { className: "bt-provider-state", "data-state": state[0] }, state[1])) : null
+ state ? (0, import_react42.createElement)("span", { className: "bt-set-control" }, (0, import_react42.createElement)("span", { className: "bt-provider-state", "data-state": state[0] }, state[1])) : null
),
- open ? (0, import_react38.createElement)(
+ open ? (0, import_react42.createElement)(
"div",
{ className: "bt-secret-edit" },
- provider.key?.writable ? (0, import_react38.createElement)(KeyEditor, { provider, apply: apply2, actions }) : null,
- provider.key && !provider.key.writable ? (0, import_react38.createElement)("div", { className: "bt-set-hint" }, t("This key comes from outside DS Bot, such as an environment variable, and cannot be changed here.")) : null,
- provider.models.length > 0 ? (0, import_react38.createElement)(
+ provider.key?.writable ? (0, import_react42.createElement)(KeyEditor, { provider, apply: apply2, actions }) : null,
+ provider.key && !provider.key.writable ? (0, import_react42.createElement)("div", { className: "bt-set-hint" }, t("This key comes from outside DS Bot, such as an environment variable, and cannot be changed here.")) : null,
+ provider.models.length > 0 ? (0, import_react42.createElement)(
"div",
{ className: "bt-secret-edit-block" },
- (0, import_react38.createElement)("div", { className: "bt-secret-edit-label" }, t("Models")),
- (0, import_react38.createElement)(
+ (0, import_react42.createElement)("div", { className: "bt-secret-edit-label" }, t("Models")),
+ (0, import_react42.createElement)(
"div",
{ className: "bt-provider-models" },
- shown.map((model) => (0, import_react38.createElement)("span", { key: model.ref, className: "bt-tag", title: model.ref }, model.name)),
- provider.models.length > shown.length ? (0, import_react38.createElement)("span", { className: "bt-set-hint" }, t("and {count} more", { count: provider.models.length - shown.length })) : null
+ shown.map((model) => (0, import_react42.createElement)("span", { key: model.ref, className: "bt-tag", title: model.ref }, model.name)),
+ provider.models.length > shown.length ? (0, import_react42.createElement)("span", { className: "bt-set-hint" }, t("and {count} more", { count: provider.models.length - shown.length })) : null
)
) : null,
- provider.removable ? (0, import_react38.createElement)(
+ provider.removable ? (0, import_react42.createElement)(
"div",
{ className: "bt-secret-row-actions" },
confirm ? [
- (0, import_react38.createElement)("span", { key: "q", className: "bt-set-hint" }, t("Remove {name}? Bots on its models need another model.", { name: provider.name })),
- (0, import_react38.createElement)("button", { key: "no", type: "button", className: "bt-soft bt-soft-sm", onClick: () => setConfirm(false) }, t("Keep")),
- (0, import_react38.createElement)("button", { key: "yes", type: "button", className: "bt-soft bt-soft-sm bt-secret-danger", onClick: () => apply2(actions.removeProvider(provider.id)) }, t("Remove"))
- ] : (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-secret-danger", onClick: () => setConfirm(true) }, (0, import_react38.createElement)(TrashIcon), t("Remove provider"))
+ (0, import_react42.createElement)("span", { key: "q", className: "bt-set-hint" }, t("Remove {name}? Bots on its models need another model.", { name: provider.name })),
+ (0, import_react42.createElement)("button", { key: "no", type: "button", className: "bt-soft bt-soft-sm", onClick: () => setConfirm(false) }, t("Keep")),
+ (0, import_react42.createElement)("button", { key: "yes", type: "button", className: "bt-soft bt-soft-sm bt-secret-danger", onClick: () => apply2(actions.removeProvider(provider.id)) }, t("Remove"))
+ ] : (0, import_react42.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-secret-danger", onClick: () => setConfirm(true) }, (0, import_react42.createElement)(TrashIcon), t("Remove provider"))
) : null
) : null
);
}
function KeyEditor({ provider, apply: apply2, actions }) {
- const [value, setValue] = (0, import_react38.useState)("");
- const [saved, setSaved] = (0, import_react38.useState)(false);
+ const [value, setValue] = (0, import_react42.useState)("");
+ const [saved, setSaved] = (0, import_react42.useState)(false);
const ready = value.trim() !== "";
const save = () => {
if (!ready) return;
@@ -15393,29 +15747,29 @@ function KeyEditor({ provider, apply: apply2, actions }) {
setSaved(false);
};
const label = t("{provider} API key", { provider: provider.name });
- return (0, import_react38.createElement)(
+ return (0, import_react42.createElement)(
"div",
{ className: "bt-secret-edit-block" },
- (0, import_react38.createElement)("div", { className: "bt-secret-edit-label" }, provider.key.configured ? t("Replace the API key") : t("API key")),
- (0, import_react38.createElement)(
+ (0, import_react42.createElement)("div", { className: "bt-secret-edit-label" }, provider.key.configured ? t("Replace the API key") : t("API key")),
+ (0, import_react42.createElement)(
"div",
{ className: "bt-secret-inline" },
- (0, import_react38.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react38.createElement)(KeyIcon), (0, import_react38.createElement)(MaskedInput, { value, onChange: edit, onEnter: save, label })),
- (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: !ready, onClick: save }, t("Save")),
- provider.key.configured ? (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-secret-danger", onClick: () => apply2(actions.setProviderKey(provider.id, null)) }, t("Remove key")) : null
+ (0, import_react42.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react42.createElement)(KeyIcon), (0, import_react42.createElement)(MaskedInput, { value, onChange: edit, onEnter: save, label })),
+ (0, import_react42.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: !ready, onClick: save }, t("Save")),
+ provider.key.configured ? (0, import_react42.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-secret-danger", onClick: () => apply2(actions.setProviderKey(provider.id, null)) }, t("Remove key")) : null
),
- saved ? (0, import_react38.createElement)("div", { className: "bt-set-hint bt-secret-ok", role: "status" }, (0, import_react38.createElement)(CheckIcon), t("Saved.")) : null
+ saved ? (0, import_react42.createElement)("div", { className: "bt-set-hint bt-secret-ok", role: "status" }, (0, import_react42.createElement)(CheckIcon), t("Saved.")) : null
);
}
function AddProvider({ view, apply: apply2, actions, onDone }) {
- const [mode, setMode] = (0, import_react38.useState)(view.addable.length > 0 ? "known" : "custom");
- return (0, import_react38.createElement)(
+ const [mode, setMode] = (0, import_react42.useState)(view.addable.length > 0 ? "known" : "custom");
+ return (0, import_react42.createElement)(
"div",
{ className: "bt-set-row bt-set-paste bt-provider-add" },
- (0, import_react38.createElement)(
+ (0, import_react42.createElement)(
Segmented,
{ label: t("Kind of provider"), value: mode },
- [["known", t("Known provider")], ["custom", t("Custom API")]].map(([id, label]) => (0, import_react38.createElement)("button", {
+ [["known", t("Known provider")], ["custom", t("Custom API")]].map(([id, label]) => (0, import_react42.createElement)("button", {
key: id,
type: "button",
"aria-pressed": mode === id,
@@ -15424,13 +15778,13 @@ function AddProvider({ view, apply: apply2, actions, onDone }) {
}, label))
),
// Both forms stay mounted, so switching keeps what is typed in the other.
- (0, import_react38.createElement)("div", { hidden: mode !== "known" }, (0, import_react38.createElement)(KnownForm, { view, apply: apply2, actions, onDone })),
- (0, import_react38.createElement)("div", { hidden: mode !== "custom" }, (0, import_react38.createElement)(CustomForm, { view, apply: apply2, actions, onDone }))
+ (0, import_react42.createElement)("div", { hidden: mode !== "known" }, (0, import_react42.createElement)(KnownForm, { view, apply: apply2, actions, onDone })),
+ (0, import_react42.createElement)("div", { hidden: mode !== "custom" }, (0, import_react42.createElement)(CustomForm, { view, apply: apply2, actions, onDone }))
);
}
function KnownForm({ view, apply: apply2, actions, onDone }) {
- const [provider, setProvider] = (0, import_react38.useState)("");
- const [key, setKey] = (0, import_react38.useState)("");
+ const [provider, setProvider] = (0, import_react42.useState)("");
+ const [key, setKey] = (0, import_react42.useState)("");
const options = [...view.addable].sort((a, b) => a.name.localeCompare(b.name));
const add = () => {
if (provider === "") return;
@@ -15438,24 +15792,24 @@ function KnownForm({ view, apply: apply2, actions, onDone }) {
if (ok) onDone();
});
};
- return (0, import_react38.createElement)(
+ return (0, import_react42.createElement)(
"div",
{ className: "bt-provider-form" },
- (0, import_react38.createElement)(
+ (0, import_react42.createElement)(
"select",
{ className: "bt-select", "aria-label": t("Provider"), value: provider, onChange: (event) => setProvider(event.target.value) },
- (0, import_react38.createElement)("option", { value: "", disabled: true }, t("Choose a provider")),
- options.map((option) => (0, import_react38.createElement)("option", { key: option.id, value: option.id }, option.name))
+ (0, import_react42.createElement)("option", { value: "", disabled: true }, t("Choose a provider")),
+ options.map((option) => (0, import_react42.createElement)("option", { key: option.id, value: option.id }, option.name))
),
- (0, import_react38.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react38.createElement)(KeyIcon), (0, import_react38.createElement)(MaskedInput, { value: key, onChange: setKey, onEnter: add, label: t("API key") })),
- (0, import_react38.createElement)(FormActions, { onCancel: onDone, onAdd: add, ready: provider !== "" })
+ (0, import_react42.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react42.createElement)(KeyIcon), (0, import_react42.createElement)(MaskedInput, { value: key, onChange: setKey, onEnter: add, label: t("API key") })),
+ (0, import_react42.createElement)(FormActions, { onCancel: onDone, onAdd: add, ready: provider !== "" })
);
}
function CustomForm({ view, apply: apply2, actions, onDone }) {
- const [draft, setDraft] = (0, import_react38.useState)({ provider: "", name: "", baseURL: "", api: view.protocols[0], key: "", typed: "" });
- const [found, setFound] = (0, import_react38.useState)(null);
- const [picked, setPicked] = (0, import_react38.useState)([]);
- const [asking, setAsking] = (0, import_react38.useState)(false);
+ const [draft, setDraft] = (0, import_react42.useState)({ provider: "", name: "", baseURL: "", api: view.protocols[0], key: "", typed: "" });
+ const [found, setFound] = (0, import_react42.useState)(null);
+ const [picked, setPicked] = (0, import_react42.useState)([]);
+ const [asking, setAsking] = (0, import_react42.useState)(false);
const set = (field, value) => setDraft((current) => ({ ...current, [field]: value }));
const typed = draft.typed.split(/[\s,]+/).map((id) => id.trim()).filter(Boolean);
const models = [...(found ?? []).filter((model) => picked.includes(model.id)), ...typed.filter((id) => !picked.includes(id)).map((id) => ({ id }))];
@@ -15474,7 +15828,7 @@ function CustomForm({ view, apply: apply2, actions, onDone }) {
if (ok) onDone();
});
};
- const input = (field, label, placeholder) => (0, import_react38.createElement)("input", {
+ const input = (field, label, placeholder) => (0, import_react42.createElement)("input", {
className: "bt-input",
"aria-label": label,
placeholder,
@@ -15483,55 +15837,55 @@ function CustomForm({ view, apply: apply2, actions, onDone }) {
autoComplete: "off",
onChange: (event) => set(field, event.target.value)
});
- return (0, import_react38.createElement)(
+ return (0, import_react42.createElement)(
"div",
{ className: "bt-provider-form" },
- (0, import_react38.createElement)(
+ (0, import_react42.createElement)(
"div",
{ className: "bt-provider-pair" },
input("provider", t("Provider ID"), t("Provider ID, e.g. my-gateway")),
input("name", t("Name"), t("Name (optional)"))
),
- (0, import_react38.createElement)(
+ (0, import_react42.createElement)(
"div",
{ className: "bt-provider-pair" },
input("baseURL", t("Endpoint"), ENDPOINT_HINTS[draft.api] ?? "https://gateway.example/v1"),
- (0, import_react38.createElement)(
+ (0, import_react42.createElement)(
"select",
{ className: "bt-select", "aria-label": t("Protocol"), value: draft.api, onChange: (event) => set("api", event.target.value) },
- view.protocols.map((api) => (0, import_react38.createElement)("option", { key: api, value: api }, PROTOCOL_NAMES[api] ?? api))
+ view.protocols.map((api) => (0, import_react42.createElement)("option", { key: api, value: api }, PROTOCOL_NAMES[api] ?? api))
)
),
- (0, import_react38.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react38.createElement)(KeyIcon), (0, import_react38.createElement)(MaskedInput, { value: draft.key, onChange: (value) => set("key", value), label: t("API key") })),
- (0, import_react38.createElement)(
+ (0, import_react42.createElement)("label", { className: "bt-q-field bt-secret-field" }, (0, import_react42.createElement)(KeyIcon), (0, import_react42.createElement)(MaskedInput, { value: draft.key, onChange: (value) => set("key", value), label: t("API key") })),
+ (0, import_react42.createElement)(
"div",
{ className: "bt-secret-edit-block" },
- (0, import_react38.createElement)(
+ (0, import_react42.createElement)(
"div",
{ className: "bt-provider-models-head" },
- (0, import_react38.createElement)("span", { className: "bt-secret-edit-label" }, t("Models")),
- (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: asking || draft.baseURL.trim() === "", onClick: fetchModels }, asking ? t("Asking…") : t("Fetch models"))
+ (0, import_react42.createElement)("span", { className: "bt-secret-edit-label" }, t("Models")),
+ (0, import_react42.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: asking || draft.baseURL.trim() === "", onClick: fetchModels }, asking ? t("Asking…") : t("Fetch models"))
),
- found !== null && found.length === 0 ? (0, import_react38.createElement)("div", { className: "bt-set-hint" }, t("The endpoint lists no models. Enter their ids below.")) : null,
- found !== null && found.length > 0 ? (0, import_react38.createElement)("div", { className: "bt-secret-bots bt-provider-found" }, found.map((model) => (0, import_react38.createElement)("button", {
+ found !== null && found.length === 0 ? (0, import_react42.createElement)("div", { className: "bt-set-hint" }, t("The endpoint lists no models. Enter their ids below.")) : null,
+ found !== null && found.length > 0 ? (0, import_react42.createElement)("div", { className: "bt-secret-bots bt-provider-found" }, found.map((model) => (0, import_react42.createElement)("button", {
key: model.id,
type: "button",
className: "bt-secret-bot",
"aria-pressed": picked.includes(model.id),
title: model.name && model.name !== model.id ? model.name : void 0,
onClick: () => toggle(model.id)
- }, (0, import_react38.createElement)("code", null, model.id), picked.includes(model.id) ? (0, import_react38.createElement)(CheckIcon) : null))) : null,
+ }, (0, import_react42.createElement)("code", null, model.id), picked.includes(model.id) ? (0, import_react42.createElement)(CheckIcon) : null))) : null,
input("typed", t("Model ids"), t("Model ids, separated by commas"))
),
- (0, import_react38.createElement)(FormActions, { onCancel: onDone, onAdd: add, ready })
+ (0, import_react42.createElement)(FormActions, { onCancel: onDone, onAdd: add, ready })
);
}
function FormActions({ onCancel, onAdd, ready }) {
- return (0, import_react38.createElement)(
+ return (0, import_react42.createElement)(
"div",
{ className: "bt-secret-row-actions" },
- (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onCancel }, t("Cancel")),
- (0, import_react38.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: !ready, onClick: onAdd }, t("Add"))
+ (0, import_react42.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: onCancel }, t("Cancel")),
+ (0, import_react42.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: !ready, onClick: onAdd }, t("Add"))
);
}
var PROVIDERS_CSS = `
@@ -15561,24 +15915,24 @@ var PROVIDERS_CSS = `
`;
// src/client/settings.js
-var import_react39 = require("react");
+var import_react43 = require("react");
var capitalize2 = (word) => word[0].toUpperCase() + word.slice(1);
var SETTINGS_PAGES = [["general", "General"], ["models", "Models"], ["bots", "Bots"], ["groups", "Group chats"], ["connectors", "Connectors"], ["capabilities", "Capabilities"], ["browser", "Browser"], ["schedules", "Scheduled tasks"], ["usage", "Usage"], ["secrets", "Secrets"], ["feedback", "Feedback"], ["about", "About DS Bot"]];
var PAGE_ICONS = { ...SETTINGS_ICONS, models: SlidersIcon, connectors: ConnectorIcon, capabilities: PlugIcon, browser: ConnectorIcon, schedules: ClockIcon, secrets: KeyIcon, feedback: FeedbackIcon, about: InfoIcon };
function SetSection({ title, className = "", children }) {
- return (0, import_react39.createElement)("section", { className: `bt-set-section ${className}`.trim() }, (0, import_react39.createElement)("h3", null, title), (0, import_react39.createElement)("div", { className: "bt-set-card" }, children));
+ return (0, import_react43.createElement)("section", { className: `bt-set-section ${className}`.trim() }, (0, import_react43.createElement)("h3", null, title), (0, import_react43.createElement)("div", { className: "bt-set-card" }, children));
}
function SetRow({ label, hint, children, className = "" }) {
- return (0, import_react39.createElement)(
+ return (0, import_react43.createElement)(
"div",
{ className: `bt-set-row ${className}`.trim() },
- (0, import_react39.createElement)("div", { className: "bt-set-copy" }, (0, import_react39.createElement)("span", null, label), hint ? (0, import_react39.createElement)("span", { className: "bt-set-hint" }, hint) : null),
- children ? (0, import_react39.createElement)("div", { className: "bt-set-control" }, children) : null
+ (0, import_react43.createElement)("div", { className: "bt-set-copy" }, (0, import_react43.createElement)("span", null, label), hint ? (0, import_react43.createElement)("span", { className: "bt-set-hint" }, hint) : null),
+ children ? (0, import_react43.createElement)("div", { className: "bt-set-control" }, children) : null
);
}
var LAYOUTS = [["bubble", "Bubble"], ["flat", "Flat"]];
function Choice({ label, value, options, pick: pick2 }) {
- return (0, import_react39.createElement)(Segmented, { label, value, className: "bt-look-seg" }, options.map(([id, text]) => (0, import_react39.createElement)("button", {
+ return (0, import_react43.createElement)(Segmented, { label, value, className: "bt-look-seg" }, options.map(([id, text]) => (0, import_react43.createElement)("button", {
key: id,
type: "button",
"aria-pressed": value === id,
@@ -15588,12 +15942,12 @@ function Choice({ label, value, options, pick: pick2 }) {
}, t(text))));
}
function WidthSlider({ label, value, save }) {
- const [width, setWidth] = (0, import_react39.useState)(value);
- const pending = (0, import_react39.useRef)(null);
- const timer = (0, import_react39.useRef)(0);
- const saveRef = (0, import_react39.useRef)(save);
+ const [width, setWidth] = (0, import_react43.useState)(value);
+ const pending = (0, import_react43.useRef)(null);
+ const timer = (0, import_react43.useRef)(0);
+ const saveRef = (0, import_react43.useRef)(save);
saveRef.current = save;
- (0, import_react39.useEffect)(() => {
+ (0, import_react43.useEffect)(() => {
if (pending.current === null) setWidth(value);
}, [value]);
const flush = () => {
@@ -15601,7 +15955,7 @@ function WidthSlider({ label, value, save }) {
pending.current = null;
if (next !== null) saveRef.current(next);
};
- (0, import_react39.useEffect)(() => () => {
+ (0, import_react43.useEffect)(() => () => {
clearTimeout(timer.current);
flush();
}, []);
@@ -15612,46 +15966,46 @@ function WidthSlider({ label, value, save }) {
timer.current = setTimeout(flush, 350);
};
const { min, max, step } = MESSAGE_WIDTH;
- return (0, import_react39.createElement)(
+ return (0, import_react43.createElement)(
"div",
{ className: "bt-range", style: { "--bt-fill": `${(width - min) / (max - min) * 100}%` } },
- (0, import_react39.createElement)("input", { type: "range", min, max, step, value: width, "aria-label": label, "aria-valuetext": `${width}%`, onChange: (event) => pick2(Number(event.target.value)) }),
- (0, import_react39.createElement)("output", null, `${width}%`)
+ (0, import_react43.createElement)("input", { type: "range", min, max, step, value: width, "aria-label": label, "aria-valuetext": `${width}%`, onChange: (event) => pick2(Number(event.target.value)) }),
+ (0, import_react43.createElement)("output", null, `${width}%`)
);
}
function GeneralPage({ roster, actions, run: run2 }) {
const prefs = roster.prefs ?? {};
const themes = allThemes();
const current = themes[prefs.theme] ? prefs.theme : "deepseek";
- const [custom, setCustom] = (0, import_react39.useState)(prefs.accent ?? "#4d6bfe");
- const timer = (0, import_react39.useRef)(0);
- (0, import_react39.useEffect)(() => () => clearTimeout(timer.current), []);
+ const [custom, setCustom] = (0, import_react43.useState)(prefs.accent ?? "#4d6bfe");
+ const timer = (0, import_react43.useRef)(0);
+ (0, import_react43.useEffect)(() => () => clearTimeout(timer.current), []);
const pickCustom = (value) => {
setCustom(value);
clearTimeout(timer.current);
timer.current = setTimeout(() => run2(actions.setPrefs({ accent: value })), 350);
};
return [
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
SetSection,
{ key: "look", title: t("Appearance") },
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
SetRow,
{ label: t("Theme"), hint: t("Colors for the whole team, on every device.") },
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
"select",
{ className: "bt-select", "aria-label": t("Theme"), value: current, onChange: (event) => run2(actions.setPrefs({ theme: event.target.value })) },
- Object.entries(themes).map(([id, theme]) => (0, import_react39.createElement)("option", { key: id, value: id }, t(theme.label)))
+ Object.entries(themes).map(([id, theme]) => (0, import_react43.createElement)("option", { key: id, value: id }, t(theme.label)))
)
),
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
SetRow,
{ label: t("Accent"), hint: t("Unread marks, badges, and the brand mark.") },
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
"div",
{ className: "bt-swatches" },
- (0, import_react39.createElement)("button", { type: "button", className: "bt-swatch bt-swatch-default", title: t("Theme accent"), "aria-label": t("Theme accent"), "aria-pressed": !prefs.accent, onClick: () => run2(actions.setPrefs({ accent: null })) }),
- ACCENT_INKS.map((ink) => (0, import_react39.createElement)("button", {
+ (0, import_react43.createElement)("button", { type: "button", className: "bt-swatch bt-swatch-default", title: t("Theme accent"), "aria-label": t("Theme accent"), "aria-pressed": !prefs.accent, onClick: () => run2(actions.setPrefs({ accent: null })) }),
+ ACCENT_INKS.map((ink) => (0, import_react43.createElement)("button", {
key: ink,
type: "button",
className: "bt-swatch",
@@ -15661,38 +16015,38 @@ function GeneralPage({ roster, actions, run: run2 }) {
style: { background: INKS[ink][0] },
onClick: () => run2(actions.setPrefs({ accent: INKS[ink][0] }))
})),
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
"label",
{ className: "bt-swatch bt-swatch-custom", title: t("Custom accent"), "data-on": Boolean(prefs.accent) && !ACCENT_INKS.some((ink) => INKS[ink][0] === prefs.accent) },
- (0, import_react39.createElement)("input", { type: "color", value: custom, "aria-label": t("Custom accent"), onChange: (event) => pickCustom(event.target.value) })
+ (0, import_react43.createElement)("input", { type: "color", value: custom, "aria-label": t("Custom accent"), onChange: (event) => pickCustom(event.target.value) })
)
)
),
- (0, import_react39.createElement)(SetRow, { label: t("Message layout") }, (0, import_react39.createElement)(Choice, { label: t("Message layout"), value: layoutOf(prefs), options: LAYOUTS, pick: (id) => run2(actions.setPrefs({ layout: id })) })),
+ (0, import_react43.createElement)(SetRow, { label: t("Message layout") }, (0, import_react43.createElement)(Choice, { label: t("Message layout"), value: layoutOf(prefs), options: LAYOUTS, pick: (id) => run2(actions.setPrefs({ layout: id })) })),
// The flat layout's text has a width of its own; the bubble width stays for the user's messages.
- layoutOf(prefs) === "flat" ? (0, import_react39.createElement)(SetRow, { label: t("Text width") }, (0, import_react39.createElement)(WidthSlider, { label: t("Text width"), value: flatWidthOf(prefs), save: (flatWidth) => run2(actions.setPrefs({ flatWidth })) })) : null,
- (0, import_react39.createElement)(SetRow, { label: t("Bubble width") }, (0, import_react39.createElement)(WidthSlider, { label: t("Bubble width"), value: widthOf(prefs), save: (width) => run2(actions.setPrefs({ width })) })),
- (0, import_react39.createElement)(SetRow, { label: t("Show thinking") }, (0, import_react39.createElement)(Switch, { label: t("Show thinking"), on: thinkingShown(prefs), onChange: (thinking) => run2(actions.setPrefs({ thinking })) }))
+ layoutOf(prefs) === "flat" ? (0, import_react43.createElement)(SetRow, { label: t("Text width") }, (0, import_react43.createElement)(WidthSlider, { label: t("Text width"), value: flatWidthOf(prefs), save: (flatWidth) => run2(actions.setPrefs({ flatWidth })) })) : null,
+ (0, import_react43.createElement)(SetRow, { label: t("Bubble width") }, (0, import_react43.createElement)(WidthSlider, { label: t("Bubble width"), value: widthOf(prefs), save: (width) => run2(actions.setPrefs({ width })) })),
+ (0, import_react43.createElement)(SetRow, { label: t("Show thinking") }, (0, import_react43.createElement)(Switch, { label: t("Show thinking"), on: thinkingShown(prefs), onChange: (thinking) => run2(actions.setPrefs({ thinking })) }))
),
- actions.setSurface ? (0, import_react39.createElement)(
+ actions.setSurface ? (0, import_react43.createElement)(
SetSection,
{ key: "mode", title: t("Mode") },
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
SetRow,
{ label: t("Classic Agent mode") },
- (0, import_react39.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.setSurface("agent") }, t("Switch"))
+ (0, import_react43.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => actions.setSurface("agent") }, t("Switch"))
)
) : null,
- (0, import_react39.createElement)(LocationsSection, { key: "places", actions, run: run2 })
+ (0, import_react43.createElement)(LocationsSection, { key: "places", actions, run: run2 })
];
}
function LocationsSection({ actions, run: run2 }) {
const app = globalThis.dsBotApp;
- const [team, setTeam] = (0, import_react39.useState)(null);
- const [data, setData] = (0, import_react39.useState)(null);
- const [moving, setMoving] = (0, import_react39.useState)(false);
- const busy = (0, import_react39.useRef)(false);
- (0, import_react39.useEffect)(() => {
+ const [team, setTeam] = (0, import_react43.useState)(null);
+ const [data, setData] = (0, import_react43.useState)(null);
+ const [moving, setMoving] = (0, import_react43.useState)(false);
+ const busy = (0, import_react43.useRef)(false);
+ (0, import_react43.useEffect)(() => {
void Promise.resolve(actions.folders()).then((info) => setTeam(info?.team ?? null)).catch(() => {
});
if (app !== void 0) void Promise.resolve(app.dataLocation()).then(setData).catch(() => {
@@ -15710,18 +16064,18 @@ function LocationsSection({ actions, run: run2 }) {
setMoving(false);
}));
};
- return (0, import_react39.createElement)(
+ return (0, import_react43.createElement)(
SetSection,
{ title: t("Locations"), className: "bt-set-places" },
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
SetRow,
{ label: t("Team workspace"), hint: t("Where Bots without a folder of their own work.") },
- team === null ? null : (0, import_react39.createElement)(FolderMenu, { value: team, team: true, actions, run: run2, onPick: pickTeam, disabled: moving })
+ team === null ? null : (0, import_react43.createElement)(FolderMenu, { value: team, team: true, actions, run: run2, onPick: pickTeam, disabled: moving })
),
- data === null ? null : (0, import_react39.createElement)(
+ data === null ? null : (0, import_react43.createElement)(
SetRow,
{ label: t("Data location"), hint: data.path },
- data.fixed ? null : (0, import_react39.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: moving, onClick: () => {
+ data.fixed ? null : (0, import_react43.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: moving, onClick: () => {
if (!busy.current) void run2(app.moveData(team ?? void 0));
} }, t("Change…"))
)
@@ -15731,52 +16085,52 @@ function MainBotsSection({ roster, actions, run: run2 }) {
const mains = (roster.mainBotIds ?? []).map((id) => roster.byId[id]).filter(Boolean);
const [first, ...others] = mains;
const candidates = roster.bots.filter((bot) => !isMainOf(roster, bot.id));
- return (0, import_react39.createElement)(
+ return (0, import_react43.createElement)(
SetSection,
{ title: t("Main Bot") },
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
SetRow,
{
label: t("Main Bot"),
hint: first ? t("First in the sidebar. Pick another Bot to hand it the role; {name} then stops being a Main Bot.", { name: first.name }) : void 0
},
- (0, import_react39.createElement)("select", {
+ (0, import_react43.createElement)("select", {
className: "bt-select",
"aria-label": t("Main Bot"),
value: first?.id ?? "",
onChange: (event) => run2(actions.setMain(event.target.value, true, first ? { replace: first.id } : {}))
- }, first ? null : (0, import_react39.createElement)("option", { value: "" }, t("Choose a Bot…")), roster.bots.map((bot) => (0, import_react39.createElement)("option", { key: bot.id, value: bot.id }, bot.name)))
+ }, first ? null : (0, import_react43.createElement)("option", { value: "" }, t("Choose a Bot…")), roster.bots.map((bot) => (0, import_react43.createElement)("option", { key: bot.id, value: bot.id }, bot.name)))
),
- others.map((bot) => (0, import_react39.createElement)(
+ others.map((bot) => (0, import_react43.createElement)(
SetRow,
{ key: bot.id, label: bot.name, hint: t("Also a Main Bot.") },
- (0, import_react39.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.setMain(bot.id, true, { primary: true })) }, t("Move to first")),
- (0, import_react39.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.setMain(bot.id, false)) }, t("Remove Main Bot role"))
+ (0, import_react43.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.setMain(bot.id, true, { primary: true })) }, t("Move to first")),
+ (0, import_react43.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.setMain(bot.id, false)) }, t("Remove Main Bot role"))
)),
- candidates.length > 0 ? (0, import_react39.createElement)(
+ candidates.length > 0 ? (0, import_react43.createElement)(
SetRow,
{ label: t("Add a Main Bot"), hint: t("Main Bots can create and change Bots, and run every group chat.") },
- (0, import_react39.createElement)("select", {
+ (0, import_react43.createElement)("select", {
className: "bt-select",
"aria-label": t("Add a Main Bot"),
value: "",
onChange: (event) => {
if (event.target.value) void run2(actions.setMain(event.target.value, true));
}
- }, (0, import_react39.createElement)("option", { value: "" }, t("Choose a Bot…")), candidates.map((bot) => (0, import_react39.createElement)("option", { key: bot.id, value: bot.id }, bot.name)))
+ }, (0, import_react43.createElement)("option", { value: "" }, t("Choose a Bot…")), candidates.map((bot) => (0, import_react43.createElement)("option", { key: bot.id, value: bot.id }, bot.name)))
) : null
);
}
var MOTIONS = [["quiet", "Quiet"], ["normal", "Normal"], ["lively", "Lively"]];
function MotionSection({ roster, actions, run: run2 }) {
const motion = roster.prefs?.motion === "quiet" || roster.prefs?.motion === "lively" ? roster.prefs.motion : "normal";
- return (0, import_react39.createElement)(
+ return (0, import_react43.createElement)(
SetSection,
{ title: t("Animation") },
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
SetRow,
{ label: t("Bot animation") },
- (0, import_react39.createElement)(Segmented, { label: t("Bot animation"), value: motion, className: "bt-motion-seg" }, MOTIONS.map(([id, label]) => (0, import_react39.createElement)("button", {
+ (0, import_react43.createElement)(Segmented, { label: t("Bot animation"), value: motion, className: "bt-motion-seg" }, MOTIONS.map(([id, label]) => (0, import_react43.createElement)("button", {
key: id,
type: "button",
"aria-pressed": motion === id,
@@ -15788,69 +16142,69 @@ function MotionSection({ roster, actions, run: run2 }) {
);
}
function BotsPage({ roster, actions, run: run2 }) {
- const [creating, setCreating] = (0, import_react39.useState)(false);
+ const [creating, setCreating] = (0, import_react43.useState)(false);
return [
- (0, import_react39.createElement)(MainBotsSection, { key: "main", roster, actions, run: run2 }),
- (0, import_react39.createElement)(MotionSection, { key: "motion", roster, actions, run: run2 }),
- creating ? (0, import_react39.createElement)(CreateBot, { key: "create", roster, actions, inline: true, onBack: () => setCreating(false), onCreated: (bot) => actions.openSettings("bots", bot.id) }) : (0, import_react39.createElement)(
+ (0, import_react43.createElement)(MainBotsSection, { key: "main", roster, actions, run: run2 }),
+ (0, import_react43.createElement)(MotionSection, { key: "motion", roster, actions, run: run2 }),
+ creating ? (0, import_react43.createElement)(CreateBot, { key: "create", roster, actions, inline: true, onBack: () => setCreating(false), onCreated: (bot) => actions.openSettings("bots", bot.id) }) : (0, import_react43.createElement)(
"div",
{ key: "new", className: "bt-actions" },
- (0, import_react39.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-with-icon", onClick: () => setCreating(true) }, (0, import_react39.createElement)(PlusIcon), t("New Bot"))
+ (0, import_react43.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-with-icon", onClick: () => setCreating(true) }, (0, import_react43.createElement)(PlusIcon), t("New Bot"))
),
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
SetSection,
{ key: "bots", title: t("Bots · {count}", { count: roster.bots.length }) },
- roster.bots.map((bot) => (0, import_react39.createElement)(
+ roster.bots.map((bot) => (0, import_react43.createElement)(
"button",
{ key: bot.id, type: "button", className: "bt-set-row", onClick: () => actions.openSettings("bots", bot.id) },
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
"span",
{ className: "bt-set-bot" },
- (0, import_react39.createElement)(BotAvatar, { bot, size: 28, badge: false, live: false }),
- (0, import_react39.createElement)("span", { className: "bt-row-title" }, bot.name),
- bot.role ? (0, import_react39.createElement)("span", { className: "bt-tag" }, bot.role) : null,
- isMainOf(roster, bot.id) ? (0, import_react39.createElement)("span", { className: "bt-tag" }, t("Main Bot")) : null,
- bot.hidden && !isMainOf(roster, bot.id) ? (0, import_react39.createElement)("span", { className: "bt-tag" }, t("Hidden")) : null
+ (0, import_react43.createElement)(BotAvatar, { bot, size: 28, badge: false, live: false }),
+ (0, import_react43.createElement)("span", { className: "bt-row-title" }, bot.name),
+ bot.role ? (0, import_react43.createElement)("span", { className: "bt-tag" }, bot.role) : null,
+ isMainOf(roster, bot.id) ? (0, import_react43.createElement)("span", { className: "bt-tag" }, t("Main Bot")) : null,
+ bot.hidden && !isMainOf(roster, bot.id) ? (0, import_react43.createElement)("span", { className: "bt-tag" }, t("Hidden")) : null
),
- (0, import_react39.createElement)("span", { className: "bt-chevron" }, (0, import_react39.createElement)(ChevronRightIcon))
+ (0, import_react43.createElement)("span", { className: "bt-chevron" }, (0, import_react43.createElement)(ChevronRightIcon))
))
)
];
}
function GroupsPage({ roster, actions, run: run2 }) {
- const [creating, setCreating] = (0, import_react39.useState)(false);
+ const [creating, setCreating] = (0, import_react43.useState)(false);
return [
- creating ? (0, import_react39.createElement)(NewGroupForm, { key: "create", roster, actions, run: run2, onCancel: () => setCreating(false), onCreated: (room2) => actions.openSettings("groups", room2.id) }) : (0, import_react39.createElement)(
+ creating ? (0, import_react43.createElement)(NewGroupForm, { key: "create", roster, actions, run: run2, onCancel: () => setCreating(false), onCreated: (room2) => actions.openSettings("groups", room2.id) }) : (0, import_react43.createElement)(
"div",
{ key: "new", className: "bt-actions" },
- (0, import_react39.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-with-icon", disabled: roster.bots.length < 2, title: roster.bots.length < 2 ? t("A group chat needs at least two Bots") : void 0, onClick: () => setCreating(true) }, (0, import_react39.createElement)(PlusIcon), t("Create group chat"))
+ (0, import_react43.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm bt-with-icon", disabled: roster.bots.length < 2, title: roster.bots.length < 2 ? t("A group chat needs at least two Bots") : void 0, onClick: () => setCreating(true) }, (0, import_react43.createElement)(PlusIcon), t("Create group chat"))
),
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
SetSection,
{ key: "groups", title: t("Group chats · {count}", { count: roster.rooms.length }) },
- roster.rooms.length === 0 ? (0, import_react39.createElement)(SetRow, { label: t("No group chats yet."), hint: t("A group chat lets several Bots work on one thing with you.") }) : roster.rooms.map((room2) => {
+ roster.rooms.length === 0 ? (0, import_react43.createElement)(SetRow, { label: t("No group chats yet."), hint: t("A group chat lets several Bots work on one thing with you.") }) : roster.rooms.map((room2) => {
const admin = roster.byId[room2.admin];
- return (0, import_react39.createElement)(
+ return (0, import_react43.createElement)(
"button",
{ key: room2.id, type: "button", className: "bt-set-row", onClick: () => actions.openSettings("groups", room2.id) },
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
"span",
{ className: "bt-set-bot" },
- (0, import_react39.createElement)(RoomAvatar, { room: room2, roster, size: 28 }),
- (0, import_react39.createElement)("span", { className: "bt-row-title" }, room2.name),
- (0, import_react39.createElement)("span", { className: "bt-tag" }, t("{count} members", { count: room2.members.length })),
- admin ? (0, import_react39.createElement)("span", { className: "bt-tag bt-tag-admin" }, (0, import_react39.createElement)(AdminStar), admin.name) : null,
- room2.hidden ? (0, import_react39.createElement)("span", { className: "bt-tag" }, t("Hidden")) : null
+ (0, import_react43.createElement)(RoomAvatar, { room: room2, roster, size: 28 }),
+ (0, import_react43.createElement)("span", { className: "bt-row-title" }, room2.name),
+ (0, import_react43.createElement)("span", { className: "bt-tag" }, t("{count} members", { count: room2.members.length })),
+ admin ? (0, import_react43.createElement)("span", { className: "bt-tag bt-tag-admin" }, (0, import_react43.createElement)(AdminStar), admin.name) : null,
+ room2.hidden ? (0, import_react43.createElement)("span", { className: "bt-tag" }, t("Hidden")) : null
),
- (0, import_react39.createElement)("span", { className: "bt-chevron" }, (0, import_react39.createElement)(ChevronRightIcon))
+ (0, import_react43.createElement)("span", { className: "bt-chevron" }, (0, import_react43.createElement)(ChevronRightIcon))
);
})
)
];
}
function SettingsDialog({ page, id, roster, actions, useUpdate, leaving = false }) {
- const [error, setError] = (0, import_react39.useState)("");
- const close = (0, import_react39.useCallback)(() => actions.closeSettings(), []);
+ const [error, setError] = (0, import_react43.useState)("");
+ const close = (0, import_react43.useCallback)(() => actions.closeSettings(), []);
useEscape(close);
const run2 = (promise) => Promise.resolve(promise).then(() => {
setError("");
@@ -15869,32 +16223,32 @@ function SettingsDialog({ page, id, roster, actions, useUpdate, leaving = false
const nav = useGlide(shown, { axis: "y" });
const pageKey = `${shown}:${bot?.id ?? room2?.id ?? ""}`;
const depth = bot || room2 ? 1 : 0;
- const last = (0, import_react39.useRef)({ key: pageKey, depth, move: "up" });
+ const last = (0, import_react43.useRef)({ key: pageKey, depth, move: "up" });
if (last.current.key !== pageKey) {
last.current = { key: pageKey, depth, move: depth > last.current.depth ? "in" : depth < last.current.depth ? "out" : "up" };
}
- const [usageOpened, setUsageOpened] = (0, import_react39.useState)(shown === "usage");
+ const [usageOpened, setUsageOpened] = (0, import_react43.useState)(shown === "usage");
if (shown === "usage" && !usageOpened) setUsageOpened(true);
- const errorLine = error ? (0, import_react39.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : null;
- return (0, import_react39.createElement)(
+ const errorLine = error ? (0, import_react43.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : null;
+ return (0, import_react43.createElement)(
"div",
{ className: "bt-settings-layer", "data-leaving": leaving || void 0 },
- (0, import_react39.createElement)("div", { className: "bt-scrim", onMouseDown: close }),
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)("div", { className: "bt-scrim", onMouseDown: close }),
+ (0, import_react43.createElement)(
"div",
{ className: "bt-settings", role: "dialog", "aria-modal": true, "aria-label": t("DS Bot settings") },
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
"nav",
{ ref: nav.box, className: "bt-settings-nav", "aria-label": t("Settings pages") },
- (0, import_react39.createElement)("span", { ref: nav.thumb, className: "bt-thumb", "aria-hidden": true }),
- pages.map(([key, text]) => (0, import_react39.createElement)("button", {
+ (0, import_react43.createElement)("span", { ref: nav.thumb, className: "bt-thumb", "aria-hidden": true }),
+ pages.map(([key, text]) => (0, import_react43.createElement)("button", {
key,
type: "button",
className: "bt-settings-item",
"aria-current": shown === key ? "page" : void 0,
onClick: () => actions.openSettings(key)
- }, (0, import_react39.createElement)(PAGE_ICONS[key]), t(text))),
- actions.openHarnessSettings ? (0, import_react39.createElement)("button", {
+ }, (0, import_react43.createElement)(PAGE_ICONS[key]), t(text))),
+ actions.openHarnessSettings ? (0, import_react43.createElement)("button", {
type: "button",
className: "bt-settings-item bt-settings-shell",
title: t("Models, providers, and the rest of DeepSeek Harness"),
@@ -15902,67 +16256,67 @@ function SettingsDialog({ page, id, roster, actions, useUpdate, leaving = false
close();
actions.openHarnessSettings();
}
- }, (0, import_react39.createElement)(SlidersIcon), t("Harness settings")) : null
+ }, (0, import_react43.createElement)(SlidersIcon), t("Harness settings")) : null
),
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
"div",
{ className: "bt-settings-main" },
- (0, import_react39.createElement)(
+ (0, import_react43.createElement)(
"div",
{ className: "bt-settings-head" },
- back ? (0, import_react39.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": back, title: back, onClick: () => actions.openSettings(shown) }, (0, import_react39.createElement)(ChevronLeftIcon)) : null,
- (0, import_react39.createElement)("h2", { key: bot?.id ?? room2?.id ?? shown }, bot?.name ?? room2?.name ?? label)
+ back ? (0, import_react43.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": back, title: back, onClick: () => actions.openSettings(shown) }, (0, import_react43.createElement)(ChevronLeftIcon)) : null,
+ (0, import_react43.createElement)("h2", { key: bot?.id ?? room2?.id ?? shown }, bot?.name ?? room2?.name ?? label)
),
- shown === "usage" ? null : (0, import_react39.createElement)(
+ shown === "usage" ? null : (0, import_react43.createElement)(
"div",
{ key: pageKey, className: "bt-settings-scroll bt-settings-page", "data-move": last.current.move },
errorLine,
- shown === "general" ? (0, import_react39.createElement)(GeneralPage, { roster, actions, run: run2 }) : null,
- shown === "models" ? (0, import_react39.createElement)(ProvidersPage, { actions, run: run2, Section: SetSection }) : null,
- bot ? (0, import_react39.createElement)("div", { className: "bt-settings-form" }, (0, import_react39.createElement)(BotSettingsForm, { key: bot.id, bot, roster, actions, run: run2 })) : null,
- shown === "bots" && !bot ? (0, import_react39.createElement)(BotsPage, { roster, actions, run: run2 }) : null,
- room2 ? (0, import_react39.createElement)("div", { className: "bt-settings-form" }, (0, import_react39.createElement)(GroupSettingsForm, { key: room2.id, room: room2, roster, actions, run: run2 })) : null,
- shown === "groups" && !room2 ? (0, import_react39.createElement)(GroupsPage, { roster, actions, run: run2 }) : null,
- shown === "connectors" ? (0, import_react39.createElement)(ConnectorsPage, { roster, actions }) : null,
- shown === "capabilities" ? (0, import_react39.createElement)(CapabilitiesPage, { roster, actions, run: run2 }) : null,
- shown === "browser" ? (0, import_react39.createElement)(BrowserPage, { roster, actions, run: run2, Section: SetSection, Row: SetRow }) : null,
- shown === "schedules" ? (0, import_react39.createElement)(SchedulesPage, { roster, actions, start: id ?? void 0 }) : null,
- shown === "secrets" ? (0, import_react39.createElement)(SecretsPage, { roster, actions, run: run2, Section: SetSection }) : null,
- shown === "feedback" ? (0, import_react39.createElement)(FeedbackPage, { actions, run: run2, Section: SetSection, Row: SetRow }) : null,
- shown === "about" ? (0, import_react39.createElement)(AboutPage, { useUpdate, actions, run: run2, Section: SetSection, Row: SetRow }) : null
+ shown === "general" ? (0, import_react43.createElement)(GeneralPage, { roster, actions, run: run2 }) : null,
+ shown === "models" ? (0, import_react43.createElement)(ProvidersPage, { actions, run: run2, Section: SetSection }) : null,
+ bot ? (0, import_react43.createElement)("div", { className: "bt-settings-form" }, (0, import_react43.createElement)(BotSettingsForm, { key: bot.id, bot, roster, actions, run: run2 })) : null,
+ shown === "bots" && !bot ? (0, import_react43.createElement)(BotsPage, { roster, actions, run: run2 }) : null,
+ room2 ? (0, import_react43.createElement)("div", { className: "bt-settings-form" }, (0, import_react43.createElement)(GroupSettingsForm, { key: room2.id, room: room2, roster, actions, run: run2 })) : null,
+ shown === "groups" && !room2 ? (0, import_react43.createElement)(GroupsPage, { roster, actions, run: run2 }) : null,
+ shown === "connectors" ? (0, import_react43.createElement)(ConnectorsPage, { roster, actions }) : null,
+ shown === "capabilities" ? (0, import_react43.createElement)(CapabilitiesPage, { roster, actions, run: run2 }) : null,
+ shown === "browser" ? (0, import_react43.createElement)(BrowserPage, { roster, actions, run: run2, Section: SetSection, Row: SetRow }) : null,
+ shown === "schedules" ? (0, import_react43.createElement)(SchedulesPage, { roster, actions, start: id ?? void 0 }) : null,
+ shown === "secrets" ? (0, import_react43.createElement)(SecretsPage, { roster, actions, run: run2, Section: SetSection }) : null,
+ shown === "feedback" ? (0, import_react43.createElement)(FeedbackPage, { actions, run: run2, Section: SetSection, Row: SetRow }) : null,
+ shown === "about" ? (0, import_react43.createElement)(AboutPage, { useUpdate, actions, run: run2, Section: SetSection, Row: SetRow }) : null
),
- usageOpened ? (0, import_react39.createElement)(
+ usageOpened ? (0, import_react43.createElement)(
"div",
{ key: "usage", className: "bt-settings-scroll bt-settings-usage", "data-off": shown === "usage" ? void 0 : "", "aria-hidden": shown === "usage" ? void 0 : true },
shown === "usage" ? errorLine : null,
- (0, import_react39.createElement)(UsagePage, { roster, actions, focusId: usageFocus })
+ (0, import_react43.createElement)(UsagePage, { roster, actions, focusId: usageFocus })
) : null
),
- (0, import_react39.createElement)("button", { type: "button", className: "bt-settings-close", "aria-label": t("Close settings"), onClick: close }, (0, import_react39.createElement)(CloseIcon))
+ (0, import_react43.createElement)("button", { type: "button", className: "bt-settings-close", "aria-label": t("Close settings"), onClick: close }, (0, import_react43.createElement)(CloseIcon))
)
);
}
// src/client/context-menu.js
-var import_react40 = require("react");
+var import_react44 = require("react");
function ContextMenu({ menu, roster, actions, leaving = false }) {
useEscape(() => actions.closeMenu());
- (0, import_react40.useEffect)(() => {
+ (0, import_react44.useEffect)(() => {
const onDown = (event) => {
if (!(event.target instanceof Element) || !event.target.closest(".bt-menu")) actions.closeMenu();
};
window.addEventListener("mousedown", onDown);
return () => window.removeEventListener("mousedown", onDown);
}, []);
- const ref = (0, import_react40.useRef)(null);
- const [place, setPlace] = (0, import_react40.useState)({ left: menu.x, top: menu.y });
+ const ref = (0, import_react44.useRef)(null);
+ const [place, setPlace] = (0, import_react44.useState)({ left: menu.x, top: menu.y });
const tick = useViewport();
- (0, import_react40.useLayoutEffect)(() => {
+ (0, import_react44.useLayoutEffect)(() => {
const box = ref.current?.getBoundingClientRect();
if (!box) return;
setPlace({ left: Math.max(8, Math.min(menu.x, window.innerWidth - box.width - 8)), top: Math.max(8, Math.min(menu.y, viewBottom() - box.height - 8)) });
}, [menu.x, menu.y, tick]);
- if (menu.kind === "agent" || menu.kind === "agent-session") return (0, import_react40.createElement)(AgentMenu, { menu, roster, actions, leaving });
+ if (menu.kind === "agent" || menu.kind === "agent-session") return (0, import_react44.createElement)(AgentMenu, { menu, roster, actions, leaving });
const bot = roster.byId[menu.id];
const room2 = roster.roomsById[menu.id];
const entry = bot ?? room2;
@@ -15993,14 +16347,14 @@ function ContextMenu({ menu, roster, actions, leaving = false }) {
isMainBot ? null : [room2 ? t("Delete group") : t("Delete"), TrashIcon, () => bot ? actions.deleteBot(bot.id) : actions.deleteRoom(menu.id), true]
]
].map((group) => group.filter(Boolean)).filter((group) => group.length > 0);
- return (0, import_react40.createElement)(
+ return (0, import_react44.createElement)(
"div",
{ ref, className: "bt-menu", role: "menu", "aria-label": t("{name} actions", { name: bot?.name ?? room2.name }), style: place, "data-leaving": leaving || void 0 },
- groups.map((group, index) => (0, import_react40.createElement)(
- import_react40.Fragment,
+ groups.map((group, index) => (0, import_react44.createElement)(
+ import_react44.Fragment,
{ key: index },
- index > 0 ? (0, import_react40.createElement)("div", { className: "bt-menu-sep", role: "separator" }) : null,
- group.map(([label, Icon, run2, danger]) => (0, import_react40.createElement)("button", {
+ index > 0 ? (0, import_react44.createElement)("div", { className: "bt-menu-sep", role: "separator" }) : null,
+ group.map(([label, Icon, run2, danger]) => (0, import_react44.createElement)("button", {
key: label,
type: "button",
role: "menuitem",
@@ -16009,15 +16363,15 @@ function ContextMenu({ menu, roster, actions, leaving = false }) {
actions.closeMenu();
void Promise.resolve(run2()).catch((error) => actions.reportError(error, "menu"));
}
- }, (0, import_react40.createElement)(Icon), label))
+ }, (0, import_react44.createElement)(Icon), label))
))
);
}
function AgentMenu({ menu, roster, actions, leaving }) {
- const ref = (0, import_react40.useRef)(null);
- const [place, setPlace] = (0, import_react40.useState)({ left: menu.x, top: menu.y });
+ const ref = (0, import_react44.useRef)(null);
+ const [place, setPlace] = (0, import_react44.useState)({ left: menu.x, top: menu.y });
const tick = useViewport();
- (0, import_react40.useLayoutEffect)(() => {
+ (0, import_react44.useLayoutEffect)(() => {
const box = ref.current?.getBoundingClientRect();
if (!box) return;
setPlace({ left: Math.max(8, Math.min(menu.x, window.innerWidth - box.width - 8)), top: Math.max(8, Math.min(menu.y, viewBottom() - box.height - 8)) });
@@ -16039,14 +16393,14 @@ function AgentMenu({ menu, roster, actions, leaving }) {
[t("Archive"), TrashIcon, () => actions.archiveAgentSession(agent.id, menu.id), true]
]
];
- return (0, import_react40.createElement)(
+ return (0, import_react44.createElement)(
"div",
{ ref, className: "bt-menu", role: "menu", "aria-label": menu.kind === "agent" ? "DSH Agent" : t("Session actions"), style: place, "data-leaving": leaving || void 0 },
- groups.map((group, index) => (0, import_react40.createElement)(
- import_react40.Fragment,
+ groups.map((group, index) => (0, import_react44.createElement)(
+ import_react44.Fragment,
{ key: index },
- index > 0 ? (0, import_react40.createElement)("div", { className: "bt-menu-sep", role: "separator" }) : null,
- group.map(([label, Icon, run2, danger]) => (0, import_react40.createElement)("button", {
+ index > 0 ? (0, import_react44.createElement)("div", { className: "bt-menu-sep", role: "separator" }) : null,
+ group.map(([label, Icon, run2, danger]) => (0, import_react44.createElement)("button", {
key: label,
type: "button",
role: "menuitem",
@@ -16055,13 +16409,13 @@ function AgentMenu({ menu, roster, actions, leaving }) {
actions.closeMenu();
void Promise.resolve(run2()).catch((error) => console.warn("[ds-bot]", error));
}
- }, (0, import_react40.createElement)(Icon), label))
+ }, (0, import_react44.createElement)(Icon), label))
))
);
}
// src/client/member-status.js
-var import_react41 = require("react");
+var import_react45 = require("react");
var NO_WORK = { bots: {}, rooms: {}, approvals: [] };
var FACES_MAX = 3;
var DOCK_EXIT_MS = 160;
@@ -16122,15 +16476,15 @@ function dockModel(sessionId, roster, work) {
};
}
function Face({ bot, ask, state }) {
- return (0, import_react41.createElement)(
+ return (0, import_react45.createElement)(
"span",
{ className: "bt-mw-face", "data-ask": ask || void 0 },
- (0, import_react41.createElement)(BotMark, { bot, size: 20, state: ask ? "alert" : state })
+ (0, import_react45.createElement)(BotMark, { bot, size: 20, state: ask ? "alert" : state })
);
}
function useFitWidth(inner, key) {
- const [width, setWidth] = (0, import_react41.useState)(null);
- (0, import_react41.useLayoutEffect)(() => {
+ const [width, setWidth] = (0, import_react45.useState)(null);
+ (0, import_react45.useLayoutEffect)(() => {
setWidth(key && inner.current ? inner.current.offsetWidth : null);
}, [key]);
return width;
@@ -16141,61 +16495,61 @@ function MemberDock({ sessionId, useRoster, useWork, actions }) {
const live = dockModel(sessionId, roster, work);
const [kept, leaving] = useLinger(live ? JSON.stringify(live) : null, DOCK_EXIT_MS);
const model = kept ? JSON.parse(kept) : null;
- const inner = (0, import_react41.useRef)(null);
+ const inner = (0, import_react45.useRef)(null);
const width = useFitWidth(inner, kept);
if (!model) return null;
const faces = model.faces.map((face) => ({ ...face, bot: roster.byId[face.id] })).filter((face) => face.bot);
const label = [model.waiting, model.doing].filter(Boolean).join(" · ");
const open = () => model.open.details ? actions.showDetails(model.open.details) : actions.openSession(model.open.session);
- return (0, import_react41.createElement)(
+ return (0, import_react45.createElement)(
"div",
{ className: "bt-mw-dock", "data-leaving": leaving || void 0 },
- (0, import_react41.createElement)(
+ (0, import_react45.createElement)(
"button",
{ type: "button", className: "bt-mw-pill", "aria-label": label, onClick: open, disabled: leaving, style: width ? { width } : void 0 },
- (0, import_react41.createElement)(
+ (0, import_react45.createElement)(
"span",
{ ref: inner, className: "bt-mw-pill-in" },
- (0, import_react41.createElement)("span", { className: "bt-mw-faces", "aria-hidden": true }, faces.map((face) => (0, import_react41.createElement)(Face, { key: face.id, ...face }))),
- (0, import_react41.createElement)(
+ (0, import_react45.createElement)("span", { className: "bt-mw-faces", "aria-hidden": true }, faces.map((face) => (0, import_react45.createElement)(Face, { key: face.id, ...face }))),
+ (0, import_react45.createElement)(
"span",
{ key: label, className: "bt-mw-label", "aria-hidden": true },
- model.waiting ? (0, import_react41.createElement)("span", { className: "bt-mw-ask" }, model.waiting) : null,
- model.waiting && model.doing ? (0, import_react41.createElement)("span", { className: "bt-mw-dot" }, "·") : null,
- model.doing ? (0, import_react41.createElement)("span", { className: "bt-mw-doing" }, (0, import_react41.createElement)(Shimmer, null, model.doing)) : null
+ model.waiting ? (0, import_react45.createElement)("span", { className: "bt-mw-ask" }, model.waiting) : null,
+ model.waiting && model.doing ? (0, import_react45.createElement)("span", { className: "bt-mw-dot" }, "·") : null,
+ model.doing ? (0, import_react45.createElement)("span", { className: "bt-mw-doing" }, (0, import_react45.createElement)(Shimmer, null, model.doing)) : null
)
)
)
);
}
-var stateLine = (className, at, ...what) => (0, import_react41.createElement)(
+var stateLine = (className, at, ...what) => (0, import_react45.createElement)(
"span",
{ className },
- (0, import_react41.createElement)("span", { className: "bt-member-what" }, ...what),
- typeof at === "number" ? (0, import_react41.createElement)(Elapsed, { at, className: "bt-member-time" }) : null
+ (0, import_react45.createElement)("span", { className: "bt-member-what" }, ...what),
+ typeof at === "number" ? (0, import_react45.createElement)(Elapsed, { at, className: "bt-member-time" }) : null
);
function ApprovalCard({ approval, bot, actions }) {
- const [busy, setBusy] = (0, import_react41.useState)(false);
+ const [busy, setBusy] = (0, import_react45.useState)(false);
const answer = (choice) => {
setBusy(true);
void Promise.resolve(actions.answerApproval(approval.id, choice)).catch((error) => actions.reportError(error, "approval")).finally(() => setBusy(false));
};
- return (0, import_react41.createElement)(
+ return (0, import_react45.createElement)(
"div",
{ className: "bt-mw-card", role: "group", "aria-label": t("{name} is waiting for your approval", { name: bot.name }) },
- (0, import_react41.createElement)("div", { className: "bt-mw-tool" }, approval.tool),
- approval.detail?.text ? (0, import_react41.createElement)("div", { className: "bt-mw-text" }, approval.detail.text) : null,
- approval.reason ? (0, import_react41.createElement)("div", { className: "bt-mw-reason" }, approval.reason) : null,
- approval.detail?.code ? (0, import_react41.createElement)("code", { className: "bt-mw-code", title: approval.detail.code }, approval.detail.code) : null,
- approval.answerable ? (0, import_react41.createElement)(
+ (0, import_react45.createElement)("div", { className: "bt-mw-tool" }, approval.tool),
+ approval.detail?.text ? (0, import_react45.createElement)("div", { className: "bt-mw-text" }, approval.detail.text) : null,
+ approval.reason ? (0, import_react45.createElement)("div", { className: "bt-mw-reason" }, approval.reason) : null,
+ approval.detail?.code ? (0, import_react45.createElement)("code", { className: "bt-mw-code", title: approval.detail.code }, approval.detail.code) : null,
+ approval.answerable ? (0, import_react45.createElement)(
"div",
{ className: "bt-mw-actions" },
- (0, import_react41.createElement)("button", { type: "button", className: "bt-q-btn", disabled: busy, onClick: () => answer("reject") }, t("Reject")),
- (0, import_react41.createElement)("button", { type: "button", className: "bt-q-submit", disabled: busy, onClick: () => answer("allow") }, t("Allow once"))
- ) : (0, import_react41.createElement)(
+ (0, import_react45.createElement)("button", { type: "button", className: "bt-q-btn", disabled: busy, onClick: () => answer("reject") }, t("Reject")),
+ (0, import_react45.createElement)("button", { type: "button", className: "bt-q-submit", disabled: busy, onClick: () => answer("allow") }, t("Allow once"))
+ ) : (0, import_react45.createElement)(
"div",
{ className: "bt-mw-actions" },
- (0, import_react41.createElement)("button", { type: "button", className: "bt-q-btn", onClick: () => actions.openSession(bot.id) }, t("Open {name}'s chat", { name: bot.name }))
+ (0, import_react45.createElement)("button", { type: "button", className: "bt-q-btn", onClick: () => actions.openSession(bot.id) }, t("Open {name}'s chat", { name: bot.name }))
)
);
}
@@ -16203,20 +16557,20 @@ function MemberState({ entry, bot, room: room2, roster }) {
if (entry?.state === "ask") return stateLine("bt-member-state bt-mw-ask", entry.approvals[0].at, t("Waiting for your approval"));
if (entry?.state !== "work") return bot.role ? stateLine("bt-member-state", void 0, bot.role) : null;
const where = entry.doing.roomId === room2.id ? "" : entry.doing.roomId ? t("in {name}", { name: roster.roomsById[entry.doing.roomId]?.name ?? t("a group chat") }) : t("in its own chat");
- return stateLine("bt-member-state", entry.doing.since, (0, import_react41.createElement)(Shimmer, null, `${workPhrase(entry.doing)}…`), where ? ` ${where}` : "");
+ return stateLine("bt-member-state", entry.doing.since, (0, import_react45.createElement)(Shimmer, null, `${workPhrase(entry.doing)}…`), where ? ` ${where}` : "");
}
function StopMemberWork({ entry, bot, room: room2, actions }) {
- const [stopping, setStopping] = (0, import_react41.useState)(false);
+ const [stopping, setStopping] = (0, import_react45.useState)(false);
if (!entry?.here || entry.state !== "work" && entry.state !== "ask") return null;
const stop = () => {
setStopping(true);
void Promise.resolve(actions.stopMemberWork(room2.id, bot.id)).catch((error) => actions.reportError(error, "stop")).finally(() => setStopping(false));
};
- return (0, import_react41.createElement)("button", { type: "button", className: "bt-member-stop", disabled: stopping, "aria-label": `${t("Stop")} · ${bot.name}`, onClick: stop }, t("Stop"));
+ return (0, import_react45.createElement)("button", { type: "button", className: "bt-member-stop", disabled: stopping, "aria-label": `${t("Stop")} · ${bot.name}`, onClick: stop }, t("Stop"));
}
function MemberApprovals({ entry, bot, actions }) {
if (entry?.state !== "ask") return null;
- return (0, import_react41.createElement)("div", { className: "bt-member-cards" }, entry.approvals.map((approval) => (0, import_react41.createElement)(ApprovalCard, { key: approval.id, approval, bot, actions })));
+ return (0, import_react45.createElement)("div", { className: "bt-member-cards" }, entry.approvals.map((approval) => (0, import_react45.createElement)(ApprovalCard, { key: approval.id, approval, bot, actions })));
}
function useMemberWork(room2, useWork) {
const work = useWork?.((value) => value) ?? NO_WORK;
@@ -16275,7 +16629,7 @@ body[data-ds-dark-theme] .bt-member-state.bt-mw-ask{color:#f0b84a}
`;
// src/client/details-drawer.js
-var import_react42 = require("react");
+var import_react46 = require("react");
function transcriptOf(list, id, name, hiddenTurns = []) {
const outline = list.projectionsBySession?.[id]?.values?.turnOutline ?? list.byId[id]?.projectionValues?.turnOutline;
if (!Array.isArray(outline)) return "";
@@ -16300,17 +16654,17 @@ var EMPTY_TABS = { ids: [], active: null };
function PermissionRow({ bot, roster, actions, run: run2 }) {
const catalog = roster.permissions;
if (!catalog?.options?.length) return null;
- return (0, import_react42.createElement)(
+ return (0, import_react46.createElement)(
"div",
{ className: "bt-drawer-permission" },
- (0, import_react42.createElement)("div", { className: "bt-section-title" }, t("Permissions")),
+ (0, import_react46.createElement)("div", { className: "bt-section-title" }, t("Permissions")),
// A Bot without its own preset may run on another one set in DSH, so its first pick always applies.
- (0, import_react42.createElement)(PermissionPicker, { catalog, saved: bot.permission ?? catalog.defaultPreset, repick: bot.permission === void 0, onPick: (permission) => run2(actions.updateBot(bot.id, { permission })) })
+ (0, import_react46.createElement)(PermissionPicker, { catalog, saved: bot.permission ?? catalog.defaultPreset, repick: bot.permission === void 0, onPick: (permission) => run2(actions.updateBot(bot.id, { permission })) })
);
}
function RunStats({ bot, part, running, actions }) {
- const [values, setValues] = (0, import_react42.useState)(null);
- (0, import_react42.useEffect)(() => {
+ const [values, setValues] = (0, import_react46.useState)(null);
+ (0, import_react46.useEffect)(() => {
if (!actions.runStats) return void 0;
let current = true;
actions.runStats(bot.id).then(
@@ -16327,56 +16681,56 @@ function RunStats({ bot, part, running, actions }) {
}, [bot.id, part, running]);
const shown = runStatsOf(values);
if (shown.length === 0) return null;
- return (0, import_react42.createElement)(
+ return (0, import_react46.createElement)(
"div",
{ className: "bt-run-stats" },
- shown.map((entry, index) => (0, import_react42.createElement)(
- import_react42.Fragment,
+ shown.map((entry, index) => (0, import_react46.createElement)(
+ import_react46.Fragment,
{ key: entry.key },
- index > 0 ? (0, import_react42.createElement)("span", { className: "bt-run-sep", "aria-hidden": true }, "·") : null,
- (0, import_react42.createElement)("span", { title: entry.title }, entry.text)
+ index > 0 ? (0, import_react46.createElement)("span", { className: "bt-run-sep", "aria-hidden": true }, "·") : null,
+ (0, import_react46.createElement)("span", { title: entry.title }, entry.text)
))
);
}
function BrowserCards({ bot, sessionId, roster, actions, useBrowserTabs, useBrowserPages }) {
const state = useBrowserTabs((map) => map[bot.id] ?? EMPTY_TABS);
const pages = useBrowserPages((map) => map);
- (0, import_react42.useEffect)(() => {
+ (0, import_react46.useEffect)(() => {
actions.browserEnsure?.(bot.id);
}, [bot.id]);
if (roster.browser !== true || !actions.browserShow) {
- return (0, import_react42.createElement)("div", { className: "bt-muted" }, t("The browser is in DSH Desktop and the DeepSeek Bot app."));
+ return (0, import_react46.createElement)("div", { className: "bt-muted" }, t("The browser is in DSH Desktop and the DeepSeek Bot app."));
}
if (state.ids.length === 0) {
- return (0, import_react42.createElement)(
+ return (0, import_react46.createElement)(
"div",
{ className: "bt-browser-empty-mark" },
- (0, import_react42.createElement)(BotMark, { bot, size: 40, state: "idle", live: true }),
- (0, import_react42.createElement)("div", { className: "bt-browser-empty-title" }, t("{name}'s browser", { name: bot.name })),
- (0, import_react42.createElement)("div", { className: "bt-muted" }, t("Open a page here and {name} can read it with you. Logins and cookies stay with {name}; other Bots never see them.", { name: bot.name })),
- (0, import_react42.createElement)("button", { type: "button", className: "bt-browser-retry", onClick: () => actions.openBrowser(sessionId) }, t("Open browser"))
+ (0, import_react46.createElement)(BotMark, { bot, size: 40, state: "idle", live: true }),
+ (0, import_react46.createElement)("div", { className: "bt-browser-empty-title" }, t("{name}'s browser", { name: bot.name })),
+ (0, import_react46.createElement)("div", { className: "bt-muted" }, t("Open a page here and {name} can read it with you. Logins and cookies stay with {name}; other Bots never see them.", { name: bot.name })),
+ (0, import_react46.createElement)("button", { type: "button", className: "bt-browser-retry", onClick: () => actions.openBrowser(sessionId) }, t("Open browser"))
);
}
- return (0, import_react42.createElement)(
+ return (0, import_react46.createElement)(
"div",
{ className: "bt-bcards" },
state.ids.map((tabId, index) => {
const page = pages[tabId] ?? {};
const label = page.title || shortUrl(page.url) || t("New tab");
- return (0, import_react42.createElement)(
+ return (0, import_react46.createElement)(
"div",
{ key: tabId, className: "bt-bcard", "data-active": state.active === tabId || void 0, style: { animationDelay: `${index * 30}ms` } },
- (0, import_react42.createElement)(
+ (0, import_react46.createElement)(
"button",
{ type: "button", className: "bt-bcard-shot", "aria-label": t("Open {title}", { title: label }), title: page.url, onClick: () => actions.browserPick(sessionId, tabId) },
- page.excerpt ? (0, import_react42.createElement)(
+ page.excerpt ? (0, import_react46.createElement)(
"span",
{ className: "bt-bcard-preview" },
- (0, import_react42.createElement)("span", { className: "bt-bcard-ptitle" }, label),
- (0, import_react42.createElement)("span", { className: "bt-bcard-excerpt" }, page.excerpt)
- ) : (0, import_react42.createElement)("span", { className: "bt-bcard-blank" }, (0, import_react42.createElement)(GlobeIcon2), (0, import_react42.createElement)("span", null, label))
+ (0, import_react46.createElement)("span", { className: "bt-bcard-ptitle" }, label),
+ (0, import_react46.createElement)("span", { className: "bt-bcard-excerpt" }, page.excerpt)
+ ) : (0, import_react46.createElement)("span", { className: "bt-bcard-blank" }, (0, import_react46.createElement)(GlobeIcon2), (0, import_react46.createElement)("span", null, label))
),
- (0, import_react42.createElement)("button", {
+ (0, import_react46.createElement)("button", {
type: "button",
className: "bt-bcard-x",
"aria-label": t("Close tab"),
@@ -16385,29 +16739,29 @@ function BrowserCards({ bot, sessionId, roster, actions, useBrowserTabs, useBrow
void actions.browserCloseTab(bot.id, tabId);
}
}, "×"),
- (0, import_react42.createElement)(
+ (0, import_react46.createElement)(
"div",
{ className: "bt-bcard-row" },
- (0, import_react42.createElement)(Favicon, { src: page.favicon, className: "bt-bcard-fav" }),
- (0, import_react42.createElement)("span", { className: "bt-bcard-title" }, label),
- page.url ? (0, import_react42.createElement)("span", { className: "bt-bcard-host" }, hostOf2(page.url)) : null
+ (0, import_react46.createElement)(Favicon, { src: page.favicon, className: "bt-bcard-fav" }),
+ (0, import_react46.createElement)("span", { className: "bt-bcard-title" }, label),
+ page.url ? (0, import_react46.createElement)("span", { className: "bt-bcard-host" }, hostOf2(page.url)) : null
)
);
}),
- (0, import_react42.createElement)("button", { type: "button", className: "bt-bcard-new", style: { animationDelay: `${state.ids.length * 30}ms` }, onClick: () => actions.browserNewTab(sessionId) }, (0, import_react42.createElement)(PlusIcon), t("New tab"))
+ (0, import_react46.createElement)("button", { type: "button", className: "bt-bcard-new", style: { animationDelay: `${state.ids.length * 30}ms` }, onClick: () => actions.browserNewTab(sessionId) }, (0, import_react46.createElement)(PlusIcon), t("New tab"))
);
}
function About({ text, title = "About" }) {
- const [open, setOpen] = (0, import_react42.useState)(false);
+ const [open, setOpen] = (0, import_react46.useState)(false);
const long = text.split("\n").length > 5 || text.length > 240;
- const body = (0, import_react42.useRef)(null);
+ const body = (0, import_react46.useRef)(null);
useMorph(body, open);
- return (0, import_react42.createElement)(
+ return (0, import_react46.createElement)(
"div",
null,
- (0, import_react42.createElement)("div", { className: "bt-section-title" }, t(title)),
- (0, import_react42.createElement)("div", { ref: body, className: "bt-about", "data-open": open || void 0 }, text),
- long ? (0, import_react42.createElement)("button", { type: "button", className: "bt-more", onClick: () => setOpen((value) => !value) }, open ? t("Show less") : t("Show more")) : null
+ (0, import_react46.createElement)("div", { className: "bt-section-title" }, t(title)),
+ (0, import_react46.createElement)("div", { ref: body, className: "bt-about", "data-open": open || void 0 }, text),
+ long ? (0, import_react46.createElement)("button", { type: "button", className: "bt-more", onClick: () => setOpen((value) => !value) }, open ? t("Show less") : t("Show more")) : null
);
}
var PILE_MAX = 4;
@@ -16415,52 +16769,52 @@ function MemberPile({ room: room2, roster }) {
const members = room2.members.map((id) => roster.byId[id]).filter(Boolean);
const shown = members.length > PILE_MAX ? members.slice(0, PILE_MAX - 1) : members;
const more = members.length - shown.length;
- return (0, import_react42.createElement)(
+ return (0, import_react46.createElement)(
"span",
{ className: "bt-pile", "aria-hidden": true },
- shown.map((bot, index) => (0, import_react42.createElement)("span", { key: bot.id, className: "bt-pile-face", style: { animationDelay: `${index * 40}ms` } }, (0, import_react42.createElement)(BotMark, { bot, size: 44, live: true }))),
- more > 0 ? (0, import_react42.createElement)("span", { key: "more", className: "bt-pile-face bt-pile-more", style: { animationDelay: `${shown.length * 40}ms` } }, `+${more}`) : null
+ shown.map((bot, index) => (0, import_react46.createElement)("span", { key: bot.id, className: "bt-pile-face", style: { animationDelay: `${index * 40}ms` } }, (0, import_react46.createElement)(BotMark, { bot, size: 44, live: true }))),
+ more > 0 ? (0, import_react46.createElement)("span", { key: "more", className: "bt-pile-face bt-pile-more", style: { animationDelay: `${shown.length * 40}ms` } }, `+${more}`) : null
);
}
var markOf = (entry) => entry?.state === "ask" ? "alert" : entry?.state === "work" ? workState(entry.doing) : "idle";
function MemberRow({ member, entry, room: room2, roster, actions }) {
- return (0, import_react42.createElement)(
+ return (0, import_react46.createElement)(
"div",
{ role: "listitem", className: "bt-member" },
- (0, import_react42.createElement)(
+ (0, import_react46.createElement)(
"div",
{ className: "bt-member-row" },
- (0, import_react42.createElement)(
+ (0, import_react46.createElement)(
"button",
{ type: "button", className: "bt-member-open", title: t("Open {name}'s chat", { name: member.name }), onClick: () => actions.openSession(member.id) },
- (0, import_react42.createElement)(BotMark, { bot: member, size: 32, state: markOf(entry) }),
- (0, import_react42.createElement)(
+ (0, import_react46.createElement)(BotMark, { bot: member, size: 32, state: markOf(entry) }),
+ (0, import_react46.createElement)(
"span",
{ className: "bt-member-text" },
- (0, import_react42.createElement)(
+ (0, import_react46.createElement)(
"span",
{ className: "bt-member-line" },
- (0, import_react42.createElement)("span", { className: "bt-member-name" }, member.name),
- room2.admin === member.id ? (0, import_react42.createElement)("span", { className: "bt-tag" }, t("Admin")) : null
+ (0, import_react46.createElement)("span", { className: "bt-member-name" }, member.name),
+ room2.admin === member.id ? (0, import_react46.createElement)("span", { className: "bt-tag" }, t("Admin")) : null
),
- (0, import_react42.createElement)(MemberState, { entry, bot: member, room: room2, roster })
+ (0, import_react46.createElement)(MemberState, { entry, bot: member, room: room2, roster })
)
),
- (0, import_react42.createElement)(StopMemberWork, { entry, bot: member, room: room2, actions })
+ (0, import_react46.createElement)(StopMemberWork, { entry, bot: member, room: room2, actions })
),
- (0, import_react42.createElement)(MemberApprovals, { entry, bot: member, actions })
+ (0, import_react46.createElement)(MemberApprovals, { entry, bot: member, actions })
);
}
function GroupOverview({ room: room2, roster, actions, usage, useWork, openSettings }) {
const members = room2.members.map((id) => roster.byId[id]).filter(Boolean);
const { entries: entries2 } = useMemberWork(room2, useWork);
return [
- room2.notice ? (0, import_react42.createElement)(About, { key: "notice", title: "Notice", text: room2.notice }) : (0, import_react42.createElement)("button", { key: "notice", type: "button", className: "bt-more", onClick: openSettings }, t("Add a notice in group settings")),
- (0, import_react42.createElement)(
+ room2.notice ? (0, import_react46.createElement)(About, { key: "notice", title: "Notice", text: room2.notice }) : (0, import_react46.createElement)("button", { key: "notice", type: "button", className: "bt-more", onClick: openSettings }, t("Add a notice in group settings")),
+ (0, import_react46.createElement)(
"div",
{ key: "members" },
- (0, import_react42.createElement)("div", { className: "bt-section-title" }, t("Members · {count}", { count: members.length })),
- (0, import_react42.createElement)("div", { className: "bt-members", role: "list" }, members.map((member) => (0, import_react42.createElement)(MemberRow, {
+ (0, import_react46.createElement)("div", { className: "bt-section-title" }, t("Members · {count}", { count: members.length })),
+ (0, import_react46.createElement)("div", { className: "bt-members", role: "list" }, members.map((member) => (0, import_react46.createElement)(MemberRow, {
key: member.id,
member,
entry: entries2.find((item) => item.id === member.id),
@@ -16469,24 +16823,24 @@ function GroupOverview({ room: room2, roster, actions, usage, useWork, openSetti
actions
})))
),
- (0, import_react42.createElement)(
+ (0, import_react46.createElement)(
"div",
{ key: "mode" },
- (0, import_react42.createElement)("div", { className: "bt-section-title" }, t("Who answers")),
- (0, import_react42.createElement)("div", { className: "bt-kv" }, (0, import_react42.createElement)("span", null, t(ROOM_MODES.find(([id]) => id === shownMode(room2, roster))?.[1] ?? "Everyone")))
+ (0, import_react46.createElement)("div", { className: "bt-section-title" }, t("Who answers")),
+ (0, import_react46.createElement)("div", { className: "bt-kv" }, (0, import_react46.createElement)("span", null, t(ROOM_MODES.find(([id]) => id === shownMode(room2, roster))?.[1] ?? "Everyone")))
),
- room2.permission ? (0, import_react42.createElement)(
+ room2.permission ? (0, import_react46.createElement)(
"div",
{ key: "permission" },
- (0, import_react42.createElement)("div", { className: "bt-section-title" }, t("Permissions")),
- (0, import_react42.createElement)("div", { className: "bt-kv" }, (0, import_react42.createElement)("span", { className: presetDanger(room2.permission) ? "bt-perm-danger" : void 0 }, presetName(room2.permission, roster.permissions)))
+ (0, import_react46.createElement)("div", { className: "bt-section-title" }, t("Permissions")),
+ (0, import_react46.createElement)("div", { className: "bt-kv" }, (0, import_react46.createElement)("span", { className: presetDanger(room2.permission) ? "bt-perm-danger" : void 0 }, presetName(room2.permission, roster.permissions)))
) : null,
- roster.memory === false ? null : (0, import_react42.createElement)(MemoryRow, { key: "memory", owner: { id: room2.id, name: room2.name, group: true }, actions }),
- usage ? (0, import_react42.createElement)(
+ roster.memory === false ? null : (0, import_react46.createElement)(MemoryRow, { key: "memory", owner: { id: room2.id, name: room2.name, group: true }, actions }),
+ usage ? (0, import_react46.createElement)(
"div",
{ key: "usage" },
- (0, import_react42.createElement)("div", { className: "bt-section-title" }, t("Usage")),
- (0, import_react42.createElement)("div", { className: "bt-kv" }, (0, import_react42.createElement)("span", null, room2.name), (0, import_react42.createElement)("span", null, usage))
+ (0, import_react46.createElement)("div", { className: "bt-section-title" }, t("Usage")),
+ (0, import_react46.createElement)("div", { className: "bt-kv" }, (0, import_react46.createElement)("span", null, room2.name), (0, import_react46.createElement)("span", null, usage))
) : null
];
}
@@ -16494,15 +16848,15 @@ function DetailsDrawer({ sessionId, startRenaming, startTab, hasStrip, roster, a
const owner = roster.byId[sessionId];
const part = owner ? currentPart(owner) : sessionId;
const isMainBot = isMainOf(roster, owner?.id);
- const [tab, setTab] = (0, import_react42.useState)("details");
+ const [tab, setTab] = (0, import_react46.useState)("details");
const room2 = roster.roomsById[sessionId];
- const [view, setView] = (0, import_react42.useState)(startTab === "settings" && (owner || room2) ? "settings" : "overview");
- const [editing, setEditing] = (0, import_react42.useState)(Boolean(startRenaming && (roster.byId[sessionId] || roster.roomsById[sessionId])));
- const [draftName, setDraftName] = (0, import_react42.useState)(roster.byId[sessionId]?.name ?? (roster.roomsById[sessionId]?.named ? roster.roomsById[sessionId].name : ""));
- const [copied, setCopied] = (0, import_react42.useState)(false);
- const [error, setError] = (0, import_react42.useState)("");
+ const [view, setView] = (0, import_react46.useState)(startTab === "settings" && (owner || room2) ? "settings" : "overview");
+ const [editing, setEditing] = (0, import_react46.useState)(Boolean(startRenaming && (roster.byId[sessionId] || roster.roomsById[sessionId])));
+ const [draftName, setDraftName] = (0, import_react46.useState)(roster.byId[sessionId]?.name ?? (roster.roomsById[sessionId]?.named ? roster.roomsById[sessionId].name : ""));
+ const [copied, setCopied] = (0, import_react46.useState)(false);
+ const [error, setError] = (0, import_react46.useState)("");
const glide = useGlide(tab);
- const last = (0, import_react42.useRef)({ view, tab, move: void 0 });
+ const last = (0, import_react46.useRef)({ view, tab, move: void 0 });
if (last.current.view !== view) last.current = { view, tab, move: view === "settings" ? "in" : "out" };
else if (last.current.tab !== tab) last.current = { view, tab, move: "tab" };
const move = last.current.move;
@@ -16527,21 +16881,21 @@ function DetailsDrawer({ sessionId, startRenaming, startTab, hasStrip, roster, a
setTimeout(() => setCopied(false), 1600);
});
};
- const errorLine = error ? (0, import_react42.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : null;
+ const errorLine = error ? (0, import_react46.createElement)("div", { className: "bt-error", role: "alert", style: { padding: 0 } }, error) : null;
if ((bot || room2) && view === "settings") {
return [
- (0, import_react42.createElement)(
+ (0, import_react46.createElement)(
"div",
{ key: "head", className: "bt-subhead", "data-move": move },
- (0, import_react42.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Back to details"), onClick: () => setView("overview") }, (0, import_react42.createElement)(ChevronLeftIcon)),
- (0, import_react42.createElement)("span", { className: "bt-subhead-title" }, bot ? t("Settings") : t("Group settings")),
- hasStrip ? null : (0, import_react42.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Close details"), onClick: close }, (0, import_react42.createElement)(CloseIcon))
+ (0, import_react46.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Back to details"), onClick: () => setView("overview") }, (0, import_react46.createElement)(ChevronLeftIcon)),
+ (0, import_react46.createElement)("span", { className: "bt-subhead-title" }, bot ? t("Settings") : t("Group settings")),
+ hasStrip ? null : (0, import_react46.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Close details"), onClick: close }, (0, import_react46.createElement)(CloseIcon))
),
- (0, import_react42.createElement)(
+ (0, import_react46.createElement)(
"div",
{ key: "set-body", className: "bt-drawer-body bt-set-body", "data-move": move },
errorLine,
- bot ? (0, import_react42.createElement)(BotSettingsForm, { bot, roster, actions, run: run2 }) : (0, import_react42.createElement)(GroupSettingsForm, { room: room2, roster, actions, run: run2, onDeleted: close })
+ bot ? (0, import_react46.createElement)(BotSettingsForm, { bot, roster, actions, run: run2 }) : (0, import_react46.createElement)(GroupSettingsForm, { room: room2, roster, actions, run: run2, onDeleted: close })
)
];
}
@@ -16552,18 +16906,18 @@ function DetailsDrawer({ sessionId, startRenaming, startTab, hasStrip, roster, a
canTerminal: actions.canOpenTerminal?.() === true,
canFiles: actions.canOpenFiles?.() === true
}).map((key) => menuItemFor(key, actions, sessionId));
- const top = (0, import_react42.createElement)(
+ const top = (0, import_react46.createElement)(
"div",
{ className: "bt-drawer-top", "data-move": side },
- bot || room2 ? (0, import_react42.createElement)("button", { type: "button", className: "bt-round", "aria-label": bot ? t("Edit Bot") : t("Group settings"), title: bot ? t("Edit Bot") : t("Group settings"), "data-info-row": "settings", onClick: () => setView("settings") }, (0, import_react42.createElement)(GearIcon)) : null,
- more.length > 0 ? (0, import_react42.createElement)("span", { "data-info-row": "more" }, (0, import_react42.createElement)(PanelMenu, { items: more, className: "bt-round", "aria-label": t("More") })) : null,
- bot || room2 ? (0, import_react42.createElement)("button", { type: "button", className: "bt-round", "aria-label": copied ? t("Copied conversation") : t("Share conversation"), title: copied ? t("Copied") : t("Copy conversation as Markdown"), onClick: share }, copied ? (0, import_react42.createElement)("span", { key: "copied", className: "bt-pop-in" }, "✓") : (0, import_react42.createElement)(ShareIcon)) : null,
- hasStrip ? null : (0, import_react42.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("Close details"), onClick: close }, (0, import_react42.createElement)(CloseIcon))
+ bot || room2 ? (0, import_react46.createElement)("button", { type: "button", className: "bt-round", "aria-label": bot ? t("Edit Bot") : t("Group settings"), title: bot ? t("Edit Bot") : t("Group settings"), "data-info-row": "settings", onClick: () => setView("settings") }, (0, import_react46.createElement)(GearIcon)) : null,
+ more.length > 0 ? (0, import_react46.createElement)("span", { "data-info-row": "more" }, (0, import_react46.createElement)(PanelMenu, { items: more, className: "bt-round", "aria-label": t("More") })) : null,
+ bot || room2 ? (0, import_react46.createElement)("button", { type: "button", className: "bt-round", "aria-label": copied ? t("Copied conversation") : t("Share conversation"), title: copied ? t("Copied") : t("Copy conversation as Markdown"), onClick: share }, copied ? (0, import_react46.createElement)("span", { key: "copied", className: "bt-pop-in" }, "✓") : (0, import_react46.createElement)(ShareIcon)) : null,
+ hasStrip ? null : (0, import_react46.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("Close details"), onClick: close }, (0, import_react46.createElement)(CloseIcon))
);
if (!bot && !room2) {
return [
- (0, import_react42.createElement)(import_react42.Fragment, { key: "top" }, top),
- (0, import_react42.createElement)("div", { key: "body", className: "bt-drawer-body" }, (0, import_react42.createElement)("div", { className: "bt-muted" }, t("This conversation is not part of your Bot team.")))
+ (0, import_react46.createElement)(import_react46.Fragment, { key: "top" }, top),
+ (0, import_react46.createElement)("div", { key: "body", className: "bt-drawer-body" }, (0, import_react46.createElement)("div", { className: "bt-muted" }, t("This conversation is not part of your Bot team.")))
];
}
const current = bot?.name ?? room2.name;
@@ -16577,12 +16931,12 @@ function DetailsDrawer({ sessionId, startRenaming, startTab, hasStrip, roster, a
const subtitle = bot ? bot.role : roomSubtitle(room2, roster);
const tabs = bot ? ["details", "browser"] : ["details"];
return [
- (0, import_react42.createElement)(import_react42.Fragment, { key: "top" }, top),
- (0, import_react42.createElement)(
+ (0, import_react46.createElement)(import_react46.Fragment, { key: "top" }, top),
+ (0, import_react46.createElement)(
"div",
{ key: "id", className: "bt-drawer-id", "data-move": side },
- bot ? (0, import_react42.createElement)(BotAvatar, { bot, size: 64, state: botState(running, doing, roster.questions?.[part] !== void 0), main: isMainBot, badge: false, gaze: true, pokeable: true }) : (0, import_react42.createElement)(MemberPile, { room: room2, roster }),
- editing ? (0, import_react42.createElement)("input", {
+ bot ? (0, import_react46.createElement)(BotAvatar, { bot, size: 64, state: botState(running, doing, roster.questions?.[part] !== void 0), main: isMainBot, badge: false, gaze: true, pokeable: true }) : (0, import_react46.createElement)(MemberPile, { room: room2, roster }),
+ editing ? (0, import_react46.createElement)("input", {
className: "bt-drawer-name-input",
autoFocus: true,
value: draftName,
@@ -16597,50 +16951,50 @@ function DetailsDrawer({ sessionId, startRenaming, startTab, hasStrip, roster, a
setEditing(false);
}
}
- }) : (0, import_react42.createElement)("button", { type: "button", className: "bt-drawer-name", "aria-label": t("Rename {name}", { name: current }), title: t("Rename"), onClick: () => {
+ }) : (0, import_react46.createElement)("button", { type: "button", className: "bt-drawer-name", "aria-label": t("Rename {name}", { name: current }), title: t("Rename"), onClick: () => {
setDraftName(room2 && !room2.named ? "" : current);
setEditing(true);
} }, current),
- subtitle ? (0, import_react42.createElement)("span", { className: "bt-drawer-role" }, subtitle) : null
+ subtitle ? (0, import_react46.createElement)("span", { className: "bt-drawer-role" }, subtitle) : null
),
- tabs.length > 1 ? (0, import_react42.createElement)(
+ tabs.length > 1 ? (0, import_react46.createElement)(
"div",
{ key: "tabs", ref: glide.box, className: "bt-tabs", role: "tablist", "data-move": side },
- (0, import_react42.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),
- tabs.map((key) => (0, import_react42.createElement)("button", { key, type: "button", role: "tab", className: "bt-tab", "aria-selected": tab === key, onClick: () => setTab(key) }, t(TAB_LABELS[key])))
+ (0, import_react46.createElement)("span", { ref: glide.thumb, className: "bt-thumb", "aria-hidden": true }),
+ tabs.map((key) => (0, import_react46.createElement)("button", { key, type: "button", role: "tab", className: "bt-tab", "aria-selected": tab === key, onClick: () => setTab(key) }, t(TAB_LABELS[key])))
) : null,
- (0, import_react42.createElement)(
+ (0, import_react46.createElement)(
"div",
{ key: `body:${tab}`, className: "bt-drawer-body", "data-move": move },
errorLine,
- room2 && tab === "details" ? (0, import_react42.createElement)(GroupOverview, { room: room2, roster, actions, usage, useWork, openSettings: () => setView("settings") }) : null,
+ room2 && tab === "details" ? (0, import_react46.createElement)(GroupOverview, { room: room2, roster, actions, usage, useWork, openSettings: () => setView("settings") }) : null,
bot && tab === "details" ? [
- (0, import_react42.createElement)(RunStats, { key: "stats", bot, part, running, actions }),
- (0, import_react42.createElement)(
+ (0, import_react46.createElement)(RunStats, { key: "stats", bot, part, running, actions }),
+ (0, import_react46.createElement)(
"div",
{ key: "model", className: "bt-drawer-model" },
- (0, import_react42.createElement)("div", { className: "bt-section-title" }, t("Model")),
- (0, import_react42.createElement)(ModelMenu, { bot, roster, actions, run: run2, wide: true }),
- modelOf(bot, roster) ? null : (0, import_react42.createElement)("div", { className: "bt-note" }, t("Pick a model and {name} can start.", { name: bot.name }))
+ (0, import_react46.createElement)("div", { className: "bt-section-title" }, t("Model")),
+ (0, import_react46.createElement)(ModelMenu, { bot, roster, actions, run: run2, wide: true }),
+ modelOf(bot, roster) ? null : (0, import_react46.createElement)("div", { className: "bt-note" }, t("Pick a model and {name} can start.", { name: bot.name }))
),
- (0, import_react42.createElement)(PermissionRow, { key: "permission", bot, roster, actions, run: run2 }),
- (0, import_react42.createElement)(
+ (0, import_react46.createElement)(PermissionRow, { key: "permission", bot, roster, actions, run: run2 }),
+ (0, import_react46.createElement)(
"div",
{ key: "folder", className: "bt-drawer-model" },
- (0, import_react42.createElement)("div", { className: "bt-section-title" }, t("Working folder")),
- (0, import_react42.createElement)(FolderMenu, { value: bot.workDir, actions, run: run2, wide: true, onPick: (workDir) => run2(actions.updateBot(bot.id, { workDir })) })
+ (0, import_react46.createElement)("div", { className: "bt-section-title" }, t("Working folder")),
+ (0, import_react46.createElement)(FolderMenu, { value: bot.workDir, actions, run: run2, wide: true, onPick: (workDir) => run2(actions.updateBot(bot.id, { workDir })) })
),
- bot.instructions ? (0, import_react42.createElement)(About, { key: "about", text: bot.instructions }) : (0, import_react42.createElement)("button", { key: "about", type: "button", className: "bt-more", onClick: () => setView("settings") }, t("Add instructions in Bot settings")),
- roster.memory === false ? null : (0, import_react42.createElement)(MemoryRow, { key: "memory", owner: { id: bot.id, name: bot.name }, actions }),
- usage ? (0, import_react42.createElement)(
+ bot.instructions ? (0, import_react46.createElement)(About, { key: "about", text: bot.instructions }) : (0, import_react46.createElement)("button", { key: "about", type: "button", className: "bt-more", onClick: () => setView("settings") }, t("Add instructions in Bot settings")),
+ roster.memory === false ? null : (0, import_react46.createElement)(MemoryRow, { key: "memory", owner: { id: bot.id, name: bot.name }, actions }),
+ usage ? (0, import_react46.createElement)(
"div",
{ key: "usage" },
- (0, import_react42.createElement)("div", { className: "bt-section-title" }, t("Usage")),
- (0, import_react42.createElement)("div", { className: "bt-kv" }, (0, import_react42.createElement)("span", null, bot.name), (0, import_react42.createElement)("span", null, usage))
+ (0, import_react46.createElement)("div", { className: "bt-section-title" }, t("Usage")),
+ (0, import_react46.createElement)("div", { className: "bt-kv" }, (0, import_react46.createElement)("span", null, bot.name), (0, import_react46.createElement)("span", null, usage))
) : null,
- (0, import_react42.createElement)(ScheduleSummary, { key: "routines", bot, actions })
+ (0, import_react46.createElement)(ScheduleSummary, { key: "routines", bot, actions })
] : null,
- bot && tab === "browser" ? (0, import_react42.createElement)(BrowserCards, { bot, sessionId, roster, actions, useBrowserTabs, useBrowserPages }) : null
+ bot && tab === "browser" ? (0, import_react46.createElement)(BrowserCards, { bot, sessionId, roster, actions, useBrowserTabs, useBrowserPages }) : null
)
];
}
@@ -16651,7 +17005,7 @@ function rectsOverlap(a, b) {
}
// src/client/browser-pane.js
-var import_react43 = require("react");
+var import_react47 = require("react");
var import_react_dom8 = require("react-dom");
var PANEL_LINGER_MS = 300;
var WIDTH_KEY = STORAGE.browserWidth;
@@ -16668,10 +17022,10 @@ var EMPTY_TABS2 = { ids: [], active: null };
var SPRING_LEAD2 = springEasing(576, 39.4);
var SPRING_TRAIL2 = springEasing(144, 19.7);
var icon = (paths) => function BrowserIcon() {
- return (0, import_react43.createElement)(
+ return (0, import_react47.createElement)(
"svg",
{ width: 16, height: 16, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },
- paths.map((d, index) => (0, import_react43.createElement)("path", { key: index, d }))
+ paths.map((d, index) => (0, import_react47.createElement)("path", { key: index, d }))
);
};
var GlobeIcon2 = icon(["M10 3a7 7 0 1 0 0 14 7 7 0 0 0 0-14z", "M3 10h14", "M10 3c2 2.2 2.9 4.5 2.9 7S12 14.8 10 17c-2-2.2-2.9-4.5-2.9-7S8 5.2 10 3z"]);
@@ -16679,16 +17033,16 @@ var BackIcon = icon(["M12.5 4.5L7 10l5.5 5.5"]);
var ForwardIcon = icon(["M7.5 4.5L13 10l-5.5 5.5"]);
var ReloadIcon = icon(["M15.5 10a5.5 5.5 0 1 1-1.6-3.9", "M15.5 3.5v3.5H12"]);
var StopIcon = icon(["M5.5 5.5l9 9M14.5 5.5l-9 9"]);
-var CloseIcon2 = icon(["M5.5 5.5l9 9M14.5 5.5l-9 9"]);
+var CloseIcon3 = icon(["M5.5 5.5l9 9M14.5 5.5l-9 9"]);
var PlusTabIcon = icon(["M10 5v10M5 10h10"]);
var LockIcon2 = icon(["M6.5 9V7a3.5 3.5 0 0 1 7 0v2", "M5.5 9h9v7h-9z"]);
var ImportIcon = icon(["M10 3.5v8.5", "M6 8.5l4 4 4-4", "M4.5 14v1.5a1.5 1.5 0 0 0 1.5 1.5h8a1.5 1.5 0 0 0 1.5-1.5V14"]);
var FileIcon = icon(["M6 3.5h5.5L14.5 6.5v10H6z", "M11 3.5v3.5h3.5"]);
var WindowIcon = icon(["M4 5h12v9.5H4z", "M4 7.5h12"]);
function Favicon({ src, className }) {
- const [failed, setFailed] = (0, import_react43.useState)(null);
- if (!src || failed === src) return (0, import_react43.createElement)("span", { className: `${className} bt-ptab-globe` }, (0, import_react43.createElement)(GlobeIcon2));
- return (0, import_react43.createElement)("img", { className, src, alt: "", "aria-hidden": true, onError: () => setFailed(src) });
+ const [failed, setFailed] = (0, import_react47.useState)(null);
+ if (!src || failed === src) return (0, import_react47.createElement)("span", { className: `${className} bt-ptab-globe` }, (0, import_react47.createElement)(GlobeIcon2));
+ return (0, import_react47.createElement)("img", { className, src, alt: "", "aria-hidden": true, onError: () => setFailed(src) });
}
var savedWidth = () => {
try {
@@ -16743,9 +17097,9 @@ var shortAddress = (url) => String(url ?? "").replace(/^https?:\/\//i, "").repla
var reducedMotion2 = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
var tabLabel = (page) => page.title || shortAddress(page.url) || t("New tab");
function PanelMenu({ items, className, "aria-label": label }) {
- const [open, setOpen] = (0, import_react43.useState)(false);
- const wrap = (0, import_react43.useRef)(null);
- (0, import_react43.useEffect)(() => {
+ const [open, setOpen] = (0, import_react47.useState)(false);
+ const wrap = (0, import_react47.useRef)(null);
+ (0, import_react47.useEffect)(() => {
if (!open) return void 0;
const onDown = (event) => {
if (wrap.current && !wrap.current.contains(event.target)) setOpen(false);
@@ -16763,10 +17117,10 @@ function PanelMenu({ items, className, "aria-label": label }) {
};
}, [open]);
if (items.length === 0) return null;
- return (0, import_react43.createElement)(
+ return (0, import_react47.createElement)(
"span",
{ className: "bt-pmenu", ref: wrap },
- (0, import_react43.createElement)("button", {
+ (0, import_react47.createElement)("button", {
type: "button",
className,
"aria-label": label,
@@ -16774,11 +17128,11 @@ function PanelMenu({ items, className, "aria-label": label }) {
"aria-haspopup": "menu",
"aria-expanded": open,
onClick: () => setOpen((value) => !value)
- }, (0, import_react43.createElement)(DotsIcon)),
- open ? (0, import_react43.createElement)(
+ }, (0, import_react47.createElement)(DotsIcon)),
+ open ? (0, import_react47.createElement)(
"div",
{ className: "bt-pmenu-pop", role: "menu" },
- items.map((item, index) => item.sep ? (0, import_react43.createElement)("span", { key: `sep-${index}`, className: "bt-pmenu-sep", role: "separator" }) : (0, import_react43.createElement)("button", {
+ items.map((item, index) => item.sep ? (0, import_react47.createElement)("span", { key: `sep-${index}`, className: "bt-pmenu-sep", role: "separator" }) : (0, import_react47.createElement)("button", {
key: item.key,
type: "button",
role: "menuitem",
@@ -16787,7 +17141,7 @@ function PanelMenu({ items, className, "aria-label": label }) {
setOpen(false);
item.onPick();
}
- }, (0, import_react43.createElement)(item.icon), (0, import_react43.createElement)("span", null, item.label)))
+ }, (0, import_react47.createElement)(item.icon), (0, import_react47.createElement)("span", null, item.label)))
) : null
);
}
@@ -16813,12 +17167,12 @@ function menuItemFor(key, actions, subject) {
var sideTitle = (chat) => chat?.entries?.[0]?.question?.trim() || t("Side chat");
function PanelStrip({ bot, subject, view, ids, active, sides, side, canBrowse, reading, onView, actions, useBrowserPages }) {
const pages = useBrowserPages((map) => map);
- const wrap = (0, import_react43.useRef)(null);
- const ind = (0, import_react43.useRef)(null);
- const spot = (0, import_react43.useRef)(null);
- const under = (0, import_react43.useRef)(null);
- const watcher = (0, import_react43.useRef)(null);
- (0, import_react43.useLayoutEffect)(() => {
+ const wrap = (0, import_react47.useRef)(null);
+ const ind = (0, import_react47.useRef)(null);
+ const spot = (0, import_react47.useRef)(null);
+ const under = (0, import_react47.useRef)(null);
+ const watcher = (0, import_react47.useRef)(null);
+ (0, import_react47.useLayoutEffect)(() => {
const box = wrap.current;
const capsule = ind.current;
if (!box || !capsule) return void 0;
@@ -16851,7 +17205,7 @@ function PanelStrip({ bot, subject, view, ids, active, sides, side, canBrowse, r
trail.cancel();
};
});
- (0, import_react43.useEffect)(() => {
+ (0, import_react47.useEffect)(() => {
const box = wrap.current;
if (!box) return void 0;
const observer = new ResizeObserver(() => {
@@ -16875,13 +17229,13 @@ function PanelStrip({ bot, subject, view, ids, active, sides, side, canBrowse, r
canTerminal: actions.canOpenTerminal?.() === true,
canFiles: actions.canOpenFiles?.() === true
}).map((key) => menuItemFor(key, actions, subject));
- return (0, import_react43.createElement)(
+ return (0, import_react47.createElement)(
"div",
{ className: "bt-ptabs", role: "tablist", "aria-label": t("Panel tabs") },
- (0, import_react43.createElement)(
+ (0, import_react47.createElement)(
"div",
{ className: "bt-ptabs-in", ref: wrap },
- (0, import_react43.createElement)(
+ (0, import_react47.createElement)(
"button",
{
type: "button",
@@ -16891,13 +17245,13 @@ function PanelStrip({ bot, subject, view, ids, active, sides, side, canBrowse, r
title: bot.name,
onClick: () => onView("details")
},
- (0, import_react43.createElement)(BotMark, { bot, size: 20, state: reading ? "searching" : "idle" }),
- view === "details" ? (0, import_react43.createElement)("span", { className: "bt-ptab-name" }, bot.name) : null
+ (0, import_react47.createElement)(BotMark, { bot, size: 20, state: reading ? "searching" : "idle" }),
+ view === "details" ? (0, import_react47.createElement)("span", { className: "bt-ptab-name" }, bot.name) : null
),
ids.map((tabId) => {
const page = pages[tabId] ?? EMPTY_PAGE;
const on = view === "browser" && tabId === active;
- return (0, import_react43.createElement)(
+ return (0, import_react47.createElement)(
"button",
{
key: tabId,
@@ -16918,9 +17272,9 @@ function PanelStrip({ bot, subject, view, ids, active, sides, side, canBrowse, r
}
}
},
- (0, import_react43.createElement)(Favicon, { src: page.favicon, className: "bt-ptab-fav" }),
- (0, import_react43.createElement)("span", { className: "bt-ptab-title" }, tabLabel(page)),
- (0, import_react43.createElement)("span", {
+ (0, import_react47.createElement)(Favicon, { src: page.favicon, className: "bt-ptab-fav" }),
+ (0, import_react47.createElement)("span", { className: "bt-ptab-title" }, tabLabel(page)),
+ (0, import_react47.createElement)("span", {
className: "bt-ptab-x",
role: "button",
"aria-label": t("Close tab"),
@@ -16934,7 +17288,7 @@ function PanelStrip({ bot, subject, view, ids, active, sides, side, canBrowse, r
}),
sides.map((chat) => {
const on = view === "side" && chat.id === side;
- return (0, import_react43.createElement)(
+ return (0, import_react47.createElement)(
"button",
{
key: chat.id,
@@ -16952,9 +17306,9 @@ function PanelStrip({ bot, subject, view, ids, active, sides, side, canBrowse, r
}
}
},
- (0, import_react43.createElement)("span", { className: "bt-ptab-globe", "aria-hidden": true }, (0, import_react43.createElement)(SideIcon)),
- (0, import_react43.createElement)("span", { className: "bt-ptab-title" }, sideTitle(chat)),
- (0, import_react43.createElement)("span", {
+ (0, import_react47.createElement)("span", { className: "bt-ptab-globe", "aria-hidden": true }, (0, import_react47.createElement)(SideIcon)),
+ (0, import_react47.createElement)("span", { className: "bt-ptab-title" }, sideTitle(chat)),
+ (0, import_react47.createElement)("span", {
className: "bt-ptab-x",
role: "button",
"aria-label": t("Close side chat"),
@@ -16966,30 +17320,30 @@ function PanelStrip({ bot, subject, view, ids, active, sides, side, canBrowse, r
}, "×")
);
}),
- (0, import_react43.createElement)("span", { ref: ind, className: "bt-ptab-ind", "aria-hidden": true })
+ (0, import_react47.createElement)("span", { ref: ind, className: "bt-ptab-ind", "aria-hidden": true })
),
// The `···` and Close stay outside the scrolling tabs, so a narrow panel keeps both.
- (0, import_react43.createElement)(PanelMenu, { items, className: "bt-ptab-new", "aria-label": t("More") }),
- (0, import_react43.createElement)("button", { type: "button", className: "bt-icon-btn bt-ptab-close", "aria-label": t("Close panel"), title: t("Close panel"), onClick: () => actions.closePanel() }, (0, import_react43.createElement)(CloseIcon2))
+ (0, import_react47.createElement)(PanelMenu, { items, className: "bt-ptab-new", "aria-label": t("More") }),
+ (0, import_react47.createElement)("button", { type: "button", className: "bt-icon-btn bt-ptab-close", "aria-label": t("Close panel"), title: t("Close panel"), onClick: () => actions.closePanel() }, (0, import_react47.createElement)(CloseIcon3))
);
}
function BrowserView({ bot, tabId, leaving, landed, actions, useBrowserPages, hold }) {
const page = useBrowserPages((pages) => pages[tabId ?? ""]) ?? EMPTY_PAGE;
- const frame = (0, import_react43.useRef)(null);
- const input = (0, import_react43.useRef)(null);
- const [draft, setDraft] = (0, import_react43.useState)(null);
- const [covered, setCovered] = (0, import_react43.useState)(false);
+ const frame = (0, import_react47.useRef)(null);
+ const input = (0, import_react47.useRef)(null);
+ const [draft, setDraft] = (0, import_react47.useState)(null);
+ const [covered, setCovered] = (0, import_react47.useState)(false);
const imports = actions.browserImport;
- const [flow, setFlow] = (0, import_react43.useState)(null);
- const flowRef = (0, import_react43.useRef)(null);
- const [sources, setSources] = (0, import_react43.useState)(null);
- const [busy, setBusy] = (0, import_react43.useState)(false);
+ const [flow, setFlow] = (0, import_react47.useState)(null);
+ const flowRef = (0, import_react47.useRef)(null);
+ const [sources, setSources] = (0, import_react47.useState)(null);
+ const [busy, setBusy] = (0, import_react47.useState)(false);
const setFlowTracked = (next) => {
flowRef.current = typeof next === "function" ? next(flowRef.current) : next;
setFlow(flowRef.current);
};
const showGuest = landed && !leaving && !covered && Boolean(page.url) && !page.error && flow === null;
- (0, import_react43.useEffect)(() => {
+ (0, import_react47.useEffect)(() => {
const update = () => {
const panel = frame.current?.getBoundingClientRect();
const overlaps2 = panel && [...document.querySelectorAll('[role="dialog"],[role="menu"],[role="listbox"]')].some((element) => rectsOverlap(panel, element.getBoundingClientRect()));
@@ -17004,7 +17358,7 @@ function BrowserView({ bot, tabId, leaving, landed, actions, useBrowserPages, ho
window.removeEventListener("resize", update);
};
}, []);
- (0, import_react43.useEffect)(() => {
+ (0, import_react47.useEffect)(() => {
setFlowTracked(null);
return () => {
const id = typeof flowRef.current === "object" && flowRef.current !== null ? flowRef.current.id : null;
@@ -17048,7 +17402,7 @@ function BrowserView({ bot, tabId, leaving, landed, actions, useBrowserPages, ho
if (id) void imports?.cancel(id).catch(() => {
});
};
- (0, import_react43.useLayoutEffect)(() => {
+ (0, import_react47.useLayoutEffect)(() => {
const element = frame.current;
if (!element || leaving || !tabId) {
void actions.browserShow(null);
@@ -17074,7 +17428,7 @@ function BrowserView({ bot, tabId, leaving, landed, actions, useBrowserPages, ho
window.removeEventListener("resize", schedule);
};
}, [tabId, showGuest, leaving]);
- (0, import_react43.useEffect)(() => {
+ (0, import_react47.useEffect)(() => {
setDraft(null);
if (landed && !page.url) input.current?.focus();
}, [tabId, landed]);
@@ -17090,38 +17444,38 @@ function BrowserView({ bot, tabId, leaving, landed, actions, useBrowserPages, ho
};
const editing = draft !== null;
const secure = /^https:/i.test(page.url);
- return (0, import_react43.createElement)(
+ return (0, import_react47.createElement)(
"div",
{ className: "bt-panel-view bt-panel-browser", "aria-label": t("{name}'s browser", { name: bot.name }) },
- actions.browserTakeover ? (0, import_react43.createElement)(
+ actions.browserTakeover ? (0, import_react47.createElement)(
"div",
{ className: "bt-browser-takeover", "data-held": hold?.by === "user" || void 0 },
- (0, import_react43.createElement)("span", null, hold?.by === "user" ? t("You control this browser") : hold?.by === "bot" ? t("The Bot handed this browser to you: {reason}", { reason: hold.reason }) : t("The Bot controls this browser")),
- hold?.by ? (0, import_react43.createElement)("button", { type: "button", onClick: () => void actions.browserGiveBack(bot.id) }, t("Give back")) : (0, import_react43.createElement)(
+ (0, import_react47.createElement)("span", null, hold?.by === "user" ? t("You control this browser") : hold?.by === "bot" ? t("The Bot handed this browser to you: {reason}", { reason: hold.reason }) : t("The Bot controls this browser")),
+ hold?.by ? (0, import_react47.createElement)("button", { type: "button", onClick: () => void actions.browserGiveBack(bot.id) }, t("Give back")) : (0, import_react47.createElement)(
"span",
{ className: "bt-browser-takeover-actions" },
- (0, import_react43.createElement)("button", { type: "button", onClick: () => void actions.browserTakeover(bot.id) }, t("Take over")),
- (0, import_react43.createElement)("button", { type: "button", onClick: () => void actions.browserStop(bot.id) }, t("Stop"))
+ (0, import_react47.createElement)("button", { type: "button", onClick: () => void actions.browserTakeover(bot.id) }, t("Take over")),
+ (0, import_react47.createElement)("button", { type: "button", onClick: () => void actions.browserStop(bot.id) }, t("Stop"))
)
) : null,
- (0, import_react43.createElement)(
+ (0, import_react47.createElement)(
"div",
{ className: "bt-browser-bar" },
- (0, import_react43.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Back"), title: t("Back"), disabled: !page.canGoBack, onClick: () => actions.browserCommand(tabId, "back") }, (0, import_react43.createElement)(BackIcon)),
- (0, import_react43.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Forward"), title: t("Forward"), disabled: !page.canGoForward, onClick: () => actions.browserCommand(tabId, "forward") }, (0, import_react43.createElement)(ForwardIcon)),
- (0, import_react43.createElement)("button", {
+ (0, import_react47.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Back"), title: t("Back"), disabled: !page.canGoBack, onClick: () => actions.browserCommand(tabId, "back") }, (0, import_react47.createElement)(BackIcon)),
+ (0, import_react47.createElement)("button", { type: "button", className: "bt-icon-btn", "aria-label": t("Forward"), title: t("Forward"), disabled: !page.canGoForward, onClick: () => actions.browserCommand(tabId, "forward") }, (0, import_react47.createElement)(ForwardIcon)),
+ (0, import_react47.createElement)("button", {
type: "button",
className: "bt-icon-btn",
disabled: !page.url,
"aria-label": page.loading ? t("Stop") : t("Reload"),
title: page.loading ? t("Stop") : t("Reload"),
onClick: () => actions.browserCommand(tabId, page.loading ? "stop" : "reload")
- }, (0, import_react43.createElement)(page.loading ? StopIcon : ReloadIcon)),
- (0, import_react43.createElement)(
+ }, (0, import_react47.createElement)(page.loading ? StopIcon : ReloadIcon)),
+ (0, import_react47.createElement)(
"form",
{ className: "bt-browser-address", onSubmit: go, "data-editing": editing || void 0 },
- (0, import_react43.createElement)("span", { className: "bt-browser-scheme", "aria-hidden": true }, (0, import_react43.createElement)(secure && !editing ? LockIcon2 : GlobeIcon2)),
- (0, import_react43.createElement)("input", {
+ (0, import_react47.createElement)("span", { className: "bt-browser-scheme", "aria-hidden": true }, (0, import_react47.createElement)(secure && !editing ? LockIcon2 : GlobeIcon2)),
+ (0, import_react47.createElement)("input", {
ref: input,
type: "text",
spellCheck: false,
@@ -17145,14 +17499,14 @@ function BrowserView({ bot, tabId, leaving, landed, actions, useBrowserPages, ho
}
})
),
- (0, import_react43.createElement)("button", {
+ (0, import_react47.createElement)("button", {
type: "button",
className: "bt-icon-btn",
"aria-label": t("New browser tab"),
title: t("New browser tab"),
onClick: () => actions.browserNewTab(bot.id)
- }, (0, import_react43.createElement)(PlusTabIcon)),
- imports ? (0, import_react43.createElement)("button", {
+ }, (0, import_react47.createElement)(PlusTabIcon)),
+ imports ? (0, import_react47.createElement)("button", {
type: "button",
className: "bt-icon-btn bt-import-btn",
"aria-label": t("Import cookies"),
@@ -17163,29 +17517,29 @@ function BrowserView({ bot, tabId, leaving, landed, actions, useBrowserPages, ho
if (flow === "menu") setFlowTracked(null);
else openImport();
}
- }, (0, import_react43.createElement)(ImportIcon)) : null,
- page.loading ? (0, import_react43.createElement)("span", { className: "bt-browser-progress", "aria-hidden": true }) : null
+ }, (0, import_react47.createElement)(ImportIcon)) : null,
+ page.loading ? (0, import_react47.createElement)("span", { className: "bt-browser-progress", "aria-hidden": true }) : null
),
- (0, import_react43.createElement)(
+ (0, import_react47.createElement)(
"div",
{ ref: frame, className: "bt-browser-frame", "data-guest": showGuest || void 0 },
- flow === "menu" ? (0, import_react43.createElement)(ImportMenu, { sources, busy, onFile: pickFile, onSource: pickSource, onClose: () => setFlowTracked(null) }) : null,
- typeof flow === "object" && flow !== null ? (0, import_react43.createElement)(ImportCard, { flow, page, busy, onApply: applyImport, onCancel: cancelImport, onCloseAndImport: closeAndImport, onDone: () => setFlowTracked(null), onReload: () => actions.browserCommand(tabId, "reload") }) : null,
- flow === null && page.error ? (0, import_react43.createElement)(
+ flow === "menu" ? (0, import_react47.createElement)(ImportMenu, { sources, busy, onFile: pickFile, onSource: pickSource, onClose: () => setFlowTracked(null) }) : null,
+ typeof flow === "object" && flow !== null ? (0, import_react47.createElement)(ImportCard, { flow, page, busy, onApply: applyImport, onCancel: cancelImport, onCloseAndImport: closeAndImport, onDone: () => setFlowTracked(null), onReload: () => actions.browserCommand(tabId, "reload") }) : null,
+ flow === null && page.error ? (0, import_react47.createElement)(
"div",
{ className: "bt-browser-empty" },
- (0, import_react43.createElement)("div", { className: "bt-browser-empty-title" }, t("This page didn’t load")),
- (0, import_react43.createElement)("div", { className: "bt-browser-empty-text" }, t(page.error)),
- page.url ? (0, import_react43.createElement)("button", { type: "button", className: "bt-browser-retry", onClick: () => {
+ (0, import_react47.createElement)("div", { className: "bt-browser-empty-title" }, t("This page didn’t load")),
+ (0, import_react47.createElement)("div", { className: "bt-browser-empty-text" }, t(page.error)),
+ page.url ? (0, import_react47.createElement)("button", { type: "button", className: "bt-browser-retry", onClick: () => {
void actions.browserNavigate(tabId, page.url);
} }, t("Try again")) : null
- ) : flow === null && !page.url ? (0, import_react43.createElement)(
+ ) : flow === null && !page.url ? (0, import_react47.createElement)(
"div",
{ className: "bt-browser-empty" },
- (0, import_react43.createElement)(BotMark, { bot, size: 48, state: "idle", live: true }),
- (0, import_react43.createElement)("div", { className: "bt-browser-empty-title" }, t("{name}'s browser", { name: bot.name })),
- (0, import_react43.createElement)("div", { className: "bt-browser-empty-text" }, t("Open a page here and {name} can read it with you. Logins and cookies stay with {name}; other Bots never see them.", { name: bot.name })),
- imports ? (0, import_react43.createElement)("button", { type: "button", className: "bt-browser-retry", onClick: openImport }, t("Import cookies")) : null
+ (0, import_react47.createElement)(BotMark, { bot, size: 48, state: "idle", live: true }),
+ (0, import_react47.createElement)("div", { className: "bt-browser-empty-title" }, t("{name}'s browser", { name: bot.name })),
+ (0, import_react47.createElement)("div", { className: "bt-browser-empty-text" }, t("Open a page here and {name} can read it with you. Logins and cookies stay with {name}; other Bots never see them.", { name: bot.name })),
+ imports ? (0, import_react47.createElement)("button", { type: "button", className: "bt-browser-retry", onClick: openImport }, t("Import cookies")) : null
) : null
)
);
@@ -17197,25 +17551,25 @@ function importError(error) {
return String(error);
}
function ImportMenu({ sources, busy, onFile, onSource, onClose }) {
- (0, import_react43.useEffect)(() => {
+ (0, import_react47.useEffect)(() => {
const close = (event) => {
if (event.key === "Escape") onClose();
};
window.addEventListener("keydown", close);
return () => window.removeEventListener("keydown", close);
}, [onClose]);
- return (0, import_react43.createElement)(
+ return (0, import_react47.createElement)(
"div",
{ className: "bt-import-menu", role: "menu", "aria-label": t("Import cookies") },
- (0, import_react43.createElement)("div", { className: "bt-import-menu-title" }, t("Import cookies")),
- (0, import_react43.createElement)(
+ (0, import_react47.createElement)("div", { className: "bt-import-menu-title" }, t("Import cookies")),
+ (0, import_react47.createElement)(
"button",
{ type: "button", className: "bt-import-item", role: "menuitem", disabled: busy, onClick: onFile },
- (0, import_react43.createElement)(FileIcon, { className: "bt-import-item-icon" }),
- (0, import_react43.createElement)("span", { className: "bt-import-item-name" }, t("From a file…")),
- (0, import_react43.createElement)("span", { className: "bt-import-item-sub" }, t("cookies.txt, JSON, storageState"))
+ (0, import_react47.createElement)(FileIcon, { className: "bt-import-item-icon" }),
+ (0, import_react47.createElement)("span", { className: "bt-import-item-name" }, t("From a file…")),
+ (0, import_react47.createElement)("span", { className: "bt-import-item-sub" }, t("cookies.txt, JSON, storageState"))
),
- sources === null ? (0, import_react43.createElement)("div", { className: "bt-import-menu-note" }, t("Loading…")) : sources.length === 0 ? (0, import_react43.createElement)("div", { className: "bt-import-menu-note" }, t("No browsers found")) : sources.map((source) => (0, import_react43.createElement)(
+ sources === null ? (0, import_react47.createElement)("div", { className: "bt-import-menu-note" }, t("Loading…")) : sources.length === 0 ? (0, import_react47.createElement)("div", { className: "bt-import-menu-note" }, t("No browsers found")) : sources.map((source) => (0, import_react47.createElement)(
"button",
{
key: source.id,
@@ -17225,83 +17579,83 @@ function ImportMenu({ sources, busy, onFile, onSource, onClose }) {
disabled: busy,
onClick: () => onSource(source)
},
- (0, import_react43.createElement)(WindowIcon, { className: "bt-import-item-icon" }),
- (0, import_react43.createElement)("span", { className: "bt-import-item-name" }, source.label),
- (0, import_react43.createElement)("span", { className: "bt-import-item-sub" }, t("Copy of its cookies"))
+ (0, import_react47.createElement)(WindowIcon, { className: "bt-import-item-icon" }),
+ (0, import_react47.createElement)("span", { className: "bt-import-item-name" }, source.label),
+ (0, import_react47.createElement)("span", { className: "bt-import-item-sub" }, t("Copy of its cookies"))
))
);
}
function ImportCard({ flow, page, busy, onApply, onCancel, onCloseAndImport, onDone, onReload }) {
const { stage } = flow;
if (stage === "running") {
- return (0, import_react43.createElement)("div", { className: "bt-import-card" }, (0, import_react43.createElement)(
+ return (0, import_react47.createElement)("div", { className: "bt-import-card" }, (0, import_react47.createElement)(
"div",
{ className: "bt-import-box" },
- (0, import_react43.createElement)("div", { className: "bt-import-title" }, t("{name} is running", { name: flow.source.name })),
- (0, import_react43.createElement)("div", { className: "bt-import-text" }, t("It must close for a moment so its cookies can be copied. It will reopen with your tabs.")),
- (0, import_react43.createElement)(
+ (0, import_react47.createElement)("div", { className: "bt-import-title" }, t("{name} is running", { name: flow.source.name })),
+ (0, import_react47.createElement)("div", { className: "bt-import-text" }, t("It must close for a moment so its cookies can be copied. It will reopen with your tabs.")),
+ (0, import_react47.createElement)(
"div",
{ className: "bt-import-actions" },
- (0, import_react43.createElement)("button", { type: "button", className: "bt-import-primary", disabled: busy, onClick: onCloseAndImport }, busy ? t("Closing…") : t("Close {name} and import", { name: flow.source.name })),
- (0, import_react43.createElement)("button", { type: "button", className: "bt-import-plain", disabled: busy, onClick: onCancel }, t("Cancel"))
+ (0, import_react47.createElement)("button", { type: "button", className: "bt-import-primary", disabled: busy, onClick: onCloseAndImport }, busy ? t("Closing…") : t("Close {name} and import", { name: flow.source.name })),
+ (0, import_react47.createElement)("button", { type: "button", className: "bt-import-plain", disabled: busy, onClick: onCancel }, t("Cancel"))
)
));
}
if (stage === "error") {
- return (0, import_react43.createElement)("div", { className: "bt-import-card" }, (0, import_react43.createElement)(
+ return (0, import_react47.createElement)("div", { className: "bt-import-card" }, (0, import_react47.createElement)(
"div",
{ className: "bt-import-box" },
- (0, import_react43.createElement)("div", { className: "bt-import-title" }, t("Import failed")),
- (0, import_react43.createElement)("div", { className: "bt-import-text" }, flow.message),
- (0, import_react43.createElement)("div", { className: "bt-import-actions" }, (0, import_react43.createElement)("button", { type: "button", className: "bt-import-plain", onClick: onCancel }, t("Close")))
+ (0, import_react47.createElement)("div", { className: "bt-import-title" }, t("Import failed")),
+ (0, import_react47.createElement)("div", { className: "bt-import-text" }, flow.message),
+ (0, import_react47.createElement)("div", { className: "bt-import-actions" }, (0, import_react47.createElement)("button", { type: "button", className: "bt-import-plain", onClick: onCancel }, t("Close")))
));
}
if (stage === "result") {
const { report } = flow;
const problems = [...report.dropped ?? [], ...report.failed ?? []];
- return (0, import_react43.createElement)("div", { className: "bt-import-card" }, (0, import_react43.createElement)(
+ return (0, import_react47.createElement)("div", { className: "bt-import-card" }, (0, import_react47.createElement)(
"div",
{ className: "bt-import-box" },
- (0, import_react43.createElement)("div", { className: "bt-import-title" }, report.stored > 0 ? t("Imported {count} cookies", { count: report.stored }) : t("No cookies were stored")),
- flow.label ? (0, import_react43.createElement)("div", { className: "bt-import-sub" }, flow.label) : null,
- problems.length ? (0, import_react43.createElement)(
+ (0, import_react47.createElement)("div", { className: "bt-import-title" }, report.stored > 0 ? t("Imported {count} cookies", { count: report.stored }) : t("No cookies were stored")),
+ flow.label ? (0, import_react47.createElement)("div", { className: "bt-import-sub" }, flow.label) : null,
+ problems.length ? (0, import_react47.createElement)(
"div",
{ className: "bt-import-list" },
- problems.slice(0, 8).map((item, index) => (0, import_react43.createElement)(
+ problems.slice(0, 8).map((item, index) => (0, import_react47.createElement)(
"div",
{ key: index, className: "bt-import-line" },
- (0, import_react43.createElement)("span", { className: "bt-import-line-name" }, item.name ?? "—"),
- (0, import_react43.createElement)("span", { className: "bt-import-line-reason" }, item.reason)
+ (0, import_react47.createElement)("span", { className: "bt-import-line-name" }, item.name ?? "—"),
+ (0, import_react47.createElement)("span", { className: "bt-import-line-reason" }, item.reason)
)),
- problems.length > 8 ? (0, import_react43.createElement)("div", { className: "bt-import-line" }, (0, import_react43.createElement)("span", { className: "bt-import-line-reason" }, t("and {count} more", { count: problems.length - 8 }))) : null
+ problems.length > 8 ? (0, import_react47.createElement)("div", { className: "bt-import-line" }, (0, import_react47.createElement)("span", { className: "bt-import-line-reason" }, t("and {count} more", { count: problems.length - 8 }))) : null
) : null,
- (0, import_react43.createElement)(
+ (0, import_react47.createElement)(
"div",
{ className: "bt-import-actions" },
- page.url ? (0, import_react43.createElement)("button", { type: "button", className: "bt-import-plain", onClick: onReload }, t("Reload the page")) : null,
- (0, import_react43.createElement)("button", { type: "button", className: "bt-import-primary", onClick: onDone }, t("Done"))
+ page.url ? (0, import_react47.createElement)("button", { type: "button", className: "bt-import-plain", onClick: onReload }, t("Reload the page")) : null,
+ (0, import_react47.createElement)("button", { type: "button", className: "bt-import-primary", onClick: onDone }, t("Done"))
)
));
}
const { preview } = flow;
- return (0, import_react43.createElement)("div", { className: "bt-import-card" }, (0, import_react43.createElement)(
+ return (0, import_react47.createElement)("div", { className: "bt-import-card" }, (0, import_react47.createElement)(
"div",
{ className: "bt-import-box" },
- (0, import_react43.createElement)("div", { className: "bt-import-title" }, t("Import {count} cookies", { count: preview.cookies })),
- (0, import_react43.createElement)(
+ (0, import_react47.createElement)("div", { className: "bt-import-title" }, t("Import {count} cookies", { count: preview.cookies })),
+ (0, import_react47.createElement)(
"div",
{ className: "bt-import-sub" },
preview.source?.label ?? "",
flow.restarted ? ` · ${t("the browser was restarted")}` : ""
),
- preview.sites.length ? (0, import_react43.createElement)(
+ preview.sites.length ? (0, import_react47.createElement)(
"div",
{ className: "bt-import-list" },
- preview.sites.map((site) => (0, import_react43.createElement)(
+ preview.sites.map((site) => (0, import_react47.createElement)(
"div",
{ key: site.site, className: "bt-import-line" },
- (0, import_react43.createElement)("span", { className: "bt-import-line-name" }, site.site),
- (0, import_react43.createElement)(
+ (0, import_react47.createElement)("span", { className: "bt-import-line-name" }, site.site),
+ (0, import_react47.createElement)(
"span",
{ className: "bt-import-line-count" },
t("{count}", { count: site.cookies }),
@@ -17309,35 +17663,35 @@ function ImportCard({ flow, page, busy, onApply, onCancel, onCloseAndImport, onD
)
))
) : null,
- preview.skipped.length ? (0, import_react43.createElement)(
+ preview.skipped.length ? (0, import_react47.createElement)(
"div",
{ className: "bt-import-list" },
- (0, import_react43.createElement)("div", { className: "bt-import-note" }, t("{count} skipped", { count: preview.skipped.length })),
- preview.skipped.slice(0, 5).map((item, index) => (0, import_react43.createElement)(
+ (0, import_react47.createElement)("div", { className: "bt-import-note" }, t("{count} skipped", { count: preview.skipped.length })),
+ preview.skipped.slice(0, 5).map((item, index) => (0, import_react47.createElement)(
"div",
{ key: index, className: "bt-import-line" },
- (0, import_react43.createElement)("span", { className: "bt-import-line-name" }, item.name ?? item.where),
- (0, import_react43.createElement)("span", { className: "bt-import-line-reason" }, item.reason)
+ (0, import_react47.createElement)("span", { className: "bt-import-line-name" }, item.name ?? item.where),
+ (0, import_react47.createElement)("span", { className: "bt-import-line-reason" }, item.reason)
)),
- preview.skipped.length > 5 ? (0, import_react43.createElement)("div", { className: "bt-import-line" }, (0, import_react43.createElement)("span", { className: "bt-import-line-reason" }, t("and {count} more", { count: preview.skipped.length - 5 }))) : null
+ preview.skipped.length > 5 ? (0, import_react47.createElement)("div", { className: "bt-import-line" }, (0, import_react47.createElement)("span", { className: "bt-import-line-reason" }, t("and {count} more", { count: preview.skipped.length - 5 }))) : null
) : null,
- preview.warnings.length ? (0, import_react43.createElement)(
+ preview.warnings.length ? (0, import_react47.createElement)(
"details",
{ className: "bt-import-warns" },
- (0, import_react43.createElement)("summary", null, t("{count} adjusted", { count: preview.warnings.reduce((n, w) => n + w.count, 0) })),
- preview.warnings.map((w, index) => (0, import_react43.createElement)(
+ (0, import_react47.createElement)("summary", null, t("{count} adjusted", { count: preview.warnings.reduce((n, w) => n + w.count, 0) })),
+ preview.warnings.map((w, index) => (0, import_react47.createElement)(
"div",
{ key: index, className: "bt-import-line" },
- (0, import_react43.createElement)("span", { className: "bt-import-line-reason" }, `${w.count} × ${w.message}`)
+ (0, import_react47.createElement)("span", { className: "bt-import-line-reason" }, `${w.count} × ${w.message}`)
))
) : null,
- preview.notes.includes("session-cookies") ? (0, import_react43.createElement)("div", { className: "bt-import-note" }, t("Cookies without an expiry stay until the app closes.")) : null,
- preview.notes.includes("local-storage-left") ? (0, import_react43.createElement)("div", { className: "bt-import-note" }, t("Some sites also keep sign-in outside cookies; you may need to sign in again there.")) : null,
- (0, import_react43.createElement)(
+ preview.notes.includes("session-cookies") ? (0, import_react47.createElement)("div", { className: "bt-import-note" }, t("Cookies without an expiry stay until the app closes.")) : null,
+ preview.notes.includes("local-storage-left") ? (0, import_react47.createElement)("div", { className: "bt-import-note" }, t("Some sites also keep sign-in outside cookies; you may need to sign in again there.")) : null,
+ (0, import_react47.createElement)(
"div",
{ className: "bt-import-actions" },
- (0, import_react43.createElement)("button", { type: "button", className: "bt-import-primary", disabled: busy, onClick: onApply }, busy ? t("Importing…") : t("Import")),
- (0, import_react43.createElement)("button", { type: "button", className: "bt-import-plain", disabled: busy, onClick: onCancel }, t("Cancel"))
+ (0, import_react47.createElement)("button", { type: "button", className: "bt-import-primary", disabled: busy, onClick: onApply }, busy ? t("Importing…") : t("Import")),
+ (0, import_react47.createElement)("button", { type: "button", className: "bt-import-plain", disabled: busy, onClick: onCancel }, t("Cancel"))
)
));
}
@@ -17351,42 +17705,42 @@ function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatu
const active = tabState.active;
const page = useBrowserPages((pages) => (active ? pages[active] : null) ?? EMPTY_PAGE);
const hold = useBrowserHolds?.((map) => bot ? map[bot.id] ?? null : null) ?? null;
- const root = (0, import_react43.useRef)(null);
- const fly = (0, import_react43.useRef)(null);
- const [landed, setLanded] = (0, import_react43.useState)(false);
- const [settling, setSettling] = (0, import_react43.useState)(false);
- const [width, setWidth] = (0, import_react43.useState)(savedWidth);
- const [viewport, setViewport] = (0, import_react43.useState)(() => window.innerWidth);
- const [dragging, setDragging] = (0, import_react43.useState)(false);
- const [resizing, setResizing] = (0, import_react43.useState)(false);
+ const root = (0, import_react47.useRef)(null);
+ const fly = (0, import_react47.useRef)(null);
+ const [landed, setLanded] = (0, import_react47.useState)(false);
+ const [settling, setSettling] = (0, import_react47.useState)(false);
+ const [width, setWidth] = (0, import_react47.useState)(savedWidth);
+ const [viewport, setViewport] = (0, import_react47.useState)(() => window.innerWidth);
+ const [dragging, setDragging] = (0, import_react47.useState)(false);
+ const [resizing, setResizing] = (0, import_react47.useState)(false);
const instant = dragging || resizing;
- const [reading, setReading] = (0, import_react43.useState)(false);
+ const [reading, setReading] = (0, import_react47.useState)(false);
const overlay = overlayAt(view, viewport);
const panelWidth = fitWidth(width ?? (view === "browser" ? DEFAULT_WIDTH : DETAILS_WIDTH), widthRange(view, viewport));
- (0, import_react43.useLayoutEffect)(() => {
+ (0, import_react47.useLayoutEffect)(() => {
if (view === "browser" && width === null) setWidth(DEFAULT_WIDTH);
}, [view, width]);
- (0, import_react43.useLayoutEffect)(() => {
+ (0, import_react47.useLayoutEffect)(() => {
chatRoom.hold(instant);
}, [instant]);
- const [last, setLast] = (0, import_react43.useState)({ view, width: panelWidth });
+ const [last, setLast] = (0, import_react47.useState)({ view, width: panelWidth });
if (last.view !== view || last.width !== panelWidth) {
setLast({ view, width: panelWidth });
if (last.view !== view) setSettling(last.width !== panelWidth && !instant);
}
- const shownView = (0, import_react43.useRef)(view);
- (0, import_react43.useLayoutEffect)(() => {
+ const shownView = (0, import_react47.useRef)(view);
+ (0, import_react47.useLayoutEffect)(() => {
const switched = settling && shownView.current !== view;
shownView.current = view;
if (switched) chatRoom.hold(true);
chatRoom.set(leaving || overlay ? null : panelWidth);
if (switched) chatRoom.hold(false);
}, [view, panelWidth, leaving, overlay]);
- (0, import_react43.useEffect)(() => () => {
+ (0, import_react47.useEffect)(() => () => {
chatRoom.set(null);
chatRoom.hold(false);
}, []);
- (0, import_react43.useEffect)(() => {
+ (0, import_react47.useEffect)(() => {
let timer;
const onResize = () => {
setResizing(true);
@@ -17400,31 +17754,31 @@ function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatu
window.removeEventListener("resize", onResize);
};
}, []);
- (0, import_react43.useEffect)(() => {
+ (0, import_react47.useEffect)(() => {
if (!settling) return void 0;
const timer = setTimeout(() => setSettling(false), SPRING_SHAPE.duration + 40);
return () => clearTimeout(timer);
}, [settling, view]);
- (0, import_react43.useEffect)(() => {
+ (0, import_react47.useEffect)(() => {
const timer = setTimeout(() => setLanded(true), 360);
return () => clearTimeout(timer);
}, []);
- (0, import_react43.useEffect)(() => {
+ (0, import_react47.useEffect)(() => {
if (canBrowse) actions.browserEnsure(bot.id);
}, [bot?.id, canBrowse]);
- (0, import_react43.useEffect)(() => {
+ (0, import_react47.useEffect)(() => {
if (view === "browser" && (active === null || !tabState.ids.includes(active))) actions.setPanelView("details");
}, [view, active, tabState.ids.length]);
- (0, import_react43.useEffect)(() => {
+ (0, import_react47.useEffect)(() => {
if (pane.view === "side" && sideChat === void 0) actions.setPanelView("details");
}, [pane.view, sideChat]);
- (0, import_react43.useEffect)(() => {
+ (0, import_react47.useEffect)(() => {
if (view !== "browser" || leaving) void actions.browserShow?.(null);
}, [view, leaving]);
- (0, import_react43.useEffect)(() => () => {
+ (0, import_react47.useEffect)(() => () => {
void actions.browserShow?.(null);
}, []);
- (0, import_react43.useEffect)(() => {
+ (0, import_react47.useEffect)(() => {
if (!page.readAt || Date.now() - page.readAt > READ_FLASH_MS) return void 0;
setReading(true);
const timer = setTimeout(() => setReading(false), READ_FLASH_MS);
@@ -17467,7 +17821,7 @@ function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatu
return actions[name](...args);
};
}
- (0, import_react43.useLayoutEffect)(() => {
+ (0, import_react47.useLayoutEffect)(() => {
const move = fly.current;
if (!move) return;
fly.current = null;
@@ -17550,7 +17904,7 @@ function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatu
for (const name of ends) grip.addEventListener(name, onEnd);
};
const hasStrip = panelHasStrip(canBrowse, tabState.ids.length, sideChats.length);
- return (0, import_react43.createElement)(
+ return (0, import_react47.createElement)(
"aside",
{
ref: root,
@@ -17568,15 +17922,15 @@ function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatu
if (event.target === event.currentTarget) setLanded(true);
}
},
- leaving || overlay ? null : (0, import_react43.createElement)("div", { className: "bt-panel-grip", role: "separator", "aria-orientation": "vertical", "aria-label": t("Resize panel"), onPointerDown: startResize }),
+ leaving || overlay ? null : (0, import_react47.createElement)("div", { className: "bt-panel-grip", role: "separator", "aria-orientation": "vertical", "aria-label": t("Resize panel"), onPointerDown: startResize }),
// Over the whole window while dragging: the cursor stays a resize cursor and the
// pages underneath (the chat, the guest) see no pointer.
- dragging ? (0, import_react_dom8.createPortal)((0, import_react43.createElement)("div", { className: "bt-drag-shield", "aria-hidden": true }), document.body) : null,
- hasStrip ? (0, import_react43.createElement)(PanelStrip, { bot, subject: pane.id, view, ids: tabState.ids, active, sides: sideChats, side: pane.side, canBrowse, reading, onView: switchView, actions: panelActions, useBrowserPages }) : null,
- view === "browser" && bot ? (0, import_react43.createElement)(BrowserView, { key: `browser:${active}`, bot, tabId: active, leaving, landed: landed && !settling, actions, useBrowserPages, hold }) : view === "side" && sideChat ? (0, import_react43.createElement)("div", { key: `side:${sideChat.id}`, className: "bt-panel-view" }, (0, import_react43.createElement)(SideChatView, { subject: pane.id, chat: sideChat, actions: panelActions })) : (0, import_react43.createElement)(
+ dragging ? (0, import_react_dom8.createPortal)((0, import_react47.createElement)("div", { className: "bt-drag-shield", "aria-hidden": true }), document.body) : null,
+ hasStrip ? (0, import_react47.createElement)(PanelStrip, { bot, subject: pane.id, view, ids: tabState.ids, active, sides: sideChats, side: pane.side, canBrowse, reading, onView: switchView, actions: panelActions, useBrowserPages }) : null,
+ view === "browser" && bot ? (0, import_react47.createElement)(BrowserView, { key: `browser:${active}`, bot, tabId: active, leaving, landed: landed && !settling, actions, useBrowserPages, hold }) : view === "side" && sideChat ? (0, import_react47.createElement)("div", { key: `side:${sideChat.id}`, className: "bt-panel-view" }, (0, import_react47.createElement)(SideChatView, { subject: pane.id, chat: sideChat, actions: panelActions })) : (0, import_react47.createElement)(
"div",
{ key: `details:${pane.id}:${pane.renaming ? "rename" : ""}:${pane.tab ?? ""}`, className: "bt-panel-view" },
- (0, import_react43.createElement)(DetailsDrawer, {
+ (0, import_react47.createElement)(DetailsDrawer, {
sessionId: pane.id,
startRenaming: pane.renaming,
startTab: pane.tab,
@@ -17717,7 +18071,7 @@ var BROWSER_CSS = `
`;
// src/client/overlays.js
-var import_react44 = require("react");
+var import_react48 = require("react");
var import_react_dom9 = require("react-dom");
var DIALOG_EXIT_MS = 160;
var MENU_EXIT_MS3 = 120;
@@ -17726,15 +18080,15 @@ function Overlays({ useRoster, useUi, useSessions, useSessionStatus, useActivity
const ui2 = useUi((value) => value);
useRegistry((value) => value);
const current = useSessions((list) => Object.values(list.byId).find((session) => (session?.retainedBy?.mainView ?? 0) > 0)?.id ?? null);
- const previous = (0, import_react44.useRef)(current);
- (0, import_react44.useEffect)(() => {
+ const previous = (0, import_react48.useRef)(current);
+ (0, import_react48.useEffect)(() => {
if (previous.current === current) return;
previous.current = current;
if (current) actions.followPanel?.(current);
}, [current]);
const open = ui2.details ? { id: ui2.details, view: ui2.view ?? "details", renaming: ui2.renaming, tab: ui2.tab, side: ui2.side } : null;
- const [kept, setKept] = (0, import_react44.useState)(open);
- (0, import_react44.useEffect)(() => {
+ const [kept, setKept] = (0, import_react48.useState)(open);
+ (0, import_react48.useEffect)(() => {
if (open) {
setKept(open);
return void 0;
@@ -17753,17 +18107,17 @@ function Overlays({ useRoster, useUi, useSessions, useSessionStatus, useActivity
const [memory, memoryLeaving] = useLinger(ui2.memory && memoryOwner(ui2.memory) ? ui2.memory : null, DIALOG_EXIT_MS);
const owner = memory ? memoryOwner(memory) : null;
const [menu, menuLeaving] = useLinger(ui2.menu, MENU_EXIT_MS3);
- return (0, import_react44.createElement)(
- import_react44.Fragment,
+ return (0, import_react48.createElement)(
+ import_react48.Fragment,
null,
- pane ? (0, import_react_dom9.createPortal)((0, import_react44.createElement)(BotPanel, { pane, leaving: open === null, roster, actions, useSessions, useSessionStatus, useActivity, useWork, useBrowserTabs, useBrowserPages, useBrowserHolds }), document.body) : null,
- ui2.newChat ? (0, import_react_dom9.createPortal)((0, import_react44.createElement)(NewChat, { key: ui2.newChat, mode: ui2.newChat, roster, actions }), document.body) : null,
- ui2.palette ? (0, import_react_dom9.createPortal)((0, import_react44.createElement)(CommandPalette, { key: ui2.palette.token, start: ui2.palette.query, token: ui2.palette.token, roster, actions, useSessions }), document.body) : null,
- ui2.exchange ? (0, import_react_dom9.createPortal)((0, import_react44.createElement)(ExchangeDialog, { pair: ui2.exchange, roster, actions }), document.body) : null,
- ui2.voice ? (0, import_react_dom9.createPortal)((0, import_react44.createElement)(VoiceMode, { key: ui2.voice, sessionId: ui2.voice, roster, actions, useSessions, useSessionStatus }), document.body) : null,
- menu ? (0, import_react_dom9.createPortal)((0, import_react44.createElement)(ContextMenu, { key: `${menu.kind ?? ""}:${menu.id}:${menu.x}:${menu.y}`, menu, roster, actions, leaving: menuLeaving }), document.body) : null,
- settings ? (0, import_react_dom9.createPortal)((0, import_react44.createElement)(SettingsDialog, { page: settings.page, id: settings.id, roster, actions, useUpdate, leaving: settingsLeaving }), document.body) : null,
- owner ? (0, import_react_dom9.createPortal)((0, import_react44.createElement)(MemoryDialog, { key: owner.id, owner, actions, leaving: memoryLeaving }), document.body) : null
+ pane ? (0, import_react_dom9.createPortal)((0, import_react48.createElement)(BotPanel, { pane, leaving: open === null, roster, actions, useSessions, useSessionStatus, useActivity, useWork, useBrowserTabs, useBrowserPages, useBrowserHolds }), document.body) : null,
+ ui2.newChat ? (0, import_react_dom9.createPortal)((0, import_react48.createElement)(NewChat, { key: ui2.newChat, mode: ui2.newChat, roster, actions }), document.body) : null,
+ ui2.palette ? (0, import_react_dom9.createPortal)((0, import_react48.createElement)(CommandPalette, { key: ui2.palette.token, start: ui2.palette.query, token: ui2.palette.token, roster, actions, useSessions }), document.body) : null,
+ ui2.exchange ? (0, import_react_dom9.createPortal)((0, import_react48.createElement)(ExchangeDialog, { pair: ui2.exchange, roster, actions }), document.body) : null,
+ ui2.voice ? (0, import_react_dom9.createPortal)((0, import_react48.createElement)(VoiceMode, { key: ui2.voice, sessionId: ui2.voice, roster, actions, useSessions, useSessionStatus }), document.body) : null,
+ menu ? (0, import_react_dom9.createPortal)((0, import_react48.createElement)(ContextMenu, { key: `${menu.kind ?? ""}:${menu.id}:${menu.x}:${menu.y}`, menu, roster, actions, leaving: menuLeaving }), document.body) : null,
+ settings ? (0, import_react_dom9.createPortal)((0, import_react48.createElement)(SettingsDialog, { page: settings.page, id: settings.id, roster, actions, useUpdate, leaving: settingsLeaving }), document.body) : null,
+ owner ? (0, import_react_dom9.createPortal)((0, import_react48.createElement)(MemoryDialog, { key: owner.id, owner, actions, leaving: memoryLeaving }), document.body) : null
);
}
@@ -18786,7 +19140,7 @@ function createSwitchWindow(settle) {
}
// src/client/user-message.js
-var import_react45 = require("react");
+var import_react49 = require("react");
var ui = __toESM(require("@deepseek-ai/dsh-client-ui-primitives"), 1);
var canDrawUserMessages = () => typeof ui.projectUserText === "function";
function contentParts(content) {
@@ -18818,38 +19172,38 @@ function userTextParts(text, bots, referenceLabels = []) {
return parts;
}
function UserText({ text, bots, referenceLabels, skillNames, references, actions }) {
- return userTextParts(text, bots, referenceLabels).map((part, index) => part.bot ? (0, import_react45.createElement)(
+ return userTextParts(text, bots, referenceLabels).map((part, index) => part.bot ? (0, import_react49.createElement)(
"button",
{ key: index, type: "button", className: "bt-umention", title: `@${part.bot.name}`, onClick: () => actions.openSession(part.bot.id) },
- (0, import_react45.createElement)(BotMark, { bot: part.bot, size: 16 }),
+ (0, import_react49.createElement)(BotMark, { bot: part.bot, size: 16 }),
part.label
- ) : (0, import_react45.createElement)(import_react45.Fragment, { key: index }, ui.projectUserText(part.text, referenceLabels, skillNames, "skill", references)));
+ ) : (0, import_react49.createElement)(import_react49.Fragment, { key: index }, ui.projectUserText(part.text, referenceLabels, skillNames, "skill", references)));
}
function Attachments({ attachments, renderMessageImages }) {
const compact2 = attachments.length > 1;
- return (0, import_react45.createElement)("div", { className: "bt-uattach" }, attachments.map((block, index) => {
+ return (0, import_react49.createElement)("div", { className: "bt-uattach" }, attachments.map((block, index) => {
if (block.type === "image") {
- return renderMessageImages ? (0, import_react45.createElement)(import_react45.Fragment, { key: index }, renderMessageImages({ images: [{ attachment: block.attachment }], align: "end", compact: compact2 })) : null;
+ return renderMessageImages ? (0, import_react49.createElement)(import_react49.Fragment, { key: index }, renderMessageImages({ images: [{ attachment: block.attachment }], align: "end", compact: compact2 })) : null;
}
const file = block.attachment;
const meta = [ui.fileExtension?.(file.name)?.toUpperCase().slice(0, 8), ui.fileSizeText?.(file.bytes)].filter(Boolean).join(" · ");
- return (0, import_react45.createElement)(
+ return (0, import_react49.createElement)(
"span",
{ key: index, className: "bt-ufile", title: file.name },
- ui.FileTypeIcon ? (0, import_react45.createElement)(ui.FileTypeIcon, { path: file.name, className: "bt-ufile-icon" }) : null,
- (0, import_react45.createElement)("span", { className: "bt-ufile-text" }, (0, import_react45.createElement)("span", { className: "bt-ufile-name" }, file.name), meta ? (0, import_react45.createElement)("span", { className: "bt-ufile-meta" }, meta) : null)
+ ui.FileTypeIcon ? (0, import_react49.createElement)(ui.FileTypeIcon, { path: file.name, className: "bt-ufile-icon" }) : null,
+ (0, import_react49.createElement)("span", { className: "bt-ufile-text" }, (0, import_react49.createElement)("span", { className: "bt-ufile-name" }, file.name), meta ? (0, import_react49.createElement)("span", { className: "bt-ufile-meta" }, meta) : null)
);
}));
}
function CopyButton({ text }) {
- const [copied, setCopied] = (0, import_react45.useState)(false);
+ const [copied, setCopied] = (0, import_react49.useState)(false);
const copy2 = () => {
void navigator.clipboard?.writeText(text).then(() => {
setCopied(true);
setTimeout(() => setCopied(false), 1e3);
});
};
- return (0, import_react45.createElement)("button", { type: "button", className: "bt-tool", "aria-label": copied ? t("Copied") : t("Copy"), title: copied ? t("Copied") : t("Copy"), onClick: copy2 }, copied ? (0, import_react45.createElement)(CheckIcon) : (0, import_react45.createElement)(CopyIcon));
+ return (0, import_react49.createElement)("button", { type: "button", className: "bt-tool", "aria-label": copied ? t("Copied") : t("Copy"), title: copied ? t("Copied") : t("Copy"), onClick: copy2 }, copied ? (0, import_react49.createElement)(CheckIcon) : (0, import_react49.createElement)(CopyIcon));
}
var clock3 = (time) => typeof time === "number" ? new Date(time).toLocaleTimeString(dateLocale(), { hour: "numeric", minute: "2-digit" }) : void 0;
function UserMessageCell({ node, sessionId, useRoster, actions, renderMessageImages, openFile, openSkill }) {
@@ -18861,10 +19215,10 @@ function UserMessageCell({ node, sessionId, useRoster, actions, renderMessageIma
const steering = node.kind === "steering";
const groupTime = roster.roomsById?.[sessionId] && Number.isFinite(data.time) ? messageClock(data.time) : void 0;
const { shown, folded, control } = useFold(text, { markdown: false });
- const body = (0, import_react45.createElement)(UserText, { text: shown, bots: mentionableBots(roster, sessionId), referenceLabels, skillNames: data.skillNames ?? [], references, actions });
- const row = (0, import_react45.useRef)(null);
- const [toolsOpen, setToolsOpen] = (0, import_react45.useState)(false);
- (0, import_react45.useEffect)(() => {
+ const body = (0, import_react49.createElement)(UserText, { text: shown, bots: mentionableBots(roster, sessionId), referenceLabels, skillNames: data.skillNames ?? [], references, actions });
+ const row = (0, import_react49.useRef)(null);
+ const [toolsOpen, setToolsOpen] = (0, import_react49.useState)(false);
+ (0, import_react49.useEffect)(() => {
if (!toolsOpen) return void 0;
const onDown = (event) => {
if (!row.current?.contains(event.target)) setToolsOpen(false);
@@ -18880,24 +19234,24 @@ function UserMessageCell({ node, sessionId, useRoster, actions, renderMessageIma
if (!noHover() || event.target instanceof Element && event.target.closest("a,button,input,textarea,select,pre,code,[role=button],[role=link]")) return;
setToolsOpen((value) => !value);
};
- return (0, import_react45.createElement)(
+ return (0, import_react49.createElement)(
"div",
{ ref: row, className: "bt-umsg", "data-steering": steering || void 0 },
- (0, import_react45.createElement)(
+ (0, import_react49.createElement)(
"div",
{ className: "bt-ustack" },
- attachments.length > 0 ? (0, import_react45.createElement)(Attachments, { attachments, renderMessageImages }) : null,
- text !== "" || rest.length > 0 ? (0, import_react45.createElement)(
+ attachments.length > 0 ? (0, import_react49.createElement)(Attachments, { attachments, renderMessageImages }) : null,
+ text !== "" || rest.length > 0 ? (0, import_react49.createElement)(
"div",
{ className: "bt-ubody", title: clock3(data.time), "data-folded": folded || void 0, onClick: tapTools },
- control ? (0, import_react45.createElement)("div", { className: "bt-fold-body" }, body) : body,
+ control ? (0, import_react49.createElement)("div", { className: "bt-fold-body" }, body) : body,
control,
- rest.map((block, index) => ui.JsonBlock ? (0, import_react45.createElement)(ui.JsonBlock, { key: index, label: t("Content"), payload: block }) : null)
+ rest.map((block, index) => ui.JsonBlock ? (0, import_react49.createElement)(ui.JsonBlock, { key: index, label: t("Content"), payload: block }) : null)
) : null,
- referenceLabels.length > 0 ? (0, import_react45.createElement)("div", { className: "bt-urefs" }, t("Referenced {labels}", { labels: referenceLabels.join(t(", ")) })) : null,
- groupTime ? (0, import_react45.createElement)("div", { className: "bt-utime", title: clockLabel(data.time) }, groupTime) : null
+ referenceLabels.length > 0 ? (0, import_react49.createElement)("div", { className: "bt-urefs" }, t("Referenced {labels}", { labels: referenceLabels.join(t(", ")) })) : null,
+ groupTime ? (0, import_react49.createElement)("div", { className: "bt-utime", title: clockLabel(data.time) }, groupTime) : null
),
- text === "" ? null : (0, import_react45.createElement)("div", { className: "bt-utools", "data-open": toolsOpen || void 0 }, (0, import_react45.createElement)(CopyButton, { text }))
+ text === "" ? null : (0, import_react49.createElement)("div", { className: "bt-utools", "data-open": toolsOpen || void 0 }, (0, import_react49.createElement)(CopyButton, { text }))
);
}
var USER_MESSAGE_CSS = `
@@ -19731,7 +20085,7 @@ function apply(ctx) {
() => installCompiledStyles(ABOUT_CSS, "about"),
() => installCompiledStyles(MEMBER_CSS, "members"),
() => installCompiledStyles(USER_MESSAGE_CSS, "user-messages"),
- () => installCompiledStyles(WIDGET_CSS, "widgets"),
+ () => installCompiledStyles(WIDGET_CSS2, "widgets"),
() => installCompiledStyles(HANDOFF_CSS, "handoff"),
() => installCompiledStyles(SIDE_CSS, "side"),
// Strip and panel styles also serve the side-chat tabs, which need no bridge.
diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.js
index 196ec5f8..1f9f57de 100644
--- a/ds-bot/src/client/i18n.js
+++ b/ds-bot/src/client/i18n.js
@@ -636,6 +636,7 @@ const ZH = {
'Copy data': '复制数据',
'Download image': '下载图片',
'This view tried to open a page and was stopped.': '这个视图想打开一个网页,已被拦下。',
+ 'Send to Bot': '发给 Bot',
// Secrets
'All Bots': '所有 Bot',
diff --git a/ds-bot/src/client/widget-cell.js b/ds-bot/src/client/widget-cell.js
index d5182a01..c7ff30b4 100644
--- a/ds-bot/src/client/widget-cell.js
+++ b/ds-bot/src/client/widget-cell.js
@@ -1,411 +1,25 @@
-import { createElement as h, Fragment, useEffect, useId, useRef, useState } from 'react'
+import { createElement as h, useRef, useState } from 'react'
import { MarkdownText } from './dsh-primitives.js'
-import { CheckIcon, CloseIcon, CopyIcon, DotsIcon, DownloadIcon, InfoIcon } from './icons.js'
import { t } from './i18n.js'
-import { AnsweredCell, keyLetter, useOptionKeys } from './questions.js'
+import { AnsweredCell } from './questions.js'
import { useDockHold } from './card-hold.js'
import { SettledHandoff } from './handoff-card.js'
import { heldCardKey } from './sources.js'
-import { Segmented } from './motion.js'
-import { CHART_CSS, TableIcon, WidgetChart } from './widget-chart.js'
-import { HTML_CSS, HtmlFrame } from './widget-html.js'
-import { asText, checkShownView, choiceValue, inputDefault, resolve, viewInputs, viewScope } from '../shared/views.js'
+import { WidgetCard, ViewUi, DEEP_UI_CSS } from 'dsh-deep-ui/react'
+import { checkShownView } from 'dsh-deep-ui/core'
-// -------------------------------------------------------------------------
-// Views (show_view): a Bot draws a declarative blueprint — text, numbers, tables,
-// charts, inputs, and answers it waits for — as part of its reply. Nothing
-// model-written executes in the page: every node maps to one of the components
-// below, formulas go through the shared evaluator, and html runs in a sandboxed
-// frame. Inputs keep their values in the page only. A view that awaits a reply
-// lives in state.views like an ask_user question; any other renders from the
-// call's arguments.
+import { WidgetView as CoreWidgetView, ViewMenuList as CoreViewMenuList } from 'dsh-deep-ui/react'
-const mdLabels = () => ({ code: { copyLabel: t('Copy'), copiedLabel: t('Copied') }, footnotes: t('Footnotes') })
-const TONES = ['good', 'warn', 'bad']
-const CALLOUT_TONES = ['info', 'good', 'warn', 'bad']
+// The core components draw with the host's labels: the submit keeps ds-bot's
+// wording, the rest resolve through ds-bot's dictionary.
+const viewT = (key, params) => (key === 'Send' ? t('Send to Bot') : t(key, params))
+const VIEW_UI = { t: viewT, Markdown: MarkdownText }
+const Card = props => h(ViewUi.Provider, { value: VIEW_UI }, h(WidgetCard, props))
+const withUi = Component => props => h(ViewUi.Provider, { value: VIEW_UI }, h(Component, props))
-const optionsOf = node => (Array.isArray(node?.options) ? node.options : [])
- .map(option => (typeof option === 'string' ? { label: option } : option))
- .filter(option => option !== null && typeof option === 'object' && option.label !== undefined)
-const fieldsOf = node => (Array.isArray(node?.fields) ? node.fields : [])
- .filter(field => field !== null && typeof field === 'object' && field.id !== undefined)
-const cellText = value => (value === null || value === undefined ? '' : typeof value === 'object' ? JSON.stringify(value) : asText(value))
-const NUMERIC_CELL = /^[-+]?[\d.,]+\s?(%|[a-zA-Z]{1,4})?$/
-
-const countType = (node, type) => {
- if (node === null || typeof node !== 'object') return 0
- const children = Array.isArray(node.children) ? node.children : []
- return (node.type === type ? 1 : 0) + children.reduce((sum, child) => sum + countType(child, type), 0)
-}
-const ANSWER_TYPES = new Set(['options', 'confirm', 'form', 'submit', 'slider', 'choice', 'toggle', 'number'])
-const hasControls = (node) => {
- if (node === null || typeof node !== 'object') return false
- if (ANSWER_TYPES.has(node.type)) return true
- return Array.isArray(node.children) && node.children.some(hasControls)
-}
-
-// The values an answer carries belong to the component whose id is its action.
-const answerValues = (answer, node) => (answer?.action === node.id ? answer.values : undefined)
-
-function OptionsInput({ node, onSubmit, keys, busy = false }) {
- const [picked, setPicked] = useState([])
- const options = optionsOf(node)
- const multi = node.multi === true
- const choose = (label) => {
- if (busy) return
- if (multi) {
- setPicked(current => (current.includes(label) ? current.filter(item => item !== label) : [...current, label]))
- return
- }
- onSubmit?.(node.id, { selected: [label] })
- }
- const submit = () => { if (!busy && picked.length > 0) onSubmit?.(node.id, { selected: picked }) }
- const ownRef = useRef(null)
- const hints = useOptionKeys(busy || !keys ? 0 : options.length, index => choose(options[index].label), ownRef)
- return h(Fragment, null,
- h('div', { className: 'bt-q-list', role: 'group' }, options.map((option, index) => {
- const selected = multi && picked.includes(option.label)
- return h('button', {
- key: option.label, type: 'button', className: 'bt-q-opt', disabled: busy,
- 'aria-pressed': multi ? selected : undefined,
- 'aria-keyshortcuts': hints ? keyLetter(index).toLowerCase() : undefined,
- onClick: () => choose(option.label),
- },
- hints ? h('span', { className: 'bt-key', 'aria-hidden': true }, keyLetter(index)) : null,
- h('span', { className: 'bt-q-body' },
- h('span', { className: 'bt-q-label' }, option.label),
- option.description ? h('span', { className: 'bt-q-desc' }, option.description) : null),
- selected ? h('span', { className: 'bt-q-check', title: t('Selected') }, h(CheckIcon)) : null)
- })),
- multi ? h('div', { className: 'bt-q-foot' },
- h('button', { type: 'button', className: 'bt-q-submit', disabled: busy || picked.length === 0, onClick: submit }, t('Submit'))) : null)
-}
-
-function SettledOptions({ node, answer }) {
- const selected = answerValues(answer, node)?.selected
- const chosen = Array.isArray(selected) ? selected : []
- return h('div', { className: 'bt-q-list', role: 'group', 'aria-label': t('Your answer') },
- optionsOf(node).map(option => h('div', { key: option.label, className: 'bt-q-opt' },
- h('span', { className: 'bt-q-body' },
- h('span', { className: 'bt-q-label' }, option.label),
- option.description ? h('span', { className: 'bt-q-desc' }, option.description) : null),
- chosen.includes(option.label) ? h('span', { className: 'bt-q-check', title: t('Selected') }, h(CheckIcon)) : null)))
-}
-
-function ConfirmInput({ node, onSubmit, busy = false }) {
- return h('div', { className: 'bt-q-foot' },
- h('button', { type: 'button', className: 'bt-q-btn', disabled: busy, onClick: () => onSubmit?.(node.id, { confirmed: false }) }, node.cancelLabel ?? t('Cancel')),
- h('button', { type: 'button', className: 'bt-q-submit', disabled: busy, onClick: () => onSubmit?.(node.id, { confirmed: true }) }, node.confirmLabel ?? t('Confirm')))
-}
-
-function SettledConfirm({ node, answer }) {
- const confirmed = answerValues(answer, node)?.confirmed
- if (confirmed !== true && confirmed !== false) {
- return h('div', { className: 'bt-q-foot' },
- h('button', { type: 'button', className: 'bt-q-btn', disabled: true }, node.cancelLabel ?? t('Cancel')),
- h('button', { type: 'button', className: 'bt-q-submit', disabled: true }, node.confirmLabel ?? t('Confirm')))
- }
- const label = confirmed ? (node.confirmLabel ?? t('Confirm')) : (node.cancelLabel ?? t('Cancel'))
- return h('span', { className: 'bt-q-badge' }, label)
-}
-
-function FormInput({ node, onSubmit, busy = false }) {
- const fields = fieldsOf(node)
- const [draft, setDraft] = useState({})
- const submit = () => { if (!busy) onSubmit?.(node.id, { fields: Object.fromEntries(fields.map(field => [field.id, draft[field.id] ?? ''])) }) }
- return h('form', {
- className: 'bt-widget-form',
- onSubmit: (event) => { event.preventDefault(); submit() },
- },
- fields.map(field => h('label', { key: field.id, className: 'bt-widget-field' },
- h('span', { className: 'bt-widget-field-label' }, field.label),
- h('span', { className: 'bt-q-field' },
- h('input', {
- className: 'bt-q-input', type: 'text', value: draft[field.id] ?? '',
- autoComplete: 'off', spellCheck: false, readOnly: busy,
- 'aria-label': field.label, placeholder: field.placeholder ?? undefined,
- onChange: (event) => { if (!busy) setDraft(current => ({ ...current, [field.id]: event.target.value })) },
- onKeyDown: (event) => {
- if (event.key !== 'Enter' || event.nativeEvent.isComposing) return
- event.preventDefault()
- submit()
- },
- })))),
- h('div', { className: 'bt-q-foot' }, h('button', { type: 'submit', className: 'bt-q-submit', disabled: busy }, node.submitLabel ?? t('Submit'))))
-}
-
-function SettledForm({ node, answer }) {
- const fields = answerValues(answer, node)?.fields
- const values = fields !== null && typeof fields === 'object' ? fields : {}
- return h('div', { className: 'bt-widget-form' },
- fieldsOf(node).map(field => h('label', { key: field.id, className: 'bt-widget-field' },
- h('span', { className: 'bt-widget-field-label' }, field.label),
- h('span', { className: 'bt-q-field' },
- h('input', { className: 'bt-q-input', type: 'text', value: values[field.id] ?? '', disabled: true, readOnly: true, 'aria-label': field.label })))))
-}
-
-function SubmitInput({ node, ctx }) {
- if (ctx.settled) return null
- return h('div', { className: 'bt-q-foot' },
- h('button', { type: 'button', className: 'bt-q-submit', disabled: ctx.busy, onClick: () => ctx.onSubmit?.(node.id, {}) }, node.label || t('Send')))
-}
-
-function WidgetTable({ node, lookup }) {
- const columns = (Array.isArray(node.columns) ? node.columns : []).filter(column => column !== null && typeof column === 'object')
- const rows = (Array.isArray(node.rows) ? node.rows : []).map(row => (Array.isArray(row) ? row : []).map(cell => resolve(cell, lookup, '')))
- // A column of numbers lines up on the right.
- const numeric = columns.map((_, index) => {
- const cells = rows.map(row => row[index]).filter(cell => cell !== undefined && cell !== '')
- return cells.length > 0 && cells.every(cell => typeof cell === 'number' || (typeof cell === 'string' && NUMERIC_CELL.test(cell.trim())))
- })
- return h('div', { className: 'bt-widget-table' },
- h('table', null,
- h('thead', null, h('tr', null, columns.map((column, index) => h('th', { key: column.key ?? index, scope: 'col', className: numeric[index] ? 'bt-num' : undefined }, column.label)))),
- h('tbody', null, rows.map((row, rowIndex) => h('tr', { key: rowIndex },
- columns.map((column, columnIndex) => h('td', { key: column.key ?? columnIndex, className: numeric[columnIndex] ? 'bt-num' : undefined }, cellText(row[columnIndex]))))))))
-}
-
-function WidgetProgress({ node, lookup }) {
- let percent
- if (node.percent !== undefined) percent = Number(resolve(node.percent, lookup, 0))
- else {
- const max = Number(resolve(node.max, lookup, 0))
- percent = max > 0 ? (Number(resolve(node.value, lookup, 0)) / max) * 100 : 0
- }
- percent = Math.max(0, Math.min(100, Number.isFinite(percent) ? percent : 0))
- const tone = resolve(node.tone, lookup)
- const right = node.valueLabel !== undefined ? asText(resolve(node.valueLabel, lookup, '')) : `${Math.round(percent)}%`
- return h('div', { className: 'bt-widget-progress', 'data-tone': TONES.includes(tone) ? tone : undefined },
- h('span', { className: 'bt-widget-progress-label' }, h('span', { className: 'bt-widget-progress-name' }, node.label), h('span', null, right)),
- h('div', {
- className: 'bt-widget-progress-track', role: 'progressbar',
- 'aria-valuenow': Math.round(percent), 'aria-valuemin': 0, 'aria-valuemax': 100, 'aria-label': node.label ?? t('Progress'), 'aria-valuetext': right,
- }, h('div', { className: 'bt-widget-progress-fill', style: { width: `${percent}%` } })))
-}
-
-function WidgetMetric({ node, lookup }) {
- const tone = resolve(node.tone, lookup)
- const caption = node.caption === undefined ? '' : asText(resolve(node.caption, lookup, ''))
- return h('div', { className: 'bt-widget-metric', 'data-tone': TONES.includes(tone) ? tone : undefined },
- h('span', { className: 'bt-widget-metric-label' }, node.label),
- h('span', { className: 'bt-widget-metric-value' }, asText(resolve(node.value, lookup, '—'))),
- caption !== '' ? h('span', { className: 'bt-view-caption' }, caption) : null)
-}
-
-function WidgetCallout({ node, lookup }) {
- const tone = resolve(node.tone, lookup)
- return h('div', { className: 'bt-view-callout', 'data-tone': CALLOUT_TONES.includes(tone) ? tone : 'info' },
- h('span', { className: 'bt-view-callout-icon', 'aria-hidden': true }, h(InfoIcon)),
- h('div', { className: 'bt-view-callout-text' }, h(MarkdownText, { text: asText(resolve(node.text, lookup, '')), labels: mdLabels(), variant: 'compact' })))
-}
-
-const LinkIcon = () => h('svg', { width: 12, height: 12, viewBox: '0 0 20 20', fill: 'none', stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true },
- h('path', { d: 'M8.5 11.5l3-3' }), h('path', { d: 'M7 9.5L5.5 11a2.5 2.5 0 0 0 3.5 3.5L10.5 13' }), h('path', { d: 'M13 10.5l1.5-1.5A2.5 2.5 0 0 0 11 5.5L9.5 7' }))
-
-function WidgetSources({ node }) {
- const items = (Array.isArray(node.items) ? node.items : []).filter(item => typeof item?.url === 'string' && /^https?:\/\//i.test(item.url))
- return h('div', { className: 'bt-view-sources', role: 'list', 'aria-label': t('Sources') },
- items.map((item, index) => h('a', { key: index, role: 'listitem', className: 'bt-view-source', href: item.url, target: '_blank', rel: 'noopener noreferrer', title: item.url }, h(LinkIcon), item.label)))
-}
-
-// -------------------------------------------------------------------------
-// Inputs. Their values stay in the page; formulas read them on every change.
-
-function InputHead({ id, label, value }) {
- return h('div', { className: 'bt-view-input-head' },
- h('label', { htmlFor: id, className: 'bt-view-input-label' }, label),
- value !== undefined ? h('output', { htmlFor: id, className: 'bt-view-input-value' }, value) : null)
-}
-
-const withUnit = (value, unit) => `${asText(value)}${unit ? ` ${unit}` : ''}`
-const grouped = value => (typeof value === 'number' && Number.isFinite(value) ? value.toLocaleString('en-US', { maximumFractionDigits: 6 }) : asText(value))
-
-function SliderInput({ node, ctx }) {
- const id = useId()
- const value = Number(ctx.values[node.id])
- const percent = node.max > node.min ? ((value - node.min) / (node.max - node.min)) * 100 : 0
- return h('div', { className: 'bt-view-input' },
- h(InputHead, { id, label: node.label, value: withUnit(grouped(value), node.unit) }),
- h('input', {
- id, type: 'range', className: 'bt-view-range', min: node.min, max: node.max, step: node.step ?? 'any', value,
- disabled: ctx.locked, style: { '--bt-fill': `${percent}%` },
- onChange: event => ctx.setInput(node.id, Number(event.target.value)),
- }))
-}
-
-function NumberInput({ node, ctx }) {
- const id = useId()
- const [draft, setDraft] = useState(null)
- const value = ctx.values[node.id]
- const accept = (raw) => {
- setDraft(raw)
- const next = Number(raw)
- if (raw.trim() === '' || !Number.isFinite(next)) return
- if ((node.min !== undefined && next < node.min) || (node.max !== undefined && next > node.max)) return
- ctx.setInput(node.id, next)
- }
- return h('div', { className: 'bt-view-input' },
- h(InputHead, { id, label: node.label }),
- h('span', { className: 'bt-q-field bt-view-number' },
- h('input', {
- id, className: 'bt-q-input', type: 'number', inputMode: 'decimal', value: draft ?? asText(value),
- min: node.min, max: node.max, step: node.step ?? 'any', disabled: ctx.locked,
- onChange: event => accept(event.target.value), onBlur: () => setDraft(null),
- }),
- node.unit ? h('span', { className: 'bt-view-unit' }, node.unit) : null))
-}
-
-// A few short options sit side by side; more, or longer ones, stack as a list.
-function ChoiceInput({ node, ctx }) {
- const labelId = useId()
- const options = optionsOf(node)
- const current = ctx.values[node.id]
- const side = options.length <= 4 && options.every(option => [...option.label].length <= 14)
- const pick = option => () => { if (!ctx.locked) ctx.setInput(node.id, choiceValue(option)) }
- return h('div', { className: 'bt-view-input' },
- h('span', { className: 'bt-view-input-label', id: labelId }, node.label),
- side
- ? h(Segmented, { label: node.label, value: options.findIndex(option => choiceValue(option) === current), className: 'bt-view-seg' },
- options.map(option => h('button', { key: option.label, type: 'button', 'aria-pressed': choiceValue(option) === current, disabled: ctx.locked, onClick: pick(option) }, option.label)))
- : h('div', { className: 'bt-view-radios', role: 'radiogroup', 'aria-labelledby': labelId },
- options.map(option => h('button', {
- key: option.label, type: 'button', role: 'radio', className: 'bt-view-radio',
- 'aria-checked': choiceValue(option) === current, disabled: ctx.locked, onClick: pick(option),
- }, h('span', { className: 'bt-view-radio-dot', 'aria-hidden': true }), option.label))))
-}
-
-function ToggleInput({ node, ctx }) {
- const on = ctx.values[node.id] === true
- return h('div', { className: 'bt-view-toggle' },
- h('span', { className: 'bt-view-input-label' }, node.label),
- h('button', { type: 'button', role: 'switch', className: 'bt-switch', 'aria-checked': on, 'aria-label': node.label, disabled: ctx.locked, onClick: () => ctx.setInput(node.id, !on) },
- h('span', { className: 'bt-switch-knob', 'aria-hidden': true })))
-}
-
-// One blueprint node. Unknown types render nothing: the host validates the
-// blueprint, so what arrives here is known or safely ignored.
-function WidgetNode({ node, ctx }) {
- if (node === null || typeof node !== 'object') return null
- const { lookup } = ctx
- switch (node.type) {
- case 'stack':
- case 'row': {
- const children = Array.isArray(node.children) ? node.children : []
- return h('div', { className: node.type === 'row' ? 'bt-view-row' : 'bt-widget-stack' },
- children.map((child, index) => h(WidgetNode, { key: child?.id ?? index, node: child, ctx })))
- }
- case 'text': {
- const text = h(MarkdownText, { text: asText(resolve(node.text, lookup, '')), labels: mdLabels(), variant: 'compact' })
- return node.tone === 'muted' ? h('div', { className: 'bt-view-muted' }, text) : text
- }
- case 'metric': return h(WidgetMetric, { node, lookup })
- case 'table': return h(WidgetTable, { node, lookup })
- case 'chart': return h(WidgetChart, { node, lookup, registerChart: ctx.registerChart, refreshCharts: ctx.refreshCharts })
- case 'progress': return h(WidgetProgress, { node, lookup })
- case 'callout': return h(WidgetCallout, { node, lookup })
- case 'sources': return h(WidgetSources, { node })
- case 'html': return h(HtmlFrame, { node })
- case 'slider': return h(SliderInput, { node, ctx })
- case 'number': return h(NumberInput, { node, ctx })
- case 'choice': return h(ChoiceInput, { node, ctx })
- case 'toggle': return h(ToggleInput, { node, ctx })
- case 'submit': return h(SubmitInput, { node, ctx })
- case 'options': return ctx.settled ? h(SettledOptions, { node, answer: ctx.answer }) : h(OptionsInput, { node, onSubmit: ctx.onSubmit, keys: ctx.keys, busy: ctx.busy })
- case 'confirm': return ctx.settled ? h(SettledConfirm, { node, answer: ctx.answer }) : h(ConfirmInput, { node, onSubmit: ctx.onSubmit, busy: ctx.busy })
- case 'form': return ctx.settled ? h(SettledForm, { node, answer: ctx.answer }) : h(FormInput, { node, onSubmit: ctx.onSubmit, busy: ctx.busy })
- default: return null
- }
-}
-
-// A whole blueprint. Inputs start where the Bot set them; an answered view shows
-// them as they were sent. Every answer carries the inputs' values. Letter keys
-// answer a lone options block from the keyboard; with more than one in a card the
-// same letter would hit both.
-export function WidgetView({ view, onSubmit, settled = false, answer = null, busy = false, registerChart, refreshCharts }) {
- const inputs = viewInputs(view)
- const [values, setValues] = useState(() => Object.fromEntries(inputs.map(node => [node.id, inputDefault(node)])))
- const sent = answer?.values?.inputs
- const current = settled && sent !== null && typeof sent === 'object' ? { ...values, ...sent } : values
- const submit = (action, extra) => onSubmit?.(action, inputs.length > 0 ? { ...extra, inputs: current } : extra)
- const ctx = {
- onSubmit: submit, settled, answer, busy, keys: !settled && countType(view, 'options') === 1,
- lookup: viewScope(view, current), values: current, locked: settled || busy,
- setInput: (id, value) => setValues(before => ({ ...before, [id]: value })), registerChart, refreshCharts,
- }
- return h(WidgetNode, { node: view, ctx })
-}
-
-// A chart keeps its actions (table view, copy, save) in the card's ⋯ menu: each
-// chart registers a handle in mount order and bumps the card so a table switch
-// shows in the open menu's wording.
-function useChartHandles() {
- const [, bump] = useState(0)
- const charts = useRef(new Map())
- const fns = useRef(null)
- if (fns.current === null) {
- const refresh = () => bump(value => value + 1)
- fns.current = {
- registerChart: (key, handle) => {
- charts.current.set(key, handle)
- refresh()
- return () => { charts.current.delete(key); refresh() }
- },
- refreshCharts: refresh,
- }
- }
- return { charts: [...charts.current.values()], ...fns.current }
-}
-
-// The dropdown's items: one flat list for a lone chart, one labelled group per
-// chart otherwise.
-export function ViewMenuList({ charts, pick }) {
- return h('div', { className: 'bt-menu bt-view-menu', role: 'menu' },
- charts.map((chart, index) => h(Fragment, { key: index },
- charts.length > 1 ? h(Fragment, null,
- index > 0 ? h('div', { className: 'bt-menu-sep', role: 'separator' }) : null,
- h('div', { className: 'bt-view-menu-label' }, chart.label ?? t('Chart {n}', { n: index + 1 }))) : null,
- h('button', { type: 'button', role: 'menuitem', onClick: pick(chart.toggleTable) }, h(TableIcon), chart.asTable ? t('View as chart') : t('View as table')),
- h('button', { type: 'button', role: 'menuitem', onClick: pick(chart.copy) }, h(CopyIcon), t('Copy data')),
- h('button', { type: 'button', role: 'menuitem', onClick: pick(chart.save) }, h(DownloadIcon), t('Download image')))))
-}
-
-function ViewMenu({ charts }) {
- const [open, setOpen] = useState(false)
- const root = useRef(null)
- useEffect(() => {
- if (!open) return undefined
- const away = (event) => { if (!root.current?.contains(event.target)) setOpen(false) }
- const key = (event) => { if (event.key === 'Escape') setOpen(false) }
- document.addEventListener('pointerdown', away, true)
- document.addEventListener('keydown', key)
- return () => { document.removeEventListener('pointerdown', away, true); document.removeEventListener('keydown', key) }
- }, [open])
- const pick = run => () => { setOpen(false); run() }
- return h('div', { ref: root, className: 'bt-view-tools', 'data-open': open ? '' : undefined },
- h('button', { type: 'button', className: 'bt-view-more', 'aria-label': t('Chart options'), 'aria-haspopup': 'menu', 'aria-expanded': open, onClick: () => setOpen(value => !value) }, h(DotsIcon)),
- open ? h(ViewMenuList, { charts, pick }) : null)
-}
-
-// What every view wears. A view with controls is a light card; one that only shows
-// sits in the reply without a frame. The title is an optional small heading, and a
-// view that still waits for its answer has a dismiss button.
-function WidgetCard({ title, view, onSubmit, onDismiss, busy = false, raised = false, settled = false, answer = null }) {
- const titleId = useId()
- const { charts, registerChart, refreshCharts } = useChartHandles()
- const framed = raised || hasControls(view)
- const className = ['bt-view', framed ? 'bt-q' : 'bt-view-bare', settled ? 'bt-q-settled' : '', raised ? 'bt-q-raised' : ''].filter(Boolean).join(' ')
- const head = title || onDismiss || countType(view, 'chart') > 0
- ? h('div', { className: 'bt-view-head' },
- title ? h('p', { className: 'bt-view-title', id: titleId }, title) : h('span', { className: 'bt-view-title' }),
- countType(view, 'chart') > 0 ? h(ViewMenu, { charts }) : null,
- onDismiss ? h('button', { type: 'button', className: 'bt-q-x', 'aria-label': t('Dismiss view'), title: t('Dismiss'), onClick: onDismiss, disabled: busy }, h(CloseIcon)) : null)
- : null
- return h('div', {
- className, role: 'group', 'aria-labelledby': title ? titleId : undefined, 'aria-label': title ? undefined : t('View'), 'aria-busy': busy || undefined,
- },
- head,
- h('div', { className: 'bt-view-body' }, h(WidgetView, { view, onSubmit, settled, answer, busy, registerChart, refreshCharts })))
-}
+// Direct renders (tests, history) still see ds-bot's labels.
+export const WidgetView = withUi(CoreWidgetView)
+export const ViewMenuList = withUi(CoreViewMenuList)
// A view waiting for its answer, inline at its call or raised in the dock. Like a
// pending question it hides on submit and comes back if the reply fails.
@@ -428,7 +42,7 @@ export function PendingView({ sessionId, view, actions, inline }) {
// back with what the user had typed or picked. The inputs stay busy meanwhile, so a
// letter key cannot answer a hidden card.
return h('div', { className: inline ? 'bt-q-inline' : 'bt-q-dock', style: flying ? { display: 'none' } : undefined, onFocusCapture: hold, onPointerDownCapture: hold },
- h(WidgetCard, { key: view.id, title: view.title ?? '', view: view.view, onSubmit, onDismiss, busy: flying, raised: !inline }))
+ h(Card, { key: view.id, title: view.title ?? '', view: view.view, onSubmit, onDismiss, busy: flying, raised: !inline }))
}
// The show_view call in the transcript.
@@ -451,7 +65,7 @@ export function WidgetCell({ sessionId, callId, args, done, isError, roster, act
if (shown.error !== undefined || shown.interactive || args?.value?.('await_reply') === true) {
return h('span', { className: 'bt-q-gone', hidden: true })
}
- return h('div', { className: 'bt-q-inline' }, h(WidgetCard, { title: shown.title, view: shown.view }))
+ return h('div', { className: 'bt-q-inline' }, h(Card, { title: shown.title, view: shown.view }))
}
// Views asked by a call the transcript does not draw wait above the composer,
@@ -477,7 +91,7 @@ export function AnsweredView({ node }) {
if (view === null || typeof view !== 'object' || view.view === undefined) return null
const answers = Array.isArray(payload.answers) ? payload.answers : []
const answer = answers.find(entry => entry?.id === view.id) ?? answers[0] ?? null
- return h('div', { className: 'bt-q-inline' }, h(WidgetCard, { title: view.title ?? '', view: view.view, settled: true, answer }))
+ return h('div', { className: 'bt-q-inline' }, h(Card, { title: view.title ?? '', view: view.view, settled: true, answer }))
}
// A question reply node carries either questions (data.questions), a view answer or
@@ -498,100 +112,20 @@ export function AnsweredReply({ node }) {
return h(AnsweredCell, { node })
}
-export const WIDGET_CSS = `
-.bt-view{min-width:0}
-.bt-view-bare{display:flex;flex-direction:column;gap:8px;width:100%;color:var(--bt-ink);font-family:var(--bt-font);animation:bt-veil-in .2s ease-out backwards}
-.bt-view-head{display:flex;align-items:flex-start;gap:8px;min-width:0}
-.bt-view-title{flex:1 1 0;min-width:0;margin:0;font-size:13px;line-height:18px;font-weight:500;color:var(--bt-ink);overflow-wrap:anywhere}
-.bt-q-settled .bt-view-title{color:var(--bt-ink-2)}
-.bt-view-tools{position:relative;flex:none;align-self:flex-start;opacity:0;transition:opacity .12s ease}
-.bt-view:hover .bt-view-tools,.bt-view-tools:focus-within,.bt-view-tools[data-open]{opacity:1}
-@media (hover:none){.bt-view-tools{opacity:1}}
-.bt-view-more{width:28px;height:28px;padding:0;border:0;border-radius:50%;background:none;color:var(--bt-ink-2);display:flex;align-items:center;justify-content:center;cursor:pointer;transition:background-color .12s ease,color .12s ease}
-.bt-view-more:hover,.bt-view-tools[data-open] .bt-view-more{background:var(--bt-hover);color:var(--bt-ink)}
-.bt-view-more:focus-visible{outline:2px solid var(--bt-accent);outline-offset:1px}
-.bt-view-more svg{width:16px;height:16px}
-.bt-menu.bt-view-menu{position:absolute;top:32px;right:0;--bt-origin:top right;min-width:180px}
-.bt-menu.bt-view-menu button{gap:8px}
-.bt-view-menu-label{padding:2px 8px;font-size:11px;line-height:14px;color:var(--bt-ink-3);white-space:nowrap}
-.bt-view-body{min-width:0}
-.bt-widget-stack{display:flex;flex-direction:column;gap:12px;min-width:0}
-.bt-view-row{display:flex;flex-wrap:wrap;gap:12px 24px;min-width:0}
-.bt-view-row>*{flex:1 1 160px;min-width:0}
-.bt-widget-metric{display:flex;flex-direction:column;gap:1px;min-width:0}
-.bt-widget-metric-label{font-size:12px;line-height:16px;color:var(--bt-ink-2)}
-.bt-widget-metric-value{font-size:22px;line-height:28px;font-weight:600;font-variant-numeric:tabular-nums;color:var(--bt-ink);overflow-wrap:anywhere}
-.bt-widget-metric[data-tone=good] .bt-widget-metric-value{color:var(--bt-green)}
-.bt-widget-metric[data-tone=warn] .bt-widget-metric-value{color:var(--bt-star)}
-.bt-widget-metric[data-tone=bad] .bt-widget-metric-value{color:var(--bt-danger)}
-.bt-view-caption{font-size:12px;line-height:16px;color:var(--bt-ink-2);overflow-wrap:anywhere}
-.bt-view-muted{font-size:12px;line-height:16px;color:var(--bt-ink-2)}
-.bt-view-muted *{font-size:inherit!important;line-height:inherit!important;color:inherit!important}
-.bt-widget-table{max-width:100%;overflow-x:auto;border:.5px solid var(--bt-line-2);border-radius:10px}
-.bt-widget-table table{border-collapse:collapse;min-width:100%;font-size:13px;line-height:18px}
-.bt-widget-table th{padding:6px 10px;font-weight:500;text-align:start;white-space:nowrap;color:var(--bt-ink-2);border-bottom:.5px solid var(--bt-line-2)}
-.bt-widget-table td{padding:6px 10px;max-width:280px;color:var(--bt-ink);overflow-wrap:anywhere}
-.bt-widget-table tbody tr+tr>*{border-top:.5px solid var(--bt-line)}
-.bt-widget-table .bt-num{text-align:end;font-variant-numeric:tabular-nums}
-.bt-widget-form{display:flex;flex-direction:column;gap:8px;margin:0}
-.bt-widget-field{display:flex;flex-direction:column;gap:4px;min-width:0}
-.bt-widget-field-label{font-size:12px;line-height:16px;color:var(--bt-ink-2)}
-.bt-widget-field .bt-q-field:has(.bt-q-input:disabled){cursor:default;opacity:.75}
-.bt-widget-progress{display:flex;flex-direction:column;gap:5px;min-width:0}
-.bt-widget-progress-label{display:flex;justify-content:space-between;gap:8px;font-size:12px;line-height:16px;color:var(--bt-ink-2);font-variant-numeric:tabular-nums}
-.bt-widget-progress-name{color:var(--bt-ink);font-weight:500}
-.bt-widget-progress-track{height:6px;border-radius:999px;background:var(--bt-hover);overflow:hidden}
-.bt-widget-progress-fill{height:100%;border-radius:inherit;background:var(--bt-accent);transition:width .12s ease,background-color .12s ease}
-.bt-widget-progress[data-tone=good] .bt-widget-progress-fill{background:var(--bt-green)}
-.bt-widget-progress[data-tone=warn] .bt-widget-progress-fill{background:var(--bt-star)}
-.bt-widget-progress[data-tone=bad] .bt-widget-progress-fill{background:var(--bt-danger)}
-.bt-widget-progress[data-tone=bad] .bt-widget-progress-label>span:last-child{color:var(--bt-danger)}
-.bt-view-callout{display:flex;gap:8px;padding:8px 12px;border-radius:10px;--bt-tone:var(--bt-accent);background:color-mix(in srgb,var(--bt-tone) 8%,transparent);color:var(--bt-ink)}
-.bt-view-callout[data-tone=good]{--bt-tone:var(--bt-green)}
-.bt-view-callout[data-tone=warn]{--bt-tone:var(--bt-star)}
-.bt-view-callout[data-tone=bad]{--bt-tone:var(--bt-danger)}
-.bt-view-callout-icon{flex:none;display:flex;padding-top:3px;color:var(--bt-tone)}
-.bt-view-callout-icon svg{width:16px;height:16px}
-.bt-view-callout-text{flex:1 1 auto;min-width:0}
-.bt-view-sources{display:flex;flex-wrap:wrap;gap:6px}
-.bt-view-source{display:inline-flex;align-items:center;gap:4px;max-width:100%;height:20px;padding:0 6px;border-radius:4px;background:var(--bt-tag-bg,var(--bt-hover));color:var(--bt-ink-2);font-size:11px;line-height:16px;text-decoration:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:background-color .12s ease,color .12s ease}
-.bt-view-source:hover{background:var(--bt-hover);color:var(--bt-ink)}
-.bt-view-source:focus-visible{outline:2px solid var(--bt-accent);outline-offset:1px}
-.bt-view-input{display:flex;flex-direction:column;gap:6px;min-width:0}
-.bt-view-input-head{display:flex;justify-content:space-between;align-items:baseline;gap:8px}
-.bt-view-input-label{font-size:12px;line-height:16px;color:var(--bt-ink-2)}
-.bt-view-input-value{font-size:15px;line-height:20px;font-weight:600;color:var(--bt-ink);font-variant-numeric:tabular-nums}
-.bt-view-range{-webkit-appearance:none;appearance:none;width:100%;height:20px;margin:0;background:transparent;cursor:pointer}
-.bt-view-range:disabled{cursor:default;opacity:.6}
-.bt-view-range::-webkit-slider-runnable-track{height:6px;border-radius:999px;background:linear-gradient(to right,var(--bt-accent) var(--bt-fill,0%),var(--bt-hover) var(--bt-fill,0%))}
-.bt-view-range::-moz-range-track{height:6px;border-radius:999px;background:var(--bt-hover)}
-.bt-view-range::-moz-range-progress{height:6px;border-radius:999px;background:var(--bt-accent)}
-.bt-view-range::-webkit-slider-thumb{-webkit-appearance:none;width:16px;height:16px;margin-top:-5px;border-radius:50%;corner-shape:round;background:var(--bt-knob);box-shadow:0 1px 3px rgba(0,0,0,.25),0 0 0 .5px rgba(0,0,0,.12)}
-.bt-view-range::-moz-range-thumb{width:16px;height:16px;border:0;border-radius:50%;background:var(--bt-knob);box-shadow:0 1px 3px rgba(0,0,0,.25),0 0 0 .5px rgba(0,0,0,.12)}
-.bt-view-range:focus-visible{outline:2px solid var(--bt-accent);outline-offset:2px;border-radius:6px}
-.bt-view-number{max-width:200px;align-items:center;gap:6px}
-.bt-view-number .bt-q-input{font-variant-numeric:tabular-nums}
-.bt-view-unit{flex:none;font-size:13px;color:var(--bt-ink-2)}
-.bt-seg.bt-view-seg{align-self:flex-start;max-width:100%}
-.bt-seg.bt-view-seg button{flex:none;padding:0 12px;white-space:nowrap}
-.bt-view-radios{display:flex;flex-direction:column;gap:2px}
-.bt-view-radio{display:flex;align-items:center;gap:8px;min-height:30px;padding:4px 8px;margin:0 -8px;border:0;border-radius:8px;background:none;font:inherit;font-size:14px;line-height:20px;color:var(--bt-ink);text-align:start;cursor:pointer;transition:background-color .12s ease}
-.bt-view-radio:hover:not(:disabled){background:var(--bt-hover)}
-.bt-view-radio:disabled{cursor:default}
-.bt-view-radio:focus-visible{outline:2px solid var(--bt-accent);outline-offset:-2px}
-.bt-view-radio-dot{flex:none;width:16px;height:16px;border-radius:50%;corner-shape:round;box-shadow:inset 0 0 0 1.5px var(--bt-line-2);transition:box-shadow .12s ease}
-.bt-view-radio[aria-checked=true] .bt-view-radio-dot{box-shadow:inset 0 0 0 5px var(--bt-accent)}
-.bt-view-toggle{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:28px}
-.bt-view-toggle .bt-view-input-label{font-size:14px;line-height:20px;color:var(--bt-ink)}
-.bt-q.bt-view{gap:10px}
-.bt-q.bt-view:not(.bt-q-raised):not(.bt-q-settled)>.bt-view-head:has(.bt-view-title:empty){margin-bottom:-6px}
-.bt-q-raised .bt-view-head{padding:14px 16px 4px 20px}
-.bt-q-raised .bt-view-body{padding:0 16px 14px 20px}
-.bt-q-raised .bt-view-body .bt-q-list{padding:0;margin:0 -8px}
-.bt-q-inline .bt-view{margin:0;width:100%;max-width:min(100%,max(calc(var(--bt-msg-w,.8) * 100%),560px));order:0}
-body[data-bt-layout=flat] .bt-q-inline .bt-view{max-width:calc(var(--bt-flat-w,1) * 100%)}
-.bt-q-inline:has(>.bt-view-bare){margin:8px 0 12px}
-@media (prefers-reduced-motion:reduce){.bt-widget-progress-fill,.bt-view-radio-dot,.bt-view-tools,.bt-view-more{transition:none}.bt-view-bare{animation:none}}
-${CHART_CSS}
-${HTML_CSS}
+// The core styles, with the --dui-* tokens rebound to ds-bot's --bt-* palette so
+// a view card keeps the Bot theme.
+export const WIDGET_CSS = `${DEEP_UI_CSS}
+body{
+--dui-ink:var(--bt-ink);--dui-ink-2:var(--bt-ink-2);--dui-ink-3:var(--bt-ink-3);
+--dui-line:var(--bt-line);--dui-line-2:var(--bt-line-2);
+--dui-card:var(--bt-card);--dui-main:var(--bt-main);
+--dui-hover:var(--bt-hover);--dui-active:var(--bt-active);
+--dui-accent:var(--bt-accent);--dui-accent-ink:var(--bt-accent-ink);
+--dui-green:var(--bt-green);--dui-star:var(--bt-star);--dui-danger:var(--bt-danger);
+--dui-knob:var(--bt-knob);--dui-tag-bg:var(--bt-tag-bg);
+--dui-ink-tangerine:var(--bt-ink-tangerine);--dui-ink-green:var(--bt-ink-green);
+--dui-ink-violet:var(--bt-ink-violet);--dui-ink-sky:var(--bt-ink-sky);
+--dui-ink-rose:var(--bt-ink-rose);--dui-ink-yellow:var(--bt-ink-yellow);
+--dui-ink-cyan:var(--bt-ink-cyan);--dui-ink-magenta:var(--bt-ink-magenta)}
+.bt-q-inline .dui-view{max-width:100%}
`
diff --git a/ds-bot/src/client/widget-chart.js b/ds-bot/src/client/widget-chart.js
deleted file mode 100644
index b65d6baf..00000000
--- a/ds-bot/src/client/widget-chart.js
+++ /dev/null
@@ -1,419 +0,0 @@
-import { createElement as h, Fragment, useEffect, useId, useLayoutEffect, useRef, useState } from 'react'
-import { t } from './i18n.js'
-import { asText, resolve } from '../shared/views.js'
-
-// -------------------------------------------------------------------------
-// The chart component of a view: bar, horizontal bar, line, area and donut, drawn
-// as SVG at the width it gets. Hover or arrow keys show a category's values and dim
-// the rest; a legend hides a series; the menu shows the data as a table, copies it
-// as CSV, or saves the chart as a PNG. Colors come from the theme only.
-
-// The first series takes the accent; the rest take the team inks.
-const PALETTE = ['var(--bt-accent)', 'var(--bt-ink-tangerine)', 'var(--bt-ink-green)', 'var(--bt-ink-violet)', 'var(--bt-ink-sky)', 'var(--bt-ink-rose)', 'var(--bt-ink-yellow)', 'var(--bt-ink-cyan)', 'var(--bt-ink-magenta)']
-const colorAt = index => PALETTE[index % PALETTE.length]
-const TICK = 10
-const LABEL = 11
-// A rough width for SVG text before it is laid out; wide (CJK) characters count double.
-const textWidth = (text, size) => [...String(text)].reduce((sum, char) => sum + (char.charCodeAt(0) > 0x2e80 ? size : size * 0.58), 0)
-const fit = (text, room, size) => {
- if (textWidth(text, size) <= room) return text
- let out = ''
- for (const char of String(text)) {
- if (textWidth(`${out}${char}…`, size) > room) break
- out += char
- }
- return out === '' ? '' : `${out}…`
-}
-
-export function formatNumber(value) {
- if (!Number.isFinite(value)) return asText(value)
- const abs = Math.abs(value)
- const digits = abs >= 100 ? 0 : abs >= 10 ? 1 : 2
- return Number(value.toFixed(digits)).toLocaleString('en-US', { maximumFractionDigits: digits })
-}
-const withUnit = (value, unit) => (unit ? (unit === '%' ? `${formatNumber(value)}%` : `${formatNumber(value)} ${unit}`) : formatNumber(value))
-
-// Round steps (1, 2, 2.5, 5 × 10ⁿ) from `low` to `high`, about four of them.
-export function niceTicks(low, high) {
- let lo = low
- let hi = high
- if (lo === hi) { lo = Math.min(0, lo); hi = hi === 0 ? 1 : Math.max(0, hi) }
- if (lo === hi) hi = lo + 1
- const raw = (hi - lo) / 4
- const magnitude = 10 ** Math.floor(Math.log10(raw))
- const step = [1, 2, 2.5, 5, 10].map(scale => scale * magnitude).find(candidate => candidate >= raw)
- const start = Math.floor(lo / step + 1e-9) * step
- const end = Math.ceil(hi / step - 1e-9) * step
- const ticks = []
- for (let value = start; value <= end + step / 2; value += step) ticks.push(Number(value.toPrecision(12)))
- return ticks
-}
-
-export function chartData(node, lookup) {
- const categories = (Array.isArray(node.categories) ? node.categories : []).map(asText)
- const series = (Array.isArray(node.series) ? node.series : []).map((item, index) => ({
- name: typeof item?.name === 'string' ? item.name : '',
- color: colorAt(index),
- values: categories.map((_, at) => {
- const value = Number(resolve(Array.isArray(item?.values) ? item.values[at] : undefined, lookup, 0))
- return Number.isFinite(value) ? value : 0
- }),
- }))
- return { kind: node.kind ?? 'bar', categories, series, unit: typeof node.unit === 'string' ? node.unit : '' }
-}
-
-const csvCell = value => (/[",\n]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value)
-export function chartCsv({ categories, series, unit }) {
- const head = ['', ...series.map((item, index) => item.name || (series.length === 1 ? unit || t('Value') : `${t('Series')} ${index + 1}`))]
- const rows = categories.map((label, at) => [label, ...series.map(item => String(item.values[at]))])
- return [head, ...rows].map(row => row.map(cell => csvCell(String(cell))).join(',')).join('\n')
-}
-
-// -------------------------------------------------------------------------
-// Drawings. Each returns the SVG body, its height, and where each category's
-// tooltip points ({ x, y } in SVG pixels).
-
-function valueAxis(values, zero) {
- const finite = values.length > 0 ? values : [0]
- const low = Math.min(...finite)
- const high = Math.max(...finite)
- if (zero) return niceTicks(Math.min(0, low), Math.max(0, high))
- const pad = (high - low) * 0.1 || Math.abs(high) * 0.1 || 1
- return niceTicks(low - pad, high + pad)
-}
-
-function columns({ categories, series, unit, kind }, width, active, shown) {
- const visible = series.filter((_, index) => shown[index])
- const ticks = valueAxis(visible.flatMap(item => item.values), kind !== 'line')
- const lo = ticks[0]
- const hi = ticks.at(-1)
- const left = Math.ceil(Math.max(...ticks.map(tick => textWidth(withUnit(tick, unit), TICK)))) + 10
- const top = 8
- const height = 220
- const bottom = 24
- const plot = { x: left, y: top, w: Math.max(40, width - left - 4), h: height - top - bottom }
- const y = value => plot.y + plot.h - ((value - lo) / (hi - lo)) * plot.h
- const band = plot.w / categories.length
- const parts = []
- for (const tick of ticks) {
- parts.push(h('line', { key: `g${tick}`, className: 'bt-chart-grid', x1: plot.x, x2: plot.x + plot.w, y1: y(tick), y2: y(tick) }))
- parts.push(h('text', { key: `t${tick}`, className: 'bt-chart-tick', x: plot.x - 8, y: y(tick) + 3, textAnchor: 'end' }, withUnit(tick, unit)))
- }
- const points = []
- categories.forEach((label, at) => {
- const cx = plot.x + band * at + band / 2
- parts.push(h('text', { key: `c${at}`, className: 'bt-chart-label', x: cx, y: height - 7, textAnchor: 'middle' }, fit(label, band - 4, LABEL)))
- points.push({ x: cx, y: y(Math.max(...visible.map(item => item.values[at]), lo)) })
- })
- if (kind === 'bar') {
- const group = band * 0.72
- const gap = visible.length > 1 ? 2 : 0
- const barW = Math.max(2, (group - gap * (visible.length - 1)) / visible.length)
- const zero = y(Math.max(lo, Math.min(0, hi)))
- categories.forEach((_, at) => {
- visible.forEach((item, row) => {
- const value = item.values[at]
- const x = plot.x + band * at + (band - group) / 2 + row * (barW + gap)
- const top2 = Math.min(y(value), zero)
- const tall = Math.max(1, Math.abs(y(value) - zero))
- const r = Math.min(4, barW / 2, tall)
- const up = value >= 0
- const d = up
- ? `M${x},${top2 + tall}V${top2 + r}q0,-${r} ${r},-${r}h${barW - 2 * r}q${r},0 ${r},${r}V${top2 + tall}z`
- : `M${x},${top2}V${top2 + tall - r}q0,${r} ${r},${r}h${barW - 2 * r}q${r},0 ${r},-${r}V${top2}z`
- parts.push(h('path', { key: `b${at}-${row}`, className: 'bt-chart-mark', 'data-dim': active !== null && active !== at ? '' : undefined, d, style: { fill: item.color } }))
- })
- })
- } else {
- const xs = categories.map((_, at) => plot.x + band * at + band / 2)
- visible.forEach((item, row) => {
- const line = item.values.map((value, at) => `${at === 0 ? 'M' : 'L'}${xs[at]},${y(value)}`).join('')
- if (kind === 'area') {
- const base = y(Math.max(lo, Math.min(0, hi)))
- parts.push(h('path', { key: `a${row}`, className: 'bt-chart-area', d: `${line}L${xs.at(-1)},${base}L${xs[0]},${base}z`, style: { fill: item.color } }))
- }
- parts.push(h('path', { key: `l${row}`, className: 'bt-chart-line', d: line, style: { stroke: item.color } }))
- item.values.forEach((value, at) => {
- parts.push(h('circle', { key: `p${row}-${at}`, className: 'bt-chart-dot', cx: xs[at], cy: y(value), r: active === at ? 4 : 2.5, style: { fill: item.color } }))
- })
- })
- if (active !== null) parts.unshift(h('line', { key: 'guide', className: 'bt-chart-guide', x1: xs[active], x2: xs[active], y1: plot.y, y2: plot.y + plot.h }))
- }
- const hits = categories.map((_, at) => ({ x: plot.x + band * at, y: plot.y, w: band, h: plot.h }))
- return { parts, height, points, hits }
-}
-
-function rows({ categories, series, unit }, width, active, shown) {
- const visible = series.filter((_, index) => shown[index])
- const ticks = valueAxis(visible.flatMap(item => item.values), true)
- const lo = ticks[0]
- const hi = ticks.at(-1)
- const labelW = Math.min(width * 0.38, Math.ceil(Math.max(...categories.map(label => textWidth(label, LABEL)))) + 10)
- const valueW = Math.ceil(Math.max(...visible.flatMap(item => item.values).map(value => textWidth(withUnit(value, unit), LABEL)))) + 10
- const barH = 14
- const rowH = 10 + visible.length * barH + (visible.length - 1) * 2
- const top = 4
- const height = top + rowH * categories.length + 22
- const plot = { x: labelW, y: top, w: Math.max(40, width - labelW - valueW), h: rowH * categories.length }
- const x = value => plot.x + ((value - lo) / (hi - lo)) * plot.w
- const parts = []
- for (const tick of ticks) {
- parts.push(h('line', { key: `g${tick}`, className: 'bt-chart-grid', x1: x(tick), x2: x(tick), y1: plot.y, y2: plot.y + plot.h }))
- parts.push(h('text', { key: `t${tick}`, className: 'bt-chart-tick', x: x(tick), y: height - 6, textAnchor: 'middle' }, withUnit(tick, unit)))
- }
- const points = []
- const zero = x(Math.max(lo, Math.min(0, hi)))
- categories.forEach((label, at) => {
- const rowY = plot.y + rowH * at + 5
- parts.push(h('text', { key: `c${at}`, className: 'bt-chart-label', x: labelW - 10, y: rowY + (rowH - 10) / 2 + 4, textAnchor: 'end' }, fit(label, labelW - 12, LABEL)))
- visible.forEach((item, row) => {
- const value = item.values[at]
- const by = rowY + row * (barH + 2)
- const left = Math.min(x(value), zero)
- const long = Math.max(1, Math.abs(x(value) - zero))
- parts.push(h('rect', { key: `b${at}-${row}`, className: 'bt-chart-mark', 'data-dim': active !== null && active !== at ? '' : undefined, x: left, y: by, width: long, height: barH, rx: Math.min(4, long / 2), style: { fill: item.color } }))
- parts.push(h('text', { key: `v${at}-${row}`, className: 'bt-chart-value', x: left + long + 6, y: by + barH - 3 }, withUnit(value, unit)))
- })
- points.push({ x: Math.max(...visible.map(item => x(item.values[at])), zero), y: rowY })
- })
- const hits = categories.map((_, at) => ({ x: 0, y: plot.y + rowH * at, w: width, h: rowH }))
- return { parts, height, points, hits }
-}
-
-function donut({ categories, series }, width, active, hover) {
- const values = (series[0]?.values ?? []).map(value => Math.max(0, value))
- const total = values.reduce((sum, value) => sum + value, 0)
- const size = Math.min(180, Math.max(120, width * 0.42))
- const r = size / 2
- const inner = r * 0.62
- const cx = r
- const cy = r
- const parts = []
- const points = []
- let angle = -Math.PI / 2
- values.forEach((value, at) => {
- const sweep = total > 0 ? (value / total) * Math.PI * 2 : 0
- const end = angle + sweep
- const mid = angle + sweep / 2
- points.push({ x: cx + Math.cos(mid) * (r - (r - inner) / 2), y: cy + Math.sin(mid) * (r - (r - inner) / 2) })
- if (sweep > 0) {
- const large = sweep > Math.PI ? 1 : 0
- const full = sweep >= Math.PI * 2 - 1e-6
- const p = (radius, theta) => `${cx + Math.cos(theta) * radius},${cy + Math.sin(theta) * radius}`
- const d = full
- ? `M${p(r, angle)}A${r},${r} 0 1 1 ${p(r, angle + Math.PI)}A${r},${r} 0 1 1 ${p(r, angle)}M${p(inner, angle)}A${inner},${inner} 0 1 0 ${p(inner, angle + Math.PI)}A${inner},${inner} 0 1 0 ${p(inner, angle)}z`
- : `M${p(r, angle)}A${r},${r} 0 ${large} 1 ${p(r, end)}L${p(inner, end)}A${inner},${inner} 0 ${large} 0 ${p(inner, angle)}z`
- parts.push(h('path', { key: `s${at}`, className: 'bt-chart-mark', 'data-dim': active !== null && active !== at ? '' : undefined, d, fillRule: 'evenodd', style: { fill: colorAt(at) }, onPointerEnter: () => hover(at) }))
- }
- angle = end
- })
- return { parts, height: size, size, points, total, values, categories }
-}
-
-// -------------------------------------------------------------------------
-
-function useWidth(box, initial) {
- const [width, setWidth] = useState(initial)
- useLayoutEffect(() => {
- const node = box.current
- if (!node || typeof ResizeObserver !== 'function') return undefined
- const measure = () => { const next = Math.round(node.clientWidth); if (next > 0) setWidth(next) }
- measure()
- const observer = new ResizeObserver(measure)
- observer.observe(node)
- return () => observer.disconnect()
- }, [])
- return width
-}
-
-// SVG styles live in the page's CSS; a saved image needs them written onto each node.
-const INLINE = ['fill', 'stroke', 'stroke-width', 'stroke-dasharray', 'opacity', 'fill-opacity', 'font-size', 'font-family', 'font-weight']
-function saveImage(svg, name) {
- const clone = svg.cloneNode(true)
- const live = [svg, ...svg.querySelectorAll('*')]
- const copy = [clone, ...clone.querySelectorAll('*')]
- live.forEach((node, index) => {
- const style = getComputedStyle(node)
- copy[index].setAttribute('style', INLINE.map(prop => `${prop}:${style.getPropertyValue(prop)}`).join(';'))
- })
- // The attributes, not the layout box: under the table view the SVG is hidden.
- const width = Number(svg.getAttribute('width'))
- const height = Number(svg.getAttribute('height'))
- clone.setAttribute('xmlns', 'http://www.w3.org/2000/svg')
- const page = getComputedStyle(document.body)
- const background = page.getPropertyValue('--bt-main').trim() || page.backgroundColor
- const url = URL.createObjectURL(new Blob([new XMLSerializer().serializeToString(clone)], { type: 'image/svg+xml' }))
- const image = new Image()
- image.onload = () => {
- const scale = 2
- const canvas = document.createElement('canvas')
- canvas.width = Math.ceil(width * scale)
- canvas.height = Math.ceil(height * scale)
- const paint = canvas.getContext('2d')
- paint.fillStyle = background
- paint.fillRect(0, 0, canvas.width, canvas.height)
- paint.drawImage(image, 0, 0, canvas.width, canvas.height)
- URL.revokeObjectURL(url)
- canvas.toBlob((blob) => {
- if (!blob) return
- const link = document.createElement('a')
- link.href = URL.createObjectURL(blob)
- link.download = name
- document.body.appendChild(link)
- link.click()
- link.remove()
- setTimeout(() => URL.revokeObjectURL(link.href), 1000)
- }, 'image/png')
- }
- image.onerror = () => URL.revokeObjectURL(url)
- image.src = url
-}
-
-export const TableIcon = () => h('svg', { width: 16, height: 16, viewBox: '0 0 20 20', fill: 'none', stroke: 'currentColor', strokeWidth: 1.6, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true },
- h('path', { d: 'M4.5 4h11A1.5 1.5 0 0 1 17 5.5v9a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 14.5v-9A1.5 1.5 0 0 1 4.5 4z' }), h('path', { d: 'M3 8.5h14M8 8.5V16' }))
-
-function ChartTable({ data }) {
- const { categories, series, unit } = data
- const heads = series.map((item, index) => item.name || (series.length === 1 ? unit || t('Value') : `${t('Series')} ${index + 1}`))
- return h('div', { className: 'bt-widget-table' },
- h('table', null,
- h('thead', null, h('tr', null, h('th', { scope: 'col' }), heads.map((head, index) => h('th', { key: index, scope: 'col', className: 'bt-num' }, head)))),
- h('tbody', null, categories.map((label, at) => h('tr', { key: at },
- h('th', { scope: 'row' }, label),
- series.map((item, index) => h('td', { key: index, className: 'bt-num' }, withUnit(item.values[at], series.length === 1 && !item.name ? '' : unit))))))))
-}
-
-export function WidgetChart({ node, lookup, registerChart, refreshCharts }) {
- const data = chartData(node, lookup)
- const { kind, categories, series, unit } = data
- const box = useRef(null)
- const svg = useRef(null)
- const width = useWidth(box, 520)
- const [active, setActive] = useState(null)
- const [hidden, setHidden] = useState([])
- const [asTable, setAsTable] = useState(false)
- const [copied, setCopied] = useState(false)
- const labelId = useId()
- const menuKey = useId()
- const table = useRef(asTable)
- table.current = asTable
- const shown = series.map((_, index) => !hidden.includes(index))
- const toggle = (index) => {
- if (hidden.includes(index)) setHidden(hidden.filter(item => item !== index))
- else if (shown.filter(Boolean).length > 1) setHidden([...hidden, index])
- }
- const label = typeof node.caption === 'string' && node.caption !== '' ? node.caption : t('Chart')
- const isDonut = kind === 'donut'
- const legendBeside = isDonut && width >= 360
- const drawn = isDonut ? donut(data, legendBeside ? width - 200 : width, active, setActive)
- : kind === 'hbar' ? rows(data, width, active, shown) : columns(data, width, active, shown)
- const svgWidth = isDonut ? drawn.size : width
- const move = (event) => {
- const keys = { ArrowRight: 1, ArrowDown: 1, ArrowLeft: -1, ArrowUp: -1 }
- if (event.key === 'Escape') { setActive(null); return }
- if (keys[event.key] === undefined) return
- event.preventDefault()
- setActive(current => (current === null ? 0 : (current + keys[event.key] + categories.length) % categories.length))
- }
- const point = active === null ? null : drawn.points[active]
- // A share in a donut already in percent needs no second percent.
- const share = at => (unit === '%' ? withUnit(drawn.values[at], unit) : `${withUnit(drawn.values[at], unit)} · ${drawn.total > 0 ? Math.round((drawn.values[at] / drawn.total) * 100) : 0}%`)
- const tipRows = active === null || isDonut ? [] : series.filter((_, index) => shown[index]).map(item => ({ color: item.color, name: item.name, value: withUnit(item.values[active], unit) }))
- const copy = () => {
- void navigator.clipboard?.writeText(chartCsv(data)).then(() => { setCopied(true); setTimeout(() => setCopied(false), 1200) })
- }
- const toggleTable = () => { table.current = !table.current; setAsTable(table.current) }
- const menuLabel = typeof node.caption === 'string' && node.caption !== '' ? node.caption : null
- const action = useRef(null)
- action.current = { label: menuLabel, copy, save: () => { if (svg.current) saveImage(svg.current, 'chart.png') }, toggleTable }
- // The card's ⋯ menu shows the chart's actions. Register once on mount — a
- // re-register would move the chart to the end of the card's group order —
- // and let the getters hand the menu the current name and table state.
- useEffect(() => registerChart?.(menuKey, {
- get label() { return action.current.label },
- get asTable() { return table.current },
- toggleTable: () => action.current.toggleTable(),
- copy: () => action.current.copy(),
- save: () => action.current.save(),
- }), [registerChart, menuKey])
- // A table switch or a new caption asks the card for a fresh menu, without
- // touching the registration order.
- useEffect(() => refreshCharts?.(), [refreshCharts, asTable, menuLabel])
- const legend = isDonut
- ? h('div', { className: 'bt-chart-legend bt-chart-legend-list' }, categories.map((name, at) => h('div', {
- key: at, className: 'bt-chart-key', 'data-dim': active !== null && active !== at ? '' : undefined,
- onPointerEnter: () => setActive(at), onPointerLeave: () => setActive(null),
- }, h('i', { style: { background: colorAt(at) } }), h('span', { className: 'bt-chart-key-name' }, name),
- h('span', { className: 'bt-chart-key-value' }, share(at)))))
- : series.length > 1 ? h('div', { className: 'bt-chart-legend' }, series.map((item, index) => h('button', {
- key: index, type: 'button', className: 'bt-chart-key', 'aria-pressed': shown[index], onClick: () => toggle(index),
- }, h('i', { style: { background: item.color } }), item.name || `${t('Series')} ${index + 1}`))) : null
- const plot = h('div', { className: 'bt-chart-plot', style: isDonut ? { width: svgWidth } : undefined },
- h('svg', {
- ref: svg, className: 'bt-chart-svg', width: svgWidth, height: drawn.height, viewBox: `0 0 ${svgWidth} ${drawn.height}`,
- role: 'img', 'aria-labelledby': labelId, tabIndex: 0,
- onKeyDown: move, onBlur: () => setActive(null), onPointerLeave: () => setActive(null),
- },
- drawn.parts,
- isDonut
- ? (active === null
- ? h('text', { className: 'bt-chart-center', x: svgWidth / 2, y: drawn.height / 2 + 5, textAnchor: 'middle' }, unit === '%' ? '' : withUnit(drawn.total, unit))
- : h(Fragment, null,
- h('text', { className: 'bt-chart-center-name', x: svgWidth / 2, y: drawn.height / 2 - 4, textAnchor: 'middle' }, fit(categories[active], drawn.size * 0.56, LABEL)),
- h('text', { className: 'bt-chart-center', x: svgWidth / 2, y: drawn.height / 2 + 14, textAnchor: 'middle' }, share(active))))
- : drawn.hits.map((hit, at) => h('rect', { key: `h${at}`, className: 'bt-chart-hit', x: hit.x, y: hit.y, width: hit.w, height: hit.h, onPointerEnter: () => setActive(at) }))),
- point && !asTable && !isDonut ? h('div', { className: 'bt-chart-tip', role: 'status', style: { left: point.x, top: point.y } },
- h('b', null, categories[active]),
- tipRows.map((row, index) => h('span', { key: index }, h('i', { style: { background: row.color } }), row.name ? `${row.name} ` : '', row.value))) : null)
- const body = asTable ? h(ChartTable, { data })
- : isDonut ? h('div', { className: legendBeside ? 'bt-chart-donut bt-chart-donut-beside' : 'bt-chart-donut', onPointerLeave: () => setActive(null) }, plot, legend)
- : h(Fragment, null, legend, plot)
- return h('figure', { ref: box, className: 'bt-chart', 'data-kind': kind },
- h('span', { id: labelId, hidden: true }, label),
- body,
- // The SVG stays mounted under the table, so the image can still be saved from it.
- asTable ? h('div', { hidden: true }, plot) : null,
- copied ? h('span', { className: 'bt-chart-copied', role: 'status' }, t('Copied')) : null,
- typeof node.caption === 'string' && node.caption !== '' ? h('figcaption', { className: 'bt-view-caption' }, node.caption) : null)
-}
-
-export const CHART_CSS = `
-.bt-chart{position:relative;margin:0;min-width:0;display:flex;flex-direction:column;gap:8px}
-.bt-chart-plot{position:relative;min-width:0}
-.bt-chart-svg{display:block;overflow:visible;outline:none;font-family:inherit}
-.bt-chart-svg text{pointer-events:none}
-.bt-chart-svg:focus-visible{outline:2px solid var(--bt-accent);outline-offset:4px;border-radius:4px}
-.bt-chart-grid{stroke:var(--bt-line);stroke-width:1;stroke-dasharray:3 3}
-.bt-chart-tick{font-size:${TICK}px;fill:var(--bt-ink-3);font-variant-numeric:tabular-nums}
-.bt-chart-label{font-size:${LABEL}px;fill:var(--bt-ink-2)}
-.bt-chart-value{font-size:${LABEL}px;fill:var(--bt-ink-2);font-variant-numeric:tabular-nums}
-.bt-chart-center{font-size:15px;font-weight:600;fill:var(--bt-ink);font-variant-numeric:tabular-nums}
-.bt-chart-center-name{font-size:${LABEL}px;fill:var(--bt-ink-2)}
-.bt-chart-mark{transition:opacity .12s ease}
-.bt-chart-mark[data-dim]{opacity:.28}
-.bt-chart-line{fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
-.bt-chart-area{opacity:.14}
-.bt-chart-dot{transition:r .12s ease}
-.bt-chart-guide{stroke:var(--bt-line-2);stroke-width:1}
-.bt-chart-hit{fill:transparent}
-.bt-chart-tip{position:absolute;z-index:4;pointer-events:none;transform:translate(-50%,calc(-100% - 8px));display:flex;flex-direction:column;gap:2px;padding:6px 10px;border-radius:10px;background:var(--bt-main);border:.5px solid var(--bt-line-2);box-shadow:0 10px 20px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);font-size:12px;line-height:16px;color:var(--bt-ink);white-space:nowrap;font-variant-numeric:tabular-nums;animation:bt-veil-in .12s ease-out}
-.bt-chart-tip b{font-weight:600}
-.bt-chart-tip span{display:flex;align-items:center;gap:6px;color:var(--bt-ink-2)}
-.bt-chart-tip i,.bt-chart-key i{flex:none;width:8px;height:8px;border-radius:50%;corner-shape:round}
-.bt-chart-legend{display:flex;flex-wrap:wrap;gap:4px 12px;padding-right:32px}
-.bt-chart-key{display:inline-flex;align-items:center;gap:6px;min-height:20px;padding:0;border:0;background:none;font:inherit;font-size:12px;line-height:16px;color:var(--bt-ink-2);cursor:pointer;transition:opacity .12s ease}
-.bt-chart-key[aria-pressed=false]{opacity:.4}
-.bt-chart-key:focus-visible{outline:2px solid var(--bt-accent);outline-offset:2px;border-radius:4px}
-.bt-chart-legend-list{flex-direction:column;flex-wrap:nowrap;gap:6px;padding:0;min-width:0}
-.bt-chart-legend-list .bt-chart-key{cursor:default;width:100%}
-.bt-chart-legend-list .bt-chart-key[data-dim]{opacity:.4}
-.bt-chart-key-name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--bt-ink)}
-.bt-chart-key-value{flex:none;font-variant-numeric:tabular-nums}
-.bt-chart-donut{display:flex;flex-direction:column;align-items:center;gap:12px}
-.bt-chart-donut-beside{flex-direction:row;align-items:center;gap:24px}
-.bt-chart-donut-beside .bt-chart-legend-list{flex:1 1 auto;max-width:280px}
-.bt-chart-copied{position:absolute;top:2px;right:36px;font-size:12px;line-height:16px;color:var(--bt-ink-2);animation:bt-veil-in .16s ease-out}
-.bt-widget-table .bt-num{text-align:end;font-variant-numeric:tabular-nums}
-.bt-widget-table tbody th{padding:6px 10px;font-weight:400;text-align:start;color:var(--bt-ink);border-bottom:0}
-@media (prefers-reduced-motion:reduce){.bt-chart-mark,.bt-chart-dot{transition:none}.bt-chart-tip{animation:none}}
-`
diff --git a/ds-bot/src/client/widget-html.js b/ds-bot/src/client/widget-html.js
deleted file mode 100644
index aa0b4ebe..00000000
--- a/ds-bot/src/client/widget-html.js
+++ /dev/null
@@ -1,76 +0,0 @@
-import { createElement as h, useEffect, useMemo, useRef, useState } from 'react'
-import { t } from './i18n.js'
-
-// -------------------------------------------------------------------------
-// The html component of a view, for what the catalog cannot draw. The Bot's markup
-// runs in a sandboxed frame: scripts only (no same-origin, so no access to the app,
-// its storage or its API), and a policy written ahead of the markup that blocks
-// every network request. The frame reports its height and takes theme colors; it
-// has no way to answer the Bot. A frame that navigates away is stopped.
-
-export const FRAME_VARS = ['--bt-ink', '--bt-ink-2', '--bt-ink-3', '--bt-line', '--bt-line-2', '--bt-card', '--bt-main', '--bt-hover', '--bt-accent', '--bt-accent-ink', '--bt-green', '--bt-star', '--bt-danger']
-export const FRAME_POLICY = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; media-src data: blob:; form-action 'none'; base-uri 'none'"
-const HEIGHT = 'bt-view-height'
-const THEME = 'bt-view-theme'
-const MIN_HEIGHT = 24
-
-export function themeVars() {
- if (typeof getComputedStyle !== 'function' || typeof document === 'undefined' || !document.body) return {}
- const style = getComputedStyle(document.body)
- const vars = {}
- for (const name of FRAME_VARS) {
- const value = style.getPropertyValue(name).trim()
- if (value !== '') vars[name] = value
- }
- // The same scheme as the page around it: a frame whose scheme differs gets an opaque
- // backdrop instead of a transparent one.
- vars['color-scheme'] = style.getPropertyValue('color-scheme').trim() || 'normal'
- return vars
-}
-
-const cssValue = value => String(value).replace(/[<>{};]/g, '')
-
-// The document the frame loads. The policy and our script come before the Bot's
-// markup, so nothing in the markup runs before them or loosens the policy.
-export function frameDocument(html, vars = {}) {
- const root = Object.entries(vars).map(([name, value]) => `${name}:${cssValue(value)}`).join(';')
- const report = `(()=>{const send=()=>parent.postMessage({type:${JSON.stringify(HEIGHT)},height:Math.ceil(document.documentElement.getBoundingClientRect().height)},'*');`
- + 'new ResizeObserver(send).observe(document.documentElement);addEventListener(\'load\',send);'
- + `addEventListener('message',e=>{if(e.source!==parent||!e.data||e.data.type!==${JSON.stringify(THEME)})return;for(const[k,v]of Object.entries(e.data.vars||{}))document.documentElement.style.setProperty(k,String(v))})})()`
- return '<!doctype html><html><head><meta charset="utf-8">'
- + `<meta http-equiv="Content-Security-Policy" content="${FRAME_POLICY}">`
- + `<style>:root{${root}}html,body{margin:0;padding:0;background:transparent;color:var(--bt-ink);font:14px/22px -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}*{box-sizing:border-box}</style>`
- + `<script>${report}</script></head><body>${html}</body></html>`
-}
-
-export function HtmlFrame({ node }) {
- const frame = useRef(null)
- const loads = useRef(0)
- const [height, setHeight] = useState(Number.isFinite(node.height) ? node.height : 120)
- const [stopped, setStopped] = useState(false)
- const doc = useMemo(() => frameDocument(String(node.html ?? ''), themeVars()), [node.html])
- useEffect(() => {
- const onMessage = (event) => {
- if (event.source !== frame.current?.contentWindow || event.data?.type !== HEIGHT) return
- const next = Number(event.data.height)
- if (Number.isFinite(next)) setHeight(Math.max(MIN_HEIGHT, Math.ceil(next)))
- }
- window.addEventListener('message', onMessage)
- const retheme = () => frame.current?.contentWindow?.postMessage({ type: THEME, vars: themeVars() }, '*')
- const observer = typeof MutationObserver === 'function' ? new MutationObserver(retheme) : null
- observer?.observe(document.body, { attributes: true, attributeFilter: ['data-ds-dark-theme', 'style', 'class'] })
- return () => { window.removeEventListener('message', onMessage); observer?.disconnect() }
- }, [])
- if (stopped) return h('p', { className: 'bt-view-frame-stopped' }, t('This view tried to open a page and was stopped.'))
- return h('iframe', {
- ref: frame, className: 'bt-view-frame', title: String(node.summary ?? ''),
- sandbox: 'allow-scripts', srcDoc: doc, referrerPolicy: 'no-referrer',
- style: { height: `${height}px` },
- onLoad: () => { loads.current += 1; if (loads.current > 1) setStopped(true) },
- })
-}
-
-export const HTML_CSS = `
-.bt-view-frame{display:block;width:100%;border:0;background:transparent}
-.bt-view-frame-stopped{margin:0;font-size:13px;line-height:18px;color:var(--bt-ink-2)}
-`
diff --git a/ds-bot/src/host/channel.js b/ds-bot/src/host/channel.js
index 4723051a..0757012f 100644
--- a/ds-bot/src/host/channel.js
+++ b/ds-bot/src/host/channel.js
@@ -5,7 +5,7 @@ import { install as installBtw } from './btw.js'
import { install as installSide } from './side.js'
import { handoffReply, questionReply, viewReply } from './parts.js'
import { defaultRelayLimit } from './groups.js'
-import { validateViewAnswer } from '../shared/views.js'
+import { validateViewAnswer } from 'dsh-deep-ui/core'
import { COLORS, EXTRA_COLORS, ROUTE } from './constants.js'
const LANGUAGES = { zh: 'Chinese (简体中文)', en: 'English' }
diff --git a/ds-bot/src/host/parts.js b/ds-bot/src/host/parts.js
index f5d89448..fb5c18c9 100644
--- a/ds-bot/src/host/parts.js
+++ b/ds-bot/src/host/parts.js
@@ -21,7 +21,7 @@ import { HANDOFF_ACK, HISTORY_TIMEOUT_MS, REPLY_KIND, SOURCE_KIND } from './cons
import { CHECKPOINT_PROMPT, STEWARD_SYSTEM, checkpointCount, checkpointTail, checkpointTailNote, checkpointText, linesFor, parseDecision, stewardRequest } from './steward.js'
import { RESUME_DELAY_MS } from './resume.js'
import { clip, createClock, escapeRegExp, estimateTokens, splitRef, textOf } from './text.js'
-import { checkShownView, inputsSummary, normalizeView, validateViewAnswer, viewSummary } from '../shared/views.js'
+import { checkShownView, normalizeView, readViewReply, viewCardText, viewReply, viewReplyText } from 'dsh-deep-ui/core'
// An ask_user card as the user saw it. The user's reply is often just an option label,
// which means nothing without the card. Arguments the tool would refuse (no question,
@@ -40,23 +40,8 @@ export function cardText(args) {
return `[Question card] ${question}${detail ? ` (${detail})` : ''}\nOptions: ${options.join(' / ')}`
}
-// A show_view card as the user saw it. A call the tool would refuse (an oversized
-// or invalid view, no title, a display-only card asked to wait or an interactive
-// one told not to) showed no card, so it gives no text. checkShownView runs the
-// tool's own checks, normalization included, so a wrapped card keeps its summary.
-export function viewCardText(args) {
- let card = args
- if (typeof card === 'string') {
- try { card = JSON.parse(card) } catch { return '' }
- }
- const shown = checkShownView(card?.title, card?.view)
- if (shown.error !== undefined) return ''
- if (!shown.interactive && card?.await_reply === true) return ''
- if (shown.interactive && card?.await_reply === false) return ''
- const summary = viewSummary(shown.view)
- const head = shown.title === '' ? '[View card]' : `[View card] ${shown.title}`
- return summary === '' ? head : `${head}\n${summary}`
-}
+// The card text and reply format live in the shared dsh-deep-ui core.
+export { viewCardText, viewReply }
// What one event adds to a Bot's chat history: an answer of the Bot's (its text, or a
// question card), or a message from the user (`who: 'user'`) or another Bot
@@ -87,19 +72,6 @@ export function questionReply(question, answer) {
}
}
-// The user's answer to a show_view card. The message carries the blueprint with
-// the answer, so the answer still makes sense after a checkpoint drops the card.
-export function viewReply(record, action, values) {
- const checked = validateViewAnswer(record?.view, action, values)
- if (checked.error !== undefined) return undefined
- const callId = record.callId ?? record.id
- const shown = { id: record.id, title: record.title, view: record.view }
- const given = { id: record.id, action, values: checked }
- return {
- text: JSON.stringify({ kind: 'answer_to_pending_view', tool: 'show_view', callId, views: [shown], answers: [given] }),
- source: { kind: REPLY_KIND, callId, outcome: 'answered' },
- }
-}
// The user's answer to a browser_handoff card: they finished the step, skipped it,
// or only gave the browser back from its panel. The message carries the reason with
@@ -126,7 +98,7 @@ export function handoffReply(hold, outcome) {
}
}
-const isRecord = value => value !== null && typeof value === 'object' && !Array.isArray(value)
+
export function readReply(text) {
let value
@@ -135,35 +107,14 @@ export function readReply(text) {
if (typeof value.callId !== 'string' || typeof value.reason !== 'string') return undefined
return { handoff: { callId: value.callId, reason: value.reason, note: typeof value.note === 'string' ? value.note : '', outcome: value.outcome === 'skipped' || value.outcome === 'returned' ? value.outcome : 'done' } }
}
- if (value?.kind === 'answer_to_pending_view' || (Array.isArray(value?.views) && value.views.length > 0 && value?.kind !== 'answer_to_pending_question')) {
- const views = (Array.isArray(value.views) ? value.views : []).filter(item => typeof item?.id === 'string' && typeof item.title === 'string' && isRecord(item.view))
- if (views.length === 0) return undefined
- const answers = (Array.isArray(value.answers) ? value.answers : []).filter(item => typeof item?.id === 'string' && typeof item.action === 'string' && isRecord(item.values))
- return { views, answers }
- }
+ const viewReplyData = readViewReply(text)
+ if (viewReplyData !== undefined) return viewReplyData
const questions = Array.isArray(value?.questions) ? value.questions.filter(item => typeof item?.id === 'string' && typeof item.question === 'string') : []
if (questions.length === 0) return undefined
const answers = (Array.isArray(value.answers) ? value.answers : []).filter(item => typeof item?.id === 'string' && Array.isArray(item.selected))
return { questions, answers }
}
-// The submitted component, and the view's inputs as the user left them. A long form
-// is cut so a checkpoint stays small.
-function actionSummary(answer, view) {
- const values = answer?.values
- if (!isRecord(values)) return '(skipped)'
- const inputs = inputsSummary(view, values.inputs)
- let text
- if (Array.isArray(values.selected)) text = `selected: ${values.selected.join(', ')}`
- else if (typeof values.confirmed === 'boolean') text = values.confirmed ? 'confirmed' : 'cancelled'
- else if (isRecord(values.fields)) text = Object.entries(values.fields).map(([key, value]) => `${key}: ${value}`).join('; ')
- else if (inputs !== '') text = ''
- else text = typeof answer.action === 'string' && answer.action !== '' ? answer.action : '(skipped)'
- if (inputs !== '') text = text === '' ? inputs : `${text}; ${inputs}`
- if (text === '') text = '(empty)'
- return text.length > 500 ? text.slice(0, 500) : text
-}
-
export function replyText(text) {
const reply = readReply(text)
if (reply === undefined) return text
@@ -171,12 +122,7 @@ export function replyText(text) {
const { reason, note, outcome } = reply.handoff
return `[Browser handoff] ${note === '' ? reason : `${reason} — ${note}`}\nAnswer: ${outcome}`
}
- if (reply.views !== undefined) {
- return reply.views.map((view) => {
- const answer = reply.answers.find(item => item.id === view.id)
- return `${view.title === '' ? '[Answer to view card]' : `[Answer to view card] ${view.title}`}\nAnswer: ${actionSummary(answer, view.view)}`
- }).join('\n\n')
- }
+ if (reply.views !== undefined) return viewReplyText(text)
return reply.questions.map((question) => {
const answer = reply.answers.find(item => item.id === question.id)
const values = [...(answer?.selected ?? []), ...(answer?.custom ? [answer.custom] : [])]
diff --git a/ds-bot/src/host/tools.js b/ds-bot/src/host/tools.js
index ebbd20ef..f68027aa 100644
--- a/ds-bot/src/host/tools.js
+++ b/ds-bot/src/host/tools.js
@@ -9,7 +9,7 @@ import { absoluteLinks } from './links.js'
import { NAME_MAX } from './requests.js'
import { unquote } from './text.js'
import { mentionSpans } from '../shared/mentions.js'
-import { checkShownView } from '../shared/views.js'
+import { checkShownView, showViewDescription, showViewParameters } from 'dsh-deep-ui/core'
export const output = { schema: { type: 'string' }, render: (_args, value) => [{ type: 'text', text: String(value) }] }
export const GROUP_REF = { type: 'string', required: true, description: 'Exact group chat name from list_bots' }
@@ -663,19 +663,12 @@ export function install(rt) {
},
}))
- ctx.tools.register(defineTool({
+ // Scoped per Bot session, not global: another plugin's global show_view serves
+ // the sessions ds-bot does not own, while this one shadows it inside them.
+ const showViewTool = defineTool({
name: 'show_view',
- description: 'Draw a view in your own chat as part of your reply: a chart, key numbers, a table, a small calculator the user can try values in, or a choice, confirmation or short form. Text you write before and after the call shows around it. Use a view when it answers better than text: a chart to compare values or show a trend, inputs with formulas to let the user try numbers (worked out in the page, no new turn), options to let the user pick. Plain rows and columns read fine as a Markdown table, and one number needs no view. Give the answer first, then the view. Never invent data; mark sample numbers and assumptions as such. Do not repeat the same data as text, chart and table. Add only the controls the user needs. A view with options, confirm, form or submit ends your turn, and the answer arrives as the user\'s next message. Never collect a key, token or password. Keep the view under 8 KB.',
- parameters: {
- title: { type: 'string', description: 'Optional short heading shown above the view' },
- view: {
- type: 'object',
- required: true,
- additionalProperties: true,
- description: 'One component { type, ...props }. Layout: stack (children, top to bottom) and row (children, side by side, wraps when narrow), 1 to 16 children; the outermost may define let: { name: "formula" }. Display: text ({ text: Markdown, tone?: "muted" }), metric ({ label, value, tone?: good|warn|bad, caption? }), table ({ columns: [{ key, label }], rows: [[cells]] }), chart ({ kind?: bar|hbar|line|area|donut, categories: [labels], series: [{ name?, values: [numbers] }], unit?, caption? }; donut takes one series), progress ({ label?, percent 0-100, or value with max, valueLabel?, tone? }), callout ({ text, tone?: info|good|warn|bad }), sources ({ items: [{ label, url }] }), html ({ html, summary, height? }: only for what nothing else can draw; it runs sandboxed with no network, cannot submit, and should use the CSS variables --bt-ink, --bt-ink-2, --bt-line, --bt-card, --bt-accent, --bt-green, --bt-star, --bt-danger). Inputs, which keep their value in the page: slider ({ id, label, min, max, step?, value, unit? }), number ({ id, label, value, min?, max?, step?, unit? }), choice ({ id, label, options: [{ label, value }], value? }), toggle ({ id, label, value? }); an input id is a plain name such as price. A metric value, caption or tone, a text, a progress field, a callout, a table cell or a chart value may be a formula { "=": "expression" } over input ids and let names: numbers, \'text\', + - * / %, < <= > >= == !=, && || !, a ? b : c, and min max abs floor ceil sqrt pow round clamp fixed(x, digits) format(x, digits) percent(x, digits). Answers, which end your turn: options ({ id, options: [{ label, description? }], multi? }), confirm ({ id, confirmLabel?, cancelLabel? }), form ({ id, fields: [{ id, label, placeholder? }], submitLabel? }), submit ({ id, label }: sends the inputs\' values to you).',
- },
- await_reply: { type: 'boolean', description: 'Wait for the user to submit the view. A view with options, confirm, form or submit always waits; a view without them cannot.' },
- },
+ description: showViewDescription({ where: 'your own chat' }),
+ parameters: showViewParameters,
output,
async execute(args, exec) {
await rt.load()
@@ -705,7 +698,22 @@ export function install(rt) {
exec.concludeTurn?.()
return 'The view is on screen; the user\'s answer arrives as their next message.'
},
- }))
+ })
+
+ // ds-bot registers show_view in the agent's own scope so it answers even in a
+ // group — where it only refuses — instead of a global registration falling to
+ // another plugin. Once per agent; the agent ctx carries the session.
+ const scopedTools = new WeakSet()
+ const shareBotTools = (agent) => {
+ if (agent === undefined || scopedTools.has(agent) || !rt.isBotSession(agent.session?.id)) return
+ if (typeof agent.ctx?.tools?.register !== 'function') return
+ try {
+ agent.ctx.tools.register(showViewTool)
+ scopedTools.add(agent)
+ } catch (error) {
+ rt.warn('ds-bot: scoping show_view for %s failed: %s', agent.session?.id, error)
+ }
+ }
// dsh's own question tool holds the turn open until the user answers, and every
// message from another Bot or a group round queues behind it. Bot Sessions ask
@@ -713,6 +721,7 @@ export function install(rt) {
// goal tools.
const hiddenTools = new WeakSet()
const hideBotUnusedTools = (agent) => {
+ shareBotTools(agent)
if (agent === undefined || hiddenTools.has(agent) || !rt.isBotSession(agent.session?.id)) return
if (typeof agent.ctx?.tools?.restrict !== 'function') return
try {
diff --git a/ds-bot/src/shared/formula.js b/ds-bot/src/shared/formula.js
deleted file mode 100644
index 83787ec8..00000000
--- a/ds-bot/src/shared/formula.js
+++ /dev/null
@@ -1,262 +0,0 @@
-// Formulas in a view blueprint: `{ "=": "price * qty" }`. A small expression language
-// the page works out each time an input moves, so a Bot writes a calculation once and
-// no model call follows. It reads names and calls a fixed set of functions; it has no
-// property access, no assignment and no loops, so it cannot reach the page or run on.
-
-const FUNCTIONS = {
- min: { args: [1, Infinity], run: (...values) => Math.min(...values.map(num)) },
- max: { args: [1, Infinity], run: (...values) => Math.max(...values.map(num)) },
- abs: { args: [1, 1], run: value => Math.abs(num(value)) },
- floor: { args: [1, 1], run: value => Math.floor(num(value)) },
- ceil: { args: [1, 1], run: value => Math.ceil(num(value)) },
- sqrt: { args: [1, 1], run: value => Math.sqrt(num(value)) },
- pow: { args: [2, 2], run: (base, power) => num(base) ** num(power) },
- round: { args: [1, 2], run: (value, digits = 0) => roundTo(num(value), digitsOf(digits)) },
- clamp: { args: [3, 3], run: (value, low, high) => Math.min(Math.max(num(value), num(low)), num(high)) },
- fixed: { args: [1, 2], run: (value, digits = 0) => roundTo(num(value), digitsOf(digits)).toFixed(digitsOf(digits)) },
- format: { args: [1, 2], run: (value, digits = 0) => grouped(num(value), digitsOf(digits)) },
- percent: { args: [1, 2], run: (value, digits = 0) => `${grouped(num(value) * 100, digitsOf(digits))}%` },
-}
-export const FORMULA_FUNCTIONS = Object.keys(FUNCTIONS)
-const CONSTANTS = new Map([['true', true], ['false', false]])
-// Nesting deeper than this is no calculation a view needs; the parser recurses per level.
-const MAX_NESTING = 64
-
-class FormulaError extends Error {}
-const fail = (message) => { throw new FormulaError(message) }
-
-function num(value) {
- if (typeof value === 'number') return value
- if (typeof value === 'boolean') return value ? 1 : 0
- const parsed = Number(value)
- if (typeof value === 'string' && value.trim() !== '' && !Number.isNaN(parsed)) return parsed
- return fail(`${JSON.stringify(value)} is not a number`)
-}
-const digitsOf = (digits) => {
- const value = num(digits)
- if (!Number.isInteger(value) || value < 0 || value > 10) fail('digits must be a whole number from 0 to 10')
- return value
-}
-const roundTo = (value, digits) => {
- const scale = 10 ** digits
- return Math.round(value * scale) / scale
-}
-function grouped(value, digits) {
- if (!Number.isFinite(value)) return String(value)
- const [whole, part] = Math.abs(roundTo(value, digits)).toFixed(digits).split('.')
- const sign = value < 0 && Number(whole + (part ?? '')) !== 0 ? '-' : ''
- return `${sign}${whole.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}${part ? `.${part}` : ''}`
-}
-
-// -------------------------------------------------------------------------
-// Tokens and parsing
-
-const IDENT = /^[A-Za-z_][A-Za-z0-9_]*$/
-export const isName = value => typeof value === 'string' && IDENT.test(value)
-const OPERATORS = ['==', '!=', '<=', '>=', '&&', '||', '+', '-', '*', '/', '%', '<', '>', '!', '?', ':', '(', ')', ',']
-
-function tokenize(source) {
- const tokens = []
- let at = 0
- while (at < source.length) {
- const char = source[at]
- if (/\s/.test(char)) { at += 1; continue }
- const number = /^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/.exec(source.slice(at))
- if (number) { tokens.push({ kind: 'number', value: Number(number[0]), at }); at += number[0].length; continue }
- const name = /^[A-Za-z_][A-Za-z0-9_]*/.exec(source.slice(at))
- if (name) { tokens.push({ kind: 'name', value: name[0], at }); at += name[0].length; continue }
- if (char === '"' || char === '\'') {
- let end = at + 1
- let text = ''
- while (end < source.length && source[end] !== char) {
- if (source[end] === '\\' && end + 1 < source.length) { text += source[end + 1]; end += 2; continue }
- text += source[end]
- end += 1
- }
- if (end >= source.length) fail(`unclosed string at ${at + 1}`)
- tokens.push({ kind: 'string', value: text, at })
- at = end + 1
- continue
- }
- const operator = OPERATORS.find(op => source.startsWith(op, at))
- if (operator === undefined) fail(`unexpected ${JSON.stringify(char)} at ${at + 1}`)
- tokens.push({ kind: 'op', value: operator, at })
- at += operator.length
- }
- return tokens
-}
-
-const BINARY = [['||'], ['&&'], ['==', '!='], ['<', '<=', '>', '>='], ['+', '-'], ['*', '/', '%']]
-
-function parse(source) {
- const tokens = tokenize(source)
- let index = 0
- let depth = 0
- const peek = () => tokens[index]
- const isOp = value => peek()?.kind === 'op' && peek().value === value
- const expect = (value) => {
- if (!isOp(value)) fail(peek() ? `expected "${value}" at ${peek().at + 1}` : `expected "${value}" at the end`)
- index += 1
- }
- const nest = (read) => {
- depth += 1
- if (depth > MAX_NESTING) fail(`nested more than ${MAX_NESTING} levels`)
- const node = read()
- depth -= 1
- return node
- }
- const ternary = () => nest(() => {
- const test = binary(0)
- if (!isOp('?')) return test
- index += 1
- const yes = ternary()
- expect(':')
- return { type: 'if', test, yes, no: ternary() }
- })
- const binary = (level) => {
- if (level === BINARY.length) return unary()
- let left = binary(level + 1)
- while (peek()?.kind === 'op' && BINARY[level].includes(peek().value)) {
- const op = peek().value
- index += 1
- left = { type: 'binary', op, left, right: binary(level + 1) }
- }
- return left
- }
- const unary = () => {
- if (isOp('-') || isOp('!') || isOp('+')) {
- const op = peek().value
- index += 1
- return nest(() => ({ type: 'unary', op, value: unary() }))
- }
- return primary()
- }
- const primary = () => {
- const token = peek()
- if (token === undefined) fail('the formula ends too early')
- index += 1
- if (token.kind === 'number' || token.kind === 'string') return { type: 'value', value: token.value }
- if (token.kind === 'op' && token.value === '(') {
- const inner = ternary()
- expect(')')
- return inner
- }
- if (token.kind !== 'name') fail(`unexpected "${token.value}" at ${token.at + 1}`)
- if (!isOp('(')) return CONSTANTS.has(token.value) ? { type: 'value', value: CONSTANTS.get(token.value) } : { type: 'name', name: token.value }
- const fn = Object.hasOwn(FUNCTIONS, token.value) ? FUNCTIONS[token.value] : undefined
- if (fn === undefined) fail(`unknown function "${token.value}"; allowed: ${FORMULA_FUNCTIONS.join(', ')}`)
- index += 1
- const args = []
- if (!isOp(')')) {
- args.push(ternary())
- while (isOp(',')) { index += 1; args.push(ternary()) }
- }
- expect(')')
- if (args.length < fn.args[0] || args.length > fn.args[1]) {
- fail(`${token.value}() takes ${fn.args[0] === fn.args[1] ? fn.args[0] : fn.args[1] === Infinity ? `at least ${fn.args[0]}` : `${fn.args[0]} or ${fn.args[1]}`} argument${fn.args[1] === 1 ? '' : 's'}; got ${args.length}`)
- }
- return { type: 'call', name: token.value, args }
- }
- if (tokens.length === 0) fail('the formula is empty')
- const tree = ternary()
- if (index < tokens.length) fail(`unexpected "${peek().value}" at ${peek().at + 1}`)
- return tree
-}
-
-function namesIn(node, found = new Set()) {
- if (node.type === 'name') found.add(node.name)
- else if (node.type === 'unary') namesIn(node.value, found)
- else if (node.type === 'binary') { namesIn(node.left, found); namesIn(node.right, found) }
- else if (node.type === 'if') { namesIn(node.test, found); namesIn(node.yes, found); namesIn(node.no, found) }
- else if (node.type === 'call') for (const arg of node.args) namesIn(arg, found)
- return found
-}
-
-// { tree, names } or { error }. `names` are the names the formula reads.
-export function compileFormula(source) {
- if (typeof source !== 'string') return { error: 'expected a formula string' }
- try {
- const tree = parse(source)
- return { tree, names: [...namesIn(tree)] }
- } catch (error) {
- if (error instanceof FormulaError) return { error: error.message }
- throw error
- }
-}
-
-// -------------------------------------------------------------------------
-// Evaluation. `lookup(name)` returns a name's value or throws.
-
-function run(node, lookup) {
- switch (node.type) {
- case 'value': return node.value
- case 'name': return lookup(node.name)
- case 'unary': {
- const value = run(node.value, lookup)
- if (node.op === '!') return !truthy(value)
- return node.op === '-' ? -num(value) : num(value)
- }
- case 'if': return truthy(run(node.test, lookup)) ? run(node.yes, lookup) : run(node.no, lookup)
- case 'call': return FUNCTIONS[node.name].run(...node.args.map(arg => run(arg, lookup)))
- default: return binary(node, lookup)
- }
-}
-const truthy = value => (typeof value === 'string' ? value !== '' : Boolean(value))
-
-function binary(node, lookup) {
- if (node.op === '&&') return truthy(run(node.left, lookup)) ? run(node.right, lookup) : false
- if (node.op === '||') { const left = run(node.left, lookup); return truthy(left) ? left : run(node.right, lookup) }
- const left = run(node.left, lookup)
- const right = run(node.right, lookup)
- switch (node.op) {
- case '+': return typeof left === 'string' || typeof right === 'string' ? `${show(left)}${show(right)}` : num(left) + num(right)
- case '-': return num(left) - num(right)
- case '*': return num(left) * num(right)
- case '/': return num(left) / num(right)
- case '%': return num(left) % num(right)
- case '==': return left === right
- case '!=': return left !== right
- case '<': return num(left) < num(right)
- case '<=': return num(left) <= num(right)
- case '>': return num(left) > num(right)
- default: return num(left) >= num(right)
- }
-}
-
-// A value as text: numbers lose float noise (0.1 + 0.2 shows 0.3).
-export function show(value) {
- if (typeof value === 'number') return Number.isFinite(value) ? String(Number(value.toPrecision(12))) : String(value)
- return String(value)
-}
-
-// A scope for one view: input values, plus `let` names worked out on demand. A cycle
-// or a missing name fails the formula that reads it.
-export function createScope(inputs, lets) {
- const done = new Map()
- const busy = new Set()
- const lookup = (name) => {
- if (inputs.has(name)) return inputs.get(name)
- if (done.has(name)) return done.get(name)
- const tree = lets.get(name)
- if (tree === undefined) fail(`unknown name "${name}"`)
- if (busy.has(name)) fail(`"${name}" refers to itself`)
- busy.add(name)
- try {
- const value = run(tree, lookup)
- done.set(name, value)
- return value
- } finally { busy.delete(name) }
- }
- return lookup
-}
-
-// { value } or { error }.
-export function evaluate(tree, lookup) {
- try {
- return { value: run(tree, lookup) }
- } catch (error) {
- if (error instanceof FormulaError) return { error: error.message }
- if (error instanceof RangeError) return { error: 'the formula is too deep to work out' }
- throw error
- }
-}
diff --git a/ds-bot/src/shared/views.js b/ds-bot/src/shared/views.js
deleted file mode 100644
index 37f3250e..00000000
--- a/ds-bot/src/shared/views.js
+++ /dev/null
@@ -1,685 +0,0 @@
-// View cards: the blueprint a Bot may show, and the answer a user may send back.
-// Pure, so the host can validate a card before it is stored and the client can
-// later render the same blueprint. No component runs model-written code: formulas
-// go through formula.js, and an html component only ever runs in a sandboxed frame.
-
-import { compileFormula, createScope, evaluate, isName, show } from './formula.js'
-
-const LAYOUT = ['stack', 'row']
-const DISPLAY = ['text', 'metric', 'table', 'chart', 'progress', 'callout', 'sources', 'html']
-const INPUT_TYPES = ['slider', 'choice', 'toggle', 'number']
-const ANSWERS = ['options', 'confirm', 'form', 'submit']
-const COMPONENTS = [...LAYOUT, ...DISPLAY, ...INPUT_TYPES, ...ANSWERS]
-const TONES = ['good', 'warn', 'bad']
-const TEXT_TONES = ['muted']
-const CALLOUT_TONES = ['info', 'good', 'warn', 'bad']
-export const CHART_KINDS = ['bar', 'hbar', 'line', 'area', 'donut']
-const INTERACTIVE = new Set(ANSWERS)
-const INPUTS = new Set(INPUT_TYPES)
-const PROPS = {
- stack: ['children', 'let'],
- row: ['children', 'let'],
- text: ['text', 'tone'],
- metric: ['label', 'value', 'tone', 'caption'],
- table: ['columns', 'rows'],
- chart: ['kind', 'categories', 'series', 'unit', 'caption'],
- progress: ['label', 'percent', 'value', 'max', 'valueLabel', 'tone'],
- callout: ['text', 'tone'],
- sources: ['items'],
- html: ['html', 'summary', 'height'],
- slider: ['id', 'label', 'min', 'max', 'step', 'value', 'unit'],
- choice: ['id', 'label', 'options', 'value'],
- toggle: ['id', 'label', 'value'],
- number: ['id', 'label', 'min', 'max', 'step', 'value', 'unit'],
- options: ['id', 'options', 'multi'],
- confirm: ['id', 'confirmLabel', 'cancelLabel'],
- form: ['id', 'fields', 'submitLabel'],
- submit: ['id', 'label'],
-}
-const MAX_DEPTH = 8
-const MAX_NODES = 64
-const MAX_CHILDREN = 16
-const MAX_TEXT = 2000
-const MAX_CELL = 200
-const MAX_COLUMNS = 8
-const MAX_ROWS = 50
-const MAX_OPTIONS = 8
-const MAX_FIELDS = 6
-const SUMMARY_PART = 40
-const SUMMARY_COUNT = 8
-const RESERVED = new Set(['true', 'false'])
-// UTF-8 bytes of the blueprint JSON plus the title. Not a wrapped document:
-// the tool rejects a show_view whose viewBytes() is over this before it
-// normalizes or validates, so the number has to be the bytes the model sent.
-export const VIEW_BYTE_LIMIT = 8192
-
-const isRecord = value => value !== null && typeof value === 'object' && !Array.isArray(value)
-const quoted = value => JSON.stringify(value)
-const allowed = list => list.join(', ')
-const isNumber = value => typeof value === 'number' && Number.isFinite(value)
-const isScalar = value => typeof value === 'string' || typeof value === 'boolean' || isNumber(value)
-
-// `{ "=": "a * b" }`: a value worked out from the view's inputs.
-export const isFormula = value => isRecord(value) && Object.keys(value).length === 1 && Object.hasOwn(value, '=')
-
-export function viewBytes(title, view) {
- return new TextEncoder().encode(`${JSON.stringify(view) ?? ''}${title ?? ''}`).length
-}
-
-const NUMERIC = ['value', 'percent', 'min', 'max', 'step', 'height']
-const numeric = value => (typeof value === 'string' && value.trim() !== '' && !Number.isNaN(Number(value)) ? Number(value) : value)
-
-// Some providers serialize nested arrays as `{ item: [...] }` (XML-style) and
-// numbers as strings. Normalize the blueprint before validation so a model is
-// not asked to retry a call whose only fault is the provider's encoding.
-// Arrays are unwrapped; numeric fields and chart values accept a numeric string.
-// Returns a new object; the input is not mutated.
-export function normalizeView(value) {
- if (Array.isArray(value)) return value.map(normalizeView)
- if (!isRecord(value)) return value
- const keys = Object.keys(value)
- // Unwrap recursively: a provider may nest the wrapper, as { item: { item: [...] } }.
- if (keys.length === 1 && keys[0] === 'item') {
- const inner = normalizeView(value.item)
- if (Array.isArray(inner)) return inner
- }
- // Define own properties: an incoming "__proto__" key must become data the
- // validator can reject, not hit the prototype setter and vanish from the JSON.
- const out = {}
- for (const key of keys) Object.defineProperty(out, key, { value: normalizeView(value[key]), writable: true, enumerable: true, configurable: true })
- for (const field of NUMERIC) if (Object.hasOwn(out, field)) out[field] = numeric(out[field])
- if (Array.isArray(out.values)) out.values = out.values.map(numeric)
- return out
-}
-
-export function validateView(view) {
- const ctx = { ids: new Set(), nodes: 0, interactive: false, inputs: new Map(), lets: new Map(), formulas: [] }
- const error = checkNode(view, 'view', 1, ctx) ?? checkFormulas(ctx)
- return error === undefined ? { ok: true, interactive: ctx.interactive } : { ok: false, error }
-}
-
-// What show_view checks before it shows a view: the same answer on the host and
-// in the client. The bytes are measured as sent, before normalizeView unwraps the
-// provider's encoding, or a wrapped view could shrink under the byte limit. The
-// normalized view and the trimmed title come back; the title may be empty.
-export function checkShownView(title, sent) {
- let bytes
- try { bytes = viewBytes(title, sent) } catch { return { error: 'The view is not JSON data.' } }
- if (bytes > VIEW_BYTE_LIMIT) return { error: `The view is ${bytes} bytes; the limit is ${VIEW_BYTE_LIMIT}.` }
- if (title !== undefined && title !== null && typeof title !== 'string') return { error: 'title: expected a string' }
- const named = String(title ?? '').trim()
- const view = normalizeView(sent)
- const checked = validateView(view)
- if (!checked.ok) return { error: checked.error }
- return { title: named, view, interactive: checked.interactive }
-}
-
-function checkNode(node, path, depth, ctx) {
- if (!isRecord(node)) return `${path}: expected a component object`
- if (depth > MAX_DEPTH) return `${path}: ${depth} levels exceeds the limit of ${MAX_DEPTH}`
- ctx.nodes += 1
- if (ctx.nodes > MAX_NODES) return `${path}: ${ctx.nodes} components exceeds the limit of ${MAX_NODES}`
- const type = node.type
- if (!COMPONENTS.includes(type)) return `${path}.type: unknown component ${quoted(type)}; allowed: ${allowed(COMPONENTS)}`
- const props = PROPS[type]
- for (const key of Object.keys(node)) {
- if (key === 'type' || props.includes(key)) continue
- return `${path}.${key}: unknown property ${quoted(key)}; allowed: ${allowed(props)}`
- }
- if (INTERACTIVE.has(type)) ctx.interactive = true
- switch (type) {
- case 'stack': case 'row': return checkLayout(node, path, depth, ctx)
- case 'text': return checkText(node, path, ctx)
- case 'metric': return checkMetric(node, path, ctx)
- case 'table': return checkTable(node, path, ctx)
- case 'chart': return checkChart(node, path, ctx)
- case 'progress': return checkProgress(node, path, ctx)
- case 'callout': return checkCallout(node, path, ctx)
- case 'sources': return checkSources(node, path)
- case 'html': return checkHtml(node, path)
- case 'slider': case 'number': return checkNumberInput(node, path, ctx)
- case 'choice': return checkChoice(node, path, ctx)
- case 'toggle': return checkToggle(node, path, ctx)
- case 'options': return checkOptions(node, path, ctx)
- case 'confirm': return checkConfirm(node, path, ctx)
- case 'form': return checkForm(node, path, ctx)
- default: return checkSubmit(node, path, ctx)
- }
-}
-
-function checkLayout(node, path, depth, ctx) {
- if (node.let !== undefined) {
- if (depth !== 1) return `${path}.let: only the outermost component can define names`
- if (!isRecord(node.let)) return `${path}.let: expected an object of names to formulas`
- for (const [name, source] of Object.entries(node.let)) {
- if (!isName(name) || RESERVED.has(name)) return `${path}.let.${name}: a name is letters, digits and _, and starts with a letter or _`
- if (typeof source !== 'string') return `${path}.let.${name}: expected a formula string`
- ctx.lets.set(name, { source, path: `${path}.let.${name}` })
- }
- }
- if (!Array.isArray(node.children)) return `${path}.children: expected an array of 1 to ${MAX_CHILDREN} components`
- if (node.children.length < 1 || node.children.length > MAX_CHILDREN) return `${path}.children: expected 1 to ${MAX_CHILDREN} children; got ${node.children.length}`
- for (let index = 0; index < node.children.length; index += 1) {
- const error = checkNode(node.children[index], `${path}.children[${index}]`, depth + 1, ctx)
- if (error !== undefined) return error
- }
- return undefined
-}
-
-// A property that may be a literal of `kind` or a formula giving one. Formulas are
-// checked once the whole tree, with every input and name, is known.
-function checkValue(node, key, path, ctx, kind, { required = false, max = MAX_TEXT } = {}) {
- const value = node[key]
- const at = `${path}.${key}`
- if (value === undefined) return required ? `${at}: ${expected(kind)}` : undefined
- if (isFormula(value)) {
- ctx.formulas.push({ source: value['='], path: at, kind })
- return undefined
- }
- if (kind === 'number') return isNumber(value) ? undefined : `${at}: ${expected(kind)}`
- if (Array.isArray(kind)) return kind.includes(value) ? undefined : `${at}: unknown tone ${quoted(value)}; allowed: ${allowed(kind)}`
- if (kind === 'string') {
- if (typeof value !== 'string') return `${at}: ${expected(kind)}`
- return value.length > max ? `${at}: ${value.length} characters exceeds the limit of ${max}` : undefined
- }
- if (!isScalar(value)) return `${at}: ${expected(kind)}`
- return undefined
-}
-const expected = kind => (kind === 'number' ? 'expected a number' : kind === 'string' ? 'expected a string' : Array.isArray(kind) ? `expected one of ${allowed(kind)}` : 'expected a string or a number')
-
-function checkText(node, path, ctx) {
- return checkValue(node, 'text', path, ctx, 'string', { required: true })
- ?? checkValue(node, 'tone', path, ctx, TEXT_TONES)
-}
-
-function checkMetric(node, path, ctx) {
- if (typeof node.label !== 'string') return `${path}.label: expected a string`
- if (node.value === undefined) return `${path}.value: expected a string or a number`
- if (typeof node.value === 'number' && !Number.isFinite(node.value)) return `${path}.value: expected a finite number`
- return checkValue(node, 'value', path, ctx, 'scalar')
- ?? checkValue(node, 'tone', path, ctx, TONES)
- ?? checkValue(node, 'caption', path, ctx, 'string')
-}
-
-function checkTable(node, path, ctx) {
- if (!Array.isArray(node.columns)) return `${path}.columns: expected an array of at most ${MAX_COLUMNS} columns`
- if (node.columns.length > MAX_COLUMNS) return `${path}.columns: ${node.columns.length} columns exceeds the limit of ${MAX_COLUMNS}`
- for (let index = 0; index < node.columns.length; index += 1) {
- const column = node.columns[index]
- const at = `${path}.columns[${index}]`
- if (!isRecord(column)) return `${at}: expected a column object`
- for (const key of Object.keys(column)) {
- if (key !== 'key' && key !== 'label') return `${at}.${key}: unknown property ${quoted(key)}; allowed: key, label`
- }
- if (typeof column.key !== 'string' || column.key === '') return `${at}.key: expected a non-empty string`
- if (typeof column.label !== 'string') return `${at}.label: expected a string`
- }
- if (!Array.isArray(node.rows)) return `${path}.rows: expected an array of at most ${MAX_ROWS} rows`
- if (node.rows.length > MAX_ROWS) return `${path}.rows: ${node.rows.length} rows exceeds the limit of ${MAX_ROWS}`
- for (let row = 0; row < node.rows.length; row += 1) {
- const cells = node.rows[row]
- if (!Array.isArray(cells)) return `${path}.rows[${row}]: expected an array of cells`
- for (let column = 0; column < cells.length; column += 1) {
- const at = `${path}.rows[${row}][${column}]`
- if (isFormula(cells[column])) { ctx.formulas.push({ source: cells[column]['='], path: at, kind: 'scalar' }); continue }
- const text = cellText(cells[column])
- if (text.length > MAX_CELL) return `${at}: ${text.length} characters exceeds the limit of ${MAX_CELL}`
- }
- }
- return undefined
-}
-
-function checkChart(node, path, ctx) {
- if (node.kind !== undefined && !CHART_KINDS.includes(node.kind)) return `${path}.kind: unknown chart ${quoted(node.kind)}; allowed: ${allowed(CHART_KINDS)}`
- if (!Array.isArray(node.categories) || node.categories.length === 0) return `${path}.categories: expected a non-empty array of labels`
- for (let index = 0; index < node.categories.length; index += 1) {
- const label = node.categories[index]
- if (typeof label !== 'string' && !isNumber(label)) return `${path}.categories[${index}]: expected a string`
- }
- if (!Array.isArray(node.series) || node.series.length === 0) return `${path}.series: expected a non-empty array of { name?, values }`
- if (node.kind === 'donut' && node.series.length > 1) return `${path}.series: a donut takes one series; got ${node.series.length}`
- for (let index = 0; index < node.series.length; index += 1) {
- const series = node.series[index]
- const at = `${path}.series[${index}]`
- if (!isRecord(series)) return `${at}: expected a series object`
- for (const key of Object.keys(series)) {
- if (key !== 'name' && key !== 'values') return `${at}.${key}: unknown property ${quoted(key)}; allowed: name, values`
- }
- if (series.name !== undefined && typeof series.name !== 'string') return `${at}.name: expected a string`
- if (!Array.isArray(series.values)) return `${at}.values: expected an array of numbers`
- if (series.values.length !== node.categories.length) return `${at}.values: ${series.values.length} values for ${node.categories.length} categories`
- for (let item = 0; item < series.values.length; item += 1) {
- const value = series.values[item]
- if (isFormula(value)) ctx.formulas.push({ source: value['='], path: `${at}.values[${item}]`, kind: 'number' })
- else if (!isNumber(value)) return `${at}.values[${item}]: expected a number`
- }
- }
- if (node.unit !== undefined && typeof node.unit !== 'string') return `${path}.unit: expected a string`
- if (node.caption !== undefined && typeof node.caption !== 'string') return `${path}.caption: expected a string`
- return undefined
-}
-
-function checkProgress(node, path, ctx) {
- if (node.label !== undefined && typeof node.label !== 'string') return `${path}.label: expected a string`
- if ((node.percent === undefined) === (node.value === undefined)) return `${path}: give percent (0 to 100), or value with max`
- if (node.percent !== undefined && !isFormula(node.percent)) {
- if (typeof node.percent !== 'number' || !Number.isFinite(node.percent) || node.percent < 0 || node.percent > 100) return `${path}.percent: expected a number from 0 to 100`
- }
- if (node.value !== undefined && node.max === undefined) return `${path}.max: expected a number with value`
- if (node.value === undefined && node.max !== undefined) return `${path}.value: expected a number with max`
- return checkValue(node, 'percent', path, ctx, 'number')
- ?? checkValue(node, 'value', path, ctx, 'number')
- ?? checkValue(node, 'max', path, ctx, 'number')
- ?? checkValue(node, 'valueLabel', path, ctx, 'scalar')
- ?? checkValue(node, 'tone', path, ctx, TONES)
-}
-
-function checkCallout(node, path, ctx) {
- return checkValue(node, 'text', path, ctx, 'string', { required: true })
- ?? checkValue(node, 'tone', path, ctx, CALLOUT_TONES)
-}
-
-function checkSources(node, path) {
- if (!Array.isArray(node.items) || node.items.length === 0) return `${path}.items: expected a non-empty array of { label, url }`
- for (let index = 0; index < node.items.length; index += 1) {
- const item = node.items[index]
- const at = `${path}.items[${index}]`
- if (!isRecord(item)) return `${at}: expected a { label, url } object`
- for (const key of Object.keys(item)) {
- if (key !== 'label' && key !== 'url') return `${at}.${key}: unknown property ${quoted(key)}; allowed: label, url`
- }
- if (typeof item.label !== 'string' || item.label.trim() === '') return `${at}.label: expected a non-empty string`
- if (typeof item.url !== 'string' || !/^https?:\/\/[^\s]+$/i.test(item.url)) return `${at}.url: expected an http(s) address`
- }
- return undefined
-}
-
-function checkHtml(node, path) {
- if (typeof node.html !== 'string' || node.html.trim() === '') return `${path}.html: expected a non-empty string`
- if (typeof node.summary !== 'string' || node.summary.trim() === '') return `${path}.summary: expected one line that says what the view shows`
- if (node.height !== undefined && (!isNumber(node.height) || node.height <= 0)) return `${path}.height: expected a positive number of pixels`
- return undefined
-}
-
-function checkInputId(node, path, ctx) {
- if (!isName(node.id) || RESERVED.has(node.id)) return `${path}.id: an input id is letters, digits and _, and starts with a letter or _, so formulas can use it`
- if (ctx.ids.has(node.id)) return `${path}.id: duplicate id ${quoted(node.id)}`
- ctx.ids.add(node.id)
- if (typeof node.label !== 'string') return `${path}.label: expected a string`
- return undefined
-}
-
-function checkNumberInput(node, path, ctx) {
- const idError = checkInputId(node, path, ctx)
- if (idError !== undefined) return idError
- for (const key of ['min', 'max', 'step']) {
- if (node[key] !== undefined && !isNumber(node[key])) return `${path}.${key}: expected a number`
- }
- if (node.type === 'slider' && (node.min === undefined || node.max === undefined)) return `${path}: a slider needs min and max`
- if (node.min !== undefined && node.max !== undefined && node.max <= node.min) return `${path}.max: expected more than min (${node.min})`
- if (node.step !== undefined && node.step <= 0) return `${path}.step: expected more than 0`
- if (!isNumber(node.value)) return `${path}.value: expected a number`
- if ((node.min !== undefined && node.value < node.min) || (node.max !== undefined && node.value > node.max)) return `${path}.value: expected a number from ${node.min ?? '-∞'} to ${node.max ?? '∞'}`
- if (node.unit !== undefined && typeof node.unit !== 'string') return `${path}.unit: expected a string`
- ctx.inputs.set(node.id, node.value)
- return undefined
-}
-
-function checkChoice(node, path, ctx) {
- const idError = checkInputId(node, path, ctx)
- if (idError !== undefined) return idError
- if (!Array.isArray(node.options) || node.options.length === 0) return `${path}.options: expected a non-empty array of { label, value }`
- const labels = new Set()
- const values = new Set()
- for (let index = 0; index < node.options.length; index += 1) {
- const option = node.options[index]
- const at = `${path}.options[${index}]`
- if (!isRecord(option)) return `${at}: expected a { label, value } object`
- for (const key of Object.keys(option)) {
- if (key !== 'label' && key !== 'value') return `${at}.${key}: unknown property ${quoted(key)}; allowed: label, value`
- }
- if (typeof option.label !== 'string' || option.label.trim() === '') return `${at}.label: expected a non-empty string`
- if (labels.has(option.label)) return `${at}.label: duplicate label ${quoted(option.label)}`
- labels.add(option.label)
- const value = option.value ?? option.label
- if (!isScalar(value)) return `${at}.value: expected a string, a number or true/false`
- if (values.has(value)) return `${at}.value: duplicate value ${quoted(value)}`
- values.add(value)
- }
- const chosen = node.value ?? choiceValue(node.options[0])
- if (!values.has(chosen)) return `${path}.value: expected one of the options' values`
- ctx.inputs.set(node.id, chosen)
- return undefined
-}
-
-function checkToggle(node, path, ctx) {
- const idError = checkInputId(node, path, ctx)
- if (idError !== undefined) return idError
- if (node.value !== undefined && typeof node.value !== 'boolean') return `${path}.value: expected true or false`
- ctx.inputs.set(node.id, node.value === true)
- return undefined
-}
-
-function checkOptions(node, path, ctx) {
- const idError = checkId(node, path, ctx)
- if (idError !== undefined) return idError
- if (node.multi !== undefined && typeof node.multi !== 'boolean') return `${path}.multi: expected a boolean`
- if (!Array.isArray(node.options)) return `${path}.options: expected an array of 1 to ${MAX_OPTIONS} options`
- if (node.options.length < 1 || node.options.length > MAX_OPTIONS) return `${path}.options: expected 1 to ${MAX_OPTIONS} options; got ${node.options.length}`
- const labels = new Set()
- for (let index = 0; index < node.options.length; index += 1) {
- const option = node.options[index]
- const at = `${path}.options[${index}]`
- if (!isRecord(option)) return `${at}: expected an option object`
- for (const key of Object.keys(option)) {
- if (key !== 'label' && key !== 'description') return `${at}.${key}: unknown property ${quoted(key)}; allowed: label, description`
- }
- if (typeof option.label !== 'string' || option.label.trim() === '') return `${at}.label: expected a non-empty string`
- if (labels.has(option.label)) return `${at}.label: duplicate label ${quoted(option.label)}`
- labels.add(option.label)
- if (option.description !== undefined && typeof option.description !== 'string') return `${at}.description: expected a string`
- }
- return undefined
-}
-
-function checkConfirm(node, path, ctx) {
- const idError = checkId(node, path, ctx)
- if (idError !== undefined) return idError
- if (node.confirmLabel !== undefined && typeof node.confirmLabel !== 'string') return `${path}.confirmLabel: expected a string`
- if (node.cancelLabel !== undefined && typeof node.cancelLabel !== 'string') return `${path}.cancelLabel: expected a string`
- return undefined
-}
-
-function checkForm(node, path, ctx) {
- const idError = checkId(node, path, ctx)
- if (idError !== undefined) return idError
- if (node.submitLabel !== undefined && typeof node.submitLabel !== 'string') return `${path}.submitLabel: expected a string`
- if (!Array.isArray(node.fields)) return `${path}.fields: expected an array of at most ${MAX_FIELDS} fields`
- if (node.fields.length > MAX_FIELDS) return `${path}.fields: ${node.fields.length} fields exceeds the limit of ${MAX_FIELDS}`
- const seen = new Set()
- for (let index = 0; index < node.fields.length; index += 1) {
- const field = node.fields[index]
- const at = `${path}.fields[${index}]`
- if (!isRecord(field)) return `${at}: expected a field object`
- for (const key of Object.keys(field)) {
- if (key !== 'id' && key !== 'label' && key !== 'placeholder') return `${at}.${key}: unknown property ${quoted(key)}; allowed: id, label, placeholder`
- }
- if (typeof field.id !== 'string' || field.id === '') return `${at}.id: expected a non-empty string`
- if (field.id === '__proto__') return `${at}.id: "__proto__" cannot be an id`
- if (seen.has(field.id)) return `${at}.id: duplicate field id ${quoted(field.id)}`
- seen.add(field.id)
- if (typeof field.label !== 'string') return `${at}.label: expected a string`
- if (field.placeholder !== undefined && typeof field.placeholder !== 'string') return `${at}.placeholder: expected a string`
- }
- return undefined
-}
-
-function checkSubmit(node, path, ctx) {
- const idError = checkId(node, path, ctx)
- if (idError !== undefined) return idError
- if (node.label !== undefined && typeof node.label !== 'string') return `${path}.label: expected a string`
- return undefined
-}
-
-function checkId(node, path, ctx) {
- if (typeof node.id !== 'string' || node.id === '') return `${path}.id: expected a non-empty string`
- // A `__proto__` id would write through to a plain object's prototype where the
- // answer is kept, losing it silently.
- if (node.id === '__proto__') return `${path}.id: "__proto__" cannot be an id`
- if (ctx.ids.has(node.id)) return `${path}.id: duplicate id ${quoted(node.id)}`
- ctx.ids.add(node.id)
- return undefined
-}
-
-// Every formula parses, reads only inputs and names the view defines, and gives the
-// right kind of value with the inputs as the Bot set them.
-function checkFormulas(ctx) {
- const known = new Set([...ctx.inputs.keys(), ...ctx.lets.keys()])
- const lets = new Map()
- for (const [name, entry] of ctx.lets) {
- if (ctx.inputs.has(name)) return `${entry.path}: ${quoted(name)} is already an input id`
- const compiled = compileFormula(entry.source)
- if (compiled.error !== undefined) return `${entry.path}: ${compiled.error}`
- const unknown = compiled.names.find(item => !known.has(item))
- if (unknown !== undefined) return `${entry.path}: unknown name ${quoted(unknown)}; known: ${allowed([...known]) || '(none)'}`
- lets.set(name, compiled.tree)
- }
- const lookup = createScope(ctx.inputs, lets)
- for (const [name, entry] of ctx.lets) {
- const result = evaluate(lets.get(name), lookup)
- if (result.error !== undefined) return `${entry.path}: ${result.error}`
- }
- for (const formula of ctx.formulas) {
- const compiled = compileFormula(formula.source)
- if (compiled.error !== undefined) return `${formula.path}: ${compiled.error}`
- const unknown = compiled.names.find(item => !known.has(item))
- if (unknown !== undefined) return `${formula.path}: unknown name ${quoted(unknown)}; known: ${allowed([...known]) || '(none)'}`
- const result = evaluate(compiled.tree, lookup)
- if (result.error !== undefined) return `${formula.path}: ${result.error}`
- const problem = kindProblem(result.value, formula.kind)
- if (problem !== undefined) return `${formula.path}: the formula gives ${quoted(result.value)}; ${problem}`
- }
- return undefined
-}
-
-function kindProblem(value, kind) {
- if (kind === 'number') return isNumber(value) ? undefined : 'expected a number'
- if (Array.isArray(kind)) return kind.includes(value) ? undefined : `expected one of ${allowed(kind)}`
- if (kind === 'string') return isScalar(value) ? undefined : 'expected text'
- return isScalar(value) ? undefined : 'expected a string or a number'
-}
-
-function cellText(value) {
- if (typeof value === 'string') return value
- const text = JSON.stringify(value)
- return typeof text === 'string' ? text : ''
-}
-
-// -------------------------------------------------------------------------
-// Working a blueprint out: the client draws with these, the summary reads them.
-
-const compiled = new WeakMap()
-const treeOf = (formula) => {
- let entry = compiled.get(formula)
- if (entry === undefined) {
- entry = compileFormula(formula['='])
- compiled.set(formula, entry)
- }
- return entry
-}
-
-export const choiceValue = option => option?.value ?? option?.label
-
-function walk(node, visit) {
- if (!isRecord(node)) return
- visit(node)
- if (LAYOUT.includes(node.type) && Array.isArray(node.children)) for (const child of node.children) walk(child, visit)
-}
-
-export function viewInputs(view) {
- const found = []
- walk(view, (node) => { if (INPUTS.has(node.type)) found.push(node) })
- return found
-}
-
-export function inputDefault(node) {
- if (node.type === 'toggle') return node.value === true
- if (node.type === 'choice') return node.value ?? choiceValue(Array.isArray(node.options) ? node.options[0] : undefined)
- return node.value
-}
-
-export const hasInputs = view => viewInputs(view).length > 0
-
-// The values a view's formulas read: each input's default unless `values` sets it.
-export function viewScope(view, values = {}) {
- const inputs = new Map()
- for (const node of viewInputs(view)) inputs.set(node.id, Object.hasOwn(values, node.id) ? values[node.id] : inputDefault(node))
- const lets = new Map()
- for (const [name, source] of Object.entries(isRecord(view?.let) ? view.let : {})) {
- const entry = compileFormula(source)
- if (entry.tree !== undefined) lets.set(name, entry.tree)
- }
- return createScope(inputs, lets)
-}
-
-// A property's value: the literal, or the formula worked out. A formula that fails
-// with these inputs gives `fallback`.
-export function resolve(value, lookup, fallback = undefined) {
- if (!isFormula(value)) return value
- const entry = treeOf(value)
- if (entry.tree === undefined) return fallback
- const result = evaluate(entry.tree, lookup)
- return result.error === undefined ? result.value : fallback
-}
-
-export const asText = value => (value === undefined || value === null ? '' : show(value))
-
-// -------------------------------------------------------------------------
-// Summaries
-
-function clip(text) {
- const flat = String(text).replace(/\s+/g, ' ').trim()
- return flat.length <= SUMMARY_PART ? flat : flat.slice(0, SUMMARY_PART)
-}
-
-const choiceLabel = (node, value) => (Array.isArray(node.options) ? node.options : []).find(option => choiceValue(option) === value)?.label ?? asText(value)
-
-function inputText(node, value) {
- if (node.type === 'toggle') return value === true ? 'on' : 'off'
- if (node.type === 'choice') return choiceLabel(node, value)
- return `${asText(value)}${node.unit ? ` ${node.unit}` : ''}`
-}
-
-function progressPercent(node, lookup) {
- if (node.percent !== undefined) return Number(resolve(node.percent, lookup, 0))
- const max = Number(resolve(node.max, lookup, 0))
- return max > 0 ? (Number(resolve(node.value, lookup, 0)) / max) * 100 : 0
-}
-
-function componentSummary(node, lookup) {
- const value = item => asText(resolve(item, lookup, ''))
- switch (node.type) {
- case 'text': return `text: ${value(node.text)}`
- case 'metric': return `metric: ${node.label}=${value(node.value)}`
- case 'table': return `table: ${(Array.isArray(node.columns) ? node.columns : []).map(column => column?.label ?? column?.key ?? '').filter(Boolean).join('/')}`
- case 'chart': {
- const series = Array.isArray(node.series) ? node.series[0] : undefined
- const values = Array.isArray(series?.values) ? series.values : []
- const unit = node.unit ? ` ${node.unit}` : ''
- return `chart: ${(Array.isArray(node.categories) ? node.categories : []).map((label, index) => `${label}=${value(values[index])}${unit}`).join(', ')}`
- }
- case 'progress': return `progress: ${node.label ? `${node.label} ` : ''}${Math.round(progressPercent(node, lookup))}%`
- case 'callout': return `callout: ${value(node.text)}`
- case 'sources': return `sources: ${(Array.isArray(node.items) ? node.items : []).map(item => item?.label).filter(Boolean).join('/')}`
- case 'html': return `html: ${node.summary ?? ''}`
- case 'slider': case 'number': case 'choice': case 'toggle': return `${node.type}: ${node.label}=${inputText(node, inputDefault(node))}`
- case 'options': return `options: ${(Array.isArray(node.options) ? node.options : []).map(option => option?.label).filter(Boolean).join('/')}`
- case 'confirm': return 'confirm'
- case 'form': return `form: ${(Array.isArray(node.fields) ? node.fields : []).map(field => field?.label ?? field?.id).filter(Boolean).join('/')}`
- case 'submit': return `submit: ${node.label ?? 'Send'}`
- default: return undefined
- }
-}
-
-// One line for a handoff or a checkpoint. Containers add nothing of their own;
-// each component keeps one short phrase, and the line stops after a few. Formulas
-// show what they give with the inputs as the Bot set them.
-export function viewSummary(view) {
- const parts = []
- const lookup = viewScope(view)
- const visit = (node) => {
- if (parts.length >= SUMMARY_COUNT || !isRecord(node)) return
- const line = componentSummary(node, lookup)
- if (line !== undefined) parts.push(clip(line))
- if (parts.length >= SUMMARY_COUNT || !LAYOUT.includes(node.type) || !Array.isArray(node.children)) return
- for (const child of node.children) visit(child)
- }
- visit(view)
- return parts.join('; ')
-}
-
-// The inputs of an answer as `Label=value` pairs, for the Bot's history.
-export function inputsSummary(view, inputs) {
- if (!isRecord(inputs)) return ''
- return viewInputs(view)
- .filter(node => Object.hasOwn(inputs, node.id))
- .map(node => `${node.label || node.id}=${inputText(node, inputs[node.id])}`)
- .join('; ')
-}
-
-// -------------------------------------------------------------------------
-// Answers
-
-function interactiveNodes(node, found = []) {
- walk(node, (item) => { if (INTERACTIVE.has(item.type)) found.push(item) })
- return found
-}
-
-// `action` is the id of the component the user submitted. One submit settles
-// the whole card, so only that component's values are kept, plus the inputs'
-// values when the view has inputs.
-export function validateViewAnswer(view, action, values) {
- const nodes = interactiveNodes(view)
- if (typeof action !== 'string' || action === '') return { error: `action: expected an interactive component id; allowed: ${allowed(nodes.map(node => node.id))}` }
- const node = nodes.find(item => item.id === action)
- if (node === undefined) return { error: `action: no interactive component with id ${quoted(action)}; allowed: ${allowed(nodes.map(item => item.id))}` }
- if (!isRecord(values)) return { error: 'values: expected an object' }
- const inputs = validateInputs(view, values.inputs)
- if (inputs.error !== undefined) return inputs
- const extra = inputs.inputs === undefined ? {} : { inputs: inputs.inputs }
- if (node.type === 'submit') return { ...extra }
- const own = node.type === 'options' ? validateOptions(node, values) : node.type === 'confirm' ? validateConfirm(values) : validateForm(node, values)
- return own.error === undefined ? { ...own, ...extra } : own
-}
-
-// Every input of the view, as sent or else as the Bot set it.
-function validateInputs(view, sent) {
- const nodes = viewInputs(view)
- if (nodes.length === 0) return sent === undefined ? {} : { error: 'values.inputs: this view has no inputs' }
- if (sent !== undefined && !isRecord(sent)) return { error: 'values.inputs: expected an object of input ids to values' }
- const given = sent ?? {}
- const ids = nodes.map(node => node.id)
- const unknown = Object.keys(given).find(key => !ids.includes(key))
- if (unknown !== undefined) return { error: `values.inputs.${unknown}: unknown input; allowed: ${allowed(ids)}` }
- const inputs = {}
- for (const node of nodes) {
- const value = Object.hasOwn(given, node.id) ? given[node.id] : inputDefault(node)
- const at = `values.inputs.${node.id}`
- if (node.type === 'toggle' && typeof value !== 'boolean') return { error: `${at}: expected true or false` }
- if (node.type === 'choice' && !(Array.isArray(node.options) ? node.options : []).some(option => choiceValue(option) === value)) return { error: `${at}: expected one of the options' values` }
- if (node.type === 'slider' || node.type === 'number') {
- if (!isNumber(value)) return { error: `${at}: expected a number` }
- if ((node.min !== undefined && value < node.min) || (node.max !== undefined && value > node.max)) return { error: `${at}: expected a number from ${node.min ?? '-∞'} to ${node.max ?? '∞'}` }
- }
- inputs[node.id] = value
- }
- return { inputs }
-}
-
-function validateOptions(node, values) {
- if (!Array.isArray(values.selected)) return { error: 'values.selected: expected an array of option labels' }
- const labels = new Set((node.options ?? []).map(option => option?.label))
- const picked = values.selected.filter(label => typeof label === 'string' && labels.has(label))
- const selected = node.multi === true ? [...new Set(picked)] : picked.slice(0, 1)
- if (selected.length === 0) return { error: 'values.selected: select at least one option' }
- return { selected }
-}
-
-function validateConfirm(values) {
- if (typeof values.confirmed !== 'boolean') return { error: 'values.confirmed: expected a boolean' }
- return { confirmed: values.confirmed }
-}
-
-function validateForm(node, values) {
- if (!isRecord(values.fields)) return { error: 'values.fields: expected an object of field ids to strings' }
- const declared = (node.fields ?? []).map(field => field?.id).filter(id => typeof id === 'string')
- const allowedIds = new Set(declared)
- const fields = {}
- for (const [key, value] of Object.entries(values.fields)) {
- if (!allowedIds.has(key)) return { error: `values.fields.${key}: unknown field; allowed: ${allowed(declared)}` }
- if (typeof value !== 'string') return { error: `values.fields.${key}: expected a string` }
- if (value.length > MAX_TEXT) return { error: `values.fields.${key}: ${value.length} characters exceeds the limit of ${MAX_TEXT}` }
- fields[key] = value
- }
- return { fields }
-}
diff --git a/ds-bot/test/about.test.js b/ds-bot/test/about.test.js
index 488c6b12..693bc063 100644
--- a/ds-bot/test/about.test.js
+++ b/ds-bot/test/about.test.js
@@ -10,6 +10,12 @@ const bundle = await build({
external: ['react', 'react-dom', '@deepseek-ai/dsh-client-ui-primitives'],
})
const react = {
+ createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx },
+ useContext: ctx => ctx.value,
+ useMemo: make => make(),
+ useCallback: fn => fn,
+ useId: () => 'dui-id',
+ useSyncExternalStore: (subscribe, getSnapshot) => getSnapshot(),
createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }),
Fragment: 'fragment',
useState: initial => [initial, () => {}],
diff --git a/ds-bot/test/account-sign-out.test.js b/ds-bot/test/account-sign-out.test.js
index 4c3403e5..78f78513 100644
--- a/ds-bot/test/account-sign-out.test.js
+++ b/ds-bot/test/account-sign-out.test.js
@@ -18,6 +18,9 @@ const { outputFiles } = await build({
const slots = []
let cursor = 0
const react = {
+ createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx },
+ useContext: ctx => ctx.value,
+ useCallback: fn => fn,
createElement: (type, props, ...children) => ({ type, props: { ...props, children } }), Fragment: Symbol('Fragment'),
useState(initial) {
const i = cursor++
diff --git a/ds-bot/test/activity-row.test.js b/ds-bot/test/activity-row.test.js
index 17700163..441bd67d 100644
--- a/ds-bot/test/activity-row.test.js
+++ b/ds-bot/test/activity-row.test.js
@@ -24,6 +24,10 @@ const { outputFiles } = await build({
external: ['react', 'react-dom', '@deepseek-ai/dsh-client-ui-primitives'],
})
const react = {
+ createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx },
+ useContext: ctx => ctx.value,
+ useCallback: fn => fn,
+ useSyncExternalStore: (subscribe, getSnapshot) => getSnapshot(),
createElement: (type, props, ...children) => ({ type, props: { ...props, children } }), Fragment: Symbol('Fragment'),
useEffect() {}, useLayoutEffect() {}, useState: initial => [initial, () => {}],
useMemo: make => make(), useRef: current => ({ current }), useId: () => 'id',
diff --git a/ds-bot/test/agents.test.js b/ds-bot/test/agents.test.js
index cb1b2608..aae47e1d 100644
--- a/ds-bot/test/agents.test.js
+++ b/ds-bot/test/agents.test.js
@@ -205,7 +205,8 @@ test('TEAM_TOOLS names exactly the tools ds-bot registers', async (t) => {
// read_browser registers only in the Desktop profile; the flag stands in for it.
const { stop, ctx } = start(TEAM, { config: { browser: true } })
t.after(stop)
- assert.deepEqual([...ctx.registeredTools.keys()].sort(), [...TEAM_TOOLS].sort())
+ // show_view registers in each Bot agent's own scope, so it is not a global one.
+ assert.deepEqual([...ctx.registeredTools.keys()].sort(), [...TEAM_TOOLS].filter(name => name !== 'show_view').sort())
})
test('agent-session honors a known workspace and falls back to the team workspace', async (t) => {
diff --git a/ds-bot/test/bot-mark.test.js b/ds-bot/test/bot-mark.test.js
index 507e29f3..983a2cbe 100644
--- a/ds-bot/test/bot-mark.test.js
+++ b/ds-bot/test/bot-mark.test.js
@@ -15,6 +15,12 @@ const module = { exports: {} }
const states = []
const sets = []
const react = {
+ createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx },
+ useContext: ctx => ctx.value,
+ useMemo: make => make(),
+ useCallback: fn => fn,
+ useId: () => 'dui-id',
+ useSyncExternalStore: (subscribe, getSnapshot) => getSnapshot(),
createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }),
useState: initial => [states.length > 0 ? states.shift() : initial, value => sets.push(value)], useEffect: () => {}, useRef: current => ({ current }), useLayoutEffect: () => {}, Fragment: 'fragment',
}
diff --git a/ds-bot/test/btw-client.test.js b/ds-bot/test/btw-client.test.js
index dfc4b4ed..9fd1ed64 100644
--- a/ds-bot/test/btw-client.test.js
+++ b/ds-bot/test/btw-client.test.js
@@ -284,7 +284,7 @@ runInNewContext(btwBundle.outputFiles[0].text, {
window: { addEventListener() {}, removeEventListener() {}, innerWidth: 1280 },
require: (name) => {
const platform = {
- react: {
+ react: { createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx }, useContext: ctx => ctx.value, useId: () => 'dui-id',
createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }),
useState: init => [typeof init === 'function' ? init() : init, () => {}],
useEffect: () => {}, useRef: () => ({ current: null }),
diff --git a/ds-bot/test/card-hold.test.js b/ds-bot/test/card-hold.test.js
index dde4d80f..07e3994f 100644
--- a/ds-bot/test/card-hold.test.js
+++ b/ds-bot/test/card-hold.test.js
@@ -35,6 +35,11 @@ const effect = (make, deps) => {
}
}
const react = {
+ Fragment: 'fragment',
+ createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx },
+ useContext: ctx => ctx.value,
+ useMemo: make => make(),
+ useCallback: fn => fn,
createElement: (type, props, ...children) => ({ type, props: { ...props, children } }),
useState: (initial) => {
const cell = slot(() => ({ value: typeof initial === 'function' ? initial() : initial }))
diff --git a/ds-bot/test/chat-rows.test.js b/ds-bot/test/chat-rows.test.js
index afd0eb7c..57b91d88 100644
--- a/ds-bot/test/chat-rows.test.js
+++ b/ds-bot/test/chat-rows.test.js
@@ -14,7 +14,7 @@ runInNewContext(bundle.outputFiles[0].text, {
module, exports: module.exports, Intl, Date, TextEncoder,
require: (name) => {
const platform = {
- react: {
+ react: { Fragment: 'fragment', createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx }, useContext: ctx => ctx.value, useCallback: fn => fn, useId: () => 'dui-id', useSyncExternalStore: (subscribe, getSnapshot) => getSnapshot(),
createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }),
useState: initial => [initial, () => {}], useRef: current => ({ current }),
useLayoutEffect() {}, useEffect() {}, useMemo: make => make(),
diff --git a/ds-bot/test/client-bundle.test.js b/ds-bot/test/client-bundle.test.js
index f4c9dfe2..a7405c12 100644
--- a/ds-bot/test/client-bundle.test.js
+++ b/ds-bot/test/client-bundle.test.js
@@ -22,7 +22,7 @@ test('client.js registers a factory that exports apply and inject', () => {
const requested = []
const platform = {
- 'react': { createElement: () => null, Fragment: Symbol('Fragment'), useState: initial => [initial, () => {}], useEffect: () => {}, useMemo: make => make(), useRef: current => ({ current }) },
+ 'react': { createElement: () => null, Fragment: Symbol('Fragment'), useState: initial => [initial, () => {}], useEffect: () => {}, useMemo: make => make(), useCallback: fn => fn, useRef: current => ({ current }), useId: () => 'id', useSyncExternalStore: (sub, get) => get(), createContext: initial => ({ value: initial, Provider: () => null }), useContext: ctx => ctx.value },
'react-dom': { createPortal: node => node },
'@deepseek-ai/dsh-client-ui-primitives': { MarkdownText: () => null },
}
diff --git a/ds-bot/test/exchange.test.js b/ds-bot/test/exchange.test.js
index 5edeb442..358c5480 100644
--- a/ds-bot/test/exchange.test.js
+++ b/ds-bot/test/exchange.test.js
@@ -48,6 +48,12 @@ function rig(initial) {
}
}
const react = {
+ createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx },
+ useContext: ctx => ctx.value,
+ useMemo: make => make(),
+ useCallback: fn => fn,
+ useId: () => 'dui-id',
+ useSyncExternalStore: (subscribe, getSnapshot) => getSnapshot(),
Fragment: 'fragment',
createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }),
useRef: (current) => { const i = at++; return slots[i] ??= { current } },
diff --git a/ds-bot/test/fake-ctx.js b/ds-bot/test/fake-ctx.js
index 5a72fa1e..9e9a995f 100644
--- a/ds-bot/test/fake-ctx.js
+++ b/ds-bot/test/fake-ctx.js
@@ -57,6 +57,26 @@ export function fakeContext({ services = {} } = {}) {
if (listener.length < 2) listener(payload)
}
},
+ // emit, but waits for async listeners — for paths like agent/created whose
+ // work must finish before the test goes on.
+ async emitAsync(name, payload) {
+ for (const listener of listeners.get(name) ?? []) {
+ if (listener.length < 2) await listener(payload)
+ }
+ },
+ // An Agent handle for sessionId whose own tool scope feeds the same map the
+ // global registrations use — how agent.ctx.tools.register looks to the host.
+ scopeAgent(sessionId) {
+ return {
+ id: sessionId,
+ session: { id: sessionId },
+ ctx: {
+ tools: { register: (tool) => { registeredTools.set(tool.name, tool); return () => {} } },
+ effect: () => {},
+ on: () => () => {},
+ },
+ }
+ },
effect(execute, label) {
calls.push(`effect ${label}`)
const dispose = execute()
diff --git a/ds-bot/test/feedback.test.js b/ds-bot/test/feedback.test.js
index a228125b..c428cc7a 100644
--- a/ds-bot/test/feedback.test.js
+++ b/ds-bot/test/feedback.test.js
@@ -15,6 +15,12 @@ const ISSUES = 'https://github.com/Fei2411/DS-Bot/issues/new'
function page(window) {
const notes = []
const react = {
+ createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx },
+ useContext: ctx => ctx.value,
+ useMemo: make => make(),
+ useCallback: fn => fn,
+ useId: () => 'dui-id',
+ useSyncExternalStore: (subscribe, getSnapshot) => getSnapshot(),
createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }),
Fragment: 'fragment',
useState: initial => [initial, (next) => { if (typeof next === 'string') notes.push(next) }],
diff --git a/ds-bot/test/fold.test.js b/ds-bot/test/fold.test.js
index a6856134..1d2beb4f 100644
--- a/ds-bot/test/fold.test.js
+++ b/ds-bot/test/fold.test.js
@@ -13,6 +13,12 @@ const bundle = await build({
let slots = []
let at = 0
const react = {
+ Fragment: 'fragment',
+ createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx },
+ useContext: ctx => ctx.value,
+ useCallback: fn => fn,
+ useId: () => 'dui-id',
+ useSyncExternalStore: (subscribe, getSnapshot) => getSnapshot(),
createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }),
useState: (initial) => {
const index = at++
diff --git a/ds-bot/test/formula.test.js b/ds-bot/test/formula.test.js
deleted file mode 100644
index 4aed642b..00000000
--- a/ds-bot/test/formula.test.js
+++ /dev/null
@@ -1,82 +0,0 @@
-import assert from 'node:assert/strict'
-import { test } from 'node:test'
-import { compileFormula, createScope, evaluate, show } from '../src/shared/formula.js'
-
-const run = (source, inputs = {}, lets = {}) => {
- const compiled = compileFormula(source)
- if (compiled.error !== undefined) return compiled
- const trees = new Map(Object.entries(lets).map(([name, text]) => [name, compileFormula(text).tree]))
- return evaluate(compiled.tree, createScope(new Map(Object.entries(inputs)), trees))
-}
-const value = (...args) => run(...args).value
-
-test('formulas do arithmetic, comparisons and conditions with the usual precedence', () => {
- assert.equal(value('1 + 2 * 3'), 7)
- assert.equal(value('(1 + 2) * 3'), 9)
- assert.equal(value('-2 ** 2'.replace('**', '*')), -4)
- assert.equal(value('10 % 4 + 1e3 / 4'), 252)
- assert.equal(value('.5 + 1.5'), 2)
- assert.equal(value('3 > 2 && 2 >= 2'), true)
- assert.equal(value('1 == 2 || !false'), true)
- assert.equal(value('x > 100 ? "bad" : x > 80 ? "warn" : "good"', { x: 90 }), 'warn')
- assert.equal(value('0 && boom'), false, 'the right side of && is not worked out when the left is false')
- assert.equal(value("'¥' + 3"), '¥3')
- assert.equal(value('0.1 + 0.2 + ""'), '0.3', 'text drops float noise')
- assert.equal(value('"2" * 3'), 6)
-})
-
-test('formulas call the fixed functions and format numbers', () => {
- assert.equal(value('min(3, 1, 2) + max(4, 5)'), 6)
- assert.equal(value('clamp(12, 0, 10)'), 10)
- assert.equal(value('round(2.345, 2)'), 2.35)
- assert.equal(value('round(2.5)'), 3)
- assert.equal(value('floor(2.9) + ceil(2.1) + abs(-1)'), 6)
- assert.equal(value('sqrt(16) + pow(2, 3)'), 12)
- assert.equal(value('fixed(3.14159, 2)'), '3.14')
- assert.equal(value('format(1234567.891, 1)'), '1,234,567.9')
- assert.equal(value('format(-1234)'), '-1,234')
- assert.equal(value('percent(0.4321, 1)'), '43.2%')
- assert.match(run('fixed(1, 11)').error, /digits must be a whole number from 0 to 10/)
- assert.match(run('round(1, 2, 3)').error, /round\(\) takes 1 or 2 arguments; got 3/)
- assert.match(run('clamp(1)').error, /clamp\(\) takes 3 arguments; got 1/)
- assert.match(run('min()').error, /min\(\) takes at least 1 argument/)
-})
-
-test('formulas read inputs and let names, and catch cycles and unknown names', () => {
- assert.equal(value('cost * 2', { req: 10 }, { cost: 'req * 3' }), 60)
- assert.match(run('a', {}, { a: 'b + 1', b: 'a + 1' }).error, /refers to itself/)
- assert.match(run('nope').error, /unknown name "nope"/)
- assert.deepEqual(compileFormula('price * qty + tax(1)').error, 'unknown function "tax"; allowed: min, max, abs, floor, ceil, sqrt, pow, round, clamp, fixed, format, percent')
- assert.deepEqual(compileFormula('price * qty + total').names, ['price', 'qty', 'total'])
-})
-
-test('formulas cannot reach the page: no property access, no prototype names, no code', () => {
- assert.match(compileFormula('constructor.constructor("x")()').error, /unexpected "\."/)
- assert.match(compileFormula('constructor("x")').error, /unknown function "constructor"/)
- assert.match(compileFormula('toString()').error, /unknown function "toString"/)
- assert.match(run('constructor').error, /unknown name "constructor"/)
- assert.match(run('__proto__').error, /unknown name "__proto__"/)
- assert.match(compileFormula('a = 1').error, /unexpected "="/)
- assert.match(compileFormula('x[0]').error, /unexpected "\["/)
- assert.match(compileFormula('`x`').error, /unexpected "`"/)
-})
-
-test('formulas report syntax errors with a position and refuse deep nesting', () => {
- assert.equal(compileFormula('').error, 'the formula is empty')
- assert.equal(compileFormula('1 +').error, 'the formula ends too early')
- assert.equal(compileFormula('(1 + 2').error, 'expected ")" at the end')
- assert.equal(compileFormula('1 2').error, 'unexpected "2" at 3')
- assert.equal(compileFormula('"open').error, 'unclosed string at 1')
- assert.equal(compileFormula('a ? b').error, 'expected ":" at the end')
- assert.equal(compileFormula(3).error, 'expected a formula string')
- assert.match(compileFormula(`${'('.repeat(80)}1${')'.repeat(80)}`).error, /nested more than 64 levels/)
- assert.match(compileFormula(`${'-'.repeat(80)}1`).error, /nested more than 64 levels/)
- assert.equal(compileFormula(`${'('.repeat(30)}1${')'.repeat(30)}`).error, undefined)
-})
-
-test('a value as text', () => {
- assert.equal(show(0.1 + 0.2), '0.3')
- assert.equal(show(Infinity), 'Infinity')
- assert.equal(show(true), 'true')
- assert.equal(show('x'), 'x')
-})
diff --git a/ds-bot/test/header.test.js b/ds-bot/test/header.test.js
index 67dac92b..ca1196fa 100644
--- a/ds-bot/test/header.test.js
+++ b/ds-bot/test/header.test.js
@@ -15,7 +15,7 @@ runInNewContext(bundle.outputFiles[0].text, {
module, exports: module.exports, URL, URLSearchParams, setTimeout, clearTimeout,
require: (name) => {
const platform = {
- react: { createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }), useState: initial => [initial, () => {}], useEffect: () => {}, useRef: current => ({ current }), useLayoutEffect: () => {}, useMemo: make => make(), useCallback: fn => fn, Fragment: 'fragment' },
+ react: { createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx }, useContext: ctx => ctx.value, useId: () => 'dui-id', useSyncExternalStore: (subscribe, getSnapshot) => getSnapshot(), createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }), useState: initial => [initial, () => {}], useEffect: () => {}, useRef: current => ({ current }), useLayoutEffect: () => {}, useMemo: make => make(), useCallback: fn => fn, Fragment: 'fragment' },
'react-dom': { createPortal: node => node },
'@deepseek-ai/dsh-client-ui-primitives': { MarkdownText: () => null },
}
diff --git a/ds-bot/test/history.test.js b/ds-bot/test/history.test.js
index 6a136796..c7c8ad5b 100644
--- a/ds-bot/test/history.test.js
+++ b/ds-bot/test/history.test.js
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict'
import { test } from 'node:test'
import { termQuery } from '../src/host/chat-index.js'
import { canonicalHeadings, cardText, historyEntry, questionReply, readReply, replyText, viewCardText } from '../src/host/parts.js'
-import { VIEW_BYTE_LIMIT, viewBytes } from '../src/shared/views.js'
+import { VIEW_BYTE_LIMIT, viewBytes } from 'dsh-deep-ui/core'
test('cardText shows a question card as the user saw it', () => {
const card = { question: ' Start where? ', detail: 'pick one', options: [{ label: 'Plan' }, { label: ' ' }, { label: 'Draft' }] }
diff --git a/ds-bot/test/install.test.js b/ds-bot/test/install.test.js
index 2330ae1f..556ab224 100644
--- a/ds-bot/test/install.test.js
+++ b/ds-bot/test/install.test.js
@@ -57,7 +57,8 @@ test('apply registers listeners, tools, and effects in a fixed order', (t) => {
'tool delete_group',
'tool post_to_group',
'tool ask_user',
- 'tool show_view',
+ // show_view is scoped per Bot agent, not a global registration.
+
'tools guard',
'on agent/created',
'on session/event',
diff --git a/ds-bot/test/member-status.test.js b/ds-bot/test/member-status.test.js
index e3252422..702c58b7 100644
--- a/ds-bot/test/member-status.test.js
+++ b/ds-bot/test/member-status.test.js
@@ -14,7 +14,7 @@ runInNewContext(bundle.outputFiles[0].text, {
module, exports: module.exports,
require: (name) => {
const platform = {
- react: { createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }), useState: initial => [initial, () => {}], useEffect: () => {}, useRef: initial => ({ current: initial }), useLayoutEffect: () => {}, Fragment: 'fragment' },
+ react: { createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx }, useContext: ctx => ctx.value, useMemo: make => make(), useCallback: fn => fn, useId: () => 'dui-id', useSyncExternalStore: (subscribe, getSnapshot) => getSnapshot(), createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }), useState: initial => [initial, () => {}], useEffect: () => {}, useRef: initial => ({ current: initial }), useLayoutEffect: () => {}, Fragment: 'fragment' },
'react-dom': {},
'@deepseek-ai/dsh-client-ui-primitives': {},
}
diff --git a/ds-bot/test/mention-rule.test.js b/ds-bot/test/mention-rule.test.js
index baa754a6..f33e4f89 100644
--- a/ds-bot/test/mention-rule.test.js
+++ b/ds-bot/test/mention-rule.test.js
@@ -19,7 +19,7 @@ const module = { exports: {} }
runInNewContext(bundle.outputFiles[0].text, {
module, exports: module.exports,
require: (name) => {
- const platform = { react: { createElement: () => null, Fragment: 'fragment', useState: initial => [initial, () => {}], useEffect: () => {}, useRef: initial => ({ current: initial }), useLayoutEffect: () => {}, useId: () => 'id' }, 'react-dom': {}, '@deepseek-ai/dsh-client-ui-primitives': {} }
+ const platform = { react: { createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx }, useContext: ctx => ctx.value, useMemo: make => make(), useCallback: fn => fn, useSyncExternalStore: (subscribe, getSnapshot) => getSnapshot(), createElement: () => null, Fragment: 'fragment', useState: initial => [initial, () => {}], useEffect: () => {}, useRef: initial => ({ current: initial }), useLayoutEffect: () => {}, useId: () => 'id' }, 'react-dom': {}, '@deepseek-ai/dsh-client-ui-primitives': {} }
if (!(name in platform)) throw new Error(`no platform module ${name}`)
return platform[name]
},
diff --git a/ds-bot/test/model-menu.test.js b/ds-bot/test/model-menu.test.js
index 128e5a02..4d40b8a2 100644
--- a/ds-bot/test/model-menu.test.js
+++ b/ds-bot/test/model-menu.test.js
@@ -14,7 +14,7 @@ runInNewContext(bundle.outputFiles[0].text, {
module, exports: module.exports,
require: name => {
const platform = {
- react: {
+ react: { Fragment: 'fragment', createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx }, useContext: ctx => ctx.value, useMemo: make => make(), useCallback: fn => fn, useId: () => 'dui-id', useSyncExternalStore: (subscribe, getSnapshot) => getSnapshot(),
createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }),
useState: initial => [initial, () => {}],
useEffect: () => {},
diff --git a/ds-bot/test/permission-picker.test.js b/ds-bot/test/permission-picker.test.js
index 61c312f4..a1e0f730 100644
--- a/ds-bot/test/permission-picker.test.js
+++ b/ds-bot/test/permission-picker.test.js
@@ -20,6 +20,10 @@ let dirty = false
let pendingEffects = []
const changed = (deps, prev) => deps === undefined || prev === undefined || deps.length !== prev.length || deps.some((dep, i) => !Object.is(dep, prev[i]))
const react = {
+ createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx },
+ useContext: ctx => ctx.value,
+ useCallback: fn => fn,
+ useSyncExternalStore: (subscribe, getSnapshot) => getSnapshot(),
createElement: (type, props, ...children) => ({ type, props: { ...props, children: children.flat(Infinity) } }),
useState(initial) {
const i = hook++
diff --git a/ds-bot/test/right-panel.test.js b/ds-bot/test/right-panel.test.js
index 9f25dd4f..1e9f11c3 100644
--- a/ds-bot/test/right-panel.test.js
+++ b/ds-bot/test/right-panel.test.js
@@ -82,7 +82,7 @@ runInNewContext(bundle.outputFiles[0].text, {
module, exports: module.exports, URL, URLSearchParams, setTimeout, clearTimeout,
require: (name) => {
const platform = {
- react: {
+ react: { createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx }, useContext: ctx => ctx.value, useId: () => 'dui-id',
createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }),
useState: initial => [initial, () => {}], useEffect: () => {}, useRef: current => ({ current }),
useLayoutEffect: () => {}, useMemo: make => make(), useCallback: fn => fn,
diff --git a/ds-bot/test/show-view-scope.test.js b/ds-bot/test/show-view-scope.test.js
new file mode 100644
index 00000000..09f4ea55
--- /dev/null
+++ b/ds-bot/test/show-view-scope.test.js
@@ -0,0 +1,54 @@
+import assert from 'node:assert/strict'
+import { test } from 'node:test'
+import { Context } from '@deepseek-ai/cordis'
+import { createScope } from '@deepseek-ai/dsh-scope'
+import ToolRuntime, { defineTool } from '@deepseek-ai/dsh-tools'
+
+// Deep UI registers show_view globally for plain sessions; ds-bot registers its
+// own in the agent scope of every session it owns, and the scoped one wins.
+const tool = (description) => defineTool({
+ name: 'show_view',
+ description,
+ parameters: { type: 'object', additionalProperties: true },
+ execute: async () => description,
+})
+
+const setup = async (t, run) => {
+ const ctx = new Context()
+ await ctx.plugin(ToolRuntime)
+ t.after(async () => ctx.fiber.dispose())
+ const plugin = { inject: ['tools'], apply: inner => run(inner.tools, inner) }
+ await ctx.plugin(plugin)
+}
+
+test('a scoped show_view shadows the global one inside a Bot session', async t => {
+ await setup(t, (tools, ctx) => {
+ tools.register(tool('global'))
+
+ const bot = {}
+ const scope = createScope(ctx, bot)
+ t.after(async () => scope.dispose())
+ scope.ctx.tools.register(tool('bot'))
+
+ assert.equal(tools.get('show_view', bot)?.description, 'bot', 'Bot agent sees its own definition')
+ assert.equal(tools.schemas(bot).find(schema => schema.name === 'show_view')?.description, 'bot')
+
+ const stranger = {}
+ assert.equal(tools.get('show_view', stranger)?.description, 'global', 'other agents keep the global one')
+ assert.equal(tools.schemas(stranger).find(schema => schema.name === 'show_view')?.description, 'global')
+ assert.equal(tools.get('show_view')?.description, 'global', 'an unscoped lookup is global too')
+ })
+})
+
+test('without a global show_view a non-Bot agent has none', async t => {
+ await setup(t, (tools, ctx) => {
+ const bot = {}
+ const scope = createScope(ctx, bot)
+ t.after(async () => scope.dispose())
+ scope.ctx.tools.register(tool('bot'))
+
+ const stranger = {}
+ assert.equal(tools.get('show_view', stranger), undefined, 'no global, no tool outside the Bot scope')
+ assert.equal(tools.get('show_view', bot)?.description, 'bot')
+ })
+})
diff --git a/ds-bot/test/side-panel.test.js b/ds-bot/test/side-panel.test.js
index d4dda64e..bb098629 100644
--- a/ds-bot/test/side-panel.test.js
+++ b/ds-bot/test/side-panel.test.js
@@ -46,7 +46,7 @@ runInNewContext(bundle.outputFiles[0].text, {
window: { addEventListener() {}, removeEventListener() {}, innerWidth: 1280 },
require: (name) => {
const platform = {
- react: {
+ react: { createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx }, useContext: ctx => ctx.value, useId: () => 'dui-id',
createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }),
useState: () => [true, () => {}], useEffect: () => {}, useRef: () => ({ current: null }),
useLayoutEffect: () => {}, useMemo: make => make(), useCallback: fn => fn,
@@ -112,7 +112,7 @@ const sideExports = (states) => {
window: { addEventListener() {}, removeEventListener() {}, innerWidth: 1280 },
require: (name) => {
const platform = {
- react: {
+ react: { createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx }, useContext: ctx => ctx.value, useId: () => 'dui-id',
createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }),
useState: init => states[hook++] ?? [init, () => {}],
useEffect: () => {}, useRef: () => ({ current: null }),
diff --git a/ds-bot/test/sidebar-switch.test.js b/ds-bot/test/sidebar-switch.test.js
index af4a499e..b7c516f7 100644
--- a/ds-bot/test/sidebar-switch.test.js
+++ b/ds-bot/test/sidebar-switch.test.js
@@ -25,6 +25,10 @@ let renderRefs
let refIndex = 0
let layoutEffects
const react = {
+ createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx },
+ useContext: ctx => ctx.value,
+ useCallback: fn => fn,
+ useSyncExternalStore: (subscribe, getSnapshot) => getSnapshot(),
createElement: (type, props, ...children) => ({ type, props: { ...props, children } }), Fragment: Symbol('Fragment'),
useEffect() {}, useLayoutEffect: effect => layoutEffects?.push(effect), useState: initial => [initial, () => {}],
useMemo: make => make(), useRef: current => renderRefs ? renderRefs[refIndex++] ??= { current } : { current }, useId: () => 'id',
diff --git a/ds-bot/test/styles.test.js b/ds-bot/test/styles.test.js
index d714f3fd..b8ccf914 100644
--- a/ds-bot/test/styles.test.js
+++ b/ds-bot/test/styles.test.js
@@ -24,6 +24,10 @@ const { outputFiles } = await build({
external: ['react', 'react-dom', '@deepseek-ai/dsh-client-ui-primitives'],
})
const react = {
+ createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx },
+ useContext: ctx => ctx.value,
+ useCallback: fn => fn,
+ useSyncExternalStore: (subscribe, getSnapshot) => getSnapshot(),
createElement: (type, props, ...children) => ({ type, props: { ...props, children } }), Fragment: Symbol('Fragment'),
useEffect() {}, useLayoutEffect() {}, useState: initial => [initial, () => {}],
useMemo: make => make(), useRef: current => ({ current }), useId: () => 'id',
diff --git a/ds-bot/test/tool-cells.test.js b/ds-bot/test/tool-cells.test.js
index 6bcc12e1..539c3fc5 100644
--- a/ds-bot/test/tool-cells.test.js
+++ b/ds-bot/test/tool-cells.test.js
@@ -25,6 +25,9 @@ const sets = []
const Fragment = Symbol('Fragment')
const h = (type, props, ...children) => ({ type, props: { ...props, children } })
const react = {
+ createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx },
+ useContext: ctx => ctx.value,
+ useCallback: fn => fn,
createElement: h, Fragment,
useEffect: (effect) => { effects.push(effect) },
useLayoutEffect: (effect) => { effects.push(effect) },
@@ -743,13 +746,13 @@ test('a show_view call the host refused draws nothing; a display-only card draws
gone(cell('Pick', { type: 'options', id: 'o', options: [{ label: 'A' }] }))
gone(cell('Meter', { type: 'metric', label: 'Done', value: '3' }, { await_reply: true }))
const card = cell(' Status ', { type: 'metric', label: 'Done', value: '3' })
- const title = find(card, node => node.props?.className === 'bt-view-title')
+ const title = find(card, node => node.props?.className === 'dui-view-title')
assert.ok(title !== undefined)
assert.equal(text(title), 'Status')
// A view needs no title: it then draws without a heading.
const bare = cell(' ', { type: 'text', text: 'hi' })
- assert.equal(find(bare, node => node.props?.className === 'bt-view-title'), undefined)
- assert.ok(find(bare, node => typeof node.props?.className === 'string' && node.props.className.includes('bt-view-bare')) !== undefined)
+ assert.equal(find(bare, node => node.props?.className === 'dui-view-title'), undefined)
+ assert.ok(find(bare, node => typeof node.props?.className === 'string' && node.props.className.includes('dui-view-bare')) !== undefined)
})
test('a display-only call still draws when the args come through the value accessor', () => {
@@ -762,7 +765,7 @@ test('a display-only call still draws when the args come through the value acces
call: { name: 'show_view', argsRaw: JSON.stringify(data) }, content: text$('The view is on screen.'), subCalls: [],
}
const node = show(callNode, { roster: team({ views: {} }) })
- const title = find(node, item => item.props?.className === 'bt-view-title')
+ const title = find(node, item => item.props?.className === 'dui-view-title')
assert.ok(title !== undefined, 'the card draws')
assert.equal(text(title), 'Status')
})
@@ -778,23 +781,23 @@ test('a view works its formulas out, draws a chart, and keeps html in a sandboxe
],
}
const live = cell(calculator)
- assert.equal(text(classed(live, 'bt-widget-metric-value')), '¥60')
- assert.equal(classed(live, 'bt-widget-metric').props['data-tone'], 'bad')
- assert.ok(classed(live, 'bt-q') !== undefined, 'a view with inputs wears a light frame')
+ assert.equal(text(classed(live, 'dui-widget-metric-value')), '¥60')
+ assert.equal(classed(live, 'dui-widget-metric').props['data-tone'], 'bad')
+ assert.ok(classed(live, 'dui-q') !== undefined, 'a view with inputs wears a light frame')
assert.equal(find(live, item => item.type === 'input' && item.props.type === 'range').props.value, 30)
const chart = cell({ type: 'chart', kind: 'bar', categories: ['A', 'B'], series: [{ values: [3, 5] }], unit: 'ms' })
- assert.ok(classed(chart, 'bt-view-bare') !== undefined, 'a view that only shows has no frame')
+ assert.ok(classed(chart, 'dui-view-bare') !== undefined, 'a view that only shows has no frame')
assert.ok(find(chart, item => item.type === 'svg') !== undefined)
const figure = find(chart, item => item.type === 'figure')
assert.equal(figure.props['data-kind'], 'bar')
// The ⋯ menu sits in the card's head, not on the chart's axes (#476).
- const head = classed(chart, 'bt-view-head')
- assert.ok(find(head, item => typeof item.props?.className === 'string' && item.props.className.includes('bt-view-more')) !== undefined, 'the card head has the menu button')
+ const head = classed(chart, 'dui-view-head')
+ assert.ok(find(head, item => typeof item.props?.className === 'string' && item.props.className.includes('dui-view-more')) !== undefined, 'the card head has the menu button')
assert.equal(find(figure, item => typeof item.props?.className === 'string' && (item.props.className.includes('bt-chart-more') || item.props.className.includes('bt-chart-tools'))), undefined, 'the chart itself has no menu')
// A view without a chart has no ⋯ button.
const metric = cell({ type: 'metric', label: 'Done', value: '3' })
- assert.equal(find(metric, item => typeof item.props?.className === 'string' && item.props.className.includes('bt-view-more')), undefined)
+ assert.equal(find(metric, item => typeof item.props?.className === 'string' && item.props.className.includes('dui-view-more')), undefined)
for (const kind of ['hbar', 'line', 'area', 'donut']) {
assert.ok(find(cell({ type: 'chart', kind, categories: ['A', 'B'], series: [{ values: [3, 5] }] }), item => item.type === 'svg') !== undefined, kind)
}
@@ -803,12 +806,12 @@ test('a view works its formulas out, draws a chart, and keeps html in a sandboxe
const handle = (label, asTable = false) => ({ label, asTable, toggleTable: () => {}, copy: () => {}, save: () => {} })
const menuItems = node => findAll(node, item => item.props?.role === 'menuitem').map(text)
const single = expand(ViewMenuList({ charts: [handle('Revenue')], pick: run => run }))
- assert.equal(findAll(single, item => item.props?.className === 'bt-view-menu-label').length, 0, 'one chart needs no group label')
+ assert.equal(findAll(single, item => item.props?.className === 'dui-view-menu-label').length, 0, 'one chart needs no group label')
assert.deepEqual(menuItems(single), ['View as table', 'Copy data', 'Download image'])
const pair = expand(ViewMenuList({ charts: [handle('Revenue'), handle(null, true), handle('Costs')], pick: run => run }))
- const labels = findAll(pair, item => item.props?.className === 'bt-view-menu-label').map(text)
+ const labels = findAll(pair, item => item.props?.className === 'dui-view-menu-label').map(text)
assert.deepEqual(labels, ['Revenue', 'Chart 2', 'Costs'], 'each group is named after its chart')
- assert.equal(findAll(pair, item => item.props?.className === 'bt-menu-sep').length, 2, 'groups are separated')
+ assert.equal(findAll(pair, item => item.props?.className === 'dui-menu-sep').length, 2, 'groups are separated')
assert.deepEqual(menuItems(pair), [
'View as table', 'Copy data', 'Download image',
'View as chart', 'Copy data', 'Download image',
@@ -832,7 +835,7 @@ test('a view works its formulas out, draws a chart, and keeps html in a sandboxe
assert.equal(ordered.length, 3)
ordered[0].toggleTable()
const orderedMenu = expand(ViewMenuList({ charts: ordered, pick: run => run }))
- assert.deepEqual(findAll(orderedMenu, item => item.props?.className === 'bt-view-menu-label').map(text), ['One', 'Two', 'Chart 3'], 'the toggled chart keeps its group position')
+ assert.deepEqual(findAll(orderedMenu, item => item.props?.className === 'dui-view-menu-label').map(text), ['One', 'Two', 'Chart 3'], 'the toggled chart keeps its group position')
assert.deepEqual(menuItems(orderedMenu).slice(0, 3), ['View as chart', 'Copy data', 'Download image'], 'the first group shows the table state')
const frame = find(cell({ type: 'html', html: '<b>hi</b>', summary: 'A greeting' }), item => item.type === 'iframe')
diff --git a/ds-bot/test/turn-tail.test.js b/ds-bot/test/turn-tail.test.js
index 3a96093d..9043ea95 100644
--- a/ds-bot/test/turn-tail.test.js
+++ b/ds-bot/test/turn-tail.test.js
@@ -16,7 +16,7 @@ runInNewContext(bundle.outputFiles[0].text, {
module, exports: module.exports, AbortController, fetch,
require: (name) => {
const platform = {
- react: {
+ react: { createContext: (initial) => { const ctx = { value: initial }; ctx.Provider = ({ value, children }) => { ctx.value = value; return children }; return ctx }, useContext: ctx => ctx.value, useCallback: fn => fn, useId: () => 'dui-id', useSyncExternalStore: (subscribe, getSnapshot) => getSnapshot(),
createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }),
useState: initial => [initial, () => {}], useEffect: (run) => { effects.push(run) }, useRef: current => ({ current }),
useLayoutEffect: () => {}, useMemo: make => make(), Fragment: 'fragment',
diff --git a/ds-bot/test/view-inputs.test.js b/ds-bot/test/view-inputs.test.js
deleted file mode 100644
index 3538310d..00000000
--- a/ds-bot/test/view-inputs.test.js
+++ /dev/null
@@ -1,129 +0,0 @@
-import assert from 'node:assert/strict'
-import { test } from 'node:test'
-import { inputsSummary, normalizeView, resolve, validateView, validateViewAnswer, viewScope, viewSummary } from '../src/shared/views.js'
-
-const text = (value = 'hello') => ({ type: 'text', text: value })
-const metric = (label = '进度', value = '70%') => ({ type: 'metric', label, value })
-const options = (id = 'pick') => ({ type: 'options', id, options: [{ label: 'A' }, { label: 'B' }] })
-const stack = (...children) => ({ type: 'stack', children })
-const slider = (over = {}) => ({ type: 'slider', id: 'req', label: 'Requests a day', min: 100, max: 5000, step: 100, value: 1200, ...over })
-const choice = (over = {}) => ({ type: 'choice', id: 'hit', label: 'Cache hits', options: [{ label: 'Low', value: 0.2 }, { label: 'Mid', value: 0.5 }], value: 0.5, ...over })
-const calculator = () => ({
- type: 'stack',
- let: { tokens: 'req * 30 * 2000 / 1e6', cost: 'tokens * (1 - hit) * 2 + tokens * hit * 0.5' },
- children: [
- slider(), choice(), { type: 'toggle', id: 'cache', label: 'Use cache', value: true },
- { type: 'metric', label: 'Monthly cost', value: { '=': "'¥' + fixed(cost, 0)" }, tone: { '=': "cost > 100 ? 'bad' : 'good'" }, caption: { '=': 'format(tokens) + " M tokens"' } },
- { type: 'progress', label: 'Basic plan', value: { '=': 'cost' }, max: 100, valueLabel: { '=': "'¥' + fixed(100 - cost, 0) + ' left'" }, tone: { '=': "cost > 80 ? 'warn' : 'good'" } },
- { type: 'chart', kind: 'bar', categories: ['A', 'B'], series: [{ name: 'Cost', values: [{ '=': 'cost' }, 50] }], unit: '¥' },
- { type: 'submit', id: 'send', label: 'Send these numbers' },
- ],
-})
-
-test('validateView accepts the new components and keeps inputs out of the interactive kind', () => {
- const display = stack(
- { type: 'row', children: [metric(), metric('b', 2)] },
- { type: 'text', text: 'note', tone: 'muted' },
- { type: 'chart', categories: ['A', 'B'], series: [{ values: [1, 2] }] },
- { type: 'chart', kind: 'donut', categories: ['A', 'B'], series: [{ name: 'Share', values: [1, 2] }], unit: '%', caption: 'Sample data' },
- { type: 'progress', label: 'Used', value: 30, max: 120, valueLabel: '90 left', tone: 'warn' },
- { type: 'callout', text: 'Careful', tone: 'warn' },
- { type: 'sources', items: [{ label: 'Docs', url: 'https://example.com/a' }] },
- { type: 'html', html: '<canvas></canvas>', summary: 'A drawing', height: 200 },
- )
- assert.deepEqual(validateView(display), { ok: true, interactive: false })
- assert.deepEqual(validateView(stack(slider(), choice(), { type: 'number', id: 'n', label: 'N', value: 1 }, { type: 'toggle', id: 't', label: 'T' })), { ok: true, interactive: false })
- assert.deepEqual(validateView(calculator()), { ok: true, interactive: true })
- assert.deepEqual(validateView(stack(slider(), { type: 'submit', id: 'go' })), { ok: true, interactive: true })
-})
-
-test('validateView checks the new components with a path', () => {
- const chart = over => ({ type: 'chart', categories: ['A', 'B'], series: [{ values: [1, 2] }], ...over })
- assert.match(validateView(chart({ kind: 'pie' })).error, /view\.kind: unknown chart "pie"; allowed: bar, hbar, line, area, donut/)
- assert.match(validateView(chart({ categories: [] })).error, /view\.categories: expected a non-empty array/)
- assert.match(validateView(chart({ series: [{ values: [1] }] })).error, /view\.series\[0\]\.values: 1 values for 2 categories/)
- assert.match(validateView(chart({ series: [{ values: [1, 'x'] }] })).error, /view\.series\[0\]\.values\[1\]: expected a number/)
- assert.match(validateView(chart({ kind: 'donut', series: [{ values: [1, 2] }, { values: [3, 4] }] })).error, /a donut takes one series; got 2/)
- assert.match(validateView({ type: 'progress', label: 'x' }).error, /give percent \(0 to 100\), or value with max/)
- assert.match(validateView({ type: 'progress', percent: 10, value: 3, max: 4 }).error, /give percent/)
- assert.match(validateView({ type: 'progress', value: 3 }).error, /view\.max: expected a number with value/)
- assert.match(validateView({ type: 'callout', text: 'x', tone: 'loud' }).error, /unknown tone "loud"; allowed: info, good, warn, bad/)
- assert.match(validateView({ type: 'text', text: 'x', tone: 'loud' }).error, /unknown tone "loud"; allowed: muted/)
- assert.match(validateView({ type: 'sources', items: [{ label: 'x', url: 'javascript:alert(1)' }] }).error, /view\.items\[0\]\.url: expected an http\(s\) address/)
- assert.match(validateView({ type: 'html', html: '<b>x</b>' }).error, /view\.summary: expected one line/)
- assert.match(validateView(slider({ id: 'my-input' })).error, /an input id is letters, digits and _/)
- assert.match(validateView(slider({ id: 'true' })).error, /an input id is letters/)
- assert.match(validateView(slider({ min: undefined })).error, /a slider needs min and max/)
- assert.match(validateView(slider({ max: 50 })).error, /view\.max: expected more than min \(100\)/)
- assert.match(validateView(slider({ value: 9000 })).error, /view\.value: expected a number from 100 to 5000/)
- assert.match(validateView(choice({ value: 0.9 })).error, /view\.value: expected one of the options' values/)
- assert.match(validateView(choice({ options: [{ label: 'A', value: 1 }, { label: 'B', value: 1 }] })).error, /duplicate value 1/)
- assert.deepEqual(validateView(choice({ options: [{ label: 'A' }, { label: 'B' }], value: undefined })), { ok: true, interactive: false })
- assert.match(validateView({ type: 'toggle', id: 't', label: 'T', value: 'yes' }).error, /expected true or false/)
- assert.match(validateView(stack(slider(), choice({ id: 'req' }))).error, /view\.children\[1\]\.id: duplicate id "req"/)
- assert.match(validateView(stack({ type: 'stack', let: { a: '1' }, children: [text()] })).error, /view\.children\[0\]\.let: only the outermost component can define names/)
-})
-
-test('validateView checks formulas against the inputs as the Bot set them', () => {
- const around = (child, extra = {}) => ({ type: 'stack', ...extra, children: [slider(), child] })
- assert.match(validateView(around({ type: 'metric', label: 'x', value: { '=': 'nope * 2' } })).error, /view\.children\[1\]\.value: unknown name "nope"; known: req/)
- assert.match(validateView(around({ type: 'metric', label: 'x', value: { '=': 'req +' } })).error, /view\.children\[1\]\.value: the formula ends too early/)
- assert.match(validateView(around({ type: 'metric', label: 'x', value: 1, tone: { '=': "'red'" } })).error, /view\.children\[1\]\.tone: the formula gives "red"; expected one of good, warn, bad/)
- assert.match(validateView(around({ type: 'progress', percent: { '=': "'half'" } })).error, /view\.children\[1\]\.percent: the formula gives "half"; expected a number/)
- assert.match(validateView(around(text(), { let: { a: 'b', b: 'a' } })).error, /view\.let\.a: "[ab]" refers to itself/)
- assert.match(validateView(around(text(), { let: { req: '1' } })).error, /view\.let\.req: "req" is already an input id/)
- assert.match(validateView(around(text(), { let: { 'bad-name': '1' } })).error, /view\.let\.bad-name: a name is letters/)
- assert.match(validateView({ type: 'table', columns: [{ key: 'a', label: 'A' }], rows: [[{ '=': 'x' }]] }).error, /view\.rows\[0\]\[0\]: unknown name "x"; known: \(none\)/)
- // A formula without inputs is still a formula.
- assert.deepEqual(validateView({ type: 'metric', label: 'x', value: { '=': '2 * 21' } }), { ok: true, interactive: false })
-})
-
-test('viewScope and resolve work the formulas out for the values the user set', () => {
- const view = calculator()
- const node = view.children[3]
- assert.equal(resolve(node.value, viewScope(view)), '¥90')
- assert.equal(resolve(node.tone, viewScope(view)), 'good')
- assert.equal(resolve(node.value, viewScope(view, { req: 2000 })), '¥150')
- assert.equal(resolve(node.tone, viewScope(view, { req: 2000 })), 'bad')
- assert.equal(resolve(node.value, viewScope(view, { hit: 0.2 })), '¥122')
- assert.equal(resolve('plain', viewScope(view)), 'plain')
- assert.equal(resolve({ '=': '1 +' }, viewScope(view), 'fallback'), 'fallback')
- assert.equal(resolve({ '=': 'pow(2, 3) + nope' }, viewScope(view), 'fallback'), 'fallback')
-})
-
-test('viewSummary shows inputs as set and formulas as worked out', () => {
- assert.equal(viewSummary(calculator()), [
- 'slider: Requests a day=1200',
- 'choice: Cache hits=Mid',
- 'toggle: Use cache=on',
- 'metric: Monthly cost=¥90',
- 'progress: Basic plan 90%',
- 'chart: A=90 ¥, B=50 ¥',
- 'submit: Send these numbers',
- ].join('; '))
- const others = stack({ type: 'html', html: '<b>x</b>', summary: 'Seat map of hall B' }, { type: 'sources', items: [{ label: 'Docs', url: 'https://a.b' }] }, { type: 'callout', text: 'Mind the gap' })
- assert.equal(viewSummary(others), 'html: Seat map of hall B; sources: Docs; callout: Mind the gap')
- assert.equal(viewSummary({ type: 'row', children: [metric()] }), 'metric: 进度=70%')
-})
-
-test('validateViewAnswer carries every input with any answer and checks each value', () => {
- const view = calculator()
- assert.deepEqual(validateViewAnswer(view, 'send', { inputs: { req: 2000 } }), { inputs: { req: 2000, hit: 0.5, cache: true } })
- assert.deepEqual(validateViewAnswer(view, 'send', {}), { inputs: { req: 1200, hit: 0.5, cache: true } })
- assert.match(validateViewAnswer(view, 'send', { inputs: { req: 9000 } }).error, /values\.inputs\.req: expected a number from 100 to 5000/)
- assert.match(validateViewAnswer(view, 'send', { inputs: { req: '2000' } }).error, /values\.inputs\.req: expected a number/)
- assert.match(validateViewAnswer(view, 'send', { inputs: { hit: 0.9 } }).error, /values\.inputs\.hit: expected one of the options' values/)
- assert.match(validateViewAnswer(view, 'send', { inputs: { cache: 'yes' } }).error, /values\.inputs\.cache: expected true or false/)
- assert.match(validateViewAnswer(view, 'send', { inputs: { other: 1 } }).error, /values\.inputs\.other: unknown input; allowed: req, hit, cache/)
- assert.match(validateViewAnswer(view, 'send', { inputs: [] }).error, /values\.inputs: expected an object/)
- const mixed = stack(slider(), options('pick'))
- assert.deepEqual(validateViewAnswer(mixed, 'pick', { selected: ['A'], inputs: { req: 300 } }), { selected: ['A'], inputs: { req: 300 } })
- assert.match(validateViewAnswer(stack(options('pick')), 'pick', { selected: ['A'], inputs: {} }).error, /values\.inputs: this view has no inputs/)
- assert.equal(inputsSummary(view, { req: 2000, hit: 0.2, cache: false }), 'Requests a day=2000; Cache hits=Low; Use cache=off')
-})
-
-test('normalizeView coerces numeric strings on input and chart fields', () => {
- assert.deepEqual(normalizeView(slider({ min: '100', max: '5000', step: '100', value: '1200' })), slider())
- assert.deepEqual(normalizeView({ type: 'chart', categories: ['A'], series: [{ values: ['3', 'x'] }] }).series[0].values, [3, 'x'])
- assert.equal(Object.hasOwn(normalizeView(text()), 'value'), false, 'a field the Bot did not send stays absent')
-})
diff --git a/ds-bot/test/view-reply.test.js b/ds-bot/test/view-reply.test.js
index 8c0d4fbb..ef68dc63 100644
--- a/ds-bot/test/view-reply.test.js
+++ b/ds-bot/test/view-reply.test.js
@@ -4,7 +4,7 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { test } from 'node:test'
import { apply } from '../index.js'
-import { normalizeView, VIEW_BYTE_LIMIT, viewBytes } from '../src/shared/views.js'
+import { normalizeView, VIEW_BYTE_LIMIT, viewBytes } from 'dsh-deep-ui/core'
import { fakeContext } from './fake-ctx.js'
const TEAM = {
@@ -29,7 +29,7 @@ const TEAM = {
const CHOICES = { type: 'options', id: 'pick', options: [{ label: 'A' }, { label: 'B' }] }
const METER = { type: 'metric', label: '进度', value: '70%' }
-function start() {
+async function start() {
const home = mkdtempSync(join(tmpdir(), 'ds-bot-views-'))
writeFileSync(join(home, 'state.json'), JSON.stringify(TEAM))
const ctx = fakeContext()
@@ -52,6 +52,8 @@ function start() {
return register(options)
}
apply(ctx, { home })
+ // show_view lives in the agent scope; a Bot agent appearing registers it.
+ await ctx.emitAsync('agent/created', { agent: ctx.scopeAgent('writer-now') })
let seq = 0
const emit = (id, type, data) => {
for (const listener of ctx.listeners.get('session/event') ?? []) {
@@ -79,7 +81,7 @@ function start() {
const text = value => [{ type: 'text', text: value }]
test('show_view registers an interactive card, refuses a group and a display-only wait, and leaves a display-only card unregistered', async (t) => {
- const { ctx, emit, show, team, stop } = start()
+ const { ctx, emit, show, team, stop } = await start()
t.after(stop)
await ctx.registeredTools.get('list_bots').execute({}, { agent: { id: 'chief' } })
@@ -150,7 +152,7 @@ test('show_view registers an interactive card, refuses a group and a display-onl
})
test('view-reply claims the card, refuses a stale or invalid answer, and restores the card when queueing fails', async (t) => {
- const { ctx, show, call, team, sent, failFlush, stop } = start()
+ const { ctx, show, call, team, sent, failFlush, stop } = await start()
t.after(stop)
await ctx.registeredTools.get('list_bots').execute({}, { agent: { id: 'chief' } })
await ctx.registeredTools.get('ask_user').execute(
@@ -206,7 +208,7 @@ test('view-reply claims the card, refuses a stale or invalid answer, and restore
})
test('dismiss-view drops the open view and leaves a question card alone', async (t) => {
- const { ctx, show, call, team, stop } = start()
+ const { ctx, show, call, team, stop } = await start()
t.after(stop)
await ctx.registeredTools.get('list_bots').execute({}, { agent: { id: 'chief' } })
await ctx.registeredTools.get('ask_user').execute(
@@ -222,7 +224,7 @@ test('dismiss-view drops the open view and leaves a question card alone', async
})
test('a user message drops the open question and the open view together', async (t) => {
- const { ctx, emit, show, team, stop } = start()
+ const { ctx, emit, show, team, stop } = await start()
t.after(stop)
await ctx.registeredTools.get('list_bots').execute({}, { agent: { id: 'chief' } })
await ctx.registeredTools.get('ask_user').execute(
@@ -239,7 +241,7 @@ test('a user message drops the open question and the open view together', async
})
test('show_view measures the bytes the model sent, before unwrapping the provider encoding', async (t) => {
- const { ctx, show, stop } = start()
+ const { ctx, show, stop } = await start()
t.after(stop)
await ctx.registeredTools.get('list_bots').execute({}, { agent: { id: 'chief' } })
// Nested { item: ... } wrappers all disappear in normalization: measured after
diff --git a/ds-bot/test/views.test.js b/ds-bot/test/views.test.js
deleted file mode 100644
index 115297e5..00000000
--- a/ds-bot/test/views.test.js
+++ /dev/null
@@ -1,189 +0,0 @@
-import assert from 'node:assert/strict'
-import { test } from 'node:test'
-import { checkShownView, normalizeView, validateView, validateViewAnswer, VIEW_BYTE_LIMIT, viewBytes, viewSummary } from '../src/shared/views.js'
-
-const text = (value = 'hello') => ({ type: 'text', text: value })
-const metric = (label = '进度', value = '70%') => ({ type: 'metric', label, value })
-const options = (id = 'pick', extra = {}) => ({ type: 'options', id, options: [{ label: 'A' }, { label: 'B' }, { label: 'C', description: 'third' }], ...extra })
-const confirm = (id = 'go') => ({ type: 'confirm', id, confirmLabel: 'Ship', cancelLabel: 'Wait' })
-const form = (id = 'ask') => ({ type: 'form', id, submitLabel: 'Send', fields: [{ id: 'name', label: 'Name', placeholder: 'Ada' }, { id: 'note', label: 'Note' }] })
-const progress = () => ({ type: 'progress', label: 'Load', percent: 40 })
-const table = () => ({ type: 'table', columns: [{ key: 'name', label: 'Name' }, { key: 'n', label: 'N' }], rows: [['Ada', 2], ['Bea', true]] })
-const stack = (...children) => ({ type: 'stack', children })
-
-test('validateView accepts every component and reports whether the card can be submitted', () => {
- for (const view of [text(), metric(), table(), progress()]) {
- assert.deepEqual(validateView(view), { ok: true, interactive: false }, view.type)
- }
- for (const view of [options(), confirm(), form()]) {
- assert.deepEqual(validateView(view), { ok: true, interactive: true }, view.type)
- }
- const card = stack(text(), metric('进度', 70), table(), options(), confirm('ship'), form(), progress())
- assert.deepEqual(validateView(card), { ok: true, interactive: true })
- assert.equal(validateView(metric('ok', '1', )).ok, true)
- assert.deepEqual(validateView({ type: 'metric', label: 'n', value: 70, tone: 'good' }), { ok: true, interactive: false })
- assert.deepEqual(validateView({ type: 'form', id: 'empty', fields: [] }), { ok: true, interactive: true })
- assert.equal(validateView({ type: 'progress', percent: 0 }).ok, true)
- assert.equal(validateView({ type: 'progress', percent: 100 }).ok, true)
-})
-
-test('normalizeView unwraps XML-style arrays and coerces numeric strings', () => {
- // Providers may serialize nested arrays as { item: [...] } and numbers as strings.
- const wrapped = { type: 'stack', children: { item: [text(), { type: 'options', id: 'env', options: { item: [{ label: 'staging' }, { label: 'prod' }] } }] } }
- const unwrapped = normalizeView(wrapped)
- assert.ok(Array.isArray(unwrapped.children), 'children unwraps to an array')
- assert.ok(Array.isArray(unwrapped.children[1].options), 'nested options unwrap to an array')
- assert.deepEqual(validateView(unwrapped), { ok: true, interactive: true })
- // Numeric strings land only on the numeric fields, never on labels or text.
- assert.deepEqual(normalizeView({ type: 'progress', label: '70', percent: '70' }), { type: 'progress', label: '70', percent: 70 })
- assert.deepEqual(normalizeView({ type: 'metric', label: '70', value: '70' }), { type: 'metric', label: '70', value: 70 })
- assert.deepEqual(normalizeView(text('70')), text('70'), 'text stays a string')
- assert.deepEqual(normalizeView(metric('进度', '70%')), metric('进度', '70%'), 'non-numeric string stays a string')
- // Input is not mutated.
- assert.equal(Array.isArray(wrapped.children), false)
- // A provider may nest the wrapper: { item: { item: [...] } } collapses too.
- const nested = normalizeView({ type: 'stack', children: { item: { item: [text()] } } })
- assert.ok(Array.isArray(nested.children), 'a nested wrapper still unwraps')
- assert.deepEqual(validateView(nested), { ok: true, interactive: false })
-})
-
-test('validateView rejects an unknown component with the path and the catalog', () => {
- const view = stack(text(), metric(), { type: 'gauge', data: [1] })
- assert.equal(validateView(view).error, 'view.children[2].type: unknown component "gauge"; allowed: stack, row, text, metric, table, chart, progress, callout, sources, html, slider, choice, toggle, number, options, confirm, form, submit')
- assert.equal(validateView(null).error, 'view: expected a component object')
- assert.equal(validateView([]).error, 'view: expected a component object')
- assert.match(validateView({ type: 'text' }).error, /view\.text: expected a string/)
- assert.match(validateView({ type: 'text', text: 'hi', style: 'red' }).error, /unknown property "style"; allowed: text/)
- assert.match(validateView({ type: 'metric', label: 'n', value: '1', tone: 'nope' }).error, /unknown tone "nope"; allowed: good, warn, bad/)
- assert.match(validateView({ type: 'stack' }).error, /expected an array of 1 to 16 components/)
- assert.match(validateView({ type: 'stack', children: [] }).error, /expected 1 to 16 children; got 0/)
- assert.match(validateView({ type: 'text', text: 'x'.repeat(2001) }).error, /2001 characters exceeds the limit of 2000/)
- assert.match(validateView({ type: 'progress', percent: 101 }).error, /expected a number from 0 to 100/)
- assert.match(validateView({ type: 'progress', percent: Number.NaN }).error, /expected a number from 0 to 100/)
-})
-
-test('validateView enforces table, options, form, depth, node, and id limits', () => {
- const wide = { type: 'table', columns: Array.from({ length: 9 }, (_, index) => ({ key: `c${index}`, label: `C${index}` })), rows: [] }
- assert.match(validateView(wide).error, /9 columns exceeds the limit of 8/)
- const tall = { type: 'table', columns: [{ key: 'a', label: 'A' }], rows: Array.from({ length: 51 }, () => ['x']) }
- assert.match(validateView(tall).error, /51 rows exceeds the limit of 50/)
- const cell = { type: 'table', columns: [{ key: 'a', label: 'A' }], rows: [['x'.repeat(201)]] }
- assert.match(validateView(cell).error, /view\.rows\[0\]\[0\]: 201 characters exceeds the limit of 200/)
- assert.match(validateView({ type: 'table', columns: [{ key: 'a', label: 'A' }], rows: ['nope'] }).error, /view\.rows\[0\]: expected an array of cells/)
-
- const tooMany = options('pick', { options: Array.from({ length: 9 }, (_, index) => ({ label: `o${index}` })) })
- assert.match(validateView(tooMany).error, /expected 1 to 8 options; got 9/)
- assert.match(validateView(options('pick', { options: [] })).error, /expected 1 to 8 options; got 0/)
- assert.match(validateView(options('pick', { options: [{ label: 'A' }, { label: 'A' }] })).error, /duplicate label "A"/)
-
- const fields = { type: 'form', id: 'ask', fields: Array.from({ length: 7 }, (_, index) => ({ id: `f${index}`, label: `F${index}` })) }
- assert.match(validateView(fields).error, /7 fields exceeds the limit of 6/)
- assert.match(validateView({ type: 'form', id: 'ask', fields: [{ id: 'name', label: 'Name' }, { id: 'name', label: 'Again' }] }).error, /duplicate field id "name"/)
- // A field id may match the form's own id: the two namespaces are separate.
- assert.equal(validateView({ type: 'form', id: 'name', fields: [{ id: 'name', label: 'Name' }] }).ok, true)
-
- let deep = text()
- for (let level = 1; level < 8; level += 1) deep = stack(deep)
- assert.equal(validateView(deep).ok, true)
- assert.match(validateView(stack(deep)).error, /9 levels exceeds the limit of 8/)
-
- assert.equal(validateView(nodes(64)).ok, true)
- assert.match(validateView(nodes(65)).error, /65 components exceeds the limit of 64/)
-
- const dup = stack(options('same'), confirm('same'))
- assert.match(validateView(dup).error, /view\.children\[1\]\.id: duplicate id "same"/)
- const many = stack(...Array.from({ length: 17 }, () => text()))
- assert.match(validateView(many).error, /expected 1 to 16 children; got 17/)
-
- // `__proto__` is no id, as a component or a field: the answer would write to a
- // plain object's prototype instead of its fields.
- assert.equal(validateView(options('__proto__')).error, 'view.id: "__proto__" cannot be an id')
- assert.equal(validateView(confirm('__proto__')).error, 'view.id: "__proto__" cannot be an id')
- assert.equal(validateView({ type: 'form', id: 'ask', fields: [{ id: '__proto__', label: 'Name' }] }).error, 'view.fields[0].id: "__proto__" cannot be an id')
-})
-
-test('normalizeView keeps an own "__proto__" key as data for the validator to reject', () => {
- // Assigning into {} would hit the prototype setter: the key would vanish from
- // the JSON while its inherited properties could still pass validation.
- const ghost = normalizeView(JSON.parse('{"__proto__": {"type": "options", "id": "x", "options": [{"label": "A"}]}}'))
- assert.equal(Object.getPrototypeOf(ghost), Object.prototype)
- assert.ok(Object.hasOwn(ghost, '__proto__'))
- assert.notEqual(JSON.stringify(ghost), '{}')
- assert.equal(validateView(ghost).ok, false)
- const typed = normalizeView(JSON.parse('{"type": "text", "text": "hi", "__proto__": {"polluted": true}}'))
- assert.match(validateView(typed).error, /view\.__proto__: unknown property "__proto__"/)
-})
-
-test('checkShownView runs the call\'s own checks and names the card and its kind', () => {
- assert.deepEqual(checkShownView(' Status ', text()), { title: 'Status', view: text(), interactive: false })
- assert.deepEqual(checkShownView('Pick', options()), { title: 'Pick', view: options(), interactive: true })
- // The bytes are measured as sent, before the provider's encoding unwraps: a
- // wrapped document cannot shrink under the limit...
- let children = [text()]
- while (viewBytes('', { type: 'stack', children }) <= VIEW_BYTE_LIMIT) children = { item: children }
- assert.match(checkShownView('Big', { type: 'stack', children }).error, new RegExp(`^The view is \\d+ bytes; the limit is ${VIEW_BYTE_LIMIT}\\.$`))
- // ...while the same card normalized fits and validates.
- assert.deepEqual(checkShownView('Pick', { type: 'stack', children: { item: { item: [options()] } } }), { title: 'Pick', view: stack(options()), interactive: true })
- // A view needs no title.
- assert.deepEqual(checkShownView(' ', text()), { title: '', view: text(), interactive: false })
- assert.deepEqual(checkShownView(undefined, text()), { title: '', view: text(), interactive: false })
- assert.equal(checkShownView(3, text()).error, 'title: expected a string')
- assert.equal(checkShownView('Card', { type: 'nope' }).error, 'view.type: unknown component "nope"; allowed: stack, row, text, metric, table, chart, progress, callout, sources, html, slider, choice, toggle, number, options, confirm, form, submit')
- assert.equal(checkShownView('Card', undefined).error, 'view: expected a component object')
- const room = VIEW_BYTE_LIMIT - viewBytes('', text())
- assert.equal(checkShownView('x'.repeat(room + 1), text()).error, `The view is ${VIEW_BYTE_LIMIT + 1} bytes; the limit is ${VIEW_BYTE_LIMIT}.`)
- assert.equal(checkShownView('Card', { get type() { throw new Error('no') } }).error, 'The view is not JSON data.')
-})
-
-test('viewBytes counts the blueprint JSON plus the title in UTF-8', () => {
- const view = text('a')
- const title = '测'
- assert.equal(viewBytes(title, view), new TextEncoder().encode(`${JSON.stringify(view)}${title}`).length)
- assert.ok(viewBytes(title, view) > `${JSON.stringify(view)}${title}`.length)
- const room = VIEW_BYTE_LIMIT - viewBytes('', view)
- assert.equal(viewBytes('x'.repeat(room), view), VIEW_BYTE_LIMIT)
- assert.equal(viewBytes(`${'x'.repeat(room)}y`, view), VIEW_BYTE_LIMIT + 1)
-})
-
-test('viewSummary keeps a short list of component values', () => {
- const view = stack(metric(), options(), text(` ${'word '.repeat(30)}`))
- assert.equal(viewSummary(view), `metric: 进度=70%; options: A/B/C; text: ${'word '.repeat(30).trim()}`.slice(0, 'metric: 进度=70%; options: A/B/C; '.length) + viewSummary(view).split('; ')[2])
- const parts = viewSummary(view).split('; ')
- assert.equal(parts[0], 'metric: 进度=70%')
- assert.equal(parts[1], 'options: A/B/C')
- assert.ok(parts[2].length <= 40)
- assert.equal(parts[2].startsWith('text:'), true)
- const many = stack(...Array.from({ length: 9 }, (_, index) => metric(`m${index}`, '1')))
- assert.equal(viewSummary(many).split('; ').length, 8)
- assert.equal(viewSummary(stack(text('a'))).includes('stack'), false)
-})
-
-test('validateViewAnswer checks the submitted component and keeps the question-card selection rules', () => {
- const view = stack(options('pick'), options('many', { multi: true, id: 'many' }), confirm('go'), form())
- assert.deepEqual(validateViewAnswer(view, 'pick', { selected: ['Z', 'B', 'A'] }), { selected: ['B'] })
- assert.deepEqual(validateViewAnswer(view, 'many', { selected: ['A', 'A', 'C', 'nope'] }), { selected: ['A', 'C'] })
- assert.equal(validateViewAnswer(view, 'pick', { selected: [] }).error, 'values.selected: select at least one option')
- assert.equal(validateViewAnswer(view, 'pick', { selected: ['nope'] }).error, 'values.selected: select at least one option')
- assert.match(validateViewAnswer(view, 'pick', {}).error, /values\.selected: expected an array/)
- assert.deepEqual(validateViewAnswer(view, 'go', { confirmed: false }), { confirmed: false })
- assert.deepEqual(validateViewAnswer(view, 'go', { confirmed: true }), { confirmed: true })
- assert.match(validateViewAnswer(view, 'go', { confirmed: 'yes' }).error, /values\.confirmed: expected a boolean/)
- assert.deepEqual(validateViewAnswer(view, 'ask', { fields: {} }), { fields: {} })
- assert.deepEqual(validateViewAnswer(view, 'ask', { fields: { name: '', note: 'hi' } }), { fields: { name: '', note: 'hi' } })
- assert.match(validateViewAnswer(view, 'ask', { fields: { other: 'x' } }).error, /unknown field; allowed: name, note/)
- assert.match(validateViewAnswer(view, 'ask', { fields: { name: 'x'.repeat(2001) } }).error, /2001 characters exceeds the limit of 2000/)
- assert.match(validateViewAnswer(view, 'missing', { selected: ['A'] }).error, /no interactive component with id "missing"; allowed: pick, many, go, ask/)
- assert.match(validateViewAnswer(view, '', {}).error, /expected an interactive component id/)
-})
-
-// `count` component nodes, packed under the 16-child cap.
-function nodes(count) {
- if (count === 1) return text('x')
- const rest = count - 1
- const width = Math.min(16, rest)
- const base = Math.floor(rest / width)
- const extra = rest % width
- const children = []
- for (let index = 0; index < width; index += 1) children.push(nodes(base + (index < extra ? 1 : 0)))
- return stack(...children)
-}