@sealmetrics/mcp 1.2.0 → 1.3.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.
Files changed (41) hide show
  1. package/README.md +30 -6
  2. package/dist/client.d.ts +28 -5
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +92 -3
  5. package/dist/client.js.map +1 -1
  6. package/dist/embedded.d.ts +29 -0
  7. package/dist/embedded.d.ts.map +1 -0
  8. package/dist/embedded.js +37 -0
  9. package/dist/embedded.js.map +1 -0
  10. package/dist/index.js +3811 -123
  11. package/dist/index.js.map +1 -1
  12. package/dist/sealmetrics.mcpb +0 -0
  13. package/dist/server.d.ts +38 -0
  14. package/dist/server.d.ts.map +1 -0
  15. package/dist/server.js +132 -0
  16. package/dist/server.js.map +1 -0
  17. package/dist/tools/channels.js +4 -4
  18. package/dist/tools/channels.js.map +1 -1
  19. package/dist/tools/conversions.d.ts +3 -0
  20. package/dist/tools/conversions.d.ts.map +1 -1
  21. package/dist/tools/conversions.js +251 -2
  22. package/dist/tools/conversions.js.map +1 -1
  23. package/dist/tools/index.d.ts.map +1 -1
  24. package/dist/tools/index.js +5 -1
  25. package/dist/tools/index.js.map +1 -1
  26. package/dist/tools/pages.d.ts.map +1 -1
  27. package/dist/tools/pages.js +103 -3
  28. package/dist/tools/pages.js.map +1 -1
  29. package/dist/tools/setup.d.ts +49 -0
  30. package/dist/tools/setup.d.ts.map +1 -0
  31. package/dist/tools/setup.js +347 -0
  32. package/dist/tools/setup.js.map +1 -0
  33. package/dist/tools/shared.d.ts +0 -12
  34. package/dist/tools/shared.d.ts.map +1 -1
  35. package/dist/tools/shared.js +0 -99
  36. package/dist/tools/shared.js.map +1 -1
  37. package/package.json +12 -3
  38. package/dist/tools/manage.d.ts +0 -3
  39. package/dist/tools/manage.d.ts.map +0 -1
  40. package/dist/tools/manage.js +0 -55
  41. package/dist/tools/manage.js.map +0 -1
@@ -1,7 +1,100 @@
1
1
  import { PERIOD_SCHEMA, COMPARE_SCHEMA, LIMIT_SCHEMA, SORT_ORDER_SCHEMA, PAGE_SCHEMA, resolveSiteId, } from "./shared.js";
