@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,8 @@
1
+ import { type ReactNode, type RefObject } from "react";
2
+ type VirtualChatItemsProps = {
3
+ items: ReactNode[];
4
+ viewportRef: RefObject<HTMLDivElement | null>;
5
+ onScrollingChange: (scrolling: boolean) => void;
6
+ };
7
+ export declare function VirtualChatItems({ items, viewportRef, onScrollingChange }: VirtualChatItemsProps): import("react").JSX.Element;
8
+ export {};
@@ -0,0 +1,153 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { cn } from "@locusgraph/components";
3
+ import { cloneElement, isValidElement, useEffect, useLayoutEffect } from "react";
4
+ import { rowOffsetStyle, useListVirtualizer, virtualRowClassName } from "../../shared/virtual/use-list-virtualizer.js";
5
+ import { gapBeforeItem, isPositionable } from "./chat-item-spacing.js";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const estimatedTurnHeightPx = 180;
8
+ function itemKey(item, index) {
9
+ return isValidElement(item) && item.key !== null ? item.key : index;
10
+ }
11
+ function withSetPosition(item, index, count) {
12
+ if (!isPositionable(item)) {
13
+ return item;
14
+ }
15
+ return cloneElement(item, {
16
+ "aria-posinset": index + 1,
17
+ "aria-setsize": count
18
+ });
19
+ }
20
+ export function VirtualChatItems(t0) {
21
+ const $ = _c(27);
22
+ const {
23
+ items,
24
+ viewportRef,
25
+ onScrollingChange
26
+ } = t0;
27
+ let t1;
28
+ if ($[0] !== viewportRef) {
29
+ t1 = () => viewportRef.current;
30
+ $[0] = viewportRef;
31
+ $[1] = t1;
32
+ } else {
33
+ t1 = $[1];
34
+ }
35
+ let t2;
36
+ if ($[2] !== items) {
37
+ t2 = index => itemKey(items[index], index);
38
+ $[2] = items;
39
+ $[3] = t2;
40
+ } else {
41
+ t2 = $[3];
42
+ }
43
+ let t3;
44
+ if ($[4] !== items.length || $[5] !== t1 || $[6] !== t2) {
45
+ t3 = {
46
+ count: items.length,
47
+ getScrollElement: t1,
48
+ estimateSize: _temp,
49
+ getItemKey: t2,
50
+ anchorTo: "end"
51
+ };
52
+ $[4] = items.length;
53
+ $[5] = t1;
54
+ $[6] = t2;
55
+ $[7] = t3;
56
+ } else {
57
+ t3 = $[7];
58
+ }
59
+ const {
60
+ virtualizer,
61
+ rows,
62
+ totalSize,
63
+ isScrolling,
64
+ itemProps
65
+ } = useListVirtualizer(t3);
66
+ let t4;
67
+ let t5;
68
+ if ($[8] !== virtualizer) {
69
+ t4 = () => {
70
+ virtualizer.scrollToEnd();
71
+ };
72
+ t5 = [virtualizer];
73
+ $[8] = virtualizer;
74
+ $[9] = t4;
75
+ $[10] = t5;
76
+ } else {
77
+ t4 = $[9];
78
+ t5 = $[10];
79
+ }
80
+ useLayoutEffect(t4, t5);
81
+ let t6;
82
+ let t7;
83
+ if ($[11] !== isScrolling || $[12] !== onScrollingChange) {
84
+ t6 = () => {
85
+ onScrollingChange(isScrolling);
86
+ };
87
+ t7 = [isScrolling, onScrollingChange];
88
+ $[11] = isScrolling;
89
+ $[12] = onScrollingChange;
90
+ $[13] = t6;
91
+ $[14] = t7;
92
+ } else {
93
+ t6 = $[13];
94
+ t7 = $[14];
95
+ }
96
+ useEffect(t6, t7);
97
+ let t8;
98
+ if ($[15] !== totalSize) {
99
+ t8 = {
100
+ height: totalSize
101
+ };
102
+ $[15] = totalSize;
103
+ $[16] = t8;
104
+ } else {
105
+ t8 = $[16];
106
+ }
107
+ let t9;
108
+ if ($[17] !== itemProps || $[18] !== items || $[19] !== rows) {
109
+ let t10;
110
+ if ($[21] !== itemProps || $[22] !== items) {
111
+ t10 = row => /*#__PURE__*/_jsx("div", {
112
+ "data-slot": "chat-item",
113
+ ...itemProps(row.index),
114
+ className: cn(virtualRowClassName, "flex flex-col"),
115
+ style: {
116
+ ...rowOffsetStyle(row.start),
117
+ paddingTop: gapBeforeItem(items, row.index)
118
+ },
119
+ children: withSetPosition(items[row.index], row.index, items.length)
120
+ }, row.key);
121
+ $[21] = itemProps;
122
+ $[22] = items;
123
+ $[23] = t10;
124
+ } else {
125
+ t10 = $[23];
126
+ }
127
+ t9 = rows.map(t10);
128
+ $[17] = itemProps;
129
+ $[18] = items;
130
+ $[19] = rows;
131
+ $[20] = t9;
132
+ } else {
133
+ t9 = $[20];
134
+ }
135
+ let t10;
136
+ if ($[24] !== t8 || $[25] !== t9) {
137
+ t10 = /*#__PURE__*/_jsx("div", {
138
+ "data-slot": "chat-virtual-list",
139
+ className: "relative w-full",
140
+ style: t8,
141
+ children: t9
142
+ });
143
+ $[24] = t8;
144
+ $[25] = t9;
145
+ $[26] = t10;
146
+ } else {
147
+ t10 = $[26];
148
+ }
149
+ return t10;
150
+ }
151
+ function _temp() {
152
+ return estimatedTurnHeightPx;
153
+ }
@@ -0,0 +1,15 @@
1
+ export type ComposerStatus = "ready" | "submitting" | "streaming" | "error";
2
+ export declare function isComposerBusy(status: ComposerStatus): boolean;
3
+ type ComposerSubmitProps = {
4
+ status: ComposerStatus;
5
+ canSend: boolean;
6
+ onStop?: () => void;
7
+ };
8
+ export declare function ComposerSubmit({ status, canSend, onStop }: ComposerSubmitProps): import("react").JSX.Element;
9
+ type ComposerAttachButtonProps = {
10
+ accept?: string;
11
+ disabled?: boolean;
12
+ onAttachFiles: (files: File[]) => void;
13
+ };
14
+ export declare function ComposerAttachButton({ accept, disabled, onAttachFiles, }: ComposerAttachButtonProps): import("react").JSX.Element;
15
+ export {};
@@ -0,0 +1,158 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { ArrowUp as ArrowUpIcon, Attachment as PaperclipIcon, StopFilledAlt as SquareIcon } from "@carbon/icons-react";
3
+ import { Button } from "@locusgraph/components";
4
+ import { useRef } from "react";
5
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
6
+ export function isComposerBusy(status) {
7
+ return status === "submitting" || status === "streaming";
8
+ }
9
+ export function ComposerSubmit(t0) {
10
+ const $ = _c(7);
11
+ const {
12
+ status,
13
+ canSend,
14
+ onStop
15
+ } = t0;
16
+ if (isComposerBusy(status)) {
17
+ const t1 = !onStop;
18
+ let t2;
19
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
20
+ t2 = /*#__PURE__*/_jsx(SquareIcon, {
21
+ "aria-hidden": "true",
22
+ className: "size-2.5 fill-current"
23
+ });
24
+ $[0] = t2;
25
+ } else {
26
+ t2 = $[0];
27
+ }
28
+ let t3;
29
+ if ($[1] !== onStop || $[2] !== t1) {
30
+ t3 = /*#__PURE__*/_jsxs(Button, {
31
+ type: "button",
32
+ size: "sm",
33
+ variant: "outline",
34
+ "data-slot": "composer-stop",
35
+ "aria-label": "Stop",
36
+ disabled: t1,
37
+ onClick: onStop,
38
+ children: [t2, "Stop"]
39
+ });
40
+ $[1] = onStop;
41
+ $[2] = t1;
42
+ $[3] = t3;
43
+ } else {
44
+ t3 = $[3];
45
+ }
46
+ return t3;
47
+ }
48
+ const t1 = !canSend;
49
+ let t2;
50
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
51
+ t2 = /*#__PURE__*/_jsx(ArrowUpIcon, {
52
+ "aria-hidden": "true"
53
+ });
54
+ $[4] = t2;
55
+ } else {
56
+ t2 = $[4];
57
+ }
58
+ let t3;
59
+ if ($[5] !== t1) {
60
+ t3 = /*#__PURE__*/_jsx(Button, {
61
+ type: "submit",
62
+ size: "icon-sm",
63
+ "data-slot": "composer-send",
64
+ "aria-label": "Send",
65
+ disabled: t1,
66
+ children: t2
67
+ });
68
+ $[5] = t1;
69
+ $[6] = t3;
70
+ } else {
71
+ t3 = $[6];
72
+ }
73
+ return t3;
74
+ }
75
+ export function ComposerAttachButton(t0) {
76
+ const $ = _c(12);
77
+ const {
78
+ accept,
79
+ disabled,
80
+ onAttachFiles
81
+ } = t0;
82
+ const inputRef = useRef(null);
83
+ let t1;
84
+ if ($[0] !== onAttachFiles) {
85
+ t1 = event => {
86
+ const picked = Array.from(event.currentTarget.files ?? []);
87
+ event.currentTarget.value = "";
88
+ if (picked.length > 0) {
89
+ onAttachFiles(picked);
90
+ }
91
+ };
92
+ $[0] = onAttachFiles;
93
+ $[1] = t1;
94
+ } else {
95
+ t1 = $[1];
96
+ }
97
+ let t2;
98
+ if ($[2] !== accept || $[3] !== t1) {
99
+ t2 = /*#__PURE__*/_jsx("input", {
100
+ ref: inputRef,
101
+ type: "file",
102
+ multiple: true,
103
+ hidden: true,
104
+ accept: accept,
105
+ tabIndex: -1,
106
+ "aria-hidden": "true",
107
+ onChange: t1
108
+ });
109
+ $[2] = accept;
110
+ $[3] = t1;
111
+ $[4] = t2;
112
+ } else {
113
+ t2 = $[4];
114
+ }
115
+ let t3;
116
+ let t4;
117
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
118
+ t3 = () => inputRef.current?.click();
119
+ t4 = /*#__PURE__*/_jsx(PaperclipIcon, {
120
+ "aria-hidden": "true"
121
+ });
122
+ $[5] = t3;
123
+ $[6] = t4;
124
+ } else {
125
+ t3 = $[5];
126
+ t4 = $[6];
127
+ }
128
+ let t5;
129
+ if ($[7] !== disabled) {
130
+ t5 = /*#__PURE__*/_jsx(Button, {
131
+ type: "button",
132
+ size: "icon-sm",
133
+ variant: "ghost",
134
+ "data-slot": "composer-attach",
135
+ "aria-label": "Attach files",
136
+ className: "text-muted-foreground hover:text-foreground",
137
+ disabled: disabled,
138
+ onClick: t3,
139
+ children: t4
140
+ });
141
+ $[7] = disabled;
142
+ $[8] = t5;
143
+ } else {
144
+ t5 = $[8];
145
+ }
146
+ let t6;
147
+ if ($[9] !== t2 || $[10] !== t5) {
148
+ t6 = /*#__PURE__*/_jsxs(_Fragment, {
149
+ children: [t2, t5]
150
+ });
151
+ $[9] = t2;
152
+ $[10] = t5;
153
+ $[11] = t6;
154
+ } else {
155
+ t6 = $[11];
156
+ }
157
+ return t6;
158
+ }
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+ import { type ComposerStatus } from "./composer-actions.js";
3
+ export type ComposerProps = Omit<React.ComponentProps<"form">, "onSubmit" | "children"> & {
4
+ onSubmit: (text: string, files: File[]) => void;
5
+ onStop?: () => void;
6
+ status?: ComposerStatus;
7
+ disabled?: boolean;
8
+ value?: string;
9
+ defaultValue?: string;
10
+ onValueChange?: (value: string) => void;
11
+ placeholder?: string;
12
+ label?: string;
13
+ files?: File[];
14
+ onAttachFiles?: (files: File[]) => void;
15
+ accept?: string;
16
+ attachments?: React.ReactNode;
17
+ modelSlot?: React.ReactNode;
18
+ errorMessage?: string;
19
+ };
20
+ export declare function Composer({ onSubmit, onStop, status, disabled, value, defaultValue, onValueChange, placeholder, label, files, onAttachFiles, accept, attachments, modelSlot, errorMessage, className, ...props }: ComposerProps): React.JSX.Element;
@@ -0,0 +1,340 @@
1
+ "use client";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
4
+ import { cn, Textarea } from "@locusgraph/components";
5
+ import * as React from "react";
6
+ import { ComposerAttachButton, ComposerSubmit, isComposerBusy } from "./composer-actions.js";
7
+ import { useAutoGrow } from "./use-auto-grow.js";
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ const noFiles = [];
10
+ function isSendShortcut(event) {
11
+ return event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing;
12
+ }
13
+ export function Composer(t0) {
14
+ const $ = _c(84);
15
+ let accept;
16
+ let attachments;
17
+ let className;
18
+ let errorMessage;
19
+ let modelSlot;
20
+ let onAttachFiles;
21
+ let onStop;
22
+ let onSubmit;
23
+ let onValueChange;
24
+ let props;
25
+ let t1;
26
+ let t2;
27
+ let t3;
28
+ let t4;
29
+ let t5;
30
+ let t6;
31
+ let value;
32
+ if ($[0] !== t0) {
33
+ ({
34
+ onSubmit,
35
+ onStop,
36
+ status: t1,
37
+ disabled: t2,
38
+ value,
39
+ defaultValue: t3,
40
+ onValueChange,
41
+ placeholder: t4,
42
+ label: t5,
43
+ files: t6,
44
+ onAttachFiles,
45
+ accept,
46
+ attachments,
47
+ modelSlot,
48
+ errorMessage,
49
+ className,
50
+ ...props
51
+ } = t0);
52
+ $[0] = t0;
53
+ $[1] = accept;
54
+ $[2] = attachments;
55
+ $[3] = className;
56
+ $[4] = errorMessage;
57
+ $[5] = modelSlot;
58
+ $[6] = onAttachFiles;
59
+ $[7] = onStop;
60
+ $[8] = onSubmit;
61
+ $[9] = onValueChange;
62
+ $[10] = props;
63
+ $[11] = t1;
64
+ $[12] = t2;
65
+ $[13] = t3;
66
+ $[14] = t4;
67
+ $[15] = t5;
68
+ $[16] = t6;
69
+ $[17] = value;
70
+ } else {
71
+ accept = $[1];
72
+ attachments = $[2];
73
+ className = $[3];
74
+ errorMessage = $[4];
75
+ modelSlot = $[5];
76
+ onAttachFiles = $[6];
77
+ onStop = $[7];
78
+ onSubmit = $[8];
79
+ onValueChange = $[9];
80
+ props = $[10];
81
+ t1 = $[11];
82
+ t2 = $[12];
83
+ t3 = $[13];
84
+ t4 = $[14];
85
+ t5 = $[15];
86
+ t6 = $[16];
87
+ value = $[17];
88
+ }
89
+ const status = t1 === undefined ? "ready" : t1;
90
+ const disabled = t2 === undefined ? false : t2;
91
+ const defaultValue = t3 === undefined ? "" : t3;
92
+ const placeholder = t4 === undefined ? "Ask the agent\u2026" : t4;
93
+ const label = t5 === undefined ? "Message" : t5;
94
+ const files = t6 === undefined ? noFiles : t6;
95
+ const [uncontrolledText, setUncontrolledText] = React.useState(defaultValue);
96
+ const text = value ?? uncontrolledText;
97
+ const errorId = React.useId();
98
+ const textareaRef = React.useRef(null);
99
+ useAutoGrow(textareaRef, text);
100
+ let t7;
101
+ if ($[18] !== status) {
102
+ t7 = isComposerBusy(status);
103
+ $[18] = status;
104
+ $[19] = t7;
105
+ } else {
106
+ t7 = $[19];
107
+ }
108
+ const isBusy = t7;
109
+ let t8;
110
+ if ($[20] !== disabled || $[21] !== files || $[22] !== isBusy || $[23] !== text) {
111
+ t8 = !disabled && !isBusy && (text.trim().length > 0 || files.length > 0);
112
+ $[20] = disabled;
113
+ $[21] = files;
114
+ $[22] = isBusy;
115
+ $[23] = text;
116
+ $[24] = t8;
117
+ } else {
118
+ t8 = $[24];
119
+ }
120
+ const canSend = t8;
121
+ let t9;
122
+ if ($[25] !== onValueChange || $[26] !== value) {
123
+ t9 = next => {
124
+ if (value === undefined) {
125
+ setUncontrolledText(next);
126
+ }
127
+ onValueChange?.(next);
128
+ };
129
+ $[25] = onValueChange;
130
+ $[26] = value;
131
+ $[27] = t9;
132
+ } else {
133
+ t9 = $[27];
134
+ }
135
+ const changeText = t9;
136
+ let t10;
137
+ if ($[28] !== canSend || $[29] !== changeText || $[30] !== files || $[31] !== onSubmit || $[32] !== text) {
138
+ t10 = () => {
139
+ if (!canSend) {
140
+ return;
141
+ }
142
+ onSubmit(text.trim(), files);
143
+ changeText("");
144
+ };
145
+ $[28] = canSend;
146
+ $[29] = changeText;
147
+ $[30] = files;
148
+ $[31] = onSubmit;
149
+ $[32] = text;
150
+ $[33] = t10;
151
+ } else {
152
+ t10 = $[33];
153
+ }
154
+ const send = t10;
155
+ const showError = status === "error" && errorMessage;
156
+ const t11 = disabled || undefined;
157
+ const t12 = isBusy || undefined;
158
+ let t13;
159
+ if ($[34] !== className) {
160
+ t13 = cn("flex flex-col bg-card text-card-foreground ring-1 ring-border transition-shadow focus-within:ring-foreground/40 data-[status=error]:ring-destructive/60 data-disabled:opacity-60", className);
161
+ $[34] = className;
162
+ $[35] = t13;
163
+ } else {
164
+ t13 = $[35];
165
+ }
166
+ let t14;
167
+ if ($[36] !== send) {
168
+ t14 = event => {
169
+ event.preventDefault();
170
+ send();
171
+ };
172
+ $[36] = send;
173
+ $[37] = t14;
174
+ } else {
175
+ t14 = $[37];
176
+ }
177
+ let t15;
178
+ if ($[38] !== attachments) {
179
+ t15 = attachments && /*#__PURE__*/_jsx("div", {
180
+ "data-slot": "composer-attachments",
181
+ className: "px-3 pt-3 empty:hidden",
182
+ children: attachments
183
+ });
184
+ $[38] = attachments;
185
+ $[39] = t15;
186
+ } else {
187
+ t15 = $[39];
188
+ }
189
+ const t16 = status === "error" || undefined;
190
+ const t17 = showError ? errorId : undefined;
191
+ let t18;
192
+ if ($[40] !== changeText) {
193
+ t18 = event_0 => changeText(event_0.currentTarget.value);
194
+ $[40] = changeText;
195
+ $[41] = t18;
196
+ } else {
197
+ t18 = $[41];
198
+ }
199
+ let t19;
200
+ if ($[42] !== send) {
201
+ t19 = event_1 => {
202
+ if (isSendShortcut(event_1)) {
203
+ event_1.preventDefault();
204
+ send();
205
+ }
206
+ };
207
+ $[42] = send;
208
+ $[43] = t19;
209
+ } else {
210
+ t19 = $[43];
211
+ }
212
+ let t20;
213
+ if ($[44] !== disabled || $[45] !== label || $[46] !== placeholder || $[47] !== t16 || $[48] !== t17 || $[49] !== t18 || $[50] !== t19 || $[51] !== text) {
214
+ t20 = /*#__PURE__*/_jsx(Textarea, {
215
+ ref: textareaRef,
216
+ "aria-label": label,
217
+ "aria-invalid": t16,
218
+ "aria-describedby": t17,
219
+ placeholder: placeholder,
220
+ disabled: disabled,
221
+ value: text,
222
+ rows: 1,
223
+ onChange: t18,
224
+ onKeyDown: t19,
225
+ className: "max-h-48 min-h-14 resize-none border-0 bg-transparent px-4 pt-3.5 pb-1 text-sm leading-relaxed shadow-none placeholder:text-muted-foreground/80 focus-visible:ring-0 dark:bg-transparent"
226
+ });
227
+ $[44] = disabled;
228
+ $[45] = label;
229
+ $[46] = placeholder;
230
+ $[47] = t16;
231
+ $[48] = t17;
232
+ $[49] = t18;
233
+ $[50] = t19;
234
+ $[51] = text;
235
+ $[52] = t20;
236
+ } else {
237
+ t20 = $[52];
238
+ }
239
+ let t21;
240
+ if ($[53] !== errorId || $[54] !== errorMessage || $[55] !== showError) {
241
+ t21 = showError && /*#__PURE__*/_jsx("p", {
242
+ id: errorId,
243
+ role: "alert",
244
+ className: "px-4 pt-1 text-xs text-destructive",
245
+ children: errorMessage
246
+ });
247
+ $[53] = errorId;
248
+ $[54] = errorMessage;
249
+ $[55] = showError;
250
+ $[56] = t21;
251
+ } else {
252
+ t21 = $[56];
253
+ }
254
+ let t22;
255
+ if ($[57] !== accept || $[58] !== disabled || $[59] !== isBusy || $[60] !== onAttachFiles) {
256
+ t22 = onAttachFiles && /*#__PURE__*/_jsx(ComposerAttachButton, {
257
+ accept: accept,
258
+ disabled: disabled || isBusy,
259
+ onAttachFiles: onAttachFiles
260
+ });
261
+ $[57] = accept;
262
+ $[58] = disabled;
263
+ $[59] = isBusy;
264
+ $[60] = onAttachFiles;
265
+ $[61] = t22;
266
+ } else {
267
+ t22 = $[61];
268
+ }
269
+ let t23;
270
+ if ($[62] !== disabled || $[63] !== modelSlot) {
271
+ t23 = modelSlot && /*#__PURE__*/_jsx("div", {
272
+ "data-slot": "composer-model",
273
+ className: cn("min-w-0", disabled && "pointer-events-none opacity-50"),
274
+ children: modelSlot
275
+ });
276
+ $[62] = disabled;
277
+ $[63] = modelSlot;
278
+ $[64] = t23;
279
+ } else {
280
+ t23 = $[64];
281
+ }
282
+ let t24;
283
+ if ($[65] !== canSend || $[66] !== onStop || $[67] !== status) {
284
+ t24 = /*#__PURE__*/_jsx("div", {
285
+ className: "ml-auto",
286
+ children: /*#__PURE__*/_jsx(ComposerSubmit, {
287
+ status: status,
288
+ canSend: canSend,
289
+ onStop: onStop
290
+ })
291
+ });
292
+ $[65] = canSend;
293
+ $[66] = onStop;
294
+ $[67] = status;
295
+ $[68] = t24;
296
+ } else {
297
+ t24 = $[68];
298
+ }
299
+ let t25;
300
+ if ($[69] !== t22 || $[70] !== t23 || $[71] !== t24) {
301
+ t25 = /*#__PURE__*/_jsxs("div", {
302
+ "data-slot": "composer-toolbar",
303
+ className: "flex items-center gap-1 px-2.5 pt-1 pb-2.5",
304
+ children: [t22, t23, t24]
305
+ });
306
+ $[69] = t22;
307
+ $[70] = t23;
308
+ $[71] = t24;
309
+ $[72] = t25;
310
+ } else {
311
+ t25 = $[72];
312
+ }
313
+ let t26;
314
+ if ($[73] !== props || $[74] !== status || $[75] !== t11 || $[76] !== t12 || $[77] !== t13 || $[78] !== t14 || $[79] !== t15 || $[80] !== t20 || $[81] !== t21 || $[82] !== t25) {
315
+ t26 = /*#__PURE__*/_jsxs("form", {
316
+ "data-slot": "composer",
317
+ "data-status": status,
318
+ "data-disabled": t11,
319
+ "aria-busy": t12,
320
+ className: t13,
321
+ onSubmit: t14,
322
+ ...props,
323
+ children: [t15, t20, t21, t25]
324
+ });
325
+ $[73] = props;
326
+ $[74] = status;
327
+ $[75] = t11;
328
+ $[76] = t12;
329
+ $[77] = t13;
330
+ $[78] = t14;
331
+ $[79] = t15;
332
+ $[80] = t20;
333
+ $[81] = t21;
334
+ $[82] = t25;
335
+ $[83] = t26;
336
+ } else {
337
+ t26 = $[83];
338
+ }
339
+ return t26;
340
+ }
@@ -0,0 +1,2 @@
1
+ import { type RefObject } from "react";
2
+ export declare function useAutoGrow(textareaRef: RefObject<HTMLTextAreaElement | null>, text: string): void;