@runtypelabs/persona 4.14.0 → 4.16.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 +4 -4
- package/dist/animations/glyph-cycle.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/{types-DveIaNx6.d.cts → types-BpWGm7_6.d.cts} +17 -0
- package/dist/animations/{types-DveIaNx6.d.ts → types-BpWGm7_6.d.ts} +17 -0
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/chunk-QJ4LV2KW.js +1 -0
- package/dist/codegen.cjs +12 -11
- package/dist/codegen.js +14 -13
- package/dist/{context-mentions-ONG7A7M6.js → context-mentions-BTSTIBFC.js} +1 -1
- package/dist/context-mentions.cjs +11 -8
- package/dist/context-mentions.d.cts +520 -21
- package/dist/context-mentions.d.ts +520 -21
- package/dist/context-mentions.js +11 -8
- package/dist/index.cjs +69 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +595 -46
- package/dist/index.d.ts +595 -46
- package/dist/index.global.js +60 -57
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +69 -68
- package/dist/index.js.map +1 -1
- package/dist/launcher.global.js +5 -2
- package/dist/launcher.global.js.map +1 -1
- package/dist/smart-dom-reader.d.cts +520 -21
- package/dist/smart-dom-reader.d.ts +520 -21
- package/dist/testing.cjs +3 -3
- package/dist/testing.d.cts +7 -0
- package/dist/testing.d.ts +7 -0
- package/dist/testing.js +3 -3
- package/dist/theme-editor-preview.cjs +67 -67
- package/dist/theme-editor-preview.d.cts +534 -22
- package/dist/theme-editor-preview.d.ts +534 -22
- package/dist/theme-editor-preview.js +57 -57
- package/dist/theme-editor.cjs +10 -10
- package/dist/theme-editor.d.cts +521 -23
- package/dist/theme-editor.d.ts +521 -23
- package/dist/theme-editor.js +10 -10
- package/dist/theme-reference.cjs +1 -1
- package/dist/theme-reference.d.cts +104 -3
- package/dist/theme-reference.d.ts +104 -3
- package/dist/theme-reference.js +1 -1
- package/dist/widget.css +1 -1
- package/package.json +1 -1
- package/src/ask-user-question-tool.ts +10 -7
- package/src/components/artifact-pane.test.ts +27 -0
- package/src/components/artifact-pane.ts +7 -3
- package/src/components/artifact-preview.ts +1 -1
- package/src/components/composer-parts.test.ts +103 -4
- package/src/components/composer-parts.ts +53 -15
- package/src/components/header-builder.ts +27 -2
- package/src/components/header-layouts.test.ts +56 -0
- package/src/components/header-layouts.ts +29 -9
- package/src/components/launcher-surface.test.ts +403 -0
- package/src/components/launcher.ts +297 -2
- package/src/components/messages.ts +5 -2
- package/src/components/panel.ts +92 -71
- package/src/components/pill-composer-builder.test.ts +18 -0
- package/src/components/suggestions.test.ts +273 -0
- package/src/components/suggestions.ts +528 -86
- package/src/components/welcome.test.ts +121 -0
- package/src/components/welcome.ts +305 -0
- package/src/components/widget-view.test.ts +5 -3
- package/src/components/widget-view.ts +18 -7
- package/src/defaults.ts +7 -5
- package/src/generated/runtype-openapi-contract.ts +17 -0
- package/src/index-core.ts +29 -2
- package/src/launcher-global.ts +11 -8
- package/src/plugins/types.ts +136 -3
- package/src/presets.ts +3 -3
- package/src/session.ts +10 -8
- package/src/styles/widget-styles.test.ts +382 -0
- package/src/styles/widget.css +778 -4
- package/src/suggest-replies-tool.test.ts +233 -2
- package/src/suggest-replies-tool.ts +115 -39
- package/src/testing/mock-stream.test.ts +19 -0
- package/src/testing/mock-stream.ts +20 -0
- package/src/theme-editor/preview-utils.test.ts +34 -0
- package/src/theme-editor/preview-utils.ts +77 -2
- package/src/theme-editor/sections.test.ts +33 -0
- package/src/theme-editor/sections.ts +83 -6
- package/src/theme-reference.ts +34 -5
- package/src/types/theme.ts +72 -3
- package/src/types.ts +312 -18
- package/src/ui.body-top-slot.test.ts +95 -0
- package/src/ui.content-width.test.ts +91 -0
- package/src/ui.detached-panel.test.ts +1 -1
- package/src/ui.docked.test.ts +7 -4
- package/src/ui.launcher-teaser.test.ts +162 -0
- package/src/ui.rebuild-composer.test.ts +491 -0
- package/src/ui.render-welcome.test.ts +505 -0
- package/src/ui.scroll-additive.test.ts +91 -21
- package/src/ui.scroll.test.ts +302 -14
- package/src/ui.suggest-replies.test.ts +1112 -1
- package/src/ui.ts +1008 -149
- package/src/ui.welcome.test.ts +504 -0
- package/src/utils/artifact-file.test.ts +1 -1
- package/src/utils/artifact-gate.test.ts +27 -0
- package/src/utils/artifact-gate.ts +9 -0
- package/src/utils/attachment-manager.test.ts +37 -0
- package/src/utils/attachment-manager.ts +15 -0
- package/src/utils/auto-follow.test.ts +23 -0
- package/src/utils/auto-follow.ts +11 -1
- package/src/utils/code-generators.test.ts +40 -0
- package/src/utils/code-generators.ts +22 -0
- package/src/utils/config-merge.test.ts +24 -0
- package/src/utils/config-merge.ts +2 -0
- package/src/utils/content-width.test.ts +37 -0
- package/src/utils/content-width.ts +17 -0
- package/src/utils/icons.test.ts +26 -0
- package/src/utils/icons.ts +8 -0
- package/src/utils/plugin-storage.test.ts +94 -0
- package/src/utils/plugin-storage.ts +98 -0
- package/src/utils/theme.test.ts +216 -0
- package/src/utils/tokens.ts +113 -3
- package/src/welcome.test.ts +213 -0
- package/src/welcome.ts +130 -0
- package/dist/chunk-MMUPR2JW.js +0 -1
package/src/welcome.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AgentWidgetConfig,
|
|
3
|
+
AgentWidgetMessage,
|
|
4
|
+
AgentWidgetWelcomeDismiss,
|
|
5
|
+
AgentWidgetWelcomeIcon,
|
|
6
|
+
AgentWidgetWelcomeVariant,
|
|
7
|
+
} from "./types";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Single source of truth for the welcome surface. Renderers consume the
|
|
11
|
+
* resolved shape only and never read `copy.welcome*` directly.
|
|
12
|
+
*
|
|
13
|
+
* The defaults live here, not in `defaults.ts`: `mergeConfigUpdate`
|
|
14
|
+
* re-applies `mergeWithDefaults` after every patch, so anything defaulted
|
|
15
|
+
* there would be materialized into the stored config and presence-based
|
|
16
|
+
* precedence could no longer tell a host-set value from a default.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** Default welcome title, applied when neither `welcome` nor `copy` sets one. */
|
|
20
|
+
export const DEFAULT_WELCOME_TITLE = "Hello 👋";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Scope statement in the assistant's voice, deliberately generic so the
|
|
24
|
+
* placeholder shape reads as something to replace with domain copy.
|
|
25
|
+
*/
|
|
26
|
+
export const DEFAULT_WELCOME_SUBTITLE =
|
|
27
|
+
"I can answer questions and help you get things done here.";
|
|
28
|
+
|
|
29
|
+
export interface ResolvedWelcomeConfig {
|
|
30
|
+
title: string;
|
|
31
|
+
subtitle: string;
|
|
32
|
+
icon?: AgentWidgetWelcomeIcon;
|
|
33
|
+
variant: AgentWidgetWelcomeVariant;
|
|
34
|
+
dismiss: AgentWidgetWelcomeDismiss;
|
|
35
|
+
/** Undefined under `variant: "hero"`, which suppresses the greeting. */
|
|
36
|
+
message?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Keyed on the config object: the resolver runs on every render, so warnings
|
|
40
|
+
// fire once per config identity instead of once per frame.
|
|
41
|
+
const warnedConfigs = new WeakSet<AgentWidgetConfig>();
|
|
42
|
+
|
|
43
|
+
const isSet = <T, K extends keyof T>(source: T | undefined, key: K): boolean =>
|
|
44
|
+
!!source && source[key] !== undefined;
|
|
45
|
+
|
|
46
|
+
const warnOnce = (config: AgentWidgetConfig | undefined, messages: string[]) => {
|
|
47
|
+
if (!config || config.debug !== true || !messages.length) return;
|
|
48
|
+
if (warnedConfigs.has(config)) return;
|
|
49
|
+
warnedConfigs.add(config);
|
|
50
|
+
messages.forEach((message) => console.warn(`[persona] ${message}`));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Per-field, presence-based precedence: `welcome.*` wins, else the legacy
|
|
55
|
+
* `copy` alias, else the default above.
|
|
56
|
+
*/
|
|
57
|
+
export const resolveWelcomeConfig = (
|
|
58
|
+
config?: AgentWidgetConfig
|
|
59
|
+
): ResolvedWelcomeConfig => {
|
|
60
|
+
const welcome = config?.welcome;
|
|
61
|
+
const copy = config?.copy;
|
|
62
|
+
|
|
63
|
+
const variant: AgentWidgetWelcomeVariant = isSet(welcome, "variant")
|
|
64
|
+
? welcome!.variant!
|
|
65
|
+
: copy?.showWelcomeCard === false
|
|
66
|
+
? "none"
|
|
67
|
+
: "card";
|
|
68
|
+
|
|
69
|
+
// Hero IS the greeting: `dismiss` is forced and `message` is suppressed.
|
|
70
|
+
const dismiss: AgentWidgetWelcomeDismiss =
|
|
71
|
+
variant === "hero"
|
|
72
|
+
? "on-first-message"
|
|
73
|
+
: isSet(welcome, "dismiss")
|
|
74
|
+
? welcome!.dismiss!
|
|
75
|
+
: "never";
|
|
76
|
+
|
|
77
|
+
const conflicts: string[] = [];
|
|
78
|
+
if (isSet(welcome, "title") && isSet(copy, "welcomeTitle")) {
|
|
79
|
+
conflicts.push(
|
|
80
|
+
"welcome.title and copy.welcomeTitle are both set; welcome.title wins. copy.welcomeTitle is deprecated."
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
if (isSet(welcome, "subtitle") && isSet(copy, "welcomeSubtitle")) {
|
|
84
|
+
conflicts.push(
|
|
85
|
+
"welcome.subtitle and copy.welcomeSubtitle are both set; welcome.subtitle wins. copy.welcomeSubtitle is deprecated."
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
if (isSet(welcome, "variant") && isSet(copy, "showWelcomeCard")) {
|
|
89
|
+
conflicts.push(
|
|
90
|
+
"welcome.variant and copy.showWelcomeCard are both set; welcome.variant wins. copy.showWelcomeCard is deprecated."
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
if (variant === "hero" && isSet(welcome, "message")) {
|
|
94
|
+
conflicts.push(
|
|
95
|
+
'welcome.message is ignored when welcome.variant is "hero": the hero is the greeting.'
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
if (variant === "hero" && isSet(welcome, "dismiss") && welcome!.dismiss !== "on-first-message") {
|
|
99
|
+
conflicts.push(
|
|
100
|
+
'welcome.dismiss is pinned to "on-first-message" when welcome.variant is "hero".'
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
warnOnce(config, conflicts);
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
title: isSet(welcome, "title")
|
|
107
|
+
? welcome!.title!
|
|
108
|
+
: copy?.welcomeTitle ?? DEFAULT_WELCOME_TITLE,
|
|
109
|
+
subtitle: isSet(welcome, "subtitle")
|
|
110
|
+
? welcome!.subtitle!
|
|
111
|
+
: copy?.welcomeSubtitle ?? DEFAULT_WELCOME_SUBTITLE,
|
|
112
|
+
icon: welcome?.icon,
|
|
113
|
+
variant,
|
|
114
|
+
dismiss,
|
|
115
|
+
message: variant === "hero" ? undefined : welcome?.message,
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Derived visibility, never stored. "User activity" is the same predicate the
|
|
121
|
+
* starters use: the session contains at least one `role: "user"` message.
|
|
122
|
+
*/
|
|
123
|
+
export const isWelcomeVisible = (
|
|
124
|
+
resolved: ResolvedWelcomeConfig,
|
|
125
|
+
messages: readonly AgentWidgetMessage[] | undefined
|
|
126
|
+
): boolean => {
|
|
127
|
+
if (resolved.variant === "none") return false;
|
|
128
|
+
if (resolved.dismiss === "never") return true;
|
|
129
|
+
return !(messages ?? []).some((message) => message.role === "user");
|
|
130
|
+
};
|
package/dist/chunk-MMUPR2JW.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var zt=(e,t)=>{let n=document.createElement(e);return t&&(n.className=t),n};var Bt=()=>document.createDocumentFragment(),Ft=(e,t={},...n)=>{let o=document.createElement(e);if(t.className&&(o.className=t.className),t.text!==void 0&&(o.textContent=t.text),t.attrs)for(let[s,a]of Object.entries(t.attrs))o.setAttribute(s,a);if(t.style){let s=o.style,a=t.style;for(let c of Object.keys(a)){let l=a[c];l!=null&&(s[c]=l)}}let r=n.filter(s=>s!=null);return r.length>0&&o.append(...r),o},Kt=(...e)=>e.filter(Boolean).join(" ");import{Activity as A,ArrowDown as k,ArrowUp as P,ArrowUpRight as L,Bot as I,ChevronDown as R,ChevronUp as D,ChevronRight as H,ChevronLeft as O,Check as z,Clipboard as B,ClipboardCopy as F,CodeXml as K,Copy as W,File as U,FileCode as j,FileSpreadsheet as $,FileText as q,ImagePlus as V,Loader as X,LoaderCircle as G,Mic as _,Paperclip as Y,RefreshCw as Z,Search as J,Send as Q,ShieldAlert as ee,ShieldCheck as te,ShieldX as ne,Square as oe,ThumbsDown as re,ThumbsUp as ie,Upload as se,Volume2 as ae,X as le,User as ce,Mail as de,Phone as ue,Calendar as me,Clock as pe,Building as ge,MapPin as he,Lock as fe,Key as we,CreditCard as ye,AtSign as be,Hash as ve,Globe as xe,Link as Ce,CircleCheck as Se,CircleX as Ee,TriangleAlert as Te,Info as Me,Ban as Ne,Shield as Ae,ArrowLeft as ke,ArrowRight as Pe,ExternalLink as Le,Ellipsis as Ie,EllipsisVertical as Re,Menu as De,House as He,Plus as Oe,Minus as ze,Pencil as Be,Trash as Fe,Trash2 as Ke,Save as We,Download as Ue,Share as je,Funnel as $e,Settings as qe,RotateCw as Ve,Maximize as Xe,Minimize as Ge,ShoppingCart as _e,ShoppingBag as Ye,Package as Ze,Truck as Je,Tag as Qe,Gift as et,Receipt as tt,Wallet as nt,Store as ot,DollarSign as rt,Percent as it,Play as st,Pause as at,VolumeX as lt,Camera as ct,Image as dt,Film as ut,Headphones as mt,MessageCircle as pt,MessageSquare as gt,Bell as ht,Heart as ft,Star as wt,Eye as yt,EyeOff as bt,Bookmark as vt,CalendarDays as xt,History as Ct,Timer as St,Folder as Et,FolderOpen as Tt,Files as Mt,Sparkles as Nt,Zap as At,Sun as kt,Moon as Pt,Flag as Lt,Monitor as It,Smartphone as Rt}from"lucide";var Dt={activity:A,"arrow-down":k,"arrow-up":P,"arrow-up-right":L,bot:I,"chevron-down":R,"chevron-up":D,"chevron-right":H,"chevron-left":O,check:z,clipboard:B,"clipboard-copy":F,"code-xml":K,copy:W,file:U,"file-code":j,"file-spreadsheet":$,"file-text":q,"image-plus":V,loader:X,"loader-circle":G,mic:_,paperclip:Y,"refresh-cw":Z,search:J,send:Q,"shield-alert":ee,"shield-check":te,"shield-x":ne,square:oe,"thumbs-down":re,"thumbs-up":ie,upload:se,"volume-2":ae,x:le,user:ce,mail:de,phone:ue,calendar:me,clock:pe,building:ge,"map-pin":he,lock:fe,key:we,"credit-card":ye,"at-sign":be,hash:ve,globe:xe,link:Ce,"circle-check":Se,"circle-x":Ee,"triangle-alert":Te,info:Me,ban:Ne,shield:Ae,"arrow-left":ke,"arrow-right":Pe,"external-link":Le,ellipsis:Ie,"ellipsis-vertical":Re,menu:De,house:He,plus:Oe,minus:ze,pencil:Be,trash:Fe,"trash-2":Ke,save:We,download:Ue,share:je,funnel:$e,settings:qe,"rotate-cw":Ve,maximize:Xe,minimize:Ge,"shopping-cart":_e,"shopping-bag":Ye,package:Ze,truck:Je,tag:Qe,gift:et,receipt:tt,wallet:nt,store:ot,"dollar-sign":rt,percent:it,play:st,pause:at,"volume-x":lt,camera:ct,image:dt,film:ut,headphones:mt,"message-circle":pt,"message-square":gt,bell:ht,heart:ft,star:wt,eye:yt,"eye-off":bt,bookmark:vt,"calendar-days":xt,history:Ct,timer:St,folder:Et,"folder-open":Tt,files:Mt,sparkles:Nt,zap:At,sun:kt,moon:Pt,flag:Lt,monitor:It,smartphone:Rt},jt=(e,t=24,n="currentColor",o=2)=>{let r=Dt[e];return r?Ht(r,t,n,o):(console.warn(`Lucide icon "${e}" is not in the Persona registry. Add it to packages/widget/src/utils/icons.ts (see docs/icon-registry-shortlist.md).`),null)};function Ht(e,t,n,o){if(!Array.isArray(e))return null;let r=document.createElementNS("http://www.w3.org/2000/svg","svg");return r.setAttribute("width",String(t)),r.setAttribute("height",String(t)),r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("fill","none"),r.setAttribute("stroke",n),r.setAttribute("stroke-width",String(o)),r.setAttribute("stroke-linecap","round"),r.setAttribute("stroke-linejoin","round"),r.setAttribute("aria-hidden","true"),e.forEach(s=>{if(!Array.isArray(s)||s.length<2)return;let a=s[0],c=s[1];if(!c)return;let l=document.createElementNS("http://www.w3.org/2000/svg",a);Object.entries(c).forEach(([h,f])=>{h!=="stroke"&&l.setAttribute(h,String(f))}),r.appendChild(l)}),r}function qt(e){let t={trigger:e.trigger??"@",position:e.triggerPosition??"anywhere",allowSpaces:!1,sources:Array.isArray(e.sources)?e.sources:[],searchPlaceholder:e.searchPlaceholder,showButton:e.showButton!==!1,buttonIconName:e.buttonIconName,buttonTooltipText:e.buttonTooltipText},n=(e.triggers??[]).map(o=>({trigger:o.trigger,position:o.triggerPosition??"anywhere",allowSpaces:o.allowSpaces??!1,sources:Array.isArray(o.sources)?o.sources:[],searchPlaceholder:o.searchPlaceholder,showButton:o.showButton===!0,buttonIconName:o.buttonIconName,buttonTooltipText:o.buttonTooltipText}));return[t,...n]}function T(e){let t=e.getRootNode?.();return t instanceof ShadowRoot||t instanceof Document?t:e.ownerDocument??document}function b(e,t,n){let o=e instanceof Document?e.head:e,r=t.replace(/["\\]/g,"\\$&");if(o.querySelector(`style[data-persona-plugin-style="${r}"]`))return;let a=(e instanceof Document?e:e.ownerDocument??document).createElement("style");a.setAttribute("data-persona-plugin-style",t),a.textContent=n,o.appendChild(a)}function Xt(e,t,n){if(e instanceof Document||e instanceof ShadowRoot){b(e,t,n);return}let o=e;if(o.isConnected){b(T(o),t,n);return}let r=o.ownerDocument??document;b(r,t,n),queueMicrotask(()=>{let s=T(o);s!==r&&b(s,t,n)})}function Ot(e){let t=e.getRootNode?.();return t instanceof ShadowRoot?t:(e.ownerDocument??document).body}function Gt(e){let{anchor:t,content:n,placement:o="bottom-start",offset:r=6,matchAnchorWidth:s=!1,horizontalOffset:a,verticalOffset:c,zIndex:l=2147483e3,onOpen:h,onDismiss:f}=e,M=e.container??Ot(t),d=!1,w=null,v=()=>{if(!d)return;let i=t.getBoundingClientRect();n.style.position="fixed",s&&(n.style.minWidth=`${i.width}px`),a&&(n.style.maxWidth=`${i.width}px`);let m=n.getBoundingClientRect(),u=c?.()??null,y=u!=null?i.top+u:i.top,x=o==="top-start"||o==="top-end"?y-r-m.height:i.bottom+r,g=o==="bottom-end"||o==="top-end"?i.right-m.width:i.left,E=a?.()??null;if(E!=null){let N=Math.max(i.left,i.right-m.width);g=Math.min(Math.max(i.left+E,i.left),N)}n.style.top=`${x}px`,n.style.left=`${g}px`},p=()=>{d&&(d=!1,w&&(w(),w=null),n.remove())},S=()=>{if(d)return;d=!0,l!=null&&(n.style.zIndex=String(l)),M.appendChild(n),v();let i=(t.ownerDocument??document).defaultView??window,m=t.ownerDocument??document,u=()=>{if(!t.isConnected){p(),f?.("anchor-removed");return}v()},y=C=>{let g=typeof C.composedPath=="function"?C.composedPath():[];g.includes(n)||g.includes(t)||(p(),f?.("outside"))},x=i.setTimeout(()=>{m.addEventListener("pointerdown",y,!0)},0);i.addEventListener("scroll",u,!0),i.addEventListener("resize",u),w=()=>{i.clearTimeout(x),m.removeEventListener("pointerdown",y,!0),i.removeEventListener("scroll",u,!0),i.removeEventListener("resize",u)},h?.()};return{get isOpen(){return d},open:S,close:p,toggle:()=>d?p():S(),reposition:v,destroy:p}}function _t(e){return(typeof e.composedPath=="function"?e.composedPath():[]).some(n=>n instanceof HTMLElement&&(n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.isContentEditable))}export{zt as a,Bt as b,Ft as c,Kt as d,jt as e,qt as f,Xt as g,Gt as h,_t as i};
|