agentic-ui-kit 0.8.0 → 0.9.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/README.md +19 -15
- package/dist/ask-user-CwDYhXX4.js +388 -0
- package/dist/core.js +3 -103
- package/dist/extensions-CJ4Asuxk.js +329 -0
- package/dist/index.js +43 -1394
- package/dist/partial-json-w_oXePqJ.js +111 -0
- package/dist/types/core/src/blocks.d.ts +1 -1
- package/dist/types/core/src/events.d.ts +1 -1
- package/dist/types/core/src/index.d.ts +9 -20
- package/dist/types/core/src/reduce.d.ts +2 -2
- package/dist/types/core/src/sse.d.ts +1 -1
- package/dist/types/core/src/ui-components.d.ts +1 -1
- package/dist/types/core/src/ui-markup.d.ts +1 -1
- package/dist/types/core/src/visuals.d.ts +11 -0
- package/dist/types/react/src/components/approval-card.d.ts +1 -1
- package/dist/types/react/src/components/ask-user.d.ts +1 -1
- package/dist/types/react/src/components/chat-list.d.ts +1 -1
- package/dist/types/react/src/components/composer.d.ts +1 -1
- package/dist/types/react/src/components/extensions.d.ts +50 -0
- package/dist/types/react/src/components/message-list.d.ts +1 -1
- package/dist/types/react/src/components/messages.d.ts +1 -1
- package/dist/types/react/src/components/tool-prompt.d.ts +1 -1
- package/dist/types/react/src/components/tools.d.ts +2 -2
- package/dist/types/react/src/hooks/sse-transport.d.ts +1 -1
- package/dist/types/react/src/hooks/use-chat.d.ts +1 -1
- package/dist/types/react/src/index.d.ts +86 -90
- package/dist/types/react/src/primitives/chat-theme.d.ts +3 -3
- package/dist/types/react/src/views/chat-transcript.d.ts +2 -5
- package/dist/types/react/src/views/chat-view.d.ts +4 -11
- package/dist/types/react/src/views/sidebar.d.ts +1 -1
- package/dist/types/react/src/visuals/core.d.ts +1 -0
- package/dist/types/react/src/visuals/index.d.ts +8 -0
- package/dist/types/react/src/visuals/provider.d.ts +26 -0
- package/dist/types/react/src/{components → visuals}/ui-components.d.ts +2 -2
- package/dist/types/react/src/{components → visuals}/ui-tree.d.ts +2 -1
- package/dist/types/react/src/{components → visuals}/widget-frame.d.ts +2 -1
- package/dist/{src-BrPYkHdt.js → visuals-CxCXnEob.js} +96 -490
- package/dist/visuals-core.js +1 -0
- package/dist/visuals.js +1134 -0
- package/package.json +9 -1
- /package/dist/types/react/src/{components → visuals}/replacements.d.ts +0 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
3
|
+
import { createContext, useContext, useId, useMemo } from "react";
|
|
4
|
+
import { Button, Tooltip, TooltipTrigger } from "react-aria-components";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/primitives/cx.ts
|
|
7
|
+
const twMerge = extendTailwindMerge({ extend: { theme: {
|
|
8
|
+
radius: [
|
|
9
|
+
"chat-sm",
|
|
10
|
+
"chat-md",
|
|
11
|
+
"chat-lg",
|
|
12
|
+
"chat-popover"
|
|
13
|
+
],
|
|
14
|
+
shadow: ["chat-popover"],
|
|
15
|
+
animate: [
|
|
16
|
+
"chat-in",
|
|
17
|
+
"chat-out",
|
|
18
|
+
"chat-fade-in",
|
|
19
|
+
"chat-fade-out",
|
|
20
|
+
"chat-drawer-in",
|
|
21
|
+
"chat-drawer-out",
|
|
22
|
+
"chat-drawer-in-right",
|
|
23
|
+
"chat-drawer-out-right",
|
|
24
|
+
"chat-sheet-in",
|
|
25
|
+
"chat-sheet-out"
|
|
26
|
+
]
|
|
27
|
+
} } });
|
|
28
|
+
/** `clsx` plus tailwind-merge: later classes win over earlier ones that set the same property, so a caller's `h-7` or `rounded-none` beats the kit's. */
|
|
29
|
+
function cx(...inputs) {
|
|
30
|
+
return twMerge(clsx(inputs));
|
|
31
|
+
}
|
|
32
|
+
// src/primitives/tooltip.tsx
|
|
33
|
+
function Tooltip$1({ content, children, placement = "top", delay = 600 }) {
|
|
34
|
+
return /* @__PURE__ */ jsxs(TooltipTrigger, {
|
|
35
|
+
delay,
|
|
36
|
+
closeDelay: 0,
|
|
37
|
+
children: [children, /* @__PURE__ */ jsx(Tooltip, {
|
|
38
|
+
placement,
|
|
39
|
+
offset: 6,
|
|
40
|
+
className: "rounded-chat-sm bg-chat-raised px-2 py-1 font-chat-sans text-(length:--chat-ui-font-size-sm) leading-4 text-chat-fg shadow-chat-popover motion-safe:data-entering:animate-chat-in motion-safe:data-exiting:animate-chat-out",
|
|
41
|
+
children: content
|
|
42
|
+
})]
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
// src/primitives/button.tsx
|
|
46
|
+
const focusRing = "outline-none data-focus-visible:ring-2 data-focus-visible:ring-chat-focus";
|
|
47
|
+
const variants = {
|
|
48
|
+
/** Plain text button, highlights on hover. Sidebar rows, header buttons. */
|
|
49
|
+
ghost: "text-chat-fg data-hovered:bg-chat-hover data-pressed:bg-chat-selected",
|
|
50
|
+
/** Filled with the surface color, e.g. the selected Chat/Cowork toggle. */
|
|
51
|
+
subtle: "bg-chat-surface font-medium text-chat-fg data-hovered:bg-chat-hover data-pressed:bg-chat-selected",
|
|
52
|
+
/** A thin border, no fill: secondary actions next to a primary one, e.g. Cancel or Share. */
|
|
53
|
+
outline: "border border-chat-border-strong font-medium text-chat-fg data-hovered:bg-chat-hover data-pressed:bg-chat-selected",
|
|
54
|
+
/** The send button and the one main action of a dialog. */
|
|
55
|
+
primary: "bg-chat-accent font-medium text-chat-accent-fg data-hovered:brightness-110 data-pressed:brightness-95",
|
|
56
|
+
/**
|
|
57
|
+
* Destructive confirmations, e.g. Delete chat. Fill --chat-danger-bg (default: --chat-danger, darkened so it
|
|
58
|
+
* doesn't read as the accent), text --chat-danger-fg (default white).
|
|
59
|
+
*/
|
|
60
|
+
danger: "bg-[var(--chat-danger-bg,color-mix(in_srgb,var(--chat-danger)_70%,black))] font-medium text-[var(--chat-danger-fg,#fff)] data-hovered:brightness-110 data-pressed:brightness-95"
|
|
61
|
+
};
|
|
62
|
+
const sizes = {
|
|
63
|
+
sm: "h-7 gap-1.5 px-2 text-(length:--chat-ui-font-size) leading-5 [@media(pointer:coarse)]:h-9",
|
|
64
|
+
md: "h-8 gap-2 px-2.5 text-(length:--chat-ui-font-size) leading-5 [@media(pointer:coarse)]:h-10",
|
|
65
|
+
/** Dialog and empty-state actions. */
|
|
66
|
+
lg: "h-9 gap-2 px-3.5 text-(length:--chat-ui-font-size) leading-5 [@media(pointer:coarse)]:h-11"
|
|
67
|
+
};
|
|
68
|
+
/** Press handlers dropped from a button that is disabled with a reason; it only looks and announces as disabled. */
|
|
69
|
+
const pressHandlers = [
|
|
70
|
+
"onPress",
|
|
71
|
+
"onPressStart",
|
|
72
|
+
"onPressEnd",
|
|
73
|
+
"onPressChange",
|
|
74
|
+
"onPressUp",
|
|
75
|
+
"onClick"
|
|
76
|
+
];
|
|
77
|
+
/**
|
|
78
|
+
* A disabled button that still explains itself. React Aria's `isDisabled` makes the button unfocusable and
|
|
79
|
+
* hoverable-less, so there'd be nothing to hang a tooltip on. With a reason the button instead stays focusable
|
|
80
|
+
* with `aria-disabled`, loses its press handlers and never submits a form, and the reason is shown as a tooltip
|
|
81
|
+
* and read as its description.
|
|
82
|
+
*/
|
|
83
|
+
function useDisabledReason(props, disabledReason) {
|
|
84
|
+
const id = useId();
|
|
85
|
+
const active = Boolean(props.isDisabled && disabledReason);
|
|
86
|
+
if (!active) return {
|
|
87
|
+
active,
|
|
88
|
+
props,
|
|
89
|
+
reasonId: void 0
|
|
90
|
+
};
|
|
91
|
+
const rest = {
|
|
92
|
+
...props,
|
|
93
|
+
isDisabled: false,
|
|
94
|
+
type: "button"
|
|
95
|
+
};
|
|
96
|
+
for (const h of pressHandlers) delete rest[h];
|
|
97
|
+
rest["aria-disabled"] = true;
|
|
98
|
+
rest["data-disabled"] = true;
|
|
99
|
+
rest["aria-describedby"] = [props["aria-describedby"], id].filter(Boolean).join(" ");
|
|
100
|
+
return {
|
|
101
|
+
active,
|
|
102
|
+
props: rest,
|
|
103
|
+
reasonId: id
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** Hover and press styles are dropped while a button is disabled with a reason, to look as disabled as one that is. */
|
|
107
|
+
const noInteraction = (classes) => classes.replace(/data-(hovered|pressed):\S+\s*/g, "");
|
|
108
|
+
function WithReason({ active, reasonId, reason, children }) {
|
|
109
|
+
if (!active) return children;
|
|
110
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Tooltip$1, {
|
|
111
|
+
content: reason,
|
|
112
|
+
children
|
|
113
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
114
|
+
id: reasonId,
|
|
115
|
+
hidden: true,
|
|
116
|
+
children: reason
|
|
117
|
+
})] });
|
|
118
|
+
}
|
|
119
|
+
function Button$1({ variant = "ghost", size = "md", className, disabledReason, ...rest }) {
|
|
120
|
+
const { active, props, reasonId } = useDisabledReason(rest, disabledReason);
|
|
121
|
+
const button = /* @__PURE__ */ jsx(Button, {
|
|
122
|
+
...props,
|
|
123
|
+
className: cx("inline-flex cursor-pointer items-center justify-center rounded-chat-sm font-chat-sans whitespace-nowrap transition-colors select-none [&_svg]:size-4 [&_svg]:shrink-0", "data-disabled:cursor-default data-disabled:opacity-40", focusRing, active ? noInteraction(variants[variant]) : variants[variant], sizes[size], className)
|
|
124
|
+
});
|
|
125
|
+
return /* @__PURE__ */ jsx(WithReason, {
|
|
126
|
+
active,
|
|
127
|
+
reasonId,
|
|
128
|
+
reason: disabledReason,
|
|
129
|
+
children: button
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function IconButton({ label, variant = "ghost", size = "md", tooltip = true, className, disabledReason, ...rest }) {
|
|
133
|
+
const { active, props, reasonId } = useDisabledReason(rest, disabledReason);
|
|
134
|
+
const button = /* @__PURE__ */ jsx(Button, {
|
|
135
|
+
...props,
|
|
136
|
+
"aria-label": label,
|
|
137
|
+
className: cx("inline-flex shrink-0 cursor-pointer items-center justify-center rounded-chat-sm transition-colors select-none", "data-disabled:cursor-default data-disabled:opacity-40 [&_svg]:size-4", focusRing, active ? noInteraction(variants[variant]) : variants[variant], variant === "ghost" && (active ? "text-chat-muted" : "text-chat-muted data-hovered:text-chat-fg"), size === "sm" ? "size-7 [@media(pointer:coarse)]:size-9" : "size-8 [@media(pointer:coarse)]:size-10", className)
|
|
138
|
+
});
|
|
139
|
+
if (active) return /* @__PURE__ */ jsx(WithReason, {
|
|
140
|
+
active: true,
|
|
141
|
+
reasonId,
|
|
142
|
+
reason: disabledReason,
|
|
143
|
+
children: button
|
|
144
|
+
});
|
|
145
|
+
return tooltip ? /* @__PURE__ */ jsx(Tooltip$1, {
|
|
146
|
+
content: label,
|
|
147
|
+
children: button
|
|
148
|
+
}) : button;
|
|
149
|
+
}
|
|
150
|
+
// src/primitives/labels.tsx
|
|
151
|
+
const plural = (count, one, many) => count === 1 ? one : many(count);
|
|
152
|
+
/** The English strings. */
|
|
153
|
+
const defaultLabels = {
|
|
154
|
+
thinking: "Thinking…",
|
|
155
|
+
thought: "Thought",
|
|
156
|
+
thoughtFor: (duration) => `Thought for ${duration}`,
|
|
157
|
+
waitingForYou: " · waiting for you",
|
|
158
|
+
usedTool: (name) => `used ${name}`,
|
|
159
|
+
joinSummaries: (phrases) => {
|
|
160
|
+
const text = phrases.join(", ");
|
|
161
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
162
|
+
},
|
|
163
|
+
duration: (seconds) => seconds < 60 ? `${seconds}s` : `${Math.floor(seconds / 60)}m ${seconds % 60}s`,
|
|
164
|
+
ranCommandLabel: "Ran a command",
|
|
165
|
+
ranCommands: (count) => plural(count, "ran a command", (n) => `ran ${n} commands`),
|
|
166
|
+
runCommandAsk: "Run this command?",
|
|
167
|
+
searchWebAsk: "Search the web?",
|
|
168
|
+
readPageAsk: "Read this page?",
|
|
169
|
+
searchedWebLabel: "Searched the web",
|
|
170
|
+
readPageLabel: "Read page",
|
|
171
|
+
readPages: (count) => plural(count, "read a page", (n) => `read ${n} pages`),
|
|
172
|
+
searchedWeb: (count) => plural(count, "searched the web", (n) => `searched the web ${n} times`),
|
|
173
|
+
recalledMemoryLabel: "Recalled memory",
|
|
174
|
+
recalledMemory: () => "recalled memory",
|
|
175
|
+
output: "Output",
|
|
176
|
+
noOutput: "(no output)",
|
|
177
|
+
noResults: "No results",
|
|
178
|
+
reasoningHidden: "The model's reasoning is not shown.",
|
|
179
|
+
allowTool: (name) => `Allow ${name}?`,
|
|
180
|
+
allowAction: (label) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
181
|
+
"Allow ",
|
|
182
|
+
label,
|
|
183
|
+
"?"
|
|
184
|
+
] }),
|
|
185
|
+
allow: "Allow",
|
|
186
|
+
deny: "Deny",
|
|
187
|
+
sidebar: "Sidebar",
|
|
188
|
+
closeSidebar: "Close sidebar",
|
|
189
|
+
openSidebar: "Open sidebar",
|
|
190
|
+
expandSidebar: "Expand sidebar",
|
|
191
|
+
collapseSidebar: "Collapse sidebar",
|
|
192
|
+
resizeSidebar: "Resize sidebar",
|
|
193
|
+
withShortcut: (label, keys) => `${label} (${keys})`,
|
|
194
|
+
ctrlKey: "Ctrl",
|
|
195
|
+
context: "Context",
|
|
196
|
+
contextUsed: "Context used",
|
|
197
|
+
percentUsed: (percent) => `${percent}% used`,
|
|
198
|
+
contextSummary: (used, limit, percent) => `Context: ${used} / ${limit} (${percent}%)`,
|
|
199
|
+
contextLoading: "Context: loading",
|
|
200
|
+
freeSpace: "Free space",
|
|
201
|
+
tokenCount: (count) => `${count} tokens`,
|
|
202
|
+
replyPlaceholder: "Reply…",
|
|
203
|
+
replyDirectly: "Or reply directly…",
|
|
204
|
+
askUserPrompt: "Question for you",
|
|
205
|
+
askUserPager: (current, total) => `${current} of ${total}`,
|
|
206
|
+
askUserPrevious: "Previous question",
|
|
207
|
+
askUserNext: "Next question",
|
|
208
|
+
askUserContinue: "Continue",
|
|
209
|
+
askUserSubmit: "Send answers",
|
|
210
|
+
askUserClose: "Close and decline",
|
|
211
|
+
askUserSomethingElse: "Something else",
|
|
212
|
+
askUserSkip: "Skip",
|
|
213
|
+
askUserSelected: (count) => `${count} selected`,
|
|
214
|
+
askUserRankHint: "Drag to re-order",
|
|
215
|
+
askUserReorder: (option) => `Move ${option}`,
|
|
216
|
+
askUserReorderKeys: "Press Alt with the up or down arrow to move",
|
|
217
|
+
askUserPicked: (options) => options.join(", "),
|
|
218
|
+
askUserRanked: (options) => `Ranked: ${options.map((o, i) => `${i + 1}. ${o}`).join(" ")}`,
|
|
219
|
+
askUserSkipped: "Skipped",
|
|
220
|
+
askUserDeclined: "You declined to answer",
|
|
221
|
+
askUserAnswers: "Your answers",
|
|
222
|
+
message: "Message",
|
|
223
|
+
stop: "Stop",
|
|
224
|
+
send: "Send",
|
|
225
|
+
listening: "Listening…",
|
|
226
|
+
transcribing: "Transcribing…",
|
|
227
|
+
dictate: "Dictate",
|
|
228
|
+
dictationCancel: "Cancel dictation",
|
|
229
|
+
dictationAccept: "Use dictation",
|
|
230
|
+
addFiles: "Add files and more",
|
|
231
|
+
attachments: "Attachments",
|
|
232
|
+
editPastedText: "Edit pasted text",
|
|
233
|
+
viewPastedText: "View pasted text",
|
|
234
|
+
removeAttachment: (name) => `Remove ${name}`,
|
|
235
|
+
pastedText: "Pasted text",
|
|
236
|
+
pasted: "Pasted",
|
|
237
|
+
failed: "Failed",
|
|
238
|
+
file: "File",
|
|
239
|
+
uploadFailed: "Upload failed",
|
|
240
|
+
cancel: "Cancel",
|
|
241
|
+
close: "Close",
|
|
242
|
+
save: "Save",
|
|
243
|
+
chats: "Chats",
|
|
244
|
+
running: "Running",
|
|
245
|
+
unread: "Unread",
|
|
246
|
+
moreOptionsFor: (title) => `More options for ${title}`,
|
|
247
|
+
new: "New",
|
|
248
|
+
viewAll: "View all",
|
|
249
|
+
chatActions: "Chat actions",
|
|
250
|
+
pin: "Pin",
|
|
251
|
+
unpin: "Unpin",
|
|
252
|
+
rename: "Rename",
|
|
253
|
+
addToProject: "Add to project",
|
|
254
|
+
searchProjects: "Search or create a project",
|
|
255
|
+
projects: "Projects",
|
|
256
|
+
newProject: "New project",
|
|
257
|
+
shareChat: "Share chat",
|
|
258
|
+
delete: "Delete",
|
|
259
|
+
justNow: "just now",
|
|
260
|
+
copy: "Copy",
|
|
261
|
+
copied: "Copied",
|
|
262
|
+
copyFieldLabel: "Link",
|
|
263
|
+
retry: "Retry",
|
|
264
|
+
edit: "Edit",
|
|
265
|
+
readAloud: "Read aloud",
|
|
266
|
+
goodResponse: "Good response",
|
|
267
|
+
badResponse: "Bad response",
|
|
268
|
+
somethingWentWrong: "Something went wrong.",
|
|
269
|
+
conversation: "Conversation",
|
|
270
|
+
scrollToBottom: "Scroll to bottom",
|
|
271
|
+
showMore: "Show more",
|
|
272
|
+
showLess: "Show less",
|
|
273
|
+
model: "Model",
|
|
274
|
+
modelButton: (label) => `Model: ${label}`,
|
|
275
|
+
effort: "Effort",
|
|
276
|
+
effortNote: "Higher effort means more thorough responses, but takes longer and uses your limits faster.",
|
|
277
|
+
recommended: "Recommended",
|
|
278
|
+
effortFaster: "Faster",
|
|
279
|
+
effortSmarter: "Smarter",
|
|
280
|
+
moreModels: "More models",
|
|
281
|
+
widget: "Widget",
|
|
282
|
+
visualUpdated: "Updated below ↓",
|
|
283
|
+
visualUpdating: "Updating…",
|
|
284
|
+
drawingWidget: "Drawing"
|
|
285
|
+
};
|
|
286
|
+
const LabelsContext = createContext(defaultLabels);
|
|
287
|
+
/** Merges `labels` over the labels of the enclosing provider (or the defaults). */
|
|
288
|
+
function LabelsProvider({ labels, children }) {
|
|
289
|
+
const parent = useLabels();
|
|
290
|
+
const merged = useMemo(() => labels ? {
|
|
291
|
+
...parent,
|
|
292
|
+
...labels
|
|
293
|
+
} : parent, [parent, labels]);
|
|
294
|
+
return /* @__PURE__ */ jsx(LabelsContext.Provider, {
|
|
295
|
+
value: merged,
|
|
296
|
+
children
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
/** The active UI strings: the enclosing `ChatTheme`'s `labels` over the English defaults. */
|
|
300
|
+
function useLabels() {
|
|
301
|
+
return useContext(LabelsContext);
|
|
302
|
+
}
|
|
303
|
+
// src/components/extensions.tsx
|
|
304
|
+
const ExtensionsContext = createContext({});
|
|
305
|
+
/** Plugs extensions into every message list below it. Nested providers add to (and override) the outer one. */
|
|
306
|
+
function ChatExtensionsProvider({ extensions, children }) {
|
|
307
|
+
const outer = useContext(ExtensionsContext);
|
|
308
|
+
const value = useMemo(() => ({
|
|
309
|
+
...outer,
|
|
310
|
+
...extensions,
|
|
311
|
+
codeBlocks: {
|
|
312
|
+
...outer.codeBlocks,
|
|
313
|
+
...extensions.codeBlocks
|
|
314
|
+
}
|
|
315
|
+
}), [outer, extensions]);
|
|
316
|
+
return /* @__PURE__ */ jsx(ExtensionsContext.Provider, {
|
|
317
|
+
value,
|
|
318
|
+
children
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
function useChatExtensions() {
|
|
322
|
+
return useContext(ExtensionsContext);
|
|
323
|
+
}
|
|
324
|
+
const InteractionContext = createContext({});
|
|
325
|
+
const ChatInteractionProvider = InteractionContext.Provider;
|
|
326
|
+
function useChatInteraction() {
|
|
327
|
+
return useContext(InteractionContext);
|
|
328
|
+
}
|
|
329
|
+
export { LabelsProvider as a, Button$1 as c, cx as d, useChatInteraction as i, IconButton as l, ChatInteractionProvider as n, defaultLabels as o, useChatExtensions as r, useLabels as s, ChatExtensionsProvider as t, Tooltip$1 as u };
|