@ai-matrx/records-ui 0.116.30 → 0.116.32

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.d.cts CHANGED
@@ -563,8 +563,6 @@ interface TableAskAgentAnswer {
563
563
  type TableAskOutcome = {
564
564
  ok: true;
565
565
  answer: TableAskAgentAnswer;
566
- /** What the run cost, in whole points at the viewer's rate. Absent or null = not measured; nothing is drawn (never dollars). */
567
- costPoints?: number | null | undefined;
568
566
  }
569
567
  /** A refusal says the real reason (`message`) and, when the host knows one, what to do (`hint`); no hint, none is invented. */
570
568
  | {
package/dist/index.d.ts CHANGED
@@ -563,8 +563,6 @@ interface TableAskAgentAnswer {
563
563
  type TableAskOutcome = {
564
564
  ok: true;
565
565
  answer: TableAskAgentAnswer;
566
- /** What the run cost, in whole points at the viewer's rate. Absent or null = not measured; nothing is drawn (never dollars). */
567
- costPoints?: number | null | undefined;
568
566
  }
569
567
  /** A refusal says the real reason (`message`) and, when the host knows one, what to do (`hint`); no hint, none is invented. */
570
568
  | {
package/dist/index.js CHANGED
@@ -182,7 +182,7 @@ import {
182
182
  withoutAddition,
183
183
  withoutLeadingBlank,
184
184
  workedOutErrorFor
185
- } from "./chunk-2SI7LSP3.js";
185
+ } from "./chunk-ECUJDR3W.js";
186
186
  import {
187
187
  CHART_PLOT_PX,
188
188
  EMBEDDED_ROW_PX,
@@ -234,7 +234,7 @@ import {
234
234
  HtmlSampleTokensProvider,
235
235
  SAMPLE_TOKEN_NAMES,
236
236
  sampleDocument
237
- } from "./chunk-W7GR64CB.js";
237
+ } from "./chunk-GT27AGOI.js";
238
238
  import {
239
239
  ArchiveItemMenu,
240
240
  ArchivedBuiltOn,
@@ -293,7 +293,7 @@ import {
293
293
  visibilityLaneFor,
294
294
  whyNotAskable,
295
295
  writeOnTheWinningVersion_exports
296
- } from "./chunk-FLIERNH7.js";
296
+ } from "./chunk-U7SHCLTY.js";
297
297
  import {
298
298
  ACTION_CHECKING_ACCESS_REASON,
299
299
  ACTION_NOT_HERE_REASON,
@@ -400,7 +400,7 @@ import {
400
400
  useRowRights,
401
401
  useTableRights,
402
402
  withoutInternalCodes
403
- } from "./chunk-7RSMA3NK.js";
403
+ } from "./chunk-5IHVQ5MS.js";
404
404
  import {
405
405
  FEWEST_KEY_VALUE_PAIRS,
406
406
  FEWEST_LIST_ITEMS,
@@ -9071,7 +9071,7 @@ function EnrichPanel({ tableId, fieldId, className }) {
9071
9071
  ] })
9072
9072
  ] }),
9073
9073
  /* @__PURE__ */ jsxs25("p", { className: "text-xs text-muted-foreground", children: [
9074
- row.runs === 0 ? "It has not run yet, so it has cost nothing." : `${row.runs} run${row.runs === 1 ? "" : "s"}` + (costInPoints(Number(row.cost_cents), host.pointsRate) !== null ? ` \xB7 ${costInPoints(Number(row.cost_cents), host.pointsRate)} so far` : "") + (row.cost_per_row_cents !== null && costInPoints(Number(row.cost_per_row_cents), host.pointsRate) !== null ? ` \xB7 ${costInPoints(Number(row.cost_per_row_cents), host.pointsRate)} a row` : "") + (row.last_run_at ? ` \xB7 last ran ${ago(row.last_run_at)}` : ""),
9074
+ row.runs === 0 ? "It has not run yet." : `${row.runs} run${row.runs === 1 ? "" : "s"}` + (costInPoints(Number(row.cost_cents), host.pointsRate) !== null ? ` \xB7 ${costInPoints(Number(row.cost_cents), host.pointsRate)} so far` : "") + (row.cost_per_row_cents !== null && costInPoints(Number(row.cost_per_row_cents), host.pointsRate) !== null ? ` \xB7 ${costInPoints(Number(row.cost_per_row_cents), host.pointsRate)} a row` : "") + (row.last_run_at ? ` \xB7 last ran ${ago(row.last_run_at)}` : ""),
9075
9075
  row.enrichment?.model ? ` \xB7 ${row.enrichment.model}` : ""
9076
9076
  ] }),
9077
9077
  rights.admin ? /* @__PURE__ */ jsxs25("div", { className: "flex flex-wrap gap-2", children: [
@@ -9152,10 +9152,7 @@ function EnrichPanel({ tableId, fieldId, className }) {
9152
9152
  /* @__PURE__ */ jsx26("span", { className: "truncate text-muted-foreground", children: preview?.find((p) => p.record_id === w.record_id)?.title ?? w.record_id.slice(0, 8) }),
9153
9153
  /* @__PURE__ */ jsx26("span", { className: "min-w-0 truncate text-right", children: w.absent ? w.absent === "conflicting" ? "Sources disagree" : "Nothing found" : String(w.value ?? "") })
9154
9154
  ] }, w.record_id)) }) : null,
