@apex-inc/mcp-server 0.60.0 → 0.61.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/tool-groups.d.ts.map +1 -1
- package/dist/tool-groups.js +6 -0
- package/dist/tool-groups.js.map +1 -1
- package/dist/tools/ad-platforms.d.ts +4 -4
- package/dist/tools/letters.d.ts +92 -11
- package/dist/tools/letters.d.ts.map +1 -1
- package/dist/tools/letters.js +96 -10
- package/dist/tools/letters.js.map +1 -1
- package/dist/tools/measurement.d.ts +318 -2
- package/dist/tools/measurement.d.ts.map +1 -1
- package/dist/tools/measurement.js +172 -10
- package/dist/tools/measurement.js.map +1 -1
- package/dist/tools.d.ts +407 -19
- package/dist/tools.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/apex-experimentation/SKILL.md +1 -1
- package/skills/apex-growth-tracking/SKILL.md +1 -1
- package/skills/apex-integration-cookbook/SKILL.md +25 -2
- package/skills/apex-journeys/SKILL.md +3 -1
- package/skills/apex-spec/SKILL.md +7 -0
|
@@ -1,4 +1,44 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
declare const keyEventSourceSchema: z.ZodObject<{
|
|
3
|
+
type: z.ZodEnum<["custom_event", "form_submit"]>;
|
|
4
|
+
event_name: z.ZodOptional<z.ZodString>;
|
|
5
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
6
|
+
target_url: z.ZodOptional<z.ZodString>;
|
|
7
|
+
where: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
8
|
+
field_path: z.ZodString;
|
|
9
|
+
operator: z.ZodEnum<["equals", "not_equals", "in", "exists", "not_exists"]>;
|
|
10
|
+
value: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
operator: "equals" | "not_equals" | "exists" | "in" | "not_exists";
|
|
13
|
+
field_path: string;
|
|
14
|
+
value?: string | number | boolean | (string | number | boolean)[] | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
operator: "equals" | "not_equals" | "exists" | "in" | "not_exists";
|
|
17
|
+
field_path: string;
|
|
18
|
+
value?: string | number | boolean | (string | number | boolean)[] | undefined;
|
|
19
|
+
}>, "many">>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
type: "form_submit" | "custom_event";
|
|
22
|
+
event_name?: string | undefined;
|
|
23
|
+
selector?: string | undefined;
|
|
24
|
+
target_url?: string | undefined;
|
|
25
|
+
where?: {
|
|
26
|
+
operator: "equals" | "not_equals" | "exists" | "in" | "not_exists";
|
|
27
|
+
field_path: string;
|
|
28
|
+
value?: string | number | boolean | (string | number | boolean)[] | undefined;
|
|
29
|
+
}[] | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
type: "form_submit" | "custom_event";
|
|
32
|
+
event_name?: string | undefined;
|
|
33
|
+
selector?: string | undefined;
|
|
34
|
+
target_url?: string | undefined;
|
|
35
|
+
where?: {
|
|
36
|
+
operator: "equals" | "not_equals" | "exists" | "in" | "not_exists";
|
|
37
|
+
field_path: string;
|
|
38
|
+
value?: string | number | boolean | (string | number | boolean)[] | undefined;
|
|
39
|
+
}[] | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
type KeyEventSourceArg = z.infer<typeof keyEventSourceSchema>;
|
|
2
42
|
export declare const measurementTools: {
|
|
3
43
|
list_events: {
|
|
4
44
|
description: string;
|
|
@@ -172,6 +212,281 @@ export declare const measurementTools: {
|
|
|
172
212
|
}[];
|
|
173
213
|
}>;
|
|
174
214
|
};
|
|
215
|
+
get_key_event: {
|
|
216
|
+
description: string;
|
|
217
|
+
schema: z.ZodObject<{
|
|
218
|
+
keyEventId: z.ZodString;
|
|
219
|
+
}, "strip", z.ZodTypeAny, {
|
|
220
|
+
keyEventId: string;
|
|
221
|
+
}, {
|
|
222
|
+
keyEventId: string;
|
|
223
|
+
}>;
|
|
224
|
+
handler: ({ keyEventId }: {
|
|
225
|
+
keyEventId: string;
|
|
226
|
+
}) => Promise<{
|
|
227
|
+
isError?: boolean | undefined;
|
|
228
|
+
content: {
|
|
229
|
+
type: "text";
|
|
230
|
+
text: string;
|
|
231
|
+
}[];
|
|
232
|
+
}>;
|
|
233
|
+
};
|
|
234
|
+
create_key_event: {
|
|
235
|
+
description: string;
|
|
236
|
+
schema: z.ZodObject<{
|
|
237
|
+
name: z.ZodString;
|
|
238
|
+
sources: z.ZodArray<z.ZodObject<{
|
|
239
|
+
type: z.ZodEnum<["custom_event", "form_submit"]>;
|
|
240
|
+
event_name: z.ZodOptional<z.ZodString>;
|
|
241
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
242
|
+
target_url: z.ZodOptional<z.ZodString>;
|
|
243
|
+
where: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
244
|
+
field_path: z.ZodString;
|
|
245
|
+
operator: z.ZodEnum<["equals", "not_equals", "in", "exists", "not_exists"]>;
|
|
246
|
+
value: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>;
|
|
247
|
+
}, "strip", z.ZodTypeAny, {
|
|
248
|
+
operator: "equals" | "not_equals" | "exists" | "in" | "not_exists";
|
|
249
|
+
field_path: string;
|
|
250
|
+
value?: string | number | boolean | (string | number | boolean)[] | undefined;
|
|
251
|
+
}, {
|
|
252
|
+
operator: "equals" | "not_equals" | "exists" | "in" | "not_exists";
|
|
253
|
+
field_path: string;
|
|
254
|
+
value?: string | number | boolean | (string | number | boolean)[] | undefined;
|
|
255
|
+
}>, "many">>;
|
|
256
|
+
}, "strip", z.ZodTypeAny, {
|
|
257
|
+
type: "form_submit" | "custom_event";
|
|
258
|
+
event_name?: string | undefined;
|
|
259
|
+
selector?: string | undefined;
|
|
260
|
+
target_url?: string | undefined;
|
|
261
|
+
where?: {
|
|
262
|
+
operator: "equals" | "not_equals" | "exists" | "in" | "not_exists";
|
|
263
|
+
field_path: string;
|
|
264
|
+
value?: string | number | boolean | (string | number | boolean)[] | undefined;
|
|
265
|
+
}[] | undefined;
|
|
266
|
+
}, {
|
|
267
|
+
type: "form_submit" | "custom_event";
|
|
268
|
+
event_name?: string | undefined;
|
|
269
|
+
selector?: string | undefined;
|
|
270
|
+
target_url?: string | undefined;
|
|
271
|
+
where?: {
|
|
272
|
+
operator: "equals" | "not_equals" | "exists" | "in" | "not_exists";
|
|
273
|
+
field_path: string;
|
|
274
|
+
value?: string | number | boolean | (string | number | boolean)[] | undefined;
|
|
275
|
+
}[] | undefined;
|
|
276
|
+
}>, "many">;
|
|
277
|
+
category: z.ZodOptional<z.ZodEnum<["purchase", "lead", "qualified_lead", "activation", "signup", "subscribe", "add_to_cart", "engagement", "other"]>>;
|
|
278
|
+
entityScope: z.ZodOptional<z.ZodEnum<["person", "account"]>>;
|
|
279
|
+
description: z.ZodOptional<z.ZodString>;
|
|
280
|
+
template: z.ZodOptional<z.ZodString>;
|
|
281
|
+
}, "strip", z.ZodTypeAny, {
|
|
282
|
+
name: string;
|
|
283
|
+
sources: {
|
|
284
|
+
type: "form_submit" | "custom_event";
|
|
285
|
+
event_name?: string | undefined;
|
|
286
|
+
selector?: string | undefined;
|
|
287
|
+
target_url?: string | undefined;
|
|
288
|
+
where?: {
|
|
289
|
+
operator: "equals" | "not_equals" | "exists" | "in" | "not_exists";
|
|
290
|
+
field_path: string;
|
|
291
|
+
value?: string | number | boolean | (string | number | boolean)[] | undefined;
|
|
292
|
+
}[] | undefined;
|
|
293
|
+
}[];
|
|
294
|
+
description?: string | undefined;
|
|
295
|
+
category?: "other" | "engagement" | "purchase" | "lead" | "qualified_lead" | "activation" | "signup" | "subscribe" | "add_to_cart" | undefined;
|
|
296
|
+
entityScope?: "account" | "person" | undefined;
|
|
297
|
+
template?: string | undefined;
|
|
298
|
+
}, {
|
|
299
|
+
name: string;
|
|
300
|
+
sources: {
|
|
301
|
+
type: "form_submit" | "custom_event";
|
|
302
|
+
event_name?: string | undefined;
|
|
303
|
+
selector?: string | undefined;
|
|
304
|
+
target_url?: string | undefined;
|
|
305
|
+
where?: {
|
|
306
|
+
operator: "equals" | "not_equals" | "exists" | "in" | "not_exists";
|
|
307
|
+
field_path: string;
|
|
308
|
+
value?: string | number | boolean | (string | number | boolean)[] | undefined;
|
|
309
|
+
}[] | undefined;
|
|
310
|
+
}[];
|
|
311
|
+
description?: string | undefined;
|
|
312
|
+
category?: "other" | "engagement" | "purchase" | "lead" | "qualified_lead" | "activation" | "signup" | "subscribe" | "add_to_cart" | undefined;
|
|
313
|
+
entityScope?: "account" | "person" | undefined;
|
|
314
|
+
template?: string | undefined;
|
|
315
|
+
}>;
|
|
316
|
+
handler: (args: {
|
|
317
|
+
name: string;
|
|
318
|
+
sources: KeyEventSourceArg[];
|
|
319
|
+
category?: string;
|
|
320
|
+
entityScope?: string;
|
|
321
|
+
description?: string;
|
|
322
|
+
template?: string;
|
|
323
|
+
}) => Promise<{
|
|
324
|
+
isError?: boolean | undefined;
|
|
325
|
+
content: {
|
|
326
|
+
type: "text";
|
|
327
|
+
text: string;
|
|
328
|
+
}[];
|
|
329
|
+
}>;
|
|
330
|
+
};
|
|
331
|
+
update_key_event: {
|
|
332
|
+
description: string;
|
|
333
|
+
schema: z.ZodObject<{
|
|
334
|
+
keyEventId: z.ZodString;
|
|
335
|
+
name: z.ZodOptional<z.ZodString>;
|
|
336
|
+
sources: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
337
|
+
type: z.ZodEnum<["custom_event", "form_submit"]>;
|
|
338
|
+
event_name: z.ZodOptional<z.ZodString>;
|
|
339
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
340
|
+
target_url: z.ZodOptional<z.ZodString>;
|
|
341
|
+
where: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
342
|
+
field_path: z.ZodString;
|
|
343
|
+
operator: z.ZodEnum<["equals", "not_equals", "in", "exists", "not_exists"]>;
|
|
344
|
+
value: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>;
|
|
345
|
+
}, "strip", z.ZodTypeAny, {
|
|
346
|
+
operator: "equals" | "not_equals" | "exists" | "in" | "not_exists";
|
|
347
|
+
field_path: string;
|
|
348
|
+
value?: string | number | boolean | (string | number | boolean)[] | undefined;
|
|
349
|
+
}, {
|
|
350
|
+
operator: "equals" | "not_equals" | "exists" | "in" | "not_exists";
|
|
351
|
+
field_path: string;
|
|
352
|
+
value?: string | number | boolean | (string | number | boolean)[] | undefined;
|
|
353
|
+
}>, "many">>;
|
|
354
|
+
}, "strip", z.ZodTypeAny, {
|
|
355
|
+
type: "form_submit" | "custom_event";
|
|
356
|
+
event_name?: string | undefined;
|
|
357
|
+
selector?: string | undefined;
|
|
358
|
+
target_url?: string | undefined;
|
|
359
|
+
where?: {
|
|
360
|
+
operator: "equals" | "not_equals" | "exists" | "in" | "not_exists";
|
|
361
|
+
field_path: string;
|
|
362
|
+
value?: string | number | boolean | (string | number | boolean)[] | undefined;
|
|
363
|
+
}[] | undefined;
|
|
364
|
+
}, {
|
|
365
|
+
type: "form_submit" | "custom_event";
|
|
366
|
+
event_name?: string | undefined;
|
|
367
|
+
selector?: string | undefined;
|
|
368
|
+
target_url?: string | undefined;
|
|
369
|
+
where?: {
|
|
370
|
+
operator: "equals" | "not_equals" | "exists" | "in" | "not_exists";
|
|
371
|
+
field_path: string;
|
|
372
|
+
value?: string | number | boolean | (string | number | boolean)[] | undefined;
|
|
373
|
+
}[] | undefined;
|
|
374
|
+
}>, "many">>;
|
|
375
|
+
category: z.ZodOptional<z.ZodEnum<["purchase", "lead", "qualified_lead", "activation", "signup", "subscribe", "add_to_cart", "engagement", "other"]>>;
|
|
376
|
+
entityScope: z.ZodOptional<z.ZodEnum<["person", "account"]>>;
|
|
377
|
+
description: z.ZodOptional<z.ZodString>;
|
|
378
|
+
isCurrentGoal: z.ZodOptional<z.ZodLiteral<true>>;
|
|
379
|
+
}, "strip", z.ZodTypeAny, {
|
|
380
|
+
keyEventId: string;
|
|
381
|
+
name?: string | undefined;
|
|
382
|
+
description?: string | undefined;
|
|
383
|
+
sources?: {
|
|
384
|
+
type: "form_submit" | "custom_event";
|
|
385
|
+
event_name?: string | undefined;
|
|
386
|
+
selector?: string | undefined;
|
|
387
|
+
target_url?: string | undefined;
|
|
388
|
+
where?: {
|
|
389
|
+
operator: "equals" | "not_equals" | "exists" | "in" | "not_exists";
|
|
390
|
+
field_path: string;
|
|
391
|
+
value?: string | number | boolean | (string | number | boolean)[] | undefined;
|
|
392
|
+
}[] | undefined;
|
|
393
|
+
}[] | undefined;
|
|
394
|
+
category?: "other" | "engagement" | "purchase" | "lead" | "qualified_lead" | "activation" | "signup" | "subscribe" | "add_to_cart" | undefined;
|
|
395
|
+
entityScope?: "account" | "person" | undefined;
|
|
396
|
+
isCurrentGoal?: true | undefined;
|
|
397
|
+
}, {
|
|
398
|
+
keyEventId: string;
|
|
399
|
+
name?: string | undefined;
|
|
400
|
+
description?: string | undefined;
|
|
401
|
+
sources?: {
|
|
402
|
+
type: "form_submit" | "custom_event";
|
|
403
|
+
event_name?: string | undefined;
|
|
404
|
+
selector?: string | undefined;
|
|
405
|
+
target_url?: string | undefined;
|
|
406
|
+
where?: {
|
|
407
|
+
operator: "equals" | "not_equals" | "exists" | "in" | "not_exists";
|
|
408
|
+
field_path: string;
|
|
409
|
+
value?: string | number | boolean | (string | number | boolean)[] | undefined;
|
|
410
|
+
}[] | undefined;
|
|
411
|
+
}[] | undefined;
|
|
412
|
+
category?: "other" | "engagement" | "purchase" | "lead" | "qualified_lead" | "activation" | "signup" | "subscribe" | "add_to_cart" | undefined;
|
|
413
|
+
entityScope?: "account" | "person" | undefined;
|
|
414
|
+
isCurrentGoal?: true | undefined;
|
|
415
|
+
}>;
|
|
416
|
+
handler: (args: {
|
|
417
|
+
keyEventId: string;
|
|
418
|
+
name?: string;
|
|
419
|
+
sources?: KeyEventSourceArg[];
|
|
420
|
+
category?: string;
|
|
421
|
+
entityScope?: string;
|
|
422
|
+
description?: string;
|
|
423
|
+
isCurrentGoal?: true;
|
|
424
|
+
}) => Promise<{
|
|
425
|
+
isError?: boolean | undefined;
|
|
426
|
+
content: {
|
|
427
|
+
type: "text";
|
|
428
|
+
text: string;
|
|
429
|
+
}[];
|
|
430
|
+
}>;
|
|
431
|
+
};
|
|
432
|
+
delete_key_event: {
|
|
433
|
+
description: string;
|
|
434
|
+
schema: z.ZodObject<{
|
|
435
|
+
keyEventId: z.ZodString;
|
|
436
|
+
}, "strip", z.ZodTypeAny, {
|
|
437
|
+
keyEventId: string;
|
|
438
|
+
}, {
|
|
439
|
+
keyEventId: string;
|
|
440
|
+
}>;
|
|
441
|
+
handler: ({ keyEventId }: {
|
|
442
|
+
keyEventId: string;
|
|
443
|
+
}) => Promise<{
|
|
444
|
+
isError?: boolean | undefined;
|
|
445
|
+
content: {
|
|
446
|
+
type: "text";
|
|
447
|
+
text: string;
|
|
448
|
+
}[];
|
|
449
|
+
}>;
|
|
450
|
+
};
|
|
451
|
+
get_key_event_reached: {
|
|
452
|
+
description: string;
|
|
453
|
+
schema: z.ZodObject<{
|
|
454
|
+
keyEventId: z.ZodString;
|
|
455
|
+
scope: z.ZodOptional<z.ZodEnum<["person", "account"]>>;
|
|
456
|
+
start: z.ZodOptional<z.ZodString>;
|
|
457
|
+
end: z.ZodOptional<z.ZodString>;
|
|
458
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
459
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
460
|
+
}, "strip", z.ZodTypeAny, {
|
|
461
|
+
keyEventId: string;
|
|
462
|
+
start?: string | undefined;
|
|
463
|
+
end?: string | undefined;
|
|
464
|
+
version?: number | undefined;
|
|
465
|
+
scope?: "account" | "person" | undefined;
|
|
466
|
+
limit?: number | undefined;
|
|
467
|
+
}, {
|
|
468
|
+
keyEventId: string;
|
|
469
|
+
start?: string | undefined;
|
|
470
|
+
end?: string | undefined;
|
|
471
|
+
version?: number | undefined;
|
|
472
|
+
scope?: "account" | "person" | undefined;
|
|
473
|
+
limit?: number | undefined;
|
|
474
|
+
}>;
|
|
475
|
+
handler: (args: {
|
|
476
|
+
keyEventId: string;
|
|
477
|
+
scope?: string;
|
|
478
|
+
start?: string;
|
|
479
|
+
end?: string;
|
|
480
|
+
version?: number;
|
|
481
|
+
limit?: number;
|
|
482
|
+
}) => Promise<{
|
|
483
|
+
isError?: boolean | undefined;
|
|
484
|
+
content: {
|
|
485
|
+
type: "text";
|
|
486
|
+
text: string;
|
|
487
|
+
}[];
|
|
488
|
+
}>;
|
|
489
|
+
};
|
|
175
490
|
list_next_moves: {
|
|
176
491
|
description: string;
|
|
177
492
|
schema: z.ZodObject<{
|
|
@@ -981,14 +1296,14 @@ export declare const measurementTools: {
|
|
|
981
1296
|
targetUrl: z.ZodOptional<z.ZodString>;
|
|
982
1297
|
isPrimary: z.ZodOptional<z.ZodBoolean>;
|
|
983
1298
|
}, "strip", z.ZodTypeAny, {
|
|
984
|
-
type: "click" | "form_submit" | "
|
|
1299
|
+
type: "click" | "form_submit" | "custom_event" | "pageview" | "file_download" | "engaged_time";
|
|
985
1300
|
name: string;
|
|
986
1301
|
eventName?: string | undefined;
|
|
987
1302
|
targetUrl?: string | undefined;
|
|
988
1303
|
selector?: string | undefined;
|
|
989
1304
|
isPrimary?: boolean | undefined;
|
|
990
1305
|
}, {
|
|
991
|
-
type: "click" | "form_submit" | "
|
|
1306
|
+
type: "click" | "form_submit" | "custom_event" | "pageview" | "file_download" | "engaged_time";
|
|
992
1307
|
name: string;
|
|
993
1308
|
eventName?: string | undefined;
|
|
994
1309
|
targetUrl?: string | undefined;
|
|
@@ -1058,4 +1373,5 @@ export declare const measurementTools: {
|
|
|
1058
1373
|
}>;
|
|
1059
1374
|
};
|
|
1060
1375
|
};
|
|
1376
|
+
export {};
|
|
1061
1377
|
//# sourceMappingURL=measurement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measurement.d.ts","sourceRoot":"","sources":["../../src/tools/measurement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"measurement.d.ts","sourceRoot":"","sources":["../../src/tools/measurement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyCxB,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMxB,CAAC;AAEH,KAAK,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAiI9D,eAAO,MAAM,gBAAgB;;;;;;;;;;wBAaH;YAAE,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE;;;;;;;;;;;;;;;;;;;4CAmEE;YAAE,cAAc,CAAC,EAAE,OAAO,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;SAAE;;;;;;;;;;;;;;;;4BAoDzE;YAAE,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;SAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwE7B;YACpB,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,CAAC;YAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;YACb,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,GAAG,CAAC,EAAE,MAAM,CAAC;YACb,OAAO,CAAC,EAAE,UAAU,CAAC;YACrB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;YACzB,aAAa,CAAC,EAAE,OAAO,CAAC;SACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0GqB;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA8IqB;YACpB,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;YACb,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,SAAS,CAAC,EAAE,OAAO,CAAC;SACrB;;;;;;;;;;;;;;;;oCA8BiC;YAAE,YAAY,EAAE,MAAM,CAAA;SAAE;;;;;;;;;;;;;;;;;;;;;;;;;wBA2BpC;YACpB,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,EAAE,MAAM,CAAC;YACf,QAAQ,EAAE,MAAM,CAAC;YACjB,kBAAkB,CAAC,EAAE,MAAM,CAAC;SAC7B;;;;;;;CAyBJ,CAAC"}
|
|
@@ -1,8 +1,38 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { apiGet, apiPost, apiPatch, apiPut, postServerEvents, SERVER_KEY_NEEDED_MESSAGE, getActiveWorkspace, } from "../api-client.js";
|
|
2
|
+
import { apiGet, apiPost, apiPatch, apiPut, apiDelete, postServerEvents, SERVER_KEY_NEEDED_MESSAGE, getActiveWorkspace, } from "../api-client.js";
|
|
3
3
|
import { getPersonLabel, lowerPerson } from "../person-label.js";
|
|
4
4
|
import { MCP_SERVER_VERSION } from "../version.js";
|
|
5
|
-
import { APEX, appUrl, MCP_AGENT_VISITOR_ID, windowQuery, } from "../tool-shared.js";
|
|
5
|
+
import { APEX, appUrl, errMsg, MCP_AGENT_VISITOR_ID, windowQuery, } from "../tool-shared.js";
|
|
6
|
+
function text(t, isError = false) {
|
|
7
|
+
return { content: [{ type: "text", text: t }], ...(isError ? { isError: true } : {}) };
|
|
8
|
+
}
|
|
9
|
+
// Nested keys are snake_case: the casing layer only translates top-level params.
|
|
10
|
+
const keyEventConditionSchema = z.object({
|
|
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"]),
|
|
13
|
+
value: z
|
|
14
|
+
.union([z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()]))])
|
|
15
|
+
.optional()
|
|
16
|
+
.describe("One value for equals / not_equals, a list for in, none for exists."),
|
|
17
|
+
});
|
|
18
|
+
const keyEventSourceSchema = z.object({
|
|
19
|
+
type: z.enum(["custom_event", "form_submit"]).describe("custom_event: a named event. form_submit: a form sent on the site."),
|
|
20
|
+
event_name: z.string().optional().describe("For custom_event: the event's name, e.g. application_submitted."),
|
|
21
|
+
selector: z.string().optional().describe('For form_submit: one form, as "#id". Omit for any form.'),
|
|
22
|
+
target_url: z.string().optional().describe("For form_submit: the page the form is on. Omit for any page."),
|
|
23
|
+
where: z.array(keyEventConditionSchema).max(10).optional().describe("Conditions on the event's data, all must hold."),
|
|
24
|
+
});
|
|
25
|
+
const keyEventCategorySchema = z
|
|
26
|
+
.enum(["purchase", "lead", "qualified_lead", "activation", "signup", "subscribe", "add_to_cart", "engagement", "other"])
|
|
27
|
+
.describe("What kind of step it is; sets its place in the funnel.");
|
|
28
|
+
function keyEventLine(k, i) {
|
|
29
|
+
const tags = [
|
|
30
|
+
k.isCurrentGoal ? "main" : null,
|
|
31
|
+
k.entityScope === "account" ? "counts companies" : null,
|
|
32
|
+
k.definitionVersion > 1 ? `v${k.definitionVersion}` : null,
|
|
33
|
+
].filter(Boolean);
|
|
34
|
+
return ` ${i + 1}. ${k.name} [${k.id}]${tags.length ? ` (${tags.join(", ")})` : ""}: ${k.counts}`;
|
|
35
|
+
}
|
|
6
36
|
const NOT_LINKED = {
|
|
7
37
|
missing_email: "no email",
|
|
8
38
|
missing_api_key: "sent without an Apex key",
|
|
@@ -450,24 +480,156 @@ export const measurementTools = {
|
|
|
450
480
|
},
|
|
451
481
|
},
|
|
452
482
|
list_key_events: {
|
|
453
|
-
description: `${APEX} — The workspace's key events
|
|
483
|
+
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. 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.`,
|
|
454
484
|
schema: z.object({}),
|
|
455
485
|
handler: async () => {
|
|
456
|
-
const res = await apiGet("/api/
|
|
486
|
+
const res = await apiGet("/api/key-events");
|
|
457
487
|
const keyEvents = res.data?.keyEvents ?? [];
|
|
458
488
|
if (keyEvents.length === 0) {
|
|
459
489
|
return {
|
|
460
|
-
content: [
|
|
490
|
+
content: [
|
|
491
|
+
{
|
|
492
|
+
type: "text",
|
|
493
|
+
text: `${APEX} No key events yet. Make one with create_key_event (for example Lead captured, reached by application_submitted or audit_booked), or on ${appUrl("/dashboard/conversions")}.`,
|
|
494
|
+
},
|
|
495
|
+
],
|
|
461
496
|
};
|
|
462
497
|
}
|
|
463
|
-
const lines = [
|
|
464
|
-
`${APEX} Key events, in funnel order`,
|
|
465
|
-
`${"═".repeat(40)}`,
|
|
466
|
-
...keyEvents.map((k, i) => ` ${i + 1}. ${k.name} [${k.conversionId}]${k.isCurrentGoal ? " (goal)" : ""}${k.counts ? `: ${k.counts}` : ""}`),
|
|
467
|
-
];
|
|
498
|
+
const lines = [`${APEX} Key events, in funnel order`, `${"═".repeat(40)}`, ...keyEvents.map(keyEventLine)];
|
|
468
499
|
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
469
500
|
},
|
|
470
501
|
},
|
|
502
|
+
get_key_event: {
|
|
503
|
+
description: `${APEX} — One key event: the events that reach it and their conditions, every earlier version, and the ad platform conversions linked to it. Id from list_key_events.`,
|
|
504
|
+
schema: z.object({ keyEventId: z.string().min(1).describe("From list_key_events.") }),
|
|
505
|
+
handler: async ({ keyEventId }) => {
|
|
506
|
+
try {
|
|
507
|
+
const res = await apiGet(`/api/key-events/${encodeURIComponent(keyEventId)}`);
|
|
508
|
+
const k = res.data?.keyEvent;
|
|
509
|
+
if (!k)
|
|
510
|
+
return text(`${APEX} Key event not found.`, true);
|
|
511
|
+
const lines = [keyEventLine(k, 0)];
|
|
512
|
+
for (const h of k.definitionHistory ?? []) {
|
|
513
|
+
lines.push(` v${h.version} until ${h.changedAt.slice(0, 10)}${h.changedBy ? ` (changed by ${h.changedBy})` : ""}: ${h.sources.length} event${h.sources.length === 1 ? "" : "s"}, counts ${h.entityScope === "account" ? "companies" : "people"}`);
|
|
514
|
+
}
|
|
515
|
+
for (const l of res.data?.links ?? [])
|
|
516
|
+
lines.push(` Linked: ${l.integration ?? "platform"} ${l.platformActionName ?? ""}`.trimEnd());
|
|
517
|
+
return text(lines.join("\n"));
|
|
518
|
+
}
|
|
519
|
+
catch (err) {
|
|
520
|
+
return text(`${APEX} ${errMsg(err)}`, true);
|
|
521
|
+
}
|
|
522
|
+
},
|
|
523
|
+
},
|
|
524
|
+
create_key_event: {
|
|
525
|
+
description: `${APEX} — Make a key event: an action that matters to the business, reached by any one of its events (sources), each with optional conditions on the event's data. Example: Lead captured, reached by application_submitted, or by audit_booked where plan is pro. Outside experiments Apex counts named events (custom_event) and form submissions (form_submit, optionally one form #id on one page). entity_scope account makes a company reach it when its first person does. People who already did it are found in their history and counted, but nothing is sent for them. Workspace admin.`,
|
|
526
|
+
schema: z.object({
|
|
527
|
+
name: z.string().min(1).max(200).describe('What the business calls it, e.g. "Lead captured".'),
|
|
528
|
+
sources: z.array(keyEventSourceSchema).min(1).max(20).describe("The events that reach it. Any one is enough."),
|
|
529
|
+
category: keyEventCategorySchema.optional(),
|
|
530
|
+
entityScope: z.enum(["person", "account"]).optional().describe("person (default) or account (a company reaches it when its first person does)."),
|
|
531
|
+
description: z.string().max(1000).optional(),
|
|
532
|
+
template: z.string().max(100).optional().describe("The template it follows, e.g. lead_captured."),
|
|
533
|
+
}),
|
|
534
|
+
handler: async (args) => {
|
|
535
|
+
try {
|
|
536
|
+
const res = await apiPost("/api/key-events", {
|
|
537
|
+
name: args.name,
|
|
538
|
+
sources: args.sources,
|
|
539
|
+
...(args.category ? { category: args.category } : {}),
|
|
540
|
+
...(args.entityScope ? { entity_scope: args.entityScope } : {}),
|
|
541
|
+
...(args.description ? { description: args.description } : {}),
|
|
542
|
+
...(args.template ? { template: args.template } : {}),
|
|
543
|
+
});
|
|
544
|
+
const k = res.data?.keyEvent;
|
|
545
|
+
return text(k ? `${APEX} Made key event:\n${keyEventLine(k, 0)}\nApex is now checking people's history for it.` : `${APEX} Made key event.`);
|
|
546
|
+
}
|
|
547
|
+
catch (err) {
|
|
548
|
+
return text(`${APEX} ${errMsg(err)}`, true);
|
|
549
|
+
}
|
|
550
|
+
},
|
|
551
|
+
},
|
|
552
|
+
update_key_event: {
|
|
553
|
+
description: `${APEX} — Change a key event. Renaming keeps its version. Changing its events, their conditions or entity_scope makes a new version: people already counted keep the version they reached, and running tests keep the one they started with. is_current_goal true makes it the main one Attribution leads with. Workspace admin.`,
|
|
554
|
+
schema: z.object({
|
|
555
|
+
keyEventId: z.string().min(1).describe("From list_key_events."),
|
|
556
|
+
name: z.string().min(1).max(200).optional(),
|
|
557
|
+
sources: z.array(keyEventSourceSchema).min(1).max(20).optional().describe("Replaces the events that reach it."),
|
|
558
|
+
category: keyEventCategorySchema.optional(),
|
|
559
|
+
entityScope: z.enum(["person", "account"]).optional(),
|
|
560
|
+
description: z.string().max(1000).optional(),
|
|
561
|
+
isCurrentGoal: z.literal(true).optional().describe("Make it the main key event."),
|
|
562
|
+
}),
|
|
563
|
+
handler: async (args) => {
|
|
564
|
+
try {
|
|
565
|
+
const res = await apiPatch(`/api/key-events/${encodeURIComponent(args.keyEventId)}`, {
|
|
566
|
+
...(args.name ? { name: args.name } : {}),
|
|
567
|
+
...(args.sources ? { sources: args.sources } : {}),
|
|
568
|
+
...(args.category ? { category: args.category } : {}),
|
|
569
|
+
...(args.entityScope ? { entity_scope: args.entityScope } : {}),
|
|
570
|
+
...(args.description !== undefined ? { description: args.description } : {}),
|
|
571
|
+
...(args.isCurrentGoal ? { is_current_goal: true } : {}),
|
|
572
|
+
});
|
|
573
|
+
const k = res.data?.keyEvent;
|
|
574
|
+
return text(k ? `${APEX} Saved:\n${keyEventLine(k, 0)}` : `${APEX} Saved.`);
|
|
575
|
+
}
|
|
576
|
+
catch (err) {
|
|
577
|
+
return text(`${APEX} ${errMsg(err)}`, true);
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
},
|
|
581
|
+
delete_key_event: {
|
|
582
|
+
description: `${APEX} — Delete a key event. Campaign steps, ad platform sends and tests that use it stop counting it. Prefer update_key_event when the meaning changed. Workspace admin.`,
|
|
583
|
+
schema: z.object({ keyEventId: z.string().min(1).describe("From list_key_events.") }),
|
|
584
|
+
handler: async ({ keyEventId }) => {
|
|
585
|
+
try {
|
|
586
|
+
await apiDelete(`/api/key-events/${encodeURIComponent(keyEventId)}`);
|
|
587
|
+
return text(`${APEX} Deleted ${keyEventId}.`);
|
|
588
|
+
}
|
|
589
|
+
catch (err) {
|
|
590
|
+
return text(`${APEX} ${errMsg(err)}`, true);
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
get_key_event_reached: {
|
|
595
|
+
description: `${APEX} — Who reached a key event: when, through which of its events, under which version, and whether Apex saw it happen or found it later in their history (history is never sent to ad platforms or journeys). scope account lists each company once, from its first person.`,
|
|
596
|
+
schema: z.object({
|
|
597
|
+
keyEventId: z.string().min(1).describe("From list_key_events."),
|
|
598
|
+
scope: z.enum(["person", "account"]).optional(),
|
|
599
|
+
start: z.string().optional().describe("ISO date; first times on or after."),
|
|
600
|
+
end: z.string().optional().describe("ISO date; first times on or before."),
|
|
601
|
+
version: z.number().int().min(1).optional(),
|
|
602
|
+
limit: z.number().int().min(1).max(1000).optional().describe("Rows to list (default 25)."),
|
|
603
|
+
}),
|
|
604
|
+
handler: async (args) => {
|
|
605
|
+
try {
|
|
606
|
+
const q = new URLSearchParams();
|
|
607
|
+
if (args.scope)
|
|
608
|
+
q.set("scope", args.scope);
|
|
609
|
+
if (args.start)
|
|
610
|
+
q.set("start", args.start);
|
|
611
|
+
if (args.end)
|
|
612
|
+
q.set("end", args.end);
|
|
613
|
+
if (args.version)
|
|
614
|
+
q.set("version", String(args.version));
|
|
615
|
+
q.set("limit", String(args.limit ?? 25));
|
|
616
|
+
const res = await apiGet(`/api/key-events/${encodeURIComponent(args.keyEventId)}/reached?${q}`);
|
|
617
|
+
const d = res.data;
|
|
618
|
+
if (!d)
|
|
619
|
+
return text(`${APEX} Key event not found.`, true);
|
|
620
|
+
const person = lowerPerson(await getPersonLabel());
|
|
621
|
+
const noun = args.scope === "account" ? (d.total === 1 ? "company" : "companies") : d.total === 1 ? person.label : person.plural;
|
|
622
|
+
const lines = [`${APEX} ${d.total} ${noun} reached it (${d.live} seen as it happened, ${d.history} found in history).`];
|
|
623
|
+
for (const r of d.reached) {
|
|
624
|
+
lines.push(` ${r.firstAt.slice(0, 16).replace("T", " ")} ${r.accountId ? `${r.accountId} via ` : ""}${r.contactId} ${r.via}${r.sourceIndex !== undefined ? `, event ${r.sourceIndex + 1}` : ""}, v${r.definitionVersion}`);
|
|
625
|
+
}
|
|
626
|
+
return text(lines.join("\n"));
|
|
627
|
+
}
|
|
628
|
+
catch (err) {
|
|
629
|
+
return text(`${APEX} ${errMsg(err)}`, true);
|
|
630
|
+
}
|
|
631
|
+
},
|
|
632
|
+
},
|
|
471
633
|
list_next_moves: {
|
|
472
634
|
description: `${APEX} — "What should I do next?" The ranked moves Apex shows on Attribution and the home page, from one engine: broken tracking to fix, spend that isn't paying, efforts worth scaling, and insight checks. Scope it to one effort with grain + ref (an ad's moves also show on its channel). If a source or check couldn't be read the reply says so, so a short list never means nothing to do.`,
|
|
473
635
|
schema: z.object({
|