@inferevents/mcp 0.5.2 → 1.0.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 +141 -59
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +59 -69
- package/dist/api-client.js.map +1 -1
- package/dist/index.js +0 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +90 -186
- package/dist/server.js.map +1 -1
- package/dist/tool-result.d.ts +34 -0
- package/dist/tool-result.d.ts.map +1 -0
- package/dist/tool-result.js +30 -0
- package/dist/tool-result.js.map +1 -0
- package/dist/tools/annotate-span.d.ts +7 -0
- package/dist/tools/annotate-span.d.ts.map +1 -0
- package/dist/tools/annotate-span.js +16 -0
- package/dist/tools/annotate-span.js.map +1 -0
- package/dist/tools/annotate-trace.d.ts +7 -0
- package/dist/tools/annotate-trace.d.ts.map +1 -0
- package/dist/tools/annotate-trace.js +16 -0
- package/dist/tools/annotate-trace.js.map +1 -0
- package/dist/tools/create-project.d.ts.map +1 -1
- package/dist/tools/create-project.js +39 -7
- package/dist/tools/create-project.js.map +1 -1
- package/dist/tools/deprecated-tools.d.ts +16 -0
- package/dist/tools/deprecated-tools.d.ts.map +1 -0
- package/dist/tools/deprecated-tools.js +78 -0
- package/dist/tools/deprecated-tools.js.map +1 -0
- package/dist/tools/deprecated.d.ts +25 -0
- package/dist/tools/deprecated.d.ts.map +1 -0
- package/dist/tools/deprecated.js +42 -0
- package/dist/tools/deprecated.js.map +1 -0
- package/dist/tools/get-cost-stats.d.ts +18 -0
- package/dist/tools/get-cost-stats.d.ts.map +1 -0
- package/dist/tools/get-cost-stats.js +88 -0
- package/dist/tools/get-cost-stats.js.map +1 -0
- package/dist/tools/get-error-spans.d.ts +8 -0
- package/dist/tools/get-error-spans.d.ts.map +1 -0
- package/dist/tools/get-error-spans.js +25 -0
- package/dist/tools/get-error-spans.js.map +1 -0
- package/dist/tools/get-insights.d.ts.map +1 -1
- package/dist/tools/get-insights.js +74 -109
- package/dist/tools/get-insights.js.map +1 -1
- package/dist/tools/get-latency-stats.d.ts +7 -0
- package/dist/tools/get-latency-stats.d.ts.map +1 -0
- package/dist/tools/get-latency-stats.js +28 -0
- package/dist/tools/get-latency-stats.js.map +1 -0
- package/dist/tools/get-project-summary.d.ts +0 -39
- package/dist/tools/get-project-summary.d.ts.map +1 -1
- package/dist/tools/get-project-summary.js +76 -79
- package/dist/tools/get-project-summary.js.map +1 -1
- package/dist/tools/get-span.d.ts +6 -0
- package/dist/tools/get-span.d.ts.map +1 -0
- package/dist/tools/get-span.js +30 -0
- package/dist/tools/get-span.js.map +1 -0
- package/dist/tools/get-token-usage.d.ts +7 -0
- package/dist/tools/get-token-usage.d.ts.map +1 -0
- package/dist/tools/get-token-usage.js +25 -0
- package/dist/tools/get-token-usage.js.map +1 -0
- package/dist/tools/get-trace.d.ts +6 -0
- package/dist/tools/get-trace.d.ts.map +1 -0
- package/dist/tools/get-trace.js +28 -0
- package/dist/tools/get-trace.js.map +1 -0
- package/dist/tools/list-spans.d.ts +15 -0
- package/dist/tools/list-spans.d.ts.map +1 -0
- package/dist/tools/list-spans.js +19 -0
- package/dist/tools/list-spans.js.map +1 -0
- package/dist/tools/schemas.d.ts +45 -0
- package/dist/tools/schemas.d.ts.map +1 -0
- package/dist/tools/schemas.js +86 -0
- package/dist/tools/schemas.js.map +1 -0
- package/dist/tools/switch-project.d.ts.map +1 -1
- package/dist/tools/switch-project.js +36 -4
- package/dist/tools/switch-project.js.map +1 -1
- package/package.json +11 -2
- package/dist/tools/annotate-thread.d.ts +0 -11
- package/dist/tools/annotate-thread.d.ts.map +0 -1
- package/dist/tools/annotate-thread.js +0 -23
- package/dist/tools/annotate-thread.js.map +0 -1
- package/dist/tools/get-event-counts.d.ts +0 -23
- package/dist/tools/get-event-counts.d.ts.map +0 -1
- package/dist/tools/get-event-counts.js +0 -50
- package/dist/tools/get-event-counts.js.map +0 -1
- package/dist/tools/get-ontology.d.ts +0 -9
- package/dist/tools/get-ontology.d.ts.map +0 -1
- package/dist/tools/get-ontology.js +0 -62
- package/dist/tools/get-ontology.js.map +0 -1
- package/dist/tools/get-retention.d.ts +0 -11
- package/dist/tools/get-retention.d.ts.map +0 -1
- package/dist/tools/get-retention.js +0 -87
- package/dist/tools/get-retention.js.map +0 -1
- package/dist/tools/get-top-events.d.ts +0 -11
- package/dist/tools/get-top-events.d.ts.map +0 -1
- package/dist/tools/get-top-events.js +0 -74
- package/dist/tools/get-top-events.js.map +0 -1
- package/dist/tools/get-user-journey.d.ts +0 -10
- package/dist/tools/get-user-journey.d.ts.map +0 -1
- package/dist/tools/get-user-journey.js +0 -143
- package/dist/tools/get-user-journey.js.map +0 -1
- package/dist/tools/update-ontology.d.ts +0 -37
- package/dist/tools/update-ontology.d.ts.map +0 -1
- package/dist/tools/update-ontology.js +0 -51
- package/dist/tools/update-ontology.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { listProjects, switchProject, writeLocalConfig } from "../config.js";
|
|
3
|
+
import { wrapResult, toolResponseText } from "../tool-result.js";
|
|
3
4
|
export const switchProjectSchema = {
|
|
4
5
|
project_name: z
|
|
5
6
|
.string()
|
|
@@ -10,7 +11,14 @@ export async function handleSwitchProject(params) {
|
|
|
10
11
|
const projects = await listProjects();
|
|
11
12
|
if (!params.project_name) {
|
|
12
13
|
if (projects.length === 0) {
|
|
13
|
-
return
|
|
14
|
+
return toolResponseText(wrapResult({
|
|
15
|
+
primary: {
|
|
16
|
+
status: "empty",
|
|
17
|
+
projects: [],
|
|
18
|
+
message: "No projects configured. Run /infer-setup to create one.",
|
|
19
|
+
},
|
|
20
|
+
source: "config",
|
|
21
|
+
}));
|
|
14
22
|
}
|
|
15
23
|
const lines = ["Your Infer projects:", ""];
|
|
16
24
|
for (const p of projects) {
|
|
@@ -18,12 +26,36 @@ export async function handleSwitchProject(params) {
|
|
|
18
26
|
lines.push(` ${p.name} — ${p.projectId}${marker}`);
|
|
19
27
|
}
|
|
20
28
|
lines.push("", "To switch: call switch_project with the project name.");
|
|
21
|
-
return
|
|
29
|
+
return toolResponseText(wrapResult({
|
|
30
|
+
primary: {
|
|
31
|
+
status: "listed",
|
|
32
|
+
projects: projects.map((p) => ({
|
|
33
|
+
name: p.name,
|
|
34
|
+
project_id: p.projectId,
|
|
35
|
+
active: p.active,
|
|
36
|
+
})),
|
|
37
|
+
rendered_text: lines.join("\n"),
|
|
38
|
+
},
|
|
39
|
+
source: "config",
|
|
40
|
+
}));
|
|
22
41
|
}
|
|
23
42
|
const config = await switchProject(params.project_name);
|
|
24
43
|
// Also write .infer.json in current directory so this project auto-selects here
|
|
25
44
|
const localPath = await writeLocalConfig(params.project_name).catch(() => null);
|
|
26
|
-
const localMsg = localPath
|
|
27
|
-
|
|
45
|
+
const localMsg = localPath
|
|
46
|
+
? ` Wrote .infer.json so this directory always uses "${params.project_name}".`
|
|
47
|
+
: "";
|
|
48
|
+
const message = `Switched to project "${params.project_name}" (${config.projectId}).${localMsg} MCP tools now query this project.`;
|
|
49
|
+
return toolResponseText(wrapResult({
|
|
50
|
+
primary: {
|
|
51
|
+
status: "switched",
|
|
52
|
+
project_name: params.project_name,
|
|
53
|
+
project_id: config.projectId,
|
|
54
|
+
wrote_local_config: localPath !== null,
|
|
55
|
+
local_config_path: localPath,
|
|
56
|
+
message,
|
|
57
|
+
},
|
|
58
|
+
source: "config",
|
|
59
|
+
}));
|
|
28
60
|
}
|
|
29
61
|
//# sourceMappingURL=switch-project.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch-project.js","sourceRoot":"","sources":["../../src/tools/switch-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"switch-project.js","sourceRoot":"","sources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|
4
|
+
"description": "MCP server for Infer LLM observability — 12 tools for span inspection, latency/cost/error analysis, and annotation threads for AI-agent gateways.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/infer-events/infer.git",
|
|
8
|
+
"directory": "packages/mcp"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/infer-events/infer/tree/main/packages/mcp#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/infer-events/infer/issues"
|
|
13
|
+
},
|
|
5
14
|
"type": "module",
|
|
6
15
|
"main": "./dist/index.js",
|
|
7
16
|
"types": "./dist/index.d.ts",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { ApiClient } from "../api-client.js";
|
|
3
|
-
export declare const annotateThreadSchema: {
|
|
4
|
-
thread_id: z.ZodString;
|
|
5
|
-
content: z.ZodString;
|
|
6
|
-
};
|
|
7
|
-
export declare function handleAnnotateThread(client: ApiClient, params: {
|
|
8
|
-
thread_id: string;
|
|
9
|
-
content: string;
|
|
10
|
-
}): Promise<string>;
|
|
11
|
-
//# sourceMappingURL=annotate-thread.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"annotate-thread.d.ts","sourceRoot":"","sources":["../../src/tools/annotate-thread.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,eAAO,MAAM,oBAAoB;;;CAOhC,CAAC;AAEF,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC7C,OAAO,CAAC,MAAM,CAAC,CAejB"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export const annotateThreadSchema = {
|
|
3
|
-
thread_id: z.string().describe("The thread ID to annotate (from get_insights thread context)."),
|
|
4
|
-
content: z.string().max(2000).describe("Your finding or conclusion about this thread. " +
|
|
5
|
-
'E.g., "Root cause: deploy abc123 broke the signup API endpoint." ' +
|
|
6
|
-
"This will appear in future insight briefings and the project summary."),
|
|
7
|
-
};
|
|
8
|
-
export async function handleAnnotateThread(client, params) {
|
|
9
|
-
const result = await client.annotateThread({
|
|
10
|
-
threadId: params.thread_id,
|
|
11
|
-
content: params.content,
|
|
12
|
-
source: "agent",
|
|
13
|
-
});
|
|
14
|
-
return [
|
|
15
|
-
`Annotation saved to thread ${result.thread_id}.`,
|
|
16
|
-
`Total annotations: ${result.annotation_count}`,
|
|
17
|
-
"",
|
|
18
|
-
`Recorded: "${params.content}"`,
|
|
19
|
-
"",
|
|
20
|
-
"This finding will appear in future insight briefings and the project summary.",
|
|
21
|
-
].join("\n");
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=annotate-thread.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"annotate-thread.js","sourceRoot":"","sources":["../../src/tools/annotate-thread.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+DAA+D,CAAC;IAC/F,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CACpC,gDAAgD;QAChD,mEAAmE;QACnE,uEAAuE,CACxE;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAiB,EACjB,MAA8C;IAE9C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC;QACzC,QAAQ,EAAE,MAAM,CAAC,SAAS;QAC1B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,MAAM,EAAE,OAAO;KAChB,CAAC,CAAC;IAEH,OAAO;QACL,8BAA8B,MAAM,CAAC,SAAS,GAAG;QACjD,sBAAsB,MAAM,CAAC,gBAAgB,EAAE;QAC/C,EAAE;QACF,cAAc,MAAM,CAAC,OAAO,GAAG;QAC/B,EAAE;QACF,+EAA+E;KAChF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { ApiClient } from "../api-client.js";
|
|
3
|
-
export declare const getEventCountsSchema: {
|
|
4
|
-
event_name: z.ZodString;
|
|
5
|
-
time_range: z.ZodString;
|
|
6
|
-
group_by: z.ZodOptional<z.ZodString>;
|
|
7
|
-
filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
8
|
-
field: z.ZodString;
|
|
9
|
-
op: z.ZodEnum<["eq", "neq", "gt", "lt", "gte", "lte", "contains"]>;
|
|
10
|
-
value: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
11
|
-
}, "strip", z.ZodTypeAny, {
|
|
12
|
-
value: string | number | boolean;
|
|
13
|
-
field: string;
|
|
14
|
-
op: "eq" | "neq" | "gt" | "lt" | "gte" | "lte" | "contains";
|
|
15
|
-
}, {
|
|
16
|
-
value: string | number | boolean;
|
|
17
|
-
field: string;
|
|
18
|
-
op: "eq" | "neq" | "gt" | "lt" | "gte" | "lte" | "contains";
|
|
19
|
-
}>, "many">>;
|
|
20
|
-
};
|
|
21
|
-
export type GetEventCountsInput = z.infer<z.ZodObject<typeof getEventCountsSchema>>;
|
|
22
|
-
export declare function handleGetEventCounts(client: ApiClient, input: GetEventCountsInput): Promise<string>;
|
|
23
|
-
//# sourceMappingURL=get-event-counts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-event-counts.d.ts","sourceRoot":"","sources":["../../src/tools/get-event-counts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAKlD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;CAqBhC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CACvC,CAAC,CAAC,SAAS,CAAC,OAAO,oBAAoB,CAAC,CACzC,CAAC;AAEF,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,MAAM,CAAC,CA2CjB"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { filterSchema } from "@inferevents/shared";
|
|
3
|
-
import { miniBarChart } from "../charts.js";
|
|
4
|
-
import { getTip } from "../tips.js";
|
|
5
|
-
export const getEventCountsSchema = {
|
|
6
|
-
event_name: z
|
|
7
|
-
.string()
|
|
8
|
-
.describe("Name of the event to count (e.g., 'signup', 'page_view', 'purchase')"),
|
|
9
|
-
time_range: z
|
|
10
|
-
.string()
|
|
11
|
-
.describe('Time range: "last_24h", "last_7d", "last_30d", "last_90d", or ISO range "2024-01-01/2024-01-31"'),
|
|
12
|
-
group_by: z
|
|
13
|
-
.string()
|
|
14
|
-
.optional()
|
|
15
|
-
.describe("Property name to group results by (e.g., 'country', 'plan', 'source')"),
|
|
16
|
-
filters: z
|
|
17
|
-
.array(filterSchema)
|
|
18
|
-
.optional()
|
|
19
|
-
.describe("Filters: [{field, op, value}]"),
|
|
20
|
-
};
|
|
21
|
-
export async function handleGetEventCounts(client, input) {
|
|
22
|
-
const result = await client.getEventCounts({
|
|
23
|
-
eventName: input.event_name,
|
|
24
|
-
timeRange: input.time_range,
|
|
25
|
-
groupBy: input.group_by,
|
|
26
|
-
filters: input.filters,
|
|
27
|
-
});
|
|
28
|
-
const chart = [];
|
|
29
|
-
if (result.warning) {
|
|
30
|
-
chart.push(`⚠️ ${result.warning}`);
|
|
31
|
-
chart.push("");
|
|
32
|
-
}
|
|
33
|
-
chart.push(`${input.event_name} — ${input.time_range}`);
|
|
34
|
-
chart.push(`${"─".repeat(50)}`);
|
|
35
|
-
chart.push(`Total: ${result.total.toLocaleString()}`);
|
|
36
|
-
if (result.groups.length > 0 && input.group_by) {
|
|
37
|
-
chart.push("");
|
|
38
|
-
chart.push(`Grouped by ${input.group_by}:`);
|
|
39
|
-
chart.push("");
|
|
40
|
-
chart.push(miniBarChart(result.groups.map((g) => ({ key: g.key, count: g.count }))));
|
|
41
|
-
}
|
|
42
|
-
if (result.total === 0) {
|
|
43
|
-
chart.push("");
|
|
44
|
-
chart.push("No events found. The event may not be tracked, the name may be");
|
|
45
|
-
chart.push("misspelled, or there was no activity in this time range.");
|
|
46
|
-
}
|
|
47
|
-
const output = "Present this chart to the user exactly as-is:\n\n```\n" + chart.join("\n") + "\n```" + getTip("afterCounts");
|
|
48
|
-
return output;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=get-event-counts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-event-counts.js","sourceRoot":"","sources":["../../src/tools/get-event-counts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAS,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,UAAU,EAAE,CAAC;SACV,MAAM,EAAE;SACR,QAAQ,CACP,sEAAsE,CACvE;IACH,UAAU,EAAE,CAAC;SACV,MAAM,EAAE;SACR,QAAQ,CACP,iGAAiG,CAClG;IACH,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QA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M,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAC3D,CACF,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CACR,gEAAgE,CACjE,CAAC;QACF,KAAK,CAAC,IAAI,CACR,0DAA0D,CAC3D,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,wDAAwD,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;IAE7H,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { ApiClient } from "../api-client.js";
|
|
3
|
-
export declare const getOntologySchema: {
|
|
4
|
-
status: z.ZodOptional<z.ZodEnum<["proposed", "confirmed", "rejected"]>>;
|
|
5
|
-
};
|
|
6
|
-
export declare function handleGetOntology(client: ApiClient, params: {
|
|
7
|
-
status?: string;
|
|
8
|
-
}): Promise<string>;
|
|
9
|
-
//# sourceMappingURL=get-ontology.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-ontology.d.ts","sourceRoot":"","sources":["../../src/tools/get-ontology.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,eAAO,MAAM,iBAAiB;;CAK7B,CAAC;AAEF,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1B,OAAO,CAAC,MAAM,CAAC,CA8DjB"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export const getOntologySchema = {
|
|
3
|
-
status: z
|
|
4
|
-
.enum(["proposed", "confirmed", "rejected"])
|
|
5
|
-
.optional()
|
|
6
|
-
.describe("Filter by status. Omit to get all entries."),
|
|
7
|
-
};
|
|
8
|
-
export async function handleGetOntology(client, params) {
|
|
9
|
-
const result = await client.getOntology({
|
|
10
|
-
status: params.status,
|
|
11
|
-
});
|
|
12
|
-
if (result.total === 0) {
|
|
13
|
-
return ("No event ontology configured yet.\n\n" +
|
|
14
|
-
"The event ontology maps your event names to product categories " +
|
|
15
|
-
"(activation, engagement, monetization, referral, noise) so Infer can " +
|
|
16
|
-
"generate richer insights like funnel bottlenecks and activation rates.\n\n" +
|
|
17
|
-
"Two ways to populate it:\n" +
|
|
18
|
-
"1. SDK hints: `infer.track('purchase', { amount: 99 }, { category: 'monetization' })`\n" +
|
|
19
|
-
"2. Use the `update_ontology` tool to classify events now.\n\n" +
|
|
20
|
-
"Would you like me to look at your top events and propose categories?");
|
|
21
|
-
}
|
|
22
|
-
const categoryIcon = {
|
|
23
|
-
activation: "A",
|
|
24
|
-
engagement: "E",
|
|
25
|
-
monetization: "M",
|
|
26
|
-
referral: "R",
|
|
27
|
-
noise: "~",
|
|
28
|
-
};
|
|
29
|
-
const statusIcon = {
|
|
30
|
-
confirmed: "✓",
|
|
31
|
-
proposed: "?",
|
|
32
|
-
rejected: "✗",
|
|
33
|
-
};
|
|
34
|
-
const chart = [
|
|
35
|
-
`Event Ontology — ${result.total} events mapped`,
|
|
36
|
-
`${"─".repeat(50)}`,
|
|
37
|
-
"",
|
|
38
|
-
];
|
|
39
|
-
// Group by category
|
|
40
|
-
const byCategory = new Map();
|
|
41
|
-
for (const entry of result.entries) {
|
|
42
|
-
const cat = entry.category;
|
|
43
|
-
if (!byCategory.has(cat))
|
|
44
|
-
byCategory.set(cat, []);
|
|
45
|
-
byCategory.get(cat).push(entry);
|
|
46
|
-
}
|
|
47
|
-
for (const [category, entries] of byCategory) {
|
|
48
|
-
const icon = categoryIcon[category] ?? "?";
|
|
49
|
-
chart.push(`[${icon}] ${category.toUpperCase()}`);
|
|
50
|
-
for (const entry of entries) {
|
|
51
|
-
const sIcon = statusIcon[entry.status] ?? "?";
|
|
52
|
-
const stage = entry.funnel_stage !== null ? ` (stage ${entry.funnel_stage})` : "";
|
|
53
|
-
const desc = entry.description ? ` — ${entry.description}` : "";
|
|
54
|
-
const source = entry.source === "sdk" ? "sdk" : "agent";
|
|
55
|
-
chart.push(` ${sIcon} ${entry.event_name}${stage}${desc} [${source}]`);
|
|
56
|
-
}
|
|
57
|
-
chart.push("");
|
|
58
|
-
}
|
|
59
|
-
const output = "Present this to the user exactly as-is:\n\n```\n" + chart.join("\n") + "```";
|
|
60
|
-
return output;
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=get-ontology.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-ontology.js","sourceRoot":"","sources":["../../src/tools/get-ontology.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,MAAM,EAAE,CAAC;SACN,IAAI,CAAC,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;SAC3C,QAAQ,EAAE;SACV,QAAQ,CAAC,4CAA4C,CAAC;CAC1D,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAiB,EACjB,MAA2B;IAE3B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC;QACtC,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,CACL,uCAAuC;YACvC,iEAAiE;YACjE,uE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,IAAI,GAAG,CAAC;YAC9C,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,CAAC,WAAW,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAClF,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;YACxD,KAAK,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,KAAK,CAAC,UAAU,GAAG,KAAK,GAAG,IAAI,MAAM,MAAM,GAAG,CAAC,CAAC;QAC7E,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,MAAM,MAAM,GAAG,kDAAkD,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IAC7F,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { ApiClient } from "../api-client.js";
|
|
3
|
-
export declare const getRetentionSchema: {
|
|
4
|
-
start_event: z.ZodString;
|
|
5
|
-
return_event: z.ZodString;
|
|
6
|
-
time_range: z.ZodString;
|
|
7
|
-
granularity: z.ZodEnum<["day", "week", "month"]>;
|
|
8
|
-
};
|
|
9
|
-
export type GetRetentionInput = z.infer<z.ZodObject<typeof getRetentionSchema>>;
|
|
10
|
-
export declare function handleGetRetention(client: ApiClient, input: GetRetentionInput): Promise<string>;
|
|
11
|
-
//# sourceMappingURL=get-retention.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-retention.d.ts","sourceRoot":"","sources":["../../src/tools/get-retention.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIlD,eAAO,MAAM,kBAAkB;;;;;CAmB9B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CACrC,CAAC,CAAC,SAAS,CAAC,OAAO,kBAAkB,CAAC,CACvC,CAAC;AAUF,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,MAAM,CAAC,CAiGjB"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { bar, status } from "../charts.js";
|
|
3
|
-
import { getTip } from "../tips.js";
|
|
4
|
-
export const getRetentionSchema = {
|
|
5
|
-
start_event: z
|
|
6
|
-
.string()
|
|
7
|
-
.describe('The event that defines cohort entry (e.g., "signup", "first_purchase")'),
|
|
8
|
-
return_event: z
|
|
9
|
-
.string()
|
|
10
|
-
.describe('The event that counts as a return (e.g., "page_view", "purchase", "login")'),
|
|
11
|
-
time_range: z
|
|
12
|
-
.string()
|
|
13
|
-
.describe('Time range: "last_7d", "last_30d", "last_90d", or ISO range "2024-01-01/2024-03-31"'),
|
|
14
|
-
granularity: z
|
|
15
|
-
.enum(["day", "week", "month"])
|
|
16
|
-
.describe('Cohort granularity: "day", "week", or "month"'),
|
|
17
|
-
};
|
|
18
|
-
// B2C weekly benchmarks for status indicators
|
|
19
|
-
const B2C_BENCHMARKS = {
|
|
20
|
-
1: { bad: 15, ok: 25, good: 35 },
|
|
21
|
-
2: { bad: 10, ok: 18, good: 28 },
|
|
22
|
-
3: { bad: 8, ok: 14, good: 24 },
|
|
23
|
-
4: { bad: 5, ok: 10, good: 20 },
|
|
24
|
-
};
|
|
25
|
-
export async function handleGetRetention(client, input) {
|
|
26
|
-
const result = await client.getRetention({
|
|
27
|
-
startEvent: input.start_event,
|
|
28
|
-
returnEvent: input.return_event,
|
|
29
|
-
timeRange: input.time_range,
|
|
30
|
-
granularity: input.granularity,
|
|
31
|
-
});
|
|
32
|
-
const chart = [];
|
|
33
|
-
if (result.warning) {
|
|
34
|
-
chart.push(`⚠️ ${result.warning}`);
|
|
35
|
-
chart.push("");
|
|
36
|
-
}
|
|
37
|
-
chart.push(`Retention: ${input.start_event} → ${input.return_event}`);
|
|
38
|
-
chart.push(`${input.granularity}ly cohorts | ${input.time_range}`);
|
|
39
|
-
chart.push(`${"─".repeat(50)}`);
|
|
40
|
-
if (result.cohorts.length === 0) {
|
|
41
|
-
chart.push("No cohort data found. Check that both events are being tracked");
|
|
42
|
-
chart.push("and that there is activity in this time range.");
|
|
43
|
-
return "Present this to the user exactly as-is:\n\n```\n" + chart.join("\n") + "\n```";
|
|
44
|
-
}
|
|
45
|
-
chart.push("");
|
|
46
|
-
// Visual retention chart per cohort
|
|
47
|
-
for (const cohort of result.cohorts) {
|
|
48
|
-
const label = new Date(cohort.period).toLocaleDateString("en-US", {
|
|
49
|
-
month: "short",
|
|
50
|
-
day: "numeric",
|
|
51
|
-
});
|
|
52
|
-
chart.push(`${label} (${cohort.users_start} users)`);
|
|
53
|
-
for (let i = 0; i < cohort.retained.length; i++) {
|
|
54
|
-
const retained = cohort.retained[i];
|
|
55
|
-
const pct = cohort.users_start > 0
|
|
56
|
-
? (retained / cohort.users_start) * 100
|
|
57
|
-
: 0;
|
|
58
|
-
const periodLabel = `${input.granularity} ${i}`;
|
|
59
|
-
// Get status indicator for weekly benchmarks
|
|
60
|
-
let statusIcon = "";
|
|
61
|
-
if (input.granularity === "week" && i > 0 && B2C_BENCHMARKS[i]) {
|
|
62
|
-
statusIcon = " " + status(pct, B2C_BENCHMARKS[i]);
|
|
63
|
-
}
|
|
64
|
-
chart.push(` ${periodLabel.padEnd(10)} ${bar(retained, cohort.users_start)}${statusIcon}`);
|
|
65
|
-
}
|
|
66
|
-
chart.push("");
|
|
67
|
-
}
|
|
68
|
-
// Overall summary
|
|
69
|
-
const totalUsers = result.cohorts.reduce((sum, c) => sum + c.users_start, 0);
|
|
70
|
-
// Calculate blended retention for the latest complete period
|
|
71
|
-
const completeCohorts = result.cohorts.filter((c) => c.retained.length > 1);
|
|
72
|
-
if (completeCohorts.length > 0) {
|
|
73
|
-
const period1Retained = completeCohorts.reduce((sum, c) => sum + (c.retained[1] ?? 0), 0);
|
|
74
|
-
const period1Total = completeCohorts.reduce((sum, c) => sum + c.users_start, 0);
|
|
75
|
-
const blendedPct = period1Total > 0
|
|
76
|
-
? ((period1Retained / period1Total) * 100).toFixed(1)
|
|
77
|
-
: "N/A";
|
|
78
|
-
chart.push(`Blended ${input.granularity}-1 retention: ${blendedPct}% across ${totalUsers} total users`);
|
|
79
|
-
}
|
|
80
|
-
if (totalUsers < 30) {
|
|
81
|
-
chart.push("");
|
|
82
|
-
chart.push(`⚠️ Small sample (${totalUsers} users). Treat as directional, not conclusive.`);
|
|
83
|
-
}
|
|
84
|
-
const output = "Present this chart to the user exactly as-is:\n\n```\n" + chart.join("\n") + "\n```" + getTip("afterRetention");
|
|
85
|
-
return output;
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=get-retention.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-retention.js","sourceRoot":"","sources":["../../src/tools/get-retention.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,WAAW,EAAE,CAAC;SACX,MAAM,EAAE;SACR,QAAQ,CACP,wEAAwE,CACzE;IACH,YAAY,EAAE,CAAC;SACZ,MAAM,EAAE;SACR,QAAQ,CACP,4EAA4E,CAC7E;IACH,UAAU,EAAE,CAAC;SACV,MAAM,EAAE;SACR,Q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CAAC,eAAe,GAAG,YAAY,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YACrD,CAAC,CAAC,KAAK,CAAC;QAEZ,KAAK,CAAC,IAAI,CACR,WAAW,KAAK,CAAC,WAAW,iBAAiB,UAAU,YAAY,UAAU,cAAc,CAC5F,CAAC;IACJ,CAAC;IAED,IAAI,UAAU,GAAG,EAAE,EAAE,CAAC;QACpB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CACR,oBAAoB,UAAU,gDAAgD,CAC/E,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,wDAAwD,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAEhI,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { ApiClient } from "../api-client.js";
|
|
3
|
-
export declare const getTopEventsSchema: {
|
|
4
|
-
time_range: z.ZodString;
|
|
5
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
6
|
-
};
|
|
7
|
-
export declare function handleGetTopEvents(client: ApiClient, params: {
|
|
8
|
-
time_range: string;
|
|
9
|
-
limit?: number;
|
|
10
|
-
}): Promise<string>;
|
|
11
|
-
//# sourceMappingURL=get-top-events.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-top-events.d.ts","sourceRoot":"","sources":["../../src/tools/get-top-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIlD,eAAO,MAAM,kBAAkB;;;CAa9B,CAAC;AAEF,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7C,OAAO,CAAC,MAAM,CAAC,CAiFjB"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { miniBarChart } from "../charts.js";
|
|
3
|
-
import { getTip } from "../tips.js";
|
|
4
|
-
export const getTopEventsSchema = {
|
|
5
|
-
time_range: z
|
|
6
|
-
.string()
|
|
7
|
-
.describe('Time range: "last_24h", "last_7d", "last_30d", "last_90d", or ISO range'),
|
|
8
|
-
limit: z
|
|
9
|
-
.number()
|
|
10
|
-
.int()
|
|
11
|
-
.min(1)
|
|
12
|
-
.max(100)
|
|
13
|
-
.optional()
|
|
14
|
-
.describe("Max number of events to return (default 20)"),
|
|
15
|
-
};
|
|
16
|
-
export async function handleGetTopEvents(client, params) {
|
|
17
|
-
const result = await client.getTopEvents({
|
|
18
|
-
timeRange: params.time_range,
|
|
19
|
-
limit: params.limit,
|
|
20
|
-
});
|
|
21
|
-
if (result.warning) {
|
|
22
|
-
return `⚠️ ${result.warning}`;
|
|
23
|
-
}
|
|
24
|
-
if (result.events.length === 0) {
|
|
25
|
-
return "❌ No events found in this time range.";
|
|
26
|
-
}
|
|
27
|
-
const totalEvents = result.events.reduce((sum, e) => sum + e.count, 0);
|
|
28
|
-
const chart = [
|
|
29
|
-
`Top Events — ${params.time_range}`,
|
|
30
|
-
`${totalEvents.toLocaleString()} total events across ${result.total_event_names} types`,
|
|
31
|
-
`${"─".repeat(50)}`,
|
|
32
|
-
"",
|
|
33
|
-
miniBarChart(result.events.map((e) => ({
|
|
34
|
-
key: e.event_name,
|
|
35
|
-
count: e.count,
|
|
36
|
-
}))),
|
|
37
|
-
"",
|
|
38
|
-
"Unique users per event:",
|
|
39
|
-
"",
|
|
40
|
-
];
|
|
41
|
-
// Build ASCII table for user stats
|
|
42
|
-
const maxNameLen = Math.max(...result.events.map((e) => e.event_name.length), 5);
|
|
43
|
-
chart.push(`${"Event".padEnd(maxNameLen)} ${"Users".padStart(5)} ${"Avg/User".padStart(8)}`);
|
|
44
|
-
chart.push(`${"─".repeat(maxNameLen)} ${"─".repeat(5)} ${"─".repeat(8)}`);
|
|
45
|
-
for (const e of result.events) {
|
|
46
|
-
const ratio = e.count > 0 ? (e.count / e.unique_users).toFixed(1) : "0";
|
|
47
|
-
chart.push(`${e.event_name.padEnd(maxNameLen)} ${String(e.unique_users).padStart(5)} ${ratio.padStart(8)}`);
|
|
48
|
-
}
|
|
49
|
-
// Available fields for group_by / filtering
|
|
50
|
-
chart.push("");
|
|
51
|
-
chart.push("Available fields for group_by:");
|
|
52
|
-
chart.push(" Columns: anonymous_id, user_id, event_type");
|
|
53
|
-
chart.push(" Context: browser, page_url, pathname, referrer, os, device_type, locale, timezone");
|
|
54
|
-
chart.push(" Geo: country, city, region, continent");
|
|
55
|
-
chart.push(" Custom: any key in event properties");
|
|
56
|
-
// Guidance for missing custom events
|
|
57
|
-
const autoTracked = [
|
|
58
|
-
"page_view",
|
|
59
|
-
"session_start",
|
|
60
|
-
"click",
|
|
61
|
-
"form_submit",
|
|
62
|
-
"error",
|
|
63
|
-
];
|
|
64
|
-
const customEvents = result.events.filter((e) => !autoTracked.includes(e.event_name));
|
|
65
|
-
if (customEvents.length === 0) {
|
|
66
|
-
chart.push("");
|
|
67
|
-
chart.push("Only auto-tracked events. No custom track() calls detected.");
|
|
68
|
-
chart.push("Add track() for key user actions (signup, purchase, feature usage).");
|
|
69
|
-
}
|
|
70
|
-
// Wrap in code block so agents display it verbatim
|
|
71
|
-
const output = "Present this chart to the user exactly as-is:\n\n```\n" + chart.join("\n") + "\n```" + getTip("afterTopEvents");
|
|
72
|
-
return output;
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=get-top-events.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-top-events.js","sourceRoot":"","sources":["../../src/tools/get-top-events.ts"],"names":[],"mappings":"AAAA,OAAO,EA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CAA4C;IAC5C,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;IAC7C,KAAK,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;IAC5D,KAAK,CAAC,IAAI,CAAC,sFAAsF,CAAC,CAAC;IACnG,KAAK,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;IAC3D,KAAK,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC;IAEtD,qCAAqC;IACrC,MAAM,WAAW,GAAG;QAClB,WAAW;QACX,eAAe;QACf,OAAO;QACP,aAAa;QACb,OAAO;KACR,CAAC;IACF,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CACvC,CAAC,CAAyB,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CACnE,CAAC;IAEF,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CACR,6DAA6D,CAC9D,CAAC;QACF,KAAK,CAAC,IAAI,CACR,qEAAqE,CACtE,CAAC;IACJ,CAAC;IAED,mDAAmD;IACnD,MAAM,MAAM,GAAG,wDAAwD,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAEhI,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { ApiClient } from "../api-client.js";
|
|
3
|
-
export declare const getUserJourneySchema: {
|
|
4
|
-
user_id: z.ZodString;
|
|
5
|
-
time_range: z.ZodOptional<z.ZodString>;
|
|
6
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
7
|
-
};
|
|
8
|
-
export type GetUserJourneyInput = z.infer<z.ZodObject<typeof getUserJourneySchema>>;
|
|
9
|
-
export declare function handleGetUserJourney(client: ApiClient, input: GetUserJourneyInput): Promise<string>;
|
|
10
|
-
//# sourceMappingURL=get-user-journey.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-user-journey.d.ts","sourceRoot":"","sources":["../../src/tools/get-user-journey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIlD,eAAO,MAAM,oBAAoB;;;;CAYhC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CACvC,CAAC,CAAC,SAAS,CAAC,OAAO,oBAAoB,CAAC,CACzC,CAAC;AAIF,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,MAAM,CAAC,CA2JjB"}
|