reifyui 0.4.2 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,93 +1,8 @@
1
- // src/stream/responses.js
2
- function createResponsesDispatcher(h) {
3
- const fnByIdx = {};
4
- const self = {
5
- responseId: null,
6
- dispatch(ev) {
7
- const t = ev.type;
8
- switch (t) {
9
- case "response.created": {
10
- const resp = ev.response || {};
11
- self.responseId = resp.id || self.responseId;
12
- if (self.responseId) h.onCreated?.(self.responseId);
13
- const sid = resp.metadata && resp.metadata.session_id || "";
14
- if (sid) h.onSession?.(sid);
15
- break;
16
- }
17
- case "response.reasoning_summary_text.delta":
18
- h.onReasoningDelta?.(ev.delta || "");
19
- break;
20
- case "response.output_item.added": {
21
- const item = ev.item || {};
22
- if (item.type === "function_call") {
23
- fnByIdx[ev.output_index] = { name: item.name || "tool", callId: item.call_id || "" };
24
- } else if (item.type === "function_call_output") {
25
- h.onToolResult?.(item.call_id || "", String(item.output ?? ""));
26
- }
27
- break;
28
- }
29
- case "response.function_call_arguments.done": {
30
- const fn = fnByIdx[ev.output_index] || { name: "tool", callId: "" };
31
- h.onToolCall?.(fn.name, ev.arguments || "", fn.callId);
32
- break;
33
- }
34
- case "response.output_text.delta":
35
- h.onTextDelta?.(ev.delta || "");
36
- break;
37
- case "response.output_text.annotation.added": {
38
- const a = ev.annotation || {};
39
- if (a.type === "container_file_citation") {
40
- h.onFile?.({ container_id: a.container_id, file_id: a.file_id, filename: a.filename });
41
- }
42
- break;
43
- }
44
- case "response.completed":
45
- h.onDone?.("completed", ev.response);
46
- break;
47
- case "response.incomplete":
48
- h.onDone?.("incomplete", ev.response);
49
- break;
50
- case "response.failed":
51
- h.onDone?.(ev.response && ev.response.status || "failed", ev.response);
52
- break;
53
- case "error":
54
- h.onError?.(ev.message || "stream error");
55
- break;
56
- default:
57
- break;
58
- }
59
- }
60
- };
61
- return self;
62
- }
63
- async function readSSEStream(body, onData) {
64
- const reader = body.getReader();
65
- const decoder = new TextDecoder();
66
- let buf = "";
67
- for (; ; ) {
68
- const { value, done } = await reader.read();
69
- if (done) break;
70
- buf += decoder.decode(value, { stream: true });
71
- let nl;
72
- while ((nl = buf.indexOf("\n\n")) !== -1) {
73
- const frame = buf.slice(0, nl);
74
- buf = buf.slice(nl + 2);
75
- const data = frame.split("\n").filter((l) => l.startsWith("data:")).map((l) => l.slice(5).trim()).join("");
76
- if (!data) continue;
77
- onData(data);
78
- }
79
- }
80
- }
81
- async function pumpResponsesStream(body, handlers) {
82
- const d = createResponsesDispatcher(handlers);
83
- await readSSEStream(body, (data) => {
84
- try {
85
- d.dispatch(JSON.parse(data));
86
- } catch {
87
- }
88
- });
89
- return d.responseId;
90
- }
1
+ import {
2
+ createResponsesDispatcher,
3
+ pumpResponsesStream,
4
+ readSSEStream
5
+ } from "./chunk-2LYV4PIX.js";
91
6
 
92
7
  // src/state/blocks.js
