@posthog/agent 2.3.316 → 2.3.326
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/agent.js +1 -1
- package/dist/agent.js.map +1 -1
- package/dist/posthog-api.js +1 -1
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +21 -3
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +21 -3
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/server/agent-server.ts +18 -1
- package/src/server/schemas.test.ts +40 -0
- package/src/server/schemas.ts +8 -1
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ import { type ServerType, serve } from "@hono/node-server";
|
|
|
12
12
|
import { getCurrentBranch } from "@posthog/git/queries";
|
|
13
13
|
import { Hono } from "hono";
|
|
14
14
|
import packageJson from "../../package.json" with { type: "json" };
|
|
15
|
-
import { POSTHOG_NOTIFICATIONS } from "../acp-extensions";
|
|
15
|
+
import { POSTHOG_METHODS, POSTHOG_NOTIFICATIONS } from "../acp-extensions";
|
|
16
16
|
import {
|
|
17
17
|
createAcpConnection,
|
|
18
18
|
type InProcessAcpConnection,
|
|
@@ -644,6 +644,23 @@ export class AgentServer {
|
|
|
644
644
|
};
|
|
645
645
|
}
|
|
646
646
|
|
|
647
|
+
case POSTHOG_METHODS.REFRESH_SESSION:
|
|
648
|
+
case "posthog/refresh_session":
|
|
649
|
+
case "refresh_session": {
|
|
650
|
+
const mcpServers = Array.isArray(params.mcpServers)
|
|
651
|
+
? params.mcpServers
|
|
652
|
+
: [];
|
|
653
|
+
|
|
654
|
+
this.logger.info("Refresh session requested", {
|
|
655
|
+
serverCount: mcpServers.length,
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
return await this.session.clientConnection.extMethod(
|
|
659
|
+
POSTHOG_METHODS.REFRESH_SESSION,
|
|
660
|
+
{ mcpServers },
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
|
|
647
664
|
case POSTHOG_NOTIFICATIONS.PERMISSION_RESPONSE:
|
|
648
665
|
case "permission_response": {
|
|
649
666
|
const requestId = params.requestId as string;
|
|
@@ -184,4 +184,44 @@ describe("validateCommandParams", () => {
|
|
|
184
184
|
|
|
185
185
|
expect(result.success).toBe(false);
|
|
186
186
|
});
|
|
187
|
+
|
|
188
|
+
it("accepts _posthog/refresh_session with mcpServers", () => {
|
|
189
|
+
const result = validateCommandParams("_posthog/refresh_session", {
|
|
190
|
+
mcpServers: [
|
|
191
|
+
{ type: "http", name: "mcp", url: "https://mcp.example.com" },
|
|
192
|
+
],
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
expect(result.success).toBe(true);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it("accepts posthog/refresh_session with empty mcpServers", () => {
|
|
199
|
+
const result = validateCommandParams("posthog/refresh_session", {
|
|
200
|
+
mcpServers: [],
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
expect(result.success).toBe(true);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it("accepts bare refresh_session", () => {
|
|
207
|
+
const result = validateCommandParams("refresh_session", {
|
|
208
|
+
mcpServers: [],
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
expect(result.success).toBe(true);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("rejects refresh_session without mcpServers", () => {
|
|
215
|
+
const result = validateCommandParams("_posthog/refresh_session", {});
|
|
216
|
+
|
|
217
|
+
expect(result.success).toBe(false);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it("rejects refresh_session with invalid mcpServers entry", () => {
|
|
221
|
+
const result = validateCommandParams("_posthog/refresh_session", {
|
|
222
|
+
mcpServers: [{ type: "stdio", name: "bad", command: "/bin/x" }],
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
expect(result.success).toBe(false);
|
|
226
|
+
});
|
|
187
227
|
});
|
package/src/server/schemas.ts
CHANGED
|
@@ -60,6 +60,10 @@ export const setConfigOptionParamsSchema = z.object({
|
|
|
60
60
|
value: z.string().min(1, "value is required"),
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
export const refreshSessionParamsSchema = z.object({
|
|
64
|
+
mcpServers: mcpServersSchema,
|
|
65
|
+
});
|
|
66
|
+
|
|
63
67
|
export const commandParamsSchemas = {
|
|
64
68
|
user_message: userMessageParamsSchema,
|
|
65
69
|
"posthog/user_message": userMessageParamsSchema,
|
|
@@ -71,6 +75,9 @@ export const commandParamsSchemas = {
|
|
|
71
75
|
"posthog/permission_response": permissionResponseParamsSchema,
|
|
72
76
|
set_config_option: setConfigOptionParamsSchema,
|
|
73
77
|
"posthog/set_config_option": setConfigOptionParamsSchema,
|
|
78
|
+
refresh_session: refreshSessionParamsSchema,
|
|
79
|
+
"posthog/refresh_session": refreshSessionParamsSchema,
|
|
80
|
+
"_posthog/refresh_session": refreshSessionParamsSchema,
|
|
74
81
|
} as const;
|
|
75
82
|
|
|
76
83
|
export type CommandMethod = keyof typeof commandParamsSchemas;
|
|
@@ -82,7 +89,7 @@ export function validateCommandParams(
|
|
|
82
89
|
const schema =
|
|
83
90
|
commandParamsSchemas[method as CommandMethod] ??
|
|
84
91
|
commandParamsSchemas[
|
|
85
|
-
method.replace(
|
|
92
|
+
method.replace(/^_?posthog\//, "") as keyof typeof commandParamsSchemas
|
|
86
93
|
];
|
|
87
94
|
|
|
88
95
|
if (!schema) {
|