@webless/agent 0.7.5 → 0.8.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 CHANGED
@@ -43,3 +43,22 @@ Agent Studio generates a live preview of the agent on your pages, so you can che
43
43
  ## This npm package
44
44
 
45
45
  `@webless/agent` is published for Webless tooling and internal use. It powers the script bundle served from the console install flow.
46
+
47
+ ## Render a stored conversation in React
48
+
49
+ `AgentTranscript` reuses the agent's message renderer without connecting to a runtime or creating a session. It renders a snapshot: no composer, feedback, regeneration, or booking actions. Links and source references remain readable; booking controls are disabled.
50
+
51
+ ```tsx
52
+ import { AgentTranscript } from "@webless/agent/react";
53
+ import "@webless/agent/react.css";
54
+
55
+ <AgentTranscript
56
+ messages={[
57
+ { id: "1", role: "visitor", text: "Can I book a demo?", createdAt: 1789056000000 },
58
+ { id: "2", role: "agent", text: "What day works for you?", createdAt: 1789056001000 },
59
+ ]}
60
+ colorScheme="light"
61
+ />
62
+ ```
63
+
64
+ The host owns fetching, authorization, pagination, scrolling, and review controls. Pass `ConversationMessage` snapshots with stable IDs and millisecond timestamps. Optional `theme`, `agentLabel`, `visitorLabel`, `label`, and `formatTimestamp` props adapt the presentation to the host. Timestamps default to UTC. Structured references render when supplied in the message; the component does not fetch missing history or tool results.
@@ -4074,6 +4074,48 @@ function MessageActions({
4074
4074
  // src/react/components/AgentRail/AgentRail.tsx
4075
4075
  import { useEffect as useEffect6, useRef as useRef6, useState as useState9 } from "react";
4076
4076
 
4077
+ // src/react/lib/agent-theme.ts
4078
+ function agentThemeStyle(theme, resolvedColorScheme) {
4079
+ const brandedTheme = { ...defaultAgentRailTheme, ...theme };
4080
+ const resolvedTheme = resolvedColorScheme === "dark" ? {
4081
+ ...brandedTheme,
4082
+ brand: theme?.brand ?? defaultDarkAgentRailTheme.brand,
4083
+ brandDeep: theme?.brandDeep ?? defaultDarkAgentRailTheme.brandDeep,
4084
+ brandSoft: theme?.brandSoft ?? `color-mix(in srgb, ${theme?.brand ?? defaultDarkAgentRailTheme.brand} 18%, ${defaultDarkAgentRailTheme.surface})`,
4085
+ border: theme?.border ?? defaultDarkAgentRailTheme.border,
4086
+ danger: theme?.danger ?? defaultDarkAgentRailTheme.danger,
4087
+ onBrand: theme?.onBrand ?? defaultDarkAgentRailTheme.onBrand,
4088
+ success: theme?.success ?? defaultDarkAgentRailTheme.success,
4089
+ surface: theme?.surface ?? defaultDarkAgentRailTheme.surface,
4090
+ surfaceMuted: theme?.surfaceMuted ?? defaultDarkAgentRailTheme.surfaceMuted,
4091
+ text: theme?.text ?? defaultDarkAgentRailTheme.text,
4092
+ textMuted: theme?.textMuted ?? defaultDarkAgentRailTheme.textMuted,
4093
+ textSubtle: theme?.textSubtle ?? defaultDarkAgentRailTheme.textSubtle,
4094
+ visitorBubble: theme?.visitorBubble ?? theme?.brand ?? defaultDarkAgentRailTheme.visitorBubble
4095
+ } : brandedTheme;
4096
+ return {
4097
+ "--rail-width": resolvedTheme.railMaxWidth,
4098
+ "--as-rail-max-width": resolvedTheme.railMaxWidth,
4099
+ "--as-brand": resolvedTheme.brand,
4100
+ "--as-brand-soft": resolvedTheme.brandSoft,
4101
+ "--as-brand-deep": resolvedTheme.brandDeep,
4102
+ "--as-surface": resolvedTheme.surface,
4103
+ "--as-surface-muted": resolvedTheme.surfaceMuted,
4104
+ "--as-text": resolvedTheme.text,
4105
+ "--as-text-muted": resolvedTheme.textMuted,
4106
+ "--as-text-subtle": resolvedTheme.textSubtle,
4107
+ "--as-border": resolvedTheme.border,
4108
+ "--as-visitor-bubble": resolvedTheme.visitorBubble,
4109
+ "--as-visitor-text": resolvedTheme.visitorText,
4110
+ "--as-on-brand": resolvedTheme.onBrand,
4111
+ "--as-success": resolvedTheme.success,
4112
+ "--as-danger": resolvedTheme.danger,
4113
+ "--as-font-body": resolvedTheme.fontBody,
4114
+ "--as-font-display": resolvedTheme.fontDisplay,
4115
+ colorScheme: resolvedColorScheme
4116
+ };
4117
+ }
4118
+
4077
4119
  // src/react/hooks/useAgentColorScheme.ts
4078
4120
  import { useSyncExternalStore } from "react";
4079
4121
  var DARK_MODE_QUERY = "(prefers-color-scheme: dark)";
@@ -6070,44 +6112,7 @@ function AgentRail({
6070
6112
  const [failedLogoUrl, setFailedLogoUrl] = useState9(null);
6071
6113
  const showBrandLogo = Boolean(resolvedBrandLogoUrl) && failedLogoUrl !== resolvedBrandLogoUrl;
6072
6114
  const resolvedColorScheme = useAgentColorScheme(colorScheme);
6073
- const brandedTheme = { ...defaultAgentRailTheme, ...theme };
6074
- const resolvedTheme = resolvedColorScheme === "dark" ? {
6075
- ...brandedTheme,
6076
- brand: theme?.brand ?? defaultDarkAgentRailTheme.brand,
6077
- brandDeep: theme?.brandDeep ?? defaultDarkAgentRailTheme.brandDeep,
6078
- brandSoft: theme?.brandSoft ?? `color-mix(in srgb, ${theme?.brand ?? defaultDarkAgentRailTheme.brand} 18%, ${defaultDarkAgentRailTheme.surface})`,
6079
- border: theme?.border ?? defaultDarkAgentRailTheme.border,
6080
- danger: theme?.danger ?? defaultDarkAgentRailTheme.danger,
6081
- onBrand: theme?.onBrand ?? defaultDarkAgentRailTheme.onBrand,
6082
- success: theme?.success ?? defaultDarkAgentRailTheme.success,
6083
- surface: theme?.surface ?? defaultDarkAgentRailTheme.surface,
6084
- surfaceMuted: theme?.surfaceMuted ?? defaultDarkAgentRailTheme.surfaceMuted,
6085
- text: theme?.text ?? defaultDarkAgentRailTheme.text,
6086
- textMuted: theme?.textMuted ?? defaultDarkAgentRailTheme.textMuted,
6087
- textSubtle: theme?.textSubtle ?? defaultDarkAgentRailTheme.textSubtle,
6088
- visitorBubble: theme?.visitorBubble ?? theme?.brand ?? defaultDarkAgentRailTheme.visitorBubble
6089
- } : brandedTheme;
6090
- const railStyle = {
6091
- "--rail-width": resolvedTheme.railMaxWidth,
6092
- "--as-rail-max-width": resolvedTheme.railMaxWidth,
6093
- "--as-brand": resolvedTheme.brand,
6094
- "--as-brand-soft": resolvedTheme.brandSoft,
6095
- "--as-brand-deep": resolvedTheme.brandDeep,
6096
- "--as-surface": resolvedTheme.surface,
6097
- "--as-surface-muted": resolvedTheme.surfaceMuted,
6098
- "--as-text": resolvedTheme.text,
6099
- "--as-text-muted": resolvedTheme.textMuted,
6100
- "--as-text-subtle": resolvedTheme.textSubtle,
6101
- "--as-border": resolvedTheme.border,
6102
- "--as-visitor-bubble": resolvedTheme.visitorBubble,
6103
- "--as-visitor-text": resolvedTheme.visitorText,
6104
- "--as-on-brand": resolvedTheme.onBrand,
6105
- "--as-success": resolvedTheme.success,
6106
- "--as-danger": resolvedTheme.danger,
6107
- "--as-font-body": resolvedTheme.fontBody,
6108
- "--as-font-display": resolvedTheme.fontDisplay,
6109
- colorScheme: resolvedColorScheme
6110
- };
6115
+ const railStyle = agentThemeStyle(theme, resolvedColorScheme);
6111
6116
  const pendingInputRequests = (state.pendingInputs ?? []).filter(
6112
6117
  (request) => shouldRenderVisitorInputCard(request) && (!state.pendingOffer || request.kind === "tool-approval")
6113
6118
  );
@@ -7123,6 +7128,9 @@ export {
7123
7128
  submitAgentPanel,
7124
7129
  defaultAgentRailTheme,
7125
7130
  defaultDarkAgentRailTheme,
7131
+ agentThemeStyle,
7132
+ useAgentColorScheme,
7133
+ MessageBubble,
7126
7134
  MessageActions,
7127
7135
  AgentRail,
7128
7136
  AssistEdgeTab,
@@ -7132,4 +7140,4 @@ export {
7132
7140
  sendAgentAnswerFeedback,
7133
7141
  AgentWidget
7134
7142
  };
7135
- //# sourceMappingURL=chunk-CD6TKXGT.js.map
7143
+ //# sourceMappingURL=chunk-JZPXXG76.js.map