@apex-inc/mcp-server 0.75.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.
Files changed (78) hide show
  1. package/dist/api-client.d.ts +13 -19
  2. package/dist/api-client.d.ts.map +1 -1
  3. package/dist/api-client.js +173 -59
  4. package/dist/api-client.js.map +1 -1
  5. package/dist/auth.d.ts.map +1 -1
  6. package/dist/auth.js +7 -6
  7. package/dist/auth.js.map +1 -1
  8. package/dist/fetch-timeout.d.ts +23 -0
  9. package/dist/fetch-timeout.d.ts.map +1 -0
  10. package/dist/fetch-timeout.js +78 -0
  11. package/dist/fetch-timeout.js.map +1 -0
  12. package/dist/hosted.d.ts +28 -0
  13. package/dist/hosted.d.ts.map +1 -0
  14. package/dist/hosted.js +56 -0
  15. package/dist/hosted.js.map +1 -0
  16. package/dist/index.js +40 -118
  17. package/dist/index.js.map +1 -1
  18. package/dist/live-test-files.d.ts +35 -0
  19. package/dist/live-test-files.d.ts.map +1 -0
  20. package/dist/live-test-files.js +114 -0
  21. package/dist/live-test-files.js.map +1 -0
  22. package/dist/live-test-guard.d.ts.map +1 -1
  23. package/dist/live-test-guard.js +7 -1
  24. package/dist/live-test-guard.js.map +1 -1
  25. package/dist/request-context.d.ts +38 -0
  26. package/dist/request-context.d.ts.map +1 -0
  27. package/dist/request-context.js +11 -0
  28. package/dist/request-context.js.map +1 -0
  29. package/dist/server-factory.d.ts +18 -0
  30. package/dist/server-factory.d.ts.map +1 -0
  31. package/dist/server-factory.js +221 -0
  32. package/dist/server-factory.js.map +1 -0
  33. package/dist/setup-catchup-tools.d.ts +4 -0
  34. package/dist/setup-catchup-tools.d.ts.map +1 -1
  35. package/dist/setup-catchup-tools.js +16 -5
  36. package/dist/setup-catchup-tools.js.map +1 -1
  37. package/dist/smoke-tools.d.ts.map +1 -1
  38. package/dist/smoke-tools.js +2 -0
  39. package/dist/smoke-tools.js.map +1 -1
  40. package/dist/tool-catalog.d.ts +2 -0
  41. package/dist/tool-catalog.d.ts.map +1 -1
  42. package/dist/tool-catalog.js +6 -1
  43. package/dist/tool-catalog.js.map +1 -1
  44. package/dist/tool-groups.d.ts.map +1 -1
  45. package/dist/tool-groups.js +12 -0
  46. package/dist/tool-groups.js.map +1 -1
  47. package/dist/tool-shared.d.ts +2 -1
  48. package/dist/tool-shared.d.ts.map +1 -1
  49. package/dist/tool-shared.js +17 -2
  50. package/dist/tool-shared.js.map +1 -1
  51. package/dist/tools/adoption.d.ts.map +1 -1
  52. package/dist/tools/adoption.js +2 -1
  53. package/dist/tools/adoption.js.map +1 -1
  54. package/dist/tools/apex-campaigns.d.ts +390 -0
  55. package/dist/tools/apex-campaigns.d.ts.map +1 -1
  56. package/dist/tools/apex-campaigns.js +253 -1
  57. package/dist/tools/apex-campaigns.js.map +1 -1
  58. package/dist/tools/context.d.ts +2 -2
  59. package/dist/tools/experiments.d.ts +69 -1
  60. package/dist/tools/experiments.d.ts.map +1 -1
  61. package/dist/tools/experiments.js +88 -24
  62. package/dist/tools/experiments.js.map +1 -1
  63. package/dist/tools/letters.d.ts +214 -48
  64. package/dist/tools/letters.d.ts.map +1 -1
  65. package/dist/tools/letters.js +233 -16
  66. package/dist/tools/letters.js.map +1 -1
  67. package/dist/tools/measurement.d.ts +70 -28
  68. package/dist/tools/measurement.d.ts.map +1 -1
  69. package/dist/tools/measurement.js +151 -13
  70. package/dist/tools/measurement.js.map +1 -1
  71. package/dist/tools.d.ts +770 -76
  72. package/dist/tools.d.ts.map +1 -1
  73. package/package.json +11 -1
  74. package/skills/apex-growth-intelligence/SKILL.md +4 -0
  75. package/skills/apex-growth-tracking/SKILL.md +1 -1
  76. package/skills/apex-integration-cookbook/SKILL.md +23 -3
  77. package/skills/apex-setup/SKILL.md +1 -1
  78. 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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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"}
