@locusgraph/loop 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/README.md +37 -2
- package/dist/agent/index.d.ts +5 -0
- package/dist/agent/index.js +5 -0
- package/dist/agent/pulse/gradient-label.d.ts +7 -0
- package/dist/agent/pulse/gradient-label.js +94 -0
- package/dist/agent/pulse/marks/bars-mark.d.ts +1 -0
- package/dist/agent/pulse/marks/bars-mark.js +51 -0
- package/dist/agent/pulse/marks/glyph-mark.d.ts +4 -0
- package/dist/agent/pulse/marks/glyph-mark.js +62 -0
- package/dist/agent/pulse/marks/locus-mark.d.ts +1 -0
- package/dist/agent/pulse/marks/locus-mark.js +73 -0
- package/dist/agent/pulse/marks/orb-mark.d.ts +1 -0
- package/dist/agent/pulse/marks/orb-mark.js +34 -0
- package/dist/agent/pulse/marks/spinner-mark.d.ts +1 -0
- package/dist/agent/pulse/marks/spinner-mark.js +32 -0
- package/dist/agent/pulse/pulse-tone.d.ts +1 -0
- package/dist/agent/pulse/pulse-tone.js +1 -0
- package/dist/agent/pulse/pulse.d.ts +12 -0
- package/dist/agent/pulse/pulse.js +166 -0
- package/dist/agent/pulse/use-loop-animation.d.ts +2 -0
- package/dist/agent/pulse/use-loop-animation.js +40 -0
- package/dist/agent/shared/status-dot.d.ts +1 -0
- package/dist/agent/shared/status-dot.js +1 -0
- package/dist/agent/steps/step-icon.d.ts +8 -0
- package/dist/agent/steps/step-icon.js +117 -0
- package/dist/agent/steps/steps.d.ts +7 -0
- package/dist/agent/steps/steps.js +249 -0
- package/dist/agent/thinking/thinking.d.ts +6 -0
- package/dist/agent/thinking/thinking.js +211 -0
- package/dist/agent/thinking/thought-duration.d.ts +2 -0
- package/dist/agent/thinking/thought-duration.js +11 -0
- package/dist/agent/tool/json-block.d.ts +5 -0
- package/dist/agent/tool/json-block.js +42 -0
- package/dist/agent/tool/tool-status.d.ts +6 -0
- package/dist/agent/tool/tool-status.js +59 -0
- package/dist/agent/tool/tool.d.ts +7 -0
- package/dist/agent/tool/tool.js +192 -0
- package/dist/approval/inbox/inbox-row.d.ts +12 -0
- package/dist/approval/inbox/inbox-row.js +328 -0
- package/dist/approval/inbox/inbox-selection.d.ts +6 -0
- package/dist/approval/inbox/inbox-selection.js +15 -0
- package/dist/approval/inbox/inbox.d.ts +12 -0
- package/dist/approval/inbox/inbox.js +258 -0
- package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
- package/dist/approval/inbox/virtual-inbox-list.js +129 -0
- package/dist/approval/index.d.ts +9 -0
- package/dist/approval/index.js +8 -0
- package/dist/approval/memory/memory-choices.d.ts +10 -0
- package/dist/approval/memory/memory-choices.js +35 -0
- package/dist/approval/memory/memory-review.d.ts +11 -0
- package/dist/approval/memory/memory-review.js +256 -0
- package/dist/approval/memory/memory-row.d.ts +9 -0
- package/dist/approval/memory/memory-row.js +226 -0
- package/dist/approval/plan/plan-review.d.ts +13 -0
- package/dist/approval/plan/plan-review.js +289 -0
- package/dist/approval/plan/plan-step-row.d.ts +13 -0
- package/dist/approval/plan/plan-step-row.js +201 -0
- package/dist/approval/plan/plan-steps.d.ts +8 -0
- package/dist/approval/plan/plan-steps.js +30 -0
- package/dist/approval/plan/question-choices.d.ts +10 -0
- package/dist/approval/plan/question-choices.js +166 -0
- package/dist/approval/plan/question.d.ts +18 -0
- package/dist/approval/plan/question.js +232 -0
- package/dist/approval/run/run-bar.d.ts +13 -0
- package/dist/approval/run/run-bar.js +189 -0
- package/dist/approval/shared/decision-line.d.ts +1 -0
- package/dist/approval/shared/decision-line.js +1 -0
- package/dist/approval/shared/risk-badge.d.ts +10 -0
- package/dist/approval/shared/risk-badge.js +57 -0
- package/dist/approval/shared/time.d.ts +3 -0
- package/dist/approval/shared/time.js +12 -0
- package/dist/approval/shared/use-focus-on-mount.d.ts +2 -0
- package/dist/approval/shared/use-focus-on-mount.js +26 -0
- package/dist/approval/spend/raise-cap-form.d.ts +8 -0
- package/dist/approval/spend/raise-cap-form.js +244 -0
- package/dist/approval/spend/spend-gate.d.ts +16 -0
- package/dist/approval/spend/spend-gate.js +250 -0
- package/dist/approval/spend/spend-math.d.ts +5 -0
- package/dist/approval/spend/spend-math.js +17 -0
- package/dist/approval/spend/spend-meter.d.ts +10 -0
- package/dist/approval/spend/spend-meter.js +377 -0
- package/dist/approval/tool/approval.d.ts +14 -0
- package/dist/approval/tool/approval.js +290 -0
- package/dist/approval/tool/args/args-editor.d.ts +16 -0
- package/dist/approval/tool/args/args-editor.js +273 -0
- package/dist/approval/tool/args/args-field.d.ts +11 -0
- package/dist/approval/tool/args/args-field.js +268 -0
- package/dist/approval/tool/args/args-validation.d.ts +8 -0
- package/dist/approval/tool/args/args-validation.js +50 -0
- package/dist/approval/tool/deny-form.d.ts +6 -0
- package/dist/approval/tool/deny-form.js +135 -0
- package/dist/approval/tool/tool-inputs.d.ts +6 -0
- package/dist/approval/tool/tool-inputs.js +142 -0
- package/dist/approval/types.d.ts +59 -0
- package/dist/approval/types.js +1 -0
- package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
- package/dist/chat/chat/chat-item-spacing.js +19 -0
- package/dist/chat/chat/chat.d.ts +8 -0
- package/dist/chat/chat/chat.js +187 -0
- package/dist/chat/chat/use-stick-to-bottom.d.ts +7 -0
- package/dist/chat/chat/use-stick-to-bottom.js +133 -0
- package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
- package/dist/chat/chat/virtual-chat-items.js +153 -0
- package/dist/chat/composer/composer-actions.d.ts +15 -0
- package/dist/chat/composer/composer-actions.js +158 -0
- package/dist/chat/composer/composer.d.ts +20 -0
- package/dist/chat/composer/composer.js +340 -0
- package/dist/chat/composer/use-auto-grow.d.ts +2 -0
- package/dist/chat/composer/use-auto-grow.js +29 -0
- package/dist/chat/files/file-meta.d.ts +13 -0
- package/dist/chat/files/file-meta.js +30 -0
- package/dist/chat/files/files.d.ts +9 -0
- package/dist/chat/files/files.js +327 -0
- package/dist/chat/index.d.ts +7 -0
- package/dist/chat/index.js +7 -0
- package/dist/chat/reply/fenced-code.d.ts +8 -0
- package/dist/chat/reply/fenced-code.js +53 -0
- package/dist/chat/reply/markdown-components.d.ts +2 -0
- package/dist/chat/reply/markdown-components.js +142 -0
- package/dist/chat/reply/reply.d.ts +8 -0
- package/dist/chat/reply/reply.js +116 -0
- package/dist/chat/turn/group-parts.d.ts +24 -0
- package/dist/chat/turn/group-parts.js +49 -0
- package/dist/chat/turn/turn.d.ts +11 -0
- package/dist/chat/turn/turn.js +253 -0
- package/dist/cost/context.d.ts +13 -0
- package/dist/cost/context.js +333 -0
- package/dist/cost/cost-steps.d.ts +17 -0
- package/dist/cost/cost-steps.js +230 -0
- package/dist/cost/cost.d.ts +8 -0
- package/dist/cost/cost.js +531 -0
- package/dist/cost/index.d.ts +4 -0
- package/dist/cost/index.js +4 -0
- package/dist/cost/model-picker.d.ts +11 -0
- package/dist/cost/model-picker.js +184 -0
- package/dist/cost/shared/context-breakdown.d.ts +15 -0
- package/dist/cost/shared/context-breakdown.js +306 -0
- package/dist/cost/shared/meter-marks.d.ts +9 -0
- package/dist/cost/shared/meter-marks.js +114 -0
- package/dist/cost/shared/model-option-row.d.ts +14 -0
- package/dist/cost/shared/model-option-row.js +189 -0
- package/dist/cost/shared/step-cost-row.d.ts +15 -0
- package/dist/cost/shared/step-cost-row.js +262 -0
- package/dist/cost/shared/usage-totals.d.ts +11 -0
- package/dist/cost/shared/usage-totals.js +30 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/memory/cite.d.ts +8 -0
- package/dist/memory/cite.js +190 -0
- package/dist/memory/index.d.ts +5 -0
- package/dist/memory/index.js +4 -0
- package/dist/memory/memorized.d.ts +14 -0
- package/dist/memory/memorized.js +225 -0
- package/dist/memory/recall.d.ts +9 -0
- package/dist/memory/recall.js +303 -0
- package/dist/memory/shared/disclosure.d.ts +6 -0
- package/dist/memory/shared/disclosure.js +6 -0
- package/dist/memory/shared/host-label.d.ts +6 -0
- package/dist/memory/shared/host-label.js +31 -0
- package/dist/memory/shared/source-mark.d.ts +5 -0
- package/dist/memory/shared/source-mark.js +42 -0
- package/dist/memory/sources.d.ts +9 -0
- package/dist/memory/sources.js +264 -0
- package/dist/shared/decision-summary.d.ts +18 -0
- package/dist/shared/decision-summary.js +144 -0
- package/dist/shared/panel-empty.d.ts +8 -0
- package/dist/shared/panel-empty.js +80 -0
- package/dist/shared/panel.d.ts +19 -0
- package/dist/shared/panel.js +251 -0
- package/dist/shared/status-dot.d.ts +6 -0
- package/dist/shared/status-dot.js +42 -0
- package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
- package/dist/shared/virtual/use-list-virtualizer.js +68 -0
- package/dist/sources.css +1 -0
- package/dist/thread/actions/action-button.d.ts +8 -0
- package/dist/thread/actions/action-button.js +67 -0
- package/dist/thread/actions/actions.d.ts +13 -0
- package/dist/thread/actions/actions.js +192 -0
- package/dist/thread/actions/branch-switcher.d.ts +10 -0
- package/dist/thread/actions/branch-switcher.js +104 -0
- package/dist/thread/canvas/canvas.d.ts +14 -0
- package/dist/thread/canvas/canvas.js +212 -0
- package/dist/thread/canvas/version-switcher.d.ts +12 -0
- package/dist/thread/canvas/version-switcher.js +152 -0
- package/dist/thread/code/code.d.ts +10 -0
- package/dist/thread/code/code.js +195 -0
- package/dist/thread/code/copy-code-button.d.ts +6 -0
- package/dist/thread/code/copy-code-button.js +66 -0
- package/dist/thread/code/highlight.d.ts +1 -0
- package/dist/thread/code/highlight.js +40 -0
- package/dist/thread/history/history-rows.d.ts +16 -0
- package/dist/thread/history/history-rows.js +23 -0
- package/dist/thread/history/history.d.ts +16 -0
- package/dist/thread/history/history.js +179 -0
- package/dist/thread/history/row/history-row.d.ts +15 -0
- package/dist/thread/history/row/history-row.js +137 -0
- package/dist/thread/history/row/thread-item-menu.d.ts +7 -0
- package/dist/thread/history/row/thread-item-menu.js +84 -0
- package/dist/thread/history/row/thread-title-editor.d.ts +7 -0
- package/dist/thread/history/row/thread-title-editor.js +81 -0
- package/dist/thread/history/thread-groups.d.ts +8 -0
- package/dist/thread/history/thread-groups.js +52 -0
- package/dist/thread/history/virtual-history-list.d.ts +11 -0
- package/dist/thread/history/virtual-history-list.js +107 -0
- package/dist/thread/index.d.ts +8 -0
- package/dist/thread/index.js +5 -0
- package/dist/thread/starters/starters.d.ts +12 -0
- package/dist/thread/starters/starters.js +100 -0
- package/dist/thread/use-copied.d.ts +5 -0
- package/dist/thread/use-copied.js +52 -0
- package/dist/types.d.ts +70 -0
- package/dist/types.js +3 -0
- package/package.json +59 -3
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { Edit as SquarePenIcon } from "@carbon/icons-react";
|
|
3
|
+
import { Button, cn } from "@locusgraph/components";
|
|
4
|
+
import { useId, useMemo, useState } from "react";
|
|
5
|
+
import { ApprovalPanel, LiveStatus, PanelBody, PanelFooter, PanelHeader, PanelTitle } from "../../../shared/panel.js";
|
|
6
|
+
import { DecisionSummary } from "../../shared/decision-line.js";
|
|
7
|
+
import { riskCopy, riskLabels, riskRing } from "../../shared/risk-badge.js";
|
|
8
|
+
import { useFocusOnMount } from "../../shared/use-focus-on-mount.js";
|
|
9
|
+
import { ArgsField } from "./args-field.js";
|
|
10
|
+
import { draftsFrom, validateDrafts, valuesFromDrafts } from "./args-validation.js";
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
|
+
function errorSummary(count) {
|
|
13
|
+
return count === 1 ? "1 field needs a fix." : `${count} fields need a fix.`;
|
|
14
|
+
}
|
|
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;
|
|
273
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ArgField } from "../../types.js";
|
|
2
|
+
import type { ArgDraft } from "./args-validation.js";
|
|
3
|
+
type ArgsFieldProps = {
|
|
4
|
+
id: string;
|
|
5
|
+
field: ArgField;
|
|
6
|
+
draft: ArgDraft | undefined;
|
|
7
|
+
error?: string;
|
|
8
|
+
onChange: (draft: ArgDraft) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function ArgsField(props: ArgsFieldProps): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { Checkbox, Input, Label, NativeSelect, NativeSelectOption } from "@locusgraph/components";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
function describedBy(id, field, error) {
|
|
5
|
+
const ids = [field.description && `${id}-hint`, error && `${id}-error`].filter(Boolean);
|
|
6
|
+
return ids.length > 0 ? ids.join(" ") : undefined;
|
|
7
|
+
}
|
|
8
|
+
function FieldControl(t0) {
|
|
9
|
+
const $ = _c(38);
|
|
10
|
+
const {
|
|
11
|
+
id,
|
|
12
|
+
field,
|
|
13
|
+
draft,
|
|
14
|
+
error,
|
|
15
|
+
onChange
|
|
16
|
+
} = t0;
|
|
17
|
+
const t1 = field.name;
|
|
18
|
+
const t2 = error ? true : undefined;
|
|
19
|
+
let t3;
|
|
20
|
+
if ($[0] !== error || $[1] !== field || $[2] !== id) {
|
|
21
|
+
t3 = describedBy(id, field, error);
|
|
22
|
+
$[0] = error;
|
|
23
|
+
$[1] = field;
|
|
24
|
+
$[2] = id;
|
|
25
|
+
$[3] = t3;
|
|
26
|
+
} else {
|
|
27
|
+
t3 = $[3];
|
|
28
|
+
}
|
|
29
|
+
const t4 = field.required || undefined;
|
|
30
|
+
let t5;
|
|
31
|
+
if ($[4] !== field.name || $[5] !== id || $[6] !== t2 || $[7] !== t3 || $[8] !== t4) {
|
|
32
|
+
t5 = {
|
|
33
|
+
id,
|
|
34
|
+
name: t1,
|
|
35
|
+
"aria-invalid": t2,
|
|
36
|
+
"aria-describedby": t3,
|
|
37
|
+
"aria-required": t4
|
|
38
|
+
};
|
|
39
|
+
$[4] = field.name;
|
|
40
|
+
$[5] = id;
|
|
41
|
+
$[6] = t2;
|
|
42
|
+
$[7] = t3;
|
|
43
|
+
$[8] = t4;
|
|
44
|
+
$[9] = t5;
|
|
45
|
+
} else {
|
|
46
|
+
t5 = $[9];
|
|
47
|
+
}
|
|
48
|
+
const shared = t5;
|
|
49
|
+
if (field.type === "boolean") {
|
|
50
|
+
const t6 = draft === true;
|
|
51
|
+
let t7;
|
|
52
|
+
if ($[10] !== onChange) {
|
|
53
|
+
t7 = checked => onChange(checked === true);
|
|
54
|
+
$[10] = onChange;
|
|
55
|
+
$[11] = t7;
|
|
56
|
+
} else {
|
|
57
|
+
t7 = $[11];
|
|
58
|
+
}
|
|
59
|
+
let t8;
|
|
60
|
+
if ($[12] !== shared || $[13] !== t6 || $[14] !== t7) {
|
|
61
|
+
t8 = /*#__PURE__*/_jsx(Checkbox, {
|
|
62
|
+
...shared,
|
|
63
|
+
checked: t6,
|
|
64
|
+
onCheckedChange: t7
|
|
65
|
+
});
|
|
66
|
+
$[12] = shared;
|
|
67
|
+
$[13] = t6;
|
|
68
|
+
$[14] = t7;
|
|
69
|
+
$[15] = t8;
|
|
70
|
+
} else {
|
|
71
|
+
t8 = $[15];
|
|
72
|
+
}
|
|
73
|
+
return t8;
|
|
74
|
+
}
|
|
75
|
+
const text = typeof draft === "string" ? draft : "";
|
|
76
|
+
if (field.type === "select") {
|
|
77
|
+
let t6;
|
|
78
|
+
if ($[16] !== onChange) {
|
|
79
|
+
t6 = event => onChange(event.target.value);
|
|
80
|
+
$[16] = onChange;
|
|
81
|
+
$[17] = t6;
|
|
82
|
+
} else {
|
|
83
|
+
t6 = $[17];
|
|
84
|
+
}
|
|
85
|
+
let t7;
|
|
86
|
+
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
|
|
87
|
+
t7 = /*#__PURE__*/_jsx(NativeSelectOption, {
|
|
88
|
+
value: "",
|
|
89
|
+
children: "Choose\u2026"
|
|
90
|
+
});
|
|
91
|
+
$[18] = t7;
|
|
92
|
+
} else {
|
|
93
|
+
t7 = $[18];
|
|
94
|
+
}
|
|
95
|
+
let t8;
|
|
96
|
+
if ($[19] !== field.options) {
|
|
97
|
+
t8 = field.options ?? [];
|
|
98
|
+
$[19] = field.options;
|
|
99
|
+
$[20] = t8;
|
|
100
|
+
} else {
|
|
101
|
+
t8 = $[20];
|
|
102
|
+
}
|
|
103
|
+
let t9;
|
|
104
|
+
if ($[21] !== t8) {
|
|
105
|
+
t9 = t8.map(_temp);
|
|
106
|
+
$[21] = t8;
|
|
107
|
+
$[22] = t9;
|
|
108
|
+
} else {
|
|
109
|
+
t9 = $[22];
|
|
110
|
+
}
|
|
111
|
+
let t10;
|
|
112
|
+
if ($[23] !== shared || $[24] !== t6 || $[25] !== t9 || $[26] !== text) {
|
|
113
|
+
t10 = /*#__PURE__*/_jsxs(NativeSelect, {
|
|
114
|
+
...shared,
|
|
115
|
+
value: text,
|
|
116
|
+
onChange: t6,
|
|
117
|
+
children: [t7, t9]
|
|
118
|
+
});
|
|
119
|
+
$[23] = shared;
|
|
120
|
+
$[24] = t6;
|
|
121
|
+
$[25] = t9;
|
|
122
|
+
$[26] = text;
|
|
123
|
+
$[27] = t10;
|
|
124
|
+
} else {
|
|
125
|
+
t10 = $[27];
|
|
126
|
+
}
|
|
127
|
+
return t10;
|
|
128
|
+
}
|
|
129
|
+
const t6 = field.type === "number" ? "number" : "text";
|
|
130
|
+
const t7 = field.type === "number" ? "decimal" : undefined;
|
|
131
|
+
let t8;
|
|
132
|
+
if ($[28] !== onChange) {
|
|
133
|
+
t8 = event_0 => onChange(event_0.target.value);
|
|
134
|
+
$[28] = onChange;
|
|
135
|
+
$[29] = t8;
|
|
136
|
+
} else {
|
|
137
|
+
t8 = $[29];
|
|
138
|
+
}
|
|
139
|
+
let t9;
|
|
140
|
+
if ($[30] !== field.max || $[31] !== field.min || $[32] !== shared || $[33] !== t6 || $[34] !== t7 || $[35] !== t8 || $[36] !== text) {
|
|
141
|
+
t9 = /*#__PURE__*/_jsx(Input, {
|
|
142
|
+
...shared,
|
|
143
|
+
type: t6,
|
|
144
|
+
inputMode: t7,
|
|
145
|
+
min: field.min,
|
|
146
|
+
max: field.max,
|
|
147
|
+
value: text,
|
|
148
|
+
onChange: t8
|
|
149
|
+
});
|
|
150
|
+
$[30] = field.max;
|
|
151
|
+
$[31] = field.min;
|
|
152
|
+
$[32] = shared;
|
|
153
|
+
$[33] = t6;
|
|
154
|
+
$[34] = t7;
|
|
155
|
+
$[35] = t8;
|
|
156
|
+
$[36] = text;
|
|
157
|
+
$[37] = t9;
|
|
158
|
+
} else {
|
|
159
|
+
t9 = $[37];
|
|
160
|
+
}
|
|
161
|
+
return t9;
|
|
162
|
+
}
|
|
163
|
+
function _temp(option) {
|
|
164
|
+
return /*#__PURE__*/_jsx(NativeSelectOption, {
|
|
165
|
+
value: option.value,
|
|
166
|
+
children: option.label
|
|
167
|
+
}, option.value);
|
|
168
|
+
}
|
|
169
|
+
export function ArgsField(props) {
|
|
170
|
+
const $ = _c(23);
|
|
171
|
+
const {
|
|
172
|
+
id,
|
|
173
|
+
field,
|
|
174
|
+
error
|
|
175
|
+
} = props;
|
|
176
|
+
const inline = field.type === "boolean";
|
|
177
|
+
const t0 = inline ? "flex flex-row-reverse items-center justify-end gap-2" : "contents";
|
|
178
|
+
let t1;
|
|
179
|
+
if ($[0] !== field.required) {
|
|
180
|
+
t1 = field.required && /*#__PURE__*/_jsx("span", {
|
|
181
|
+
className: "text-xs font-normal text-muted-foreground",
|
|
182
|
+
children: "required"
|
|
183
|
+
});
|
|
184
|
+
$[0] = field.required;
|
|
185
|
+
$[1] = t1;
|
|
186
|
+
} else {
|
|
187
|
+
t1 = $[1];
|
|
188
|
+
}
|
|
189
|
+
let t2;
|
|
190
|
+
if ($[2] !== field.label || $[3] !== id || $[4] !== t1) {
|
|
191
|
+
t2 = /*#__PURE__*/_jsxs(Label, {
|
|
192
|
+
htmlFor: id,
|
|
193
|
+
children: [field.label, t1]
|
|
194
|
+
});
|
|
195
|
+
$[2] = field.label;
|
|
196
|
+
$[3] = id;
|
|
197
|
+
$[4] = t1;
|
|
198
|
+
$[5] = t2;
|
|
199
|
+
} else {
|
|
200
|
+
t2 = $[5];
|
|
201
|
+
}
|
|
202
|
+
let t3;
|
|
203
|
+
if ($[6] !== props) {
|
|
204
|
+
t3 = /*#__PURE__*/_jsx(FieldControl, {
|
|
205
|
+
...props
|
|
206
|
+
});
|
|
207
|
+
$[6] = props;
|
|
208
|
+
$[7] = t3;
|
|
209
|
+
} else {
|
|
210
|
+
t3 = $[7];
|
|
211
|
+
}
|
|
212
|
+
let t4;
|
|
213
|
+
if ($[8] !== t0 || $[9] !== t2 || $[10] !== t3) {
|
|
214
|
+
t4 = /*#__PURE__*/_jsxs("div", {
|
|
215
|
+
className: t0,
|
|
216
|
+
children: [t2, t3]
|
|
217
|
+
});
|
|
218
|
+
$[8] = t0;
|
|
219
|
+
$[9] = t2;
|
|
220
|
+
$[10] = t3;
|
|
221
|
+
$[11] = t4;
|
|
222
|
+
} else {
|
|
223
|
+
t4 = $[11];
|
|
224
|
+
}
|
|
225
|
+
let t5;
|
|
226
|
+
if ($[12] !== field.description || $[13] !== id) {
|
|
227
|
+
t5 = field.description && /*#__PURE__*/_jsx("p", {
|
|
228
|
+
id: `${id}-hint`,
|
|
229
|
+
className: "text-xs text-muted-foreground",
|
|
230
|
+
children: field.description
|
|
231
|
+
});
|
|
232
|
+
$[12] = field.description;
|
|
233
|
+
$[13] = id;
|
|
234
|
+
$[14] = t5;
|
|
235
|
+
} else {
|
|
236
|
+
t5 = $[14];
|
|
237
|
+
}
|
|
238
|
+
let t6;
|
|
239
|
+
if ($[15] !== error || $[16] !== id) {
|
|
240
|
+
t6 = error && /*#__PURE__*/_jsx("p", {
|
|
241
|
+
id: `${id}-error`,
|
|
242
|
+
className: "text-xs text-destructive",
|
|
243
|
+
children: error
|
|
244
|
+
});
|
|
245
|
+
$[15] = error;
|
|
246
|
+
$[16] = id;
|
|
247
|
+
$[17] = t6;
|
|
248
|
+
} else {
|
|
249
|
+
t6 = $[17];
|
|
250
|
+
}
|
|
251
|
+
let t7;
|
|
252
|
+
if ($[18] !== field.type || $[19] !== t4 || $[20] !== t5 || $[21] !== t6) {
|
|
253
|
+
t7 = /*#__PURE__*/_jsxs("div", {
|
|
254
|
+
"data-slot": "args-field",
|
|
255
|
+
"data-type": field.type,
|
|
256
|
+
className: "flex flex-col gap-1.5 [&_[data-slot=native-select-wrapper]]:w-full",
|
|
257
|
+
children: [t4, t5, t6]
|
|
258
|
+
});
|
|
259
|
+
$[18] = field.type;
|
|
260
|
+
$[19] = t4;
|
|
261
|
+
$[20] = t5;
|
|
262
|
+
$[21] = t6;
|
|
263
|
+
$[22] = t7;
|
|
264
|
+
} else {
|
|
265
|
+
t7 = $[22];
|
|
266
|
+
}
|
|
267
|
+
return t7;
|
|
268
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ArgField, ArgValues } from "../../types.js";
|
|
2
|
+
export type ArgDraft = string | boolean;
|
|
3
|
+
export type ArgDrafts = Record<string, ArgDraft>;
|
|
4
|
+
export type ArgErrors = Record<string, string>;
|
|
5
|
+
export declare function draftsFrom(fields: ArgField[], initialValues: ArgValues): ArgDrafts;
|
|
6
|
+
export declare function fieldError(field: ArgField, draft: ArgDraft | undefined): string | undefined;
|
|
7
|
+
export declare function validateDrafts(fields: ArgField[], drafts: ArgDrafts): ArgErrors;
|
|
8
|
+
export declare function valuesFromDrafts(fields: ArgField[], drafts: ArgDrafts): ArgValues;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export function draftsFrom(fields, initialValues) {
|
|
2
|
+
return Object.fromEntries(fields.map(field => {
|
|
3
|
+
const initial = initialValues[field.name];
|
|
4
|
+
if (field.type === "boolean") return [field.name, initial === true];
|
|
5
|
+
return [field.name, initial === undefined ? "" : String(initial)];
|
|
6
|
+
}));
|
|
7
|
+
}
|
|
8
|
+
function numberError(field, draft) {
|
|
9
|
+
const value = Number(draft);
|
|
10
|
+
if (!Number.isFinite(value)) return `${field.label} must be a number.`;
|
|
11
|
+
if (field.min !== undefined && value < field.min) {
|
|
12
|
+
return `${field.label} must be at least ${field.min}.`;
|
|
13
|
+
}
|
|
14
|
+
if (field.max !== undefined && value > field.max) {
|
|
15
|
+
return `${field.label} must be at most ${field.max}.`;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
export function fieldError(field, draft) {
|
|
20
|
+
if (field.type === "boolean") return undefined;
|
|
21
|
+
const text = typeof draft === "string" ? draft.trim() : "";
|
|
22
|
+
if (text === "") return field.required ? `${field.label} is required.` : undefined;
|
|
23
|
+
if (field.type === "number") return numberError(field, text);
|
|
24
|
+
if (field.type === "select" && !field.options?.some(option => option.value === text)) {
|
|
25
|
+
return `Choose one of the listed ${field.label.toLowerCase()} options.`;
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
export function validateDrafts(fields, drafts) {
|
|
30
|
+
const errors = {};
|
|
31
|
+
for (const field of fields) {
|
|
32
|
+
const error = fieldError(field, drafts[field.name]);
|
|
33
|
+
if (error) errors[field.name] = error;
|
|
34
|
+
}
|
|
35
|
+
return errors;
|
|
36
|
+
}
|
|
37
|
+
function valueFromDraft(field, draft) {
|
|
38
|
+
if (field.type === "boolean") return draft === true;
|
|
39
|
+
const text = typeof draft === "string" ? draft.trim() : "";
|
|
40
|
+
if (text === "") return undefined;
|
|
41
|
+
return field.type === "number" ? Number(text) : text;
|
|
42
|
+
}
|
|
43
|
+
export function valuesFromDrafts(fields, drafts) {
|
|
44
|
+
const values = {};
|
|
45
|
+
for (const field of fields) {
|
|
46
|
+
const value = valueFromDraft(field, drafts[field.name]);
|
|
47
|
+
if (value !== undefined) values[field.name] = value;
|
|
48
|
+
}
|
|
49
|
+
return values;
|
|
50
|
+
}
|