@mast-ai/react-ui 0.3.0 → 0.5.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.
@@ -16,40 +16,47 @@
16
16
  *
17
17
  * Two non-obvious tricks this preset relies on:
18
18
  *
19
- * 1. Listing all three selectors with equal specificity so source order
19
+ * 1. Listing every theme variant with equal specificity so source order
20
20
  * tie-breaks in the consumer's favor. A bare [data-mast-root] block loses
21
- * to the library's [data-mast-root][data-mast-theme='dark'] block in dark
22
- * mode and the dark theme would keep the library's hardcoded colors.
21
+ * to the library's [data-mast-root][data-mast-theme='dark'] (and the
22
+ * OS-following [data-mast-theme='auto']) blocks, so explicit dark mode
23
+ * and OS-following users would keep the library's hardcoded colors. The
24
+ * preset declares its rules inside the same `@layer mast-ai` block as the
25
+ * default stylesheet, so the source-order tie-break is preserved when
26
+ * both files are loaded.
23
27
  *
24
28
  * 2. Setting data-mast-theme={theme} on the panel root in your app keeps the
25
29
  * library's dark detection in sync with shadcn's class-based dark mode
26
- * (.dark on <html>). Without it, the library follows OS preference and
27
- * can mismatch the app theme.
30
+ * (.dark on <html>). Without it, the library defaults to the light theme
31
+ * and can mismatch an app forced into dark.
28
32
  *
29
33
  * See docs/react-ui/USAGE.md §5 for the full integration guide.
30
34
  */
31
35
 
32
- [data-mast-root],
33
- [data-mast-root][data-mast-theme='dark'],
34
- [data-mast-root][data-mast-theme='light'] {
35
- --mast-bg: hsl(var(--background));
36
- --mast-bg-subtle: hsl(var(--muted) / 0.2);
37
- --mast-fg: hsl(var(--foreground));
38
- --mast-fg-muted: hsl(var(--muted-foreground));
39
- --mast-border: hsl(var(--border));
40
- --mast-accent: hsl(var(--primary));
41
- --mast-accent-fg: hsl(var(--primary-foreground));
42
- --mast-thinking-bg: hsl(var(--muted));
43
- --mast-thinking-fg: hsl(var(--muted-foreground));
44
- --mast-tool-bg: hsl(var(--muted) / 0.4);
45
- --mast-tool-fg: hsl(var(--muted-foreground));
46
- --mast-tool-pending: hsl(var(--primary));
47
- --mast-tool-error-bg: hsl(var(--destructive) / 0.1);
48
- --mast-tool-error-fg: hsl(var(--destructive));
49
- --mast-tool-cancelled-bg: hsl(var(--muted));
50
- --mast-tool-cancelled-fg: hsl(var(--muted-foreground));
51
- --mast-user-bubble: hsl(var(--primary));
52
- --mast-user-fg: hsl(var(--primary-foreground));
53
- --mast-mention-chip-bg: hsl(var(--primary) / 0.1);
54
- --mast-mention-chip-fg: hsl(var(--primary));
55
- }
36
+ @layer mast-ai {
37
+ [data-mast-root],
38
+ [data-mast-root][data-mast-theme='dark'],
39
+ [data-mast-root][data-mast-theme='light'],
40
+ [data-mast-root][data-mast-theme='auto'] {
41
+ --mast-bg: hsl(var(--background));
42
+ --mast-bg-subtle: hsl(var(--muted) / 0.2);
43
+ --mast-fg: hsl(var(--foreground));
44
+ --mast-fg-muted: hsl(var(--muted-foreground));
45
+ --mast-border: hsl(var(--border));
46
+ --mast-accent: hsl(var(--primary));
47
+ --mast-accent-fg: hsl(var(--primary-foreground));
48
+ --mast-thinking-bg: hsl(var(--muted));
49
+ --mast-thinking-fg: hsl(var(--muted-foreground));
50
+ --mast-tool-bg: hsl(var(--muted) / 0.4);
51
+ --mast-tool-fg: hsl(var(--muted-foreground));
52
+ --mast-tool-pending: hsl(var(--primary));
53
+ --mast-tool-error-bg: hsl(var(--destructive) / 0.1);
54
+ --mast-tool-error-fg: hsl(var(--destructive));
55
+ --mast-tool-cancelled-bg: hsl(var(--muted));
56
+ --mast-tool-cancelled-fg: hsl(var(--muted-foreground));
57
+ --mast-user-bubble: hsl(var(--primary));
58
+ --mast-user-fg: hsl(var(--primary-foreground));
59
+ --mast-mention-chip-bg: hsl(var(--primary) / 0.1);
60
+ --mast-mention-chip-fg: hsl(var(--primary));
61
+ }
62
+ } /* @layer mast-ai */
package/dist/types.d.ts CHANGED
@@ -83,6 +83,29 @@ export interface ToolEventEntry {
83
83
  */
84
84
  status?: ToolCallStatus;
85
85
  }
