@tangle-network/agent-app 0.45.20 → 0.45.22

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 (113) 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 +22 -5
  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-PAB253MA.js → chunk-7V2I3JGZ.js} +19 -3
  16. package/dist/chunk-7V2I3JGZ.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-AH3IOSWF.js → chunk-NZVBJM73.js} +1432 -187
  26. package/dist/chunk-NZVBJM73.js.map +1 -0
  27. package/dist/{chunk-OO4DROKM.js → chunk-OASVAPRL.js} +3 -3
  28. package/dist/{chunk-ZSGTG6PK.js → chunk-P5PIAQVS.js} +2 -2
  29. package/dist/chunk-PC2WYTK7.js +405 -0
  30. package/dist/chunk-PC2WYTK7.js.map +1 -0
  31. package/dist/{chunk-YEFFHORB.js → chunk-TX6S7XXU.js} +8 -2
  32. package/dist/chunk-TX6S7XXU.js.map +1 -0
  33. package/dist/chunk-UGWQLQDS.js +35 -0
  34. package/dist/chunk-UGWQLQDS.js.map +1 -0
  35. package/dist/{chunk-O22STZ3P.js → chunk-X5DQ5QOP.js} +2 -2
  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/{mcp-BiKqnsJV.d.ts → mcp-xxoZZfor.d.ts} +2 -2
  51. package/dist/openui/index.d.ts +208 -0
  52. package/dist/openui/index.js +350 -0
  53. package/dist/openui/index.js.map +1 -0
  54. package/dist/openui-react/index.d.ts +119 -0
  55. package/dist/openui-react/index.js +149 -0
  56. package/dist/openui-react/index.js.map +1 -0
  57. package/dist/platform/index.js +2 -2
  58. package/dist/preset-cloudflare/index.d.ts +2 -2
  59. package/dist/rate-limit-BOVmJRXZ.d.ts +35 -0
  60. package/dist/record/drizzle.d.ts +682 -0
  61. package/dist/record/drizzle.js +579 -0
  62. package/dist/record/drizzle.js.map +1 -0
  63. package/dist/record/index.d.ts +16 -0
  64. package/dist/record/index.js +35 -0
  65. package/dist/record/index.js.map +1 -0
  66. package/dist/runtime/index.d.ts +3 -3
  67. package/dist/sandbox/index.d.ts +13 -4
  68. package/dist/sandbox/index.js +6 -3
  69. package/dist/sequences/index.d.ts +3 -3
  70. package/dist/sequences/index.js +1 -1
  71. package/dist/session-shell/index.d.ts +173 -1
  72. package/dist/session-shell/index.js +13 -1
  73. package/dist/teams/index.js +9 -9
  74. package/dist/teams/invitations-api.js +3 -3
  75. package/dist/tools/index.d.ts +5 -5
  76. package/dist/tools/index.js +3 -2
  77. package/dist/{types-DbU-oO5h.d.ts → types-B25Mib1r.d.ts} +11 -0
  78. package/dist/types-DrBidf3O.d.ts +123 -0
  79. package/dist/values-C7RidJuI.d.ts +156 -0
  80. package/dist/web/index.d.ts +197 -31
  81. package/dist/web/index.js +15 -3
  82. package/dist/web-react/async/index.d.ts +309 -0
  83. package/dist/web-react/async/index.js +327 -0
  84. package/dist/web-react/async/index.js.map +1 -0
  85. package/dist/web-react/index.d.ts +338 -2
  86. package/dist/web-react/index.js +52 -6
  87. package/dist/work-product/index.d.ts +1 -1
  88. package/dist/work-product/index.js +2 -1
  89. package/dist/work-product/index.js.map +1 -1
  90. package/dist/workspace-react/index.js +1 -1
  91. package/package.json +43 -3
  92. package/dist/DesignCanvas-NEIW3AER.js +0 -10
  93. package/dist/DesignCanvasEditor-QD33OI2W.js +0 -13
  94. package/dist/chunk-AH3IOSWF.js.map +0 -1
  95. package/dist/chunk-GINKOZFD.js +0 -214
  96. package/dist/chunk-GINKOZFD.js.map +0 -1
  97. package/dist/chunk-J25RST7G.js +0 -126
  98. package/dist/chunk-J25RST7G.js.map +0 -1
  99. package/dist/chunk-PAB253MA.js.map +0 -1
  100. package/dist/chunk-WBHPN5DY.js +0 -158
  101. package/dist/chunk-WBHPN5DY.js.map +0 -1
  102. package/dist/chunk-YEFFHORB.js.map +0 -1
  103. /package/dist/{DesignCanvas-NEIW3AER.js.map → DesignCanvas-ZG7DJS7C.js.map} +0 -0
  104. /package/dist/{DesignCanvasEditor-QD33OI2W.js.map → DesignCanvasEditor-SLFMHOII.js.map} +0 -0
  105. /package/dist/{chunk-KPRBFNGT.js.map → chunk-3IHYJIDJ.js.map} +0 -0
  106. /package/dist/{chunk-MYS7DHMM.js.map → chunk-4QVG4WJQ.js.map} +0 -0
  107. /package/dist/{chunk-RMHZKMQ4.js.map → chunk-73CQJOIU.js.map} +0 -0
  108. /package/dist/{chunk-U4BXAZCN.js.map → chunk-DRB77FYL.js.map} +0 -0
  109. /package/dist/{chunk-6MUJROBT.js.map → chunk-E4DHYENH.js.map} +0 -0
  110. /package/dist/{chunk-OO4DROKM.js.map → chunk-OASVAPRL.js.map} +0 -0
  111. /package/dist/{chunk-ZSGTG6PK.js.map → chunk-P5PIAQVS.js.map} +0 -0
  112. /package/dist/{chunk-O22STZ3P.js.map → chunk-X5DQ5QOP.js.map} +0 -0
  113. /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 useEffect11, useMemo as useMemo9, useRef as useRef10, useState as useState15, memo } from "react";
40
40
 
41
41
  // src/web-react/smooth-text.ts
42
42
  import { useEffect, useRef, useState } from "react";
@@ -3568,9 +3568,1231 @@ function SessionRow({
3568
3568
  ] });
3569
3569
  }
3570
3570
 
