@xemahq/ui-kernel 0.1.6 → 0.1.7
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/dist/lib/biome-host/create-biome-orval-config.d.ts +14 -0
- package/dist/lib/biome-host/create-biome-orval-config.d.ts.map +1 -0
- package/dist/lib/biome-host/create-biome-orval-config.js +22 -0
- package/dist/lib/biome-host/create-biome-orval-config.js.map +1 -0
- package/dist/lib/biome-host/host-bridge.d.ts +2 -0
- package/dist/lib/biome-host/host-bridge.d.ts.map +1 -1
- package/dist/lib/biome-host/host-bridge.js.map +1 -1
- package/dist/lib/biome-host/host-sources.d.ts +2 -0
- package/dist/lib/biome-host/host-sources.d.ts.map +1 -1
- package/dist/lib/biome-host/index.d.ts +1 -0
- package/dist/lib/biome-host/index.d.ts.map +1 -1
- package/dist/lib/biome-host/index.js +1 -0
- package/dist/lib/biome-host/index.js.map +1 -1
- package/dist/session-kit/approvals/ApprovalButton.d.ts +14 -0
- package/dist/session-kit/approvals/ApprovalButton.d.ts.map +1 -0
- package/dist/session-kit/approvals/ApprovalButton.js +45 -0
- package/dist/session-kit/approvals/ApprovalButton.js.map +1 -0
- package/dist/session-kit/approvals/ApprovalCard.d.ts +12 -0
- package/dist/session-kit/approvals/ApprovalCard.d.ts.map +1 -0
- package/dist/session-kit/approvals/ApprovalCard.js +117 -0
- package/dist/session-kit/approvals/ApprovalCard.js.map +1 -0
- package/dist/session-kit/approvals/ApprovalsCenter.d.ts +11 -0
- package/dist/session-kit/approvals/ApprovalsCenter.d.ts.map +1 -0
- package/dist/session-kit/approvals/ApprovalsCenter.js +127 -0
- package/dist/session-kit/approvals/ApprovalsCenter.js.map +1 -0
- package/dist/session-kit/approvals/CapabilityApprovalStickyBar.d.ts +12 -0
- package/dist/session-kit/approvals/CapabilityApprovalStickyBar.d.ts.map +1 -0
- package/dist/session-kit/approvals/CapabilityApprovalStickyBar.js +36 -0
- package/dist/session-kit/approvals/CapabilityApprovalStickyBar.js.map +1 -0
- package/dist/session-kit/approvals/Obligation.d.ts +15 -0
- package/dist/session-kit/approvals/Obligation.d.ts.map +1 -0
- package/dist/session-kit/approvals/Obligation.js +42 -0
- package/dist/session-kit/approvals/Obligation.js.map +1 -0
- package/dist/session-kit/approvals/ScopedBody.d.ts +9 -0
- package/dist/session-kit/approvals/ScopedBody.d.ts.map +1 -0
- package/dist/session-kit/approvals/ScopedBody.js +145 -0
- package/dist/session-kit/approvals/ScopedBody.js.map +1 -0
- package/dist/session-kit/approvals/approval-icons.d.ts +15 -0
- package/dist/session-kit/approvals/approval-icons.d.ts.map +1 -0
- package/dist/session-kit/approvals/approval-icons.js +3 -0
- package/dist/session-kit/approvals/approval-icons.js.map +1 -0
- package/dist/session-kit/approvals/approval-model.d.ts +83 -0
- package/dist/session-kit/approvals/approval-model.d.ts.map +1 -0
- package/dist/session-kit/approvals/approval-model.js +25 -0
- package/dist/session-kit/approvals/approval-model.js.map +1 -0
- package/dist/session-kit/approvals/index.d.ts +12 -0
- package/dist/session-kit/approvals/index.d.ts.map +1 -0
- package/dist/session-kit/approvals/index.js +28 -0
- package/dist/session-kit/approvals/index.js.map +1 -0
- package/dist/session-kit/approvals/obligation-display.d.ts +17 -0
- package/dist/session-kit/approvals/obligation-display.d.ts.map +1 -0
- package/dist/session-kit/approvals/obligation-display.js +58 -0
- package/dist/session-kit/approvals/obligation-display.js.map +1 -0
- package/dist/session-kit/approvals/risk-accent.d.ts +8 -0
- package/dist/session-kit/approvals/risk-accent.d.ts.map +1 -0
- package/dist/session-kit/approvals/risk-accent.js +28 -0
- package/dist/session-kit/approvals/risk-accent.js.map +1 -0
- package/dist/session-kit/approvals/scope-icons.d.ts +12 -0
- package/dist/session-kit/approvals/scope-icons.d.ts.map +1 -0
- package/dist/session-kit/approvals/scope-icons.js +14 -0
- package/dist/session-kit/approvals/scope-icons.js.map +1 -0
- package/dist/session-kit/combobox/Combobox.d.ts +46 -0
- package/dist/session-kit/combobox/Combobox.d.ts.map +1 -0
- package/dist/session-kit/combobox/Combobox.js +113 -0
- package/dist/session-kit/combobox/Combobox.js.map +1 -0
- package/dist/session-kit/combobox/use-click-outside.d.ts +3 -0
- package/dist/session-kit/combobox/use-click-outside.d.ts.map +1 -0
- package/dist/session-kit/combobox/use-click-outside.js +18 -0
- package/dist/session-kit/combobox/use-click-outside.js.map +1 -0
- package/dist/session-kit/display/ContextHeader.d.ts +27 -0
- package/dist/session-kit/display/ContextHeader.d.ts.map +1 -0
- package/dist/session-kit/display/ContextHeader.js +47 -0
- package/dist/session-kit/display/ContextHeader.js.map +1 -0
- package/dist/session-kit/display/FileDiffCard.d.ts +18 -0
- package/dist/session-kit/display/FileDiffCard.d.ts.map +1 -0
- package/dist/session-kit/display/FileDiffCard.js +58 -0
- package/dist/session-kit/display/FileDiffCard.js.map +1 -0
- package/dist/session-kit/display/MD.d.ts +7 -0
- package/dist/session-kit/display/MD.d.ts.map +1 -0
- package/dist/session-kit/display/MD.js +89 -0
- package/dist/session-kit/display/MD.js.map +1 -0
- package/dist/session-kit/display/MessageTurn.d.ts +21 -0
- package/dist/session-kit/display/MessageTurn.d.ts.map +1 -0
- package/dist/session-kit/display/MessageTurn.js +62 -0
- package/dist/session-kit/display/MessageTurn.js.map +1 -0
- package/dist/session-kit/display/ThinkingPanel.d.ts +12 -0
- package/dist/session-kit/display/ThinkingPanel.d.ts.map +1 -0
- package/dist/session-kit/display/ThinkingPanel.js +30 -0
- package/dist/session-kit/display/ThinkingPanel.js.map +1 -0
- package/dist/session-kit/display/TodoChecklist.d.ts +17 -0
- package/dist/session-kit/display/TodoChecklist.d.ts.map +1 -0
- package/dist/session-kit/display/TodoChecklist.js +50 -0
- package/dist/session-kit/display/TodoChecklist.js.map +1 -0
- package/dist/session-kit/display/TokenMeter.d.ts +15 -0
- package/dist/session-kit/display/TokenMeter.d.ts.map +1 -0
- package/dist/session-kit/display/TokenMeter.js +35 -0
- package/dist/session-kit/display/TokenMeter.js.map +1 -0
- package/dist/session-kit/display/ToolStrip.d.ts +31 -0
- package/dist/session-kit/display/ToolStrip.d.ts.map +1 -0
- package/dist/session-kit/display/ToolStrip.js +99 -0
- package/dist/session-kit/display/ToolStrip.js.map +1 -0
- package/dist/session-kit/display/TypingDots.d.ts +3 -0
- package/dist/session-kit/display/TypingDots.d.ts.map +1 -0
- package/dist/session-kit/display/TypingDots.js +14 -0
- package/dist/session-kit/display/TypingDots.js.map +1 -0
- package/dist/session-kit/index.d.ts +21 -0
- package/dist/session-kit/index.d.ts.map +1 -0
- package/dist/session-kit/index.js +37 -0
- package/dist/session-kit/index.js.map +1 -0
- package/dist/session-kit/lib/enums.d.ts +34 -0
- package/dist/session-kit/lib/enums.d.ts.map +1 -0
- package/dist/session-kit/lib/enums.js +44 -0
- package/dist/session-kit/lib/enums.js.map +1 -0
- package/dist/session-kit/lib/portal-accent.d.ts +3 -0
- package/dist/session-kit/lib/portal-accent.d.ts.map +1 -0
- package/dist/session-kit/lib/portal-accent.js +9 -0
- package/dist/session-kit/lib/portal-accent.js.map +1 -0
- package/dist/session-kit/lib/status-dot.d.ts +10 -0
- package/dist/session-kit/lib/status-dot.d.ts.map +1 -0
- package/dist/session-kit/lib/status-dot.js +43 -0
- package/dist/session-kit/lib/status-dot.js.map +1 -0
- package/dist/session-kit/primitives/Avatar.d.ts +10 -0
- package/dist/session-kit/primitives/Avatar.d.ts.map +1 -0
- package/dist/session-kit/primitives/Avatar.js +21 -0
- package/dist/session-kit/primitives/Avatar.js.map +1 -0
- package/dist/session-kit/primitives/PortalGlyph.d.ts +12 -0
- package/dist/session-kit/primitives/PortalGlyph.d.ts.map +1 -0
- package/dist/session-kit/primitives/PortalGlyph.js +21 -0
- package/dist/session-kit/primitives/PortalGlyph.js.map +1 -0
- package/dist/session-kit/primitives/RiskPill.d.ts +12 -0
- package/dist/session-kit/primitives/RiskPill.d.ts.map +1 -0
- package/dist/session-kit/primitives/RiskPill.js +53 -0
- package/dist/session-kit/primitives/RiskPill.js.map +1 -0
- package/dist/session-kit/primitives/ScopeDot.d.ts +9 -0
- package/dist/session-kit/primitives/ScopeDot.d.ts.map +1 -0
- package/dist/session-kit/primitives/ScopeDot.js +23 -0
- package/dist/session-kit/primitives/ScopeDot.js.map +1 -0
- package/dist/session-kit/primitives/Segmented.d.ts +16 -0
- package/dist/session-kit/primitives/Segmented.d.ts.map +1 -0
- package/dist/session-kit/primitives/Segmented.js +31 -0
- package/dist/session-kit/primitives/Segmented.js.map +1 -0
- package/package.json +2 -2
- package/src/lib/biome-host/create-biome-orval-config.ts +76 -0
- package/src/lib/biome-host/host-bridge.ts +22 -0
- package/src/lib/biome-host/host-sources.ts +13 -0
- package/src/lib/biome-host/index.ts +1 -0
- package/src/session-kit/approvals/ApprovalButton.tsx +89 -0
- package/src/session-kit/approvals/ApprovalCard.tsx +336 -0
- package/src/session-kit/approvals/ApprovalsCenter.tsx +327 -0
- package/src/session-kit/approvals/CapabilityApprovalStickyBar.tsx +118 -0
- package/src/session-kit/approvals/Obligation.tsx +111 -0
- package/src/session-kit/approvals/ScopedBody.tsx +392 -0
- package/src/session-kit/approvals/approval-icons.ts +31 -0
- package/src/session-kit/approvals/approval-model.ts +205 -0
- package/src/session-kit/approvals/index.ts +22 -0
- package/src/session-kit/approvals/obligation-display.ts +100 -0
- package/src/session-kit/approvals/risk-accent.ts +47 -0
- package/src/session-kit/approvals/scope-icons.ts +19 -0
- package/src/session-kit/combobox/Combobox.tsx +327 -0
- package/src/session-kit/combobox/use-click-outside.ts +21 -0
- package/src/session-kit/display/ContextHeader.tsx +148 -0
- package/src/session-kit/display/FileDiffCard.tsx +140 -0
- package/src/session-kit/display/MD.tsx +153 -0
- package/src/session-kit/display/MessageTurn.tsx +157 -0
- package/src/session-kit/display/ThinkingPanel.tsx +78 -0
- package/src/session-kit/display/TodoChecklist.tsx +120 -0
- package/src/session-kit/display/TokenMeter.tsx +89 -0
- package/src/session-kit/display/ToolStrip.tsx +278 -0
- package/src/session-kit/display/TypingDots.tsx +24 -0
- package/src/session-kit/index.ts +44 -0
- package/src/session-kit/lib/enums.ts +66 -0
- package/src/session-kit/lib/portal-accent.ts +30 -0
- package/src/session-kit/lib/status-dot.ts +68 -0
- package/src/session-kit/primitives/Avatar.tsx +44 -0
- package/src/session-kit/primitives/PortalGlyph.tsx +51 -0
- package/src/session-kit/primitives/RiskPill.tsx +95 -0
- package/src/session-kit/primitives/ScopeDot.tsx +47 -0
- package/src/session-kit/primitives/Segmented.tsx +71 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal, dependency-free markdown renderer for transcript bodies
|
|
3
|
+
* (bold, inline code, fenced blocks, bullet lists). The host shell has
|
|
4
|
+
* a full `MarkdownRenderer` (ReactMarkdown + mermaid + syntax
|
|
5
|
+
* highlighting), but that renderer imports framework modules
|
|
6
|
+
* (`next/navigation`, …) and cannot live in this layer-agnostic kernel
|
|
7
|
+
* package.
|
|
8
|
+
*
|
|
9
|
+
* So the kit ships this tiny fallback AND every body-rendering component
|
|
10
|
+
* accepts a `renderMarkdown` prop — the host injects its own renderer
|
|
11
|
+
* for rich content, the kit falls back to `MD` when none is supplied.
|
|
12
|
+
*
|
|
13
|
+
* Inline formatting is parsed into real React nodes (no
|
|
14
|
+
* `dangerouslySetInnerHTML`) so it is XSS-safe by construction.
|
|
15
|
+
*/
|
|
16
|
+
import { Fragment, type ReactElement, type ReactNode } from 'react';
|
|
17
|
+
|
|
18
|
+
/** Signature a host markdown renderer must satisfy to plug into the kit. */
|
|
19
|
+
export type MarkdownRender = (text: string) => ReactNode;
|
|
20
|
+
|
|
21
|
+
const INLINE_CODE_STYLE = {
|
|
22
|
+
fontSize: 12,
|
|
23
|
+
padding: '1px 5px',
|
|
24
|
+
background: 'hsl(var(--paper-sunk))',
|
|
25
|
+
border: '1px solid hsl(var(--rule))',
|
|
26
|
+
borderRadius: 4,
|
|
27
|
+
color: 'hsl(var(--ink))',
|
|
28
|
+
} as const;
|
|
29
|
+
|
|
30
|
+
/** Parse `**bold**` and `` `code` `` spans into React nodes. */
|
|
31
|
+
function renderInline(text: string): ReactNode[] {
|
|
32
|
+
const nodes: ReactNode[] = [];
|
|
33
|
+
// Split on bold or inline-code tokens, keeping the delimiters.
|
|
34
|
+
const parts = text.split(/(\*\*[^*]+\*\*|`[^`]+`)/g);
|
|
35
|
+
parts.forEach((part, index) => {
|
|
36
|
+
if (!part) return;
|
|
37
|
+
if (part.startsWith('**') && part.endsWith('**')) {
|
|
38
|
+
nodes.push(
|
|
39
|
+
<strong key={index} style={{ fontWeight: 600, color: 'hsl(var(--ink))' }}>
|
|
40
|
+
{part.slice(2, -2)}
|
|
41
|
+
</strong>,
|
|
42
|
+
);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (part.startsWith('`') && part.endsWith('`')) {
|
|
46
|
+
nodes.push(
|
|
47
|
+
<code key={index} className="mono" style={INLINE_CODE_STYLE}>
|
|
48
|
+
{part.slice(1, -1)}
|
|
49
|
+
</code>,
|
|
50
|
+
);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// Plain text — preserve hard line breaks.
|
|
54
|
+
const lines = part.split('\n');
|
|
55
|
+
lines.forEach((line, lineIndex) => {
|
|
56
|
+
if (lineIndex > 0) nodes.push(<br key={`${index}-br-${lineIndex}`} />);
|
|
57
|
+
if (line) nodes.push(<Fragment key={`${index}-t-${lineIndex}`}>{line}</Fragment>);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
return nodes;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface MDProps {
|
|
64
|
+
readonly children: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function MD({ children }: MDProps): ReactElement {
|
|
68
|
+
const text = String(children ?? '');
|
|
69
|
+
const blocks = text.split(/\n\n+/);
|
|
70
|
+
return (
|
|
71
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 9 }}>
|
|
72
|
+
{blocks.map((block, index) => {
|
|
73
|
+
if (block.startsWith('```')) {
|
|
74
|
+
const code = block.replace(/```[a-z]*\n?/i, '').replace(/```$/, '');
|
|
75
|
+
return (
|
|
76
|
+
<pre
|
|
77
|
+
key={index}
|
|
78
|
+
className="mono"
|
|
79
|
+
style={{
|
|
80
|
+
margin: 0,
|
|
81
|
+
padding: '11px 13px',
|
|
82
|
+
background: 'hsl(var(--paper-sunk))',
|
|
83
|
+
border: '1px solid hsl(var(--rule))',
|
|
84
|
+
borderRadius: 8,
|
|
85
|
+
fontSize: 12,
|
|
86
|
+
lineHeight: 1.6,
|
|
87
|
+
overflowX: 'auto',
|
|
88
|
+
color: 'hsl(var(--ink-2))',
|
|
89
|
+
whiteSpace: 'pre',
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
{code}
|
|
93
|
+
</pre>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
if (/^[-•]\s/m.test(block)) {
|
|
97
|
+
const items = block.split('\n').filter(Boolean);
|
|
98
|
+
return (
|
|
99
|
+
<ul
|
|
100
|
+
key={index}
|
|
101
|
+
style={{
|
|
102
|
+
margin: 0,
|
|
103
|
+
paddingLeft: 2,
|
|
104
|
+
listStyle: 'none',
|
|
105
|
+
display: 'flex',
|
|
106
|
+
flexDirection: 'column',
|
|
107
|
+
gap: 5,
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
110
|
+
{items.map((item, itemIndex) => (
|
|
111
|
+
<li
|
|
112
|
+
key={itemIndex}
|
|
113
|
+
style={{
|
|
114
|
+
display: 'flex',
|
|
115
|
+
gap: 9,
|
|
116
|
+
fontSize: 13.5,
|
|
117
|
+
lineHeight: 1.55,
|
|
118
|
+
color: 'hsl(var(--ink-2))',
|
|
119
|
+
}}
|
|
120
|
+
>
|
|
121
|
+
<span
|
|
122
|
+
style={{
|
|
123
|
+
marginTop: 8,
|
|
124
|
+
width: 4,
|
|
125
|
+
height: 4,
|
|
126
|
+
borderRadius: '50%',
|
|
127
|
+
background: 'hsl(var(--ink-4))',
|
|
128
|
+
flexShrink: 0,
|
|
129
|
+
}}
|
|
130
|
+
/>
|
|
131
|
+
<span>{renderInline(item.replace(/^[-•]\s/, ''))}</span>
|
|
132
|
+
</li>
|
|
133
|
+
))}
|
|
134
|
+
</ul>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
return (
|
|
138
|
+
<p
|
|
139
|
+
key={index}
|
|
140
|
+
style={{
|
|
141
|
+
margin: 0,
|
|
142
|
+
fontSize: 13.5,
|
|
143
|
+
lineHeight: 1.62,
|
|
144
|
+
color: 'hsl(var(--ink-2))',
|
|
145
|
+
}}
|
|
146
|
+
>
|
|
147
|
+
{renderInline(block)}
|
|
148
|
+
</p>
|
|
149
|
+
);
|
|
150
|
+
})}
|
|
151
|
+
</div>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single message turn. User turns render a right-aligned soft bubble;
|
|
3
|
+
* agent turns render a thin gutter + role caption + flowing body.
|
|
4
|
+
*
|
|
5
|
+
* The body is rendered by `renderMarkdown` when supplied (Pillar 2 wires
|
|
6
|
+
* the host's full `MarkdownRenderer` here) and falls back to the kit's
|
|
7
|
+
* built-in `MD` otherwise — so the kit is self-contained but never
|
|
8
|
+
* forces its tiny renderer on a host that has a richer one.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { MD, type MarkdownRender } from './MD';
|
|
12
|
+
import { TypingDots } from './TypingDots';
|
|
13
|
+
import { SessionSkin, TurnRole } from '../lib/enums';
|
|
14
|
+
import { portalAccent, type PortalAccentVar } from '../lib/portal-accent';
|
|
15
|
+
|
|
16
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
17
|
+
|
|
18
|
+
export interface SessionMessage {
|
|
19
|
+
readonly role: TurnRole;
|
|
20
|
+
readonly content?: string;
|
|
21
|
+
/** Agent display name (caption). */
|
|
22
|
+
readonly agent?: string;
|
|
23
|
+
/** Optional phase chip text. */
|
|
24
|
+
readonly phase?: string;
|
|
25
|
+
/** True while this turn is actively streaming. */
|
|
26
|
+
readonly streaming?: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface MessageTurnProps {
|
|
30
|
+
readonly msg: SessionMessage;
|
|
31
|
+
readonly skin?: SessionSkin;
|
|
32
|
+
/** Active portal accent token; defaults to the brand accent. */
|
|
33
|
+
readonly accentVar?: PortalAccentVar;
|
|
34
|
+
/** Host markdown renderer; falls back to the kit's `MD`. */
|
|
35
|
+
readonly renderMarkdown?: MarkdownRender;
|
|
36
|
+
/** Agent avatar glyph (host-supplied) shown in the gutter. */
|
|
37
|
+
readonly agentIcon?: ReactNode;
|
|
38
|
+
/** Inline widgets (tool strip, diff, todo, …) rendered below the body. */
|
|
39
|
+
readonly children?: ReactNode;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function MessageTurn({
|
|
43
|
+
msg,
|
|
44
|
+
skin = SessionSkin.Minimal,
|
|
45
|
+
accentVar,
|
|
46
|
+
renderMarkdown,
|
|
47
|
+
agentIcon,
|
|
48
|
+
children,
|
|
49
|
+
}: MessageTurnProps): ReactElement {
|
|
50
|
+
if (msg.role === TurnRole.User) {
|
|
51
|
+
return (
|
|
52
|
+
<div style={{ display: 'flex', justifyContent: 'flex-end', padding: '2px 0' }}>
|
|
53
|
+
<div
|
|
54
|
+
style={{
|
|
55
|
+
maxWidth: '78%',
|
|
56
|
+
padding: '9px 13px',
|
|
57
|
+
borderRadius: '12px 12px 4px 12px',
|
|
58
|
+
background: 'hsl(var(--paper-sunk))',
|
|
59
|
+
border: '1px solid hsl(var(--rule))',
|
|
60
|
+
fontSize: 13.5,
|
|
61
|
+
lineHeight: 1.55,
|
|
62
|
+
color: 'hsl(var(--ink))',
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
{msg.content}
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const accent = portalAccent(accentVar);
|
|
72
|
+
const renderBody: MarkdownRender = renderMarkdown ?? ((t) => <MD>{t}</MD>);
|
|
73
|
+
const functional = skin === SessionSkin.Functional;
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<div style={{ display: 'flex', gap: 12, padding: '2px 0' }}>
|
|
77
|
+
<div
|
|
78
|
+
style={{
|
|
79
|
+
width: 26,
|
|
80
|
+
flexShrink: 0,
|
|
81
|
+
display: 'flex',
|
|
82
|
+
flexDirection: 'column',
|
|
83
|
+
alignItems: 'center',
|
|
84
|
+
gap: 4,
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
87
|
+
<span
|
|
88
|
+
style={{
|
|
89
|
+
width: 26,
|
|
90
|
+
height: 26,
|
|
91
|
+
borderRadius: 8,
|
|
92
|
+
display: 'grid',
|
|
93
|
+
placeItems: 'center',
|
|
94
|
+
background: functional ? portalAccent(accentVar, 0.12) : 'transparent',
|
|
95
|
+
color: accent,
|
|
96
|
+
border: functional ? 'none' : '1px solid hsl(var(--rule-2))',
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
{agentIcon}
|
|
100
|
+
</span>
|
|
101
|
+
<span
|
|
102
|
+
style={{
|
|
103
|
+
flex: 1,
|
|
104
|
+
width: 1.5,
|
|
105
|
+
background: 'hsl(var(--rule))',
|
|
106
|
+
borderRadius: 1,
|
|
107
|
+
minHeight: 8,
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
</div>
|
|
111
|
+
<div style={{ flex: 1, minWidth: 0, paddingBottom: 6 }}>
|
|
112
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 7 }}>
|
|
113
|
+
<span className="cap" style={{ color: 'hsl(var(--ink-3))' }}>
|
|
114
|
+
{msg.agent ?? 'Agent'}
|
|
115
|
+
</span>
|
|
116
|
+
{msg.phase && (
|
|
117
|
+
<span
|
|
118
|
+
className="mono"
|
|
119
|
+
style={{
|
|
120
|
+
fontSize: 10,
|
|
121
|
+
color: accent,
|
|
122
|
+
padding: '1px 6px',
|
|
123
|
+
background: portalAccent(accentVar, 0.09),
|
|
124
|
+
borderRadius: 5,
|
|
125
|
+
border: `1px solid ${portalAccent(accentVar, 0.2)}`,
|
|
126
|
+
}}
|
|
127
|
+
>
|
|
128
|
+
{msg.phase}
|
|
129
|
+
</span>
|
|
130
|
+
)}
|
|
131
|
+
{msg.streaming && (
|
|
132
|
+
<span
|
|
133
|
+
style={{
|
|
134
|
+
display: 'inline-flex',
|
|
135
|
+
alignItems: 'center',
|
|
136
|
+
gap: 5,
|
|
137
|
+
fontSize: 11,
|
|
138
|
+
color: 'hsl(var(--info))',
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
<TypingDots />
|
|
142
|
+
</span>
|
|
143
|
+
)}
|
|
144
|
+
</div>
|
|
145
|
+
{msg.content && (
|
|
146
|
+
<div
|
|
147
|
+
className={msg.streaming && !children ? 'xk-caret' : ''}
|
|
148
|
+
style={{ display: 'inline' }}
|
|
149
|
+
>
|
|
150
|
+
{renderBody(msg.content)}
|
|
151
|
+
</div>
|
|
152
|
+
)}
|
|
153
|
+
{children}
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collapsible agent-reasoning panel. Dashed left border when open.
|
|
3
|
+
* The disclosure + brain icons are host-supplied.
|
|
4
|
+
*/
|
|
5
|
+
import { useState, type ReactElement, type ReactNode } from 'react';
|
|
6
|
+
|
|
7
|
+
import { SessionSkin } from '../lib/enums';
|
|
8
|
+
|
|
9
|
+
export interface ThinkingPanelProps {
|
|
10
|
+
readonly text: string;
|
|
11
|
+
readonly skin?: SessionSkin;
|
|
12
|
+
readonly defaultOpen?: boolean;
|
|
13
|
+
/** Icon shown when collapsed (e.g. a chevron-right). */
|
|
14
|
+
readonly collapsedIcon?: ReactNode;
|
|
15
|
+
/** Icon shown when expanded (e.g. a chevron-down). */
|
|
16
|
+
readonly expandedIcon?: ReactNode;
|
|
17
|
+
/** Leading "thinking" glyph (e.g. a brain). */
|
|
18
|
+
readonly leadingIcon?: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function ThinkingPanel({
|
|
22
|
+
text,
|
|
23
|
+
skin = SessionSkin.Minimal,
|
|
24
|
+
defaultOpen = false,
|
|
25
|
+
collapsedIcon,
|
|
26
|
+
expandedIcon,
|
|
27
|
+
leadingIcon,
|
|
28
|
+
}: ThinkingPanelProps): ReactElement {
|
|
29
|
+
// `skin` is accepted for API parity with the rest of the kit; the
|
|
30
|
+
// thinking panel renders identically in both skins today.
|
|
31
|
+
void skin;
|
|
32
|
+
const [open, setOpen] = useState(defaultOpen);
|
|
33
|
+
return (
|
|
34
|
+
<div style={{ marginTop: 9 }}>
|
|
35
|
+
<button
|
|
36
|
+
type="button"
|
|
37
|
+
onClick={() => setOpen((v) => !v)}
|
|
38
|
+
style={{
|
|
39
|
+
display: 'inline-flex',
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
gap: 7,
|
|
42
|
+
fontSize: 12,
|
|
43
|
+
color: 'hsl(var(--ink-3))',
|
|
44
|
+
padding: '3px 2px',
|
|
45
|
+
transition: 'color 140ms ease',
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
{open ? expandedIcon : collapsedIcon}
|
|
49
|
+
{leadingIcon && (
|
|
50
|
+
<span style={{ display: 'inline-flex', color: 'hsl(var(--p-people))' }}>
|
|
51
|
+
{leadingIcon}
|
|
52
|
+
</span>
|
|
53
|
+
)}
|
|
54
|
+
<span style={{ fontWeight: 500 }}>Thinking</span>
|
|
55
|
+
<span className="mono" style={{ fontSize: 10.5, opacity: 0.6 }}>
|
|
56
|
+
{text.length} chars
|
|
57
|
+
</span>
|
|
58
|
+
</button>
|
|
59
|
+
{open && (
|
|
60
|
+
<div
|
|
61
|
+
style={{
|
|
62
|
+
marginTop: 5,
|
|
63
|
+
marginLeft: 6,
|
|
64
|
+
paddingLeft: 12,
|
|
65
|
+
borderLeft: '1.5px dashed hsl(var(--rule-2))',
|
|
66
|
+
fontSize: 12.5,
|
|
67
|
+
lineHeight: 1.6,
|
|
68
|
+
fontStyle: 'italic',
|
|
69
|
+
color: 'hsl(var(--ink-3))',
|
|
70
|
+
whiteSpace: 'pre-wrap',
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
{text}
|
|
74
|
+
</div>
|
|
75
|
+
)}
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan / todo checklist. Each row's state is a `TodoState` enum value.
|
|
3
|
+
* The header glyph, the "done" check, and the "active" spinner are
|
|
4
|
+
* host-supplied icon nodes.
|
|
5
|
+
*/
|
|
6
|
+
import { SessionSkin, TodoState } from '../lib/enums';
|
|
7
|
+
|
|
8
|
+
import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export interface TodoItem {
|
|
12
|
+
readonly label: string;
|
|
13
|
+
readonly state: TodoState;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface TodoChecklistProps {
|
|
17
|
+
readonly items: ReadonlyArray<TodoItem>;
|
|
18
|
+
readonly skin?: SessionSkin;
|
|
19
|
+
readonly title?: string;
|
|
20
|
+
/** Header glyph (e.g. a check icon). */
|
|
21
|
+
readonly titleIcon?: ReactNode;
|
|
22
|
+
/** Check mark rendered inside a completed item's box. */
|
|
23
|
+
readonly doneIcon?: ReactNode;
|
|
24
|
+
/** Spinner rendered inside the active item's box. */
|
|
25
|
+
readonly activeIcon?: ReactNode;
|
|
26
|
+
readonly style?: CSSProperties;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function TodoChecklist({
|
|
30
|
+
items,
|
|
31
|
+
skin = SessionSkin.Minimal,
|
|
32
|
+
title = 'Plan',
|
|
33
|
+
titleIcon,
|
|
34
|
+
doneIcon,
|
|
35
|
+
activeIcon,
|
|
36
|
+
style,
|
|
37
|
+
}: TodoChecklistProps): ReactElement {
|
|
38
|
+
const done = items.filter((i) => i.state === TodoState.Done).length;
|
|
39
|
+
return (
|
|
40
|
+
<div
|
|
41
|
+
style={{
|
|
42
|
+
marginTop: 9,
|
|
43
|
+
border: '1px solid hsl(var(--rule))',
|
|
44
|
+
borderRadius: 9,
|
|
45
|
+
background: 'hsl(var(--paper-elev))',
|
|
46
|
+
overflow: 'hidden',
|
|
47
|
+
...style,
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
<div
|
|
51
|
+
style={{
|
|
52
|
+
display: 'flex',
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
gap: 8,
|
|
55
|
+
padding: '8px 12px',
|
|
56
|
+
borderBottom: '1px solid hsl(var(--rule))',
|
|
57
|
+
background:
|
|
58
|
+
skin === SessionSkin.Functional ? 'hsl(var(--muted))' : 'transparent',
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
{titleIcon && (
|
|
62
|
+
<span style={{ display: 'inline-flex', color: 'hsl(var(--primary))' }}>
|
|
63
|
+
{titleIcon}
|
|
64
|
+
</span>
|
|
65
|
+
)}
|
|
66
|
+
<span className="cap">{title}</span>
|
|
67
|
+
<span style={{ flex: 1 }} />
|
|
68
|
+
<span className="mono" style={{ fontSize: 11, color: 'hsl(var(--ink-3))' }}>
|
|
69
|
+
{done}/{items.length}
|
|
70
|
+
</span>
|
|
71
|
+
</div>
|
|
72
|
+
<div style={{ padding: '6px 0' }}>
|
|
73
|
+
{items.map((item, index) => {
|
|
74
|
+
const isDone = item.state === TodoState.Done;
|
|
75
|
+
const isActive = item.state === TodoState.Active;
|
|
76
|
+
return (
|
|
77
|
+
<div
|
|
78
|
+
key={index}
|
|
79
|
+
style={{
|
|
80
|
+
display: 'flex',
|
|
81
|
+
alignItems: 'center',
|
|
82
|
+
gap: 10,
|
|
83
|
+
padding: '5px 12px',
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
<span
|
|
87
|
+
style={{
|
|
88
|
+
width: 16,
|
|
89
|
+
height: 16,
|
|
90
|
+
borderRadius: 5,
|
|
91
|
+
flexShrink: 0,
|
|
92
|
+
display: 'grid',
|
|
93
|
+
placeItems: 'center',
|
|
94
|
+
border: isDone
|
|
95
|
+
? 'none'
|
|
96
|
+
: `1.5px solid ${isActive ? 'hsl(var(--warning))' : 'hsl(var(--rule-2))'}`,
|
|
97
|
+
background: isDone ? 'hsl(var(--success))' : 'transparent',
|
|
98
|
+
color: '#fff',
|
|
99
|
+
}}
|
|
100
|
+
>
|
|
101
|
+
{isDone && doneIcon}
|
|
102
|
+
{isActive && activeIcon}
|
|
103
|
+
</span>
|
|
104
|
+
<span
|
|
105
|
+
style={{
|
|
106
|
+
fontSize: 13,
|
|
107
|
+
color: isDone ? 'hsl(var(--ink-4))' : 'hsl(var(--ink-2))',
|
|
108
|
+
textDecoration: isDone ? 'line-through' : 'none',
|
|
109
|
+
fontWeight: isActive ? 500 : 400,
|
|
110
|
+
}}
|
|
111
|
+
>
|
|
112
|
+
{item.label}
|
|
113
|
+
</span>
|
|
114
|
+
</div>
|
|
115
|
+
);
|
|
116
|
+
})}
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token/cost meter — input & output token counts plus a running dollar
|
|
3
|
+
* cost. Used both inside the ContextHeader and (in Pillar 2) absolute
|
|
4
|
+
* top-right of the composer.
|
|
5
|
+
*/
|
|
6
|
+
import { SessionSkin } from '../lib/enums';
|
|
7
|
+
|
|
8
|
+
import type { CSSProperties, ReactElement } from 'react';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export interface TokenCounts {
|
|
12
|
+
readonly input: number;
|
|
13
|
+
readonly output: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface TokenMeterProps {
|
|
17
|
+
readonly tokens: TokenCounts;
|
|
18
|
+
readonly cost: number;
|
|
19
|
+
readonly skin?: SessionSkin;
|
|
20
|
+
/**
|
|
21
|
+
* When true, shows a pulsing `--info` dot — used by the composer while
|
|
22
|
+
* the agent is streaming (that is when token movement matters).
|
|
23
|
+
*/
|
|
24
|
+
readonly streaming?: boolean;
|
|
25
|
+
readonly style?: CSSProperties;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function fmt(n: number): string {
|
|
29
|
+
return n >= 1000 ? `${(n / 1000).toFixed(1)}k` : String(n);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function TokenMeter({
|
|
33
|
+
tokens,
|
|
34
|
+
cost,
|
|
35
|
+
skin = SessionSkin.Minimal,
|
|
36
|
+
streaming = false,
|
|
37
|
+
style,
|
|
38
|
+
}: TokenMeterProps): ReactElement {
|
|
39
|
+
const functional = skin === SessionSkin.Functional;
|
|
40
|
+
return (
|
|
41
|
+
<span
|
|
42
|
+
className="mono"
|
|
43
|
+
style={{
|
|
44
|
+
display: 'inline-flex',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
gap: 9,
|
|
47
|
+
fontSize: 11,
|
|
48
|
+
color: 'hsl(var(--ink-3))',
|
|
49
|
+
padding: functional ? '3px 9px' : 0,
|
|
50
|
+
background: functional ? 'hsl(var(--muted))' : 'transparent',
|
|
51
|
+
border: functional ? '1px solid hsl(var(--rule))' : 'none',
|
|
52
|
+
borderRadius: 7,
|
|
53
|
+
...style,
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
{streaming && (
|
|
57
|
+
<span
|
|
58
|
+
className="xk-pulse-soft"
|
|
59
|
+
style={{
|
|
60
|
+
width: 5,
|
|
61
|
+
height: 5,
|
|
62
|
+
borderRadius: '50%',
|
|
63
|
+
background: 'hsl(var(--info))',
|
|
64
|
+
flexShrink: 0,
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
)}
|
|
68
|
+
<span title="input tokens">
|
|
69
|
+
{fmt(tokens.input)}
|
|
70
|
+
<span style={{ opacity: 0.55 }}> in</span>
|
|
71
|
+
</span>
|
|
72
|
+
<span title="output tokens">
|
|
73
|
+
{fmt(tokens.output)}
|
|
74
|
+
<span style={{ opacity: 0.55 }}> out</span>
|
|
75
|
+
</span>
|
|
76
|
+
<span
|
|
77
|
+
style={{
|
|
78
|
+
width: 3,
|
|
79
|
+
height: 3,
|
|
80
|
+
borderRadius: '50%',
|
|
81
|
+
background: 'hsl(var(--ink-4))',
|
|
82
|
+
}}
|
|
83
|
+
/>
|
|
84
|
+
<span style={{ color: 'hsl(var(--ink-2))', fontWeight: 600 }}>
|
|
85
|
+
${cost.toFixed(3)}
|
|
86
|
+
</span>
|
|
87
|
+
</span>
|
|
88
|
+
);
|
|
89
|
+
}
|