@waniwani/sdk 0.14.0 → 0.14.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.
@@ -57,7 +57,28 @@ interface KbClient {
57
57
  sources(): Promise<KbSource[]>;
58
58
  }
59
59
 
60
- type EventType = "session.started" | "tool.called" | "quote.requested" | "quote.succeeded" | "quote.failed" | "link.clicked" | "purchase.completed" | "widget_render" | "widget_click" | "widget_link_click" | "widget_error" | "widget_scroll" | "widget_form_field" | "widget_form_submit" | "user.identified" | "price_shown" | "prices_compared" | "option_selected" | "lead" | "converted";
60
+ type EventType = "session.started" | "page.viewed" | "tool.called" | "quote.requested" | "quote.succeeded" | "quote.failed" | "link.clicked" | "purchase.completed" | "widget_render" | "widget_click" | "widget_link_click" | "widget_error" | "widget_scroll" | "widget_form_field" | "widget_form_submit" | "user.identified" | "price_shown" | "prices_compared" | "option_selected" | "lead" | "converted";
61
+ /**
62
+ * Properties for `page.viewed` — emitted once when the chat widget initializes
63
+ * on a host page (the top of the funnel). Attributed to the anonymous
64
+ * `visitorId` (mapped to `externalUserId`), never to a session: a page view
65
+ * must not create a session, otherwise sessions would equal page views and the
66
+ * "landed → started a conversation" funnel collapses.
67
+ */
68
+ interface PageViewedProperties {
69
+ /** Full URL of the host page the widget loaded on. */
70
+ url?: string;
71
+ /** Referrer of the host page, if any. */
72
+ referrer?: string;
73
+ /** Embed mode the widget initialized in. */
74
+ mode?: "inline" | "floating";
75
+ /** Resolved device type from the visitor context. */
76
+ deviceType?: "mobile" | "tablet" | "desktop";
77
+ /** Primary browser language (BCP-47). */
78
+ language?: string;
79
+ /** IANA timezone of the visitor. */
80
+ timezone?: string;
81
+ }
61
82
  interface ToolCalledProperties {
62
83
  name?: string;
63
84
  type?: "pricing" | "product_info" | "availability" | "support" | "other";
@@ -132,6 +153,9 @@ interface BaseTrackEvent extends TrackingContext {
132
153
  }
133
154
  type TrackEvent = ({
134
155
  event: "session.started";
156
+ } & BaseTrackEvent) | ({
157
+ event: "page.viewed";
158
+ properties?: PageViewedProperties;
135
159
  } & BaseTrackEvent) | ({
136
160
  event: "tool.called";
137
161
  properties?: ToolCalledProperties;
@@ -110,13 +110,13 @@ interface ChatAppearance {
110
110
  variables?: ChatTheme;
111
111
  }
112
112
  /**
113
- * Tool call rendering mode.
113
+ * Tool-call activity rendering mode. Steps are grouped into one collapsible
114
+ * "chain of thought".
114
115
  *
115
- * - `true` (default) — full request/response panels.
116
- * - `"titles-only"` — a compact text indicator with the tool title, no
117
- * JSON panels.
118
- * - `false` tool calls are hidden entirely; a generic working indicator
119
- * shows while tools run.
116
+ * - `true` (default) — each step expands to its request/response JSON.
117
+ * - `"titles-only"` — step labels only, no JSON.
118
+ * - `false` — the chain (and the reasoning trace) are hidden entirely; only
119
+ * a generic working indicator shows while the agent works.
120
120
  */
121
121
  type ShowToolCalls = boolean | "titles-only";
122
122
 
@@ -238,13 +238,14 @@ interface ChatBaseProps {
238
238
  */
239
239
  debug?: boolean;
240
240
  /**
241
- * How tool calls are rendered in the chat.
241
+ * How the agent's tool-call activity renders. Steps are grouped into a
242
+ * single collapsible "chain of thought" that auto-expands while the agent
243
+ * works and collapses to a summary once it settles.
242
244
  *
243
- * - `true` (default) — full request/response panels.
244
- * - `"titles-only"` — a compact text indicator with the tool title, no
245
- * JSON panels.
246
- * - `false` tool calls are hidden entirely; a generic working
247
- * indicator shows while tools run.
245
+ * - `true` (default) — each step expands to its request/response JSON.
246
+ * - `"titles-only"` — step labels only, no JSON.
247
+ * - `false` — the chain is hidden entirely, along with the reasoning
248
+ * trace; only the generic "On it…" indicator shows while the agent works.
248
249
  *
249
250
  * MCP App widgets attached to a tool call are always rendered.
250
251
  */