2
+ // Common multi-value filter and `include` schema for /stats/pages and /stats/landing-pages.
3
+ // Mirrors the API parameters declared in routers/stats.py (PRD 03).
4
+ const MULTI_FILTER_SCHEMA = {
5
+ country: {
6
+ type: "array",
7
+ items: { type: "string", minLength: 1 },
8
+ minItems: 1,
9
+ description: "Filter by country code(s) (e.g. ['ES', 'US']).",
10
+ },
11
+ device_type: {
12
+ type: "array",
13
+ items: { type: "string", minLength: 1 },
14
+ minItems: 1,
15
+ description: "Filter by device type(s) (e.g. ['mobile', 'desktop']).",
16
+ },
17
+ browser: {
18
+ type: "array",
19
+ items: { type: "string", minLength: 1 },
20
+ minItems: 1,
21
+ description: "Filter by browser name(s).",
22
+ },
23
+ os: {
24
+ type: "array",
25
+ items: { type: "string", minLength: 1 },
26
+ minItems: 1,
27
+ description: "Filter by operating system name(s).",
28
+ },
29
+ channel_group: {
30
+ type: "array",
31
+ items: { type: "string", minLength: 1 },
32
+ minItems: 1,
33
+ description: "Filter by channel group(s).",
34
+ },
35
+ utm_source: {
36
+ type: "array",
37
+ items: { type: "string", minLength: 1 },
38
+ minItems: 1,
39
+ description: "Filter by UTM source(s).",
40
+ },
41
+ utm_medium: {
42
+ type: "array",
43
+ items: { type: "string", minLength: 1 },
44
+ minItems: 1,
45
+ description: "Filter by UTM medium(s).",
46
+ },
47
+ utm_campaign: {
48
+ type: "array",
49
+ items: { type: "string", minLength: 1 },
50
+ minItems: 1,
51
+ description: "Filter by UTM campaign(s).",
52
+ },
53
+ utm_term: {
54
+ type: "array",
55
+ items: { type: "string", minLength: 1 },
56
+ minItems: 1,
57
+ description: "Filter by UTM term(s).",
58
+ },
59
+ // `minItems` intentionally absent — empty array ≡ no grouping (PRD 08
60
+ // VAL-006 exception). Filter arrays use minItems: 1 because an empty
61
+ // filter list would silently match nothing; `include` instead is a no-op
62
+ // when empty, matching the API behavior.
63
+ include: {
64
+ type: "array",
65
+ items: { type: "string", enum: ["device", "browser", "os", "channel_group"] },
66
+ description: "Add dimension(s) to GROUP BY and response. Allowed values: device, browser, os, channel_group. Empty/absent means no extra grouping.",
67
+ },
68
+ };
69
+ const MULTI_FILTER_KEYS = [
70
+ "country",
71
+ "device_type",
72
+ "browser",
73
+ "os",
74
+ "channel_group",
75
+ "utm_source",
76
+ "utm_medium",
77
+ "utm_campaign",
78
+ "utm_term",
79
+ "include",
80
+ ];
81
+ function pickMultiFilters(args) {
82
+ const out = {};
83
+ for (const key of MULTI_FILTER_KEYS) {
84
+ const value = args[key];
85
+ if (Array.isArray(value) && value.length > 0) {
86
+ out[key] = value;
87
+ }
88
+ }
89
+ return out;
90
+ }
2
91
  export const getPagesTool = {
3
92
  name: "get_pages",
4
- description: "Get metrics per page URL path: pageviews, entrances, conversions. Useful for finding most popular pages and content performance.",
93
+ description: "Get metrics per page URL path: pageviews and entrances. Useful for finding most popular pages and content performance. " +
94
+ "For bounce rate by entry page, use get_landing_pages instead — bounce is not interpretable at page granularity. " +
95
+ "Supports multi-value filters (country, device_type, browser, os, channel_group, UTMs) as arrays of strings — e.g. " +
96
+ "device_type=['mobile'] to filter to mobile only. Pass include=['device'] to also break down metrics by device. " +
97
+ "The two are orthogonal — combine them as needed.",
5
98
  inputSchema: {
6
99
  type: "object",
7
100
  properties: {
@@ -15,7 +108,7 @@ export const getPagesTool = {
15
108
  sort_by: {
16
109
  type: "string",
17
110
  description: "Field to sort by.",
18
- enum: ["page_views", "entrances", "engaged_entrances", "conversions", "revenue"],
111
+ enum: ["page_views", "entrances"],
19
112
  default: "page_views",
20
113
  },
21
114
  sort_order: SORT_ORDER_SCHEMA,
@@ -24,6 +117,7 @@ export const getPagesTool = {
24
117
  type: "string",
25
118
  description: "Filter pages by URL path pattern (e.g. '/blog').",
26
119
  },
120
+ ...MULTI_FILTER_SCHEMA,
27
121
  },
28
122
  },
29
123
  handler: async (client, args) => {
@@ -36,12 +130,16 @@ export const getPagesTool = {
36
130
  sort_by: args.sort_by ?? "page_views",
37
131
  sort_order: args.sort_order ?? "desc",
38
132
  path_filter: args.path_filter,
133
+ ...pickMultiFilters(args),
39
134
  });
40
135
  },
41
136
  };
