@waniwani/sdk 0.14.19 → 0.14.21

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.
@@ -3,8 +3,8 @@ export { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
3
  import { z } from 'zod';
4
4
  import { ZodRawShapeCompat, ShapeOutput } from '@modelcontextprotocol/sdk/server/zod-compat.js';
5
5
  export { ZodRawShapeCompat } from '@modelcontextprotocol/sdk/server/zod-compat.js';
6
+ import { ToolAnnotations, ContentBlock, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
6
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
7
- import { ContentBlock, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
8
8
  import * as React$1 from 'react';
9
9
  import React__default, { ReactNode, JSX, SetStateAction } from 'react';
10
10
  import * as ai from 'ai';
@@ -83,6 +83,11 @@ interface SearchResult {
83
83
  score: number;
84
84
  metadata?: Record<string, string>;
85
85
  }
86
+ interface KbSearchTrace {
87
+ query: string;
88
+ resultCount: number;
89
+ results: Array<Pick<SearchResult, "source" | "heading" | "score">>;
90
+ }
86
91
  /** A file to ingest into the knowledge base */
87
92
  interface KbIngestFile {
88
93
  /** Filename (used as chunk source identifier) */
@@ -132,7 +137,7 @@ interface KbClient {
132
137
  sources(): Promise<KbSource[]>;
133
138
  }
134
139
 
135
- 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";
140
+ 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_qualified" | "converted";
136
141
  /**
137
142
  * Properties for `page.viewed` — emitted once when the chat widget initializes
138
143
  * on a host page (the top of the funnel). Attributed to the anonymous
@@ -157,6 +162,8 @@ interface PageViewedProperties {
157
162
  interface ToolCalledProperties {
158
163
  name?: string;
159
164
  type?: "pricing" | "product_info" | "availability" | "support" | "other";
165
+ /** Retrieval traces for kb.search() calls made inside this tool handler. */
166
+ kbSearch?: KbSearchTrace[];
160
167
  }
161
168
  interface QuoteSucceededProperties {
162
169
  amount?: number;
@@ -188,7 +195,23 @@ interface OptionSelectedProperties {
188
195
  amount: number;
189
196
  currency: string;
190
197
  }
191
- interface LeadProperties {
198
+ /**
199
+ * Properties for `lead_qualified` — your code declaring that a person met your
200
+ * qualification bar (finished the qualifying questions, requested a demo,
201
+ * matched your target profile). Sharing an email mid-conversation is
202
+ * `identify(userId, { email })`, not a qualified lead.
203
+ */
204
+ interface LeadQualifiedProperties {
205
+ /**
206
+ * Your own lead id (e.g. the record id your lead-gen API returns). The
207
+ * strongest dedup key and the stable reference back to your system.
208
+ */
209
+ externalId?: string;
210
+ /** The lead's email, if known. */
211
+ email?: string;
212
+ /** The lead's name, if known. */
213
+ name?: string;
214
+ /** Acquisition source of the lead (e.g. "newsletter"). */
192
215
  source?: string;
193
216
  }
194
217
  interface ConvertedProperties {
@@ -259,8 +282,8 @@ type TrackEvent = ({
259
282
  event: "option_selected";
260
283
  properties?: OptionSelectedProperties;
261
284
  } & BaseTrackEvent) | ({
262
- event: "lead";
263
- properties?: LeadProperties;
285
+ event: "lead_qualified";
286
+ properties?: LeadQualifiedProperties;
264
287
  } & BaseTrackEvent) | ({
265
288
  event: "converted";
266
289
  properties?: ConvertedProperties;
@@ -290,12 +313,12 @@ interface RevenuePricesComparedInput extends TrackingContext, PricesComparedProp
290
313
  interface RevenueOptionSelectedInput extends TrackingContext, OptionSelectedProperties {
291
314
  }
292
315
  /**
293
- * Input for `track.lead()`. `source` is the lead's acquisition source
294
- * (the `lead` event property, e.g. "newsletter") — on this helper it shadows
295
- * the envelope `source` from the tracking context. To set a custom envelope
296
- * source on a lead, use the generic `track({ event: "lead", … })`.
316
+ * Input for `track.leadQualified()`. `source` is the lead's acquisition source
317
+ * (the event property, e.g. "newsletter") — on this helper it shadows the
318
+ * envelope `source` from the tracking context. To set a custom envelope source
319
+ * on a lead, use the generic `track({ event: "lead_qualified", … })`.
297
320
  */
298
- interface RevenueLeadInput extends TrackingContext, LeadProperties {
321
+ interface RevenueLeadQualifiedInput extends TrackingContext, LeadQualifiedProperties {
299
322
  }
300
323
  interface RevenueConvertedInput extends TrackingContext, ConvertedProperties {
301
324
  }
@@ -314,7 +337,7 @@ interface RevenueTrackingApi {
314
337
  optionSelected: (input: RevenueOptionSelectedInput) => Promise<{
315
338
  eventId: string;
316
339
  }>;
317
- lead: (input?: RevenueLeadInput) => Promise<{
340
+ leadQualified: (input?: RevenueLeadQualifiedInput) => Promise<{
318
341
  eventId: string;
319
342
  }>;
320
343
  converted: (input: RevenueConvertedInput) => Promise<{
@@ -323,7 +346,7 @@ interface RevenueTrackingApi {
323
346
  }
324
347
  /**
325
348
  * `client.track` — callable for generic events (`track(event)`), with the
326
- * revenue helpers attached flat: `track.priceShown()`, `track.lead()`,
349
+ * revenue helpers attached flat: `track.priceShown()`, `track.leadQualified()`,
327
350
  * `track.converted()`, etc.
328
351
  */
329
352
  interface TrackFn extends RevenueTrackingApi {
@@ -372,7 +395,7 @@ interface TrackingClient {
372
395
  * Returns a deterministic event id immediately after enqueue.
373
396
  *
374
397
  * Also exposes the revenue helpers flat: `client.track.priceShown()`,
375
- * `client.track.lead()`, `client.track.converted()`, etc.
398
+ * `client.track.leadQualified()`, `client.track.converted()`, etc.
376
399
  */
377
400
  track: TrackFn;
378
401
  /**
@@ -443,13 +466,15 @@ type ToolConfig<TInput extends ZodRawShapeCompat> = {
443
466
  * result is consumed programmatically by the widget.
444
467
  */
445
468
  autoInjectResultText?: boolean;
446
- /** Annotations describe the tool's potential impact. */
447
- annotations?: {
448
- readOnlyHint?: boolean;
449
- idempotentHint?: boolean;
450
- openWorldHint?: boolean;
451
- destructiveHint?: boolean;
452
- };
469
+ /**
470
+ * Annotations describe the tool's potential impact. Passed through to
471
+ * `registerTool` as-is.
472
+ *
473
+ * Includes MCP's `title` — a human-readable name for the tool. Claude's
474
+ * Connectors Directory requires it on every tool and flags the server at
475
+ * submission without it; the top-level `title` does not satisfy that.
476
+ */
477
+ annotations?: ToolAnnotations;
453
478
  };
454
479
  type ToolHandler<TInput extends ZodRawShapeCompat> = (input: ShapeOutput<TInput>, context: ToolHandlerContext) => Promise<{
455
480
  /** Text content to return */