3571
- // src/web-react/agent-session-controls.tsx
3572
- import { useMemo as useMemo7, useState as useState13 } from "react";
3571
+ // src/web-react/record-grid.tsx
3572
+ import {
3573
+ Fragment as Fragment7,
3574
+ useCallback as useCallback8,
3575
+ useEffect as useEffect10,
3576
+ useId,
3577
+ useMemo as useMemo7,
3578
+ useRef as useRef9,
3579
+ useState as useState13
3580
+ } from "react";
3581
+
3582
+ // src/web-react/record-grid-model.ts
3583
+ function recordGridOk(value) {
3584
+ return { succeeded: true, value };
3585
+ }
3586
+ function recordGridFail(error) {
3587
+ return { succeeded: false, error };
3588
+ }
3589
+ function isRecordGridCellApplicable(column, values) {
3590
+ const dependency = column.dependsOn;
3591
+ if (!dependency) return true;
3592
+ const held = values[dependency.column] ?? null;
3593
+ return sameRecordGridValue(held, dependency.equals);
3594
+ }
3595
+ function sameRecordGridValue(a, b) {
3596
+ return Object.is(a ?? null, b ?? null);
3597
+ }
3598
+ var NUMERIC = /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/;
3599
+ var ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
3600
+ function parseNumericText(raw) {
3601
+ const trimmed = raw.trim();
3602
+ if (trimmed === "") return { empty: true };
3603
+ const parenthesized = /^\(.+\)$/.test(trimmed);
3604
+ const body = (parenthesized ? trimmed.slice(1, -1).trim() : trimmed).replace(/[\s,]/g, "").replace(/^([+-]?)\p{Sc}/u, "$1");
3605
+ if (!NUMERIC.test(body)) return { invalid: true };
3606
+ const parsed = Number(body);
3607
+ if (!Number.isFinite(parsed)) return { invalid: true };
3608
+ return { value: parenthesized ? -parsed : parsed };
3609
+ }
3610
+ function isCalendarDate(text) {
3611
+ if (!ISO_DATE.test(text)) return false;
3612
+ const [year, month, day] = text.split("-").map((part) => Number(part));
3613
+ if (month === void 0 || day === void 0 || year === void 0) return false;
3614
+ if (month < 1 || month > 12 || day < 1) return false;
3615
+ const stamp = Date.UTC(year, month - 1, day);
3616
+ const date = new Date(stamp);
3617
+ return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
3618
+ }
3619
+ function parseRecordGridInput(column, raw) {
3620
+ switch (column.kind) {
3621
+ case "text": {
3622
+ const trimmed = raw.trim();
3623
+ return recordGridOk(trimmed === "" ? null : trimmed);
3624
+ }
3625
+ case "select": {
3626
+ const trimmed = raw.trim();
3627
+ return recordGridOk(trimmed === "" ? null : trimmed);
3628
+ }
3629
+ case "boolean": {
3630
+ const trimmed = raw.trim().toLowerCase();
3631
+ if (trimmed === "") return recordGridOk(null);
3632
+ if (trimmed === "true") return recordGridOk(true);
3633
+ if (trimmed === "false") return recordGridOk(false);
3634
+ return recordGridFail(`${column.header} must be true or false \u2014 got \u201C${raw}\u201D.`);
3635
+ }
3636
+ case "date": {
3637
+ const trimmed = raw.trim();
3638
+ if (trimmed === "") return recordGridOk(null);
3639
+ if (!isCalendarDate(trimmed)) {
3640
+ return recordGridFail(`${column.header} must be a date in YYYY-MM-DD form \u2014 got \u201C${raw}\u201D.`);
3641
+ }
3642
+ return recordGridOk(trimmed);
3643
+ }
3644
+ case "number":
3645
+ case "currency": {
3646
+ const parsed = parseNumericText(raw);
3647
+ if ("empty" in parsed) return recordGridOk(null);
3648
+ if ("invalid" in parsed) return recordGridFail(`${column.header} must be a number \u2014 got \u201C${raw}\u201D.`);
3649
+ return recordGridOk(parsed.value);
3650
+ }
3651
+ }
3652
+ }
3653
+ function describeOptions(column) {
3654
+ return column.options.map((option) => option.label).join(", ");
3655
+ }
3656
+ function validateRecordGridCell(column, value) {
3657
+ const normalized = value === "" ? null : value;
3658
+ if (normalized === null) {
3659
+ if (column.required) return recordGridFail(`${column.header} is required.`);
3660
+ const custom2 = column.validate?.(null);
3661
+ return custom2 === void 0 || custom2 === null ? recordGridOk(null) : recordGridFail(custom2);
3662
+ }
3663
+ switch (column.kind) {
3664
+ case "text": {
3665
+ if (typeof normalized !== "string") return recordGridFail(`${column.header} must be text.`);
3666
+ if (column.minLength !== void 0 && normalized.length < column.minLength) {
3667
+ return recordGridFail(`${column.header} must be at least ${column.minLength} characters \u2014 got ${normalized.length}.`);
3668
+ }
3669
+ if (column.maxLength !== void 0 && normalized.length > column.maxLength) {
3670
+ return recordGridFail(`${column.header} must be at most ${column.maxLength} characters \u2014 got ${normalized.length}.`);
3671
+ }
3672
+ if (column.pattern && !column.pattern.test(normalized)) {
3673
+ return recordGridFail(column.patternMessage ?? `${column.header} does not match ${column.pattern.source}.`);
3674
+ }
3675
+ break;
3676
+ }
3677
+ case "number":
3678
+ case "currency": {
3679
+ if (typeof normalized !== "number" || !Number.isFinite(normalized)) {
3680
+ return recordGridFail(`${column.header} must be a number.`);
3681
+ }
3682
+ if (column.kind === "number" && column.integer === true && !Number.isInteger(normalized)) {
3683
+ return recordGridFail(`${column.header} must be a whole number \u2014 got ${normalized}.`);
3684
+ }
3685
+ if (column.min !== void 0 && normalized < column.min) {
3686
+ return recordGridFail(`${column.header} must be at least ${column.min} \u2014 got ${normalized}.`);
3687
+ }
3688
+ if (column.max !== void 0 && normalized > column.max) {
3689
+ return recordGridFail(`${column.header} must be at most ${column.max} \u2014 got ${normalized}.`);
3690
+ }
3691
+ break;
3692
+ }
3693
+ case "date": {
3694
+ if (typeof normalized !== "string" || !isCalendarDate(normalized)) {
3695
+ return recordGridFail(`${column.header} must be a date in YYYY-MM-DD form.`);
3696
+ }
3697
+ if (column.min !== void 0 && normalized < column.min) {
3698
+ return recordGridFail(`${column.header} must be on or after ${column.min} \u2014 got ${normalized}.`);
3699
+ }
3700
+ if (column.max !== void 0 && normalized > column.max) {
3701
+ return recordGridFail(`${column.header} must be on or before ${column.max} \u2014 got ${normalized}.`);
3702
+ }
3703
+ break;
3704
+ }
3705
+ case "select": {
3706
+ if (typeof normalized !== "string") return recordGridFail(`${column.header} must be one of: ${describeOptions(column)}.`);
3707
+ if (!column.options.some((option) => option.value === normalized)) {
3708
+ return recordGridFail(`${column.header} must be one of: ${describeOptions(column)} \u2014 got \u201C${normalized}\u201D.`);
3709
+ }
3710
+ break;
3711
+ }
3712
+ case "boolean": {
3713
+ if (typeof normalized !== "boolean") return recordGridFail(`${column.header} must be true or false.`);
3714
+ break;
3715
+ }
3716
+ }
3717
+ const custom = column.validate?.(normalized);
3718
+ if (custom !== void 0 && custom !== null) return recordGridFail(custom);
3719
+ return recordGridOk(normalized);
3720
+ }
3721
+ function readRecordGridCell(column, raw) {
3722
+ const parsed = parseRecordGridInput(column, raw);
3723
+ if (!parsed.succeeded) return parsed;
3724
+ return validateRecordGridCell(column, parsed.value);
3725
+ }
3726
+ function validateRecordGridRow(columns, values) {
3727
+ const accepted = {};
3728
+ const cellErrors = {};
3729
+ let firstError = null;
3730
+ for (const column of columns) {
3731
+ if (!isRecordGridCellApplicable(column, values)) {
3732
+ accepted[column.id] = null;
3733
+ continue;
3734
+ }
3735
+ const outcome = validateRecordGridCell(column, values[column.id] ?? null);
3736
+ if (outcome.succeeded) {
3737
+ accepted[column.id] = outcome.value;
3738
+ continue;
3739
+ }
3740
+ cellErrors[column.id] = outcome.error;
3741
+ if (firstError === null) firstError = outcome.error;
3742
+ }
3743
+ if (firstError !== null) {
3744
+ const count = Object.keys(cellErrors).length;
3745
+ const error = count === 1 ? firstError : `${count} fields need attention. ${firstError}`;
3746
+ return { succeeded: false, error, cellErrors };
3747
+ }
3748
+ return { succeeded: true, value: accepted };
3749
+ }
3750
+ function formatRecordGridValue(column, value, locale) {
3751
+ if (value === null || value === "") return "";
3752
+ switch (column.kind) {
3753
+ case "currency": {
3754
+ if (typeof value !== "number") return String(value);
3755
+ return new Intl.NumberFormat(locale, {
3756
+ style: "currency",
3757
+ currency: column.currency,
3758
+ ...column.fractionDigits === void 0 ? {} : { minimumFractionDigits: column.fractionDigits, maximumFractionDigits: column.fractionDigits }
3759
+ }).format(value);
3760
+ }
3761
+ case "number": {
3762
+ if (typeof value !== "number") return String(value);
3763
+ return new Intl.NumberFormat(locale).format(value);
3764
+ }
3765
+ case "date": {
3766
+ if (typeof value !== "string" || !isCalendarDate(value)) return String(value);
3767
+ return new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeZone: "UTC" }).format(
3768
+ /* @__PURE__ */ new Date(`${value}T00:00:00Z`)
3769
+ );
3770
+ }
3771
+ case "select": {
3772
+ const option = column.options.find((candidate) => candidate.value === value);
3773
+ return option ? option.label : String(value);
3774
+ }
3775
+ case "boolean": {
3776
+ if (typeof value !== "boolean") return String(value);
3777
+ return value ? column.trueLabel ?? "Yes" : column.falseLabel ?? "No";
3778
+ }
3779
+ case "text":
3780
+ return String(value);
3781
+ }
3782
+ }
3783
+ function recordGridEditorText(column, value) {
3784
+ if (value === null) return "";
3785
+ if (column.kind === "boolean") return value === true ? "true" : "false";
3786
+ return String(value);
3787
+ }
3788
+ function recordGridRowLabel(columns, row) {
3789
+ if (row.label !== void 0 && row.label !== "") return row.label;
3790
+ for (const column of columns) {
3791
+ if (column.kind !== "text" && column.kind !== "select") continue;
3792
+ const value = row.values[column.id];
3793
+ if (typeof value === "string" && value !== "") return formatRecordGridValue(column, value);
3794
+ }
3795
+ return row.id;
3796
+ }
3797
+ function sumRecordGridColumn(rows, columnId) {
3798
+ let total = 0;
3799
+ for (const row of rows) {
3800
+ const value = row.values[columnId];
3801
+ if (typeof value === "number" && Number.isFinite(value)) total += value;
3802
+ }
3803
+ return total;
3804
+ }
3805
+ var EMPTY_RECORD_GRID_OVERLAY = { updates: {}, created: [], removed: [] };
3806
+ function projectRecordGridRows(rows, overlay) {
3807
+ const removed = new Set(overlay.removed);
3808
+ const projected = [];
3809
+ for (const row of rows) {
3810
+ if (removed.has(row.id)) continue;
3811
+ const patch = overlay.updates[row.id];
3812
+ projected.push(patch === void 0 ? row : { ...row, values: { ...row.values, ...patch } });
3813
+ }
3814
+ for (const row of overlay.created) {
3815
+ if (removed.has(row.id)) continue;
3816
+ const patch = overlay.updates[row.id];
3817
+ projected.push(patch === void 0 ? row : { ...row, values: { ...row.values, ...patch } });
3818
+ }
3819
+ return projected;
3820
+ }
3821
+ function withRecordGridUpdate(overlay, rowId, columnId, value) {
3822
+ const rowPatch = { ...overlay.updates[rowId] ?? {}, [columnId]: value };
3823
+ return { ...overlay, updates: { ...overlay.updates, [rowId]: rowPatch } };
3824
+ }
3825
+ function withoutRecordGridUpdate(overlay, rowId, columnId) {
3826
+ const rowPatch = overlay.updates[rowId];
3827
+ if (rowPatch === void 0 || !(columnId in rowPatch)) return overlay;
3828
+ const nextPatch = {};
3829
+ for (const [key, value] of Object.entries(rowPatch)) {
3830
+ if (key !== columnId) nextPatch[key] = value;
3831
+ }
3832
+ const updates = { ...overlay.updates };
3833
+ if (Object.keys(nextPatch).length === 0) delete updates[rowId];
3834
+ else updates[rowId] = nextPatch;
3835
+ return { ...overlay, updates };
3836
+ }
3837
+ function withRecordGridServerRow(overlay, draftId, row) {
3838
+ const createdIndex = overlay.created.findIndex((candidate) => candidate.id === draftId);
3839
+ if (createdIndex >= 0) {
3840
+ const created = [...overlay.created];
3841
+ created[createdIndex] = row;
3842
+ return { ...overlay, created, updates: withoutRowUpdates(overlay.updates, draftId, row.id) };
3843
+ }
3844
+ return { ...overlay, updates: { ...overlay.updates, [row.id]: { ...row.values } } };
3845
+ }
3846
+ function withoutRowUpdates(updates, ...rowIds) {
3847
+ const drop = new Set(rowIds);
3848
+ const next = {};
3849
+ let changed = false;
3850
+ for (const [rowId, patch] of Object.entries(updates)) {
3851
+ if (drop.has(rowId)) changed = true;
3852
+ else next[rowId] = patch;
3853
+ }
3854
+ return changed ? next : updates;
3855
+ }
3856
+ function withRecordGridCreated(overlay, row) {
3857
+ return { ...overlay, created: [...overlay.created, row] };
3858
+ }
3859
+ function withoutRecordGridCreated(overlay, rowId) {
3860
+ const created = overlay.created.filter((row) => row.id !== rowId);
3861
+ if (created.length === overlay.created.length) return overlay;
3862
+ return { ...overlay, created, updates: withoutRowUpdates(overlay.updates, rowId) };
3863
+ }
3864
+ function withRecordGridRemoved(overlay, rowId) {
3865
+ if (overlay.removed.includes(rowId)) return overlay;
3866
+ return { ...overlay, removed: [...overlay.removed, rowId] };
3867
+ }
3868
+ function withoutRecordGridRemoved(overlay, rowId) {
3869
+ if (!overlay.removed.includes(rowId)) return overlay;
3870
+ return { ...overlay, removed: overlay.removed.filter((candidate) => candidate !== rowId) };
3871
+ }
3872
+ function pruneRecordGridOverlay(rows, overlay) {
3873
+ const byId = new Map(rows.map((row) => [row.id, row]));
3874
+ const createdIds = new Set(overlay.created.map((row) => row.id));
3875
+ let changed = false;
3876
+ const updates = {};
3877
+ for (const [rowId, patch] of Object.entries(overlay.updates)) {
3878
+ const row = byId.get(rowId);
3879
+ if (row === void 0) {
3880
+ if (createdIds.has(rowId)) {
3881
+ updates[rowId] = patch;
3882
+ continue;
3883
+ }
3884
+ changed = true;
3885
+ continue;
3886
+ }
3887
+ const kept = {};
3888
+ for (const [columnId, value] of Object.entries(patch)) {
3889
+ if (sameRecordGridValue(row.values[columnId], value)) changed = true;
3890
+ else kept[columnId] = value;
3891
+ }
3892
+ if (Object.keys(kept).length > 0) updates[rowId] = kept;
3893
+ }
3894
+ const created = overlay.created.filter((row) => {
3895
+ const settled = byId.has(row.id);
3896
+ if (settled) changed = true;
3897
+ return !settled;
3898
+ });
3899
+ const removed = overlay.removed.filter((rowId) => {
3900
+ const settled = !byId.has(rowId);
3901
+ if (settled) changed = true;
3902
+ return !settled;
3903
+ });
3904
+ if (!changed) return overlay;
3905
+ return { updates, created, removed };
3906
+ }
3907
+
3908
+ // src/web-react/record-grid.tsx
3573
3909
  import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