@@ -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";
@@ -38,7 +39,7 @@ function everyoneInSegmentLine(c) {
38
39
  const segmentEventWhereSchema = z
39
40
  .array(z.object({
40
41
  field_path: z.string().min(1).describe("Event property path (dot notation for nested keys, e.g. ft_source_group or plan.tier)."),
41
- operator: z.enum(["equals", "not_equals", "in", "exists", "not_exists"]),
42
+ operator: z.enum(["equals", "not_equals", "in", "contains", "gt", "gte", "lt", "lte", "exists", "not_exists"]),
42
43
  value: z
43
44
  .union([
44
45
  z.string(),
@@ -47,7 +48,7 @@ const segmentEventWhereSchema = z
47
48
  z.array(z.union([z.string(), z.number(), z.boolean()])),
48
49
  ])
49
50
  .optional()
50
- .describe("Value to match (omit for exists/not_exists; array for in)."),
51
+ .describe("Value to match (omit for exists/not_exists; array for in; number for gt/gte/lt/lte)."),
51
52
  }))
52
53
  .max(10)
53
54
  .optional()
@@ -65,8 +66,12 @@ const segmentConditionsSchema = z.object({
65
66
  scope: z.enum(["person", "account"]).optional(),
66
67
  window_days: z.number().optional(),
67
68
  attribute: z.string().optional(),
68
- op: z.enum(["is", "is_not", "exists"]).optional(),
69
+ op: z.enum(["is", "is_not", "contains", "exists"]).optional(),
69
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 })."),
70
75
  })),
71
76
  })),
72
77
  });
@@ -85,7 +90,7 @@ export const letterTools = {
85
90
  catalogEntryIds: z.array(z.string()).describe("IDs from the recommendation output to generate"),
86
91
  }),
87
92
  handler: async (args) => {
88
- 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 });
89
94
  const count = Array.isArray(data) ? data.length : 0;
90
95
  return { content: [{ type: "text", text: `Generated ${count} communication(s).\n\n${JSON.stringify(data, null, 2)}` }] };
91
96
  },
@@ -127,6 +132,7 @@ export const letterTools = {
127
132
  title: String(comm.title ?? "Untitled"),
128
133
  version: typeof comm.version === "number" ? comm.version : 1,
129
134
  status: String(comm.status ?? "draft"),
135
+ has_unpublished_changes: Boolean(comm.draftContent),
130
136
  pipeline: commType === "transactional"
131
137
  ? "transactional"
132
138
  : "marketing",
@@ -418,9 +424,10 @@ export const letterTools = {
418
424
  },
419
425
  },
