@apex-inc/mcp-server 0.70.0 → 0.72.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 +11 -0
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +38 -0
- package/dist/api-client.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/letter-blocks.d.ts +2 -2
- package/dist/setup-catchup-tools.d.ts +24 -15
- package/dist/setup-catchup-tools.d.ts.map +1 -1
- package/dist/setup-catchup-tools.js +122 -53
- package/dist/setup-catchup-tools.js.map +1 -1
- package/dist/setup-checklist.d.ts +1 -0
- package/dist/setup-checklist.d.ts.map +1 -1
- package/dist/setup-checklist.js +2 -1
- package/dist/setup-checklist.js.map +1 -1
- package/dist/tool-groups.d.ts.map +1 -1
- package/dist/tool-groups.js +3 -0
- package/dist/tool-groups.js.map +1 -1
- package/dist/tools/experiments.d.ts +2 -2
- package/dist/tools/experiments.js +1 -1
- package/dist/tools/experiments.js.map +1 -1
- package/dist/tools/letters.d.ts +208 -17
- package/dist/tools/letters.d.ts.map +1 -1
- package/dist/tools/letters.js +170 -51
- package/dist/tools/letters.js.map +1 -1
- package/dist/tools/measurement.d.ts +43 -12
- package/dist/tools/measurement.d.ts.map +1 -1
- package/dist/tools/measurement.js +49 -5
- package/dist/tools/measurement.js.map +1 -1
- package/dist/tools/partners.d.ts +17 -14
- package/dist/tools/partners.d.ts.map +1 -1
- package/dist/tools/partners.js +30 -5
- package/dist/tools/partners.js.map +1 -1
- package/dist/tools.d.ts +296 -53
- package/dist/tools.d.ts.map +1 -1
- package/dist/workspace-target-url.d.ts.map +1 -1
- package/dist/workspace-target-url.js +8 -3
- package/dist/workspace-target-url.js.map +1 -1
- package/package.json +1 -1
- package/skills/apex-setup/SKILL.md +6 -1
package/dist/tools/letters.d.ts
CHANGED
|
@@ -367,7 +367,7 @@ export declare const letterTools: {
|
|
|
367
367
|
button_width?: "fill" | "hug" | undefined;
|
|
368
368
|
eyebrow?: string | undefined;
|
|
369
369
|
caption?: string | undefined;
|
|
370
|
-
tone?: "
|
|
370
|
+
tone?: "warning" | "plain" | "success" | "neutral" | undefined;
|
|
371
371
|
height?: number | undefined;
|
|
372
372
|
color?: string | undefined;
|
|
373
373
|
thickness?: number | undefined;
|
|
@@ -389,7 +389,7 @@ export declare const letterTools: {
|
|
|
389
389
|
button_width?: "fill" | "hug" | undefined;
|
|
390
390
|
eyebrow?: string | undefined;
|
|
391
391
|
caption?: string | undefined;
|
|
392
|
-
tone?: "
|
|
392
|
+
tone?: "warning" | "plain" | "success" | "neutral" | undefined;
|
|
393
393
|
height?: number | undefined;
|
|
394
394
|
color?: string | undefined;
|
|
395
395
|
thickness?: number | undefined;
|
|
@@ -428,7 +428,7 @@ export declare const letterTools: {
|
|
|
428
428
|
button_width?: "fill" | "hug" | undefined;
|
|
429
429
|
eyebrow?: string | undefined;
|
|
430
430
|
caption?: string | undefined;
|
|
431
|
-
tone?: "
|
|
431
|
+
tone?: "warning" | "plain" | "success" | "neutral" | undefined;
|
|
432
432
|
height?: number | undefined;
|
|
433
433
|
color?: string | undefined;
|
|
434
434
|
thickness?: number | undefined;
|
|
@@ -463,7 +463,7 @@ export declare const letterTools: {
|
|
|
463
463
|
button_width?: "fill" | "hug" | undefined;
|
|
464
464
|
eyebrow?: string | undefined;
|
|
465
465
|
caption?: string | undefined;
|
|
466
|
-
tone?: "
|
|
466
|
+
tone?: "warning" | "plain" | "success" | "neutral" | undefined;
|
|
467
467
|
height?: number | undefined;
|
|
468
468
|
color?: string | undefined;
|
|
469
469
|
thickness?: number | undefined;
|
|
@@ -612,14 +612,10 @@ export declare const letterTools: {
|
|
|
612
612
|
handler: (args: {
|
|
613
613
|
communicationId: string;
|
|
614
614
|
}) => Promise<{
|
|
615
|
-
content:
|
|
615
|
+
content: {
|
|
616
616
|
type: "text";
|
|
617
617
|
text: string;
|
|
618
|
-
}
|
|
619
|
-
type: "image";
|
|
620
|
-
data: string;
|
|
621
|
-
mimeType: string;
|
|
622
|
-
})[];
|
|
618
|
+
}[];
|
|
623
619
|
}>;
|
|
624
620
|
};
|
|
625
621
|
add_communication_variant: {
|
|
@@ -868,16 +864,20 @@ export declare const letterTools: {
|
|
|
868
864
|
schema: z.ZodObject<{
|
|
869
865
|
name: z.ZodOptional<z.ZodString>;
|
|
870
866
|
audience_bucket: z.ZodOptional<z.ZodEnum<["production", "beta", "dev"]>>;
|
|
867
|
+
attributionWindowDays: z.ZodOptional<z.ZodNumber>;
|
|
871
868
|
}, "strip", z.ZodTypeAny, {
|
|
872
869
|
name?: string | undefined;
|
|
870
|
+
attributionWindowDays?: number | undefined;
|
|
873
871
|
audience_bucket?: "production" | "beta" | "dev" | undefined;
|
|
874
872
|
}, {
|
|
875
873
|
name?: string | undefined;
|
|
874
|
+
attributionWindowDays?: number | undefined;
|
|
876
875
|
audience_bucket?: "production" | "beta" | "dev" | undefined;
|
|
877
876
|
}>;
|
|
878
|
-
handler: ({ name, audience_bucket }: {
|
|
877
|
+
handler: ({ name, audience_bucket, attributionWindowDays, }: {
|
|
879
878
|
name?: string;
|
|
880
879
|
audience_bucket?: "production" | "beta" | "dev";
|
|
880
|
+
attributionWindowDays?: number;
|
|
881
881
|
}) => Promise<{
|
|
882
882
|
content: {
|
|
883
883
|
type: "text";
|
|
@@ -909,14 +909,10 @@ export declare const letterTools: {
|
|
|
909
909
|
}[];
|
|
910
910
|
isError: boolean;
|
|
911
911
|
} | {
|
|
912
|
-
content:
|
|
912
|
+
content: {
|
|
913
913
|
type: "text";
|
|
914
914
|
text: string;
|
|
915
|
-
}
|
|
916
|
-
type: "image";
|
|
917
|
-
data: string;
|
|
918
|
-
mimeType: string;
|
|
919
|
-
})[];
|
|
915
|
+
}[];
|
|
920
916
|
}>;
|
|
921
917
|
};
|
|
922
918
|
list_trigger_contracts: {
|
|
@@ -1713,5 +1709,200 @@ export declare const letterTools: {
|
|
|
1713
1709
|
}[];
|
|
1714
1710
|
}>;
|
|
1715
1711
|
};
|
|
1712
|
+
update_segment: {
|
|
1713
|
+
description: string;
|
|
1714
|
+
schema: z.ZodObject<{
|
|
1715
|
+
segmentId: z.ZodString;
|
|
1716
|
+
scope: z.ZodOptional<z.ZodEnum<["workspace", "org"]>>;
|
|
1717
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1718
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1719
|
+
conditions: z.ZodOptional<z.ZodObject<{
|
|
1720
|
+
match: z.ZodEnum<["all", "any"]>;
|
|
1721
|
+
groups: z.ZodArray<z.ZodObject<{
|
|
1722
|
+
match: z.ZodEnum<["all", "any"]>;
|
|
1723
|
+
conditions: z.ZodArray<z.ZodObject<{
|
|
1724
|
+
verb: z.ZodOptional<z.ZodEnum<["has", "hasnt"]>>;
|
|
1725
|
+
event: z.ZodOptional<z.ZodString>;
|
|
1726
|
+
key_event_id: z.ZodOptional<z.ZodString>;
|
|
1727
|
+
scope: z.ZodOptional<z.ZodEnum<["person", "account"]>>;
|
|
1728
|
+
window_days: z.ZodOptional<z.ZodNumber>;
|
|
1729
|
+
attribute: z.ZodOptional<z.ZodString>;
|
|
1730
|
+
op: z.ZodOptional<z.ZodEnum<["is", "is_not", "exists"]>>;
|
|
1731
|
+
value: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
1732
|
+
}, "strip", z.ZodTypeAny, {
|
|
1733
|
+
event?: string | undefined;
|
|
1734
|
+
value?: string | number | boolean | undefined;
|
|
1735
|
+
key_event_id?: string | undefined;
|
|
1736
|
+
scope?: "account" | "person" | undefined;
|
|
1737
|
+
attribute?: string | undefined;
|
|
1738
|
+
window_days?: number | undefined;
|
|
1739
|
+
verb?: "has" | "hasnt" | undefined;
|
|
1740
|
+
op?: "exists" | "is" | "is_not" | undefined;
|
|
1741
|
+
}, {
|
|
1742
|
+
event?: string | undefined;
|
|
1743
|
+
value?: string | number | boolean | undefined;
|
|
1744
|
+
key_event_id?: string | undefined;
|
|
1745
|
+
scope?: "account" | "person" | undefined;
|
|
1746
|
+
attribute?: string | undefined;
|
|
1747
|
+
window_days?: number | undefined;
|
|
1748
|
+
verb?: "has" | "hasnt" | undefined;
|
|
1749
|
+
op?: "exists" | "is" | "is_not" | undefined;
|
|
1750
|
+
}>, "many">;
|
|
1751
|
+
}, "strip", z.ZodTypeAny, {
|
|
1752
|
+
match: "all" | "any";
|
|
1753
|
+
conditions: {
|
|
1754
|
+
event?: string | undefined;
|
|
1755
|
+
value?: string | number | boolean | undefined;
|
|
1756
|
+
key_event_id?: string | undefined;
|
|
1757
|
+
scope?: "account" | "person" | undefined;
|
|
1758
|
+
attribute?: string | undefined;
|
|
1759
|
+
window_days?: number | undefined;
|
|
1760
|
+
verb?: "has" | "hasnt" | undefined;
|
|
1761
|
+
op?: "exists" | "is" | "is_not" | undefined;
|
|
1762
|
+
}[];
|
|
1763
|
+
}, {
|
|
1764
|
+
match: "all" | "any";
|
|
1765
|
+
conditions: {
|
|
1766
|
+
event?: string | undefined;
|
|
1767
|
+
value?: string | number | boolean | undefined;
|
|
1768
|
+
key_event_id?: string | undefined;
|
|
1769
|
+
scope?: "account" | "person" | undefined;
|
|
1770
|
+
attribute?: string | undefined;
|
|
1771
|
+
window_days?: number | undefined;
|
|
1772
|
+
verb?: "has" | "hasnt" | undefined;
|
|
1773
|
+
op?: "exists" | "is" | "is_not" | undefined;
|
|
1774
|
+
}[];
|
|
1775
|
+
}>, "many">;
|
|
1776
|
+
}, "strip", z.ZodTypeAny, {
|
|
1777
|
+
match: "all" | "any";
|
|
1778
|
+
groups: {
|
|
1779
|
+
match: "all" | "any";
|
|
1780
|
+
conditions: {
|
|
1781
|
+
event?: string | undefined;
|
|
1782
|
+
value?: string | number | boolean | undefined;
|
|
1783
|
+
key_event_id?: string | undefined;
|
|
1784
|
+
scope?: "account" | "person" | undefined;
|
|
1785
|
+
attribute?: string | undefined;
|
|
1786
|
+
window_days?: number | undefined;
|
|
1787
|
+
verb?: "has" | "hasnt" | undefined;
|
|
1788
|
+
op?: "exists" | "is" | "is_not" | undefined;
|
|
1789
|
+
}[];
|
|
1790
|
+
}[];
|
|
1791
|
+
}, {
|
|
1792
|
+
match: "all" | "any";
|
|
1793
|
+
groups: {
|
|
1794
|
+
match: "all" | "any";
|
|
1795
|
+
conditions: {
|
|
1796
|
+
event?: string | undefined;
|
|
1797
|
+
value?: string | number | boolean | undefined;
|
|
1798
|
+
key_event_id?: string | undefined;
|
|
1799
|
+
scope?: "account" | "person" | undefined;
|
|
1800
|
+
attribute?: string | undefined;
|
|
1801
|
+
window_days?: number | undefined;
|
|
1802
|
+
verb?: "has" | "hasnt" | undefined;
|
|
1803
|
+
op?: "exists" | "is" | "is_not" | undefined;
|
|
1804
|
+
}[];
|
|
1805
|
+
}[];
|
|
1806
|
+
}>>;
|
|
1807
|
+
predicate: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1808
|
+
}, "strip", z.ZodTypeAny, {
|
|
1809
|
+
segmentId: string;
|
|
1810
|
+
name?: string | undefined;
|
|
1811
|
+
description?: string | undefined;
|
|
1812
|
+
scope?: "workspace" | "org" | undefined;
|
|
1813
|
+
conditions?: {
|
|
1814
|
+
match: "all" | "any";
|
|
1815
|
+
groups: {
|
|
1816
|
+
match: "all" | "any";
|
|
1817
|
+
conditions: {
|
|
1818
|
+
event?: string | undefined;
|
|
1819
|
+
value?: string | number | boolean | undefined;
|
|
1820
|
+
key_event_id?: string | undefined;
|
|
1821
|
+
scope?: "account" | "person" | undefined;
|
|
1822
|
+
attribute?: string | undefined;
|
|
1823
|
+
window_days?: number | undefined;
|
|
1824
|
+
verb?: "has" | "hasnt" | undefined;
|
|
1825
|
+
op?: "exists" | "is" | "is_not" | undefined;
|
|
1826
|
+
}[];
|
|
1827
|
+
}[];
|
|
1828
|
+
} | undefined;
|
|
1829
|
+
predicate?: Record<string, unknown> | undefined;
|
|
1830
|
+
}, {
|
|
1831
|
+
segmentId: string;
|
|
1832
|
+
name?: string | undefined;
|
|
1833
|
+
description?: string | undefined;
|
|
1834
|
+
scope?: "workspace" | "org" | undefined;
|
|
1835
|
+
conditions?: {
|
|
1836
|
+
match: "all" | "any";
|
|
1837
|
+
groups: {
|
|
1838
|
+
match: "all" | "any";
|
|
1839
|
+
conditions: {
|
|
1840
|
+
event?: string | undefined;
|
|
1841
|
+
value?: string | number | boolean | undefined;
|
|
1842
|
+
key_event_id?: string | undefined;
|
|
1843
|
+
scope?: "account" | "person" | undefined;
|
|
1844
|
+
attribute?: string | undefined;
|
|
1845
|
+
window_days?: number | undefined;
|
|
1846
|
+
verb?: "has" | "hasnt" | undefined;
|
|
1847
|
+
op?: "exists" | "is" | "is_not" | undefined;
|
|
1848
|
+
}[];
|
|
1849
|
+
}[];
|
|
1850
|
+
} | undefined;
|
|
1851
|
+
predicate?: Record<string, unknown> | undefined;
|
|
1852
|
+
}>;
|
|
1853
|
+
handler: (args: {
|
|
1854
|
+
segmentId: string;
|
|
1855
|
+
scope?: "workspace" | "org";
|
|
1856
|
+
name?: string;
|
|
1857
|
+
description?: string;
|
|
1858
|
+
conditions?: unknown;
|
|
1859
|
+
predicate?: unknown;
|
|
1860
|
+
}) => Promise<{
|
|
1861
|
+
content: {
|
|
1862
|
+
type: "text";
|
|
1863
|
+
text: string;
|
|
1864
|
+
}[];
|
|
1865
|
+
isError: boolean;
|
|
1866
|
+
} | {
|
|
1867
|
+
content: {
|
|
1868
|
+
type: "text";
|
|
1869
|
+
text: string;
|
|
1870
|
+
}[];
|
|
1871
|
+
isError?: undefined;
|
|
1872
|
+
}>;
|
|
1873
|
+
};
|
|
1874
|
+
delete_segment: {
|
|
1875
|
+
description: string;
|
|
1876
|
+
schema: z.ZodObject<{
|
|
1877
|
+
segmentId: z.ZodString;
|
|
1878
|
+
scope: z.ZodOptional<z.ZodEnum<["workspace", "org"]>>;
|
|
1879
|
+
confirmInUse: z.ZodOptional<z.ZodBoolean>;
|
|
1880
|
+
}, "strip", z.ZodTypeAny, {
|
|
1881
|
+
segmentId: string;
|
|
1882
|
+
scope?: "workspace" | "org" | undefined;
|
|
1883
|
+
confirmInUse?: boolean | undefined;
|
|
1884
|
+
}, {
|
|
1885
|
+
segmentId: string;
|
|
1886
|
+
scope?: "workspace" | "org" | undefined;
|
|
1887
|
+
confirmInUse?: boolean | undefined;
|
|
1888
|
+
}>;
|
|
1889
|
+
handler: (args: {
|
|
1890
|
+
segmentId: string;
|
|
1891
|
+
scope?: "workspace" | "org";
|
|
1892
|
+
confirmInUse?: boolean;
|
|
1893
|
+
}) => Promise<{
|
|
1894
|
+
content: {
|
|
1895
|
+
type: "text";
|
|
1896
|
+
text: string;
|
|
1897
|
+
}[];
|
|
1898
|
+
isError: boolean;
|
|
1899
|
+
} | {
|
|
1900
|
+
content: {
|
|
1901
|
+
type: "text";
|
|
1902
|
+
text: string;
|
|
1903
|
+
}[];
|
|
1904
|
+
isError?: undefined;
|
|
1905
|
+
}>;
|
|
1906
|
+
};
|
|
1716
1907
|
};
|
|
1717
1908
|
//# sourceMappingURL=letters.d.ts.map
|
|
@@ -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;AAoBxB,OAAO,EAAsE,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEhI,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,8BAA8B,CAAC;AAqDtC,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;wBAeE;YAAE,eAAe,EAAE,MAAM,EAAE,CAAA;SAAE;;;;;;;;;;;;;;;;;;;;;;;;;wBAgC7B;YACpB,QAA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AAC;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,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { apiGet, apiPost, apiPatch, apiDelete, apiDeleteJson,
|
|
2
|
+
import { apiGet, apiPost, apiPatch, apiDelete, apiDeleteJson, getActiveWorkspace, resolveActiveOrg, } from "../api-client.js";
|
|
3
3
|
import { controlGateGuidanceFor } from "../control-gate-guidance.js";
|
|
4
4
|
import { notStartedExplanation, publishedExperimentLine } from "../publish-communication-copy.js";
|
|
5
5
|
import { applyAddJourneyStep } from "../add-journey-step.js";
|
|
@@ -184,7 +184,10 @@ export const letterTools = {
|
|
|
184
184
|
promote_theme_id: z.string().optional().describe("Promote an existing workspace theme up to the organization so sibling workspaces inherit it."),
|
|
185
185
|
promote_from_workspace_key: z.string().optional().describe("Source workspace key when using promote_theme_id. Defaults to the active workspace."),
|
|
186
186
|
set_default: z.boolean().optional().describe("When creating/promoting an org theme, also set it as the organization default."),
|
|
187
|
-
style: z
|
|
187
|
+
style: z
|
|
188
|
+
.record(z.string(), z.unknown())
|
|
189
|
+
.optional()
|
|
190
|
+
.describe("Email style tokens (camelCase keys — unknown keys are rejected). Colors (hex like '#E4572E'): canvasBg, bodyBg, textColor, buttonColor (button text contrast is auto-derived; do not pass buttonBg/buttonText), linkColor (not accentColor), headerBandColor, footerBandColor, dividerColor. Layout & typography: bodyWidth (320-800 px), fontFamily (curated font id), headingSize (20-40 px), headingSizeH2 (14-40 px), headingSizeH3 (14-40 px), textSize (12-20 px), headerAlign ('left'|'center'|'right'), footerAlign ('left'|'center'|'right'), headerBand, footerBand, bandWidth, buttonRadius (0-40 px), dividerThickness (px), darkMode ('fidelity'|'adapt')."),
|
|
188
191
|
roles: z.record(z.string(), z.unknown()).optional(),
|
|
189
192
|
}),
|
|
190
193
|
handler: async (args) => {
|
|
@@ -252,7 +255,10 @@ export const letterTools = {
|
|
|
252
255
|
org_id: z.string().optional().describe("Organization ID when scope='org'. Defaults to the active organization."),
|
|
253
256
|
reset_to_org: z.boolean().optional().describe("Drop a workspace custom override copy of an organization theme so this workspace inherits the organization's live theme again."),
|
|
254
257
|
name: z.string().min(1).max(60).optional(),
|
|
255
|
-
style: z
|
|
258
|
+
style: z
|
|
259
|
+
.record(z.string(), z.unknown())
|
|
260
|
+
.optional()
|
|
261
|
+
.describe("Email style tokens to merge (camelCase keys — unknown keys are rejected). Colors (hex like '#E4572E'): canvasBg, bodyBg, textColor, buttonColor (button text contrast is auto-derived; do not pass buttonBg/buttonText), linkColor (not accentColor), headerBandColor, footerBandColor, dividerColor. Layout & typography: bodyWidth (320-800 px), fontFamily (curated font id), headingSize (20-40 px), headingSizeH2 (14-40 px), headingSizeH3 (14-40 px), textSize (12-20 px), headerAlign ('left'|'center'|'right'), footerAlign ('left'|'center'|'right'), headerBand, footerBand, bandWidth, buttonRadius (0-40 px), dividerThickness (px), darkMode ('fidelity'|'adapt')."),
|
|
256
262
|
roles: z.record(z.string(), z.unknown()).optional(),
|
|
257
263
|
set_default: z.boolean().optional(),
|
|
258
264
|
}),
|
|
@@ -684,15 +690,12 @@ export const letterTools = {
|
|
|
684
690
|
},
|
|
685
691
|
},
|
|
686
692
|
preview_communication: {
|
|
687
|
-
description: "
|
|
693
|
+
description: "Inspect a communication with your brand and Theme applied. Returns the subject, rendered plain-text body, every picture's URL and size in order, Title/Body/Button roles, block overrides, and the direct Apex UI link where the owner can inspect light/dark mode, different email clients, and visually edit the letter.",
|
|
688
694
|
schema: z.object({
|
|
689
695
|
communicationId: z.string().describe("The communication ID to preview"),
|
|
690
696
|
}),
|
|
691
697
|
handler: async (args) => {
|
|
692
|
-
const
|
|
693
|
-
apiPost(`/api/communications/${args.communicationId}/preview`, {}),
|
|
694
|
-
fetchInlineImageBlock(`/api/communications/${encodeURIComponent(args.communicationId)}/preview-image`),
|
|
695
|
-
]);
|
|
698
|
+
const data = await apiPost(`/api/communications/${args.communicationId}/preview`, {});
|
|
696
699
|
// Strip tags from subject (preview may annotate it with a slot span).
|
|
697
700
|
const subject = (data.subject ?? "").replace(/<[^>]+>/g, "");
|
|
698
701
|
const text = (data.text ?? "").trim();
|
|
@@ -722,31 +725,30 @@ export const letterTools = {
|
|
|
722
725
|
return ` ${i + 1}. ${img.alt || "(no alt)"}: ${img.src}${size ? ` (${size})` : ""}`;
|
|
723
726
|
})
|
|
724
727
|
: [" (none)"];
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
return { content };
|
|
728
|
+
return {
|
|
729
|
+
content: [
|
|
730
|
+
{
|
|
731
|
+
type: "text",
|
|
732
|
+
text: [
|
|
733
|
+
`Subject: ${subject || "(none)"}`,
|
|
734
|
+
``,
|
|
735
|
+
`Rendered body:`,
|
|
736
|
+
text ? text : "(empty — add content via edit_communication)",
|
|
737
|
+
``,
|
|
738
|
+
`Pictures, in order (the brand header logo included):`,
|
|
739
|
+
...imageLines,
|
|
740
|
+
``,
|
|
741
|
+
`Theme roles:`,
|
|
742
|
+
...roleLines,
|
|
743
|
+
``,
|
|
744
|
+
`Block overrides:`,
|
|
745
|
+
...overrideLines,
|
|
746
|
+
``,
|
|
747
|
+
`Open in Apex to preview light/dark mode, test email clients, or edit: ${link}`,
|
|
748
|
+
].join("\n"),
|
|
749
|
+
},
|
|
750
|
+
],
|
|
751
|
+
};
|
|
750
752
|
},
|
|
751
753
|
},
|
|
752
754
|
add_communication_variant: {
|
|
@@ -1059,23 +1061,36 @@ export const letterTools = {
|
|
|
1059
1061
|
// Agent-friendly arg names (snake_case) are mapped to the REST
|
|
1060
1062
|
// routes inside each handler.,
|
|
1061
1063
|
create_journey: {
|
|
1062
|
-
description: `${APEX} — Create a blank draft journey (an unconfigured event trigger wired to an exit). 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.`,
|
|
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.`,
|
|
1063
1065
|
schema: z.object({
|
|
1064
1066
|
name: z.string().optional().describe("Journey name (default 'Untitled journey')."),
|
|
1065
1067
|
audience_bucket: z
|
|
1066
1068
|
.enum(["production", "beta", "dev"])
|
|
1067
1069
|
.optional()
|
|
1068
1070
|
.describe("Who this journey enrolls. Default production. Never All or Unclassified."),
|
|
1071
|
+
attributionWindowDays: z
|
|
1072
|
+
.number()
|
|
1073
|
+
.int()
|
|
1074
|
+
.min(1)
|
|
1075
|
+
.max(90)
|
|
1076
|
+
.optional()
|
|
1077
|
+
.describe("Optional per-journey attribution window in days (1-90). Omit to inherit the workspace's messaging guardrails default."),
|
|
1069
1078
|
}),
|
|
1070
|
-
handler: async ({ name, audience_bucket }) => {
|
|
1079
|
+
handler: async ({ name, audience_bucket, attributionWindowDays, }) => {
|
|
1071
1080
|
try {
|
|
1072
|
-
const j = await apiPost("/api/journeys/blank", {
|
|
1081
|
+
const j = await apiPost("/api/journeys/blank", {
|
|
1082
|
+
name,
|
|
1083
|
+
...(attributionWindowDays !== undefined ? { attributionWindowDays } : {}),
|
|
1084
|
+
});
|
|
1073
1085
|
if (audience_bucket && audience_bucket !== "production") {
|
|
1074
1086
|
await apiPatch(`/api/journeys/${j.id}`, { audienceBucket: audience_bucket });
|
|
1075
1087
|
}
|
|
1076
1088
|
if (!tenantOk(j.workspaceKey))
|
|
1077
1089
|
return tenantMismatch();
|
|
1078
|
-
|
|
1090
|
+
const winText = typeof j.attributionWindowDays === "number"
|
|
1091
|
+
? `, attribution window: ${j.attributionWindowDays}d`
|
|
1092
|
+
: "";
|
|
1093
|
+
return { content: [{ type: "text", text: `${APEX} Created draft journey "${j.name}" (id: ${j.id}${winText}). Open it in the browser: ${journeyLink(j.id)}\nNext: set_journey_trigger, then add_journey_step.` }] };
|
|
1079
1094
|
}
|
|
1080
1095
|
catch (err) {
|
|
1081
1096
|
return { content: [{ type: "text", text: `${APEX} ${errMsg(err)}` }], isError: true };
|
|
@@ -1083,26 +1098,21 @@ export const letterTools = {
|
|
|
1083
1098
|
},
|
|
1084
1099
|
},
|
|
1085
1100
|
create_journey_from_template: {
|
|
1086
|
-
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
|
|
1101
|
+
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.`,
|
|
1087
1102
|
schema: z.object({ templateId: z.string().describe("Template id from get_wiring_status (e.g. 'mobile-cart-recovery').") }),
|
|
1088
1103
|
handler: async ({ templateId }) => {
|
|
1089
1104
|
try {
|
|
1090
1105
|
const j = await apiPost("/api/journeys/from-template", { templateId });
|
|
1091
1106
|
if (!tenantOk(j.workspaceKey))
|
|
1092
1107
|
return tenantMismatch();
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
},
|
|
1102
|
-
];
|
|
1103
|
-
if (imageBlock)
|
|
1104
|
-
content.push(imageBlock);
|
|
1105
|
-
return { content };
|
|
1108
|
+
return {
|
|
1109
|
+
content: [
|
|
1110
|
+
{
|
|
1111
|
+
type: "text",
|
|
1112
|
+
text: `${APEX} Instantiated "${j.name}" (id: ${j.id}) from template ${templateId}.\nOpen in Apex to inspect or edit on the visual canvas: ${journeyLink(j.id)}\nReview its steps with get_journey, then publish_journey once approved.`,
|
|
1113
|
+
},
|
|
1114
|
+
],
|
|
1115
|
+
};
|
|
1106
1116
|
}
|
|
1107
1117
|
catch (err) {
|
|
1108
1118
|
return { content: [{ type: "text", text: `${APEX} ${errMsg(err)}` }], isError: true };
|
|
@@ -2028,5 +2038,114 @@ export const letterTools = {
|
|
|
2028
2038
|
};
|
|
2029
2039
|
},
|
|
2030
2040
|
},
|
|
2041
|
+
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.`,
|
|
2043
|
+
schema: z.object({
|
|
2044
|
+
segmentId: z.string().min(1).describe("Segment ID from list_segments or create_segment."),
|
|
2045
|
+
scope: z.enum(["workspace", "org"]).optional().describe("Segment scope (default workspace)."),
|
|
2046
|
+
name: z.string().min(1).optional().describe("New segment name."),
|
|
2047
|
+
description: z.string().optional().describe("New segment description."),
|
|
2048
|
+
conditions: z
|
|
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
|
+
})
|
|
2065
|
+
.optional()
|
|
2066
|
+
.describe("Replacement friendly conditions (compiled server-side). Sub-keys are snake_case."),
|
|
2067
|
+
predicate: z.record(z.string(), z.unknown()).optional().describe("Replacement raw SegmentPredicate."),
|
|
2068
|
+
}),
|
|
2069
|
+
handler: async (args) => {
|
|
2070
|
+
try {
|
|
2071
|
+
const scope = args.scope ?? "workspace";
|
|
2072
|
+
const body = { scope };
|
|
2073
|
+
if (args.name !== undefined)
|
|
2074
|
+
body.name = args.name;
|
|
2075
|
+
if (args.description !== undefined)
|
|
2076
|
+
body.description = args.description;
|
|
2077
|
+
if (args.predicate !== undefined)
|
|
2078
|
+
body.predicate = args.predicate;
|
|
2079
|
+
else if (args.conditions !== undefined)
|
|
2080
|
+
body.conditions = args.conditions;
|
|
2081
|
+
if (Object.keys(body).length === 1) {
|
|
2082
|
+
return {
|
|
2083
|
+
content: [
|
|
2084
|
+
{
|
|
2085
|
+
type: "text",
|
|
2086
|
+
text: `${APEX} Pass at least one field to update (name, description, conditions, or predicate).`,
|
|
2087
|
+
},
|
|
2088
|
+
],
|
|
2089
|
+
isError: true,
|
|
2090
|
+
};
|
|
2091
|
+
}
|
|
2092
|
+
const data = await apiPatch(`/api/segments/${encodeURIComponent(args.segmentId)}?scope=${scope}`, body);
|
|
2093
|
+
return {
|
|
2094
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
2095
|
+
};
|
|
2096
|
+
}
|
|
2097
|
+
catch (err) {
|
|
2098
|
+
return { content: [{ type: "text", text: `${APEX} ${errMsg(err)}` }], isError: true };
|
|
2099
|
+
}
|
|
2100
|
+
},
|
|
2101
|
+
},
|
|
2102
|
+
delete_segment: {
|
|
2103
|
+
description: `${APEX} — Delete a custom segment (starter segments cannot be deleted). Checks whether any active journeys reference the segment first; if it is in use, refuses until the owner confirms with confirm_in_use: true.`,
|
|
2104
|
+
schema: z.object({
|
|
2105
|
+
segmentId: z.string().min(1).describe("Segment ID from list_segments."),
|
|
2106
|
+
scope: z.enum(["workspace", "org"]).optional().describe("Segment scope (default workspace)."),
|
|
2107
|
+
confirmInUse: z
|
|
2108
|
+
.boolean()
|
|
2109
|
+
.optional()
|
|
2110
|
+
.describe("Pass true only after the owner confirms deleting a segment currently referenced by one or more journeys."),
|
|
2111
|
+
}),
|
|
2112
|
+
handler: async (args) => {
|
|
2113
|
+
try {
|
|
2114
|
+
const scope = args.scope ?? "workspace";
|
|
2115
|
+
if (!args.confirmInUse) {
|
|
2116
|
+
try {
|
|
2117
|
+
const usageRes = await apiGet("/api/segments/usage");
|
|
2118
|
+
const usedIn = usageRes?.data?.usage?.[args.segmentId] ?? 0;
|
|
2119
|
+
if (usedIn > 0) {
|
|
2120
|
+
return {
|
|
2121
|
+
content: [
|
|
2122
|
+
{
|
|
2123
|
+
type: "text",
|
|
2124
|
+
text: `${APEX} Segment "${args.segmentId}" is currently used in ${usedIn} ${usedIn === 1 ? "journey" : "journeys"}. Deleting it will stop those journeys from enrolling people through it. Confirm with the owner, then retry with confirm_in_use: true.`,
|
|
2125
|
+
},
|
|
2126
|
+
],
|
|
2127
|
+
isError: true,
|
|
2128
|
+
};
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
catch {
|
|
2132
|
+
// Usage endpoint is best-effort for workspace segments; proceed if unavailable.
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
await apiDelete(`/api/segments/${encodeURIComponent(args.segmentId)}?scope=${scope}`);
|
|
2136
|
+
return {
|
|
2137
|
+
content: [
|
|
2138
|
+
{
|
|
2139
|
+
type: "text",
|
|
2140
|
+
text: `${APEX} Deleted segment "${args.segmentId}" (scope: ${scope}).`,
|
|
2141
|
+
},
|
|
2142
|
+
],
|
|
2143
|
+
};
|
|
2144
|
+
}
|
|
2145
|
+
catch (err) {
|
|
2146
|
+
return { content: [{ type: "text", text: `${APEX} ${errMsg(err)}` }], isError: true };
|
|
2147
|
+
}
|
|
2148
|
+
},
|
|
2149
|
+
},
|
|
2031
2150
|
};
|
|
2032
2151
|
//# sourceMappingURL=letters.js.map
|