@galaxycore/ai-chat 0.4.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.
- package/CHANGELOG.md +7 -0
- package/README.md +3 -3
- package/dist/appearance.js +1 -1
- package/dist/context.js +1 -1
- package/dist/headless.d.ts +2 -2
- package/dist/headless.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +348 -239
- package/dist/index.js.map +1 -1
- package/dist/{labels-DJsjblzj.js → labels-BM5o9a9K.js} +5 -1
- package/dist/{labels-DJsjblzj.js.map → labels-BM5o9a9K.js.map} +1 -1
- package/dist/{labels-BBjaNAlS.d.ts → labels-D8smv23O.d.ts} +36 -2
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.js +1 -1
- package/dist/markdown.js.map +1 -1
- package/dist/styles.css +206 -112
- package/dist/{ui-primitives-DlZ1hJkr.js → ui-primitives-BCbe9Ds8.js} +4 -4
- package/dist/{ui-primitives-DlZ1hJkr.js.map → ui-primitives-BCbe9Ds8.js.map} +1 -1
- package/docs/api-reference.md +2 -2
- package/docs/design.md +2 -2
- package/docs/integration.md +3 -4
- package/docs/patent-prototype.md +72 -0
- package/docs/patent-visual-baseline.json +121 -0
- package/docs/publishing.md +7 -7
- package/docs/validation.md +2 -0
- package/package.json +4 -10
package/dist/styles.css
CHANGED
|
@@ -2,33 +2,41 @@
|
|
|
2
2
|
|
|
3
3
|
/* All selectors are scoped. Override these tokens on .gc-chat. */
|
|
4
4
|
.gc-chat {
|
|
5
|
-
--gc-chat-bg: #
|
|
5
|
+
--gc-chat-bg: #ffffff;
|
|
6
6
|
--gc-chat-surface: #fff;
|
|
7
|
-
--gc-chat-surface-hover: #
|
|
8
|
-
--gc-chat-text: #
|
|
9
|
-
--gc-chat-muted: #
|
|
10
|
-
--gc-chat-border: #
|
|
11
|
-
--gc-chat-border-strong: #
|
|
12
|
-
--gc-chat-focus: #
|
|
13
|
-
--gc-chat-tooltip-bg: #
|
|
7
|
+
--gc-chat-surface-hover: #f7f8fb;
|
|
8
|
+
--gc-chat-text: #253047;
|
|
9
|
+
--gc-chat-muted: #677287;
|
|
10
|
+
--gc-chat-border: #e8ecf3;
|
|
11
|
+
--gc-chat-border-strong: #ced9ff;
|
|
12
|
+
--gc-chat-focus: #3157d5;
|
|
13
|
+
--gc-chat-tooltip-bg: #253047;
|
|
14
14
|
--gc-chat-tooltip-text: #ffffff;
|
|
15
|
-
--gc-chat-user-bg: #
|
|
16
|
-
--gc-chat-accent: #
|
|
17
|
-
--gc-chat-accent-soft: #
|
|
18
|
-
--gc-chat-danger: #
|
|
19
|
-
--gc-chat-danger-bg: #
|
|
20
|
-
--gc-chat-shadow:
|
|
21
|
-
--gc-chat-radius:
|
|
22
|
-
--gc-chat-panel-radius:
|
|
15
|
+
--gc-chat-user-bg: #f7f8fb;
|
|
16
|
+
--gc-chat-accent: #3157d5;
|
|
17
|
+
--gc-chat-accent-soft: #f0f4ff;
|
|
18
|
+
--gc-chat-danger: #b44444;
|
|
19
|
+
--gc-chat-danger-bg: #fff2f1;
|
|
20
|
+
--gc-chat-shadow: none;
|
|
21
|
+
--gc-chat-radius: 11px;
|
|
22
|
+
--gc-chat-panel-radius: 16px;
|
|
23
23
|
--gc-chat-space-inline: 24px;
|
|
24
|
-
--gc-chat-message-gap:
|
|
25
|
-
--gc-chat-content-width:
|
|
24
|
+
--gc-chat-message-gap: 25px;
|
|
25
|
+
--gc-chat-content-width: 654px;
|
|
26
26
|
--gc-chat-font-size: 14px;
|
|
27
|
-
--gc-chat-control-size:
|
|
27
|
+
--gc-chat-control-size: 30px;
|
|
28
28
|
--gc-chat-accent-foreground: #ffffff;
|
|
29
|
-
--gc-chat-
|
|
30
|
-
--gc-chat-send-
|
|
31
|
-
--gc-chat-
|
|
29
|
+
--gc-chat-solid: #365bd7;
|
|
30
|
+
--gc-chat-send-bg: var(--gc-chat-solid);
|
|
31
|
+
--gc-chat-send-foreground: var(--gc-chat-accent-foreground);
|
|
32
|
+
--gc-chat-success: #37745d;
|
|
33
|
+
--gc-chat-success-bg: #eff7f3;
|
|
34
|
+
--gc-chat-warning: #8b631c;
|
|
35
|
+
--gc-chat-warning-bg: #fff9ec;
|
|
36
|
+
--gc-chat-send-size: 31px;
|
|
37
|
+
--gc-chat-suggestion-height: 39px;
|
|
38
|
+
--gc-chat-icon-size: 16px;
|
|
39
|
+
--gc-chat-prose-font: -apple-system-body, ui-sans-serif, -apple-system, system-ui, 'Segoe UI', Helvetica, 'Apple Color Emoji', Arial, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
32
40
|
box-sizing: border-box;
|
|
33
41
|
border: 1px solid var(--gc-chat-border);
|
|
34
42
|
border-radius: var(--gc-chat-panel-radius);
|
|
@@ -47,50 +55,59 @@
|
|
|
47
55
|
color-scheme: light;
|
|
48
56
|
font-family: var(--gc-chat-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif);
|
|
49
57
|
font-size: var(--gc-chat-font-size);
|
|
50
|
-
|
|
58
|
+
font-weight: 400;
|
|
59
|
+
line-height: 1.65;
|
|
51
60
|
-webkit-font-smoothing: antialiased;
|
|
52
61
|
}
|
|
53
62
|
.gc-chat[data-theme='dark'] {
|
|
54
|
-
--gc-chat-bg: #
|
|
55
|
-
--gc-chat-surface: #
|
|
56
|
-
--gc-chat-surface-hover: #
|
|
57
|
-
--gc-chat-text: #
|
|
58
|
-
--gc-chat-muted: #
|
|
59
|
-
--gc-chat-border: #
|
|
60
|
-
--gc-chat-border-strong: #
|
|
61
|
-
--gc-chat-focus: #
|
|
62
|
-
--gc-chat-tooltip-bg: #
|
|
63
|
-
--gc-chat-tooltip-text: #
|
|
64
|
-
--gc-chat-user-bg: #
|
|
65
|
-
--gc-chat-accent: #
|
|
66
|
-
--gc-chat-accent-soft: #
|
|
67
|
-
--gc-chat-danger: #
|
|
68
|
-
--gc-chat-danger-bg: #
|
|
69
|
-
--gc-chat-shadow:
|
|
70
|
-
--gc-chat-accent-foreground: #
|
|
71
|
-
--gc-chat-success: #
|
|
63
|
+
--gc-chat-bg: #171b24;
|
|
64
|
+
--gc-chat-surface: #171b24;
|
|
65
|
+
--gc-chat-surface-hover: #202632;
|
|
66
|
+
--gc-chat-text: #e6ebf5;
|
|
67
|
+
--gc-chat-muted: #a4b0c5;
|
|
68
|
+
--gc-chat-border: #343e50;
|
|
69
|
+
--gc-chat-border-strong: #50618f;
|
|
70
|
+
--gc-chat-focus: #a2b6ff;
|
|
71
|
+
--gc-chat-tooltip-bg: #e6ebf5;
|
|
72
|
+
--gc-chat-tooltip-text: #171b24;
|
|
73
|
+
--gc-chat-user-bg: #202632;
|
|
74
|
+
--gc-chat-accent: #a2b6ff;
|
|
75
|
+
--gc-chat-accent-soft: #252f4d;
|
|
76
|
+
--gc-chat-danger: #ffabab;
|
|
77
|
+
--gc-chat-danger-bg: #3a272b;
|
|
78
|
+
--gc-chat-shadow: none;
|
|
79
|
+
--gc-chat-accent-foreground: #19213a;
|
|
80
|
+
--gc-chat-success: #8dc9ae;
|
|
81
|
+
--gc-chat-success-bg: #22372e;
|
|
82
|
+
--gc-chat-warning: #e9c078;
|
|
83
|
+
--gc-chat-warning-bg: #322c22;
|
|
84
|
+
--gc-chat-solid: #a2b6ff;
|
|
72
85
|
color-scheme: dark;
|
|
73
86
|
}
|
|
74
87
|
@media (prefers-color-scheme: dark) {
|
|
75
88
|
.gc-chat[data-theme='auto'] {
|
|
76
|
-
--gc-chat-bg: #
|
|
77
|
-
--gc-chat-surface: #
|
|
78
|
-
--gc-chat-surface-hover: #
|
|
79
|
-
--gc-chat-text: #
|
|
80
|
-
--gc-chat-muted: #
|
|
81
|
-
--gc-chat-border: #
|
|
82
|
-
--gc-chat-border-strong: #
|
|
83
|
-
--gc-chat-focus: #
|
|
84
|
-
--gc-chat-tooltip-bg: #
|
|
85
|
-
--gc-chat-tooltip-text: #
|
|
86
|
-
--gc-chat-user-bg: #
|
|
87
|
-
--gc-chat-accent: #
|
|
88
|
-
--gc-chat-accent-soft: #
|
|
89
|
-
--gc-chat-danger: #
|
|
90
|
-
--gc-chat-danger-bg: #
|
|
91
|
-
--gc-chat-shadow:
|
|
92
|
-
--gc-chat-accent-foreground: #
|
|
93
|
-
--gc-chat-success: #
|
|
89
|
+
--gc-chat-bg: #171b24;
|
|
90
|
+
--gc-chat-surface: #171b24;
|
|
91
|
+
--gc-chat-surface-hover: #202632;
|
|
92
|
+
--gc-chat-text: #e6ebf5;
|
|
93
|
+
--gc-chat-muted: #a4b0c5;
|
|
94
|
+
--gc-chat-border: #343e50;
|
|
95
|
+
--gc-chat-border-strong: #50618f;
|
|
96
|
+
--gc-chat-focus: #a2b6ff;
|
|
97
|
+
--gc-chat-tooltip-bg: #e6ebf5;
|
|
98
|
+
--gc-chat-tooltip-text: #171b24;
|
|
99
|
+
--gc-chat-user-bg: #202632;
|
|
100
|
+
--gc-chat-accent: #a2b6ff;
|
|
101
|
+
--gc-chat-accent-soft: #252f4d;
|
|
102
|
+
--gc-chat-danger: #ffabab;
|
|
103
|
+
--gc-chat-danger-bg: #3a272b;
|
|
104
|
+
--gc-chat-shadow: none;
|
|
105
|
+
--gc-chat-accent-foreground: #19213a;
|
|
106
|
+
--gc-chat-success: #8dc9ae;
|
|
107
|
+
--gc-chat-success-bg: #22372e;
|
|
108
|
+
--gc-chat-warning: #e9c078;
|
|
109
|
+
--gc-chat-warning-bg: #322c22;
|
|
110
|
+
--gc-chat-solid: #a2b6ff;
|
|
94
111
|
color-scheme: dark;
|
|
95
112
|
}
|
|
96
113
|
}
|
|
@@ -99,38 +116,51 @@
|
|
|
99
116
|
.gc-chat[data-density='compact'] { --gc-chat-space-inline: 16px; --gc-chat-message-gap: 22px; --gc-chat-font-size: 13px; --gc-chat-control-size: 32px; }
|
|
100
117
|
.gc-chat *, .gc-chat *::before, .gc-chat *::after { box-sizing: border-box; }
|
|
101
118
|
.gc-chat :where(button, textarea, input, select) { font: inherit; }
|
|
119
|
+
.gc-chat :is(p, h1, h2, h3, h4, h5, h6, li) { font-family: var(--gc-chat-prose-font); }
|
|
120
|
+
.gc-chat :is(strong, b) { font-weight: 600; }
|
|
121
|
+
.gc-chat [hidden] { display: none !important; }
|
|
122
|
+
.gc-chat ::selection { background: var(--gc-chat-border-strong); color: var(--gc-chat-text); }
|
|
102
123
|
.gc-chat button { -webkit-tap-highlight-color: transparent; cursor: pointer; }
|
|
103
|
-
.gc-chat button:disabled { opacity: .
|
|
124
|
+
.gc-chat button:disabled { opacity: .5; cursor: not-allowed; }
|
|
104
125
|
.gc-chat button, .gc-chat a, .gc-chat summary { touch-action: manipulation; }
|
|
105
|
-
.gc-chat :where(button, a, summary,
|
|
126
|
+
.gc-chat :where(button, a, summary, input, select, [tabindex]):focus-visible { outline: 2px solid var(--gc-chat-focus); outline-offset: 3px; }
|
|
106
127
|
.gc-chat :where(button) { color: inherit; }
|
|
107
128
|
.gc-chat svg { flex-shrink: 0; }
|
|
108
|
-
|
|
109
|
-
.gc-
|
|
110
|
-
.gc-
|
|
129
|
+
/* Freeze the prototype's Lucide treatment without depending on the preview host. */
|
|
130
|
+
.gc-chat svg.lucide { display: block; width: var(--gc-chat-icon-size); height: var(--gc-chat-icon-size); flex: none; margin: 0; stroke-width: 1.6; }
|
|
131
|
+
.gc-chat__header { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; gap: 11px; padding: 19px var(--gc-chat-space-inline); border-bottom: 1px solid var(--gc-chat-border); }
|
|
132
|
+
.gc-chat__heading { display: flex; align-items: center; gap: 11px; min-width: 0; }
|
|
133
|
+
.gc-chat__brand { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; color: var(--gc-chat-accent); background: var(--gc-chat-accent-soft); }
|
|
111
134
|
.gc-chat__brand svg { width: 16px; height: 16px; }
|
|
112
|
-
.gc-chat__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-
|
|
135
|
+
.gc-chat .gc-chat__title { display: block; font-family: var(--gc-chat-prose-font); margin: 0; color: var(--gc-chat-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; line-height: 1.5; font-weight: 600; letter-spacing: .02em; }
|
|
136
|
+
.gc-chat__header-copy { min-width: 0; }
|
|
137
|
+
.gc-chat .gc-chat__subtitle { font-family: var(--gc-chat-prose-font); margin: 2px 0 0; font-size: 12px; line-height: 1.65; color: var(--gc-chat-muted); }
|
|
113
138
|
.gc-chat__header-actions { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
|
|
114
139
|
.gc-chat__messages-wrap { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
|
|
115
|
-
.gc-chat__messages { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter:
|
|
140
|
+
.gc-chat__messages { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: auto; scrollbar-width: thin; scrollbar-color: var(--gc-chat-border) transparent; outline-offset: -4px !important; }
|
|
116
141
|
.gc-chat__messages::-webkit-scrollbar { width: 6px; }
|
|
117
142
|
.gc-chat__messages { scroll-behavior: auto; }
|
|
118
143
|
.gc-chat__messages[data-following='true'] { overflow-anchor: none; }
|
|
119
144
|
.gc-chat__messages::-webkit-scrollbar-thumb { background: var(--gc-chat-border); border-radius: 8px; }
|
|
120
|
-
.gc-chat__messages-content { display: flex; flex-direction: column; min-height: 100%; width: 100%; max-width: var(--gc-chat-content-width); margin-inline: auto; padding:
|
|
145
|
+
.gc-chat__messages-content { display: flex; flex-direction: column; min-height: 100%; width: 100%; max-width: var(--gc-chat-content-width); margin-inline: auto; padding: 23px calc(var(--gc-chat-space-inline) + 1px) 0; gap: var(--gc-chat-message-gap); }
|
|
121
146
|
.gc-chat__message { min-width: 0; max-width: 100%; }
|
|
122
|
-
.gc-chat__message--user { align-self: flex-end; max-width:
|
|
123
|
-
.gc-chat__message--user .gc-chat__message-body { background: var(--gc-chat-user-bg); border:
|
|
147
|
+
.gc-chat__message--user { align-self: flex-end; max-width: 91%; }
|
|
148
|
+
.gc-chat__message--user .gc-chat__message-body { background: var(--gc-chat-user-bg); border: 0; border-radius: 12px 12px 3px 12px; padding: 10px 15px; }
|
|
124
149
|
.gc-chat__message--assistant { width: 100%; }
|
|
150
|
+
.gc-chat__message--user .gc-chat__text { line-height: 1.65; }
|
|
151
|
+
.gc-chat__message-heading, .gc-chat__message-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 12px; line-height: 1.65; }
|
|
152
|
+
.gc-chat__assistant-mark, .gc-chat__mini-mark { display: inline-grid; place-items: center; width: 23px; height: 23px; flex: 0 0 23px; border-radius: 7px; background: var(--gc-chat-accent-soft); color: var(--gc-chat-accent); }
|
|
153
|
+
.gc-chat .gc-chat__assistant-name, .gc-chat__message-head > strong { font-size: 13px; font-weight: 600; }
|
|
154
|
+
.gc-chat__message-time, .gc-chat__message-head > time { margin-left: auto; color: var(--gc-chat-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
|
|
125
155
|
.gc-chat__message-body { display: flex; flex-direction: column; gap: 14px; overflow-wrap: anywhere; }
|
|
126
156
|
.gc-chat__part:empty { display: none; }
|
|
127
157
|
.gc-chat__text { min-width: 0; line-height: 1.85; }
|
|
128
158
|
.gc-chat__plain-text { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
129
|
-
.gc-chat__text :
|
|
130
|
-
.gc-chat__text :
|
|
131
|
-
.gc-chat__text :
|
|
132
|
-
.gc-chat__text :
|
|
133
|
-
.gc-chat__text :
|
|
159
|
+
.gc-chat__text :is(p, ul, ol, blockquote, pre, table) { margin-block: 0 16px; }
|
|
160
|
+
.gc-chat__text :is(h1, h2, h3, h4) { font-size: 1.04em; line-height: 1.6; margin: 24px 0 10px; font-weight: 600; letter-spacing: -.2px; }
|
|
161
|
+
.gc-chat__text :is(h1, h2, h3, h4):first-child { margin-top: 0; }
|
|
162
|
+
.gc-chat__text :is(p, ul, ol, blockquote, pre, table):last-child { margin-bottom: 0; }
|
|
163
|
+
.gc-chat__text :is(ul, ol) { padding-left: 24px; }
|
|
134
164
|
.gc-chat__text li { margin-block: 6px; padding-inline-start: 3px; }
|
|
135
165
|
.gc-chat__text li > p { margin-bottom: 6px; }
|
|
136
166
|
.gc-chat__text a { color: var(--gc-chat-accent); text-underline-offset: 3px; }
|
|
@@ -143,10 +173,10 @@
|
|
|
143
173
|
.gc-chat__text th { font-weight: 600; }
|
|
144
174
|
.gc-chat__text hr { border: 0; border-top: 1px solid var(--gc-chat-border); margin: 24px 0; }
|
|
145
175
|
.gc-chat__text img { max-width: 100%; height: auto; border-radius: 12px; }
|
|
146
|
-
.gc-chat__text :
|
|
176
|
+
.gc-chat__text :is(h5, h6) { font-size: 1em; line-height: 1.6; margin: 20px 0 8px; font-weight: 600; }
|
|
147
177
|
/* Streamdown emits utility classes; these semantic selectors make Tailwind optional. */
|
|
148
178
|
.gc-chat__markdown { min-width: 0; }
|
|
149
|
-
.gc-chat__markdown [data-streamdown='strong'] { font-weight:
|
|
179
|
+
.gc-chat__markdown [data-streamdown='strong'] { font-weight: 600; }
|
|
150
180
|
.gc-chat__markdown [data-streamdown='code-block'] { min-width: 0; max-width: 100%; margin: 16px 0; border: 1px solid var(--gc-chat-border); border-radius: 12px; overflow: hidden; background: var(--gc-chat-surface); }
|
|
151
181
|
.gc-chat__markdown [data-streamdown='code-block-header'] { padding: 6px 13px; border-bottom: 1px solid var(--gc-chat-border); background: var(--gc-chat-bg); color: var(--gc-chat-muted); font-size: 11px; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; }
|
|
152
182
|
.gc-chat__markdown [data-streamdown='code-block-body'] { overflow: auto; max-width: 100%; padding: 12px 14px; }
|
|
@@ -170,33 +200,85 @@
|
|
|
170
200
|
@media (prefers-color-scheme: dark) {
|
|
171
201
|
.gc-chat[data-theme='auto'] .gc-chat__markdown [data-streamdown='code-block-body'] code > span > span { color: var(--shiki-dark, var(--sdm-c, inherit)); background: var(--shiki-dark-bg, var(--sdm-tbg, transparent)); }
|
|
172
202
|
}
|
|
173
|
-
.gc-chat__message-footer {
|
|
174
|
-
.gc-chat__message-actions { display: flex; min-height:
|
|
175
|
-
.gc-chat__icon-button { display: inline-
|
|
176
|
-
.gc-chat__icon-button:hover:not(:disabled) { background: var(--gc-chat-surface-hover); color: var(--gc-chat-text); }
|
|
177
|
-
.gc-chat__icon-button > svg { width:
|
|
178
|
-
.gc-chat__icon-button[data-size='sm'] { width: 30px; height: 30px; padding:
|
|
203
|
+
.gc-chat__message-footer { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 10px 0 13px; }
|
|
204
|
+
.gc-chat__message-actions { display: flex; min-height: var(--gc-chat-control-size); gap: 6px; align-items: center; }
|
|
205
|
+
.gc-chat__icon-button { display: inline-grid; place-items: center; width: var(--gc-chat-control-size); height: var(--gc-chat-control-size); padding: 1px 6px; border: 0; border-radius: 6px; background: transparent; flex-shrink: 0; color: var(--gc-chat-muted); transition: background 160ms ease, color 160ms ease; }
|
|
206
|
+
.gc-chat__icon-button:not(.gc-chat__send):hover:not(:disabled) { background: var(--gc-chat-surface-hover); color: var(--gc-chat-text); }
|
|
207
|
+
.gc-chat__icon-button > svg { width: var(--gc-chat-icon-size); height: var(--gc-chat-icon-size); }
|
|
208
|
+
.gc-chat__icon-button[data-size='sm'] { width: 30px; height: 30px; padding: 1px 6px; border-radius: 6px; }
|
|
179
209
|
.gc-chat__icon-button[data-variant='filled'] { background: var(--gc-chat-surface-hover); color: var(--gc-chat-text); }
|
|
180
210
|
.gc-chat__icon-button[data-copied='true'] { color: var(--gc-chat-success); }
|
|
181
|
-
.gc-chat__icon-button:active:not(:disabled) { background: color-mix(in srgb, var(--gc-chat-text) 10%, var(--gc-chat-surface)); }
|
|
211
|
+
.gc-chat__icon-button:not(.gc-chat__send):active:not(:disabled) { background: color-mix(in srgb, var(--gc-chat-text) 10%, var(--gc-chat-surface)); }
|
|
182
212
|
.gc-chat__message-actions .gc-chat__icon-button svg { width: 16px; height: 16px; }
|
|
183
|
-
.gc-chat__button { display: inline-flex; align-items: center; justify-content: center; min-height:
|
|
184
|
-
.gc-chat__button:hover:not(:disabled) { background: var(--gc-chat-surface-hover); }
|
|
185
|
-
.gc-chat__button--primary { background: var(--gc-chat-accent-soft); color: var(--gc-chat-
|
|
186
|
-
.gc-
|
|
187
|
-
.gc-
|
|
188
|
-
.gc-
|
|
189
|
-
.gc-
|
|
190
|
-
.gc-
|
|
191
|
-
.gc-
|
|
192
|
-
.gc-
|
|
193
|
-
.gc-
|
|
213
|
+
.gc-chat__button, .gc-chat__suggestion { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: var(--gc-chat-suggestion-height); padding: 8px 12px; border: 1px solid var(--gc-chat-border); border-radius: 8px; background: var(--gc-chat-surface); color: var(--gc-chat-text); font-size: 12px; font-weight: 500; line-height: 1.45; transition: background 160ms ease, border-color 160ms ease; }
|
|
214
|
+
.gc-chat__button:not([data-emphasis='quiet']):hover:not(:disabled), .gc-chat__suggestion:not([data-emphasis='quiet']):hover:not(:disabled) { background: var(--gc-chat-surface-hover); border-color: var(--gc-chat-border-strong); }
|
|
215
|
+
.gc-chat__button--primary, .gc-chat__button[data-emphasis='recommended'], .gc-chat__suggestion[data-emphasis='recommended'] { background: var(--gc-chat-accent-soft); border-color: var(--gc-chat-border-strong); color: var(--gc-chat-accent); }
|
|
216
|
+
.gc-chat__button--primary:hover:not(:disabled), .gc-chat__button[data-emphasis='recommended']:hover:not(:disabled), .gc-chat__suggestion[data-emphasis='recommended']:hover:not(:disabled) { background: var(--gc-chat-border-strong); }
|
|
217
|
+
.gc-chat__button[data-emphasis='solid'] { background: var(--gc-chat-solid); border-color: var(--gc-chat-solid); color: var(--gc-chat-accent-foreground); }
|
|
218
|
+
.gc-chat__button[data-emphasis='solid']:hover:not(:disabled) { background: var(--gc-chat-solid); border-color: var(--gc-chat-solid); filter: brightness(.96); }
|
|
219
|
+
.gc-chat__button[data-emphasis='quiet'], .gc-chat__suggestion[data-emphasis='quiet'] { color: var(--gc-chat-muted); border-color: transparent; background: transparent; }
|
|
220
|
+
.gc-chat__suggestion[data-pending='true'] { cursor: progress; }
|
|
221
|
+
.gc-chat__suggestion > span { min-width: 0; text-align: left; }
|
|
222
|
+
.gc-chat__suggestions { padding: 20px 0 4px; }
|
|
223
|
+
.gc-chat__suggestions-heading { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; margin-bottom: 10px; }
|
|
224
|
+
.gc-chat .gc-chat__suggestions-heading h3 { margin: 0; color: var(--gc-chat-muted); font-size: 12px; font-weight: 500; line-height: 1.5555555556; }
|
|
225
|
+
.gc-chat__suggestions-reason { color: var(--gc-chat-muted); font-size: 11px; }
|
|
226
|
+
.gc-chat__suggestions-actions, .gc-chat__button-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
|
227
|
+
/* Optional structured content uses the same reading rhythm as the reference. */
|
|
228
|
+
.gc-chat .gc-chat__intro { margin: 0 0 14px; font-size: var(--gc-chat-font-size); line-height: 1.85; }
|
|
229
|
+
.gc-chat__status { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-bottom: 12px; color: var(--gc-chat-success); font-size: 12px; }
|
|
230
|
+
.gc-chat__status .gc-chat__status-note { margin-left: 5px; color: var(--gc-chat-muted); }
|
|
231
|
+
.gc-chat__disclosures { margin-bottom: 15px; }
|
|
232
|
+
.gc-chat__disclosures > details { border-top: 1px solid var(--gc-chat-border); }
|
|
233
|
+
.gc-chat__disclosures > details:last-child { border-bottom: 1px solid var(--gc-chat-border); }
|
|
234
|
+
.gc-chat__disclosures > details > summary { display: flex; align-items: center; gap: 7px; list-style: none; color: var(--gc-chat-muted); font-size: 13px; padding: 10px 0; cursor: pointer; }
|
|
235
|
+
.gc-chat__disclosures > details > summary::-webkit-details-marker { display: none; }
|
|
236
|
+
.gc-chat__chevron { transition: transform 180ms ease; }
|
|
237
|
+
.gc-chat__disclosures > details[open] > summary .gc-chat__chevron { transform: rotate(90deg); }
|
|
238
|
+
.gc-chat__count { margin-left: auto; color: var(--gc-chat-muted); font-size: 12px; }
|
|
239
|
+
.gc-chat .gc-chat__disclosure-details { margin: 0; padding: 0 0 13px 23px; font-size: 12px; color: var(--gc-chat-muted); }
|
|
240
|
+
.gc-chat__change { display: flex; gap: 16px; align-items: baseline; margin: 5px 0; }
|
|
241
|
+
.gc-chat__change dt { flex: 0 0 56px; color: var(--gc-chat-muted); }
|
|
242
|
+
.gc-chat__change dd { margin: 0; color: var(--gc-chat-text); overflow-wrap: anywhere; }
|
|
243
|
+
.gc-chat__notice { display: flex; align-items: flex-start; gap: 9px; padding: 12px 14px; border-radius: 9px; background: var(--gc-chat-warning-bg); color: var(--gc-chat-warning); font-size: 12px; line-height: 1.8; }
|
|
244
|
+
.gc-chat__notice > svg { flex: 0 0 16px; }
|
|
245
|
+
.gc-chat__notice strong { display: block; font-size: 13px; font-weight: 500; margin-bottom: 2px; }
|
|
246
|
+
.gc-chat__notice[data-tone='success'] { color: var(--gc-chat-success); background: var(--gc-chat-success-bg); }
|
|
247
|
+
.gc-chat__undo { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; color: var(--gc-chat-success); font-size: 12px; }
|
|
248
|
+
.gc-chat__text-button { border: 0; background: transparent; color: var(--gc-chat-accent); font-size: 12px; padding: 6px 2px; text-underline-offset: 3px; }
|
|
249
|
+
.gc-chat__text-button:hover { text-decoration: underline; }
|
|
250
|
+
.gc-chat__clarify { margin-top: 18px; padding: 16px 0 0; border-top: 1px solid var(--gc-chat-border); }
|
|
251
|
+
.gc-chat .gc-chat__clarify h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; line-height: 1.5555555556; }
|
|
252
|
+
.gc-chat .gc-chat__clarify p { margin: 0 0 12px; color: var(--gc-chat-muted); font-size: 12px; }
|
|
253
|
+
.gc-chat__clarify fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
|
|
254
|
+
.gc-chat__option { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 8px; background: var(--gc-chat-surface); cursor: pointer; }
|
|
255
|
+
.gc-chat__option:has(input:checked) { background: var(--gc-chat-accent-soft); }
|
|
256
|
+
.gc-chat__option input { accent-color: var(--gc-chat-solid); width: 16px; height: 16px; flex-shrink: 0; margin: 0; }
|
|
257
|
+
.gc-chat__option-copy { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 10px; }
|
|
258
|
+
.gc-chat__option-copy small { color: var(--gc-chat-muted); font-size: 12px; }
|
|
259
|
+
.gc-chat__current { margin-left: auto; flex-shrink: 0; color: var(--gc-chat-accent); font-size: 11px; }
|
|
260
|
+
.gc-chat__confirm-note { color: var(--gc-chat-muted); font-size: 11px; }
|
|
261
|
+
.gc-chat__followup { padding: 3px 0; }
|
|
262
|
+
.gc-chat .gc-chat__followup p { margin: 0 0 10px; }
|
|
263
|
+
.gc-chat__followup small { display: block; font-size: 12px; color: var(--gc-chat-muted); }
|
|
264
|
+
.gc-chat__query { padding: 10px 12px; margin: 10px 0 13px; background: var(--gc-chat-surface-hover); border-radius: 7px; font-size: 12px; overflow-wrap: anywhere; }
|
|
265
|
+
.gc-chat__loading-bars { display: grid; gap: 8px; margin: 12px 0; }
|
|
266
|
+
.gc-chat__loading-bars span { background: var(--gc-chat-surface-hover); border-radius: 4px; height: 10px; width: 76%; }
|
|
267
|
+
.gc-chat__loading-bars span:last-child { width: 51%; }
|
|
268
|
+
.gc-chat__bottom { flex-shrink: 0; width: 100%; padding: 16px var(--gc-chat-space-inline) 14px; border-top: 1px solid var(--gc-chat-border); }
|
|
269
|
+
.gc-chat__composer-wrap { min-width: 0; }
|
|
270
|
+
.gc-chat__composer { position: relative; border: 1px solid var(--gc-chat-border); border-radius: var(--gc-chat-radius); background: var(--gc-chat-surface); padding: 11px 12px 9px; box-shadow: none; transition: border-color 160ms ease; }
|
|
271
|
+
.gc-chat__composer:focus-within { border-color: var(--gc-chat-accent); }
|
|
272
|
+
.gc-chat__context { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; padding: 0; color: var(--gc-chat-muted); font-size: 11px; overflow-wrap: anywhere; }
|
|
273
|
+
.gc-chat__context strong { font-weight: 500; color: var(--gc-chat-text); }
|
|
274
|
+
.gc-chat .gc-chat__input { display: block; width: 100%; resize: vertical; min-height: 46px; max-height: 180px; border: 0; background: transparent; color: var(--gc-chat-text); padding: 2px; line-height: 1.7; font-size: 13px; caret-color: var(--gc-chat-accent); scrollbar-width: thin; }
|
|
275
|
+
.gc-chat__input::placeholder { color: var(--gc-chat-muted); opacity: 1; }
|
|
276
|
+
.gc-chat__composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 6px; }
|
|
277
|
+
.gc-chat__input-hint { font-size: 11px; line-height: 1.65; color: var(--gc-chat-muted); }
|
|
194
278
|
.gc-chat__toolbar { display: flex; align-items: center; gap: 4px; min-width: 0; flex: 1; flex-wrap: wrap; }
|
|
195
|
-
.gc-chat__send { display:
|
|
196
|
-
.gc-chat__send:
|
|
197
|
-
.gc-
|
|
198
|
-
.gc-chat__send:disabled { background: var(--gc-chat-surface-hover); color: var(--gc-chat-muted) !important; opacity: .65; }
|
|
199
|
-
.gc-chat__disclaimer { margin: 10px 4px 0; text-align: center; font-size: 10px; line-height: 1.5; color: var(--gc-chat-muted); }
|
|
279
|
+
.gc-chat__send { display: grid; place-items: center; width: var(--gc-chat-send-size); height: var(--gc-chat-send-size); border: 0; border-radius: 7px; background: var(--gc-chat-send-bg); color: var(--gc-chat-send-foreground); padding: 1px 6px; flex-shrink: 0; }
|
|
280
|
+
.gc-chat .gc-chat__send:disabled { background: var(--gc-chat-surface-hover); color: var(--gc-chat-muted); opacity: 1; }
|
|
281
|
+
.gc-chat .gc-chat__disclaimer { margin: 9px 0 0; text-align: center; font-size: 11px; line-height: 1.65; color: var(--gc-chat-muted); }
|
|
200
282
|
.gc-chat__attachments { display: flex; gap: 7px; flex-wrap: wrap; padding: 0 3px 10px; margin: 0; list-style: none; }
|
|
201
283
|
.gc-chat__attachment { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 5px 4px 9px; background: var(--gc-chat-bg); border: 1px solid var(--gc-chat-border); border-radius: 9px; font-size: 11px; line-height: 1.5; }
|
|
202
284
|
.gc-chat__attachment > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
|
|
@@ -261,12 +343,6 @@
|
|
|
261
343
|
.gc-chat__unsupported > svg { width: 16px; height: 16px; }
|
|
262
344
|
.gc-chat__unsupported code { font-size: 11px; }
|
|
263
345
|
.gc-chat__sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
|
|
264
|
-
@media (max-width: 420px) {
|
|
265
|
-
.gc-chat__header { min-height: 54px; padding: 10px 16px; }
|
|
266
|
-
.gc-chat__messages-content { padding: 12px 16px 24px; gap: var(--gc-chat-message-gap); }
|
|
267
|
-
.gc-chat__bottom { padding: 0 10px 9px; }
|
|
268
|
-
.gc-chat__message--user { max-width: 92%; }
|
|
269
|
-
}
|
|
270
346
|
.gc-chat__spinner { animation: gc-chat-spin 1.5s linear infinite; }
|
|
271
347
|
@keyframes gc-chat-spin { to { transform: rotate(360deg); } }
|
|
272
348
|
.gc-chat__reasoning[data-streaming] > summary { color: var(--gc-chat-accent); }
|
|
@@ -276,7 +352,7 @@
|
|
|
276
352
|
.gc-chat[data-density='compact'] .gc-chat__composer { padding: 10px; }
|
|
277
353
|
.gc-chat[data-density='compact'] .gc-chat__disclaimer { margin-top: 7px; }
|
|
278
354
|
/* Context references are compact, independently actionable disclosures. */
|
|
279
|
-
.gc-chat__context:has(.gc-chat__context-tray) { display: block; padding: 0
|
|
355
|
+
.gc-chat__context:has(.gc-chat__context-tray) { display: block; padding: 0; }
|
|
280
356
|
.gc-chat__context-tray { width: 100%; min-width: 0; font-size: 12px; color: var(--gc-chat-muted); }
|
|
281
357
|
.gc-chat__context-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
|
|
282
358
|
.gc-chat__context-toolbar:empty { display: none; }
|
|
@@ -329,18 +405,36 @@
|
|
|
329
405
|
.gc-chat__voice-remember input { accent-color: var(--gc-chat-accent); }
|
|
330
406
|
.gc-chat__voice-unsupported, .gc-chat__voice-error { display: flex; align-items: flex-start; gap: 6px; margin: 0 4px 10px; font-size: 11px; line-height: 1.65; color: var(--gc-chat-muted); }
|
|
331
407
|
.gc-chat__voice-error { color: var(--gc-chat-danger); }
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
.gc-
|
|
335
|
-
.gc-
|
|
408
|
+
/* Both narrow viewports and sidebars keep the prototype’s mobile layout. */
|
|
409
|
+
@media (max-width: 520px) {
|
|
410
|
+
.gc-chat__header { padding: 16px 17px; }
|
|
411
|
+
.gc-chat__messages-content { padding: 20px 17px 0; }
|
|
412
|
+
.gc-chat__bottom { padding: 14px 16px 12px; }
|
|
413
|
+
.gc-chat__message--user { max-width: 95%; }
|
|
414
|
+
.gc-chat__button, .gc-chat__suggestion { min-height: 44px; }
|
|
415
|
+
.gc-chat__suggestions-actions .gc-chat__suggestion[data-emphasis='recommended'], .gc-chat__button-row .gc-chat__button[data-emphasis='recommended'] { flex-basis: 100%; justify-content: flex-start; }
|
|
416
|
+
.gc-chat__suggestions-reason { display: none; }
|
|
417
|
+
.gc-chat .gc-chat__input { font-size: 16px; }
|
|
418
|
+
.gc-chat__context-label-text { max-width: 140px; }
|
|
419
|
+
}
|
|
420
|
+
@container (max-width: 520px) {
|
|
421
|
+
.gc-chat__header { padding: 16px 17px; }
|
|
422
|
+
.gc-chat__messages-content { padding: 20px 17px 0; }
|
|
423
|
+
.gc-chat__bottom { padding: 14px 16px 12px; }
|
|
424
|
+
.gc-chat__message--user { max-width: 95%; }
|
|
425
|
+
.gc-chat__button, .gc-chat__suggestion { min-height: 44px; }
|
|
426
|
+
.gc-chat__suggestions-actions .gc-chat__suggestion[data-emphasis='recommended'], .gc-chat__button-row .gc-chat__button[data-emphasis='recommended'] { flex-basis: 100%; justify-content: flex-start; }
|
|
427
|
+
.gc-chat__suggestions-reason { display: none; }
|
|
428
|
+
.gc-chat .gc-chat__input { font-size: 16px; }
|
|
336
429
|
.gc-chat__context-label-text { max-width: 140px; }
|
|
337
430
|
}
|
|
338
431
|
@media (pointer: coarse) {
|
|
339
432
|
.gc-chat .gc-chat__icon-button, .gc-chat .gc-chat__send { min-width: 44px; min-height: 44px; }
|
|
340
|
-
.gc-chat__button, .gc-
|
|
433
|
+
.gc-chat__button, .gc-chat__suggestion, .gc-chat__text-button { min-height: 44px; min-width: 44px; }
|
|
434
|
+
.gc-chat__context-select, .gc-chat__tool-heading, .gc-chat__reasoning > summary, .gc-chat__disclosures > details > summary { min-height: 44px; }
|
|
341
435
|
.gc-chat__context-label { min-height: 48px; }
|
|
342
436
|
.gc-chat__context-actions { padding-block: 2px; }
|
|
343
|
-
.gc-chat__input { font-size: max(16px, var(--gc-chat-font-size)); }
|
|
437
|
+
.gc-chat .gc-chat__input { font-size: max(16px, var(--gc-chat-font-size)); }
|
|
344
438
|
}
|
|
345
439
|
@media (prefers-reduced-motion: reduce) {
|
|
346
440
|
.gc-chat *, .gc-chat *::before, .gc-chat *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
|
|
@@ -51,9 +51,9 @@ function ChatAppearanceProvider({ icons, children }) {
|
|
|
51
51
|
function Icon({ name, ...props }) {
|
|
52
52
|
const Component = useContext(IconContext)[name] ?? defaultIcons[name];
|
|
53
53
|
return /* @__PURE__ */ jsx(Component, {
|
|
54
|
-
width:
|
|
55
|
-
height:
|
|
56
|
-
strokeWidth: 1.
|
|
54
|
+
width: 16,
|
|
55
|
+
height: 16,
|
|
56
|
+
strokeWidth: 1.6,
|
|
57
57
|
"aria-hidden": "true",
|
|
58
58
|
focusable: "false",
|
|
59
59
|
...props
|
|
@@ -174,4 +174,4 @@ const ChatIconButton = forwardRef(function ChatIconButton({ label, icon, childre
|
|
|
174
174
|
//#endregion
|
|
175
175
|
export { ChatAppearanceProvider as n, Icon as r, ChatIconButton as t };
|
|
176
176
|
|
|
177
|
-
//# sourceMappingURL=ui-primitives-
|
|
177
|
+
//# sourceMappingURL=ui-primitives-BCbe9Ds8.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-primitives-DlZ1hJkr.js","names":[],"sources":["../src/icons.tsx","../src/ui-primitives.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, useMemo } from 'react';\nimport type { ComponentType, ReactNode } from 'react';\nimport {\n Mic, AudioLines, TextQuote, Table2, ChartNoAxesCombined, PanelTop, Crosshair, ArrowUpRight,\n ArrowDown, ArrowUp, Ban, Brain, Check, ChevronRight, CircleAlert, Copy,\n FileText, Link, LoaderCircle, MoreHorizontal, Plus, RotateCcw, Sparkles,\n Search, Square, SquarePen, Wrench, X,\n} from 'lucide-react';\nimport type { LucideProps } from 'lucide-react';\n\nexport type ChatIconName = 'send' | 'stop' | 'plus' | 'close' | 'copy' | 'check' | 'refresh' | 'down' | 'file' | 'sparkle' | 'more' | 'edit' | 'chevron' | 'link' | 'tool' | 'thinking' | 'warning' | 'blocked' | 'loader' | 'mic' | 'audio' | 'text' | 'table' | 'chart' | 'page' | 'target' | 'external' | 'search';\nexport type ChatIconProps = Omit<LucideProps, 'ref'>;\nexport type ChatIconOverrides = Partial<Record<ChatIconName, ComponentType<ChatIconProps>>>;\n/** @internal Alias retained for component implementations. */\nexport type IconName = ChatIconName;\n\n// Named imports keep the icon set small; consumers never download a dynamic icon registry.\nconst defaultIcons: Record<ChatIconName, ComponentType<ChatIconProps>> = {\n mic: Mic, audio: AudioLines, text: TextQuote, table: Table2, chart: ChartNoAxesCombined, page: PanelTop, target: Crosshair, external: ArrowUpRight, search: Search,\n send: ArrowUp, stop: Square, plus: Plus, close: X, copy: Copy, check: Check,\n refresh: RotateCcw, down: ArrowDown, file: FileText, sparkle: Sparkles,\n more: MoreHorizontal, edit: SquarePen, chevron: ChevronRight, link: Link,\n tool: Wrench, thinking: Brain, warning: CircleAlert, blocked: Ban, loader: LoaderCircle,\n};\n\nconst IconContext = createContext<ChatIconOverrides>({});\n\nexport interface ChatAppearanceProviderProps {\n /** Replace just the icons your product needs. Overrides inherit through nested providers. */\n icons?: ChatIconOverrides;\n children: ReactNode;\n}\n\n/** A DOM-free, instance-scoped provider. Works with ChatPanel and standalone primitives. */\nexport function ChatAppearanceProvider({ icons, children }: ChatAppearanceProviderProps) {\n const parent = useContext(IconContext);\n const value = useMemo(() => {\n const merged = { ...parent };\n for (const name of Object.keys(icons ?? {}) as ChatIconName[]) {\n if (icons?.[name]) merged[name] = icons[name];\n }\n return merged;\n }, [parent, icons]);\n return <IconContext.Provider value={value}>{children}</IconContext.Provider>;\n}\n\nexport function Icon({ name, ...props }: ChatIconProps & { name: ChatIconName }) {\n const overrides = useContext(IconContext);\n const Component = overrides[name] ?? defaultIcons[name];\n return <Component width={20} height={20} strokeWidth={1.7} aria-hidden=\"true\" focusable=\"false\" {...props} />;\n}\n","\"use client\";\n\nimport { forwardRef, useEffect, useRef, useState } from 'react';\nimport type { ButtonHTMLAttributes, CSSProperties, ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\nimport { Icon, type ChatIconName } from './icons';\n\nexport interface ChatIconButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {\n /** Accessible name; also used as the default tooltip. */\n label: string;\n icon?: ChatIconName;\n children?: ReactNode;\n size?: 'sm' | 'md';\n variant?: 'ghost' | 'filled';\n /** Set false to suppress the visual tooltip, or pass a more descriptive label. */\n tooltip?: boolean | string;\n}\n\ntype TooltipPosition = { left: number; top: number; placement: 'top' | 'bottom'; style: CSSProperties };\n\n/** Labelled native button with a viewport-safe tooltip. No wrapper affects host flex layouts. */\nexport const ChatIconButton = forwardRef<HTMLButtonElement, ChatIconButtonProps>(function ChatIconButton({\n label, icon, children, size = 'md', variant = 'ghost', tooltip = true, className, type = 'button',\n onPointerEnter, onPointerLeave, onPointerDown, onFocus, onBlur, onClick, onKeyDown, ...props\n}, forwardedRef) {\n const button = useRef<HTMLButtonElement | null>(null);\n const tooltipElement = useRef<HTMLSpanElement | null>(null);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const [position, setPosition] = useState<TooltipPosition>();\n const text = typeof tooltip === 'string' ? tooltip : label;\n\n function hide() {\n clearTimeout(timer.current);\n setPosition(undefined);\n }\n function show(delay: number) {\n clearTimeout(timer.current);\n if (!tooltip || props.disabled) return;\n timer.current = setTimeout(() => {\n const element = button.current;\n if (!element || !element.isConnected) return;\n const rect = element.getBoundingClientRect();\n const theme = window.getComputedStyle(element);\n const placement = rect.top > 120 ? 'top' : 'bottom';\n // The tooltip is portalled to avoid clipping by message scrollers and panels.\n // Resolve tokens at the trigger so each instance retains its own theme.\n setPosition({\n left: Math.max(Math.min(128, window.innerWidth / 2), Math.min(window.innerWidth - Math.min(128, window.innerWidth / 2), rect.left + rect.width / 2)),\n top: placement === 'top' ? rect.top - 8 : rect.bottom + 8,\n placement,\n style: {\n background: theme.getPropertyValue('--gc-chat-tooltip-bg').trim() || '#272b32',\n color: theme.getPropertyValue('--gc-chat-tooltip-text').trim() || '#fff',\n fontFamily: theme.fontFamily,\n },\n });\n }, delay);\n }\n\n useEffect(() => () => clearTimeout(timer.current), []);\n useEffect(() => {\n if (!position) return;\n const dismiss = (event: KeyboardEvent) => { if (event.key === 'Escape') hide(); };\n // Hide on movement rather than leaving a detached tooltip over different content.\n const onScroll = (event: Event) => { if (event.target !== tooltipElement.current) hide(); };\n window.addEventListener('scroll', onScroll, true);\n window.addEventListener('resize', hide);\n window.addEventListener('keydown', dismiss);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n window.removeEventListener('resize', hide);\n window.removeEventListener('keydown', dismiss);\n };\n }, [position]);\n useEffect(() => { if (props.disabled || !tooltip) hide(); }, [props.disabled, tooltip]);\n\n return <>\n <button {...props} ref={element => {\n button.current = element;\n if (typeof forwardedRef === 'function') return forwardedRef(element);\n else if (forwardedRef) forwardedRef.current = element;\n }} type={type} aria-label={label}\n className={['gc-chat__icon-button', className].filter(Boolean).join(' ')}\n data-size={size} data-variant={variant}\n onPointerEnter={event => { onPointerEnter?.(event); if (!event.defaultPrevented && event.pointerType !== 'touch') show(400); }}\n onPointerLeave={event => { onPointerLeave?.(event); clearTimeout(timer.current); timer.current = setTimeout(hide, 150); }}\n onPointerDown={event => { onPointerDown?.(event); hide(); }}\n onFocus={event => { onFocus?.(event); if (!event.defaultPrevented) show(0); }}\n onBlur={event => { onBlur?.(event); hide(); }}\n onClick={event => { onClick?.(event); hide(); }}\n onKeyDown={event => { onKeyDown?.(event); if (event.key === 'Escape') hide(); }}>\n {children ?? (icon ? <Icon name={icon} /> : null)}\n </button>\n {position && createPortal(<span ref={tooltipElement} className=\"gc-chat__tooltip\" role=\"tooltip\" data-placement={position.placement}\n onPointerEnter={() => clearTimeout(timer.current)} onPointerLeave={hide}\n style={{ left: position.left, top: position.top, ...position.style }}>{text}</span>, button.current?.ownerDocument.body ?? document.body)}\n </>;\n});\n"],"mappings":";;;;;;AAmBA,MAAM,eAAmE;CACvE,KAAK;CAAK,OAAO;CAAY,MAAM;CAAW,OAAO;CAAQ,OAAO;CAAqB,MAAM;CAAU,QAAQ;CAAW,UAAU;CAAc,QAAQ;CAC5J,MAAM;CAAS,MAAM;CAAQ,MAAM;CAAM,OAAO;CAAG,MAAM;CAAM,OAAO;CACtE,SAAS;CAAW,MAAM;CAAW,MAAM;CAAU,SAAS;CAC9D,MAAM;CAAgB,MAAM;CAAW,SAAS;CAAc,MAAM;CACpE,MAAM;CAAQ,UAAU;CAAO,SAAS;CAAa,SAAS;CAAK,QAAQ;AAC7E;AAEA,MAAM,cAAc,cAAiC,CAAC,CAAC;;AASvD,SAAgB,uBAAuB,EAAE,OAAO,YAAyC;CACvF,MAAM,SAAS,WAAW,WAAW;CACrC,MAAM,QAAQ,cAAc;EAC1B,M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,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EACvE,aAAW;EAAM,gBAAc;EAC/B,iBAAgB,UAAS;GAAE,iBAAiB,KAAK;GAAG,IAAI,CAAC,MAAM,oBAAoB,MAAM,gBAAgB,SAAS,KAAK,GAAG;EAAG;EAC7H,iBAAgB,UAAS;GAAE,iBAAiB,KAAK;GAAG,aAAa,MAAM,OAAO;GAAG,MAAM,UAAU,WAAW,MAAM,GAAG;EAAG;EACxH,gBAAe,UAAS;GAAE,gBAAgB,KAAK;GAAG,KAAK;EAAG;EAC1D,UAAS,UAAS;GAAE,UAAU,KAAK;GAAG,IAAI,CAAC,MAAM,kBAAkB,KAAK,CAAC;EAAG;EAC5E,SAAQ,UAAS;GAAE,SAAS,KAAK;GAAG,KAAK;EAAG;EAC5C,UAAS,UAAS;GAAE,UAAU,KAAK;GAAG,KAAK;EAAG;EAC9C,YAAW,UAAS;GAAE,YAAY,KAAK;GAAG,IAAI,MAAM,QAAQ,UAAU,KAAK;EAAG;EAC7E,UAAA,aAAa,OAAO,oBAAC,MAAD,EAAM,MAAM,KAAO,CAAA,IAAI;CACtC,CAAA,GACP,YAAY,aAAa,oBAAC,QAAD;EAAM,KAAK;EAAgB,WAAU;EAAmB,MAAK;EAAU,kBAAgB,SAAS;EACxH,sBAAsB,aAAa,MAAM,OAAO;EAAG,gBAAgB;EACnE,OAAO;GAAE,MAAM,SAAS;GAAM,KAAK,SAAS;GAAK,GAAG,SAAS;EAAM;EAAI,UAAA;CAAW,CAAA,GAAG,OAAO,SAAS,cAAc,QAAQ,SAAS,IAAI,CAC1I,EAAA,CAAA;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"ui-primitives-BCbe9Ds8.js","names":[],"sources":["../src/icons.tsx","../src/ui-primitives.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, useMemo } from 'react';\nimport type { ComponentType, ReactNode } from 'react';\nimport {\n Mic, AudioLines, TextQuote, Table2, ChartNoAxesCombined, PanelTop, Crosshair, ArrowUpRight,\n ArrowDown, ArrowUp, Ban, Brain, Check, ChevronRight, CircleAlert, Copy,\n FileText, Link, LoaderCircle, MoreHorizontal, Plus, RotateCcw, Sparkles,\n Search, Square, SquarePen, Wrench, X,\n} from 'lucide-react';\nimport type { LucideProps } from 'lucide-react';\n\nexport type ChatIconName = 'send' | 'stop' | 'plus' | 'close' | 'copy' | 'check' | 'refresh' | 'down' | 'file' | 'sparkle' | 'more' | 'edit' | 'chevron' | 'link' | 'tool' | 'thinking' | 'warning' | 'blocked' | 'loader' | 'mic' | 'audio' | 'text' | 'table' | 'chart' | 'page' | 'target' | 'external' | 'search';\nexport type ChatIconProps = Omit<LucideProps, 'ref'>;\nexport type ChatIconOverrides = Partial<Record<ChatIconName, ComponentType<ChatIconProps>>>;\n/** @internal Alias retained for component implementations. */\nexport type IconName = ChatIconName;\n\n// Named imports keep the icon set small; consumers never download a dynamic icon registry.\nconst defaultIcons: Record<ChatIconName, ComponentType<ChatIconProps>> = {\n mic: Mic, audio: AudioLines, text: TextQuote, table: Table2, chart: ChartNoAxesCombined, page: PanelTop, target: Crosshair, external: ArrowUpRight, search: Search,\n send: ArrowUp, stop: Square, plus: Plus, close: X, copy: Copy, check: Check,\n refresh: RotateCcw, down: ArrowDown, file: FileText, sparkle: Sparkles,\n more: MoreHorizontal, edit: SquarePen, chevron: ChevronRight, link: Link,\n tool: Wrench, thinking: Brain, warning: CircleAlert, blocked: Ban, loader: LoaderCircle,\n};\n\nconst IconContext = createContext<ChatIconOverrides>({});\n\nexport interface ChatAppearanceProviderProps {\n /** Replace just the icons your product needs. Overrides inherit through nested providers. */\n icons?: ChatIconOverrides;\n children: ReactNode;\n}\n\n/** A DOM-free, instance-scoped provider. Works with ChatPanel and standalone primitives. */\nexport function ChatAppearanceProvider({ icons, children }: ChatAppearanceProviderProps) {\n const parent = useContext(IconContext);\n const value = useMemo(() => {\n const merged = { ...parent };\n for (const name of Object.keys(icons ?? {}) as ChatIconName[]) {\n if (icons?.[name]) merged[name] = icons[name];\n }\n return merged;\n }, [parent, icons]);\n return <IconContext.Provider value={value}>{children}</IconContext.Provider>;\n}\n\nexport function Icon({ name, ...props }: ChatIconProps & { name: ChatIconName }) {\n const overrides = useContext(IconContext);\n const Component = overrides[name] ?? defaultIcons[name];\n return <Component width={16} height={16} strokeWidth={1.6} aria-hidden=\"true\" focusable=\"false\" {...props} />;\n}\n","\"use client\";\n\nimport { forwardRef, useEffect, useRef, useState } from 'react';\nimport type { ButtonHTMLAttributes, CSSProperties, ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\nimport { Icon, type ChatIconName } from './icons';\n\nexport interface ChatIconButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {\n /** Accessible name; also used as the default tooltip. */\n label: string;\n icon?: ChatIconName;\n children?: ReactNode;\n size?: 'sm' | 'md';\n variant?: 'ghost' | 'filled';\n /** Set false to suppress the visual tooltip, or pass a more descriptive label. */\n tooltip?: boolean | string;\n}\n\ntype TooltipPosition = { left: number; top: number; placement: 'top' | 'bottom'; style: CSSProperties };\n\n/** Labelled native button with a viewport-safe tooltip. No wrapper affects host flex layouts. */\nexport const ChatIconButton = forwardRef<HTMLButtonElement, ChatIconButtonProps>(function ChatIconButton({\n label, icon, children, size = 'md', variant = 'ghost', tooltip = true, className, type = 'button',\n onPointerEnter, onPointerLeave, onPointerDown, onFocus, onBlur, onClick, onKeyDown, ...props\n}, forwardedRef) {\n const button = useRef<HTMLButtonElement | null>(null);\n const tooltipElement = useRef<HTMLSpanElement | null>(null);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const [position, setPosition] = useState<TooltipPosition>();\n const text = typeof tooltip === 'string' ? tooltip : label;\n\n function hide() {\n clearTimeout(timer.current);\n setPosition(undefined);\n }\n function show(delay: number) {\n clearTimeout(timer.current);\n if (!tooltip || props.disabled) return;\n timer.current = setTimeout(() => {\n const element = button.current;\n if (!element || !element.isConnected) return;\n const rect = element.getBoundingClientRect();\n const theme = window.getComputedStyle(element);\n const placement = rect.top > 120 ? 'top' : 'bottom';\n // The tooltip is portalled to avoid clipping by message scrollers and panels.\n // Resolve tokens at the trigger so each instance retains its own theme.\n setPosition({\n left: Math.max(Math.min(128, window.innerWidth / 2), Math.min(window.innerWidth - Math.min(128, window.innerWidth / 2), rect.left + rect.width / 2)),\n top: placement === 'top' ? rect.top - 8 : rect.bottom + 8,\n placement,\n style: {\n background: theme.getPropertyValue('--gc-chat-tooltip-bg').trim() || '#272b32',\n color: theme.getPropertyValue('--gc-chat-tooltip-text').trim() || '#fff',\n fontFamily: theme.fontFamily,\n },\n });\n }, delay);\n }\n\n useEffect(() => () => clearTimeout(timer.current), []);\n useEffect(() => {\n if (!position) return;\n const dismiss = (event: KeyboardEvent) => { if (event.key === 'Escape') hide(); };\n // Hide on movement rather than leaving a detached tooltip over different content.\n const onScroll = (event: Event) => { if (event.target !== tooltipElement.current) hide(); };\n window.addEventListener('scroll', onScroll, true);\n window.addEventListener('resize', hide);\n window.addEventListener('keydown', dismiss);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n window.removeEventListener('resize', hide);\n window.removeEventListener('keydown', dismiss);\n };\n }, [position]);\n useEffect(() => { if (props.disabled || !tooltip) hide(); }, [props.disabled, tooltip]);\n\n return <>\n <button {...props} ref={element => {\n button.current = element;\n if (typeof forwardedRef === 'function') return forwardedRef(element);\n else if (forwardedRef) forwardedRef.current = element;\n }} type={type} aria-label={label}\n className={['gc-chat__icon-button', className].filter(Boolean).join(' ')}\n data-size={size} data-variant={variant}\n onPointerEnter={event => { onPointerEnter?.(event); if (!event.defaultPrevented && event.pointerType !== 'touch') show(400); }}\n onPointerLeave={event => { onPointerLeave?.(event); clearTimeout(timer.current); timer.current = setTimeout(hide, 150); }}\n onPointerDown={event => { onPointerDown?.(event); hide(); }}\n onFocus={event => { onFocus?.(event); if (!event.defaultPrevented) show(0); }}\n onBlur={event => { onBlur?.(event); hide(); }}\n onClick={event => { onClick?.(event); hide(); }}\n onKeyDown={event => { onKeyDown?.(event); if (event.key === 'Escape') hide(); }}>\n {children ?? (icon ? <Icon name={icon} /> : null)}\n </button>\n {position && createPortal(<span ref={tooltipElement} className=\"gc-chat__tooltip\" role=\"tooltip\" data-placement={position.placement}\n onPointerEnter={() => clearTimeout(timer.current)} onPointerLeave={hide}\n style={{ left: position.left, top: position.top, ...position.style }}>{text}</span>, button.current?.ownerDocument.body ?? document.body)}\n </>;\n});\n"],"mappings":";;;;;;AAmBA,MAAM,eAAmE;CACvE,KAAK;CAAK,OAAO;CAAY,MAAM;CAAW,OAAO;CAAQ,OAAO;CAAqB,MAAM;CAAU,QAAQ;CAAW,UAAU;CAAc,QAAQ;CAC5J,MAAM;CAAS,MAAM;CAAQ,MAAM;CAAM,OAAO;CAAG,MAAM;CAAM,OAAO;CACtE,SAAS;CAAW,MAAM;CAAW,MAAM;CAAU,SAAS;CAC9D,MAAM;CAAgB,MAAM;CAAW,SAAS;CAAc,MAAM;CACpE,MAAM;CAAQ,UAAU;CAAO,SAAS;CAAa,SAAS;CAAK,QAAQ;AAC7E;AAEA,MAAM,cAAc,cAAiC,CAAC,CAAC;;AASvD,SAAgB,uBAAuB,EAAE,OAAO,YAAyC;CACvF,MAAM,SAAS,WAAW,WAAW;CACrC,MAAM,QAAQ,cAAc;EAC1B,MAAM,SAAS,EAAE,GAAG,OAAO;EAC3B,KAAK,MAAM,QAAQ,OAAO,KAAK,SAAS,CAAC,CAAC,GACxC,IAAI,QAAQ,OAAO,OAAO,QAAQ,MAAM;EAE1C,OAAO;CACT,GAAG,CAAC,QAAQ,KAAK,CAAC;CAClB,OAAO,oBAAC,YAAY,UAAb;EAA6B;EAAQ;CAA+B,CAAA;AAC7E;AAEA,SAAgB,KAAK,EAAE,MAAM,GAAG,SAAiD;CAE/E,MAAM,YADY,WAAW,WACH,CAAC,CAAC,SAAS,aAAa;CAClD,OAAO,oBAAC,WAAD;EAAW,OAAO;EAAI,QAAQ;EAAI,aAAa;EA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,MAAM,kBAAkB,KAAK,CAAC;EAAG;EAC5E,SAAQ,UAAS;GAAE,SAAS,KAAK;GAAG,KAAK;EAAG;EAC5C,UAAS,UAAS;GAAE,UAAU,KAAK;GAAG,KAAK;EAAG;EAC9C,YAAW,UAAS;GAAE,YAAY,KAAK;GAAG,IAAI,MAAM,QAAQ,UAAU,KAAK;EAAG;EAC7E,UAAA,aAAa,OAAO,oBAAC,MAAD,EAAM,MAAM,KAAO,CAAA,IAAI;CACtC,CAAA,GACP,YAAY,aAAa,oBAAC,QAAD;EAAM,KAAK;EAAgB,WAAU;EAAmB,MAAK;EAAU,kBAAgB,SAAS;EACxH,sBAAsB,aAAa,MAAM,OAAO;EAAG,gBAAgB;EACnE,OAAO;GAAE,MAAM,SAAS;GAAM,KAAK,SAAS;GAAK,GAAG,SAAS;EAAM;EAAI,UAAA;CAAW,CAAA,GAAG,OAAO,SAAS,cAAc,QAAQ,SAAS,IAAI,CAC1I,EAAA,CAAA;AACJ,CAAC"}
|
package/docs/api-reference.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
| `/context` | `useChatContext`、`ContextTray`、`createTextSelectionAdapter` |
|
|
13
13
|
| `/appearance` | `ChatAppearanceProvider`、`ChatIcon`、`ChatIconButton` 和类型 |
|
|
14
14
|
| `/voice` | `useSpeechInput`、`createBrowserSpeechAdapter`、语音契约与错误类型 |
|
|
15
|
-
| `/markdown` | `MarkdownResponse
|
|
15
|
+
| `/markdown` | `MarkdownResponse`;Streamdown 随包自动安装 |
|
|
16
16
|
| `/styles.css` | 组件作用域样式;不依赖 Tailwind |
|
|
17
17
|
|
|
18
18
|
`@galaxycore/ai-chat-gateway` 是单独的服务器包,只能在 Node 服务端导入。
|
|
@@ -45,7 +45,7 @@ options 沿用 `@ai-sdk/react` 的 `UseChatOptions<M>`。返回 SDK `UseChatHelp
|
|
|
45
45
|
| `empty` | ReactNode | 空会话引导,快捷问题由宿主发送 |
|
|
46
46
|
| `composer` / `footer` | ReactNode | 完整替换输入区 / 底部说明 |
|
|
47
47
|
| `composerProps` | Composer props 子集 | 上下文、toolbar、attachments、speech、disabled |
|
|
48
|
-
| `renderText` | `({text,isStreaming}) => ReactNode` | Markdown
|
|
48
|
+
| `renderText` | `({text,isStreaming}) => ReactNode` | 覆盖默认助手 Markdown / 用户纯文本渲染 |
|
|
49
49
|
| `smoothStreaming` | `boolean`,默认 `true` | 活跃文本的短窗口平滑显示;停止立即展示全文,自定义 part renderer 自行控制。见 [流式体验](streaming.md) |
|
|
50
50
|
| `renderers` | 按 part.type 映射 | 最高优先级的自定义消息片段 |
|
|
51
51
|
| `tools` | 按 toolName 映射 | 自定义业务工具结果卡片 |
|
package/docs/design.md
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
└─ 宿主自定义 Transport:已有协议或专用执行环境
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
一个 npm 包,多入口:根入口提供 UI 与 hook;`/headless` 不引入界面/Markdown;`/markdown`
|
|
25
|
+
一个 npm 包,多入口:根入口提供 UI 与 hook;`/headless` 不引入界面/Markdown;`/markdown` 独立导出默认 Streamdown 渲染器;`/styles.css` 显式引入;`/ag-ui` 提供框架无关的 AG-UI 文本/工具子集协议适配。React、AI SDK 用 peer dependency 避免宿主双实例。ESM 和 TypeScript 声明,保留 `use client`,适配 Vite/Next.js;不依赖 Next.js API、不要求 Tailwind/shadcn、不访问全局业务 store。
|
|
26
26
|
|
|
27
27
|
统一采用 AI SDK 7 的 `UIMessage`/`ChatTransport`/`UseChatOptions`,不复制协议、不创建第二套消息状态机。泛型消息沿 hook、面板、renderers 传递。通过 `chat` 控制器属性组合 UI,避免全局单例和弱类型 Context。外部 `Chat` 实例可跨面板保持会话;会话切换按 id 或实例管理,输入草稿随会话清空。
|
|
28
28
|
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
| 生命周期 | 原生 onFinish/onError/onData/onToolCall | 埋点、持久化、自定义工具执行 |
|
|
39
39
|
| 历史数据 | options.messages、chat.setMessages | 加载、分页、冲突策略、服务端 schema 校验 |
|
|
40
40
|
|
|
41
|
-
附件仅在显式配置上传接口时启用;不默认把大文件转 base64
|
|
41
|
+
附件仅在显式配置上传接口时启用;不默认把大文件转 base64。前端文件大小/类型校验只是体验约束,服务端必须重新校验。助手文本默认安全渲染 Markdown,用户文本默认保留原文;Streamdown 为运行依赖;链接过滤协议,外链使用 noopener/noreferrer。工具输出默认结构化展示,工具动作由显式审批按钮触发,包不执行宿主工具。
|
|
42
42
|
|
|
43
43
|
## 最新稳定技术栈
|
|
44
44
|
|
package/docs/integration.md
CHANGED
|
@@ -10,11 +10,10 @@
|
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
12
|
npm install @galaxycore/ai-chat ai@^7.0.137 @ai-sdk/react@^4.0.140
|
|
13
|
-
#
|
|
14
|
-
npm install streamdown@^2.7.0
|
|
13
|
+
# Streamdown is installed automatically with the chat package.
|
|
15
14
|
```
|
|
16
15
|
|
|
17
|
-
宿主已有 React/React DOM;不要让组件包安装出另一份 React。根入口提供默认 UI 与 hook,`/headless` 只提供无界面能力,`/markdown`
|
|
16
|
+
宿主已有 React/React DOM;不要让组件包安装出另一份 React。根入口提供默认 UI 与 hook,`/headless` 只提供无界面能力,`/markdown` 提供独立 `MarkdownResponse`,`/styles.css` 必须由宿主显式导入。消费构建使用 ESM,无需 Tailwind 或 shadcn。
|
|
18
17
|
|
|
19
18
|
```tsx
|
|
20
19
|
import { useMemo } from 'react';
|
|
@@ -39,7 +38,7 @@ export function Assistant() {
|
|
|
39
38
|
}
|
|
40
39
|
```
|
|
41
40
|
|
|
42
|
-
Markdown
|
|
41
|
+
助手回复默认启用 Markdown,用户输入保留原文。`renderText` 可以覆盖默认行为,`/markdown` 入口继续兼容。完全自定义 UI 时,从 `/headless` 导入 `useAiChat` 并使用 `chat.messages`、`sendMessage`、`stop`、`regenerate` 等标准控制器方法。
|
|
43
42
|
|
|
44
43
|
## 浏览器与后端 agent 的分工
|
|
45
44
|
|