420
426
  edit_communication: {
421
- 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.",
422
428
  schema: z.object({
423
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)."),
424
431
  subject: z.string().optional().describe("New email subject line"),
425
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."),
426
433
  blocks: z
@@ -433,7 +440,10 @@ export const letterTools = {
433
440
  .optional()
434
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.'),
435
442
  replyTo: z.string().optional().describe('Where replies to the email go. "" clears it.'),
436
- status: z.enum(["draft", "active", "paused"]).optional().describe("Communication status"),
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.'),
437
447
  audience_bucket: z
438
448
  .enum(["production", "beta", "dev"])
439
449
  .optional()
@@ -461,6 +471,8 @@ export const letterTools = {
461
471
  return { content: [{ type: "text", text: guard.text }] };
462
472
  }
463
473
  const body = {};
474
+ if (args.title !== undefined)
475
+ body.title = args.title.trim();
464
476
  if (args.status)
465
477
  body.status = args.status;
466
478
  if (args.channels)
@@ -705,6 +717,7 @@ export const letterTools = {
705
717
  id: comm.id,
706
718
  title: comm.title,
707
719
  status: comm.status,
720
+ has_unpublished_changes: Boolean(comm.draftContent),
708
721
  ...(comm.kind ? { kind: comm.kind } : {}),
709
722
  channels: comm.channels,
710
723
  pipeline: comm.pipeline,
@@ -1132,6 +1145,64 @@ export const letterTools = {
1132
1145
  }
1133
1146
  },
1134
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
+ },
1135
1206
  create_journey_from_template: {
1136
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.`,
1137
1208
  schema: z.object({ templateId: z.string().describe("Template id from get_wiring_status (e.g. 'mobile-cart-recovery').") }),
@@ -1155,7 +1226,7 @@ export const letterTools = {
1155
1226
  },
1156
1227
  },
1157
1228
  get_journey_funnel_coverage: {
1158
- description: `${APEX} — Read the workspace's funnel stages, stage-to-stage progress (default last 30 days), and which funnel gaps (e.g. Sign-up → Activation, Churned → Reactivated) have live journeys, draft journeys, or no journey yet. Call this before create_journey_from_funnel_gap to get exact from_key_event_id and to_key_event_id values.`,
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.`,
1159
1230
  schema: z.object({
1160
1231
  days: z
1161
1232
  .number()
@@ -1185,6 +1256,9 @@ export const letterTools = {
1185
1256
  const stageLine = d.stages
1186
1257
  .map((s) => `${s.label} (${s.reachedWindow} in ${d.windowDays}d)`)
1187
1258
  .join(" → ");
1259
+ const driftSummary = (d.summary.journeysWithExitDrift ?? 0) > 0
1260
+ ? `, ${d.summary.journeysWithExitDrift} needing exit sync`
1261
+ : "";
1188
1262
  const gapLines = d.gaps.map((g) => {
1189
1263
  const status = g.coverageStatus === "live"
1190
1264
  ? `LIVE (${g.journeys.map((j) => `"${j.name}" [${j.id}]`).join(", ")})`
@@ -1194,19 +1268,34 @@ export const letterTools = {
1194
1268
  const prog = g.progress.enteredWindow > 0 && g.progress.progressRateWindow !== null
1195
1269
  ? `${Math.round(g.progress.progressRateWindow * 100)}% (${g.progress.progressedWindow}/${g.progress.enteredWindow}, ${g.progress.stillInGapWindow} waiting)`
1196
1270
  : `no activity in last ${d.windowDays}d`;
1197
- return ` • ${g.kind === "winback" ? "[Win-back] " : ""}${g.from.label} → ${g.to.label} | ${status} | ${prog}\n from_key_event_id: "${g.from.keyEventId}", to_key_event_id: "${g.to.keyEventId}"`;
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");
1198
1287
  });
1199
1288
  return {
1200
1289
  content: [
1201
1290
  {
1202
1291
  type: "text",
1203
1292
  text: [
1204
- `${APEX} Funnel coverage (last ${d.windowDays}d): ${d.summary.liveCovered}/${d.summary.totalGaps} live, ${d.summary.draftOnly} draft, ${d.summary.uncovered} uncovered`,
1293
+ `${APEX} Funnel coverage (last ${d.windowDays}d): ${d.summary.liveCovered}/${d.summary.totalGaps} live, ${d.summary.draftOnly} draft, ${d.summary.uncovered} uncovered${driftSummary}`,
1205
1294
  `Stages: ${stageLine}`,
1206
1295
  ``,
1207
1296
  ...gapLines,
1208
1297
  ``,
1209
- `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.`,
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").`,
1210
1299
  ].join("\n"),
1211
1300
  },
1212
1301
  ],
@@ -1218,10 +1307,18 @@ export const letterTools = {
1218
1307
  },
1219
1308
  },
