@locusgraph/loop 0.1.0 → 0.2.1

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 (115) hide show
  1. package/README.md +2 -0
  2. package/dist/agent/pulse/gradient-label.js +36 -15
  3. package/dist/agent/pulse/marks/bars-mark.js +24 -10
  4. package/dist/agent/pulse/marks/glyph-mark.js +17 -11
  5. package/dist/agent/pulse/marks/locus-mark.js +39 -28
  6. package/dist/agent/pulse/marks/orb-mark.js +21 -8
  7. package/dist/agent/pulse/marks/spinner-mark.js +20 -1
  8. package/dist/agent/pulse/pulse.js +63 -35
  9. package/dist/agent/pulse/use-loop-animation.js +14 -16
  10. package/dist/agent/steps/step-icon.js +40 -24
  11. package/dist/agent/steps/steps.js +72 -25
  12. package/dist/agent/thinking/thinking.js +203 -23
  13. package/dist/agent/thinking/thought-duration.js +7 -9
  14. package/dist/agent/tool/json-block.js +18 -11
  15. package/dist/agent/tool/tool-status.js +28 -18
  16. package/dist/agent/tool/tool.js +184 -6
  17. package/dist/approval/inbox/inbox-row.d.ts +3 -2
  18. package/dist/approval/inbox/inbox-row.js +96 -7
  19. package/dist/approval/inbox/inbox-selection.js +7 -13
  20. package/dist/approval/inbox/inbox.d.ts +2 -1
  21. package/dist/approval/inbox/inbox.js +99 -18
  22. package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
  23. package/dist/approval/inbox/virtual-inbox-list.js +53 -0
  24. package/dist/approval/memory/memory-choices.js +27 -22
  25. package/dist/approval/memory/memory-review.js +108 -17
  26. package/dist/approval/memory/memory-row.js +80 -19
  27. package/dist/approval/plan/plan-review.js +129 -28
  28. package/dist/approval/plan/plan-step-row.js +91 -44
  29. package/dist/approval/plan/plan-steps.js +24 -23
  30. package/dist/approval/plan/question-choices.js +73 -40
  31. package/dist/approval/plan/question.d.ts +1 -1
  32. package/dist/approval/plan/question.js +108 -27
  33. package/dist/approval/run/run-bar.js +94 -22
  34. package/dist/approval/shared/decision-line.js +1 -1
  35. package/dist/approval/shared/risk-badge.js +32 -16
  36. package/dist/approval/shared/time.js +5 -8
  37. package/dist/approval/shared/use-focus-on-mount.js +7 -6
  38. package/dist/approval/spend/raise-cap-form.js +64 -19
  39. package/dist/approval/spend/spend-gate.js +124 -21
  40. package/dist/approval/spend/spend-math.js +7 -8
  41. package/dist/approval/spend/spend-meter.js +136 -35
  42. package/dist/approval/tool/approval.js +113 -27
  43. package/dist/approval/tool/args/args-editor.js +104 -26
  44. package/dist/approval/tool/args/args-field.js +79 -22
  45. package/dist/approval/tool/args/args-validation.js +38 -47
  46. package/dist/approval/tool/deny-form.js +43 -10
  47. package/dist/approval/tool/tool-inputs.js +62 -38
  48. package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
  49. package/dist/chat/chat/chat-item-spacing.js +19 -0
  50. package/dist/chat/chat/chat.d.ts +2 -1
  51. package/dist/chat/chat/chat.js +181 -5
  52. package/dist/chat/chat/use-stick-to-bottom.js +71 -48
  53. package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
  54. package/dist/chat/chat/virtual-chat-items.js +60 -0
  55. package/dist/chat/composer/composer-actions.js +69 -17
  56. package/dist/chat/composer/composer.js +330 -32
  57. package/dist/chat/composer/use-auto-grow.js +9 -9
  58. package/dist/chat/files/file-meta.js +19 -19
  59. package/dist/chat/files/files.js +92 -29
  60. package/dist/chat/reply/fenced-code.js +23 -21
  61. package/dist/chat/reply/markdown-components.js +137 -17
  62. package/dist/chat/reply/reply.js +30 -10
  63. package/dist/chat/turn/group-parts.js +43 -29
  64. package/dist/chat/turn/turn.js +87 -30
  65. package/dist/cost/context.js +104 -23
  66. package/dist/cost/cost-steps.js +67 -14
  67. package/dist/cost/cost.js +128 -23
  68. package/dist/cost/model-picker.js +51 -6
  69. package/dist/cost/shared/context-breakdown.js +83 -10
  70. package/dist/cost/shared/meter-marks.js +49 -9
  71. package/dist/cost/shared/model-option-row.js +56 -22
  72. package/dist/cost/shared/step-cost-row.js +65 -22
  73. package/dist/cost/shared/usage-totals.js +22 -18
  74. package/dist/memory/cite.js +62 -12
  75. package/dist/memory/memorized.js +65 -11
  76. package/dist/memory/recall.js +101 -17
  77. package/dist/memory/shared/host-label.js +19 -22
  78. package/dist/memory/shared/source-mark.js +11 -3
  79. package/dist/memory/sources.js +78 -14
  80. package/dist/shared/decision-summary.js +51 -14
  81. package/dist/shared/panel-empty.js +20 -3
  82. package/dist/shared/panel.js +69 -13
  83. package/dist/shared/status-dot.js +16 -8
  84. package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
  85. package/dist/shared/virtual/use-list-virtualizer.js +68 -0
  86. package/dist/thread/actions/action-button.js +22 -3
  87. package/dist/thread/actions/actions.js +184 -13
  88. package/dist/thread/actions/branch-switcher.js +28 -5
  89. package/dist/thread/canvas/canvas.js +205 -5
  90. package/dist/thread/canvas/version-switcher.js +54 -8
  91. package/dist/thread/code/code.js +186 -24
  92. package/dist/thread/code/copy-code-button.js +30 -14
  93. package/dist/thread/code/highlight.js +30 -29
  94. package/dist/thread/history/history-rows.d.ts +16 -0
  95. package/dist/thread/history/history-rows.js +23 -0
  96. package/dist/thread/history/history.d.ts +3 -2
  97. package/dist/thread/history/history.js +174 -5
  98. package/dist/thread/history/{history-row.d.ts → row/history-row.d.ts} +3 -2
  99. package/dist/thread/history/row/history-row.js +58 -0
  100. package/dist/thread/history/row/thread-item-menu.js +31 -0
  101. package/dist/thread/history/row/thread-title-editor.js +38 -0
  102. package/dist/thread/history/thread-groups.d.ts +1 -1
  103. package/dist/thread/history/thread-groups.js +40 -34
  104. package/dist/thread/history/virtual-history-list.d.ts +11 -0
  105. package/dist/thread/history/virtual-history-list.js +71 -0
  106. package/dist/thread/index.d.ts +1 -1
  107. package/dist/thread/starters/starters.js +33 -8
  108. package/dist/thread/use-copied.js +18 -16
  109. package/dist/types.js +1 -1
  110. package/package.json +6 -4
  111. package/dist/thread/history/history-row.js +0 -17
  112. package/dist/thread/history/thread-item-menu.js +0 -6
  113. package/dist/thread/history/thread-title-editor.js +0 -25
  114. /package/dist/thread/history/{thread-item-menu.d.ts → row/thread-item-menu.d.ts} +0 -0
  115. /package/dist/thread/history/{thread-title-editor.d.ts → row/thread-title-editor.d.ts} +0 -0