3910
+ var CELL_KEY_SEPARATOR = "\0";
3911
+ function cellKey(rowId, columnId) {
3912
+ return `${rowId}${CELL_KEY_SEPARATOR}${columnId}`;
3913
+ }
3914
+ var NAVIGATION_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Home", "End"]);
3915
+ function clamp(value, max) {
3916
+ if (value < 0) return 0;
3917
+ if (value > max) return max;
3918
+ return value;
3919
+ }
3920
+ function alignmentClass(column) {
3921
+ const align = column.align ?? (column.kind === "number" || column.kind === "currency" ? "right" : "left");
3922
+ return align === "right" ? "text-right" : "text-left";
3923
+ }
3924
+ function groupColumns(columns) {
3925
+ const groups = [];
3926
+ for (const column of columns) {
3927
+ const label = column.group ?? null;
3928
+ const existing = groups.find((group) => group.label === label);
3929
+ if (existing) existing.columns.push(column);
3930
+ else groups.push({ label, columns: [column] });
3931
+ }
3932
+ return groups;
3933
+ }
3934
+ 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";
3935
+ var BASIS_TONES = {
3936
+ source: "border-primary/60 text-primary",
3937
+ confirmed: "border-success/60 text-success",
3938
+ derived: "border-border text-muted-foreground"
3939
+ };
3940
+ var BASIS_TITLES = {
3941
+ source: "Extracted from a source document",
3942
+ confirmed: "Confirmed by a person",
3943
+ derived: "Computed from other values"
3944
+ };
3945
+ function RecordGrid({
3946
+ columns,
3947
+ rows,
3948
+ caption,
3949
+ state = "ready",
3950
+ error,
3951
+ onRetry,
3952
+ empty,
3953
+ onCreate,
3954
+ onUpdate,
3955
+ onDelete,
3956
+ newRowDefaults,
3957
+ addLabel = "Add row",
3958
+ locale,
3959
+ toolbar,
3960
+ loadingRowCount = 3,
3961
+ className
3962
+ }) {
3963
+ const fieldPrefix = useId();
3964
+ const [overlay, setOverlay] = useState13(EMPTY_RECORD_GRID_OVERLAY);
3965
+ const [editing, setEditingState] = useState13(null);
3966
+ const [cellErrors, setCellErrors] = useState13({});
3967
+ const [rowErrors, setRowErrors] = useState13({});
3968
+ const [pendingRows, setPendingRows] = useState13({});
3969
+ const [focus, setFocus] = useState13(null);
3970
+ const [openSource, setOpenSource] = useState13(null);
3971
+ const [confirmDelete, setConfirmDelete] = useState13(null);
3972
+ const [adding, setAdding] = useState13(false);
3973
+ const [draft, setDraft] = useState13({ ...newRowDefaults ?? {} });
3974
+ const [draftErrors, setDraftErrors] = useState13({});
3975
+ const [draftError, setDraftError] = useState13(null);
3976
+ const [creating, setCreating] = useState13(false);
3977
+ const cellRefs = useRef9(/* @__PURE__ */ new Map());
3978
+ const settling = useRef9(false);
3979
+ const draftCounter = useRef9(0);
3980
+ const editingRef = useRef9(null);
3981
+ const setEditing = useCallback8((next) => {
3982
+ editingRef.current = next;
3983
+ setEditingState(next);
3984
+ }, []);
3985
+ useEffect10(() => {
3986
+ setOverlay((current) => pruneRecordGridOverlay(rows, current));
3987
+ }, [rows]);
3988
+ const visibleRows = useMemo7(() => projectRecordGridRows(rows, overlay), [rows, overlay]);
3989
+ const activeFocus = useMemo7(() => {
3990
+ if (focus === null) return null;
3991
+ if (!visibleRows.some((row) => row.id === focus.rowId)) return null;
3992
+ if (!columns.some((column) => column.id === focus.columnId)) return null;
3993
+ return focus;
3994
+ }, [columns, focus, visibleRows]);
3995
+ const setCellError = useCallback8((key, message) => {
3996
+ setCellErrors((current) => {
3997
+ if (message === null) {
3998
+ if (!(key in current)) return current;
3999
+ const next = { ...current };
4000
+ delete next[key];
4001
+ return next;
4002
+ }
4003
+ if (current[key] === message) return current;
4004
+ return { ...current, [key]: message };
4005
+ });
4006
+ }, []);
4007
+ const setRowError = useCallback8((rowId, message) => {
4008
+ setRowErrors((current) => {
4009
+ if (message === null) {
4010
+ if (!(rowId in current)) return current;
4011
+ const next = { ...current };
4012
+ delete next[rowId];
4013
+ return next;
4014
+ }
4015
+ return { ...current, [rowId]: message };
4016
+ });
4017
+ }, []);
4018
+ const setRowPending = useCallback8((rowId, pending) => {
4019
+ setPendingRows((current) => {
4020
+ if (pending) return rowId in current ? current : { ...current, [rowId]: true };
4021
+ if (!(rowId in current)) return current;
4022
+ const next = { ...current };
4023
+ delete next[rowId];
4024
+ return next;
4025
+ });
4026
+ }, []);
4027
+ const focusCell = useCallback8((rowId, columnId) => {
4028
+ setFocus({ rowId, columnId });
4029
+ cellRefs.current.get(cellKey(rowId, columnId))?.focus();
4030
+ }, []);
4031
+ const beginEdit = useCallback8(
4032
+ (row, column) => {
4033
+ setCellError(cellKey(row.id, column.id), null);
4034
+ setEditing({
4035
+ rowId: row.id,
4036
+ columnId: column.id,
4037
+ text: recordGridEditorText(column, row.values[column.id] ?? null)
4038
+ });
4039
+ },
4040
+ [setCellError, setEditing]
4041
+ );
4042
+ const applyCellWrite = useCallback8(
4043
+ async (row, column, value) => {
4044
+ if (!onUpdate) return;
4045
+ const values = { ...row.values, [column.id]: value };
4046
+ setOverlay((current) => withRecordGridUpdate(current, row.id, column.id, value));
4047
+ setRowError(row.id, null);
4048
+ setRowPending(row.id, true);
4049
+ let outcome;
4050
+ try {
4051
+ outcome = await onUpdate({ row, columnId: column.id, value, values });
4052
+ } catch (cause) {
4053
+ outcome = { succeeded: false, error: cause instanceof Error ? cause.message : String(cause) };
4054
+ }
4055
+ setRowPending(row.id, false);
4056
+ if (outcome.succeeded) {
4057
+ const canonical = outcome.value;
4058
+ if (canonical) setOverlay((current) => withRecordGridServerRow(current, row.id, canonical));
4059
+ return;
4060
+ }
4061
+ setOverlay((current) => withoutRecordGridUpdate(current, row.id, column.id));
4062
+ const rejected = formatRecordGridValue(column, value, locale);
4063
+ setRowError(
4064
+ row.id,
4065
+ rejected === "" ? `Could not save ${column.header}: ${outcome.error}` : `Could not save ${column.header} as ${rejected}: ${outcome.error}`
4066
+ );
4067
+ },
4068
+ [locale, onUpdate, setRowError, setRowPending]
4069
+ );
4070
+ const commitEdit = useCallback8(
4071
+ async (row, column, text) => {
4072
+ const open = editingRef.current;
4073
+ if (open === null || open.rowId !== row.id || open.columnId !== column.id) return;
4074
+ if (settling.current) return;
4075
+ settling.current = true;
4076
+ try {
4077
+ const key = cellKey(row.id, column.id);
4078
+ const parsed = readRecordGridCell(column, text);
4079
+ if (!parsed.succeeded) {
4080
+ setCellError(key, parsed.error);
4081
+ setEditing({ rowId: row.id, columnId: column.id, text });
4082
+ return;
4083
+ }
4084
+ setCellError(key, null);
4085
+ setEditing(null);
4086
+ if (sameRecordGridValue(row.values[column.id], parsed.value)) return;
4087
+ await applyCellWrite(row, column, parsed.value);
4088
+ } finally {
4089
+ settling.current = false;
4090
+ }
4091
+ },
4092
+ [applyCellWrite, setCellError, setEditing]
4093
+ );
4094
+ const cancelEdit = useCallback8(
4095
+ (row, column) => {
4096
+ setCellError(cellKey(row.id, column.id), null);
4097
+ setEditing(null);
4098
+ focusCell(row.id, column.id);
4099
+ },
4100
+ [focusCell, setCellError, setEditing]
4101
+ );
4102
+ const performDelete = useCallback8(
4103
+ async (row) => {
4104
+ if (!onDelete) return;
4105
+ setConfirmDelete(null);
4106
+ setRowError(row.id, null);
4107
+ setOverlay((current) => withRecordGridRemoved(current, row.id));
4108
+ let outcome;
4109
+ try {
4110
+ outcome = await onDelete(row);
4111
+ } catch (cause) {
4112
+ outcome = { succeeded: false, error: cause instanceof Error ? cause.message : String(cause) };
4113
+ }
4114
+ if (outcome.succeeded) return;
4115
+ setOverlay((current) => withoutRecordGridRemoved(current, row.id));
4116
+ setRowError(row.id, `Could not delete ${recordGridRowLabel(columns, row)}: ${outcome.error}`);
4117
+ },
4118
+ [columns, onDelete, setRowError]
4119
+ );
4120
+ const resetDraft = useCallback8(() => {
4121
+ setDraft({ ...newRowDefaults ?? {} });
4122
+ setDraftErrors({});
4123
+ setDraftError(null);
4124
+ }, [newRowDefaults]);
4125
+ const openAdd = useCallback8(() => {
4126
+ resetDraft();
4127
+ setAdding(true);
4128
+ }, [resetDraft]);
4129
+ const submitDraft = useCallback8(async () => {
4130
+ if (!onCreate) return;
4131
+ const validated = validateRecordGridRow(columns, draft);
4132
+ if (!validated.succeeded) {
4133
+ setDraftErrors(validated.cellErrors);
4134
+ setDraftError(validated.error);
4135
+ return;
4136
+ }
4137
+ setDraftErrors({});
4138
+ setDraftError(null);
4139
+ draftCounter.current += 1;
4140
+ const draftId = `${fieldPrefix}-draft-${draftCounter.current}`;
4141
+ setOverlay((current) => withRecordGridCreated(current, { id: draftId, values: validated.value }));
4142
+ setCreating(true);
4143
+ let outcome;
4144
+ try {
4145
+ outcome = await onCreate(validated.value);
4146
+ } catch (cause) {
4147
+ outcome = { succeeded: false, error: cause instanceof Error ? cause.message : String(cause) };
4148
+ }
4149
+ setCreating(false);
4150
+ if (outcome.succeeded) {
4151
+ setOverlay((current) => withRecordGridServerRow(current, draftId, outcome.value));
4152
+ setAdding(false);
4153
+ resetDraft();
4154
+ return;
4155
+ }
4156
+ setOverlay((current) => withoutRecordGridCreated(current, draftId));
4157
+ setDraftError(outcome.error);
4158
+ }, [columns, draft, fieldPrefix, onCreate, resetDraft]);
4159
+ const handleGridKeyDown = useCallback8(
4160
+ (event) => {
4161
+ if (editing !== null) return;
4162
+ const target = event.target;
4163
+ const rowId = target.dataset?.recordGridRow;
4164
+ const columnId = target.dataset?.recordGridColumn;
4165
+ if (rowId === void 0 || columnId === void 0) return;
4166
+ const rowIndex = visibleRows.findIndex((row) => row.id === rowId);
4167
+ const columnIndex = columns.findIndex((column) => column.id === columnId);
4168
+ if (rowIndex < 0 || columnIndex < 0) return;
4169
+ if (event.key === "Enter") {
4170
+ const row = visibleRows[rowIndex];
4171
+ const column = columns[columnIndex];
4172
+ if (!row || !column) return;
4173
+ if (!onUpdate || column.editable === false || row.readOnly === true) return;
4174
+ if (column.kind === "boolean") return;
4175
+ if (!isRecordGridCellApplicable(column, row.values)) return;
4176
+ event.preventDefault();
4177
+ beginEdit(row, column);
4178
+ return;
4179
+ }
4180
+ if (!NAVIGATION_KEYS.has(event.key)) return;
4181
+ event.preventDefault();
4182
+ let nextRow = rowIndex;
4183
+ let nextColumn = columnIndex;
4184
+ if (event.key === "ArrowUp") nextRow = clamp(rowIndex - 1, visibleRows.length - 1);
4185
+ if (event.key === "ArrowDown") nextRow = clamp(rowIndex + 1, visibleRows.length - 1);
4186
+ if (event.key === "ArrowLeft") nextColumn = clamp(columnIndex - 1, columns.length - 1);
4187
+ if (event.key === "ArrowRight") nextColumn = clamp(columnIndex + 1, columns.length - 1);
4188
+ if (event.key === "Home") nextColumn = 0;
4189
+ if (event.key === "End") nextColumn = columns.length - 1;
4190
+ const destinationRow = visibleRows[nextRow];
4191
+ const destinationColumn = columns[nextColumn];
4192
+ if (!destinationRow || !destinationColumn) return;
4193
+ focusCell(destinationRow.id, destinationColumn.id);
4194
+ },
4195
+ [beginEdit, columns, editing, focusCell, onUpdate, visibleRows]
4196
+ );
4197
+ const dataState = typeof error === "string" && error !== "" ? "error" : state;
4198
+ if (dataState === "loading") {
4199
+ return /* @__PURE__ */ jsxs11("div", { className: `space-y-3 ${className ?? ""}`, children: [
4200
+ toolbar,
4201
+ /* @__PURE__ */ jsxs11(
4202
+ "div",
4203
+ {
4204
+ role: "status",
4205
+ "aria-busy": "true",
4206
+ "aria-live": "polite",
4207
+ className: "space-y-2 rounded-xl border border-border bg-card p-4",
4208
+ children: [
4209
+ /* @__PURE__ */ jsxs11("span", { className: "sr-only", children: [
4210
+ "Loading ",
4211
+ caption
4212
+ ] }),
4213
+ Array.from({ length: Math.max(1, loadingRowCount) }, (_, index) => /* @__PURE__ */ jsx13("div", { className: "h-8 animate-pulse rounded-md bg-muted/50", "aria-hidden": true }, index))
4214
+ ]
4215
+ }
4216
+ )
4217
+ ] });
4218
+ }
4219
+ if (dataState === "error") {
4220
+ return /* @__PURE__ */ jsxs11("div", { className: `space-y-3 ${className ?? ""}`, children: [
4221
+ toolbar,
4222
+ /* @__PURE__ */ jsxs11("div", { role: "alert", className: "rounded-xl border border-destructive/40 bg-destructive/10 px-4 py-4", children: [
4223
+ /* @__PURE__ */ jsx13("p", { className: "text-sm font-medium text-destructive", children: typeof error === "string" && error !== "" ? error : `${caption} could not be loaded.` }),
4224
+ onRetry && /* @__PURE__ */ jsx13(
4225
+ "button",
4226
+ {
4227
+ type: "button",
4228
+ onClick: onRetry,
4229
+ 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",
4230
+ children: "Try again"
4231
+ }
4232
+ )
4233
+ ] })
4234
+ ] });
4235
+ }
4236
+ const addForm = adding && onCreate ? /* @__PURE__ */ jsx13(
4237
+ AddRecordForm,
4238
+ {
4239
+ columns,
4240
+ draft,
4241
+ setDraft,
4242
+ errors: draftErrors,
4243
+ formError: draftError,
4244
+ busy: creating,
4245
+ label: addLabel,
4246
+ fieldPrefix,
4247
+ onSubmit: () => void submitDraft(),
4248
+ onCancel: () => {
4249
+ setAdding(false);
4250
+ resetDraft();
4251
+ }
4252
+ }
4253
+ ) : null;
4254
+ if (visibleRows.length === 0) {
4255
+ return /* @__PURE__ */ jsxs11("div", { className: `space-y-3 ${className ?? ""}`, children: [
4256
+ toolbar,
4257
+ addForm ?? /* @__PURE__ */ jsxs11("div", { className: "rounded-xl border border-dashed border-border px-6 py-10 text-center", children: [
4258
+ /* @__PURE__ */ jsx13("p", { className: "text-sm font-medium text-foreground", children: empty.title }),
4259
+ empty.description && /* @__PURE__ */ jsx13("p", { className: "mx-auto mt-1 max-w-md text-sm text-muted-foreground", children: empty.description }),
4260
+ /* @__PURE__ */ jsxs11("div", { className: "mt-4 flex flex-wrap items-center justify-center gap-2", children: [
4261
+ empty.action,
4262
+ onCreate && /* @__PURE__ */ jsx13(
4263
+ "button",
4264
+ {
4265
+ type: "button",
4266
+ onClick: openAdd,
4267
+ className: "rounded-md border border-border px-3 py-1.5 text-sm font-medium text-foreground transition hover:bg-accent/30",
4268
+ children: addLabel
4269
+ }
4270
+ )
4271
+ ] })
4272
+ ] })
4273
+ ] });
4274
+ }
4275
+ const hasFooter = columns.some((column) => column.footerValue !== void 0);
4276
+ const columnSpan = columns.length + (onDelete ? 1 : 0);
4277
+ return /* @__PURE__ */ jsxs11("div", { className: `space-y-3 ${className ?? ""}`, children: [
4278
+ toolbar,
4279
+ /* @__PURE__ */ jsx13("div", { className: "overflow-x-auto rounded-xl border border-border bg-card", children: /* @__PURE__ */ jsxs11(
4280
+ "table",
4281
+ {
4282
+ role: "grid",
4283
+ "aria-label": caption,
4284
+ className: "w-full border-collapse text-left text-sm",
4285
+ onKeyDown: handleGridKeyDown,
4286
+ children: [
4287
+ /* @__PURE__ */ jsx13("thead", { children: /* @__PURE__ */ jsxs11("tr", { role: "row", className: "border-b border-border text-[11px] uppercase tracking-wide text-muted-foreground", children: [
4288
+ columns.map((column) => /* @__PURE__ */ jsx13(
4289
+ "th",
4290
+ {
4291
+ role: "columnheader",
4292
+ scope: "col",
4293
+ className: `px-3 py-2 font-medium ${alignmentClass(column)}`,
4294
+ children: column.header
4295
+ },
4296
+ column.id
4297
+ )),
4298
+ onDelete && /* @__PURE__ */ jsx13("th", { role: "columnheader", scope: "col", className: "w-px px-3 py-2 font-medium", children: /* @__PURE__ */ jsx13("span", { className: "sr-only", children: "Row actions" }) })
4299
+ ] }) }),
4300
+ /* @__PURE__ */ jsx13("tbody", { children: visibleRows.map((row) => {
4301
+ const rowLabel = recordGridRowLabel(columns, row);
4302
+ const pending = row.id in pendingRows;
4303
+ const rowError = rowErrors[row.id];
4304
+ return /* @__PURE__ */ jsxs11(Fragment7, { children: [
4305
+ /* @__PURE__ */ jsxs11("tr", { role: "row", "aria-busy": pending, className: `border-b border-border/50 ${pending ? "opacity-60" : ""}`, children: [
4306
+ columns.map((column) => {
4307
+ const key = cellKey(row.id, column.id);
4308
+ const applicable = isRecordGridCellApplicable(column, row.values);
4309
+ const editable = onUpdate !== void 0 && column.editable !== false && row.readOnly !== true && applicable;
4310
+ const value = row.values[column.id] ?? null;
4311
+ const isEditing = editing?.rowId === row.id && editing.columnId === column.id;
4312
+ const cellError = cellErrors[key];
4313
+ const active = activeFocus === null ? row.id === visibleRows[0]?.id && column.id === columns[0]?.id : activeFocus.rowId === row.id && activeFocus.columnId === column.id;
4314
+ const source = row.sources?.[column.id];
4315
+ const errorId = `${fieldPrefix}-cell-error-${row.id}-${column.id}`;
4316
+ if (isEditing && editable) {
4317
+ return /* @__PURE__ */ jsxs11("td", { role: "gridcell", className: `px-3 py-1.5 ${alignmentClass(column)}`, children: [
4318
+ /* @__PURE__ */ jsx13(
4319
+ CellEditor,
4320
+ {
4321
+ column,
4322
+ rowLabel,
4323
+ text: editing.text,
4324
+ invalid: cellError !== void 0,
4325
+ describedBy: cellError === void 0 ? void 0 : errorId,
4326
+ onText: (text) => setEditing({ rowId: row.id, columnId: column.id, text }),
4327
+ onCommit: (text) => void commitEdit(row, column, text),
4328
+ onCancel: () => cancelEdit(row, column)
4329
+ }
4330
+ ),
4331
+ cellError !== void 0 && /* @__PURE__ */ jsx13("p", { id: errorId, role: "alert", className: "mt-1 text-[11px] leading-snug text-destructive", children: cellError })
4332
+ ] }, column.id);
4333
+ }
4334
+ if (column.kind === "boolean" && editable) {
4335
+ return /* @__PURE__ */ jsx13("td", { role: "gridcell", className: `px-3 py-2 ${alignmentClass(column)}`, children: /* @__PURE__ */ jsx13(
4336
+ "input",
4337
+ {
4338
+ type: "checkbox",
4339
+ checked: value === true,
4340
+ "aria-label": `${column.header}, ${rowLabel}`,
4341
+ "data-record-grid-row": row.id,
4342
+ "data-record-grid-column": column.id,
4343
+ tabIndex: active ? 0 : -1,
4344
+ ref: (node) => {
4345
+ cellRefs.current.set(key, node);
4346
+ },
4347
+ onFocus: () => setFocus({ rowId: row.id, columnId: column.id }),
4348
+ onChange: (event) => void applyCellWrite(row, column, event.target.checked),
4349
+ className: "h-4 w-4 rounded border-border accent-primary"
4350
+ }
4351
+ ) }, column.id);
4352
+ }
4353
+ const display = applicable ? formatRecordGridValue(column, value, locale) : "";
4354
+ return /* @__PURE__ */ jsx13(
4355
+ "td",
4356
+ {
4357
+ role: "gridcell",
4358
+ "aria-readonly": editable ? void 0 : true,
4359
+ "data-record-grid-row": row.id,
4360
+ "data-record-grid-column": column.id,
4361
+ tabIndex: active ? 0 : -1,
4362
+ ref: (node) => {
4363
+ cellRefs.current.set(key, node);
4364
+ },
4365
+ onFocus: () => setFocus({ rowId: row.id, columnId: column.id }),
4366
+ onClick: () => {
4367
+ if (editable) beginEdit(row, column);
4368
+ },
4369
+ className: `px-3 py-2 outline-none focus:ring-2 focus:ring-inset focus:ring-primary/50 ${alignmentClass(
4370
+ column
4371
+ )} ${editable ? "cursor-text" : ""}`,
4372
+ children: /* @__PURE__ */ jsxs11("span", { className: "inline-flex max-w-full items-center gap-1.5", children: [
4373
+ /* @__PURE__ */ jsx13("span", { className: display === "" ? "text-muted-foreground" : "truncate text-foreground", children: display === "" ? applicable ? "\u2014" : "n/a" : display }),
4374
+ source && /* @__PURE__ */ jsx13(
4375
+ SourceMarker,
4376
+ {
4377
+ panelId: `${fieldPrefix}-source-${row.id}-${column.id}`,
4378
+ columnHeader: column.header,
4379
+ rowLabel,
4380
+ source,
4381
+ open: openSource === key,
4382
+ onToggle: () => setOpenSource((current) => current === key ? null : key)
4383
+ }
4384
+ )
4385
+ ] })
4386
+ },
4387
+ column.id
4388
+ );
4389
+ }),
4390
+ onDelete && /* @__PURE__ */ jsx13("td", { role: "gridcell", className: "px-3 py-2 text-right", children: row.readOnly === true ? null : confirmDelete === row.id ? /* @__PURE__ */ jsxs11("span", { className: "inline-flex items-center gap-1.5", children: [
4391
+ /* @__PURE__ */ jsx13(
4392
+ "button",
4393
+ {
4394
+ type: "button",
4395
+ "aria-label": `Confirm delete ${rowLabel}`,
4396
+ onClick: () => void performDelete(row),
4397
+ className: "rounded-md bg-destructive/10 px-2 py-1 text-xs font-medium text-destructive transition hover:bg-destructive/20",
4398
+ children: "Delete"
4399
+ }
4400
+ ),
4401
+ /* @__PURE__ */ jsx13(
4402
+ "button",
4403
+ {
4404
+ type: "button",
4405
+ "aria-label": `Keep ${rowLabel}`,
4406
+ onClick: () => setConfirmDelete(null),
4407
+ className: "rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground transition hover:bg-accent/30",
4408
+ children: "Cancel"
4409
+ }
4410
+ )
4411
+ ] }) : /* @__PURE__ */ jsx13(
4412
+ "button",
4413
+ {
4414
+ type: "button",
4415
+ "aria-label": `Delete ${rowLabel}`,
4416
+ onClick: () => setConfirmDelete(row.id),
4417
+ className: "rounded-md p-1.5 text-muted-foreground transition hover:bg-destructive/10 hover:text-destructive",
4418
+ children: /* @__PURE__ */ jsxs11(
4419
+ "svg",
4420
+ {
4421
+ viewBox: "0 0 24 24",
4422
+ className: "h-3.5 w-3.5",
4423
+ fill: "none",
4424
+ stroke: "currentColor",
4425
+ strokeWidth: "2",
4426
+ strokeLinecap: "round",
4427
+ strokeLinejoin: "round",
4428
+ "aria-hidden": true,
4429
+ children: [
4430
+ /* @__PURE__ */ jsx13("polyline", { points: "3 6 5 6 21 6" }),
4431
+ /* @__PURE__ */ jsx13("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" })
4432
+ ]
4433
+ }
4434
+ )
4435
+ }
4436
+ ) })
4437
+ ] }),
4438
+ rowError !== void 0 && /* @__PURE__ */ jsx13("tr", { role: "row", className: "border-b border-border/50", children: /* @__PURE__ */ jsx13("td", { role: "gridcell", colSpan: columnSpan, className: "px-3 pb-2", children: /* @__PURE__ */ jsx13("p", { role: "alert", className: "rounded-md bg-destructive/10 px-2.5 py-1.5 text-xs text-destructive", children: rowError }) }) })
4439
+ ] }, row.id);
4440
+ }) }),
4441
+ hasFooter && /* @__PURE__ */ jsx13("tfoot", { children: /* @__PURE__ */ jsxs11("tr", { role: "row", className: "border-t-2 border-border", children: [
4442
+ columns.map((column) => /* @__PURE__ */ jsx13(
4443
+ "td",
4444
+ {
4445
+ role: "gridcell",
4446
+ className: `px-3 py-2 text-sm font-semibold text-foreground ${alignmentClass(column)}`,
4447
+ children: column.footerValue ? formatRecordGridValue(column, column.footerValue(visibleRows), locale) : ""
4448
+ },
4449
+ column.id
4450
+ )),
4451
+ onDelete && /* @__PURE__ */ jsx13("td", { role: "gridcell" })
4452
+ ] }) })
4453
+ ]
4454
+ }
4455
+ ) }),
4456
+ onCreate && (addForm ?? /* @__PURE__ */ jsxs11(
4457
+ "button",
4458
+ {
4459
+ type: "button",
4460
+ onClick: openAdd,
4461
+ 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",
4462
+ children: [
4463
+ /* @__PURE__ */ jsxs11(
4464
+ "svg",
4465
+ {
4466
+ viewBox: "0 0 24 24",
4467
+ className: "h-3.5 w-3.5",
4468
+ fill: "none",
4469
+ stroke: "currentColor",
4470
+ strokeWidth: "2",
4471
+ strokeLinecap: "round",
4472
+ strokeLinejoin: "round",
4473
+ "aria-hidden": true,
4474
+ children: [
4475
+ /* @__PURE__ */ jsx13("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
4476
+ /* @__PURE__ */ jsx13("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
4477
+ ]
4478
+ }
4479
+ ),
4480
+ addLabel
4481
+ ]
4482
+ }
4483
+ ))
4484
+ ] });
4485
+ }
4486
+ function CellEditor({ column, rowLabel, text, invalid, describedBy, onText, onCommit, onCancel }) {
4487
+ const shared = {
4488
+ "aria-label": `${column.header}, ${rowLabel}`,
4489
+ "aria-invalid": invalid ? true : void 0,
4490
+ "aria-describedby": describedBy,
4491
+ autoFocus: true,
4492
+ className: INPUT_CLASS
4493
+ };
4494
+ if (column.kind === "select") {
4495
+ return /* @__PURE__ */ jsxs11(
4496
+ "select",
4497
+ {
4498
+ ...shared,
4499
+ value: text,
4500
+ onChange: (event) => {
4501
+ onText(event.target.value);
4502
+ onCommit(event.target.value);
4503
+ },
4504
+ onKeyDown: (event) => {
4505
+ if (event.key === "Escape") {
4506
+ event.preventDefault();
4507
+ onCancel();
4508
+ }
4509
+ },
4510
+ onBlur: () => onCommit(text),
4511
+ children: [
4512
+ /* @__PURE__ */ jsx13("option", { value: "", children: "\u2014" }),
4513
+ column.options.map((option) => /* @__PURE__ */ jsx13("option", { value: option.value, children: option.label }, option.value))
4514
+ ]
4515
+ }
4516
+ );
4517
+ }
4518
+ const keyDown = (event) => {
4519
+ const multiline = column.kind === "text" && column.multiline === true;
4520
+ if (event.key === "Enter" && !multiline) {
4521
+ event.preventDefault();
4522
+ onCommit(text);
4523
+ return;
4524
+ }
4525
+ if (event.key === "Escape") {
4526
+ event.preventDefault();
4527
+ onCancel();
4528
+ }
4529
+ };
4530
+ if (column.kind === "text" && column.multiline === true) {
4531
+ return /* @__PURE__ */ jsx13(
4532
+ "textarea",
4533
+ {
4534
+ ...shared,
4535
+ rows: 3,
4536
+ value: text,
4537
+ onChange: (event) => onText(event.target.value),
4538
+ onKeyDown: keyDown,
4539
+ onBlur: () => onCommit(text)
4540
+ }
4541
+ );
4542
+ }
4543
+ return /* @__PURE__ */ jsx13(
4544
+ "input",
4545
+ {
4546
+ ...shared,
4547
+ type: column.kind === "date" ? "date" : "text",
4548
+ inputMode: column.kind === "number" || column.kind === "currency" ? "decimal" : void 0,
4549
+ value: text,
4550
+ onChange: (event) => onText(event.target.value),
4551
+ onKeyDown: keyDown,
4552
+ onBlur: () => onCommit(text)
4553
+ }
4554
+ );
4555
+ }
4556
+ function SourceMarker({ panelId, columnHeader, rowLabel, source, open, onToggle }) {
4557
+ const basis = source.basis ?? "source";
4558
+ return /* @__PURE__ */ jsxs11("span", { className: "relative inline-flex", children: [
4559
+ /* @__PURE__ */ jsx13(
4560
+ "button",
4561
+ {
4562
+ type: "button",
4563
+ "aria-label": `Source for ${columnHeader}, ${rowLabel}`,
4564
+ "aria-expanded": open,
4565
+ "aria-controls": open ? panelId : void 0,
4566
+ title: BASIS_TITLES[basis],
4567
+ onClick: (event) => {
4568
+ event.stopPropagation();
4569
+ onToggle();
4570
+ },
4571
+ className: `inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border ${BASIS_TONES[basis]}`,
4572
+ children: /* @__PURE__ */ jsx13(
4573
+ "svg",
4574
+ {
4575
+ viewBox: "0 0 24 24",
4576
+ className: "h-2.5 w-2.5",
4577
+ fill: "none",
4578
+ stroke: "currentColor",
4579
+ strokeWidth: "2.5",
4580
+ strokeLinecap: "round",
4581
+ "aria-hidden": true,
4582
+ children: /* @__PURE__ */ jsx13("path", { d: "M9 8h6M9 12h6M9 16h3" })
4583
+ }
4584
+ )
4585
+ }
4586
+ ),
4587
+ open && /* @__PURE__ */ jsxs11(
4588
+ "span",
4589
+ {
4590
+ id: panelId,
4591
+ role: "note",
4592
+ className: "absolute left-0 top-5 z-10 w-64 rounded-lg border border-border bg-card p-3 text-left shadow-lg",
4593
+ children: [
4594
+ source.quote && /* @__PURE__ */ jsxs11("span", { className: "block border-l-2 border-primary/50 pl-2 text-xs italic leading-snug text-foreground", children: [
4595
+ "\u201C",
4596
+ source.quote,
4597
+ "\u201D"
4598
+ ] }),
4599
+ /* @__PURE__ */ jsxs11("span", { className: "mt-2 block text-[11px] text-muted-foreground", children: [
4600
+ source.label ?? "Source",
4601
+ source.locator ? ` \xB7 ${source.locator}` : "",
4602
+ ` \xB7 ${BASIS_TITLES[basis]}`
4603
+ ] }),
4604
+ source.href && /* @__PURE__ */ jsx13(
4605
+ "a",
4606
+ {
4607
+ href: source.href,
4608
+ target: "_blank",
4609
+ rel: "noreferrer",
4610
+ onClick: (event) => event.stopPropagation(),
4611
+ className: "mt-1.5 inline-block text-[11px] font-medium text-primary underline-offset-2 hover:underline",
4612
+ children: "Open source"
4613
+ }
4614
+ )
4615
+ ]
4616
+ }
4617
+ )
4618
+ ] });
4619
+ }
4620
+ function AddRecordForm({
4621
+ columns,
4622
+ draft,
4623
+ setDraft,
4624
+ errors,
4625
+ formError,
4626
+ busy,
4627
+ label,
4628
+ fieldPrefix,
4629
+ onSubmit,
4630
+ onCancel
4631
+ }) {
4632
+ const groups = useMemo7(() => groupColumns(columns), [columns]);
4633
+ return /* @__PURE__ */ jsxs11(
4634
+ "form",
4635
+ {
4636
+ noValidate: true,
4637
+ "aria-label": label,
4638
+ onSubmit: (event) => {
4639
+ event.preventDefault();
4640
+ onSubmit();
4641
+ },
4642
+ className: "space-y-4 rounded-xl border border-border bg-card p-4",
4643
+ children: [
4644
+ /* @__PURE__ */ jsx13("h3", { className: "text-sm font-semibold text-foreground", children: label }),
4645
+ formError !== null && /* @__PURE__ */ jsx13("p", { role: "alert", className: "rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive", children: formError }),
4646
+ groups.map((group) => {
4647
+ const fields = group.columns.filter((column) => isRecordGridCellApplicable(column, draft));
4648
+ if (fields.length === 0) return null;
4649
+ return /* @__PURE__ */ jsxs11(
4650
+ "fieldset",
4651
+ {
4652
+ className: group.label === null ? "min-w-0" : "min-w-0 rounded-lg border border-border/70 p-3",
4653
+ children: [
4654
+ group.label !== null && /* @__PURE__ */ jsx13("legend", { className: "px-1 text-xs font-medium text-muted-foreground", children: group.label }),
4655
+ /* @__PURE__ */ jsx13("div", { className: "grid gap-3 sm:grid-cols-2", children: fields.map((column) => {
4656
+ const fieldId = `${fieldPrefix}-${column.id}`;
4657
+ const errorId = `${fieldId}-error`;
4658
+ const message = errors[column.id];
4659
+ return /* @__PURE__ */ jsxs11(
4660
+ "div",
4661
+ {
4662
+ className: column.kind === "text" && column.multiline === true ? "sm:col-span-2" : "",
4663
+ children: [
4664
+ /* @__PURE__ */ jsxs11("label", { htmlFor: fieldId, className: "mb-1 block text-xs font-medium text-muted-foreground", children: [
4665
+ column.header,
4666
+ column.required === true && /* @__PURE__ */ jsx13("span", { className: "ml-0.5 text-destructive", children: "*" })
4667
+ ] }),
4668
+ /* @__PURE__ */ jsx13(
4669
+ DraftField,
4670
+ {
4671
+ column,
4672
+ id: fieldId,
4673
+ value: draft[column.id] ?? null,
4674
+ invalid: message !== void 0,
4675
+ describedBy: message === void 0 ? void 0 : errorId,
4676
+ onValue: (next) => setDraft({ ...draft, [column.id]: next })
4677
+ }
4678
+ ),
4679
+ column.hint && /* @__PURE__ */ jsx13("p", { className: "mt-1 text-[11px] text-muted-foreground", children: column.hint }),
4680
+ message !== void 0 && /* @__PURE__ */ jsx13("p", { id: errorId, role: "alert", className: "mt-1 text-[11px] text-destructive", children: message })
4681
+ ]
4682
+ },
4683
+ column.id
4684
+ );
4685
+ }) })
4686
+ ]
4687
+ },
4688
+ group.label ?? "_"
4689
+ );
4690
+ }),
4691
+ /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2", children: [
4692
+ /* @__PURE__ */ jsx13(
4693
+ "button",
4694
+ {
4695
+ type: "submit",
4696
+ disabled: busy,
4697
+ 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",
4698
+ children: busy ? "Saving\u2026" : "Save"
4699
+ }
4700
+ ),
4701
+ /* @__PURE__ */ jsx13(
4702
+ "button",
4703
+ {
4704
+ type: "button",
4705
+ onClick: onCancel,
4706
+ className: "rounded-md border border-border px-3 py-1.5 text-sm font-medium text-muted-foreground transition hover:bg-accent/30",
4707
+ children: "Cancel"
4708
+ }
4709
+ )
4710
+ ] })
4711
+ ]
4712
+ }
4713
+ );
4714
+ }
4715
+ function DraftField({ column, id, value, invalid, describedBy, onValue }) {
4716
+ const shared = {
4717
+ id,
4718
+ "aria-invalid": invalid ? true : void 0,
4719
+ "aria-describedby": describedBy
4720
+ };
4721
+ if (column.kind === "boolean") {
4722
+ return /* @__PURE__ */ jsx13(
4723
+ "input",
4724
+ {
4725
+ ...shared,
4726
+ type: "checkbox",
4727
+ checked: value === true,
4728
+ onChange: (event) => onValue(event.target.checked),
4729
+ className: "h-4 w-4 rounded border-border accent-primary"
4730
+ }
4731
+ );
4732
+ }
4733
+ if (column.kind === "select") {
4734
+ return /* @__PURE__ */ jsxs11(
4735
+ "select",
4736
+ {
4737
+ ...shared,
4738
+ className: INPUT_CLASS,
4739
+ value: typeof value === "string" ? value : "",
4740
+ onChange: (event) => onValue(event.target.value === "" ? null : event.target.value),
4741
+ children: [
4742
+ /* @__PURE__ */ jsx13("option", { value: "", children: "\u2014" }),
4743
+ column.options.map((option) => /* @__PURE__ */ jsx13("option", { value: option.value, children: option.label }, option.value))
4744
+ ]
4745
+ }
4746
+ );
4747
+ }
4748
+ if (column.kind === "text" && column.multiline === true) {
4749
+ return /* @__PURE__ */ jsx13(
4750
+ "textarea",
4751
+ {
4752
+ ...shared,
4753
+ className: INPUT_CLASS,
4754
+ rows: 3,
4755
+ value: typeof value === "string" ? value : "",
4756
+ onChange: (event) => onValue(event.target.value === "" ? null : event.target.value)
4757
+ }
4758
+ );
4759
+ }
4760
+ if (column.kind === "number" || column.kind === "currency") {
4761
+ return /* @__PURE__ */ jsx13(
4762
+ "input",
4763
+ {
4764
+ ...shared,
4765
+ className: INPUT_CLASS,
4766
+ type: "text",
4767
+ inputMode: "decimal",
4768
+ value: value === null ? "" : String(value),
4769
+ onChange: (event) => {
4770
+ const raw = event.target.value;
4771
+ if (raw.trim() === "") {
4772
+ onValue(null);
4773
+ return;
4774
+ }
4775
+ const parsed = readRecordGridCell(column, raw);
4776
+ onValue(parsed.succeeded ? parsed.value : raw);
4777
+ }
4778
+ }
4779
+ );
4780
+ }
4781
+ return /* @__PURE__ */ jsx13(
4782
+ "input",
4783
+ {
4784
+ ...shared,
4785
+ className: INPUT_CLASS,
4786
+ type: column.kind === "date" ? "date" : "text",
4787
+ value: typeof value === "string" ? value : "",
4788
+ onChange: (event) => onValue(event.target.value === "" ? null : event.target.value)
4789
+ }
4790
+ );
4791
+ }
4792
+
4793
+ // src/web-react/agent-session-controls.tsx
4794
+ import { useMemo as useMemo8, useState as useState14 } from "react";
4795
+ import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
3574
4796
  var HARNESS_LABELS = {
3575
4797
  opencode: "OpenCode (any model)",
3576
4798
  "claude-code": "Claude Code (Anthropic)",
@@ -3590,12 +4812,12 @@ function harnessLabel(h) {
3590
4812
  return HARNESS_LABELS[h] ?? h;
3591
4813
  }
3592
4814
  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" }) });
4815
+ return /* @__PURE__ */ jsx14("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx14("path", { d: "m6 9 6 6 6-6" }) });
3594
4816
  }
3595
4817
  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" })
4818
+ return /* @__PURE__ */ jsxs12("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
4819
+ /* @__PURE__ */ jsx14("circle", { cx: "12", cy: "12", r: "3" }),
4820
+ /* @__PURE__ */ jsx14("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
4821
  ] });