1220
1309
  create_journey_from_funnel_gap: {
1221
- 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. Call get_journey_funnel_coverage first to see the workspace's gaps and key event ids.`,
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.`,
1222
1311
  schema: z.object({
1223
1312
  fromKeyEventId: z.string().describe("Starting funnel stage key event id (from get_journey_funnel_coverage)."),
1224
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\")."),
1225
1322
  name: z.string().optional().describe("Optional journey name (defaults to '<From> → <To>')."),
1226
1323
  description: z.string().optional().describe("Optional journey description."),
1227
1324
  attributionWindowDays: z
@@ -1236,11 +1333,13 @@ export const letterTools = {
1236
1333
  .optional()
1237
1334
  .describe("Who this journey enrolls. Default production."),
1238
1335
  }),
1239
- handler: async ({ fromKeyEventId, toKeyEventId, name, description, attributionWindowDays, audienceBucket, }) => {
1336
+ handler: async ({ fromKeyEventId, toKeyEventId, mode, templateId, name, description, attributionWindowDays, audienceBucket, }) => {
1240
1337
  try {
1241
1338
  const res = await apiPost("/api/journeys/from-funnel-gap", {
1242
1339
  fromKeyEventId,
1243
1340
  toKeyEventId,
1341
+ ...(mode !== undefined ? { mode } : {}),
1342
+ ...(templateId !== undefined ? { templateId } : {}),
1244
1343
  ...(name !== undefined ? { name } : {}),
1245
1344
  ...(description !== undefined ? { description } : {}),
1246
1345
  ...(attributionWindowDays !== undefined ? { attributionWindowDays } : {}),
@@ -1254,6 +1353,17 @@ export const letterTools = {
1254
1353
  if (!tenantOk(j.workspaceKey ?? res.metadata?.workspace_key))
1255
1354
  return tenantMismatch();
1256
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.`;
1257
1367
  return {
1258
1368
  content: [
1259
1369
  {
@@ -1263,8 +1373,9 @@ export const letterTools = {
1263
1373
  `• Starts when: someone reaches ${g.from.label} (from now on; past history stays out)`,
1264
1374
  `• Goal: ${g.to.label}`,
1265
1375
  `• Auto-exits on: ${exits || g.to.label}`,
1376
+ structureLine,
1266
1377
  `Open on the visual canvas: ${journeyLink(j.id)}`,
1267
- `Next: add_journey_step to drop in waits and letters, then publish_journey once approved.`,
1378
+ nextLine,
1268
1379
  ].join("\n"),
1269
1380
  },
1270
1381
  ],
@@ -1275,6 +1386,112 @@ export const letterTools = {
1275
1386
  }
1276
1387
  },
1277
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
+ },
1278
1495
  list_trigger_contracts: {
1279
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.`,
1280
1497
  schema: z.object({}),
@@ -1558,7 +1775,7 @@ export const letterTools = {
1558
1775
  scope: z.enum(["person", "account"]).optional().describe("key event only: account = their company reached it."),
1559
1776
  field_path: z.string().optional().describe("attribute only: dotted path, e.g. 'cart.valueCents' or 'plan'."),
1560
1777
  operator: z
1561
- .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"])
1562
1779
  .optional()
1563
1780
  .describe("attribute only."),
1564
1781
  value: z
@@ -1890,7 +2107,7 @@ export const letterTools = {
1890
2107
  }
1891
2108
  if (!tenantOk(comm.workspaceKey))
1892
2109
  return tenantMismatch();
1893
- 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 (or edit_communication), then reference it from a journey send step.` }] };
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.` }] };
1894
2111
  }
1895
2112
  catch (err) {
1896
2113
  return { content: [{ type: "text", text: `${APEX} ${errMsg(err)}` }], isError: true };
@@ -2151,7 +2368,7 @@ export const letterTools = {
2151
2368
  },
2152
2369
  },
2153
2370
  create_segment: {
2154
- 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), 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.`,
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.`,
2155
2372
  schema: z.object({
2156
2373
  name: z.string().describe("Segment name"),
2157
2374
  description: z.string().optional(),