@@ -1,39 +1,102 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Code as FileCodeIcon, DocumentBlank as FileIcon, DataTable as FileSpreadsheetIcon, Document as FileTextIcon, Close as XIcon, } from "@carbon/icons-react";
1
+ import { Code as FileCodeIcon, DocumentBlank as FileIcon, DataTable as FileSpreadsheetIcon, Document as FileTextIcon, Close as XIcon } from "@carbon/icons-react";
3
2
  import { cn } from "@locusgraph/components";
4
3
  import { fileExtensionLabel, formatBytes, isImageFile } from "./file-meta.js";
5
- const iconsByMediaType = [
6
- [/csv|spreadsheet|excel/, FileSpreadsheetIcon],
7
- [/json|javascript|typescript|xml|x-python/, FileCodeIcon],
8
- [/text|pdf|markdown|word/, FileTextIcon],
9
- ];
4
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
+ const iconsByMediaType = [[/csv|spreadsheet|excel/, FileSpreadsheetIcon], [/json|javascript|typescript|xml|x-python/, FileCodeIcon], [/text|pdf|markdown|word/, FileTextIcon]];
10
6
  function iconForMediaType(mediaType) {
11
- const match = iconsByMediaType.find(([pattern]) => mediaType && pattern.test(mediaType));
12
- return match ? match[1] : FileIcon;
7
+ const match = iconsByMediaType.find(([pattern]) => mediaType && pattern.test(mediaType));
8
+ return match ? match[1] : FileIcon;
13
9
  }
