@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.
Files changed (214) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -2
  3. package/dist/agent/index.d.ts +5 -0
  4. package/dist/agent/index.js +5 -0
  5. package/dist/agent/pulse/gradient-label.d.ts +7 -0
  6. package/dist/agent/pulse/gradient-label.js +94 -0
  7. package/dist/agent/pulse/marks/bars-mark.d.ts +1 -0
  8. package/dist/agent/pulse/marks/bars-mark.js +51 -0
  9. package/dist/agent/pulse/marks/glyph-mark.d.ts +4 -0
  10. package/dist/agent/pulse/marks/glyph-mark.js +62 -0
  11. package/dist/agent/pulse/marks/locus-mark.d.ts +1 -0
  12. package/dist/agent/pulse/marks/locus-mark.js +73 -0
  13. package/dist/agent/pulse/marks/orb-mark.d.ts +1 -0
  14. package/dist/agent/pulse/marks/orb-mark.js +34 -0
  15. package/dist/agent/pulse/marks/spinner-mark.d.ts +1 -0
  16. package/dist/agent/pulse/marks/spinner-mark.js +32 -0
  17. package/dist/agent/pulse/pulse-tone.d.ts +1 -0
  18. package/dist/agent/pulse/pulse-tone.js +1 -0
  19. package/dist/agent/pulse/pulse.d.ts +12 -0
  20. package/dist/agent/pulse/pulse.js +166 -0
  21. package/dist/agent/pulse/use-loop-animation.d.ts +2 -0
  22. package/dist/agent/pulse/use-loop-animation.js +40 -0
  23. package/dist/agent/shared/status-dot.d.ts +1 -0
  24. package/dist/agent/shared/status-dot.js +1 -0
  25. package/dist/agent/steps/step-icon.d.ts +8 -0
  26. package/dist/agent/steps/step-icon.js +117 -0
  27. package/dist/agent/steps/steps.d.ts +7 -0
  28. package/dist/agent/steps/steps.js +249 -0
  29. package/dist/agent/thinking/thinking.d.ts +6 -0
  30. package/dist/agent/thinking/thinking.js +211 -0
  31. package/dist/agent/thinking/thought-duration.d.ts +2 -0
  32. package/dist/agent/thinking/thought-duration.js +11 -0
  33. package/dist/agent/tool/json-block.d.ts +5 -0
  34. package/dist/agent/tool/json-block.js +42 -0
  35. package/dist/agent/tool/tool-status.d.ts +6 -0
  36. package/dist/agent/tool/tool-status.js +59 -0
  37. package/dist/agent/tool/tool.d.ts +7 -0
  38. package/dist/agent/tool/tool.js +192 -0
  39. package/dist/approval/inbox/inbox-row.d.ts +12 -0
  40. package/dist/approval/inbox/inbox-row.js +328 -0
  41. package/dist/approval/inbox/inbox-selection.d.ts +6 -0
  42. package/dist/approval/inbox/inbox-selection.js +15 -0
  43. package/dist/approval/inbox/inbox.d.ts +12 -0
  44. package/dist/approval/inbox/inbox.js +258 -0
  45. package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
  46. package/dist/approval/inbox/virtual-inbox-list.js +129 -0
  47. package/dist/approval/index.d.ts +9 -0
  48. package/dist/approval/index.js +8 -0
  49. package/dist/approval/memory/memory-choices.d.ts +10 -0
  50. package/dist/approval/memory/memory-choices.js +35 -0
  51. package/dist/approval/memory/memory-review.d.ts +11 -0
  52. package/dist/approval/memory/memory-review.js +256 -0
  53. package/dist/approval/memory/memory-row.d.ts +9 -0
  54. package/dist/approval/memory/memory-row.js +226 -0
  55. package/dist/approval/plan/plan-review.d.ts +13 -0
  56. package/dist/approval/plan/plan-review.js +289 -0
  57. package/dist/approval/plan/plan-step-row.d.ts +13 -0
  58. package/dist/approval/plan/plan-step-row.js +201 -0
  59. package/dist/approval/plan/plan-steps.d.ts +8 -0
  60. package/dist/approval/plan/plan-steps.js +30 -0
  61. package/dist/approval/plan/question-choices.d.ts +10 -0
  62. package/dist/approval/plan/question-choices.js +166 -0
  63. package/dist/approval/plan/question.d.ts +18 -0
  64. package/dist/approval/plan/question.js +232 -0
  65. package/dist/approval/run/run-bar.d.ts +13 -0
  66. package/dist/approval/run/run-bar.js +189 -0
  67. package/dist/approval/shared/decision-line.d.ts +1 -0
  68. package/dist/approval/shared/decision-line.js +1 -0
  69. package/dist/approval/shared/risk-badge.d.ts +10 -0
  70. package/dist/approval/shared/risk-badge.js +57 -0
  71. package/dist/approval/shared/time.d.ts +3 -0
  72. package/dist/approval/shared/time.js +12 -0
  73. package/dist/approval/shared/use-focus-on-mount.d.ts +2 -0
  74. package/dist/approval/shared/use-focus-on-mount.js +26 -0
  75. package/dist/approval/spend/raise-cap-form.d.ts +8 -0
  76. package/dist/approval/spend/raise-cap-form.js +244 -0
  77. package/dist/approval/spend/spend-gate.d.ts +16 -0
  78. package/dist/approval/spend/spend-gate.js +250 -0
  79. package/dist/approval/spend/spend-math.d.ts +5 -0
  80. package/dist/approval/spend/spend-math.js +17 -0
  81. package/dist/approval/spend/spend-meter.d.ts +10 -0
  82. package/dist/approval/spend/spend-meter.js +377 -0
  83. package/dist/approval/tool/approval.d.ts +14 -0
  84. package/dist/approval/tool/approval.js +290 -0
  85. package/dist/approval/tool/args/args-editor.d.ts +16 -0
  86. package/dist/approval/tool/args/args-editor.js +273 -0
  87. package/dist/approval/tool/args/args-field.d.ts +11 -0
  88. package/dist/approval/tool/args/args-field.js +268 -0
  89. package/dist/approval/tool/args/args-validation.d.ts +8 -0
  90. package/dist/approval/tool/args/args-validation.js +50 -0
  91. package/dist/approval/tool/deny-form.d.ts +6 -0
  92. package/dist/approval/tool/deny-form.js +135 -0
  93. package/dist/approval/tool/tool-inputs.d.ts +6 -0
  94. package/dist/approval/tool/tool-inputs.js +142 -0
  95. package/dist/approval/types.d.ts +59 -0
  96. package/dist/approval/types.js +1 -0
  97. package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
  98. package/dist/chat/chat/chat-item-spacing.js +19 -0
  99. package/dist/chat/chat/chat.d.ts +8 -0
  100. package/dist/chat/chat/chat.js +187 -0
  101. package/dist/chat/chat/use-stick-to-bottom.d.ts +7 -0
  102. package/dist/chat/chat/use-stick-to-bottom.js +133 -0
  103. package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
  104. package/dist/chat/chat/virtual-chat-items.js +153 -0
  105. package/dist/chat/composer/composer-actions.d.ts +15 -0
  106. package/dist/chat/composer/composer-actions.js +158 -0
  107. package/dist/chat/composer/composer.d.ts +20 -0
  108. package/dist/chat/composer/composer.js +340 -0
  109. package/dist/chat/composer/use-auto-grow.d.ts +2 -0
  110. package/dist/chat/composer/use-auto-grow.js +29 -0
  111. package/dist/chat/files/file-meta.d.ts +13 -0
  112. package/dist/chat/files/file-meta.js +30 -0
  113. package/dist/chat/files/files.d.ts +9 -0
  114. package/dist/chat/files/files.js +327 -0
  115. package/dist/chat/index.d.ts +7 -0
  116. package/dist/chat/index.js +7 -0
  117. package/dist/chat/reply/fenced-code.d.ts +8 -0
  118. package/dist/chat/reply/fenced-code.js +53 -0
  119. package/dist/chat/reply/markdown-components.d.ts +2 -0
  120. package/dist/chat/reply/markdown-components.js +142 -0
  121. package/dist/chat/reply/reply.d.ts +8 -0
  122. package/dist/chat/reply/reply.js +116 -0
  123. package/dist/chat/turn/group-parts.d.ts +24 -0
  124. package/dist/chat/turn/group-parts.js +49 -0
  125. package/dist/chat/turn/turn.d.ts +11 -0
  126. package/dist/chat/turn/turn.js +253 -0
  127. package/dist/cost/context.d.ts +13 -0
  128. package/dist/cost/context.js +333 -0
  129. package/dist/cost/cost-steps.d.ts +17 -0
  130. package/dist/cost/cost-steps.js +230 -0
  131. package/dist/cost/cost.d.ts +8 -0
  132. package/dist/cost/cost.js +531 -0
  133. package/dist/cost/index.d.ts +4 -0
  134. package/dist/cost/index.js +4 -0
  135. package/dist/cost/model-picker.d.ts +11 -0
  136. package/dist/cost/model-picker.js +184 -0
  137. package/dist/cost/shared/context-breakdown.d.ts +15 -0
  138. package/dist/cost/shared/context-breakdown.js +306 -0
  139. package/dist/cost/shared/meter-marks.d.ts +9 -0
  140. package/dist/cost/shared/meter-marks.js +114 -0
  141. package/dist/cost/shared/model-option-row.d.ts +14 -0
  142. package/dist/cost/shared/model-option-row.js +189 -0
  143. package/dist/cost/shared/step-cost-row.d.ts +15 -0
  144. package/dist/cost/shared/step-cost-row.js +262 -0
  145. package/dist/cost/shared/usage-totals.d.ts +11 -0
  146. package/dist/cost/shared/usage-totals.js +30 -0
  147. package/dist/index.d.ts +7 -0
  148. package/dist/index.js +7 -0
  149. package/dist/memory/cite.d.ts +8 -0
  150. package/dist/memory/cite.js +190 -0
  151. package/dist/memory/index.d.ts +5 -0
  152. package/dist/memory/index.js +4 -0
  153. package/dist/memory/memorized.d.ts +14 -0
  154. package/dist/memory/memorized.js +225 -0
  155. package/dist/memory/recall.d.ts +9 -0
  156. package/dist/memory/recall.js +303 -0
  157. package/dist/memory/shared/disclosure.d.ts +6 -0
  158. package/dist/memory/shared/disclosure.js +6 -0
  159. package/dist/memory/shared/host-label.d.ts +6 -0
  160. package/dist/memory/shared/host-label.js +31 -0
  161. package/dist/memory/shared/source-mark.d.ts +5 -0
  162. package/dist/memory/shared/source-mark.js +42 -0
  163. package/dist/memory/sources.d.ts +9 -0
  164. package/dist/memory/sources.js +264 -0
  165. package/dist/shared/decision-summary.d.ts +18 -0
  166. package/dist/shared/decision-summary.js +144 -0
  167. package/dist/shared/panel-empty.d.ts +8 -0
  168. package/dist/shared/panel-empty.js +80 -0
  169. package/dist/shared/panel.d.ts +19 -0
  170. package/dist/shared/panel.js +251 -0
  171. package/dist/shared/status-dot.d.ts +6 -0
  172. package/dist/shared/status-dot.js +42 -0
  173. package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
  174. package/dist/shared/virtual/use-list-virtualizer.js +68 -0
  175. package/dist/sources.css +1 -0
  176. package/dist/thread/actions/action-button.d.ts +8 -0
  177. package/dist/thread/actions/action-button.js +67 -0
  178. package/dist/thread/actions/actions.d.ts +13 -0
  179. package/dist/thread/actions/actions.js +192 -0
  180. package/dist/thread/actions/branch-switcher.d.ts +10 -0
  181. package/dist/thread/actions/branch-switcher.js +104 -0
  182. package/dist/thread/canvas/canvas.d.ts +14 -0
  183. package/dist/thread/canvas/canvas.js +212 -0
  184. package/dist/thread/canvas/version-switcher.d.ts +12 -0
  185. package/dist/thread/canvas/version-switcher.js +152 -0
  186. package/dist/thread/code/code.d.ts +10 -0
  187. package/dist/thread/code/code.js +195 -0
  188. package/dist/thread/code/copy-code-button.d.ts +6 -0
  189. package/dist/thread/code/copy-code-button.js +66 -0
  190. package/dist/thread/code/highlight.d.ts +1 -0
  191. package/dist/thread/code/highlight.js +40 -0
  192. package/dist/thread/history/history-rows.d.ts +16 -0
  193. package/dist/thread/history/history-rows.js +23 -0
  194. package/dist/thread/history/history.d.ts +16 -0
  195. package/dist/thread/history/history.js +179 -0
  196. package/dist/thread/history/row/history-row.d.ts +15 -0
  197. package/dist/thread/history/row/history-row.js +137 -0
  198. package/dist/thread/history/row/thread-item-menu.d.ts +7 -0
  199. package/dist/thread/history/row/thread-item-menu.js +84 -0
  200. package/dist/thread/history/row/thread-title-editor.d.ts +7 -0
  201. package/dist/thread/history/row/thread-title-editor.js +81 -0
  202. package/dist/thread/history/thread-groups.d.ts +8 -0
  203. package/dist/thread/history/thread-groups.js +52 -0
  204. package/dist/thread/history/virtual-history-list.d.ts +11 -0
  205. package/dist/thread/history/virtual-history-list.js +107 -0
  206. package/dist/thread/index.d.ts +8 -0
  207. package/dist/thread/index.js +5 -0
  208. package/dist/thread/starters/starters.d.ts +12 -0
  209. package/dist/thread/starters/starters.js +100 -0
  210. package/dist/thread/use-copied.d.ts +5 -0
  211. package/dist/thread/use-copied.js +52 -0
  212. package/dist/types.d.ts +70 -0
  213. package/dist/types.js +3 -0
  214. package/package.json +59 -3