93
8
  function withText(blocks, d) {
@@ -1648,18 +1563,23 @@ import { createPortal as createPortal2 } from "react-dom";
1648
1563
  import { Fragment as Fragment6, jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
1649
1564
  var cellKey = (rowId, colId) => `${rowId}:${colId}`;
1650
1565
  var uid = (p) => `${p}_${Math.random().toString(36).slice(2, 10)}`;
1651
- var TYPE_LABEL = {
1652
- text: "Text",
1653
- number: "Number",
1654
- select: "Select",
1655
- tags: "Tags",
1656
- checkbox: "Checkbox",
1657
- date: "Date",
1658
- url: "Link",
1659
- resource: "Resource",
1660
- compute: "Computed"
1661
- };
1662
- var MANUAL_TYPES = ["text", "number", "select", "tags", "checkbox", "date", "url", "resource"];
1566
+ var DEFAULT_COLUMN_TYPES = [
1567
+ { type: "text", label: "Text" },
1568
+ { type: "number", label: "Number" },
1569
+ { type: "select", label: "Select" },
1570
+ { type: "tags", label: "Tags" },
1571
+ { type: "checkbox", label: "Checkbox" },
1572
+ { type: "date", label: "Date" },
1573
+ { type: "url", label: "Link" },
1574
+ { type: "resource", label: "Resource" },
1575
+ {
1576
+ type: "compute",
1577
+ label: "Computed",
1578
+ computed: true,
1579
+ configKey: "compute",
1580
+ badge: (col) => col.compute?.kind
1581
+ }
1582
+ ];
1663
1583
  var COMPUTE_KINDS = [
1664
1584
  { kind: "prompt", label: "AI prompt" },
1665
1585
  { kind: "harness", label: "Agent (harness)" },
@@ -1669,22 +1589,30 @@ var COMPUTE_KINDS = [
1669
1589
  var RESOURCE_KINDS = ["image", "sheet", "slides", "workflow", "graph"];
1670
1590
  var RESOURCE_ICON = { image: "\u{1F5BC}", sheet: "\u25A6", slides: "\u25A4", workflow: "\u2699", graph: "\u25C9" };
1671
1591
  function PopPortal({ anchor, width = 250, estHeight = 300, className, children, onClose }) {
1592
+ const boxRef = useRef6(null);
1672
1593
  useEffect6(() => {
1673
1594
  if (!onClose) return void 0;
1674
1595
  const close = () => onClose();
1596
+ const onDown = (e) => {
1597
+ if (boxRef.current && boxRef.current.contains(e.target)) return;
1598
+ if (anchor && e.clientX >= anchor.left && e.clientX <= anchor.right && e.clientY >= anchor.top && e.clientY <= anchor.bottom) return;
1599
+ onClose();
1600
+ };
1601
+ window.addEventListener("mousedown", onDown);
1675
1602
  window.addEventListener("scroll", close, true);
1676
1603
  window.addEventListener("resize", close);
1677
1604
  return () => {
1605
+ window.removeEventListener("mousedown", onDown);
1678
1606
  window.removeEventListener("scroll", close, true);
1679
1607
  window.removeEventListener("resize", close);
1680
1608
  };
1681
- }, [onClose]);
1609
+ }, [onClose, anchor]);
1682
1610
  if (!anchor) return null;
1683
1611
  const left = Math.max(8, Math.min(anchor.right - width, window.innerWidth - width - 8));
1684
1612
  let top = anchor.bottom + 6;
1685
1613
  if (top + estHeight > window.innerHeight - 8) top = Math.max(8, anchor.top - estHeight - 6);
1686
1614
  return createPortal2(
1687
- /* @__PURE__ */ jsx11("div", { className, style: { position: "fixed", top, left, width, zIndex: 1e3 }, children }),
1615
+ /* @__PURE__ */ jsx11("div", { ref: boxRef, className, style: { position: "fixed", top, left, width, zIndex: 1e3 }, children }),
1688
1616
  document.body
1689
1617
  );
1690
1618
  }
@@ -1776,7 +1704,20 @@ function CellValue({ cell, col, fetchBlobUrl, onOpenResource }) {
1776
1704
  return /* @__PURE__ */ jsx11("span", { className: "shg-val-txt", children: typeof v === "object" ? JSON.stringify(v) : String(v) });
1777
1705
  }
1778
1706
  }
1779
- function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false, fetchBlobUrl, onOpenResource, peerMarks, onActiveCell }) {
1707
+ function SheetGrid({
1708
+ sheet,
1709
+ onChange,
1710
+ onRunCell,
1711
+ onRunColumn,
1712
+ readOnly = false,
1713
+ fetchBlobUrl,
1714
+ onOpenResource,
1715
+ peerMarks,
1716
+ onActiveCell,
1717
+ columnTypes = DEFAULT_COLUMN_TYPES,
1718
+ renderCell,
1719
+ renderColumnConfig
1720
+ }) {
1780
1721
  const columns = sheet?.columns || [];
1781
1722
  const rows = sheet?.rows || [];
1782
1723
  const cells = sheet?.cells || {};
@@ -1788,6 +1729,12 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1788
1729
  const [dropAt, setDropAt] = useState7(null);
1789
1730
  const inputRef = useRef6(null);
1790
1731
  const dragRef = useRef6(null);
1732
+ const descOf = (type) => columnTypes.find((t) => t.type === type) || { type, label: type };
1733
+ const isComputed = (col) => !!descOf(col?.type).computed;
1734
+ const isEditable = (col) => {
1735
+ const d = descOf(col?.type);
1736
+ return d.editable ?? !d.computed;
1737
+ };
1791
1738
  const startResize = (e, kind, id, start) => {
1792
1739
  if (readOnly) return;
1793
1740
  e.preventDefault();
@@ -1893,11 +1840,14 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1893
1840
  };
1894
1841
  const setCell = (rowId, colId, value) => mutate((n) => {
1895
1842
  n.cells = n.cells || {};
1896
- n.cells[cellKey(rowId, colId)] = { value, status: "done", updated_at: Math.floor(Date.now() / 1e3) };
1843
+ const k = cellKey(rowId, colId);
1844
+ const col = (n.columns || []).find((c) => c.id === colId);
1845
+ const prev = n.cells[k];
1846
+ n.cells[k] = isComputed(col) && prev ? { ...prev, value } : { value };
1897
1847
  });
1898
1848
  const openEdit = (rowId, col, anchorEl) => {
1899
1849
  if (readOnly) return;
1900
- if (col.type === "compute") return;
1850
+ if (!isEditable(col)) return;
1901
1851
  if (col.type === "checkbox") {
1902
1852
  const cur = cells[cellKey(rowId, col.id)];
1903
1853
  setCell(rowId, col.id, !(cur && cur.value));
@@ -1943,7 +1893,9 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
1943
1893
  const c = n.columns.find((x) => x.id === colId);
1944
1894
  if (!c) return;
1945
1895
  Object.assign(c, patch);
1946
- if (patch.type && patch.type !== "compute") delete c.compute;
1896
+ if (patch.type) {
1897
+ for (const d of columnTypes) if (d.configKey && d.type !== patch.type) delete c[d.configKey];
1898
+ }
1947
1899
  });
1948
1900
  const renderEditor = (col) => {
1949
1901
  if (col.type === "resource") {
@@ -2042,7 +1994,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
2042
1994
  columns.map((col) => /* @__PURE__ */ jsxs10(
2043
1995
  "th",
2044
1996
  {
2045
- className: "shg-col" + (col.type === "compute" ? " shg-col-compute" : "") + dndClass("col", col.id),
1997
+ className: "shg-col" + (isComputed(col) ? " shg-col-compute" : "") + dndClass("col", col.id),
2046
1998
  style: colWidth(col) ? { width: colWidth(col), minWidth: colWidth(col), maxWidth: colWidth(col) } : void 0,
2047
1999
  ...dndProps("col", col.id),
2048
2000
  children: [
@@ -2053,6 +2005,9 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
2053
2005
  col,
2054
2006
  columns,
2055
2007
  readOnly,
2008
+ desc: descOf(col.type),
2009
+ columnTypes,
2010
+ renderColumnConfig,
2056
2011
  menuOpen: menuCol?.id === col.id,
2057
2012
  menuAnchor: menuCol?.id === col.id ? menuCol.rect : null,
2058
2013
  onMenu: (e) => setMenuCol(menuCol?.id === col.id ? null : { id: col.id, rect: e.currentTarget.getBoundingClientRect() }),
@@ -2063,7 +2018,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
2063
2018
  setMenuCol(null);
2064
2019
  deleteColumn(col.id);
2065
2020
  },
2066
- onRun: col.type === "compute" && onRunColumn ? () => onRunColumn(col.id) : null
2021
+ onRun: isComputed(col) && onRunColumn ? () => onRunColumn(col.id) : null
2067
2022
  }
2068
2023
  ) })
2069
2024
  ]
@@ -2097,12 +2052,27 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
2097
2052
  ),
2098
2053
  columns.map((col) => {
2099
2054
  const c = cells[cellKey(row.id, col.id)] || {};
2055
+ const computed = isComputed(col);
2100
2056
  const isEditing = editing && editing.rowId === row.id && editing.colId === col.id;
2101
2057
  const peer = peerMarks && peerMarks[cellKey(row.id, col.id)];
2058
+ const custom = renderCell && renderCell({
2059
+ cell: c,
2060
+ column: col,
2061
+ row,
2062
+ rowIndex: ri,
2063
+ sheet,
2064
+ computed,
2065
+ width: colWidth(col),
2066
+ height: rowHeight(row),
2067
+ editing: !!isEditing,
2068
+ readOnly,
2069
+ setCell: (v) => setCell(row.id, col.id, v),
2070
+ runCell: onRunCell && !readOnly ? () => onRunCell(row.id, col.id) : null
2071
+ });
2102
2072
  return /* @__PURE__ */ jsxs10(
2103
2073
  "td",
2104
2074
  {
2105
- className: "shg-cell" + (col.type === "compute" ? " shg-cell-compute" : "") + (c.status && col.type === "compute" ? ` shg-cell-${c.status}` : "") + (peer ? " shg-cell-peer" : ""),
2075
+ className: "shg-cell" + (computed ? " shg-cell-compute" : "") + (c.status && computed ? ` shg-cell-${c.status}` : "") + (peer ? " shg-cell-peer" : ""),
2106
2076
  style: peer ? { boxShadow: `inset 0 0 0 2px ${peer.color}` } : void 0,
2107
2077
  onClick: (e) => {
2108
2078
  if (!isEditing) openEdit(row.id, col, e.currentTarget);
@@ -2110,15 +2080,15 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
2110
2080
  title: c.error || "",
2111
2081
  children: [
2112
2082
  peer && /* @__PURE__ */ jsx11("span", { className: "shg-peer-flag", style: { background: peer.color }, children: peer.name }),
2113
- isEditing ? renderEditor(col) : /* @__PURE__ */ jsxs10(
2083
+ isEditing ? renderEditor(col) : /* @__PURE__ */ jsx11(
2114
2084
  "div",
2115
2085
  {
2116
2086
  className: "shg-val",
2117
2087
  style: { maxWidth: colWidth(col) ? colWidth(col) - 20 : 400 },
2118
- children: [
2119
- col.type === "compute" && /* @__PURE__ */ jsx11(StatusDot, { status: c.status }),
2088
+ children: custom !== void 0 ? custom : /* @__PURE__ */ jsxs10(Fragment6, { children: [
2089
+ computed && /* @__PURE__ */ jsx11(StatusDot, { status: c.status }),
2120
2090
  /* @__PURE__ */ jsx11(CellValue, { cell: c, col, fetchBlobUrl, onOpenResource }),
2121
- col.type === "compute" && !readOnly && onRunCell && /* @__PURE__ */ jsx11(
2091
+ computed && !readOnly && onRunCell && /* @__PURE__ */ jsx11(
2122
2092
  "button",
2123
2093
  {
2124
2094
  className: "shg-runcell",
@@ -2130,7 +2100,7 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
2130
2100
  children: "\u25B6"
2131
2101
  }
2132
2102
  )
2133
- ]
2103
+ ] })
2134
2104
  }
2135
2105
  )
2136
2106
  ]
@@ -2150,10 +2120,26 @@ function SheetGrid({ sheet, onChange, onRunCell, onRunColumn, readOnly = false,
2150
2120
  ] })
2151
2121
  ] }) }) });
