@tangle-network/agent-app 0.45.21 → 0.45.23

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.
Files changed (118) hide show
  1. package/dist/DesignCanvas-ZG7DJS7C.js +10 -0
  2. package/dist/DesignCanvasEditor-SLFMHOII.js +13 -0
  3. package/dist/app-auth/index.js +2 -2
  4. package/dist/assistant/index.d.ts +1 -1
  5. package/dist/assistant/index.js +5 -5
  6. package/dist/{attachment-validation-CsmUzuI3.d.ts → attachment-validation-BfJDBU1g.d.ts} +41 -5
  7. package/dist/{auth-DJjJBtYw.d.ts → auth-BYtiazA4.d.ts} +1 -1
  8. package/dist/chat-react/index.js +2 -2
  9. package/dist/chat-routes/index.d.ts +8 -4
  10. package/dist/chat-routes/index.js +21 -4
  11. package/dist/chat-routes/index.js.map +1 -1
  12. package/dist/{chunk-KPRBFNGT.js → chunk-3IHYJIDJ.js} +3 -3
  13. package/dist/{chunk-MYS7DHMM.js → chunk-4QVG4WJQ.js} +2 -2
  14. package/dist/{chunk-RMHZKMQ4.js → chunk-73CQJOIU.js} +5 -5
  15. package/dist/{chunk-AH3IOSWF.js → chunk-7PFFFRVU.js} +2077 -341
  16. package/dist/chunk-7PFFFRVU.js.map +1 -0
  17. package/dist/chunk-CCVG2TL6.js +327 -0
  18. package/dist/chunk-CCVG2TL6.js.map +1 -0
  19. package/dist/{chunk-U4BXAZCN.js → chunk-DRB77FYL.js} +2 -2
  20. package/dist/{chunk-6MUJROBT.js → chunk-E4DHYENH.js} +2 -2
  21. package/dist/chunk-F7VH4G5C.js +283 -0
  22. package/dist/chunk-F7VH4G5C.js.map +1 -0
  23. package/dist/chunk-I24YIKHO.js +183 -0
  24. package/dist/chunk-I24YIKHO.js.map +1 -0
  25. package/dist/{chunk-OO4DROKM.js → chunk-OASVAPRL.js} +3 -3
  26. package/dist/{chunk-ZSGTG6PK.js → chunk-P5PIAQVS.js} +2 -2
  27. package/dist/chunk-PC2WYTK7.js +405 -0
  28. package/dist/chunk-PC2WYTK7.js.map +1 -0
  29. package/dist/{chunk-YEFFHORB.js → chunk-TX6S7XXU.js} +8 -2
  30. package/dist/chunk-TX6S7XXU.js.map +1 -0
  31. package/dist/chunk-UGWQLQDS.js +35 -0
  32. package/dist/chunk-UGWQLQDS.js.map +1 -0
  33. package/dist/{chunk-O22STZ3P.js → chunk-X5DQ5QOP.js} +2 -2
  34. package/dist/chunk-XEA5EG6P.js +1478 -0
  35. package/dist/chunk-XEA5EG6P.js.map +1 -0
  36. package/dist/{chunk-PCJHEZA7.js → chunk-YABHE2QY.js} +2 -2
  37. package/dist/design-canvas/index.d.ts +3 -3
  38. package/dist/design-canvas/index.js +2 -2
  39. package/dist/design-canvas-react/engine.js +4 -4
  40. package/dist/design-canvas-react/index.js +7 -7
  41. package/dist/design-canvas-react/lazy.js +1 -1
  42. package/dist/documents/index.d.ts +233 -0
  43. package/dist/documents/index.js +495 -0
  44. package/dist/documents/index.js.map +1 -0
  45. package/dist/documents/pdf-inspector.d.ts +60 -0
  46. package/dist/documents/pdf-inspector.js +100 -0
  47. package/dist/documents/pdf-inspector.js.map +1 -0
  48. package/dist/eval/index.d.ts +1 -1
  49. package/dist/fold-DACU7gtf.d.ts +320 -0
  50. package/dist/legibility/cli.d.ts +1 -0
  51. package/dist/legibility/cli.js +143 -0
  52. package/dist/legibility/cli.js.map +1 -0
  53. package/dist/legibility/index.d.ts +572 -0
  54. package/dist/legibility/index.js +33 -0
  55. package/dist/legibility/index.js.map +1 -0
  56. package/dist/{mcp-BiKqnsJV.d.ts → mcp-xxoZZfor.d.ts} +2 -2
  57. package/dist/openui/index.d.ts +208 -0
  58. package/dist/openui/index.js +350 -0
  59. package/dist/openui/index.js.map +1 -0
  60. package/dist/openui-react/index.d.ts +119 -0
  61. package/dist/openui-react/index.js +149 -0
  62. package/dist/openui-react/index.js.map +1 -0
  63. package/dist/platform/index.js +2 -2
  64. package/dist/preset-cloudflare/index.d.ts +2 -2
  65. package/dist/rate-limit-BOVmJRXZ.d.ts +35 -0
  66. package/dist/record/drizzle.d.ts +682 -0
  67. package/dist/record/drizzle.js +579 -0
  68. package/dist/record/drizzle.js.map +1 -0
  69. package/dist/record/index.d.ts +16 -0
  70. package/dist/record/index.js +35 -0
  71. package/dist/record/index.js.map +1 -0
  72. package/dist/runtime/index.d.ts +3 -3
  73. package/dist/sandbox/index.d.ts +2 -2
  74. package/dist/sandbox/index.js +3 -2
  75. package/dist/sequences/index.d.ts +3 -3
  76. package/dist/sequences/index.js +1 -1
  77. package/dist/session-shell/index.d.ts +173 -1
  78. package/dist/session-shell/index.js +13 -1
  79. package/dist/teams/index.js +9 -9
  80. package/dist/teams/invitations-api.js +3 -3
  81. package/dist/tools/index.d.ts +5 -5
  82. package/dist/tools/index.js +3 -2
  83. package/dist/{types-DbU-oO5h.d.ts → types-B25Mib1r.d.ts} +11 -0
  84. package/dist/types-DrBidf3O.d.ts +123 -0
  85. package/dist/values-C7RidJuI.d.ts +156 -0
  86. package/dist/web/index.d.ts +197 -31
  87. package/dist/web/index.js +15 -3
  88. package/dist/web-react/async/index.d.ts +309 -0
  89. package/dist/web-react/async/index.js +327 -0
  90. package/dist/web-react/async/index.js.map +1 -0
  91. package/dist/web-react/index.d.ts +586 -2
  92. package/dist/web-react/index.js +84 -6
  93. package/dist/work-product/index.d.ts +1 -1
  94. package/dist/work-product/index.js +2 -1
  95. package/dist/work-product/index.js.map +1 -1
  96. package/dist/workspace-react/index.js +1 -1
  97. package/package.json +49 -3
  98. package/dist/DesignCanvas-NEIW3AER.js +0 -10
  99. package/dist/DesignCanvasEditor-QD33OI2W.js +0 -13
  100. package/dist/chunk-AH3IOSWF.js.map +0 -1
  101. package/dist/chunk-GINKOZFD.js +0 -214
  102. package/dist/chunk-GINKOZFD.js.map +0 -1
  103. package/dist/chunk-J25RST7G.js +0 -126
  104. package/dist/chunk-J25RST7G.js.map +0 -1
  105. package/dist/chunk-WBHPN5DY.js +0 -158
  106. package/dist/chunk-WBHPN5DY.js.map +0 -1
  107. package/dist/chunk-YEFFHORB.js.map +0 -1
  108. /package/dist/{DesignCanvas-NEIW3AER.js.map → DesignCanvas-ZG7DJS7C.js.map} +0 -0
  109. /package/dist/{DesignCanvasEditor-QD33OI2W.js.map → DesignCanvasEditor-SLFMHOII.js.map} +0 -0
  110. /package/dist/{chunk-KPRBFNGT.js.map → chunk-3IHYJIDJ.js.map} +0 -0
  111. /package/dist/{chunk-MYS7DHMM.js.map → chunk-4QVG4WJQ.js.map} +0 -0
  112. /package/dist/{chunk-RMHZKMQ4.js.map → chunk-73CQJOIU.js.map} +0 -0
  113. /package/dist/{chunk-U4BXAZCN.js.map → chunk-DRB77FYL.js.map} +0 -0
  114. /package/dist/{chunk-6MUJROBT.js.map → chunk-E4DHYENH.js.map} +0 -0
  115. /package/dist/{chunk-OO4DROKM.js.map → chunk-OASVAPRL.js.map} +0 -0
  116. /package/dist/{chunk-ZSGTG6PK.js.map → chunk-P5PIAQVS.js.map} +0 -0
  117. /package/dist/{chunk-O22STZ3P.js.map → chunk-X5DQ5QOP.js.map} +0 -0
  118. /package/dist/{chunk-PCJHEZA7.js.map → chunk-YABHE2QY.js.map} +0 -0
@@ -5,7 +5,7 @@ import {
5
5
  UNTITLED_SESSION_LABEL,
6
6
  mergeSessionPages,
7
7
  sessionLabel
8
- } from "./chunk-GINKOZFD.js";
8
+ } from "./chunk-PC2WYTK7.js";
9
9
  import {
10
10
  WorkProductCard,
11
11
  workProductPartsFromMessageParts
@@ -36,7 +36,7 @@ import {
36
36
  } from "./chunk-TH7L265V.js";
37
37
 
38
38
  // src/web-react/index.tsx
39
- import { useEffect as useEffect10, useMemo as useMemo8, useRef as useRef9, useState as useState14, memo } from "react";
39
+ import { useEffect as useEffect12, useMemo as useMemo9, useRef as useRef11, useState as useState16, memo } from "react";
40
40
 
41
41
  // src/web-react/smooth-text.ts
42
42
  import { useEffect, useRef, useState } from "react";
@@ -2700,8 +2700,483 @@ function AgentActivityPanel({ fetchActivity, renderMissionRef, title = "Agent ac
2700
2700
  ] });
2701
2701
  }
2702
2702
 
2703
+ // src/web-react/provenance.tsx
2704
+ import { useCallback as useCallback7, useEffect as useEffect9, useId, useRef as useRef8, useState as useState12 } from "react";
2705
+
2706
+ // src/web-react/provenance-model.ts
2707
+ var PROVENANCE_BASES = ["extracted", "entered", "computed", "asserted"];
2708
+ var BASIS_META = {
2709
+ extracted: {
2710
+ label: "From document",
2711
+ meaning: "Read out of a source document.",
2712
+ checkableAgainst: "the document it was read from"
2713
+ },
2714
+ entered: {
2715
+ label: "Entered by a person",
2716
+ meaning: "A person typed or confirmed this value.",
2717
+ checkableAgainst: "the person who entered it"
2718
+ },
2719
+ computed: {
2720
+ label: "Computed",
2721
+ meaning: "Produced from other values.",
2722
+ checkableAgainst: "the values it was computed from"
2723
+ },
2724
+ asserted: {
2725
+ label: "Agent, unverified",
2726
+ meaning: "The agent stated this. No source was recorded behind it.",
2727
+ checkableAgainst: null
2728
+ }
2729
+ };
2730
+ function provenanceBasisMeta(basis) {
2731
+ return BASIS_META[basis];
2732
+ }
2733
+ var STANDING_META = {
2734
+ settled: { label: "Traced", action: "Nothing to check \u2014 this value can be traced to where it came from." },
2735
+ check: { label: "Check the source", action: "Open the source and confirm this value before you rely on it." },
2736
+ confirm: { label: "Needs a person", action: "Someone has to confirm this value before it is used." }
2737
+ };
2738
+ function provenanceStandingMeta(standing) {
2739
+ return STANDING_META[standing];
2740
+ }
2741
+ var STANDING_SEVERITY = { settled: 0, check: 1, confirm: 2 };
2742
+ function weakerProvenanceStanding(a, b) {
2743
+ return STANDING_SEVERITY[a] >= STANDING_SEVERITY[b] ? a : b;
2744
+ }
2745
+ var DEFAULT_PROVENANCE_CONFIDENCE_POLICY = {
2746
+ settledAtOrAbove: 0.9,
2747
+ checkAtOrAbove: 0.6
2748
+ };
2749
+ function standingFromConfidence(confidence, policy = DEFAULT_PROVENANCE_CONFIDENCE_POLICY) {
2750
+ if (confidence >= policy.settledAtOrAbove) return "settled";
2751
+ if (confidence >= policy.checkAtOrAbove) return "check";
2752
+ return "confirm";
2753
+ }
2754
+ function standingFromBasis(basis) {
2755
+ return basis === "asserted" ? "check" : "settled";
2756
+ }
2757
+ function describeProvenanceSourceStatus(source) {
2758
+ if (source.status === "loading") return `Looking up ${source.label}\u2026`;
2759
+ if (source.status === "unavailable") {
2760
+ return source.unavailableReason ? `${source.label} could not be opened \u2014 ${source.unavailableReason}` : `${source.label} could not be opened.`;
2761
+ }
2762
+ return null;
2763
+ }
2764
+ function provenanceGaps(record) {
2765
+ const gaps = [];
2766
+ const sources = record.sources ?? [];
2767
+ if (record.basis === "extracted" && sources.length === 0) {
2768
+ gaps.push({
2769
+ kind: "no-source",
2770
+ message: "Read from a document, but no document is on file \u2014 nothing here shows where this came from."
2771
+ });
2772
+ }
2773
+ if (record.basis === "computed" && (record.inputs ?? []).length === 0) {
2774
+ gaps.push({
2775
+ kind: "no-inputs",
2776
+ message: "Computed, but the values it was computed from are not recorded."
2777
+ });
2778
+ }
2779
+ for (const source of sources) {
2780
+ if (source.status !== "unavailable") continue;
2781
+ gaps.push({
2782
+ kind: "unavailable-source",
2783
+ message: describeProvenanceSourceStatus(source) ?? `${source.label} could not be opened.`,
2784
+ source
2785
+ });
2786
+ }
2787
+ return gaps;
2788
+ }
2789
+ function loadingProvenanceSources(record) {
2790
+ return (record.sources ?? []).filter((source) => source.status === "loading");
2791
+ }
2792
+ function resolveProvenanceStanding(record, policy = DEFAULT_PROVENANCE_CONFIDENCE_POLICY) {
2793
+ let standing = record.standing ?? (record.confidence === void 0 ? standingFromBasis(record.basis) : standingFromConfidence(record.confidence, policy));
2794
+ if (record.basis === "asserted") standing = weakerProvenanceStanding(standing, "check");
2795
+ for (const gap of provenanceGaps(record)) {
2796
+ standing = weakerProvenanceStanding(standing, gap.kind === "unavailable-source" ? "check" : "confirm");
2797
+ }
2798
+ return standing;
2799
+ }
2800
+ function rollUpProvenanceStanding(record, policy = DEFAULT_PROVENANCE_CONFIDENCE_POLICY, seen = /* @__PURE__ */ new Set()) {
2801
+ if (seen.has(record)) return "settled";
2802
+ seen.add(record);
2803
+ let standing = resolveProvenanceStanding(record, policy);
2804
+ for (const input of record.inputs ?? []) {
2805
+ standing = weakerProvenanceStanding(standing, rollUpProvenanceStanding(input, policy, seen));
2806
+ }
2807
+ return standing;
2808
+ }
2809
+ function sourcePhrase(source) {
2810
+ return source.locator ? `${source.label}, ${source.locator}` : source.label;
2811
+ }
2812
+ function inputPhrase(input) {
2813
+ return input.label ?? input.display;
2814
+ }
2815
+ function describeProvenance(record) {
2816
+ const sources = record.sources ?? [];
2817
+ const first = sources[0];
2818
+ const more = sources.length > 1 ? ` and ${sources.length - 1} more source${sources.length > 2 ? "s" : ""}` : "";
2819
+ switch (record.basis) {
2820
+ case "extracted":
2821
+ return first ? `Read from ${sourcePhrase(first)}${more}.` : "Read from a document, but no document is on file.";
2822
+ case "entered":
2823
+ return first ? `Entered by ${sourcePhrase(first)}.` : "Entered by a person.";
2824
+ case "computed": {
2825
+ const inputs = record.inputs ?? [];
2826
+ if (record.derivation) return `Computed from ${record.derivation}.`;
2827
+ if (inputs.length === 0) return "Computed, but the values it was computed from are not recorded.";
2828
+ return `Computed from ${inputs.map(inputPhrase).join(", ")}.`;
2829
+ }
2830
+ case "asserted":
2831
+ return first ? `Stated by the agent, pointing at ${sourcePhrase(first)} \u2014 not verified against it.` : "Stated by the agent, with no source to check it against.";
2832
+ }
2833
+ }
2834
+ function provenanceNextMove(record, standing, policy = DEFAULT_PROVENANCE_CONFIDENCE_POLICY) {
2835
+ const generic = provenanceStandingMeta(standing).action;
2836
+ if (standing === "settled") return generic;
2837
+ const gaps = provenanceGaps(record);
2838
+ if (gaps.some((gap) => gap.kind === "no-source")) {
2839
+ return "Nobody recorded where this came from. Confirm the value and record its source before it is used.";
2840
+ }
2841
+ if (gaps.some((gap) => gap.kind === "no-inputs")) {
2842
+ return "Nobody recorded what this was computed from. Confirm the value and record its inputs before it is used.";
2843
+ }
2844
+ if (gaps.some((gap) => gap.kind === "unavailable-source")) {
2845
+ return "The source could not be opened. Try again, or confirm this value another way before you rely on it.";
2846
+ }
2847
+ if (record.basis === "asserted" && (record.sources ?? []).length === 0) {
2848
+ return "The agent gave no source. Check this against the real document before you rely on it.";
2849
+ }
2850
+ if (record.basis === "computed" && (record.inputs ?? []).length > 0 && resolveProvenanceStanding(record, policy) === "settled") {
2851
+ return "One of the values this was computed from still needs checking \u2014 open the marked ones below.";
2852
+ }
2853
+ return generic;
2854
+ }
2855
+ function provenanceTriggerLabel(record, standing) {
2856
+ const value = record.display.trim() === "" ? "this missing value" : `\u201C${record.display}\u201D`;
2857
+ const named = record.label ? `${record.label} ${value}` : value;
2858
+ const basis = provenanceBasisMeta(record.basis).label;
2859
+ const next = standing === "settled" ? "" : ` ${provenanceStandingMeta(standing).label}.`;
2860
+ return `Where ${named} came from \u2014 ${basis}.${next}`;
2861
+ }
2862
+
2863
+ // src/web-react/provenance.tsx
2864
+ import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
2865
+ var BASIS_TONES = {
2866
+ extracted: "border-primary/30 bg-primary/10 text-primary",
2867
+ entered: "border-success/30 bg-success/10 text-success",
2868
+ computed: "border-border bg-muted/50 text-foreground",
2869
+ asserted: "border-warning/40 bg-warning/10 text-warning"
2870
+ };
2871
+ var STANDING_TONES = {
2872
+ settled: "text-muted-foreground",
2873
+ check: "text-warning",
2874
+ confirm: "text-destructive"
2875
+ };
2876
+ function BasisGlyph({ basis, className }) {
2877
+ const shared = {
2878
+ viewBox: "0 0 24 24",
2879
+ fill: "none",
2880
+ stroke: "currentColor",
2881
+ strokeWidth: 2,
2882
+ strokeLinecap: "round",
2883
+ strokeLinejoin: "round",
2884
+ "aria-hidden": true,
2885
+ className
2886
+ };
2887
+ switch (basis) {
2888
+ case "extracted":
2889
+ return /* @__PURE__ */ jsxs9("svg", { ...shared, children: [
2890
+ /* @__PURE__ */ jsx11("path", { d: "M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z" }),
2891
+ /* @__PURE__ */ jsx11("polyline", { points: "14 3 14 8 19 8" }),
2892
+ /* @__PURE__ */ jsx11("line", { x1: "9", y1: "13", x2: "15", y2: "13" })
2893
+ ] });
2894
+ case "entered":
2895
+ return /* @__PURE__ */ jsxs9("svg", { ...shared, children: [
2896
+ /* @__PURE__ */ jsx11("path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" }),
2897
+ /* @__PURE__ */ jsx11("circle", { cx: "12", cy: "7", r: "4" })
2898
+ ] });
2899
+ case "computed":
2900
+ return /* @__PURE__ */ jsxs9("svg", { ...shared, children: [
2901
+ /* @__PURE__ */ jsx11("line", { x1: "4", y1: "9", x2: "20", y2: "9" }),
2902
+ /* @__PURE__ */ jsx11("line", { x1: "4", y1: "15", x2: "20", y2: "15" }),
2903
+ /* @__PURE__ */ jsx11("line", { x1: "10", y1: "3", x2: "8", y2: "21" }),
2904
+ /* @__PURE__ */ jsx11("line", { x1: "16", y1: "3", x2: "14", y2: "21" })
2905
+ ] });
2906
+ case "asserted":
2907
+ return /* @__PURE__ */ jsxs9("svg", { ...shared, children: [
2908
+ /* @__PURE__ */ jsx11("path", { d: "M12 3v3M12 18v3M3 12h3M18 12h3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M18.4 5.6l-2.1 2.1M7.7 16.3l-2.1 2.1" }),
2909
+ /* @__PURE__ */ jsx11("circle", { cx: "12", cy: "12", r: "3.2" })
2910
+ ] });
2911
+ }
2912
+ }
2913
+ var openPanels = /* @__PURE__ */ new Set();
2914
+ function closeTrailsOutside(root) {
2915
+ for (const other of Array.from(openPanels)) {
2916
+ if (root === null || !other.root.contains(root)) other.close();
2917
+ }
2918
+ }
2919
+ var DEFAULT_MISSING_VALUE_LABEL = "No value recorded";
2920
+ function SourceRow({
2921
+ source,
2922
+ record,
2923
+ onOpenSource,
2924
+ onRetrySource
2925
+ }) {
2926
+ const status = source.status ?? "ready";
2927
+ const statusLine = describeProvenanceSourceStatus(source);
2928
+ const openable = status === "ready" && (onOpenSource !== void 0 || source.href !== void 0);
2929
+ return /* @__PURE__ */ jsxs9("li", { className: "rounded-md border border-border/60 bg-background/40 px-2.5 py-2", children: [
2930
+ /* @__PURE__ */ jsxs9("div", { className: "flex flex-wrap items-baseline gap-x-2 gap-y-1", children: [
2931
+ /* @__PURE__ */ jsx11("span", { className: "text-[13px] font-medium text-foreground", children: source.label }),
2932
+ source.locator && /* @__PURE__ */ jsx11("span", { className: "text-[11px] text-muted-foreground", children: source.locator }),
2933
+ openable && (onOpenSource ? /* @__PURE__ */ jsxs9(
2934
+ "button",
2935
+ {
2936
+ type: "button",
2937
+ onClick: () => onOpenSource(source, record),
2938
+ className: "rounded px-1 text-[11px] font-medium text-primary underline-offset-2 hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
2939
+ children: [
2940
+ "Open ",
2941
+ source.label
2942
+ ]
2943
+ }
2944
+ ) : /* @__PURE__ */ jsxs9(
2945
+ "a",
2946
+ {
2947
+ href: source.href,
2948
+ target: "_blank",
2949
+ rel: "noreferrer",
2950
+ className: "rounded px-1 text-[11px] font-medium text-primary underline-offset-2 hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
2951
+ children: [
2952
+ "Open ",
2953
+ source.label
2954
+ ]
2955
+ }
2956
+ ))
2957
+ ] }),
2958
+ source.quote && /* @__PURE__ */ jsxs9("blockquote", { className: "mt-1 border-l-2 border-primary/50 pl-2 text-[12px] italic leading-snug text-foreground", children: [
2959
+ "\u201C",
2960
+ source.quote,
2961
+ "\u201D"
2962
+ ] }),
2963
+ statusLine && // `role="status"` and not `alert`: the reader opened this panel, so the
2964
+ // update is theirs to read, not an interruption. Either way it is TEXT
2965
+ // — a spinner alone and a greyed row alone both render as "nothing
2966
+ // here".
2967
+ /* @__PURE__ */ jsxs9(
2968
+ "p",
2969
+ {
2970
+ role: "status",
2971
+ className: `mt-1 text-[11px] ${status === "unavailable" ? "text-destructive" : "text-muted-foreground"}`,
2972
+ children: [
2973
+ statusLine,
2974
+ status === "unavailable" && onRetrySource && /* @__PURE__ */ jsx11(
2975
+ "button",
2976
+ {
2977
+ type: "button",
2978
+ onClick: () => onRetrySource(source, record),
2979
+ className: "ml-2 rounded border border-border px-1.5 py-0.5 text-[11px] font-medium text-foreground hover:bg-accent/30 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
2980
+ children: "Try again"
2981
+ }
2982
+ )
2983
+ ]
2984
+ }
2985
+ )
2986
+ ] });
2987
+ }
2988
+ function ProvenanceValue({
2989
+ record,
2990
+ onOpenSource,
2991
+ onRetrySource,
2992
+ confidencePolicy,
2993
+ maxDepth = 2,
2994
+ defaultOpen = false,
2995
+ missingValueLabel = DEFAULT_MISSING_VALUE_LABEL,
2996
+ className
2997
+ }) {
2998
+ const [open, setOpen] = useState12(defaultOpen);
2999
+ const triggerRef = useRef8(null);
3000
+ const rootRef = useRef8(null);
3001
+ const panelId = useId();
3002
+ const standing = rollUpProvenanceStanding(record, confidencePolicy);
3003
+ const basisMeta = provenanceBasisMeta(record.basis);
3004
+ const standingMeta = provenanceStandingMeta(standing);
3005
+ const gaps = provenanceGaps(record);
3006
+ const loading = loadingProvenanceSources(record);
3007
+ const sources = record.sources ?? [];
3008
+ const inputs = record.inputs ?? [];
3009
+ const hasValue = record.display.trim() !== "";
3010
+ const onKeyDown = useCallback7(
3011
+ (event) => {
3012
+ if (event.key !== "Escape" || !open) return;
3013
+ event.stopPropagation();
3014
+ setOpen(false);
3015
+ triggerRef.current?.focus();
3016
+ },
3017
+ [open]
3018
+ );
3019
+ const onToggle = useCallback7(() => {
3020
+ if (!open) closeTrailsOutside(rootRef.current);
3021
+ setOpen(!open);
3022
+ }, [open]);
3023
+ useEffect9(() => {
3024
+ const root = rootRef.current;
3025
+ if (!open || root === null) return;
3026
+ const entry = { root, close: () => setOpen(false) };
3027
+ openPanels.add(entry);
3028
+ const onPointerDown = (event) => {
3029
+ const target = event.target;
3030
+ if (target instanceof Node && root.contains(target)) return;
3031
+ setOpen(false);
3032
+ };
3033
+ document.addEventListener("mousedown", onPointerDown, true);
3034
+ document.addEventListener("touchstart", onPointerDown, true);
3035
+ return () => {
3036
+ openPanels.delete(entry);
3037
+ document.removeEventListener("mousedown", onPointerDown, true);
3038
+ document.removeEventListener("touchstart", onPointerDown, true);
3039
+ };
3040
+ }, [open]);
3041
+ const summary = /* @__PURE__ */ jsxs9("span", { className: "inline-flex flex-wrap items-baseline gap-x-1.5", children: [
3042
+ record.label && /* @__PURE__ */ jsx11("span", { className: "text-[11px] text-muted-foreground", children: record.label }),
3043
+ /* @__PURE__ */ jsx11("span", { className: hasValue ? "text-sm text-foreground" : "text-sm italic text-muted-foreground", children: hasValue ? record.display : missingValueLabel })
3044
+ ] });
3045
+ if (maxDepth <= 0) {
3046
+ return /* @__PURE__ */ jsxs9(
3047
+ "div",
3048
+ {
3049
+ className: `inline-block max-w-full ${className ?? ""}`,
3050
+ "data-provenance-basis": record.basis,
3051
+ "data-provenance-standing": standing,
3052
+ children: [
3053
+ summary,
3054
+ /* @__PURE__ */ jsxs9(
3055
+ "span",
3056
+ {
3057
+ className: `ml-1.5 inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${BASIS_TONES[record.basis]}`,
3058
+ children: [
3059
+ /* @__PURE__ */ jsx11(BasisGlyph, { basis: record.basis, className: "h-3 w-3" }),
3060
+ basisMeta.label
3061
+ ]
3062
+ }
3063
+ ),
3064
+ /* @__PURE__ */ jsx11("span", { className: "mt-0.5 block text-[11px] text-muted-foreground", children: describeProvenance(record) })
3065
+ ]
3066
+ }
3067
+ );
3068
+ }
3069
+ return /* @__PURE__ */ jsxs9(
3070
+ "div",
3071
+ {
3072
+ ref: rootRef,
3073
+ className: `inline-block max-w-full ${className ?? ""}`,
3074
+ onKeyDown,
3075
+ "data-provenance-basis": record.basis,
3076
+ "data-provenance-standing": standing,
3077
+ children: [
3078
+ /* @__PURE__ */ jsxs9("span", { className: "inline-flex flex-wrap items-baseline gap-1.5", children: [
3079
+ summary,
3080
+ /* @__PURE__ */ jsxs9(
3081
+ "button",
3082
+ {
3083
+ ref: triggerRef,
3084
+ type: "button",
3085
+ onClick: onToggle,
3086
+ "aria-expanded": open,
3087
+ "aria-controls": panelId,
3088
+ "aria-label": provenanceTriggerLabel(record, standing),
3089
+ className: `inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition hover:brightness-105 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring ${BASIS_TONES[record.basis]}`,
3090
+ children: [
3091
+ /* @__PURE__ */ jsx11(BasisGlyph, { basis: record.basis, className: "h-3 w-3" }),
3092
+ /* @__PURE__ */ jsx11("span", { "aria-hidden": true, children: basisMeta.label })
3093
+ ]
3094
+ }
3095
+ ),
3096
+ standing !== "settled" && // Legible at rest: what to do about the value does not wait for
3097
+ // someone to open the panel. `aria-hidden` because the trigger's
3098
+ // accessible name already carries it — this is the visual half.
3099
+ /* @__PURE__ */ jsx11("span", { "aria-hidden": true, className: `text-[10px] font-medium ${STANDING_TONES[standing]}`, children: standingMeta.label })
3100
+ ] }),
3101
+ open && /* @__PURE__ */ jsxs9(
3102
+ "div",
3103
+ {
3104
+ id: panelId,
3105
+ role: "group",
3106
+ "aria-label": provenanceTriggerLabel(record, standing),
3107
+ className: "mt-1.5 w-full min-w-0 space-y-2 rounded-lg border border-border bg-card px-3 py-2.5 text-left",
3108
+ children: [
3109
+ /* @__PURE__ */ jsxs9("div", { children: [
3110
+ /* @__PURE__ */ jsx11("p", { className: "text-[12px] leading-snug text-foreground", children: describeProvenance(record) }),
3111
+ /* @__PURE__ */ jsxs9("p", { className: `mt-0.5 text-[11px] leading-snug ${STANDING_TONES[standing]}`, children: [
3112
+ standingMeta.label,
3113
+ " \u2014 ",
3114
+ provenanceNextMove(record, standing, confidencePolicy)
3115
+ ] }),
3116
+ basisMeta.checkableAgainst === null && /* @__PURE__ */ jsxs9("p", { className: "mt-0.5 text-[11px] leading-snug text-muted-foreground", children: [
3117
+ basisMeta.meaning,
3118
+ " There is nothing outside the model to check it against."
3119
+ ] })
3120
+ ] }),
3121
+ sources.length > 0 && /* @__PURE__ */ jsx11("ul", { className: "space-y-1.5", children: sources.map((source, index) => /* @__PURE__ */ jsx11(
3122
+ SourceRow,
3123
+ {
3124
+ source,
3125
+ record,
3126
+ onOpenSource,
3127
+ onRetrySource
3128
+ },
3129
+ `${source.label}-${source.locator ?? ""}-${index}`
3130
+ )) }),
3131
+ gaps.filter((gap) => gap.kind !== "unavailable-source").map((gap) => (
3132
+ // An unavailable source already states itself on its own row; a
3133
+ // structural gap has no row to state it, so it gets one here.
3134
+ /* @__PURE__ */ jsx11("p", { className: "rounded-md bg-destructive/10 px-2 py-1.5 text-[11px] leading-snug text-destructive", children: gap.message }, gap.kind)
3135
+ )),
3136
+ loading.length > 0 && sources.length === 0 && /* @__PURE__ */ jsx11("p", { role: "status", className: "text-[11px] text-muted-foreground", children: "Looking up where this came from\u2026" }),
3137
+ inputs.length > 0 && /* @__PURE__ */ jsxs9("div", { className: "border-t border-border/60 pt-2", children: [
3138
+ /* @__PURE__ */ jsx11("p", { className: "text-[10px] font-medium uppercase tracking-wide text-muted-foreground", children: record.derivation ? `Computed from ${record.derivation}` : "Computed from" }),
3139
+ /* @__PURE__ */ jsx11("ul", { className: "mt-1.5 space-y-1.5", children: inputs.map((input, index) => /* @__PURE__ */ jsx11("li", { children: /* @__PURE__ */ jsx11(
3140
+ ProvenanceValue,
3141
+ {
3142
+ record: input,
3143
+ onOpenSource,
3144
+ onRetrySource,
3145
+ confidencePolicy,
3146
+ maxDepth: maxDepth - 1,
3147
+ missingValueLabel
3148
+ }
3149
+ ) }, `${input.label ?? input.display}-${index}`)) })
3150
+ ] })
3151
+ ]
3152
+ }
3153
+ )
3154
+ ]
3155
+ }
3156
+ );
3157
+ }
3158
+ function ProvenanceLegend({ bases, className }) {
3159
+ if (bases.length === 0) return null;
3160
+ return /* @__PURE__ */ jsx11("ul", { className: `flex flex-wrap items-center gap-x-3 gap-y-1.5 ${className ?? ""}`, children: bases.map((basis) => {
3161
+ const meta = provenanceBasisMeta(basis);
3162
+ return /* @__PURE__ */ jsxs9("li", { className: "flex items-center gap-1.5 text-[11px] text-muted-foreground", children: [
3163
+ /* @__PURE__ */ jsxs9(
3164
+ "span",
3165
+ {
3166
+ className: `inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${BASIS_TONES[basis]}`,
3167
+ children: [
3168
+ /* @__PURE__ */ jsx11(BasisGlyph, { basis, className: "h-3 w-3" }),
3169
+ meta.label
3170
+ ]
3171
+ }
3172
+ ),
3173
+ /* @__PURE__ */ jsx11("span", { children: meta.meaning })
3174
+ ] }, basis);
3175
+ }) });
3176
+ }
3177
+
2703
3178
  // src/web-react/seat-paywall.tsx