9155
- outcome && (outcome.fieldId === void 0 || outcome.fieldId === row.field_id) ? outcome.ok ? /* @__PURE__ */ jsxs25("p", { className: "text-xs text-muted-foreground", "data-testid": "enrich-outcome", children: [
9156
- outcome.message,
9157
- costInPoints(outcome.costCents, host.pointsRate) !== null ? ` \xB7 ${costInPoints(outcome.costCents, host.pointsRate)}` : ""
9158
- ] }) : (
9155
+ outcome && (outcome.fieldId === void 0 || outcome.fieldId === row.field_id) ? outcome.ok ? /* @__PURE__ */ jsx26("p", { className: "text-xs text-muted-foreground", "data-testid": "enrich-outcome", children: outcome.message }) : (
9159
9156
  // A run that did not happen is a refusal, with a heading and a remedy,
9160
9157
  // never the host's words in red (lane REFUSAL-SWEEP).
9161
9158
  /* @__PURE__ */ jsx26(
@@ -20849,7 +20846,7 @@ function useRowColorBy(all, colorKey, style) {
20849
20846
  // src/workedOutDate.ts
20850
20847
  import { FORMULA_NODE_RESULTS } from "@ai-matrx/records";
20851
20848
  var WORKED_OUT_DATE_LOCK = "Worked out \xB7 can't move";
20852
- var INLINE_DEPTH = 8;
20849
+ var FORMULA_TYPING_ROUNDS = 9;
20853
20850
  var configOf = (field) => field?.config ?? {};
20854
20851
  function isStoredDate(field) {
20855
20852
  if (!field || field.type !== "range") return false;
@@ -20863,27 +20860,36 @@ function ownExpression(field) {
20863
20860
  const expr = config["expr"];
20864
20861
  return !("via" in config) && expr && typeof expr === "object" && !Array.isArray(expr) ? expr : null;
20865
20862
  }
20866
- function inlineFormulas(node, all, seen = []) {
20867
- if (!node || typeof node !== "object" || Array.isArray(node)) return node;
20868
- const n = node;
20869
- if ("field" in n) {
20870
- const f = all.find((x) => x.id === n["field"]);
20871
- const expr = ownExpression(f);
20872
- if (!expr) return node;
20873
- const id = String(n["field"]);
20874
- if (seen.includes(id) || seen.length >= INLINE_DEPTH) return null;
20875
- return inlineFormulas(expr, all, [...seen, id]);
20863
+ function typedAs(field, kind2) {
20864
+ if (kind2 === "date") return { ...field, type: "range", config: { kind: "date", _typed: true } };
20865
+ if (kind2 === "number") return { ...field, type: "range", config: { _typed: true } };
20866
+ if (kind2 === "text") return { ...field, type: "text" };
20867
+ if (kind2 === "boolean") return { ...field, type: "boolean" };
20868
+ return field;
20869
+ }
20870
+ var typedRounds = /* @__PURE__ */ new WeakMap();
20871
+ function typedFormulaFields(all, rounds = FORMULA_TYPING_ROUNDS) {
20872
+ let byRounds = typedRounds.get(all);
20873
+ const hit = byRounds?.get(rounds);
20874
+ if (hit) return hit;
20875
+ let cur = all;
20876
+ for (let i = 0; i < rounds; i++) {
20877
+ const prev = cur;
20878
+ cur = all.map((f) => {
20879
+ const expr = ownExpression(f);
20880
+ return expr ? typedAs(f, formulaResultKind(expr, prev)) : f;
20881
+ });
20876
20882
  }
20877
- if (Array.isArray(n["args"])) {
20878
- const args = [];
20879
- for (const a of n["args"]) {
20880
- const r = inlineFormulas(a, all, seen);
20881
- if (r === null) return null;
20882
- args.push(r);
20883
- }
20884
- return { ...n, args };
20883
+ if (!byRounds) {
20884
+ byRounds = /* @__PURE__ */ new Map();
20885
+ typedRounds.set(all, byRounds);
20885
20886
  }
20886
- return node;
20887
+ byRounds.set(rounds, cur);
20888
+ return cur;
20889
+ }
20890
+ function formulaTypeOf(targetId, all, rounds = FORMULA_TYPING_ROUNDS) {
20891
+ const expr = ownExpression(all.find((f) => f.id === targetId));
20892
+ return expr ? formulaResultKind(expr, typedFormulaFields(all, rounds)) : "unknown";
20887
20893
  }
20888
20894
  function formulaResultKind(node, all) {
20889
20895
  if (!node || typeof node !== "object" || Array.isArray(node)) return "unknown";
@@ -20922,10 +20928,7 @@ function formulaResultKind(node, all) {
20922
20928
  return FORMULA_NODE_RESULTS[op] ?? "unknown";
20923
20929
  }
20924
20930
  function isDateFormula(field, all) {
20925
- const expr = ownExpression(field);
20926
- if (!expr || !field) return false;
20927
- const inlined = inlineFormulas(expr, all, [field.id]);
20928
- return inlined !== null && formulaResultKind(inlined, all) === "date";
20931
+ return !!field && formulaTypeOf(field.id, all) === "date";
20929
20932
  }
20930
20933
  function isComputedField(field) {
20931
20934
  return field?.type === "formula";
@@ -35772,7 +35775,6 @@ function QuestionAnswerView({ tableId, spec, answer, fields, related = NO_RELATE
35772
35775
 
35773
35776
  // src/TableAsk.tsx
35774
35777
  import { useEffect as useEffect91, useState as useState102 } from "react";
35775
- import { formatPoints as formatPoints2 } from "@ai-matrx/kit/format";
35776
35778
  import { BasicInput as BasicInput21, Button as Button85, Popover as Popover10, PopoverContent as PopoverContent10, PopoverTrigger as PopoverTrigger10, Skeleton as Skeleton35 } from "@ai-matrx/design-system";
35777
35779
  import { optionLabel as optionLabel2 } from "@ai-matrx/records";
35778
35780
  import { useFields as useFields30, useRecordsClient as useRecordsClient81, useTable as useTable31 } from "@ai-matrx/records/react";
@@ -36006,7 +36008,7 @@ function TableAsk({ tableId, onOpenInQuestions, viewId }) {
36006
36008
  setSaid({ kind: "asking", reads: words2.trim() });
36007
36009
  const got = await askTable({ tableId, question: words2.trim(), viewId: viewId ?? "" });
36008
36010
  setSaid(
36009
- got.ok ? { kind: "agent-answer", answer: got.answer, costPoints: got.costPoints ?? null } : { kind: "agent-failed", error: (0, refusals_exports.refusal)("door", got.message, got.hint ?? null) }
36011
+ got.ok ? { kind: "agent-answer", answer: got.answer } : { kind: "agent-failed", error: (0, refusals_exports.refusal)("door", got.message, got.hint ?? null) }
36010
36012
  );
36011
36013
  return;
36012
36014
  }
@@ -36059,7 +36061,7 @@ function TableAsk({ tableId, onOpenInQuestions, viewId }) {
36059
36061
  /* @__PURE__ */ jsx113(Skeleton35, { className: "h-24 w-full", "data-table-ask-pending": "" })
36060
36062
  ] }) : null,
36061
36063
  said.kind === "agent-failed" ? /* @__PURE__ */ jsx113("div", { "data-table-ask-failed": "", children: /* @__PURE__ */ jsx113(RefusalNotice, { error: said.error }) }) : null,
36062
- said.kind === "agent-answer" ? /* @__PURE__ */ jsx113(AgentAnswer, { tableId, answer: said.answer, fields: all, costPoints: said.costPoints }) : null,
36064
+ said.kind === "agent-answer" ? /* @__PURE__ */ jsx113(AgentAnswer, { tableId, answer: said.answer, fields: all }) : null,
36063
36065
  said.kind === "refused" ? /* @__PURE__ */ jsx113(RefusalNotice, { error: said.error }) : null,
36064
36066
  said.kind === "answer" ? /* @__PURE__ */ jsxs106(Fragment49, { children: [
36065
36067
  /* @__PURE__ */ jsx113("p", { className: "truncate text-muted-foreground", title: said.reads, "data-table-ask-reads": "", children: said.reads }),
@@ -36108,8 +36110,7 @@ function useNames(tableId, ids) {
36108
36110
  function AgentAnswer({
36109
36111
  tableId,
36110
36112
  answer,
36111
- fields,
36112
- costPoints = null
36113
+ fields
36113
36114
  }) {
36114
36115
  const client = useRecordsClient81();
36115
36116
  const ui = useRecordsUi();
@@ -36175,7 +36176,6 @@ function AgentAnswer({
36175
36176
  ] }, `${c.record_id}:${c.field_key}:${i}`)) }) : null,
36176
36177
  open.length > 1 ? /* @__PURE__ */ jsx113(Button85, { size: "sm", className: "w-fit self-end", disabled: busy, onClick: () => void apply(open), "data-table-ask-apply-all": "", children: "Apply all" }) : null,
36177
36178
  refusal3 ? /* @__PURE__ */ jsx113(RefusalNotice, { error: refusal3 }) : null,
36178
- costPoints !== null ? /* @__PURE__ */ jsx113("p", { className: "text-muted-foreground", "data-table-ask-cost": "", children: formatPoints2(costPoints) }) : null,
36179
36179
  answer.could_not.length > 0 ? /* @__PURE__ */ jsx113("ul", { className: "text-muted-foreground", "data-table-ask-could-not": "", children: answer.could_not.map((w) => /* @__PURE__ */ jsx113("li", { children: w }, w)) }) : null
36180
36180
  ] });
36181
36181
  }