@blade-hq/agent-react 1.1.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.
package/dist/style.css ADDED
@@ -0,0 +1,391 @@
1
+ /*
2
+ * @blade-hq/agent-react 自包含样式。
3
+ *
4
+ * 组件同时携带 Tailwind class 与 blade-chat-* 前缀类:宿主项目装了 Tailwind 时
5
+ * 由 Tailwind 提供完整视觉;没装时,本文件为核心布局与配色提供等效的普通 CSS,
6
+ * 保证聊天界面开箱可用。所有颜色经由 CSS 变量,宿主可整体换肤。
7
+ */
8
+
9
+ :root,
10
+ :host {
11
+ --background: 0 0% 100%;
12
+ --foreground: 215 13% 15%;
13
+ --card: 0 0% 100%;
14
+ --card-foreground: 215 13% 15%;
15
+ --popover: 0 0% 100%;
16
+ --popover-foreground: 215 13% 15%;
17
+ --primary: 223 100% 54%;
18
+ --primary-foreground: 0 0% 100%;
19
+ --muted: 220 40% 95%;
20
+ --muted-foreground: 220 9% 52%;
21
+ --accent: 220 100% 92%;
22
+ --accent-foreground: 215 13% 15%;
23
+ --destructive: 0 100% 50%;
24
+ --destructive-foreground: 0 0% 100%;
25
+ --border: 220 20% 90%;
26
+ --input: 220 20% 96%;
27
+ --ring: 223 100% 54%;
28
+ --radius: 0.4rem;
29
+ --user-msg-bg: 220 9% 95%;
30
+ --user-msg-fg: 215 13% 15%;
31
+ --user-msg-border: 220 15% 88%;
32
+ }
33
+
34
+ [data-theme="dark"] {
35
+ --background: 222 22% 5%;
36
+ --foreground: 210 18% 88%;
37
+ --card: 222 20% 8%;
38
+ --card-foreground: 210 18% 88%;
39
+ --popover: 222 18% 10%;
40
+ --popover-foreground: 210 18% 88%;
41
+ --primary: 38 88% 60%;
42
+ --primary-foreground: 222 22% 6%;
43
+ --muted: 222 16% 11%;
44
+ --muted-foreground: 220 8% 48%;
45
+ --accent: 222 16% 13%;
46
+ --accent-foreground: 210 18% 88%;
47
+ --destructive: 0 65% 55%;
48
+ --destructive-foreground: 210 18% 95%;
49
+ --border: 222 12% 17%;
50
+ --input: 222 12% 13%;
51
+ --ring: 38 88% 60%;
52
+ --user-msg-bg: 38 22% 12%;
53
+ --user-msg-fg: 38 65% 80%;
54
+ --user-msg-border: 38 30% 19%;
55
+ }
56
+
57
+ /* ---------------------------------------------------------------- 布局骨架 */
58
+
59
+ /* <blade-chat> 宿主默认块级 + 默认高度;页面对元素写的任何尺寸规则都会覆盖
60
+ * :host 默认值。host 容器把高度传导给内部 flex 链,消息区撑满、输入框钉底。 */
61
+ :host {
62
+ display: block;
63
+ height: 560px;
64
+ }
65
+
66
+ .blade-chat-host {
67
+ height: 100%;
68
+ display: flex;
69
+ flex-direction: column;
70
+ }
71
+
72
+ .blade-chat {
73
+ display: flex;
74
+ flex-direction: column;
75
+ flex: 1 1 0%;
76
+ min-height: 0;
77
+ overflow: hidden;
78
+ background: hsl(var(--background));
79
+ color: hsl(var(--foreground));
80
+ font-family:
81
+ system-ui,
82
+ -apple-system,
83
+ "Segoe UI",
84
+ Roboto,
85
+ "PingFang SC",
86
+ "Microsoft YaHei",
87
+ sans-serif;
88
+ }
89
+
90
+ .blade-chat-messages {
91
+ position: relative;
92
+ flex: 1 1 0%;
93
+ min-height: 0;
94
+ }
95
+
96
+ .blade-chat-messages-content {
97
+ margin: 0 auto;
98
+ max-width: 748px;
99
+ }
100
+
101
+ .blade-chat-messages-content > div {
102
+ display: flex;
103
+ flex-direction: column;
104
+ gap: 2.25rem;
105
+ min-width: 0;
106
+ }
107
+
108
+ .blade-chat-login,
109
+ .blade-chat-version-mismatch {
110
+ display: flex;
111
+ flex: 1 1 0%;
112
+ align-items: center;
113
+ justify-content: center;
114
+ padding: 1.5rem;
115
+ }
116
+
117
+ /* ---------------------------------------------------------------- 消息气泡 */
118
+
119
+ .blade-chat-user-row {
120
+ display: flex;
121
+ justify-content: flex-end;
122
+ }
123
+
124
+ .blade-chat-user-col {
125
+ display: flex;
126
+ flex-direction: column;
127
+ align-items: flex-end;
128
+ gap: 0.75rem;
129
+ max-width: 72%;
130
+ }
131
+
132
+ .blade-chat-user-bubble {
133
+ max-width: 100%;
134
+ border: 1px solid hsl(var(--user-msg-border));
135
+ background: hsl(var(--user-msg-bg));
136
+ color: hsl(var(--user-msg-fg));
137
+ border-radius: 20px;
138
+ border-bottom-right-radius: 6px;
139
+ padding: 13px 18px;
140
+ font-size: 0.875rem;
141
+ line-height: 1.65;
142
+ }
143
+
144
+ .blade-chat-assistant-turn {
145
+ display: flex;
146
+ flex-direction: column;
147
+ gap: 0.75rem;
148
+ }
149
+
150
+ .blade-chat-assistant-text {
151
+ font-size: 15px;
152
+ line-height: 2;
153
+ color: hsl(var(--foreground));
154
+ }
155
+
156
+ .blade-chat-error-row {
157
+ display: flex;
158
+ justify-content: center;
159
+ }
160
+
161
+ .blade-chat-error-block {
162
+ max-width: 85%;
163
+ border-left: 3px solid hsl(var(--destructive));
164
+ padding: 0.25rem 1rem;
165
+ font-size: 0.875rem;
166
+ line-height: 1.75rem;
167
+ color: hsl(var(--destructive));
168
+ }
169
+
170
+ .blade-chat-error-bar {
171
+ display: flex;
172
+ align-items: flex-start;
173
+ gap: 0.5rem;
174
+ border-bottom: 1px solid hsl(var(--destructive) / 0.3);
175
+ background: hsl(var(--destructive) / 0.08);
176
+ padding: 0.75rem 1rem;
177
+ font-size: 0.875rem;
178
+ color: hsl(var(--destructive));
179
+ }
180
+
181
+ /* ---------------------------------------------------------------- 输入区 */
182
+
183
+ .blade-chat-input {
184
+ border-top: 1px solid hsl(var(--border));
185
+ padding: 0.75rem 1rem;
186
+ }
187
+
188
+ .blade-chat-input-inner {
189
+ margin: 0 auto;
190
+ display: flex;
191
+ align-items: flex-end;
192
+ gap: 0.5rem;
193
+ max-width: 748px;
194
+ border: 1px solid hsl(var(--border));
195
+ background: hsl(var(--card));
196
+ border-radius: 1rem;
197
+ padding: 0.5rem 0.75rem;
198
+ }
199
+
200
+ .blade-chat-textarea {
201
+ flex: 1 1 0%;
202
+ resize: none;
203
+ border: 0;
204
+ background: transparent;
205
+ color: hsl(var(--foreground));
206
+ font: inherit;
207
+ font-size: 0.875rem;
208
+ line-height: 1.5rem;
209
+ padding: 0.25rem 0;
210
+ min-height: 28px;
211
+ max-height: 12rem;
212
+ outline: none;
213
+ }
214
+
215
+ .blade-chat-input-inner button {
216
+ cursor: pointer;
217
+ border: 0;
218
+ }
219
+
220
+ /* ---------------------------------------------------------------- 工具块 */
221
+
222
+ .blade-chat-tool,
223
+ .blade-chat-agent-loop,
224
+ .blade-chat-thinking {
225
+ margin-left: 1rem;
226
+ font-size: 0.75rem;
227
+ }
228
+
229
+ .blade-chat-tool-detail pre {
230
+ overflow: auto;
231
+ white-space: pre-wrap;
232
+ border-radius: 0.375rem;
233
+ background: hsl(var(--muted));
234
+ padding: 0.5rem;
235
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
236
+ font-size: 11px;
237
+ color: hsl(var(--foreground));
238
+ }
239
+
240
+ /* ---------------------------------------------------------------- Markdown */
241
+
242
+ .blade-chat-markdown {
243
+ overflow-wrap: break-word;
244
+ }
245
+
246
+ .blade-chat-prose p {
247
+ margin: 0.5em 0;
248
+ }
249
+
250
+ .blade-chat-prose > p:first-child,
251
+ .blade-chat-prose > ul:first-child,
252
+ .blade-chat-prose > ol:first-child {
253
+ margin-top: 0;
254
+ }
255
+
256
+ .blade-chat-prose > p:last-child,
257
+ .blade-chat-prose > ul:last-child,
258
+ .blade-chat-prose > ol:last-child {
259
+ margin-bottom: 0;
260
+ }
261
+
262
+ .blade-chat-prose ul,
263
+ .blade-chat-prose ol {
264
+ margin: 0.5em 0;
265
+ padding-left: 1.4em;
266
+ }
267
+
268
+ .blade-chat-prose li {
269
+ margin: 0.25em 0;
270
+ }
271
+
272
+ .blade-chat-prose h1 {
273
+ font-size: 1.25em;
274
+ font-weight: 600;
275
+ margin: 1em 0 0.5em;
276
+ }
277
+
278
+ .blade-chat-prose h2 {
279
+ font-size: 1.15em;
280
+ font-weight: 600;
281
+ margin: 1em 0 0.5em;
282
+ }
283
+
284
+ .blade-chat-prose h3,
285
+ .blade-chat-prose h4 {
286
+ font-size: 1.05em;
287
+ font-weight: 600;
288
+ margin: 0.9em 0 0.4em;
289
+ }
290
+
291
+ .blade-chat-prose blockquote {
292
+ border-left: 3px solid hsl(var(--border));
293
+ margin: 0.5em 0;
294
+ padding-left: 0.9em;
295
+ color: hsl(var(--muted-foreground));
296
+ }
297
+
298
+ .blade-chat-prose a {
299
+ color: hsl(var(--primary));
300
+ text-decoration: underline;
301
+ }
302
+
303
+ .blade-chat-prose code {
304
+ background: hsl(var(--muted) / 0.6);
305
+ border-radius: 0.25rem;
306
+ padding: 0.1em 0.35em;
307
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
308
+ font-size: 0.9em;
309
+ }
310
+
311
+ .blade-chat-prose table {
312
+ border-collapse: collapse;
313
+ margin: 0.75em 0;
314
+ width: 100%;
315
+ }
316
+
317
+ .blade-chat-prose th,
318
+ .blade-chat-prose td {
319
+ border: 1px solid hsl(var(--border));
320
+ padding: 0.4em 0.7em;
321
+ text-align: left;
322
+ }
323
+
324
+ .blade-chat-codeblock {
325
+ margin: 0.75rem 0;
326
+ overflow: hidden;
327
+ border: 1px solid hsl(var(--border));
328
+ border-radius: 0.75rem;
329
+ }
330
+
331
+ .blade-chat-codeblock-header {
332
+ display: flex;
333
+ align-items: center;
334
+ justify-content: space-between;
335
+ height: 34px;
336
+ border-bottom: 1px solid hsl(var(--border));
337
+ background: hsl(var(--muted) / 0.5);
338
+ padding: 0 0.375rem 0 0.875rem;
339
+ color: hsl(var(--muted-foreground));
340
+ }
341
+
342
+ .blade-chat-codeblock-header button {
343
+ cursor: pointer;
344
+ border: 0;
345
+ background: transparent;
346
+ display: inline-flex;
347
+ align-items: center;
348
+ gap: 0.25rem;
349
+ color: inherit;
350
+ }
351
+
352
+ .blade-chat-codeblock-body {
353
+ margin: 0;
354
+ overflow-x: auto;
355
+ background: hsl(var(--muted) / 0.25);
356
+ padding: 0.875rem 1rem;
357
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
358
+ font-size: 13.5px;
359
+ line-height: 1.7;
360
+ }
361
+
362
+ .blade-chat-codeblock-body code {
363
+ background: transparent;
364
+ padding: 0;
365
+ }
366
+
367
+ /* ---------------------------------------------------------------- 动效 */
368
+
369
+ .blade-shimmer-text {
370
+ background: linear-gradient(
371
+ 90deg,
372
+ hsl(var(--muted-foreground)) 0%,
373
+ hsl(var(--foreground)) 50%,
374
+ hsl(var(--muted-foreground)) 100%
375
+ );
376
+ background-size: 200% 100%;
377
+ -webkit-background-clip: text;
378
+ background-clip: text;
379
+ -webkit-text-fill-color: transparent;
380
+ color: transparent;
381
+ animation: blade-shimmer 2s linear infinite;
382
+ }
383
+
384
+ @keyframes blade-shimmer {
385
+ from {
386
+ background-position: 200% 0;
387
+ }
388
+ to {
389
+ background-position: -200% 0;
390
+ }
391
+ }
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@blade-hq/agent-react",
3
+ "version": "1.1.1",
4
+ "description": "Blade Agent React 绑定:BladeProvider、useAgentSession、开箱即用的 ChatView 聊天界面。",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./style.css": "./dist/style.css"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "public-api.md"
19
+ ],
20
+ "sideEffects": [
21
+ "**/*.css"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "dependencies": {
27
+ "@blade-hq/agent-client": "1.1.1",
28
+ "clsx": "^2.1.0",
29
+ "lucide-react": "^0.468.0",
30
+ "streamdown": "^2.0.0",
31
+ "use-stick-to-bottom": "^1.1.3"
32
+ },
33
+ "peerDependencies": {
34
+ "react": "^18.0.0 || ^19.0.0",
35
+ "react-dom": "^18.0.0 || ^19.0.0"
36
+ }
37
+ }