@sentientui/mcp 0.24.2 → 0.25.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.
@@ -667,12 +667,17 @@ function registerProjectTools(server, client) {
667
667
  "get_project_stats",
668
668
  {
669
669
  title: "Project health stats",
670
- description: "Get ingestion health for a project: status, events and sessions in the last 24 hours, the time of the last event, and the all-time count of calls to the SentientUI agent API (/v1/agent) \u2014 NOT MCP tool calls.",
670
+ description: "Get ingestion health for a project: status, events in the last 24 hours, the People count for the same window (visitors who ran the page, interacted and passed the bot check), how many visitors are still being analysed, how many are automated, the time of the last event, and the all-time count of calls to the SentientUI agent API (/v1/agent) \u2014 NOT MCP tool calls.",
671
671
  inputSchema: { projectId: projectIdSchema },
672
672
  outputSchema: {
673
673
  status: z2.string().describe("Overall project health status"),
674
674
  events24h: z2.number().describe("Events in the last 24 hours"),
675
- sessions24h: z2.number().describe("Sessions in the last 24 hours"),
675
+ // This field used to be raw sessions; it now carries People, so the old
676
+ // description told an agent bots and unverified visitors were in it.
677
+ sessions24h: z2.number().describe("Deprecated alias of people on a current API; the raw session count on an older one"),
678
+ people: z2.number().nullable().describe("People in the last 24 hours: visitors who ran the page, interacted and passed the bot check; null when the API predates the traffic classification"),
679
+ beingAnalysed: z2.number().nullable().describe("Visitors still being analysed \u2014 usually settled within 3 hours; null on an older API"),
680
+ automated: z2.number().nullable().describe("Automated visitors: AI assistants, search & AI crawlers and other automated; null on an older API"),
676
681
  // Was "Total agent (MCP/API) calls" — but the count comes from
677
682
  // agent_events, which only the /v1/agent endpoint writes. MCP tool calls
678
683
  // are never in it, so an agent read its own activity as missing.
@@ -686,22 +691,30 @@ function registerProjectTools(server, client) {
686
691
  }
687
692
  },
688
693
  withApiErrorGuidance(async ({ projectId }) => {
689
- var _a;
694
+ var _a, _b, _c, _d, _e, _f, _g;
690
695
  const id = encodeURIComponent(projectId);
691
696
  const stats = await client.get(`/projects/${id}/health`);
697
+ const peopleCount = (_b = stats.people) != null ? _b : (_a = stats.traffic) == null ? void 0 : _a.people;
698
+ const classified = peopleCount !== void 0;
699
+ const people = classified ? peopleCount : null;
700
+ const beingAnalysed = classified ? (_d = (_c = stats.traffic) == null ? void 0 : _c.beingAnalysed) != null ? _d : 0 : null;
701
+ const automated = classified ? (_f = (_e = stats.traffic) == null ? void 0 : _e.automated) != null ? _f : 0 : null;
692
702
  const text = [
693
703
  `Status: ${stats.status}`,
694
704
  `Events (24h): ${stats.events24h}`,
695
- `Sessions (24h): ${stats.sessions24h}`,
705
+ ...classified ? [`People (24h): ${people}`, `Being analysed: ${beingAnalysed}`, `Automated: ${automated}`] : [`Sessions (24h): ${stats.sessions24h}`],
696
706
  `Agent API calls (/v1/agent, all-time): ${stats.agentCalls}`,
697
- `Last event: ${(_a = stats.lastEventAt) != null ? _a : "never"}`
707
+ `Last event: ${(_g = stats.lastEventAt) != null ? _g : "never"}`
698
708
  ].join("\n");
699
709
  return {
700
710
  content: [{ type: "text", text }],
701
711
  structuredContent: {
702
712
  status: stats.status,
703
713
  events24h: stats.events24h,
704
- sessions24h: stats.sessions24h,
714
+ sessions24h: people != null ? people : stats.sessions24h,
715
+ people,
716
+ beingAnalysed,
717
+ automated,
705
718
  agentCalls: stats.agentCalls,
706
719
  lastEventAt: stats.lastEventAt
707
720
  }
@@ -795,7 +808,7 @@ function registerComponentTools(server, client) {
795
808
  "list_components",
796
809
  {
797
810
  title: "List components",
798
- description: "List all adaptive components in a project with variant counts and impression totals. Counts cover all retained data by default; pass range or from/to for a window." + UNTRUSTED_FIELDS_NOTE,
811
+ description: "List all adaptive components in a project with variant counts and impression totals. Counts cover all retained data by default; pass range or from/to for a window. Impressions and conversions are People's; unconfirmedConversions is the API's count from visitors we couldn't confirm as people (not included in conversions)." + UNTRUSTED_FIELDS_NOTE,
799
812
  inputSchema: __spreadValues({ projectId: projectIdSchema }, rangeInputSchema("all")),
800
813
  outputSchema: {
801
814
  components: z3.array(
@@ -803,7 +816,8 @@ function registerComponentTools(server, client) {
803
816
  componentId: z3.string(),
804
817
  variantCount: z3.number(),
805
818
  impressions: z3.number(),
806
- conversions: z3.number()
819
+ conversions: z3.number(),
820
+ unconfirmedConversions: z3.number().nullable().describe("Conversions from visitors we couldn't confirm as people (not in conversions); null on an older API")
807
821
  })
808
822
  ).describe("Adaptive components in the project (empty if none)"),
809
823
  total: z3.number().describe("Total components in the project \u2014 larger than the list when truncated"),
@@ -819,12 +833,16 @@ function registerComponentTools(server, client) {
819
833
  withApiErrorGuidance(async ({ projectId, range, from, to }) => {
820
834
  const { components, total, window, truncated } = await fetchAllComponents(client, projectId, { rangeArgs: { range, from, to } });
821
835
  const structuredContent = {
822
- components: components.map((c) => ({
823
- componentId: c.component_id,
824
- variantCount: c.variants.length,
825
- impressions: c.total_impressions,
826
- conversions: c.total_conversions
827
- })),
836
+ components: components.map((c) => {
837
+ var _a;
838
+ return {
839
+ componentId: c.component_id,
840
+ variantCount: c.variants.length,
841
+ impressions: c.total_impressions,
842
+ conversions: c.total_conversions,
843
+ unconfirmedConversions: (_a = c.total_unconfirmed_conversions) != null ? _a : null
844
+ };
845
+ }),
828
846
  total,
829
847
  truncated,
830
848
  window
@@ -836,7 +854,7 @@ function registerComponentTools(server, client) {
836
854
  };
837
855
  }
838
856
  const lines = components.map(
839
- (c) => `- ${untrusted(c.component_id)}: ${c.variants.length} variants, ${c.total_impressions} impressions, ${c.total_conversions} conversions`
857
+ (c) => `- ${untrusted(c.component_id)}: ${c.variants.length} variants, ${c.total_impressions} impressions, ${c.total_conversions} conversions` + (c.total_unconfirmed_conversions ? ` (+${c.total_unconfirmed_conversions} conversions from visitors we couldn't confirm as people)` : "")
840
858
  );
841
859
  if (truncated) {
842
860
  lines.push(`Showing ${components.length} of ${total} components \u2014 fetch cap reached; the rest exist but are not listed here.`);
@@ -848,7 +866,7 @@ function registerComponentTools(server, client) {
848
866
  "get_variant_performance",
849
867
  {
850
868
  title: "Variant performance",
851
- description: "Per-variant conversion over the selected window (default: last 7 calendar days), keyed by component AND variant, each rate with its sample (converting sessions / exposed sessions). Each non-baseline variant carries the server's evidence verdict against its component's baseline arm (100-visit floor on both arms, multiple-comparison-corrected bars): `verdict` judges the windowed rate this row prints when the server sends window evidence (`verdictBasis` = window), and falls back to the all-time verdict on older APIs (`verdictBasis` = all_time). The all-time verdict is also reported separately as reliability (`evidenceState`, `reliabilityVerdict`). Only ahead/behind is a comparative result; raw rates are not a ranking. The change vs the preceding window is an untested descriptor." + UNTRUSTED_FIELDS_NOTE,
869
+ description: "Per-variant conversion over the selected window (default: last 7 calendar days), as conversion rate among People (exposed and converting sessions are People's; conversions from visitors we couldn't confirm as people are reported beside them as unconfirmedConversions, never in the rate), keyed by component AND variant, each rate with its sample (converting sessions / exposed sessions). Each non-baseline variant carries the server's evidence verdict against its component's baseline arm (100-visit floor on both arms, multiple-comparison-corrected bars): `verdict` judges the windowed rate this row prints when the server sends window evidence (`verdictBasis` = window), and falls back to the all-time verdict on older APIs (`verdictBasis` = all_time). The all-time verdict is also reported separately as reliability (`evidenceState`, `reliabilityVerdict`) \u2014 that all-time reliability is the optimizer's own evidence, not a People-only figure. Only ahead/behind is a comparative result; raw rates are not a ranking. The change vs the preceding window is an untested descriptor." + UNTRUSTED_FIELDS_NOTE,
852
870
  inputSchema: __spreadValues({ projectId: projectIdSchema }, rangeInputSchema("7d")),
853
871
  _meta: uiMeta("variant-performance"),
854
872
  outputSchema: {
@@ -859,7 +877,8 @@ function registerComponentTools(server, client) {
859
877
  isBaseline: z3.boolean().describe("The arm the server measures the others against"),
860
878
  baselineExplicit: z3.boolean().describe("False when no arm is named 'control' and the baseline is just the alphabetically-first id"),
861
879
  sessions: z3.number().describe("Exposed sessions in the window (the n of currentCvr)"),
862
- conversions: z3.number().describe("Converting sessions in the window"),
880
+ conversions: z3.number().describe("Converting People (sessions) in the window"),
881
+ unconfirmedConversions: z3.number().nullable().describe("Converting sessions from visitors we couldn't confirm as people (the API's own remainder; not in conversions or currentCvr); null on an older API"),
863
882
  currentCvr: z3.number().nullable().describe("conversions / sessions over the window (0-1); null at 0 sessions"),
864
883
  lowSample: z3.boolean().describe(`True under ${MIN_EVIDENCE_SAMPLE} sessions \u2014 the rate is not interpretable on its own`),
865
884
  evidenceState: z3.string().nullable().describe("Reliability (all time): the server's ALL-TIME evidence state vs the baseline on direct evidence \u2014 not_enough_data | early_signal | moderate_evidence | strong_evidence | likely_worse | inconclusive; null for the baseline or when not provided. Not a verdict on the windowed rate"),
@@ -886,7 +905,7 @@ function registerComponentTools(server, client) {
886
905
  }
887
906
  },
888
907
  withApiErrorGuidance(async ({ projectId, range, from, to }) => {
889
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
908
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
890
909
  const id = encodeURIComponent(projectId);
891
910
  const [componentsRes, trendsRes] = await Promise.all([
892
911
  settled(fetchAllComponents(client, projectId, { rangeArgs: { range, from, to } })),
@@ -967,13 +986,14 @@ function registerComponentTools(server, client) {
967
986
  baselineExplicit: (_i = baseline == null ? void 0 : baseline.explicit) != null ? _i : false,
968
987
  sessions: n,
969
988
  conversions: conv,
989
+ unconfirmedConversions: (_j = v.unconfirmed_conversions) != null ? _j : null,
970
990
  currentCvr: n > 0 ? conv / n : null,
971
991
  lowSample: isLowSample(n),
972
992
  evidenceState: state,
973
- probBeatsBaseline: (_j = stats == null ? void 0 : stats.probBeatsControl) != null ? _j : null,
993
+ probBeatsBaseline: (_k = stats == null ? void 0 : stats.probBeatsControl) != null ? _k : null,
974
994
  reliabilityVerdict,
975
995
  windowEvidenceState: wState,
976
- windowProbBeatsBaseline: (_k = wStats == null ? void 0 : wStats.probBeatsControl) != null ? _k : null,
996
+ windowProbBeatsBaseline: (_l = wStats == null ? void 0 : wStats.probBeatsControl) != null ? _l : null,
977
997
  verdict,
978
998
  verdictBasis,
979
999
  priorCvr,
@@ -1003,6 +1023,7 @@ function registerComponentTools(server, client) {
1003
1023
  `vs preceding window: ${(priorCvr * 100).toFixed(2)}%${pn}, ${deltaPp > 0 ? "+" : ""}${deltaPp.toFixed(1)} pp${momentum ? `, ${momentum}` : ""} (untested)`
1004
1024
  );
1005
1025
  }
1026
+ if (v.unconfirmed_conversions) parts.push(`${v.unconfirmed_conversions} conversions from visitors we couldn't confirm as people`);
1006
1027
  block.push(parts.join(" \xB7 "));
1007
1028
  }
1008
1029
  textBlocks.push(block.join("\n"));
@@ -1017,7 +1038,7 @@ function registerComponentTools(server, client) {
1017
1038
  }
1018
1039
  const header = [
1019
1040
  windowLine(window),
1020
- `Rates: converting ${sessionUnit} \xF7 exposed ${sessionUnit} in the window. ` + (anyAllTimeBasis ? "Evidence: the server's ALL-TIME comparison of each arm against its component's baseline (this API sends no windowed verdict) \u2014 " : "Evidence (this window): the server's comparison of each arm's windowed rate against its component's baseline; reliability (all time): the all-time verdict on direct evidence, which can differ \u2014 ") + 'only "ahead"/"behind" is a result; do not rank arms by raw rate.'
1041
+ `Rates: conversion rate among People \u2014 converting ${sessionUnit} \xF7 exposed ${sessionUnit} in the window. ` + (anyAllTimeBasis ? "Evidence: the server's ALL-TIME comparison of each arm against its component's baseline (this API sends no windowed verdict) \u2014 " : "Evidence (this window): the server's comparison of each arm's windowed rate against its component's baseline; reliability (all time): the all-time verdict on direct evidence, which can differ \u2014 ") + 'only "ahead"/"behind" is a result; do not rank arms by raw rate.'
1021
1042
  ].filter(Boolean);
1022
1043
  const footer = truncated ? ["", "Fetch cap reached \u2014 some components are not listed."] : [];
1023
1044
  const text = [...header, "", textBlocks.join("\n\n"), ...footer].join("\n");
@@ -1032,7 +1053,7 @@ var DEFAULT_LIMIT = 10;
1032
1053
  var MAX_LIMIT = 50;
1033
1054
  var EMPTY_REASON_TEXT = {
1034
1055
  no_events: "The snippet has not fired yet \u2014 nothing has reached us.",
1035
- no_traffic_yet: "Test traffic only so far; no genuine visitors yet.",
1056
+ no_traffic_yet: "In the last 7 days we've only seen visitors we couldn't confirm as people. New visitors are usually confirmed within 3 hours, and this report fills in as they are.",
1036
1057
  awaiting_profiles: "Still building visitor profiles before visitors can be grouped.",
1037
1058
  no_variants: "Nothing to compare yet \u2014 no adaptive component is running.",
1038
1059
  nothing_moved: "Enough data, and nothing moved this period. That is a result.",
@@ -1279,12 +1300,12 @@ function registerStageTools(server, client) {
1279
1300
  // Mirrors GET /projects/:id/stage-report. Says OBSERVATIONAL in the
1280
1301
  // description because nothing serves on stage yet: an agent must not
1281
1302
  // read a per-context arm result as "stage-based serving would win".
1282
- description: `E-commerce projects: where visitors are in buying (new, browsing, carted, customer, lapsed) \u2014 share of human sessions per stage (each session counted once, at its latest recorded stage; hinted = set by a tagged campaign, not observed history), arrival channel x stage with conversion, how visitors moved between stages from one visit to the next, the TESTED holdout lift per first-visit context and per first-visit arrival channel (the same always-valid test as the headline lift, all-time, alpha split over all 23 possible series; "collecting" and "awaiting_conversions" are early, not results), and each region's versions per context judged against the original with the per-audience evidence rule. OBSERVATIONAL: nothing is served by stage yet; the per-context results are what stage-based serving would have to beat. Defaults to the last 30 days; pass range or from/to. Returns enabled:false when the project does not record stages.` + UNTRUSTED_FIELDS_NOTE,
1303
+ description: `E-commerce projects: where visitors are in buying (new, browsing, carted, customer, lapsed) \u2014 share of People per stage (each session counted once, at its latest recorded stage; hinted = set by a tagged campaign, not observed history), arrival channel x stage with conversion, how visitors moved between stages from one visit to the next, the TESTED holdout lift per first-visit context and per first-visit arrival channel (the same always-valid test as the headline lift, all-time, alpha split over all 23 possible series; "collecting" and "awaiting_conversions" are early, not results), and each region's versions per context judged against the original with the per-audience evidence rule. OBSERVATIONAL: nothing is served by stage yet; the per-context results are what stage-based serving would have to beat. Defaults to the last 30 days; pass range or from/to. Counts and conversion rates are among People (visitors who ran the page, interacted and passed the bot check); the holdout lift test is the one exception: it runs on the optimizer's own population, so its visitor counts will not add up to the People figures beside it. Returns enabled:false when the project does not record stages.` + UNTRUSTED_FIELDS_NOTE,
1283
1304
  inputSchema: __spreadValues({ projectId: projectIdSchema }, rangeInputSchema("30d")),
1284
1305
  outputSchema: {
1285
1306
  enabled: z6.boolean().describe("False when the project does not record funnel stages (settings.stage absent)"),
1286
1307
  mode: z6.string().nullable().describe("'record' (reporting only) \u2014 serving by stage is not available yet"),
1287
- sessions: z6.number().describe("Human sessions with a recorded stage in the window"),
1308
+ sessions: z6.number().describe("People with a recorded stage in the window"),
1288
1309
  hinted: z6.number().describe("Of those, sessions whose stage came from a campaign tag, not observed history"),
1289
1310
  stages: z6.array(z6.object({ stage: z6.string(), sessions: z6.number(), share: z6.number().describe("0-1"), observed: z6.number(), hinted: z6.number() })),
1290
1311
  channels: z6.array(z6.object({ channel: z6.string(), sessions: z6.number(), conversions: z6.number(), conversionRate: z6.number().nullable() })),
@@ -1413,7 +1434,7 @@ function registerGoalTools(server, client) {
1413
1434
  // stages. The title and the first words of the description now say what
1414
1435
  // it is, and point to the real funnel tool.
1415
1436
  title: "Goal conversions (per goal \u2014 not a step funnel)",
1416
- description: "Per-goal conversion summary \u2014 NOT a step funnel (for step-by-step drop-off use list_funnels + get_funnel_report). Gets goal hit counts and unique-session conversion rates for a window (default: last 30 calendar days), plus a per-variant breakdown. NOTE: the per-variant completionRate values are ALL-TIME (bounded only by plan retention), NOT windowed \u2014 a variant completion rate needs the full assignment history as its denominator, so it does not change when you narrow `range`, and retired components keep appearing in it. Only hits/uniqueSessions/conversionRate/revenue respect the window. Per-variant rates are descriptive, not joined to the evidence verdicts \u2014 for whether an arm is ahead, use get_variant_performance." + UNTRUSTED_FIELDS_NOTE,
1437
+ description: "Per-goal conversion summary \u2014 NOT a step funnel (for step-by-step drop-off use list_funnels + get_funnel_report). Gets goal hit counts and unique-session conversion rates for a window (counts and the rate are People's: conversion rate among People, meaning visitors who ran the page, interacted and passed the bot check; conversions by every other visitor are reported beside them as unconfirmedHits/unconfirmedSessions/unconfirmedRevenue, 'from visitors we couldn't confirm as people', never inside the rate) (default: last 30 calendar days), plus a per-variant breakdown. NOTE: the per-variant completionRate values are ALL-TIME (bounded only by plan retention), NOT windowed \u2014 a variant completion rate needs the full assignment history as its denominator, so it does not change when you narrow `range`, and retired components keep appearing in it. Only hits/uniqueSessions/conversionRate/revenue respect the window. Per-variant rates are descriptive, not joined to the evidence verdicts \u2014 for whether an arm is ahead, use get_variant_performance." + UNTRUSTED_FIELDS_NOTE,
1417
1438
  inputSchema: __spreadValues({ projectId: projectIdSchema }, rangeInputSchema("30d")),
1418
1439
  _meta: uiMeta("goal-funnel"),
1419
1440
  outputSchema: {
@@ -1423,7 +1444,10 @@ function registerGoalTools(server, client) {
1423
1444
  goalName: z7.string(),
1424
1445
  hits: z7.number(),
1425
1446
  uniqueSessions: z7.number(),
1426
- conversionRate: z7.number().describe("Unique-session conversion rate (0-1)"),
1447
+ conversionRate: z7.number().describe("Conversion rate among People (0-1): People who converted \xF7 People in the window"),
1448
+ unconfirmedHits: z7.number().nullable().describe("Conversions from visitors we couldn't confirm as people (the API's own remainder; not in hits or the rate); null on an older API"),
1449
+ unconfirmedSessions: z7.number().nullable().describe("Converting sessions from visitors we couldn't confirm as people; null on an older API"),
1450
+ unconfirmedRevenue: z7.number().nullable().describe("Revenue from visitors we couldn't confirm as people (revenue is everyone's total); null when none or on an older API"),
1427
1451
  revenue: z7.number().nullable().describe("Total revenue from valued conversions, in the project currency (null for valueless goals)"),
1428
1452
  avgOrderValue: z7.number().nullable().describe("Average value per valued conversion (null for valueless goals)"),
1429
1453
  revenuePerSession: z7.number().nullable().describe("Revenue divided by all project sessions (null for valueless goals)"),
@@ -1459,15 +1483,18 @@ function registerGoalTools(server, client) {
1459
1483
  window: data.window,
1460
1484
  currency: (_a = data.currency) != null ? _a : "USD",
1461
1485
  goals: data.goals.map((g) => {
1462
- var _a2, _b2, _c;
1486
+ var _a2, _b2, _c, _d, _e, _f;
1463
1487
  return {
1464
1488
  goalName: g.goalName,
1465
1489
  hits: g.hits,
1466
1490
  uniqueSessions: g.uniqueSessions,
1467
1491
  conversionRate: g.pct,
1468
- revenue: (_a2 = g.revenue) != null ? _a2 : null,
1469
- avgOrderValue: (_b2 = g.avgOrderValue) != null ? _b2 : null,
1470
- revenuePerSession: (_c = g.revenuePerSession) != null ? _c : null,
1492
+ unconfirmedHits: (_a2 = g.unconfirmedHits) != null ? _a2 : null,
1493
+ unconfirmedSessions: (_b2 = g.unconfirmedSessions) != null ? _b2 : null,
1494
+ unconfirmedRevenue: (_c = g.unconfirmedRevenue) != null ? _c : null,
1495
+ revenue: (_d = g.revenue) != null ? _d : null,
1496
+ avgOrderValue: (_e = g.avgOrderValue) != null ? _e : null,
1497
+ revenuePerSession: (_f = g.revenuePerSession) != null ? _f : null,
1471
1498
  variants: g.variants.map((v) => {
1472
1499
  var _a3, _b3;
1473
1500
  return {
@@ -1492,9 +1519,13 @@ function registerGoalTools(server, client) {
1492
1519
  const currency = (_b = data.currency) != null ? _b : "USD";
1493
1520
  const win = windowLine(data.window);
1494
1521
  const lines = data.goals.flatMap((g) => {
1495
- var _a2;
1522
+ var _a2, _b2, _c;
1496
1523
  return [
1497
- `${untrusted(g.goalName)}: ${g.hits} hits, ${g.uniqueSessions} unique sessions, ${(g.pct * 100).toFixed(1)}% conversion` + (g.revenue != null ? `, ${g.revenue.toFixed(2)} ${currency} revenue (${((_a2 = g.avgOrderValue) != null ? _a2 : 0).toFixed(2)} avg order)` : ""),
1524
+ `${untrusted(g.goalName)}: ${g.hits} hits, ${g.uniqueSessions} unique sessions, ${(g.pct * 100).toFixed(1)}% conversion rate among People` + (g.revenue != null ? `, ${g.revenue.toFixed(2)} ${currency} revenue (${((_a2 = g.avgOrderValue) != null ? _a2 : 0).toFixed(2)} avg order)` : ""),
1525
+ // The remainder is the API's own (total − People); recomputing it here
1526
+ // would be a third definition that could drift from the dashboard's.
1527
+ ...g.unconfirmedHits || g.unconfirmedSessions ? [` ${(_b2 = g.unconfirmedHits) != null ? _b2 : 0} hits (${(_c = g.unconfirmedSessions) != null ? _c : 0} sessions) from visitors we couldn't confirm as people`] : [],
1528
+ ...g.unconfirmedRevenue != null && g.unconfirmedRevenue !== 0 ? [` ${g.unconfirmedRevenue.toFixed(2)} ${currency} revenue from visitors we couldn't confirm as people`] : [],
1498
1529
  // The per-variant rates come from an all-time query (analytics.ts
1499
1530
  // query 2, deliberately unwindowed so the denominator is the full
1500
1531
  // assignment history). The dashboard labels them; this text had not,
@@ -1722,7 +1753,7 @@ function registerFunnelTools(server, client) {
1722
1753
  "get_funnel_report",
1723
1754
  {
1724
1755
  title: "Funnel drop-off report",
1725
- description: 'Per-step reach and drop-off for one funnel over its conversion window, with per-variant and audience splits per step, final-step revenue, and the holdout ("without optimization") comparison.' + UNTRUSTED_FIELDS_NOTE,
1756
+ description: `Per-step reach and drop-off for one funnel over its conversion window (reach and drop-off are People: visitors who ran the page, interacted and passed the bot check; others who reached a step are in unconfirmedReached, from visitors we couldn't confirm as people, never inside a drop-off), with per-variant and audience splits per step, final-step revenue (the total, every visitor's orders, with unconfirmedRevenue beside it; avg order and per-entering-visitor are People's), and the holdout ("without optimization") comparison.` + UNTRUSTED_FIELDS_NOTE,
1726
1757
  inputSchema: { projectId: projectIdSchema, funnelId: funnelIdSchema },
1727
1758
  outputSchema: {
1728
1759
  funnelId: z8.string(),
@@ -1735,7 +1766,8 @@ function registerFunnelTools(server, client) {
1735
1766
  stepIndex: z8.number(),
1736
1767
  goalId: z8.string(),
1737
1768
  displayName: z8.string(),
1738
- reached: z8.number().describe("Distinct visitors reaching this step in-window"),
1769
+ reached: z8.number().describe("Distinct People reaching this step in-window"),
1770
+ unconfirmedReached: z8.number().nullable().describe("Visitors we couldn't confirm as people who reached this step (the API's own remainder; not in reached or any drop-off); null on an older API"),
1739
1771
  dropOffFromPrevious: z8.number().nullable().describe("1 - reached/previousReached (null on the first step)"),
1740
1772
  neverFired: z8.boolean().describe("True when the step goal has never been recorded anywhere \u2014 likely a typo"),
1741
1773
  variants: z8.array(z8.object({
@@ -1747,20 +1779,21 @@ function registerFunnelTools(server, client) {
1747
1779
  personas: z8.array(z8.object({ label: z8.string(), reached: z8.number() }))
1748
1780
  })
1749
1781
  ),
1750
- revenue: z8.number().nullable().describe("Final-step revenue in the project currency (null when no valued conversions)"),
1751
- avgOrderValue: z8.number().nullable(),
1752
- revenuePerEnteringVisitor: z8.number().nullable(),
1782
+ revenue: z8.number().nullable().describe("Final-step revenue in the project currency: the total, every visitor's orders plus orders with no visit (null when no valued conversions)"),
1783
+ unconfirmedRevenue: z8.number().nullable().describe("The part of revenue from visitors we couldn't confirm as people (the API's own remainder); null when none or on an older API"),
1784
+ avgOrderValue: z8.number().nullable().describe("People's revenue per People order"),
1785
+ revenuePerEnteringVisitor: z8.number().nullable().describe("People's revenue per People entering the funnel"),
1753
1786
  holdoutCompletion: z8.object({ entered: z8.number(), reached: z8.number() }).nullable().describe('Holdout visitors entering vs finishing \u2014 the "without optimization" line')
1754
1787
  },
1755
1788
  annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false }
1756
1789
  },
1757
1790
  withApiErrorGuidance(async ({ projectId, funnelId }) => {
1758
- var _a;
1791
+ var _a, _b;
1759
1792
  const data = await client.get(`/projects/${encodeURIComponent(projectId)}/funnels/${encodeURIComponent(funnelId)}/report`);
1760
1793
  const lines = [`${untrusted(data.displayName)} \u2014 last ${data.windowDays} days`];
1761
1794
  for (const s of data.steps) {
1762
1795
  lines.push(
1763
- `${s.stepIndex + 1}. ${untrusted(s.displayName)}: ${s.reached} reached` + stepChangeText(s.dropOffFromPrevious) + (s.neverFired ? " [never recorded \u2014 check the goal name]" : "")
1796
+ `${s.stepIndex + 1}. ${untrusted(s.displayName)}: ${s.reached} People reached` + (s.unconfirmedReached ? ` (${s.unconfirmedReached} more from visitors we couldn't confirm as people)` : "") + stepChangeText(s.dropOffFromPrevious) + (s.neverFired ? " [never recorded \u2014 check the goal name]" : "")
1764
1797
  );
1765
1798
  for (const v of s.variants) {
1766
1799
  lines.push(` ${untrusted(v.componentId)}/${untrusted(v.variantId)}: ${v.reached}/${v.assigned} assigned sessions reached this step`);
@@ -1768,7 +1801,9 @@ function registerFunnelTools(server, client) {
1768
1801
  }
1769
1802
  if (data.revenue != null) {
1770
1803
  lines.push(
1771
- `Revenue: ${data.revenue.toFixed(2)} ${data.currency}` + (data.avgOrderValue != null ? ` (${data.avgOrderValue.toFixed(2)} ${data.currency} avg order)` : "") + (data.revenuePerEnteringVisitor != null ? `, ${data.revenuePerEnteringVisitor.toFixed(2)} ${data.currency} per entering visitor` : "")
1804
+ `Revenue: ${data.revenue.toFixed(2)} ${data.currency}` + // The API's remainder, verbatim: no arithmetic here, or this line
1805
+ // would print a figure the dashboard does not.
1806
+ (data.unconfirmedRevenue != null && data.unconfirmedRevenue !== 0 ? ` (${data.unconfirmedRevenue.toFixed(2)} ${data.currency} from visitors we couldn't confirm as people)` : "") + (data.avgOrderValue != null ? ` (${data.avgOrderValue.toFixed(2)} ${data.currency} avg order)` : "") + (data.revenuePerEnteringVisitor != null ? `, ${data.revenuePerEnteringVisitor.toFixed(2)} ${data.currency} per entering visitor` : "")
1772
1807
  );
1773
1808
  }
1774
1809
  if (data.holdoutCompletion && data.holdoutCompletion.entered > 0) {
@@ -1777,7 +1812,14 @@ function registerFunnelTools(server, client) {
1777
1812
  return {
1778
1813
  content: [{ type: "text", text: lines.join("\n") }],
1779
1814
  // Tolerate an API deployed before strict funnels existed.
1780
- structuredContent: __spreadProps(__spreadValues({}, data), { strictOrder: (_a = data.strictOrder) != null ? _a : true })
1815
+ structuredContent: __spreadProps(__spreadValues({}, data), {
1816
+ strictOrder: (_a = data.strictOrder) != null ? _a : true,
1817
+ unconfirmedRevenue: (_b = data.unconfirmedRevenue) != null ? _b : null,
1818
+ steps: data.steps.map((s) => {
1819
+ var _a2;
1820
+ return __spreadProps(__spreadValues({}, s), { unconfirmedReached: (_a2 = s.unconfirmedReached) != null ? _a2 : null });
1821
+ })
1822
+ })
1781
1823
  };
1782
1824
  })
1783
1825
  );
@@ -2586,11 +2628,12 @@ project has its own persona vocabulary (dashboard -> Settings -> Personas), and
2586
2628
  EMPTY: every visitor is 'unknown' until a persona exists, and the optimizer learns across all
2587
2629
  traffic pooled in the meantime. Personas are DISCOVERED from behavior \u2014 or, far faster,
2588
2630
  DECLARED by the app when it already knows the visitor's role: init({ persona: 'admin' }) /
2589
- <AdaptiveProvider persona=...> / window.sentient.persona. Declared beats inferred and serves
2631
+ <AdaptiveProvider persona=...> / window.sentient.persona. Declared beats discovered and serves
2590
2632
  at full confidence; unrecognized values are ignored server-side and surfaced in the dashboard
2591
2633
  so the operator can add them. Keep persona a low-cardinality role slug \u2014 never a user id.
2592
- Decisions are locked per session: a first visit sees the original, the return visit adapts. Integrate one rung at a
2593
- time.
2634
+ Decisions are locked per visit: a first visit usually sees the original and the return visit adapts \u2014 the
2635
+ exception is a visitor arriving on a campaign link, whose first page can already show the campaign's version
2636
+ (see Campaigns). Integrate one rung at a time.
2594
2637
 
2595
2638
  ## Setup (60 seconds, no account)
2596
2639
 
@@ -2614,10 +2657,13 @@ time.
2614
2657
 
2615
2658
  ## Rung 1 \u2014 Style (CSS only)
2616
2659
 
2617
- Persona attributes on <html> (zero declaration; the attribute carries the project's own
2618
- vocabulary keys \u2014 declared or inferred):
2660
+ Persona attributes on <html> (zero declaration). The attribute carries the key the visit is
2661
+ SERVED as: a declared key as-is ('admin'), a discovered group with its d- prefix
2662
+ ('d-content'), a campaign ('c-spring') or retargeting group ('r-spring'), or 'unknown'. CSS for a discovered group must target the d- key \u2014 a rule
2663
+ written against a bare 'content' stops matching once the group carries its prefix:
2619
2664
 
2620
2665
  html[data-sentient-persona='admin'] .admin-tools { display: block; }
2666
+ html[data-sentient-persona='d-content'] .reading-list { display: block; }
2621
2667
  html[data-sentient-confidence='low'] .admin-tools { display: none; }
2622
2668
 
2623
2669
  Learned style tokens (element-scoped, SSR-safe):
@@ -2707,6 +2753,44 @@ Consent: add consentFrom (same presets as above) to window.sentient when the sit
2707
2753
  banner, or consent: false plus SentientSnippet.grantConsent() on accept. On Shopify, snippet 0.32
2708
2754
  and later follows Shopify's Customer Privacy API automatically.
2709
2755
 
2756
+ ## Campaigns \u2014 ad and email links
2757
+
2758
+ A campaign is named in the dashboard (Settings -> Campaigns -> Prepare a campaign): its name, the
2759
+ utm_campaign its links carry (optionally utm_source / utm_medium, or the ad platform), what the ad
2760
+ promises, any discount code, and its landing page. Visitors arriving on its links are served as the
2761
+ campaign \u2014 persona 'c-spring' for a campaign named "Spring" \u2014 with versions written for it, from the
2762
+ FIRST page of the visit; a visitor who comes back without a tagged link within 30 days is still the
2763
+ campaign's until it ends. A visitor the site already knows (a declared persona or a discovered group)
2764
+ keeps that audience; the click still counts on the campaign card, as "already known". After a
2765
+ campaign, its visitors who did not convert can be moved into a retargeting group ('r-spring') with
2766
+ its own versions and its own result.
2767
+
2768
+ What the integration must do is get the landing URL to the first decision:
2769
+
2770
+ - Tag every ad and email link: ?utm_campaign=spring&utm_source=newsletter&utm_medium=email.
2771
+ utm_campaign is required \u2014 it is what a campaign matches on; an untagged link is served like any
2772
+ other visit.
2773
+ - Snippet, Shopify theme embed, AdaptiveProvider, and AdaptiveRoot in app/layout.tsx with no server
2774
+ preload: nothing to add. The browser's first decision carries the page URL.
2775
+ - Next.js server preload (ANY of registrySlotIds, registrySlots, components, sections or slots on
2776
+ AdaptiveRoot): the server decides before the browser runs, and a Server Component cannot read
2777
+ the request URL. Next.js never passes searchParams to a layout, so preload in app/layout.tsx decides a campaign visitor's
2778
+ first page as everyone else's (the campaign starts on their next visit, and that first click is not
2779
+ on the campaign card). Where a page renders AdaptiveRoot itself, pass the page's own:
2780
+
2781
+ export default async function Page({ searchParams }: { searchParams: Promise<Record<string, string | string[] | undefined>> }) {
2782
+ return (
2783
+ <AdaptiveRoot apiKey={process.env.NEXT_PUBLIC_SENTIENT_API_KEY ?? ''}
2784
+ searchParams={await searchParams} pathname="/spring">
2785
+ \u2026
2786
+ </AdaptiveRoot>
2787
+ );
2788
+ }
2789
+
2790
+ - Verify with a tagged link in a fresh browser profile: once the page has decided, <html
2791
+ data-sentient-persona> reads the campaign's key ('c-spring'). The React SDK always sets it; the
2792
+ snippet only with personaAttributes: true in window.sentient.
2793
+
2710
2794
  ## Capture AI assistants (server-side, any framework)
2711
2795
 
2712
2796
  AI assistants that fetch pages for their users (ChatGPT-User, Claude-User, Perplexity-User)
@@ -2770,7 +2854,7 @@ function registerAgentTrafficTools(server, client) {
2770
2854
  "get_agent_traffic",
2771
2855
  {
2772
2856
  title: "Agent traffic",
2773
- description: "Which AI agents and crawlers are reading this site: totals by type (passive crawlers, agentic browsers, agent API calls), engine breakdown, and the paths they fetch most. Defaults to the last 30 calendar days; pass range (7d/30d/90d/all) or from/to (YYYY-MM-DD) like every other windowed tool (agent logs are retained 30 days on Free/Starter, 90 on Growth+). Agent traffic is tracked separately and never counted in conversion rate." + UNTRUSTED_FIELDS_NOTE,
2857
+ description: "Which AI agents and crawlers are reading this site: totals by type (passive crawlers, automated browser sessions, agent API calls), engine breakdown, and the paths they fetch most. Defaults to the last 30 calendar days; pass range (7d/30d/90d/all) or from/to (YYYY-MM-DD) like every other windowed tool (agent logs are retained 30 days on Free/Starter, 90 on Growth+). Automated traffic is reported separately: conversion rate is among People only (see get_traffic_breakdown)." + UNTRUSTED_FIELDS_NOTE,
2774
2858
  // This tool alone took ad-hoc ISO from/to with no range token and echoed
2775
2859
  // no window, while every other windowed tool used rangeInputSchema — so
2776
2860
  // agents passed range:'7d' here, it was silently dropped, and 30 days of
@@ -2813,7 +2897,7 @@ function registerAgentTrafficTools(server, client) {
2813
2897
  }
2814
2898
  const lines = [
2815
2899
  ...win ? [win] : [],
2816
- `Agent traffic: ${s.totals.crawler} crawler fetches, ${s.totals.api} agent API calls, ${s.totals.browser} agentic browser sessions.`,
2900
+ `Agent traffic: ${s.totals.crawler} crawler fetches, ${s.totals.api} agent API calls, ${s.totals.browser} automated browser sessions.`,
2817
2901
  `Live user fetches: ${s.intents.user} \xB7 Search index: ${s.intents.search} \xB7 Training: ${s.intents.training}${s.intents.other ? ` \xB7 Other: ${s.intents.other}` : ""} (a "live user fetch" = an AI assistant reading your site to answer a real person).`,
2818
2902
  "",
2819
2903
  "Engines:",
@@ -2892,33 +2976,91 @@ function registerAgentTrafficTools(server, client) {
2892
2976
  );
2893
2977
  }
2894
2978
 
2895
- // src/tools/cells.ts
2979
+ // src/tools/traffic.ts
2896
2980
  import { z as z16 } from "zod/v3";
2897
- var personaOutput = z16.object({
2898
- key: z16.string(),
2899
- displayName: z16.string(),
2900
- description: z16.string().nullable(),
2901
- share: z16.number().describe("Fraction of 30-day decided sessions")
2981
+ var NOTICE_TEXT = {
2982
+ no_interaction_evidence: "Your integration isn't reporting clicks or scrolls, so we can't confirm anyone as a person yet.",
2983
+ server_only: "We receive these visits from your server but never see a browser, so we can't confirm them as people or bots."
2984
+ };
2985
+ var trafficRangeSchema = z16.enum(["24h", "7d", "30d", "90d", "all"]).optional().describe("'24h' is the rolling last 24 hours; 7d/30d/90d/all are calendar windows in the project's reporting timezone (default 30d)");
2986
+ function registerTrafficTools(server, client) {
2987
+ server.registerTool(
2988
+ "get_traffic_breakdown",
2989
+ {
2990
+ title: "Traffic breakdown",
2991
+ description: "Where a project\u2019s traffic came from. Every visitor (one per browser or device) last seen in the window falls into exactly one of seven groups that add up to the total: People (ran the page, interacted (click, scroll, mouse, touch or key) and passed the bot check), Loaded but didn\u2019t interact, Not verified \u2014 no browser activity, Being analysed (usually settled within 3 hours), AI assistants, Search & AI crawlers and Other automated. Each group carries plain-English evidence counts; named AI assistants and crawlers, conversions (total and from People) and notices are included. Conversion rates elsewhere are conversion rate among People. Reporting only \u2014 it does not change what the optimizer learns from." + UNTRUSTED_FIELDS_NOTE,
2992
+ inputSchema: { projectId: projectIdSchema, range: trafficRangeSchema },
2993
+ outputSchema: {
2994
+ window: z16.object({ from: z16.string(), to: z16.string() }),
2995
+ total: z16.number().describe("Visitors in the window; the groups add up to this"),
2996
+ groups: z16.array(
2997
+ z16.object({
2998
+ group: z16.string().describe("people | loaded_no_interaction | not_verified | being_analysed | ai_assistant | crawler | other_automated"),
2999
+ label: z16.string(),
3000
+ count: z16.number(),
3001
+ evidence: z16.array(z16.object({ code: z16.string(), label: z16.string(), count: z16.number() }))
3002
+ })
3003
+ ),
3004
+ agents: z16.array(z16.object({ name: z16.string(), group: z16.string(), count: z16.number() })),
3005
+ conversions: z16.object({
3006
+ total: z16.number().describe("Conversions from every visitor"),
3007
+ fromPeople: z16.number().describe("Conversions from People; the rest are from visitors we couldn\u2019t confirm as people")
3008
+ }),
3009
+ notices: z16.array(z16.string()).describe("no_interaction_evidence | server_only")
3010
+ },
3011
+ annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false }
3012
+ },
3013
+ withApiErrorGuidance(async ({ projectId, range }) => {
3014
+ var _a, _b, _c;
3015
+ const id = encodeURIComponent(projectId);
3016
+ const t = await client.get(`/projects/${id}/traffic${range ? `?range=${encodeURIComponent(range)}` : ""}`);
3017
+ const beingAnalysed = (_b = (_a = t.groups.find((g) => g.group === "being_analysed")) == null ? void 0 : _a.count) != null ? _b : 0;
3018
+ const lines = [
3019
+ `Traffic from ${t.window.from.slice(0, 10)} to ${t.window.to.slice(0, 10)}: ${t.total} visitors.`,
3020
+ ...t.groups.map((g) => `- ${g.label}: ${g.count}`)
3021
+ ];
3022
+ if (beingAnalysed > 0) {
3023
+ lines.push("", `${beingAnalysed} visitors are being analysed \u2014 usually settled within 3 hours`);
3024
+ }
3025
+ if (t.agents.length > 0) {
3026
+ lines.push("", "Named agents:", ...t.agents.map((a) => `- ${untrusted(a.name)}: ${a.count}`));
3027
+ }
3028
+ lines.push("", `${t.conversions.total} conversions in total, ${t.conversions.fromPeople} from People.`);
3029
+ for (const n of t.notices) lines.push((_c = NOTICE_TEXT[n]) != null ? _c : n);
3030
+ return { content: [{ type: "text", text: lines.join("\n") }], structuredContent: t };
3031
+ }, {
3032
+ range_too_large: "That window has too much traffic to break down in one go. Ask for a shorter range (24h, 7d or 30d) and try again."
3033
+ })
3034
+ );
3035
+ }
3036
+
3037
+ // src/tools/cells.ts
3038
+ import { z as z17 } from "zod/v3";
3039
+ var personaOutput = z17.object({
3040
+ key: z17.string(),
3041
+ displayName: z17.string(),
3042
+ description: z17.string().nullable(),
3043
+ share: z17.number().describe("Fraction of 30-day decided sessions")
2902
3044
  });
2903
- var cellOutput = z16.object({
2904
- slotId: z16.string(),
2905
- persona: z16.string(),
2906
- status: z16.string().describe("pending | generating | review (waiting for approval) | live | error | rejected"),
2907
- requestedBy: z16.string(),
2908
- armId: z16.string().nullable(),
2909
- rationale: z16.string().nullable(),
2910
- error: z16.string().nullable(),
2911
- updatedAt: z16.string(),
3045
+ var cellOutput = z17.object({
3046
+ slotId: z17.string(),
3047
+ persona: z17.string(),
3048
+ status: z17.string().describe("pending | generating | review (waiting for approval) | live | error | rejected"),
3049
+ requestedBy: z17.string(),
3050
+ armId: z17.string().nullable(),
3051
+ rationale: z17.string().nullable(),
3052
+ error: z17.string().nullable(),
3053
+ updatedAt: z17.string(),
2912
3054
  // These ride the API response too; omitting them from the schema made zod
2913
3055
  // STRIP them, so agents could never see refinement or retry state.
2914
- refinedFrom: z16.string().nullable().optional().describe("Incumbent arm this cell is improving on \u2014 a pending cell with this set still SERVES the incumbent"),
2915
- notBefore: z16.string().nullable().optional().describe("ISO time the queue will next consider this cell (retry backoff / daily-cap deferral); null when due now"),
2916
- attempts: z16.number().optional().describe("Generation attempts so far"),
2917
- performance: z16.object({
2918
- shown: z16.number(),
2919
- conversions: z16.number(),
2920
- deltaPct: z16.number().nullable().describe("Signed % vs the original conversion rate \u2014 a point estimate; only meaningful beside a winning/losing tier"),
2921
- tier: z16.string().describe(
3056
+ refinedFrom: z17.string().nullable().optional().describe("Incumbent arm this cell is improving on \u2014 a pending cell with this set still SERVES the incumbent"),
3057
+ notBefore: z17.string().nullable().optional().describe("ISO time the queue will next consider this cell (retry backoff / daily-cap deferral); null when due now"),
3058
+ attempts: z17.number().optional().describe("Generation attempts so far"),
3059
+ performance: z17.object({
3060
+ shown: z17.number(),
3061
+ conversions: z17.number(),
3062
+ deltaPct: z17.number().nullable().describe("Signed % vs the original conversion rate \u2014 a point estimate; only meaningful beside a winning/losing tier"),
3063
+ tier: z17.string().describe(
2922
3064
  'early | no_baseline (under 100 views) | winning | losing (posterior separated from the original, corrected across the slot column) | flat (NOT separated yet \u2014 not "equal")'
2923
3065
  )
2924
3066
  }).optional().describe("Present on live cells (and, mid-refinement, the incumbent arm): the at-a-glance readout")
@@ -2931,28 +3073,28 @@ function registerCellTools(server, client) {
2931
3073
  description: 'The "Who sees what" matrix: which visitor types (personas) have an AI-generated version live in each personalizable region (slot), with per-persona traffic share and the first-miss auto-fill setting. A cell with no row means that visitor type sees the original.' + UNTRUSTED_FIELDS_NOTE,
2932
3074
  inputSchema: { projectId: projectIdSchema },
2933
3075
  outputSchema: {
2934
- slots: z16.array(
2935
- z16.object({
2936
- slotId: z16.string(),
2937
- displayName: z16.string(),
2938
- supportsForms: z16.boolean(),
3076
+ slots: z17.array(
3077
+ z17.object({
3078
+ slotId: z17.string(),
3079
+ displayName: z17.string(),
3080
+ supportsForms: z17.boolean(),
2939
3081
  // API sends this; without it zod stripped the draft-vs-live signal.
2940
- live: z16.boolean().optional().describe("False for an sdk-registered draft column \u2014 nothing serves until its first generation publishes it")
3082
+ live: z17.boolean().optional().describe("False for an sdk-registered draft column \u2014 nothing serves until its first generation publishes it")
2941
3083
  })
2942
3084
  ),
2943
- personas: z16.array(personaOutput),
2944
- cells: z16.array(cellOutput),
2945
- autoFill: z16.boolean(),
3085
+ personas: z17.array(personaOutput),
3086
+ cells: z17.array(cellOutput),
3087
+ autoFill: z17.boolean(),
2946
3088
  // The API has always sent this; without it in the schema zod stripped
2947
3089
  // it, and generate_cell had no way to know a version would wait for a
2948
3090
  // human instead of publishing.
2949
- reviewMode: z16.boolean().optional().describe("True when generated versions wait for approval (review_cell) instead of publishing automatically"),
3091
+ reviewMode: z17.boolean().optional().describe("True when generated versions wait for approval (review_cell) instead of publishing automatically"),
2950
3092
  // Nullable: a project with no persona set at all reports null, not a
2951
3093
  // string. That is the NORMAL state since the default vocabulary was
2952
3094
  // emptied, so a non-nullable schema failed output validation on most
2953
3095
  // projects and the tool returned nothing but a zod error.
2954
- personaSource: z16.string().nullable().describe('Active persona-set source: default | declared | discovered, or null when the project has no persona set (one "everyone" row)'),
2955
- undecidedShare: z16.number()
3096
+ personaSource: z17.string().nullable().describe('Active persona-set source: default | declared | discovered, or null when the project has no persona set (one "everyone" row)'),
3097
+ undecidedShare: z17.number()
2956
3098
  },
2957
3099
  annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false }
2958
3100
  },
@@ -2992,26 +3134,26 @@ function registerCellTools(server, client) {
2992
3134
  description: "One cell's full story: the generated option a visitor type sees in a slot, why it was written (the stored generation rationale), and how it is performing vs the original (deterministic plain-language verdict)." + UNTRUSTED_FIELDS_NOTE,
2993
3135
  inputSchema: {
2994
3136
  projectId: projectIdSchema,
2995
- slotId: z16.string().min(1).max(128).describe("The slot id (a matrix column)"),
2996
- persona: z16.string().min(1).max(64).describe("The persona key (a matrix row)")
3137
+ slotId: z17.string().min(1).max(128).describe("The slot id (a matrix column)"),
3138
+ persona: z17.string().min(1).max(64).describe("The persona key (a matrix row)")
2997
3139
  },
2998
3140
  outputSchema: {
2999
3141
  cell: cellOutput.nullable(),
3000
- arm: z16.object({
3001
- id: z16.string(),
3002
- displayName: z16.string().nullable(),
3003
- content: z16.string().nullable(),
3004
- blocks: z16.unknown().nullable()
3142
+ arm: z17.object({
3143
+ id: z17.string(),
3144
+ displayName: z17.string().nullable(),
3145
+ content: z17.string().nullable(),
3146
+ blocks: z17.unknown().nullable()
3005
3147
  }).nullable(),
3006
- performance: z16.object({
3007
- shown: z16.number(),
3008
- conversions: z16.number(),
3009
- conversionRate: z16.number(),
3010
- baselineShown: z16.number(),
3011
- baselineConversions: z16.number(),
3012
- baselineConversionRate: z16.number()
3148
+ performance: z17.object({
3149
+ shown: z17.number(),
3150
+ conversions: z17.number(),
3151
+ conversionRate: z17.number(),
3152
+ baselineShown: z17.number(),
3153
+ baselineConversions: z17.number(),
3154
+ baselineConversionRate: z17.number()
3013
3155
  }).nullable(),
3014
- verdict: z16.string()
3156
+ verdict: z17.string()
3015
3157
  },
3016
3158
  annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false }
3017
3159
  },
@@ -3056,14 +3198,14 @@ function registerCellTools(server, client) {
3056
3198
  description: "Queue AI generation of a version for one (persona, slot) cell; the worker writes it asynchronously, brand-locked. If the project has review mode on, the finished version WAITS for approval (list_cell_reviews / review_cell) and serves nobody until approved; otherwise it publishes automatically as a named option the optimizer explores. Also regenerates or retries a failed cell. Generation volume is capped per plan (Free included). Check get_cell_matrix for progress. Confirm with the user before calling \u2014 each generation is a model call against the plan quota.",
3057
3199
  inputSchema: {
3058
3200
  projectId: projectIdSchema,
3059
- slotId: z16.string().min(1).max(128).describe("The slot id (a matrix column)"),
3060
- persona: z16.string().min(1).max(64).describe("The persona key (a matrix row)")
3201
+ slotId: z17.string().min(1).max(128).describe("The slot id (a matrix column)"),
3202
+ persona: z17.string().min(1).max(64).describe("The persona key (a matrix row)")
3061
3203
  },
3062
3204
  outputSchema: {
3063
- slotId: z16.string(),
3064
- persona: z16.string(),
3065
- status: z16.literal("pending").describe("Queued \u2014 check get_cell_matrix for progress"),
3066
- reviewMode: z16.boolean().nullable().describe("True: the version will wait for review_cell approval. False: it publishes automatically. Null: could not be read.")
3205
+ slotId: z17.string(),
3206
+ persona: z17.string(),
3207
+ status: z17.literal("pending").describe("Queued \u2014 check get_cell_matrix for progress"),
3208
+ reviewMode: z17.boolean().nullable().describe("True: the version will wait for review_cell approval. False: it publishes automatically. Null: could not be read.")
3067
3209
  },
3068
3210
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false }
3069
3211
  },
@@ -3091,19 +3233,19 @@ function registerCellTools(server, client) {
3091
3233
  description: "Generated versions waiting for approval (review mode): which slot and visitor type, the proposed text or layout, and why it was written. Approve or reject each with review_cell after the user decides." + UNTRUSTED_FIELDS_NOTE,
3092
3234
  inputSchema: { projectId: projectIdSchema },
3093
3235
  outputSchema: {
3094
- reviews: z16.array(
3095
- z16.object({
3096
- slotId: z16.string(),
3097
- slotName: z16.string(),
3098
- persona: z16.string(),
3099
- personaDisplay: z16.string(),
3100
- content: z16.string().nullable().describe("Proposed text, when the version is text (null for a block/layout version)"),
3101
- rationale: z16.string().nullable(),
3102
- refinedFrom: z16.string().nullable().describe("Live version this one would replace; that version keeps serving until approval"),
3103
- updatedAt: z16.string()
3236
+ reviews: z17.array(
3237
+ z17.object({
3238
+ slotId: z17.string(),
3239
+ slotName: z17.string(),
3240
+ persona: z17.string(),
3241
+ personaDisplay: z17.string(),
3242
+ content: z17.string().nullable().describe("Proposed text, when the version is text (null for a block/layout version)"),
3243
+ rationale: z17.string().nullable(),
3244
+ refinedFrom: z17.string().nullable().describe("Live version this one would replace; that version keeps serving until approval"),
3245
+ updatedAt: z17.string()
3104
3246
  })
3105
3247
  ),
3106
- total: z16.number().int().describe("How many versions are waiting in all. The list holds at most the oldest 200; decide those to see the rest.")
3248
+ total: z17.number().int().describe("How many versions are waiting in all. The list holds at most the oldest 200; decide those to see the rest.")
3107
3249
  },
3108
3250
  annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false }
3109
3251
  },
@@ -3153,17 +3295,17 @@ function registerCellTools(server, client) {
3153
3295
  description: "Approve or reject ONE generated version waiting for review (see list_cell_reviews). 'approve' publishes it to live visitors of that type; 'reject' discards it (a rejected refinement leaves the current live version in place). This is the human decision review mode exists for \u2014 only call it with the user's explicit go-ahead.",
3154
3296
  inputSchema: {
3155
3297
  projectId: projectIdSchema,
3156
- slotId: z16.string().min(1).max(128).describe("The slot id of the version under review"),
3157
- persona: z16.string().min(1).max(64).describe("The persona key of the version under review"),
3158
- action: z16.enum(["approve", "reject"]),
3159
- feedback: z16.string().max(2e3).optional().describe("Optional reviewer note, stored with a rejection")
3298
+ slotId: z17.string().min(1).max(128).describe("The slot id of the version under review"),
3299
+ persona: z17.string().min(1).max(64).describe("The persona key of the version under review"),
3300
+ action: z17.enum(["approve", "reject"]),
3301
+ feedback: z17.string().max(2e3).optional().describe("Optional reviewer note, stored with a rejection")
3160
3302
  },
3161
3303
  outputSchema: {
3162
- slotId: z16.string(),
3163
- persona: z16.string(),
3164
- action: z16.enum(["approve", "reject"]),
3165
- status: z16.string().describe("live (approved, or a rejected refinement whose incumbent keeps serving) | rejected"),
3166
- armId: z16.string().nullable().describe("The published option id, on approval")
3304
+ slotId: z17.string(),
3305
+ persona: z17.string(),
3306
+ action: z17.enum(["approve", "reject"]),
3307
+ status: z17.string().describe("live (approved, or a rejected refinement whose incumbent keeps serving) | rejected"),
3308
+ armId: z17.string().nullable().describe("The published option id, on approval")
3167
3309
  },
3168
3310
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false }
3169
3311
  },
@@ -3190,7 +3332,7 @@ function registerCellTools(server, client) {
3190
3332
  }
3191
3333
 
3192
3334
  // src/server.ts
3193
- var PKG_VERSION = true ? "0.24.2" : "0.0.0-dev";
3335
+ var PKG_VERSION = true ? "0.25.1" : "0.0.0-dev";
3194
3336
  function createMcpServer(client) {
3195
3337
  const server = new McpServer(
3196
3338
  {
@@ -3226,6 +3368,7 @@ function createMcpServer(client) {
3226
3368
  registerVariantWriteTools(server, client);
3227
3369
  registerIntegrationGuideTools(server);
3228
3370
  registerAgentTrafficTools(server, client);
3371
+ registerTrafficTools(server, client);
3229
3372
  registerCellTools(server, client);
3230
3373
  return server;
3231
3374
  }