3600
4822
  }
3601
4823
  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 +4826,11 @@ function HarnessPicker({
3604
4826
  onChange,
3605
4827
  available
3606
4828
  }) {
3607
- const [open, setOpen] = useState13(false);
4829
+ const [open, setOpen] = useState14(false);
3608
4830
  const { containerRef, triggerProps } = usePopover(open, setOpen);
3609
4831
  const options = available ?? Object.keys(HARNESS_LABELS);
3610
- return /* @__PURE__ */ jsxs11("div", { ref: containerRef, className: "relative inline-flex", children: [
3611
- /* @__PURE__ */ jsxs11(
4832
+ return /* @__PURE__ */ jsxs12("div", { ref: containerRef, className: "relative inline-flex", children: [
4833
+ /* @__PURE__ */ jsxs12(
3612
4834
  "button",
3613
4835
  {
3614
4836
  type: "button",
@@ -3617,12 +4839,12 @@ function HarnessPicker({
3617
4839
  title: "Agent backend",
3618
4840
  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
4841
  children: [
3620
- /* @__PURE__ */ jsx13("span", { className: "truncate", children: harnessLabel(value) }),
3621
- /* @__PURE__ */ jsx13(ChevronDown2, { className: "h-3.5 w-3.5 text-muted-foreground" })
4842
+ /* @__PURE__ */ jsx14("span", { className: "truncate", children: harnessLabel(value) }),
4843
+ /* @__PURE__ */ jsx14(ChevronDown2, { className: "h-3.5 w-3.5 text-muted-foreground" })
3622
4844
  ]
3623
4845
  }
3624
4846
  ),
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(
4847
+ open && /* @__PURE__ */ jsx14("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__ */ jsx14(
3626
4848
  "button",
3627
4849
  {
3628
4850
  type: "button",
@@ -3641,7 +4863,7 @@ function HarnessPicker({
3641
4863
  }
3642
4864
  function useCoherentHandlers(props) {
3643
4865
  const { model, models, harness, onModelChange, onHarnessChange } = props;
3644
- const canonicalIds = useMemo7(() => models.map((m) => m.id), [models]);
4866
+ const canonicalIds = useMemo8(() => models.map((m) => m.id), [models]);
3645
4867
  const onModel = (next) => {
3646
4868
  onModelChange(next);
3647
4869
  const nextHarness = snapHarnessToModel(harness, next);
@@ -3669,11 +4891,11 @@ function AgentSessionControls(props) {
3669
4891
  className
3670
4892
  } = props;
3671
4893
  const { onModel, onHarness } = useCoherentHandlers(props);
3672
- const [open, setOpen] = useState13(false);
4894
+ const [open, setOpen] = useState14(false);
3673
4895
  const { containerRef: popoverRef, triggerProps } = usePopover(open, setOpen);
3674
4896
  const selectedModel = models.find((m) => m.id === model);
3675
4897
  const showEffort = selectedModel?.supportsReasoning ?? true;
3676
- const modelPicker = /* @__PURE__ */ jsx13(
4898
+ const modelPicker = /* @__PURE__ */ jsx14(
3677
4899
  ModelPicker,
3678
4900
  {
3679
4901
  value: model,
@@ -3684,17 +4906,17 @@ function AgentSessionControls(props) {
3684
4906
  }
3685
4907
  );
3686
4908
  if (layout === "inline") {
3687
- return /* @__PURE__ */ jsxs11("div", { className: `flex items-center gap-1.5 ${className ?? ""}`, children: [
4909
+ return /* @__PURE__ */ jsxs12("div", { className: `flex items-center gap-1.5 ${className ?? ""}`, children: [
3688
4910
  modelPicker,
3689
- showHarness && /* @__PURE__ */ jsx13(HarnessPicker, { value: harness, onChange: onHarness, available: availableHarnesses }),
3690
- showEffort && /* @__PURE__ */ jsx13(EffortPicker, { value: effort, onChange: onEffortChange })
4911
+ showHarness && /* @__PURE__ */ jsx14(HarnessPicker, { value: harness, onChange: onHarness, available: availableHarnesses }),
4912
+ showEffort && /* @__PURE__ */ jsx14(EffortPicker, { value: effort, onChange: onEffortChange })
3691
4913
  ] });
3692
4914
  }
3693
4915
  const hasAdvanced = showHarness || showEffort;
3694
- return /* @__PURE__ */ jsxs11("div", { className: `flex items-center gap-1.5 ${className ?? ""}`, children: [
4916
+ return /* @__PURE__ */ jsxs12("div", { className: `flex items-center gap-1.5 ${className ?? ""}`, children: [
3695
4917
  modelPicker,
3696
- hasAdvanced && /* @__PURE__ */ jsxs11("div", { ref: popoverRef, className: "relative inline-flex", children: [
3697
- /* @__PURE__ */ jsx13(
4918
+ hasAdvanced && /* @__PURE__ */ jsxs12("div", { ref: popoverRef, className: "relative inline-flex", children: [
4919
+ /* @__PURE__ */ jsx14(
3698
4920
  "button",
3699
4921
  {
3700
4922
  type: "button",
@@ -3703,19 +4925,19 @@ function AgentSessionControls(props) {
3703
4925
  title: "Model settings \u2014 pick the agent backend and how hard it thinks",
3704
4926
  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
4927
  "data-state": open ? "open" : "closed",
3706
- children: /* @__PURE__ */ jsx13(GearGlyph, { className: "h-4 w-4" })
4928
+ children: /* @__PURE__ */ jsx14(GearGlyph, { className: "h-4 w-4" })
3707
4929
  }
3708
4930
  ),
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." })
4931
+ open && /* @__PURE__ */ jsxs12("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: [
4932
+ showHarness && /* @__PURE__ */ jsxs12("div", { className: "space-y-1.5", children: [
4933
+ /* @__PURE__ */ jsx14("p", { className: "text-xs font-medium text-foreground", children: "Agent backend" }),
4934
+ /* @__PURE__ */ jsx14(HarnessPicker, { value: harness, onChange: onHarness, available: availableHarnesses }),
4935
+ /* @__PURE__ */ jsx14("p", { className: "text-[11px] leading-snug text-muted-foreground", children: "The engine that runs the agent. Switching it keeps your model choice compatible." })
3714
4936
  ] }),
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." })
4937
+ showEffort && /* @__PURE__ */ jsxs12("div", { className: "space-y-1.5", children: [
4938
+ /* @__PURE__ */ jsx14("p", { className: "text-xs font-medium text-foreground", children: "Thinking" }),
4939
+ /* @__PURE__ */ jsx14(EffortPicker, { value: effort, onChange: onEffortChange, label: "" }),
4940
+ /* @__PURE__ */ jsx14("p", { className: "text-[11px] leading-snug text-muted-foreground", children: "How hard the agent thinks before answering. Higher is slower but more thorough." })
3719
4941
  ] })
3720
4942
  ] })
3721
4943
  ] })
@@ -3723,7 +4945,7 @@ function AgentSessionControls(props) {
3723
4945
  }
3724
4946
 
3725
4947
  // src/web-react/index.tsx
3726
- import { Fragment as Fragment7, jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
4948
+ import { Fragment as Fragment8, jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
3727
4949
  function formatModelCost(msg, models) {
3728
4950
  if (msg.promptTokens == null && msg.completionTokens == null) return null;
3729
4951
  const pricing = models.find((m) => m.id === msg.modelUsed)?.pricing;
@@ -3737,41 +4959,41 @@ function formatTokensPerSecond(msg) {
3737
4959
  return `${Math.round(msg.completionTokens / (msg.durationMs / 1e3))} tok/s`;
3738
4960
  }
3739
4961
  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(
4962
+ return /* @__PURE__ */ jsxs13("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: [
4963
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2 border-b border-border px-4 py-3", children: [
4964
+ /* @__PURE__ */ jsx15(
3743
4965
  "span",
3744
4966
  {
3745
4967
  className: `h-2 w-2 shrink-0 rounded-full ${run.status === "running" ? "bg-warning" : run.status === "error" ? "bg-destructive" : "bg-success"}`
3746
4968
  }
3747
4969
  ),
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 })
4970
+ /* @__PURE__ */ jsxs13("div", { className: "min-w-0 flex-1", children: [
4971
+ /* @__PURE__ */ jsx15("p", { className: "truncate text-sm font-semibold", children: run.title }),
4972
+ /* @__PURE__ */ jsx15("p", { className: "truncate font-mono text-[11px] text-muted-foreground", children: run.toolName })
3751
4973
  ] }),
3752
- /* @__PURE__ */ jsx14(
4974
+ /* @__PURE__ */ jsx15(
3753
4975
  "button",
3754
4976
  {
3755
4977
  type: "button",
3756
4978
  onClick: onClose,
3757
4979
  "aria-label": "Close",
3758
4980
  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" }) })
4981
+ children: /* @__PURE__ */ jsx15("svg", { className: "h-4 w-4", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx15("path", { d: "M18 6 6 18M6 6l12 12" }) })
3760
4982
  }
3761
4983
  )
3762
4984
  ] }),
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() })
4985
+ /* @__PURE__ */ jsxs13("div", { className: "flex-1 space-y-3 overflow-y-auto p-4", children: [
4986
+ run.steps.length === 0 && /* @__PURE__ */ jsx15("p", { className: "text-sm text-muted-foreground", children: "No steps recorded yet." }),
4987
+ run.steps.map((step, i) => /* @__PURE__ */ jsxs13("div", { className: "rounded-lg border border-border/60 bg-background", children: [
4988
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-baseline gap-2 border-b border-border/40 px-3 py-1.5", children: [
4989
+ /* @__PURE__ */ jsx15("span", { className: `font-mono text-[11px] ${step.status === "error" ? "text-destructive" : "text-muted-foreground"}`, children: step.status === "error" ? "\u2717" : "$" }),
4990
+ /* @__PURE__ */ jsx15("code", { className: "min-w-0 flex-1 truncate font-mono text-xs", children: step.label }),
4991
+ /* @__PURE__ */ jsx15("span", { className: "shrink-0 text-[10px] text-muted-foreground", children: new Date(step.at).toLocaleTimeString() })
3770
4992
  ] }),
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 })
4993
+ step.detail && /* @__PURE__ */ jsx15("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
4994
  ] }, i))
3773
4995
  ] }),
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." })
4996
+ /* @__PURE__ */ jsx15("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
4997
  ] });
3776
4998
  }
3777
4999
  function pendingApprovalOf(call) {
@@ -3785,20 +5007,20 @@ function ChatEmptyState({
3785
5007
  subline = "Describe the outcome you want. The agent works through it step by step, and pauses for your approval before anything irreversible.",
3786
5008
  doors
3787
5009
  }) {
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(
5010
+ return /* @__PURE__ */ jsxs13("div", { className: "mx-auto flex w-full max-w-2xl flex-col items-center px-6 py-12 text-center sm:py-20", children: [
5011
+ /* @__PURE__ */ jsx15("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__ */ jsx15(BrandMark, { size: 32, className: "shrink-0" }) }),
5012
+ /* @__PURE__ */ jsx15("p", { className: "text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground", children: productName }),
5013
+ /* @__PURE__ */ jsx15("h2", { className: "mt-1.5 text-balance text-2xl font-semibold leading-tight text-foreground sm:text-[28px]", children: headline }),
5014
+ subline && /* @__PURE__ */ jsx15("p", { className: "mt-3 max-w-md text-[15px] leading-relaxed text-muted-foreground", children: subline }),
5015
+ doors && doors.length > 0 && /* @__PURE__ */ jsx15("div", { className: "mt-7 grid w-full gap-2.5 sm:grid-cols-3", children: doors.slice(0, 3).map((door, i) => /* @__PURE__ */ jsxs13(
3794
5016
  "button",
3795
5017
  {
3796
5018
  type: "button",
3797
5019
  onClick: door.onSelect,
3798
5020
  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
5021
  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 })
5022
+ /* @__PURE__ */ jsx15("span", { className: "text-sm font-semibold text-foreground", children: door.label }),
5023
+ door.description && /* @__PURE__ */ jsx15("span", { className: "mt-0.5 text-[12px] leading-snug text-muted-foreground", children: door.description })
3802
5024
  ]
3803
5025
  },
3804
5026
  i
@@ -3807,26 +5029,26 @@ function ChatEmptyState({
3807
5029
  }
3808
5030
  function ToolGlyph({ name, className }) {
3809
5031
  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" })
5032
+ return /* @__PURE__ */ jsxs13("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
5033
+ /* @__PURE__ */ jsx15("polyline", { points: "4 17 10 11 4 5" }),
5034
+ /* @__PURE__ */ jsx15("line", { x1: "12", y1: "19", x2: "20", y2: "19" })
3813
5035
  ] });
3814
5036
  }
3815
5037
  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" })
5038
+ return /* @__PURE__ */ jsxs13("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
5039
+ /* @__PURE__ */ jsx15("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
5040
+ /* @__PURE__ */ jsx15("path", { d: "M14 2v6h6M9 15l2 2 4-4" })
3819
5041
  ] });
3820
5042
  }
3821
5043
  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" })
5044
+ return /* @__PURE__ */ jsxs13("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": true, children: [
5045
+ /* @__PURE__ */ jsx15("circle", { cx: "12", cy: "12", r: "9" }),
5046
+ /* @__PURE__ */ jsx15("path", { d: "M12 7v5l3 3" })
3825
5047
  ] });
3826
5048
  }
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" })
5049
+ return /* @__PURE__ */ jsxs13("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
5050
+ /* @__PURE__ */ jsx15("path", { d: "M12 3v3m0 12v3M3 12h3m12 0h3" }),
5051
+ /* @__PURE__ */ jsx15("circle", { cx: "12", cy: "12", r: "4" })
3830
5052
  ] });
3831
5053
  }
3832
5054
  function toolOutcomeOf(call) {
@@ -3894,40 +5116,40 @@ function truncate(v, max = 240) {
3894
5116
  function KvRows({ data }) {
3895
5117
  const entries = Object.entries(data).filter(([, v]) => v !== void 0 && v !== null && v !== "");
3896
5118
  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) })
5119
+ return /* @__PURE__ */ jsx15("dl", { className: "grid grid-cols-[auto_1fr] gap-x-3 gap-y-1", children: entries.map(([k, v]) => /* @__PURE__ */ jsxs13("div", { className: "contents", children: [
5120
+ /* @__PURE__ */ jsx15("dt", { className: "font-mono text-[11px] text-muted-foreground", children: k }),
5121
+ /* @__PURE__ */ jsx15("dd", { className: "min-w-0 whitespace-pre-wrap break-words font-mono text-[11px] text-muted-foreground", children: truncate(v) })
3900
5122
  ] }, k)) });
3901
5123
  }
3902
5124
  function ShellDetail({ call }) {
3903
5125
  const outcome = toolOutcomeOf(call);
3904
5126
  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: [
5127
+ return /* @__PURE__ */ jsxs13("div", { className: "overflow-hidden rounded-md bg-zinc-900 font-mono text-[11px] leading-relaxed", children: [
5128
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2 px-3 pt-2 text-zinc-400", children: [
5129
+ /* @__PURE__ */ jsx15("span", { className: "select-none text-zinc-500", children: "$" }),
5130
+ /* @__PURE__ */ jsx15("span", { className: "min-w-0 flex-1 truncate text-zinc-200", children: String(call.args?.command ?? "") }),
5131
+ r.exitCode != null && /* @__PURE__ */ jsxs13("span", { className: r.exitCode === 0 ? "text-success" : "text-destructive", children: [
3910
5132
  "exit ",
3911
5133
  r.exitCode
3912
5134
  ] })
3913
5135
  ] }),
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)" })
5136
+ /* @__PURE__ */ jsx15("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
5137
  ] });
3916
5138
  }
3917
5139
  function DefaultToolDetail({ call }) {
3918
5140
  const result = call.result;
3919
5141
  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 })
5142
+ return /* @__PURE__ */ jsxs13("div", { className: "space-y-2", children: [
5143
+ call.args && Object.keys(call.args).length > 0 && /* @__PURE__ */ jsxs13("div", { children: [
5144
+ /* @__PURE__ */ jsx15("p", { className: "mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground", children: "Called with" }),
5145
+ /* @__PURE__ */ jsx15(KvRows, { data: call.args })
3924
5146
  ] }),
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) })
5147
+ envelope ? /* @__PURE__ */ jsxs13("div", { children: [
5148
+ /* @__PURE__ */ jsx15("p", { className: "mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground", children: envelope.ok === false ? "Failed" : "Result" }),
5149
+ envelope.ok === false ? /* @__PURE__ */ jsx15("p", { className: "text-xs text-destructive", children: envelope.message ?? "Tool failed" }) : envelope.result && typeof envelope.result === "object" ? /* @__PURE__ */ jsx15(KvRows, { data: envelope.result }) : envelope.result != null ? /* @__PURE__ */ jsx15("p", { className: "font-mono text-[11px] text-muted-foreground", children: truncate(envelope.result) }) : null
5150
+ ] }) : result != null ? /* @__PURE__ */ jsxs13("div", { children: [
5151
+ /* @__PURE__ */ jsx15("p", { className: "mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground", children: "Result" }),
5152
+ /* @__PURE__ */ jsx15("p", { className: "font-mono text-[11px] text-muted-foreground", children: truncate(result) })
3931
5153
  ] }) : null
3932
5154
  ] });
3933
5155
  }
@@ -3938,23 +5160,23 @@ function ProposalCard({
3938
5160
  approval,
3939
5161
  renderers
3940
5162
  }) {
3941
- const [expanded, setExpanded] = useState14(false);
5163
+ const [expanded, setExpanded] = useState15(false);
3942
5164
  const { summary, meta } = proposalPreview(call);
3943
5165
  const custom = renderers?.[call.name]?.(call, message);
3944
5166
  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)) })
5167
+ return /* @__PURE__ */ jsxs13("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: [
5168
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-start gap-2.5 px-4 pt-3.5", children: [
5169
+ /* @__PURE__ */ jsx15("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__ */ jsx15(ToolGlyph, { name: call.name, className: "h-3.5 w-3.5" }) }),
5170
+ /* @__PURE__ */ jsxs13("div", { className: "min-w-0 flex-1", children: [
5171
+ /* @__PURE__ */ jsx15("p", { className: "text-[10px] font-semibold uppercase tracking-wider text-warning-foreground", children: "Needs your approval" }),
5172
+ /* @__PURE__ */ jsx15("p", { className: "mt-0.5 text-[15px] font-semibold leading-snug text-foreground", children: friendlyToolTitle(call) }),
5173
+ summary && /* @__PURE__ */ jsx15("p", { className: "mt-1 text-[13px] leading-relaxed text-muted-foreground", children: summary }),
5174
+ meta.length > 0 && /* @__PURE__ */ jsx15("div", { className: "mt-1.5 flex flex-wrap items-center gap-1.5", children: meta.map((m, i) => /* @__PURE__ */ jsx15("span", { className: "rounded-full bg-muted/60 px-2 py-0.5 text-[11px] font-medium text-muted-foreground", children: m }, i)) })
3953
5175
  ] })
3954
5176
  ] }),
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(
5177
+ /* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap items-center gap-2 px-4 pb-3.5 pt-3", children: [
5178
+ approval ? /* @__PURE__ */ jsxs13(Fragment8, { children: [
5179
+ /* @__PURE__ */ jsx15(
3958
5180
  "button",
3959
5181
  {
3960
5182
  type: "button",
@@ -3964,7 +5186,7 @@ function ProposalCard({
3964
5186
  children: "Approve & run"
3965
5187
  }
3966
5188
  ),
3967
- /* @__PURE__ */ jsx14(
5189
+ /* @__PURE__ */ jsx15(
3968
5190
  "button",
3969
5191
  {
3970
5192
  type: "button",
@@ -3974,8 +5196,8 @@ function ProposalCard({
3974
5196
  children: "Reject"
3975
5197
  }
3976
5198
  )
3977
- ] }) : /* @__PURE__ */ jsx14("span", { className: "text-[12px] font-medium text-muted-foreground", children: "Awaiting approval\u2026" }),
3978
- /* @__PURE__ */ jsxs12(
5199
+ ] }) : /* @__PURE__ */ jsx15("span", { className: "text-[12px] font-medium text-muted-foreground", children: "Awaiting approval\u2026" }),
5200
+ /* @__PURE__ */ jsxs13(
3979
5201
  "button",
3980
5202
  {
3981
5203
  type: "button",
@@ -3984,23 +5206,23 @@ function ProposalCard({
3984
5206
  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
5207
  children: [
3986
5208
  expanded ? "Hide details" : "View details",
3987
- /* @__PURE__ */ jsx14(ChevronDown, { className: `h-3 w-3 transition-transform ${expanded ? "rotate-180" : ""}` })
5209
+ /* @__PURE__ */ jsx15(ChevronDown, { className: `h-3 w-3 transition-transform ${expanded ? "rotate-180" : ""}` })
3988
5210
  ]
3989
5211
  }
3990
5212
  )
3991
5213
  ] }),
3992
- expanded && /* @__PURE__ */ jsx14("div", { className: "border-t border-warning/20 px-4 py-3 text-xs", children: custom ?? /* @__PURE__ */ jsx14(DefaultToolDetail, { call }) })
5214
+ expanded && /* @__PURE__ */ jsx15("div", { className: "border-t border-warning/20 px-4 py-3 text-xs", children: custom ?? /* @__PURE__ */ jsx15(DefaultToolDetail, { call }) })
3993
5215
  ] });
3994
5216
  }
3995
5217
  function FollowupCard({ call }) {
3996
5218
  const a = call.args ?? {};
3997
5219
  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) })
5220
+ return /* @__PURE__ */ jsxs13("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: [
5221
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2", children: [
5222
+ /* @__PURE__ */ jsx15(ToolGlyph, { name: call.name, className: "h-3.5 w-3.5 shrink-0 text-primary/80" }),
5223
+ /* @__PURE__ */ jsx15("span", { className: "min-w-0 flex-1 truncate font-medium text-foreground", children: friendlyToolTitle(call) })
4002
5224
  ] }),
4003
- when && /* @__PURE__ */ jsx14("p", { className: "mt-0.5 pl-[22px] text-[12px] text-muted-foreground", children: when })
5225
+ when && /* @__PURE__ */ jsx15("p", { className: "mt-0.5 pl-[22px] text-[12px] text-muted-foreground", children: when })
4004
5226
  ] });
4005
5227
  }
4006
5228
  function ToolCallCard({
@@ -4010,13 +5232,13 @@ function ToolCallCard({
4010
5232
  onOpenRun,
4011
5233
  renderers
4012
5234
  }) {
4013
- const [expanded, setExpanded] = useState14(false);
5235
+ const [expanded, setExpanded] = useState15(false);
4014
5236
  const pending = call.status === "done" ? pendingApprovalOf(call) : null;
4015
5237
  const kind = blockKindOf(call);
4016
5238
  const failed = call.status === "error" || toolOutcomeOf(call)?.ok === false;
4017
5239
  const custom = renderers?.[call.name]?.(call, message);
4018
5240
  if (pending) {
4019
- return /* @__PURE__ */ jsx14(
5241
+ return /* @__PURE__ */ jsx15(
4020
5242
  ProposalCard,
4021
5243
  {
4022
5244
  call,
@@ -4028,16 +5250,16 @@ function ToolCallCard({
4028
5250
  );
4029
5251
  }
4030
5252
  if (kind === "followup" && !failed) {
4031
- return /* @__PURE__ */ jsx14(FollowupCard, { call });
5253
+ return /* @__PURE__ */ jsx15(FollowupCard, { call });
4032
5254
  }
4033
5255
  const isCommand = kind === "command";
4034
- return /* @__PURE__ */ jsxs12(
5256
+ return /* @__PURE__ */ jsxs13(
4035
5257
  "div",
4036
5258
  {
4037
5259
  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
5260
  children: [
4039
- /* @__PURE__ */ jsxs12("div", { className: "flex w-full items-center gap-2 px-3 py-2", children: [
4040
- /* @__PURE__ */ jsxs12(
5261
+ /* @__PURE__ */ jsxs13("div", { className: "flex w-full items-center gap-2 px-3 py-2", children: [
5262
+ /* @__PURE__ */ jsxs13(
4041
5263
  "button",
4042
5264
  {
4043
5265
  type: "button",
@@ -4045,14 +5267,14 @@ function ToolCallCard({
4045
5267
  "aria-expanded": expanded,
4046
5268
  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
5269
  children: [
4048
- /* @__PURE__ */ jsx14(
5270
+ /* @__PURE__ */ jsx15(
4049
5271
  "span",
4050
5272
  {
4051
5273
  className: `h-2 w-2 shrink-0 rounded-full ${call.status === "running" ? "animate-pulse bg-warning" : failed ? "bg-destructive" : "bg-success"}`
4052
5274
  }
4053
5275
  ),
4054
- /* @__PURE__ */ jsx14(ToolGlyph, { name: call.name, className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
4055
- /* @__PURE__ */ jsx14(
5276
+ /* @__PURE__ */ jsx15(ToolGlyph, { name: call.name, className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
5277
+ /* @__PURE__ */ jsx15(
4056
5278
  "span",
4057
5279
  {
4058
5280
  className: `min-w-0 flex-1 truncate ${isCommand ? "font-mono text-[12px] tracking-tight text-foreground/90" : "font-medium"}`,
@@ -4062,8 +5284,8 @@ function ToolCallCard({
4062
5284
  ]
4063
5285
  }
4064
5286
  ),
4065
- /* @__PURE__ */ jsx14("span", { className: "shrink-0 text-[11px] text-muted-foreground", children: call.status === "running" ? "running\u2026" : failed ? "failed" : "done" }),
4066
- /* @__PURE__ */ jsx14(
5287
+ /* @__PURE__ */ jsx15("span", { className: "shrink-0 text-[11px] text-muted-foreground", children: call.status === "running" ? "running\u2026" : failed ? "failed" : "done" }),
5288
+ /* @__PURE__ */ jsx15(
4067
5289
  "button",
4068
5290
  {
4069
5291
  type: "button",
@@ -4071,13 +5293,13 @@ function ToolCallCard({
4071
5293
  "aria-label": expanded ? "Collapse details" : "Expand details",
4072
5294
  "aria-expanded": expanded,
4073
5295
  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" : ""}` })
5296
+ children: /* @__PURE__ */ jsx15(ChevronDown, { className: `h-3 w-3 text-muted-foreground transition-transform ${expanded ? "rotate-180" : ""}` })
4075
5297
  }
4076
5298
  )
4077
5299
  ] }),
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(
5300
+ expanded && /* @__PURE__ */ jsxs13("div", { className: "border-t border-border/40 px-3 py-2.5", children: [
5301
+ custom ?? (call.name === "sandbox_run_command" ? /* @__PURE__ */ jsx15(ShellDetail, { call }) : /* @__PURE__ */ jsx15(DefaultToolDetail, { call })),
5302
+ onOpenRun && call.name.startsWith("sandbox_") && /* @__PURE__ */ jsx15(
4081
5303
  "button",
4082
5304
  {
4083
5305
  type: "button",
@@ -4092,7 +5314,7 @@ function ToolCallCard({
4092
5314
  );
4093
5315
  }
4094
5316
  function StreamingCaret() {
4095
- return /* @__PURE__ */ jsx14(
5317
+ return /* @__PURE__ */ jsx15(
4096
5318
  "span",
4097
5319
  {
4098
5320
  className: "ml-0.5 inline-block h-[1.1em] w-[3px] translate-y-[2px] animate-pulse rounded-sm bg-foreground/70",
@@ -4108,11 +5330,11 @@ function SegmentText({
4108
5330
  messageClassName
4109
5331
  }) {
4110
5332
  const text = useSmoothText(content, streaming);
4111
- const body = useMemo8(() => renderBody(text), [renderBody, text]);
5333
+ const body = useMemo9(() => renderBody(text), [renderBody, text]);
4112
5334
  if (!content.trim() && !showCaret) return null;
4113
- return /* @__PURE__ */ jsxs12("div", { className: messageClassName, children: [
5335
+ return /* @__PURE__ */ jsxs13("div", { className: messageClassName, children: [
4114
5336
  body,
4115
- showCaret && /* @__PURE__ */ jsx14(StreamingCaret, {})
5337
+ showCaret && /* @__PURE__ */ jsx15(StreamingCaret, {})
4116
5338
  ] });
4117
5339
  }
4118
5340
  var COLLAPSE_TOOL_RUN_AT = 3;
@@ -4136,7 +5358,7 @@ function SegmentedBody({
4136
5358
  const leftoverToolCalls = (msg.toolCalls ?? []).filter(
4137
5359
  (tc) => !segmentToolIds.has(tc.id)
4138
5360
  );
4139
- const renderToolCard = (call) => /* @__PURE__ */ jsx14(
5361
+ const renderToolCard = (call) => /* @__PURE__ */ jsx15(
4140
5362
  ToolCallCard,
4141
5363
  {
4142
5364
  call,
@@ -4159,9 +5381,9 @@ function SegmentedBody({
4159
5381
  else groups.push({ kind: "tools", index: i, calls: [seg.call] });
4160
5382
  }
4161
5383
  }
4162
- return /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-2", children: [
5384
+ return /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-2", children: [
4163
5385
  groups.map(
4164
- (g) => g.kind === "text" ? /* @__PURE__ */ jsx14(
5386
+ (g) => g.kind === "text" ? /* @__PURE__ */ jsx15(
4165
5387
  SegmentText,
4166
5388
  {
4167
5389
  content: g.content,
@@ -4171,24 +5393,24 @@ function SegmentedBody({
4171
5393
  messageClassName
4172
5394
  },
4173
5395
  `text-${g.index}`
4174
- ) : !streaming && g.calls.length >= COLLAPSE_TOOL_RUN_AT && !g.calls.some(isImportantTool) ? /* @__PURE__ */ jsxs12(
5396
+ ) : !streaming && g.calls.length >= COLLAPSE_TOOL_RUN_AT && !g.calls.some(isImportantTool) ? /* @__PURE__ */ jsxs13(
4175
5397
  "details",
4176
5398
  {
4177
5399
  className: "rounded-lg border-l-2 border-border/70 bg-muted/20 px-3 py-2",
4178
5400
  children: [
4179
- /* @__PURE__ */ jsxs12("summary", { className: "cursor-pointer select-none text-xs font-medium text-muted-foreground", children: [
5401
+ /* @__PURE__ */ jsxs13("summary", { className: "cursor-pointer select-none text-xs font-medium text-muted-foreground", children: [
4180
5402
  "Worked through ",
4181
5403
  g.calls.length,
4182
5404
  " steps"
4183
5405
  ] }),
4184
- /* @__PURE__ */ jsx14("div", { className: "mt-2 flex flex-col gap-2", children: g.calls.map(renderToolCard) })
5406
+ /* @__PURE__ */ jsx15("div", { className: "mt-2 flex flex-col gap-2", children: g.calls.map(renderToolCard) })
4185
5407
  ]
4186
5408
  },
4187
5409
  `tools-${g.index}`
4188
- ) : /* @__PURE__ */ jsx14("div", { className: "flex flex-col gap-2", children: g.calls.map(renderToolCard) }, `tools-${g.index}`)
5410
+ ) : /* @__PURE__ */ jsx15("div", { className: "flex flex-col gap-2", children: g.calls.map(renderToolCard) }, `tools-${g.index}`)
4189
5411
  ),
4190
5412
  leftoverToolCalls.map(renderToolCard),
4191
- streaming && segments[lastIndex]?.kind === "tool" && /* @__PURE__ */ jsx14(StreamingCaret, {})
5413
+ streaming && segments[lastIndex]?.kind === "tool" && /* @__PURE__ */ jsx15(StreamingCaret, {})
4192
5414
  ] });
4193
5415
  }
4194
5416
  function AssistantMessageImpl({
@@ -4208,40 +5430,40 @@ function AssistantMessageImpl({
4208
5430
  }) {
4209
5431
  const content = useSmoothText(msg.content, streaming);
4210
5432
  const reasoning = useSmoothText(msg.reasoning ?? "", streaming);
4211
- const body = useMemo8(() => renderBody(content), [renderBody, content]);
5433
+ const body = useMemo9(() => renderBody(content), [renderBody, content]);
4212
5434
  const segments = msg.segments;
4213
5435
  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);
5436
+ const reasoningScrollRef = useRef10(null);
5437
+ const thinkStartRef = useRef10(null);
5438
+ const thinkMsRef = useRef10(null);
4217
5439
  if (streaming && reasoning && !hasAnswerText && thinkStartRef.current === null) {
4218
5440
  thinkStartRef.current = performance.now();
4219
5441
  }
4220
5442
  if (hasAnswerText && thinkStartRef.current !== null && thinkMsRef.current === null) {
4221
5443
  thinkMsRef.current = performance.now() - thinkStartRef.current;
4222
5444
  }
4223
- useEffect10(() => {
5445
+ useEffect11(() => {
4224
5446
  const el = reasoningScrollRef.current;
4225
5447
  if (el && streaming && !hasAnswerText) el.scrollTop = el.scrollHeight;
4226
5448
  }, [reasoning, streaming, hasAnswerText]);
4227
5449
  const thinkingSeconds = useThinkingSeconds(
4228
5450
  streaming && !!reasoning && !hasAnswerText
4229
5451
  );
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) })
5452
+ return /* @__PURE__ */ jsxs13("div", { className: "mx-auto w-full max-w-3xl px-6 py-3", children: [
5453
+ /* @__PURE__ */ jsxs13("div", { className: "mb-1 flex items-baseline gap-2 text-[11px] tracking-wide text-muted-foreground", children: [
5454
+ /* @__PURE__ */ jsx15("span", { className: "font-semibold uppercase", children: agentLabel }),
5455
+ msg.modelUsed && /* @__PURE__ */ jsx15("span", { className: "font-mono normal-case", children: msg.modelUsed }),
5456
+ formatTokensPerSecond(msg) && /* @__PURE__ */ jsx15("span", { children: formatTokensPerSecond(msg) }),
5457
+ formatModelCost(msg, models) && /* @__PURE__ */ jsx15("span", { children: formatModelCost(msg, models) })
4236
5458
  ] }),
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: [
5459
+ reasoning && /* @__PURE__ */ jsxs13("details", { className: "mb-2 rounded-lg border-l-2 border-border/70 bg-muted/20 px-3 py-2", open: !hasAnswerText, children: [
5460
+ /* @__PURE__ */ jsx15("summary", { className: "cursor-pointer select-none text-xs font-medium text-muted-foreground", children: !hasAnswerText ? /* @__PURE__ */ jsxs13("span", { className: "animate-pulse", children: [
4239
5461
  "Thinking",
4240
5462
  thinkingSeconds >= 3 ? ` \xB7 ${thinkingSeconds}s` : "\u2026"
4241
5463
  ] }) : 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 })
5464
+ /* @__PURE__ */ jsx15("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
5465
  ] }),
4244
- segments && segments.length > 0 ? /* @__PURE__ */ jsx14(
5466
+ segments && segments.length > 0 ? /* @__PURE__ */ jsx15(
4245
5467
  SegmentedBody,
4246
5468
  {
4247
5469
  segments,
@@ -4253,12 +5475,12 @@ function AssistantMessageImpl({
4253
5475
  toolRenderers,
4254
5476
  messageClassName
4255
5477
  }
4256
- ) : /* @__PURE__ */ jsxs12(Fragment7, { children: [
4257
- /* @__PURE__ */ jsxs12("div", { className: messageClassName, children: [
5478
+ ) : /* @__PURE__ */ jsxs13(Fragment8, { children: [
5479
+ /* @__PURE__ */ jsxs13("div", { className: messageClassName, children: [
4258
5480
  body,
4259
- streaming && content && !msg.toolCalls?.length && /* @__PURE__ */ jsx14(StreamingCaret, {})
5481
+ streaming && content && !msg.toolCalls?.length && /* @__PURE__ */ jsx15(StreamingCaret, {})
4260
5482
  ] }),
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(
5483
+ msg.toolCalls && msg.toolCalls.length > 0 && /* @__PURE__ */ jsx15("div", { className: "mt-2 flex flex-col gap-1.5", children: msg.toolCalls.map((tc) => /* @__PURE__ */ jsx15(
4262
5484
  ToolCallCard,
4263
5485
  {
4264
5486
  call: tc,
@@ -4270,7 +5492,7 @@ function AssistantMessageImpl({
4270
5492
  tc.id
4271
5493
  )) })
4272
5494
  ] }),
4273
- durableCards && msg.parts && /* @__PURE__ */ jsx14(
5495
+ durableCards && msg.parts && /* @__PURE__ */ jsx15(
4274
5496
  DurableChatCards,
4275
5497
  {
4276
5498
  ...durableCards,
@@ -4279,7 +5501,7 @@ function AssistantMessageImpl({
4279
5501
  className: "mt-3"
4280
5502
  }
4281
5503
  ),
4282
- workProductCards && workProductPartsFromMessageParts(msg.parts).map((part) => /* @__PURE__ */ jsx14(
5504
+ workProductCards && workProductPartsFromMessageParts(msg.parts).map((part) => /* @__PURE__ */ jsx15(
4283
5505
  WorkProductCard,
4284
5506
  {
4285
5507
  part,
@@ -4289,7 +5511,7 @@ function AssistantMessageImpl({
4289
5511
  `${part.ref.id}:${part.ref.version}`
4290
5512
  )),
4291
5513
  renderExtras?.(msg),
4292
- resolveAttachmentUrl && attachmentPartsFromMessageParts(msg.parts).length > 0 && /* @__PURE__ */ jsx14("div", { className: "mt-2", children: /* @__PURE__ */ jsx14(
5514
+ resolveAttachmentUrl && attachmentPartsFromMessageParts(msg.parts).length > 0 && /* @__PURE__ */ jsx15("div", { className: "mt-2", children: /* @__PURE__ */ jsx15(
4293
5515
  MessageAttachments,
4294
5516
  {
4295
5517
  parts: attachmentPartsFromMessageParts(msg.parts),
@@ -4301,8 +5523,8 @@ function AssistantMessageImpl({
4301
5523
  }
4302
5524
  var AssistantMessage = memo(AssistantMessageImpl);
4303
5525
  function useThinkingSeconds(active) {
4304
- const [seconds, setSeconds] = useState14(0);
4305
- useEffect10(() => {
5526
+ const [seconds, setSeconds] = useState15(0);
5527
+ useEffect11(() => {
4306
5528
  if (!active) return;
4307
5529
  setSeconds(0);
4308
5530
  const id = setInterval(() => setSeconds((s) => s + 1), 1e3);
@@ -4312,23 +5534,23 @@ function useThinkingSeconds(active) {
4312
5534
  }
4313
5535
  function ThinkingRow({ agentLabel }) {
4314
5536
  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" }) }),
5537
+ return /* @__PURE__ */ jsxs13("div", { className: "mx-auto w-full max-w-3xl px-6 py-3", children: [
5538
+ /* @__PURE__ */ jsx15("p", { className: "mb-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: agentLabel }),
5539
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2 text-base text-muted-foreground", children: [
5540
+ /* @__PURE__ */ jsx15("svg", { className: "h-4 w-4 animate-spin", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": true, children: /* @__PURE__ */ jsx15("path", { d: "M21 12a9 9 0 1 1-6.219-8.56", strokeLinecap: "round" }) }),
4319
5541
  "Thinking",
4320
5542
  seconds >= 3 ? ` \xB7 ${seconds}s` : "..."
4321
5543
  ] })
4322
5544
  ] });
4323
5545
  }
4324
5546
  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" })
5547
+ return /* @__PURE__ */ jsx15("div", { className: "mx-auto w-full max-w-3xl px-6 py-3", children: /* @__PURE__ */ jsxs13("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: [
5548
+ /* @__PURE__ */ jsxs13("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: [
5549
+ /* @__PURE__ */ jsx15("circle", { cx: "12", cy: "12", r: "9" }),
5550
+ /* @__PURE__ */ jsx15("path", { d: "M12 8v4m0 4h.01" })
4329
5551
  ] }),
4330
- /* @__PURE__ */ jsx14("span", { className: "min-w-0 flex-1 break-words", children: message }),
4331
- onRetry && /* @__PURE__ */ jsx14(
5552
+ /* @__PURE__ */ jsx15("span", { className: "min-w-0 flex-1 break-words", children: message }),
5553
+ onRetry && /* @__PURE__ */ jsx15(
4332
5554
  "button",
4333
5555
  {
4334
5556
  type: "button",
@@ -4361,31 +5583,31 @@ function ChatMessages({
4361
5583
  workProductCards
4362
5584
  }) {
4363
5585
  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 })),
5586
+ const renderBody = useMemo9(
5587
+ () => renderMarkdown ?? ((content) => /* @__PURE__ */ jsx15("p", { className: "whitespace-pre-wrap", children: content })),
4366
5588
  [renderMarkdown]
4367
5589
  );
4368
5590
  const lastIsUser = messages[messages.length - 1]?.role === "user";
4369
5591
  if (messages.length === 0 && !loading && !error) {
4370
- const empty = renderEmpty ? renderEmpty() : /* @__PURE__ */ jsx14(ChatEmptyState, { ...emptyState });
4371
- return /* @__PURE__ */ jsxs12(Fragment7, { children: [
5592
+ const empty = renderEmpty ? renderEmpty() : /* @__PURE__ */ jsx15(ChatEmptyState, { ...emptyState });
5593
+ return /* @__PURE__ */ jsxs13(Fragment8, { children: [
4372
5594
  header,
4373
5595
  empty
4374
5596
  ] });
4375
5597
  }
4376
- return /* @__PURE__ */ jsxs12(Fragment7, { children: [
5598
+ return /* @__PURE__ */ jsxs13(Fragment8, { children: [
4377
5599
  header,
4378
5600
  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(
5601
+ (msg) => msg.role === "user" ? /* @__PURE__ */ jsx15("div", { className: "mx-auto w-full max-w-3xl px-6 py-3", children: /* @__PURE__ */ jsxs13("div", { className: "ml-auto w-fit max-w-[85%]", children: [
5602
+ /* @__PURE__ */ jsx15("p", { className: "mb-1 text-right text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: userLabel }),
5603
+ /* @__PURE__ */ jsx15(
4382
5604
  "div",
4383
5605
  {
4384
5606
  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 })
5607
+ children: /* @__PURE__ */ jsx15("p", { className: "whitespace-pre-wrap", children: msg.content })
4386
5608
  }
4387
5609
  ),
4388
- resolveAttachmentUrl && attachmentPartsFromMessageParts(msg.parts).length > 0 && /* @__PURE__ */ jsx14("div", { className: "mt-1.5", children: /* @__PURE__ */ jsx14(
5610
+ resolveAttachmentUrl && attachmentPartsFromMessageParts(msg.parts).length > 0 && /* @__PURE__ */ jsx15("div", { className: "mt-1.5", children: /* @__PURE__ */ jsx15(
4389
5611
  MessageAttachments,
4390
5612
  {
4391
5613
  parts: attachmentPartsFromMessageParts(msg.parts),
@@ -4393,7 +5615,7 @@ function ChatMessages({
4393
5615
  justify: "end"
4394
5616
  }
4395
5617
  ) })
4396
- ] }) }, msg.id) : /* @__PURE__ */ jsx14(
5618
+ ] }) }, msg.id) : /* @__PURE__ */ jsx15(
4397
5619
  AssistantMessage,
4398
5620
  {
4399
5621
  msg,
@@ -4413,8 +5635,8 @@ function ChatMessages({
4413
5635
  msg.id
4414
5636
  )
4415
5637
  ),
4416
- loading && lastIsUser && /* @__PURE__ */ jsx14(ThinkingRow, { agentLabel }),
4417
- error && !loading && /* @__PURE__ */ jsx14(StreamErrorRow, { message: error, onRetry })
5638
+ loading && lastIsUser && /* @__PURE__ */ jsx15(ThinkingRow, { agentLabel }),
5639
+ error && !loading && /* @__PURE__ */ jsx15(StreamErrorRow, { message: error, onRetry })
4418
5640
  ] });
4419
5641
  }
4420
5642
 
@@ -4490,6 +5712,29 @@ export {
4490
5712
  useSessionActions,
4491
5713
  formatSessionTimestamp,
4492
5714
  SessionHistoryPanel,
5715
+ recordGridOk,
5716
+ recordGridFail,
5717
+ isRecordGridCellApplicable,
5718
+ sameRecordGridValue,
5719
+ parseRecordGridInput,
5720
+ validateRecordGridCell,
5721
+ readRecordGridCell,
5722
+ validateRecordGridRow,
5723
+ formatRecordGridValue,
5724
+ recordGridEditorText,
5725
+ recordGridRowLabel,
5726
+ sumRecordGridColumn,
5727
+ EMPTY_RECORD_GRID_OVERLAY,
5728
+ projectRecordGridRows,
5729
+ withRecordGridUpdate,
5730
+ withoutRecordGridUpdate,
5731
+ withRecordGridServerRow,
5732
+ withRecordGridCreated,
5733
+ withoutRecordGridCreated,
5734
+ withRecordGridRemoved,
5735
+ withoutRecordGridRemoved,
5736
+ pruneRecordGridOverlay,
5737
+ RecordGrid,
4493
5738
  AgentSessionControls,
4494
5739
  formatModelCost,
4495
5740
  formatTokensPerSecond,
@@ -4499,4 +5744,4 @@ export {
4499
5744
  useThinkingSeconds,
4500
5745
  ChatMessages
4501
5746
  };
4502
- //# sourceMappingURL=chunk-AH3IOSWF.js.map
5747
+ //# sourceMappingURL=chunk-NZVBJM73.js.map