@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,116 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { cn } from "@locusgraph/components";
|
|
3
|
+
import { memo } from "react";
|
|
4
|
+
import ReactMarkdown from "react-markdown";
|
|
5
|
+
import remarkGfm from "remark-gfm";
|
|
6
|
+
import { markdownComponents } from "./markdown-components.js";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
const codeFence = /^ {0,3}(```|~~~)/gm;
|
|
9
|
+
export function closeOpenCodeFence(markdown) {
|
|
10
|
+
const fences = markdown.match(codeFence) ?? [];
|
|
11
|
+
const lastFence = fences.at(-1)?.trim().slice(0, 3);
|
|
12
|
+
return fences.length % 2 === 1 ? `${markdown}\n${lastFence}` : markdown;
|
|
13
|
+
}
|
|
14
|
+
const Markdown = memo(function Markdown(t0) {
|
|
15
|
+
const $ = _c(3);
|
|
16
|
+
const {
|
|
17
|
+
markdown
|
|
18
|
+
} = t0;
|
|
19
|
+
let t1;
|
|
20
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
21
|
+
t1 = [remarkGfm];
|
|
22
|
+
$[0] = t1;
|
|
23
|
+
} else {
|
|
24
|
+
t1 = $[0];
|
|
25
|
+
}
|
|
26
|
+
let t2;
|
|
27
|
+
if ($[1] !== markdown) {
|
|
28
|
+
t2 = /*#__PURE__*/_jsx(ReactMarkdown, {
|
|
29
|
+
remarkPlugins: t1,
|
|
30
|
+
components: markdownComponents,
|
|
31
|
+
children: markdown
|
|
32
|
+
});
|
|
33
|
+
$[1] = markdown;
|
|
34
|
+
$[2] = t2;
|
|
35
|
+
} else {
|
|
36
|
+
t2 = $[2];
|
|
37
|
+
}
|
|
38
|
+
return t2;
|
|
39
|
+
});
|
|
40
|
+
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";
|
|
41
|
+
export function Reply(t0) {
|
|
42
|
+
const $ = _c(18);
|
|
43
|
+
let children;
|
|
44
|
+
let className;
|
|
45
|
+
let props;
|
|
46
|
+
let t1;
|
|
47
|
+
if ($[0] !== t0) {
|
|
48
|
+
({
|
|
49
|
+
children,
|
|
50
|
+
state: t1,
|
|
51
|
+
className,
|
|
52
|
+
...props
|
|
53
|
+
} = t0);
|
|
54
|
+
$[0] = t0;
|
|
55
|
+
$[1] = children;
|
|
56
|
+
$[2] = className;
|
|
57
|
+
$[3] = props;
|
|
58
|
+
$[4] = t1;
|
|
59
|
+
} else {
|
|
60
|
+
children = $[1];
|
|
61
|
+
className = $[2];
|
|
62
|
+
props = $[3];
|
|
63
|
+
t1 = $[4];
|
|
64
|
+
}
|
|
65
|
+
const state = t1 === undefined ? "done" : t1;
|
|
66
|
+
const isStreaming = state === "streaming";
|
|
67
|
+
let t2;
|
|
68
|
+
if ($[5] !== children || $[6] !== isStreaming) {
|
|
69
|
+
t2 = isStreaming ? closeOpenCodeFence(children) : children;
|
|
70
|
+
$[5] = children;
|
|
71
|
+
$[6] = isStreaming;
|
|
72
|
+
$[7] = t2;
|
|
73
|
+
} else {
|
|
74
|
+
t2 = $[7];
|
|
75
|
+
}
|
|
76
|
+
const markdown = t2;
|
|
77
|
+
const t3 = isStreaming ? "polite" : undefined;
|
|
78
|
+
let t4;
|
|
79
|
+
if ($[8] !== className) {
|
|
80
|
+
t4 = cn("min-w-0 text-sm leading-relaxed wrap-break-word text-foreground", streamingCaret, className);
|
|
81
|
+
$[8] = className;
|
|
82
|
+
$[9] = t4;
|
|
83
|
+
} else {
|
|
84
|
+
t4 = $[9];
|
|
85
|
+
}
|
|
86
|
+
let t5;
|
|
87
|
+
if ($[10] !== markdown) {
|
|
88
|
+
t5 = /*#__PURE__*/_jsx(Markdown, {
|
|
89
|
+
markdown: markdown
|
|
90
|
+
});
|
|
91
|
+
$[10] = markdown;
|
|
92
|
+
$[11] = t5;
|
|
93
|
+
} else {
|
|
94
|
+
t5 = $[11];
|
|
95
|
+
}
|
|
96
|
+
let t6;
|
|
97
|
+
if ($[12] !== props || $[13] !== state || $[14] !== t3 || $[15] !== t4 || $[16] !== t5) {
|
|
98
|
+
t6 = /*#__PURE__*/_jsx("div", {
|
|
99
|
+
"data-slot": "reply",
|
|
100
|
+
"data-state": state,
|
|
101
|
+
"aria-live": t3,
|
|
102
|
+
className: t4,
|
|
103
|
+
...props,
|
|
104
|
+
children: t5
|
|
105
|
+
});
|
|
106
|
+
$[12] = props;
|
|
107
|
+
$[13] = state;
|
|
108
|
+
$[14] = t3;
|
|
109
|
+
$[15] = t4;
|
|
110
|
+
$[16] = t5;
|
|
111
|
+
$[17] = t6;
|
|
112
|
+
} else {
|
|
113
|
+
t6 = $[17];
|
|
114
|
+
}
|
|
115
|
+
return t6;
|
|
116
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FilePart, MessagePart, ReasoningPart, SourceUrlPart, TextPart, ToolPart } from "../../types.js";
|
|
2
|
+
export type PartSegment = {
|
|
3
|
+
kind: "text";
|
|
4
|
+
key: string;
|
|
5
|
+
part: TextPart;
|
|
6
|
+
} | {
|
|
7
|
+
kind: "reasoning";
|
|
8
|
+
key: string;
|
|
9
|
+
part: ReasoningPart;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "tool";
|
|
12
|
+
key: string;
|
|
13
|
+
part: ToolPart;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "files";
|
|
16
|
+
key: string;
|
|
17
|
+
parts: FilePart[];
|
|
18
|
+
} | {
|
|
19
|
+
kind: "sources";
|
|
20
|
+
key: string;
|
|
21
|
+
parts: SourceUrlPart[];
|
|
22
|
+
};
|
|
23
|
+
export declare function isToolPart(part: MessagePart): part is ToolPart;
|
|
24
|
+
export declare function groupParts(parts: MessagePart[]): PartSegment[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export function isToolPart(part) {
|
|
2
|
+
return part.type === "dynamic-tool" || part.type.startsWith("tool-");
|
|
3
|
+
}
|
|
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,
|
|
12
|
+
key,
|
|
13
|
+
parts: [part]
|
|
14
|
+
} : {
|
|
15
|
+
kind,
|
|
16
|
+
key,
|
|
17
|
+
parts: [part]
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export function groupParts(parts) {
|
|
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;
|
|
49
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type { AgentMessage, ReasoningPart, SourceUrlPart, ToolPart } from "../../types.js";
|
|
3
|
+
export type TurnProps = Omit<React.ComponentProps<"div">, "children"> & {
|
|
4
|
+
message: AgentMessage;
|
|
5
|
+
avatar?: React.ReactNode;
|
|
6
|
+
footer?: React.ReactNode;
|
|
7
|
+
renderReasoning?: (part: ReasoningPart) => React.ReactNode;
|
|
8
|
+
renderTool?: (part: ToolPart) => React.ReactNode;
|
|
9
|
+
renderSources?: (parts: SourceUrlPart[]) => React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
export declare function Turn({ message, avatar, footer, renderReasoning, renderTool, renderSources, className, ...props }: TurnProps): React.JSX.Element;
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { cn, MessageAvatar, MessageContent, MessageFooter, Message as MessageRow } from "@locusgraph/components";
|
|
3
|
+
import { Thinking } from "../../agent/thinking/thinking.js";
|
|
4
|
+
import { Tool } from "../../agent/tool/tool.js";
|
|
5
|
+
import { Sources } from "../../memory/sources.js";
|
|
6
|
+
import { fileFromFilePart } from "../files/file-meta.js";
|
|
7
|
+
import { Files } from "../files/files.js";
|
|
8
|
+
import { Reply } from "../reply/reply.js";
|
|
9
|
+
import { groupParts } from "./group-parts.js";
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
const roleLabels = {
|
|
12
|
+
user: "You said",
|
|
13
|
+
assistant: "Assistant said",
|
|
14
|
+
system: "System note"
|
|
15
|
+
};
|
|
16
|
+
function UserText(t0) {
|
|
17
|
+
const $ = _c(2);
|
|
18
|
+
const {
|
|
19
|
+
part
|
|
20
|
+
} = t0;
|
|
21
|
+
let t1;
|
|
22
|
+
if ($[0] !== part.text) {
|
|
23
|
+
t1 = /*#__PURE__*/_jsx("div", {
|
|
24
|
+
"data-slot": "message-user-text",
|
|
25
|
+
className: "max-w-[85%] bg-muted px-3.5 py-2 text-sm leading-relaxed whitespace-pre-wrap wrap-break-word text-foreground",
|
|
26
|
+
children: part.text
|
|
27
|
+
});
|
|
28
|
+
$[0] = part.text;
|
|
29
|
+
$[1] = t1;
|
|
30
|
+
} else {
|
|
31
|
+
t1 = $[1];
|
|
32
|
+
}
|
|
33
|
+
return t1;
|
|
34
|
+
}
|
|
35
|
+
function partClassName(role, kind) {
|
|
36
|
+
if (role === "user") {
|
|
37
|
+
return "w-full items-end";
|
|
38
|
+
}
|
|
39
|
+
if (role === "system") {
|
|
40
|
+
return "border-l-2 border-border pl-3 *:data-[slot=reply]:text-xs *:data-[slot=reply]:text-muted-foreground";
|
|
41
|
+
}
|
|
42
|
+
return cn(kind === "text" && "*:data-[slot=reply]:max-w-[68ch]");
|
|
43
|
+
}
|
|
44
|
+
function renderSegment(segment, isUser, renderers) {
|
|
45
|
+
switch (segment.kind) {
|
|
46
|
+
case "text":
|
|
47
|
+
return isUser ? /*#__PURE__*/_jsx(UserText, {
|
|
48
|
+
part: segment.part
|
|
49
|
+
}) : /*#__PURE__*/_jsx(Reply, {
|
|
50
|
+
state: segment.part.state,
|
|
51
|
+
children: segment.part.text
|
|
52
|
+
});
|
|
53
|
+
case "reasoning":
|
|
54
|
+
return renderers.renderReasoning ? renderers.renderReasoning(segment.part) : /*#__PURE__*/_jsx(Thinking, {
|
|
55
|
+
text: segment.part.text,
|
|
56
|
+
state: segment.part.state,
|
|
57
|
+
durationMs: segment.part.durationMs
|
|
58
|
+
});
|
|
59
|
+
case "tool":
|
|
60
|
+
return renderers.renderTool ? renderers.renderTool(segment.part) : /*#__PURE__*/_jsx(Tool, {
|
|
61
|
+
part: segment.part
|
|
62
|
+
});
|
|
63
|
+
case "sources":
|
|
64
|
+
return renderers.renderSources ? renderers.renderSources(segment.parts) : /*#__PURE__*/_jsx(Sources, {
|
|
65
|
+
sources: segment.parts
|
|
66
|
+
});
|
|
67
|
+
case "files":
|
|
68
|
+
return /*#__PURE__*/_jsx(Files, {
|
|
69
|
+
items: segment.parts.map(fileFromFilePart),
|
|
70
|
+
className: cn(isUser && "justify-end")
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function Turn(t0) {
|
|
75
|
+
const $ = _c(52);
|
|
76
|
+
let avatar;
|
|
77
|
+
let className;
|
|
78
|
+
let footer;
|
|
79
|
+
let message;
|
|
80
|
+
let props;
|
|
81
|
+
let renderReasoning;
|
|
82
|
+
let renderSources;
|
|
83
|
+
let renderTool;
|
|
84
|
+
if ($[0] !== t0) {
|
|
85
|
+
({
|
|
86
|
+
message,
|
|
87
|
+
avatar,
|
|
88
|
+
footer,
|
|
89
|
+
renderReasoning,
|
|
90
|
+
renderTool,
|
|
91
|
+
renderSources,
|
|
92
|
+
className,
|
|
93
|
+
...props
|
|
94
|
+
} = t0);
|
|
95
|
+
$[0] = t0;
|
|
96
|
+
$[1] = avatar;
|
|
97
|
+
$[2] = className;
|
|
98
|
+
$[3] = footer;
|
|
99
|
+
$[4] = message;
|
|
100
|
+
$[5] = props;
|
|
101
|
+
$[6] = renderReasoning;
|
|
102
|
+
$[7] = renderSources;
|
|
103
|
+
$[8] = renderTool;
|
|
104
|
+
} else {
|
|
105
|
+
avatar = $[1];
|
|
106
|
+
className = $[2];
|
|
107
|
+
footer = $[3];
|
|
108
|
+
message = $[4];
|
|
109
|
+
props = $[5];
|
|
110
|
+
renderReasoning = $[6];
|
|
111
|
+
renderSources = $[7];
|
|
112
|
+
renderTool = $[8];
|
|
113
|
+
}
|
|
114
|
+
const isUser = message.role === "user";
|
|
115
|
+
let T0;
|
|
116
|
+
let T1;
|
|
117
|
+
let t1;
|
|
118
|
+
let t2;
|
|
119
|
+
let t3;
|
|
120
|
+
let t4;
|
|
121
|
+
let t5;
|
|
122
|
+
let t6;
|
|
123
|
+
let t7;
|
|
124
|
+
let t8;
|
|
125
|
+
let t9;
|
|
126
|
+
if ($[9] !== avatar || $[10] !== className || $[11] !== isUser || $[12] !== message.parts || $[13] !== message.role || $[14] !== props || $[15] !== renderReasoning || $[16] !== renderSources || $[17] !== renderTool) {
|
|
127
|
+
const renderers = {
|
|
128
|
+
renderReasoning,
|
|
129
|
+
renderTool,
|
|
130
|
+
renderSources
|
|
131
|
+
};
|
|
132
|
+
T1 = MessageRow;
|
|
133
|
+
t3 = message.role;
|
|
134
|
+
t4 = isUser ? "end" : "start";
|
|
135
|
+
t5 = roleLabels[message.role];
|
|
136
|
+
t6 = "article";
|
|
137
|
+
if ($[29] !== className) {
|
|
138
|
+
t7 = cn("gap-3 data-[role=system]:text-muted-foreground", className);
|
|
139
|
+
$[29] = className;
|
|
140
|
+
$[30] = t7;
|
|
141
|
+
} else {
|
|
142
|
+
t7 = $[30];
|
|
143
|
+
}
|
|
144
|
+
t8 = props;
|
|
145
|
+
if ($[31] !== avatar) {
|
|
146
|
+
t9 = avatar && /*#__PURE__*/_jsx(MessageAvatar, {
|
|
147
|
+
className: "mt-0.5 self-start group-has-data-[slot=message-footer]/message:translate-y-0",
|
|
148
|
+
children: avatar
|
|
149
|
+
});
|
|
150
|
+
$[31] = avatar;
|
|
151
|
+
$[32] = t9;
|
|
152
|
+
} else {
|
|
153
|
+
t9 = $[32];
|
|
154
|
+
}
|
|
155
|
+
T0 = MessageContent;
|
|
156
|
+
const t10 = isUser && "items-end gap-2";
|
|
157
|
+
if ($[33] !== t10) {
|
|
158
|
+
t1 = cn("gap-4", t10);
|
|
159
|
+
$[33] = t10;
|
|
160
|
+
$[34] = t1;
|
|
161
|
+
} else {
|
|
162
|
+
t1 = $[34];
|
|
163
|
+
}
|
|
164
|
+
t2 = groupParts(message.parts).map(segment => /*#__PURE__*/_jsx("div", {
|
|
165
|
+
"data-slot": "message-part",
|
|
166
|
+
"data-kind": segment.kind,
|
|
167
|
+
className: cn("flex min-w-0 flex-col", partClassName(message.role, segment.kind)),
|
|
168
|
+
children: renderSegment(segment, isUser, renderers)
|
|
169
|
+
}, segment.key));
|
|
170
|
+
$[9] = avatar;
|
|
171
|
+
$[10] = className;
|
|
172
|
+
$[11] = isUser;
|
|
173
|
+
$[12] = message.parts;
|
|
174
|
+
$[13] = message.role;
|
|
175
|
+
$[14] = props;
|
|
176
|
+
$[15] = renderReasoning;
|
|
177
|
+
$[16] = renderSources;
|
|
178
|
+
$[17] = renderTool;
|
|
179
|
+
$[18] = T0;
|
|
180
|
+
$[19] = T1;
|
|
181
|
+
$[20] = t1;
|
|
182
|
+
$[21] = t2;
|
|
183
|
+
$[22] = t3;
|
|
184
|
+
$[23] = t4;
|
|
185
|
+
$[24] = t5;
|
|
186
|
+
$[25] = t6;
|
|
187
|
+
$[26] = t7;
|
|
188
|
+
$[27] = t8;
|
|
189
|
+
$[28] = t9;
|
|
190
|
+
} else {
|
|
191
|
+
T0 = $[18];
|
|
192
|
+
T1 = $[19];
|
|
193
|
+
t1 = $[20];
|
|
194
|
+
t2 = $[21];
|
|
195
|
+
t3 = $[22];
|
|
196
|
+
t4 = $[23];
|
|
197
|
+
t5 = $[24];
|
|
198
|
+
t6 = $[25];
|
|
199
|
+
t7 = $[26];
|
|
200
|
+
t8 = $[27];
|
|
201
|
+
t9 = $[28];
|
|
202
|
+
}
|
|
203
|
+
let t10;
|
|
204
|
+
if ($[35] !== footer) {
|
|
205
|
+
t10 = footer && /*#__PURE__*/_jsx(MessageFooter, {
|
|
206
|
+
className: "px-0",
|
|
207
|
+
children: footer
|
|
208
|
+
});
|
|
209
|
+
$[35] = footer;
|
|
210
|
+
$[36] = t10;
|
|
211
|
+
} else {
|
|
212
|
+
t10 = $[36];
|
|
213
|
+
}
|
|
214
|
+
let t11;
|
|
215
|
+
if ($[37] !== T0 || $[38] !== t1 || $[39] !== t10 || $[40] !== t2) {
|
|
216
|
+
t11 = /*#__PURE__*/_jsxs(T0, {
|
|
217
|
+
className: t1,
|
|
218
|
+
children: [t2, t10]
|
|
219
|
+
});
|
|
220
|
+
$[37] = T0;
|
|
221
|
+
$[38] = t1;
|
|
222
|
+
$[39] = t10;
|
|
223
|
+
$[40] = t2;
|
|
224
|
+
$[41] = t11;
|
|
225
|
+
} else {
|
|
226
|
+
t11 = $[41];
|
|
227
|
+
}
|
|
228
|
+
let t12;
|
|
229
|
+
if ($[42] !== T1 || $[43] !== t11 || $[44] !== t3 || $[45] !== t4 || $[46] !== t5 || $[47] !== t6 || $[48] !== t7 || $[49] !== t8 || $[50] !== t9) {
|
|
230
|
+
t12 = /*#__PURE__*/_jsxs(T1, {
|
|
231
|
+
"data-role": t3,
|
|
232
|
+
align: t4,
|
|
233
|
+
"aria-label": t5,
|
|
234
|
+
role: t6,
|
|
235
|
+
className: t7,
|
|
236
|
+
...t8,
|
|
237
|
+
children: [t9, t11]
|
|
238
|
+
});
|
|
239
|
+
$[42] = T1;
|
|
240
|
+
$[43] = t11;
|
|
241
|
+
$[44] = t3;
|
|
242
|
+
$[45] = t4;
|
|
243
|
+
$[46] = t5;
|
|
244
|
+
$[47] = t6;
|
|
245
|
+
$[48] = t7;
|
|
246
|
+
$[49] = t8;
|
|
247
|
+
$[50] = t9;
|
|
248
|
+
$[51] = t12;
|
|
249
|
+
} else {
|
|
250
|
+
t12 = $[51];
|
|
251
|
+
}
|
|
252
|
+
return t12;
|
|
253
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ContextSegment } from "./shared/context-breakdown.js";
|
|
2
|
+
export type { ContextSegment } from "./shared/context-breakdown.js";
|
|
3
|
+
export type ContextStatus = "ok" | "near" | "full";
|
|
4
|
+
export type ContextProps = {
|
|
5
|
+
usedTokens: number;
|
|
6
|
+
limitTokens: number;
|
|
7
|
+
breakdown?: ContextSegment[];
|
|
8
|
+
variant?: "bar" | "ring";
|
|
9
|
+
label?: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function contextStatus(usedTokens: number, limitTokens: number): ContextStatus;
|
|
13
|
+
export declare function Context({ usedTokens, limitTokens, breakdown, variant, label, className, }: ContextProps): import("react").JSX.Element;
|