@@ -0,0 +1,135 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { Button, Label, Textarea } from "@locusgraph/components";
3
+ import { useId, useState } from "react";
4
+ import { PanelBody, PanelFooter } from "../../shared/panel.js";
5
+ import { useFocusOnMount } from "../shared/use-focus-on-mount.js";
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
+ export function DenyForm(t0) {
8
+ const $ = _c(24);
9
+ const {
10
+ onDeny,
11
+ onBack
12
+ } = t0;
13
+ const [reason, setReason] = useState("");
14
+ const reasonId = useId();
15
+ const reasonRef = useFocusOnMount(true);
16
+ let t1;
17
+ if ($[0] !== reason) {
18
+ t1 = reason.trim();
19
+ $[0] = reason;
20
+ $[1] = t1;
21
+ } else {
22
+ t1 = $[1];
23
+ }
24
+ const trimmed = t1;
25
+ let t2;
26
+ if ($[2] !== onDeny || $[3] !== trimmed) {
27
+ t2 = event => {
28
+ event.preventDefault();
29
+ onDeny(trimmed === "" ? undefined : trimmed);
30
+ };
31
+ $[2] = onDeny;
32
+ $[3] = trimmed;
33
+ $[4] = t2;
34
+ } else {
35
+ t2 = $[4];
36
+ }
37
+ let t3;
38
+ if ($[5] !== reasonId) {
39
+ t3 = /*#__PURE__*/_jsx(Label, {
40
+ htmlFor: reasonId,
41
+ className: "text-xs font-normal text-muted-foreground",
42
+ children: "Reason for the agent (optional)"
43
+ });
44
+ $[5] = reasonId;
45
+ $[6] = t3;
46
+ } else {
47
+ t3 = $[6];
48
+ }
49
+ let t4;
50
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
51
+ t4 = event_0 => setReason(event_0.target.value);
52
+ $[7] = t4;
53
+ } else {
54
+ t4 = $[7];
55
+ }
56
+ let t5;
57
+ if ($[8] !== reason || $[9] !== reasonId || $[10] !== reasonRef) {
58
+ t5 = /*#__PURE__*/_jsx(Textarea, {
59
+ id: reasonId,
60
+ ref: reasonRef,
61
+ value: reason,
62
+ placeholder: "Tell the agent what to do instead",
63
+ onChange: t4
64
+ });
65
+ $[8] = reason;
66
+ $[9] = reasonId;
67
+ $[10] = reasonRef;
68
+ $[11] = t5;
69
+ } else {
70
+ t5 = $[11];
71
+ }
72
+ let t6;
73
+ if ($[12] !== t3 || $[13] !== t5) {
74
+ t6 = /*#__PURE__*/_jsxs(PanelBody, {
75
+ className: "gap-2 pt-0",
76
+ children: [t3, t5]
77
+ });
78
+ $[12] = t3;
79
+ $[13] = t5;
80
+ $[14] = t6;
81
+ } else {
82
+ t6 = $[14];
83
+ }
84
+ let t7;
85
+ if ($[15] !== onBack) {
86
+ t7 = /*#__PURE__*/_jsx(Button, {
87
+ type: "button",
88
+ variant: "ghost",
89
+ size: "sm",
90
+ onClick: onBack,
91
+ children: "Back"
92
+ });
93
+ $[15] = onBack;
94
+ $[16] = t7;
95
+ } else {
96
+ t7 = $[16];
97
+ }
98
+ let t8;
99
+ if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
100
+ t8 = /*#__PURE__*/_jsx(Button, {
101
+ type: "submit",
102
+ variant: "destructive",
103
+ size: "sm",
104
+ children: "Send denial"
105
+ });
106
+ $[17] = t8;
107
+ } else {
108
+ t8 = $[17];
109
+ }
110
+ let t9;
111
+ if ($[18] !== t7) {
112
+ t9 = /*#__PURE__*/_jsxs(PanelFooter, {
113
+ children: [t7, t8]
114
+ });
115
+ $[18] = t7;
116
+ $[19] = t9;
117
+ } else {
118
+ t9 = $[19];
119
+ }
120
+ let t10;
121
+ if ($[20] !== t2 || $[21] !== t6 || $[22] !== t9) {
122
+ t10 = /*#__PURE__*/_jsxs("form", {
123
+ "data-slot": "deny-form",
124
+ onSubmit: t2,
125
+ children: [t6, t9]
126
+ });
127
+ $[20] = t2;
128
+ $[21] = t6;
129
+ $[22] = t9;
130
+ $[23] = t10;
131
+ } else {
132
+ t10 = $[23];
133
+ }
134
+ return t10;
135
+ }
@@ -0,0 +1,6 @@
1
+ export declare function readableValue(value: unknown): string;
2
+ export declare function humanizeKey(key: string): string;
3
+ export declare function ToolInputs({ input, muted }: {
4
+ input: unknown;
5
+ muted?: boolean;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,142 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { cn } from "@locusgraph/components";
3
+ import { useId, useState } from "react";
4
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
+ function isPlainRecord(value) {
6
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7
+ }
8
+ function isPrimitive(value) {
9
+ return value === null || ["string", "number", "boolean"].includes(typeof value);
10
+ }
11
+ export function readableValue(value) {
12
+ if (value === null || value === undefined) return "None";
13
+ if (typeof value === "boolean") return value ? "Yes" : "No";
14
+ if (typeof value === "string" || typeof value === "number") return String(value);
15
+ if (Array.isArray(value) && value.every(isPrimitive)) {
16
+ return value.length === 0 ? "None" : value.map(readableValue).join(", ");
17
+ }
18
+ return JSON.stringify(value);
19
+ }
20
+ const acronyms = {
21
+ api: "API",
22
+ csv: "CSV",
23
+ id: "ID",
24
+ ids: "IDs",
25
+ json: "JSON",
26
+ pdf: "PDF",
27
+ sql: "SQL",
28
+ url: "URL",
29
+ urls: "URLs",
30
+ usd: "USD"
31
+ };
32
+ export function humanizeKey(key) {
33
+ const words = key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").trim().toLowerCase().split(/\s+/).map(word => acronyms[word] ?? word);
34
+ const sentence = words.join(" ");
35
+ return sentence.charAt(0).toUpperCase() + sentence.slice(1);
36
+ }
37
+ function rawJson(input) {
38
+ return JSON.stringify(input, null, 2) ?? "undefined";
39
+ }
40
+ export function ToolInputs(t0) {
41
+ const $ = _c(22);
42
+ const {
43
+ input,
44
+ muted: t1
45
+ } = t0;
46
+ const muted = t1 === undefined ? false : t1;
47
+ const [showRaw, setShowRaw] = useState(false);
48
+ const rawId = useId();
49
+ let entries;
50
+ let t2;
51
+ let t3;
52
+ let t4;
53
+ if ($[0] !== input || $[1] !== muted || $[2] !== showRaw) {
54
+ entries = isPlainRecord(input) ? Object.entries(input) : null;
55
+ t2 = "tool-inputs";
56
+ t3 = "flex flex-col gap-2";
57
+ t4 = entries && !showRaw && /*#__PURE__*/_jsxs("dl", {
58
+ className: cn("-mx-5 flex flex-col divide-y border-y text-sm", muted && "text-muted-foreground"),
59
+ children: [entries.map(_temp), entries.length === 0 && /*#__PURE__*/_jsx("div", {
60
+ className: "px-5 py-2.5 text-xs text-muted-foreground",
61
+ children: "No inputs."
62
+ })]
63
+ });
64
+ $[0] = input;
65
+ $[1] = muted;
66
+ $[2] = showRaw;
67
+ $[3] = entries;
68
+ $[4] = t2;
69
+ $[5] = t3;
70
+ $[6] = t4;
71
+ } else {
72
+ entries = $[3];
73
+ t2 = $[4];
74
+ t3 = $[5];
75
+ t4 = $[6];
76
+ }
77
+ let t5;
78
+ if ($[7] !== entries || $[8] !== input || $[9] !== rawId || $[10] !== showRaw) {
79
+ t5 = (showRaw || !entries) && /*#__PURE__*/_jsx("pre", {
80
+ id: rawId,
81
+ className: "overflow-x-auto bg-muted/40 p-3 font-mono text-xs",
82
+ children: rawJson(input)
83
+ });
84
+ $[7] = entries;
85
+ $[8] = input;
86
+ $[9] = rawId;
87
+ $[10] = showRaw;
88
+ $[11] = t5;
89
+ } else {
90
+ t5 = $[11];
91
+ }
92
+ let t6;
93
+ if ($[12] !== entries || $[13] !== rawId || $[14] !== showRaw) {
94
+ t6 = entries && /*#__PURE__*/_jsx("button", {
95
+ type: "button",
96
+ className: "eyebrow self-start outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/70 motion-safe:transition-colors",
97
+ "aria-expanded": showRaw,
98
+ "aria-controls": showRaw ? rawId : undefined,
99
+ onClick: () => setShowRaw(_temp2),
100
+ children: showRaw ? "Show fields" : "Show raw"
101
+ });
102
+ $[12] = entries;
103
+ $[13] = rawId;
104
+ $[14] = showRaw;
105
+ $[15] = t6;
106
+ } else {
107
+ t6 = $[15];
108
+ }
109
+ let t7;
110
+ if ($[16] !== t2 || $[17] !== t3 || $[18] !== t4 || $[19] !== t5 || $[20] !== t6) {
111
+ t7 = /*#__PURE__*/_jsxs("div", {
112
+ "data-slot": t2,
113
+ className: t3,
114
+ children: [t4, t5, t6]
115
+ });
116
+ $[16] = t2;
117
+ $[17] = t3;
118
+ $[18] = t4;
119
+ $[19] = t5;
120
+ $[20] = t6;
121
+ $[21] = t7;
122
+ } else {
123
+ t7 = $[21];
124
+ }
125
+ return t7;
126
+ }
127
+ function _temp2(current) {
128
+ return !current;
129
+ }
130
+ function _temp(t0) {
131
+ const [key, value] = t0;
132
+ return /*#__PURE__*/_jsxs("div", {
133
+ className: "grid grid-cols-[minmax(0,8.5rem)_minmax(0,1fr)] items-baseline gap-3 px-5 py-2.5",
134
+ children: [/*#__PURE__*/_jsx("dt", {
135
+ className: "text-xs text-muted-foreground",
136
+ children: humanizeKey(key)
137
+ }), /*#__PURE__*/_jsx("dd", {
138
+ className: "font-mono text-sm break-words",
139
+ children: readableValue(value)
140
+ })]
141
+ }, key);
142
+ }
@@ -0,0 +1,59 @@
1
+ import type { RiskLevel } from "../types.js";
2
+ export type DecidedAt = number | string | Date;
3
+ export type ApprovalDecision = {
4
+ approved: boolean;
5
+ by: string;
6
+ at: DecidedAt;
7
+ reason?: string;
8
+ };
9
+ export type ArgFieldType = "text" | "number" | "boolean" | "select";
10
+ export type ArgFieldOption = {
11
+ value: string;
12
+ label: string;
13
+ };
14
+ export type ArgField = {
15
+ name: string;
16
+ label: string;
17
+ type: ArgFieldType;
18
+ options?: ArgFieldOption[];
19
+ required?: boolean;
20
+ min?: number;
21
+ max?: number;
22
+ description?: string;
23
+ };
24
+ export type ArgValue = string | number | boolean;
25
+ export type ArgValues = Record<string, ArgValue>;
26
+ export type PlanStepDraft = {
27
+ id: string;
28
+ title: string;
29
+ detail?: string;
30
+ };
31
+ export type QuestionOption = {
32
+ id: string;
33
+ label: string;
34
+ description?: string;
35
+ };
36
+ export type QuestionAnswer = {
37
+ optionId?: string;
38
+ text?: string;
39
+ };
40
+ export type ProposedMemory = {
41
+ id: string;
42
+ text: string;
43
+ kind?: string;
44
+ sensitive?: boolean;
45
+ };
46
+ export type MemoryReviewResult = {
47
+ kept: ProposedMemory[];
48
+ edited: ProposedMemory[];
49
+ discarded: ProposedMemory[];
50
+ };
51
+ export type RunBarStatus = "running" | "paused" | "stopped" | "done";
52
+ export type PendingApproval = {
53
+ id: string;
54
+ title: string;
55
+ runName: string;
56
+ risk: RiskLevel;
57
+ requestedAt: DecidedAt;
58
+ summary?: string;
59
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { type ReactNode } from "react";
2
+ export declare function gapBeforeItem(items: ReactNode[], index: number): number;
3
+ export declare function isPositionable(node: ReactNode): node is React.ReactElement;
@@ -0,0 +1,19 @@
1
+ import { Fragment, isValidElement } from "react";
2
+ const turnGapPx = 32;
3
+ const answerAfterQuestionGapPx = 16;
4
+ function roleOf(node) {
5
+ if (!isValidElement(node)) {
6
+ return undefined;
7
+ }
8
+ return node.props["data-role"] ?? node.props.message?.role;
9
+ }
10
+ export function gapBeforeItem(items, index) {
11
+ if (index === 0) {
12
+ return 0;
13
+ }
14
+ const answersQuestion = roleOf(items[index - 1]) === "user" && roleOf(items[index]) === "assistant";
15
+ return answersQuestion ? answerAfterQuestionGapPx : turnGapPx;
16
+ }
17
+ export function isPositionable(node) {
18
+ return isValidElement(node) && node.type !== Fragment && typeof node.type !== "string";
19
+ }
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ export type ChatProps = React.ComponentProps<"div"> & {
3
+ empty?: React.ReactNode;
4
+ label?: string;
5
+ jumpLabel?: string;
6
+ virtualize?: boolean;
7
+ };
8
+ export declare function Chat({ children, empty, label, jumpLabel, virtualize, className, ...props }: ChatProps): React.JSX.Element;
@@ -0,0 +1,187 @@
1
+ "use client";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
4
+ import { ArrowDown as ArrowDownIcon } from "@carbon/icons-react";
5
+ import { Button, cn } from "@locusgraph/components";
6
+ import * as React from "react";
7
+ import { shouldVirtualize } from "../../shared/virtual/use-list-virtualizer.js";
8
+ import { useStickToBottom } from "./use-stick-to-bottom.js";
9
+ import { VirtualChatItems } from "./virtual-chat-items.js";
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ export function Chat(t0) {
12
+ const $ = _c(43);
13
+ let children;
14
+ let className;
15
+ let empty;
16
+ let props;
17
+ let t1;
18
+ let t2;
19
+ let t3;
20
+ if ($[0] !== t0) {
21
+ ({
22
+ children,
23
+ empty,
24
+ label: t1,
25
+ jumpLabel: t2,
26
+ virtualize: t3,
27
+ className,
28
+ ...props
29
+ } = t0);
30
+ $[0] = t0;
31
+ $[1] = children;
32
+ $[2] = className;
33
+ $[3] = empty;
34
+ $[4] = props;
35
+ $[5] = t1;
36
+ $[6] = t2;
37
+ $[7] = t3;
38
+ } else {
39
+ children = $[1];
40
+ className = $[2];
41
+ empty = $[3];
42
+ props = $[4];
43
+ t1 = $[5];
44
+ t2 = $[6];
45
+ t3 = $[7];
46
+ }
47
+ const label = t1 === undefined ? "Chat" : t1;
48
+ const jumpLabel = t2 === undefined ? "Jump to latest" : t2;
49
+ const virtualize = t3 === undefined ? true : t3;
50
+ const {
51
+ viewportRef,
52
+ contentRef,
53
+ isAtBottom,
54
+ handleScroll,
55
+ scrollToLatest
56
+ } = useStickToBottom();
57
+ const [scrolling, setScrolling] = React.useState(false);
58
+ let isEmpty;
59
+ let items;
60
+ let t4;
61
+ if ($[8] !== children || $[9] !== virtualize) {
62
+ items = React.Children.toArray(children);
63
+ isEmpty = items.length === 0;
64
+ t4 = shouldVirtualize(items.length, virtualize);
65
+ $[8] = children;
66
+ $[9] = virtualize;
67
+ $[10] = isEmpty;
68
+ $[11] = items;
69
+ $[12] = t4;
70
+ } else {
71
+ isEmpty = $[10];
72
+ items = $[11];
73
+ t4 = $[12];
74
+ }
75
+ const isVirtual = t4;
76
+ const t5 = isEmpty || undefined;
77
+ const t6 = isVirtual || undefined;
78
+ let t7;
79
+ if ($[13] !== className) {
80
+ t7 = cn("relative flex min-h-0 flex-1 flex-col overflow-hidden", className);
81
+ $[13] = className;
82
+ $[14] = t7;
83
+ } else {
84
+ t7 = $[14];
85
+ }
86
+ const t8 = isVirtual && scrolling || undefined;
87
+ let t9;
88
+ if ($[15] !== children || $[16] !== empty || $[17] !== isEmpty || $[18] !== isVirtual || $[19] !== items || $[20] !== viewportRef) {
89
+ t9 = isEmpty ? /*#__PURE__*/_jsx("div", {
90
+ "data-slot": "chat-empty",
91
+ className: "flex flex-1 flex-col items-center justify-center text-center",
92
+ children: empty
93
+ }) : isVirtual ? /*#__PURE__*/_jsx(VirtualChatItems, {
94
+ items: items,
95
+ viewportRef: viewportRef,
96
+ onScrollingChange: setScrolling
97
+ }) : children;
98
+ $[15] = children;
99
+ $[16] = empty;
100
+ $[17] = isEmpty;
101
+ $[18] = isVirtual;
102
+ $[19] = items;
103
+ $[20] = viewportRef;
104
+ $[21] = t9;
105
+ } else {
106
+ t9 = $[21];
107
+ }
108
+ let t10;
109
+ if ($[22] !== contentRef || $[23] !== t9) {
110
+ t10 = /*#__PURE__*/_jsx("div", {
111
+ ref: contentRef,
112
+ "data-slot": "chat-content",
113
+ className: "mx-auto flex min-h-full w-full max-w-3xl flex-col gap-8 px-4 py-6 [&>[data-role=user]+[data-role=assistant]]:-mt-4",
114
+ children: t9
115
+ });
116
+ $[22] = contentRef;
117
+ $[23] = t9;
118
+ $[24] = t10;
119
+ } else {
120
+ t10 = $[24];
121
+ }
122
+ let t11;
123
+ if ($[25] !== handleScroll || $[26] !== label || $[27] !== t10 || $[28] !== t8 || $[29] !== viewportRef) {
124
+ t11 = /*#__PURE__*/_jsx("div", {
125
+ ref: viewportRef,
126
+ "data-slot": "chat-viewport",
127
+ role: "log",
128
+ "aria-label": label,
129
+ "aria-busy": t8,
130
+ tabIndex: 0,
131
+ onScroll: handleScroll,
132
+ className: "min-h-0 flex-1 overflow-y-auto overscroll-contain outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset",
133
+ children: t10
134
+ });
135
+ $[25] = handleScroll;
136
+ $[26] = label;
137
+ $[27] = t10;
138
+ $[28] = t8;
139
+ $[29] = viewportRef;
140
+ $[30] = t11;
141
+ } else {
142
+ t11 = $[30];
143
+ }
144
+ let t12;
145
+ if ($[31] !== isAtBottom || $[32] !== isEmpty || $[33] !== jumpLabel || $[34] !== scrollToLatest) {
146
+ t12 = !isEmpty && !isAtBottom && /*#__PURE__*/_jsxs(Button, {
147
+ type: "button",
148
+ variant: "outline",
149
+ size: "sm",
150
+ "data-slot": "chat-jump",
151
+ onClick: scrollToLatest,
152
+ className: "absolute bottom-3 left-1/2 h-7 -translate-x-1/2 bg-card px-3 text-xs text-muted-foreground shadow-none hover:text-foreground motion-safe:animate-in motion-safe:fade-in-0 dark:bg-card",
153
+ children: [/*#__PURE__*/_jsx(ArrowDownIcon, {
154
+ "aria-hidden": "true",
155
+ className: "size-3.5"
156
+ }), jumpLabel]
157
+ });
158
+ $[31] = isAtBottom;
159
+ $[32] = isEmpty;
160
+ $[33] = jumpLabel;
161
+ $[34] = scrollToLatest;
162
+ $[35] = t12;
163
+ } else {
164
+ t12 = $[35];
165
+ }
166
+ let t13;
167
+ if ($[36] !== props || $[37] !== t11 || $[38] !== t12 || $[39] !== t5 || $[40] !== t6 || $[41] !== t7) {
168
+ t13 = /*#__PURE__*/_jsxs("div", {
169
+ "data-slot": "chat",
170
+ "data-empty": t5,
171
+ "data-virtual": t6,
172
+ className: t7,
173
+ ...props,
174
+ children: [t11, t12]
175
+ });
176
+ $[36] = props;
177
+ $[37] = t11;
178
+ $[38] = t12;
179
+ $[39] = t5;
180
+ $[40] = t6;
181
+ $[41] = t7;
182
+ $[42] = t13;
183
+ } else {
184
+ t13 = $[42];
185
+ }
186
+ return t13;
187
+ }
@@ -0,0 +1,7 @@
1
+ export declare function useStickToBottom(): {
2
+ viewportRef: import("react").RefObject<HTMLDivElement | null>;
3
+ contentRef: import("react").RefObject<HTMLDivElement | null>;
4
+ isAtBottom: boolean;
5
+ handleScroll: () => void;
6
+ scrollToLatest: () => void;
7
+ };
@@ -0,0 +1,133 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ const bottomThresholdPx = 48;
4
+ function distanceFromBottom(element) {
5
+ return element.scrollHeight - element.scrollTop - element.clientHeight;
6
+ }
7
+ function prefersReducedMotion() {
8
+ return typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches === true;
9
+ }
10
+ function scrolledUpByReader(viewport, previous) {
11
+ return viewport.scrollTop < previous.top && viewport.scrollHeight === previous.height;
12
+ }
13
+ export function useStickToBottom() {
14
+ const $ = _c(8);
15
+ const viewportRef = useRef(null);
16
+ const contentRef = useRef(null);
17
+ const stuckRef = useRef(true);
18
+ let t0;
19
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
20
+ t0 = {
21
+ top: 0,
22
+ height: 0
23
+ };
24
+ $[0] = t0;
25
+ } else {
26
+ t0 = $[0];
27
+ }
28
+ const lastScrollRef = useRef(t0);
29
+ const [isAtBottom, setIsAtBottom] = useState(true);
30
+ let t1;
31
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
32
+ t1 = () => {
33
+ const viewport = viewportRef.current;
34
+ if (viewport) {
35
+ viewport.scrollTop = viewport.scrollHeight;
36
+ }
37
+ };
38
+ $[1] = t1;
39
+ } else {
40
+ t1 = $[1];
41
+ }
42
+ const pinToBottom = t1;
43
+ let t2;
44
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
45
+ t2 = () => {
46
+ const viewport_0 = viewportRef.current;
47
+ if (!viewport_0) {
48
+ return;
49
+ }
50
+ const atBottom = distanceFromBottom(viewport_0) <= bottomThresholdPx;
51
+ const readerScrolledUp = scrolledUpByReader(viewport_0, lastScrollRef.current);
52
+ lastScrollRef.current = {
53
+ top: viewport_0.scrollTop,
54
+ height: viewport_0.scrollHeight
55
+ };
56
+ if (atBottom) {
57
+ stuckRef.current = true;
58
+ } else {
59
+ if (readerScrolledUp) {
60
+ stuckRef.current = false;
61
+ } else {
62
+ if (stuckRef.current) {
63
+ pinToBottom();
64
+ }
65
+ }
66
+ }
67
+ setIsAtBottom(stuckRef.current);
68
+ };
69
+ $[2] = t2;
70
+ } else {
71
+ t2 = $[2];
72
+ }
73
+ const handleScroll = t2;
74
+ let t3;
75
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
76
+ t3 = () => {
77
+ const viewport_1 = viewportRef.current;
78
+ if (!viewport_1) {
79
+ return;
80
+ }
81
+ stuckRef.current = true;
82
+ setIsAtBottom(true);
83
+ viewport_1.scrollTo({
84
+ top: viewport_1.scrollHeight,
85
+ behavior: prefersReducedMotion() ? "auto" : "smooth"
86
+ });
87
+ };
88
+ $[3] = t3;
89
+ } else {
90
+ t3 = $[3];
91
+ }
92
+ const scrollToLatest = t3;
93
+ let t4;
94
+ let t5;
95
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
96
+ t4 = () => {
97
+ const content = contentRef.current;
98
+ if (!content || typeof ResizeObserver === "undefined") {
99
+ return;
100
+ }
101
+ pinToBottom();
102
+ const observer = new ResizeObserver(() => {
103
+ if (stuckRef.current) {
104
+ pinToBottom();
105
+ }
106
+ });
107
+ observer.observe(content);
108
+ return () => observer.disconnect();
109
+ };
110
+ t5 = [pinToBottom];
111
+ $[4] = t4;
112
+ $[5] = t5;
113
+ } else {
114
+ t4 = $[4];
115
+ t5 = $[5];
116
+ }
117
+ useEffect(t4, t5);
118
+ let t6;
119
+ if ($[6] !== isAtBottom) {
120
+ t6 = {
121
+ viewportRef,
122
+ contentRef,
123
+ isAtBottom,
124
+ handleScroll,
125
+ scrollToLatest
126
+ };
127
+ $[6] = isAtBottom;
128
+ $[7] = t6;
129
+ } else {
130
+ t6 = $[7];
131
+ }
132
+ return t6;
133
+ }