2152
2122
  }
2153
- function ColumnHeader({ col, columns, readOnly, menuOpen, menuAnchor, onMenu, onCloseMenu, onRename, onConfigure, onDelete, onRun }) {
2123
+ function ColumnHeader({
2124
+ col,
2125
+ columns,
2126
+ readOnly,
2127
+ desc,
2128
+ columnTypes,
2129
+ renderColumnConfig,
2130
+ menuOpen,
2131
+ menuAnchor,
2132
+ onMenu,
2133
+ onCloseMenu,
2134
+ onRename,
2135
+ onConfigure,
2136
+ onDelete,
2137
+ onRun
2138
+ }) {
2154
2139
  const [editing, setEditing] = useState7(false);
2155
2140
  const [name, setName] = useState7(col.name);
2156
2141
  useEffect6(() => setName(col.name), [col.name]);
2142
+ const badge = desc.badge ? desc.badge(col) : void 0;
2157
2143
  return /* @__PURE__ */ jsxs10("div", { className: "shg-colhdr", children: [
2158
2144
  /* @__PURE__ */ jsxs10("div", { className: "shg-colhdr-main", children: [
2159
2145
  editing && !readOnly ? /* @__PURE__ */ jsx11(
@@ -2172,9 +2158,9 @@ function ColumnHeader({ col, columns, readOnly, menuOpen, menuAnchor, onMenu, on
2172
2158
  }
2173
2159
  }
2174
2160
  ) : /* @__PURE__ */ jsx11("span", { className: "shg-colname", onDoubleClick: () => !readOnly && setEditing(true), title: col.name, children: col.name }),
2175
- /* @__PURE__ */ jsxs10("span", { className: "shg-coltype" + (col.type === "compute" ? " compute" : ""), children: [
2176
- TYPE_LABEL[col.type] || col.type,
2177
- col.type === "compute" && col.compute?.kind ? ` \xB7 ${col.compute.kind}` : ""
2161
+ /* @__PURE__ */ jsxs10("span", { className: "shg-coltype" + (desc.computed ? " compute" : ""), children: [
2162
+ desc.label || col.type,
2163
+ badge ? ` \xB7 ${badge}` : ""
2178
2164
  ] })
2179
2165
  ] }),
2180
2166
  !readOnly && /* @__PURE__ */ jsxs10("div", { className: "shg-colhdr-tools", children: [
@@ -2187,6 +2173,8 @@ function ColumnHeader({ col, columns, readOnly, menuOpen, menuAnchor, onMenu, on
2187
2173
  col,
2188
2174
  columns,
2189
2175
  anchor: menuAnchor,
2176
+ columnTypes,
2177
+ renderColumnConfig,
2190
2178
  onApply: (patch) => {
2191
2179
  onConfigure(col.id, patch);
2192
2180
  onCloseMenu();
@@ -2197,7 +2185,7 @@ function ColumnHeader({ col, columns, readOnly, menuOpen, menuAnchor, onMenu, on
2197
2185
  )
2198
2186
  ] });
2199
2187
  }
2200
- function ColumnMenu({ col, columns, anchor, onApply, onDelete, onClose }) {
2188
+ function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onApply, onDelete, onClose }) {
2201
2189
  const [type, setType] = useState7(col.type || "text");
2202
2190
  const [optText, setOptText] = useState7(
2203
2191
  normOptions(col.options).map((o) => o.label).join("\n")
@@ -2209,14 +2197,6 @@ function ColumnMenu({ col, columns, anchor, onApply, onDelete, onClose }) {
2209
2197
  const [wfSlug, setWfSlug] = useState7(comp.workflow_slug || "");
2210
2198
  const [outKey, setOutKey] = useState7(comp.output_key || "");
2211
2199
  const [deps, setDeps] = useState7(new Set(comp.deps || []));
2212
- const ref = useRef6(null);
2213
- useEffect6(() => {
2214
- const onDown = (e) => {
2215
- if (ref.current && !ref.current.contains(e.target)) onClose();
2216
- };
2217
- window.addEventListener("mousedown", onDown);
2218
- return () => window.removeEventListener("mousedown", onDown);
2219
- }, [onClose]);
2220
2200
  const others = columns.filter((c) => c.id !== col.id);
2221
2201
  const toggleDep = (id) => setDeps((s) => {
2222
2202
  const n = new Set(s);
@@ -2244,99 +2224,126 @@ function ColumnMenu({ col, columns, anchor, onApply, onDelete, onClose }) {
2244
2224
  }
2245
2225
  onApply(patch);
2246
2226
  };
2247
- return /* @__PURE__ */ jsx11(PopPortal, { anchor, width: 250, estHeight: 340, className: "shg-menu", onClose, children: /* @__PURE__ */ jsxs10("div", { ref, onClick: (e) => e.stopPropagation(), children: [
2248
- /* @__PURE__ */ jsxs10("label", { className: "shg-menu-lbl", children: [
2249
- "Type",
2250
- /* @__PURE__ */ jsxs10("select", { className: "shg-menu-input", value: type, onChange: (e) => setType(e.target.value), children: [
2251
- MANUAL_TYPES.map((t) => /* @__PURE__ */ jsx11("option", { value: t, children: TYPE_LABEL[t] }, t)),
2252
- /* @__PURE__ */ jsx11("option", { value: "compute", children: "Computed" })
2253
- ] })
2254
- ] }),
2255
- (type === "select" || type === "tags") && /* @__PURE__ */ jsxs10("label", { className: "shg-menu-lbl", children: [
2256
- "Options (one per line)",
2257
- /* @__PURE__ */ jsx11(
2258
- "textarea",
2259
- {
2260
- className: "shg-menu-input",
2261
- rows: 3,
2262
- value: optText,
2263
- onChange: (e) => setOptText(e.target.value),
2264
- placeholder: "Todo\nDoing\nDone"
2265
- }
2266
- )
2267
- ] }),
2268
- type === "compute" && /* @__PURE__ */ jsxs10(Fragment6, { children: [
2269
- /* @__PURE__ */ jsxs10("label", { className: "shg-menu-lbl", children: [
2270
- "Runs",
2271
- /* @__PURE__ */ jsx11("select", { className: "shg-menu-input", value: kind, onChange: (e) => setKind(e.target.value), children: COMPUTE_KINDS.map((k) => /* @__PURE__ */ jsx11("option", { value: k.kind, children: k.label }, k.kind)) })
2272
- ] }),
2273
- (kind === "prompt" || kind === "harness") && /* @__PURE__ */ jsxs10("label", { className: "shg-menu-lbl", children: [
2274
- "Prompt \u2014 reference columns as ",
2275
- "{{Name}}",
2276
- /* @__PURE__ */ jsx11(
2277
- "textarea",
2278
- {
2279
- className: "shg-menu-input",
2280
- rows: 3,
2281
- value: prompt,
2282
- onChange: (e) => setPrompt(e.target.value),
2283
- placeholder: "Summarize {{Company}} in one line"
2284
- }
2285
- )
2286
- ] }),
2287
- kind === "harness" && /* @__PURE__ */ jsxs10("label", { className: "shg-menu-lbl", children: [
2288
- "Agent id",
2289
- /* @__PURE__ */ jsx11("input", { className: "shg-menu-input", value: harnessId, onChange: (e) => setHarnessId(e.target.value), placeholder: "chrn_\u2026" })
2290
- ] }),
2291
- kind === "workflow" && /* @__PURE__ */ jsxs10(Fragment6, { children: [
2227
+ const custom = renderColumnConfig && renderColumnConfig({
2228
+ column: col,
2229
+ columns,
2230
+ type,
2231
+ applyPatch: (patch) => onApply({ type, ...patch }),
2232
+ deleteColumn: onDelete,
2233
+ close: onClose
2234
+ });
2235
+ const desc = columnTypes.find((t) => t.type === type) || {};
2236
+ return /* @__PURE__ */ jsx11(
2237
+ PopPortal,
2238
+ {
2239
+ anchor,
2240
+ width: desc.configWidth || 250,
2241
+ estHeight: desc.configHeight || 340,
2242
+ className: "shg-menu",
2243
+ onClose,
2244
+ children: /* @__PURE__ */ jsxs10("div", { onClick: (e) => e.stopPropagation(), children: [
2292
2245
  /* @__PURE__ */ jsxs10("label", { className: "shg-menu-lbl", children: [
2293
- "Workflow id",
2294
- /* @__PURE__ */ jsx11("input", { className: "shg-menu-input", value: wfSlug, onChange: (e) => setWfSlug(e.target.value), placeholder: "my-workflow" })
2246
+ "Type",
2247
+ /* @__PURE__ */ jsx11("select", { className: "shg-menu-input", value: type, onChange: (e) => setType(e.target.value), children: columnTypes.map((t) => /* @__PURE__ */ jsx11("option", { value: t.type, children: t.label }, t.type)) })
2295
2248
  ] }),
2296
- /* @__PURE__ */ jsxs10("label", { className: "shg-menu-lbl", children: [
2297
- "Output key (optional)",
2298
- /* @__PURE__ */ jsx11("input", { className: "shg-menu-input", value: outKey, onChange: (e) => setOutKey(e.target.value), placeholder: "summary" })
2249
+ (type === "select" || type === "tags") && /* @__PURE__ */ jsxs10("label", { className: "shg-menu-lbl", children: [
2250
+ "Options (one per line)",
2251
+ /* @__PURE__ */ jsx11(
2252
+ "textarea",
2253
+ {
2254
+ className: "shg-menu-input",
2255
+ rows: 3,
2256
+ value: optText,
2257
+ onChange: (e) => setOptText(e.target.value),
2258
+ placeholder: "Todo\nDoing\nDone"
2259
+ }
2260
+ )
2261
+ ] }),
2262
+ custom !== void 0 ? custom : /* @__PURE__ */ jsxs10(Fragment6, { children: [
2263
+ type === "compute" && /* @__PURE__ */ jsxs10(Fragment6, { children: [
2264
+ /* @__PURE__ */ jsxs10("label", { className: "shg-menu-lbl", children: [
2265
+ "Runs",
2266
+ /* @__PURE__ */ jsx11("select", { className: "shg-menu-input", value: kind, onChange: (e) => setKind(e.target.value), children: COMPUTE_KINDS.map((k) => /* @__PURE__ */ jsx11("option", { value: k.kind, children: k.label }, k.kind)) })
2267
+ ] }),
2268
+ (kind === "prompt" || kind === "harness") && /* @__PURE__ */ jsxs10("label", { className: "shg-menu-lbl", children: [
2269
+ "Prompt \u2014 reference columns as ",
2270
+ "{{Name}}",
2271
+ /* @__PURE__ */ jsx11(
2272
+ "textarea",
2273
+ {
2274
+ className: "shg-menu-input",
2275
+ rows: 3,
2276
+ value: prompt,
2277
+ onChange: (e) => setPrompt(e.target.value),
2278
+ placeholder: "Summarize {{Company}} in one line"
2279
+ }
2280
+ )
2281
+ ] }),
2282
+ kind === "harness" && /* @__PURE__ */ jsxs10("label", { className: "shg-menu-lbl", children: [
2283
+ "Agent id",
2284
+ /* @__PURE__ */ jsx11("input", { className: "shg-menu-input", value: harnessId, onChange: (e) => setHarnessId(e.target.value), placeholder: "chrn_\u2026" })
2285
+ ] }),
2286
+ kind === "workflow" && /* @__PURE__ */ jsxs10(Fragment6, { children: [
2287
+ /* @__PURE__ */ jsxs10("label", { className: "shg-menu-lbl", children: [
2288
+ "Workflow id",
2289
+ /* @__PURE__ */ jsx11("input", { className: "shg-menu-input", value: wfSlug, onChange: (e) => setWfSlug(e.target.value), placeholder: "my-workflow" })
2290
+ ] }),
2291
+ /* @__PURE__ */ jsxs10("label", { className: "shg-menu-lbl", children: [
2292
+ "Output key (optional)",
2293
+ /* @__PURE__ */ jsx11("input", { className: "shg-menu-input", value: outKey, onChange: (e) => setOutKey(e.target.value), placeholder: "summary" })
2294
+ ] })
2295
+ ] }),
2296
+ others.length > 0 && /* @__PURE__ */ jsxs10("div", { className: "shg-menu-lbl", children: [
2297
+ "Reads columns",
2298
+ /* @__PURE__ */ jsx11("div", { className: "shg-menu-deps", children: others.map((c) => /* @__PURE__ */ jsxs10("label", { className: "shg-menu-dep", children: [
2299
+ /* @__PURE__ */ jsx11("input", { type: "checkbox", checked: deps.has(c.id), onChange: () => toggleDep(c.id) }),
2300
+ " ",
2301
+ c.name
2302
+ ] }, c.id)) })
2303
+ ] })
2304
+ ] }),
2305
+ /* @__PURE__ */ jsxs10("div", { className: "shg-menu-actions", children: [
2306
+ /* @__PURE__ */ jsx11("button", { className: "shg-menu-del", onClick: onDelete, children: "Delete column" }),
2307
+ /* @__PURE__ */ jsx11("button", { className: "shg-menu-apply", onClick: apply, children: "Apply" })
2308
+ ] })
2299
2309
  ] })
2300
- ] }),
2301
- others.length > 0 && /* @__PURE__ */ jsxs10("div", { className: "shg-menu-lbl", children: [
2302
- "Reads columns",
2303
- /* @__PURE__ */ jsx11("div", { className: "shg-menu-deps", children: others.map((c) => /* @__PURE__ */ jsxs10("label", { className: "shg-menu-dep", children: [
2304
- /* @__PURE__ */ jsx11("input", { type: "checkbox", checked: deps.has(c.id), onChange: () => toggleDep(c.id) }),
2305
- " ",
2306
- c.name
2307
- ] }, c.id)) })
2308
2310
  ] })
2309
- ] }),
2310
- /* @__PURE__ */ jsxs10("div", { className: "shg-menu-actions", children: [
2311
- /* @__PURE__ */ jsx11("button", { className: "shg-menu-del", onClick: onDelete, children: "Delete column" }),
2312
- /* @__PURE__ */ jsx11("button", { className: "shg-menu-apply", onClick: apply, children: "Apply" })
2313
- ] })
2314
- ] }) });
2311
+ }
2312
+ );
2315
2313
  }
2316
- function sheetToDelimited(sheet, sep = ",") {
2314
+ function defaultCellText(cell) {
2315
+ const v = cell?.value;
2316
+ if (v == null) return "";
2317
+ if (Array.isArray(v)) return v.join(", ");
2318
+ if (typeof v === "object") return JSON.stringify(v);
2319
+ return String(v);
2320
+ }
2321
+ function sheetToDelimited(sheet, sep = ",", { cellText = defaultCellText } = {}) {
2317
2322
  const cols = sheet?.columns || [];
2318
2323
  const rows = sheet?.rows || [];
2319
2324
  const cells = sheet?.cells || {};
2320
- const esc = (v) => {
2321
- const s = v == null ? "" : Array.isArray(v) ? v.join(", ") : typeof v === "object" ? JSON.stringify(v) : String(v);
2325
+ const esc = (s) => {
2322
2326
  if (sep === "," && /[",\n]/.test(s)) return `"${s.replace(/"/g, '""')}"`;
2323
2327
  return s;
2324
2328
  };
2325
2329
  const header = cols.map((c) => esc(c.name)).join(sep);
2326
- const body = rows.map((r) => cols.map((c) => {
2327
- const cell = cells[cellKey(r.id, c.id)];
2328
- return esc(cell ? cell.value : "");
2329
- }).join(sep));
2330
+ const body = rows.map((r) => cols.map((c) => esc(String(cellText(cells[cellKey(r.id, c.id)], c) ?? ""))).join(sep));
2330
2331
  return [header, ...body].join("\n");
2331
2332
  }
2332
- function sheetToAoA(sheet) {
2333
+ function defaultCellValue(cell) {
2334
+ const v = cell?.value;
2335
+ if (v == null) return "";
2336
+ if (Array.isArray(v)) return v.join(", ");
2337
+ if (typeof v === "object") return JSON.stringify(v);
2338
+ return v;
2339
+ }
2340
+ function sheetToAoA(sheet, { cellText = defaultCellValue } = {}) {
2333
2341
  const cols = sheet?.columns || [];
2334
2342
  const rows = sheet?.rows || [];
2335
2343
  const cells = sheet?.cells || {};
2336
- const val = (v) => v == null ? "" : Array.isArray(v) ? v.join(", ") : typeof v === "object" ? JSON.stringify(v) : v;
2337
2344
  return [
2338
2345
  cols.map((c) => c.name),
2339
- ...rows.map((r) => cols.map((c) => val(cells[cellKey(r.id, c.id)]?.value)))
2346
+ ...rows.map((r) => cols.map((c) => cellText(cells[cellKey(r.id, c.id)], c) ?? ""))
2340
2347
  ];
2341
2348
  }
2342
2349
  export {