@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.
- package/LICENSE +21 -0
- package/README.md +37 -2
- package/dist/agent/index.d.ts +5 -0
- package/dist/agent/index.js +5 -0
- package/dist/agent/pulse/gradient-label.d.ts +7 -0
- package/dist/agent/pulse/gradient-label.js +94 -0
- package/dist/agent/pulse/marks/bars-mark.d.ts +1 -0
- package/dist/agent/pulse/marks/bars-mark.js +51 -0
- package/dist/agent/pulse/marks/glyph-mark.d.ts +4 -0
- package/dist/agent/pulse/marks/glyph-mark.js +62 -0
- package/dist/agent/pulse/marks/locus-mark.d.ts +1 -0
- package/dist/agent/pulse/marks/locus-mark.js +73 -0
- package/dist/agent/pulse/marks/orb-mark.d.ts +1 -0
- package/dist/agent/pulse/marks/orb-mark.js +34 -0
- package/dist/agent/pulse/marks/spinner-mark.d.ts +1 -0
- package/dist/agent/pulse/marks/spinner-mark.js +32 -0
- package/dist/agent/pulse/pulse-tone.d.ts +1 -0
- package/dist/agent/pulse/pulse-tone.js +1 -0
- package/dist/agent/pulse/pulse.d.ts +12 -0
- package/dist/agent/pulse/pulse.js +166 -0
- package/dist/agent/pulse/use-loop-animation.d.ts +2 -0
- package/dist/agent/pulse/use-loop-animation.js +40 -0
- package/dist/agent/shared/status-dot.d.ts +1 -0
- package/dist/agent/shared/status-dot.js +1 -0
- package/dist/agent/steps/step-icon.d.ts +8 -0
- package/dist/agent/steps/step-icon.js +117 -0
- package/dist/agent/steps/steps.d.ts +7 -0
- package/dist/agent/steps/steps.js +249 -0
- package/dist/agent/thinking/thinking.d.ts +6 -0
- package/dist/agent/thinking/thinking.js +211 -0
- package/dist/agent/thinking/thought-duration.d.ts +2 -0
- package/dist/agent/thinking/thought-duration.js +11 -0
- package/dist/agent/tool/json-block.d.ts +5 -0
- package/dist/agent/tool/json-block.js +42 -0
- package/dist/agent/tool/tool-status.d.ts +6 -0
- package/dist/agent/tool/tool-status.js +59 -0
- package/dist/agent/tool/tool.d.ts +7 -0
- package/dist/agent/tool/tool.js +192 -0
- package/dist/approval/inbox/inbox-row.d.ts +12 -0
- package/dist/approval/inbox/inbox-row.js +328 -0
- package/dist/approval/inbox/inbox-selection.d.ts +6 -0
- package/dist/approval/inbox/inbox-selection.js +15 -0
- package/dist/approval/inbox/inbox.d.ts +12 -0
- package/dist/approval/inbox/inbox.js +258 -0
- package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
- package/dist/approval/inbox/virtual-inbox-list.js +129 -0
- package/dist/approval/index.d.ts +9 -0
- package/dist/approval/index.js +8 -0
- package/dist/approval/memory/memory-choices.d.ts +10 -0
- package/dist/approval/memory/memory-choices.js +35 -0
- package/dist/approval/memory/memory-review.d.ts +11 -0
- package/dist/approval/memory/memory-review.js +256 -0
- package/dist/approval/memory/memory-row.d.ts +9 -0
- package/dist/approval/memory/memory-row.js +226 -0
- package/dist/approval/plan/plan-review.d.ts +13 -0
- package/dist/approval/plan/plan-review.js +289 -0
- package/dist/approval/plan/plan-step-row.d.ts +13 -0
- package/dist/approval/plan/plan-step-row.js +201 -0
- package/dist/approval/plan/plan-steps.d.ts +8 -0
- package/dist/approval/plan/plan-steps.js +30 -0
- package/dist/approval/plan/question-choices.d.ts +10 -0
- package/dist/approval/plan/question-choices.js +166 -0
- package/dist/approval/plan/question.d.ts +18 -0
- package/dist/approval/plan/question.js +232 -0
- package/dist/approval/run/run-bar.d.ts +13 -0
- package/dist/approval/run/run-bar.js +189 -0
- package/dist/approval/shared/decision-line.d.ts +1 -0
- package/dist/approval/shared/decision-line.js +1 -0
- package/dist/approval/shared/risk-badge.d.ts +10 -0
- package/dist/approval/shared/risk-badge.js +57 -0
- package/dist/approval/shared/time.d.ts +3 -0
- package/dist/approval/shared/time.js +12 -0
- package/dist/approval/shared/use-focus-on-mount.d.ts +2 -0
- package/dist/approval/shared/use-focus-on-mount.js +26 -0
- package/dist/approval/spend/raise-cap-form.d.ts +8 -0
- package/dist/approval/spend/raise-cap-form.js +244 -0
- package/dist/approval/spend/spend-gate.d.ts +16 -0
- package/dist/approval/spend/spend-gate.js +250 -0
- package/dist/approval/spend/spend-math.d.ts +5 -0
- package/dist/approval/spend/spend-math.js +17 -0
- package/dist/approval/spend/spend-meter.d.ts +10 -0
- package/dist/approval/spend/spend-meter.js +377 -0
- package/dist/approval/tool/approval.d.ts +14 -0
- package/dist/approval/tool/approval.js +290 -0
- package/dist/approval/tool/args/args-editor.d.ts +16 -0
- package/dist/approval/tool/args/args-editor.js +273 -0
- package/dist/approval/tool/args/args-field.d.ts +11 -0
- package/dist/approval/tool/args/args-field.js +268 -0
- package/dist/approval/tool/args/args-validation.d.ts +8 -0
- package/dist/approval/tool/args/args-validation.js +50 -0
- package/dist/approval/tool/deny-form.d.ts +6 -0
- package/dist/approval/tool/deny-form.js +135 -0
- package/dist/approval/tool/tool-inputs.d.ts +6 -0
- package/dist/approval/tool/tool-inputs.js +142 -0
- package/dist/approval/types.d.ts +59 -0
- package/dist/approval/types.js +1 -0
- package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
- package/dist/chat/chat/chat-item-spacing.js +19 -0
- package/dist/chat/chat/chat.d.ts +8 -0
- package/dist/chat/chat/chat.js +187 -0
- package/dist/chat/chat/use-stick-to-bottom.d.ts +7 -0
- package/dist/chat/chat/use-stick-to-bottom.js +133 -0
- package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
- package/dist/chat/chat/virtual-chat-items.js +153 -0
- package/dist/chat/composer/composer-actions.d.ts +15 -0
- package/dist/chat/composer/composer-actions.js +158 -0
- package/dist/chat/composer/composer.d.ts +20 -0
- package/dist/chat/composer/composer.js +340 -0
- package/dist/chat/composer/use-auto-grow.d.ts +2 -0
- package/dist/chat/composer/use-auto-grow.js +29 -0
- package/dist/chat/files/file-meta.d.ts +13 -0
- package/dist/chat/files/file-meta.js +30 -0
- package/dist/chat/files/files.d.ts +9 -0
- package/dist/chat/files/files.js +327 -0
- package/dist/chat/index.d.ts +7 -0
- package/dist/chat/index.js +7 -0
- package/dist/chat/reply/fenced-code.d.ts +8 -0
- package/dist/chat/reply/fenced-code.js +53 -0
- package/dist/chat/reply/markdown-components.d.ts +2 -0
- package/dist/chat/reply/markdown-components.js +142 -0
- package/dist/chat/reply/reply.d.ts +8 -0
- package/dist/chat/reply/reply.js +116 -0
- package/dist/chat/turn/group-parts.d.ts +24 -0
- package/dist/chat/turn/group-parts.js +49 -0
- package/dist/chat/turn/turn.d.ts +11 -0
- package/dist/chat/turn/turn.js +253 -0
- package/dist/cost/context.d.ts +13 -0
- package/dist/cost/context.js +333 -0
- package/dist/cost/cost-steps.d.ts +17 -0
- package/dist/cost/cost-steps.js +230 -0
- package/dist/cost/cost.d.ts +8 -0
- package/dist/cost/cost.js +531 -0
- package/dist/cost/index.d.ts +4 -0
- package/dist/cost/index.js +4 -0
- package/dist/cost/model-picker.d.ts +11 -0
- package/dist/cost/model-picker.js +184 -0
- package/dist/cost/shared/context-breakdown.d.ts +15 -0
- package/dist/cost/shared/context-breakdown.js +306 -0
- package/dist/cost/shared/meter-marks.d.ts +9 -0
- package/dist/cost/shared/meter-marks.js +114 -0
- package/dist/cost/shared/model-option-row.d.ts +14 -0
- package/dist/cost/shared/model-option-row.js +189 -0
- package/dist/cost/shared/step-cost-row.d.ts +15 -0
- package/dist/cost/shared/step-cost-row.js +262 -0
- package/dist/cost/shared/usage-totals.d.ts +11 -0
- package/dist/cost/shared/usage-totals.js +30 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/memory/cite.d.ts +8 -0
- package/dist/memory/cite.js +190 -0
- package/dist/memory/index.d.ts +5 -0
- package/dist/memory/index.js +4 -0
- package/dist/memory/memorized.d.ts +14 -0
- package/dist/memory/memorized.js +225 -0
- package/dist/memory/recall.d.ts +9 -0
- package/dist/memory/recall.js +303 -0
- package/dist/memory/shared/disclosure.d.ts +6 -0
- package/dist/memory/shared/disclosure.js +6 -0
- package/dist/memory/shared/host-label.d.ts +6 -0
- package/dist/memory/shared/host-label.js +31 -0
- package/dist/memory/shared/source-mark.d.ts +5 -0
- package/dist/memory/shared/source-mark.js +42 -0
- package/dist/memory/sources.d.ts +9 -0
- package/dist/memory/sources.js +264 -0
- package/dist/shared/decision-summary.d.ts +18 -0
- package/dist/shared/decision-summary.js +144 -0
- package/dist/shared/panel-empty.d.ts +8 -0
- package/dist/shared/panel-empty.js +80 -0
- package/dist/shared/panel.d.ts +19 -0
- package/dist/shared/panel.js +251 -0
- package/dist/shared/status-dot.d.ts +6 -0
- package/dist/shared/status-dot.js +42 -0
- package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
- package/dist/shared/virtual/use-list-virtualizer.js +68 -0
- package/dist/sources.css +1 -0
- package/dist/thread/actions/action-button.d.ts +8 -0
- package/dist/thread/actions/action-button.js +67 -0
- package/dist/thread/actions/actions.d.ts +13 -0
- package/dist/thread/actions/actions.js +192 -0
- package/dist/thread/actions/branch-switcher.d.ts +10 -0
- package/dist/thread/actions/branch-switcher.js +104 -0
- package/dist/thread/canvas/canvas.d.ts +14 -0
- package/dist/thread/canvas/canvas.js +212 -0
- package/dist/thread/canvas/version-switcher.d.ts +12 -0
- package/dist/thread/canvas/version-switcher.js +152 -0
- package/dist/thread/code/code.d.ts +10 -0
- package/dist/thread/code/code.js +195 -0
- package/dist/thread/code/copy-code-button.d.ts +6 -0
- package/dist/thread/code/copy-code-button.js +66 -0
- package/dist/thread/code/highlight.d.ts +1 -0
- package/dist/thread/code/highlight.js +40 -0
- package/dist/thread/history/history-rows.d.ts +16 -0
- package/dist/thread/history/history-rows.js +23 -0
- package/dist/thread/history/history.d.ts +16 -0
- package/dist/thread/history/history.js +179 -0
- package/dist/thread/history/row/history-row.d.ts +15 -0
- package/dist/thread/history/row/history-row.js +137 -0
- package/dist/thread/history/row/thread-item-menu.d.ts +7 -0
- package/dist/thread/history/row/thread-item-menu.js +84 -0
- package/dist/thread/history/row/thread-title-editor.d.ts +7 -0
- package/dist/thread/history/row/thread-title-editor.js +81 -0
- package/dist/thread/history/thread-groups.d.ts +8 -0
- package/dist/thread/history/thread-groups.js +52 -0
- package/dist/thread/history/virtual-history-list.d.ts +11 -0
- package/dist/thread/history/virtual-history-list.js +107 -0
- package/dist/thread/index.d.ts +8 -0
- package/dist/thread/index.js +5 -0
- package/dist/thread/starters/starters.d.ts +12 -0
- package/dist/thread/starters/starters.js +100 -0
- package/dist/thread/use-copied.d.ts +5 -0
- package/dist/thread/use-copied.js +52 -0
- package/dist/types.d.ts +70 -0
- package/dist/types.js +3 -0
- package/package.json +59 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { useLayoutEffect } from "react";
|
|
3
|
+
function supportsFieldSizing() {
|
|
4
|
+
return typeof CSS !== "undefined" && CSS.supports?.("field-sizing", "content") === true;
|
|
5
|
+
}
|
|
6
|
+
export function useAutoGrow(textareaRef, text) {
|
|
7
|
+
const $ = _c(4);
|
|
8
|
+
let t0;
|
|
9
|
+
let t1;
|
|
10
|
+
if ($[0] !== text || $[1] !== textareaRef) {
|
|
11
|
+
t0 = () => {
|
|
12
|
+
const textarea = textareaRef.current;
|
|
13
|
+
if (!textarea || supportsFieldSizing() || text === undefined) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
textarea.style.height = "auto";
|
|
17
|
+
textarea.style.height = `${textarea.scrollHeight}px`;
|
|
18
|
+
};
|
|
19
|
+
t1 = [textareaRef, text];
|
|
20
|
+
$[0] = text;
|
|
21
|
+
$[1] = textareaRef;
|
|
22
|
+
$[2] = t0;
|
|
23
|
+
$[3] = t1;
|
|
24
|
+
} else {
|
|
25
|
+
t0 = $[2];
|
|
26
|
+
t1 = $[3];
|
|
27
|
+
}
|
|
28
|
+
useLayoutEffect(t0, t1);
|
|
29
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FilePart } from "../../types.js";
|
|
2
|
+
export type FileItem = {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
mediaType?: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
sizeBytes?: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function formatBytes(bytes: number): string;
|
|
10
|
+
export declare function isImageFile(item: FileItem): boolean;
|
|
11
|
+
export declare function fileExtensionLabel(item: FileItem): string | undefined;
|
|
12
|
+
export declare function filenameFromUrl(url: string): string;
|
|
13
|
+
export declare function fileFromFilePart(part: FilePart, index: number): FileItem;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const byteUnits = ["B", "KB", "MB", "GB"];
|
|
2
|
+
export function formatBytes(bytes) {
|
|
3
|
+
let value = bytes;
|
|
4
|
+
let unitIndex = 0;
|
|
5
|
+
while (value >= 1024 && unitIndex < byteUnits.length - 1) {
|
|
6
|
+
value /= 1024;
|
|
7
|
+
unitIndex += 1;
|
|
8
|
+
}
|
|
9
|
+
const rounded = unitIndex === 0 || value >= 10 ? Math.round(value) : Math.round(value * 10) / 10;
|
|
10
|
+
return `${rounded} ${byteUnits[unitIndex]}`;
|
|
11
|
+
}
|
|
12
|
+
export function isImageFile(item) {
|
|
13
|
+
return Boolean(item.url && item.mediaType?.startsWith("image/"));
|
|
14
|
+
}
|
|
15
|
+
export function fileExtensionLabel(item) {
|
|
16
|
+
const extension = item.name.includes(".") ? item.name.split(".").at(-1) : undefined;
|
|
17
|
+
return extension ? extension.toUpperCase() : undefined;
|
|
18
|
+
}
|
|
19
|
+
export function filenameFromUrl(url) {
|
|
20
|
+
const lastSegment = url.split(/[?#]/)[0]?.split("/").at(-1);
|
|
21
|
+
return lastSegment && !url.startsWith("data:") ? decodeURIComponent(lastSegment) : "Attachment";
|
|
22
|
+
}
|
|
23
|
+
export function fileFromFilePart(part, index) {
|
|
24
|
+
return {
|
|
25
|
+
id: `${index}:${part.url.slice(0, 64)}`,
|
|
26
|
+
name: part.filename ?? filenameFromUrl(part.url),
|
|
27
|
+
mediaType: part.mediaType,
|
|
28
|
+
url: part.url
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { type FileItem } from "./file-meta.js";
|
|
3
|
+
export type FilesLayout = "inline" | "grid";
|
|
4
|
+
export type FilesProps = Omit<React.ComponentProps<"ul">, "children"> & {
|
|
5
|
+
items: FileItem[];
|
|
6
|
+
layout?: FilesLayout;
|
|
7
|
+
onRemove?: (id: string) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare function Files({ items, layout, onRemove, className, ...props }: FilesProps): React.JSX.Element | null;
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { Code as FileCodeIcon, DocumentBlank as FileIcon, DataTable as FileSpreadsheetIcon, Document as FileTextIcon, Close as XIcon } from "@carbon/icons-react";
|
|
3
|
+
import { cn } from "@locusgraph/components";
|
|
4
|
+
import { fileExtensionLabel, formatBytes, isImageFile } from "./file-meta.js";
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
const iconsByMediaType = [[/csv|spreadsheet|excel/, FileSpreadsheetIcon], [/json|javascript|typescript|xml|x-python/, FileCodeIcon], [/text|pdf|markdown|word/, FileTextIcon]];
|
|
7
|
+
function iconForMediaType(mediaType) {
|
|
8
|
+
const match = iconsByMediaType.find(([pattern]) => mediaType && pattern.test(mediaType));
|
|
9
|
+
return match ? match[1] : FileIcon;
|
|
10
|
+
}
|
|
11
|
+
function describeFile(item) {
|
|
12
|
+
const parts = [fileExtensionLabel(item), item.sizeBytes === undefined ? undefined : formatBytes(item.sizeBytes)];
|
|
13
|
+
const description = parts.filter(Boolean).join(" · ");
|
|
14
|
+
return description || undefined;
|
|
15
|
+
}
|
|
16
|
+
function FilePreview(t0) {
|
|
17
|
+
const $ = _c(11);
|
|
18
|
+
const {
|
|
19
|
+
item,
|
|
20
|
+
isGrid
|
|
21
|
+
} = t0;
|
|
22
|
+
let t1;
|
|
23
|
+
if ($[0] !== item.mediaType) {
|
|
24
|
+
t1 = iconForMediaType(item.mediaType);
|
|
25
|
+
$[0] = item.mediaType;
|
|
26
|
+
$[1] = t1;
|
|
27
|
+
} else {
|
|
28
|
+
t1 = $[1];
|
|
29
|
+
}
|
|
30
|
+
const Icon = t1;
|
|
31
|
+
const t2 = isGrid ? "aspect-[16/10] w-full" : "size-10";
|
|
32
|
+
let t3;
|
|
33
|
+
if ($[2] !== t2) {
|
|
34
|
+
t3 = cn("grid shrink-0 place-items-center overflow-hidden bg-muted text-muted-foreground", t2);
|
|
35
|
+
$[2] = t2;
|
|
36
|
+
$[3] = t3;
|
|
37
|
+
} else {
|
|
38
|
+
t3 = $[3];
|
|
39
|
+
}
|
|
40
|
+
let t4;
|
|
41
|
+
if ($[4] !== Icon || $[5] !== isGrid || $[6] !== item) {
|
|
42
|
+
t4 = isImageFile(item) ? /*#__PURE__*/_jsx("img", {
|
|
43
|
+
src: item.url,
|
|
44
|
+
alt: "",
|
|
45
|
+
loading: "lazy",
|
|
46
|
+
className: "size-full object-cover"
|
|
47
|
+
}) : /*#__PURE__*/_jsx(Icon, {
|
|
48
|
+
"aria-hidden": "true",
|
|
49
|
+
className: isGrid ? "size-6" : "size-4"
|
|
50
|
+
});
|
|
51
|
+
$[4] = Icon;
|
|
52
|
+
$[5] = isGrid;
|
|
53
|
+
$[6] = item;
|
|
54
|
+
$[7] = t4;
|
|
55
|
+
} else {
|
|
56
|
+
t4 = $[7];
|
|
57
|
+
}
|
|
58
|
+
let t5;
|
|
59
|
+
if ($[8] !== t3 || $[9] !== t4) {
|
|
60
|
+
t5 = /*#__PURE__*/_jsx("span", {
|
|
61
|
+
"data-slot": "files-preview",
|
|
62
|
+
className: t3,
|
|
63
|
+
children: t4
|
|
64
|
+
});
|
|
65
|
+
$[8] = t3;
|
|
66
|
+
$[9] = t4;
|
|
67
|
+
$[10] = t5;
|
|
68
|
+
} else {
|
|
69
|
+
t5 = $[10];
|
|
70
|
+
}
|
|
71
|
+
return t5;
|
|
72
|
+
}
|
|
73
|
+
function RemoveButton(t0) {
|
|
74
|
+
const $ = _c(10);
|
|
75
|
+
const {
|
|
76
|
+
item,
|
|
77
|
+
isGrid,
|
|
78
|
+
onRemove
|
|
79
|
+
} = t0;
|
|
80
|
+
const t1 = `Remove ${item.name}`;
|
|
81
|
+
let t2;
|
|
82
|
+
if ($[0] !== item.id || $[1] !== onRemove) {
|
|
83
|
+
t2 = () => onRemove(item.id);
|
|
84
|
+
$[0] = item.id;
|
|
85
|
+
$[1] = onRemove;
|
|
86
|
+
$[2] = t2;
|
|
87
|
+
} else {
|
|
88
|
+
t2 = $[2];
|
|
89
|
+
}
|
|
90
|
+
const t3 = isGrid && "absolute top-1 right-1 bg-card/90";
|
|
91
|
+
let t4;
|
|
92
|
+
if ($[3] !== t3) {
|
|
93
|
+
t4 = cn("grid size-6 shrink-0 place-items-center text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring", t3);
|
|
94
|
+
$[3] = t3;
|
|
95
|
+
$[4] = t4;
|
|
96
|
+
} else {
|
|
97
|
+
t4 = $[4];
|
|
98
|
+
}
|
|
99
|
+
let t5;
|
|
100
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
101
|
+
t5 = /*#__PURE__*/_jsx(XIcon, {
|
|
102
|
+
"aria-hidden": "true",
|
|
103
|
+
className: "size-3.5"
|
|
104
|
+
});
|
|
105
|
+
$[5] = t5;
|
|
106
|
+
} else {
|
|
107
|
+
t5 = $[5];
|
|
108
|
+
}
|
|
109
|
+
let t6;
|
|
110
|
+
if ($[6] !== t1 || $[7] !== t2 || $[8] !== t4) {
|
|
111
|
+
t6 = /*#__PURE__*/_jsx("button", {
|
|
112
|
+
type: "button",
|
|
113
|
+
"aria-label": t1,
|
|
114
|
+
onClick: t2,
|
|
115
|
+
className: t4,
|
|
116
|
+
children: t5
|
|
117
|
+
});
|
|
118
|
+
$[6] = t1;
|
|
119
|
+
$[7] = t2;
|
|
120
|
+
$[8] = t4;
|
|
121
|
+
$[9] = t6;
|
|
122
|
+
} else {
|
|
123
|
+
t6 = $[9];
|
|
124
|
+
}
|
|
125
|
+
return t6;
|
|
126
|
+
}
|
|
127
|
+
function FileChip(t0) {
|
|
128
|
+
const $ = _c(27);
|
|
129
|
+
const {
|
|
130
|
+
item,
|
|
131
|
+
isGrid,
|
|
132
|
+
onRemove
|
|
133
|
+
} = t0;
|
|
134
|
+
let t1;
|
|
135
|
+
if ($[0] !== item) {
|
|
136
|
+
t1 = describeFile(item);
|
|
137
|
+
$[0] = item;
|
|
138
|
+
$[1] = t1;
|
|
139
|
+
} else {
|
|
140
|
+
t1 = $[1];
|
|
141
|
+
}
|
|
142
|
+
const description = t1;
|
|
143
|
+
const t2 = isGrid ? "flex-col" : "w-60 max-w-full items-center gap-2.5 pr-1";
|
|
144
|
+
const t3 = !isGrid && !onRemove && "pr-3";
|
|
145
|
+
let t4;
|
|
146
|
+
if ($[2] !== t2 || $[3] !== t3) {
|
|
147
|
+
t4 = cn("relative flex min-w-0 bg-card text-card-foreground ring-1 ring-border", t2, t3);
|
|
148
|
+
$[2] = t2;
|
|
149
|
+
$[3] = t3;
|
|
150
|
+
$[4] = t4;
|
|
151
|
+
} else {
|
|
152
|
+
t4 = $[4];
|
|
153
|
+
}
|
|
154
|
+
let t5;
|
|
155
|
+
if ($[5] !== isGrid || $[6] !== item) {
|
|
156
|
+
t5 = /*#__PURE__*/_jsx(FilePreview, {
|
|
157
|
+
item: item,
|
|
158
|
+
isGrid: isGrid
|
|
159
|
+
});
|
|
160
|
+
$[5] = isGrid;
|
|
161
|
+
$[6] = item;
|
|
162
|
+
$[7] = t5;
|
|
163
|
+
} else {
|
|
164
|
+
t5 = $[7];
|
|
165
|
+
}
|
|
166
|
+
const t6 = isGrid && "px-2.5 py-2";
|
|
167
|
+
let t7;
|
|
168
|
+
if ($[8] !== t6) {
|
|
169
|
+
t7 = cn("flex min-w-0 flex-1 flex-col gap-0.5", t6);
|
|
170
|
+
$[8] = t6;
|
|
171
|
+
$[9] = t7;
|
|
172
|
+
} else {
|
|
173
|
+
t7 = $[9];
|
|
174
|
+
}
|
|
175
|
+
let t8;
|
|
176
|
+
if ($[10] !== item.name) {
|
|
177
|
+
t8 = /*#__PURE__*/_jsx("span", {
|
|
178
|
+
title: item.name,
|
|
179
|
+
className: "truncate text-xs leading-tight font-medium",
|
|
180
|
+
children: item.name
|
|
181
|
+
});
|
|
182
|
+
$[10] = item.name;
|
|
183
|
+
$[11] = t8;
|
|
184
|
+
} else {
|
|
185
|
+
t8 = $[11];
|
|
186
|
+
}
|
|
187
|
+
let t9;
|
|
188
|
+
if ($[12] !== description) {
|
|
189
|
+
t9 = description && /*#__PURE__*/_jsx("span", {
|
|
190
|
+
className: "truncate font-mono text-xs leading-tight text-muted-foreground tabular-nums",
|
|
191
|
+
children: description
|
|
192
|
+
});
|
|
193
|
+
$[12] = description;
|
|
194
|
+
$[13] = t9;
|
|
195
|
+
} else {
|
|
196
|
+
t9 = $[13];
|
|
197
|
+
}
|
|
198
|
+
let t10;
|
|
199
|
+
if ($[14] !== t7 || $[15] !== t8 || $[16] !== t9) {
|
|
200
|
+
t10 = /*#__PURE__*/_jsxs("span", {
|
|
201
|
+
className: t7,
|
|
202
|
+
children: [t8, t9]
|
|
203
|
+
});
|
|
204
|
+
$[14] = t7;
|
|
205
|
+
$[15] = t8;
|
|
206
|
+
$[16] = t9;
|
|
207
|
+
$[17] = t10;
|
|
208
|
+
} else {
|
|
209
|
+
t10 = $[17];
|
|
210
|
+
}
|
|
211
|
+
let t11;
|
|
212
|
+
if ($[18] !== isGrid || $[19] !== item || $[20] !== onRemove) {
|
|
213
|
+
t11 = onRemove && /*#__PURE__*/_jsx(RemoveButton, {
|
|
214
|
+
item: item,
|
|
215
|
+
isGrid: isGrid,
|
|
216
|
+
onRemove: onRemove
|
|
217
|
+
});
|
|
218
|
+
$[18] = isGrid;
|
|
219
|
+
$[19] = item;
|
|
220
|
+
$[20] = onRemove;
|
|
221
|
+
$[21] = t11;
|
|
222
|
+
} else {
|
|
223
|
+
t11 = $[21];
|
|
224
|
+
}
|
|
225
|
+
let t12;
|
|
226
|
+
if ($[22] !== t10 || $[23] !== t11 || $[24] !== t4 || $[25] !== t5) {
|
|
227
|
+
t12 = /*#__PURE__*/_jsxs("li", {
|
|
228
|
+
"data-slot": "files-item",
|
|
229
|
+
className: t4,
|
|
230
|
+
children: [t5, t10, t11]
|
|
231
|
+
});
|
|
232
|
+
$[22] = t10;
|
|
233
|
+
$[23] = t11;
|
|
234
|
+
$[24] = t4;
|
|
235
|
+
$[25] = t5;
|
|
236
|
+
$[26] = t12;
|
|
237
|
+
} else {
|
|
238
|
+
t12 = $[26];
|
|
239
|
+
}
|
|
240
|
+
return t12;
|
|
241
|
+
}
|
|
242
|
+
export function Files(t0) {
|
|
243
|
+
const $ = _c(21);
|
|
244
|
+
let className;
|
|
245
|
+
let items;
|
|
246
|
+
let onRemove;
|
|
247
|
+
let props;
|
|
248
|
+
let t1;
|
|
249
|
+
if ($[0] !== t0) {
|
|
250
|
+
({
|
|
251
|
+
items,
|
|
252
|
+
layout: t1,
|
|
253
|
+
onRemove,
|
|
254
|
+
className,
|
|
255
|
+
...props
|
|
256
|
+
} = t0);
|
|
257
|
+
$[0] = t0;
|
|
258
|
+
$[1] = className;
|
|
259
|
+
$[2] = items;
|
|
260
|
+
$[3] = onRemove;
|
|
261
|
+
$[4] = props;
|
|
262
|
+
$[5] = t1;
|
|
263
|
+
} else {
|
|
264
|
+
className = $[1];
|
|
265
|
+
items = $[2];
|
|
266
|
+
onRemove = $[3];
|
|
267
|
+
props = $[4];
|
|
268
|
+
t1 = $[5];
|
|
269
|
+
}
|
|
270
|
+
const layout = t1 === undefined ? "inline" : t1;
|
|
271
|
+
if (items.length === 0) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
const isGrid = layout === "grid";
|
|
275
|
+
const t2 = isGrid ? "grid grid-cols-2 gap-2 sm:grid-cols-3" : "flex flex-wrap gap-2";
|
|
276
|
+
let t3;
|
|
277
|
+
if ($[6] !== className || $[7] !== t2) {
|
|
278
|
+
t3 = cn(t2, className);
|
|
279
|
+
$[6] = className;
|
|
280
|
+
$[7] = t2;
|
|
281
|
+
$[8] = t3;
|
|
282
|
+
} else {
|
|
283
|
+
t3 = $[8];
|
|
284
|
+
}
|
|
285
|
+
let t4;
|
|
286
|
+
if ($[9] !== isGrid || $[10] !== items || $[11] !== onRemove) {
|
|
287
|
+
let t5;
|
|
288
|
+
if ($[13] !== isGrid || $[14] !== onRemove) {
|
|
289
|
+
t5 = item => /*#__PURE__*/_jsx(FileChip, {
|
|
290
|
+
item: item,
|
|
291
|
+
isGrid: isGrid,
|
|
292
|
+
onRemove: onRemove
|
|
293
|
+
}, item.id);
|
|
294
|
+
$[13] = isGrid;
|
|
295
|
+
$[14] = onRemove;
|
|
296
|
+
$[15] = t5;
|
|
297
|
+
} else {
|
|
298
|
+
t5 = $[15];
|
|
299
|
+
}
|
|
300
|
+
t4 = items.map(t5);
|
|
301
|
+
$[9] = isGrid;
|
|
302
|
+
$[10] = items;
|
|
303
|
+
$[11] = onRemove;
|
|
304
|
+
$[12] = t4;
|
|
305
|
+
} else {
|
|
306
|
+
t4 = $[12];
|
|
307
|
+
}
|
|
308
|
+
let t5;
|
|
309
|
+
if ($[16] !== layout || $[17] !== props || $[18] !== t3 || $[19] !== t4) {
|
|
310
|
+
t5 = /*#__PURE__*/_jsx("ul", {
|
|
311
|
+
"data-slot": "files",
|
|
312
|
+
"data-layout": layout,
|
|
313
|
+
"aria-label": "Files",
|
|
314
|
+
className: t3,
|
|
315
|
+
...props,
|
|
316
|
+
children: t4
|
|
317
|
+
});
|
|
318
|
+
$[16] = layout;
|
|
319
|
+
$[17] = props;
|
|
320
|
+
$[18] = t3;
|
|
321
|
+
$[19] = t4;
|
|
322
|
+
$[20] = t5;
|
|
323
|
+
} else {
|
|
324
|
+
t5 = $[20];
|
|
325
|
+
}
|
|
326
|
+
return t5;
|
|
327
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./chat/chat.js";
|
|
2
|
+
export * from "./composer/composer.js";
|
|
3
|
+
export { type ComposerStatus, isComposerBusy } from "./composer/composer-actions.js";
|
|
4
|
+
export { type FileItem, fileFromFilePart, formatBytes } from "./files/file-meta.js";
|
|
5
|
+
export * from "./files/files.js";
|
|
6
|
+
export * from "./reply/reply.js";
|
|
7
|
+
export * from "./turn/turn.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./chat/chat.js";
|
|
2
|
+
export * from "./composer/composer.js";
|
|
3
|
+
export { isComposerBusy } from "./composer/composer-actions.js";
|
|
4
|
+
export { fileFromFilePart, formatBytes } from "./files/file-meta.js";
|
|
5
|
+
export * from "./files/files.js";
|
|
6
|
+
export * from "./reply/reply.js";
|
|
7
|
+
export * from "./turn/turn.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ExtraProps } from "react-markdown";
|
|
2
|
+
type HastNode = NonNullable<ExtraProps["node"]>;
|
|
3
|
+
export declare function fencedCode(node: HastNode | undefined): {
|
|
4
|
+
code: string;
|
|
5
|
+
language: string;
|
|
6
|
+
} | null;
|
|
7
|
+
export declare function FencedCode({ node }: ExtraProps): import("react").JSX.Element | null;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { Code } from "../../thread/code/code.js";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
function textOf(child) {
|
|
5
|
+
if (child.type === "text") return child.value;
|
|
6
|
+
if (child.type === "element") return child.children.map(textOf).join("");
|
|
7
|
+
return "";
|
|
8
|
+
}
|
|
9
|
+
function languageOf(className) {
|
|
10
|
+
const classes = Array.isArray(className) ? className.map(String) : [];
|
|
11
|
+
const language = classes.find(value => value.startsWith("language-"));
|
|
12
|
+
return language ? language.slice("language-".length) : "text";
|
|
13
|
+
}
|
|
14
|
+
export function fencedCode(node) {
|
|
15
|
+
const code = node?.children.find(child => child.type === "element" && child.tagName === "code");
|
|
16
|
+
if (!code) return null;
|
|
17
|
+
return {
|
|
18
|
+
code: code.children.map(textOf).join("").replace(/\n$/, ""),
|
|
19
|
+
language: languageOf(code.properties.className)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function FencedCode(t0) {
|
|
23
|
+
const $ = _c(5);
|
|
24
|
+
const {
|
|
25
|
+
node
|
|
26
|
+
} = t0;
|
|
27
|
+
let t1;
|
|
28
|
+
if ($[0] !== node) {
|
|
29
|
+
t1 = fencedCode(node);
|
|
30
|
+
$[0] = node;
|
|
31
|
+
$[1] = t1;
|
|
32
|
+
} else {
|
|
33
|
+
t1 = $[1];
|
|
34
|
+
}
|
|
35
|
+
const fenced = t1;
|
|
36
|
+
if (!fenced) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
let t2;
|
|
40
|
+
if ($[2] !== fenced.code || $[3] !== fenced.language) {
|
|
41
|
+
t2 = /*#__PURE__*/_jsx(Code, {
|
|
42
|
+
code: fenced.code,
|
|
43
|
+
language: fenced.language,
|
|
44
|
+
className: "mt-4 first:mt-0"
|
|
45
|
+
});
|
|
46
|
+
$[2] = fenced.code;
|
|
47
|
+
$[3] = fenced.language;
|
|
48
|
+
$[4] = t2;
|
|
49
|
+
} else {
|
|
50
|
+
t2 = $[4];
|
|
51
|
+
}
|
|
52
|
+
return t2;
|
|
53
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { cn } from "@locusgraph/components";
|
|
2
|
+
import { FencedCode, fencedCode } from "./fenced-code.js";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
const blockGap = "mt-4 first:mt-0";
|
|
5
|
+
export const markdownComponents = {
|
|
6
|
+
p: ({
|
|
7
|
+
node: _node,
|
|
8
|
+
className,
|
|
9
|
+
...props
|
|
10
|
+
}) => /*#__PURE__*/_jsx("p", {
|
|
11
|
+
className: cn("leading-relaxed text-pretty [&:not(:first-child)]:mt-3", className),
|
|
12
|
+
...props
|
|
13
|
+
}),
|
|
14
|
+
a: ({
|
|
15
|
+
node: _node,
|
|
16
|
+
className,
|
|
17
|
+
...props
|
|
18
|
+
}) => /*#__PURE__*/_jsx("a", {
|
|
19
|
+
target: "_blank",
|
|
20
|
+
rel: "noopener noreferrer",
|
|
21
|
+
className: cn("font-medium text-foreground underline decoration-muted-foreground/50 underline-offset-3 transition-colors hover:decoration-foreground", className),
|
|
22
|
+
...props
|
|
23
|
+
}),
|
|
24
|
+
h1: ({
|
|
25
|
+
node: _node,
|
|
26
|
+
className,
|
|
27
|
+
...props
|
|
28
|
+
}) => /*#__PURE__*/_jsx("h1", {
|
|
29
|
+
className: cn("mt-7 mb-2 text-base font-semibold tracking-tight first:mt-0", className),
|
|
30
|
+
...props
|
|
31
|
+
}),
|
|
32
|
+
h2: ({
|
|
33
|
+
node: _node,
|
|
34
|
+
className,
|
|
35
|
+
...props
|
|
36
|
+
}) => /*#__PURE__*/_jsx("h2", {
|
|
37
|
+
className: cn("mt-6 mb-2 text-base font-semibold tracking-tight first:mt-0", className),
|
|
38
|
+
...props
|
|
39
|
+
}),
|
|
40
|
+
h3: ({
|
|
41
|
+
node: _node,
|
|
42
|
+
className,
|
|
43
|
+
...props
|
|
44
|
+
}) => /*#__PURE__*/_jsx("h3", {
|
|
45
|
+
className: cn("mt-5 mb-1.5 text-sm font-semibold first:mt-0", className),
|
|
46
|
+
...props
|
|
47
|
+
}),
|
|
48
|
+
h4: ({
|
|
49
|
+
node: _node,
|
|
50
|
+
className,
|
|
51
|
+
...props
|
|
52
|
+
}) => /*#__PURE__*/_jsx("h4", {
|
|
53
|
+
className: cn("eyebrow mt-5 mb-1.5 first:mt-0", className),
|
|
54
|
+
...props
|
|
55
|
+
}),
|
|
56
|
+
ul: ({
|
|
57
|
+
node: _node,
|
|
58
|
+
className,
|
|
59
|
+
...props
|
|
60
|
+
}) => /*#__PURE__*/_jsx("ul", {
|
|
61
|
+
className: cn("mt-3 list-disc space-y-1.5 pl-5 first:mt-0 [li_&]:mt-1.5", className),
|
|
62
|
+
...props
|
|
63
|
+
}),
|
|
64
|
+
ol: ({
|
|
65
|
+
node: _node,
|
|
66
|
+
className,
|
|
67
|
+
...props
|
|
68
|
+
}) => /*#__PURE__*/_jsx("ol", {
|
|
69
|
+
className: cn("mt-3 list-decimal space-y-1.5 pl-5 first:mt-0 marker:tabular-nums [li_&]:mt-1.5", className),
|
|
70
|
+
...props
|
|
71
|
+
}),
|
|
72
|
+
li: ({
|
|
73
|
+
node: _node,
|
|
74
|
+
className,
|
|
75
|
+
...props
|
|
76
|
+
}) => /*#__PURE__*/_jsx("li", {
|
|
77
|
+
className: cn("pl-1 leading-relaxed marker:text-muted-foreground [&>p]:mt-0", className),
|
|
78
|
+
...props
|
|
79
|
+
}),
|
|
80
|
+
blockquote: ({
|
|
81
|
+
node: _node,
|
|
82
|
+
className,
|
|
83
|
+
...props
|
|
84
|
+
}) => /*#__PURE__*/_jsx("blockquote", {
|
|
85
|
+
className: cn("border-l-2 border-border pl-4 text-muted-foreground", blockGap, className),
|
|
86
|
+
...props
|
|
87
|
+
}),
|
|
88
|
+
hr: ({
|
|
89
|
+
node: _node,
|
|
90
|
+
className,
|
|
91
|
+
...props
|
|
92
|
+
}) => /*#__PURE__*/_jsx("hr", {
|
|
93
|
+
className: cn("my-6 border-border", className),
|
|
94
|
+
...props
|
|
95
|
+
}),
|
|
96
|
+
pre: ({
|
|
97
|
+
node,
|
|
98
|
+
className,
|
|
99
|
+
...props
|
|
100
|
+
}) => fencedCode(node) ? /*#__PURE__*/_jsx(FencedCode, {
|
|
101
|
+
node: node
|
|
102
|
+
}) : /*#__PURE__*/_jsx("pre", {
|
|
103
|
+
className: cn("overflow-x-auto bg-muted/40 p-3 font-mono text-xs leading-relaxed", blockGap, className),
|
|
104
|
+
...props
|
|
105
|
+
}),
|
|
106
|
+
code: ({
|
|
107
|
+
node: _node,
|
|
108
|
+
className,
|
|
109
|
+
...props
|
|
110
|
+
}) => /*#__PURE__*/_jsx("code", {
|
|
111
|
+
className: cn("bg-muted px-1.5 py-0.5 font-mono text-[0.85em] text-foreground [pre_&]:bg-transparent [pre_&]:p-0", className),
|
|
112
|
+
...props
|
|
113
|
+
}),
|
|
114
|
+
table: ({
|
|
115
|
+
node: _node,
|
|
116
|
+
className,
|
|
117
|
+
...props
|
|
118
|
+
}) => /*#__PURE__*/_jsx("div", {
|
|
119
|
+
"data-slot": "reply-table",
|
|
120
|
+
className: cn("overflow-x-auto ring-1 ring-border", blockGap),
|
|
121
|
+
children: /*#__PURE__*/_jsx("table", {
|
|
122
|
+
className: cn("w-full border-collapse text-sm [&_td:not(:first-child)]:tabular-nums", className),
|
|
123
|
+
...props
|
|
124
|
+
})
|
|
125
|
+
}),
|
|
126
|
+
th: ({
|
|
127
|
+
node: _node,
|
|
128
|
+
className,
|
|
129
|
+
...props
|
|
130
|
+
}) => /*#__PURE__*/_jsx("th", {
|
|
131
|
+
className: cn("eyebrow border-b bg-muted/30 px-3 py-2 text-left font-normal", className),
|
|
132
|
+
...props
|
|
133
|
+
}),
|
|
134
|
+
td: ({
|
|
135
|
+
node: _node,
|
|
136
|
+
className,
|
|
137
|
+
...props
|
|
138
|
+
}) => /*#__PURE__*/_jsx("td", {
|
|
139
|
+
className: cn("border-b px-3 py-2 align-top [tr:last-child_&]:border-b-0", className),
|
|
140
|
+
...props
|
|
141
|
+
})
|
|
142
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type { StreamState } from "../../types.js";
|
|
3
|
+
export type ReplyProps = Omit<React.ComponentProps<"div">, "children"> & {
|
|
4
|
+
children: string;
|
|
5
|
+
state?: StreamState;
|
|
6
|
+
};
|
|
7
|
+
export declare function closeOpenCodeFence(markdown: string): string;
|
|
8
|
+
export declare function Reply({ children, state, className, ...props }: ReplyProps): React.JSX.Element;
|