@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,67 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { Button, Tooltip, TooltipContent, TooltipTrigger } from "@locusgraph/components";
3
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
+ export function ActionButton(t0) {
5
+ const $ = _c(13);
6
+ let children;
7
+ let label;
8
+ let props;
9
+ if ($[0] !== t0) {
10
+ ({
11
+ label,
12
+ children,
13
+ ...props
14
+ } = t0);
15
+ $[0] = t0;
16
+ $[1] = children;
17
+ $[2] = label;
18
+ $[3] = props;
19
+ } else {
20
+ children = $[1];
21
+ label = $[2];
22
+ props = $[3];
23
+ }
24
+ let t1;
25
+ if ($[4] !== children || $[5] !== label || $[6] !== props) {
26
+ t1 = /*#__PURE__*/_jsx(TooltipTrigger, {
27
+ asChild: true,
28
+ children: /*#__PURE__*/_jsx(Button, {
29
+ type: "button",
30
+ variant: "ghost",
31
+ size: "icon-sm",
32
+ "aria-label": label,
33
+ className: "text-muted-foreground hover:bg-accent hover:text-foreground [&_svg]:size-4",
34
+ ...props,
35
+ children: children
36
+ })
37
+ });
38
+ $[4] = children;
39
+ $[5] = label;
40
+ $[6] = props;
41
+ $[7] = t1;
42
+ } else {
43
+ t1 = $[7];
44
+ }
45
+ let t2;
46
+ if ($[8] !== label) {
47
+ t2 = /*#__PURE__*/_jsx(TooltipContent, {
48
+ children: label
49
+ });
50
+ $[8] = label;
51
+ $[9] = t2;
52
+ } else {
53
+ t2 = $[9];
54
+ }
55
+ let t3;
56
+ if ($[10] !== t1 || $[11] !== t2) {
57
+ t3 = /*#__PURE__*/_jsxs(Tooltip, {
58
+ children: [t1, t2]
59
+ });
60
+ $[10] = t1;
61
+ $[11] = t2;
62
+ $[12] = t3;
63
+ } else {
64
+ t3 = $[12];
65
+ }
66
+ return t3;
67
+ }
@@ -0,0 +1,13 @@
1
+ import type { ComponentProps } from "react";
2
+ import { type MessageBranch } from "./branch-switcher.js";
3
+ export type MessageFeedback = "up" | "down" | null;
4
+ type ActionsProps = ComponentProps<"div"> & {
5
+ onCopy?: () => void;
6
+ onRetry?: () => void;
7
+ feedback?: MessageFeedback;
8
+ onFeedback?: (feedback: MessageFeedback) => void;
9
+ branch?: MessageBranch;
10
+ onBranchChange?: (index: number) => void;
11
+ };
12
+ export declare function Actions({ onCopy, onRetry, feedback, onFeedback, branch, onBranchChange, className, ...props }: ActionsProps): import("react").JSX.Element | null;
13
+ export {};
@@ -0,0 +1,192 @@
1
+ "use client";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
4
+ import { Checkmark as CheckIcon, Copy as CopyIcon, Renew as RefreshCwIcon, ThumbsDown as ThumbsDownIcon, ThumbsUp as ThumbsUpIcon } from "@carbon/icons-react";
5
+ import { cn, TooltipProvider } from "@locusgraph/components";
6
+ import { useCopied } from "../use-copied.js";
7
+ import { ActionButton } from "./action-button.js";
8
+ import { BranchSwitcher } from "./branch-switcher.js";
9
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
10
+ function toggledFeedback(current, chosen) {
11
+ return current === chosen ? null : chosen;
12
+ }
13
+ export function Actions(t0) {
14
+ const $ = _c(40);
15
+ let branch;
16
+ let className;
17
+ let onBranchChange;
18
+ let onCopy;
19
+ let onFeedback;
20
+ let onRetry;
21
+ let props;
22
+ let t1;
23
+ if ($[0] !== t0) {
24
+ ({
25
+ onCopy,
26
+ onRetry,
27
+ feedback: t1,
28
+ onFeedback,
29
+ branch,
30
+ onBranchChange,
31
+ className,
32
+ ...props
33
+ } = t0);
34
+ $[0] = t0;
35
+ $[1] = branch;
36
+ $[2] = className;
37
+ $[3] = onBranchChange;
38
+ $[4] = onCopy;
39
+ $[5] = onFeedback;
40
+ $[6] = onRetry;
41
+ $[7] = props;
42
+ $[8] = t1;
43
+ } else {
44
+ branch = $[1];
45
+ className = $[2];
46
+ onBranchChange = $[3];
47
+ onCopy = $[4];
48
+ onFeedback = $[5];
49
+ onRetry = $[6];
50
+ props = $[7];
51
+ t1 = $[8];
52
+ }
53
+ const feedback = t1 === undefined ? null : t1;
54
+ const {
55
+ copied,
56
+ markCopied
57
+ } = useCopied();
58
+ const showBranch = branch !== undefined && branch.count > 1 && onBranchChange !== undefined;
59
+ if (!onCopy && !onRetry && !onFeedback && !showBranch) {
60
+ return null;
61
+ }
62
+ let t2;
63
+ if ($[9] !== className) {
64
+ t2 = cn("flex items-center gap-0.5", className);
65
+ $[9] = className;
66
+ $[10] = t2;
67
+ } else {
68
+ t2 = $[10];
69
+ }
70
+ let t3;
71
+ if ($[11] !== branch || $[12] !== onBranchChange || $[13] !== showBranch) {
72
+ t3 = showBranch && /*#__PURE__*/_jsx(BranchSwitcher, {
73
+ branch: branch,
74
+ onBranchChange: onBranchChange
75
+ });
76
+ $[11] = branch;
77
+ $[12] = onBranchChange;
78
+ $[13] = showBranch;
79
+ $[14] = t3;
80
+ } else {
81
+ t3 = $[14];
82
+ }
83
+ let t4;
84
+ if ($[15] !== onCopy || $[16] !== onFeedback || $[17] !== onRetry || $[18] !== showBranch) {
85
+ t4 = showBranch && (onCopy || onRetry || onFeedback) && /*#__PURE__*/_jsx("span", {
86
+ "aria-hidden": true,
87
+ className: "mx-1 h-3.5 w-px bg-border"
88
+ });
89
+ $[15] = onCopy;
90
+ $[16] = onFeedback;
91
+ $[17] = onRetry;
92
+ $[18] = showBranch;
93
+ $[19] = t4;
94
+ } else {
95
+ t4 = $[19];
96
+ }
97
+ let t5;
98
+ if ($[20] !== copied || $[21] !== markCopied || $[22] !== onCopy) {
99
+ t5 = onCopy && /*#__PURE__*/_jsx(ActionButton, {
100
+ label: copied ? "Copied" : "Copy",
101
+ onClick: () => {
102
+ onCopy();
103
+ markCopied();
104
+ },
105
+ children: copied ? /*#__PURE__*/_jsx(CheckIcon, {
106
+ className: "text-good"
107
+ }) : /*#__PURE__*/_jsx(CopyIcon, {})
108
+ });
109
+ $[20] = copied;
110
+ $[21] = markCopied;
111
+ $[22] = onCopy;
112
+ $[23] = t5;
113
+ } else {
114
+ t5 = $[23];
115
+ }
116
+ let t6;
117
+ if ($[24] !== onRetry) {
118
+ t6 = onRetry && /*#__PURE__*/_jsx(ActionButton, {
119
+ label: "Retry",
120
+ onClick: onRetry,
121
+ children: /*#__PURE__*/_jsx(RefreshCwIcon, {})
122
+ });
123
+ $[24] = onRetry;
124
+ $[25] = t6;
125
+ } else {
126
+ t6 = $[25];
127
+ }
128
+ let t7;
129
+ if ($[26] !== feedback || $[27] !== onFeedback) {
130
+ t7 = onFeedback && /*#__PURE__*/_jsxs(_Fragment, {
131
+ children: [/*#__PURE__*/_jsx(ActionButton, {
132
+ label: "Good response",
133
+ "aria-pressed": feedback === "up",
134
+ className: cn(feedback === "up" && "text-foreground"),
135
+ onClick: () => onFeedback(toggledFeedback(feedback, "up")),
136
+ children: /*#__PURE__*/_jsx(ThumbsUpIcon, {
137
+ className: cn(feedback === "up" && "fill-current")
138
+ })
139
+ }), /*#__PURE__*/_jsx(ActionButton, {
140
+ label: "Bad response",
141
+ "aria-pressed": feedback === "down",
142
+ className: cn(feedback === "down" && "text-foreground"),
143
+ onClick: () => onFeedback(toggledFeedback(feedback, "down")),
144
+ children: /*#__PURE__*/_jsx(ThumbsDownIcon, {
145
+ className: cn(feedback === "down" && "fill-current")
146
+ })
147
+ })]
148
+ });
149
+ $[26] = feedback;
150
+ $[27] = onFeedback;
151
+ $[28] = t7;
152
+ } else {
153
+ t7 = $[28];
154
+ }
155
+ let t8;
156
+ if ($[29] !== copied) {
157
+ t8 = copied && /*#__PURE__*/_jsx("span", {
158
+ role: "status",
159
+ className: "sr-only",
160
+ children: "Copied"
161
+ });
162
+ $[29] = copied;
163
+ $[30] = t8;
164
+ } else {
165
+ t8 = $[30];
166
+ }
167
+ let t9;
168
+ if ($[31] !== props || $[32] !== t2 || $[33] !== t3 || $[34] !== t4 || $[35] !== t5 || $[36] !== t6 || $[37] !== t7 || $[38] !== t8) {
169
+ t9 = /*#__PURE__*/_jsx(TooltipProvider, {
170
+ children: /*#__PURE__*/_jsxs("div", {
171
+ "data-slot": "actions",
172
+ role: "toolbar",
173
+ "aria-label": "Message actions",
174
+ className: t2,
175
+ ...props,
176
+ children: [t3, t4, t5, t6, t7, t8]
177
+ })
178
+ });
179
+ $[31] = props;
180
+ $[32] = t2;
181
+ $[33] = t3;
182
+ $[34] = t4;
183
+ $[35] = t5;
184
+ $[36] = t6;
185
+ $[37] = t7;
186
+ $[38] = t8;
187
+ $[39] = t9;
188
+ } else {
189
+ t9 = $[39];
190
+ }
191
+ return t9;
192
+ }
@@ -0,0 +1,10 @@
1
+ export type MessageBranch = {
2
+ index: number;
3
+ count: number;
4
+ };
5
+ type BranchSwitcherProps = {
6
+ branch: MessageBranch;
7
+ onBranchChange: (index: number) => void;
8
+ };
9
+ export declare function BranchSwitcher({ branch, onBranchChange }: BranchSwitcherProps): import("react").JSX.Element;
10
+ export {};
@@ -0,0 +1,104 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { ChevronLeft as ChevronLeftIcon, ChevronRight as ChevronRightIcon } from "@carbon/icons-react";
3
+ import { ActionButton } from "./action-button.js";
4
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
+ export function BranchSwitcher(t0) {
6
+ const $ = _c(20);
7
+ const {
8
+ branch,
9
+ onBranchChange
10
+ } = t0;
11
+ const position = branch.index + 1;
12
+ const t1 = branch.index <= 0;
13
+ let t2;
14
+ if ($[0] !== branch.index || $[1] !== onBranchChange) {
15
+ t2 = () => onBranchChange(branch.index - 1);
16
+ $[0] = branch.index;
17
+ $[1] = onBranchChange;
18
+ $[2] = t2;
19
+ } else {
20
+ t2 = $[2];
21
+ }
22
+ let t3;
23
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
24
+ t3 = /*#__PURE__*/_jsx(ChevronLeftIcon, {});
25
+ $[3] = t3;
26
+ } else {
27
+ t3 = $[3];
28
+ }
29
+ let t4;
30
+ if ($[4] !== t1 || $[5] !== t2) {
31
+ t4 = /*#__PURE__*/_jsx(ActionButton, {
32
+ label: "Previous version",
33
+ disabled: t1,
34
+ onClick: t2,
35
+ children: t3
36
+ });
37
+ $[4] = t1;
38
+ $[5] = t2;
39
+ $[6] = t4;
40
+ } else {
41
+ t4 = $[6];
42
+ }
43
+ const t5 = `${position} / ${branch.count}`;
44
+ let t6;
45
+ if ($[7] !== t5) {
46
+ t6 = /*#__PURE__*/_jsx("span", {
47
+ "aria-live": "polite",
48
+ className: "min-w-9 text-center font-mono text-xs text-muted-foreground tabular-nums",
49
+ children: t5
50
+ });
51
+ $[7] = t5;
52
+ $[8] = t6;
53
+ } else {
54
+ t6 = $[8];
55
+ }
56
+ const t7 = position >= branch.count;
57
+ let t8;
58
+ if ($[9] !== branch.index || $[10] !== onBranchChange) {
59
+ t8 = () => onBranchChange(branch.index + 1);
60
+ $[9] = branch.index;
61
+ $[10] = onBranchChange;
62
+ $[11] = t8;
63
+ } else {
64
+ t8 = $[11];
65
+ }
66
+ let t9;
67
+ if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
68
+ t9 = /*#__PURE__*/_jsx(ChevronRightIcon, {});
69
+ $[12] = t9;
70
+ } else {
71
+ t9 = $[12];
72
+ }
73
+ let t10;
74
+ if ($[13] !== t7 || $[14] !== t8) {
75
+ t10 = /*#__PURE__*/_jsx(ActionButton, {
76
+ label: "Next version",
77
+ disabled: t7,
78
+ onClick: t8,
79
+ children: t9
80
+ });
81
+ $[13] = t7;
82
+ $[14] = t8;
83
+ $[15] = t10;
84
+ } else {
85
+ t10 = $[15];
86
+ }
87
+ let t11;
88
+ if ($[16] !== t10 || $[17] !== t4 || $[18] !== t6) {
89
+ t11 = /*#__PURE__*/_jsxs("div", {
90
+ "data-slot": "branch-switcher",
91
+ role: "group",
92
+ "aria-label": "Reply versions",
93
+ className: "flex items-center",
94
+ children: [t4, t6, t10]
95
+ });
96
+ $[16] = t10;
97
+ $[17] = t4;
98
+ $[18] = t6;
99
+ $[19] = t11;
100
+ } else {
101
+ t11 = $[19];
102
+ }
103
+ return t11;
104
+ }
@@ -0,0 +1,14 @@
1
+ import type { ComponentProps, ReactNode } from "react";
2
+ import { type CanvasVersion } from "./version-switcher.js";
3
+ type CanvasProps = Omit<ComponentProps<"aside">, "title"> & {
4
+ title: string;
5
+ kind?: string;
6
+ versions?: CanvasVersion[];
7
+ versionId?: string;
8
+ onVersionChange?: (id: string) => void;
9
+ actions?: ReactNode;
10
+ onClose?: () => void;
11
+ children: ReactNode;
12
+ };
13
+ export declare function Canvas({ title, kind, versions, versionId, onVersionChange, actions, onClose, children, className, ...props }: CanvasProps): import("react").JSX.Element;
14
+ export {};
@@ -0,0 +1,212 @@
1
+ "use client";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
4
+ import { Close as XIcon } from "@carbon/icons-react";
5
+ import { Button, cn, ScrollArea } from "@locusgraph/components";
6
+ import { VersionSwitcher } from "./version-switcher.js";
7
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
+ function currentVersionOf(versions, versionId) {
9
+ return versions.find(version => version.id === versionId) ?? versions.at(-1);
10
+ }
11
+ export function Canvas(t0) {
12
+ const $ = _c(46);
13
+ let actions;
14
+ let children;
15
+ let className;
16
+ let kind;
17
+ let onClose;
18
+ let onVersionChange;
19
+ let props;
20
+ let t1;
21
+ let title;
22
+ let versionId;
23
+ if ($[0] !== t0) {
24
+ ({
25
+ title,
26
+ kind,
27
+ versions: t1,
28
+ versionId,
29
+ onVersionChange,
30
+ actions,
31
+ onClose,
32
+ children,
33
+ className,
34
+ ...props
35
+ } = t0);
36
+ $[0] = t0;
37
+ $[1] = actions;
38
+ $[2] = children;
39
+ $[3] = className;
40
+ $[4] = kind;
41
+ $[5] = onClose;
42
+ $[6] = onVersionChange;
43
+ $[7] = props;
44
+ $[8] = t1;
45
+ $[9] = title;
46
+ $[10] = versionId;
47
+ } else {
48
+ actions = $[1];
49
+ children = $[2];
50
+ className = $[3];
51
+ kind = $[4];
52
+ onClose = $[5];
53
+ onVersionChange = $[6];
54
+ props = $[7];
55
+ t1 = $[8];
56
+ title = $[9];
57
+ versionId = $[10];
58
+ }
59
+ let t2;
60
+ if ($[11] !== t1) {
61
+ t2 = t1 === undefined ? [] : t1;
62
+ $[11] = t1;
63
+ $[12] = t2;
64
+ } else {
65
+ t2 = $[12];
66
+ }
67
+ const versions = t2;
68
+ let t3;
69
+ if ($[13] !== versionId || $[14] !== versions) {
70
+ t3 = currentVersionOf(versions, versionId);
71
+ $[13] = versionId;
72
+ $[14] = versions;
73
+ $[15] = t3;
74
+ } else {
75
+ t3 = $[15];
76
+ }
77
+ const current = t3;
78
+ let t4;
79
+ if ($[16] !== className) {
80
+ t4 = cn("flex h-full min-h-0 min-w-0 flex-col bg-card text-card-foreground ring-1 ring-border", className);
81
+ $[16] = className;
82
+ $[17] = t4;
83
+ } else {
84
+ t4 = $[17];
85
+ }
86
+ let t5;
87
+ if ($[18] !== kind) {
88
+ t5 = kind && /*#__PURE__*/_jsx("span", {
89
+ className: "eyebrow",
90
+ children: kind
91
+ });
92
+ $[18] = kind;
93
+ $[19] = t5;
94
+ } else {
95
+ t5 = $[19];
96
+ }
97
+ let t6;
98
+ if ($[20] !== title) {
99
+ t6 = /*#__PURE__*/_jsx("h2", {
100
+ className: "truncate font-sans text-base leading-snug font-semibold tracking-tight",
101
+ children: title
102
+ });
103
+ $[20] = title;
104
+ $[21] = t6;
105
+ } else {
106
+ t6 = $[21];
107
+ }
108
+ let t7;
109
+ if ($[22] !== t5 || $[23] !== t6) {
110
+ t7 = /*#__PURE__*/_jsxs("div", {
111
+ className: "flex min-w-0 flex-1 flex-col gap-1",
112
+ children: [t5, t6]
113
+ });
114
+ $[22] = t5;
115
+ $[23] = t6;
116
+ $[24] = t7;
117
+ } else {
118
+ t7 = $[24];
119
+ }
120
+ let t8;
121
+ if ($[25] !== onClose) {
122
+ t8 = onClose && /*#__PURE__*/_jsx(Button, {
123
+ type: "button",
124
+ variant: "ghost",
125
+ size: "icon-sm",
126
+ "aria-label": "Close panel",
127
+ className: "text-muted-foreground hover:text-foreground",
128
+ onClick: onClose,
129
+ children: /*#__PURE__*/_jsx(XIcon, {})
130
+ });
131
+ $[25] = onClose;
132
+ $[26] = t8;
133
+ } else {
134
+ t8 = $[26];
135
+ }
136
+ let t9;
137
+ if ($[27] !== actions || $[28] !== t8) {
138
+ t9 = /*#__PURE__*/_jsxs("div", {
139
+ className: "-mr-2 flex shrink-0 items-center gap-0.5 text-muted-foreground",
140
+ children: [actions, t8]
141
+ });
142
+ $[27] = actions;
143
+ $[28] = t8;
144
+ $[29] = t9;
145
+ } else {
146
+ t9 = $[29];
147
+ }
148
+ let t10;
149
+ if ($[30] !== t7 || $[31] !== t9) {
150
+ t10 = /*#__PURE__*/_jsxs("header", {
151
+ className: "flex items-start gap-3 border-b px-5 pt-3.5 pb-3",
152
+ children: [t7, t9]
153
+ });
154
+ $[30] = t7;
155
+ $[31] = t9;
156
+ $[32] = t10;
157
+ } else {
158
+ t10 = $[32];
159
+ }
160
+ let t11;
161
+ if ($[33] !== children) {
162
+ t11 = /*#__PURE__*/_jsx(ScrollArea, {
163
+ className: "min-h-0 flex-1",
164
+ children: /*#__PURE__*/_jsx("div", {
165
+ "data-slot": "canvas-content",
166
+ className: "px-5 py-4 has-[>[data-slot=code]:only-child]:p-0 [&>[data-slot=code]:only-child]:ring-0",
167
+ children: children
168
+ })
169
+ });
170
+ $[33] = children;
171
+ $[34] = t11;
172
+ } else {
173
+ t11 = $[34];
174
+ }
175
+ let t12;
176
+ if ($[35] !== current || $[36] !== onVersionChange || $[37] !== versions) {
177
+ t12 = current && /*#__PURE__*/_jsx("footer", {
178
+ className: "flex h-10 items-center gap-2 border-t bg-muted/30 pr-3 pl-5",
179
+ children: /*#__PURE__*/_jsx(VersionSwitcher, {
180
+ versions: versions,
181
+ current: current,
182
+ onVersionChange: onVersionChange
183
+ })
184
+ });
185
+ $[35] = current;
186
+ $[36] = onVersionChange;
187
+ $[37] = versions;
188
+ $[38] = t12;
189
+ } else {
190
+ t12 = $[38];
191
+ }
192
+ let t13;
193
+ if ($[39] !== props || $[40] !== t10 || $[41] !== t11 || $[42] !== t12 || $[43] !== t4 || $[44] !== title) {
194
+ t13 = /*#__PURE__*/_jsxs("aside", {
195
+ "data-slot": "canvas",
196
+ "aria-label": title,
197
+ className: t4,
198
+ ...props,
199
+ children: [t10, t11, t12]
200
+ });
201
+ $[39] = props;
202
+ $[40] = t10;
203
+ $[41] = t11;
204
+ $[42] = t12;
205
+ $[43] = t4;
206
+ $[44] = title;
207
+ $[45] = t13;
208
+ } else {
209
+ t13 = $[45];
210
+ }
211
+ return t13;
212
+ }
@@ -0,0 +1,12 @@
1
+ export type CanvasVersion = {
2
+ id: string;
3
+ label: string;
4
+ createdAt: string;
5
+ };
6
+ type VersionSwitcherProps = {
7
+ versions: CanvasVersion[];
8
+ current: CanvasVersion;
9
+ onVersionChange?: (id: string) => void;
10
+ };
11
+ export declare function VersionSwitcher({ versions, current, onVersionChange }: VersionSwitcherProps): import("react").JSX.Element;
12
+ export {};