@apex-inc/mcp-server 0.75.0 → 0.79.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/api-client.d.ts +13 -21
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +203 -61
- package/dist/api-client.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +7 -6
- package/dist/auth.js.map +1 -1
- package/dist/fetch-timeout.d.ts +23 -0
- package/dist/fetch-timeout.d.ts.map +1 -0
- package/dist/fetch-timeout.js +78 -0
- package/dist/fetch-timeout.js.map +1 -0
- package/dist/hosted.d.ts +34 -0
- package/dist/hosted.d.ts.map +1 -0
- package/dist/hosted.js +74 -0
- package/dist/hosted.js.map +1 -0
- package/dist/index.js +49 -117
- package/dist/index.js.map +1 -1
- package/dist/letter-blocks.d.ts.map +1 -1
- package/dist/letter-blocks.js +13 -22
- package/dist/letter-blocks.js.map +1 -1
- package/dist/live-test-files.d.ts +35 -0
- package/dist/live-test-files.d.ts.map +1 -0
- package/dist/live-test-files.js +114 -0
- package/dist/live-test-files.js.map +1 -0
- package/dist/live-test-guard.d.ts.map +1 -1
- package/dist/live-test-guard.js +7 -1
- package/dist/live-test-guard.js.map +1 -1
- package/dist/request-context.d.ts +40 -0
- package/dist/request-context.d.ts.map +1 -0
- package/dist/request-context.js +11 -0
- package/dist/request-context.js.map +1 -0
- package/dist/server-factory.d.ts +31 -0
- package/dist/server-factory.d.ts.map +1 -0
- package/dist/server-factory.js +585 -0
- package/dist/server-factory.js.map +1 -0
- package/dist/setup-catchup-tools.d.ts +4 -0
- package/dist/setup-catchup-tools.d.ts.map +1 -1
- package/dist/setup-catchup-tools.js +33 -67
- package/dist/setup-catchup-tools.js.map +1 -1
- package/dist/smoke-tools.d.ts.map +1 -1
- package/dist/smoke-tools.js +2 -0
- package/dist/smoke-tools.js.map +1 -1
- package/dist/tool-catalog.d.ts +2 -0
- package/dist/tool-catalog.d.ts.map +1 -1
- package/dist/tool-catalog.js +6 -1
- package/dist/tool-catalog.js.map +1 -1
- package/dist/tool-groups.d.ts.map +1 -1
- package/dist/tool-groups.js +12 -0
- package/dist/tool-groups.js.map +1 -1
- package/dist/tool-mode.d.ts +48 -0
- package/dist/tool-mode.d.ts.map +1 -0
- package/dist/tool-mode.js +189 -0
- package/dist/tool-mode.js.map +1 -0
- package/dist/tool-shared.d.ts +9 -1
- package/dist/tool-shared.d.ts.map +1 -1
- package/dist/tool-shared.js +52 -6
- package/dist/tool-shared.js.map +1 -1
- package/dist/tools/adoption.d.ts.map +1 -1
- package/dist/tools/adoption.js +2 -1
- package/dist/tools/adoption.js.map +1 -1
- package/dist/tools/apex-campaigns.d.ts +394 -0
- package/dist/tools/apex-campaigns.d.ts.map +1 -1
- package/dist/tools/apex-campaigns.js +256 -1
- package/dist/tools/apex-campaigns.js.map +1 -1
- package/dist/tools/context.d.ts +2 -2
- package/dist/tools/experiments.d.ts +69 -1
- package/dist/tools/experiments.d.ts.map +1 -1
- package/dist/tools/experiments.js +140 -76
- package/dist/tools/experiments.js.map +1 -1
- package/dist/tools/letters.d.ts +214 -48
- package/dist/tools/letters.d.ts.map +1 -1
- package/dist/tools/letters.js +240 -44
- package/dist/tools/letters.js.map +1 -1
- package/dist/tools/measurement.d.ts +70 -28
- package/dist/tools/measurement.d.ts.map +1 -1
- package/dist/tools/measurement.js +165 -27
- package/dist/tools/measurement.js.map +1 -1
- package/dist/tools.d.ts +774 -76
- package/dist/tools.d.ts.map +1 -1
- package/package.json +11 -1
- package/skills/apex-growth-intelligence/SKILL.md +4 -0
- package/skills/apex-growth-tracking/SKILL.md +1 -1
- package/skills/apex-integration-cookbook/SKILL.md +23 -3
- package/skills/apex-setup/SKILL.md +2 -1
- package/skills/apex-spec/SKILL.md +6 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
2
|
import { apiGet, apiPost, apiPatch, apiDelete, getActiveWorkspace, } from "../api-client.js";
|
|
3
|
+
import { LONG_REQUEST_TIMEOUT_MS } from "../fetch-timeout.js";
|
|
4
|
+
import { resolveLiveCheckFiles } from "../live-test-files.js";
|
|
5
5
|
import { resolveExperimentHypothesis } from "../experiment-copy.js";
|
|
6
6
|
import { activationLiveLine, shouldRefuseActivationWiring } from "../activation-wiring.js";
|
|
7
7
|
import { parseFrontDoorRefusal, renderFrontDoorRefusal } from "../belief-front-door.js";
|
|
8
8
|
import { apexBaseUrl } from "../base-url.js";
|
|
9
9
|
import { fetchLiveTestHits, formatLiveTestStop, isFileStop, isObjectStop, } from "../live-test-guard.js";
|
|
10
10
|
import { hasConflictAdvisory, renderConflictAdvisory, } from "../conflict-advisory.js";
|
|
11
|
-
import { APEX, controlPctOf, daysRunningOf, experimentTimingLabel, predictionLines, findVariant, missingScreenshotLines, formatArmLine, titleCaseEvent, assertTargetUrlForActiveWorkspace, errMsg, resolveCreateSurface, } from "../tool-shared.js";
|
|
12
|
-
const STARTING_CONFIDENCE_HELP = "
|
|
13
|
-
const NEW_BECAUSE_HELP = "
|
|
11
|
+
import { appUrl, APEX, controlPctOf, daysRunningOf, experimentTimingLabel, predictionLines, findVariant, missingScreenshotLines, formatArmLine, titleCaseEvent, assertTargetUrlForActiveWorkspace, errMsg, resolveCreateSurface, } from "../tool-shared.js";
|
|
12
|
+
const STARTING_CONFIDENCE_HELP = "Omit unless backed by prior test/data (untested claims start at 50%).";
|
|
13
|
+
const NEW_BECAUSE_HELP = "One sentence on how this differs from related beliefs (only after Apex returned matches).";
|
|
14
14
|
const NETWORK_WORD = {
|
|
15
15
|
meta: "Meta",
|
|
16
16
|
google: "Google",
|
|
@@ -45,7 +45,7 @@ const KEY_EVENT_GOAL_PARAM = {
|
|
|
45
45
|
primaryMetricKeyEventId: z
|
|
46
46
|
.string()
|
|
47
47
|
.optional()
|
|
48
|
-
.describe("
|
|
48
|
+
.describe("Key event id (from list_key_events) to judge the test on; pass this OR primary_metric_event, never both."),
|
|
49
49
|
};
|
|
50
50
|
/** The key event a goal names, read from the active workspace, or why it can't be read. */
|
|
51
51
|
async function readKeyEventGoal(id) {
|
|
@@ -79,11 +79,11 @@ const FORM_GOAL_PARAMS = {
|
|
|
79
79
|
primaryMetricFormPage: z
|
|
80
80
|
.string()
|
|
81
81
|
.optional()
|
|
82
|
-
.describe("With primary_metric_event
|
|
82
|
+
.describe("With primary_metric_event='form_submit': count only forms on this path/URL."),
|
|
83
83
|
primaryMetricFormId: z
|
|
84
84
|
.string()
|
|
85
85
|
.optional()
|
|
86
|
-
.describe("With primary_metric_event
|
|
86
|
+
.describe("With primary_metric_event='form_submit': count only this HTML form id."),
|
|
87
87
|
};
|
|
88
88
|
/** The page-and-form narrowing for a form goal, or why it was refused. */
|
|
89
89
|
function formGoalOf(args) {
|
|
@@ -434,49 +434,49 @@ export const experimentTools = {
|
|
|
434
434
|
},
|
|
435
435
|
},
|
|
436
436
|
create_experiment: {
|
|
437
|
-
description: `${APEX} — Create an experiment
|
|
437
|
+
description: `${APEX} — Create an experiment draft and implementation recipe (useApexVariant). Call with preview=true first.`,
|
|
438
438
|
schema: z.object({
|
|
439
439
|
name: z.string().describe("Experiment name"),
|
|
440
|
-
targetUrl: z.string().optional().describe("
|
|
441
|
-
controlContent: z.string().optional().describe("
|
|
442
|
-
variantContent: z.string().optional().describe("
|
|
443
|
-
targetComponent: z.string().optional().describe("
|
|
444
|
-
targetAnchor: z.string().optional().describe("Section anchor/ID
|
|
445
|
-
trafficSplit: z.number().min(1).max(99).optional().describe("
|
|
446
|
-
beliefId: z.string().optional().describe("
|
|
447
|
-
hypothesisId: z.string().optional().describe("
|
|
448
|
-
predictionId: z.string().optional().describe("
|
|
449
|
-
beliefStatement: z.string().optional().describe("
|
|
450
|
-
beliefConfidence: z.number().min(0).max(100).optional().describe(`
|
|
451
|
-
newBecause: z.string().optional().describe(`With beliefStatement
|
|
452
|
-
hypothesisStatement: z.string().optional().describe("Optional hypothesis
|
|
453
|
-
primaryMetricEvent: z.string().optional().describe("
|
|
454
|
-
primaryMetricType: z.enum(["rate", "count", "revenue", "duration"]).optional().describe("
|
|
455
|
-
primaryMetricValueProperty: z.string().optional().describe("
|
|
440
|
+
targetUrl: z.string().optional().describe("Registered host URL on the active workspace (include #anchor if needed). Required for web/mobile."),
|
|
441
|
+
controlContent: z.string().optional().describe("Current control content (required for web/mobile)."),
|
|
442
|
+
variantContent: z.string().optional().describe("New variant content (required for web/mobile)."),
|
|
443
|
+
targetComponent: z.string().optional().describe("Target component or file path"),
|
|
444
|
+
targetAnchor: z.string().optional().describe("Section anchor/ID (e.g. 'pricing', 'hero')"),
|
|
445
|
+
trafficSplit: z.number().min(1).max(99).optional().describe("Control traffic % (default 50)"),
|
|
446
|
+
beliefId: z.string().optional().describe("Existing assumption id"),
|
|
447
|
+
hypothesisId: z.string().optional().describe("Existing hypothesis id"),
|
|
448
|
+
predictionId: z.string().optional().describe("Existing prediction id"),
|
|
449
|
+
beliefStatement: z.string().optional().describe("Create and link a new belief + hypothesis if no beliefId"),
|
|
450
|
+
beliefConfidence: z.number().min(0).max(100).optional().describe(`With beliefStatement: ${STARTING_CONFIDENCE_HELP}`),
|
|
451
|
+
newBecause: z.string().optional().describe(`With beliefStatement: ${NEW_BECAUSE_HELP}`),
|
|
452
|
+
hypothesisStatement: z.string().optional().describe("Optional hypothesis alongside beliefStatement"),
|
|
453
|
+
primaryMetricEvent: z.string().optional().describe("Goal event (standard or workspace event from list_metrics). Prefer outcome over proxy."),
|
|
454
|
+
primaryMetricType: z.enum(["rate", "count", "revenue", "duration"]).optional().describe("Goal type: rate (default), count, revenue, or duration."),
|
|
455
|
+
primaryMetricValueProperty: z.string().optional().describe("Property to sum for revenue/duration goals (default 'value')."),
|
|
456
456
|
...KEY_EVENT_GOAL_PARAM,
|
|
457
457
|
...FORM_GOAL_PARAMS,
|
|
458
|
-
guardrailEvent: z.string().optional().describe("
|
|
459
|
-
guardrailType: z.enum(["rate", "revenue", "duration"]).optional().describe("
|
|
460
|
-
guardrailThreshold: z.number().optional().describe("
|
|
461
|
-
predictionMagnitude: z.string().optional().describe("
|
|
462
|
-
surface: z.enum(["web", "mobile", "paid_channel"]).optional().describe("
|
|
458
|
+
guardrailEvent: z.string().optional().describe("Optional extra protective event (Apex already auto-protects revenue/refunds/errors)."),
|
|
459
|
+
guardrailType: z.enum(["rate", "revenue", "duration"]).optional().describe("Guardrail type: rate (default), revenue, or duration."),
|
|
460
|
+
guardrailThreshold: z.number().optional().describe("Relative harm threshold (default 0.25 = +25%)."),
|
|
461
|
+
predictionMagnitude: z.string().optional().describe("Expected lift (e.g. '10% lift'). Required before activation."),
|
|
462
|
+
surface: z.enum(["web", "mobile", "paid_channel"]).optional().describe("Property: 'web', 'mobile', or 'paid_channel' (Ad holdout). Auto-detected when omitted."),
|
|
463
463
|
paid_channel: z
|
|
464
464
|
.object({
|
|
465
|
-
network: z.enum(["meta", "google", "tiktok", "linkedin"]).describe("Ad network
|
|
466
|
-
ad_account_id: z.string().optional().describe("
|
|
467
|
-
ad_set_ids: z.array(z.string()).min(1).describe("Ad set
|
|
468
|
-
holdout_percent: z.number().min(0.05).max(0.5).describe("
|
|
469
|
-
attach_mode: z.enum(["apex", "manual"]).optional().describe("'apex'
|
|
470
|
-
washout_days: z.number().int().min(0).max(30).optional().describe("
|
|
471
|
-
population_segment_id: z.string().optional().describe("Optional Segment id narrowing
|
|
465
|
+
network: z.enum(["meta", "google", "tiktok", "linkedin"]).describe("Ad network (Meta or Google)."),
|
|
466
|
+
ad_account_id: z.string().optional().describe("Ad account id (omit for connected default)."),
|
|
467
|
+
ad_set_ids: z.array(z.string()).min(1).describe("Ad set / Google campaign ids (max 20, frozen at create)."),
|
|
468
|
+
holdout_percent: z.number().min(0.05).max(0.5).describe("Held-back share, 0.05-0.5 (e.g. 0.2)."),
|
|
469
|
+
attach_mode: z.enum(["apex", "manual"]).optional().describe("'apex' (Meta default) or 'manual' (Google default)."),
|
|
470
|
+
washout_days: z.number().int().min(0).max(30).optional().describe("Washout days before counting (default 3)."),
|
|
471
|
+
population_segment_id: z.string().optional().describe("Optional Segment id narrowing population."),
|
|
472
472
|
})
|
|
473
473
|
.optional()
|
|
474
|
-
.describe("Ad holdout
|
|
475
|
-
dataSourceId: z.string().optional().describe("Optional
|
|
476
|
-
randomizationUnit: z.enum(["device", "visitor", "person", "account", "org"]).optional().describe("
|
|
477
|
-
minSamplePerArm: z.number().int().min(30).optional().describe("
|
|
478
|
-
runtimeDays: z.number().int().min(1).max(365).optional().describe("
|
|
479
|
-
preview: z.boolean().optional().describe("
|
|
474
|
+
.describe("Ad holdout config (required for surface='paid_channel')."),
|
|
475
|
+
dataSourceId: z.string().optional().describe("Optional Data Source id (usually inferred from surface)."),
|
|
476
|
+
randomizationUnit: z.enum(["device", "visitor", "person", "account", "org"]).optional().describe("Bucketing unit (default 'visitor')."),
|
|
477
|
+
minSamplePerArm: z.number().int().min(30).optional().describe("Min exposed subjects per arm (default 50, floor 30; frozen at launch)."),
|
|
478
|
+
runtimeDays: z.number().int().min(1).max(365).optional().describe("Max runtime in days (default 14; frozen at launch)."),
|
|
479
|
+
preview: z.boolean().optional().describe("Preview without creating (default true)."),
|
|
480
480
|
}),
|
|
481
481
|
handler: async (args) => {
|
|
482
482
|
// Mobile Measurement P3a — an Ad holdout is not a code change. No page,
|
|
@@ -1040,7 +1040,9 @@ export const experimentTools = {
|
|
|
1040
1040
|
}),
|
|
1041
1041
|
handler: async ({ experimentId }) => {
|
|
1042
1042
|
try {
|
|
1043
|
-
const res = await apiPost(`/api/experiments/${encodeURIComponent(experimentId)}/recapture`, {}
|
|
1043
|
+
const res = await apiPost(`/api/experiments/${encodeURIComponent(experimentId)}/recapture`, {}, {
|
|
1044
|
+
timeoutMs: LONG_REQUEST_TIMEOUT_MS,
|
|
1045
|
+
});
|
|
1044
1046
|
const { captured, errors, identical, message } = res.data;
|
|
1045
1047
|
const lines = [
|
|
1046
1048
|
`${APEX} Re-captured ${captured} screenshot${captured === 1 ? "" : "s"} for ${experimentId}.`,
|
|
@@ -1668,15 +1670,20 @@ export const experimentTools = {
|
|
|
1668
1670
|
},
|
|
1669
1671
|
},
|
|
1670
1672
|
list_beliefs: {
|
|
1671
|
-
description: `${APEX} — List the workspace's beliefs (the assumptions experiments test). Shows confidence, validation state, and AI-generated provenance so you can LINK an existing belief instead of minting a duplicate.`,
|
|
1673
|
+
description: `${APEX} — List the workspace's beliefs (the assumptions experiments test). Shows confidence, validation state, and AI-generated provenance so you can LINK an existing belief instead of minting a duplicate. Pass include_archived: true to include archived beliefs.`,
|
|
1672
1674
|
schema: z.object({
|
|
1673
1675
|
query: z
|
|
1674
1676
|
.string()
|
|
1675
1677
|
.optional()
|
|
1676
1678
|
.describe("Filter beliefs by a keyword in the statement"),
|
|
1679
|
+
includeArchived: z
|
|
1680
|
+
.boolean()
|
|
1681
|
+
.optional()
|
|
1682
|
+
.describe("Include archived beliefs (default false)."),
|
|
1677
1683
|
}),
|
|
1678
|
-
handler: async ({ query }) => {
|
|
1679
|
-
const
|
|
1684
|
+
handler: async ({ query, includeArchived }) => {
|
|
1685
|
+
const path = includeArchived ? "/api/beliefs?includeArchived=true" : "/api/beliefs";
|
|
1686
|
+
const beliefs = await apiGet(path);
|
|
1680
1687
|
const q = query?.toLowerCase().trim();
|
|
1681
1688
|
const filtered = q
|
|
1682
1689
|
? beliefs.filter((b) => b.statement.toLowerCase().includes(q))
|
|
@@ -1696,6 +1703,7 @@ export const experimentTools = {
|
|
|
1696
1703
|
.map((b) => {
|
|
1697
1704
|
const tags = [
|
|
1698
1705
|
`${Math.round(b.confidence * 100)}% confidence`,
|
|
1706
|
+
b.archivedAt ? "archived" : null,
|
|
1699
1707
|
b.validationState === "unvalidated" ? "unvalidated" : null,
|
|
1700
1708
|
b.generatedFromExperimentId ? "AI-generated" : null,
|
|
1701
1709
|
]
|
|
@@ -1713,7 +1721,7 @@ export const experimentTools = {
|
|
|
1713
1721
|
`${"═".repeat(40)}`,
|
|
1714
1722
|
lines,
|
|
1715
1723
|
``,
|
|
1716
|
-
`Link one to a new experiment with its id, or
|
|
1724
|
+
`Link one to a new experiment with its id, edit wording with update_belief, or retire an obsolete claim with archive_belief.`,
|
|
1717
1725
|
`If two of these state the same claim, merge them (merge_beliefs) so their evidence adds up in one place.`,
|
|
1718
1726
|
].join("\n"),
|
|
1719
1727
|
},
|
|
@@ -1721,6 +1729,65 @@ export const experimentTools = {
|
|
|
1721
1729
|
};
|
|
1722
1730
|
},
|
|
1723
1731
|
},
|
|
1732
|
+
update_belief: {
|
|
1733
|
+
description: `${APEX} — Edit a belief's statement in place (for example during a rebrand or to clarify wording). Preserves the belief's id, confidence, evidence, and linked experiments. Workspace admin.`,
|
|
1734
|
+
schema: z.object({
|
|
1735
|
+
beliefId: z.string().min(1).describe("The belief id to edit (from list_beliefs)."),
|
|
1736
|
+
statement: z.string().trim().min(1).max(2000).describe("The updated belief statement."),
|
|
1737
|
+
}),
|
|
1738
|
+
handler: async ({ beliefId, statement }) => {
|
|
1739
|
+
try {
|
|
1740
|
+
const res = await apiPatch(`/api/beliefs/${encodeURIComponent(beliefId)}`, { statement: statement.trim() });
|
|
1741
|
+
const updated = res.data;
|
|
1742
|
+
return {
|
|
1743
|
+
content: [
|
|
1744
|
+
{
|
|
1745
|
+
type: "text",
|
|
1746
|
+
text: [
|
|
1747
|
+
`${APEX} Belief updated (${updated?.id ?? beliefId})`,
|
|
1748
|
+
` Statement: "${updated?.statement ?? statement.trim()}"`,
|
|
1749
|
+
` Open Beliefs: ${appUrl("/dashboard/beliefs")}`,
|
|
1750
|
+
].join("\n"),
|
|
1751
|
+
},
|
|
1752
|
+
],
|
|
1753
|
+
};
|
|
1754
|
+
}
|
|
1755
|
+
catch (err) {
|
|
1756
|
+
return textError(`Could not update belief: ${errMsg(err)}`);
|
|
1757
|
+
}
|
|
1758
|
+
},
|
|
1759
|
+
},
|
|
1760
|
+
archive_belief: {
|
|
1761
|
+
description: `${APEX} — Archive (or restore) a belief so retired claims leave active lists and duplicate checks while keeping past experiment history intact. Refuses if an active experiment is currently testing this belief. Pass archived: false to restore an archived belief. Workspace admin.`,
|
|
1762
|
+
schema: z.object({
|
|
1763
|
+
beliefId: z.string().min(1).describe("The belief id to archive or restore (from list_beliefs)."),
|
|
1764
|
+
archived: z
|
|
1765
|
+
.boolean()
|
|
1766
|
+
.optional()
|
|
1767
|
+
.describe("true (default) to archive; false to restore an archived belief."),
|
|
1768
|
+
}),
|
|
1769
|
+
handler: async ({ beliefId, archived = true }) => {
|
|
1770
|
+
try {
|
|
1771
|
+
const res = await apiPatch(`/api/beliefs/${encodeURIComponent(beliefId)}`, { archived });
|
|
1772
|
+
const updated = res.data;
|
|
1773
|
+
return {
|
|
1774
|
+
content: [
|
|
1775
|
+
{
|
|
1776
|
+
type: "text",
|
|
1777
|
+
text: [
|
|
1778
|
+
`${APEX} Belief ${archived ? "archived" : "restored"} (${updated?.id ?? beliefId})`,
|
|
1779
|
+
` Statement: "${updated?.statement ?? beliefId}"`,
|
|
1780
|
+
` Open Beliefs: ${appUrl("/dashboard/beliefs")}`,
|
|
1781
|
+
].join("\n"),
|
|
1782
|
+
},
|
|
1783
|
+
],
|
|
1784
|
+
};
|
|
1785
|
+
}
|
|
1786
|
+
catch (err) {
|
|
1787
|
+
return textError(`Could not ${archived ? "archive" : "restore"} belief: ${errMsg(err)}`);
|
|
1788
|
+
}
|
|
1789
|
+
},
|
|
1790
|
+
},
|
|
1724
1791
|
merge_beliefs: {
|
|
1725
1792
|
description: `${APEX} — Merge a duplicate belief into the one that survives. Use when two beliefs state the same claim, so their evidence is split and neither confidence tells the truth. Moves the duplicate's evidence, hypotheses, predictions, outcomes, decision-log entries, child beliefs and linked tests onto the survivor, writes a decision-log entry naming what moved, and keeps the duplicate as a redirect (old ids still resolve; lists hide it). Not reversible from the tools. Show the user both statements and get their go-ahead before calling.`,
|
|
1726
1793
|
schema: z.object({
|
|
@@ -2051,22 +2118,23 @@ export const experimentTools = {
|
|
|
2051
2118
|
},
|
|
2052
2119
|
},
|
|
2053
2120
|
update_experiment: {
|
|
2054
|
-
description: `${APEX} — Edit an
|
|
2121
|
+
description: `${APEX} — Edit an existing experiment. Drafts are editable; running experiments freeze pre-registration and bucketing (use fork_experiment instead).`,
|
|
2055
2122
|
schema: z.object({
|
|
2056
|
-
experimentId: z.string().describe("
|
|
2057
|
-
name: z.string().optional().describe("Rename (
|
|
2058
|
-
surface: z.enum(["web", "mobile", "paid_channel"]).optional().describe("
|
|
2059
|
-
hypothesis: z.string().optional().describe("
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2123
|
+
experimentId: z.string().describe("Experiment id"),
|
|
2124
|
+
name: z.string().optional().describe("Rename (editable anytime)"),
|
|
2125
|
+
surface: z.enum(["web", "mobile", "paid_channel"]).optional().describe("Surface (draft with 0 exposures only)"),
|
|
2126
|
+
hypothesis: z.string().optional().describe("Hypothesis (draft only)"),
|
|
2127
|
+
beliefId: z.string().min(1).optional().describe("Re-link to another belief id (draft only)"),
|
|
2128
|
+
targetUrl: z.string().optional().describe("Retarget draft to a registered workspace URL"),
|
|
2129
|
+
predictionId: z.string().optional().describe("Attach a prediction id from log_prediction (required before activation)"),
|
|
2130
|
+
primaryMetricEvent: z.string().optional().describe("Primary goal event (draft only)"),
|
|
2063
2131
|
primaryMetricType: z.enum(["rate", "count", "revenue", "duration"]).optional(),
|
|
2064
2132
|
...KEY_EVENT_GOAL_PARAM,
|
|
2065
2133
|
...FORM_GOAL_PARAMS,
|
|
2066
|
-
guardrailEvent: z.string().optional().describe("
|
|
2067
|
-
minSamplePerArm: z.number().int().min(30).optional().describe("
|
|
2068
|
-
runtimeDays: z.number().int().min(1).max(365).optional().describe("
|
|
2069
|
-
allocation: z.enum(["even", "adaptive"]).optional().describe("Journey message
|
|
2134
|
+
guardrailEvent: z.string().optional().describe("Extra protective guardrail event (draft only)"),
|
|
2135
|
+
minSamplePerArm: z.number().int().min(30).optional().describe("Min exposed subjects per arm (floor 30; draft only)"),
|
|
2136
|
+
runtimeDays: z.number().int().min(1).max(365).optional().describe("Max runtime in days (draft only)"),
|
|
2137
|
+
allocation: z.enum(["even", "adaptive"]).optional().describe("Journey message test split (draft only): 'even' (default) or 'adaptive'. Ask the owner before changing."),
|
|
2070
2138
|
}),
|
|
2071
2139
|
handler: async (args) => {
|
|
2072
2140
|
if (args.targetUrl) {
|
|
@@ -2104,6 +2172,8 @@ export const experimentTools = {
|
|
|
2104
2172
|
body.surface = args.surface;
|
|
2105
2173
|
if (args.hypothesis !== undefined)
|
|
2106
2174
|
body.hypothesis = args.hypothesis;
|
|
2175
|
+
if (args.beliefId !== undefined)
|
|
2176
|
+
body.beliefId = args.beliefId.trim();
|
|
2107
2177
|
if (args.targetUrl !== undefined)
|
|
2108
2178
|
body.targetUrl = args.targetUrl;
|
|
2109
2179
|
if (args.predictionId !== undefined)
|
|
@@ -2263,13 +2333,17 @@ export const experimentTools = {
|
|
|
2263
2333
|
file_paths: z
|
|
2264
2334
|
.array(z.string())
|
|
2265
2335
|
.optional()
|
|
2266
|
-
.describe("Repo-relative paths you are about to edit or commit.
|
|
2336
|
+
.describe("Repo-relative or absolute paths you are about to edit or commit. When editing inside a git worktree or another checkout, pass file_contents (preferred), absolute paths, or repo_root so Apex reads the right copy."),
|
|
2267
2337
|
file_contents: z
|
|
2268
2338
|
.array(z.object({
|
|
2269
2339
|
path: z.string(),
|
|
2270
2340
|
content: z.string().describe("Full file at HEAD, not the diff hunk."),
|
|
2271
2341
|
}))
|
|
2272
2342
|
.optional(),
|
|
2343
|
+
repo_root: z
|
|
2344
|
+
.string()
|
|
2345
|
+
.optional()
|
|
2346
|
+
.describe("Absolute path to the repo or git worktree root you are editing. Resolves relative file_paths against this folder instead of the MCP process directory."),
|
|
2273
2347
|
urls: z
|
|
2274
2348
|
.array(z.string())
|
|
2275
2349
|
.optional()
|
|
@@ -2289,21 +2363,11 @@ export const experimentTools = {
|
|
|
2289
2363
|
}),
|
|
2290
2364
|
handler: async (args) => {
|
|
2291
2365
|
try {
|
|
2292
|
-
const
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
}
|
|
2297
|
-
for (const raw of args.file_paths ?? []) {
|
|
2298
|
-
if (!raw || byPath.has(raw))
|
|
2299
|
-
continue;
|
|
2300
|
-
const abs = raw.startsWith("/") ? raw : join(process.cwd(), raw);
|
|
2301
|
-
byPath.set(raw, {
|
|
2302
|
-
path: raw,
|
|
2303
|
-
content: existsSync(abs) ? readFileSync(abs, "utf8") : undefined,
|
|
2304
|
-
});
|
|
2305
|
-
}
|
|
2306
|
-
const files = [...byPath.values()];
|
|
2366
|
+
const files = resolveLiveCheckFiles({
|
|
2367
|
+
filePaths: args.file_paths,
|
|
2368
|
+
fileContents: args.file_contents,
|
|
2369
|
+
repoRoot: args.repo_root,
|
|
2370
|
+
});
|
|
2307
2371
|
const hits = await fetchLiveTestHits({
|
|
2308
2372
|
files,
|
|
2309
2373
|
urls: args.urls,
|