@locusgraph/loop 0.1.0 → 0.2.0

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 (115) hide show
  1. package/README.md +2 -0
  2. package/dist/agent/pulse/gradient-label.js +86 -15
  3. package/dist/agent/pulse/marks/bars-mark.js +46 -10
  4. package/dist/agent/pulse/marks/glyph-mark.js +56 -11
  5. package/dist/agent/pulse/marks/locus-mark.js +63 -28
  6. package/dist/agent/pulse/marks/orb-mark.js +31 -8
  7. package/dist/agent/pulse/marks/spinner-mark.js +29 -1
  8. package/dist/agent/pulse/pulse.js +150 -35
  9. package/dist/agent/pulse/use-loop-animation.js +36 -17
  10. package/dist/agent/steps/step-icon.js +110 -24
  11. package/dist/agent/steps/steps.js +235 -25
  12. package/dist/agent/thinking/thinking.js +203 -23
  13. package/dist/agent/thinking/thought-duration.js +7 -9
  14. package/dist/agent/tool/json-block.js +38 -11
  15. package/dist/agent/tool/tool-status.js +51 -18
  16. package/dist/agent/tool/tool.js +184 -6
  17. package/dist/approval/inbox/inbox-row.d.ts +3 -2
  18. package/dist/approval/inbox/inbox-row.js +321 -7
  19. package/dist/approval/inbox/inbox-selection.js +7 -13
  20. package/dist/approval/inbox/inbox.d.ts +2 -1
  21. package/dist/approval/inbox/inbox.js +250 -18
  22. package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
  23. package/dist/approval/inbox/virtual-inbox-list.js +129 -0
  24. package/dist/approval/memory/memory-choices.js +27 -22
  25. package/dist/approval/memory/memory-review.js +242 -17
  26. package/dist/approval/memory/memory-row.js +215 -19
  27. package/dist/approval/plan/plan-review.js +279 -28
  28. package/dist/approval/plan/plan-step-row.js +194 -43
  29. package/dist/approval/plan/plan-steps.js +24 -23
  30. package/dist/approval/plan/question-choices.js +158 -39
  31. package/dist/approval/plan/question.d.ts +1 -1
  32. package/dist/approval/plan/question.js +223 -26
  33. package/dist/approval/run/run-bar.js +178 -22
  34. package/dist/approval/shared/decision-line.js +1 -1
  35. package/dist/approval/shared/risk-badge.js +47 -16
  36. package/dist/approval/shared/time.js +5 -8
  37. package/dist/approval/shared/use-focus-on-mount.js +23 -6
  38. package/dist/approval/spend/raise-cap-form.js +235 -17
  39. package/dist/approval/spend/spend-gate.js +239 -21
  40. package/dist/approval/spend/spend-math.js +7 -8
  41. package/dist/approval/spend/spend-meter.js +362 -34
  42. package/dist/approval/tool/approval.js +272 -27
  43. package/dist/approval/tool/args/args-editor.js +262 -26
  44. package/dist/approval/tool/args/args-field.js +259 -19
  45. package/dist/approval/tool/args/args-validation.js +38 -47
  46. package/dist/approval/tool/deny-form.js +130 -10
  47. package/dist/approval/tool/tool-inputs.js +127 -38
  48. package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
  49. package/dist/chat/chat/chat-item-spacing.js +19 -0
  50. package/dist/chat/chat/chat.d.ts +2 -1
  51. package/dist/chat/chat/chat.js +181 -5
  52. package/dist/chat/chat/use-stick-to-bottom.js +123 -47
  53. package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
  54. package/dist/chat/chat/virtual-chat-items.js +153 -0
  55. package/dist/chat/composer/composer-actions.js +151 -16
  56. package/dist/chat/composer/composer.js +330 -32
  57. package/dist/chat/composer/use-auto-grow.js +24 -9
  58. package/dist/chat/files/file-meta.js +19 -19
  59. package/dist/chat/files/files.js +316 -28
  60. package/dist/chat/reply/fenced-code.js +45 -21
  61. package/dist/chat/reply/markdown-components.js +137 -17
  62. package/dist/chat/reply/reply.js +105 -10
  63. package/dist/chat/turn/group-parts.js +43 -29
  64. package/dist/chat/turn/turn.js +238 -30
  65. package/dist/cost/context.js +321 -23
  66. package/dist/cost/cost-steps.js +220 -14
  67. package/dist/cost/cost.js +521 -27
  68. package/dist/cost/model-picker.js +181 -6
  69. package/dist/cost/shared/context-breakdown.js +299 -10
  70. package/dist/cost/shared/meter-marks.js +107 -9
  71. package/dist/cost/shared/model-option-row.js +178 -21
  72. package/dist/cost/shared/step-cost-row.js +248 -20
  73. package/dist/cost/shared/usage-totals.js +22 -18
  74. package/dist/memory/cite.js +182 -11
  75. package/dist/memory/memorized.js +217 -11
  76. package/dist/memory/recall.js +296 -17
  77. package/dist/memory/shared/host-label.js +19 -22
  78. package/dist/memory/shared/source-mark.js +39 -3
  79. package/dist/memory/sources.js +255 -13
  80. package/dist/shared/decision-summary.js +133 -14
  81. package/dist/shared/panel-empty.js +78 -3
  82. package/dist/shared/panel.js +243 -13
  83. package/dist/shared/status-dot.js +38 -8
  84. package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
  85. package/dist/shared/virtual/use-list-virtualizer.js +68 -0
  86. package/dist/thread/actions/action-button.js +65 -3
  87. package/dist/thread/actions/actions.js +184 -13
  88. package/dist/thread/actions/branch-switcher.js +102 -5
  89. package/dist/thread/canvas/canvas.js +205 -5
  90. package/dist/thread/canvas/version-switcher.js +149 -8
  91. package/dist/thread/code/code.js +186 -24
  92. package/dist/thread/code/copy-code-button.js +61 -13
  93. package/dist/thread/code/highlight.js +30 -29
  94. package/dist/thread/history/history-rows.d.ts +16 -0
  95. package/dist/thread/history/history-rows.js +23 -0
  96. package/dist/thread/history/history.d.ts +3 -2
  97. package/dist/thread/history/history.js +174 -5
  98. package/dist/thread/history/{history-row.d.ts → row/history-row.d.ts} +3 -2
  99. package/dist/thread/history/row/history-row.js +137 -0
  100. package/dist/thread/history/row/thread-item-menu.js +84 -0
  101. package/dist/thread/history/row/thread-title-editor.js +81 -0
  102. package/dist/thread/history/thread-groups.d.ts +1 -1
  103. package/dist/thread/history/thread-groups.js +40 -34
  104. package/dist/thread/history/virtual-history-list.d.ts +11 -0
  105. package/dist/thread/history/virtual-history-list.js +107 -0
  106. package/dist/thread/index.d.ts +1 -1
  107. package/dist/thread/starters/starters.js +92 -7
  108. package/dist/thread/use-copied.js +45 -15
  109. package/dist/types.js +1 -1
  110. package/package.json +6 -4
  111. package/dist/thread/history/history-row.js +0 -17
  112. package/dist/thread/history/thread-item-menu.js +0 -6
  113. package/dist/thread/history/thread-title-editor.js +0 -25
  114. /package/dist/thread/history/{thread-item-menu.d.ts → row/thread-item-menu.d.ts} +0 -0
  115. /package/dist/thread/history/{thread-title-editor.d.ts → row/thread-title-editor.d.ts} +0 -0