14
10
  function describeFile(item) {
15
- const parts = [
16
- fileExtensionLabel(item),
17
- item.sizeBytes === undefined ? undefined : formatBytes(item.sizeBytes),
18
- ];
19
- const description = parts.filter(Boolean).join(" · ");
20
- return description || undefined;
11
+ const parts = [fileExtensionLabel(item), item.sizeBytes === undefined ? undefined : formatBytes(item.sizeBytes)];
12
+ const description = parts.filter(Boolean).join(" · ");
13
+ return description || undefined;
21
14
  }
22
- function FilePreview({ item, isGrid }) {
23
- const Icon = iconForMediaType(item.mediaType);
24
- return (_jsx("span", { "data-slot": "files-preview", className: cn("grid shrink-0 place-items-center overflow-hidden bg-muted text-muted-foreground", isGrid ? "aspect-[16/10] w-full" : "size-10"), children: isImageFile(item) ? (_jsx("img", { src: item.url, alt: "", loading: "lazy", className: "size-full object-cover" })) : (_jsx(Icon, { "aria-hidden": "true", className: isGrid ? "size-6" : "size-4" })) }));
15
+ function FilePreview({
16
+ item,
17
+ isGrid
18
+ }) {
19
+ const Icon = iconForMediaType(item.mediaType);
20
+ return /*#__PURE__*/_jsx("span", {
21
+ "data-slot": "files-preview",
22
+ className: cn("grid shrink-0 place-items-center overflow-hidden bg-muted text-muted-foreground", isGrid ? "aspect-[16/10] w-full" : "size-10"),
23
+ children: isImageFile(item) ? /*#__PURE__*/_jsx("img", {
24
+ src: item.url,
25
+ alt: "",
26
+ loading: "lazy",
27
+ className: "size-full object-cover"
28
+ }) : /*#__PURE__*/_jsx(Icon, {
29
+ "aria-hidden": "true",
30
+ className: isGrid ? "size-6" : "size-4"
31
+ })
32
+ });
25
33
  }
26
- function RemoveButton({ item, isGrid, onRemove }) {
27
- return (_jsx("button", { type: "button", "aria-label": `Remove ${item.name}`, onClick: () => onRemove(item.id), className: 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", isGrid && "absolute top-1 right-1 bg-card/90"), children: _jsx(XIcon, { "aria-hidden": "true", className: "size-3.5" }) }));
34
+ function RemoveButton({
35
+ item,
36
+ isGrid,
37
+ onRemove
38
+ }) {
39
+ return /*#__PURE__*/_jsx("button", {
40
+ type: "button",
41
+ "aria-label": `Remove ${item.name}`,
42
+ onClick: () => onRemove(item.id),
43
+ className: 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", isGrid && "absolute top-1 right-1 bg-card/90"),
44
+ children: /*#__PURE__*/_jsx(XIcon, {
45
+ "aria-hidden": "true",
46
+ className: "size-3.5"
47
+ })
48
+ });
28
49
  }
29
- function FileChip({ item, isGrid, onRemove }) {
30
- const description = describeFile(item);
31
- return (_jsxs("li", { "data-slot": "files-item", className: cn("relative flex min-w-0 bg-card text-card-foreground ring-1 ring-border", isGrid ? "flex-col" : "w-60 max-w-full items-center gap-2.5 pr-1", !isGrid && !onRemove && "pr-3"), children: [_jsx(FilePreview, { item: item, isGrid: isGrid }), _jsxs("span", { className: cn("flex min-w-0 flex-1 flex-col gap-0.5", isGrid && "px-2.5 py-2"), children: [_jsx("span", { title: item.name, className: "truncate text-xs leading-tight font-medium", children: item.name }), description && (_jsx("span", { className: "truncate font-mono text-xs leading-tight text-muted-foreground tabular-nums", children: description }))] }), onRemove && _jsx(RemoveButton, { item: item, isGrid: isGrid, onRemove: onRemove })] }));
50
+ function FileChip({
51
+ item,
52
+ isGrid,
53
+ onRemove
54
+ }) {
55
+ const description = describeFile(item);
56
+ return /*#__PURE__*/_jsxs("li", {
57
+ "data-slot": "files-item",
58
+ className: cn("relative flex min-w-0 bg-card text-card-foreground ring-1 ring-border", isGrid ? "flex-col" : "w-60 max-w-full items-center gap-2.5 pr-1", !isGrid && !onRemove && "pr-3"),
59
+ children: [/*#__PURE__*/_jsx(FilePreview, {
60
+ item: item,
61
+ isGrid: isGrid
62
+ }), /*#__PURE__*/_jsxs("span", {
63
+ className: cn("flex min-w-0 flex-1 flex-col gap-0.5", isGrid && "px-2.5 py-2"),
64
+ children: [/*#__PURE__*/_jsx("span", {
65
+ title: item.name,
66
+ className: "truncate text-xs leading-tight font-medium",
67
+ children: item.name
68
+ }), description && /*#__PURE__*/_jsx("span", {
69
+ className: "truncate font-mono text-xs leading-tight text-muted-foreground tabular-nums",
70
+ children: description
71
+ })]
72
+ }), onRemove && /*#__PURE__*/_jsx(RemoveButton, {
73
+ item: item,
74
+ isGrid: isGrid,
75
+ onRemove: onRemove
76
+ })]
77
+ });
32
78
  }
33
- export function Files({ items, layout = "inline", onRemove, className, ...props }) {
34
- if (items.length === 0) {
35
- return null;
36
- }
37
- const isGrid = layout === "grid";
38
- return (_jsx("ul", { "data-slot": "files", "data-layout": layout, "aria-label": "Files", className: cn(isGrid ? "grid grid-cols-2 gap-2 sm:grid-cols-3" : "flex flex-wrap gap-2", className), ...props, children: items.map((item) => (_jsx(FileChip, { item: item, isGrid: isGrid, onRemove: onRemove }, item.id))) }));
79
+ export function Files({
80
+ items,
81
+ layout = "inline",
82
+ onRemove,
83
+ className,
84
+ ...props
85
+ }) {
86
+ if (items.length === 0) {
87
+ return null;
88
+ }
89
+ const isGrid = layout === "grid";
90
+ return /*#__PURE__*/_jsx("ul", {
91
+ "data-slot": "files",
92
+ "data-layout": layout,
93
+ "aria-label": "Files",
94
+ className: cn(isGrid ? "grid grid-cols-2 gap-2 sm:grid-cols-3" : "flex flex-wrap gap-2", className),
95
+ ...props,
96
+ children: items.map(item => /*#__PURE__*/_jsx(FileChip, {
97
+ item: item,
98
+ isGrid: isGrid,
99
+ onRemove: onRemove
100
+ }, item.id))
101
+ });
39
102
  }
@@ -1,29 +1,31 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  import { Code } from "../../thread/code/code.js";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  function textOf(child) {
4
- if (child.type === "text")
5
- return child.value;
6
- if (child.type === "element")
7
- return child.children.map(textOf).join("");
8
- return "";
4
+ if (child.type === "text") return child.value;
5
+ if (child.type === "element") return child.children.map(textOf).join("");
6
+ return "";
9
7
  }
10
8
  function languageOf(className) {
11
- const classes = Array.isArray(className) ? className.map(String) : [];
12
- const language = classes.find((value) => value.startsWith("language-"));
13
- return language ? language.slice("language-".length) : "text";
9
+ const classes = Array.isArray(className) ? className.map(String) : [];
10
+ const language = classes.find(value => value.startsWith("language-"));
11
+ return language ? language.slice("language-".length) : "text";
14
12
  }
15
13
  export function fencedCode(node) {
16
- const code = node?.children.find((child) => child.type === "element" && child.tagName === "code");
17
- if (!code)
18
- return null;
19
- return {
20
- code: code.children.map(textOf).join("").replace(/\n$/, ""),
21
- language: languageOf(code.properties.className),
22
- };
14
+ const code = node?.children.find(child => child.type === "element" && child.tagName === "code");
15
+ if (!code) return null;
16
+ return {
17
+ code: code.children.map(textOf).join("").replace(/\n$/, ""),
18
+ language: languageOf(code.properties.className)
19
+ };
23
20
  }
24
- export function FencedCode({ node }) {
25
- const fenced = fencedCode(node);
26
- if (!fenced)
27
- return null;
28
- return _jsx(Code, { code: fenced.code, language: fenced.language, className: "mt-4 first:mt-0" });
21
+ export function FencedCode({
22
+ node
23
+ }) {
24
+ const fenced = fencedCode(node);
25
+ if (!fenced) return null;
26
+ return /*#__PURE__*/_jsx(Code, {
27
+ code: fenced.code,
28
+ language: fenced.language,
29
+ className: "mt-4 first:mt-0"
30
+ });
29
31
  }
@@ -1,22 +1,142 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  import { cn } from "@locusgraph/components";
3
2
  import { FencedCode, fencedCode } from "./fenced-code.js";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
4
  const blockGap = "mt-4 first:mt-0";
5
5
  export const markdownComponents = {
6
- p: ({ node: _node, className, ...props }) => (_jsx("p", { className: cn("leading-relaxed text-pretty [&:not(:first-child)]:mt-3", className), ...props })),
7
- a: ({ node: _node, className, ...props }) => (_jsx("a", { target: "_blank", rel: "noopener noreferrer", className: cn("font-medium text-foreground underline decoration-muted-foreground/50 underline-offset-3 transition-colors hover:decoration-foreground", className), ...props })),
8
- h1: ({ node: _node, className, ...props }) => (_jsx("h1", { className: cn("mt-7 mb-2 text-base font-semibold tracking-tight first:mt-0", className), ...props })),
9
- h2: ({ node: _node, className, ...props }) => (_jsx("h2", { className: cn("mt-6 mb-2 text-base font-semibold tracking-tight first:mt-0", className), ...props })),
10
- h3: ({ node: _node, className, ...props }) => (_jsx("h3", { className: cn("mt-5 mb-1.5 text-sm font-semibold first:mt-0", className), ...props })),
11
- h4: ({ node: _node, className, ...props }) => (_jsx("h4", { className: cn("eyebrow mt-5 mb-1.5 first:mt-0", className), ...props })),
12
- ul: ({ node: _node, className, ...props }) => (_jsx("ul", { className: cn("mt-3 list-disc space-y-1.5 pl-5 first:mt-0 [li_&]:mt-1.5", className), ...props })),
13
- ol: ({ node: _node, className, ...props }) => (_jsx("ol", { className: cn("mt-3 list-decimal space-y-1.5 pl-5 first:mt-0 marker:tabular-nums [li_&]:mt-1.5", className), ...props })),
14
- li: ({ node: _node, className, ...props }) => (_jsx("li", { className: cn("pl-1 leading-relaxed marker:text-muted-foreground [&>p]:mt-0", className), ...props })),
15
- blockquote: ({ node: _node, className, ...props }) => (_jsx("blockquote", { className: cn("border-l-2 border-border pl-4 text-muted-foreground", blockGap, className), ...props })),
16
- hr: ({ node: _node, className, ...props }) => (_jsx("hr", { className: cn("my-6 border-border", className), ...props })),
17
- pre: ({ node, className, ...props }) => fencedCode(node) ? (_jsx(FencedCode, { node: node })) : (_jsx("pre", { className: cn("overflow-x-auto bg-muted/40 p-3 font-mono text-xs leading-relaxed", blockGap, className), ...props })),
18
- code: ({ node: _node, className, ...props }) => (_jsx("code", { className: cn("bg-muted px-1.5 py-0.5 font-mono text-[0.85em] text-foreground [pre_&]:bg-transparent [pre_&]:p-0", className), ...props })),
19
- table: ({ node: _node, className, ...props }) => (_jsx("div", { "data-slot": "reply-table", className: cn("overflow-x-auto ring-1 ring-border", blockGap), children: _jsx("table", { className: cn("w-full border-collapse text-sm [&_td:not(:first-child)]:tabular-nums", className), ...props }) })),
20
- th: ({ node: _node, className, ...props }) => (_jsx("th", { className: cn("eyebrow border-b bg-muted/30 px-3 py-2 text-left font-normal", className), ...props })),
21
- td: ({ node: _node, className, ...props }) => (_jsx("td", { className: cn("border-b px-3 py-2 align-top [tr:last-child_&]:border-b-0", className), ...props })),
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
+ })
22
142
  };
@@ -1,21 +1,41 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  import { cn } from "@locusgraph/components";
3
2
  import { memo } from "react";
4
3
  import ReactMarkdown from "react-markdown";
5
4
  import remarkGfm from "remark-gfm";
6
5
  import { markdownComponents } from "./markdown-components.js";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
7
  const codeFence = /^ {0,3}(```|~~~)/gm;
8
8
  export function closeOpenCodeFence(markdown) {
9
- const fences = markdown.match(codeFence) ?? [];
10
- const lastFence = fences.at(-1)?.trim().slice(0, 3);
11
- return fences.length % 2 === 1 ? `${markdown}\n${lastFence}` : markdown;
9
+ const fences = markdown.match(codeFence) ?? [];
10
+ const lastFence = fences.at(-1)?.trim().slice(0, 3);
11
+ return fences.length % 2 === 1 ? `${markdown}\n${lastFence}` : markdown;
12
12
  }
13
- const Markdown = memo(function Markdown({ markdown }) {
14
- return (_jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], components: markdownComponents, children: markdown }));
13
+ const Markdown = memo(function Markdown({
14
+ markdown
15
+ }) {
16
+ return /*#__PURE__*/_jsx(ReactMarkdown, {
17
+ remarkPlugins: [remarkGfm],
18
+ components: markdownComponents,
19
+ children: markdown
20
+ });
15
21
  });
16
22
  const streamingCaret = "data-[state=streaming]:[&>:last-child]:after:ml-0.5 data-[state=streaming]:[&>:last-child]:after:inline-block data-[state=streaming]:[&>:last-child]:after:h-[1em] data-[state=streaming]:[&>:last-child]:after:w-[0.5ch] data-[state=streaming]:[&>:last-child]:after:translate-y-[0.15em] data-[state=streaming]:[&>:last-child]:after:bg-foreground/70 data-[state=streaming]:[&>:last-child]:after:content-[''] motion-safe:data-[state=streaming]:[&>:last-child]:after:animate-pulse";
17
- export function Reply({ children, state = "done", className, ...props }) {
18
- const isStreaming = state === "streaming";
19
- const markdown = isStreaming ? closeOpenCodeFence(children) : children;
20
- return (_jsx("div", { "data-slot": "reply", "data-state": state, "aria-live": isStreaming ? "polite" : undefined, className: cn("min-w-0 text-sm leading-relaxed wrap-break-word text-foreground", streamingCaret, className), ...props, children: _jsx(Markdown, { markdown: markdown }) }));
23
+ export function Reply({
24
+ children,
25
+ state = "done",
26
+ className,
27
+ ...props
28
+ }) {
29
+ const isStreaming = state === "streaming";
30
+ const markdown = isStreaming ? closeOpenCodeFence(children) : children;
31
+ return /*#__PURE__*/_jsx("div", {
32
+ "data-slot": "reply",
33
+ "data-state": state,
34
+ "aria-live": isStreaming ? "polite" : undefined,
35
+ className: cn("min-w-0 text-sm leading-relaxed wrap-break-word text-foreground", streamingCaret, className),
36
+ ...props,
37
+ children: /*#__PURE__*/_jsx(Markdown, {
38
+ markdown: markdown
39
+ })
40
+ });
21
41
  }
@@ -1,35 +1,49 @@
1
1
  export function isToolPart(part) {
2
- return part.type === "dynamic-tool" || part.type.startsWith("tool-");
2
+ return part.type === "dynamic-tool" || part.type.startsWith("tool-");
3
3
  }
4
4
  function appendToRun(segments, kind, part, key) {
5
- const previous = segments.at(-1);
6
- if (previous?.kind === kind) {
7
- previous.parts.push(part);
8
- return;
9
- }
10
- segments.push(kind === "files"
11
- ? { kind, key, parts: [part] }
12
- : { kind, key, parts: [part] });
5
+ const previous = segments.at(-1);
6
+ if (previous?.kind === kind) {
7
+ previous.parts.push(part);
8
+ return;
9
+ }
10
+ segments.push(kind === "files" ? {
11
+ kind,
12
+ key,
13
+ parts: [part]
14
+ } : {
15
+ kind,
16
+ key,
17
+ parts: [part]
18
+ });
13
19
  }
14
20
  export function groupParts(parts) {
15
- const segments = [];
16
- parts.forEach((part, index) => {
17
- const key = `${part.type}:${index}`;
18
- if (part.type === "text") {
19
- segments.push({ kind: "text", key, part });
20
- }
21
- else if (part.type === "reasoning") {
22
- segments.push({ kind: "reasoning", key, part });
23
- }
24
- else if (part.type === "file") {
25
- appendToRun(segments, "files", part, key);
26
- }
27
- else if (part.type === "source-url") {
28
- appendToRun(segments, "sources", part, key);
29
- }
30
- else if (isToolPart(part)) {
31
- segments.push({ kind: "tool", key: part.toolCallId, part });
32
- }
33
- });
34
- return segments;
21
+ const segments = [];
22
+ parts.forEach((part, index) => {
23
+ const key = `${part.type}:${index}`;
24
+ if (part.type === "text") {
25
+ segments.push({
26
+ kind: "text",
27
+ key,
28
+ part
29
+ });
30
+ } else if (part.type === "reasoning") {
31
+ segments.push({
32
+ kind: "reasoning",
33
+ key,
34
+ part
35
+ });
36
+ } else if (part.type === "file") {
37
+ appendToRun(segments, "files", part, key);
38
+ } else if (part.type === "source-url") {
39
+ appendToRun(segments, "sources", part, key);
40
+ } else if (isToolPart(part)) {
41
+ segments.push({
42
+ kind: "tool",
43
+ key: part.toolCallId,
44
+ part
45
+ });
46
+ }
47
+ });
48
+ return segments;
35
49
  }
@@ -1,5 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { cn, MessageAvatar, MessageContent, MessageFooter, Message as MessageRow, } from "@locusgraph/components";
1
+ import { cn, MessageAvatar, MessageContent, MessageFooter, Message as MessageRow } from "@locusgraph/components";
3
2
  import { Thinking } from "../../agent/thinking/thinking.js";
4
3
  import { Tool } from "../../agent/tool/tool.js";
5
4
  import { Sources } from "../../memory/sources.js";
@@ -7,39 +6,97 @@ import { fileFromFilePart } from "../files/file-meta.js";
7
6
  import { Files } from "../files/files.js";
8
7
  import { Reply } from "../reply/reply.js";
9
8
  import { groupParts } from "./group-parts.js";
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
10
  const roleLabels = {
11
- user: "You said",
12
- assistant: "Assistant said",
13
- system: "System note",
11
+ user: "You said",
12
+ assistant: "Assistant said",
13
+ system: "System note"
14
14
  };
15
- function UserText({ part }) {
16
- return (_jsx("div", { "data-slot": "message-user-text", className: "max-w-[85%] bg-muted px-3.5 py-2 text-sm leading-relaxed whitespace-pre-wrap wrap-break-word text-foreground", children: part.text }));
15
+ function UserText({
16
+ part
17
+ }) {
18
+ return /*#__PURE__*/_jsx("div", {
19
+ "data-slot": "message-user-text",
20
+ className: "max-w-[85%] bg-muted px-3.5 py-2 text-sm leading-relaxed whitespace-pre-wrap wrap-break-word text-foreground",
21
+ children: part.text
22
+ });
17
23
  }
18
24
  function partClassName(role, kind) {
19
- if (role === "user") {
20
- return "w-full items-end";
21
- }
22
- if (role === "system") {
23
- return "border-l-2 border-border pl-3 *:data-[slot=reply]:text-xs *:data-[slot=reply]:text-muted-foreground";
24
- }
25
- return cn(kind === "text" && "*:data-[slot=reply]:max-w-[68ch]");
25
+ if (role === "user") {
26
+ return "w-full items-end";
27
+ }
28
+ if (role === "system") {
29
+ return "border-l-2 border-border pl-3 *:data-[slot=reply]:text-xs *:data-[slot=reply]:text-muted-foreground";
30
+ }
31
+ return cn(kind === "text" && "*:data-[slot=reply]:max-w-[68ch]");
26
32
  }
27
33
  function renderSegment(segment, isUser, renderers) {
28
- switch (segment.kind) {
29
- case "text":
30
- return isUser ? (_jsx(UserText, { part: segment.part })) : (_jsx(Reply, { state: segment.part.state, children: segment.part.text }));
31
- case "reasoning":
32
- return renderers.renderReasoning ? (renderers.renderReasoning(segment.part)) : (_jsx(Thinking, { text: segment.part.text, state: segment.part.state, durationMs: segment.part.durationMs }));
33
- case "tool":
34
- return renderers.renderTool ? (renderers.renderTool(segment.part)) : (_jsx(Tool, { part: segment.part }));
35
- case "sources":
36
- return renderers.renderSources ? (renderers.renderSources(segment.parts)) : (_jsx(Sources, { sources: segment.parts }));
37
- case "files":
38
- return (_jsx(Files, { items: segment.parts.map(fileFromFilePart), className: cn(isUser && "justify-end") }));
39
- }
34
+ switch (segment.kind) {
35
+ case "text":
36
+ return isUser ? /*#__PURE__*/_jsx(UserText, {
37
+ part: segment.part
38
+ }) : /*#__PURE__*/_jsx(Reply, {
39
+ state: segment.part.state,
40
+ children: segment.part.text
41
+ });
42
+ case "reasoning":
43
+ return renderers.renderReasoning ? renderers.renderReasoning(segment.part) : /*#__PURE__*/_jsx(Thinking, {
44
+ text: segment.part.text,
45
+ state: segment.part.state,
46
+ durationMs: segment.part.durationMs
47
+ });
48
+ case "tool":
49
+ return renderers.renderTool ? renderers.renderTool(segment.part) : /*#__PURE__*/_jsx(Tool, {
50
+ part: segment.part
51
+ });
52
+ case "sources":
53
+ return renderers.renderSources ? renderers.renderSources(segment.parts) : /*#__PURE__*/_jsx(Sources, {
54
+ sources: segment.parts
55
+ });
56
+ case "files":
57
+ return /*#__PURE__*/_jsx(Files, {
58
+ items: segment.parts.map(fileFromFilePart),
59
+ className: cn(isUser && "justify-end")
60
+ });
61
+ }
40
62
  }
41
- export function Turn({ message, avatar, footer, renderReasoning, renderTool, renderSources, className, ...props }) {
42
- const isUser = message.role === "user";
43
- const renderers = { renderReasoning, renderTool, renderSources };
44
- return (_jsxs(MessageRow, { "data-role": message.role, align: isUser ? "end" : "start", "aria-label": roleLabels[message.role], role: "article", className: cn("gap-3 data-[role=system]:text-muted-foreground", className), ...props, children: [avatar && (_jsx(MessageAvatar, { className: "mt-0.5 self-start group-has-data-[slot=message-footer]/message:translate-y-0", children: avatar })), _jsxs(MessageContent, { className: cn("gap-4", isUser && "items-end gap-2"), children: [groupParts(message.parts).map((segment) => (_jsx("div", { "data-slot": "message-part", "data-kind": segment.kind, className: cn("flex min-w-0 flex-col", partClassName(message.role, segment.kind)), children: renderSegment(segment, isUser, renderers) }, segment.key))), footer && _jsx(MessageFooter, { className: "px-0", children: footer })] })] }));
63
+ export function Turn({
64
+ message,
65
+ avatar,
66
+ footer,
67
+ renderReasoning,
68
+ renderTool,
69
+ renderSources,
70
+ className,
71
+ ...props
72
+ }) {
73
+ const isUser = message.role === "user";
74
+ const renderers = {
75
+ renderReasoning,
76
+ renderTool,
77
+ renderSources
78
+ };
79
+ return /*#__PURE__*/_jsxs(MessageRow, {
80
+ "data-role": message.role,
81
+ align: isUser ? "end" : "start",
82
+ "aria-label": roleLabels[message.role],
83
+ role: "article",
84
+ className: cn("gap-3 data-[role=system]:text-muted-foreground", className),
85
+ ...props,
86
+ children: [avatar && /*#__PURE__*/_jsx(MessageAvatar, {
87
+ className: "mt-0.5 self-start group-has-data-[slot=message-footer]/message:translate-y-0",
88
+ children: avatar
89
+ }), /*#__PURE__*/_jsxs(MessageContent, {
90
+ className: cn("gap-4", isUser && "items-end gap-2"),
91
+ children: [groupParts(message.parts).map(segment => /*#__PURE__*/_jsx("div", {
92
+ "data-slot": "message-part",
93
+ "data-kind": segment.kind,
94
+ className: cn("flex min-w-0 flex-col", partClassName(message.role, segment.kind)),
95
+ children: renderSegment(segment, isUser, renderers)
96
+ }, segment.key)), footer && /*#__PURE__*/_jsx(MessageFooter, {
97
+ className: "px-0",
98
+ children: footer
99
+ })]
100
+ })]
101
+ });
45
102
  }