@posthog/agent 2.3.341 → 2.3.349
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 +30 -27
- package/dist/agent.js.map +1 -1
- package/dist/posthog-api.d.ts +5 -3
- package/dist/posthog-api.js +10 -21
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.d.ts +7 -0
- package/dist/server/agent-server.js +186 -39
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +186 -39
- package/dist/server/bin.cjs.map +1 -1
- package/dist/types.d.ts +3 -1
- package/package.json +4 -4
- package/src/adapters/claude/conversion/acp-to-sdk.test.ts +49 -0
- package/src/adapters/claude/conversion/acp-to-sdk.ts +23 -6
- package/src/posthog-api.test.ts +32 -0
- package/src/posthog-api.ts +13 -30
- package/src/server/agent-server.test.ts +96 -0
- package/src/server/agent-server.ts +207 -11
- package/src/server/schemas.test.ts +10 -0
- package/src/server/schemas.ts +25 -6
- package/src/test/mocks/msw-handlers.ts +4 -1
- package/src/types.ts +4 -1
package/src/server/schemas.ts
CHANGED
|
@@ -41,12 +41,31 @@ export const jsonRpcRequestSchema = z.object({
|
|
|
41
41
|
|
|
42
42
|
export type JsonRpcRequest = z.infer<typeof jsonRpcRequestSchema>;
|
|
43
43
|
|
|
44
|
-
export const userMessageParamsSchema = z
|
|
45
|
-
|
|
46
|
-
z
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
export const userMessageParamsSchema = z
|
|
45
|
+
.object({
|
|
46
|
+
content: z
|
|
47
|
+
.union([
|
|
48
|
+
z.string().min(1, "Content is required"),
|
|
49
|
+
z
|
|
50
|
+
.array(z.record(z.string(), z.unknown()))
|
|
51
|
+
.min(1, "Content is required"),
|
|
52
|
+
])
|
|
53
|
+
.optional(),
|
|
54
|
+
artifacts: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
55
|
+
})
|
|
56
|
+
.refine(
|
|
57
|
+
(params) => {
|
|
58
|
+
const hasContent =
|
|
59
|
+
typeof params.content === "string"
|
|
60
|
+
? params.content.trim().length > 0
|
|
61
|
+
: Array.isArray(params.content) && params.content.length > 0;
|
|
62
|
+
const hasArtifacts =
|
|
63
|
+
Array.isArray(params.artifacts) && params.artifacts.length > 0;
|
|
64
|
+
|
|
65
|
+
return hasContent || hasArtifacts;
|
|
66
|
+
},
|
|
67
|
+
{ error: "Either content or artifacts are required" },
|
|
68
|
+
);
|
|
50
69
|
|
|
51
70
|
export const permissionResponseParamsSchema = z.object({
|
|
52
71
|
requestId: z.string().min(1, "requestId is required"),
|
|
@@ -5,6 +5,7 @@ type AnyHttpResponse = Response | ReturnType<typeof HttpResponse.json>;
|
|
|
5
5
|
export interface PostHogHandlersOptions {
|
|
6
6
|
baseUrl?: string;
|
|
7
7
|
onAppendLog?: (entries: unknown[]) => void;
|
|
8
|
+
onUpdateTaskRun?: (body: unknown) => void;
|
|
8
9
|
getTask?: () => unknown;
|
|
9
10
|
getTaskRun?: () => unknown;
|
|
10
11
|
appendLogResponse?: () => AnyHttpResponse;
|
|
@@ -14,6 +15,7 @@ export function createPostHogHandlers(options: PostHogHandlersOptions = {}) {
|
|
|
14
15
|
const {
|
|
15
16
|
baseUrl = "http://localhost:8000",
|
|
16
17
|
onAppendLog,
|
|
18
|
+
onUpdateTaskRun,
|
|
17
19
|
getTask,
|
|
18
20
|
getTaskRun,
|
|
19
21
|
appendLogResponse,
|
|
@@ -85,7 +87,8 @@ export function createPostHogHandlers(options: PostHogHandlersOptions = {}) {
|
|
|
85
87
|
// PATCH /runs/:runId - Update task run
|
|
86
88
|
http.patch(
|
|
87
89
|
`${baseUrl}/api/projects/:projectId/tasks/:taskId/runs/:runId/`,
|
|
88
|
-
() => {
|
|
90
|
+
async ({ request }) => {
|
|
91
|
+
onUpdateTaskRun?.(await request.json());
|
|
89
92
|
return HttpResponse.json({});
|
|
90
93
|
},
|
|
91
94
|
),
|
package/src/types.ts
CHANGED
|
@@ -56,11 +56,14 @@ export type ArtifactType =
|
|
|
56
56
|
| "reference"
|
|
57
57
|
| "output"
|
|
58
58
|
| "artifact"
|
|
59
|
-
| "tree_snapshot"
|
|
59
|
+
| "tree_snapshot"
|
|
60
|
+
| "user_attachment";
|
|
60
61
|
|
|
61
62
|
export interface TaskRunArtifact {
|
|
63
|
+
id?: string;
|
|
62
64
|
name: string;
|
|
63
65
|
type: ArtifactType;
|
|
66
|
+
source?: string;
|
|
64
67
|
size?: number;
|
|
65
68
|
content_type?: string;
|
|
66
69
|
storage_path?: string;
|