86
+ /**
87
+ * A thinking/reasoning block produced during one LLM turn.
88
+ *
89
+ * Created when the first `thinking` delta arrives after a tool call (or at
90
+ * the very start of the stream) and accumulated until the next tool call or
91
+ * the end of the turn. Multiple `ThinkingEntry` blocks may appear in
92
+ * `ConversationEntry.contentBlocks` when the model thinks, calls a tool,
93
+ * then thinks again.
94
+ */
95
+ export interface ThinkingEntry {
96
+ /** Stable identifier used as the React `key` for this block. */
97
+ id: string;
98
+ /** Discriminator. */
99
+ type: 'thinking';
100
+ /** Accumulated reasoning text. Grows with each `thinking` delta. */
101
+ content: string;
102
+ }
103
+ /**
104
+ * A single content block within an assistant turn. Either a thinking/reasoning
105
+ * trace or a tool invocation. The array is ordered by arrival time, so
106
+ * thinking blocks and tool calls are interleaved in the sequence they occurred.
107
+ */
108
+ export type ContentBlock = ThinkingEntry | ToolEventEntry;
86
109
  /**
87
110
  * The rendered state of a single turn in the conversation.
88
111
  *
@@ -104,16 +127,15 @@ export interface ConversationEntry {
104
127
  */
105
128
  text: string;
106
129
  /**
107
- * Accumulated thinking/reasoning trace for this assistant turn.
108
- * Only present when the model emits `thinking` deltas.
109
- */
110
- thinking?: string;
111
- /**
112
- * Ordered list of tool invocations made during this assistant turn.
113
- * Each element corresponds to one `tool_call_started` event and is updated
114
- * in-place as the tool executes.
130
+ * Ordered list of content blocks produced during this assistant turn.
131
+ *
132
+ * Each `thinking` delta is accumulated into the last `ThinkingEntry` block,
133
+ * or starts a new one when the previous block is a tool call. Each
134
+ * `tool_call_started` event appends a `ToolEventEntry`. The ordering
135
+ * faithfully reflects the sequence in which thinking and tool calls occurred,
136
+ * so multi-turn reasoning (think tool think again) renders correctly.
115
137
  */
116
- toolEvents: ToolEventEntry[];
138
+ contentBlocks: ContentBlock[];
117
139
  /**
118
140
  * `true` while the assistant is generating this entry; `false` once `done`,
119
141
  * an error, or a cancellation is received.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mast-ai/react-ui",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -35,7 +35,7 @@
35
35
  "format": "prettier --write src"
36
36
  },
37
37
  "peerDependencies": {
38
- "@mast-ai/core": "^0.3.0",
38
+ "@mast-ai/core": "^0.5.0",
39
39
  "@tanstack/react-virtual": ">=3.0.0",
40
40
  "react": ">=19.0.0",
41
41
  "react-dom": ">=19.0.0"