@@ -1,45 +1,290 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { ShieldAlert as ShieldAlertIcon, Tools as WrenchIcon } from "@carbon/icons-react";
3
3
  import { Button, cn } from "@locusgraph/components";
4
4
  import { useState } from "react";
5
- import { ApprovalPanel, LiveStatus, PanelBody, PanelFooter, PanelHeader, PanelTitle, } from "../../shared/panel.js";
5
+ import { ApprovalPanel, LiveStatus, PanelBody, PanelFooter, PanelHeader, PanelTitle } from "../../shared/panel.js";
6
6
  import { toolNameOf } from "../../types.js";
7
7
  import { DecisionSummary } from "../shared/decision-line.js";
8
8
  import { riskCopy, riskLabels, riskRing } from "../shared/risk-badge.js";
9
9
  import { useFocusOnMount } from "../shared/use-focus-on-mount.js";
10
10
  import { DenyForm } from "./deny-form.js";
11
11
  import { ToolInputs } from "./tool-inputs.js";
12
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
12
13
  const settledStateLabels = {
13
- "approval-responded": "Reply sent. Waiting for the tool to run.",
14
- "output-available": "Approved and run.",
15
- "output-error": "Approved, but the tool failed.",
16
- "output-denied": "Denied. The tool did not run.",
14
+ "approval-responded": "Reply sent. Waiting for the tool to run.",
15
+ "output-available": "Approved and run.",
16
+ "output-error": "Approved, but the tool failed.",
17
+ "output-denied": "Denied. The tool did not run."
17
18
  };
18
19
  function settledLabel(state) {
19
- return settledStateLabels[state] ?? "Waiting for the tool inputs.";
20
+ return settledStateLabels[state] ?? "Waiting for the tool inputs.";
20
21
  }
21
22
  function headerStatus(awaiting, decision) {
22
- if (decision) {
23
- return decision.approved
24
- ? { status: "Approved", tone: "done" }
25
- : { status: "Denied", tone: "danger" };
26
- }
27
- return awaiting ? { status: "Waiting for you", tone: "waiting" } : { tone: "idle" };
23
+ if (decision) {
24
+ return decision.approved ? {
25
+ status: "Approved",
26
+ tone: "done"
27
+ } : {
28
+ status: "Denied",
29
+ tone: "danger"
30
+ };
31
+ }
32
+ return awaiting ? {
33
+ status: "Waiting for you",
34
+ tone: "waiting"
35
+ } : {
36
+ tone: "idle"
37
+ };
28
38
  }