2704
- import { Fragment as Fragment5, jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
3179
+ import { Fragment as Fragment5, jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
2705
3180
  function usd(cents) {
2706
3181
  return new Intl.NumberFormat("en-US", {
2707
3182
  style: "currency",
@@ -2711,7 +3186,7 @@ function usd(cents) {
2711
3186
  }).format(cents / 100);
2712
3187
  }
2713
3188
  function CheckGlyph3() {
2714
- return /* @__PURE__ */ jsx11(
3189
+ return /* @__PURE__ */ jsx12(
2715
3190
  "svg",
2716
3191
  {
2717
3192
  className: "h-4 w-4 shrink-0 text-primary",
@@ -2722,14 +3197,14 @@ function CheckGlyph3() {
2722
3197
  strokeLinecap: "round",
2723
3198
  strokeLinejoin: "round",
2724
3199
  "aria-hidden": true,
2725
- children: /* @__PURE__ */ jsx11("path", { d: "M20 6 9 17l-5-5" })
3200
+ children: /* @__PURE__ */ jsx12("path", { d: "M20 6 9 17l-5-5" })
2726
3201
  }
2727
3202
  );
2728
3203
  }
2729
3204
  function Benefit({ children }) {
2730
- return /* @__PURE__ */ jsxs9("li", { className: "flex items-start gap-2.5 text-sm text-foreground", children: [
2731
- /* @__PURE__ */ jsx11("span", { className: "mt-0.5", children: /* @__PURE__ */ jsx11(CheckGlyph3, {}) }),
2732
- /* @__PURE__ */ jsx11("span", { children })
3205
+ return /* @__PURE__ */ jsxs10("li", { className: "flex items-start gap-2.5 text-sm text-foreground", children: [
3206
+ /* @__PURE__ */ jsx12("span", { className: "mt-0.5", children: /* @__PURE__ */ jsx12(CheckGlyph3, {}) }),
3207
+ /* @__PURE__ */ jsx12("span", { children })
2733
3208
  ] });
2734
3209
  }
2735
3210
  function SeatPaywall({
@@ -2747,46 +3222,46 @@ function SeatPaywall({
2747
3222
  const recurringPrice = offer ? usd(offer.recurring.priceCents) : `$${priceUsd}`;
2748
3223
  const recurringUsage = offer ? usd(offer.recurring.includedCreditsCents) : `$${includedUsageUsd}`;
2749
3224
  const introductory = offer?.introductory ?? null;
2750
- return /* @__PURE__ */ jsx11("div", { className: "flex min-h-[60vh] w-full items-center justify-center p-6", children: /* @__PURE__ */ jsxs9("div", { className: "w-full max-w-md rounded-2xl border border-border bg-card p-8 shadow-sm", children: [
2751
- /* @__PURE__ */ jsx11("p", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: product }),
2752
- /* @__PURE__ */ jsxs9("h1", { className: "mt-2 text-2xl font-semibold tracking-tight text-foreground", children: [
3225
+ return /* @__PURE__ */ jsx12("div", { className: "flex min-h-[60vh] w-full items-center justify-center p-6", children: /* @__PURE__ */ jsxs10("div", { className: "w-full max-w-md rounded-2xl border border-border bg-card p-8 shadow-sm", children: [
3226
+ /* @__PURE__ */ jsx12("p", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: product }),
3227
+ /* @__PURE__ */ jsxs10("h1", { className: "mt-2 text-2xl font-semibold tracking-tight text-foreground", children: [
2753
3228
  "Unlock ",
2754
3229
  product
2755
3230
  ] }),
2756
- tagline && /* @__PURE__ */ jsx11("p", { className: "mt-2 text-sm text-muted-foreground", children: tagline }),
2757
- introductory ? /* @__PURE__ */ jsxs9(Fragment5, { children: [
2758
- /* @__PURE__ */ jsxs9("div", { className: "mt-6 flex items-baseline gap-1.5", children: [
2759
- /* @__PURE__ */ jsx11("span", { className: "text-3xl font-semibold text-foreground", children: usd(introductory.priceCents) }),
2760
- /* @__PURE__ */ jsx11("span", { className: "text-sm text-muted-foreground", children: "first month" })
3231
+ tagline && /* @__PURE__ */ jsx12("p", { className: "mt-2 text-sm text-muted-foreground", children: tagline }),
3232
+ introductory ? /* @__PURE__ */ jsxs10(Fragment5, { children: [
3233
+ /* @__PURE__ */ jsxs10("div", { className: "mt-6 flex items-baseline gap-1.5", children: [
3234
+ /* @__PURE__ */ jsx12("span", { className: "text-3xl font-semibold text-foreground", children: usd(introductory.priceCents) }),
3235
+ /* @__PURE__ */ jsx12("span", { className: "text-sm text-muted-foreground", children: "first month" })
2761
3236
  ] }),
2762
- /* @__PURE__ */ jsxs9("p", { className: "mt-1 text-sm text-muted-foreground", children: [
3237
+ /* @__PURE__ */ jsxs10("p", { className: "mt-1 text-sm text-muted-foreground", children: [
2763
3238
  "Includes ",
2764
3239
  usd(introductory.includedCreditsCents),
2765
3240
  " of AI usage in your first month"
2766
3241
  ] }),
2767
- /* @__PURE__ */ jsxs9("p", { className: "mt-1 text-sm text-muted-foreground", children: [
3242
+ /* @__PURE__ */ jsxs10("p", { className: "mt-1 text-sm text-muted-foreground", children: [
2768
3243
  "Then ",
2769
3244
  recurringPrice,
2770
3245
  "/mo \xB7 includes ",
2771
3246
  recurringUsage,
2772
3247
  "/mo of AI usage"
2773
3248
  ] })
2774
- ] }) : /* @__PURE__ */ jsxs9(Fragment5, { children: [
2775
- /* @__PURE__ */ jsxs9("div", { className: "mt-6 flex items-baseline gap-1.5", children: [
2776
- /* @__PURE__ */ jsx11("span", { className: "text-3xl font-semibold text-foreground", children: recurringPrice }),
2777
- /* @__PURE__ */ jsx11("span", { className: "text-sm text-muted-foreground", children: "/mo" })
3249
+ ] }) : /* @__PURE__ */ jsxs10(Fragment5, { children: [
3250
+ /* @__PURE__ */ jsxs10("div", { className: "mt-6 flex items-baseline gap-1.5", children: [
3251
+ /* @__PURE__ */ jsx12("span", { className: "text-3xl font-semibold text-foreground", children: recurringPrice }),
3252
+ /* @__PURE__ */ jsx12("span", { className: "text-sm text-muted-foreground", children: "/mo" })
2778
3253
  ] }),
2779
- /* @__PURE__ */ jsxs9("p", { className: "mt-1 text-sm text-muted-foreground", children: [
3254
+ /* @__PURE__ */ jsxs10("p", { className: "mt-1 text-sm text-muted-foreground", children: [
2780
3255
  "Includes ",
2781
3256
  recurringUsage,
2782
3257
  "/mo of AI usage"
2783
3258
  ] })
2784
3259
  ] }),
2785
- /* @__PURE__ */ jsx11("ul", { className: "mt-6 space-y-2.5", children: (benefits ?? [
3260
+ /* @__PURE__ */ jsx12("ul", { className: "mt-6 space-y-2.5", children: (benefits ?? [
2786
3261
  `Full access to ${product}`,
2787
3262
  `${recurringUsage}/mo of AI usage included`
2788
- ]).map((benefit, i) => /* @__PURE__ */ jsx11(Benefit, { children: benefit }, i)) }),
2789
- /* @__PURE__ */ jsx11(
3263
+ ]).map((benefit, i) => /* @__PURE__ */ jsx12(Benefit, { children: benefit }, i)) }),
3264
+ /* @__PURE__ */ jsx12(
2790
3265
  "button",
2791
3266
  {
2792
3267
  type: "button",
@@ -2796,32 +3271,32 @@ function SeatPaywall({
2796
3271
  children: pending ? "Opening checkout\u2026" : ctaLabel ?? `Unlock ${product}`
2797
3272
  }
2798
3273
  ),
2799
- footnote && /* @__PURE__ */ jsx11("p", { className: "mt-3 text-center text-xs text-muted-foreground/70", children: footnote })
3274
+ footnote && /* @__PURE__ */ jsx12("p", { className: "mt-3 text-center text-xs text-muted-foreground/70", children: footnote })
2800
3275
  ] }) });
2801
3276
  }
2802
3277
 
2803
3278
  // src/web-react/session-history.tsx
2804
3279
  import {
2805
- useCallback as useCallback7,
2806
- useEffect as useEffect9,
3280
+ useCallback as useCallback8,
3281
+ useEffect as useEffect10,
2807
3282
  useMemo as useMemo6,
2808
- useRef as useRef8,
2809
- useState as useState12
3283
+ useRef as useRef9,
3284
+ useState as useState13
2810
3285
  } from "react";
2811
- import { Fragment as Fragment6, jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
3286
+ import { Fragment as Fragment6, jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
2812
3287
  function rethrowAsync(error) {
2813
3288
  queueMicrotask(() => {
2814
3289
  throw error;
2815
3290
  });
2816
3291
  }
2817
3292
  function useInfiniteScroll(onLoadMore, { enabled, root, rootMargin = "300px" }) {
2818
- const [sentinel, setSentinel] = useState12(null);
2819
- const sentinelRef = useCallback7((node) => setSentinel(node), []);
2820
- const onLoadMoreRef = useRef8(onLoadMore);
2821
- useEffect9(() => {
3293
+ const [sentinel, setSentinel] = useState13(null);
3294
+ const sentinelRef = useCallback8((node) => setSentinel(node), []);
3295
+ const onLoadMoreRef = useRef9(onLoadMore);
3296
+ useEffect10(() => {
2822
3297
  onLoadMoreRef.current = onLoadMore;
2823
3298
  }, [onLoadMore]);
2824
- useEffect9(() => {
3299
+ useEffect10(() => {
2825
3300
  if (!sentinel || !enabled) return;
2826
3301
  if (typeof IntersectionObserver === "undefined") return;
2827
3302
  const observer = new IntersectionObserver(
@@ -2850,24 +3325,24 @@ function useSessionHistory({
2850
3325
  initialPage,
2851
3326
  defaultSort = "newest"
2852
3327
  }) {
2853
- const [items, setItems] = useState12(initialPage.items);
2854
- const [nextCursor, setNextCursor] = useState12(initialPage.nextCursor ?? null);
2855
- const [phase, setPhase] = useState12("idle");
2856
- const [reloadKey, setReloadKey] = useState12(0);
2857
- const seqRef = useRef8(0);
2858
- const resetAbortRef = useRef8(null);
2859
- const loadMoreAbortRef = useRef8(null);
2860
- const loadingMoreRef = useRef8(false);
2861
- const lastOpRef = useRef8("first");
2862
- const nextCursorRef = useRef8(nextCursor);
3328
+ const [items, setItems] = useState13(initialPage.items);
3329
+ const [nextCursor, setNextCursor] = useState13(initialPage.nextCursor ?? null);
3330
+ const [phase, setPhase] = useState13("idle");
3331
+ const [reloadKey, setReloadKey] = useState13(0);
3332
+ const seqRef = useRef9(0);
3333
+ const resetAbortRef = useRef9(null);
3334
+ const loadMoreAbortRef = useRef9(null);
3335
+ const loadingMoreRef = useRef9(false);
3336
+ const lastOpRef = useRef9("first");
3337
+ const nextCursorRef = useRef9(nextCursor);
2863
3338
  nextCursorRef.current = nextCursor;
2864
- const viewRef = useRef8({ q, sort, fetchPage });
3339
+ const viewRef = useRef9({ q, sort, fetchPage });
2865
3340
  viewRef.current = { q, sort, fetchPage };
2866
- const seedRef = useRef8(initialPage);
3341
+ const seedRef = useRef9(initialPage);
2867
3342
  seedRef.current = initialPage;
2868
3343
  const isDefaultView = q === "" && sort === defaultSort;
2869
3344
  const seedKey = useMemo6(() => seedSignature(initialPage), [initialPage]);
2870
- useEffect9(() => {
3345
+ useEffect10(() => {
2871
3346
  resetAbortRef.current?.abort();
2872
3347
  loadMoreAbortRef.current?.abort();
2873
3348
  loadingMoreRef.current = false;
@@ -2898,7 +3373,7 @@ function useSessionHistory({
2898
3373
  })();
2899
3374
  return () => controller.abort();
2900
3375
  }, [q, sort, seedKey, isDefaultView, reloadKey]);
2901
- const loadMore = useCallback7(() => {
3376
+ const loadMore = useCallback8(() => {
2902
3377
  const cursor = nextCursorRef.current;
2903
3378
  if (!cursor || loadingMoreRef.current) return;
2904
3379
  const { q: currentQ, sort: currentSort, fetchPage: currentFetch } = viewRef.current;
@@ -2923,14 +3398,14 @@ function useSessionHistory({
2923
3398
  }
2924
3399
  })();
2925
3400
  }, []);
2926
- const retry = useCallback7(() => {
3401
+ const retry = useCallback8(() => {
2927
3402
  if (lastOpRef.current === "more") loadMore();
2928
3403
  else setReloadKey((key) => key + 1);
2929
3404
  }, [loadMore]);
2930
- const reload = useCallback7(() => {
3405
+ const reload = useCallback8(() => {
2931
3406
  setReloadKey((key) => key + 1);
2932
3407
  }, []);
2933
- useEffect9(
3408
+ useEffect10(
2934
3409
  () => () => {
2935
3410
  resetAbortRef.current?.abort();
2936
3411
  loadMoreAbortRef.current?.abort();
@@ -2971,21 +3446,21 @@ function useSessionActions({
2971
3446
  labels
2972
3447
  }) {
2973
3448
  const text = { ...DEFAULT_LABELS, ...labels };
2974
- const [renameTarget, setRenameTarget] = useState12(null);
2975
- const [renameValue, setRenameValue] = useState12("");
2976
- const [deleteTarget, setDeleteTarget] = useState12(null);
2977
- const [busy, setBusy] = useState12(false);
2978
- const [error, setError] = useState12(null);
2979
- const openRename = useCallback7((session) => {
3449
+ const [renameTarget, setRenameTarget] = useState13(null);
3450
+ const [renameValue, setRenameValue] = useState13("");
3451
+ const [deleteTarget, setDeleteTarget] = useState13(null);
3452
+ const [busy, setBusy] = useState13(false);
3453
+ const [error, setError] = useState13(null);
3454
+ const openRename = useCallback8((session) => {
2980
3455
  setError(null);
2981
3456
  setRenameTarget(session);
2982
3457
  setRenameValue(session.title ?? "");
2983
3458
  }, []);
2984
- const openDelete = useCallback7((session) => {
3459
+ const openDelete = useCallback8((session) => {
2985
3460
  setError(null);
2986
3461
  setDeleteTarget(session);
2987
3462
  }, []);
2988
- const submitRename = useCallback7(async () => {
3463
+ const submitRename = useCallback8(async () => {
2989
3464
  if (!renameTarget) return;
2990
3465
  const title = renameValue.trim();
2991
3466
  if (!title || title === renameTarget.title) {
@@ -3007,7 +3482,7 @@ function useSessionActions({
3007
3482
  setBusy(false);
3008
3483
  }
3009
3484
  }, [renameTarget, renameValue, renameSession, notify, onChanged, text.renamed, text.renameFailed]);
3010
- const confirmDelete = useCallback7(async () => {
3485
+ const confirmDelete = useCallback8(async () => {
3011
3486
  if (!deleteTarget) return;
3012
3487
  const deletingCurrent = currentSessionId != null && deleteTarget.id === currentSessionId;
3013
3488
  setBusy(true);
@@ -3026,21 +3501,21 @@ function useSessionActions({
3026
3501
  setBusy(false);
3027
3502
  }
3028
3503
  }, [deleteTarget, currentSessionId, deleteSession, notify, onChanged, onDeletedCurrent, text.deleted, text.deleteFailed]);
3029
- const dialogs = /* @__PURE__ */ jsxs10(Fragment6, { children: [
3030
- renameTarget && /* @__PURE__ */ jsxs10(
3504
+ const dialogs = /* @__PURE__ */ jsxs11(Fragment6, { children: [
3505
+ renameTarget && /* @__PURE__ */ jsxs11(
3031
3506
  SessionDialog,
3032
3507
  {
3033
3508
  title: text.renameTitle,
3034
3509
  onClose: () => setRenameTarget(null),
3035
3510
  busy,
3036
3511
  error,
3037
- footer: /* @__PURE__ */ jsxs10(Fragment6, { children: [
3038
- /* @__PURE__ */ jsx12(DialogButton, { onClick: () => setRenameTarget(null), disabled: busy, variant: "ghost", children: text.cancel }),
3039
- /* @__PURE__ */ jsx12(DialogButton, { onClick: () => void submitRename(), disabled: busy || !renameValue.trim(), children: text.renameSubmit })
3512
+ footer: /* @__PURE__ */ jsxs11(Fragment6, { children: [
3513
+ /* @__PURE__ */ jsx13(DialogButton, { onClick: () => setRenameTarget(null), disabled: busy, variant: "ghost", children: text.cancel }),
3514
+ /* @__PURE__ */ jsx13(DialogButton, { onClick: () => void submitRename(), disabled: busy || !renameValue.trim(), children: text.renameSubmit })
3040
3515
  ] }),
3041
3516
  children: [
3042
- /* @__PURE__ */ jsx12("label", { htmlFor: "agent-app-rename-session", className: "text-xs text-muted-foreground", children: text.renameField }),
3043
- /* @__PURE__ */ jsx12(
3517
+ /* @__PURE__ */ jsx13("label", { htmlFor: "agent-app-rename-session", className: "text-xs text-muted-foreground", children: text.renameField }),
3518
+ /* @__PURE__ */ jsx13(
3044
3519
  "input",
3045
3520
  {
3046
3521
  id: "agent-app-rename-session",
@@ -3059,18 +3534,18 @@ function useSessionActions({
3059
3534
  ]
3060
3535
  }
3061
3536
  ),
3062
- deleteTarget && /* @__PURE__ */ jsx12(
3537
+ deleteTarget && /* @__PURE__ */ jsx13(
3063
3538
  SessionDialog,
3064
3539
  {
3065
3540
  title: text.deleteTitle,
3066
3541
  onClose: () => setDeleteTarget(null),
3067
3542
  busy,
3068
3543
  error,
3069
- footer: /* @__PURE__ */ jsxs10(Fragment6, { children: [
3070
- /* @__PURE__ */ jsx12(DialogButton, { onClick: () => setDeleteTarget(null), disabled: busy, variant: "ghost", children: text.cancel }),
3071
- /* @__PURE__ */ jsx12(DialogButton, { onClick: () => void confirmDelete(), disabled: busy, variant: "destructive", children: text.deleteSubmit })
3544
+ footer: /* @__PURE__ */ jsxs11(Fragment6, { children: [
3545
+ /* @__PURE__ */ jsx13(DialogButton, { onClick: () => setDeleteTarget(null), disabled: busy, variant: "ghost", children: text.cancel }),
3546
+ /* @__PURE__ */ jsx13(DialogButton, { onClick: () => void confirmDelete(), disabled: busy, variant: "destructive", children: text.deleteSubmit })
3072
3547
  ] }),
3073
- children: /* @__PURE__ */ jsx12("p", { className: "text-sm text-muted-foreground", children: text.deleteBody(sessionLabel(deleteTarget)) })
3548
+ children: /* @__PURE__ */ jsx13("p", { className: "text-sm text-muted-foreground", children: text.deleteBody(sessionLabel(deleteTarget)) })
3074
3549
  }
3075
3550
  )
3076
3551
  ] });
@@ -3083,7 +3558,7 @@ function DialogButton({
3083
3558
  variant = "primary"
3084
3559
  }) {
3085
3560
  const tone = variant === "ghost" ? "text-muted-foreground hover:bg-accent/30 hover:text-foreground" : variant === "destructive" ? "bg-destructive text-destructive-foreground hover:opacity-90" : "bg-primary text-primary-foreground hover:opacity-90";
3086
- return /* @__PURE__ */ jsx12(
3561
+ return /* @__PURE__ */ jsx13(
3087
3562
  "button",
3088
3563
  {
3089
3564
  type: "button",
@@ -3102,15 +3577,15 @@ function SessionDialog({
3102
3577
  busy,
3103
3578
  error
3104
3579
  }) {
3105
- useEffect9(() => {
3580
+ useEffect10(() => {
3106
3581
  const onKey = (e) => {
3107
3582
  if (e.key === "Escape" && !busy) onClose();
3108
3583
  };
3109
3584
  document.addEventListener("keydown", onKey);
3110
3585
  return () => document.removeEventListener("keydown", onKey);
3111
3586
  }, [busy, onClose]);
3112
- return /* @__PURE__ */ jsxs10("div", { className: "fixed inset-0 z-50 flex items-center justify-center p-4", children: [
3113
- /* @__PURE__ */ jsx12(
3587
+ return /* @__PURE__ */ jsxs11("div", { className: "fixed inset-0 z-50 flex items-center justify-center p-4", children: [
3588
+ /* @__PURE__ */ jsx13(
3114
3589
  "div",
3115
3590
  {
3116
3591
  className: "absolute inset-0 bg-black/50",
@@ -3120,7 +3595,7 @@ function SessionDialog({
3120
3595
  "aria-hidden": true
3121
3596
  }
3122
3597
  ),
3123
- /* @__PURE__ */ jsxs10(
3598
+ /* @__PURE__ */ jsxs11(
3124
3599
  "div",
3125
3600
  {
3126
3601
  role: "dialog",
@@ -3128,17 +3603,17 @@ function SessionDialog({
3128
3603
  "aria-label": title,
3129
3604
  className: "relative w-full max-w-sm rounded-xl border border-border bg-card p-5 shadow-lg",
3130
3605
  children: [
3131
- /* @__PURE__ */ jsx12("h2", { className: "text-sm font-semibold text-foreground", children: title }),
3132
- /* @__PURE__ */ jsx12("div", { className: "mt-3", children }),
3133
- error && /* @__PURE__ */ jsx12("p", { role: "alert", className: "mt-3 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive", children: error }),
3134
- /* @__PURE__ */ jsx12("div", { className: "mt-5 flex justify-end gap-2", children: footer })
3606
+ /* @__PURE__ */ jsx13("h2", { className: "text-sm font-semibold text-foreground", children: title }),
3607
+ /* @__PURE__ */ jsx13("div", { className: "mt-3", children }),
3608
+ error && /* @__PURE__ */ jsx13("p", { role: "alert", className: "mt-3 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive", children: error }),
3609
+ /* @__PURE__ */ jsx13("div", { className: "mt-5 flex justify-end gap-2", children: footer })
3135
3610
  ]
3136
3611
  }
3137
3612
  )
3138
3613
  ] });
3139
3614
  }
3140
3615
  function AnchorLink({ to, className, children }) {
3141
- return /* @__PURE__ */ jsx12("a", { href: to, className, children });
3616
+ return /* @__PURE__ */ jsx13("a", { href: to, className, children });
3142
3617
  }
3143
3618
  var MINUTE = 6e4;
3144
3619
  var HOUR = 60 * MINUTE;
@@ -3155,14 +3630,14 @@ function formatSessionTimestamp(isoDate) {
3155
3630
  return new Date(at).toLocaleDateString(void 0, { month: "short", day: "numeric" });
3156
3631
  }
3157
3632
  function SkeletonRows() {
3158
- return /* @__PURE__ */ jsx12("div", { className: "flex flex-col gap-0.5", "aria-hidden": true, children: Array.from({ length: 8 }).map((_, i) => /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-3 px-3 py-2.5", children: [
3159
- /* @__PURE__ */ jsx12("div", { className: "h-4 w-4 animate-pulse rounded bg-muted" }),
3160
- /* @__PURE__ */ jsx12("div", { className: "h-4 w-1/2 animate-pulse rounded bg-muted" }),
3161
- /* @__PURE__ */ jsx12("div", { className: "ml-auto h-3 w-12 animate-pulse rounded bg-muted" })
3633
+ return /* @__PURE__ */ jsx13("div", { className: "flex flex-col gap-0.5", "aria-hidden": true, children: Array.from({ length: 8 }).map((_, i) => /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-3 px-3 py-2.5", children: [
3634
+ /* @__PURE__ */ jsx13("div", { className: "h-4 w-4 animate-pulse rounded bg-muted" }),
3635
+ /* @__PURE__ */ jsx13("div", { className: "h-4 w-1/2 animate-pulse rounded bg-muted" }),
3636
+ /* @__PURE__ */ jsx13("div", { className: "ml-auto h-3 w-12 animate-pulse rounded bg-muted" })
3162
3637
  ] }, i)) });
3163
3638
  }
3164
3639
  function MessageIcon({ className }) {
3165
- return /* @__PURE__ */ jsx12("svg", { viewBox: "0 0 24 24", className, fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx12("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) });
3640
+ return /* @__PURE__ */ jsx13("svg", { viewBox: "0 0 24 24", className, fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx13("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) });
3166
3641
  }
3167
3642
  function SessionHistoryPanel({
3168
3643
  history,
@@ -3189,7 +3664,7 @@ function SessionHistoryPanel({
3189
3664
  contentWidth = "reading",
3190
3665
  className
3191
3666
  }) {
3192
- const scrollRef = useRef8(null);
3667
+ const scrollRef = useRef9(null);
3193
3668
  const sentinelRef = useInfiniteScroll(history.loadMore, {
3194
3669
  enabled: history.hasMore && !history.isLoadingMore && !history.isError,
3195
3670
  root: scrollRef,
@@ -3198,15 +3673,15 @@ function SessionHistoryPanel({
3198
3673
  const searchTerm = query.trim();
3199
3674
  const isSearching = searchTerm.length > 0;
3200
3675
  const column = contentWidth === "full" ? "w-full" : "mx-auto w-full max-w-4xl";
3201
- const [selectedIds, setSelectedIds] = useState12(/* @__PURE__ */ new Set());
3202
- const [ageDays, setAgeDays] = useState12("30");
3203
- const [bulkTarget, setBulkTarget] = useState12(null);
3204
- const [bulkBusy, setBulkBusy] = useState12(false);
3205
- const [bulkError, setBulkError] = useState12(null);
3206
- useEffect9(() => {
3676
+ const [selectedIds, setSelectedIds] = useState13(/* @__PURE__ */ new Set());
3677
+ const [ageDays, setAgeDays] = useState13("30");
3678
+ const [bulkTarget, setBulkTarget] = useState13(null);
3679
+ const [bulkBusy, setBulkBusy] = useState13(false);
3680
+ const [bulkError, setBulkError] = useState13(null);
3681
+ useEffect10(() => {
3207
3682
  setSelectedIds(/* @__PURE__ */ new Set());
3208
3683
  }, [searchTerm, sort]);
3209
- useEffect9(() => {
3684
+ useEffect10(() => {
3210
3685
  const visible = new Set(history.items.map((item) => item.id));
3211
3686
  setSelectedIds((current) => {
3212
3687
  const next = new Set([...current].filter((id) => visible.has(id)));
@@ -3217,7 +3692,7 @@ function SessionHistoryPanel({
3217
3692
  const allVisibleSelected = history.items.length > 0 && history.items.every((item) => selectedIds.has(item.id));
3218
3693
  const parsedAgeDays = Number(ageDays);
3219
3694
  const validAgeDays = Number.isInteger(parsedAgeDays) && parsedAgeDays >= 1 && parsedAgeDays <= 36500;
3220
- const openBulkAction = useCallback7((action) => {
3695
+ const openBulkAction = useCallback8((action) => {
3221
3696
  const verb = deleteLabel.toLowerCase();
3222
3697
  if (action.kind === "selected") {
3223
3698
  setBulkTarget({
@@ -3234,7 +3709,7 @@ function SessionHistoryPanel({
3234
3709
  body: "This applies to every matching session in this workspace, including sessions not currently loaded in this list."
3235
3710
  });
3236
3711
  }, [deleteLabel]);
3237
- const confirmBulkAction = useCallback7(async () => {
3712
+ const confirmBulkAction = useCallback8(async () => {
3238
3713
  if (!bulkTarget || !onBulkAction) return;
3239
3714
  setBulkBusy(true);
3240
3715
  setBulkError(null);
@@ -3249,25 +3724,25 @@ function SessionHistoryPanel({
3249
3724
  setBulkBusy(false);
3250
3725
  }
3251
3726
  }, [bulkTarget, deleteLabel, history, onBulkAction]);
3252
- return /* @__PURE__ */ jsxs10("div", { className: `flex min-h-0 min-w-0 flex-1 flex-col ${className ?? ""}`, children: [
3253
- /* @__PURE__ */ jsx12("header", { className: "flex h-14 shrink-0 items-center border-b border-border px-4 sm:px-6", children: /* @__PURE__ */ jsxs10("div", { className: `flex items-center gap-3 px-3 ${column}`, children: [
3254
- /* @__PURE__ */ jsx12("h1", { className: "flex-1 truncate text-sm font-semibold text-foreground", children: title }),
3255
- newSessionHref && /* @__PURE__ */ jsxs10(
3727
+ return /* @__PURE__ */ jsxs11("div", { className: `flex min-h-0 min-w-0 flex-1 flex-col ${className ?? ""}`, children: [
3728
+ /* @__PURE__ */ jsx13("header", { className: "flex h-14 shrink-0 items-center border-b border-border px-4 sm:px-6", children: /* @__PURE__ */ jsxs11("div", { className: `flex items-center gap-3 px-3 ${column}`, children: [
3729
+ /* @__PURE__ */ jsx13("h1", { className: "flex-1 truncate text-sm font-semibold text-foreground", children: title }),
3730
+ newSessionHref && /* @__PURE__ */ jsxs11(
3256
3731
  Link,
3257
3732
  {
3258
3733
  to: newSessionHref,
3259
3734
  className: "inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground transition hover:opacity-90",
3260
3735
  children: [
3261
- /* @__PURE__ */ jsx12("span", { "aria-hidden": true, className: "text-sm leading-none", children: "+" }),
3736
+ /* @__PURE__ */ jsx13("span", { "aria-hidden": true, className: "text-sm leading-none", children: "+" }),
3262
3737
  "New chat"
3263
3738
  ]
3264
3739
  }
3265
3740
  )
3266
3741
  ] }) }),
3267
- /* @__PURE__ */ jsxs10("div", { ref: scrollRef, className: "min-h-0 flex-1 overflow-y-auto", children: [
3268
- hasAnySessions && /* @__PURE__ */ jsxs10("div", { className: "sticky top-0 z-10 bg-background px-4 sm:px-6", children: [
3269
- /* @__PURE__ */ jsxs10("div", { className: `flex flex-col gap-2 px-3 pb-3 pt-4 sm:flex-row sm:items-center sm:gap-3 ${column}`, children: [
3270
- /* @__PURE__ */ jsx12(
3742
+ /* @__PURE__ */ jsxs11("div", { ref: scrollRef, className: "min-h-0 flex-1 overflow-y-auto", children: [
3743
+ hasAnySessions && /* @__PURE__ */ jsxs11("div", { className: "sticky top-0 z-10 bg-background px-4 sm:px-6", children: [
3744
+ /* @__PURE__ */ jsxs11("div", { className: `flex flex-col gap-2 px-3 pb-3 pt-4 sm:flex-row sm:items-center sm:gap-3 ${column}`, children: [
3745
+ /* @__PURE__ */ jsx13(
3271
3746
  "input",
3272
3747
  {
3273
3748
  type: "search",
@@ -3278,7 +3753,7 @@ function SessionHistoryPanel({
3278
3753
  className: "h-9 min-w-0 appearance-none rounded-md border border-border bg-card px-3 text-sm text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring sm:flex-1 [&::-webkit-search-cancel-button]:appearance-none"
3279
3754
  }
3280
3755
  ),
3281
- /* @__PURE__ */ jsxs10(
3756
+ /* @__PURE__ */ jsxs11(
3282
3757
  "select",
3283
3758
  {
3284
3759
  value: sort,
@@ -3286,15 +3761,15 @@ function SessionHistoryPanel({
3286
3761
  "aria-label": "Sort sessions",
3287
3762
  className: "h-9 shrink-0 appearance-none rounded-md border border-border bg-card px-2 text-sm text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring sm:w-[132px]",
3288
3763
  children: [
3289
- /* @__PURE__ */ jsx12("option", { value: "newest", children: "Newest" }),
3290
- /* @__PURE__ */ jsx12("option", { value: "oldest", children: "Oldest" })
3764
+ /* @__PURE__ */ jsx13("option", { value: "newest", children: "Newest" }),
3765
+ /* @__PURE__ */ jsx13("option", { value: "oldest", children: "Oldest" })
3291
3766
  ]
3292
3767
  }
3293
3768
  )
3294
3769
  ] }),
3295
- onBulkAction && /* @__PURE__ */ jsxs10("div", { className: `flex flex-col gap-2 border-t border-border/60 px-3 py-3 ${column}`, children: [
3296
- /* @__PURE__ */ jsxs10("div", { className: "flex flex-wrap items-center gap-2", children: [
3297
- /* @__PURE__ */ jsx12(
3770
+ onBulkAction && /* @__PURE__ */ jsxs11("div", { className: `flex flex-col gap-2 border-t border-border/60 px-3 py-3 ${column}`, children: [
3771
+ /* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap items-center gap-2", children: [
3772
+ /* @__PURE__ */ jsx13(
3298
3773
  "button",
3299
3774
  {
3300
3775
  type: "button",
@@ -3304,7 +3779,7 @@ function SessionHistoryPanel({
3304
3779
  children: "Select all"
3305
3780
  }
3306
3781
  ),
3307
- /* @__PURE__ */ jsx12(
3782
+ /* @__PURE__ */ jsx13(
3308
3783
  "button",
3309
3784
  {
3310
3785
  type: "button",
@@ -3314,11 +3789,11 @@ function SessionHistoryPanel({
3314
3789
  children: "Deselect all"
3315
3790
  }
3316
3791
  ),
3317
- /* @__PURE__ */ jsxs10("span", { className: "text-xs text-muted-foreground", "aria-live": "polite", children: [
3792
+ /* @__PURE__ */ jsxs11("span", { className: "text-xs text-muted-foreground", "aria-live": "polite", children: [
3318
3793
  selectedCount,
3319
3794
  " selected"
3320
3795
  ] }),
3321
- selectedCount > 0 && /* @__PURE__ */ jsxs10(
3796
+ selectedCount > 0 && /* @__PURE__ */ jsxs11(
3322
3797
  "button",
3323
3798
  {
3324
3799
  type: "button",
@@ -3331,9 +3806,9 @@ function SessionHistoryPanel({
3331
3806
  }
3332
3807
  )
3333
3808
  ] }),
3334
- /* @__PURE__ */ jsxs10("div", { className: "flex flex-wrap items-center gap-2", children: [
3335
- /* @__PURE__ */ jsx12("label", { htmlFor: "agent-app-session-age", className: "text-xs text-muted-foreground", children: "Session age" }),
3336
- /* @__PURE__ */ jsx12(
3809
+ /* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap items-center gap-2", children: [
3810
+ /* @__PURE__ */ jsx13("label", { htmlFor: "agent-app-session-age", className: "text-xs text-muted-foreground", children: "Session age" }),
3811
+ /* @__PURE__ */ jsx13(
3337
3812
  "input",
3338
3813
  {
3339
3814
  id: "agent-app-session-age",
@@ -3346,8 +3821,8 @@ function SessionHistoryPanel({
3346
3821
  className: "h-8 w-20 rounded-md border border-border bg-card px-2 text-xs tabular-nums text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring"
3347
3822
  }
3348
3823
  ),
3349
- /* @__PURE__ */ jsx12("span", { className: "text-xs text-muted-foreground", children: "days" }),
3350
- /* @__PURE__ */ jsxs10(
3824
+ /* @__PURE__ */ jsx13("span", { className: "text-xs text-muted-foreground", children: "days" }),
3825
+ /* @__PURE__ */ jsxs11(
3351
3826
  "button",
3352
3827
  {
3353
3828
  type: "button",
@@ -3360,7 +3835,7 @@ function SessionHistoryPanel({
3360
3835
  ]
3361
3836
  }
3362
3837
  ),
3363
- /* @__PURE__ */ jsxs10(
3838
+ /* @__PURE__ */ jsxs11(
3364
3839
  "button",
3365
3840
  {
3366
3841
  type: "button",
@@ -3376,15 +3851,15 @@ function SessionHistoryPanel({
3376
3851
  ] })
3377
3852
  ] })
3378
3853
  ] }),
3379
- /* @__PURE__ */ jsx12("div", { className: `px-4 pb-8 pt-1 sm:px-6 ${column}`, children: !hasAnySessions ? /* @__PURE__ */ jsxs10("div", { className: "flex min-h-[50vh] flex-col items-center justify-center gap-2 text-center", children: [
3380
- /* @__PURE__ */ jsx12("p", { className: "text-sm font-medium text-foreground", children: emptyTitle }),
3381
- /* @__PURE__ */ jsx12("p", { className: "max-w-xs text-xs text-muted-foreground", children: emptyDescription })
3382
- ] }) : history.isLoadingFirst ? /* @__PURE__ */ jsx12(SkeletonRows, {}) : history.items.length === 0 ? history.isError ? /* @__PURE__ */ jsx12(ErrorBlock, { onRetry: history.retry, message: "Couldn\u2019t load your sessions." }) : isSearching ? /* @__PURE__ */ jsxs10("p", { className: "py-16 text-center text-sm text-muted-foreground", children: [
3854
+ /* @__PURE__ */ jsx13("div", { className: `px-4 pb-8 pt-1 sm:px-6 ${column}`, children: !hasAnySessions ? /* @__PURE__ */ jsxs11("div", { className: "flex min-h-[50vh] flex-col items-center justify-center gap-2 text-center", children: [
3855
+ /* @__PURE__ */ jsx13("p", { className: "text-sm font-medium text-foreground", children: emptyTitle }),
3856
+ /* @__PURE__ */ jsx13("p", { className: "max-w-xs text-xs text-muted-foreground", children: emptyDescription })
3857
+ ] }) : history.isLoadingFirst ? /* @__PURE__ */ jsx13(SkeletonRows, {}) : history.items.length === 0 ? history.isError ? /* @__PURE__ */ jsx13(ErrorBlock, { onRetry: history.retry, message: "Couldn\u2019t load your sessions." }) : isSearching ? /* @__PURE__ */ jsxs11("p", { className: "py-16 text-center text-sm text-muted-foreground", children: [
3383
3858
  "No sessions match \u201C",
3384
3859
  searchTerm,
3385
3860
  "\u201D."
3386
- ] }) : /* @__PURE__ */ jsx12("p", { className: "py-16 text-center text-sm text-muted-foreground", children: "No sessions remain." }) : /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-0.5", children: [
3387
- history.items.map((session) => /* @__PURE__ */ jsx12(
3861
+ ] }) : /* @__PURE__ */ jsx13("p", { className: "py-16 text-center text-sm text-muted-foreground", children: "No sessions remain." }) : /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-0.5", children: [
3862
+ history.items.map((session) => /* @__PURE__ */ jsx13(
3388
3863
  SessionRow,
3389
3864
  {
3390
3865
  session,
@@ -3411,10 +3886,10 @@ function SessionHistoryPanel({
3411
3886
  },
3412
3887
  session.id
3413
3888
  )),
3414
- history.isError ? /* @__PURE__ */ jsx12(ErrorBlock, { onRetry: history.retry, message: "Couldn\u2019t load more sessions.", inline: true }) : history.hasMore ? /* @__PURE__ */ jsx12("div", { ref: sentinelRef, className: "flex items-center justify-center py-6", children: history.isLoadingMore && /* @__PURE__ */ jsx12("span", { className: "text-xs text-muted-foreground", children: "Loading\u2026" }) }) : null
3889
+ history.isError ? /* @__PURE__ */ jsx13(ErrorBlock, { onRetry: history.retry, message: "Couldn\u2019t load more sessions.", inline: true }) : history.hasMore ? /* @__PURE__ */ jsx13("div", { ref: sentinelRef, className: "flex items-center justify-center py-6", children: history.isLoadingMore && /* @__PURE__ */ jsx13("span", { className: "text-xs text-muted-foreground", children: "Loading\u2026" }) }) : null
3415
3890
  ] }) })
3416
3891
  ] }),
3417
- bulkTarget && /* @__PURE__ */ jsx12(
3892
+ bulkTarget && /* @__PURE__ */ jsx13(
3418
3893
  SessionDialog,
3419
3894
  {
3420
3895
  title: bulkTarget.title,
@@ -3426,8 +3901,8 @@ function SessionHistoryPanel({
3426
3901
  },
3427
3902
  busy: bulkBusy,
3428
3903
  error: bulkError,
3429
- footer: /* @__PURE__ */ jsxs10(Fragment6, { children: [
3430
- /* @__PURE__ */ jsx12(
3904
+ footer: /* @__PURE__ */ jsxs11(Fragment6, { children: [
3905
+ /* @__PURE__ */ jsx13(
3431
3906
  DialogButton,
3432
3907
  {
3433
3908
  onClick: () => {
@@ -3439,21 +3914,21 @@ function SessionHistoryPanel({
3439
3914
  children: "Cancel"
3440
3915
  }
3441
3916
  ),
3442
- /* @__PURE__ */ jsx12(DialogButton, { onClick: () => void confirmBulkAction(), disabled: bulkBusy, variant: "destructive", children: bulkBusy ? "Working\u2026" : deleteLabel })
3917
+ /* @__PURE__ */ jsx13(DialogButton, { onClick: () => void confirmBulkAction(), disabled: bulkBusy, variant: "destructive", children: bulkBusy ? "Working\u2026" : deleteLabel })
3443
3918
  ] }),
3444
- children: /* @__PURE__ */ jsx12("p", { className: "text-sm text-muted-foreground", children: bulkTarget.body })
3919
+ children: /* @__PURE__ */ jsx13("p", { className: "text-sm text-muted-foreground", children: bulkTarget.body })
3445
3920
  }
3446
3921
  )
3447
3922
  ] });
3448
3923
  }
3449
3924
  function ErrorBlock({ message, onRetry, inline }) {
3450
- return /* @__PURE__ */ jsxs10(
3925
+ return /* @__PURE__ */ jsxs11(
3451
3926
  "div",
3452
3927
  {
3453
3928
  className: inline ? "flex items-center justify-center gap-3 py-6 text-sm text-muted-foreground" : "flex min-h-[40vh] flex-col items-center justify-center gap-3 text-center",
3454
3929
  children: [
3455
- /* @__PURE__ */ jsx12("span", { className: "text-sm text-muted-foreground", children: message }),
3456
- /* @__PURE__ */ jsx12(
3930
+ /* @__PURE__ */ jsx13("span", { className: "text-sm text-muted-foreground", children: message }),
3931
+ /* @__PURE__ */ jsx13(
3457
3932
  "button",
3458
3933
  {
3459
3934
  type: "button",
@@ -3482,12 +3957,12 @@ function SessionRow({
3482
3957
  selected,
3483
3958
  onSelectedChange
3484
3959
  }) {
3485
- const [menuOpen, setMenuOpen] = useState12(false);
3960
+ const [menuOpen, setMenuOpen] = useState13(false);
3486
3961
  const extras = extraActions?.(session) ?? [];
3487
3962
  const hasMenu = Boolean(onRename) || Boolean(onDelete) || extras.length > 0;
3488
3963
  const showUnread = Boolean(session.unread) && !responding;
3489
- return /* @__PURE__ */ jsxs10("div", { className: "group relative flex items-center gap-2 rounded-lg px-3 py-2.5 transition-colors hover:bg-accent/20", children: [
3490
- selectable && /* @__PURE__ */ jsx12(
3964
+ return /* @__PURE__ */ jsxs11("div", { className: "group relative flex items-center gap-2 rounded-lg px-3 py-2.5 transition-colors hover:bg-accent/20", children: [
3965
+ selectable && /* @__PURE__ */ jsx13(
3491
3966
  "input",
3492
3967
  {
3493
3968
  type: "checkbox",
@@ -3497,10 +3972,10 @@ function SessionRow({
3497
3972
  className: "h-4 w-4 shrink-0 rounded border-border accent-primary"
3498
3973
  }
3499
3974
  ),
3500
- /* @__PURE__ */ jsxs10(Link, { to: href, className: "flex min-w-0 flex-1 items-center gap-3", children: [
3501
- showUnread && /* @__PURE__ */ jsx12("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full bg-primary", "aria-hidden": true }),
3502
- /* @__PURE__ */ jsx12(MessageIcon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
3503
- /* @__PURE__ */ jsx12(
3975
+ /* @__PURE__ */ jsxs11(Link, { to: href, className: "flex min-w-0 flex-1 items-center gap-3", children: [
3976
+ showUnread && /* @__PURE__ */ jsx13("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full bg-primary", "aria-hidden": true }),
3977
+ /* @__PURE__ */ jsx13(MessageIcon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
3978
+ /* @__PURE__ */ jsx13(
3504
3979
  "span",
3505
3980
  {
3506
3981
  className: `truncate text-sm ${responding ? "text-muted-foreground" : "text-foreground"} ${showUnread ? "font-semibold" : ""}`,
@@ -3509,9 +3984,9 @@ function SessionRow({
3509
3984
  }
3510
3985
  )
3511
3986
  ] }),
3512
- /* @__PURE__ */ jsx12("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: timestamp }),
3513
- hasMenu && /* @__PURE__ */ jsxs10("div", { className: "relative shrink-0", children: [
3514
- /* @__PURE__ */ jsx12(
3987
+ /* @__PURE__ */ jsx13("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: timestamp }),
3988
+ hasMenu && /* @__PURE__ */ jsxs11("div", { className: "relative shrink-0", children: [
3989
+ /* @__PURE__ */ jsx13(
3515
3990
  "button",
3516
3991
  {
3517
3992
  type: "button",
@@ -3519,13 +3994,13 @@ function SessionRow({
3519
3994
  "aria-expanded": menuOpen,
3520
3995
  onClick: () => setMenuOpen((open) => !open),
3521
3996
  className: "flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted hover:text-foreground focus-visible:opacity-100 sm:opacity-0 sm:group-hover:opacity-100 aria-expanded:opacity-100",
3522
- children: /* @__PURE__ */ jsx12("span", { "aria-hidden": true, className: "text-base leading-none", children: "\u22EF" })
3997
+ children: /* @__PURE__ */ jsx13("span", { "aria-hidden": true, className: "text-base leading-none", children: "\u22EF" })
3523
3998
  }
3524
3999
  ),
3525
- menuOpen && /* @__PURE__ */ jsxs10(Fragment6, { children: [
3526
- /* @__PURE__ */ jsx12("div", { className: "fixed inset-0 z-20", onClick: () => setMenuOpen(false), "aria-hidden": true }),
3527
- /* @__PURE__ */ jsxs10("div", { className: "absolute right-0 z-30 mt-1 w-36 overflow-hidden rounded-md border border-border bg-card py-1 shadow-lg", children: [
3528
- onRename && /* @__PURE__ */ jsx12(
4000
+ menuOpen && /* @__PURE__ */ jsxs11(Fragment6, { children: [
4001
+ /* @__PURE__ */ jsx13("div", { className: "fixed inset-0 z-20", onClick: () => setMenuOpen(false), "aria-hidden": true }),
4002
+ /* @__PURE__ */ jsxs11("div", { className: "absolute right-0 z-30 mt-1 w-36 overflow-hidden rounded-md border border-border bg-card py-1 shadow-lg", children: [
4003
+ onRename && /* @__PURE__ */ jsx13(
3529
4004
  "button",
3530
4005
  {
3531
4006
  type: "button",
@@ -3537,7 +4012,7 @@ function SessionRow({
3537
4012
  children: renameLabel
3538
4013
  }
3539
4014
  ),
3540
- extras.map((action) => /* @__PURE__ */ jsx12(
4015
+ extras.map((action) => /* @__PURE__ */ jsx13(
3541
4016
  "button",
3542
4017
  {
3543
4018
  type: "button",
@@ -3550,7 +4025,7 @@ function SessionRow({
3550
4025
  },
3551
4026
  action.id
3552
4027
  )),
3553
- onDelete && /* @__PURE__ */ jsx12(
4028
+ onDelete && /* @__PURE__ */ jsx13(
3554
4029
  "button",
3555
4030
  {
3556
4031
  type: "button",
@@ -3568,9 +4043,1231 @@ function SessionRow({
3568
4043
  ] });
3569
4044
  }
3570
4045
 
4046
+ // src/web-react/record-grid.tsx
4047
+ import {
4048
+ Fragment as Fragment7,
4049
+ useCallback as useCallback9,
4050
+ useEffect as useEffect11,
4051
+ useId as useId2,
4052
+ useMemo as useMemo7,
4053
+ useRef as useRef10,
4054
+ useState as useState14
4055
+ } from "react";
4056
+
4057
+ // src/web-react/record-grid-model.ts
4058
+ function recordGridOk(value) {
4059
+ return { succeeded: true, value };
4060
+ }
4061
+ function recordGridFail(error) {
4062
+ return { succeeded: false, error };
4063
+ }
4064
+ function isRecordGridCellApplicable(column, values) {
4065
+ const dependency = column.dependsOn;
4066
+ if (!dependency) return true;
4067
+ const held = values[dependency.column] ?? null;
4068
+ return sameRecordGridValue(held, dependency.equals);
4069
+ }
4070
+ function sameRecordGridValue(a, b) {
4071
+ return Object.is(a ?? null, b ?? null);
4072
+ }
4073
+ var NUMERIC = /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/;
4074
+ var ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
4075
+ function parseNumericText(raw) {
4076
+ const trimmed = raw.trim();
4077
+ if (trimmed === "") return { empty: true };
4078
+ const parenthesized = /^\(.+\)$/.test(trimmed);
4079
+ const body = (parenthesized ? trimmed.slice(1, -1).trim() : trimmed).replace(/[\s,]/g, "").replace(/^([+-]?)\p{Sc}/u, "$1");
4080
+ if (!NUMERIC.test(body)) return { invalid: true };
4081
+ const parsed = Number(body);
4082
+ if (!Number.isFinite(parsed)) return { invalid: true };
4083
+ return { value: parenthesized ? -parsed : parsed };
4084
+ }
4085
+ function isCalendarDate(text) {
4086
+ if (!ISO_DATE.test(text)) return false;
4087
+ const [year, month, day] = text.split("-").map((part) => Number(part));
4088
+ if (month === void 0 || day === void 0 || year === void 0) return false;
4089
+ if (month < 1 || month > 12 || day < 1) return false;
4090
+ const stamp = Date.UTC(year, month - 1, day);
4091
+ const date = new Date(stamp);
4092
+ return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
4093
+ }
4094
+ function parseRecordGridInput(column, raw) {
4095
+ switch (column.kind) {
4096
+ case "text": {
4097
+ const trimmed = raw.trim();
4098
+ return recordGridOk(trimmed === "" ? null : trimmed);
4099
+ }
4100
+ case "select": {
4101
+ const trimmed = raw.trim();
4102
+ return recordGridOk(trimmed === "" ? null : trimmed);
4103
+ }
4104
+ case "boolean": {
4105
+ const trimmed = raw.trim().toLowerCase();
4106
+ if (trimmed === "") return recordGridOk(null);
4107
+ if (trimmed === "true") return recordGridOk(true);
4108
+ if (trimmed === "false") return recordGridOk(false);
4109
+ return recordGridFail(`${column.header} must be true or false \u2014 got \u201C${raw}\u201D.`);
4110
+ }
4111
+ case "date": {
4112
+ const trimmed = raw.trim();
4113
+ if (trimmed === "") return recordGridOk(null);
4114
+ if (!isCalendarDate(trimmed)) {
4115
+ return recordGridFail(`${column.header} must be a date in YYYY-MM-DD form \u2014 got \u201C${raw}\u201D.`);
4116
+ }
4117
+ return recordGridOk(trimmed);
4118
+ }
4119
+ case "number":
4120
+ case "currency": {
4121
+ const parsed = parseNumericText(raw);
4122
+ if ("empty" in parsed) return recordGridOk(null);
4123
+ if ("invalid" in parsed) return recordGridFail(`${column.header} must be a number \u2014 got \u201C${raw}\u201D.`);
4124
+ return recordGridOk(parsed.value);
4125
+ }
4126
+ }
4127
+ }
4128
+ function describeOptions(column) {
4129
+ return column.options.map((option) => option.label).join(", ");
4130
+ }
4131
+ function validateRecordGridCell(column, value) {
4132
+ const normalized = value === "" ? null : value;
4133
+ if (normalized === null) {
4134
+ if (column.required) return recordGridFail(`${column.header} is required.`);
4135
+ const custom2 = column.validate?.(null);
4136
+ return custom2 === void 0 || custom2 === null ? recordGridOk(null) : recordGridFail(custom2);
4137
+ }
4138
+ switch (column.kind) {
4139
+ case "text": {
4140
+ if (typeof normalized !== "string") return recordGridFail(`${column.header} must be text.`);
4141
+ if (column.minLength !== void 0 && normalized.length < column.minLength) {
4142
+ return recordGridFail(`${column.header} must be at least ${column.minLength} characters \u2014 got ${normalized.length}.`);
4143
+ }
4144
+ if (column.maxLength !== void 0 && normalized.length > column.maxLength) {
4145
+ return recordGridFail(`${column.header} must be at most ${column.maxLength} characters \u2014 got ${normalized.length}.`);
4146
+ }
4147
+ if (column.pattern && !column.pattern.test(normalized)) {
4148
+ return recordGridFail(column.patternMessage ?? `${column.header} does not match ${column.pattern.source}.`);
4149
+ }
4150
+ break;
4151
+ }
4152
+ case "number":
4153
+ case "currency": {
4154
+ if (typeof normalized !== "number" || !Number.isFinite(normalized)) {
4155
+ return recordGridFail(`${column.header} must be a number.`);
4156
+ }
4157
+ if (column.kind === "number" && column.integer === true && !Number.isInteger(normalized)) {
4158
+ return recordGridFail(`${column.header} must be a whole number \u2014 got ${normalized}.`);
4159
+ }
4160
+ if (column.min !== void 0 && normalized < column.min) {
4161
+ return recordGridFail(`${column.header} must be at least ${column.min} \u2014 got ${normalized}.`);
4162
+ }
4163
+ if (column.max !== void 0 && normalized > column.max) {
4164
+ return recordGridFail(`${column.header} must be at most ${column.max} \u2014 got ${normalized}.`);
4165
+ }
4166
+ break;
4167
+ }
4168
+ case "date": {
4169
+ if (typeof normalized !== "string" || !isCalendarDate(normalized)) {
4170
+ return recordGridFail(`${column.header} must be a date in YYYY-MM-DD form.`);
4171
+ }
4172
+ if (column.min !== void 0 && normalized < column.min) {
4173
+ return recordGridFail(`${column.header} must be on or after ${column.min} \u2014 got ${normalized}.`);
4174
+ }
4175
+ if (column.max !== void 0 && normalized > column.max) {
4176
+ return recordGridFail(`${column.header} must be on or before ${column.max} \u2014 got ${normalized}.`);
4177
+ }
4178
+ break;
4179
+ }
4180
+ case "select": {
4181
+ if (typeof normalized !== "string") return recordGridFail(`${column.header} must be one of: ${describeOptions(column)}.`);
4182
+ if (!column.options.some((option) => option.value === normalized)) {
4183
+ return recordGridFail(`${column.header} must be one of: ${describeOptions(column)} \u2014 got \u201C${normalized}\u201D.`);
4184
+ }
4185
+ break;
4186
+ }
4187
+ case "boolean": {
4188
+ if (typeof normalized !== "boolean") return recordGridFail(`${column.header} must be true or false.`);
4189
+ break;
4190
+ }
4191
+ }
4192
+ const custom = column.validate?.(normalized);
4193
+ if (custom !== void 0 && custom !== null) return recordGridFail(custom);
4194
+ return recordGridOk(normalized);
4195
+ }
4196
+ function readRecordGridCell(column, raw) {
4197
+ const parsed = parseRecordGridInput(column, raw);
4198
+ if (!parsed.succeeded) return parsed;
4199
+ return validateRecordGridCell(column, parsed.value);
4200
+ }
4201
+ function validateRecordGridRow(columns, values) {
4202
+ const accepted = {};
4203
+ const cellErrors = {};
4204
+ let firstError = null;
4205
+ for (const column of columns) {
4206
+ if (!isRecordGridCellApplicable(column, values)) {
4207
+ accepted[column.id] = null;
4208
+ continue;
4209
+ }
4210
+ const outcome = validateRecordGridCell(column, values[column.id] ?? null);
4211
+ if (outcome.succeeded) {
4212
+ accepted[column.id] = outcome.value;
4213
+ continue;
4214
+ }
4215
+ cellErrors[column.id] = outcome.error;
4216
+ if (firstError === null) firstError = outcome.error;
4217
+ }
4218
+ if (firstError !== null) {
4219
+ const count = Object.keys(cellErrors).length;
4220
+ const error = count === 1 ? firstError : `${count} fields need attention. ${firstError}`;
4221
+ return { succeeded: false, error, cellErrors };
4222
+ }
4223
+ return { succeeded: true, value: accepted };
4224
+ }
4225
+ function formatRecordGridValue(column, value, locale) {
4226
+ if (value === null || value === "") return "";
4227
+ switch (column.kind) {
4228
+ case "currency": {
4229
+ if (typeof value !== "number") return String(value);
4230
+ return new Intl.NumberFormat(locale, {
4231
+ style: "currency",
4232
+ currency: column.currency,
4233
+ ...column.fractionDigits === void 0 ? {} : { minimumFractionDigits: column.fractionDigits, maximumFractionDigits: column.fractionDigits }
4234
+ }).format(value);
4235
+ }
4236
+ case "number": {
4237
+ if (typeof value !== "number") return String(value);
4238
+ return new Intl.NumberFormat(locale).format(value);
4239
+ }
4240
+ case "date": {
4241
+ if (typeof value !== "string" || !isCalendarDate(value)) return String(value);
4242
+ return new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeZone: "UTC" }).format(
4243
+ /* @__PURE__ */ new Date(`${value}T00:00:00Z`)
4244
+ );
4245
+ }
4246
+ case "select": {
4247
+ const option = column.options.find((candidate) => candidate.value === value);
4248
+ return option ? option.label : String(value);
4249
+ }
4250
+ case "boolean": {
4251
+ if (typeof value !== "boolean") return String(value);
4252
+ return value ? column.trueLabel ?? "Yes" : column.falseLabel ?? "No";
4253
+ }
4254
+ case "text":
4255
+ return String(value);
4256
+ }
4257
+ }
4258
+ function recordGridEditorText(column, value) {
4259
+ if (value === null) return "";
4260
+ if (column.kind === "boolean") return value === true ? "true" : "false";
4261
+ return String(value);
4262
+ }
4263
+ function recordGridRowLabel(columns, row) {
4264
+ if (row.label !== void 0 && row.label !== "") return row.label;
4265
+ for (const column of columns) {
4266
+ if (column.kind !== "text" && column.kind !== "select") continue;
4267
+ const value = row.values[column.id];
4268
+ if (typeof value === "string" && value !== "") return formatRecordGridValue(column, value);
4269
+ }
4270
+ return row.id;
4271
+ }
4272
+ function sumRecordGridColumn(rows, columnId) {
4273
+ let total = 0;
4274
+ for (const row of rows) {
4275
+ const value = row.values[columnId];
4276
+ if (typeof value === "number" && Number.isFinite(value)) total += value;
4277
+ }
4278
+ return total;
4279
+ }
4280
+ var EMPTY_RECORD_GRID_OVERLAY = { updates: {}, created: [], removed: [] };
4281
+ function projectRecordGridRows(rows, overlay) {
4282
+ const removed = new Set(overlay.removed);
4283
+ const projected = [];
4284
+ for (const row of rows) {
4285
+ if (removed.has(row.id)) continue;
4286
+ const patch = overlay.updates[row.id];
4287
+ projected.push(patch === void 0 ? row : { ...row, values: { ...row.values, ...patch } });
4288
+ }
4289
+ for (const row of overlay.created) {
4290
+ if (removed.has(row.id)) continue;
4291
+ const patch = overlay.updates[row.id];
4292
+ projected.push(patch === void 0 ? row : { ...row, values: { ...row.values, ...patch } });
4293
+ }
4294
+ return projected;
4295
+ }
4296
+ function withRecordGridUpdate(overlay, rowId, columnId, value) {
4297
+ const rowPatch = { ...overlay.updates[rowId] ?? {}, [columnId]: value };
4298
+ return { ...overlay, updates: { ...overlay.updates, [rowId]: rowPatch } };
4299
+ }
4300
+ function withoutRecordGridUpdate(overlay, rowId, columnId) {
4301
+ const rowPatch = overlay.updates[rowId];
4302
+ if (rowPatch === void 0 || !(columnId in rowPatch)) return overlay;
4303
+ const nextPatch = {};
4304
+ for (const [key, value] of Object.entries(rowPatch)) {
4305
+ if (key !== columnId) nextPatch[key] = value;
4306
+ }
4307
+ const updates = { ...overlay.updates };
4308
+ if (Object.keys(nextPatch).length === 0) delete updates[rowId];
4309
+ else updates[rowId] = nextPatch;
4310
+ return { ...overlay, updates };
4311
+ }
4312
+ function withRecordGridServerRow(overlay, draftId, row) {
4313
+ const createdIndex = overlay.created.findIndex((candidate) => candidate.id === draftId);
4314
+ if (createdIndex >= 0) {
4315
+ const created = [...overlay.created];
4316
+ created[createdIndex] = row;
4317
+ return { ...overlay, created, updates: withoutRowUpdates(overlay.updates, draftId, row.id) };
4318
+ }
4319
+ return { ...overlay, updates: { ...overlay.updates, [row.id]: { ...row.values } } };
4320
+ }
4321
+ function withoutRowUpdates(updates, ...rowIds) {
4322
+ const drop = new Set(rowIds);
4323
+ const next = {};
4324
+ let changed = false;
4325
+ for (const [rowId, patch] of Object.entries(updates)) {
4326
+ if (drop.has(rowId)) changed = true;
4327
+ else next[rowId] = patch;
4328
+ }
4329
+ return changed ? next : updates;
4330
+ }
4331
+ function withRecordGridCreated(overlay, row) {
4332
+ return { ...overlay, created: [...overlay.created, row] };
4333
+ }
4334
+ function withoutRecordGridCreated(overlay, rowId) {
4335
+ const created = overlay.created.filter((row) => row.id !== rowId);
4336
+ if (created.length === overlay.created.length) return overlay;
4337
+ return { ...overlay, created, updates: withoutRowUpdates(overlay.updates, rowId) };
4338
+ }
4339
+ function withRecordGridRemoved(overlay, rowId) {
4340
+ if (overlay.removed.includes(rowId)) return overlay;
4341
+ return { ...overlay, removed: [...overlay.removed, rowId] };
4342
+ }
4343
+ function withoutRecordGridRemoved(overlay, rowId) {
4344
+ if (!overlay.removed.includes(rowId)) return overlay;
4345
+ return { ...overlay, removed: overlay.removed.filter((candidate) => candidate !== rowId) };
4346
+ }
4347
+ function pruneRecordGridOverlay(rows, overlay) {
4348
+ const byId = new Map(rows.map((row) => [row.id, row]));
4349
+ const createdIds = new Set(overlay.created.map((row) => row.id));
4350
+ let changed = false;
4351
+ const updates = {};
4352
+ for (const [rowId, patch] of Object.entries(overlay.updates)) {
4353
+ const row = byId.get(rowId);
4354
+ if (row === void 0) {
4355
+ if (createdIds.has(rowId)) {
4356
+ updates[rowId] = patch;
4357
+ continue;
4358
+ }
4359
+ changed = true;
4360
+ continue;
4361
+ }
4362
+ const kept = {};
4363
+ for (const [columnId, value] of Object.entries(patch)) {
4364
+ if (sameRecordGridValue(row.values[columnId], value)) changed = true;
4365
+ else kept[columnId] = value;
4366
+ }
4367
+ if (Object.keys(kept).length > 0) updates[rowId] = kept;
4368
+ }
4369
+ const created = overlay.created.filter((row) => {
4370
+ const settled = byId.has(row.id);
4371
+ if (settled) changed = true;
4372
+ return !settled;
4373
+ });
4374
+ const removed = overlay.removed.filter((rowId) => {
4375
+ const settled = !byId.has(rowId);
4376
+ if (settled) changed = true;
4377
+ return !settled;
4378
+ });
4379
+ if (!changed) return overlay;
4380
+ return { updates, created, removed };
4381
+ }
4382
+
4383
+ // src/web-react/record-grid.tsx
4384
+ import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
4385
+ var CELL_KEY_SEPARATOR = "\0";
4386
+ function cellKey(rowId, columnId) {
4387
+ return `${rowId}${CELL_KEY_SEPARATOR}${columnId}`;
4388
+ }
4389
+ var NAVIGATION_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Home", "End"]);
4390
+ function clamp(value, max) {
4391
+ if (value < 0) return 0;
4392
+ if (value > max) return max;
4393
+ return value;
4394
+ }
4395
+ function alignmentClass(column) {
4396
+ const align = column.align ?? (column.kind === "number" || column.kind === "currency" ? "right" : "left");
4397
+ return align === "right" ? "text-right" : "text-left";
4398
+ }
4399
+ function groupColumns(columns) {
4400
+ const groups = [];
4401
+ for (const column of columns) {
4402
+ const label = column.group ?? null;
4403
+ const existing = groups.find((group) => group.label === label);
4404
+ if (existing) existing.columns.push(column);
4405
+ else groups.push({ label, columns: [column] });
4406
+ }
4407
+ return groups;
4408
+ }
4409
+ var INPUT_CLASS = "w-full rounded-md border border-border bg-background px-2 py-1 text-sm text-foreground outline-none focus:border-primary/60 focus:ring-1 focus:ring-primary/40";
4410
+ var BASIS_TONES2 = {
4411
+ source: "border-primary/60 text-primary",
4412
+ confirmed: "border-success/60 text-success",
4413
+ derived: "border-border text-muted-foreground"
4414
+ };
4415
+ var BASIS_TITLES = {
4416
+ source: "Extracted from a source document",
4417
+ confirmed: "Confirmed by a person",
4418
+ derived: "Computed from other values"
4419
+ };
4420
+ function RecordGrid({
4421
+ columns,
4422
+ rows,
4423
+ caption,
4424
+ state = "ready",
4425
+ error,
4426
+ onRetry,
4427
+ empty,
4428
+ onCreate,
4429
+ onUpdate,
4430
+ onDelete,
4431
+ newRowDefaults,
4432
+ addLabel = "Add row",
4433
+ locale,
4434
+ toolbar,
4435
+ loadingRowCount = 3,
4436
+ className
4437
+ }) {
4438
+ const fieldPrefix = useId2();
4439
+ const [overlay, setOverlay] = useState14(EMPTY_RECORD_GRID_OVERLAY);
4440
+ const [editing, setEditingState] = useState14(null);
4441
+ const [cellErrors, setCellErrors] = useState14({});
4442
+ const [rowErrors, setRowErrors] = useState14({});
4443
+ const [pendingRows, setPendingRows] = useState14({});
4444
+ const [focus, setFocus] = useState14(null);
4445
+ const [openSource, setOpenSource] = useState14(null);
4446
+ const [confirmDelete, setConfirmDelete] = useState14(null);
4447
+ const [adding, setAdding] = useState14(false);
4448
+ const [draft, setDraft] = useState14({ ...newRowDefaults ?? {} });
4449
+ const [draftErrors, setDraftErrors] = useState14({});
4450
+ const [draftError, setDraftError] = useState14(null);
4451
+ const [creating, setCreating] = useState14(false);
4452
+ const cellRefs = useRef10(/* @__PURE__ */ new Map());
4453
+ const settling = useRef10(false);
4454
+ const draftCounter = useRef10(0);
4455
+ const editingRef = useRef10(null);
4456
+ const setEditing = useCallback9((next) => {
4457
+ editingRef.current = next;
4458
+ setEditingState(next);
4459
+ }, []);
4460
+ useEffect11(() => {
4461
+ setOverlay((current) => pruneRecordGridOverlay(rows, current));
4462
+ }, [rows]);
4463
+ const visibleRows = useMemo7(() => projectRecordGridRows(rows, overlay), [rows, overlay]);
4464
+ const activeFocus = useMemo7(() => {
4465
+ if (focus === null) return null;
4466
+ if (!visibleRows.some((row) => row.id === focus.rowId)) return null;
4467
+ if (!columns.some((column) => column.id === focus.columnId)) return null;
4468
+ return focus;
4469
+ }, [columns, focus, visibleRows]);
4470
+ const setCellError = useCallback9((key, message) => {
4471
+ setCellErrors((current) => {
4472
+ if (message === null) {
4473
+ if (!(key in current)) return current;
4474
+ const next = { ...current };
4475
+ delete next[key];
4476
+ return next;
4477
+ }
4478
+ if (current[key] === message) return current;
4479
+ return { ...current, [key]: message };
4480
+ });
4481
+ }, []);
4482
+ const setRowError = useCallback9((rowId, message) => {
4483
+ setRowErrors((current) => {
4484
+ if (message === null) {
4485
+ if (!(rowId in current)) return current;
4486
+ const next = { ...current };
4487
+ delete next[rowId];
4488
+ return next;
4489
+ }
4490
+ return { ...current, [rowId]: message };
4491
+ });
4492
+ }, []);
4493
+ const setRowPending = useCallback9((rowId, pending) => {
4494
+ setPendingRows((current) => {
4495
+ if (pending) return rowId in current ? current : { ...current, [rowId]: true };
4496
+ if (!(rowId in current)) return current;
4497
+ const next = { ...current };
4498
+ delete next[rowId];
4499
+ return next;
4500
+ });
4501
+ }, []);
4502
+ const focusCell = useCallback9((rowId, columnId) => {
4503
+ setFocus({ rowId, columnId });
4504
+ cellRefs.current.get(cellKey(rowId, columnId))?.focus();
4505
+ }, []);
4506
+ const beginEdit = useCallback9(
4507
+ (row, column) => {
4508
+ setCellError(cellKey(row.id, column.id), null);
4509
+ setEditing({
4510
+ rowId: row.id,
4511
+ columnId: column.id,
4512
+ text: recordGridEditorText(column, row.values[column.id] ?? null)
4513
+ });
4514
+ },
4515
+ [setCellError, setEditing]
4516
+ );
4517
+ const applyCellWrite = useCallback9(
4518
+ async (row, column, value) => {
4519
+ if (!onUpdate) return;
4520
+ const values = { ...row.values, [column.id]: value };
4521
+ setOverlay((current) => withRecordGridUpdate(current, row.id, column.id, value));
4522
+ setRowError(row.id, null);
4523
+ setRowPending(row.id, true);
4524
+ let outcome;
4525
+ try {
4526
+ outcome = await onUpdate({ row, columnId: column.id, value, values });
4527
+ } catch (cause) {
4528
+ outcome = { succeeded: false, error: cause instanceof Error ? cause.message : String(cause) };
4529
+ }
4530
+ setRowPending(row.id, false);
4531
+ if (outcome.succeeded) {
4532
+ const canonical = outcome.value;
4533
+ if (canonical) setOverlay((current) => withRecordGridServerRow(current, row.id, canonical));
4534
+ return;
4535
+ }
4536
+ setOverlay((current) => withoutRecordGridUpdate(current, row.id, column.id));
4537
+ const rejected = formatRecordGridValue(column, value, locale);
4538
+ setRowError(
4539
+ row.id,
4540
+ rejected === "" ? `Could not save ${column.header}: ${outcome.error}` : `Could not save ${column.header} as ${rejected}: ${outcome.error}`
4541
+ );
4542
+ },
4543
+ [locale, onUpdate, setRowError, setRowPending]
4544
+ );
4545
+ const commitEdit = useCallback9(
4546
+ async (row, column, text) => {
4547
+ const open = editingRef.current;
4548
+ if (open === null || open.rowId !== row.id || open.columnId !== column.id) return;
4549
+ if (settling.current) return;
4550
+ settling.current = true;
4551
+ try {
4552
+ const key = cellKey(row.id, column.id);
4553
+ const parsed = readRecordGridCell(column, text);
4554
+ if (!parsed.succeeded) {
4555
+ setCellError(key, parsed.error);
4556
+ setEditing({ rowId: row.id, columnId: column.id, text });
4557
+ return;
4558
+ }
4559
+ setCellError(key, null);
4560
+ setEditing(null);
4561
+ if (sameRecordGridValue(row.values[column.id], parsed.value)) return;
4562
+ await applyCellWrite(row, column, parsed.value);
4563
+ } finally {
4564
+ settling.current = false;
4565
+ }
4566
+ },
4567
+ [applyCellWrite, setCellError, setEditing]
4568
+ );
4569
+ const cancelEdit = useCallback9(
4570
+ (row, column) => {
4571
+ setCellError(cellKey(row.id, column.id), null);
4572
+ setEditing(null);
4573
+ focusCell(row.id, column.id);
4574
+ },
4575
+ [focusCell, setCellError, setEditing]
4576
+ );
4577
+ const performDelete = useCallback9(
4578
+ async (row) => {
4579
+ if (!onDelete) return;
4580
+ setConfirmDelete(null);
4581
+ setRowError(row.id, null);
4582
+ setOverlay((current) => withRecordGridRemoved(current, row.id));
4583
+ let outcome;
4584
+ try {
4585
+ outcome = await onDelete(row);
4586
+ } catch (cause) {
4587
+ outcome = { succeeded: false, error: cause instanceof Error ? cause.message : String(cause) };
4588
+ }
4589
+ if (outcome.succeeded) return;
4590
+ setOverlay((current) => withoutRecordGridRemoved(current, row.id));
4591
+ setRowError(row.id, `Could not delete ${recordGridRowLabel(columns, row)}: ${outcome.error}`);
4592
+ },
4593
+ [columns, onDelete, setRowError]
4594
+ );
4595
+ const resetDraft = useCallback9(() => {
4596
+ setDraft({ ...newRowDefaults ?? {} });
4597
+ setDraftErrors({});
4598
+ setDraftError(null);
4599
+ }, [newRowDefaults]);
4600
+ const openAdd = useCallback9(() => {
4601
+ resetDraft();
4602
+ setAdding(true);
4603
+ }, [resetDraft]);
4604
+ const submitDraft = useCallback9(async () => {
4605
+ if (!onCreate) return;
4606
+ const validated = validateRecordGridRow(columns, draft);
4607
+ if (!validated.succeeded) {
4608
+ setDraftErrors(validated.cellErrors);
4609
+ setDraftError(validated.error);
4610
+ return;
4611
+ }
4612
+ setDraftErrors({});
4613
+ setDraftError(null);
4614
+ draftCounter.current += 1;
4615
+ const draftId = `${fieldPrefix}-draft-${draftCounter.current}`;
4616
+ setOverlay((current) => withRecordGridCreated(current, { id: draftId, values: validated.value }));
4617
+ setCreating(true);
4618
+ let outcome;
4619
+ try {
4620
+ outcome = await onCreate(validated.value);
4621
+ } catch (cause) {
4622
+ outcome = { succeeded: false, error: cause instanceof Error ? cause.message : String(cause) };
4623
+ }
4624
+ setCreating(false);
4625
+ if (outcome.succeeded) {
4626
+ setOverlay((current) => withRecordGridServerRow(current, draftId, outcome.value));
4627
+ setAdding(false);
4628
+ resetDraft();
4629
+ return;
4630
+ }
4631
+ setOverlay((current) => withoutRecordGridCreated(current, draftId));
4632
+ setDraftError(outcome.error);
4633
+ }, [columns, draft, fieldPrefix, onCreate, resetDraft]);
4634
+ const handleGridKeyDown = useCallback9(
4635
+ (event) => {
4636
+ if (editing !== null) return;
4637
+ const target = event.target;
4638
+ const rowId = target.dataset?.recordGridRow;
4639
+ const columnId = target.dataset?.recordGridColumn;
4640
+ if (rowId === void 0 || columnId === void 0) return;
4641
+ const rowIndex = visibleRows.findIndex((row) => row.id === rowId);
4642
+ const columnIndex = columns.findIndex((column) => column.id === columnId);
4643
+ if (rowIndex < 0 || columnIndex < 0) return;
4644
+ if (event.key === "Enter") {
4645
+ const row = visibleRows[rowIndex];
4646
+ const column = columns[columnIndex];
4647
+ if (!row || !column) return;
4648
+ if (!onUpdate || column.editable === false || row.readOnly === true) return;
4649
+ if (column.kind === "boolean") return;
4650
+ if (!isRecordGridCellApplicable(column, row.values)) return;
4651
+ event.preventDefault();
4652
+ beginEdit(row, column);
4653
+ return;
4654
+ }
4655
+ if (!NAVIGATION_KEYS.has(event.key)) return;
4656
+ event.preventDefault();
4657
+ let nextRow = rowIndex;
4658
+ let nextColumn = columnIndex;
4659
+ if (event.key === "ArrowUp") nextRow = clamp(rowIndex - 1, visibleRows.length - 1);
4660
+ if (event.key === "ArrowDown") nextRow = clamp(rowIndex + 1, visibleRows.length - 1);
4661
+ if (event.key === "ArrowLeft") nextColumn = clamp(columnIndex - 1, columns.length - 1);
4662
+ if (event.key === "ArrowRight") nextColumn = clamp(columnIndex + 1, columns.length - 1);
4663
+ if (event.key === "Home") nextColumn = 0;
4664
+ if (event.key === "End") nextColumn = columns.length - 1;
4665
+ const destinationRow = visibleRows[nextRow];
4666
+ const destinationColumn = columns[nextColumn];
4667
+ if (!destinationRow || !destinationColumn) return;
4668
+ focusCell(destinationRow.id, destinationColumn.id);
4669
+ },
4670
+ [beginEdit, columns, editing, focusCell, onUpdate, visibleRows]
4671
+ );
4672
+ const dataState = typeof error === "string" && error !== "" ? "error" : state;
4673
+ if (dataState === "loading") {
4674
+ return /* @__PURE__ */ jsxs12("div", { className: `space-y-3 ${className ?? ""}`, children: [
4675
+ toolbar,
4676
+ /* @__PURE__ */ jsxs12(
4677
+ "div",
4678
+ {
4679
+ role: "status",
4680
+ "aria-busy": "true",
4681
+ "aria-live": "polite",
4682
+ className: "space-y-2 rounded-xl border border-border bg-card p-4",
4683
+ children: [
4684
+ /* @__PURE__ */ jsxs12("span", { className: "sr-only", children: [
4685
+ "Loading ",
4686
+ caption
4687
+ ] }),
4688
+ Array.from({ length: Math.max(1, loadingRowCount) }, (_, index) => /* @__PURE__ */ jsx14("div", { className: "h-8 animate-pulse rounded-md bg-muted/50", "aria-hidden": true }, index))
4689
+ ]
4690
+ }
4691
+ )
4692
+ ] });
4693
+ }
4694
+ if (dataState === "error") {
4695
+ return /* @__PURE__ */ jsxs12("div", { className: `space-y-3 ${className ?? ""}`, children: [
4696
+ toolbar,
4697
+ /* @__PURE__ */ jsxs12("div", { role: "alert", className: "rounded-xl border border-destructive/40 bg-destructive/10 px-4 py-4", children: [
4698
+ /* @__PURE__ */ jsx14("p", { className: "text-sm font-medium text-destructive", children: typeof error === "string" && error !== "" ? error : `${caption} could not be loaded.` }),
4699
+ onRetry && /* @__PURE__ */ jsx14(
4700
+ "button",
4701
+ {
4702
+ type: "button",
4703
+ onClick: onRetry,
4704
+ className: "mt-3 rounded-md border border-destructive/40 px-3 py-1.5 text-xs font-medium text-destructive transition hover:bg-destructive/10",
4705
+ children: "Try again"
4706
+ }
4707
+ )
4708
+ ] })
4709
+ ] });
4710
+ }
4711
+ const addForm = adding && onCreate ? /* @__PURE__ */ jsx14(
4712
+ AddRecordForm,
4713
+ {
4714
+ columns,
4715
+ draft,
4716
+ setDraft,
4717
+ errors: draftErrors,
4718
+ formError: draftError,
4719
+ busy: creating,
4720
+ label: addLabel,
4721
+ fieldPrefix,
4722
+ onSubmit: () => void submitDraft(),
4723
+ onCancel: () => {
4724
+ setAdding(false);
4725
+ resetDraft();
4726
+ }
4727
+ }
4728
+ ) : null;
4729
+ if (visibleRows.length === 0) {
4730
+ return /* @__PURE__ */ jsxs12("div", { className: `space-y-3 ${className ?? ""}`, children: [
4731
+ toolbar,
4732
+ addForm ?? /* @__PURE__ */ jsxs12("div", { className: "rounded-xl border border-dashed border-border px-6 py-10 text-center", children: [
4733
+ /* @__PURE__ */ jsx14("p", { className: "text-sm font-medium text-foreground", children: empty.title }),
4734
+ empty.description && /* @__PURE__ */ jsx14("p", { className: "mx-auto mt-1 max-w-md text-sm text-muted-foreground", children: empty.description }),
4735
+ /* @__PURE__ */ jsxs12("div", { className: "mt-4 flex flex-wrap items-center justify-center gap-2", children: [
4736
+ empty.action,
4737
+ onCreate && /* @__PURE__ */ jsx14(
4738
+ "button",
4739
+ {
4740
+ type: "button",
4741
+ onClick: openAdd,
4742
+ className: "rounded-md border border-border px-3 py-1.5 text-sm font-medium text-foreground transition hover:bg-accent/30",
4743
+ children: addLabel
4744
+ }
4745
+ )
4746
+ ] })
4747
+ ] })
4748
+ ] });
4749
+ }
4750
+ const hasFooter = columns.some((column) => column.footerValue !== void 0);
4751
+ const columnSpan = columns.length + (onDelete ? 1 : 0);
4752
+ return /* @__PURE__ */ jsxs12("div", { className: `space-y-3 ${className ?? ""}`, children: [
4753
+ toolbar,
4754
+ /* @__PURE__ */ jsx14("div", { className: "overflow-x-auto rounded-xl border border-border bg-card", children: /* @__PURE__ */ jsxs12(
4755
+ "table",
4756
+ {
4757
+ role: "grid",
4758
+ "aria-label": caption,
4759
+ className: "w-full border-collapse text-left text-sm",
4760
+ onKeyDown: handleGridKeyDown,
4761
+ children: [
4762
+ /* @__PURE__ */ jsx14("thead", { children: /* @__PURE__ */ jsxs12("tr", { role: "row", className: "border-b border-border text-[11px] uppercase tracking-wide text-muted-foreground", children: [
4763
+ columns.map((column) => /* @__PURE__ */ jsx14(
4764
+ "th",
4765
+ {
4766
+ role: "columnheader",
4767
+ scope: "col",
4768
+ className: `px-3 py-2 font-medium ${alignmentClass(column)}`,
4769
+ children: column.header
4770
+ },
4771
+ column.id
4772
+ )),
4773
+ onDelete && /* @__PURE__ */ jsx14("th", { role: "columnheader", scope: "col", className: "w-px px-3 py-2 font-medium", children: /* @__PURE__ */ jsx14("span", { className: "sr-only", children: "Row actions" }) })
4774
+ ] }) }),
4775
+ /* @__PURE__ */ jsx14("tbody", { children: visibleRows.map((row) => {
4776
+ const rowLabel = recordGridRowLabel(columns, row);
4777
+ const pending = row.id in pendingRows;
4778
+ const rowError = rowErrors[row.id];
4779
+ return /* @__PURE__ */ jsxs12(Fragment7, { children: [
4780
+ /* @__PURE__ */ jsxs12("tr", { role: "row", "aria-busy": pending, className: `border-b border-border/50 ${pending ? "opacity-60" : ""}`, children: [
4781
+ columns.map((column) => {
4782
+ const key = cellKey(row.id, column.id);
4783
+ const applicable = isRecordGridCellApplicable(column, row.values);
4784
+ const editable = onUpdate !== void 0 && column.editable !== false && row.readOnly !== true && applicable;
4785
+ const value = row.values[column.id] ?? null;
4786
+ const isEditing = editing?.rowId === row.id && editing.columnId === column.id;
4787
+ const cellError = cellErrors[key];
4788
+ const active = activeFocus === null ? row.id === visibleRows[0]?.id && column.id === columns[0]?.id : activeFocus.rowId === row.id && activeFocus.columnId === column.id;
4789
+ const source = row.sources?.[column.id];
4790
+ const errorId = `${fieldPrefix}-cell-error-${row.id}-${column.id}`;
4791
+ if (isEditing && editable) {
4792
+ return /* @__PURE__ */ jsxs12("td", { role: "gridcell", className: `px-3 py-1.5 ${alignmentClass(column)}`, children: [
4793
+ /* @__PURE__ */ jsx14(
4794
+ CellEditor,
4795
+ {
4796
+ column,
4797
+ rowLabel,
4798
+ text: editing.text,
4799
+ invalid: cellError !== void 0,
4800
+ describedBy: cellError === void 0 ? void 0 : errorId,
4801
+ onText: (text) => setEditing({ rowId: row.id, columnId: column.id, text }),
4802
+ onCommit: (text) => void commitEdit(row, column, text),
4803
+ onCancel: () => cancelEdit(row, column)
4804
+ }
4805
+ ),
4806
+ cellError !== void 0 && /* @__PURE__ */ jsx14("p", { id: errorId, role: "alert", className: "mt-1 text-[11px] leading-snug text-destructive", children: cellError })
4807
+ ] }, column.id);
4808
+ }
4809
+ if (column.kind === "boolean" && editable) {
4810
+ return /* @__PURE__ */ jsx14("td", { role: "gridcell", className: `px-3 py-2 ${alignmentClass(column)}`, children: /* @__PURE__ */ jsx14(
4811
+ "input",
4812
+ {
4813
+ type: "checkbox",
4814
+ checked: value === true,
4815
+ "aria-label": `${column.header}, ${rowLabel}`,
4816
+ "data-record-grid-row": row.id,
4817
+ "data-record-grid-column": column.id,
4818
+ tabIndex: active ? 0 : -1,
4819
+ ref: (node) => {
4820
+ cellRefs.current.set(key, node);
4821
+ },
4822
+ onFocus: () => setFocus({ rowId: row.id, columnId: column.id }),
4823
+ onChange: (event) => void applyCellWrite(row, column, event.target.checked),
4824
+ className: "h-4 w-4 rounded border-border accent-primary"
4825
+ }
4826
+ ) }, column.id);
4827
+ }
4828
+ const display = applicable ? formatRecordGridValue(column, value, locale) : "";
4829
+ return /* @__PURE__ */ jsx14(
4830
+ "td",
4831
+ {
4832
+ role: "gridcell",
4833
+ "aria-readonly": editable ? void 0 : true,
4834
+ "data-record-grid-row": row.id,
4835
+ "data-record-grid-column": column.id,
4836
+ tabIndex: active ? 0 : -1,
4837
+ ref: (node) => {
4838
+ cellRefs.current.set(key, node);
4839
+ },
4840
+ onFocus: () => setFocus({ rowId: row.id, columnId: column.id }),
4841
+ onClick: () => {
4842
+ if (editable) beginEdit(row, column);
4843
+ },
4844
+ className: `px-3 py-2 outline-none focus:ring-2 focus:ring-inset focus:ring-primary/50 ${alignmentClass(
4845
+ column
4846
+ )} ${editable ? "cursor-text" : ""}`,
4847
+ children: /* @__PURE__ */ jsxs12("span", { className: "inline-flex max-w-full items-center gap-1.5", children: [
4848
+ /* @__PURE__ */ jsx14("span", { className: display === "" ? "text-muted-foreground" : "truncate text-foreground", children: display === "" ? applicable ? "\u2014" : "n/a" : display }),
4849
+ source && /* @__PURE__ */ jsx14(
4850
+ SourceMarker,
4851
+ {
4852
+ panelId: `${fieldPrefix}-source-${row.id}-${column.id}`,
4853
+ columnHeader: column.header,
4854
+ rowLabel,
4855
+ source,
4856
+ open: openSource === key,
4857
+ onToggle: () => setOpenSource((current) => current === key ? null : key)
4858
+ }
4859
+ )
4860
+ ] })
4861
+ },
4862
+ column.id
4863
+ );
4864
+ }),
4865
+ onDelete && /* @__PURE__ */ jsx14("td", { role: "gridcell", className: "px-3 py-2 text-right", children: row.readOnly === true ? null : confirmDelete === row.id ? /* @__PURE__ */ jsxs12("span", { className: "inline-flex items-center gap-1.5", children: [
4866
+ /* @__PURE__ */ jsx14(
4867
+ "button",
4868
+ {
4869
+ type: "button",
4870
+ "aria-label": `Confirm delete ${rowLabel}`,
4871
+ onClick: () => void performDelete(row),
4872
+ className: "rounded-md bg-destructive/10 px-2 py-1 text-xs font-medium text-destructive transition hover:bg-destructive/20",
4873
+ children: "Delete"
4874
+ }
4875
+ ),
4876
+ /* @__PURE__ */ jsx14(
4877
+ "button",
4878
+ {
4879
+ type: "button",
4880
+ "aria-label": `Keep ${rowLabel}`,
4881
+ onClick: () => setConfirmDelete(null),
4882
+ className: "rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground transition hover:bg-accent/30",
4883
+ children: "Cancel"
4884
+ }
4885
+ )
4886
+ ] }) : /* @__PURE__ */ jsx14(
4887
+ "button",
4888
+ {
4889
+ type: "button",
4890
+ "aria-label": `Delete ${rowLabel}`,
4891
+ onClick: () => setConfirmDelete(row.id),
4892
+ className: "rounded-md p-1.5 text-muted-foreground transition hover:bg-destructive/10 hover:text-destructive",
4893
+ children: /* @__PURE__ */ jsxs12(
4894
+ "svg",
4895
+ {
4896
+ viewBox: "0 0 24 24",
4897
+ className: "h-3.5 w-3.5",
4898
+ fill: "none",
4899
+ stroke: "currentColor",
4900
+ strokeWidth: "2",
4901
+ strokeLinecap: "round",
4902
+ strokeLinejoin: "round",
4903
+ "aria-hidden": true,
4904
+ children: [
4905
+ /* @__PURE__ */ jsx14("polyline", { points: "3 6 5 6 21 6" }),
4906
+ /* @__PURE__ */ jsx14("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
4907
+ ]
4908
+ }
4909
+ )
4910
+ }
4911
+ ) })
4912
+ ] }),
4913
+ rowError !== void 0 && /* @__PURE__ */ jsx14("tr", { role: "row", className: "border-b border-border/50", children: /* @__PURE__ */ jsx14("td", { role: "gridcell", colSpan: columnSpan, className: "px-3 pb-2", children: /* @__PURE__ */ jsx14("p", { role: "alert", className: "rounded-md bg-destructive/10 px-2.5 py-1.5 text-xs text-destructive", children: rowError }) }) })
4914
+ ] }, row.id);
4915
+ }) }),
4916
+ hasFooter && /* @__PURE__ */ jsx14("tfoot", { children: /* @__PURE__ */ jsxs12("tr", { role: "row", className: "border-t-2 border-border", children: [
4917
+ columns.map((column) => /* @__PURE__ */ jsx14(
4918
+ "td",
4919
+ {
4920
+ role: "gridcell",
4921
+ className: `px-3 py-2 text-sm font-semibold text-foreground ${alignmentClass(column)}`,
4922
+ children: column.footerValue ? formatRecordGridValue(column, column.footerValue(visibleRows), locale) : ""
4923
+ },
4924
+ column.id
4925
+ )),
4926
+ onDelete && /* @__PURE__ */ jsx14("td", { role: "gridcell" })
4927
+ ] }) })
4928
+ ]
4929
+ }
4930
+ ) }),
4931
+ onCreate && (addForm ?? /* @__PURE__ */ jsxs12(
4932
+ "button",
4933
+ {
4934
+ type: "button",
4935
+ onClick: openAdd,
4936
+ className: "inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-sm font-medium text-foreground transition hover:bg-accent/30",
4937
+ children: [
4938
+ /* @__PURE__ */ jsxs12(
4939
+ "svg",
4940
+ {
4941
+ viewBox: "0 0 24 24",
4942
+ className: "h-3.5 w-3.5",
4943
+ fill: "none",
4944
+ stroke: "currentColor",
4945
+ strokeWidth: "2",
4946
+ strokeLinecap: "round",
4947
+ strokeLinejoin: "round",
4948
+ "aria-hidden": true,
4949
+ children: [
4950
+ /* @__PURE__ */ jsx14("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
4951
+ /* @__PURE__ */ jsx14("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
4952
+ ]
4953
+ }
4954
+ ),
4955
+ addLabel
4956
+ ]
4957
+ }
4958
+ ))
4959
+ ] });
4960
+ }
4961
+ function CellEditor({ column, rowLabel, text, invalid, describedBy, onText, onCommit, onCancel }) {
4962
+ const shared = {
4963
+ "aria-label": `${column.header}, ${rowLabel}`,
4964
+ "aria-invalid": invalid ? true : void 0,
4965
+ "aria-describedby": describedBy,
4966
+ autoFocus: true,
4967
+ className: INPUT_CLASS
4968
+ };
4969
+ if (column.kind === "select") {
4970
+ return /* @__PURE__ */ jsxs12(
4971
+ "select",
4972
+ {
4973
+ ...shared,
4974
+ value: text,
4975
+ onChange: (event) => {
4976
+ onText(event.target.value);
4977
+ onCommit(event.target.value);
4978
+ },
4979
+ onKeyDown: (event) => {
4980
+ if (event.key === "Escape") {
4981
+ event.preventDefault();
4982
+ onCancel();
4983
+ }
4984
+ },
4985
+ onBlur: () => onCommit(text),
4986
+ children: [
4987
+ /* @__PURE__ */ jsx14("option", { value: "", children: "\u2014" }),
4988
+ column.options.map((option) => /* @__PURE__ */ jsx14("option", { value: option.value, children: option.label }, option.value))
4989
+ ]
4990
+ }
4991
+ );
4992
+ }
4993
+ const keyDown = (event) => {
4994
+ const multiline = column.kind === "text" && column.multiline === true;
4995
+ if (event.key === "Enter" && !multiline) {
4996
+ event.preventDefault();
4997
+ onCommit(text);
4998
+ return;
4999
+ }
5000
+ if (event.key === "Escape") {
5001
+ event.preventDefault();
5002
+ onCancel();
5003
+ }
5004
+ };
5005
+ if (column.kind === "text" && column.multiline === true) {
5006
+ return /* @__PURE__ */ jsx14(
5007
+ "textarea",
5008
+ {
5009
+ ...shared,
5010
+ rows: 3,
5011
+ value: text,
5012
+ onChange: (event) => onText(event.target.value),
5013
+ onKeyDown: keyDown,
5014
+ onBlur: () => onCommit(text)
5015
+ }
5016
+ );
5017
+ }
5018
+ return /* @__PURE__ */ jsx14(
5019
+ "input",
5020
+ {
5021
+ ...shared,
5022
+ type: column.kind === "date" ? "date" : "text",
5023
+ inputMode: column.kind === "number" || column.kind === "currency" ? "decimal" : void 0,
5024
+ value: text,
5025
+ onChange: (event) => onText(event.target.value),
5026
+ onKeyDown: keyDown,
5027
+ onBlur: () => onCommit(text)
5028
+ }
5029
+ );
5030
+ }
5031
+ function SourceMarker({ panelId, columnHeader, rowLabel, source, open, onToggle }) {
5032
+ const basis = source.basis ?? "source";
5033
+ return /* @__PURE__ */ jsxs12("span", { className: "relative inline-flex", children: [
5034
+ /* @__PURE__ */ jsx14(
5035
+ "button",
5036
+ {
5037
+ type: "button",
5038
+ "aria-label": `Source for ${columnHeader}, ${rowLabel}`,
5039
+ "aria-expanded": open,
5040
+ "aria-controls": open ? panelId : void 0,
5041
+ title: BASIS_TITLES[basis],
5042
+ onClick: (event) => {
5043
+ event.stopPropagation();
5044
+ onToggle();
5045
+ },
5046
+ className: `inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border ${BASIS_TONES2[basis]}`,
5047
+ children: /* @__PURE__ */ jsx14(
5048
+ "svg",
5049
+ {
5050
+ viewBox: "0 0 24 24",
5051
+ className: "h-2.5 w-2.5",
5052
+ fill: "none",
5053
+ stroke: "currentColor",
5054
+ strokeWidth: "2.5",
5055
+ strokeLinecap: "round",
5056
+ "aria-hidden": true,
5057
+ children: /* @__PURE__ */ jsx14("path", { d: "M9 8h6M9 12h6M9 16h3" })
5058
+ }
5059
+ )
5060
+ }
5061
+ ),
5062
+ open && /* @__PURE__ */ jsxs12(
5063
+ "span",
5064
+ {
5065
+ id: panelId,
5066
+ role: "note",
5067
+ className: "absolute left-0 top-5 z-10 w-64 rounded-lg border border-border bg-card p-3 text-left shadow-lg",
5068
+ children: [
5069
+ source.quote && /* @__PURE__ */ jsxs12("span", { className: "block border-l-2 border-primary/50 pl-2 text-xs italic leading-snug text-foreground", children: [
5070
+ "\u201C",
5071
+ source.quote,
5072
+ "\u201D"
5073
+ ] }),
5074
+ /* @__PURE__ */ jsxs12("span", { className: "mt-2 block text-[11px] text-muted-foreground", children: [
5075
+ source.label ?? "Source",
5076
+ source.locator ? ` \xB7 ${source.locator}` : "",
5077
+ ` \xB7 ${BASIS_TITLES[basis]}`
5078
+ ] }),
5079
+ source.href && /* @__PURE__ */ jsx14(
5080
+ "a",
5081
+ {
5082
+ href: source.href,
5083
+ target: "_blank",
5084
+ rel: "noreferrer",
5085
+ onClick: (event) => event.stopPropagation(),
5086
+ className: "mt-1.5 inline-block text-[11px] font-medium text-primary underline-offset-2 hover:underline",
5087
+ children: "Open source"
5088
+ }
5089
+ )
5090
+ ]
5091
+ }
5092
+ )
5093
+ ] });
5094
+ }
5095
+ function AddRecordForm({
5096
+ columns,
5097
+ draft,
5098
+ setDraft,
5099
+ errors,
5100
+ formError,
5101
+ busy,
5102
+ label,
5103
+ fieldPrefix,
5104
+ onSubmit,
5105
+ onCancel
5106
+ }) {
5107
+ const groups = useMemo7(() => groupColumns(columns), [columns]);
5108
+ return /* @__PURE__ */ jsxs12(
5109
+ "form",
5110
+ {
5111
+ noValidate: true,
5112
+ "aria-label": label,
5113
+ onSubmit: (event) => {
5114
+ event.preventDefault();
5115
+ onSubmit();
5116
+ },
5117
+ className: "space-y-4 rounded-xl border border-border bg-card p-4",
5118
+ children: [
5119
+ /* @__PURE__ */ jsx14("h3", { className: "text-sm font-semibold text-foreground", children: label }),
5120
+ formError !== null && /* @__PURE__ */ jsx14("p", { role: "alert", className: "rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive", children: formError }),
5121
+ groups.map((group) => {
5122
+ const fields = group.columns.filter((column) => isRecordGridCellApplicable(column, draft));
5123
+ if (fields.length === 0) return null;
5124
+ return /* @__PURE__ */ jsxs12(
5125
+ "fieldset",
5126
+ {
5127
+ className: group.label === null ? "min-w-0" : "min-w-0 rounded-lg border border-border/70 p-3",
5128
+ children: [
5129
+ group.label !== null && /* @__PURE__ */ jsx14("legend", { className: "px-1 text-xs font-medium text-muted-foreground", children: group.label }),
5130
+ /* @__PURE__ */ jsx14("div", { className: "grid gap-3 sm:grid-cols-2", children: fields.map((column) => {
5131
+ const fieldId = `${fieldPrefix}-${column.id}`;
5132
+ const errorId = `${fieldId}-error`;
5133
+ const message = errors[column.id];
5134
+ return /* @__PURE__ */ jsxs12(
5135
+ "div",
5136
+ {
5137
+ className: column.kind === "text" && column.multiline === true ? "sm:col-span-2" : "",
5138
+ children: [
5139
+ /* @__PURE__ */ jsxs12("label", { htmlFor: fieldId, className: "mb-1 block text-xs font-medium text-muted-foreground", children: [
5140
+ column.header,
5141
+ column.required === true && /* @__PURE__ */ jsx14("span", { className: "ml-0.5 text-destructive", children: "*" })
5142
+ ] }),
5143
+ /* @__PURE__ */ jsx14(
5144
+ DraftField,
5145
+ {
5146
+ column,
5147
+ id: fieldId,
5148
+ value: draft[column.id] ?? null,
5149
+ invalid: message !== void 0,
5150
+ describedBy: message === void 0 ? void 0 : errorId,
5151
+ onValue: (next) => setDraft({ ...draft, [column.id]: next })
5152
+ }
5153
+ ),
5154
+ column.hint && /* @__PURE__ */ jsx14("p", { className: "mt-1 text-[11px] text-muted-foreground", children: column.hint }),
5155
+ message !== void 0 && /* @__PURE__ */ jsx14("p", { id: errorId, role: "alert", className: "mt-1 text-[11px] text-destructive", children: message })
5156
+ ]
5157
+ },
5158
+ column.id
5159
+ );
5160
+ }) })
5161
+ ]
5162
+ },
5163
+ group.label ?? "_"
5164
+ );
5165
+ }),
5166
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2", children: [
5167
+ /* @__PURE__ */ jsx14(
5168
+ "button",
5169
+ {
5170
+ type: "submit",
5171
+ disabled: busy,
5172
+ className: "rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground transition hover:bg-primary/90 disabled:opacity-50",
5173
+ children: busy ? "Saving\u2026" : "Save"
5174
+ }
5175
+ ),
5176
+ /* @__PURE__ */ jsx14(
5177
+ "button",
5178
+ {
5179
+ type: "button",
5180
+ onClick: onCancel,
5181
+ className: "rounded-md border border-border px-3 py-1.5 text-sm font-medium text-muted-foreground transition hover:bg-accent/30",
5182
+ children: "Cancel"
5183
+ }
5184
+ )
5185
+ ] })
5186
+ ]
5187
+ }
5188
+ );
5189
+ }
5190
+ function DraftField({ column, id, value, invalid, describedBy, onValue }) {
5191
+ const shared = {
5192
+ id,
5193
+ "aria-invalid": invalid ? true : void 0,
5194
+ "aria-describedby": describedBy
5195
+ };
5196
+ if (column.kind === "boolean") {
5197
+ return /* @__PURE__ */ jsx14(
5198
+ "input",
5199
+ {
5200
+ ...shared,
5201
+ type: "checkbox",
5202
+ checked: value === true,
5203
+ onChange: (event) => onValue(event.target.checked),
5204
+ className: "h-4 w-4 rounded border-border accent-primary"
5205
+ }
5206
+ );
5207
+ }
5208
+ if (column.kind === "select") {
5209
+ return /* @__PURE__ */ jsxs12(
5210
+ "select",
5211
+ {
5212
+ ...shared,
5213
+ className: INPUT_CLASS,
5214
+ value: typeof value === "string" ? value : "",
5215
+ onChange: (event) => onValue(event.target.value === "" ? null : event.target.value),
5216
+ children: [
5217
+ /* @__PURE__ */ jsx14("option", { value: "", children: "\u2014" }),
5218
+ column.options.map((option) => /* @__PURE__ */ jsx14("option", { value: option.value, children: option.label }, option.value))
5219
+ ]
5220
+ }
5221
+ );
5222
+ }
5223
+ if (column.kind === "text" && column.multiline === true) {
5224
+ return /* @__PURE__ */ jsx14(
5225
+ "textarea",
5226
+ {
5227
+ ...shared,
5228
+ className: INPUT_CLASS,
5229
+ rows: 3,
5230
+ value: typeof value === "string" ? value : "",
5231
+ onChange: (event) => onValue(event.target.value === "" ? null : event.target.value)
5232
+ }
5233
+ );
5234
+ }
5235
+ if (column.kind === "number" || column.kind === "currency") {
5236
+ return /* @__PURE__ */ jsx14(
5237
+ "input",
5238
+ {
5239
+ ...shared,
5240
+ className: INPUT_CLASS,
5241
+ type: "text",
5242
+ inputMode: "decimal",
5243
+ value: value === null ? "" : String(value),
5244
+ onChange: (event) => {
5245
+ const raw = event.target.value;
5246
+ if (raw.trim() === "") {
5247
+ onValue(null);
5248
+ return;
5249
+ }
5250
+ const parsed = readRecordGridCell(column, raw);
5251
+ onValue(parsed.succeeded ? parsed.value : raw);
5252
+ }
5253
+ }
5254
+ );
5255
+ }
5256
+ return /* @__PURE__ */ jsx14(
5257
+ "input",
5258
+ {
5259
+ ...shared,
5260
+ className: INPUT_CLASS,
5261
+ type: column.kind === "date" ? "date" : "text",
5262
+ value: typeof value === "string" ? value : "",
5263
+ onChange: (event) => onValue(event.target.value === "" ? null : event.target.value)
5264
+ }
5265
+ );
5266
+ }
5267
+
3571
5268
  // src/web-react/agent-session-controls.tsx
3572
- import { useMemo as useMemo7, useState as useState13 } from "react";
3573
- import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
5269
+ import { useMemo as useMemo8, useState as useState15 } from "react";
5270
+ import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
3574
5271
  var HARNESS_LABELS = {
3575
5272
  opencode: "OpenCode (any model)",
3576
5273
  "claude-code": "Claude Code (Anthropic)",
@@ -3590,12 +5287,12 @@ function harnessLabel(h) {
3590
5287
  return HARNESS_LABELS[h] ?? h;
3591
5288
  }
3592
5289
  function ChevronDown2({ className }) {
3593
- return /* @__PURE__ */ jsx13("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx13("path", { d: "m6 9 6 6 6-6" }) });
5290
+ return /* @__PURE__ */ jsx15("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx15("path", { d: "m6 9 6 6 6-6" }) });
3594
5291
  }
3595
5292
  function GearGlyph({ className }) {
3596
- return /* @__PURE__ */ jsxs11("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
3597
- /* @__PURE__ */ jsx13("circle", { cx: "12", cy: "12", r: "3" }),
3598
- /* @__PURE__ */ jsx13("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1Z" })
5293
+ return /* @__PURE__ */ jsxs13("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
5294
+ /* @__PURE__ */ jsx15("circle", { cx: "12", cy: "12", r: "3" }),
5295
+ /* @__PURE__ */ jsx15("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1Z" })
3599
5296
  ] });
3600
5297
  }
3601
5298
  var FOCUS_RING = "focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background";
@@ -3604,11 +5301,11 @@ function HarnessPicker({
3604
5301
  onChange,
3605
5302
  available
3606
5303
  }) {
3607
- const [open, setOpen] = useState13(false);
5304
+ const [open, setOpen] = useState15(false);
3608
5305
  const { containerRef, triggerProps } = usePopover(open, setOpen);
3609
5306
  const options = available ?? Object.keys(HARNESS_LABELS);
3610
- return /* @__PURE__ */ jsxs11("div", { ref: containerRef, className: "relative inline-flex", children: [
3611
- /* @__PURE__ */ jsxs11(
5307
+ return /* @__PURE__ */ jsxs13("div", { ref: containerRef, className: "relative inline-flex", children: [
5308
+ /* @__PURE__ */ jsxs13(
3612
5309
  "button",
3613
5310
  {
3614
5311
  type: "button",
@@ -3617,12 +5314,12 @@ function HarnessPicker({
3617
5314
  title: "Agent backend",
3618
5315
  className: `inline-flex w-full items-center justify-between gap-1.5 rounded-lg border border-border bg-card px-3 py-1.5 text-sm font-medium text-foreground transition hover:bg-accent/30 ${FOCUS_RING}`,
3619
5316
  children: [
3620
- /* @__PURE__ */ jsx13("span", { className: "truncate", children: harnessLabel(value) }),
3621
- /* @__PURE__ */ jsx13(ChevronDown2, { className: "h-3.5 w-3.5 text-muted-foreground" })
5317
+ /* @__PURE__ */ jsx15("span", { className: "truncate", children: harnessLabel(value) }),
5318
+ /* @__PURE__ */ jsx15(ChevronDown2, { className: "h-3.5 w-3.5 text-muted-foreground" })
3622
5319
  ]
3623
5320
  }
3624
5321
  ),
3625
- open && /* @__PURE__ */ jsx13("div", { role: "menu", className: "absolute bottom-full left-0 z-50 mb-2 max-h-64 w-full min-w-[220px] overflow-y-auto rounded-xl border border-border bg-card p-1 shadow-lg", children: options.map((h) => /* @__PURE__ */ jsx13(
5322
+ open && /* @__PURE__ */ jsx15("div", { role: "menu", className: "absolute bottom-full left-0 z-50 mb-2 max-h-64 w-full min-w-[220px] overflow-y-auto rounded-xl border border-border bg-card p-1 shadow-lg", children: options.map((h) => /* @__PURE__ */ jsx15(
3626
5323
  "button",
3627
5324
  {
3628
5325
  type: "button",
@@ -3641,7 +5338,7 @@ function HarnessPicker({
3641
5338
  }
3642
5339
  function useCoherentHandlers(props) {
3643
5340
  const { model, models, harness, onModelChange, onHarnessChange } = props;
3644
- const canonicalIds = useMemo7(() => models.map((m) => m.id), [models]);
5341
+ const canonicalIds = useMemo8(() => models.map((m) => m.id), [models]);
3645
5342
  const onModel = (next) => {
3646
5343
  onModelChange(next);
3647
5344
  const nextHarness = snapHarnessToModel(harness, next);
@@ -3669,11 +5366,11 @@ function AgentSessionControls(props) {
3669
5366
  className
3670
5367
  } = props;
3671
5368
  const { onModel, onHarness } = useCoherentHandlers(props);
3672
- const [open, setOpen] = useState13(false);
5369
+ const [open, setOpen] = useState15(false);
3673
5370
  const { containerRef: popoverRef, triggerProps } = usePopover(open, setOpen);
3674
5371
  const selectedModel = models.find((m) => m.id === model);
3675
5372
  const showEffort = selectedModel?.supportsReasoning ?? true;
3676
- const modelPicker = /* @__PURE__ */ jsx13(
5373
+ const modelPicker = /* @__PURE__ */ jsx15(
3677
5374
  ModelPicker,
3678
5375
  {
3679
5376
  value: model,
@@ -3684,17 +5381,17 @@ function AgentSessionControls(props) {
3684
5381
  }
3685
5382
  );
3686
5383
  if (layout === "inline") {
3687
- return /* @__PURE__ */ jsxs11("div", { className: `flex items-center gap-1.5 ${className ?? ""}`, children: [
5384
+ return /* @__PURE__ */ jsxs13("div", { className: `flex items-center gap-1.5 ${className ?? ""}`, children: [
3688
5385
  modelPicker,
3689
- showHarness && /* @__PURE__ */ jsx13(HarnessPicker, { value: harness, onChange: onHarness, available: availableHarnesses }),
3690
- showEffort && /* @__PURE__ */ jsx13(EffortPicker, { value: effort, onChange: onEffortChange })
5386
+ showHarness && /* @__PURE__ */ jsx15(HarnessPicker, { value: harness, onChange: onHarness, available: availableHarnesses }),
5387
+ showEffort && /* @__PURE__ */ jsx15(EffortPicker, { value: effort, onChange: onEffortChange })
3691
5388
  ] });
3692
5389
  }
3693
5390
  const hasAdvanced = showHarness || showEffort;
3694
- return /* @__PURE__ */ jsxs11("div", { className: `flex items-center gap-1.5 ${className ?? ""}`, children: [
5391
+ return /* @__PURE__ */ jsxs13("div", { className: `flex items-center gap-1.5 ${className ?? ""}`, children: [
3695
5392
  modelPicker,
3696
- hasAdvanced && /* @__PURE__ */ jsxs11("div", { ref: popoverRef, className: "relative inline-flex", children: [
3697
- /* @__PURE__ */ jsx13(
5393
+ hasAdvanced && /* @__PURE__ */ jsxs13("div", { ref: popoverRef, className: "relative inline-flex", children: [
5394
+ /* @__PURE__ */ jsx15(
3698
5395
  "button",
3699
5396
  {
3700
5397
  type: "button",
@@ -3703,19 +5400,19 @@ function AgentSessionControls(props) {
3703
5400
  title: "Model settings \u2014 pick the agent backend and how hard it thinks",
3704
5401
  className: `flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground data-[state=open]:bg-muted ${FOCUS_RING}`,
3705
5402
  "data-state": open ? "open" : "closed",
3706
- children: /* @__PURE__ */ jsx13(GearGlyph, { className: "h-4 w-4" })
5403
+ children: /* @__PURE__ */ jsx15(GearGlyph, { className: "h-4 w-4" })
3707
5404
  }
3708
5405
  ),
3709
- open && /* @__PURE__ */ jsxs11("div", { className: "absolute bottom-full left-0 z-50 mb-2 w-72 space-y-3 rounded-xl border border-border bg-card p-3 shadow-lg", children: [
3710
- showHarness && /* @__PURE__ */ jsxs11("div", { className: "space-y-1.5", children: [
3711
- /* @__PURE__ */ jsx13("p", { className: "text-xs font-medium text-foreground", children: "Agent backend" }),
3712
- /* @__PURE__ */ jsx13(HarnessPicker, { value: harness, onChange: onHarness, available: availableHarnesses }),
3713
- /* @__PURE__ */ jsx13("p", { className: "text-[11px] leading-snug text-muted-foreground", children: "The engine that runs the agent. Switching it keeps your model choice compatible." })
5406
+ open && /* @__PURE__ */ jsxs13("div", { className: "absolute bottom-full left-0 z-50 mb-2 w-72 space-y-3 rounded-xl border border-border bg-card p-3 shadow-lg", children: [
5407
+ showHarness && /* @__PURE__ */ jsxs13("div", { className: "space-y-1.5", children: [
5408
+ /* @__PURE__ */ jsx15("p", { className: "text-xs font-medium text-foreground", children: "Agent backend" }),
5409
+ /* @__PURE__ */ jsx15(HarnessPicker, { value: harness, onChange: onHarness, available: availableHarnesses }),
5410
+ /* @__PURE__ */ jsx15("p", { className: "text-[11px] leading-snug text-muted-foreground", children: "The engine that runs the agent. Switching it keeps your model choice compatible." })
3714
5411
  ] }),
3715
- showEffort && /* @__PURE__ */ jsxs11("div", { className: "space-y-1.5", children: [
3716
- /* @__PURE__ */ jsx13("p", { className: "text-xs font-medium text-foreground", children: "Thinking" }),
3717
- /* @__PURE__ */ jsx13(EffortPicker, { value: effort, onChange: onEffortChange, label: "" }),
3718
- /* @__PURE__ */ jsx13("p", { className: "text-[11px] leading-snug text-muted-foreground", children: "How hard the agent thinks before answering. Higher is slower but more thorough." })
5412
+ showEffort && /* @__PURE__ */ jsxs13("div", { className: "space-y-1.5", children: [
5413
+ /* @__PURE__ */ jsx15("p", { className: "text-xs font-medium text-foreground", children: "Thinking" }),
5414
+ /* @__PURE__ */ jsx15(EffortPicker, { value: effort, onChange: onEffortChange, label: "" }),
5415
+ /* @__PURE__ */ jsx15("p", { className: "text-[11px] leading-snug text-muted-foreground", children: "How hard the agent thinks before answering. Higher is slower but more thorough." })
3719
5416
  ] })
3720
5417
  ] })
3721
5418
  ] })
@@ -3723,7 +5420,7 @@ function AgentSessionControls(props) {
3723
5420
  }
3724
5421
 
3725
5422
  // src/web-react/index.tsx
3726
- import { Fragment as Fragment7, jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
5423
+ import { Fragment as Fragment8, jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
3727
5424
  function formatModelCost(msg, models) {
3728
5425
  if (msg.promptTokens == null && msg.completionTokens == null) return null;
3729
5426
  const pricing = models.find((m) => m.id === msg.modelUsed)?.pricing;
@@ -3737,41 +5434,41 @@ function formatTokensPerSecond(msg) {
3737
5434
  return `${Math.round(msg.completionTokens / (msg.durationMs / 1e3))} tok/s`;
3738
5435
  }
3739
5436
  function RunDrillIn({ run, onClose }) {
3740
- return /* @__PURE__ */ jsxs12("div", { className: "fixed inset-y-0 right-0 z-50 flex w-[480px] max-w-full flex-col border-l border-border bg-card shadow-xl", children: [
3741
- /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2 border-b border-border px-4 py-3", children: [
3742
- /* @__PURE__ */ jsx14(
5437
+ return /* @__PURE__ */ jsxs14("div", { className: "fixed inset-y-0 right-0 z-50 flex w-[480px] max-w-full flex-col border-l border-border bg-card shadow-xl", children: [
5438
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2 border-b border-border px-4 py-3", children: [
5439
+ /* @__PURE__ */ jsx16(
3743
5440
  "span",
3744
5441
  {
3745
5442
  className: `h-2 w-2 shrink-0 rounded-full ${run.status === "running" ? "bg-warning" : run.status === "error" ? "bg-destructive" : "bg-success"}`
3746
5443
  }
3747
5444
  ),
3748
- /* @__PURE__ */ jsxs12("div", { className: "min-w-0 flex-1", children: [
3749
- /* @__PURE__ */ jsx14("p", { className: "truncate text-sm font-semibold", children: run.title }),
3750
- /* @__PURE__ */ jsx14("p", { className: "truncate font-mono text-[11px] text-muted-foreground", children: run.toolName })
5445
+ /* @__PURE__ */ jsxs14("div", { className: "min-w-0 flex-1", children: [
5446
+ /* @__PURE__ */ jsx16("p", { className: "truncate text-sm font-semibold", children: run.title }),
5447
+ /* @__PURE__ */ jsx16("p", { className: "truncate font-mono text-[11px] text-muted-foreground", children: run.toolName })
3751
5448
  ] }),
3752
- /* @__PURE__ */ jsx14(
5449
+ /* @__PURE__ */ jsx16(
3753
5450
  "button",
3754
5451
  {
3755
5452
  type: "button",
3756
5453
  onClick: onClose,
3757
5454
  "aria-label": "Close",
3758
5455
  className: "rounded-md p-1.5 text-muted-foreground transition hover:bg-accent/30 hover:text-foreground",
3759
- children: /* @__PURE__ */ jsx14("svg", { className: "h-4 w-4", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx14("path", { d: "M18 6 6 18M6 6l12 12" }) })
5456
+ children: /* @__PURE__ */ jsx16("svg", { className: "h-4 w-4", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx16("path", { d: "M18 6 6 18M6 6l12 12" }) })
3760
5457
  }
3761
5458
  )
3762
5459
  ] }),
3763
- /* @__PURE__ */ jsxs12("div", { className: "flex-1 space-y-3 overflow-y-auto p-4", children: [
3764
- run.steps.length === 0 && /* @__PURE__ */ jsx14("p", { className: "text-sm text-muted-foreground", children: "No steps recorded yet." }),
3765
- run.steps.map((step, i) => /* @__PURE__ */ jsxs12("div", { className: "rounded-lg border border-border/60 bg-background", children: [
3766
- /* @__PURE__ */ jsxs12("div", { className: "flex items-baseline gap-2 border-b border-border/40 px-3 py-1.5", children: [
3767
- /* @__PURE__ */ jsx14("span", { className: `font-mono text-[11px] ${step.status === "error" ? "text-destructive" : "text-muted-foreground"}`, children: step.status === "error" ? "\u2717" : "$" }),
3768
- /* @__PURE__ */ jsx14("code", { className: "min-w-0 flex-1 truncate font-mono text-xs", children: step.label }),
3769
- /* @__PURE__ */ jsx14("span", { className: "shrink-0 text-[10px] text-muted-foreground", children: new Date(step.at).toLocaleTimeString() })
5460
+ /* @__PURE__ */ jsxs14("div", { className: "flex-1 space-y-3 overflow-y-auto p-4", children: [
5461
+ run.steps.length === 0 && /* @__PURE__ */ jsx16("p", { className: "text-sm text-muted-foreground", children: "No steps recorded yet." }),
5462
+ run.steps.map((step, i) => /* @__PURE__ */ jsxs14("div", { className: "rounded-lg border border-border/60 bg-background", children: [
5463
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-baseline gap-2 border-b border-border/40 px-3 py-1.5", children: [
5464
+ /* @__PURE__ */ jsx16("span", { className: `font-mono text-[11px] ${step.status === "error" ? "text-destructive" : "text-muted-foreground"}`, children: step.status === "error" ? "\u2717" : "$" }),
5465
+ /* @__PURE__ */ jsx16("code", { className: "min-w-0 flex-1 truncate font-mono text-xs", children: step.label }),
5466
+ /* @__PURE__ */ jsx16("span", { className: "shrink-0 text-[10px] text-muted-foreground", children: new Date(step.at).toLocaleTimeString() })
3770
5467
  ] }),
3771
- step.detail && /* @__PURE__ */ jsx14("pre", { className: "max-h-48 overflow-auto whitespace-pre-wrap px-3 py-2 font-mono text-[11px] leading-relaxed text-muted-foreground", children: step.detail })
5468
+ step.detail && /* @__PURE__ */ jsx16("pre", { className: "max-h-48 overflow-auto whitespace-pre-wrap px-3 py-2 font-mono text-[11px] leading-relaxed text-muted-foreground", children: step.detail })
3772
5469
  ] }, i))
3773
5470
  ] }),
3774
- /* @__PURE__ */ jsx14("p", { className: "border-t border-border px-4 py-2 text-[11px] text-muted-foreground", children: "Readonly drill-in. Follow up in the main chat." })
5471
+ /* @__PURE__ */ jsx16("p", { className: "border-t border-border px-4 py-2 text-[11px] text-muted-foreground", children: "Readonly drill-in. Follow up in the main chat." })
3775
5472
  ] });
3776
5473
  }
3777
5474
  function pendingApprovalOf(call) {
@@ -3785,20 +5482,20 @@ function ChatEmptyState({
3785
5482
  subline = "Describe the outcome you want. The agent works through it step by step, and pauses for your approval before anything irreversible.",
3786
5483
  doors
3787
5484
  }) {
3788
- return /* @__PURE__ */ jsxs12("div", { className: "mx-auto flex w-full max-w-2xl flex-col items-center px-6 py-12 text-center sm:py-20", children: [
3789
- /* @__PURE__ */ jsx14("span", { className: "mb-5 inline-flex h-14 w-14 items-center justify-center rounded-2xl bg-primary/10 ring-1 ring-primary/15", children: /* @__PURE__ */ jsx14(BrandMark, { size: 32, className: "shrink-0" }) }),
3790
- /* @__PURE__ */ jsx14("p", { className: "text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground", children: productName }),
3791
- /* @__PURE__ */ jsx14("h2", { className: "mt-1.5 text-balance text-2xl font-semibold leading-tight text-foreground sm:text-[28px]", children: headline }),
3792
- subline && /* @__PURE__ */ jsx14("p", { className: "mt-3 max-w-md text-[15px] leading-relaxed text-muted-foreground", children: subline }),
3793
- doors && doors.length > 0 && /* @__PURE__ */ jsx14("div", { className: "mt-7 grid w-full gap-2.5 sm:grid-cols-3", children: doors.slice(0, 3).map((door, i) => /* @__PURE__ */ jsxs12(
5485
+ return /* @__PURE__ */ jsxs14("div", { className: "mx-auto flex w-full max-w-2xl flex-col items-center px-6 py-12 text-center sm:py-20", children: [
5486
+ /* @__PURE__ */ jsx16("span", { className: "mb-5 inline-flex h-14 w-14 items-center justify-center rounded-2xl bg-primary/10 ring-1 ring-primary/15", children: /* @__PURE__ */ jsx16(BrandMark, { size: 32, className: "shrink-0" }) }),
5487
+ /* @__PURE__ */ jsx16("p", { className: "text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground", children: productName }),
5488
+ /* @__PURE__ */ jsx16("h2", { className: "mt-1.5 text-balance text-2xl font-semibold leading-tight text-foreground sm:text-[28px]", children: headline }),
5489
+ subline && /* @__PURE__ */ jsx16("p", { className: "mt-3 max-w-md text-[15px] leading-relaxed text-muted-foreground", children: subline }),
5490
+ doors && doors.length > 0 && /* @__PURE__ */ jsx16("div", { className: "mt-7 grid w-full gap-2.5 sm:grid-cols-3", children: doors.slice(0, 3).map((door, i) => /* @__PURE__ */ jsxs14(
3794
5491
  "button",
3795
5492
  {
3796
5493
  type: "button",
3797
5494
  onClick: door.onSelect,
3798
5495
  className: "group flex min-h-[44px] flex-col items-start rounded-xl border border-border bg-card px-4 py-3 text-left transition hover:border-primary/40 hover:bg-accent/30 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
3799
5496
  children: [
3800
- /* @__PURE__ */ jsx14("span", { className: "text-sm font-semibold text-foreground", children: door.label }),
3801
- door.description && /* @__PURE__ */ jsx14("span", { className: "mt-0.5 text-[12px] leading-snug text-muted-foreground", children: door.description })
5497
+ /* @__PURE__ */ jsx16("span", { className: "text-sm font-semibold text-foreground", children: door.label }),
5498
+ door.description && /* @__PURE__ */ jsx16("span", { className: "mt-0.5 text-[12px] leading-snug text-muted-foreground", children: door.description })
3802
5499
  ]
3803
5500
  },
3804
5501
  i
@@ -3807,26 +5504,26 @@ function ChatEmptyState({
3807
5504
  }
3808
5505
  function ToolGlyph({ name, className }) {
3809
5506
  if (name.startsWith("sandbox_")) {
3810
- return /* @__PURE__ */ jsxs12("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
3811
- /* @__PURE__ */ jsx14("polyline", { points: "4 17 10 11 4 5" }),
3812
- /* @__PURE__ */ jsx14("line", { x1: "12", y1: "19", x2: "20", y2: "19" })
5507
+ return /* @__PURE__ */ jsxs14("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
5508
+ /* @__PURE__ */ jsx16("polyline", { points: "4 17 10 11 4 5" }),
5509
+ /* @__PURE__ */ jsx16("line", { x1: "12", y1: "19", x2: "20", y2: "19" })
3813
5510
  ] });
3814
5511
  }
3815
5512
  if (name === "submit_proposal") {
3816
- return /* @__PURE__ */ jsxs12("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
3817
- /* @__PURE__ */ jsx14("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
3818
- /* @__PURE__ */ jsx14("path", { d: "M14 2v6h6M9 15l2 2 4-4" })
5513
+ return /* @__PURE__ */ jsxs14("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
5514
+ /* @__PURE__ */ jsx16("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
5515
+ /* @__PURE__ */ jsx16("path", { d: "M14 2v6h6M9 15l2 2 4-4" })
3819
5516
  ] });
3820
5517
  }
3821
5518
  if (name === "schedule_followup") {
3822
- return /* @__PURE__ */ jsxs12("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": true, children: [
3823
- /* @__PURE__ */ jsx14("circle", { cx: "12", cy: "12", r: "9" }),
3824
- /* @__PURE__ */ jsx14("path", { d: "M12 7v5l3 3" })
5519
+ return /* @__PURE__ */ jsxs14("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": true, children: [
5520
+ /* @__PURE__ */ jsx16("circle", { cx: "12", cy: "12", r: "9" }),
5521
+ /* @__PURE__ */ jsx16("path", { d: "M12 7v5l3 3" })
3825
5522
  ] });
3826
5523
  }
3827
- return /* @__PURE__ */ jsxs12("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
3828
- /* @__PURE__ */ jsx14("path", { d: "M12 3v3m0 12v3M3 12h3m12 0h3" }),
3829
- /* @__PURE__ */ jsx14("circle", { cx: "12", cy: "12", r: "4" })
5524
+ return /* @__PURE__ */ jsxs14("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
5525
+ /* @__PURE__ */ jsx16("path", { d: "M12 3v3m0 12v3M3 12h3m12 0h3" }),
5526
+ /* @__PURE__ */ jsx16("circle", { cx: "12", cy: "12", r: "4" })
3830
5527
  ] });
3831
5528
  }
3832
5529
  function toolOutcomeOf(call) {
@@ -3894,40 +5591,40 @@ function truncate(v, max = 240) {
3894
5591
  function KvRows({ data }) {
3895
5592
  const entries = Object.entries(data).filter(([, v]) => v !== void 0 && v !== null && v !== "");
3896
5593
  if (!entries.length) return null;
3897
- return /* @__PURE__ */ jsx14("dl", { className: "grid grid-cols-[auto_1fr] gap-x-3 gap-y-1", children: entries.map(([k, v]) => /* @__PURE__ */ jsxs12("div", { className: "contents", children: [
3898
- /* @__PURE__ */ jsx14("dt", { className: "font-mono text-[11px] text-muted-foreground", children: k }),
3899
- /* @__PURE__ */ jsx14("dd", { className: "min-w-0 whitespace-pre-wrap break-words font-mono text-[11px] text-muted-foreground", children: truncate(v) })
5594
+ return /* @__PURE__ */ jsx16("dl", { className: "grid grid-cols-[auto_1fr] gap-x-3 gap-y-1", children: entries.map(([k, v]) => /* @__PURE__ */ jsxs14("div", { className: "contents", children: [
5595
+ /* @__PURE__ */ jsx16("dt", { className: "font-mono text-[11px] text-muted-foreground", children: k }),
5596
+ /* @__PURE__ */ jsx16("dd", { className: "min-w-0 whitespace-pre-wrap break-words font-mono text-[11px] text-muted-foreground", children: truncate(v) })
3900
5597
  ] }, k)) });
3901
5598
  }
3902
5599
  function ShellDetail({ call }) {
3903
5600
  const outcome = toolOutcomeOf(call);
3904
5601
  const r = outcome?.result ?? {};
3905
- return /* @__PURE__ */ jsxs12("div", { className: "overflow-hidden rounded-md bg-zinc-900 font-mono text-[11px] leading-relaxed", children: [
3906
- /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2 px-3 pt-2 text-zinc-400", children: [
3907
- /* @__PURE__ */ jsx14("span", { className: "select-none text-zinc-500", children: "$" }),
3908
- /* @__PURE__ */ jsx14("span", { className: "min-w-0 flex-1 truncate text-zinc-200", children: String(call.args?.command ?? "") }),
3909
- r.exitCode != null && /* @__PURE__ */ jsxs12("span", { className: r.exitCode === 0 ? "text-success" : "text-destructive", children: [
5602
+ return /* @__PURE__ */ jsxs14("div", { className: "overflow-hidden rounded-md bg-zinc-900 font-mono text-[11px] leading-relaxed", children: [
5603
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2 px-3 pt-2 text-zinc-400", children: [
5604
+ /* @__PURE__ */ jsx16("span", { className: "select-none text-zinc-500", children: "$" }),
5605
+ /* @__PURE__ */ jsx16("span", { className: "min-w-0 flex-1 truncate text-zinc-200", children: String(call.args?.command ?? "") }),
5606
+ r.exitCode != null && /* @__PURE__ */ jsxs14("span", { className: r.exitCode === 0 ? "text-success" : "text-destructive", children: [
3910
5607
  "exit ",
3911
5608
  r.exitCode
3912
5609
  ] })
3913
5610
  ] }),
3914
- /* @__PURE__ */ jsx14("pre", { className: "max-h-56 overflow-auto whitespace-pre-wrap px-3 pb-2.5 pt-1.5 text-zinc-300", children: outcome?.ok === false ? outcome.message ?? "failed" : [r.stdout, r.stderr].filter(Boolean).join("\n") || "(no output)" })
5611
+ /* @__PURE__ */ jsx16("pre", { className: "max-h-56 overflow-auto whitespace-pre-wrap px-3 pb-2.5 pt-1.5 text-zinc-300", children: outcome?.ok === false ? outcome.message ?? "failed" : [r.stdout, r.stderr].filter(Boolean).join("\n") || "(no output)" })
3915
5612
  ] });
3916
5613
  }
3917
5614
  function DefaultToolDetail({ call }) {
3918
5615
  const result = call.result;
3919
5616
  const envelope = typeof result === "object" && result !== null ? result : null;
3920
- return /* @__PURE__ */ jsxs12("div", { className: "space-y-2", children: [
3921
- call.args && Object.keys(call.args).length > 0 && /* @__PURE__ */ jsxs12("div", { children: [
3922
- /* @__PURE__ */ jsx14("p", { className: "mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground", children: "Called with" }),
3923
- /* @__PURE__ */ jsx14(KvRows, { data: call.args })
5617
+ return /* @__PURE__ */ jsxs14("div", { className: "space-y-2", children: [
5618
+ call.args && Object.keys(call.args).length > 0 && /* @__PURE__ */ jsxs14("div", { children: [
5619
+ /* @__PURE__ */ jsx16("p", { className: "mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground", children: "Called with" }),
5620
+ /* @__PURE__ */ jsx16(KvRows, { data: call.args })
3924
5621
  ] }),
3925
- envelope ? /* @__PURE__ */ jsxs12("div", { children: [
3926
- /* @__PURE__ */ jsx14("p", { className: "mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground", children: envelope.ok === false ? "Failed" : "Result" }),
3927
- envelope.ok === false ? /* @__PURE__ */ jsx14("p", { className: "text-xs text-destructive", children: envelope.message ?? "Tool failed" }) : envelope.result && typeof envelope.result === "object" ? /* @__PURE__ */ jsx14(KvRows, { data: envelope.result }) : envelope.result != null ? /* @__PURE__ */ jsx14("p", { className: "font-mono text-[11px] text-muted-foreground", children: truncate(envelope.result) }) : null
3928
- ] }) : result != null ? /* @__PURE__ */ jsxs12("div", { children: [
3929
- /* @__PURE__ */ jsx14("p", { className: "mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground", children: "Result" }),
3930
- /* @__PURE__ */ jsx14("p", { className: "font-mono text-[11px] text-muted-foreground", children: truncate(result) })
5622
+ envelope ? /* @__PURE__ */ jsxs14("div", { children: [
5623
+ /* @__PURE__ */ jsx16("p", { className: "mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground", children: envelope.ok === false ? "Failed" : "Result" }),
5624
+ envelope.ok === false ? /* @__PURE__ */ jsx16("p", { className: "text-xs text-destructive", children: envelope.message ?? "Tool failed" }) : envelope.result && typeof envelope.result === "object" ? /* @__PURE__ */ jsx16(KvRows, { data: envelope.result }) : envelope.result != null ? /* @__PURE__ */ jsx16("p", { className: "font-mono text-[11px] text-muted-foreground", children: truncate(envelope.result) }) : null
5625
+ ] }) : result != null ? /* @__PURE__ */ jsxs14("div", { children: [
5626
+ /* @__PURE__ */ jsx16("p", { className: "mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground", children: "Result" }),
5627
+ /* @__PURE__ */ jsx16("p", { className: "font-mono text-[11px] text-muted-foreground", children: truncate(result) })
3931
5628
  ] }) : null
3932
5629
  ] });
3933
5630
  }
@@ -3938,23 +5635,23 @@ function ProposalCard({
3938
5635
  approval,
3939
5636
  renderers
3940
5637
  }) {
3941
- const [expanded, setExpanded] = useState14(false);
5638
+ const [expanded, setExpanded] = useState16(false);
3942
5639
  const { summary, meta } = proposalPreview(call);
3943
5640
  const custom = renderers?.[call.name]?.(call, message);
3944
5641
  const { pending: deciding, run: decide } = usePending();
3945
- return /* @__PURE__ */ jsxs12("div", { className: "w-full max-w-full rounded-xl border border-warning/50 bg-warning/[0.06] text-sm shadow-sm ring-1 ring-warning/10", children: [
3946
- /* @__PURE__ */ jsxs12("div", { className: "flex items-start gap-2.5 px-4 pt-3.5", children: [
3947
- /* @__PURE__ */ jsx14("span", { className: "mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-warning/15 text-warning", children: /* @__PURE__ */ jsx14(ToolGlyph, { name: call.name, className: "h-3.5 w-3.5" }) }),
3948
- /* @__PURE__ */ jsxs12("div", { className: "min-w-0 flex-1", children: [
3949
- /* @__PURE__ */ jsx14("p", { className: "text-[10px] font-semibold uppercase tracking-wider text-warning-foreground", children: "Needs your approval" }),
3950
- /* @__PURE__ */ jsx14("p", { className: "mt-0.5 text-[15px] font-semibold leading-snug text-foreground", children: friendlyToolTitle(call) }),
3951
- summary && /* @__PURE__ */ jsx14("p", { className: "mt-1 text-[13px] leading-relaxed text-muted-foreground", children: summary }),
3952
- meta.length > 0 && /* @__PURE__ */ jsx14("div", { className: "mt-1.5 flex flex-wrap items-center gap-1.5", children: meta.map((m, i) => /* @__PURE__ */ jsx14("span", { className: "rounded-full bg-muted/60 px-2 py-0.5 text-[11px] font-medium text-muted-foreground", children: m }, i)) })
5642
+ return /* @__PURE__ */ jsxs14("div", { className: "w-full max-w-full rounded-xl border border-warning/50 bg-warning/[0.06] text-sm shadow-sm ring-1 ring-warning/10", children: [
5643
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-start gap-2.5 px-4 pt-3.5", children: [
5644
+ /* @__PURE__ */ jsx16("span", { className: "mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-warning/15 text-warning", children: /* @__PURE__ */ jsx16(ToolGlyph, { name: call.name, className: "h-3.5 w-3.5" }) }),
5645
+ /* @__PURE__ */ jsxs14("div", { className: "min-w-0 flex-1", children: [
5646
+ /* @__PURE__ */ jsx16("p", { className: "text-[10px] font-semibold uppercase tracking-wider text-warning-foreground", children: "Needs your approval" }),
5647
+ /* @__PURE__ */ jsx16("p", { className: "mt-0.5 text-[15px] font-semibold leading-snug text-foreground", children: friendlyToolTitle(call) }),
5648
+ summary && /* @__PURE__ */ jsx16("p", { className: "mt-1 text-[13px] leading-relaxed text-muted-foreground", children: summary }),
5649
+ meta.length > 0 && /* @__PURE__ */ jsx16("div", { className: "mt-1.5 flex flex-wrap items-center gap-1.5", children: meta.map((m, i) => /* @__PURE__ */ jsx16("span", { className: "rounded-full bg-muted/60 px-2 py-0.5 text-[11px] font-medium text-muted-foreground", children: m }, i)) })
3953
5650
  ] })
3954
5651
  ] }),
3955
- /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap items-center gap-2 px-4 pb-3.5 pt-3", children: [
3956
- approval ? /* @__PURE__ */ jsxs12(Fragment7, { children: [
3957
- /* @__PURE__ */ jsx14(
5652
+ /* @__PURE__ */ jsxs14("div", { className: "flex flex-wrap items-center gap-2 px-4 pb-3.5 pt-3", children: [
5653
+ approval ? /* @__PURE__ */ jsxs14(Fragment8, { children: [
5654
+ /* @__PURE__ */ jsx16(
3958
5655
  "button",
3959
5656
  {
3960
5657
  type: "button",
@@ -3964,7 +5661,7 @@ function ProposalCard({
3964
5661
  children: "Approve & run"
3965
5662
  }
3966
5663
  ),
3967
- /* @__PURE__ */ jsx14(
5664
+ /* @__PURE__ */ jsx16(
3968
5665
  "button",
3969
5666
  {
3970
5667
  type: "button",
@@ -3974,8 +5671,8 @@ function ProposalCard({
3974
5671
  children: "Reject"
3975
5672
  }
3976
5673
  )
3977
- ] }) : /* @__PURE__ */ jsx14("span", { className: "text-[12px] font-medium text-muted-foreground", children: "Awaiting approval\u2026" }),
3978
- /* @__PURE__ */ jsxs12(
5674
+ ] }) : /* @__PURE__ */ jsx16("span", { className: "text-[12px] font-medium text-muted-foreground", children: "Awaiting approval\u2026" }),
5675
+ /* @__PURE__ */ jsxs14(
3979
5676
  "button",
3980
5677
  {
3981
5678
  type: "button",
@@ -3984,23 +5681,23 @@ function ProposalCard({
3984
5681
  className: "ml-auto inline-flex items-center gap-1 rounded text-[12px] font-medium text-muted-foreground transition hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
3985
5682
  children: [
3986
5683
  expanded ? "Hide details" : "View details",
3987
- /* @__PURE__ */ jsx14(ChevronDown, { className: `h-3 w-3 transition-transform ${expanded ? "rotate-180" : ""}` })
5684
+ /* @__PURE__ */ jsx16(ChevronDown, { className: `h-3 w-3 transition-transform ${expanded ? "rotate-180" : ""}` })
3988
5685
  ]
3989
5686
  }
3990
5687
  )
3991
5688
  ] }),
3992
- expanded && /* @__PURE__ */ jsx14("div", { className: "border-t border-warning/20 px-4 py-3 text-xs", children: custom ?? /* @__PURE__ */ jsx14(DefaultToolDetail, { call }) })
5689
+ expanded && /* @__PURE__ */ jsx16("div", { className: "border-t border-warning/20 px-4 py-3 text-xs", children: custom ?? /* @__PURE__ */ jsx16(DefaultToolDetail, { call }) })
3993
5690
  ] });
3994
5691
  }
3995
5692
  function FollowupCard({ call }) {
3996
5693
  const a = call.args ?? {};
3997
5694
  const when = typeof a.when === "string" ? a.when : typeof a.at === "string" ? a.at : typeof a.schedule === "string" ? a.schedule : null;
3998
- return /* @__PURE__ */ jsxs12("div", { className: "w-fit min-w-[260px] max-w-full rounded-lg border border-border/60 border-l-2 border-l-primary/60 bg-muted/20 px-3 py-2 text-sm", children: [
3999
- /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2", children: [
4000
- /* @__PURE__ */ jsx14(ToolGlyph, { name: call.name, className: "h-3.5 w-3.5 shrink-0 text-primary/80" }),
4001
- /* @__PURE__ */ jsx14("span", { className: "min-w-0 flex-1 truncate font-medium text-foreground", children: friendlyToolTitle(call) })
5695
+ return /* @__PURE__ */ jsxs14("div", { className: "w-fit min-w-[260px] max-w-full rounded-lg border border-border/60 border-l-2 border-l-primary/60 bg-muted/20 px-3 py-2 text-sm", children: [
5696
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2", children: [
5697
+ /* @__PURE__ */ jsx16(ToolGlyph, { name: call.name, className: "h-3.5 w-3.5 shrink-0 text-primary/80" }),
5698
+ /* @__PURE__ */ jsx16("span", { className: "min-w-0 flex-1 truncate font-medium text-foreground", children: friendlyToolTitle(call) })
4002
5699
  ] }),
4003
- when && /* @__PURE__ */ jsx14("p", { className: "mt-0.5 pl-[22px] text-[12px] text-muted-foreground", children: when })
5700
+ when && /* @__PURE__ */ jsx16("p", { className: "mt-0.5 pl-[22px] text-[12px] text-muted-foreground", children: when })
4004
5701
  ] });
4005
5702
  }
4006
5703
  function ToolCallCard({
@@ -4010,13 +5707,13 @@ function ToolCallCard({
4010
5707
  onOpenRun,
4011
5708
  renderers
4012
5709
  }) {
4013
- const [expanded, setExpanded] = useState14(false);
5710
+ const [expanded, setExpanded] = useState16(false);
4014
5711
  const pending = call.status === "done" ? pendingApprovalOf(call) : null;
4015
5712
  const kind = blockKindOf(call);
4016
5713
  const failed = call.status === "error" || toolOutcomeOf(call)?.ok === false;
4017
5714
  const custom = renderers?.[call.name]?.(call, message);
4018
5715
  if (pending) {
4019
- return /* @__PURE__ */ jsx14(
5716
+ return /* @__PURE__ */ jsx16(
4020
5717
  ProposalCard,
4021
5718
  {
4022
5719
  call,
@@ -4028,16 +5725,16 @@ function ToolCallCard({
4028
5725
  );
4029
5726
  }
4030
5727
  if (kind === "followup" && !failed) {
4031
- return /* @__PURE__ */ jsx14(FollowupCard, { call });
5728
+ return /* @__PURE__ */ jsx16(FollowupCard, { call });
4032
5729
  }
4033
5730
  const isCommand = kind === "command";
4034
- return /* @__PURE__ */ jsxs12(
5731
+ return /* @__PURE__ */ jsxs14(
4035
5732
  "div",
4036
5733
  {
4037
5734
  className: `w-fit min-w-[280px] max-w-full rounded-lg border text-xs transition ${failed ? "border-destructive/40 bg-destructive/5" : "border-border/60 bg-muted/20"}`,
4038
5735
  children: [
4039
- /* @__PURE__ */ jsxs12("div", { className: "flex w-full items-center gap-2 px-3 py-2", children: [
4040
- /* @__PURE__ */ jsxs12(
5736
+ /* @__PURE__ */ jsxs14("div", { className: "flex w-full items-center gap-2 px-3 py-2", children: [
5737
+ /* @__PURE__ */ jsxs14(
4041
5738
  "button",
4042
5739
  {
4043
5740
  type: "button",
@@ -4045,14 +5742,14 @@ function ToolCallCard({
4045
5742
  "aria-expanded": expanded,
4046
5743
  className: "flex min-w-0 flex-1 items-center gap-2 rounded text-left focus:outline-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
4047
5744
  children: [
4048
- /* @__PURE__ */ jsx14(
5745
+ /* @__PURE__ */ jsx16(
4049
5746
  "span",
4050
5747
  {
4051
5748
  className: `h-2 w-2 shrink-0 rounded-full ${call.status === "running" ? "animate-pulse bg-warning" : failed ? "bg-destructive" : "bg-success"}`
4052
5749
  }
4053
5750
  ),
4054
- /* @__PURE__ */ jsx14(ToolGlyph, { name: call.name, className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
4055
- /* @__PURE__ */ jsx14(
5751
+ /* @__PURE__ */ jsx16(ToolGlyph, { name: call.name, className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
5752
+ /* @__PURE__ */ jsx16(
4056
5753
  "span",
4057
5754
  {
4058
5755
  className: `min-w-0 flex-1 truncate ${isCommand ? "font-mono text-[12px] tracking-tight text-foreground/90" : "font-medium"}`,
@@ -4062,8 +5759,8 @@ function ToolCallCard({
4062
5759
  ]
4063
5760
  }
4064
5761
  ),
4065
- /* @__PURE__ */ jsx14("span", { className: "shrink-0 text-[11px] text-muted-foreground", children: call.status === "running" ? "running\u2026" : failed ? "failed" : "done" }),
4066
- /* @__PURE__ */ jsx14(
5762
+ /* @__PURE__ */ jsx16("span", { className: "shrink-0 text-[11px] text-muted-foreground", children: call.status === "running" ? "running\u2026" : failed ? "failed" : "done" }),
5763
+ /* @__PURE__ */ jsx16(
4067
5764
  "button",
4068
5765
  {
4069
5766
  type: "button",
@@ -4071,13 +5768,13 @@ function ToolCallCard({
4071
5768
  "aria-label": expanded ? "Collapse details" : "Expand details",
4072
5769
  "aria-expanded": expanded,
4073
5770
  className: "shrink-0 rounded p-0.5 focus:outline-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
4074
- children: /* @__PURE__ */ jsx14(ChevronDown, { className: `h-3 w-3 text-muted-foreground transition-transform ${expanded ? "rotate-180" : ""}` })
5771
+ children: /* @__PURE__ */ jsx16(ChevronDown, { className: `h-3 w-3 text-muted-foreground transition-transform ${expanded ? "rotate-180" : ""}` })
4075
5772
  }
4076
5773
  )
4077
5774
  ] }),
4078
- expanded && /* @__PURE__ */ jsxs12("div", { className: "border-t border-border/40 px-3 py-2.5", children: [
4079
- custom ?? (call.name === "sandbox_run_command" ? /* @__PURE__ */ jsx14(ShellDetail, { call }) : /* @__PURE__ */ jsx14(DefaultToolDetail, { call })),
4080
- onOpenRun && call.name.startsWith("sandbox_") && /* @__PURE__ */ jsx14(
5775
+ expanded && /* @__PURE__ */ jsxs14("div", { className: "border-t border-border/40 px-3 py-2.5", children: [
5776
+ custom ?? (call.name === "sandbox_run_command" ? /* @__PURE__ */ jsx16(ShellDetail, { call }) : /* @__PURE__ */ jsx16(DefaultToolDetail, { call })),
5777
+ onOpenRun && call.name.startsWith("sandbox_") && /* @__PURE__ */ jsx16(
4081
5778
  "button",
4082
5779
  {
4083
5780
  type: "button",
@@ -4092,7 +5789,7 @@ function ToolCallCard({
4092
5789
  );
4093
5790
  }
4094
5791
  function StreamingCaret() {
4095
- return /* @__PURE__ */ jsx14(
5792
+ return /* @__PURE__ */ jsx16(
4096
5793
  "span",
4097
5794
  {
4098
5795
  className: "ml-0.5 inline-block h-[1.1em] w-[3px] translate-y-[2px] animate-pulse rounded-sm bg-foreground/70",
@@ -4108,11 +5805,11 @@ function SegmentText({
4108
5805
  messageClassName
4109
5806
  }) {
4110
5807
  const text = useSmoothText(content, streaming);
4111
- const body = useMemo8(() => renderBody(text), [renderBody, text]);
5808
+ const body = useMemo9(() => renderBody(text), [renderBody, text]);
4112
5809
  if (!content.trim() && !showCaret) return null;
4113
- return /* @__PURE__ */ jsxs12("div", { className: messageClassName, children: [
5810
+ return /* @__PURE__ */ jsxs14("div", { className: messageClassName, children: [
4114
5811
  body,
4115
- showCaret && /* @__PURE__ */ jsx14(StreamingCaret, {})
5812
+ showCaret && /* @__PURE__ */ jsx16(StreamingCaret, {})
4116
5813
  ] });
4117
5814
  }
4118
5815
  var COLLAPSE_TOOL_RUN_AT = 3;
@@ -4136,7 +5833,7 @@ function SegmentedBody({
4136
5833
  const leftoverToolCalls = (msg.toolCalls ?? []).filter(
4137
5834
  (tc) => !segmentToolIds.has(tc.id)
4138
5835
  );
4139
- const renderToolCard = (call) => /* @__PURE__ */ jsx14(
5836
+ const renderToolCard = (call) => /* @__PURE__ */ jsx16(
4140
5837
  ToolCallCard,
4141
5838
  {
4142
5839
  call,
@@ -4159,9 +5856,9 @@ function SegmentedBody({
4159
5856
  else groups.push({ kind: "tools", index: i, calls: [seg.call] });
4160
5857
  }
4161
5858
  }
4162
- return /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-2", children: [
5859
+ return /* @__PURE__ */ jsxs14("div", { className: "flex flex-col gap-2", children: [
4163
5860
  groups.map(
4164
- (g) => g.kind === "text" ? /* @__PURE__ */ jsx14(
5861
+ (g) => g.kind === "text" ? /* @__PURE__ */ jsx16(
4165
5862
  SegmentText,
4166
5863
  {
4167
5864
  content: g.content,
@@ -4171,24 +5868,24 @@ function SegmentedBody({
4171
5868
  messageClassName
4172
5869
  },
4173
5870
  `text-${g.index}`
4174
- ) : !streaming && g.calls.length >= COLLAPSE_TOOL_RUN_AT && !g.calls.some(isImportantTool) ? /* @__PURE__ */ jsxs12(
5871
+ ) : !streaming && g.calls.length >= COLLAPSE_TOOL_RUN_AT && !g.calls.some(isImportantTool) ? /* @__PURE__ */ jsxs14(
4175
5872
  "details",
4176
5873
  {
4177
5874
  className: "rounded-lg border-l-2 border-border/70 bg-muted/20 px-3 py-2",
4178
5875
  children: [
4179
- /* @__PURE__ */ jsxs12("summary", { className: "cursor-pointer select-none text-xs font-medium text-muted-foreground", children: [
5876
+ /* @__PURE__ */ jsxs14("summary", { className: "cursor-pointer select-none text-xs font-medium text-muted-foreground", children: [
4180
5877
  "Worked through ",
4181
5878
  g.calls.length,
4182
5879
  " steps"
4183
5880
  ] }),
4184
- /* @__PURE__ */ jsx14("div", { className: "mt-2 flex flex-col gap-2", children: g.calls.map(renderToolCard) })
5881
+ /* @__PURE__ */ jsx16("div", { className: "mt-2 flex flex-col gap-2", children: g.calls.map(renderToolCard) })
4185
5882
  ]
4186
5883
  },
4187
5884
  `tools-${g.index}`
4188
- ) : /* @__PURE__ */ jsx14("div", { className: "flex flex-col gap-2", children: g.calls.map(renderToolCard) }, `tools-${g.index}`)
5885
+ ) : /* @__PURE__ */ jsx16("div", { className: "flex flex-col gap-2", children: g.calls.map(renderToolCard) }, `tools-${g.index}`)
4189
5886
  ),
4190
5887
  leftoverToolCalls.map(renderToolCard),
4191
- streaming && segments[lastIndex]?.kind === "tool" && /* @__PURE__ */ jsx14(StreamingCaret, {})
5888
+ streaming && segments[lastIndex]?.kind === "tool" && /* @__PURE__ */ jsx16(StreamingCaret, {})
4192
5889
  ] });
4193
5890
  }
4194
5891
  function AssistantMessageImpl({
@@ -4208,40 +5905,40 @@ function AssistantMessageImpl({
4208
5905
  }) {
4209
5906
  const content = useSmoothText(msg.content, streaming);
4210
5907
  const reasoning = useSmoothText(msg.reasoning ?? "", streaming);
4211
- const body = useMemo8(() => renderBody(content), [renderBody, content]);
5908
+ const body = useMemo9(() => renderBody(content), [renderBody, content]);
4212
5909
  const segments = msg.segments;
4213
5910
  const hasAnswerText = content !== "" || (segments?.some((s) => s.kind === "text" && s.content.trim() !== "") ?? false);
4214
- const reasoningScrollRef = useRef9(null);
4215
- const thinkStartRef = useRef9(null);
4216
- const thinkMsRef = useRef9(null);
5911
+ const reasoningScrollRef = useRef11(null);
5912
+ const thinkStartRef = useRef11(null);
5913
+ const thinkMsRef = useRef11(null);
4217
5914
  if (streaming && reasoning && !hasAnswerText && thinkStartRef.current === null) {
4218
5915
  thinkStartRef.current = performance.now();
4219
5916
  }
4220
5917
  if (hasAnswerText && thinkStartRef.current !== null && thinkMsRef.current === null) {
4221
5918
  thinkMsRef.current = performance.now() - thinkStartRef.current;
4222
5919
  }
4223
- useEffect10(() => {
5920
+ useEffect12(() => {
4224
5921
  const el = reasoningScrollRef.current;
4225
5922
  if (el && streaming && !hasAnswerText) el.scrollTop = el.scrollHeight;
4226
5923
  }, [reasoning, streaming, hasAnswerText]);
4227
5924
  const thinkingSeconds = useThinkingSeconds(
4228
5925
  streaming && !!reasoning && !hasAnswerText
4229
5926
  );
4230
- return /* @__PURE__ */ jsxs12("div", { className: "mx-auto w-full max-w-3xl px-6 py-3", children: [
4231
- /* @__PURE__ */ jsxs12("div", { className: "mb-1 flex items-baseline gap-2 text-[11px] tracking-wide text-muted-foreground", children: [
4232
- /* @__PURE__ */ jsx14("span", { className: "font-semibold uppercase", children: agentLabel }),
4233
- msg.modelUsed && /* @__PURE__ */ jsx14("span", { className: "font-mono normal-case", children: msg.modelUsed }),
4234
- formatTokensPerSecond(msg) && /* @__PURE__ */ jsx14("span", { children: formatTokensPerSecond(msg) }),
4235
- formatModelCost(msg, models) && /* @__PURE__ */ jsx14("span", { children: formatModelCost(msg, models) })
5927
+ return /* @__PURE__ */ jsxs14("div", { className: "mx-auto w-full max-w-3xl px-6 py-3", children: [
5928
+ /* @__PURE__ */ jsxs14("div", { className: "mb-1 flex items-baseline gap-2 text-[11px] tracking-wide text-muted-foreground", children: [
5929
+ /* @__PURE__ */ jsx16("span", { className: "font-semibold uppercase", children: agentLabel }),
5930
+ msg.modelUsed && /* @__PURE__ */ jsx16("span", { className: "font-mono normal-case", children: msg.modelUsed }),
5931
+ formatTokensPerSecond(msg) && /* @__PURE__ */ jsx16("span", { children: formatTokensPerSecond(msg) }),
5932
+ formatModelCost(msg, models) && /* @__PURE__ */ jsx16("span", { children: formatModelCost(msg, models) })
4236
5933
  ] }),
4237
- reasoning && /* @__PURE__ */ jsxs12("details", { className: "mb-2 rounded-lg border-l-2 border-border/70 bg-muted/20 px-3 py-2", open: !hasAnswerText, children: [
4238
- /* @__PURE__ */ jsx14("summary", { className: "cursor-pointer select-none text-xs font-medium text-muted-foreground", children: !hasAnswerText ? /* @__PURE__ */ jsxs12("span", { className: "animate-pulse", children: [
5934
+ reasoning && /* @__PURE__ */ jsxs14("details", { className: "mb-2 rounded-lg border-l-2 border-border/70 bg-muted/20 px-3 py-2", open: !hasAnswerText, children: [
5935
+ /* @__PURE__ */ jsx16("summary", { className: "cursor-pointer select-none text-xs font-medium text-muted-foreground", children: !hasAnswerText ? /* @__PURE__ */ jsxs14("span", { className: "animate-pulse", children: [
4239
5936
  "Thinking",
4240
5937
  thinkingSeconds >= 3 ? ` \xB7 ${thinkingSeconds}s` : "\u2026"
4241
5938
  ] }) : thinkMsRef.current != null ? `Thought for ${Math.max(1, Math.round(thinkMsRef.current / 1e3))}s` : "Thought process" }),
4242
- /* @__PURE__ */ jsx14("div", { ref: reasoningScrollRef, className: "mt-2 max-h-48 overflow-y-auto whitespace-pre-wrap text-[13px] leading-relaxed text-muted-foreground", children: reasoning })
5939
+ /* @__PURE__ */ jsx16("div", { ref: reasoningScrollRef, className: "mt-2 max-h-48 overflow-y-auto whitespace-pre-wrap text-[13px] leading-relaxed text-muted-foreground", children: reasoning })
4243
5940
  ] }),
4244
- segments && segments.length > 0 ? /* @__PURE__ */ jsx14(
5941
+ segments && segments.length > 0 ? /* @__PURE__ */ jsx16(
4245
5942
  SegmentedBody,
4246
5943
  {
4247
5944
  segments,
@@ -4253,12 +5950,12 @@ function AssistantMessageImpl({
4253
5950
  toolRenderers,
4254
5951
  messageClassName
4255
5952
  }
4256
- ) : /* @__PURE__ */ jsxs12(Fragment7, { children: [
4257
- /* @__PURE__ */ jsxs12("div", { className: messageClassName, children: [
5953
+ ) : /* @__PURE__ */ jsxs14(Fragment8, { children: [
5954
+ /* @__PURE__ */ jsxs14("div", { className: messageClassName, children: [
4258
5955
  body,
4259
- streaming && content && !msg.toolCalls?.length && /* @__PURE__ */ jsx14(StreamingCaret, {})
5956
+ streaming && content && !msg.toolCalls?.length && /* @__PURE__ */ jsx16(StreamingCaret, {})
4260
5957
  ] }),
4261
- msg.toolCalls && msg.toolCalls.length > 0 && /* @__PURE__ */ jsx14("div", { className: "mt-2 flex flex-col gap-1.5", children: msg.toolCalls.map((tc) => /* @__PURE__ */ jsx14(
5958
+ msg.toolCalls && msg.toolCalls.length > 0 && /* @__PURE__ */ jsx16("div", { className: "mt-2 flex flex-col gap-1.5", children: msg.toolCalls.map((tc) => /* @__PURE__ */ jsx16(
4262
5959
  ToolCallCard,
4263
5960
  {
4264
5961
  call: tc,
@@ -4270,7 +5967,7 @@ function AssistantMessageImpl({
4270
5967
  tc.id
4271
5968
  )) })
4272
5969
  ] }),
4273
- durableCards && msg.parts && /* @__PURE__ */ jsx14(
5970
+ durableCards && msg.parts && /* @__PURE__ */ jsx16(
4274
5971
  DurableChatCards,
4275
5972
  {
4276
5973
  ...durableCards,
@@ -4279,7 +5976,7 @@ function AssistantMessageImpl({
4279
5976
  className: "mt-3"
4280
5977
  }
4281
5978
  ),
4282
- workProductCards && workProductPartsFromMessageParts(msg.parts).map((part) => /* @__PURE__ */ jsx14(
5979
+ workProductCards && workProductPartsFromMessageParts(msg.parts).map((part) => /* @__PURE__ */ jsx16(
4283
5980
  WorkProductCard,
4284
5981
  {
4285
5982
  part,
@@ -4289,7 +5986,7 @@ function AssistantMessageImpl({
4289
5986
  `${part.ref.id}:${part.ref.version}`
4290
5987
  )),
4291
5988
  renderExtras?.(msg),
4292
- resolveAttachmentUrl && attachmentPartsFromMessageParts(msg.parts).length > 0 && /* @__PURE__ */ jsx14("div", { className: "mt-2", children: /* @__PURE__ */ jsx14(
5989
+ resolveAttachmentUrl && attachmentPartsFromMessageParts(msg.parts).length > 0 && /* @__PURE__ */ jsx16("div", { className: "mt-2", children: /* @__PURE__ */ jsx16(
4293
5990
  MessageAttachments,
4294
5991
  {
4295
5992
  parts: attachmentPartsFromMessageParts(msg.parts),
@@ -4301,8 +5998,8 @@ function AssistantMessageImpl({
4301
5998
  }
4302
5999
  var AssistantMessage = memo(AssistantMessageImpl);
4303
6000
  function useThinkingSeconds(active) {
4304
- const [seconds, setSeconds] = useState14(0);
4305
- useEffect10(() => {
6001
+ const [seconds, setSeconds] = useState16(0);
6002
+ useEffect12(() => {
4306
6003
  if (!active) return;
4307
6004
  setSeconds(0);
4308
6005
  const id = setInterval(() => setSeconds((s) => s + 1), 1e3);
@@ -4312,23 +6009,23 @@ function useThinkingSeconds(active) {
4312
6009
  }
4313
6010
  function ThinkingRow({ agentLabel }) {
4314
6011
  const seconds = useThinkingSeconds(true);
4315
- return /* @__PURE__ */ jsxs12("div", { className: "mx-auto w-full max-w-3xl px-6 py-3", children: [
4316
- /* @__PURE__ */ jsx14("p", { className: "mb-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: agentLabel }),
4317
- /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2 text-base text-muted-foreground", children: [
4318
- /* @__PURE__ */ jsx14("svg", { className: "h-4 w-4 animate-spin", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": true, children: /* @__PURE__ */ jsx14("path", { d: "M21 12a9 9 0 1 1-6.219-8.56", strokeLinecap: "round" }) }),
6012
+ return /* @__PURE__ */ jsxs14("div", { className: "mx-auto w-full max-w-3xl px-6 py-3", children: [
6013
+ /* @__PURE__ */ jsx16("p", { className: "mb-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: agentLabel }),
6014
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2 text-base text-muted-foreground", children: [
6015
+ /* @__PURE__ */ jsx16("svg", { className: "h-4 w-4 animate-spin", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": true, children: /* @__PURE__ */ jsx16("path", { d: "M21 12a9 9 0 1 1-6.219-8.56", strokeLinecap: "round" }) }),
4319
6016
  "Thinking",
4320
6017
  seconds >= 3 ? ` \xB7 ${seconds}s` : "..."
4321
6018
  ] })
4322
6019
  ] });
4323
6020
  }
4324
6021
  function StreamErrorRow({ message, onRetry }) {
4325
- return /* @__PURE__ */ jsx14("div", { className: "mx-auto w-full max-w-3xl px-6 py-3", children: /* @__PURE__ */ jsxs12("div", { role: "alert", className: "flex items-start gap-2.5 rounded-lg border border-destructive/40 bg-destructive/5 px-3 py-2.5 text-sm text-destructive", children: [
4326
- /* @__PURE__ */ jsxs12("svg", { className: "mt-0.5 h-4 w-4 shrink-0", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
4327
- /* @__PURE__ */ jsx14("circle", { cx: "12", cy: "12", r: "9" }),
4328
- /* @__PURE__ */ jsx14("path", { d: "M12 8v4m0 4h.01" })
6022
+ return /* @__PURE__ */ jsx16("div", { className: "mx-auto w-full max-w-3xl px-6 py-3", children: /* @__PURE__ */ jsxs14("div", { role: "alert", className: "flex items-start gap-2.5 rounded-lg border border-destructive/40 bg-destructive/5 px-3 py-2.5 text-sm text-destructive", children: [
6023
+ /* @__PURE__ */ jsxs14("svg", { className: "mt-0.5 h-4 w-4 shrink-0", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
6024
+ /* @__PURE__ */ jsx16("circle", { cx: "12", cy: "12", r: "9" }),
6025
+ /* @__PURE__ */ jsx16("path", { d: "M12 8v4m0 4h.01" })
4329
6026
  ] }),
4330
- /* @__PURE__ */ jsx14("span", { className: "min-w-0 flex-1 break-words", children: message }),
4331
- onRetry && /* @__PURE__ */ jsx14(
6027
+ /* @__PURE__ */ jsx16("span", { className: "min-w-0 flex-1 break-words", children: message }),
6028
+ onRetry && /* @__PURE__ */ jsx16(
4332
6029
  "button",
4333
6030
  {
4334
6031
  type: "button",
@@ -4361,31 +6058,31 @@ function ChatMessages({
4361
6058
  workProductCards
4362
6059
  }) {
4363
6060
  const messageClassName = messageSize === "large" ? "agent-app-message-copy text-[17px] leading-[1.75]" : "agent-app-message-copy text-base leading-[1.75]";
4364
- const renderBody = useMemo8(
4365
- () => renderMarkdown ?? ((content) => /* @__PURE__ */ jsx14("p", { className: "whitespace-pre-wrap", children: content })),
6061
+ const renderBody = useMemo9(
6062
+ () => renderMarkdown ?? ((content) => /* @__PURE__ */ jsx16("p", { className: "whitespace-pre-wrap", children: content })),
4366
6063
  [renderMarkdown]
4367
6064
  );
4368
6065
  const lastIsUser = messages[messages.length - 1]?.role === "user";
4369
6066
  if (messages.length === 0 && !loading && !error) {
4370
- const empty = renderEmpty ? renderEmpty() : /* @__PURE__ */ jsx14(ChatEmptyState, { ...emptyState });
4371
- return /* @__PURE__ */ jsxs12(Fragment7, { children: [
6067
+ const empty = renderEmpty ? renderEmpty() : /* @__PURE__ */ jsx16(ChatEmptyState, { ...emptyState });
6068
+ return /* @__PURE__ */ jsxs14(Fragment8, { children: [
4372
6069
  header,
4373
6070
  empty
4374
6071
  ] });
4375
6072
  }
4376
- return /* @__PURE__ */ jsxs12(Fragment7, { children: [
6073
+ return /* @__PURE__ */ jsxs14(Fragment8, { children: [
4377
6074
  header,
4378
6075
  messages.map(
4379
- (msg) => msg.role === "user" ? /* @__PURE__ */ jsx14("div", { className: "mx-auto w-full max-w-3xl px-6 py-3", children: /* @__PURE__ */ jsxs12("div", { className: "ml-auto w-fit max-w-[85%]", children: [
4380
- /* @__PURE__ */ jsx14("p", { className: "mb-1 text-right text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: userLabel }),
4381
- /* @__PURE__ */ jsx14(
6076
+ (msg) => msg.role === "user" ? /* @__PURE__ */ jsx16("div", { className: "mx-auto w-full max-w-3xl px-6 py-3", children: /* @__PURE__ */ jsxs14("div", { className: "ml-auto w-fit max-w-[85%]", children: [
6077
+ /* @__PURE__ */ jsx16("p", { className: "mb-1 text-right text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: userLabel }),
6078
+ /* @__PURE__ */ jsx16(
4382
6079
  "div",
4383
6080
  {
4384
6081
  className: `rounded-2xl rounded-tr-md bg-primary/10 px-4 py-2.5 ${messageClassName}`,
4385
- children: /* @__PURE__ */ jsx14("p", { className: "whitespace-pre-wrap", children: msg.content })
6082
+ children: /* @__PURE__ */ jsx16("p", { className: "whitespace-pre-wrap", children: msg.content })
4386
6083
  }
4387
6084
  ),
4388
- resolveAttachmentUrl && attachmentPartsFromMessageParts(msg.parts).length > 0 && /* @__PURE__ */ jsx14("div", { className: "mt-1.5", children: /* @__PURE__ */ jsx14(
6085
+ resolveAttachmentUrl && attachmentPartsFromMessageParts(msg.parts).length > 0 && /* @__PURE__ */ jsx16("div", { className: "mt-1.5", children: /* @__PURE__ */ jsx16(
4389
6086
  MessageAttachments,
4390
6087
  {
4391
6088
  parts: attachmentPartsFromMessageParts(msg.parts),
@@ -4393,7 +6090,7 @@ function ChatMessages({
4393
6090
  justify: "end"
4394
6091
  }
4395
6092
  ) })
4396
- ] }) }, msg.id) : /* @__PURE__ */ jsx14(
6093
+ ] }) }, msg.id) : /* @__PURE__ */ jsx16(
4397
6094
  AssistantMessage,
4398
6095
  {
4399
6096
  msg,
@@ -4413,8 +6110,8 @@ function ChatMessages({
4413
6110
  msg.id
4414
6111
  )
4415
6112
  ),
4416
- loading && lastIsUser && /* @__PURE__ */ jsx14(ThinkingRow, { agentLabel }),
4417
- error && !loading && /* @__PURE__ */ jsx14(StreamErrorRow, { message: error, onRetry })
6113
+ loading && lastIsUser && /* @__PURE__ */ jsx16(ThinkingRow, { agentLabel }),
6114
+ error && !loading && /* @__PURE__ */ jsx16(StreamErrorRow, { message: error, onRetry })
4418
6115
  ] });
4419
6116
  }
4420
6117
 
@@ -4484,12 +6181,51 @@ export {
4484
6181
  FlowWaterfall,
4485
6182
  MissionActivityLane,
4486
6183
  AgentActivityPanel,
6184
+ PROVENANCE_BASES,
6185
+ provenanceBasisMeta,
6186
+ provenanceStandingMeta,
6187
+ weakerProvenanceStanding,
6188
+ DEFAULT_PROVENANCE_CONFIDENCE_POLICY,
6189
+ standingFromConfidence,
6190
+ describeProvenanceSourceStatus,
6191
+ provenanceGaps,
6192
+ loadingProvenanceSources,
6193
+ resolveProvenanceStanding,
6194
+ rollUpProvenanceStanding,
6195
+ describeProvenance,
6196
+ provenanceNextMove,
6197
+ provenanceTriggerLabel,
6198
+ ProvenanceValue,
6199
+ ProvenanceLegend,
4487
6200
  SeatPaywall,
4488
6201
  useInfiniteScroll,
4489
6202
  useSessionHistory,
4490
6203
  useSessionActions,
4491
6204
  formatSessionTimestamp,
4492
6205
  SessionHistoryPanel,
6206
+ recordGridOk,
6207
+ recordGridFail,
6208
+ isRecordGridCellApplicable,
6209
+ sameRecordGridValue,
6210
+ parseRecordGridInput,
6211
+ validateRecordGridCell,
6212
+ readRecordGridCell,
6213
+ validateRecordGridRow,
6214
+ formatRecordGridValue,
6215
+ recordGridEditorText,
6216
+ recordGridRowLabel,
6217
+ sumRecordGridColumn,
6218
+ EMPTY_RECORD_GRID_OVERLAY,
6219
+ projectRecordGridRows,
6220
+ withRecordGridUpdate,
6221
+ withoutRecordGridUpdate,
6222
+ withRecordGridServerRow,
6223
+ withRecordGridCreated,
6224
+ withoutRecordGridCreated,
6225
+ withRecordGridRemoved,
6226
+ withoutRecordGridRemoved,
6227
+ pruneRecordGridOverlay,
6228
+ RecordGrid,
4493
6229
  AgentSessionControls,
4494
6230
  formatModelCost,
4495
6231
  formatTokensPerSecond,
@@ -4499,4 +6235,4 @@ export {
4499
6235
  useThinkingSeconds,
4500
6236
  ChatMessages
4501
6237
  };
4502
- //# sourceMappingURL=chunk-AH3IOSWF.js.map
6238
+ //# sourceMappingURL=chunk-7PFFFRVU.js.map