@apex-inc/mcp-server 0.33.0 → 0.35.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 +19 -18
- package/dist/api-client.d.ts +5 -0
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +40 -24
- package/dist/api-client.js.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +5 -7
- package/dist/prompts.js.map +1 -1
- package/dist/setup-catchup-tools.d.ts +98 -0
- package/dist/setup-catchup-tools.d.ts.map +1 -1
- package/dist/setup-catchup-tools.js +84 -3
- package/dist/setup-catchup-tools.js.map +1 -1
- package/dist/smoke-tools.d.ts +56 -0
- package/dist/smoke-tools.d.ts.map +1 -0
- package/dist/smoke-tools.js +262 -0
- package/dist/smoke-tools.js.map +1 -0
- package/dist/tool-catalog.d.ts +10 -0
- package/dist/tool-catalog.d.ts.map +1 -0
- package/dist/tool-catalog.js +36 -0
- package/dist/tool-catalog.js.map +1 -0
- package/dist/tool-groups.d.ts +5 -0
- package/dist/tool-groups.d.ts.map +1 -0
- package/dist/tool-groups.js +213 -0
- package/dist/tool-groups.js.map +1 -0
- package/dist/tool-shared.d.ts +300 -0
- package/dist/tool-shared.d.ts.map +1 -0
- package/dist/tool-shared.js +319 -0
- package/dist/tool-shared.js.map +1 -0
- package/dist/tools/accounts.d.ts +124 -0
- package/dist/tools/accounts.d.ts.map +1 -0
- package/dist/tools/accounts.js +99 -0
- package/dist/tools/accounts.js.map +1 -0
- package/dist/tools/adoption.d.ts +499 -0
- package/dist/tools/adoption.d.ts.map +1 -0
- package/dist/tools/adoption.js +447 -0
- package/dist/tools/adoption.js.map +1 -0
- package/dist/tools/context.d.ts +216 -0
- package/dist/tools/context.d.ts.map +1 -0
- package/dist/tools/context.js +328 -0
- package/dist/tools/context.js.map +1 -0
- package/dist/tools/experiments.d.ts +1250 -0
- package/dist/tools/experiments.d.ts.map +1 -0
- package/dist/tools/experiments.js +2563 -0
- package/dist/tools/experiments.js.map +1 -0
- package/dist/tools/letters.d.ts +1107 -0
- package/dist/tools/letters.d.ts.map +1 -0
- package/dist/tools/letters.js +1324 -0
- package/dist/tools/letters.js.map +1 -0
- package/dist/tools/measurement.d.ts +886 -0
- package/dist/tools/measurement.d.ts.map +1 -0
- package/dist/tools/measurement.js +1353 -0
- package/dist/tools/measurement.js.map +1 -0
- package/dist/tools/partners.d.ts +364 -0
- package/dist/tools/partners.d.ts.map +1 -0
- package/dist/tools/partners.js +199 -0
- package/dist/tools/partners.js.map +1 -0
- package/dist/tools.d.ts +3445 -2825
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +26 -6112
- package/dist/tools.js.map +1 -1
- package/package.json +3 -2
- package/skills/apex-communications/SKILL.md +5 -5
- package/skills/apex-experimentation/SKILL.md +43 -11
- package/skills/apex-growth-intelligence/SKILL.md +23 -2
- package/skills/apex-growth-tracking/SKILL.md +10 -1
- package/skills/apex-integration-cookbook/SKILL.md +24 -1
- package/skills/apex-journeys/SKILL.md +19 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { join, dirname } from "node:path";
|
|
4
|
+
import { apiGet, setActiveWorkspace, getActiveWorkspace, getUserContext } from "./api-client.js";
|
|
5
|
+
import { collectHosts, evaluateTargetUrl } from "./workspace-target-url.js";
|
|
6
|
+
export const APEX = "Apex";
|
|
7
|
+
/**
|
|
8
|
+
* MOBX-006 — stable synthetic visitor id for agent-fired events.
|
|
9
|
+
*
|
|
10
|
+
* `/api/events` only counts an event toward wiring detection when it
|
|
11
|
+
* carries a top-level `visitorId`. A per-process random suffix keeps
|
|
12
|
+
* the id stable for the MCP server's lifetime (so repeated track_event
|
|
13
|
+
* calls roll up to one synthetic "visitor") while distinguishing
|
|
14
|
+
* separate agent sessions from each other.
|
|
15
|
+
*/
|
|
16
|
+
export const MCP_AGENT_VISITOR_ID = `mcp-agent-${Math.random().toString(36).slice(2, 10)}`;
|
|
17
|
+
/** Control traffic % derived from the unified allocation weights (default 50). */
|
|
18
|
+
export function controlPctOf(exp) {
|
|
19
|
+
const w = exp.allocation?.weights?.control;
|
|
20
|
+
return typeof w === "number" ? Math.round(w * 100) : 50;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Days running, derived locally from startedAt/createdAt → completedAt/now.
|
|
24
|
+
* The legacy web shape carried a server-computed `daysRunning`; the unified
|
|
25
|
+
* shape does not, so we compute it from the lifecycle timestamps.
|
|
26
|
+
*/
|
|
27
|
+
export function daysRunningOf(exp) {
|
|
28
|
+
const start = exp.startedAt || exp.createdAt;
|
|
29
|
+
if (!start)
|
|
30
|
+
return 0;
|
|
31
|
+
const startMs = new Date(start).getTime();
|
|
32
|
+
if (Number.isNaN(startMs))
|
|
33
|
+
return 0;
|
|
34
|
+
const endMs = exp.completedAt ? new Date(exp.completedAt).getTime() : Date.now();
|
|
35
|
+
return Math.max(0, Math.floor((endMs - startMs) / 86_400_000));
|
|
36
|
+
}
|
|
37
|
+
/** Find a unified variant by its key (e.g. "control", "variant_a"). */
|
|
38
|
+
export function findVariant(exp, key) {
|
|
39
|
+
return exp.variants?.find((v) => v.key === key);
|
|
40
|
+
}
|
|
41
|
+
/** Render a per-arm exposure line for wiring summaries. */
|
|
42
|
+
export function formatArmLine(arm) {
|
|
43
|
+
const live = arm.exposures > 0;
|
|
44
|
+
const dot = live ? "●" : "○";
|
|
45
|
+
const seen = arm.lastSeenAt ? `, last seen ${arm.lastSeenAt}` : "";
|
|
46
|
+
return ` ${dot} ${arm.label} (${arm.variantKey}): ${arm.exposures} exposure${arm.exposures === 1 ? "" : "s"}${seen}`;
|
|
47
|
+
}
|
|
48
|
+
/** "add_to_cart" → "Add To Cart" (for primaryMetric labels). */
|
|
49
|
+
export function titleCaseEvent(event) {
|
|
50
|
+
return event
|
|
51
|
+
.split(/[_\s]+/)
|
|
52
|
+
.filter(Boolean)
|
|
53
|
+
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
|
|
54
|
+
.join(" ");
|
|
55
|
+
}
|
|
56
|
+
export function activeWorkspaceSiteUrl() {
|
|
57
|
+
const ctx = getUserContext();
|
|
58
|
+
const key = getActiveWorkspace();
|
|
59
|
+
if (!ctx || !key)
|
|
60
|
+
return null;
|
|
61
|
+
for (const org of ctx.orgs) {
|
|
62
|
+
const match = org.workspaces.find((w) => w.workspaceKey === key);
|
|
63
|
+
if (match?.url)
|
|
64
|
+
return match.url;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
export async function assertTargetUrlForActiveWorkspace(targetUrl) {
|
|
69
|
+
const namedSites = [];
|
|
70
|
+
let workspaceUrl = activeWorkspaceSiteUrl();
|
|
71
|
+
let catalogUnreadable = false;
|
|
72
|
+
try {
|
|
73
|
+
const env = await apiGet("/api/workspace/environments");
|
|
74
|
+
namedSites.push(...(env.data.production_hosts ?? []), ...(env.data.beta_hosts ?? []));
|
|
75
|
+
for (const row of env.data.known_hosts ?? []) {
|
|
76
|
+
namedSites.push(typeof row === "string" ? row : row.hostname ?? "");
|
|
77
|
+
}
|
|
78
|
+
if (env.data.workspace_url)
|
|
79
|
+
workspaceUrl = env.data.workspace_url;
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
catalogUnreadable = true;
|
|
83
|
+
}
|
|
84
|
+
let analyticsHosts = [];
|
|
85
|
+
try {
|
|
86
|
+
const json = await apiGet("/api/analytics/hostnames?limit=100");
|
|
87
|
+
analyticsHosts = json.data ?? [];
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
/* analytics is a supplement, not the source of truth */
|
|
91
|
+
}
|
|
92
|
+
const allowed = collectHosts({
|
|
93
|
+
analyticsHosts,
|
|
94
|
+
namedSites,
|
|
95
|
+
workspaceUrl,
|
|
96
|
+
});
|
|
97
|
+
if (allowed.length === 0 && catalogUnreadable) {
|
|
98
|
+
return {
|
|
99
|
+
ok: false,
|
|
100
|
+
message: "Could not load this workspace's sites (list_workspace_environments failed). Name the site with set_workspace_environments before setting target_url. Do not guess a brand domain or a sibling workspace's site.",
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return evaluateTargetUrl(targetUrl, allowed);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Query string for the pack report windows: relative (`days` / `months`)
|
|
107
|
+
* or explicit `start` + `end` (YYYY-MM-DD, both required together —
|
|
108
|
+
* explicit bounds win server-side).
|
|
109
|
+
*/
|
|
110
|
+
export function windowQuery(opts) {
|
|
111
|
+
const params = new URLSearchParams();
|
|
112
|
+
if (opts.days)
|
|
113
|
+
params.set("days", String(opts.days));
|
|
114
|
+
if (opts.months)
|
|
115
|
+
params.set("months", String(opts.months));
|
|
116
|
+
if (opts.start && opts.end) {
|
|
117
|
+
params.set("start", opts.start);
|
|
118
|
+
params.set("end", opts.end);
|
|
119
|
+
}
|
|
120
|
+
const qs = params.toString();
|
|
121
|
+
return qs ? `?${qs}` : "";
|
|
122
|
+
}
|
|
123
|
+
export function errMsg(err) {
|
|
124
|
+
return err instanceof Error ? err.message : String(err);
|
|
125
|
+
}
|
|
126
|
+
/** Build a dashboard deep link on the same host the MCP talks to (app origin). */
|
|
127
|
+
export function appUrl(path) {
|
|
128
|
+
const base = process.env.APEX_URL || process.env.APEX_API_URL || "http://localhost:3001";
|
|
129
|
+
return `${base.replace(/\/$/, "")}${path}`;
|
|
130
|
+
}
|
|
131
|
+
export function journeyLink(id) {
|
|
132
|
+
return appUrl(`/dashboard/communications/journeys/${id}`);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Detect a MOBILE experiment surface from repo signals (the MCP runs in the
|
|
136
|
+
* merchant's repo). Walks up a few dirs looking for capacitor.config.* or a
|
|
137
|
+
* Capacitor/RN dependency. Returns null when there's no mobile signal (web is
|
|
138
|
+
* the safe default — a website repo carries no special marker). QA 2026-06-18.
|
|
139
|
+
*/
|
|
140
|
+
export function detectSurfaceFromRepo() {
|
|
141
|
+
try {
|
|
142
|
+
let dir = process.cwd();
|
|
143
|
+
for (let i = 0; i < 4; i++) {
|
|
144
|
+
for (const f of [
|
|
145
|
+
"capacitor.config.ts",
|
|
146
|
+
"capacitor.config.js",
|
|
147
|
+
"capacitor.config.json",
|
|
148
|
+
"capacitor.config.mjs",
|
|
149
|
+
]) {
|
|
150
|
+
if (existsSync(join(dir, f)))
|
|
151
|
+
return "mobile";
|
|
152
|
+
}
|
|
153
|
+
const pkgPath = join(dir, "package.json");
|
|
154
|
+
if (existsSync(pkgPath)) {
|
|
155
|
+
try {
|
|
156
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
157
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
158
|
+
if (deps["@apex-inc/capacitor-plugin"] ||
|
|
159
|
+
deps["@capacitor/core"] ||
|
|
160
|
+
deps["react-native"]) {
|
|
161
|
+
return "mobile";
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
/* unreadable package.json — keep walking */
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const parent = dirname(dir);
|
|
169
|
+
if (parent === dir)
|
|
170
|
+
break;
|
|
171
|
+
dir = parent;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
/* fs not available — fall through */
|
|
176
|
+
}
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Resolve the experiment surface. Explicit wins; otherwise detect from repo
|
|
181
|
+
* signals, then the workspace's registered data sources. Returns an `ambiguous`
|
|
182
|
+
* error only when both web and mobile data sources exist and there's no repo
|
|
183
|
+
* signal — in that case the agent must choose. (QA: stop defaulting to web.)
|
|
184
|
+
*/
|
|
185
|
+
export async function resolveCreateSurface(explicit) {
|
|
186
|
+
if (explicit)
|
|
187
|
+
return { surface: explicit };
|
|
188
|
+
const repo = detectSurfaceFromRepo();
|
|
189
|
+
if (repo)
|
|
190
|
+
return { surface: repo };
|
|
191
|
+
try {
|
|
192
|
+
const ws = getActiveWorkspace();
|
|
193
|
+
if (ws) {
|
|
194
|
+
const r = await apiGet(`/api/workspaces/${encodeURIComponent(ws)}/readiness`);
|
|
195
|
+
const sources = r.data?.sources ?? [];
|
|
196
|
+
const hasMobile = sources.some((s) => s.kind === "ios" || s.kind === "android");
|
|
197
|
+
const hasWeb = sources.some((s) => s.kind === "website");
|
|
198
|
+
if (hasMobile && !hasWeb)
|
|
199
|
+
return { surface: "mobile" };
|
|
200
|
+
if (hasWeb && !hasMobile)
|
|
201
|
+
return { surface: "web" };
|
|
202
|
+
if (hasMobile && hasWeb)
|
|
203
|
+
return { ambiguous: true };
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
/* readiness unavailable — fall back to web */
|
|
208
|
+
}
|
|
209
|
+
return { surface: "web" };
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Tenant echo (council CISO): never report a mutation as successful for a record
|
|
213
|
+
* outside the active workspace (guards a leaked/cross-workspace key).
|
|
214
|
+
*/
|
|
215
|
+
export function tenantOk(workspaceKey) {
|
|
216
|
+
const active = getActiveWorkspace();
|
|
217
|
+
return !active || !workspaceKey || workspaceKey === active;
|
|
218
|
+
}
|
|
219
|
+
export function tenantMismatch() {
|
|
220
|
+
return {
|
|
221
|
+
content: [
|
|
222
|
+
{
|
|
223
|
+
type: "text",
|
|
224
|
+
text: `${APEX} Refusing to confirm: the affected record belongs to a different workspace.`,
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
isError: true,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Shared schema + handler for `switch_workspace` (canonical) and its
|
|
232
|
+
* deprecated alias `switch_project`. Both register against the same handler
|
|
233
|
+
* so existing agent calls keep working through the project→workspace rename.
|
|
234
|
+
*
|
|
235
|
+
* After updating the active workspace locally, we VALIDATE the switch with an
|
|
236
|
+
* authed read against `/api/setup-state` (which `apiGet` scopes to the active
|
|
237
|
+
* workspace). Validation is non-fatal: the local switch always succeeds, but
|
|
238
|
+
* we surface an auth/reachability warning so the user knows to connect or
|
|
239
|
+
* fix the workspace key.
|
|
240
|
+
*/
|
|
241
|
+
export const switchWorkspaceSchema = z.object({
|
|
242
|
+
workspaceKey: z.string().optional().describe("The workspace key to switch to."),
|
|
243
|
+
projectKey: z
|
|
244
|
+
.string()
|
|
245
|
+
.optional()
|
|
246
|
+
.describe("Deprecated alias of workspaceKey. Use workspaceKey."),
|
|
247
|
+
});
|
|
248
|
+
export async function switchWorkspaceHandler(args) {
|
|
249
|
+
const key = args.workspaceKey ?? args.projectKey;
|
|
250
|
+
if (!key) {
|
|
251
|
+
return {
|
|
252
|
+
content: [{
|
|
253
|
+
type: "text",
|
|
254
|
+
text: "Provide a workspaceKey to switch to (projectKey is accepted as a deprecated alias).",
|
|
255
|
+
}],
|
|
256
|
+
isError: true,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
setActiveWorkspace(key);
|
|
260
|
+
const deprecationNote = !args.workspaceKey && args.projectKey
|
|
261
|
+
? " (note: `projectKey` is deprecated — use `workspaceKey`.)"
|
|
262
|
+
: "";
|
|
263
|
+
// Validate the switch by reading setup-state for the now-active workspace.
|
|
264
|
+
let validation = " Verified — Apex can read this workspace.";
|
|
265
|
+
try {
|
|
266
|
+
await apiGet("/api/setup-state");
|
|
267
|
+
}
|
|
268
|
+
catch (err) {
|
|
269
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
270
|
+
if (/\(401\)|\(403\)|authentication failed/i.test(message)) {
|
|
271
|
+
validation =
|
|
272
|
+
"\n\n⚠️ Switched locally, but could not verify the workspace — authentication failed. " +
|
|
273
|
+
"Connect the MCP server to Apex (run any Apex tool to get a one-time approval link), " +
|
|
274
|
+
"or regenerate APEX_API_KEY in Apex → Settings → AI Agents, then try again.";
|
|
275
|
+
}
|
|
276
|
+
else if (/\(404\)/.test(message)) {
|
|
277
|
+
validation =
|
|
278
|
+
`\n\n⚠️ Switched locally, but Apex returned 404 for "${key}" — the workspace key may be wrong. ` +
|
|
279
|
+
"Use list_workspaces to see the valid keys for your API key.";
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
validation = `\n\n⚠️ Switched locally, but could not reach Apex to verify it (${message}).`;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
content: [{
|
|
287
|
+
type: "text",
|
|
288
|
+
text: `Switched to workspace: ${key}. All subsequent calls will use this workspace.${deprecationNote}${validation}`,
|
|
289
|
+
}],
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Shared handler for `list_workspaces` (canonical) and its deprecated alias
|
|
294
|
+
* `list_projects`. Both register against the same handler so existing agent
|
|
295
|
+
* calls keep working through the project→workspace rename.
|
|
296
|
+
*/
|
|
297
|
+
export async function listWorkspacesHandler() {
|
|
298
|
+
// NOTE: `/api/projects` is the PERMANENT alias path this tool has shipped
|
|
299
|
+
// against — it returns the flat row shape below. Do not point at
|
|
300
|
+
// `/api/workspaces` (different response shape).
|
|
301
|
+
const workspaces = await apiGet("/api/projects");
|
|
302
|
+
const current = getActiveWorkspace();
|
|
303
|
+
if (!workspaces.length) {
|
|
304
|
+
return {
|
|
305
|
+
content: [{ type: "text", text: "No workspaces found for this API key." }],
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
const lines = workspaces.map((p) => {
|
|
309
|
+
const active = p.workspaceKey === current ? " ← active" : "";
|
|
310
|
+
return ` ${p.workspaceKey} — ${p.name} (${p.url})${active}`;
|
|
311
|
+
});
|
|
312
|
+
return {
|
|
313
|
+
content: [{
|
|
314
|
+
type: "text",
|
|
315
|
+
text: [`Workspaces (${workspaces.length}):`, ...lines].join("\n"),
|
|
316
|
+
}],
|
|
317
|
+
};
|
|
318
|
+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
sort: z.ZodOptional<z.ZodEnum<["ltv", "name", "members", "pipeline"]>>;
|
|
7
|
+
search: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
sort?: "name" | "pipeline" | "ltv" | "members" | undefined;
|
|
10
|
+
search?: string | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
sort?: "name" | "pipeline" | "ltv" | "members" | undefined;
|
|
13
|
+
search?: string | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
handler: ({ sort, search }: {
|
|
16
|
+
sort?: string;
|
|
17
|
+
search?: string;
|
|
18
|
+
}) => Promise<{
|
|
19
|
+
content: {
|
|
20
|
+
type: "text";
|
|
21
|
+
text: string;
|
|
22
|
+
}[];
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
get_account: {
|
|
26
|
+
description: string;
|
|
27
|
+
schema: z.ZodObject<{
|
|
28
|
+
accountId: z.ZodString;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
accountId: string;
|
|
31
|
+
}, {
|
|
32
|
+
accountId: string;
|
|
33
|
+
}>;
|
|
34
|
+
handler: ({ accountId }: {
|
|
35
|
+
accountId: string;
|
|
36
|
+
}) => Promise<{
|
|
37
|
+
content: {
|
|
38
|
+
type: "text";
|
|
39
|
+
text: string;
|
|
40
|
+
}[];
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
get_account_people: {
|
|
44
|
+
description: string;
|
|
45
|
+
schema: z.ZodObject<{
|
|
46
|
+
accountId: z.ZodString;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
accountId: string;
|
|
49
|
+
}, {
|
|
50
|
+
accountId: string;
|
|
51
|
+
}>;
|
|
52
|
+
handler: ({ accountId }: {
|
|
53
|
+
accountId: string;
|
|
54
|
+
}) => Promise<{
|
|
55
|
+
content: {
|
|
56
|
+
type: "text";
|
|
57
|
+
text: string;
|
|
58
|
+
}[];
|
|
59
|
+
}>;
|
|
60
|
+
};
|
|
61
|
+
list_sub_accounts: {
|
|
62
|
+
description: string;
|
|
63
|
+
schema: z.ZodObject<{
|
|
64
|
+
accountId: z.ZodString;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
accountId: string;
|
|
67
|
+
}, {
|
|
68
|
+
accountId: string;
|
|
69
|
+
}>;
|
|
70
|
+
handler: ({ accountId }: {
|
|
71
|
+
accountId: string;
|
|
72
|
+
}) => Promise<{
|
|
73
|
+
content: {
|
|
74
|
+
type: "text";
|
|
75
|
+
text: string;
|
|
76
|
+
}[];
|
|
77
|
+
}>;
|
|
78
|
+
};
|
|
79
|
+
get_contact_groups: {
|
|
80
|
+
description: string;
|
|
81
|
+
schema: z.ZodObject<{
|
|
82
|
+
contactId: z.ZodString;
|
|
83
|
+
}, "strip", z.ZodTypeAny, {
|
|
84
|
+
contactId: string;
|
|
85
|
+
}, {
|
|
86
|
+
contactId: string;
|
|
87
|
+
}>;
|
|
88
|
+
handler: ({ contactId }: {
|
|
89
|
+
contactId: string;
|
|
90
|
+
}) => Promise<{
|
|
91
|
+
content: {
|
|
92
|
+
type: "text";
|
|
93
|
+
text: string;
|
|
94
|
+
}[];
|
|
95
|
+
}>;
|
|
96
|
+
};
|
|
97
|
+
update_account_pipeline: {
|
|
98
|
+
description: string;
|
|
99
|
+
schema: z.ZodObject<{
|
|
100
|
+
accountId: z.ZodString;
|
|
101
|
+
pipelineValue: z.ZodNumber;
|
|
102
|
+
note: z.ZodOptional<z.ZodString>;
|
|
103
|
+
}, "strip", z.ZodTypeAny, {
|
|
104
|
+
accountId: string;
|
|
105
|
+
pipelineValue: number;
|
|
106
|
+
note?: string | undefined;
|
|
107
|
+
}, {
|
|
108
|
+
accountId: string;
|
|
109
|
+
pipelineValue: number;
|
|
110
|
+
note?: string | undefined;
|
|
111
|
+
}>;
|
|
112
|
+
handler: ({ accountId, pipelineValue, note, }: {
|
|
113
|
+
accountId: string;
|
|
114
|
+
pipelineValue: number;
|
|
115
|
+
note?: string;
|
|
116
|
+
}) => Promise<{
|
|
117
|
+
content: {
|
|
118
|
+
type: "text";
|
|
119
|
+
text: string;
|
|
120
|
+
}[];
|
|
121
|
+
}>;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=accounts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/tools/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;oCAUa;YAAE,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,CAAA;SAAE;;;;;;;;;;;;;;;;iCAkBrC;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE;;;;;;;;;;;;;;;;iCAiBrB;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE;;;;;;;;;;;;;;;;iCAiBrB;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE;;;;;;;;;;;;;;;;iCAiBrB;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE;;;;;;;;;;;;;;;;;;;;;;uDAuBjD;YACD,SAAS,EAAE,MAAM,CAAC;YAClB,aAAa,EAAE,MAAM,CAAC;YACtB,IAAI,CAAC,EAAE,MAAM,CAAC;SACf;;;;;;;CAYJ,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { apiGet, apiPost } from "../api-client.js";
|
|
3
|
+
import { APEX } from "../tool-shared.js";
|
|
4
|
+
export const accountTools = {
|
|
5
|
+
list_accounts: {
|
|
6
|
+
description: `${APEX} — List B2B accounts (companies / clients) in the active workspace with rollup LTV, member count, and pipeline. Accounts aggregate every member's revenue into one company-level number. Default sort is by LTV.`,
|
|
7
|
+
schema: z.object({
|
|
8
|
+
sort: z
|
|
9
|
+
.enum(["ltv", "name", "members", "pipeline"])
|
|
10
|
+
.optional()
|
|
11
|
+
.describe("Sort order (default: ltv)."),
|
|
12
|
+
search: z.string().optional().describe("Filter by account name or domain."),
|
|
13
|
+
}),
|
|
14
|
+
handler: async ({ sort, search }) => {
|
|
15
|
+
const q = new URLSearchParams();
|
|
16
|
+
if (sort)
|
|
17
|
+
q.set("sort", sort);
|
|
18
|
+
if (search)
|
|
19
|
+
q.set("search", search);
|
|
20
|
+
const qs = q.toString();
|
|
21
|
+
const json = await apiGet(`/api/accounts${qs ? `?${qs}` : ""}`);
|
|
22
|
+
const data = Array.isArray(json) ? json : (json.data ?? []);
|
|
23
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
get_account: {
|
|
27
|
+
description: `${APEX} — Read one B2B account: rollup counters (account LTV, gross, refunds, purchases), member count, plan, seats, and traits. Account LTV is the sum of every member's directly-billed revenue with no double counting.`,
|
|
28
|
+
schema: z.object({
|
|
29
|
+
accountId: z.string().describe("Internal acct_ id from list_accounts."),
|
|
30
|
+
}),
|
|
31
|
+
handler: async ({ accountId }) => {
|
|
32
|
+
const json = await apiGet(`/api/accounts/${encodeURIComponent(accountId)}`);
|
|
33
|
+
return {
|
|
34
|
+
content: [
|
|
35
|
+
{ type: "text", text: JSON.stringify(json.data ?? json, null, 2) },
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
get_account_people: {
|
|
41
|
+
description: `${APEX} — The member roster for an account: every Contact linked to it (primary members plus sub-account members), with each member's directly-billed revenue, score, and last-active. Per-person dollars are what that member was billed — account LTV is never split across seats.`,
|
|
42
|
+
schema: z.object({
|
|
43
|
+
accountId: z.string().describe("Internal acct_ id (or a sub-account id)."),
|
|
44
|
+
}),
|
|
45
|
+
handler: async ({ accountId }) => {
|
|
46
|
+
const json = await apiGet(`/api/accounts/${encodeURIComponent(accountId)}/people`);
|
|
47
|
+
return {
|
|
48
|
+
content: [
|
|
49
|
+
{ type: "text", text: JSON.stringify(json.data ?? [], null, 2) },
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
list_sub_accounts: {
|
|
55
|
+
description: `${APEX} — List the sub-accounts (workspaces / teams / projects) that belong to a B2B account (B2B-001). Sub-accounts are the intermediate org-unit layer between an account and its people; each carries a kind label and its own member count.`,
|
|
56
|
+
schema: z.object({
|
|
57
|
+
accountId: z.string().describe("Parent account id from list_accounts."),
|
|
58
|
+
}),
|
|
59
|
+
handler: async ({ accountId }) => {
|
|
60
|
+
const json = await apiGet(`/api/accounts/${encodeURIComponent(accountId)}/subaccounts`);
|
|
61
|
+
return {
|
|
62
|
+
content: [
|
|
63
|
+
{ type: "text", text: JSON.stringify(json.data ?? [], null, 2) },
|
|
64
|
+
],
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
get_contact_groups: {
|
|
69
|
+
description: `${APEX} — The account groups (workspaces / teams) a contact belongs to (B2B-001) — the answer to "which workspaces is this user in?". Returns each group with its kind and the contact's role in it.`,
|
|
70
|
+
schema: z.object({
|
|
71
|
+
contactId: z.string().describe("Contact / customer id."),
|
|
72
|
+
}),
|
|
73
|
+
handler: async ({ contactId }) => {
|
|
74
|
+
const json = await apiGet(`/api/customers/${encodeURIComponent(contactId)}/groups`);
|
|
75
|
+
return {
|
|
76
|
+
content: [
|
|
77
|
+
{ type: "text", text: JSON.stringify(json.data ?? [], null, 2) },
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
update_account_pipeline: {
|
|
83
|
+
description: `${APEX} — Log an account-level pipeline (open-deal) value with a note (Sales-Led / Hybrid workspaces). The account number is canonical for reporting when both an account and a contact pipeline value exist.`,
|
|
84
|
+
schema: z.object({
|
|
85
|
+
accountId: z.string().describe("Internal acct_ id."),
|
|
86
|
+
pipelineValue: z.number().describe("Open-deal value in USD."),
|
|
87
|
+
note: z.string().optional().describe("Why the value changed."),
|
|
88
|
+
}),
|
|
89
|
+
handler: async ({ accountId, pipelineValue, note, }) => {
|
|
90
|
+
const json = await apiPost(`/api/accounts/${encodeURIComponent(accountId)}/pipeline`, { pipelineValue, note });
|
|
91
|
+
return {
|
|
92
|
+
content: [
|
|
93
|
+
{ type: "text", text: JSON.stringify(json.data ?? json, null, 2) },
|
|
94
|
+
],
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/tools/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,aAAa,EAAE;QACb,WAAW,EAAE,GAAG,IAAI,kNAAkN;QACtO,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;YACf,IAAI,EAAE,CAAC;iBACJ,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;iBAC5C,QAAQ,EAAE;iBACV,QAAQ,CAAC,4BAA4B,CAAC;YACzC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;SAC5E,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAsC,EAAE,EAAE;YACtE,MAAM,CAAC,GAAG,IAAI,eAAe,EAAE,CAAC;YAChC,IAAI,IAAI;gBAAE,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC9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