42
137
  export const getLandingPagesTool = {
43
138
  name: "get_landing_pages",
44
- description: "Get landing page performance: entrances, bounce rate, conversions. Landing pages are the first page users see when entering the site. High bounce rates indicate poor landing page experience.",
139
+ description: "Get landing page performance: entrances, bounce rate, conversions. Landing pages are the first page users see when entering the site. High bounce rates indicate poor landing page experience. " +
140
+ "Supports multi-value filters (country, device_type, browser, os, channel_group, UTMs) as arrays of strings — e.g. " +
141
+ "country=['ES','PT'] to filter to two countries. Pass include=['channel_group'] to also break down by channel group. " +
142
+ "The two are orthogonal — combine them as needed.",
45
143
  inputSchema: {
46
144
  type: "object",
47
145
  properties: {
@@ -64,6 +162,7 @@ export const getLandingPagesTool = {
64
162
  type: "string",
65
163
  description: "Filter by URL path pattern.",
66
164
  },
165
+ ...MULTI_FILTER_SCHEMA,
67
166
  },
68
167
  },
69
168
  handler: async (client, args) => {
@@ -76,6 +175,7 @@ export const getLandingPagesTool = {
76
175
  sort_by: args.sort_by ?? "entrances",
77
176
  sort_order: args.sort_order ?? "desc",
78
177
  path_filter: args.path_filter,
178
+ ...pickMultiFilters(args),
79
179
  });
80
180
  },
81
181
  };
