@cellarnode/ui 0.202.0 → 0.206.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/README.md +25 -9
- package/dist/agent/activity-ledger.d.ts.map +1 -1
- package/dist/agent/activity-ledger.js +1 -1
- package/dist/agent/activity-ledger.js.map +1 -1
- package/dist/agent/composer.d.ts +64 -2
- package/dist/agent/composer.d.ts.map +1 -1
- package/dist/agent/composer.js +247 -9
- package/dist/agent/composer.js.map +1 -1
- package/dist/agent/confirm-card.d.ts.map +1 -1
- package/dist/agent/confirm-card.js +1 -1
- package/dist/agent/confirm-card.js.map +1 -1
- package/dist/agent/context.d.ts +94 -0
- package/dist/agent/context.d.ts.map +1 -0
- package/dist/agent/context.js +92 -0
- package/dist/agent/context.js.map +1 -0
- package/dist/agent/conversation.d.ts +41 -1
- package/dist/agent/conversation.d.ts.map +1 -1
- package/dist/agent/conversation.js +91 -6
- package/dist/agent/conversation.js.map +1 -1
- package/dist/agent/dropzone.d.ts +155 -0
- package/dist/agent/dropzone.d.ts.map +1 -0
- package/dist/agent/dropzone.js +404 -0
- package/dist/agent/dropzone.js.map +1 -0
- package/dist/agent/fixtures.d.ts.map +1 -1
- package/dist/agent/fixtures.js +6 -0
- package/dist/agent/fixtures.js.map +1 -1
- package/dist/agent/index.d.ts +12 -1
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +10 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/markdown.d.ts.map +1 -1
- package/dist/agent/markdown.js +127 -9
- package/dist/agent/markdown.js.map +1 -1
- package/dist/agent/mentions.d.ts +75 -0
- package/dist/agent/mentions.d.ts.map +1 -0
- package/dist/agent/mentions.js +184 -0
- package/dist/agent/mentions.js.map +1 -0
- package/dist/agent/message.d.ts +16 -1
- package/dist/agent/message.d.ts.map +1 -1
- package/dist/agent/message.js +26 -6
- package/dist/agent/message.js.map +1 -1
- package/dist/agent/quote-reply.d.ts +40 -0
- package/dist/agent/quote-reply.d.ts.map +1 -0
- package/dist/agent/quote-reply.js +97 -0
- package/dist/agent/quote-reply.js.map +1 -0
- package/dist/agent/role-cards/brand-profile-card.d.ts +60 -0
- package/dist/agent/role-cards/brand-profile-card.d.ts.map +1 -0
- package/dist/agent/role-cards/brand-profile-card.js +113 -0
- package/dist/agent/role-cards/brand-profile-card.js.map +1 -0
- package/dist/agent/role-cards/card-text.d.ts +10 -0
- package/dist/agent/role-cards/card-text.d.ts.map +1 -0
- package/dist/agent/role-cards/card-text.js +38 -0
- package/dist/agent/role-cards/card-text.js.map +1 -0
- package/dist/agent/role-cards/fixtures.d.ts +29 -1
- package/dist/agent/role-cards/fixtures.d.ts.map +1 -1
- package/dist/agent/role-cards/fixtures.js +210 -1
- package/dist/agent/role-cards/fixtures.js.map +1 -1
- package/dist/agent/role-cards/host-contract.d.ts +34 -4
- package/dist/agent/role-cards/host-contract.d.ts.map +1 -1
- package/dist/agent/role-cards/host-contract.js +87 -1
- package/dist/agent/role-cards/host-contract.js.map +1 -1
- package/dist/agent/role-cards/inspector-view.d.ts.map +1 -1
- package/dist/agent/role-cards/inspector-view.js +12 -0
- package/dist/agent/role-cards/inspector-view.js.map +1 -1
- package/dist/agent/role-cards/lab-report-card.d.ts +40 -0
- package/dist/agent/role-cards/lab-report-card.d.ts.map +1 -0
- package/dist/agent/role-cards/lab-report-card.js +58 -0
- package/dist/agent/role-cards/lab-report-card.js.map +1 -0
- package/dist/agent/role-cards/label-card.d.ts +42 -0
- package/dist/agent/role-cards/label-card.d.ts.map +1 -0
- package/dist/agent/role-cards/label-card.js +65 -0
- package/dist/agent/role-cards/label-card.js.map +1 -0
- package/dist/agent/role-cards/org-card.d.ts +20 -0
- package/dist/agent/role-cards/org-card.d.ts.map +1 -0
- package/dist/agent/role-cards/org-card.js +37 -0
- package/dist/agent/role-cards/org-card.js.map +1 -0
- package/dist/agent/role-cards/registry.d.ts +13 -1
- package/dist/agent/role-cards/registry.d.ts.map +1 -1
- package/dist/agent/role-cards/registry.js +33 -0
- package/dist/agent/role-cards/registry.js.map +1 -1
- package/dist/agent/role-cards/schedule-card.d.ts +30 -0
- package/dist/agent/role-cards/schedule-card.d.ts.map +1 -0
- package/dist/agent/role-cards/schedule-card.js +58 -0
- package/dist/agent/role-cards/schedule-card.js.map +1 -0
- package/dist/agent/role-cards/stats-card.d.ts +30 -0
- package/dist/agent/role-cards/stats-card.d.ts.map +1 -0
- package/dist/agent/role-cards/stats-card.js +31 -0
- package/dist/agent/role-cards/stats-card.js.map +1 -0
- package/dist/agent/role-cards/text-safety.d.ts +3 -0
- package/dist/agent/role-cards/text-safety.d.ts.map +1 -1
- package/dist/agent/role-cards/text-safety.js +16 -0
- package/dist/agent/role-cards/text-safety.js.map +1 -1
- package/dist/agent/schema.d.ts +21 -0
- package/dist/agent/schema.d.ts.map +1 -1
- package/dist/agent/schema.js +22 -1
- package/dist/agent/schema.js.map +1 -1
- package/dist/agent/suggestions.d.ts +66 -0
- package/dist/agent/suggestions.d.ts.map +1 -0
- package/dist/agent/suggestions.js +186 -0
- package/dist/agent/suggestions.js.map +1 -0
- package/dist/agent/text-clean.d.ts +12 -0
- package/dist/agent/text-clean.d.ts.map +1 -0
- package/dist/agent/text-clean.js +55 -0
- package/dist/agent/text-clean.js.map +1 -0
- package/dist/agent/thread-list.d.ts +16 -4
- package/dist/agent/thread-list.d.ts.map +1 -1
- package/dist/agent/thread-list.js +43 -26
- package/dist/agent/thread-list.js.map +1 -1
- package/dist/agent/thread-title.d.ts +46 -0
- package/dist/agent/thread-title.d.ts.map +1 -0
- package/dist/agent/thread-title.js +99 -0
- package/dist/agent/thread-title.js.map +1 -0
- package/dist/agent/tool-activity-model.d.ts +4 -0
- package/dist/agent/tool-activity-model.d.ts.map +1 -1
- package/dist/agent/tool-activity-model.js +7 -0
- package/dist/agent/tool-activity-model.js.map +1 -1
- package/dist/agent/tool-activity.d.ts +6 -0
- package/dist/agent/tool-activity.d.ts.map +1 -1
- package/dist/agent/tool-activity.js +51 -9
- package/dist/agent/tool-activity.js.map +1 -1
- package/dist/agent/tool-call-card.d.ts +2 -0
- package/dist/agent/tool-call-card.d.ts.map +1 -1
- package/dist/agent/tool-call-card.js +13 -3
- package/dist/agent/tool-call-card.js.map +1 -1
- package/dist/agent/ui.d.ts +7 -0
- package/dist/agent/ui.d.ts.map +1 -1
- package/dist/agent/ui.js +7 -0
- package/dist/agent/ui.js.map +1 -1
- package/dist/animated-icons/download-icon.d.ts.map +1 -1
- package/dist/animated-icons/download-icon.js +6 -1
- package/dist/animated-icons/download-icon.js.map +1 -1
- package/dist/animated-icons/filter-icon.d.ts.map +1 -1
- package/dist/animated-icons/filter-icon.js +6 -1
- package/dist/animated-icons/filter-icon.js.map +1 -1
- package/dist/animated-icons/upload-icon.d.ts.map +1 -1
- package/dist/animated-icons/upload-icon.js +6 -1
- package/dist/animated-icons/upload-icon.js.map +1 -1
- package/dist/brand/brand-image-source-picker.d.ts.map +1 -1
- package/dist/brand/brand-image-source-picker.js +9 -6
- package/dist/brand/brand-image-source-picker.js.map +1 -1
- package/dist/brand/brand-profile-form-values.d.ts +2 -2
- package/dist/chat/chat-surface.d.ts +16 -1
- package/dist/chat/chat-surface.d.ts.map +1 -1
- package/dist/chat/chat-surface.js +18 -16
- package/dist/chat/chat-surface.js.map +1 -1
- package/dist/chat/chat-toggle-button.d.ts.map +1 -1
- package/dist/chat/chat-toggle-button.js +11 -5
- package/dist/chat/chat-toggle-button.js.map +1 -1
- package/dist/chat/index.d.ts +1 -1
- package/dist/chat/index.d.ts.map +1 -1
- package/dist/chat/index.js.map +1 -1
- package/dist/components/bottle-extract-dialog.js +1 -1
- package/dist/components/bottle-extract-dialog.js.map +1 -1
- package/dist/components/branch-overview-panel.d.ts.map +1 -1
- package/dist/components/branch-overview-panel.js +8 -4
- package/dist/components/branch-overview-panel.js.map +1 -1
- package/dist/components/branch-resolution-modal.js +1 -1
- package/dist/components/branch-resolution-modal.js.map +1 -1
- package/dist/components/card-stack.d.ts.map +1 -1
- package/dist/components/card-stack.js +9 -1
- package/dist/components/card-stack.js.map +1 -1
- package/dist/components/copy-button.d.ts.map +1 -1
- package/dist/components/copy-button.js +15 -4
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/listbox.d.ts.map +1 -1
- package/dist/components/listbox.js +5 -1
- package/dist/components/listbox.js.map +1 -1
- package/dist/components/metric-card.d.ts +1 -1
- package/dist/components/metric-card.d.ts.map +1 -1
- package/dist/components/metric-card.js +2 -2
- package/dist/components/metric-card.js.map +1 -1
- package/dist/components/shadcn-button.d.ts +1 -1
- package/dist/components/sidebar/sidebar-menu.d.ts +1 -1
- package/dist/components/toast.d.ts.map +1 -1
- package/dist/components/toast.js +1 -1
- package/dist/components/toast.js.map +1 -1
- package/dist/discovery/command-palette-trigger.d.ts.map +1 -1
- package/dist/discovery/command-palette-trigger.js +2 -2
- package/dist/discovery/command-palette-trigger.js.map +1 -1
- package/dist/globe/globe-scene-camera.d.ts.map +1 -1
- package/dist/globe/globe-scene-camera.js +5 -2
- package/dist/globe/globe-scene-camera.js.map +1 -1
- package/dist/lab-reports/upload-lab-report-dialog.d.ts.map +1 -1
- package/dist/lab-reports/upload-lab-report-dialog.js +3 -3
- package/dist/lab-reports/upload-lab-report-dialog.js.map +1 -1
- package/dist/mcp-connect/clients.d.ts +4 -2
- package/dist/mcp-connect/clients.d.ts.map +1 -1
- package/dist/mcp-connect/clients.js +5 -3
- package/dist/mcp-connect/clients.js.map +1 -1
- package/dist/mcp-connect/mcp-connect-panel.js +1 -1
- package/dist/mcp-connect/mcp-connect-panel.js.map +1 -1
- package/dist/nav/app-sidebar.d.ts +5 -0
- package/dist/nav/app-sidebar.d.ts.map +1 -1
- package/dist/nav/app-sidebar.js +5 -3
- package/dist/nav/app-sidebar.js.map +1 -1
- package/dist/nav/sidebar-footer.d.ts +3 -1
- package/dist/nav/sidebar-footer.d.ts.map +1 -1
- package/dist/nav/sidebar-footer.js +5 -3
- package/dist/nav/sidebar-footer.js.map +1 -1
- package/dist/notifications/index.d.ts +1 -1
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications/notification-badge.d.ts +2 -0
- package/dist/notifications/notification-badge.d.ts.map +1 -1
- package/dist/notifications/notification-badge.js +9 -2
- package/dist/notifications/notification-badge.js.map +1 -1
- package/dist/notifications/notification-tray.d.ts.map +1 -1
- package/dist/notifications/notification-tray.js +12 -2
- package/dist/notifications/notification-tray.js.map +1 -1
- package/dist/offer/negotiation-labels.d.ts +5 -1
- package/dist/offer/negotiation-labels.d.ts.map +1 -1
- package/dist/offer/negotiation-labels.js +1 -1
- package/dist/offer/negotiation-labels.js.map +1 -1
- package/dist/offer/new-activity-pill.js +1 -1
- package/dist/offer/new-activity-pill.js.map +1 -1
- package/dist/opportunities/index.d.ts +1 -1
- package/dist/opportunities/index.d.ts.map +1 -1
- package/dist/opportunities/index.js.map +1 -1
- package/dist/opportunities/opportunity-add-to-journey-button.d.ts.map +1 -1
- package/dist/opportunities/opportunity-add-to-journey-button.js +17 -3
- package/dist/opportunities/opportunity-add-to-journey-button.js.map +1 -1
- package/dist/opportunities/opportunity-filter-bar.d.ts.map +1 -1
- package/dist/opportunities/opportunity-filter-bar.js +7 -1
- package/dist/opportunities/opportunity-filter-bar.js.map +1 -1
- package/dist/opportunities/wizard/wizard-stepper.d.ts +15 -0
- package/dist/opportunities/wizard/wizard-stepper.d.ts.map +1 -1
- package/dist/opportunities/wizard/wizard-stepper.js +17 -8
- package/dist/opportunities/wizard/wizard-stepper.js.map +1 -1
- package/dist/org/invite-member-dialog.d.ts.map +1 -1
- package/dist/org/invite-member-dialog.js +12 -1
- package/dist/org/invite-member-dialog.js.map +1 -1
- package/dist/portfolio/version-rail.d.ts.map +1 -1
- package/dist/portfolio/version-rail.js +1 -1
- package/dist/portfolio/version-rail.js.map +1 -1
- package/dist/portfolio-import/import-job-detail-view.d.ts.map +1 -1
- package/dist/portfolio-import/import-job-detail-view.js +12 -1
- package/dist/portfolio-import/import-job-detail-view.js.map +1 -1
- package/dist/portfolio-import/import-job-panels.d.ts.map +1 -1
- package/dist/portfolio-import/import-job-panels.js +13 -2
- package/dist/portfolio-import/import-job-panels.js.map +1 -1
- package/dist/portfolio-import/import-products-dialog.d.ts.map +1 -1
- package/dist/portfolio-import/import-products-dialog.js +5 -2
- package/dist/portfolio-import/import-products-dialog.js.map +1 -1
- package/dist/profile/api-keys/backend-as-metadata.fixture.d.ts +9 -0
- package/dist/profile/api-keys/backend-as-metadata.fixture.d.ts.map +1 -0
- package/dist/profile/api-keys/backend-as-metadata.fixture.js +42 -0
- package/dist/profile/api-keys/backend-as-metadata.fixture.js.map +1 -0
- package/dist/profile/api-keys/connected-apps-card.d.ts +2 -2
- package/dist/profile/api-keys/connected-apps-card.d.ts.map +1 -1
- package/dist/profile/api-keys/connected-apps-card.js +7 -3
- package/dist/profile/api-keys/connected-apps-card.js.map +1 -1
- package/dist/profile/api-keys/create-api-key-dialog.js +2 -2
- package/dist/profile/api-keys/create-api-key-dialog.js.map +1 -1
- package/dist/profile/api-keys/index.d.ts +2 -1
- package/dist/profile/api-keys/index.d.ts.map +1 -1
- package/dist/profile/api-keys/index.js +2 -1
- package/dist/profile/api-keys/index.js.map +1 -1
- package/dist/profile/api-keys/oauth-scopes.d.ts +8 -0
- package/dist/profile/api-keys/oauth-scopes.d.ts.map +1 -0
- package/dist/profile/api-keys/oauth-scopes.js +41 -0
- package/dist/profile/api-keys/oauth-scopes.js.map +1 -0
- package/dist/profile/api-keys/profile-keys-section.d.ts +6 -1
- package/dist/profile/api-keys/profile-keys-section.d.ts.map +1 -1
- package/dist/profile/api-keys/profile-keys-section.js +17 -2
- package/dist/profile/api-keys/profile-keys-section.js.map +1 -1
- package/dist/profile/api-keys/scope-list.d.ts +6 -1
- package/dist/profile/api-keys/scope-list.d.ts.map +1 -1
- package/dist/profile/api-keys/scope-list.js +10 -3
- package/dist/profile/api-keys/scope-list.js.map +1 -1
- package/dist/profile/api-keys/types.d.ts +14 -0
- package/dist/profile/api-keys/types.d.ts.map +1 -1
- package/dist/profile/api-keys/types.js +21 -0
- package/dist/profile/api-keys/types.js.map +1 -1
- package/dist/realtime/organisation-events/schemas.d.ts +2 -2
- package/package.json +7 -2
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useId, useRef, useState } from "react";
|
|
3
|
+
import { AtSign } from "lucide-react";
|
|
4
|
+
import { cn } from "../lib/utils.js";
|
|
5
|
+
import { fmt, useCopy } from "./copy.js";
|
|
6
|
+
import { MaskedValue } from "./masked-value.js";
|
|
7
|
+
import { cleanLine } from "./text-clean.js";
|
|
8
|
+
import { isMasked } from "./schema.js";
|
|
9
|
+
export const MAX_MENTION_RESULTS = 8;
|
|
10
|
+
export const MENTION_DEBOUNCE_MS = 200;
|
|
11
|
+
export const MAX_MENTION_QUERY = 40;
|
|
12
|
+
const MAX_MENTION_LABEL = 80;
|
|
13
|
+
const MAX_ID = 128;
|
|
14
|
+
export const DEFAULT_MENTION_COPY = {
|
|
15
|
+
list: "Mention suggestions",
|
|
16
|
+
searching: "Searching",
|
|
17
|
+
none: "No matches",
|
|
18
|
+
error: "Could not search. Keep typing to try again.",
|
|
19
|
+
results: "{count} results",
|
|
20
|
+
kindLabels: {},
|
|
21
|
+
};
|
|
22
|
+
/** The `@query` at the caret: it starts the text or follows whitespace, and has no space in it yet. */
|
|
23
|
+
export function activeMentionQuery(text, caret) {
|
|
24
|
+
const before = text.slice(0, caret);
|
|
25
|
+
const m = /(^|\s)@([^\s@]{0,40})$/u.exec(before);
|
|
26
|
+
if (!m)
|
|
27
|
+
return null;
|
|
28
|
+
const query = m[2] ?? "";
|
|
29
|
+
return { start: caret - query.length - 1, query };
|
|
30
|
+
}
|
|
31
|
+
const MAX_DETAIL = 60;
|
|
32
|
+
const MAX_MASK_DISPLAY = 40;
|
|
33
|
+
/** A second line the ui will draw: text cleaned and cut, a mask rebuilt (still a mask), numbers and booleans kept, the rest dropped. */
|
|
34
|
+
function cleanDetail(detail) {
|
|
35
|
+
if (typeof detail === "string")
|
|
36
|
+
return cleanLine(detail, MAX_DETAIL, true);
|
|
37
|
+
if (typeof detail === "number")
|
|
38
|
+
return Number.isFinite(detail) ? detail : undefined;
|
|
39
|
+
if (typeof detail === "boolean")
|
|
40
|
+
return detail;
|
|
41
|
+
if (isMasked(detail))
|
|
42
|
+
return {
|
|
43
|
+
masked: true,
|
|
44
|
+
display: cleanLine(detail.display, MAX_MASK_DISPLAY, true) ?? "hidden",
|
|
45
|
+
};
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
/** Candidates the ui will draw: valid, cleaned, de-duplicated and capped. A host cannot make the list longer or the text unsafe. */
|
|
49
|
+
export function sanitizeCandidates(raw) {
|
|
50
|
+
const seen = new Set();
|
|
51
|
+
const out = [];
|
|
52
|
+
for (const c of raw) {
|
|
53
|
+
if (out.length >= MAX_MENTION_RESULTS)
|
|
54
|
+
break;
|
|
55
|
+
if (typeof c?.id !== "string" || c.id === "" || c.id.length > MAX_ID)
|
|
56
|
+
continue;
|
|
57
|
+
// The label goes into the person's message: no invisible or look-alike-hiding characters survive.
|
|
58
|
+
const label = cleanLine(c.label, MAX_MENTION_LABEL, true);
|
|
59
|
+
const kind = cleanLine(c.kind, 24, true);
|
|
60
|
+
if (!label || !kind)
|
|
61
|
+
continue;
|
|
62
|
+
const key = `${kind}\u0000${c.id}`;
|
|
63
|
+
if (seen.has(key))
|
|
64
|
+
continue;
|
|
65
|
+
seen.add(key);
|
|
66
|
+
const detail = cleanDetail(c.detail);
|
|
67
|
+
out.push({ kind, id: c.id, label, ...(detail === undefined ? {} : { detail }) });
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @internal The `@` state: the query at the caret, a debounced and abortable search, a capped and cleaned result list, and the
|
|
73
|
+
* keyboard model (up and down, Enter or Tab to accept, Escape to close until the query changes). A source that throws, rejects,
|
|
74
|
+
* or returns something that is not a list ends in the error state, never in "Searching" for ever.
|
|
75
|
+
*/
|
|
76
|
+
export function useMentions(text, caret, source) {
|
|
77
|
+
const listId = useId();
|
|
78
|
+
const active_ = source ? activeMentionQuery(text, caret) : null;
|
|
79
|
+
const query = active_?.query;
|
|
80
|
+
const start = active_?.start;
|
|
81
|
+
const key = query === undefined ? undefined : `${start}:${query}`;
|
|
82
|
+
const [result, setResult] = useState();
|
|
83
|
+
const [active, setActive] = useState(0);
|
|
84
|
+
const [dismissedKey, setDismissedKey] = useState();
|
|
85
|
+
const sourceRef = useRef(source);
|
|
86
|
+
sourceRef.current = source;
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (query === undefined || key === undefined)
|
|
89
|
+
return;
|
|
90
|
+
const controller = new AbortController();
|
|
91
|
+
const timer = setTimeout(() => {
|
|
92
|
+
const run = sourceRef.current;
|
|
93
|
+
if (!run)
|
|
94
|
+
return;
|
|
95
|
+
// One chain: a throw anywhere in it (the source, or cleaning what it returned) ends in the error state.
|
|
96
|
+
Promise.resolve()
|
|
97
|
+
.then(() => run(query, controller.signal))
|
|
98
|
+
.then((found) => {
|
|
99
|
+
if (controller.signal.aborted)
|
|
100
|
+
return;
|
|
101
|
+
if (!Array.isArray(found))
|
|
102
|
+
throw new Error("not a list");
|
|
103
|
+
setResult({ key, status: "ready", items: sanitizeCandidates(found) });
|
|
104
|
+
setActive(0);
|
|
105
|
+
})
|
|
106
|
+
.catch(() => {
|
|
107
|
+
if (!controller.signal.aborted)
|
|
108
|
+
setResult({ key, status: "error", items: [] });
|
|
109
|
+
});
|
|
110
|
+
}, MENTION_DEBOUNCE_MS);
|
|
111
|
+
return () => {
|
|
112
|
+
clearTimeout(timer);
|
|
113
|
+
controller.abort();
|
|
114
|
+
};
|
|
115
|
+
}, [query, key]);
|
|
116
|
+
const fresh = result && result.key === key ? result : undefined;
|
|
117
|
+
const status = key === undefined ? "idle" : (fresh?.status ?? "loading");
|
|
118
|
+
const items = fresh?.status === "ready" ? fresh.items : EMPTY;
|
|
119
|
+
const open = key !== undefined && key !== dismissedKey;
|
|
120
|
+
const move = useCallback((delta) => setActive((a) => Math.max(0, Math.min(items.length - 1, a + delta))), [items.length]);
|
|
121
|
+
return {
|
|
122
|
+
open,
|
|
123
|
+
status,
|
|
124
|
+
items,
|
|
125
|
+
active: Math.min(active, Math.max(0, items.length - 1)),
|
|
126
|
+
listId,
|
|
127
|
+
optionId: (i) => `${listId}-o${i}`,
|
|
128
|
+
setActive,
|
|
129
|
+
move,
|
|
130
|
+
dismiss: () => setDismissedKey(key),
|
|
131
|
+
accept: (i) => {
|
|
132
|
+
const item = items[i];
|
|
133
|
+
if (!item || start === undefined)
|
|
134
|
+
return null;
|
|
135
|
+
const insert = `@${item.label} `;
|
|
136
|
+
const next = text.slice(0, start) + insert + text.slice(caret);
|
|
137
|
+
return {
|
|
138
|
+
text: next,
|
|
139
|
+
caret: start + insert.length,
|
|
140
|
+
start,
|
|
141
|
+
length: insert.length - 1,
|
|
142
|
+
mention: { kind: item.kind, id: item.id, label: item.label },
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
const EMPTY = [];
|
|
148
|
+
/** What a screen reader hears about the list: searching, how many results, none, or the error. Empty when the list is closed. */
|
|
149
|
+
export function mentionAnnouncement(state, copy) {
|
|
150
|
+
if (!state.open)
|
|
151
|
+
return "";
|
|
152
|
+
if (state.status === "loading")
|
|
153
|
+
return copy.searching;
|
|
154
|
+
if (state.status === "error")
|
|
155
|
+
return copy.error;
|
|
156
|
+
if (state.status === "ready")
|
|
157
|
+
return state.items.length === 0 ? copy.none : fmt(copy.results, { count: state.items.length });
|
|
158
|
+
return "";
|
|
159
|
+
}
|
|
160
|
+
/** The results, drawn above the field: text only (kind small, then the label, then the detail), masked details masked. */
|
|
161
|
+
export function AgentMentionList({ state, copy, onAccept, }) {
|
|
162
|
+
const c = useCopy(DEFAULT_MENTION_COPY, copy);
|
|
163
|
+
if (!state.open)
|
|
164
|
+
return null;
|
|
165
|
+
const note = state.status === "loading"
|
|
166
|
+
? c.searching
|
|
167
|
+
: state.status === "error"
|
|
168
|
+
? c.error
|
|
169
|
+
: state.status === "ready" && state.items.length === 0
|
|
170
|
+
? c.none
|
|
171
|
+
: null;
|
|
172
|
+
if (state.items.length === 0 && note === null)
|
|
173
|
+
return null;
|
|
174
|
+
return (_jsxs("div", { className: "agent-fade-in mb-1 overflow-hidden rounded-xl ring-1 ring-border/60", children: [state.items.length > 0 && (_jsx("ul", { id: state.listId, role: "listbox", "aria-label": c.list, className: "flex max-h-56 flex-col overflow-y-auto", children: state.items.map((m, i) => (_jsxs("li", { id: state.optionId(i), role: "option", "aria-selected": i === state.active,
|
|
175
|
+
// Keep focus (and the caret) in the field: choosing must not blur it.
|
|
176
|
+
onMouseDown: (e) => e.preventDefault(), onMouseEnter: () => state.setActive(i), onClick: () => onAccept(i), className: cn("flex min-h-9 cursor-pointer items-center gap-2 px-3 py-1.5 text-sm/5 text-foreground pointer-coarse:min-h-11 not-first:border-t not-first:border-border/60", i === state.active ? "bg-muted" : "bg-transparent"), children: [_jsx(AtSign, { "aria-hidden": true, className: "size-3.5 shrink-0 text-muted-foreground" }), _jsx("span", { className: "shrink-0 text-xs/5 text-muted-foreground", children: c.kindLabels[m.kind] ?? m.kind }), _jsx("bdi", { className: "min-w-0 flex-1 truncate", children: m.label }), m.detail !== undefined &&
|
|
177
|
+
m.detail !== null &&
|
|
178
|
+
m.detail !== "" && (
|
|
179
|
+
// The detail gives way first: it is capped, and the name keeps the room.
|
|
180
|
+
_jsx("span", { className: "min-w-0 max-w-[35%] truncate text-xs/5 text-muted-foreground", children: _jsx(MaskedValue, { value: m.detail }) }))] }, `${m.kind}\u0000${m.id}`))) })), note !== null && (
|
|
181
|
+
// (the announcement is spoken by the composer's persistent live region: this is the visible copy)
|
|
182
|
+
_jsx("p", { "aria-hidden": true, className: "px-3 py-1.5 text-xs/5 text-muted-foreground", children: note }))] }));
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=mentions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mentions.js","sourceRoot":"","sources":["../../src/agent/mentions.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAkB,MAAM,UAAU,CAAC;AAqBpD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AACrC,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,MAAM,GAAG,GAAG,CAAC;AAanB,MAAM,CAAC,MAAM,oBAAoB,GAAqB;IACpD,IAAI,EAAE,qBAAqB;IAC3B,SAAS,EAAE,WAAW;IACtB,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,6CAA6C;IACpD,OAAO,EAAE,iBAAiB;IAC1B,UAAU,EAAE,EAAE;CACf,CAAC;AAEF,uGAAuG;AACvG,MAAM,UAAU,kBAAkB,CAChC,IAAY,EACZ,KAAa;IAEb,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACpC,MAAM,CAAC,GAAG,yB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} from "./context.js";
|
|
1
2
|
import { type ReactNode } from "react";
|
|
2
3
|
import { type AgentLinkPolicy, type AgentMarkdownCopy } from "./markdown.js";
|
|
3
4
|
import { type AgentToolActivityCopy } from "./tool-activity.js";
|
|
@@ -11,6 +12,8 @@ export interface AgentMessageCopy {
|
|
|
11
12
|
retry: string;
|
|
12
13
|
copy: string;
|
|
13
14
|
copied: string;
|
|
15
|
+
/** The action beside Copy that quotes the reply (or the part selected in it) into the composer. */
|
|
16
|
+
quote: string;
|
|
14
17
|
/** @deprecated A thought is a step in the activity trail now: its wording is `activityCopy.thought`. Unused. */
|
|
15
18
|
thinking: string;
|
|
16
19
|
}
|
|
@@ -38,6 +41,18 @@ export interface AgentMessageProps extends AgentToolNaming {
|
|
|
38
41
|
markdownCopy?: Partial<AgentMarkdownCopy>;
|
|
39
42
|
/** The message arrived while the conversation was open: it fades and slides in once. Parts added later fade in on their own. */
|
|
40
43
|
entering?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Show this user message's `context` chips above it. The conversation turns it on only when the context differs from the previous
|
|
46
|
+
* question's, so a run of questions about the same page names it once. Default: show.
|
|
47
|
+
*/
|
|
48
|
+
showContext?: boolean;
|
|
49
|
+
/** This question has no context although the one before it had: say so quietly, so a change to "none" is not invisible. */
|
|
50
|
+
contextCleared?: boolean;
|
|
51
|
+
/** The ids of the messages in the thread: a sent quote offers "Show the answer" only while its answer is among them. */
|
|
52
|
+
knownMessageIds?: ReadonlySet<string>;
|
|
53
|
+
/** Adds a "Quote" action beside Copy on an answer. Gets the selected passage inside this reply, else the start of the whole reply. */
|
|
54
|
+
onQuote?: (quote: AgentQuote) => void;
|
|
55
|
+
contextCopy?: Partial<AgentContextChipsCopy>;
|
|
41
56
|
/** Clock override (ms since epoch) for approval expiry; stories and tests pin it. */
|
|
42
57
|
nowMs?: number;
|
|
43
58
|
copy?: Partial<AgentMessageCopy>;
|
|
@@ -48,5 +63,5 @@ export interface AgentMessageProps extends AgentToolNaming {
|
|
|
48
63
|
* re-read) and render as markdown; user messages are plain text in a right-aligned bubble. A run of tool calls is one
|
|
49
64
|
* activity row, never a card per call; approvals and domain cards stay in place, prominent.
|
|
50
65
|
*/
|
|
51
|
-
export declare function AgentMessage({ message, approvalStatus, onApproval, onRetry, onRetryTool, renderCard, toolLabels, formatToolLabel, cardLabels, toolWording, cardCoversCall, onNavigate, linkPolicy, locale, activityCopy, markdownCopy, entering, nowMs, copy, className, }: AgentMessageProps): import("react/jsx-runtime").JSX.Element;
|
|
66
|
+
export declare function AgentMessage({ message, approvalStatus, onApproval, onRetry, onRetryTool, renderCard, toolLabels, formatToolLabel, cardLabels, toolWording, cardCoversCall, onNavigate, linkPolicy, locale, activityCopy, markdownCopy, entering, showContext, contextCleared, knownMessageIds, onQuote, contextCopy, nowMs, copy, className, }: AgentMessageProps): import("react/jsx-runtime").JSX.Element;
|
|
52
67
|
//# sourceMappingURL=message.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/agent/message.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/agent/message.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAOlE,OAAO,EAAiB,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,EAAqB,KAAK,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAoB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGhE,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC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1C,gIAAgI;IAChI,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2HAA2H;IAC3H,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,wHAAwH;IACxH,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,sIAAsI;IACtI,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,WAAW,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC7C,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,cAAc,EACd,UAAU,EACV,OAAO,EACP,WAAW,EACX,UAAU,EACV,UAAU,EACV,eAAe,EACf,UAAU,EACV,WAAW,EACX,cAAc,EACd,UAAU,EACV,UAAU,EACV,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,WAAkB,EAClB,cAAsB,EACtB,eAAe,EACf,OAAO,EACP,WAAW,EACX,KAAK,EACL,IAAI,EACJ,SAAS,GACV,EAAE,iBAAiB,2CAyLnB"}
|
package/dist/agent/message.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { AgentContextChips, AgentQuoteBlock, DEFAULT_CONTEXT_COPY, cleanQuote, } from "./context.js";
|
|
3
|
+
import { useMemo, useRef, useState } from "react";
|
|
4
|
+
import { Quote, RotateCw } from "lucide-react";
|
|
5
|
+
import { selectedQuote } from "./quote-reply.js";
|
|
4
6
|
import { CopyButton } from "../components/copy-button.js";
|
|
5
7
|
import { cn } from "../lib/utils.js";
|
|
6
8
|
import { useCopy } from "./copy.js";
|
|
@@ -17,6 +19,7 @@ const DEFAULT_COPY = {
|
|
|
17
19
|
retry: "Retry",
|
|
18
20
|
copy: "Copy reply",
|
|
19
21
|
copied: "Copied",
|
|
22
|
+
quote: "Quote reply",
|
|
20
23
|
thinking: "Summary",
|
|
21
24
|
};
|
|
22
25
|
const partKey = (part, i) => `${part.type}:${i}`;
|
|
@@ -25,8 +28,10 @@ const partKey = (part, i) => `${part.type}:${i}`;
|
|
|
25
28
|
* re-read) and render as markdown; user messages are plain text in a right-aligned bubble. A run of tool calls is one
|
|
26
29
|
* activity row, never a card per call; approvals and domain cards stay in place, prominent.
|
|
27
30
|
*/
|
|
28
|
-
export function AgentMessage({ message, approvalStatus, onApproval, onRetry, onRetryTool, renderCard, toolLabels, formatToolLabel, cardLabels, toolWording, cardCoversCall, onNavigate, linkPolicy, locale, activityCopy, markdownCopy, entering, nowMs, copy, className, }) {
|
|
31
|
+
export function AgentMessage({ message, approvalStatus, onApproval, onRetry, onRetryTool, renderCard, toolLabels, formatToolLabel, cardLabels, toolWording, cardCoversCall, onNavigate, linkPolicy, locale, activityCopy, markdownCopy, entering, showContext = true, contextCleared = false, knownMessageIds, onQuote, contextCopy, nowMs, copy, className, }) {
|
|
29
32
|
const c = useCopy(DEFAULT_COPY, copy);
|
|
33
|
+
const ctxCopy = useCopy(DEFAULT_CONTEXT_COPY, contextCopy);
|
|
34
|
+
const articleRef = useRef(null);
|
|
30
35
|
const user = message.role === "user";
|
|
31
36
|
const text = message.parts.flatMap((p) => (p.type === "text" ? [p.text] : [])).join("\n\n");
|
|
32
37
|
// The host's cards are drawn once, here: whether a card drew anything decides whether its step is marked "shown below".
|
|
@@ -49,7 +54,7 @@ export function AgentMessage({ message, approvalStatus, onApproval, onRetry, onR
|
|
|
49
54
|
// part that arrives afterwards fades in by itself.
|
|
50
55
|
const [mountedParts] = useState(message.parts.length);
|
|
51
56
|
const lastIndex = message.parts.length - 1;
|
|
52
|
-
return (_jsxs("article", { "aria-label": user ? c.userLabel : c.assistantLabel, "data-role": message.role, className: cn("flex flex-col gap-2", user ? "items-end" : "items-stretch", entering && "agent-enter", className), children: [items.map((item) => {
|
|
57
|
+
return (_jsxs("article", { ref: articleRef, "aria-label": user ? c.userLabel : c.assistantLabel, "data-role": message.role, "data-message-id": message.id, className: cn("flex flex-col gap-2", user ? "items-end" : "items-stretch", entering && "agent-enter", className), children: [user && showContext && message.context && message.context.length > 0 && (_jsx(AgentContextChips, { contexts: message.context, onNavigate: onNavigate, linkPolicy: linkPolicy, copy: contextCopy })), user && contextCleared && (_jsx("p", { className: "text-xs/4 text-muted-foreground", children: ctxCopy.cleared })), user && message.quotes && message.quotes.length > 0 && (_jsx("div", { className: "flex flex-col items-end gap-1.5 self-end", children: message.quotes.map((q, i) => (_jsx(AgentQuoteBlock, { text: q.text, messageId: q.messageId, canJump: Boolean(q.messageId && knownMessageIds?.has(q.messageId)), copy: contextCopy }, `${i}:${q.text.slice(0, 24)}`))) })), items.map((item) => {
|
|
53
58
|
if (item.kind === "activity") {
|
|
54
59
|
return (_jsx(AgentToolActivity, { steps: item.steps, toolLabels: toolLabels, formatToolLabel: formatToolLabel, cardLabels: cardLabels, toolWording: toolWording, onRetry: onRetryTool, locale: locale, copy: activityCopy, className: item.startIndex >= mountedParts ? "agent-fade-in" : undefined }, item.key));
|
|
55
60
|
}
|
|
@@ -62,7 +67,9 @@ export function AgentMessage({ message, approvalStatus, onApproval, onRetry, onR
|
|
|
62
67
|
return (_jsx("p", { className: "max-w-5/6 rounded-2xl rounded-br-sm bg-primary px-3.5 py-2 text-sm/6 whitespace-pre-wrap text-primary-foreground", children: part.text }, key));
|
|
63
68
|
if (part.text.trim() === "")
|
|
64
69
|
return null;
|
|
65
|
-
return (
|
|
70
|
+
return (
|
|
71
|
+
// `data-quotable`: the only part of an answer a quote may come from (not its cards, activity or controls).
|
|
72
|
+
_jsx("div", { "data-quotable": "", children: _jsx(AgentMarkdown, { text: part.text, streaming: Boolean(message.streaming) && i === lastIndex, onNavigate: onNavigate, linkPolicy: linkPolicy, copy: markdownCopy, className: later ? "agent-fade-in" : undefined }) }, key));
|
|
66
73
|
case "thinking":
|
|
67
74
|
return null; // a thought is a step in the activity trail
|
|
68
75
|
case "toolCall":
|
|
@@ -78,6 +85,19 @@ export function AgentMessage({ message, approvalStatus, onApproval, onRetry, onR
|
|
|
78
85
|
return (_jsx("div", { className: later ? "agent-fade-in" : undefined, children: card }, key));
|
|
79
86
|
}
|
|
80
87
|
}
|
|
81
|
-
}), !user && message.stopped && _jsx("p", { className: "text-xs/4 text-muted-foreground", children: c.stopped }), !user && message.failed && (_jsxs("div", { className: "flex items-center gap-2 text-xs/5 text-[var(--tone-danger-fg)]", children: [_jsx("span", { children: c.failed }), onRetry && (_jsxs("button", { type: "button", className: agentButton.ghost, onClick: () => onRetry(message.id), children: [_jsx(RotateCw, { "aria-hidden": true, className: "size-3.5" }), c.retry] }))] })), !user && !message.streaming && text && (
|
|
88
|
+
}), !user && message.stopped && _jsx("p", { className: "text-xs/4 text-muted-foreground", children: c.stopped }), !user && message.failed && (_jsxs("div", { className: "flex items-center gap-2 text-xs/5 text-[var(--tone-danger-fg)]", children: [_jsx("span", { children: c.failed }), onRetry && (_jsxs("button", { type: "button", className: agentButton.ghost, onClick: () => onRetry(message.id), children: [_jsx(RotateCw, { "aria-hidden": true, className: "size-3.5" }), c.retry] }))] })), !user && !message.streaming && text && (_jsxs("div", { className: "flex items-center gap-1 self-start", children: [_jsx(CopyButton, { value: text, label: c.copy, copiedLabel: c.copied }), onQuote && (_jsx("button", { type: "button", "aria-label": c.quote, title: c.quote, className: agentButton.ghost, onClick: () => {
|
|
89
|
+
// A passage selected in THIS reply, else the start of the reply itself (the same cleaning and cut either way).
|
|
90
|
+
const article = articleRef.current;
|
|
91
|
+
const frame = article?.closest('[role="log"]') ?? article;
|
|
92
|
+
const picked = article && frame ? selectedQuote(frame, article) : null;
|
|
93
|
+
// else the start of what is SHOWN of the first text part (not the markdown source of all of them)
|
|
94
|
+
const first = article?.querySelector("[data-quotable]")?.textContent;
|
|
95
|
+
const quote = picked?.quote ?? {
|
|
96
|
+
messageId: message.id,
|
|
97
|
+
text: cleanQuote(first ?? message.parts.find((p) => p.type === "text")?.text ?? ""),
|
|
98
|
+
};
|
|
99
|
+
if (quote.text)
|
|
100
|
+
onQuote(quote);
|
|
101
|
+
}, children: _jsx(Quote, { "aria-hidden": true, className: "size-3.5 rtl:-scale-x-100" }) }))] }))] }));
|
|
82
102
|
}
|
|
83
103
|
//# sourceMappingURL=message.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/agent/message.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/agent/message.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,UAAU,GAGX,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAgD,MAAM,YAAY,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAA8B,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAA6C,MAAM,u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E,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,EAAE,IAAI,IAAI,EAAE,CAClE;6BACF,CAAC;4BACF,IAAI,KAAK,CAAC,IAAI;gCAAE,OAAO,CAAC,KAAK,CAAC,CAAC;wBACjC,CAAC,YAED,KAAC,KAAK,yBAAa,SAAS,EAAC,2BAA2B,GAAG,GACpD,CACV,IACG,CACP,IACO,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
import { type AgentQuote } from "./context.js";
|
|
3
|
+
export interface AgentQuoteReplyCopy {
|
|
4
|
+
/** The chip beside a selection in an answer. */
|
|
5
|
+
reply: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const DEFAULT_QUOTE_REPLY_COPY: AgentQuoteReplyCopy;
|
|
8
|
+
interface Selection_ {
|
|
9
|
+
quote: AgentQuote;
|
|
10
|
+
/** The chip's offset from the frame's start edge (left, or right in a right-to-left frame), in px. */
|
|
11
|
+
x: number;
|
|
12
|
+
top: number;
|
|
13
|
+
rtl: boolean;
|
|
14
|
+
frameWidth: number;
|
|
15
|
+
}
|
|
16
|
+
/** The selected text when the whole selection sits inside ONE quotable part (of the given article, when one is named). */
|
|
17
|
+
export declare function selectedQuote(frame: HTMLElement, within?: HTMLElement): {
|
|
18
|
+
quote: AgentQuote;
|
|
19
|
+
range: Range;
|
|
20
|
+
} | null;
|
|
21
|
+
/**
|
|
22
|
+
* @internal Watches the document selection and reports the passage selected inside one answer's text, with where to draw the
|
|
23
|
+
* "Reply" chip. The passage is cleaned and cut here ({@link cleanQuote}); nothing is read from the DOM but plain selected text.
|
|
24
|
+
* Only listens while `enabled`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useQuoteSelection(frameRef: RefObject<HTMLElement | null>, enabled: boolean): {
|
|
27
|
+
selection: Selection_ | null;
|
|
28
|
+
clear: () => void;
|
|
29
|
+
};
|
|
30
|
+
export declare function AgentQuoteReplyButton({ top, x, rtl, frameWidth, onClick, copy, }: {
|
|
31
|
+
top: number;
|
|
32
|
+
/** Offset from the frame's start edge (its left, or right when `rtl`). */
|
|
33
|
+
x: number;
|
|
34
|
+
rtl: boolean;
|
|
35
|
+
frameWidth: number;
|
|
36
|
+
onClick: () => void;
|
|
37
|
+
copy?: Partial<AgentQuoteReplyCopy>;
|
|
38
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=quote-reply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote-reply.d.ts","sourceRoot":"","sources":["../../src/agent/quote-reply.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6D,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlG,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAGxD,MAAM,WAAW,mBAAmB;IAClC,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;CACf;AACD,eAAO,MAAM,wBAAwB,EAAE,mBAAwC,CAAC;AAEhF,UAAU,UAAU;IAClB,KAAK,EAAE,UAAU,CAAC;IAClB,sGAAsG;IACtG,CAAC,EAAE,MAAM,CAAC;IACV,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,OAAO,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAaD,0HAA0H;AAC1H,wBAAgB,aAAa,CAC3B,KAAK,EAAE,WAAW,EAClB,MAAM,CAAC,EAAE,WAAW,GACnB;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAAG,IAAI,CAW5C;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO;;;EAkD1F;AAED,wBAAgB,qBAAqB,CAAC,EACpC,GAAG,EACH,CAAC,EACD,GAAG,EACH,UAAU,EACV,OAAO,EACP,IAAI,GACL,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,0EAA0E;IAC1E,CAAC,EAAE,MAAM,CAAC;IACV,GAAG,EAAE,OAAO,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACrC,2CAqBA"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import { Reply } from "lucide-react";
|
|
4
|
+
import { cn } from "../lib/utils.js";
|
|
5
|
+
import { useCopy } from "./copy.js";
|
|
6
|
+
import { cleanQuote } from "./context.js";
|
|
7
|
+
import { agentChipSolid, focusRing } from "./ui.js";
|
|
8
|
+
export const DEFAULT_QUOTE_REPLY_COPY = { reply: "Reply" };
|
|
9
|
+
/**
|
|
10
|
+
* The part of an assistant answer a quote may come from: the markdown TEXT of ONE message (`data-quotable`). Confirm cards, tool
|
|
11
|
+
* activity, host and role cards and the Copy control are not quotable, so a quote can never carry their text.
|
|
12
|
+
*/
|
|
13
|
+
function quotableOf(node, frame) {
|
|
14
|
+
const el = node instanceof Element ? node : (node?.parentElement ?? null);
|
|
15
|
+
const part = el?.closest("[data-quotable]") ?? null;
|
|
16
|
+
const article = part?.closest('[data-role="assistant"][data-message-id]') ?? null;
|
|
17
|
+
return part && article && frame.contains(article) ? part : null;
|
|
18
|
+
}
|
|
19
|
+
/** The selected text when the whole selection sits inside ONE quotable part (of the given article, when one is named). */
|
|
20
|
+
export function selectedQuote(frame, within) {
|
|
21
|
+
const s = typeof window === "undefined" ? null : window.getSelection();
|
|
22
|
+
// One range only: Firefox can hold several, and `toString()` would join text from places the person did not see together.
|
|
23
|
+
if (!s || s.rangeCount !== 1 || s.isCollapsed)
|
|
24
|
+
return null;
|
|
25
|
+
const range = s.getRangeAt(0);
|
|
26
|
+
const from = quotableOf(range.startContainer, frame);
|
|
27
|
+
const to = quotableOf(range.endContainer, frame);
|
|
28
|
+
if (!from || from !== to || (within && !within.contains(from)))
|
|
29
|
+
return null;
|
|
30
|
+
const text = cleanQuote(range.toString());
|
|
31
|
+
const id = from.closest("[data-message-id]")?.dataset.messageId;
|
|
32
|
+
return text && id ? { quote: { messageId: id, text }, range } : null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @internal Watches the document selection and reports the passage selected inside one answer's text, with where to draw the
|
|
36
|
+
* "Reply" chip. The passage is cleaned and cut here ({@link cleanQuote}); nothing is read from the DOM but plain selected text.
|
|
37
|
+
* Only listens while `enabled`.
|
|
38
|
+
*/
|
|
39
|
+
export function useQuoteSelection(frameRef, enabled) {
|
|
40
|
+
const [sel, setSel] = useState(null);
|
|
41
|
+
const raf = useRef(0);
|
|
42
|
+
const read = useCallback(() => {
|
|
43
|
+
const frame = frameRef.current;
|
|
44
|
+
const found = frame ? selectedQuote(frame) : null;
|
|
45
|
+
if (!frame || !found)
|
|
46
|
+
return setSel(null);
|
|
47
|
+
// (jsdom has no layout: a missing method is a zero rect)
|
|
48
|
+
const r = found.range.getBoundingClientRect?.() ?? new DOMRect();
|
|
49
|
+
const f = frame.getBoundingClientRect();
|
|
50
|
+
const rtl = getComputedStyle(frame).direction === "rtl";
|
|
51
|
+
const top = Math.max(4, r.top - f.top - 40);
|
|
52
|
+
// Anchored to the START of the selection in the writing direction; the button clamps itself to the frame once it knows its width.
|
|
53
|
+
const x = Math.max(4, rtl ? f.right - r.right : r.left - f.left);
|
|
54
|
+
setSel((prev) => prev &&
|
|
55
|
+
prev.quote.text === found.quote.text &&
|
|
56
|
+
prev.quote.messageId === found.quote.messageId &&
|
|
57
|
+
prev.top === top &&
|
|
58
|
+
prev.x === x &&
|
|
59
|
+
prev.rtl === rtl &&
|
|
60
|
+
prev.frameWidth === f.width
|
|
61
|
+
? prev
|
|
62
|
+
: { quote: found.quote, top, x, rtl, frameWidth: f.width });
|
|
63
|
+
}, [frameRef]);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (!enabled) {
|
|
66
|
+
setSel(null);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const schedule = () => {
|
|
70
|
+
cancelAnimationFrame(raf.current);
|
|
71
|
+
raf.current = requestAnimationFrame(read);
|
|
72
|
+
};
|
|
73
|
+
document.addEventListener("selectionchange", schedule);
|
|
74
|
+
window.addEventListener("resize", schedule);
|
|
75
|
+
// The chip follows the text when the log scrolls.
|
|
76
|
+
document.addEventListener("scroll", schedule, true);
|
|
77
|
+
return () => {
|
|
78
|
+
cancelAnimationFrame(raf.current);
|
|
79
|
+
document.removeEventListener("selectionchange", schedule);
|
|
80
|
+
window.removeEventListener("resize", schedule);
|
|
81
|
+
document.removeEventListener("scroll", schedule, true);
|
|
82
|
+
};
|
|
83
|
+
}, [enabled, read]);
|
|
84
|
+
return { selection: enabled ? sel : null, clear: () => setSel(null) };
|
|
85
|
+
}
|
|
86
|
+
export function AgentQuoteReplyButton({ top, x, rtl, frameWidth, onClick, copy, }) {
|
|
87
|
+
const c = useCopy(DEFAULT_QUOTE_REPLY_COPY, copy);
|
|
88
|
+
const ref = useRef(null);
|
|
89
|
+
const [width, setWidth] = useState(0);
|
|
90
|
+
// The chip's real width (it depends on the translated word), so it can be kept inside the frame at either edge.
|
|
91
|
+
useLayoutEffect(() => setWidth(ref.current?.offsetWidth ?? 0), [c.reply]);
|
|
92
|
+
const offset = Math.max(4, Math.min(x, frameWidth - width - 4));
|
|
93
|
+
return (_jsxs("button", { ref: ref, type: "button",
|
|
94
|
+
// Pressing the chip must not clear the selection it is about to quote.
|
|
95
|
+
onMouseDown: (e) => e.preventDefault(), onClick: onClick, style: { top, ...(rtl ? { right: offset } : { left: offset }) }, className: cn("agent-fade-in absolute z-10", agentChipSolid, focusRing), children: [_jsx(Reply, { "aria-hidden": true, className: "size-3.5 rtl:-scale-x-100" }), c.reply] }));
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=quote-reply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote-reply.js","sourceRoot":"","sources":["../../src/agent/quote-reply.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAClG,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,UAAU,EAAmB,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAMjD,MAAM,CAAC,MAAM,wBAAwB,GAAwB,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAWhF;;;GAGG;AACH,SAAS,UAAU,CAAC,IAAiB,EAAE,KAAkB;IACvD,MAAM,EAAE,GAAG,IAAI,YAAY,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,aAAa,IAAI,IAAI,CAAC,CAAC;IAC1E,MAAM,IAAI,GAAG,EAAE,EAAE,OAAO,CAAc,iBAAiB,CAAC,IAAI,IAAI,CAAC;IACjE,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,CAAc,0CAA0C,CAAC,IAAI,IAAI,CAAC;IAC/F,OAAO,IAAI,IAAI,OAAO,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAClE,CAAC;AAED,0HAA0H;AAC1H,MAAM,UAAU,aAAa,CAC3B,KAAkB,EAClB,MAAoB;IAEpB,MAAM,CAAC,GAAG,OAAO,MAAM,KAAK,WA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,EACP,IAAI,GASL;IACC,MAAM,CAAC,GAAG,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC;IAClD,MAAM,GAAG,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAC5C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtC,gHAAgH;IAChH,eAAe,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1E,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;IAChE,OAAO,CACL,kBACE,GAAG,EAAE,GAAG,EACR,IAAI,EAAC,QAAQ;QACb,uEAAuE;QACvE,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,EACtC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,EAC/D,SAAS,EAAE,EAAE,CAAC,6BAA6B,EAAE,cAAc,EAAE,SAAS,CAAC,aAEvE,KAAC,KAAK,yBAAa,SAAS,EAAC,2BAA2B,GAAG,EAC1D,CAAC,CAAC,KAAK,IACD,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { BrandProfileCardData } from "@cellarnode/agent-cards/zod4";
|
|
2
|
+
import { type AgentRoleCardHostProps } from "./card-kit.js";
|
|
3
|
+
export interface AgentBrandProfileCardCopy {
|
|
4
|
+
title: string;
|
|
5
|
+
generationTitle: string;
|
|
6
|
+
draft: string;
|
|
7
|
+
approved: string;
|
|
8
|
+
generating: string;
|
|
9
|
+
abandoned: string;
|
|
10
|
+
revision: string;
|
|
11
|
+
tone: string;
|
|
12
|
+
country: string;
|
|
13
|
+
fields: string;
|
|
14
|
+
confidence: string;
|
|
15
|
+
publicContact: string;
|
|
16
|
+
publicKeyPeople: string;
|
|
17
|
+
shown: string;
|
|
18
|
+
hidden: string;
|
|
19
|
+
images: string;
|
|
20
|
+
logo: string;
|
|
21
|
+
favicon: string;
|
|
22
|
+
banner: string;
|
|
23
|
+
ogImage: string;
|
|
24
|
+
present: string;
|
|
25
|
+
missing: string;
|
|
26
|
+
approvedOn: string;
|
|
27
|
+
scrapedNote: string;
|
|
28
|
+
/** `{done}` pages read of `{total}`. */
|
|
29
|
+
progress: string;
|
|
30
|
+
progressLabel: string;
|
|
31
|
+
phase: string;
|
|
32
|
+
outcome: string;
|
|
33
|
+
canStart: string;
|
|
34
|
+
cannotStart: string;
|
|
35
|
+
/** Why a new generation cannot start. */
|
|
36
|
+
reason: string;
|
|
37
|
+
cooldown: string;
|
|
38
|
+
activeAttempt: string;
|
|
39
|
+
retryLimit: string;
|
|
40
|
+
nextEligible: string;
|
|
41
|
+
retriesLeft: string;
|
|
42
|
+
/** The generation run's status, by the backend's code. */
|
|
43
|
+
runStatus: Record<string, string>;
|
|
44
|
+
/** The crawl step, by the backend's code. */
|
|
45
|
+
phases: Record<string, string>;
|
|
46
|
+
/** How useful the draft is, by the backend's code. */
|
|
47
|
+
outcomes: Record<string, string>;
|
|
48
|
+
}
|
|
49
|
+
export interface AgentBrandProfileCardProps extends AgentRoleCardHostProps {
|
|
50
|
+
data: BrandProfileCardData;
|
|
51
|
+
copy?: Partial<AgentBrandProfileCardCopy>;
|
|
52
|
+
/** A BCP 47 tag for the numbers. */
|
|
53
|
+
locale?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @internal Read card for the brand profile and/or its generation run (CEL-2560). The tagline was scraped from a website, so it is
|
|
57
|
+
* quoted and marked as read-from-the-site; image URLs and the source URL are never carried, only whether each image exists.
|
|
58
|
+
*/
|
|
59
|
+
export declare function AgentBrandProfileCard({ data, copy, locale, ...host }: AgentBrandProfileCardProps): import("react/jsx-runtime").JSX.Element | null;
|
|
60
|
+
//# sourceMappingURL=brand-profile-card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-profile-card.d.ts","sourceRoot":"","sources":["../../../src/agent/role-cards/brand-profile-card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,EAQL,KAAK,sBAAsB,EAC5B,MAAM,YAAY,CAAC;AAKpB,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,Q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