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