@locusgraph/loop 0.3.1 → 0.4.1

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