@locusgraph/loop 0.3.1 → 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.
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,21 +1,26 @@
1
1
  "use client";
2
2
 
3
3
  import { c as _c } from "react/compiler-runtime";
4
- import { Edit as SquarePenIcon } from "@carbon/icons-react";
5
4
  import { Button, cn } from "@locusgraph/components";
6
- import { useId, useMemo, useState } from "react";
7
- import { ApprovalPanel, LiveStatus, PanelBody, PanelFooter, PanelHeader, PanelTitle } from "../../../shared/panel.js";
8
- import { DecisionSummary } from "../../shared/decision-line.js";
9
- import { riskCopy, riskLabels, riskRing } from "../../shared/risk-badge.js";
10
- import { useFocusOnMount } from "../../shared/use-focus-on-mount.js";
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";
11
12
  import { ArgsField } from "./args-field.js";
12
13
  import { draftsFrom, validateDrafts, valuesFromDrafts } from "./args-validation.js";
13
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
+ }
14
19
  function errorSummary(count) {
15
20
  return count === 1 ? "1 field needs a fix." : `${count} fields need a fix.`;
16
21
  }
17
22
  export function ArgsEditor(t0) {
18
- const $ = _c(58);
23
+ const $ = _c(51);
19
24
  const {
20
25
  toolName,
21
26
  fields,
@@ -39,7 +44,7 @@ export function ArgsEditor(t0) {
39
44
  }
40
45
  const initialValues = t4;
41
46
  const risk = t2 === undefined ? "write" : t2;
42
- const autoFocus = t3 === undefined ? false : t3;
47
+ const autoFocus = t3 === undefined ? true : t3;
43
48
  const baseId = useId();
44
49
  let t5;
45
50
  if ($[2] !== fields || $[3] !== initialValues) {
@@ -82,85 +87,79 @@ export function ArgsEditor(t0) {
82
87
  }
83
88
  const visibleErrors = t8;
84
89
  const destructive = risk === "destructive";
85
- const submitRef = useFocusOnMount(autoFocus && !decision);
86
- const t9 = `Edit ${toolName} inputs`;
87
- const t10 = decision ? decision.approved ? "approved" : "denied" : "editing";
88
- const t11 = !decision && riskRing[risk];
89
- let t12;
90
- if ($[13] !== className || $[14] !== t11) {
91
- t12 = cn(t11, className);
92
- $[13] = className;
93
- $[14] = t11;
94
- $[15] = t12;
95
- } else {
96
- t12 = $[15];
97
- }
98
- let t13;
99
- if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
100
- t13 = /*#__PURE__*/_jsx(SquarePenIcon, {
101
- "aria-hidden": true
102
- });
103
- $[16] = t13;
104
- } else {
105
- t13 = $[16];
106
- }
107
- const t14 = decision ? "Tool call" : "Edit before approving";
108
- const t15 = riskLabels[risk];
109
- const t16 = decision ? decision.approved ? "Approved" : "Cancelled" : "Waiting for you";
110
- const t17 = decision ? decision.approved ? "done" : "danger" : "waiting";
111
- let t18;
112
- if ($[17] !== t14 || $[18] !== t15 || $[19] !== t16 || $[20] !== t17) {
113
- t18 = /*#__PURE__*/_jsx(PanelHeader, {
114
- icon: t13,
115
- eyebrow: t14,
116
- aside: t15,
117
- status: t16,
118
- tone: t17
119
- });
120
- $[17] = t14;
121
- $[18] = t15;
122
- $[19] = t16;
123
- $[20] = t17;
124
- $[21] = t18;
90
+ let t9;
91
+ if ($[13] !== toolName) {
92
+ t9 = humanToolName(toolName);
93
+ $[13] = toolName;
94
+ $[14] = t9;
125
95
  } else {
126
- t18 = $[21];
96
+ t9 = $[14];
127
97
  }
128
- const t19 = decision && "text-muted-foreground";
129
- let t20;
130
- if ($[22] !== t19) {
131
- t20 = cn("truncate font-mono", t19);
132
- $[22] = t19;
133
- $[23] = t20;
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;
134
116
  } else {
135
- t20 = $[23];
117
+ t10 = $[17];
118
+ t11 = $[18];
136
119
  }
137
- let t21;
138
- if ($[24] !== t20 || $[25] !== toolName) {
139
- t21 = /*#__PURE__*/_jsx(PanelTitle, {
140
- className: t20,
141
- children: toolName
142
- });
143
- $[24] = t20;
144
- $[25] = toolName;
145
- $[26] = t21;
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;
146
131
  } else {
147
- t21 = $[26];
132
+ t15 = $[21];
148
133
  }
149
- let t22;
150
- 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) {
151
- t22 = decision ? /*#__PURE__*/_jsx(PanelBody, {
152
- className: "pt-3",
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,
138
+ icon: /*#__PURE__*/_jsx(SquarePenIcon, {
139
+ weight: "bold",
140
+ "aria-hidden": true
141
+ }),
153
142
  children: /*#__PURE__*/_jsx(DecisionSummary, {
154
143
  decision: decision,
155
144
  deniedVerb: "Cancelled",
156
- result: decision.approved ? `${toolName} approved with edited inputs` : `${toolName} cancelled`
145
+ result: decision.approved ? `${name} approved with edited inputs` : `${name} cancelled`
157
146
  })
158
147
  }) : /*#__PURE__*/_jsxs(_Fragment, {
159
- children: [/*#__PURE__*/_jsxs("p", {
160
- className: "px-5 pt-1 text-sm text-muted-foreground",
161
- children: [description ?? riskCopy[risk](toolName), " The tool runs with what you send."]
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]()
162
159
  }), /*#__PURE__*/_jsxs("form", {
160
+ ref: formRef,
163
161
  noValidate: true,
162
+ className: "flex flex-col gap-2",
164
163
  onSubmit: event => {
165
164
  event.preventDefault();
166
165
  const firstInvalid = fields.find(field => errors[field.name]);
@@ -174,102 +173,94 @@ export function ArgsEditor(t0) {
174
173
  }
175
174
  onApprove(valuesFromDrafts(fields, drafts));
176
175
  },
177
- children: [/*#__PURE__*/_jsx(PanelBody, {
178
- className: "gap-5 pt-5",
179
- children: fields.map(field_0 => /*#__PURE__*/_jsx(ArgsField, {
180
- id: `${baseId}-${field_0.name}`,
181
- field: field_0,
182
- draft: drafts[field_0.name],
183
- error: visibleErrors[field_0.name],
184
- onChange: draft => setDrafts(current => ({
185
- ...current,
186
- [field_0.name]: draft
187
- }))
188
- }, field_0.name))
189
- }), /*#__PURE__*/_jsxs(PanelFooter, {
190
- className: "justify-between",
191
- children: [/*#__PURE__*/_jsx("span", {
192
- className: cn("hidden font-mono text-[11px] sm:inline", showErrors && errorCount > 0 ? "text-destructive" : "text-muted-foreground"),
193
- children: showErrors && errorCount > 0 ? errorSummary(errorCount) : "The run is paused"
194
- }), /*#__PURE__*/_jsxs("span", {
195
- className: "flex flex-wrap gap-2",
196
- children: [/*#__PURE__*/_jsx(Button, {
197
- type: "button",
198
- size: "sm",
199
- variant: "ghost",
200
- onClick: onCancel,
201
- children: "Cancel"
202
- }), /*#__PURE__*/_jsx(Button, {
203
- ref: submitRef,
204
- type: "submit",
205
- size: "sm",
206
- variant: destructive ? "destructive" : "default",
207
- children: actionLabel ?? `Run ${toolName} with these inputs`
208
- })]
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)
209
201
  })]
210
202
  })]
211
203
  })]
212
204
  });
213
- $[27] = actionLabel;
214
- $[28] = baseId;
215
- $[29] = decision;
216
- $[30] = description;
217
- $[31] = destructive;
218
- $[32] = drafts;
219
- $[33] = errorCount;
220
- $[34] = errors;
221
- $[35] = fields;
222
- $[36] = onApprove;
223
- $[37] = onCancel;
224
- $[38] = risk;
225
- $[39] = showErrors;
226
- $[40] = submitRef;
227
- $[41] = toolName;
228
- $[42] = visibleErrors;
229
- $[43] = t22;
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;
230
221
  } else {
231
- t22 = $[43];
222
+ t16 = $[37];
232
223
  }