@@ -1 +1 @@
1
- {"version":3,"file":"pages.js","sourceRoot":"","sources":["../../src/tools/pages.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,aAAa,GACd,MAAM,aAAa,CAAC;AAGrB,MAAM,CAAC,MAAM,YAAY,GAAY;IACnC,IAAI,EAAE,WAAW;IACjB,WAAW,EACT,kIAAkI;IACpI,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gB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,UAAU,EAAE,IAAI,CAAC,UAAgC;YACjD,OAAO,EAAE,IAAI,CAAC,OAA6B;SAC5C,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
@@ -0,0 +1,49 @@
1
+ import type { SealMetricsClient } from "../client.js";
2
+ export interface SetupState {
3
+ provisioned: boolean;
4
+ accountId?: string;
5
+ pixelVerified: boolean;
6
+ }
7
+ export interface SetupContext {
8
+ client: SealMetricsClient;
9
+ baseUrl: string;
10
+ provisionKey: string;
11
+ /** install_source attribution (RF-3205). */
12
+ installSource: string;
13
+ /** Project root if the client exposes one (editors); undefined in Desktop chat. */
14
+ cwd?: string;
15
+ state: SetupState;
16
+ /**
17
+ * Called after a successful provision_site so the server adopts the api_key and
18
+ * enables the ~47 read-only tools in the same session (RF-3202b). The api_key is
19
+ * passed here but NEVER returned to the model (VAL-3201).
20
+ */
21
+ onProvisioned: (apiKey: string, accountId: string) => void;
22
+ /** Poll tuning (tests pass small values). Defaults: 2s interval, 25s timeout. */
23
+ pollDefaults?: {
24
+ intervalMs?: number;
25
+ timeoutMs?: number;
26
+ };
27
+ /** Injectable clock/sleep for the instrumentation verifier (tests). */
28
+ now?: () => number;
29
+ sleep?: (ms: number) => Promise<void>;
30
+ }
31
+ /** Setup tool shape (like ToolDef but the handler closes over the SetupContext). */
32
+ export interface SetupToolDef {
33
+ name: string;
34
+ description: string;
35
+ inputSchema: {
36
+ type: "object";
37
+ properties: Record<string, unknown>;
38
+ required?: string[];
39
+ };
40
+ annotations: {
41
+ title: string;
42
+ readOnlyHint: boolean;
43
+ openWorldHint?: boolean;
44
+ };
45
+ handler: (args: Record<string, unknown>) => Promise<unknown>;
46
+ }
47
+ /** Build the five (RF-3203) setup tools bound to a context. */
48
+ export declare function createSetupTools(ctx: SetupContext): SetupToolDef[];
49
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/tools/setup.ts"],"names":[],"mappings":"AA4B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M,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9D;AAWD,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,YAAY,EAAE,CAwUlE"}
@@ -0,0 +1,347 @@
1
+ /**
2
+ * MCP write-path setup tools (Fase 3 Bloque 2, RF-3203). These let a user register
3
+ * + verify a SealMetrics site **from the chat** (Claude Desktop, no terminal),
4
+ * reusing `@sealmetrics/setup-core` (Bloque 1) so the logic is never duplicated
5
+ * CLI↔MCP. The MCP never edits the user's source (RF-3204) — provision_site hands
6
+ * back the snippet + guide; the agent (with repo) or the human (paste) places it.
7
+ *
8
+ * Privacy/secret handling (VAL-3201/3203, RF-3207):
9
+ * - provision_site NEVER returns the api_key to the model (it is adopted into
10
+ * memory to enable the read-only tools and saved by the user via env/email).
11
+ * - provision_site NEVER returns the claim_url magic-link token (it goes by
12
+ * email); it returns `claim_email_sent_to` + `dashboard_url` only.
13
+ */
14
+ import { detectFramework, buildProvisionBody, unwrapProvisionData, provisionErrorForStatus, fetchPixelStatus, pollPixelStatus, getInstrumentationGuide, getStackGuide, getPlatformPluginGuide, checkInstrumentation, detectPII, } from "@sealmetrics/setup-core";
15
+ import { SealMetricsAPIError } from "../errors.js";
16
+ /** Terms of Service URL — shown so the human can read them before accepting (parity with the CLI). */
17
+ const TOS_URL = "https://sealmetrics.com/terms";
18
+ function str(v) {
19
+ if (v === undefined || v === null)
20
+ return undefined;
21
+ const s = String(v).trim();
22
+ return s.length > 0 ? s : undefined;
23
+ }
24
+ /** Build the five (RF-3203) setup tools bound to a context. */
25
+ export function createSetupTools(ctx) {
26
+ const provisionSite = {
27
+ name: "provision_site",
28
+ description: "Register a NEW free SealMetrics site from the chat (no terminal needed). Creates the account, returns the tracker snippet to place in your site's <head>, and emails you a claim link to set a password. After this succeeds, the read-only analytics tools are enabled in this session. Does NOT edit your code — you (or the agent, if it has the repo) place the snippet.",
29
+ inputSchema: {
30
+ type: "object",
31
+ properties: {
32
+ site_name: { type: "string", description: "Human-friendly name for the site (e.g. 'My Shop')." },
33
+ domain: { type: "string", description: "Primary domain of the site (e.g. 'myshop.com'). Optional." },
34
+ email: { type: "string", description: "Your email — receives the claim link to set a password." },
35
+ name: { type: "string", description: "Your name. Optional." },
36
+ accept_terms: {
37
+ type: "boolean",
38
+ description: "Must be true: confirms the user has read and accepts the SealMetrics Terms of Service (https://sealmetrics.com/terms). Show the user this link first; do NOT accept on their behalf.",
39
+ },
40
+ },
41
+ required: ["site_name", "email", "accept_terms"],
42
+ },
43
+ annotations: { title: "Provision a SealMetrics site", readOnlyHint: false, openWorldHint: true },
44
+ handler: async (args) => {
45
+ if (args.accept_terms !== true && args.accept_terms !== "true") {
46
+ throw new Error(`accept_terms must be true. Show the user the SealMetrics Terms of Service (${TOS_URL}) and ask them to confirm — do not accept on their behalf.`);
47
+ }
48
+ const siteName = str(args.site_name);
49
+ const email = str(args.email);
50
+ if (!siteName)
51
+ throw new Error("site_name is required.");
52
+ if (!email)
53
+ throw new Error("email is required.");
54
+ const input = {
55
+ siteName,
56
+ domain: str(args.domain),
57
+ email,
58
+ name: str(args.name),
59
+ installSource: ctx.installSource, // "mcp" — attribution (RF-3205/RF-3604)
60
+ };
61
+ let envelope;
62
+ try {
63
+ envelope = await ctx.client.post("/provision", buildProvisionBody(input), {
64
+ provisionKey: ctx.provisionKey,
65
+ });
66
+ }
67
+ catch (e) {
68
+ if (e instanceof SealMetricsAPIError) {
69
+ // Map HTTP status → the shared ProvisionError code/message (TEST-3203/3601).
70
+ const pe = provisionErrorForStatus(e.statusCode);
71
+ throw new Error(`${pe.code}: ${pe.message}`);
72
+ }
73
+ throw e;
74
+ }
75
+ const result = unwrapProvisionData(envelope);
76
+ // Adopt the api_key + enable read-only tools (RF-3202b). NEVER returned to the model.
77
+ ctx.onProvisioned(result.api_key, result.account_id);
78
+ ctx.state.provisioned = true;
79
+ ctx.state.accountId = result.account_id;
80
+ // Return ONLY non-secret fields: no api_key (VAL-3201), no claim_url token (RF-3207/VAL-3203).
81
+ return {
82
+ account_id: result.account_id,
83
+ snippet: result.snippet,
84
+ dashboard_url: result.dashboard_url,
85
+ claim_email_sent_to: email,
86
+ free_quota: result.free_quota,
87
+ next_steps: [
88
+ "Place the snippet in your site's <head> on every page. If the agent has your repo it can do this; otherwise paste it yourself.",
89
+ "Run verify_setup once the snippet is live to confirm the pixel is sending data.",
90
+ "Read-only analytics tools are now enabled in THIS session.",
91
+ "To keep them after restarting Claude Desktop, paste the api_key from your welcome email into the SEALMETRICS_API_KEY field of the extension settings.",
92
+ "Check your email to claim the account (set a password) — this unlocks the web dashboard. Analytics work without it.",
93
+ ],
94
+ };
95
+ },
96
+ };
97
+ const verifySetup = {
98
+ name: "verify_setup",
99
+ description: "Poll until the SealMetrics pixel is confirmed installed (a real pageview has reached the backend) or it times out. Run this after placing the snippet. Reads only — sends no data.",
100
+ inputSchema: {
101
+ type: "object",
102
+ properties: {
103
+ account_id: {
104
+ type: "string",
105
+ description: "Site/account id to verify. Defaults to the site provisioned in this session.",
106
+ },
107
+ timeout_seconds: {
108
+ type: "number",
109
+ description: "Max seconds to wait for the first hit (default 25).",
110
+ },
111
+ },
112
+ },
113
+ annotations: { title: "Verify pixel install", readOnlyHint: true, openWorldHint: true },
114
+ handler: async (args) => {
115
+ const accountId = str(args.account_id) ?? ctx.state.accountId;
116
+ if (!accountId)
117
+ throw new Error("account_id is required (provision a site first).");
118
+ const apiKey = ctx.client.getApiKey();
119
+ if (!apiKey) {
120
+ throw new Error("AUTH_REQUIRED: no api_key available to verify. Provision a site first, or set SEALMETRICS_API_KEY.");
121
+ }
122
+ const timeoutMs = ctx.pollDefaults?.timeoutMs ??
123
+ (typeof args.timeout_seconds === "number" ? Math.max(0, args.timeout_seconds) * 1000 : 25_000);
124
+ const intervalMs = ctx.pollDefaults?.intervalMs ?? 2_000;
125
+ const res = await pollPixelStatus({
126
+ fetchStatus: () => fetchPixelStatus(accountId, { baseUrl: ctx.baseUrl, apiKey }),
127
+ timeoutMs,
128
+ intervalMs,
129
+ });
130
+ if (res.verified === true)
131
+ ctx.state.pixelVerified = true;
132
+ return {
133
+ account_id: accountId,
134
+ installed: res.verified === true,
135
+ status: res.verified === true ? "verified" : "pending",
136
+ total_hits: res.totalHits ?? 0,
137
+ next_steps: res.verified === true
138
+ ? ["Pixel confirmed. You can now query analytics with the read-only tools."]
139
+ : [
140
+ "No hits yet. Make sure the snippet is in the <head> of a live page, then load that page and re-run verify_setup.",
141
+ ],
142
+ };
143
+ },
144
+ };
145
+ const getSetupStatus = {
146
+ name: "get_setup_status",
147
+ description: "Report where the setup flow is: whether a site has been provisioned in this session and whether its pixel has been verified.",
148
+ inputSchema: { type: "object", properties: {} },
149
+ annotations: { title: "Setup status", readOnlyHint: true },
150
+ handler: async () => ({
151
+ provisioned: ctx.state.provisioned,
152
+ account_id: ctx.state.accountId,
153
+ pixel_verified: ctx.state.pixelVerified,
154
+ }),
155
+ };
156
+ const detectFrameworkTool = {
157
+ name: "detect_framework",
158
+ description: "Best-effort detect the web framework/CMS of a project so the snippet can be placed correctly. Pass `path` if you have the repo; in a pure chat (no repo) returns 'unknown' plus the manual guide. Read-only — never edits files.",
159
+ inputSchema: {
160
+ type: "object",
161
+ properties: {
162
+ path: {
163
+ type: "string",
164
+ description: "Absolute path to the project root. Optional; omit if you don't have the repo.",
165
+ },
166
+ },
167
+ },
168
+ annotations: { title: "Detect framework", readOnlyHint: true },
169
+ handler: async (args) => {
170
+ const path = str(args.path) ?? ctx.cwd;
171
+ if (!path) {
172
+ const guide = getStackGuide("unknown");
173
+ return {
174
+ framework: "unknown",
175
+ strategy: "manual",
176
+ location: guide.location,
177
+ placement: guide.placement,
178
+ provision_only: true,
179
+ note: "No project path available (e.g. Claude Desktop chat). Provide `path` if you have the repo, or place the snippet manually using loading_notes.",
180
+ loading_notes: guide.notes,
181
+ };
182
+ }
183
+ const d = detectFramework(path);
184
+ const guide = getStackGuide(d.framework);
185
+ return {
186
+ framework: d.framework,
187
+ platform: d.platform,
188
+ strategy: d.strategy,
189
+ location: d.recommendedLocation,
190
+ placement: d.placementHint,
191
+ provision_only: d.provisionOnly,
192
+ loading_notes: guide.notes,
193
+ ...(d.platform
194
+ ? { plugin_guidance: getPlatformPluginGuide(d.platform, ctx.state.accountId ?? "[YOUR_ACCOUNT_ID]") }
195
+ : {}),
196
+ };
197
+ },
198
+ };
199
+ const getInstrumentationGuideTool = {
200
+ name: "get_instrumentation_guide",
201
+ description: "Return the canonical SealMetrics event-instrumentation guide (closed conv/micro taxonomy + privacy rules) with your account_id substituted. Use it before writing sealmetrics.conv()/micro() calls. The MCP does NOT write these calls — the agent does, guided by this.",
202
+ inputSchema: {
203
+ type: "object",
204
+ properties: {
205
+ account_id: {
206
+ type: "string",
207
+ description: "Account id to substitute into the guide. Defaults to the provisioned site.",
208
+ },
209
+ },
210
+ },
211
+ annotations: { title: "Instrumentation guide", readOnlyHint: true },
212
+ handler: async (args) => {
213
+ const accountId = str(args.account_id) ?? ctx.state.accountId ?? "[YOUR_ACCOUNT_ID]";
214
+ return { account_id: accountId, guide: getInstrumentationGuide(accountId) };
215
+ },
216
+ };
217
+ const verifyEventInstrumented = {
218
+ name: "verify_event_instrumented",
219
+ description: "Close the instrumentation loop (Fase 3 Bloque 4): after you add a sealmetrics.conv()/micro() call AND trigger it (a test visit/action), confirm the event reached the backend with the expected type. ALSO validates the event name against the closed taxonomy and rejects PII in properties before declaring success. Reads only.",
220
+ inputSchema: {
221
+ type: "object",
222
+ properties: {
223
+ account_id: { type: "string", description: "Site/account id. Defaults to the provisioned site." },
224
+ kind: { type: "string", enum: ["conv", "micro"], description: "Event kind: 'conv' or 'micro'." },
225
+ name: { type: "string", description: "Event name (must be in the closed taxonomy, e.g. 'purchase')." },
226
+ timeout_seconds: { type: "number", description: "Max seconds to wait for the event (default 25)." },
227
+ },
228
+ required: ["kind", "name"],
229
+ },
230
+ annotations: { title: "Verify instrumented event", readOnlyHint: true, openWorldHint: true },
231
+ handler: async (args) => {
232
+ const accountId = str(args.account_id) ?? ctx.state.accountId;
233
+ if (!accountId)
234
+ throw new Error("account_id is required (provision a site first).");
235
+ const kind = str(args.kind);
236
+ const name = str(args.name);
237
+ if (kind !== "conv" && kind !== "micro")
238
+ throw new Error("kind must be 'conv' or 'micro'.");
239
+ if (!name)
240
+ throw new Error("name is required.");
241
+ const apiKey = ctx.client.getApiKey();
242
+ if (!apiKey)
243
+ throw new Error("AUTH_REQUIRED: no api_key available. Provision a site first or set SEALMETRICS_API_KEY.");
244
+ // 1) Static gate: taxonomy (VAL-3401) + PII (VAL-3402). Reject before confirming.
245
+ const check = checkInstrumentation(kind, name);
246
+ if (!check.taxonomy.valid) {
247
+ return {
248
+ status: "rejected",
249
+ reason: "out_of_taxonomy",
250
+ name,
251
+ suggestion: check.taxonomy.suggestion,
252
+ message: `'${name}' is not in the closed ${kind} taxonomy.${check.taxonomy.suggestion ? ` Did you mean '${check.taxonomy.suggestion}'?` : ""} Fix the event name before verifying.`,
253
+ };
254
+ }
255
+ // 2) Confirm the event reached the backend by polling the raw endpoint and
256
+ // matching by recency (the raw routes filter by date, not last-N-seconds).
257
+ const path = kind === "conv" ? "/stats/conversions/raw" : "/stats/microconversions/raw";
258
+ const typeParam = kind === "conv" ? "conversion_type" : "microconversion_type";
259
+ const timeoutMs = ctx.pollDefaults?.timeoutMs ??
260
+ (typeof args.timeout_seconds === "number" ? Math.max(0, args.timeout_seconds) * 1000 : 25_000);
261
+ const intervalMs = ctx.pollDefaults?.intervalMs ?? 3_000;
262
+ const startedAt = ctx.now ? ctx.now() : Date.now();
263
+ const deadline = startedAt + timeoutMs;
264
+ let found;
265
+ let piiFlagged = [];
266
+ for (;;) {
267
+ try {
268
+ const raw = await ctx.client.requestDirect(path, {
269
+ site_id: accountId,
270
+ period: "today",
271
+ [typeParam]: name,
272
+ include_properties: "true",
273
+ page_size: "20",
274
+ });
275
+ const rows = Array.isArray(raw?.data) ? raw.data : [];
276
+ // Match the most recent row whose timestamp is at/after we started.
277
+ for (const row of rows) {
278
+ const ts = Date.parse(String(row.timestamp_utc ?? ""));
279
+ if (Number.isFinite(ts) && ts >= startedAt - 5_000) {
280
+ found = row;
281
+ const findings = detectPropertiesPII(row.properties);
282
+ piiFlagged = findings;
283
+ break;
284
+ }
285
+ }
286
+ }
287
+ catch {
288
+ // transient — keep polling until the deadline
289
+ }
290
+ if (found)
291
+ break;
292
+ const nowMs = ctx.now ? ctx.now() : Date.now();
293
+ if (nowMs + intervalMs >= deadline)
294
+ break;
295
+ await sleep(intervalMs, ctx.sleep);
296
+ }
297
+ if (!found) {
298
+ return {
299
+ status: "pending",
300
+ account_id: accountId,
301
+ kind,
302
+ name,
303
+ message: `No '${name}' ${kind} event seen yet. Trigger the event (a test visit/action), then re-run. Raw endpoints lag ~2-5s.`,
304
+ };
305
+ }
306
+ if (piiFlagged.length > 0) {
307
+ return {
308
+ status: "warning_pii",
309
+ account_id: accountId,
310
+ kind,
311
+ name,
312
+ pii_properties: piiFlagged,
313
+ message: `Event '${name}' arrived, but its properties look like PII (${piiFlagged
314
+ .map((f) => f.key)
315
+ .join(", ")}). Remove personal data / order/user IDs — these must NEVER be tracked.`,
316
+ };
317
+ }
318
+ return {
319
+ status: "verified",
320
+ account_id: accountId,
321
+ kind,
322
+ name,
323
+ message: `Event '${name}' confirmed in SealMetrics with no PII. Instrumentation verified.`,
324
+ };
325
+ },
326
+ };
327
+ return [
328
+ provisionSite,
329
+ verifySetup,
330
+ getSetupStatus,
331
+ detectFrameworkTool,
332
+ getInstrumentationGuideTool,
333
+ verifyEventInstrumented,
334
+ ];
335
+ }
336
+ // Local helpers ---------------------------------------------------------------
337
+ function sleep(ms, custom) {
338
+ if (custom)
339
+ return custom(ms);
340
+ return new Promise((r) => setTimeout(r, ms));
341
+ }
342
+ function detectPropertiesPII(properties) {
343
+ if (!properties || typeof properties !== "object")
344
+ return [];
345
+ return detectPII(properties).map((f) => ({ reason: f.reason, key: f.key }));
346
+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AC/D,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,mBAAmB,CAAC,UAAmB;IAC9C,IAAI,CAAC,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IAC7D,OAAO,SAAS,CAAC,UAAqC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AACzG,CAAC"}
@@ -1,11 +1,3 @@
1
- /**
2
- * Convert a period string (e.g. "30d", "this_month") to start_date / end_date.
3
- * Needed for endpoints that don't accept the `period` shorthand.
4
- */
5
- export declare function periodToDateRange(period: string): {
6
- start_date: string;
7
- end_date: string;
8
- };
9
1
  export declare const PERIOD_SCHEMA: {
10
2
  readonly type: "string";
11
3
  readonly description: "Time period for the report. Examples: \"today\", \"yesterday\", \"7d\", \"30d\", \"90d\", \"this_month\", \"last_month\", \"this_year\". Default: \"30d\".";
@@ -33,10 +25,6 @@ export declare const PAGE_SCHEMA: {
33
25
  readonly description: "Page number for paginated results (default: 1).";
34
26
  readonly default: 1;
35
27
  };
36
- /**
37
- * Validate a freeform string input: reject control characters and enforce length limit.
38
- */
39
- export declare function sanitizeInput(value: unknown, name: string, maxLen?: number): string | undefined;
40
28
  /**
41
29
  * Resolve site_id from tool args or SEALMETRICS_SITE_ID env var.
42
30
  * Throws if neither is available.
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/tools/shared.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CA6E1F;AAED,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAEX,eAAO,MAAM,cAAc;;;;CAKjB,CAAC;AAEX,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AAEX,eAAO,MAAM,iBAAiB;;;;;CAKpB,CAAC;AAEX,eAAO,MAAM,WAAW;;;;CAId,CAAC;AAIX;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,SAAmB,GAAG,MAAM,GAAG,SAAS,CAUzG;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAYnE"}
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/tools/shared.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAEX,eAAO,MAAM,cAAc;;;;CAKjB,CAAC;AAEX,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AAEX,eAAO,MAAM,iBAAiB;;;;;CAKpB,CAAC;AAEX,eAAO,MAAM,WAAW;;;;CAId,CAAC;AAEX;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CASnE"}