@apex-inc/mcp-server 0.75.0 → 0.79.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/api-client.d.ts +13 -21
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +203 -61
- package/dist/api-client.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +7 -6
- package/dist/auth.js.map +1 -1
- package/dist/fetch-timeout.d.ts +23 -0
- package/dist/fetch-timeout.d.ts.map +1 -0
- package/dist/fetch-timeout.js +78 -0
- package/dist/fetch-timeout.js.map +1 -0
- package/dist/hosted.d.ts +34 -0
- package/dist/hosted.d.ts.map +1 -0
- package/dist/hosted.js +74 -0
- package/dist/hosted.js.map +1 -0
- package/dist/index.js +49 -117
- package/dist/index.js.map +1 -1
- package/dist/letter-blocks.d.ts.map +1 -1
- package/dist/letter-blocks.js +13 -22
- package/dist/letter-blocks.js.map +1 -1
- package/dist/live-test-files.d.ts +35 -0
- package/dist/live-test-files.d.ts.map +1 -0
- package/dist/live-test-files.js +114 -0
- package/dist/live-test-files.js.map +1 -0
- package/dist/live-test-guard.d.ts.map +1 -1
- package/dist/live-test-guard.js +7 -1
- package/dist/live-test-guard.js.map +1 -1
- package/dist/request-context.d.ts +40 -0
- package/dist/request-context.d.ts.map +1 -0
- package/dist/request-context.js +11 -0
- package/dist/request-context.js.map +1 -0
- package/dist/server-factory.d.ts +31 -0
- package/dist/server-factory.d.ts.map +1 -0
- package/dist/server-factory.js +585 -0
- package/dist/server-factory.js.map +1 -0
- package/dist/setup-catchup-tools.d.ts +4 -0
- package/dist/setup-catchup-tools.d.ts.map +1 -1
- package/dist/setup-catchup-tools.js +33 -67
- package/dist/setup-catchup-tools.js.map +1 -1
- package/dist/smoke-tools.d.ts.map +1 -1
- package/dist/smoke-tools.js +2 -0
- package/dist/smoke-tools.js.map +1 -1
- package/dist/tool-catalog.d.ts +2 -0
- package/dist/tool-catalog.d.ts.map +1 -1
- package/dist/tool-catalog.js +6 -1
- package/dist/tool-catalog.js.map +1 -1
- package/dist/tool-groups.d.ts.map +1 -1
- package/dist/tool-groups.js +12 -0
- package/dist/tool-groups.js.map +1 -1
- package/dist/tool-mode.d.ts +48 -0
- package/dist/tool-mode.d.ts.map +1 -0
- package/dist/tool-mode.js +189 -0
- package/dist/tool-mode.js.map +1 -0
- package/dist/tool-shared.d.ts +9 -1
- package/dist/tool-shared.d.ts.map +1 -1
- package/dist/tool-shared.js +52 -6
- package/dist/tool-shared.js.map +1 -1
- package/dist/tools/adoption.d.ts.map +1 -1
- package/dist/tools/adoption.js +2 -1
- package/dist/tools/adoption.js.map +1 -1
- package/dist/tools/apex-campaigns.d.ts +394 -0
- package/dist/tools/apex-campaigns.d.ts.map +1 -1
- package/dist/tools/apex-campaigns.js +256 -1
- package/dist/tools/apex-campaigns.js.map +1 -1
- package/dist/tools/context.d.ts +2 -2
- package/dist/tools/experiments.d.ts +69 -1
- package/dist/tools/experiments.d.ts.map +1 -1
- package/dist/tools/experiments.js +140 -76
- package/dist/tools/experiments.js.map +1 -1
- package/dist/tools/letters.d.ts +214 -48
- package/dist/tools/letters.d.ts.map +1 -1
- package/dist/tools/letters.js +240 -44
- package/dist/tools/letters.js.map +1 -1
- package/dist/tools/measurement.d.ts +70 -28
- package/dist/tools/measurement.d.ts.map +1 -1
- package/dist/tools/measurement.js +165 -27
- package/dist/tools/measurement.js.map +1 -1
- package/dist/tools.d.ts +774 -76
- package/dist/tools.d.ts.map +1 -1
- package/package.json +11 -1
- package/skills/apex-growth-intelligence/SKILL.md +4 -0
- package/skills/apex-growth-tracking/SKILL.md +1 -1
- package/skills/apex-integration-cookbook/SKILL.md +23 -3
- package/skills/apex-setup/SKILL.md +2 -1
- package/skills/apex-spec/SKILL.md +6 -1
|
@@ -9,25 +9,26 @@ function text(t, isError = false) {
|
|
|
9
9
|
// Nested keys are snake_case: the casing layer only translates top-level params.
|
|
10
10
|
const keyEventConditionSchema = z.object({
|
|
11
11
|
field_path: z.string().min(1).describe('A property on the event, dots for nested ones, e.g. "plan".'),
|
|
12
|
-
operator: z.enum(["equals", "not_equals", "in", "exists", "not_exists"]),
|
|
12
|
+
operator: z.enum(["equals", "not_equals", "in", "contains", "gt", "gte", "lt", "lte", "exists", "not_exists"]),
|
|
13
13
|
value: z
|
|
14
14
|
.union([z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()]))])
|
|
15
15
|
.optional()
|
|
16
|
-
.describe("One value for equals / not_equals, a list for in, none for exists."),
|
|
16
|
+
.describe("One value for equals / not_equals / contains / gt / gte / lt / lte, a list for in, none for exists."),
|
|
17
17
|
});
|
|
18
18
|
const keyEventSourceSchema = z.object({
|
|
19
|
-
type: z.enum(["custom_event", "form_submit"]).describe("custom_event
|
|
20
|
-
event_name: z.string().optional().describe("
|
|
21
|
-
selector: z.string().optional().describe('
|
|
22
|
-
target_url: z.string().optional().describe("
|
|
23
|
-
where: z.array(keyEventConditionSchema).max(10).optional().describe("
|
|
19
|
+
type: z.enum(["custom_event", "form_submit"]).describe("custom_event or form_submit"),
|
|
20
|
+
event_name: z.string().optional().describe("Event name for custom_event"),
|
|
21
|
+
selector: z.string().optional().describe('Optional form "#id" for form_submit'),
|
|
22
|
+
target_url: z.string().optional().describe("Optional page path/URL for form_submit"),
|
|
23
|
+
where: z.array(keyEventConditionSchema).max(10).optional().describe("Optional event property conditions (all must match)"),
|
|
24
24
|
revenue_stream: z
|
|
25
25
|
.enum(["dedupe_with_billing", "additive"])
|
|
26
26
|
.optional()
|
|
27
|
-
.describe('
|
|
27
|
+
.describe('Revenue key events only: "dedupe_with_billing" (default) or "additive".'),
|
|
28
28
|
});
|
|
29
29
|
const keyEventCategorySchema = z
|
|
30
30
|
.enum([
|
|
31
|
+
"install",
|
|
31
32
|
"purchase",
|
|
32
33
|
"lead",
|
|
33
34
|
"qualified_lead",
|
|
@@ -35,6 +36,7 @@ const keyEventCategorySchema = z
|
|
|
35
36
|
"signup",
|
|
36
37
|
"subscribe",
|
|
37
38
|
"add_to_cart",
|
|
39
|
+
"checkout",
|
|
38
40
|
"engagement",
|
|
39
41
|
"expansion",
|
|
40
42
|
"referral",
|
|
@@ -73,7 +75,11 @@ function keyEventLine(k, i) {
|
|
|
73
75
|
k.definitionVersion > 1 ? `v${k.definitionVersion}` : null,
|
|
74
76
|
].filter(Boolean);
|
|
75
77
|
const head = ` ${i + 1}. ${k.name} [${k.id}]${tags.length ? ` (${tags.join(", ")})` : ""}: ${k.counts}`;
|
|
76
|
-
|
|
78
|
+
const warnings = [
|
|
79
|
+
k.nameWarning ? ` ⚠ ${k.nameWarning}` : null,
|
|
80
|
+
k.transportWarning ? ` ⚠ ${k.transportWarning.message}` : null,
|
|
81
|
+
].filter(Boolean);
|
|
82
|
+
return warnings.length > 0 ? [head, ...warnings].join("\n") : head;
|
|
77
83
|
}
|
|
78
84
|
const KEY_EVENT_USE_KIND = {
|
|
79
85
|
journey: "Adaptive Journey",
|
|
@@ -301,16 +307,23 @@ export const measurementTools = {
|
|
|
301
307
|
},
|
|
302
308
|
},
|
|
303
309
|
get_growth_reality: {
|
|
304
|
-
description: `${APEX} — "Is our growth real?" Per
|
|
310
|
+
description: `${APEX} — "Is our growth real?" Per key event, the four-way readout: exposed rate vs persistent do-nothing global holdout (with 95% CI and incremental conversions/revenue), previous-period baseline, and opt-in industry benchmark when available. Pass key_event_id to inspect one key event.`,
|
|
305
311
|
schema: z.object({
|
|
306
312
|
days: z
|
|
307
313
|
.union([z.number(), z.literal("all")])
|
|
308
314
|
.optional()
|
|
309
315
|
.describe("Trailing window in days, or 'all' for since-inception (default)."),
|
|
316
|
+
keyEventId: z
|
|
317
|
+
.string()
|
|
318
|
+
.optional()
|
|
319
|
+
.describe("Optional key event ID to return the four-way readout for one key event."),
|
|
310
320
|
}),
|
|
311
|
-
handler: async ({ days }) => {
|
|
312
|
-
const
|
|
313
|
-
|
|
321
|
+
handler: async ({ days, keyEventId, }) => {
|
|
322
|
+
const params = new URLSearchParams();
|
|
323
|
+
params.set("days", days && days !== "all" ? String(days) : "all");
|
|
324
|
+
if (keyEventId)
|
|
325
|
+
params.set("key_event_id", keyEventId);
|
|
326
|
+
const res = await apiGet(`/api/growth/reality?${params.toString()}`);
|
|
314
327
|
const goals = res.data?.goals ?? [];
|
|
315
328
|
const unmeasured = res.data?.unmeasuredKeyEvents ?? [];
|
|
316
329
|
if (goals.length === 0 && unmeasured.length === 0) {
|
|
@@ -324,6 +337,7 @@ export const measurementTools = {
|
|
|
324
337
|
};
|
|
325
338
|
}
|
|
326
339
|
const pctFmt = (v) => v == null ? "—" : `${v > 0 ? "+" : ""}${(v * 100).toFixed(1)}%`;
|
|
340
|
+
const rateFmt = (v) => v == null ? "—" : `${(v * 100).toFixed(1)}%`;
|
|
327
341
|
const lines = goals.map((g) => {
|
|
328
342
|
const totalConversions = (g.counts?.exposedConversions ?? 0) + (g.counts?.holdoutConversions ?? 0);
|
|
329
343
|
if (totalConversions === 0) {
|
|
@@ -331,8 +345,22 @@ export const measurementTools = {
|
|
|
331
345
|
const totalSubjects = (g.counts?.exposedSubjects ?? 0) + (g.counts?.holdoutSubjects ?? 0);
|
|
332
346
|
return ` • ${g.goalName}: NO EVENTS YET (0 ${evLabel}conversions across ${totalSubjects.toLocaleString()} holdout-tracked people since ${g.collectingSince || "—"} — check get_wiring_status or list_data_sources)`;
|
|
333
347
|
}
|
|
348
|
+
const extras = [];
|
|
349
|
+
if (g.exposedRate != null && g.holdoutRate != null) {
|
|
350
|
+
extras.push(`exposed ${rateFmt(g.exposedRate)} vs holdout ${rateFmt(g.holdoutRate)}`);
|
|
351
|
+
}
|
|
352
|
+
if (g.previousBaselineRate != null) {
|
|
353
|
+
extras.push(`prior baseline ${rateFmt(g.previousBaselineRate)}`);
|
|
354
|
+
}
|
|
355
|
+
if (typeof g.industryBenchmark === "object" && g.industryBenchmark != null) {
|
|
356
|
+
extras.push(`industry ${rateFmt(g.industryBenchmark.rate)}`);
|
|
357
|
+
}
|
|
358
|
+
else if (g.industryBenchmark === "opt_in_required") {
|
|
359
|
+
extras.push("industry benchmark: opt in via Workspace Settings");
|
|
360
|
+
}
|
|
361
|
+
const extraSuffix = extras.length > 0 ? ` (${extras.join(" · ")})` : "";
|
|
334
362
|
if (!g.isDecisive) {
|
|
335
|
-
return ` • ${g.goalName}: COLLECTING (directional ${pctFmt(g.lift)}, ${totalConversions.toLocaleString()} conversions since ${g.collectingSince || "—"})`;
|
|
363
|
+
return ` • ${g.goalName}: COLLECTING (directional ${pctFmt(g.lift)}, ${totalConversions.toLocaleString()} conversions since ${g.collectingSince || "—"})${extraSuffix}`;
|
|
336
364
|
}
|
|
337
365
|
const ci = g.liftCI
|
|
338
366
|
? ` [${pctFmt(g.liftCI.lower)}, ${pctFmt(g.liftCI.upper)}]`
|
|
@@ -340,7 +368,7 @@ export const measurementTools = {
|
|
|
340
368
|
const rev = typeof g.incrementalRevenue === "number"
|
|
341
369
|
? ` · ~$${Math.round(g.incrementalRevenue).toLocaleString()} incremental`
|
|
342
370
|
: "";
|
|
343
|
-
return ` • ${g.goalName}: ${pctFmt(g.lift)} vs holdout${ci} — DECISIVE${rev}`;
|
|
371
|
+
return ` • ${g.goalName}: ${pctFmt(g.lift)} vs holdout${ci} — DECISIVE${rev}${extraSuffix}`;
|
|
344
372
|
});
|
|
345
373
|
if (unmeasured.length > 0) {
|
|
346
374
|
for (const u of unmeasured) {
|
|
@@ -577,6 +605,107 @@ export const measurementTools = {
|
|
|
577
605
|
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
578
606
|
},
|
|
579
607
|
},
|
|
608
|
+
get_funnel: {
|
|
609
|
+
description: `${APEX} — Read the workspace's conversion funnel (Visitors → Key Events → Revenue), optionally broken down by any custom or governed event property (e.g. source_group, plan_tier, quiz_track). Pass breakdown_by to slice every funnel step by each person's earliest seen value for that property in the date window (sticky carryover across downstream steps, top N values plus Other and (not set)). Pass steps (event names or key event ids from list_key_events) to evaluate an ad-hoc step sequence on the same date window.`,
|
|
610
|
+
schema: z.object({
|
|
611
|
+
start: z.string().optional().describe("First day, YYYY-MM-DD (default 30 days ago)."),
|
|
612
|
+
end: z.string().optional().describe("Last day, YYYY-MM-DD, inclusive (default today)."),
|
|
613
|
+
days: z.number().int().min(1).max(365).optional().describe("Rolling days window when start is omitted (default 30)."),
|
|
614
|
+
breakdownBy: z
|
|
615
|
+
.string()
|
|
616
|
+
.optional()
|
|
617
|
+
.describe("Custom or governed event property path to group funnel steps by (e.g. source_group, plan_tier, meta.channel)."),
|
|
618
|
+
steps: z
|
|
619
|
+
.array(z.string())
|
|
620
|
+
.min(1)
|
|
621
|
+
.max(10)
|
|
622
|
+
.optional()
|
|
623
|
+
.describe("Optional ad-hoc step sequence (event names like page_view, quiz_started, purchase or key event ids). Defaults to the workspace's Key Events funnel."),
|
|
624
|
+
breakdownLimit: z
|
|
625
|
+
.number()
|
|
626
|
+
.int()
|
|
627
|
+
.min(1)
|
|
628
|
+
.max(50)
|
|
629
|
+
.optional()
|
|
630
|
+
.describe("Maximum distinct property values to list before rolling the rest into Other (default 20, max 50)."),
|
|
631
|
+
}),
|
|
632
|
+
handler: async (args = {}) => {
|
|
633
|
+
const params = new URLSearchParams();
|
|
634
|
+
if (args.start)
|
|
635
|
+
params.set("start", args.start);
|
|
636
|
+
if (args.end)
|
|
637
|
+
params.set("end", args.end);
|
|
638
|
+
if (args.days !== undefined && !args.start)
|
|
639
|
+
params.set("days", String(args.days));
|
|
640
|
+
if (args.breakdownBy)
|
|
641
|
+
params.set("breakdown_by", args.breakdownBy);
|
|
642
|
+
if (args.steps && args.steps.length > 0)
|
|
643
|
+
params.set("steps", args.steps.join(","));
|
|
644
|
+
if (args.breakdownLimit !== undefined)
|
|
645
|
+
params.set("breakdown_limit", String(args.breakdownLimit));
|
|
646
|
+
const suffix = params.toString() ? `?${params.toString()}` : "";
|
|
647
|
+
const funnel = await apiGet(`/api/funnel${suffix}`);
|
|
648
|
+
const windowLabel = args.start
|
|
649
|
+
? `${args.start} to ${args.end ?? "today"}`
|
|
650
|
+
: `last ${funnel.period?.days ?? args.days ?? 30} days`;
|
|
651
|
+
const lines = [`${APEX} Funnel (${windowLabel})`];
|
|
652
|
+
const fmtUsd = (n) => n.toLocaleString("en-US", {
|
|
653
|
+
style: "currency",
|
|
654
|
+
currency: "USD",
|
|
655
|
+
minimumFractionDigits: 2,
|
|
656
|
+
maximumFractionDigits: 2,
|
|
657
|
+
});
|
|
658
|
+
const stageRows = funnel.funnelStages ?? [];
|
|
659
|
+
if (stageRows.length > 0) {
|
|
660
|
+
lines.push("", "Stages:");
|
|
661
|
+
for (const s of stageRows) {
|
|
662
|
+
lines.push(` • ${s.label}: ${s.countMethod === "revenue_sum" ? fmtUsd(s.count) : s.count.toLocaleString("en-US")}`);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
else {
|
|
666
|
+
lines.push("", `Visitors: ${funnel.stages.visitors.toLocaleString("en-US")} | Goal completions: ${funnel.stages.goalCompletions.toLocaleString("en-US")} | Identified: ${funnel.stages.leads.toLocaleString("en-US")} | Customers: ${funnel.stages.customers.toLocaleString("en-US")} | Revenue: ${fmtUsd(funnel.stages.revenue)}`);
|
|
667
|
+
}
|
|
668
|
+
const pb = funnel.propertyBreakdown;
|
|
669
|
+
if (pb) {
|
|
670
|
+
lines.push("", `Breakdown by ${pb.property} (first-seen value carried across steps):`);
|
|
671
|
+
if (pb.servedFrom === "unavailable") {
|
|
672
|
+
lines.push(` Unavailable: ${pb.unavailableReason ?? "query could not run"}`);
|
|
673
|
+
}
|
|
674
|
+
else if (pb.rows.length === 0) {
|
|
675
|
+
lines.push(` No people in this range carried ${pb.property}.`);
|
|
676
|
+
}
|
|
677
|
+
else {
|
|
678
|
+
const stepLabels = pb.steps.map((s) => s.label);
|
|
679
|
+
lines.push(` Steps: ${stepLabels.join(" → ")}`);
|
|
680
|
+
for (const row of pb.rows) {
|
|
681
|
+
const name = row.isOther && pb.otherValueCount > 0
|
|
682
|
+
? `${row.value} (+${pb.otherValueCount} more)`
|
|
683
|
+
: row.value;
|
|
684
|
+
const seq = row.counts
|
|
685
|
+
.map((c, i) => {
|
|
686
|
+
const rate = row.stepRates[i];
|
|
687
|
+
const pctStr = rate !== null && rate !== undefined ? ` (${(rate * 100).toFixed(1)}%)` : "";
|
|
688
|
+
return `${stepLabels[i]}: ${c.toLocaleString("en-US")}${pctStr}`;
|
|
689
|
+
})
|
|
690
|
+
.join(" → ");
|
|
691
|
+
const overall = row.overallRate !== null ? ` | overall ${(row.overallRate * 100).toFixed(1)}%` : "";
|
|
692
|
+
lines.push(` • ${name}: ${seq}${overall}`);
|
|
693
|
+
}
|
|
694
|
+
const totalSeq = pb.totals
|
|
695
|
+
.map((t, i) => `${stepLabels[i]}: ${t.toLocaleString("en-US")}`)
|
|
696
|
+
.join(" → ");
|
|
697
|
+
lines.push(` Total: ${totalSeq}`);
|
|
698
|
+
if (pb.otherValueCount > 0) {
|
|
699
|
+
lines.push(` Showing top ${pb.cappedAt} of ${pb.totalDistinctValues} distinct values (${pb.otherValueCount} combined in Other).`);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
else if (funnel.availableProperties && funnel.availableProperties.length > 0) {
|
|
704
|
+
lines.push("", `Available event properties for breakdown_by: ${funnel.availableProperties.slice(0, 15).join(", ")}`);
|
|
705
|
+
}
|
|
706
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
707
|
+
},
|
|
708
|
+
},
|
|
580
709
|
list_key_events: {
|
|
581
710
|
description: `${APEX} — The workspace's key events (the actions that matter to the business: Lead captured, Qualified, Revenue realized) in funnel order: which events reach each one, its version, whether it counts people or companies, and which one is the main one. Pass include_archived: true to include archived key events too (needed to find an id for restore_key_event). These are the columns get_efforts shows; pass the ids to get_efforts key_event_ids or set_campaign_steps. Make one with create_key_event.`,
|
|
582
711
|
schema: z.object({
|
|
@@ -632,23 +761,23 @@ export const measurementTools = {
|
|
|
632
761
|
},
|
|
633
762
|
},
|
|
634
763
|
create_key_event: {
|
|
635
|
-
description: `${APEX} —
|
|
764
|
+
description: `${APEX} — Create a key event reached by one or more source events (with optional conditions). Backfills history without triggering sends. Workspace admin.`,
|
|
636
765
|
schema: z.object({
|
|
637
|
-
name: z.string().min(1).max(200).describe('
|
|
638
|
-
sources: z.array(keyEventSourceSchema).min(1).max(20).describe("
|
|
766
|
+
name: z.string().min(1).max(200).describe('Key event name, e.g. "Lead captured"'),
|
|
767
|
+
sources: z.array(keyEventSourceSchema).min(1).max(20).describe("Source events (any match counts)"),
|
|
639
768
|
category: keyEventCategorySchema.optional(),
|
|
640
|
-
entityScope: z.enum(["person", "account"]).optional().describe("person (default) or account
|
|
769
|
+
entityScope: z.enum(["person", "account"]).optional().describe("person (default) or account"),
|
|
641
770
|
description: z.string().max(1000).optional(),
|
|
642
|
-
template: z.string().max(100).optional().describe("
|
|
643
|
-
position: z.number().int().min(0).max(999).optional().describe("Optional
|
|
771
|
+
template: z.string().max(100).optional().describe("Optional template id, e.g. lead_captured"),
|
|
772
|
+
position: z.number().int().min(0).max(999).optional().describe("Optional funnel rank (0 = earliest)"),
|
|
644
773
|
funnelRole: z
|
|
645
774
|
.enum(["stage", "off_ramp", "return", "milestone"])
|
|
646
775
|
.optional()
|
|
647
|
-
.describe("
|
|
776
|
+
.describe("Funnel role: stage, off_ramp (churn), return (reactivation), or milestone"),
|
|
648
777
|
reactivatesChurned: z
|
|
649
778
|
.boolean()
|
|
650
779
|
.optional()
|
|
651
|
-
.describe("
|
|
780
|
+
.describe("Bring churned people back to active when reached"),
|
|
652
781
|
}),
|
|
653
782
|
handler: async (args) => {
|
|
654
783
|
try {
|
|
@@ -961,7 +1090,7 @@ export const measurementTools = {
|
|
|
961
1090
|
},
|
|
962
1091
|
},
|
|
963
1092
|
suggest_key_events: {
|
|
964
|
-
description: `${APEX} — What Apex suggests about key events, from the events it hears: events that mean the same moment and should count as one key event, a single event that is a standard moment (order_placed is a purchase) with no key event for it yet, events to add to a key event the workspace has, and two key events that count the same thing. Also lists key events Apex already set up automatically (each with its suggestion_id so the owner can undo it) and previously declined suggestions. Show the owner the suggestion and the why, then accept_key_event_suggestion, dismiss_key_event_suggestion, or undo_key_event_suggestion on their answer. Never accept on your own.`,
|
|
1093
|
+
description: `${APEX} — What Apex suggests about key events, from the events it hears and the workspace's Event Dictionary: events that mean the same moment and should count as one key event, a single event that is a standard moment (order_placed is a purchase) with no key event for it yet, a published custom event marked as a primary metric in the Event Dictionary with no key event yet, events to add to a key event the workspace has, and two key events that count the same thing. Also lists key events Apex already set up automatically (each with its suggestion_id so the owner can undo it) and previously declined suggestions. Show the owner the suggestion and the why, then accept_key_event_suggestion, dismiss_key_event_suggestion, or undo_key_event_suggestion on their answer. Never accept on your own.`,
|
|
965
1094
|
schema: z.object({}),
|
|
966
1095
|
handler: async () => {
|
|
967
1096
|
try {
|
|
@@ -1863,8 +1992,11 @@ Events fired through this tool carry a stable synthetic visitorId (mcp-agent-*,
|
|
|
1863
1992
|
}
|
|
1864
1993
|
const schemaLink = appUrl("/dashboard/settings/workspace/schema");
|
|
1865
1994
|
const status = res.status ?? (args.publish ? "published" : "draft");
|
|
1995
|
+
const keyEventHint = res._keyEventSuggestionReady
|
|
1996
|
+
? ` A Key Event suggestion is ready for "${res.name ?? args.name}" (marked as a primary metric). Run suggest_key_events to review and confirm it, or visit ${appUrl("/dashboard/key-events")}.`
|
|
1997
|
+
: "";
|
|
1866
1998
|
const msg = status === "published"
|
|
1867
|
-
? `Defined and published governed event "${res.name}" (SchemaVer ${res.schemaVer ?? "1-0-0"}, published). Manage governed events at ${schemaLink}
|
|
1999
|
+
? `Defined and published governed event "${res.name}" (SchemaVer ${res.schemaVer ?? "1-0-0"}, published). Manage governed events at ${schemaLink}.${keyEventHint}`
|
|
1868
2000
|
: `Defined governed event "${res.name}" (SchemaVer ${res.schemaVer ?? "1-0-0"}, draft). Draft definitions already work in journeys, key events, and experiments. Call publish_event_definition({ name: "${res.name}" }) when ready to publish, or manage it at ${schemaLink}.`;
|
|
1869
2001
|
return {
|
|
1870
2002
|
content: [
|
|
@@ -1936,7 +2068,10 @@ Events fired through this tool carry a stable synthetic visitorId (mcp-agent-*,
|
|
|
1936
2068
|
const changeNote = res._change
|
|
1937
2069
|
? ` Change: ${res._change}${res._breaking ? " (breaking)" : ""}.`
|
|
1938
2070
|
: "";
|
|
1939
|
-
|
|
2071
|
+
const keyEventHint = res._keyEventSuggestionReady
|
|
2072
|
+
? ` A Key Event suggestion is ready for "${res.name ?? args.name.trim()}" (marked as a primary metric). Run suggest_key_events to review and confirm it, or visit ${appUrl("/dashboard/key-events")}.`
|
|
2073
|
+
: "";
|
|
2074
|
+
return text(`${APEX} Updated governed event "${res.name ?? args.name.trim()}" (SchemaVer ${res.schemaVer ?? "1-0-0"}, status: ${res.status ?? "draft"}).${changeNote} Manage governed events at ${schemaLink}.${keyEventHint}`);
|
|
1940
2075
|
}
|
|
1941
2076
|
catch (err) {
|
|
1942
2077
|
return text(`${APEX} ${errMsg(err)}`, true);
|
|
@@ -1958,7 +2093,10 @@ Events fired through this tool carry a stable synthetic visitorId (mcp-agent-*,
|
|
|
1958
2093
|
return text(`${APEX} Could not publish "${name}": ${res.error}`, true);
|
|
1959
2094
|
}
|
|
1960
2095
|
const schemaLink = appUrl("/dashboard/settings/workspace/schema");
|
|
1961
|
-
|
|
2096
|
+
const keyEventHint = res._keyEventSuggestionReady
|
|
2097
|
+
? ` A Key Event suggestion is ready for "${res.name ?? name.trim()}" (marked as a primary metric). Run suggest_key_events to review and confirm it, or visit ${appUrl("/dashboard/key-events")}.`
|
|
2098
|
+
: "";
|
|
2099
|
+
return text(`${APEX} Published governed event "${res.name ?? name.trim()}" (SchemaVer ${res.schemaVer ?? "1-0-0"}, status: ${res.status ?? "published"}). Manage governed events at ${schemaLink}.${keyEventHint}`);
|
|
1962
2100
|
}
|
|
1963
2101
|
catch (err) {
|
|
1964
2102
|
return text(`${APEX} ${errMsg(err)}`, true);
|