233
- let t23;
234
- if ($[44] !== errorCount || $[45] !== showErrors) {
235
- t23 = showErrors && errorCount > 0 ? errorSummary(errorCount) : "";
236
- $[44] = errorCount;
237
- $[45] = showErrors;
238
- $[46] = t23;
224
+ let t17;
225
+ if ($[38] !== errorCount || $[39] !== hasErrorSummary) {
226
+ t17 = hasErrorSummary ? errorSummary(errorCount) : "";
227
+ $[38] = errorCount;
228
+ $[39] = hasErrorSummary;
229
+ $[40] = t17;
239
230
  } else {
240
- t23 = $[46];
231
+ t17 = $[40];
241
232
  }
242
- let t24;
243
- if ($[47] !== t23) {
244
- t24 = /*#__PURE__*/_jsx(LiveStatus, {
245
- message: t23
233
+ let t18;
234
+ if ($[41] !== t17) {
235
+ t18 = /*#__PURE__*/_jsx(LiveStatus, {
236
+ message: t17
246
237
  });
247
- $[47] = t23;
248
- $[48] = t24;
238
+ $[41] = t17;
239
+ $[42] = t18;
249
240
  } else {
250
- t24 = $[48];
241
+ t18 = $[42];
251
242
  }
252
- let t25;
253
- if ($[49] !== risk || $[50] !== t10 || $[51] !== t12 || $[52] !== t18 || $[53] !== t21 || $[54] !== t22 || $[55] !== t24 || $[56] !== t9) {
254
- t25 = /*#__PURE__*/_jsxs(ApprovalPanel, {
243
+ let t19;
244
+ if ($[43] !== risk || $[44] !== t12 || $[45] !== t13 || $[46] !== t15 || $[47] !== t16 || $[48] !== t18 || $[49] !== toolName) {
245
+ t19 = /*#__PURE__*/_jsxs("section", {
255
246
  "data-slot": "args-editor",
256
247
  "data-risk": risk,
257
- "aria-label": t9,
258
- "data-state": t10,
259
- className: t12,
260
- children: [t18, t21, t22, t24]
248
+ "data-tool-name": toolName,
249
+ "aria-label": t12,
250
+ "data-state": t13,
251
+ className: t15,
252
+ children: [t16, t18]
261
253
  });
262
- $[49] = risk;
263
- $[50] = t10;
264
- $[51] = t12;
265
- $[52] = t18;
266
- $[53] = t21;
267
- $[54] = t22;
268
- $[55] = t24;
269
- $[56] = t9;
270
- $[57] = t25;
254
+ $[43] = risk;
255
+ $[44] = t12;
256
+ $[45] = t13;
257
+ $[46] = t15;
258
+ $[47] = t16;
259
+ $[48] = t18;
260
+ $[49] = toolName;
261
+ $[50] = t19;
271
262
  } else {
272
- t25 = $[57];
263
+ t19 = $[50];
273
264
  }
274
- return t25;
265
+ return t19;
275
266
  }