29
39
  function decidedResult(toolName, state, decision) {
30
- return settledStateLabels[state] ?? `${toolName} ${decision.approved ? "approved" : "denied"}`;
40
+ return settledStateLabels[state] ?? `${toolName} ${decision.approved ? "approved" : "denied"}`;
31
41
  }
32
- export function Approval({ part, risk = "write", actionLabel, description, decision, onApprove, onDeny, autoFocus = true, className, }) {
33
- const [denying, setDenying] = useState(false);
34
- const toolName = toolNameOf(part);
35
- const awaiting = !decision && part.state === "approval-requested";
36
- const approveRef = useFocusOnMount(autoFocus && awaiting);
37
- const destructive = risk === "destructive";
38
- const Icon = destructive ? ShieldAlertIcon : WrenchIcon;
39
- const header = headerStatus(awaiting, decision);
40
- return (_jsxs(ApprovalPanel, { "data-slot": "approval", "data-risk": risk, "data-state": decision ? (decision.approved ? "approved" : "denied") : part.state, "aria-label": `Approve ${toolName}`, className: cn(awaiting && riskRing[risk], className), children: [_jsx(PanelHeader, { icon: _jsx(Icon, { "aria-hidden": true }), eyebrow: awaiting ? "Approval needed" : "Tool call", aside: riskLabels[risk], status: header.status, tone: header.tone }), _jsx(PanelTitle, { className: cn("truncate font-mono", !awaiting && "text-muted-foreground"), children: toolName }), awaiting && (_jsx("p", { className: "px-5 pt-1 text-sm text-muted-foreground", children: description ?? riskCopy[risk](toolName) })), awaiting && !denying && (_jsxs(_Fragment, { children: [_jsx(PanelBody, { children: _jsx(ToolInputs, { input: part.input }) }), _jsxs(PanelFooter, { className: "justify-between", children: [_jsx("span", { className: "hidden font-mono text-[11px] text-muted-foreground sm:inline", children: "The run is paused" }), _jsxs("span", { className: "flex flex-wrap gap-2", children: [_jsx(Button, { type: "button", size: "sm", variant: "ghost", onClick: () => setDenying(true), children: "Deny" }), _jsx(Button, { ref: approveRef, type: "button", size: "sm", variant: destructive ? "destructive" : "default", onClick: onApprove, children: actionLabel ?? `Run ${toolName}` })] })] })] })), awaiting && denying && (_jsxs(_Fragment, { children: [_jsx(PanelBody, { className: "pb-4", children: _jsx(ToolInputs, { input: part.input, muted: true }) }), _jsx(DenyForm, { onDeny: onDeny, onBack: () => setDenying(false) })] })), !awaiting && (_jsx(PanelBody, { className: "pt-3", children: decision ? (_jsx(DecisionSummary, { decision: decision, result: decidedResult(toolName, part.state, decision) })) : (_jsx("p", { className: "text-sm text-muted-foreground", children: settledLabel(part.state) })) })), _jsx(LiveStatus, { message: decision
41
- ? `${toolName} ${decision.approved ? "approved" : "denied"} by ${decision.by}`
42
- : awaiting
43
- ? `${toolName} is waiting for your approval`
44
- : settledLabel(part.state) })] }));
42
+ export function Approval(t0) {
43
+ const $ = _c(64);
44
+ const {
45
+ part,
46
+ risk: t1,
47
+ actionLabel,
48
+ description,
49
+ decision,
50
+ onApprove,
51
+ onDeny,
52
+ autoFocus: t2,
53
+ className
54
+ } = t0;
55
+ const risk = t1 === undefined ? "write" : t1;
56
+ const autoFocus = t2 === undefined ? true : t2;
57
+ const [denying, setDenying] = useState(false);
58
+ let t3;
59
+ if ($[0] !== part) {
60
+ t3 = toolNameOf(part);
61
+ $[0] = part;
62
+ $[1] = t3;
63
+ } else {
64
+ t3 = $[1];
65
+ }
66
+ const toolName = t3;
67
+ const awaiting = !decision && part.state === "approval-requested";
68
+ const approveRef = useFocusOnMount(autoFocus && awaiting);
69
+ const destructive = risk === "destructive";
70
+ const Icon = destructive ? ShieldAlertIcon : WrenchIcon;
71
+ let t4;
72
+ if ($[2] !== awaiting || $[3] !== decision) {
73
+ t4 = headerStatus(awaiting, decision);
74
+ $[2] = awaiting;
75
+ $[3] = decision;
76
+ $[4] = t4;
77
+ } else {
78
+ t4 = $[4];
79
+ }
80
+ const header = t4;
81
+ const t5 = decision ? decision.approved ? "approved" : "denied" : part.state;
82
+ const t6 = `Approve ${toolName}`;
83
+ const t7 = awaiting && riskRing[risk];
84
+ let t8;
85
+ if ($[5] !== className || $[6] !== t7) {
86
+ t8 = cn(t7, className);
87
+ $[5] = className;
88
+ $[6] = t7;
89
+ $[7] = t8;
90
+ } else {
91
+ t8 = $[7];
92
+ }
93
+ let t9;
94
+ if ($[8] !== Icon) {
95
+ t9 = /*#__PURE__*/_jsx(Icon, {
96
+ "aria-hidden": true
97
+ });
98
+ $[8] = Icon;
99
+ $[9] = t9;
100
+ } else {
101
+ t9 = $[9];
102
+ }
103
+ const t10 = awaiting ? "Approval needed" : "Tool call";
104
+ const t11 = riskLabels[risk];
105
+ let t12;
106
+ if ($[10] !== header.status || $[11] !== header.tone || $[12] !== t10 || $[13] !== t11 || $[14] !== t9) {
107
+ t12 = /*#__PURE__*/_jsx(PanelHeader, {
108
+ icon: t9,
109
+ eyebrow: t10,
110
+ aside: t11,
111
+ status: header.status,
112
+ tone: header.tone
113
+ });
114
+ $[10] = header.status;
115
+ $[11] = header.tone;
116
+ $[12] = t10;
117
+ $[13] = t11;
118
+ $[14] = t9;
119
+ $[15] = t12;
120
+ } else {
121
+ t12 = $[15];
122
+ }
123
+ const t13 = !awaiting && "text-muted-foreground";
124
+ let t14;
125
+ if ($[16] !== t13) {
126
+ t14 = cn("truncate font-mono", t13);
127
+ $[16] = t13;
128
+ $[17] = t14;
129
+ } else {
130
+ t14 = $[17];
131
+ }
132
+ let t15;
133
+ if ($[18] !== t14 || $[19] !== toolName) {
134
+ t15 = /*#__PURE__*/_jsx(PanelTitle, {
135
+ className: t14,
136
+ children: toolName
137
+ });
138
+ $[18] = t14;
139
+ $[19] = toolName;
140
+ $[20] = t15;
141
+ } else {
142
+ t15 = $[20];
143
+ }
144
+ let t16;
145
+ if ($[21] !== awaiting || $[22] !== description || $[23] !== risk || $[24] !== toolName) {
146
+ t16 = awaiting && /*#__PURE__*/_jsx("p", {
147
+ className: "px-5 pt-1 text-sm text-muted-foreground",
148
+ children: description ?? riskCopy[risk](toolName)
149
+ });
150
+ $[21] = awaiting;
151
+ $[22] = description;
152
+ $[23] = risk;
153
+ $[24] = toolName;
154
+ $[25] = t16;
155
+ } else {
156
+ t16 = $[25];
157
+ }
158
+ let t17;
159
+ if ($[26] !== actionLabel || $[27] !== approveRef || $[28] !== awaiting || $[29] !== denying || $[30] !== destructive || $[31] !== onApprove || $[32] !== part || $[33] !== toolName) {
160
+ t17 = awaiting && !denying && /*#__PURE__*/_jsxs(_Fragment, {
161
+ children: [/*#__PURE__*/_jsx(PanelBody, {
162
+ children: /*#__PURE__*/_jsx(ToolInputs, {
163
+ input: part.input
164
+ })
165
+ }), /*#__PURE__*/_jsxs(PanelFooter, {
166
+ className: "justify-between",
167
+ children: [/*#__PURE__*/_jsx("span", {
168
+ className: "hidden font-mono text-[11px] text-muted-foreground sm:inline",
169
+ children: "The run is paused"
170
+ }), /*#__PURE__*/_jsxs("span", {
171
+ className: "flex flex-wrap gap-2",
172
+ children: [/*#__PURE__*/_jsx(Button, {
173
+ type: "button",
174
+ size: "sm",
175
+ variant: "ghost",
176
+ onClick: () => setDenying(true),
177
+ children: "Deny"
178
+ }), /*#__PURE__*/_jsx(Button, {
179
+ ref: approveRef,
180
+ type: "button",
181
+ size: "sm",
182
+ variant: destructive ? "destructive" : "default",
183
+ onClick: onApprove,
184
+ children: actionLabel ?? `Run ${toolName}`
185
+ })]
186
+ })]
187
+ })]
188
+ });
189
+ $[26] = actionLabel;
190
+ $[27] = approveRef;
191
+ $[28] = awaiting;
192
+ $[29] = denying;
193
+ $[30] = destructive;
194
+ $[31] = onApprove;
195
+ $[32] = part;
196
+ $[33] = toolName;
197
+ $[34] = t17;
198
+ } else {
199
+ t17 = $[34];
200
+ }
201
+ let t18;
202
+ if ($[35] !== awaiting || $[36] !== denying || $[37] !== onDeny || $[38] !== part) {
203
+ t18 = awaiting && denying && /*#__PURE__*/_jsxs(_Fragment, {
204
+ children: [/*#__PURE__*/_jsx(PanelBody, {
205
+ className: "pb-4",
206
+ children: /*#__PURE__*/_jsx(ToolInputs, {
207
+ input: part.input,
208
+ muted: true
209
+ })
210
+ }), /*#__PURE__*/_jsx(DenyForm, {
211
+ onDeny: onDeny,
212
+ onBack: () => setDenying(false)
213
+ })]
214
+ });
215
+ $[35] = awaiting;
216
+ $[36] = denying;
217
+ $[37] = onDeny;
218
+ $[38] = part;
219
+ $[39] = t18;
220
+ } else {
221
+ t18 = $[39];
222
+ }
223
+ let t19;
224
+ if ($[40] !== awaiting || $[41] !== decision || $[42] !== part || $[43] !== toolName) {
225
+ t19 = !awaiting && /*#__PURE__*/_jsx(PanelBody, {
226
+ className: "pt-3",
227
+ children: decision ? /*#__PURE__*/_jsx(DecisionSummary, {
228
+ decision: decision,
229
+ result: decidedResult(toolName, part.state, decision)
230
+ }) : /*#__PURE__*/_jsx("p", {
231
+ className: "text-sm text-muted-foreground",
232
+ children: settledLabel(part.state)
233
+ })
234
+ });
235
+ $[40] = awaiting;
236
+ $[41] = decision;
237
+ $[42] = part;
238
+ $[43] = toolName;
239
+ $[44] = t19;
240
+ } else {
241
+ t19 = $[44];
242
+ }
243
+ let t20;
244
+ if ($[45] !== awaiting || $[46] !== decision || $[47] !== part || $[48] !== toolName) {
245
+ t20 = decision ? `${toolName} ${decision.approved ? "approved" : "denied"} by ${decision.by}` : awaiting ? `${toolName} is waiting for your approval` : settledLabel(part.state);
246
+ $[45] = awaiting;
247
+ $[46] = decision;
248
+ $[47] = part;
249
+ $[48] = toolName;
250
+ $[49] = t20;
251
+ } else {
252
+ t20 = $[49];
253
+ }
254
+ let t21;
255
+ if ($[50] !== t20) {
256
+ t21 = /*#__PURE__*/_jsx(LiveStatus, {
257
+ message: t20
258
+ });
259
+ $[50] = t20;
260
+ $[51] = t21;
261
+ } else {
262
+ t21 = $[51];
263
+ }
264
+ let t22;
265
+ if ($[52] !== risk || $[53] !== t12 || $[54] !== t15 || $[55] !== t16 || $[56] !== t17 || $[57] !== t18 || $[58] !== t19 || $[59] !== t21 || $[60] !== t5 || $[61] !== t6 || $[62] !== t8) {
266
+ t22 = /*#__PURE__*/_jsxs(ApprovalPanel, {
267
+ "data-slot": "approval",
268
+ "data-risk": risk,
269
+ "data-state": t5,
270
+ "aria-label": t6,
271
+ className: t8,
272
+ children: [t12, t15, t16, t17, t18, t19, t21]
273
+ });
274
+ $[52] = risk;
275
+ $[53] = t12;
276
+ $[54] = t15;
277
+ $[55] = t16;
278
+ $[56] = t17;
279
+ $[57] = t18;
280
+ $[58] = t19;
281
+ $[59] = t21;
282
+ $[60] = t5;
283
+ $[61] = t6;
284
+ $[62] = t8;
285
+ $[63] = t22;
286
+ } else {
287
+ t22 = $[63];
288
+ }
289
+ return t22;
45
290
  }
@@ -1,37 +1,273 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { Edit as SquarePenIcon } from "@carbon/icons-react";
3
3
  import { Button, cn } from "@locusgraph/components";
4
4
  import { useId, useMemo, useState } from "react";
5
- import { ApprovalPanel, LiveStatus, PanelBody, PanelFooter, PanelHeader, PanelTitle, } from "../../../shared/panel.js";
5
+ import { ApprovalPanel, LiveStatus, PanelBody, PanelFooter, PanelHeader, PanelTitle } from "../../../shared/panel.js";
6
6
  import { DecisionSummary } from "../../shared/decision-line.js";
7
7
  import { riskCopy, riskLabels, riskRing } from "../../shared/risk-badge.js";
8
8
  import { useFocusOnMount } from "../../shared/use-focus-on-mount.js";
9
9
  import { ArgsField } from "./args-field.js";
10
10
  import { draftsFrom, validateDrafts, valuesFromDrafts } from "./args-validation.js";
11
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
12
  function errorSummary(count) {
12
- return count === 1 ? "1 field needs a fix." : `${count} fields need a fix.`;
13
+ return count === 1 ? "1 field needs a fix." : `${count} fields need a fix.`;
13
14
  }
14
- export function ArgsEditor({ toolName, fields, initialValues = {}, risk = "write", actionLabel, description, decision, onApprove, onCancel, autoFocus = false, className, }) {
15
- const baseId = useId();
16
- const [drafts, setDrafts] = useState(() => draftsFrom(fields, initialValues));
17
- const [showErrors, setShowErrors] = useState(false);
18
- const errors = useMemo(() => validateDrafts(fields, drafts), [fields, drafts]);
19
- const errorCount = Object.keys(errors).length;
20
- const visibleErrors = showErrors ? errors : {};
21
- const destructive = risk === "destructive";
22
- const submitRef = useFocusOnMount(autoFocus && !decision);
23
- return (_jsxs(ApprovalPanel, { "data-slot": "args-editor", "data-risk": risk, "aria-label": `Edit ${toolName} inputs`, "data-state": decision ? (decision.approved ? "approved" : "denied") : "editing", className: cn(!decision && riskRing[risk], className), children: [_jsx(PanelHeader, { icon: _jsx(SquarePenIcon, { "aria-hidden": true }), eyebrow: decision ? "Tool call" : "Edit before approving", aside: riskLabels[risk], status: decision ? (decision.approved ? "Approved" : "Cancelled") : "Waiting for you", tone: decision ? (decision.approved ? "done" : "danger") : "waiting" }), _jsx(PanelTitle, { className: cn("truncate font-mono", decision && "text-muted-foreground"), children: toolName }), decision ? (_jsx(PanelBody, { className: "pt-3", children: _jsx(DecisionSummary, { decision: decision, deniedVerb: "Cancelled", result: decision.approved
24
- ? `${toolName} approved with edited inputs`
25
- : `${toolName} cancelled` }) })) : (_jsxs(_Fragment, { children: [_jsxs("p", { className: "px-5 pt-1 text-sm text-muted-foreground", children: [description ?? riskCopy[risk](toolName), " The tool runs with what you send."] }), _jsxs("form", { noValidate: true, onSubmit: (event) => {
26
- event.preventDefault();
27
- const firstInvalid = fields.find((field) => errors[field.name]);
28
- if (firstInvalid) {
29
- setShowErrors(true);
30
- const control = event.currentTarget.elements.namedItem(firstInvalid.name);
31
- if (control instanceof HTMLElement)
32
- control.focus();
33
- return;
34
- }
35
- onApprove(valuesFromDrafts(fields, drafts));
36
- }, children: [_jsx(PanelBody, { className: "gap-5 pt-5", children: fields.map((field) => (_jsx(ArgsField, { id: `${baseId}-${field.name}`, field: field, draft: drafts[field.name], error: visibleErrors[field.name], onChange: (draft) => setDrafts((current) => ({ ...current, [field.name]: draft })) }, field.name))) }), _jsxs(PanelFooter, { className: "justify-between", children: [_jsx("span", { className: cn("hidden font-mono text-[11px] sm:inline", showErrors && errorCount > 0 ? "text-destructive" : "text-muted-foreground"), children: showErrors && errorCount > 0 ? errorSummary(errorCount) : "The run is paused" }), _jsxs("span", { className: "flex flex-wrap gap-2", children: [_jsx(Button, { type: "button", size: "sm", variant: "ghost", onClick: onCancel, children: "Cancel" }), _jsx(Button, { ref: submitRef, type: "submit", size: "sm", variant: destructive ? "destructive" : "default", children: actionLabel ?? `Run ${toolName} with these inputs` })] })] })] })] })), _jsx(LiveStatus, { message: showErrors && errorCount > 0 ? errorSummary(errorCount) : "" })] }));
15
+ export function ArgsEditor(t0) {
16
+ const $ = _c(58);
17
+ const {
18
+ toolName,
19
+ fields,
20
+ initialValues: t1,
21
+ risk: t2,
22
+ actionLabel,
23
+ description,
24
+ decision,
25
+ onApprove,
26
+ onCancel,
27
+ autoFocus: t3,
28
+ className
29
+ } = t0;
30
+ let t4;
31
+ if ($[0] !== t1) {
32
+ t4 = t1 === undefined ? {} : t1;
33
+ $[0] = t1;
34
+ $[1] = t4;
35
+ } else {
36
+ t4 = $[1];
37
+ }
38
+ const initialValues = t4;
39
+ const risk = t2 === undefined ? "write" : t2;
40
+ const autoFocus = t3 === undefined ? false : t3;
41
+ const baseId = useId();
42
+ let t5;
43
+ if ($[2] !== fields || $[3] !== initialValues) {
44
+ t5 = () => draftsFrom(fields, initialValues);
45
+ $[2] = fields;
46
+ $[3] = initialValues;
47
+ $[4] = t5;
48
+ } else {
49
+ t5 = $[4];
50
+ }
51
+ const [drafts, setDrafts] = useState(t5);
52
+ const [showErrors, setShowErrors] = useState(false);
53
+ let t6;
54
+ if ($[5] !== drafts || $[6] !== fields) {
55
+ t6 = validateDrafts(fields, drafts);
56
+ $[5] = drafts;
57
+ $[6] = fields;
58
+ $[7] = t6;
59
+ } else {
60
+ t6 = $[7];
61
+ }
62
+ const errors = t6;
63
+ let t7;
64
+ if ($[8] !== errors) {
65
+ t7 = Object.keys(errors);
66
+ $[8] = errors;
67
+ $[9] = t7;
68
+ } else {
69
+ t7 = $[9];
70
+ }
71
+ const errorCount = t7.length;
72
+ let t8;
73
+ if ($[10] !== errors || $[11] !== showErrors) {
74
+ t8 = showErrors ? errors : {};
75
+ $[10] = errors;
76
+ $[11] = showErrors;
77
+ $[12] = t8;
78
+ } else {
79
+ t8 = $[12];
80
+ }
81
+ const visibleErrors = t8;
82
+ const destructive = risk === "destructive";
83
+ const submitRef = useFocusOnMount(autoFocus && !decision);
84
+ const t9 = `Edit ${toolName} inputs`;
85
+ const t10 = decision ? decision.approved ? "approved" : "denied" : "editing";
86
+ const t11 = !decision && riskRing[risk];
87
+ let t12;
88
+ if ($[13] !== className || $[14] !== t11) {
89
+ t12 = cn(t11, className);
90
+ $[13] = className;
91
+ $[14] = t11;
92
+ $[15] = t12;
93
+ } else {
94
+ t12 = $[15];
95
+ }
96
+ let t13;
97
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
98
+ t13 = /*#__PURE__*/_jsx(SquarePenIcon, {
99
+ "aria-hidden": true
100
+ });
101
+ $[16] = t13;
102
+ } else {
103
+ t13 = $[16];
104
+ }
105
+ const t14 = decision ? "Tool call" : "Edit before approving";
106
+ const t15 = riskLabels[risk];
107
+ const t16 = decision ? decision.approved ? "Approved" : "Cancelled" : "Waiting for you";
108
+ const t17 = decision ? decision.approved ? "done" : "danger" : "waiting";
109
+ let t18;
110
+ if ($[17] !== t14 || $[18] !== t15 || $[19] !== t16 || $[20] !== t17) {
111
+ t18 = /*#__PURE__*/_jsx(PanelHeader, {
112
+ icon: t13,
113
+ eyebrow: t14,
114
+ aside: t15,
115
+ status: t16,
116
+ tone: t17
117
+ });
118
+ $[17] = t14;
119
+ $[18] = t15;
120
+ $[19] = t16;
121
+ $[20] = t17;
122
+ $[21] = t18;
123
+ } else {
124
+ t18 = $[21];
125
+ }
126
+ const t19 = decision && "text-muted-foreground";
127
+ let t20;
128
+ if ($[22] !== t19) {
129
+ t20 = cn("truncate font-mono", t19);
130
+ $[22] = t19;
131
+ $[23] = t20;
132
+ } else {
133
+ t20 = $[23];
134
+ }
135
+ let t21;
136
+ if ($[24] !== t20 || $[25] !== toolName) {
137
+ t21 = /*#__PURE__*/_jsx(PanelTitle, {
138
+ className: t20,
139
+ children: toolName
140
+ });
141
+ $[24] = t20;
142
+ $[25] = toolName;
143
+ $[26] = t21;
144
+ } else {
145
+ t21 = $[26];
146
+ }
147
+ let t22;
148
+ if ($[27] !== actionLabel || $[28] !== baseId || $[29] !== decision || $[30] !== description || $[31] !== destructive || $[32] !== drafts || $[33] !== errorCount || $[34] !== errors || $[35] !== fields || $[36] !== onApprove || $[37] !== onCancel || $[38] !== risk || $[39] !== showErrors || $[40] !== submitRef || $[41] !== toolName || $[42] !== visibleErrors) {
149
+ t22 = decision ? /*#__PURE__*/_jsx(PanelBody, {
150
+ className: "pt-3",
151
+ children: /*#__PURE__*/_jsx(DecisionSummary, {
152
+ decision: decision,
153
+ deniedVerb: "Cancelled",
154
+ result: decision.approved ? `${toolName} approved with edited inputs` : `${toolName} cancelled`
155
+ })
156
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
157
+ children: [/*#__PURE__*/_jsxs("p", {
158
+ className: "px-5 pt-1 text-sm text-muted-foreground",
159
+ children: [description ?? riskCopy[risk](toolName), " The tool runs with what you send."]
160
+ }), /*#__PURE__*/_jsxs("form", {
161
+ noValidate: true,
162
+ onSubmit: event => {
163
+ event.preventDefault();
164
+ const firstInvalid = fields.find(field => errors[field.name]);
165
+ if (firstInvalid) {
166
+ setShowErrors(true);
167
+ const control = event.currentTarget.elements.namedItem(firstInvalid.name);
168
+ if (control instanceof HTMLElement) {
169
+ control.focus();
170
+ }
171
+ return;
172
+ }
173
+ onApprove(valuesFromDrafts(fields, drafts));
174
+ },
175
+ children: [/*#__PURE__*/_jsx(PanelBody, {
176
+ className: "gap-5 pt-5",
177
+ children: fields.map(field_0 => /*#__PURE__*/_jsx(ArgsField, {
178
+ id: `${baseId}-${field_0.name}`,
179
+ field: field_0,
180
+ draft: drafts[field_0.name],
181
+ error: visibleErrors[field_0.name],
182
+ onChange: draft => setDrafts(current => ({
183
+ ...current,
184
+ [field_0.name]: draft
185
+ }))
186
+ }, field_0.name))
187
+ }), /*#__PURE__*/_jsxs(PanelFooter, {
188
+ className: "justify-between",
189
+ children: [/*#__PURE__*/_jsx("span", {
190
+ className: cn("hidden font-mono text-[11px] sm:inline", showErrors && errorCount > 0 ? "text-destructive" : "text-muted-foreground"),
191
+ children: showErrors && errorCount > 0 ? errorSummary(errorCount) : "The run is paused"
192
+ }), /*#__PURE__*/_jsxs("span", {
193
+ className: "flex flex-wrap gap-2",
194
+ children: [/*#__PURE__*/_jsx(Button, {
195
+ type: "button",
196
+ size: "sm",
197
+ variant: "ghost",
198
+ onClick: onCancel,
199
+ children: "Cancel"
200
+ }), /*#__PURE__*/_jsx(Button, {
201
+ ref: submitRef,
202
+ type: "submit",
203
+ size: "sm",
204
+ variant: destructive ? "destructive" : "default",
205
+ children: actionLabel ?? `Run ${toolName} with these inputs`
206
+ })]
207
+ })]
208
+ })]
209
+ })]
210
+ });
211
+ $[27] = actionLabel;
212
+ $[28] = baseId;
213
+ $[29] = decision;
214
+ $[30] = description;
215
+ $[31] = destructive;
216
+ $[32] = drafts;
217
+ $[33] = errorCount;
218
+ $[34] = errors;
219
+ $[35] = fields;
220
+ $[36] = onApprove;
221
+ $[37] = onCancel;
222
+ $[38] = risk;
223
+ $[39] = showErrors;
224
+ $[40] = submitRef;
225
+ $[41] = toolName;
226
+ $[42] = visibleErrors;
227
+ $[43] = t22;
228
+ } else {
229
+ t22 = $[43];
230
+ }
231
+ let t23;
232
+ if ($[44] !== errorCount || $[45] !== showErrors) {
233
+ t23 = showErrors && errorCount > 0 ? errorSummary(errorCount) : "";
234
+ $[44] = errorCount;
235
+ $[45] = showErrors;
236
+ $[46] = t23;
237
+ } else {
238
+ t23 = $[46];
239
+ }
240
+ let t24;
241
+ if ($[47] !== t23) {
242
+ t24 = /*#__PURE__*/_jsx(LiveStatus, {
243
+ message: t23
244
+ });
245
+ $[47] = t23;
246
+ $[48] = t24;
247
+ } else {
248
+ t24 = $[48];
249
+ }
250
+ let t25;
251
+ if ($[49] !== risk || $[50] !== t10 || $[51] !== t12 || $[52] !== t18 || $[53] !== t21 || $[54] !== t22 || $[55] !== t24 || $[56] !== t9) {
252
+ t25 = /*#__PURE__*/_jsxs(ApprovalPanel, {
253
+ "data-slot": "args-editor",
254
+ "data-risk": risk,
255
+ "aria-label": t9,
256
+ "data-state": t10,
257
+ className: t12,
258
+ children: [t18, t21, t22, t24]
259
+ });
260
+ $[49] = risk;
261
+ $[50] = t10;
262
+ $[51] = t12;
263
+ $[52] = t18;
264
+ $[53] = t21;
265
+ $[54] = t22;
266
+ $[55] = t24;
267
+ $[56] = t9;
268
+ $[57] = t25;
269
+ } else {
270
+ t25 = $[57];
271
+ }
272
+ return t25;
37
273
  }