@apex-inc/mcp-server 0.74.0 → 0.78.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/dist/api-client.d.ts +13 -19
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +173 -59
- 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 +28 -0
- package/dist/hosted.d.ts.map +1 -0
- package/dist/hosted.js +56 -0
- package/dist/hosted.js.map +1 -0
- package/dist/index.js +40 -118
- package/dist/index.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 +38 -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 +18 -0
- package/dist/server-factory.d.ts.map +1 -0
- package/dist/server-factory.js +221 -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 +16 -5
- 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 +14 -0
- package/dist/tool-groups.js.map +1 -1
- package/dist/tool-shared.d.ts +2 -1
- package/dist/tool-shared.d.ts.map +1 -1
- package/dist/tool-shared.js +17 -2
- 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 +390 -0
- package/dist/tools/apex-campaigns.d.ts.map +1 -1
- package/dist/tools/apex-campaigns.js +253 -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 +88 -24
- package/dist/tools/experiments.js.map +1 -1
- package/dist/tools/letters.d.ts +423 -65
- package/dist/tools/letters.d.ts.map +1 -1
- package/dist/tools/letters.js +383 -42
- package/dist/tools/letters.js.map +1 -1
- package/dist/tools/measurement.d.ts +80 -38
- package/dist/tools/measurement.d.ts.map +1 -1
- package/dist/tools/measurement.js +151 -13
- package/dist/tools/measurement.js.map +1 -1
- package/dist/tools.d.ts +1047 -157
- 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 +1 -1
- package/skills/apex-spec/SKILL.md +6 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"letters.d.ts","sourceRoot":"","sources":["../../src/tools/letters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"letters.d.ts","sourceRoot":"","sources":["../../src/tools/letters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqBxB,OAAO,EAAsE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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA2BqB;YACpB,SAAS,EAAE,MAAM,CAAC;YAClB,KAAK,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;YAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,UAAU,CAAC,EAAE,OAAO,CAAC;YACrB,SAAS,CAAC,EAAE,OAAO,CAAC;SACrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0CqB;YACpB,SAAS,EAAE,MAAM,CAAC;YAClB,KAAK,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;YAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;SACxB;;;;;;;;;;;;;;CAwCJ,CAAC"}
|
package/dist/tools/letters.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { apiGet, apiPost, apiPatch, apiDelete, apiDeleteJson, getActiveWorkspace, resolveActiveOrg, } from "../api-client.js";
|
|
3
|
+
import { LONG_REQUEST_TIMEOUT_MS } from "../fetch-timeout.js";
|
|
3
4
|
import { controlGateGuidanceFor } from "../control-gate-guidance.js";
|
|
4
5
|
import { notStartedExplanation, publishedExperimentLine } from "../publish-communication-copy.js";
|
|
5
6
|
import { applyAddJourneyStep } from "../add-journey-step.js";
|
|
@@ -35,6 +36,45 @@ function everyoneInSegmentLine(c) {
|
|
|
35
36
|
const been = c.alreadyBeenIn ? ` ${people(c.alreadyBeenIn)} already went through it in the last 90 days and won't start again.` : "";
|
|
36
37
|
return `${c.capped ? "At least " : ""}${people(c.wouldStart)} in ${c.segmentName} would start.${been}`;
|
|
37
38
|
}
|
|
39
|
+
const segmentEventWhereSchema = z
|
|
40
|
+
.array(z.object({
|
|
41
|
+
field_path: z.string().min(1).describe("Event property path (dot notation for nested keys, e.g. ft_source_group or plan.tier)."),
|
|
42
|
+
operator: z.enum(["equals", "not_equals", "in", "contains", "gt", "gte", "lt", "lte", "exists", "not_exists"]),
|
|
43
|
+
value: z
|
|
44
|
+
.union([
|
|
45
|
+
z.string(),
|
|
46
|
+
z.number(),
|
|
47
|
+
z.boolean(),
|
|
48
|
+
z.array(z.union([z.string(), z.number(), z.boolean()])),
|
|
49
|
+
])
|
|
50
|
+
.optional()
|
|
51
|
+
.describe("Value to match (omit for exists/not_exists; array for in; number for gt/gte/lt/lte)."),
|
|
52
|
+
}))
|
|
53
|
+
.max(10)
|
|
54
|
+
.optional()
|
|
55
|
+
.describe("Optional event-property filters (ANDed on the same event).");
|
|
56
|
+
const segmentConditionsSchema = z.object({
|
|
57
|
+
match: z.enum(["all", "any"]),
|
|
58
|
+
groups: z.array(z.object({
|
|
59
|
+
match: z.enum(["all", "any"]),
|
|
60
|
+
conditions: z.array(z.object({
|
|
61
|
+
verb: z.enum(["has", "hasnt"]).optional(),
|
|
62
|
+
event: z.string().optional(),
|
|
63
|
+
where: segmentEventWhereSchema,
|
|
64
|
+
at_least: z.number().int().min(1).optional(),
|
|
65
|
+
key_event_id: z.string().optional(),
|
|
66
|
+
scope: z.enum(["person", "account"]).optional(),
|
|
67
|
+
window_days: z.number().optional(),
|
|
68
|
+
attribute: z.string().optional(),
|
|
69
|
+
op: z.enum(["is", "is_not", "contains", "exists"]).optional(),
|
|
70
|
+
value: z.union([z.string(), z.number(), z.boolean()]).optional(),
|
|
71
|
+
brought_by_campaign: z
|
|
72
|
+
.union([z.string().min(1), z.object({ campaign_id: z.string().min(1) })])
|
|
73
|
+
.optional()
|
|
74
|
+
.describe("People brought by an Apex Campaign (pass campaign_id or { campaign_id })."),
|
|
75
|
+
})),
|
|
76
|
+
})),
|
|
77
|
+
});
|
|
38
78
|
export const letterTools = {
|
|
39
79
|
recommend_communications: {
|
|
40
80
|
description: "Get recommended lifecycle communications for your vertical and conversion model. Returns a prioritized list of emails and push notifications to set up.",
|
|
@@ -50,7 +90,7 @@ export const letterTools = {
|
|
|
50
90
|
catalogEntryIds: z.array(z.string()).describe("IDs from the recommendation output to generate"),
|
|
51
91
|
}),
|
|
52
92
|
handler: async (args) => {
|
|
53
|
-
const data = await apiPost("/api/communications/generate", { catalogEntryIds: args.catalogEntryIds });
|
|
93
|
+
const data = await apiPost("/api/communications/generate", { catalogEntryIds: args.catalogEntryIds }, { timeoutMs: LONG_REQUEST_TIMEOUT_MS });
|
|
54
94
|
const count = Array.isArray(data) ? data.length : 0;
|
|
55
95
|
return { content: [{ type: "text", text: `Generated ${count} communication(s).\n\n${JSON.stringify(data, null, 2)}` }] };
|
|
56
96
|
},
|
|
@@ -92,6 +132,7 @@ export const letterTools = {
|
|
|
92
132
|
title: String(comm.title ?? "Untitled"),
|
|
93
133
|
version: typeof comm.version === "number" ? comm.version : 1,
|
|
94
134
|
status: String(comm.status ?? "draft"),
|
|
135
|
+
has_unpublished_changes: Boolean(comm.draftContent),
|
|
95
136
|
pipeline: commType === "transactional"
|
|
96
137
|
? "transactional"
|
|
97
138
|
: "marketing",
|
|
@@ -383,9 +424,10 @@ export const letterTools = {
|
|
|
383
424
|
},
|
|
384
425
|
},
|
|
385
426
|
edit_communication: {
|
|
386
|
-
description: "Update a communication's subject, body, CTA, channels, or status. Pass the communication ID and the fields to update. For blank/builder comms, the headline/body/ctaLabel/ctaUrl slots are synced into the rendered email body — verify with preview_communication.\n\nA communication's Control is protected when it won an experiment or a published journey is sending it. Editing it then requires `intent`: \"compete\" adds your edit as a variant and measures it against the current content (nothing changes for recipients yet); \"replace\" makes your edit what everyone receives and supersedes any prior win. WHEN IN DOUBT, USE \"compete\" — it is recoverable, \"replace\" discards a measured result permanently. The server returns 409 intent_required with both options if you omit it.",
|
|
427
|
+
description: "Update a communication's title, subject, body, CTA, channels, or status. Pass the communication ID and the fields to update. For blank/builder comms, the headline/body/ctaLabel/ctaUrl slots are synced into the rendered email body — verify with preview_communication.\n\nA communication's Control is protected when it won an experiment or a published journey is sending it. Editing it then requires `intent`: \"compete\" adds your edit as a variant and measures it against the current content (nothing changes for recipients yet); \"replace\" makes your edit what everyone receives and supersedes any prior win. WHEN IN DOUBT, USE \"compete\" — it is recoverable, \"replace\" discards a measured result permanently. The server returns 409 intent_required with both options if you omit it.",
|
|
387
428
|
schema: z.object({
|
|
388
429
|
communicationId: z.string().describe("The communication ID to update"),
|
|
430
|
+
title: z.string().min(1).max(200).optional().describe("Rename the communication (shown in Apex lists and journeys)."),
|
|
389
431
|
subject: z.string().optional().describe("New email subject line"),
|
|
390
432
|
slots: z.record(z.string()).optional().describe("Content overrides: headline, body, ctaLabel, ctaUrl. These now sync into the rendered email body (not just metadata). Picture: imageUrl (public PNG/JPG/GIF URL; \"\" removes it), imageAlt, imageHeight (display px), imageNaturalWidth + imageNaturalHeight (the file's real pixel size, so tall art is not stretched to full width). Sets the letter's first image, adding one under the brand header when there is none."),
|
|
391
433
|
blocks: z
|
|
@@ -398,7 +440,10 @@ export const letterTools = {
|
|
|
398
440
|
.optional()
|
|
399
441
|
.describe('Who the email is signed by, shown as its From name (e.g. "Chris"). Until the workspace\'s own sending domain is verified it reads "Chris via Apex". "" clears it.'),
|
|
400
442
|
replyTo: z.string().optional().describe('Where replies to the email go. "" clears it.'),
|
|
401
|
-
status: z
|
|
443
|
+
status: z
|
|
444
|
+
.enum(["draft", "active", "paused"])
|
|
445
|
+
.optional()
|
|
446
|
+
.describe('Communication status. Prefer publish_communication to publish a draft live (it checks tokens, categories, and live experiments and creates a version snapshot). Pass status: "draft" only to unpublish a template back to Draft.'),
|
|
402
447
|
audience_bucket: z
|
|
403
448
|
.enum(["production", "beta", "dev"])
|
|
404
449
|
.optional()
|
|
@@ -426,6 +471,8 @@ export const letterTools = {
|
|
|
426
471
|
return { content: [{ type: "text", text: guard.text }] };
|
|
427
472
|
}
|
|
428
473
|
const body = {};
|
|
474
|
+
if (args.title !== undefined)
|
|
475
|
+
body.title = args.title.trim();
|
|
429
476
|
if (args.status)
|
|
430
477
|
body.status = args.status;
|
|
431
478
|
if (args.channels)
|
|
@@ -670,6 +717,7 @@ export const letterTools = {
|
|
|
670
717
|
id: comm.id,
|
|
671
718
|
title: comm.title,
|
|
672
719
|
status: comm.status,
|
|
720
|
+
has_unpublished_changes: Boolean(comm.draftContent),
|
|
673
721
|
...(comm.kind ? { kind: comm.kind } : {}),
|
|
674
722
|
channels: comm.channels,
|
|
675
723
|
pipeline: comm.pipeline,
|
|
@@ -1061,7 +1109,7 @@ export const letterTools = {
|
|
|
1061
1109
|
// Agent-friendly arg names (snake_case) are mapped to the REST
|
|
1062
1110
|
// routes inside each handler.,
|
|
1063
1111
|
create_journey: {
|
|
1064
|
-
description: `${APEX} — Create a blank draft journey (an unconfigured event trigger wired to an exit). Inherits the workspace's messaging guardrails attribution window by default (or pass attribution_window_days to override for this journey). Then set_journey_trigger and add_journey_step to build it, and publish_journey to launch. For e-commerce flows like cart recovery, prefer create_journey_from_template. audience_bucket defaults to production (live customers). Same email on TestFlight and the store is two people — do not create a staging copy of the journey.`,
|
|
1112
|
+
description: `${APEX} — Create a blank draft journey (an unconfigured event trigger wired to an exit). Inherits the workspace's messaging guardrails attribution window by default (or pass attribution_window_days to override for this journey). Then set_journey_trigger and add_journey_step to build it, and publish_journey to launch. If the journey is meant to close a funnel gap (e.g. Sign-up → Activation or Churned → Reactivated), prefer create_journey_from_funnel_gap so the trigger, goal, and later-stage auto-exits are wired automatically. For e-commerce flows like cart recovery, prefer create_journey_from_template. audience_bucket defaults to production (live customers). Same email on TestFlight and the store is two people — do not create a staging copy of the journey.`,
|
|
1065
1113
|
schema: z.object({
|
|
1066
1114
|
name: z.string().optional().describe("Journey name (default 'Untitled journey')."),
|
|
1067
1115
|
audience_bucket: z
|
|
@@ -1097,6 +1145,64 @@ export const letterTools = {
|
|
|
1097
1145
|
}
|
|
1098
1146
|
},
|
|
1099
1147
|
},
|
|
1148
|
+
update_journey: {
|
|
1149
|
+
description: `${APEX} — Rename a journey or update its description, audience bucket, or attribution window. Edits the journey's draft; if the journey is already published, call publish_journey after renaming so live labels match. Workspace admin.`,
|
|
1150
|
+
schema: z.object({
|
|
1151
|
+
journeyId: z.string().min(1).describe("The journey ID to update (from list_journeys)."),
|
|
1152
|
+
name: z.string().trim().min(1).max(200).optional().describe("New journey name."),
|
|
1153
|
+
description: z.string().max(1000).optional().describe("Updated journey description."),
|
|
1154
|
+
audience_bucket: z
|
|
1155
|
+
.enum(["production", "beta", "dev"])
|
|
1156
|
+
.optional()
|
|
1157
|
+
.describe("Who this journey enrolls."),
|
|
1158
|
+
attributionWindowDays: z
|
|
1159
|
+
.number()
|
|
1160
|
+
.int()
|
|
1161
|
+
.min(1)
|
|
1162
|
+
.max(90)
|
|
1163
|
+
.optional()
|
|
1164
|
+
.describe("Attribution window in days (1-90)."),
|
|
1165
|
+
}),
|
|
1166
|
+
handler: async ({ journeyId, name, description, audience_bucket, attributionWindowDays, }) => {
|
|
1167
|
+
const body = {};
|
|
1168
|
+
if (name !== undefined)
|
|
1169
|
+
body.name = name.trim();
|
|
1170
|
+
if (description !== undefined)
|
|
1171
|
+
body.description = description;
|
|
1172
|
+
if (audience_bucket !== undefined)
|
|
1173
|
+
body.audienceBucket = audience_bucket;
|
|
1174
|
+
if (attributionWindowDays !== undefined) {
|
|
1175
|
+
body.attributionWindowDays = attributionWindowDays;
|
|
1176
|
+
}
|
|
1177
|
+
if (Object.keys(body).length === 0) {
|
|
1178
|
+
return {
|
|
1179
|
+
content: [
|
|
1180
|
+
{
|
|
1181
|
+
type: "text",
|
|
1182
|
+
text: `${APEX} Pass at least one field to update (name, description, audience_bucket, or attribution_window_days).`,
|
|
1183
|
+
},
|
|
1184
|
+
],
|
|
1185
|
+
isError: true,
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
try {
|
|
1189
|
+
const j = await apiPatch(`/api/journeys/${encodeURIComponent(journeyId)}`, body);
|
|
1190
|
+
if (!tenantOk(j.workspaceKey))
|
|
1191
|
+
return tenantMismatch();
|
|
1192
|
+
return {
|
|
1193
|
+
content: [
|
|
1194
|
+
{
|
|
1195
|
+
type: "text",
|
|
1196
|
+
text: `${APEX} Updated journey "${j.name}" (id: ${j.id}).\nOpen in Apex: ${journeyLink(j.id)}`,
|
|
1197
|
+
},
|
|
1198
|
+
],
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
catch (err) {
|
|
1202
|
+
return { content: [{ type: "text", text: `${APEX} ${errMsg(err)}` }], isError: true };
|
|
1203
|
+
}
|
|
1204
|
+
},
|
|
1205
|
+
},
|
|
1100
1206
|
create_journey_from_template: {
|
|
1101
1207
|
description: `${APEX} — Instantiate a starter journey template (e.g. Abandoned Cart Recovery) into a fresh draft. Get the templateId from get_wiring_status (Ready-to-run templates list their id). Returns a direct link into the Apex visual journey canvas so the owner can inspect or edit the flow and letters before calling publish_journey.`,
|
|
1102
1208
|
schema: z.object({ templateId: z.string().describe("Template id from get_wiring_status (e.g. 'mobile-cart-recovery').") }),
|
|
@@ -1119,6 +1225,273 @@ export const letterTools = {
|
|
|
1119
1225
|
}
|
|
1120
1226
|
},
|
|
1121
1227
|
},
|
|
1228
|
+
get_journey_funnel_coverage: {
|
|
1229
|
+
description: `${APEX} — Read the workspace's funnel stages, stage-to-stage progress (default last 30 days), which funnel gaps (e.g. Sign-up → Activation, Churned → Reactivated) have live journeys, draft journeys, or no journey yet, matching vertical templates for each gap, and any journeys missing auto-exits after newer funnel stages were added. Call this before create_journey_from_funnel_gap or sync_journey_funnel_exits.`,
|
|
1230
|
+
schema: z.object({
|
|
1231
|
+
days: z
|
|
1232
|
+
.number()
|
|
1233
|
+
.int()
|
|
1234
|
+
.min(1)
|
|
1235
|
+
.max(365)
|
|
1236
|
+
.optional()
|
|
1237
|
+
.describe("Window in days for stage-to-stage progress counts (default 30)."),
|
|
1238
|
+
}),
|
|
1239
|
+
handler: async ({ days }) => {
|
|
1240
|
+
try {
|
|
1241
|
+
const qs = days !== undefined ? `?days=${encodeURIComponent(String(days))}` : "";
|
|
1242
|
+
const res = await apiGet(`/api/journeys/funnel-coverage${qs}`);
|
|
1243
|
+
if (!tenantOk(res.metadata?.workspace_key))
|
|
1244
|
+
return tenantMismatch();
|
|
1245
|
+
const d = res.data;
|
|
1246
|
+
if (!d || d.source !== "key_events" || d.gaps.length === 0) {
|
|
1247
|
+
return {
|
|
1248
|
+
content: [
|
|
1249
|
+
{
|
|
1250
|
+
type: "text",
|
|
1251
|
+
text: `${APEX} This workspace doesn't have at least two active funnel stages in Key Events yet. Define funnel stages with create_key_event (or on /dashboard/key-events) first.`,
|
|
1252
|
+
},
|
|
1253
|
+
],
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
const stageLine = d.stages
|
|
1257
|
+
.map((s) => `${s.label} (${s.reachedWindow} in ${d.windowDays}d)`)
|
|
1258
|
+
.join(" → ");
|
|
1259
|
+
const driftSummary = (d.summary.journeysWithExitDrift ?? 0) > 0
|
|
1260
|
+
? `, ${d.summary.journeysWithExitDrift} needing exit sync`
|
|
1261
|
+
: "";
|
|
1262
|
+
const gapLines = d.gaps.map((g) => {
|
|
1263
|
+
const status = g.coverageStatus === "live"
|
|
1264
|
+
? `LIVE (${g.journeys.map((j) => `"${j.name}" [${j.id}]`).join(", ")})`
|
|
1265
|
+
: g.coverageStatus === "draft"
|
|
1266
|
+
? `DRAFT/PAUSED (${g.journeys.map((j) => `"${j.name}" [${j.id}]`).join(", ")})`
|
|
1267
|
+
: "NO JOURNEY";
|
|
1268
|
+
const prog = g.progress.enteredWindow > 0 && g.progress.progressRateWindow !== null
|
|
1269
|
+
? `${Math.round(g.progress.progressRateWindow * 100)}% (${g.progress.progressedWindow}/${g.progress.enteredWindow}, ${g.progress.stillInGapWindow} waiting)`
|
|
1270
|
+
: `no activity in last ${d.windowDays}d`;
|
|
1271
|
+
const extras = [];
|
|
1272
|
+
const tpls = g.recommendedTemplates ?? [];
|
|
1273
|
+
if (tpls.length > 0) {
|
|
1274
|
+
extras.push(` templates: ${tpls.map((t) => `"${t.id}" (${t.title}${t.hasExperiment ? ", A/B test" : ""})`).join(", ")}`);
|
|
1275
|
+
}
|
|
1276
|
+
for (const j of g.journeys) {
|
|
1277
|
+
const missing = j.missingAutoExits ?? [];
|
|
1278
|
+
if (missing.length > 0) {
|
|
1279
|
+
extras.push(` drift on [${j.id}]: missing auto-exit for ${missing.map((m) => m.label).join(", ")} — call sync_journey_funnel_exits`);
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
return [
|
|
1283
|
+
` • ${g.kind === "winback" ? "[Win-back] " : ""}${g.from.label} → ${g.to.label} | ${status} | ${prog}`,
|
|
1284
|
+
` from_key_event_id: "${g.from.keyEventId}", to_key_event_id: "${g.to.keyEventId}"`,
|
|
1285
|
+
...extras,
|
|
1286
|
+
].join("\n");
|
|
1287
|
+
});
|
|
1288
|
+
return {
|
|
1289
|
+
content: [
|
|
1290
|
+
{
|
|
1291
|
+
type: "text",
|
|
1292
|
+
text: [
|
|
1293
|
+
`${APEX} Funnel coverage (last ${d.windowDays}d): ${d.summary.liveCovered}/${d.summary.totalGaps} live, ${d.summary.draftOnly} draft, ${d.summary.uncovered} uncovered${driftSummary}`,
|
|
1294
|
+
`Stages: ${stageLine}`,
|
|
1295
|
+
``,
|
|
1296
|
+
...gapLines,
|
|
1297
|
+
``,
|
|
1298
|
+
`To auto-wire a draft journey for any gap, call create_journey_from_funnel_gap with its from_key_event_id and to_key_event_id (defaults to a timed starter sequence; pass template_id to start from a recommended template, or mode: "blank").`,
|
|
1299
|
+
].join("\n"),
|
|
1300
|
+
},
|
|
1301
|
+
],
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
catch (err) {
|
|
1305
|
+
return { content: [{ type: "text", text: `${APEX} ${errMsg(err)}` }], isError: true };
|
|
1306
|
+
}
|
|
1307
|
+
},
|
|
1308
|
+
},
|
|
1309
|
+
create_journey_from_funnel_gap: {
|
|
1310
|
+
description: `${APEX} — Create a draft journey pre-wired for a workspace funnel gap (e.g. Sign-up → Activation, or Churned → Reactivated). Automatically sets the start trigger on from_key_event_id (last-day segment so past history never floods it), sets the journey goal to to_key_event_id, and wires automatic exit rules for the goal, every later funnel stage, and off-ramps. By default creates a timed starter sequence with editable draft emails (mode: "starter_sequence"). Pass template_id (from get_journey_funnel_coverage) to bind a curated template directly to this funnel gap, or mode: "blank" for guardrails only.`,
|
|
1311
|
+
schema: z.object({
|
|
1312
|
+
fromKeyEventId: z.string().describe("Starting funnel stage key event id (from get_journey_funnel_coverage)."),
|
|
1313
|
+
toKeyEventId: z.string().describe("Goal funnel stage key event id (from get_journey_funnel_coverage)."),
|
|
1314
|
+
mode: z
|
|
1315
|
+
.enum(["starter_sequence", "template", "blank"])
|
|
1316
|
+
.optional()
|
|
1317
|
+
.describe('Starting structure: "starter_sequence" (default timed cadence + draft emails), "template" (bind template_id to this gap), or "blank" (guardrails only).'),
|
|
1318
|
+
templateId: z
|
|
1319
|
+
.string()
|
|
1320
|
+
.optional()
|
|
1321
|
+
.describe("Optional recommended template id from get_journey_funnel_coverage (automatically selects mode: \"template\")."),
|
|
1322
|
+
name: z.string().optional().describe("Optional journey name (defaults to '<From> → <To>')."),
|
|
1323
|
+
description: z.string().optional().describe("Optional journey description."),
|
|
1324
|
+
attributionWindowDays: z
|
|
1325
|
+
.number()
|
|
1326
|
+
.int()
|
|
1327
|
+
.min(1)
|
|
1328
|
+
.max(90)
|
|
1329
|
+
.optional()
|
|
1330
|
+
.describe("Optional attribution window in days (1-90). Omit to inherit workspace default."),
|
|
1331
|
+
audienceBucket: z
|
|
1332
|
+
.enum(["production", "beta", "dev"])
|
|
1333
|
+
.optional()
|
|
1334
|
+
.describe("Who this journey enrolls. Default production."),
|
|
1335
|
+
}),
|
|
1336
|
+
handler: async ({ fromKeyEventId, toKeyEventId, mode, templateId, name, description, attributionWindowDays, audienceBucket, }) => {
|
|
1337
|
+
try {
|
|
1338
|
+
const res = await apiPost("/api/journeys/from-funnel-gap", {
|
|
1339
|
+
fromKeyEventId,
|
|
1340
|
+
toKeyEventId,
|
|
1341
|
+
...(mode !== undefined ? { mode } : {}),
|
|
1342
|
+
...(templateId !== undefined ? { templateId } : {}),
|
|
1343
|
+
...(name !== undefined ? { name } : {}),
|
|
1344
|
+
...(description !== undefined ? { description } : {}),
|
|
1345
|
+
...(attributionWindowDays !== undefined ? { attributionWindowDays } : {}),
|
|
1346
|
+
...(audienceBucket !== undefined ? { audienceBucket } : {}),
|
|
1347
|
+
});
|
|
1348
|
+
const j = res.data?.journey;
|
|
1349
|
+
const g = res.data?.gap;
|
|
1350
|
+
if (!j || !g) {
|
|
1351
|
+
return { content: [{ type: "text", text: `${APEX} Unexpected empty response creating funnel journey.` }], isError: true };
|
|
1352
|
+
}
|
|
1353
|
+
if (!tenantOk(j.workspaceKey ?? res.metadata?.workspace_key))
|
|
1354
|
+
return tenantMismatch();
|
|
1355
|
+
const exits = g.autoExitKeyEvents.map((e) => e.label).join(", ");
|
|
1356
|
+
const resolvedMode = res.data?.mode ?? (templateId ? "template" : mode ?? "starter_sequence");
|
|
1357
|
+
const commsCreated = res.data?.commsCreated ?? 0;
|
|
1358
|
+
const commsReused = res.data?.commsReused ?? 0;
|
|
1359
|
+
const structureLine = resolvedMode === "template"
|
|
1360
|
+
? `• Structure: template "${res.data?.templateId ?? templateId}" bound to this gap (${commsCreated} created, ${commsReused} reused)`
|
|
1361
|
+
: resolvedMode === "blank"
|
|
1362
|
+
? `• Structure: blank canvas (trigger, goal, and auto-exits wired)`
|
|
1363
|
+
: `• Structure: starter sequence (${commsCreated} draft ${commsCreated === 1 ? "email" : "emails"} ready to review)`;
|
|
1364
|
+
const nextLine = resolvedMode === "blank"
|
|
1365
|
+
? `Next: add_journey_step to drop in waits and letters, then publish_journey once approved.`
|
|
1366
|
+
: `Next: review or tailor the draft letters, then publish_journey once approved.`;
|
|
1367
|
+
return {
|
|
1368
|
+
content: [
|
|
1369
|
+
{
|
|
1370
|
+
type: "text",
|
|
1371
|
+
text: [
|
|
1372
|
+
`${APEX} Created funnel-wired draft journey "${j.name}" (id: ${j.id}).`,
|
|
1373
|
+
`• Starts when: someone reaches ${g.from.label} (from now on; past history stays out)`,
|
|
1374
|
+
`• Goal: ${g.to.label}`,
|
|
1375
|
+
`• Auto-exits on: ${exits || g.to.label}`,
|
|
1376
|
+
structureLine,
|
|
1377
|
+
`Open on the visual canvas: ${journeyLink(j.id)}`,
|
|
1378
|
+
nextLine,
|
|
1379
|
+
].join("\n"),
|
|
1380
|
+
},
|
|
1381
|
+
],
|
|
1382
|
+
};
|
|
1383
|
+
}
|
|
1384
|
+
catch (err) {
|
|
1385
|
+
return { content: [{ type: "text", text: `${APEX} ${errMsg(err)}` }], isError: true };
|
|
1386
|
+
}
|
|
1387
|
+
},
|
|
1388
|
+
},
|
|
1389
|
+
sync_journey_funnel_exits: {
|
|
1390
|
+
description: `${APEX} — Sync newly added downstream funnel stages or off-ramps into a funnel-gap journey's draft auto-exits. Safe for live journeys: updates the draft only and tells you if publish_journey is needed to roll the new exits live.`,
|
|
1391
|
+
schema: z.object({
|
|
1392
|
+
journeyId: z.string().describe("Journey id to sync funnel auto-exits for."),
|
|
1393
|
+
}),
|
|
1394
|
+
handler: async ({ journeyId }) => {
|
|
1395
|
+
try {
|
|
1396
|
+
const res = await apiPost(`/api/journeys/${encodeURIComponent(journeyId)}/sync-funnel-exits`, {});
|
|
1397
|
+
const j = res.data?.journey;
|
|
1398
|
+
if (!j) {
|
|
1399
|
+
return { content: [{ type: "text", text: `${APEX} Unexpected empty response syncing funnel auto-exits.` }], isError: true };
|
|
1400
|
+
}
|
|
1401
|
+
if (!tenantOk(j.workspaceKey ?? res.metadata?.workspace_key))
|
|
1402
|
+
return tenantMismatch();
|
|
1403
|
+
const added = res.data?.added ?? [];
|
|
1404
|
+
if (added.length === 0) {
|
|
1405
|
+
return {
|
|
1406
|
+
content: [
|
|
1407
|
+
{
|
|
1408
|
+
type: "text",
|
|
1409
|
+
text: `${APEX} "${j.name}" (${j.id}) is already in sync with the workspace's current funnel stages and off-ramps.`,
|
|
1410
|
+
},
|
|
1411
|
+
],
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
const names = added.map((a) => a.label).join(", ");
|
|
1415
|
+
const publishNote = res.data?.needsPublish
|
|
1416
|
+
? `This journey is live — call publish_journey("${j.id}") to roll the new auto-exits out to active enrollments.`
|
|
1417
|
+
: `Saved to draft. Publish when ready.`;
|
|
1418
|
+
return {
|
|
1419
|
+
content: [
|
|
1420
|
+
{
|
|
1421
|
+
type: "text",
|
|
1422
|
+
text: [
|
|
1423
|
+
`${APEX} Added ${added.length} missing funnel auto-${added.length === 1 ? "exit" : "exits"} to "${j.name}" (${j.id}): ${names}.`,
|
|
1424
|
+
publishNote,
|
|
1425
|
+
`Open on the visual canvas: ${journeyLink(j.id)}`,
|
|
1426
|
+
].join("\n"),
|
|
1427
|
+
},
|
|
1428
|
+
],
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
catch (err) {
|
|
1432
|
+
return { content: [{ type: "text", text: `${APEX} ${errMsg(err)}` }], isError: true };
|
|
1433
|
+
}
|
|
1434
|
+
},
|
|
1435
|
+
},
|
|
1436
|
+
fill_funnel_gaps: {
|
|
1437
|
+
description: `${APEX} — Create one draft Adaptive Journey for every uncovered gap in the workspace's Key Event funnel (or pass gap_ids to fill specific gaps). Uses the top matching Journey Template when available, falling back to a multi-touch starter sequence, and wires start trigger, goal, and automatic exits for each gap. Drafts only — never auto-publishes.`,
|
|
1438
|
+
schema: z.object({
|
|
1439
|
+
gapIds: z
|
|
1440
|
+
.array(z.string())
|
|
1441
|
+
.optional()
|
|
1442
|
+
.describe("Optional list of gap ids from get_journey_funnel_coverage to fill. Omit to fill every uncovered gap."),
|
|
1443
|
+
audienceBucket: z
|
|
1444
|
+
.enum(["production", "beta", "dev"])
|
|
1445
|
+
.optional()
|
|
1446
|
+
.describe("Audience bucket for the new drafts. Defaults to production."),
|
|
1447
|
+
}),
|
|
1448
|
+
handler: async ({ gapIds, audienceBucket, }) => {
|
|
1449
|
+
try {
|
|
1450
|
+
const res = await apiPost("/api/journeys/fill-funnel-gaps", {
|
|
1451
|
+
...(gapIds !== undefined ? { gapIds } : {}),
|
|
1452
|
+
...(audienceBucket !== undefined ? { audienceBucket } : {}),
|
|
1453
|
+
});
|
|
1454
|
+
if (!tenantOk(res.metadata?.workspace_key))
|
|
1455
|
+
return tenantMismatch();
|
|
1456
|
+
const created = res.data?.created ?? [];
|
|
1457
|
+
const skipped = res.data?.skipped ?? [];
|
|
1458
|
+
if (created.length === 0) {
|
|
1459
|
+
return {
|
|
1460
|
+
content: [
|
|
1461
|
+
{
|
|
1462
|
+
type: "text",
|
|
1463
|
+
text: `${APEX} No new journeys created — every requested funnel gap is already covered (${skipped.length} skipped).`,
|
|
1464
|
+
},
|
|
1465
|
+
],
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
const lines = created.map((c) => {
|
|
1469
|
+
const source = c.mode === "template" && c.templateId
|
|
1470
|
+
? `template "${c.templateId}"`
|
|
1471
|
+
: "starter sequence";
|
|
1472
|
+
return ` • ${c.fromLabel} → ${c.toLabel}: "${c.journeyName}" (id: ${c.journeyId}, ${source}, ${c.commsCreated} draft ${c.commsCreated === 1 ? "email" : "emails"}) — ${journeyLink(c.journeyId)}`;
|
|
1473
|
+
});
|
|
1474
|
+
return {
|
|
1475
|
+
content: [
|
|
1476
|
+
{
|
|
1477
|
+
type: "text",
|
|
1478
|
+
text: [
|
|
1479
|
+
`${APEX} Created ${created.length} draft ${created.length === 1 ? "journey" : "journeys"} wired to your funnel (${res.data?.totalCommsCreated ?? 0} draft emails scaffolded).`,
|
|
1480
|
+
...lines,
|
|
1481
|
+
skipped.length > 0 ? `Skipped ${skipped.length} already-covered or unavailable gap(s).` : "",
|
|
1482
|
+
`Review each draft and call publish_journey once approved.`,
|
|
1483
|
+
]
|
|
1484
|
+
.filter(Boolean)
|
|
1485
|
+
.join("\n"),
|
|
1486
|
+
},
|
|
1487
|
+
],
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1490
|
+
catch (err) {
|
|
1491
|
+
return { content: [{ type: "text", text: `${APEX} ${errMsg(err)}` }], isError: true };
|
|
1492
|
+
}
|
|
1493
|
+
},
|
|
1494
|
+
},
|
|
1122
1495
|
list_trigger_contracts: {
|
|
1123
1496
|
description: `${APEX} — List the workspace's trigger contracts (the event bindings you pass to set_journey_trigger / add_journey_exit). Returns each contract's id + the event it fires on. Call this before set_journey_trigger so you use a real id instead of guessing.`,
|
|
1124
1497
|
schema: z.object({}),
|
|
@@ -1402,7 +1775,7 @@ export const letterTools = {
|
|
|
1402
1775
|
scope: z.enum(["person", "account"]).optional().describe("key event only: account = their company reached it."),
|
|
1403
1776
|
field_path: z.string().optional().describe("attribute only: dotted path, e.g. 'cart.valueCents' or 'plan'."),
|
|
1404
1777
|
operator: z
|
|
1405
|
-
.enum(["equals", "not_equals", "greater_than", "less_than", "in", "exists", "not_exists"])
|
|
1778
|
+
.enum(["equals", "not_equals", "contains", "greater_than", "less_than", "in", "exists", "not_exists"])
|
|
1406
1779
|
.optional()
|
|
1407
1780
|
.describe("attribute only."),
|
|
1408
1781
|
value: z
|
|
@@ -1734,7 +2107,7 @@ export const letterTools = {
|
|
|
1734
2107
|
}
|
|
1735
2108
|
if (!tenantOk(comm.workspaceKey))
|
|
1736
2109
|
return tenantMismatch();
|
|
1737
|
-
return { content: [{ type: "text", text: `${APEX} Created draft communication "${comm.title}" (id: ${comm.id}). Open it in the browser: ${appUrl(`/dashboard/communications/${comm.id}`)}\nEdit it
|
|
2110
|
+
return { content: [{ type: "text", text: `${APEX} Created draft communication "${comm.title}" (id: ${comm.id}). Open it in the browser: ${appUrl(`/dashboard/communications/${comm.id}`)}\nEdit it with edit_communication, publish it with publish_communication, then reference it from a journey send step.` }] };
|
|
1738
2111
|
}
|
|
1739
2112
|
catch (err) {
|
|
1740
2113
|
return { content: [{ type: "text", text: `${APEX} ${errMsg(err)}` }], isError: true };
|
|
@@ -1995,28 +2368,12 @@ export const letterTools = {
|
|
|
1995
2368
|
},
|
|
1996
2369
|
},
|
|
1997
2370
|
create_segment: {
|
|
1998
|
-
description: `${APEX} — Create a segment from friendly "conditions" (compiled server-side) OR a raw predicate. Conditions grammar: match all|any of groups; each group match all|any of conditions; each condition is an event ({verb:"has"|"hasnt", event, window_days?}), a key event ({verb:"has"|"hasnt", key_event_id, window_days?, scope?:"person"|"account"}; ids from list_key_events; window_days bounds the first time it was reached; scope "account" means their company reached it), or a trait ({attribute, op:"is"|"is_not"|"exists", value?}). Prefer a key event over the raw events behind it: it is what Attribution counts, conditions included. This is the same grammar the dashboard chip builder speaks.`,
|
|
2371
|
+
description: `${APEX} — Create a segment from friendly "conditions" (compiled server-side) OR a raw predicate. Conditions grammar: match all|any of groups; each group match all|any of conditions; each condition is an event ({verb:"has"|"hasnt", event, where?: [{field_path, operator:"equals"|"not_equals"|"in"|"exists"|"not_exists", value?}], at_least?, window_days?}), a key event ({verb:"has"|"hasnt", key_event_id, window_days?, scope?:"person"|"account"}; ids from list_key_events; window_days bounds the first time it was reached; scope "account" means their company reached it), a campaign source ({brought_by_campaign: "<campaign_id>"} — matches people brought by that Apex Campaign; journeys starting from this segment show up under the campaign's Followed up stage), or a trait ({attribute, op:"is"|"is_not"|"exists", value?}). Prefer a key event over the raw events behind it: it is what Attribution counts, conditions included. Use where on an event condition when filtering on specific event properties (e.g. page_view where ft_source_group equals ai_assistant). This is the same grammar the dashboard chip builder speaks.`,
|
|
1999
2372
|
schema: z.object({
|
|
2000
2373
|
name: z.string().describe("Segment name"),
|
|
2001
2374
|
description: z.string().optional(),
|
|
2002
2375
|
scope: z.enum(["workspace", "org"]).optional().describe("Defaults to workspace"),
|
|
2003
|
-
conditions:
|
|
2004
|
-
.object({
|
|
2005
|
-
match: z.enum(["all", "any"]),
|
|
2006
|
-
groups: z.array(z.object({
|
|
2007
|
-
match: z.enum(["all", "any"]),
|
|
2008
|
-
conditions: z.array(z.object({
|
|
2009
|
-
verb: z.enum(["has", "hasnt"]).optional(),
|
|
2010
|
-
event: z.string().optional(),
|
|
2011
|
-
key_event_id: z.string().optional(),
|
|
2012
|
-
scope: z.enum(["person", "account"]).optional(),
|
|
2013
|
-
window_days: z.number().optional(),
|
|
2014
|
-
attribute: z.string().optional(),
|
|
2015
|
-
op: z.enum(["is", "is_not", "exists"]).optional(),
|
|
2016
|
-
value: z.union([z.string(), z.number(), z.boolean()]).optional(),
|
|
2017
|
-
})),
|
|
2018
|
-
})),
|
|
2019
|
-
})
|
|
2376
|
+
conditions: segmentConditionsSchema
|
|
2020
2377
|
.optional()
|
|
2021
2378
|
.describe("Friendly conditions (preferred). Sub-keys are snake_case."),
|
|
2022
2379
|
predicate: z.record(z.string(), z.unknown()).optional().describe("Raw SegmentPredicate escape hatch"),
|
|
@@ -2039,29 +2396,13 @@ export const letterTools = {
|
|
|
2039
2396
|
},
|
|
2040
2397
|
},
|
|
2041
2398
|
update_segment: {
|
|
2042
|
-
description: `${APEX} — Update an existing custom segment's name, description, friendly conditions, or raw predicate. Starter segments are read-only (clone them with create_segment instead). Same conditions grammar as create_segment.`,
|
|
2399
|
+
description: `${APEX} — Update an existing custom segment's name, description, friendly conditions, or raw predicate. Starter segments are read-only (clone them with create_segment instead). Same conditions grammar as create_segment (including event property where filters).`,
|
|
2043
2400
|
schema: z.object({
|
|
2044
2401
|
segmentId: z.string().min(1).describe("Segment ID from list_segments or create_segment."),
|
|
2045
2402
|
scope: z.enum(["workspace", "org"]).optional().describe("Segment scope (default workspace)."),
|
|
2046
2403
|
name: z.string().min(1).optional().describe("New segment name."),
|
|
2047
2404
|
description: z.string().optional().describe("New segment description."),
|
|
2048
|
-
conditions:
|
|
2049
|
-
.object({
|
|
2050
|
-
match: z.enum(["all", "any"]),
|
|
2051
|
-
groups: z.array(z.object({
|
|
2052
|
-
match: z.enum(["all", "any"]),
|
|
2053
|
-
conditions: z.array(z.object({
|
|
2054
|
-
verb: z.enum(["has", "hasnt"]).optional(),
|
|
2055
|
-
event: z.string().optional(),
|
|
2056
|
-
key_event_id: z.string().optional(),
|
|
2057
|
-
scope: z.enum(["person", "account"]).optional(),
|
|
2058
|
-
window_days: z.number().optional(),
|
|
2059
|
-
attribute: z.string().optional(),
|
|
2060
|
-
op: z.enum(["is", "is_not", "exists"]).optional(),
|
|
2061
|
-
value: z.union([z.string(), z.number(), z.boolean()]).optional(),
|
|
2062
|
-
})),
|
|
2063
|
-
})),
|
|
2064
|
-
})
|
|
2405
|
+
conditions: segmentConditionsSchema
|
|
2065
2406
|
.optional()
|
|
2066
2407
|
.describe("Replacement friendly conditions (compiled server-side). Sub-keys are snake_case."),
|
|
2067
2408
|
predicate: z.record(z.string(), z.unknown()).optional().describe("Replacement raw SegmentPredicate."),
|